@zinejs/core 0.8.0 → 0.8.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
@@ -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.#Mt(), 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.#Nt(), 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.#$e(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.#et(t.renderer ?? "auto");
500
500
  }
501
501
  get ready() {
502
502
  return this.#ye;
@@ -529,7 +529,7 @@ var J = class {
529
529
  return this.#h;
530
530
  }
531
531
  setSpreadMode(e) {
532
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#gt(), this.#_t());
532
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#_t(), this.#vt());
533
533
  }
534
534
  toggleSpreadMode() {
535
535
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
@@ -545,16 +545,16 @@ var J = class {
545
545
  if (this.#v = e, e) {
546
546
  let e = this.#z?.measure().containerWidth;
547
547
  if (e === void 0) return;
548
- this.#_ = !1, this.#ht(e);
548
+ this.#_ = !1, this.#gt(e);
549
549
  } else {
550
550
  if (!this.#_) return;
551
- this.#_ = !1, this.#gt();
551
+ this.#_ = !1, this.#_t();
552
552
  }
553
- this.#_t();
553
+ this.#vt();
554
554
  }
555
555
  }
556
556
  getPageImage(e) {
557
- return this.#kt(e);
557
+ return this.#At(e);
558
558
  }
559
559
  canFlipNext() {
560
560
  return this.#E + 1 < this.#T.length;
@@ -580,22 +580,22 @@ var J = class {
580
580
  async print() {
581
581
  let e = await this.getSourceFile(), t = this.#e.ownerDocument;
582
582
  if (!e || !t) return !1;
583
- let n = t.createElement("iframe");
584
- return n.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;", n.setAttribute("aria-hidden", "true"), n.src = e.url, new Promise((r) => {
585
- let i = !1, a = (t) => {
586
- i || (i = !0, setTimeout(() => {
587
- n.remove(), e.revoke && URL.revokeObjectURL(e.url);
588
- }, 6e4), r(t));
583
+ let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("iframe");
584
+ return i.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;", i.setAttribute("aria-hidden", "true"), i.src = n, new Promise((e) => {
585
+ let a = !1, o = (t) => {
586
+ a || (a = !0, setTimeout(() => {
587
+ i.remove(), r && URL.revokeObjectURL(n);
588
+ }, 6e4), e(t));
589
589
  };
590
- n.addEventListener("load", () => {
590
+ i.addEventListener("load", () => {
591
591
  try {
592
- let e = n.contentWindow;
593
- if (!e) return a(!1);
594
- e.focus(), e.print(), a(!0);
592
+ let e = i.contentWindow;
593
+ if (!e) return o(!1);
594
+ e.focus(), e.print(), o(!0);
595
595
  } catch {
596
- a(!1);
596
+ o(!1);
597
597
  }
598
- }), n.addEventListener("error", () => a(!1)), t.body.appendChild(n);
598
+ }), i.addEventListener("error", () => o(!1)), t.body.appendChild(i);
599
599
  });
600
600
  }
601
601
  canOutline() {
@@ -617,15 +617,28 @@ var J = class {
617
617
  if (!e) return !1;
618
618
  let t = this.#e.ownerDocument;
619
619
  if (!t) return !1;
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");
620
+ let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("a");
626
621
  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
622
  }
628
- #be(e, t) {
623
+ async #be(e, t) {
624
+ if (e.revoke || !this.#xe(e.url, t)) return {
625
+ url: e.url,
626
+ revoke: e.revoke ?? !1
627
+ };
628
+ try {
629
+ let t = await (await fetch(e.url)).blob();
630
+ return {
631
+ url: URL.createObjectURL(t),
632
+ revoke: !0
633
+ };
634
+ } catch {
635
+ return {
636
+ url: e.url,
637
+ revoke: !1
638
+ };
639
+ }
640
+ }
641
+ #xe(e, t) {
629
642
  let n = t.defaultView?.location?.href;
630
643
  if (!n) return !1;
631
644
  try {
@@ -658,29 +671,29 @@ var J = class {
658
671
  return a;
659
672
  }
660
673
  flipNext() {
661
- this.#xe(1);
674
+ this.#Se(1);
662
675
  }
663
676
  flipPrev() {
664
- this.#xe(-1);
677
+ this.#Se(-1);
665
678
  }
666
- #xe(e) {
667
- this.#Se(() => this.#De(this.#E + e));
679
+ #Se(e) {
680
+ this.#Ce(() => this.#Oe(this.#E + e));
668
681
  }
669
682
  flipTo(e) {
670
683
  let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
671
- this.#Se(() => this.#De(this.#jt(t)));
684
+ this.#Ce(() => this.#Oe(this.#Mt(t)));
672
685
  }
673
- #Se(e) {
674
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#Ce(), e()) : this.#q = e;
686
+ #Ce(e) {
687
+ this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#we(), e()) : this.#q = e;
675
688
  }
676
- #Ce() {
689
+ #we() {
677
690
  let e = this.#J;
678
691
  e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
679
692
  }
680
- #we() {
693
+ #Te() {
681
694
  let e = this.#q;
682
695
  if (!e) {
683
- this.#Tt();
696
+ this.#Et();
684
697
  return;
685
698
  }
686
699
  this.#q = null, e();
@@ -697,15 +710,15 @@ var J = class {
697
710
  x: r.containerWidth / 2,
698
711
  y: r.containerHeight / 2
699
712
  }, 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);
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 });
713
+ [s, c] = this.#De(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.#Ee(), this.#St(), this.#n.emit("zoomChanged", { scale: n });
701
714
  }
702
715
  resetZoom() {
703
716
  this.setZoom(1);
704
717
  }
705
- #Te() {
718
+ #Ee() {
706
719
  this.#e.style.touchAction = this.#I > 1 ? "none" : "pan-y";
707
720
  }
708
- #Ee(e, t, n, r, i) {
721
+ #De(e, t, n, r, i) {
709
722
  let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
710
723
  x: 0,
711
724
  y: 0,
@@ -718,29 +731,29 @@ var J = class {
718
731
  return this.#n.on(e, t);
719
732
  }
720
733
  destroy() {
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();
734
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ge(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#it(), 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();
722
735
  }
723
- #De(e) {
736
+ #Oe(e) {
724
737
  if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
725
- let t = e > this.#E ? "forward" : "backward", n = this.#Me(e);
738
+ let t = e > this.#E ? "forward" : "backward", n = this.#Ne(e);
726
739
  this.#n.emit("flipStart", {
727
740
  from: this.#D,
728
741
  to: n
729
- }), this.#Oe(e, t, n, ++this.#Y);
742
+ }), this.#ke(e, t, n, ++this.#Y);
730
743
  }
731
- async #Oe(e, t, n, r) {
732
- let i = this.#T[e], a = i ? await this.#Ot(i) : {
744
+ async #ke(e, t, n, r) {
745
+ let i = this.#T[e], a = i ? await this.#kt(i) : {
733
746
  left: null,
734
747
  right: null
735
748
  };
736
749
  r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
737
750
  fill: this.#h,
738
- curl: this.#pt(),
751
+ curl: this.#mt(),
739
752
  anchor: { y: this.#l }
740
- }), this.#ke(0, 1, t, () => this.#je(e, n, a), () => this.#Ae(n)));
753
+ }), this.#Ae(0, 1, t, () => this.#Me(e, n, a), () => this.#je(n)));
741
754
  }
742
- #ke(e, t, n, r, i) {
743
- let a = this.#ft() * Math.abs(t - e);
755
+ #Ae(e, t, n, r, i) {
756
+ let a = this.#pt() * Math.abs(t - e);
744
757
  if (a <= 0) {
745
758
  this.#z?.setFlipProgress(t, n), r();
746
759
  return;
@@ -758,22 +771,22 @@ var J = class {
758
771
  };
759
772
  this.#H = requestAnimationFrame(l);
760
773
  }
761
- #Ae(e) {
762
- this.#D !== e && (this.#D = e, this.#dt(), this.#n.emit("pageChanged", { page: e }));
774
+ #je(e) {
775
+ this.#D !== e && (this.#D = e, this.#ft(), this.#n.emit("pageChanged", { page: e }));
763
776
  }
764
- #je(e, t, n) {
777
+ #Me(e, t, n) {
765
778
  let r = this.#T[e];
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();
779
+ this.#E = e, this.#O = n, r && this.#yt(r, n), this.#jt(), this.#i.send("settle"), this.#oe = performance.now(), this.#je(t), this.#n.emit("flipEnd", { page: t }), this.#Te();
767
780
  }
768
- #Me(e) {
781
+ #Ne(e) {
769
782
  let t = this.#T[e];
770
783
  if (!t) return this.#D;
771
784
  let n = [t.left, t.right].filter((e) => e !== null);
772
785
  return n.length > 0 ? Math.min(...n) : this.#D;
773
786
  }
774
- #Ne(e, t) {
787
+ #Pe(e, t) {
775
788
  if (this.#Z || !this.#z) return;
776
- if (this.#We(), this.#I > 1) {
789
+ if (this.#Ge(), this.#I > 1) {
777
790
  if (this.#i.send("panStart") === null) return;
778
791
  this.#X = {
779
792
  baseTx: this.#L,
@@ -781,7 +794,7 @@ var J = class {
781
794
  };
782
795
  return;
783
796
  }
784
- let n = this.#Be(), r = this.#Ve(e, t);
797
+ let n = this.#Ve(), r = this.#He(e, t);
785
798
  this.#G = r;
786
799
  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;
787
800
  if (this.#i.state !== "idle") {
@@ -789,7 +802,7 @@ var J = class {
789
802
  this.#W = null;
790
803
  return;
791
804
  }
792
- this.#Ce();
805
+ this.#we();
793
806
  }
794
807
  if (!s) return;
795
808
  this.#l = Y(r.y / n.height, 0, 1);
@@ -797,11 +810,11 @@ var J = class {
797
810
  u < 0 || u >= this.#T.length || (this.#W = {
798
811
  direction: l ? "forward" : "backward",
799
812
  targetIndex: u,
800
- toPage: this.#Me(u),
813
+ toPage: this.#Ne(u),
801
814
  width: n.width
802
815
  });
803
816
  }
804
- #Pe() {
817
+ #Fe() {
805
818
  let e = this.#W;
806
819
  e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
807
820
  direction: e.direction,
@@ -816,32 +829,32 @@ var J = class {
816
829
  }, this.#n.emit("flipStart", {
817
830
  from: this.#D,
818
831
  to: e.toPage
819
- }), this.#Fe(e.targetIndex, e.direction)));
832
+ }), this.#Ie(e.targetIndex, e.direction)));
820
833
  }
821
- async #Fe(e, t) {
822
- let n = this.#T[e], r = n ? await this.#Ot(n) : {
834
+ async #Ie(e, t) {
835
+ let n = this.#T[e], r = n ? await this.#kt(n) : {
823
836
  left: null,
824
837
  right: null
825
838
  };
826
839
  this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
827
840
  fill: this.#h,
828
- curl: this.#pt(),
841
+ curl: this.#mt(),
829
842
  anchor: { y: this.#l }
830
843
  }), this.#z?.setFlipProgress(this.#U.t, t));
831
844
  }
832
- #Ie(e, t) {
845
+ #Le(e, t) {
833
846
  if (this.#Z) return;
834
847
  if (this.#X) {
835
848
  if (!this.#z) return;
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();
849
+ let n = this.#z.measure(), [r, i] = this.#De(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
850
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#St();
838
851
  return;
839
852
  }
840
- this.#W && Math.hypot(e, t) > F && this.#Pe();
853
+ this.#W && Math.hypot(e, t) > F && this.#Fe();
841
854
  let n = this.#U;
842
855
  n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
843
856
  }
844
- #Le(e) {
857
+ #Re(e) {
845
858
  if (this.#Z) return;
846
859
  if (this.#X) {
847
860
  this.#X = null, this.#i.send("panEnd");
@@ -849,35 +862,35 @@ var J = class {
849
862
  }
850
863
  let t = this.#U;
851
864
  if (!t) {
852
- this.#W = null, this.#Re(e) || this.#ze(e);
865
+ this.#W = null, this.#ze(e) || this.#Be(e);
853
866
  return;
854
867
  }
855
868
  this.#U = null, this.#i.send("release");
856
869
  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;
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());
870
+ i || t.t >= .5 && !a ? this.#Ae(t.t, 1, t.direction, () => this.#Me(t.targetIndex, t.toPage, t.toContent), () => this.#je(t.toPage)) : this.#Ae(t.t, 0, t.direction, () => this.#Ke());
858
871
  }
859
- #Re(e) {
872
+ #ze(e) {
860
873
  if (this.#I > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
861
874
  let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
862
- if (!this.#Ue(n)) return !1;
875
+ if (!this.#We(n)) return !1;
863
876
  let r = t ? 1 : -1;
864
- return this.#Se(() => this.#De(this.#E + r)), !0;
877
+ return this.#Ce(() => this.#Oe(this.#E + r)), !0;
865
878
  }
866
- #ze(e) {
879
+ #Be(e) {
867
880
  if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
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);
881
+ let t = this.#Ue(this.#G);
882
+ if (!t || !this.#We(t)) return;
883
+ this.#l = Y(this.#G.y / this.#Ve().height, 0, 1);
884
+ let n = t === "forward" ? 1 : -1, r = () => this.#Oe(this.#E + n);
885
+ if (this.#Ge(), this.#p <= 0) {
886
+ this.#Ce(r);
874
887
  return;
875
888
  }
876
889
  this.#K = setTimeout(() => {
877
- this.#K = null, this.#Se(r);
890
+ this.#K = null, this.#Ce(r);
878
891
  }, this.#p);
879
892
  }
880
- #Be() {
893
+ #Ve() {
881
894
  let e = this.#z.measure();
882
895
  return e.content ?? e.book ?? {
883
896
  x: 0,
@@ -886,40 +899,40 @@ var J = class {
886
899
  height: e.containerHeight
887
900
  };
888
901
  }
889
- #Ve(e, t) {
890
- let n = this.#e.getBoundingClientRect(), r = this.#Be();
902
+ #He(e, t) {
903
+ let n = this.#e.getBoundingClientRect(), r = this.#Ve();
891
904
  return {
892
905
  x: e - n.left - r.x,
893
906
  y: t - n.top - r.y
894
907
  };
895
908
  }
896
- #He(e) {
909
+ #Ue(e) {
897
910
  if (!this.#z) return null;
898
- let t = this.#Be().width, n;
911
+ let t = this.#Ve().width, n;
899
912
  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;
900
913
  let r = this.#a === "rtl" ? "left" : "right";
901
914
  return n === r ? "forward" : "backward";
902
915
  }
903
- #Ue(e) {
916
+ #We(e) {
904
917
  let t = this.#E + (e === "forward" ? 1 : -1);
905
918
  return t >= 0 && t < this.#T.length;
906
919
  }
907
- #We() {
920
+ #Ge() {
908
921
  this.#K !== null && (clearTimeout(this.#K), this.#K = null);
909
922
  }
910
- #Ge() {
923
+ #Ke() {
911
924
  let e = this.#T[this.#E];
912
- e && this.#vt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#we();
925
+ e && this.#yt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#Te();
913
926
  }
914
- #Ke() {
915
- if (this.#W = null, this.#We(), this.#U) {
927
+ #qe() {
928
+ if (this.#W = null, this.#Ge(), this.#U) {
916
929
  this.#U = null, this.#i.send("release"), this.#i.send("settle");
917
930
  let e = this.#T[this.#E];
918
- e && this.#vt(e, this.#O);
931
+ e && this.#yt(e, this.#O);
919
932
  } else this.#X && (this.#X = null, this.#i.send("panEnd"));
920
933
  this.#Z = !0, this.#Q = this.#I;
921
934
  }
922
- #qe(e, t, n) {
935
+ #Je(e, t, n) {
923
936
  if (!this.#Z) return;
924
937
  let r = this.#e.getBoundingClientRect();
925
938
  this.setZoom(this.#Q * n, {
@@ -927,15 +940,15 @@ var J = class {
927
940
  y: t - r.top
928
941
  });
929
942
  }
930
- #Je() {
943
+ #Ye() {
931
944
  this.#Z = !1;
932
945
  }
933
- #Ye() {
946
+ #Xe() {
934
947
  if (!this.#S) return;
935
948
  let e = (e) => e.preventDefault();
936
949
  this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
937
950
  }
938
- #Xe() {
951
+ #Ze() {
939
952
  let e = (e) => {
940
953
  if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
941
954
  e.preventDefault();
@@ -947,7 +960,7 @@ var J = class {
947
960
  };
948
961
  this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
949
962
  }
950
- #Ze() {
963
+ #Qe() {
951
964
  let e = (e) => {
952
965
  let t = this.#M;
953
966
  if (!this.#A || t === null || !this.#z) return;
@@ -960,72 +973,72 @@ var J = class {
960
973
  };
961
974
  return;
962
975
  }
963
- this.#ae = null, this.#Qe(e.clientX, e.clientY, t);
976
+ this.#ae = null, this.#$e(e.clientX, e.clientY, t);
964
977
  };
965
978
  this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
966
979
  }
967
- #Qe(e, t, n) {
980
+ #$e(e, t, n) {
968
981
  if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
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;
982
+ let n = this.#He(e, t), r = this.#Ue(n);
983
+ if (r !== null && this.#We(r) || this.#i.state === "animating" || performance.now() - this.#oe <= R) return;
971
984
  }
972
- this.#We();
985
+ this.#Ge();
973
986
  let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
974
987
  this.setZoom(r, {
975
988
  x: e - i.left,
976
989
  y: t - i.top
977
990
  });
978
991
  }
979
- async #$e(e) {
992
+ async #et(e) {
980
993
  let t = k(e);
981
- if (this.#t.onProgress?.((e) => this.#et(e)), typeof this.#t.open == "function") {
982
- this.#tt();
994
+ if (this.#t.onProgress?.((e) => this.#tt(e)), typeof this.#t.open == "function") {
995
+ this.#nt();
983
996
  try {
984
- await this.#t.open(), this.#Mt();
997
+ await this.#t.open(), this.#Nt();
985
998
  } catch (e) {
986
- throw this.#rt(), e;
999
+ throw this.#it(), e;
987
1000
  }
988
- this.#nt("preparing");
1001
+ this.#rt("preparing");
989
1002
  }
990
1003
  this.#t.prefetch([this.#D]);
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);
1004
+ let n = await t, r = await this.#at(n);
1005
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#xt(e)), this.#gt(r.measure().containerWidth);
993
1006
  let i = new m({
994
- onStart: (e) => this.#Ne(e.x, e.y),
995
- onMove: (e) => this.#Ie(e.dx, e.dy),
996
- onEnd: (e) => this.#Le(e)
1007
+ onStart: (e) => this.#Pe(e.x, e.y),
1008
+ onMove: (e) => this.#Le(e.dx, e.dy),
1009
+ onEnd: (e) => this.#Re(e)
997
1010
  }), a = new _({
998
- onPinchStart: () => this.#Ke(),
999
- onPinchMove: (e) => this.#qe(e.centerX, e.centerY, e.scale),
1000
- onPinchEnd: () => this.#Je()
1011
+ onPinchStart: () => this.#qe(),
1012
+ onPinchMove: (e) => this.#Je(e.centerX, e.centerY, e.scale),
1013
+ onPinchEnd: () => this.#Ye()
1001
1014
  });
1002
1015
  this.#te = h(this.#e, {
1003
1016
  pointer: i,
1004
1017
  pinch: a
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");
1018
+ }), this.#Ee(), this.#Ze(), this.#Qe(), this.#Xe(), this.#st(), this.#se = this.#ut(), await this.#vt(), this.#it(), this.#Dt(), this.#jt(), this.#ft(), this.#lt(), await this.#ct(), this.#n.emit("ready");
1006
1019
  }
1007
- #et(e) {
1020
+ #tt(e) {
1008
1021
  this.#me = e, this.#n.emit("progress", e), this.#pe?.update(e);
1009
1022
  }
1010
- async #tt() {
1023
+ async #nt() {
1011
1024
  if (this.#fe === !1 || this.#V) return;
1012
1025
  let e = this.#e;
1013
1026
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1014
- let { mountLoading: t } = await import("./loading-C0qbANt2.js");
1027
+ let { mountLoading: t } = await import("./loading-BBK6YbSW.js");
1015
1028
  if (this.#he === "done" || this.#V) return;
1016
1029
  this.#pe = t(e), this.#me && this.#pe.update(this.#me), this.#he === "preparing" && this.#pe.preparing();
1017
1030
  } catch {}
1018
1031
  }
1019
- #nt(e) {
1032
+ #rt(e) {
1020
1033
  this.#he !== "done" && (this.#he = e, this.#pe?.preparing());
1021
1034
  }
1022
- #rt() {
1035
+ #it() {
1023
1036
  this.#he = "done", this.#pe?.destroy(), this.#pe = null;
1024
1037
  }
1025
- async #it(e) {
1038
+ async #at(e) {
1026
1039
  try {
1027
1040
  return await e.mount(this.#e), e.onFatal?.(() => {
1028
- this.#at();
1041
+ this.#ot();
1029
1042
  }), e;
1030
1043
  } catch {
1031
1044
  e.destroy();
@@ -1036,7 +1049,7 @@ var J = class {
1036
1049
  }), t;
1037
1050
  }
1038
1051
  }
1039
- async #at() {
1052
+ async #ot() {
1040
1053
  if (this.#B || this.#V) return;
1041
1054
  this.#B = !0, this.#z?.destroy(), this.#z = null;
1042
1055
  let e = await k("css");
@@ -1044,29 +1057,29 @@ var J = class {
1044
1057
  e.destroy();
1045
1058
  return;
1046
1059
  }
1047
- await e.mount(this.#e), this.#z = e, this.#ht(e.measure().containerWidth), await this.#_t(), this.#n.emit("rendererFallback", {
1060
+ await e.mount(this.#e), this.#z = e, this.#gt(e.measure().containerWidth), await this.#vt(), this.#n.emit("rendererFallback", {
1048
1061
  from: "webgl2",
1049
1062
  to: "css"
1050
1063
  });
1051
1064
  }
1052
- #ot() {
1065
+ #st() {
1053
1066
  if (typeof matchMedia != "function") return;
1054
1067
  let e = matchMedia("(prefers-reduced-motion: reduce)");
1055
1068
  this.#$ = e.matches, e.addEventListener?.("change", (e) => {
1056
1069
  this.#$ = e.matches;
1057
1070
  });
1058
1071
  }
1059
- async #st() {
1072
+ async #ct() {
1060
1073
  if (this.#ue === !1 || this.#V) return;
1061
1074
  let e = this.#e;
1062
1075
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1063
- let { mountControls: t } = await import("./controls-Djjk8Yac.js");
1076
+ let { mountControls: t } = await import("./controls-DgEXR2zi.js");
1064
1077
  if (this.#V) return;
1065
1078
  let n = this.#ue === !0 ? {} : this.#ue;
1066
1079
  this.#de = t(this, e, n);
1067
1080
  } catch {}
1068
1081
  }
1069
- #ct() {
1082
+ #lt() {
1070
1083
  if (!this.#x || globalThis.location === void 0) return;
1071
1084
  let e = globalThis;
1072
1085
  this.#C = w(e, (e) => {
@@ -1081,18 +1094,18 @@ var J = class {
1081
1094
  let n = new URL(t);
1082
1095
  return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1083
1096
  }
1084
- #lt() {
1097
+ #ut() {
1085
1098
  let e = this.#e, t = e.ownerDocument;
1086
1099
  if (!t || typeof e.setAttribute != "function") return null;
1087
1100
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1088
- let n = (e) => this.#ut(e);
1101
+ let n = (e) => this.#dt(e);
1089
1102
  e.addEventListener("keydown", n);
1090
1103
  let r = t.createElement("div");
1091
1104
  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, () => {
1092
1105
  e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1093
1106
  };
1094
1107
  }
1095
- #ut(e) {
1108
+ #dt(e) {
1096
1109
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1097
1110
  switch (e.key) {
1098
1111
  case "ArrowRight":
@@ -1108,70 +1121,70 @@ var J = class {
1108
1121
  default: break;
1109
1122
  }
1110
1123
  }
1111
- #dt() {
1124
+ #ft() {
1112
1125
  this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1113
1126
  }
1114
- #ft() {
1127
+ #pt() {
1115
1128
  return this.#$ ? W : this.#k * (this.#h ? z : 1);
1116
1129
  }
1117
- #pt() {
1130
+ #mt() {
1118
1131
  return this.#$ ? "simple" : this.#c;
1119
1132
  }
1120
1133
  update() {
1121
- !this.#z || this.#i.state !== "idle" || (this.#ht(this.#z.measure().containerWidth), this.#_t());
1134
+ !this.#z || this.#i.state !== "idle" || (this.#gt(this.#z.measure().containerWidth), this.#vt());
1122
1135
  }
1123
- #mt() {
1136
+ #ht() {
1124
1137
  return this.#_ || this.#o === "single" ? "single" : this.#o;
1125
1138
  }
1126
- #ht(e) {
1139
+ #gt(e) {
1127
1140
  let t = this.#v && o(e, this.#m);
1128
- t !== this.#_ && (this.#_ = t, this.#gt());
1141
+ t !== this.#_ && (this.#_ = t, this.#_t());
1129
1142
  }
1130
- #gt() {
1131
- let e = this.#mt(), t = e !== this.#g;
1143
+ #_t() {
1144
+ let e = this.#ht(), t = e !== this.#g;
1132
1145
  this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1133
1146
  direction: this.#a,
1134
1147
  mode: e
1135
- }), this.#E = this.#jt(this.#D), t && this.#n.emit("spreadChanged", {
1148
+ }), this.#E = this.#Mt(this.#D), t && this.#n.emit("spreadChanged", {
1136
1149
  mode: e,
1137
1150
  singlePage: this.#h
1138
1151
  });
1139
1152
  }
1140
- async #_t() {
1153
+ async #vt() {
1141
1154
  let e = this.#T[this.#E];
1142
- !e || !this.#z || (this.#O = await this.#Ot(e), this.#vt(e, this.#O));
1155
+ !e || !this.#z || (this.#O = await this.#kt(e), this.#yt(e, this.#O));
1143
1156
  }
1144
- #vt(e, t) {
1145
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#yt(), this.#ge = 1, this.#xt();
1157
+ #yt(e, t) {
1158
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#bt(), this.#ge = 1, this.#St();
1146
1159
  }
1147
- #yt() {
1160
+ #bt() {
1148
1161
  let e = this.#z?.measure().book;
1149
1162
  if (!e || e.width <= 0 || e.height <= 0) return;
1150
1163
  let t = (e.width / e.height).toFixed(4);
1151
1164
  t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1152
1165
  }
1153
- #bt(e) {
1166
+ #xt(e) {
1154
1167
  if (this.#i.state !== "idle") {
1155
1168
  this.#le.add(e);
1156
1169
  return;
1157
1170
  }
1158
1171
  let t = this.#T[this.#E];
1159
- t && (t.left === e || t.right === e) && this.#_t();
1172
+ t && (t.left === e || t.right === e) && this.#vt();
1160
1173
  }
1161
- #xt() {
1174
+ #St() {
1162
1175
  this.#ve !== null && clearTimeout(this.#ve);
1163
- let e = this.#Ct();
1176
+ let e = this.#wt();
1164
1177
  if (e !== this.#ge) {
1165
1178
  if (e === 1) {
1166
- this.#_e++, this.#ge = 1, this.#_t();
1179
+ this.#_e++, this.#ge = 1, this.#vt();
1167
1180
  return;
1168
1181
  }
1169
1182
  this.#ve = setTimeout(() => {
1170
- this.#ve = null, this.#wt();
1183
+ this.#ve = null, this.#Tt();
1171
1184
  }, V);
1172
1185
  }
1173
1186
  }
1174
- #St() {
1187
+ #Ct() {
1175
1188
  let e = this.#z?.measure(), t = e?.content ?? e?.book;
1176
1189
  if (!t || t.width <= 0) return 1;
1177
1190
  let n = this.#O, r = +!!n.left + +!!n.right;
@@ -1184,14 +1197,14 @@ var J = class {
1184
1197
  }
1185
1198
  return o === 0 ? 1 : o;
1186
1199
  }
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);
1200
+ #wt() {
1201
+ let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#Ct() * Math.max(t, e);
1189
1202
  return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1190
1203
  }
1191
- async #wt() {
1204
+ async #Tt() {
1192
1205
  let e = this.#T[this.#E];
1193
1206
  if (!this.#z || !e) return;
1194
- let t = this.#Ct();
1207
+ let t = this.#wt();
1195
1208
  if (t === 1 || t === this.#ge || this.#i.state !== "idle") return;
1196
1209
  let n = ++this.#_e, r = {
1197
1210
  x: 0,
@@ -1212,34 +1225,34 @@ var J = class {
1212
1225
  }), null;
1213
1226
  }
1214
1227
  }));
1215
- if (n !== this.#_e || this.#Ct() !== t || this.#i.state !== "idle") return;
1228
+ if (n !== this.#_e || this.#wt() !== t || this.#i.state !== "idle") return;
1216
1229
  let a = i[0] ?? null, o = i[1] ?? null;
1217
1230
  a === this.#O.left && o === this.#O.right || (this.#ge = t, this.#O = {
1218
1231
  left: a,
1219
1232
  right: o
1220
1233
  }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1221
1234
  }
1222
- #Tt() {
1235
+ #Et() {
1223
1236
  if (this.#le.size === 0) return;
1224
1237
  let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1225
- this.#le.clear(), t && this.#_t();
1226
- }
1227
- #Et() {
1228
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Dt()), this.#P.observe(this.#e));
1238
+ this.#le.clear(), t && this.#vt();
1229
1239
  }
1230
1240
  #Dt() {
1241
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Ot()), this.#P.observe(this.#e));
1242
+ }
1243
+ #Ot() {
1231
1244
  this.#F || (this.#F = !0, requestAnimationFrame(() => {
1232
1245
  this.#F = !1, this.update();
1233
1246
  }));
1234
1247
  }
1235
- async #Ot(e) {
1236
- let [t, n] = await Promise.all([this.#kt(e.left), this.#kt(e.right)]);
1248
+ async #kt(e) {
1249
+ let [t, n] = await Promise.all([this.#At(e.left), this.#At(e.right)]);
1237
1250
  return {
1238
1251
  left: t,
1239
1252
  right: n
1240
1253
  };
1241
1254
  }
1242
- async #kt(e) {
1255
+ async #At(e) {
1243
1256
  if (e === null) return null;
1244
1257
  try {
1245
1258
  return await this.#t.get(e);
@@ -1250,7 +1263,7 @@ var J = class {
1250
1263
  }), null;
1251
1264
  }
1252
1265
  }
1253
- #At() {
1266
+ #jt() {
1254
1267
  let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1255
1268
  for (let n of e) {
1256
1269
  let e = this.#T[n];
@@ -1258,22 +1271,22 @@ var J = class {
1258
1271
  }
1259
1272
  this.#t.prefetch(t);
1260
1273
  }
1261
- #jt(e) {
1274
+ #Mt(e) {
1262
1275
  let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1263
1276
  return t === -1 ? 0 : t;
1264
1277
  }
1265
- #Mt() {
1278
+ #Nt() {
1266
1279
  let e = this.#t.pageCount;
1267
1280
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1268
1281
  let t = this.#b;
1269
1282
  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}).`);
1270
- let n = this.#mt();
1283
+ let n = this.#ht();
1271
1284
  this.#h = n === "single", this.#T = a(e, {
1272
1285
  direction: this.#a,
1273
1286
  mode: n
1274
1287
  });
1275
1288
  let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1276
- this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#jt(this.#D);
1289
+ this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#Mt(this.#D);
1277
1290
  }
1278
1291
  };
1279
1292
  function Y(e, t, n) {