@zinejs/core 0.8.2 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +27 -49
  3. package/dist/{bundled-Cp43MIt0.js → bundled-ESapkNsS.js} +34 -34
  4. package/dist/bundled-ESapkNsS.js.map +1 -0
  5. package/dist/controls/contextMenu.d.ts +16 -0
  6. package/dist/controls/controls.d.ts +10 -3
  7. package/dist/controls/icons.d.ts +6 -2
  8. package/dist/controls/menu.d.ts +68 -0
  9. package/dist/controls/search.d.ts +15 -2
  10. package/dist/controls/styles.d.ts +1 -1
  11. package/dist/controls/toolbar.d.ts +1 -1
  12. package/dist/controls/types.d.ts +6 -0
  13. package/dist/{controls-DgEXR2zi.js → controls-DzVdwPJB.js} +349 -196
  14. package/dist/controls-DzVdwPJB.js.map +1 -0
  15. package/dist/curls.js +1 -1
  16. package/dist/flipSound-BFXSkWBo.js +78 -0
  17. package/dist/flipSound-BFXSkWBo.js.map +1 -0
  18. package/dist/geometry/curls/cone.d.ts +4 -3
  19. package/dist/index.js +671 -440
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.umd.js +26 -7
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/loading/loading.d.ts +1 -1
  24. package/dist/loading-DF88K9yJ.js +45 -0
  25. package/dist/loading-DF88K9yJ.js.map +1 -0
  26. package/dist/renderer/gl/texture.d.ts +13 -2
  27. package/dist/renderer/types.d.ts +6 -0
  28. package/dist/renderer/webglRenderer.d.ts +1 -0
  29. package/dist/{share-WXdscwp3.js → share-Cq3RsjPr.js} +2 -2
  30. package/dist/{share-WXdscwp3.js.map → share-Cq3RsjPr.js.map} +1 -1
  31. package/dist/sound/clip.d.ts +9 -0
  32. package/dist/sound/flipSound.d.ts +30 -0
  33. package/dist/source/types.d.ts +5 -0
  34. package/dist/styles-C1Qp5pby.js +42 -0
  35. package/dist/styles-C1Qp5pby.js.map +1 -0
  36. package/dist/{webglRenderer-nGRruZk2.js → webglRenderer-CmQ_mUrX.js} +113 -101
  37. package/dist/webglRenderer-CmQ_mUrX.js.map +1 -0
  38. package/dist/zine.d.ts +75 -1
  39. package/options.schema.json +66 -0
  40. package/package.json +13 -11
  41. package/dist/bundled-Cp43MIt0.js.map +0 -1
  42. package/dist/controls-DgEXR2zi.js.map +0 -1
  43. package/dist/loading-BBK6YbSW.js +0 -45
  44. package/dist/loading-BBK6YbSW.js.map +0 -1
  45. package/dist/styles-B8fFoYm_.js +0 -40
  46. package/dist/styles-B8fFoYm_.js.map +0 -1
  47. package/dist/webglRenderer-nGRruZk2.js.map +0 -1
package/dist/index.js CHANGED
@@ -238,7 +238,7 @@ var _ = class {
238
238
  }
239
239
  #a() {
240
240
  let e = [...this.#t.values()], t = e[0], n = e[1];
241
- if (!t || !n) throw Error("pinch requires two active pointers");
241
+ if (!t || !n) throw Error("Zine: pinch requires two active pointers.");
242
242
  return {
243
243
  a: t,
244
244
  b: n
@@ -261,7 +261,7 @@ function C(e, t) {
261
261
  let n = new URLSearchParams(e.replace(/^#/, ""));
262
262
  return n.set(v, String(t + 1)), `#${n.toString()}`;
263
263
  }
264
- function w(e, t) {
264
+ function ee(e, t) {
265
265
  let n = null, r = () => {
266
266
  let r = S(e.location.hash);
267
267
  r === null || r === n || (n = r, t(r));
@@ -280,49 +280,49 @@ function w(e, t) {
280
280
  }
281
281
  //#endregion
282
282
  //#region src/renderer/select.ts
283
- var T = {
283
+ var te = {
284
284
  css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
285
- webgl2: async () => new (await (import("./webglRenderer-nGRruZk2.js"))).WebglRenderer()
286
- }, E = !0;
287
- function D(e) {
285
+ webgl2: async () => new (await (import("./webglRenderer-CmQ_mUrX.js"))).WebglRenderer()
286
+ }, ne = !0;
287
+ function w(e) {
288
288
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
289
289
  }
290
- function O(e) {
291
- return e.gpu && E ? ["webgl2", "css"] : ["css"];
290
+ function T(e) {
291
+ return e.gpu && ne ? ["webgl2", "css"] : ["css"];
292
292
  }
293
- function ee() {
294
- return { gpu: te() };
293
+ function E() {
294
+ return { gpu: D() };
295
295
  }
296
- function te() {
296
+ function D() {
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 = ee()) {
304
- if (D(e)) return e;
305
- let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
303
+ async function O(e = "auto", t = E()) {
304
+ if (w(e)) return e;
305
+ let n = Array.isArray(e) ? e : e === "auto" ? T(t) : [e];
306
306
  for (let e of n) {
307
307
  if (e === "webgl2" && !t.gpu) continue;
308
- let n = T[e];
308
+ let n = te[e];
309
309
  if (n) return n();
310
310
  }
311
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'.`);
312
312
  }
313
313
  //#endregion
314
314
  //#region src/source/compose.ts
315
- function A(e, t) {
315
+ function re(e, t) {
316
316
  let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
317
- return !n && !r && !i ? e : new M(e, t);
317
+ return !n && !r && !i ? e : new ae(e, t);
318
318
  }
319
- function j(e) {
319
+ function ie(e) {
320
320
  return fetch(e).then((t) => {
321
321
  if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
322
322
  return t.blob();
323
323
  }).then((e) => createImageBitmap(e));
324
324
  }
325
- var M = class {
325
+ var ae = class {
326
326
  #e;
327
327
  #t;
328
328
  #n;
@@ -391,16 +391,16 @@ var M = class {
391
391
  }
392
392
  #s(e) {
393
393
  let t = this.#a.get(e);
394
- return t === void 0 && (t = j(e).catch((t) => {
394
+ return t === void 0 && (t = ie(e).catch((t) => {
395
395
  throw this.#a.delete(e), t;
396
396
  }), this.#a.set(e, t)), t;
397
397
  }
398
- }, 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;
399
- function q(e, t, n) {
400
- let r = Math.max(0, t - B), i = Math.min(e.length, t + n + B), a = e.slice(r, i).replace(/\s+/g, " ").trim();
398
+ }, k = .25, A = .0015, j = 6, M = 250, N = 24, P = 2 * M, F = 1.2, I = 32, L = 60, R = 2.5, z = 1.5, B = 120, V = .85, H = .82, U = .12, oe = 360, W = 28, G = 260, K = 7e3, q = 2200, J = "zine:hints-learned", Y = "zine:sound-muted";
399
+ function se(e, t, n) {
400
+ let r = Math.max(0, t - I), i = Math.min(e.length, t + n + I), a = e.slice(r, i).replace(/\s+/g, " ").trim();
401
401
  return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
402
402
  }
403
- var J = class {
403
+ var ce = class {
404
404
  #e;
405
405
  #t;
406
406
  #n = new l();
@@ -414,110 +414,141 @@ var J = class {
414
414
  #u;
415
415
  #d;
416
416
  #f;
417
- #p;
418
- #m;
419
- #h = !1;
420
- #g = null;
421
- #_ = !1;
417
+ #p = null;
418
+ #m = null;
419
+ #h;
420
+ #g;
421
+ #_;
422
422
  #v;
423
- #y = "";
424
- #b;
425
- #x;
426
- #S;
427
- #C = null;
428
- #w = null;
429
- #T = [];
430
- #E = 0;
431
- #D = 0;
432
- #O = {
433
- left: null,
434
- right: null
423
+ #y = null;
424
+ #b = !1;
425
+ #x = !1;
426
+ #S = !1;
427
+ #C = {
428
+ turn: !1,
429
+ zoom: !1,
430
+ pan: !1
435
431
  };
436
- #k;
437
- #A;
438
- #j;
432
+ #w = null;
433
+ #T = null;
434
+ #E = null;
435
+ #D = null;
436
+ #O = null;
437
+ #k = null;
438
+ #A = !1;
439
+ #j = "";
439
440
  #M;
440
441
  #N;
441
- #P = null;
442
+ #P;
442
443
  #F = !1;
443
- #I = 1;
444
- #L = 0;
445
- #R = 0;
444
+ #I = null;
445
+ #L = !1;
446
+ #R;
446
447
  #z = null;
447
- #B = !1;
448
- #V = !1;
449
- #H = null;
448
+ #B;
449
+ #V;
450
+ #H;
450
451
  #U = null;
451
452
  #W = null;
452
- #G = null;
453
- #K = null;
454
- #q = null;
455
- #J = null;
456
- #Y = 0;
457
- #X = null;
458
- #Z = !1;
459
- #Q = 1;
460
- #$ = !1;
453
+ #G = [];
454
+ #K = 0;
455
+ #q = 0;
456
+ #J = {
457
+ left: null,
458
+ right: null
459
+ };
460
+ #Y;
461
+ #X;
462
+ #Z;
463
+ #Q;
464
+ #$;
461
465
  #ee = null;
462
- #te = null;
463
- #ne = null;
464
- #re = null;
465
- #ie = null;
466
+ #te = !1;
467
+ #ne = 1;
468
+ #re = 0;
469
+ #ie = 0;
466
470
  #ae = null;
467
- #oe = -Infinity;
468
- #se = null;
471
+ #oe = !1;
472
+ #se = !1;
469
473
  #ce = null;
470
- #le = /* @__PURE__ */ new Set();
471
- #ue;
474
+ #le = null;
475
+ #ue = null;
472
476
  #de = null;
473
- #fe;
477
+ #fe = null;
474
478
  #pe = null;
475
479
  #me = null;
476
- #he = "download";
477
- #ge = 1;
478
- #_e = 0;
479
- #ve = null;
480
- #ye;
480
+ #he = 0;
481
+ #ge = null;
482
+ #_e = !1;
483
+ #ve = 1;
484
+ #ye = !1;
485
+ #be = null;
486
+ #xe = null;
487
+ #Se = null;
488
+ #Ce = null;
489
+ #we = null;
490
+ #Te = null;
491
+ #Ee = -Infinity;
492
+ #De = null;
493
+ #Oe = null;
494
+ #ke = /* @__PURE__ */ new Set();
495
+ #Ae;
496
+ #je = null;
497
+ #Me;
498
+ #Ne = null;
499
+ #Pe;
500
+ #Fe;
501
+ #Ie = null;
502
+ #Le = null;
503
+ #Re = "download";
504
+ #ze = 1;
505
+ #Be = 0;
506
+ #Ve = null;
507
+ #He;
481
508
  debug = { setFlipProgress: (e, t) => {
482
- this.#z?.setFlipProgress(e, t);
509
+ this.#ae?.setFlipProgress(e, t);
483
510
  } };
484
511
  constructor(e, t) {
485
- 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, {
512
+ ue(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 = re(t.source, {
486
513
  frontCover: t.frontCover,
487
514
  backCover: t.backCover,
488
515
  pages: t.pages
489
516
  });
490
517
  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.#Nt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
492
- let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
518
+ this.#a = n, this.#V = (t.deepLink ?? !0) && b(), this.#H = 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.#f = t.cursorHints ?? !0;
519
+ let r = t.hints ?? !0;
520
+ this.#h = r === !0 || r !== !1 && (r.enabled ?? !0), this.#g = r !== !0 && r !== !1 && (r.persist ?? !1), this.#g && this.#yt();
521
+ let i = t.sound ?? !1;
522
+ this.#_ = i !== !1, this.#v = i === !0 || i === !1 ? {} : i, this.#b = typeof i == "object" && i ? i.muted ?? !1 : !1, this.#x = typeof i == "object" && i ? i.persist ?? !1 : !1, this.#_ && this.#x && this.#Ye(), this.#P = t.singlePageThreshold ?? 640, this.#R = t.responsiveSpread ?? !0, this.#Ae = t.controls ?? !0, this.#Me = t.contextMenu ?? !t.disableContextMenu, this.#Pe = new Set(t.hideControls ?? []), this.#Fe = t.loading ?? !0, this.#B = t.startPage, typeof this.#t.open != "function" && this.#wn(), this.#Y = t.flipDuration ?? 800, this.#X = t.zoom?.enabled ?? !0, this.#Z = t.zoom?.wheel ?? !0;
523
+ let a = t.zoom?.doubleClick, o = a === !1 ? [] : [...a ?? [
493
524
  1,
494
525
  2,
495
526
  4
496
527
  ]].sort((e, t) => e - t);
497
- this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
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.#et(t.renderer ?? "auto");
528
+ this.#Q = o.length > 0 ? o : null, this.#$ = t.zoom?.max ?? 4;
529
+ let s = this.#X && this.#Q !== null, c = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
530
+ this.#M = this.#u !== "off" && s && c && t.clickFlipDelay !== 0, this.#N = this.#M ? t.clickFlipDelay ?? M : 0, this.#He = this.#Ut(t.renderer ?? "auto");
500
531
  }
501
532
  get ready() {
502
- return this.#ye;
533
+ return this.#He;
503
534
  }
504
535
  getPageCount() {
505
536
  return this.#t.pageCount;
506
537
  }
507
538
  getPage() {
508
- return this.#D;
539
+ return this.#q;
509
540
  }
510
541
  get container() {
511
542
  return this.#e;
512
543
  }
513
544
  getPageBox() {
514
- return this.#z?.measure().book ?? null;
545
+ return this.#ae?.measure().book ?? null;
515
546
  }
516
547
  getSpreads() {
517
- return this.#T;
548
+ return this.#G;
518
549
  }
519
550
  getSpreadIndex() {
520
- return this.#E;
551
+ return this.#K;
521
552
  }
522
553
  getDirection() {
523
554
  return this.#a;
@@ -526,44 +557,44 @@ var J = class {
526
557
  return this.#o;
527
558
  }
528
559
  isSinglePage() {
529
- return this.#h;
560
+ return this.#F;
530
561
  }
531
562
  setSpreadMode(e) {
532
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#_t(), this.#vt());
563
+ e !== this.#o && (this.#o = e, this.#L = !1, this.#cn(), this.#ln());
533
564
  }
534
565
  toggleSpreadMode() {
535
566
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
536
567
  }
537
568
  getResponsiveSpread() {
538
- return this.#v;
569
+ return this.#R;
539
570
  }
540
571
  isResponsiveSingle() {
541
- return this.#_ && this.#o !== "single";
572
+ return this.#L && this.#o !== "single";
542
573
  }
543
574
  setResponsiveSpread(e) {
544
- if (e !== this.#v) {
545
- if (this.#v = e, e) {
546
- let e = this.#z?.measure().containerWidth;
575
+ if (e !== this.#R) {
576
+ if (this.#R = e, e) {
577
+ let e = this.#ae?.measure().containerWidth;
547
578
  if (e === void 0) return;
548
- this.#_ = !1, this.#gt(e);
579
+ this.#L = !1, this.#sn(e);
549
580
  } else {
550
- if (!this.#_) return;
551
- this.#_ = !1, this.#_t();
581
+ if (!this.#L) return;
582
+ this.#L = !1, this.#cn();
552
583
  }
553
- this.#vt();
584
+ this.#ln();
554
585
  }
555
586
  }
556
587
  getPageImage(e) {
557
- return this.#At(e);
588
+ return this.#xn(e);
558
589
  }
559
590
  canFlipNext() {
560
- return this.#E + 1 < this.#T.length;
591
+ return this.#K + 1 < this.#G.length;
561
592
  }
562
593
  canFlipPrev() {
563
- return this.#E > 0;
594
+ return this.#K > 0;
564
595
  }
565
596
  getMaxZoom() {
566
- return this.#N;
597
+ return this.#$;
567
598
  }
568
599
  canSearch() {
569
600
  return typeof this.#t.getText == "function";
@@ -580,7 +611,7 @@ var J = class {
580
611
  async print() {
581
612
  let e = await this.getSourceFile(), t = this.#e.ownerDocument;
582
613
  if (!e || !t) return !1;
583
- let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("iframe");
614
+ let { url: n, revoke: r } = await this.#Ue(e, t), i = t.createElement("iframe");
584
615
  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
616
  let a = !1, o = (t) => {
586
617
  a || (a = !0, setTimeout(() => {
@@ -602,11 +633,11 @@ var J = class {
602
633
  return typeof this.#t.getOutline == "function";
603
634
  }
604
635
  getOutline() {
605
- if (!this.#ce) {
636
+ if (!this.#Oe) {
606
637
  let e = this.#t.getOutline;
607
- this.#ce = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
638
+ this.#Oe = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
608
639
  }
609
- return this.#ce;
640
+ return this.#Oe;
610
641
  }
611
642
  async getSourceFile() {
612
643
  let e = this.#t.getDownload;
@@ -617,11 +648,11 @@ var J = class {
617
648
  if (!e) return !1;
618
649
  let t = this.#e.ownerDocument;
619
650
  if (!t) return !1;
620
- let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("a");
651
+ let { url: n, revoke: r } = await this.#Ue(e, t), i = t.createElement("a");
621
652
  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;
622
653
  }
623
- async #be(e, t) {
624
- if (e.revoke || !this.#xe(e.url, t)) return {
654
+ async #Ue(e, t) {
655
+ if (e.revoke || !this.#We(e.url, t)) return {
625
656
  url: e.url,
626
657
  revoke: e.revoke ?? !1
627
658
  };
@@ -638,7 +669,7 @@ var J = class {
638
669
  };
639
670
  }
640
671
  }
641
- #xe(e, t) {
672
+ #We(e, t) {
642
673
  let n = t.defaultView?.location?.href;
643
674
  if (!n) return !1;
644
675
  try {
@@ -665,97 +696,118 @@ var J = class {
665
696
  let i = t.toLowerCase().indexOf(r);
666
697
  i < 0 || a.push({
667
698
  page: e,
668
- excerpt: q(t, i, r.length)
699
+ excerpt: se(t, i, r.length)
669
700
  });
670
701
  }
671
702
  return a;
672
703
  }
673
704
  flipNext() {
674
- this.#Se(1);
705
+ this.#Ge(1);
675
706
  }
676
707
  flipPrev() {
677
- this.#Se(-1);
708
+ this.#Ge(-1);
678
709
  }
679
- #Se(e) {
680
- this.#Ce(() => this.#Oe(this.#E + e));
710
+ #Ge(e) {
711
+ this.#Ke(() => this.#$e(this.#K + e));
681
712
  }
682
713
  flipTo(e) {
683
- let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
684
- this.#Ce(() => this.#Oe(this.#Mt(t)));
714
+ let t = X(e, 0, Math.max(0, this.#t.pageCount - 1));
715
+ this.#Ke(() => this.#$e(this.#Cn(t)));
685
716
  }
686
- #Ce(e) {
687
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#we(), e()) : this.#q = e;
717
+ #Ke(e) {
718
+ this.#i.state === "idle" ? e() : this.#me ? (this.#pe = null, this.#qe(), e()) : this.#pe = e;
688
719
  }
689
- #we() {
690
- let e = this.#J;
691
- e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
720
+ #qe() {
721
+ let e = this.#me;
722
+ e && (this.#me = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#ae?.setFlipProgress(e.toT, e.direction), e.onDone());
692
723
  }
693
- #Te() {
694
- let e = this.#q;
724
+ #Je() {
725
+ let e = this.#pe;
695
726
  if (!e) {
696
- this.#Et();
727
+ this.#_n();
697
728
  return;
698
729
  }
699
- this.#q = null, e();
730
+ this.#pe = null, e();
700
731
  }
701
732
  getZoom() {
702
- return this.#I;
733
+ return this.#ne;
703
734
  }
704
735
  setZoom(e, t) {
705
- if (!this.#z || !this.#A) return;
706
- let n = Y(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
707
- x: i.x + this.#L + i.width / 2,
708
- y: i.y + this.#R + i.height / 2
736
+ if (!this.#ae || !this.#X) return;
737
+ this.#wt(), this.#Dt();
738
+ let n = X(e, 1, this.#$), r = this.#ae.measure(), i = r.screenAt?.(this.#ne), a = t ?? (i ? {
739
+ x: i.x + this.#re + i.width / 2,
740
+ y: i.y + this.#ie + i.height / 2
709
741
  } : null) ?? {
710
742
  x: r.containerWidth / 2,
711
743
  y: r.containerHeight / 2
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);
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 });
744
+ }, o = this.#ne, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#re), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#ie);
745
+ [s, c] = this.#Qe(s, c, n, r.containerWidth, r.containerHeight), this.#ne = n, this.#re = s, this.#ie = c, this.#ae.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Ze(), this.#pn(), this.#_t(), o <= 1 && n > 1 && (this.#bt("zoom"), this.#Ot()), this.#n.emit("zoomChanged", { scale: n });
714
746
  }
715
747
  resetZoom() {
716
748
  this.setZoom(1);
717
749
  }
718
- #Ee() {
719
- this.#e.style.touchAction = this.#I > 1 ? "none" : "pan-y";
750
+ isSoundEnabled() {
751
+ return this.#_;
752
+ }
753
+ isSoundMuted() {
754
+ return this.#_ && this.#b;
755
+ }
756
+ setSoundMuted(e) {
757
+ this.#_ && (this.#b = e, this.#y?.setMuted(e), this.#x && this.#Xe(e), e || this.#Wt());
720
758
  }
721
- #De(e, t, n, r, i) {
722
- let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
759
+ #Ye() {
760
+ try {
761
+ let e = localStorage.getItem(Y);
762
+ (e === "true" || e === "false") && (this.#b = e === "true");
763
+ } catch {}
764
+ }
765
+ #Xe(e) {
766
+ try {
767
+ localStorage.setItem(Y, String(e));
768
+ } catch {}
769
+ }
770
+ #Ze() {
771
+ this.#e.style.touchAction = this.#ne > 1 ? "none" : "pan-y";
772
+ }
773
+ #Qe(e, t, n, r, i) {
774
+ let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#ae?.measure().screenAt?.(n) ?? {
723
775
  x: 0,
724
776
  y: 0,
725
777
  width: r * n,
726
778
  height: i * n
727
- }, [c, l] = X(s.x, s.width, r), [u, d] = X(s.y, s.height, i);
728
- return [o(Y(e, c, l)), o(Y(t, u, d))];
779
+ }, [c, l] = Z(s.x, s.width, r), [u, d] = Z(s.y, s.height, i);
780
+ return [o(X(e, c, l)), o(X(t, u, d))];
729
781
  }
730
782
  on(e, t) {
731
783
  return this.#n.on(e, t);
732
784
  }
733
785
  destroy() {
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();
786
+ this.#se = !0, this.#ce !== null && cancelAnimationFrame(this.#ce), this.#me = null, this.#pe = null, this.#Pt(), this.#St(), this.#wt(), this.#Dt(), this.#Nt(), this.#At(), this.#y?.destroy(), this.#y = null, this.#ee?.disconnect(), this.#U?.stop(), this.#U = null, this.#W?.(), this.#V && x(), this.#je?.(), this.#Ne?.(), this.#Yt(), this.#De?.(), this.#Se?.(), this.#we?.(), this.#Ce?.(), this.#m?.(), this.#xe?.(), this.#Ve !== null && clearTimeout(this.#Ve), this.#Be++, this.#ae?.destroy(), this.#ae = null, this.#t.destroy(), this.#n.clear();
735
787
  }
736
- #Oe(e) {
737
- if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
738
- let t = e > this.#E ? "forward" : "backward", n = this.#Ne(e);
788
+ #$e(e) {
789
+ if (e < 0 || e >= this.#G.length || e === this.#K || (this.#wt(), this.#Dt(), this.#i.send("flip") === null)) return;
790
+ let t = e > this.#K ? "forward" : "backward", n = this.#it(e);
739
791
  this.#n.emit("flipStart", {
740
- from: this.#D,
792
+ from: this.#q,
741
793
  to: n
742
- }), this.#ke(e, t, n, ++this.#Y);
794
+ }), this.#Gt(), this.#et(e, t, n, ++this.#he);
743
795
  }
744
- async #ke(e, t, n, r) {
745
- let i = this.#T[e], a = i ? await this.#kt(i) : {
796
+ async #et(e, t, n, r) {
797
+ let i = this.#G[e], a = i ? await this.#bn(i) : {
746
798
  left: null,
747
799
  right: null
748
800
  };
749
- r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
750
- fill: this.#h,
751
- curl: this.#mt(),
801
+ r === this.#he && (this.#ae?.beginFlip(this.#J, a, t, {
802
+ fill: this.#F,
803
+ curl: this.#an(),
752
804
  anchor: { y: this.#l }
753
- }), this.#Ae(0, 1, t, () => this.#Me(e, n, a), () => this.#je(n)));
805
+ }), this.#tt(0, 1, t, () => this.#rt(e, n, a), () => this.#nt(n)));
754
806
  }
755
- #Ae(e, t, n, r, i) {
756
- let a = this.#pt() * Math.abs(t - e);
807
+ #tt(e, t, n, r, i) {
808
+ let a = this.#in() * Math.abs(t - e);
757
809
  if (a <= 0) {
758
- this.#z?.setFlipProgress(t, n), r();
810
+ this.#ae?.setFlipProgress(t, n), r();
759
811
  return;
760
812
  }
761
813
  let o = {
@@ -763,60 +815,60 @@ var J = class {
763
815
  direction: n,
764
816
  onDone: r
765
817
  };
766
- this.#J = o;
818
+ this.#me = o;
767
819
  let s = performance.now(), c = !1, l = (u) => {
768
- if (this.#J !== o) return;
769
- let d = Math.min(1, (u - s) / a), f = this.#h ? ne(d) : Z(d);
770
- 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());
820
+ if (this.#me !== o) return;
821
+ let d = Math.min(1, (u - s) / a), f = le(d);
822
+ i && !c && f >= (this.#F ? H : V) && (c = !0, i()), d < 1 ? (this.#ae?.setFlipProgress(e + (t - e) * f, n), this.#ce = requestAnimationFrame(l)) : (this.#ae?.setFlipProgress(t, n), this.#ce = null, this.#me = null, r());
771
823
  };
772
- this.#H = requestAnimationFrame(l);
824
+ this.#ce = requestAnimationFrame(l);
773
825
  }
774
- #je(e) {
775
- this.#D !== e && (this.#D = e, this.#ft(), this.#n.emit("pageChanged", { page: e }));
826
+ #nt(e) {
827
+ this.#q !== e && (this.#q = e, this.#rn(), this.#n.emit("pageChanged", { page: e }));
776
828
  }
777
- #Me(e, t, n) {
778
- let r = this.#T[e];
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();
829
+ #rt(e, t, n) {
830
+ let r = this.#G[e];
831
+ this.#K = e, this.#J = n, r && this.#un(r, n), this.#Sn(), this.#i.send("settle"), this.#Ee = performance.now(), this.#nt(t), this.#bt("turn"), this.#_t(), this.#n.emit("flipEnd", { page: t }), this.#Je();
780
832
  }
781
- #Ne(e) {
782
- let t = this.#T[e];
783
- if (!t) return this.#D;
833
+ #it(e) {
834
+ let t = this.#G[e];
835
+ if (!t) return this.#q;
784
836
  let n = [t.left, t.right].filter((e) => e !== null);
785
- return n.length > 0 ? Math.min(...n) : this.#D;
837
+ return n.length > 0 ? Math.min(...n) : this.#q;
786
838
  }
787
- #Pe(e, t) {
788
- if (this.#Z || !this.#z) return;
789
- if (this.#Ge(), this.#I > 1) {
839
+ #at(e, t) {
840
+ if (this.#_e || !this.#ae) return;
841
+ if (this.#Dt(), this.#Pt(), this.#ne > 1) {
790
842
  if (this.#i.send("panStart") === null) return;
791
- this.#X = {
792
- baseTx: this.#L,
793
- baseTy: this.#R
843
+ this.#ge = {
844
+ baseTx: this.#re,
845
+ baseTy: this.#ie
794
846
  };
795
847
  return;
796
848
  }
797
- let n = this.#Ve(), r = this.#He(e, t);
798
- this.#G = r;
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;
849
+ let n = this.#ft(), r = this.#pt(e, t);
850
+ this.#de = r;
851
+ let i = Math.min(n.width, n.height) * k, 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;
800
852
  if (this.#i.state !== "idle") {
801
- if (!this.#J || !s) {
802
- this.#W = null;
853
+ if (!this.#me || !s) {
854
+ this.#ue = null;
803
855
  return;
804
856
  }
805
- this.#we();
857
+ this.#qe();
806
858
  }
807
859
  if (!s) return;
808
- this.#l = Y(r.y / n.height, 0, 1);
809
- let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#E + (l ? 1 : -1);
810
- u < 0 || u >= this.#T.length || (this.#W = {
860
+ this.#l = X(r.y / n.height, 0, 1);
861
+ let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#K + (l ? 1 : -1);
862
+ u < 0 || u >= this.#G.length || (this.#ue = {
811
863
  direction: l ? "forward" : "backward",
812
864
  targetIndex: u,
813
- toPage: this.#Ne(u),
865
+ toPage: this.#it(u),
814
866
  width: n.width
815
867
  });
816
868
  }
817
- #Fe() {
818
- let e = this.#W;
819
- e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
869
+ #ot() {
870
+ let e = this.#ue;
871
+ e && (this.#ue = null, this.#i.send("grab") !== null && (this.#le = {
820
872
  direction: e.direction,
821
873
  targetIndex: e.targetIndex,
822
874
  toPage: e.toPage,
@@ -827,71 +879,75 @@ var J = class {
827
879
  width: e.width,
828
880
  t: 0
829
881
  }, this.#n.emit("flipStart", {
830
- from: this.#D,
882
+ from: this.#q,
831
883
  to: e.toPage
832
- }), this.#Ie(e.targetIndex, e.direction)));
884
+ }), this.#st(e.targetIndex, e.direction)));
833
885
  }
834
- async #Ie(e, t) {
835
- let n = this.#T[e], r = n ? await this.#kt(n) : {
886
+ async #st(e, t) {
887
+ let n = this.#G[e], r = n ? await this.#bn(n) : {
836
888
  left: null,
837
889
  right: null
838
890
  };
839
- this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
840
- fill: this.#h,
841
- curl: this.#mt(),
891
+ this.#le?.targetIndex === e && (this.#le.toContent = r, this.#ae?.beginFlip(this.#J, r, t, {
892
+ fill: this.#F,
893
+ curl: this.#an(),
842
894
  anchor: { y: this.#l }
843
- }), this.#z?.setFlipProgress(this.#U.t, t));
844
- }
845
- #Le(e, t) {
846
- if (this.#Z) return;
847
- if (this.#X) {
848
- if (!this.#z) return;
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();
895
+ }), this.#ae?.setFlipProgress(this.#le.t, t));
896
+ }
897
+ #ct(e, t) {
898
+ if (this.#_e) return;
899
+ if (this.#ge) {
900
+ if (!this.#ae) return;
901
+ let n = this.#ae.measure(), [r, i] = this.#Qe(this.#ge.baseTx + e, this.#ge.baseTy + t, this.#ne, n.containerWidth, n.containerHeight);
902
+ this.#re = r, this.#ie = i, this.#ae.setViewTransform(this.#ne, r, i), this.#pn(), this.#bt("pan"), this.#At();
851
903
  return;
852
904
  }
853
- this.#W && Math.hypot(e, t) > F && this.#Fe();
854
- let n = this.#U;
855
- n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
856
- }
857
- #Re(e) {
858
- if (this.#Z) return;
859
- if (this.#X) {
860
- this.#X = null, this.#i.send("panEnd");
905
+ this.#ue && Math.hypot(e, t) > j && this.#ot();
906
+ let n = this.#le;
907
+ n && (n.t = X((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#ae?.setFlipProgress(n.t, n.direction));
908
+ }
909
+ #lt(e) {
910
+ if (this.#_e) return;
911
+ if (this.#ge) {
912
+ this.#ge = null, this.#i.send("panEnd"), this.#_t();
861
913
  return;
862
914
  }
863
- let t = this.#U;
915
+ let t = this.#le;
864
916
  if (!t) {
865
- this.#W = null, this.#ze(e) || this.#Be(e);
917
+ this.#ue = null, this.#ut(e) || this.#dt(e);
866
918
  return;
867
919
  }
868
- this.#U = null, this.#i.send("release");
920
+ this.#le = null, this.#i.send("release");
869
921
  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;
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());
922
+ i || t.t >= .5 && !a ? (this.#Gt(), this.#tt(t.t, 1, t.direction, () => this.#rt(t.targetIndex, t.toPage, t.toContent), () => this.#nt(t.toPage))) : this.#tt(t.t, 0, t.direction, () => this.#Ft());
871
923
  }
872
- #ze(e) {
873
- if (this.#I > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
924
+ #ut(e) {
925
+ if (this.#ne > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
874
926
  let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
875
- if (!this.#We(n)) return !1;
927
+ if (!this.#ht(n)) return this.#Et(n), !1;
876
928
  let r = t ? 1 : -1;
877
- return this.#Ce(() => this.#Oe(this.#E + r)), !0;
878
- }
879
- #Be(e) {
880
- if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
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);
929
+ return this.#Ke(() => this.#$e(this.#K + r)), !0;
930
+ }
931
+ #dt(e) {
932
+ if (this.#u === "off" || this.#ne > 1 || !this.#de || Math.abs(e.dx) > j || Math.abs(e.dy) > j) return;
933
+ let t = this.#mt(this.#de);
934
+ if (!t) return;
935
+ if (!this.#ht(t)) {
936
+ this.#Et(t);
887
937
  return;
888
938
  }
889
- this.#K = setTimeout(() => {
890
- this.#K = null, this.#Ce(r);
891
- }, this.#p);
939
+ this.#l = X(this.#de.y / this.#ft().height, 0, 1);
940
+ let n = t === "forward" ? 1 : -1, r = () => this.#$e(this.#K + n);
941
+ if (this.#Pt(), this.#N <= 0) {
942
+ this.#Ke(r);
943
+ return;
944
+ }
945
+ this.#fe = setTimeout(() => {
946
+ this.#fe = null, this.#Ke(r);
947
+ }, this.#N);
892
948
  }
893
- #Ve() {
894
- let e = this.#z.measure();
949
+ #ft() {
950
+ let e = this.#ae.measure();
895
951
  return e.content ?? e.book ?? {
896
952
  x: 0,
897
953
  y: 0,
@@ -899,213 +955,364 @@ var J = class {
899
955
  height: e.containerHeight
900
956
  };
901
957
  }
902
- #He(e, t) {
903
- let n = this.#e.getBoundingClientRect(), r = this.#Ve();
958
+ #pt(e, t) {
959
+ let n = this.#e.getBoundingClientRect(), r = this.#ft();
904
960
  return {
905
961
  x: e - n.left - r.x,
906
962
  y: t - n.top - r.y
907
963
  };
908
964
  }
909
- #Ue(e) {
910
- if (!this.#z) return null;
911
- let t = this.#Ve().width, n;
965
+ #mt(e) {
966
+ if (!this.#ae) return null;
967
+ let t = this.#ft().width, n;
912
968
  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;
913
969
  let r = this.#a === "rtl" ? "left" : "right";
914
970
  return n === r ? "forward" : "backward";
915
971
  }
916
- #We(e) {
917
- let t = this.#E + (e === "forward" ? 1 : -1);
918
- return t >= 0 && t < this.#T.length;
972
+ #ht(e) {
973
+ let t = this.#K + (e === "forward" ? 1 : -1);
974
+ return t >= 0 && t < this.#G.length;
919
975
  }
920
- #Ge() {
921
- this.#K !== null && (clearTimeout(this.#K), this.#K = null);
976
+ #gt() {
977
+ let e = (e) => {
978
+ let t = e;
979
+ this.#p = {
980
+ x: t.clientX,
981
+ y: t.clientY
982
+ }, this.#_t();
983
+ }, t = () => {
984
+ this.#p = null, this.#_t();
985
+ };
986
+ this.#e.addEventListener("pointermove", e), this.#e.addEventListener("pointerleave", t), this.#m = () => {
987
+ this.#e.removeEventListener("pointermove", e), this.#e.removeEventListener("pointerleave", t);
988
+ };
922
989
  }
923
- #Ke() {
924
- let e = this.#T[this.#E];
925
- e && this.#yt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#Te();
990
+ #_t() {
991
+ if (!this.#f || !this.#ae) return;
992
+ let e = "";
993
+ this.#le || this.#ge ? e = "grabbing" : this.#p && (e = this.#vt(this.#p.x, this.#p.y)), this.#e.style.cursor = e;
994
+ }
995
+ #vt(e, t) {
996
+ if (!this.#ae) return "";
997
+ let n = this.#ft(), r = this.#pt(e, t);
998
+ if (r.x < 0 || r.y < 0 || r.x > n.width || r.y > n.height) return "";
999
+ if (this.#ne > 1) return "grab";
1000
+ let i = this.#mt(r);
1001
+ return i && this.#ht(i) ? "pointer" : this.#X && this.#Q !== null ? "zoom-in" : "";
1002
+ }
1003
+ #yt() {
1004
+ try {
1005
+ let e = localStorage.getItem(J);
1006
+ if (!e) return;
1007
+ let t = JSON.parse(e);
1008
+ this.#C = {
1009
+ turn: t.turn === !0,
1010
+ zoom: t.zoom === !0,
1011
+ pan: t.pan === !0
1012
+ };
1013
+ } catch {}
926
1014
  }
927
- #qe() {
928
- if (this.#W = null, this.#Ge(), this.#U) {
929
- this.#U = null, this.#i.send("release"), this.#i.send("settle");
930
- let e = this.#T[this.#E];
931
- e && this.#yt(e, this.#O);
932
- } else this.#X && (this.#X = null, this.#i.send("panEnd"));
933
- this.#Z = !0, this.#Q = this.#I;
934
- }
935
- #Je(e, t, n) {
936
- if (!this.#Z) return;
1015
+ #bt(e) {
1016
+ if (!this.#C[e] && (this.#C[e] = !0, e === "turn" && this.#St(), e === "zoom" && this.#Nt(), this.#g)) try {
1017
+ localStorage.setItem(J, JSON.stringify(this.#C));
1018
+ } catch {}
1019
+ }
1020
+ #xt() {
1021
+ !this.#h || this.#ye || this.#C.turn || (this.#St(), this.#w = setTimeout(() => {
1022
+ this.#w = null, this.#Ct();
1023
+ }, K));
1024
+ }
1025
+ #St() {
1026
+ this.#w !== null && (clearTimeout(this.#w), this.#w = null);
1027
+ }
1028
+ async #Ct() {
1029
+ if (!this.#h || this.#ye || this.#C.turn || !this.#ae || typeof requestAnimationFrame != "function" || this.#i.state !== "idle") return;
1030
+ let e = this.#K + 1, t = this.#G[e];
1031
+ if (!t) return;
1032
+ let n = await this.#bn(t);
1033
+ if (this.#se || this.#C.turn || this.#i.state !== "idle" || this.#T) return;
1034
+ this.#l = 1, this.#ae.beginFlip(this.#J, n, "forward", {
1035
+ fill: this.#F,
1036
+ curl: this.#an(),
1037
+ anchor: { y: this.#l }
1038
+ });
1039
+ let r = {};
1040
+ this.#T = r;
1041
+ let i = performance.now(), a = oe * 2, o = () => {
1042
+ if (this.#T !== r) return;
1043
+ let e = Math.min(1, (performance.now() - i) / a), t = U * Math.sin(e * Math.PI);
1044
+ this.#ae?.setFlipProgress(Math.max(0, t), "forward"), e < 1 ? this.#ce = requestAnimationFrame(o) : (this.#ce = null, this.#T = null, this.#Tt());
1045
+ };
1046
+ this.#ce = requestAnimationFrame(o);
1047
+ }
1048
+ #wt() {
1049
+ this.#T && (this.#T = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#Tt());
1050
+ }
1051
+ #Tt() {
1052
+ let e = this.#G[this.#K];
1053
+ e && this.#i.state === "idle" && this.#un(e, this.#J);
1054
+ }
1055
+ #Et(e) {
1056
+ if (!this.#ae || typeof requestAnimationFrame != "function" || this.#ye || this.#i.state !== "idle" || this.#ne > 1 || this.#E) return;
1057
+ let t = e === "forward", n = (this.#a === "rtl" ? !t : t) ? -1 : 1, r = {};
1058
+ this.#E = r;
1059
+ let i = performance.now(), a = () => {
1060
+ if (this.#E !== r) return;
1061
+ let e = Math.min(1, (performance.now() - i) / G), t = W * Math.sin(e * Math.PI);
1062
+ this.#ae?.setViewTransform(1, n * t, 0), e < 1 ? this.#ce = requestAnimationFrame(a) : (this.#ce = null, this.#E = null, this.#ae?.setViewTransform(1, 0, 0));
1063
+ };
1064
+ this.#ce = requestAnimationFrame(a);
1065
+ }
1066
+ #Dt() {
1067
+ this.#E && (this.#E = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#ae?.setViewTransform(1, 0, 0));
1068
+ }
1069
+ #Ot() {
1070
+ this.#C.pan || this.#kt("Drag to move");
1071
+ }
1072
+ #kt(e) {
1073
+ if (!this.#h) return;
1074
+ let t = this.#e.ownerDocument;
1075
+ if (!t || typeof this.#e.appendChild != "function") return;
1076
+ this.#At();
1077
+ let n = t.createElement("div");
1078
+ n.className = "zine-hint-caption", n.setAttribute("aria-hidden", "true"), n.textContent = e, n.style.cssText = "position:absolute;left:50%;bottom:16px;transform:translateX(-50%);z-index:3;pointer-events:none;padding:6px 12px;border-radius:999px;font:500 13px/1.2 system-ui,sans-serif;color:#fff;background:rgba(24,24,27,0.82);box-shadow:0 1px 4px rgba(0,0,0,0.35);white-space:nowrap;opacity:0;";
1079
+ let r = !this.#ye && typeof requestAnimationFrame == "function";
1080
+ r && (n.style.transition = "opacity 200ms ease"), this.#e.appendChild(n), this.#D = n, r ? requestAnimationFrame(() => {
1081
+ this.#D === n && (n.style.opacity = "1");
1082
+ }) : n.style.opacity = "1", this.#O = setTimeout(() => this.#At(), q);
1083
+ }
1084
+ #At() {
1085
+ this.#O !== null && (clearTimeout(this.#O), this.#O = null), this.#D?.remove(), this.#D = null;
1086
+ }
1087
+ #jt(e, t) {
1088
+ !this.#h || this.#C.zoom || this.#A || this.#j === "mouse" && this.#vt(e, t) === "zoom-in" && (this.#i.state === "animating" || performance.now() - this.#Ee <= P || (this.#Nt(), this.#k = setTimeout(() => {
1089
+ this.#k = null, !(this.#C.zoom || this.#A) && (this.#A = !0, this.#kt(this.#Mt()));
1090
+ }, M)));
1091
+ }
1092
+ #Mt() {
1093
+ let e = [];
1094
+ if (this.#Q !== null && e.push("Double-click"), this.#Z) {
1095
+ let t = this.#e.ownerDocument?.defaultView?.navigator, n = /Mac|iPhone|iPad/.test(t?.platform ?? "");
1096
+ e.push(`${n ? "⌘" : "Ctrl"}-scroll`);
1097
+ }
1098
+ return `${e.join(" or ")} to zoom`;
1099
+ }
1100
+ #Nt() {
1101
+ this.#k !== null && (clearTimeout(this.#k), this.#k = null);
1102
+ }
1103
+ #Pt() {
1104
+ this.#fe !== null && (clearTimeout(this.#fe), this.#fe = null);
1105
+ }
1106
+ #Ft() {
1107
+ let e = this.#G[this.#K];
1108
+ e && this.#un(e, this.#J), this.#i.send("settle"), this.#_t(), this.#n.emit("flipEnd", { page: this.#q }), this.#Je();
1109
+ }
1110
+ #It() {
1111
+ if (this.#ue = null, this.#Pt(), this.#le) {
1112
+ this.#le = null, this.#i.send("release"), this.#i.send("settle");
1113
+ let e = this.#G[this.#K];
1114
+ e && this.#un(e, this.#J);
1115
+ } else this.#ge && (this.#ge = null, this.#i.send("panEnd"));
1116
+ this.#_e = !0, this.#ve = this.#ne;
1117
+ }
1118
+ #Lt(e, t, n) {
1119
+ if (!this.#_e) return;
937
1120
  let r = this.#e.getBoundingClientRect();
938
- this.setZoom(this.#Q * n, {
1121
+ this.setZoom(this.#ve * n, {
939
1122
  x: e - r.left,
940
1123
  y: t - r.top
941
1124
  });
942
1125
  }
943
- #Ye() {
944
- this.#Z = !1;
1126
+ #Rt() {
1127
+ this.#_e = !1;
945
1128
  }
946
- #Xe() {
947
- if (!this.#S) return;
1129
+ #zt() {
1130
+ if (!this.#H) return;
948
1131
  let e = (e) => e.preventDefault();
949
- this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
1132
+ this.#e.addEventListener("contextmenu", e), this.#Ce = () => this.#e.removeEventListener("contextmenu", e);
950
1133
  }
951
- #Ze() {
1134
+ #Bt() {
952
1135
  let e = (e) => {
953
- if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
1136
+ if (!this.#Z || !this.#X || !(e.ctrlKey || e.metaKey)) return;
954
1137
  e.preventDefault();
955
- let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * P);
956
- this.setZoom(this.#I * n, {
1138
+ let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * A);
1139
+ this.setZoom(this.#ne * n, {
957
1140
  x: e.clientX - t.left,
958
1141
  y: e.clientY - t.top
959
1142
  });
960
1143
  };
961
- this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
1144
+ this.#e.addEventListener("wheel", e, { passive: !1 }), this.#Se = () => this.#e.removeEventListener("wheel", e);
962
1145
  }
963
- #Qe() {
1146
+ #Vt() {
964
1147
  let e = (e) => {
965
- let t = this.#M;
966
- if (!this.#A || t === null || !this.#z) return;
967
- let n = performance.now(), r = this.#ae;
968
- if (!(r !== null && n - r.t <= I && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= L)) {
969
- this.#ae = {
1148
+ this.#j = e.pointerType;
1149
+ }, t = (e) => {
1150
+ let t = this.#Q;
1151
+ if (!this.#X || t === null || !this.#ae) return;
1152
+ let n = performance.now(), r = this.#Te;
1153
+ if (!(r !== null && n - r.t <= M && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= N)) {
1154
+ this.#Te = {
970
1155
  t: n,
971
1156
  x: e.clientX,
972
1157
  y: e.clientY
973
- };
1158
+ }, this.#jt(e.clientX, e.clientY);
974
1159
  return;
975
1160
  }
976
- this.#ae = null, this.#$e(e.clientX, e.clientY, t);
1161
+ this.#Te = null, this.#Nt(), this.#Ht(e.clientX, e.clientY, t);
1162
+ };
1163
+ this.#e.addEventListener("pointerdown", e), this.#e.addEventListener("click", t), this.#we = () => {
1164
+ this.#e.removeEventListener("pointerdown", e), this.#e.removeEventListener("click", t);
977
1165
  };
978
- this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
979
1166
  }
980
- #$e(e, t, n) {
981
- if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
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;
1167
+ #Ht(e, t, n) {
1168
+ if (this.#ne <= 1 && this.#u !== "off" && !this.#M) {
1169
+ let n = this.#pt(e, t), r = this.#mt(n);
1170
+ if (r !== null && this.#ht(r) || this.#i.state === "animating" || performance.now() - this.#Ee <= P) return;
984
1171
  }
985
- this.#Ge();
986
- let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
1172
+ this.#Pt();
1173
+ let r = n.find((e) => e > this.#ne + 1e-6) ?? n[0] ?? this.#ne, i = this.#e.getBoundingClientRect();
987
1174
  this.setZoom(r, {
988
1175
  x: e - i.left,
989
1176
  y: t - i.top
990
1177
  });
991
1178
  }
992
- async #et(e) {
993
- let t = k(e);
994
- if (this.#t.onProgress?.((e) => this.#tt(e)), typeof this.#t.open == "function") {
995
- this.#nt();
1179
+ async #Ut(e) {
1180
+ let t = O(e);
1181
+ if (this.#t.onProgress?.((e) => this.#Kt(e)), typeof this.#t.open == "function") {
1182
+ this.#qt();
996
1183
  try {
997
- await this.#t.open(), this.#Nt();
1184
+ await this.#t.open(), this.#wn();
998
1185
  } catch (e) {
999
- throw this.#it(), e;
1186
+ throw this.#Yt(), e;
1000
1187
  }
1001
- this.#rt("preparing");
1188
+ this.#Jt("preparing");
1002
1189
  }
1003
- this.#t.prefetch([this.#D]);
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);
1190
+ this.#t.prefetch([this.#q]);
1191
+ let n = await t, r = await this.#Xt(n);
1192
+ this.#ae = r, this.#t.onPageUpdate?.((e) => this.#fn(e)), this.#sn(r.measure().containerWidth);
1006
1193
  let i = new m({
1007
- onStart: (e) => this.#Pe(e.x, e.y),
1008
- onMove: (e) => this.#Le(e.dx, e.dy),
1009
- onEnd: (e) => this.#Re(e)
1194
+ onStart: (e) => this.#at(e.x, e.y),
1195
+ onMove: (e) => this.#ct(e.dx, e.dy),
1196
+ onEnd: (e) => this.#lt(e)
1010
1197
  }), a = new _({
1011
- onPinchStart: () => this.#qe(),
1012
- onPinchMove: (e) => this.#Je(e.centerX, e.centerY, e.scale),
1013
- onPinchEnd: () => this.#Ye()
1198
+ onPinchStart: () => this.#It(),
1199
+ onPinchMove: (e) => this.#Lt(e.centerX, e.centerY, e.scale),
1200
+ onPinchEnd: () => this.#Rt()
1014
1201
  });
1015
- this.#te = h(this.#e, {
1202
+ this.#xe = h(this.#e, {
1016
1203
  pointer: i,
1017
1204
  pinch: a
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");
1205
+ }), this.#Ze(), this.#Bt(), this.#Vt(), this.#zt(), this.#gt(), this.#Qt(), this.#De = this.#tn(), await this.#ln(), this.#Yt(), this.#vn(), this.#Sn(), this.#rn(), this.#en(), await this.#$t(), this.#Wt(), this.#n.emit("ready"), this.#Ct(), this.#xt();
1019
1206
  }
1020
- #tt(e) {
1021
- this.#me = e, this.#n.emit("progress", e), this.#pe?.update(e);
1207
+ async #Wt() {
1208
+ if (!(!this.#_ || this.#b || this.#S || this.#se)) {
1209
+ this.#S = !0;
1210
+ try {
1211
+ let { FlipSound: e } = await import("./flipSound-BFXSkWBo.js");
1212
+ if (this.#se) return;
1213
+ this.#y = new e(this.#v), this.#y.setMuted(this.#b);
1214
+ } catch {}
1215
+ }
1216
+ }
1217
+ #Gt() {
1218
+ this.#y?.play();
1219
+ }
1220
+ #Kt(e) {
1221
+ this.#Le = e, this.#n.emit("progress", e), this.#Ie?.update(e);
1022
1222
  }
1023
- async #nt() {
1024
- if (this.#fe === !1 || this.#V) return;
1223
+ async #qt() {
1224
+ if (this.#Fe === !1 || this.#se) return;
1025
1225
  let e = this.#e;
1026
1226
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1027
- let { mountLoading: t } = await import("./loading-BBK6YbSW.js");
1028
- if (this.#he === "done" || this.#V) return;
1029
- this.#pe = t(e), this.#me && this.#pe.update(this.#me), this.#he === "preparing" && this.#pe.preparing();
1227
+ let { mountLoading: t } = await import("./loading-DF88K9yJ.js");
1228
+ if (this.#Re === "done" || this.#se) return;
1229
+ this.#Ie = t(e), this.#Le && this.#Ie.update(this.#Le), this.#Re === "preparing" && this.#Ie.preparing();
1030
1230
  } catch {}
1031
1231
  }
1032
- #rt(e) {
1033
- this.#he !== "done" && (this.#he = e, this.#pe?.preparing());
1232
+ #Jt(e) {
1233
+ this.#Re !== "done" && (this.#Re = e, this.#Ie?.preparing());
1034
1234
  }
1035
- #it() {
1036
- this.#he = "done", this.#pe?.destroy(), this.#pe = null;
1235
+ #Yt() {
1236
+ this.#Re = "done", this.#Ie?.destroy(), this.#Ie = null;
1037
1237
  }
1038
- async #at(e) {
1238
+ async #Xt(e) {
1039
1239
  try {
1040
1240
  return await e.mount(this.#e), e.onFatal?.(() => {
1041
- this.#ot();
1241
+ this.#Zt();
1042
1242
  }), e;
1043
1243
  } catch {
1044
1244
  e.destroy();
1045
- let t = await k("css");
1046
- return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
1245
+ let t = await O("css");
1246
+ return await t.mount(this.#e), this.#oe = !0, this.#n.emit("rendererFallback", {
1047
1247
  from: "webgl2",
1048
1248
  to: "css"
1049
1249
  }), t;
1050
1250
  }
1051
1251
  }
1052
- async #ot() {
1053
- if (this.#B || this.#V) return;
1054
- this.#B = !0, this.#z?.destroy(), this.#z = null;
1055
- let e = await k("css");
1056
- if (this.#V) {
1252
+ async #Zt() {
1253
+ if (this.#oe || this.#se) return;
1254
+ this.#oe = !0, this.#ae?.destroy(), this.#ae = null;
1255
+ let e = await O("css");
1256
+ if (this.#se) {
1057
1257
  e.destroy();
1058
1258
  return;
1059
1259
  }
1060
- await e.mount(this.#e), this.#z = e, this.#gt(e.measure().containerWidth), await this.#vt(), this.#n.emit("rendererFallback", {
1260
+ await e.mount(this.#e), this.#ae = e, this.#sn(e.measure().containerWidth), await this.#ln(), this.#n.emit("rendererFallback", {
1061
1261
  from: "webgl2",
1062
1262
  to: "css"
1063
1263
  });
1064
1264
  }
1065
- #st() {
1265
+ #Qt() {
1066
1266
  if (typeof matchMedia != "function") return;
1067
1267
  let e = matchMedia("(prefers-reduced-motion: reduce)");
1068
- this.#$ = e.matches, e.addEventListener?.("change", (e) => {
1069
- this.#$ = e.matches;
1268
+ this.#ye = e.matches, e.addEventListener?.("change", (e) => {
1269
+ this.#ye = e.matches;
1070
1270
  });
1071
1271
  }
1072
- async #ct() {
1073
- if (this.#ue === !1 || this.#V) return;
1074
- let e = this.#e;
1075
- if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1076
- let { mountControls: t } = await import("./controls-DgEXR2zi.js");
1077
- if (this.#V) return;
1078
- let n = this.#ue === !0 ? {} : this.#ue;
1079
- this.#de = t(this, e, n);
1272
+ async #$t() {
1273
+ let e = this.#Ae !== !1, t = this.#Me !== !1;
1274
+ if (!e && !t || this.#se) return;
1275
+ let n = this.#e;
1276
+ if (!(!n.ownerDocument || typeof n.appendChild != "function")) try {
1277
+ let { mountControls: e, mountContextMenu: t } = await import("./controls-DzVdwPJB.js");
1278
+ if (this.#se) return;
1279
+ if (this.#Ae !== !1) {
1280
+ let t = this.#Ae === !0 ? {} : this.#Ae;
1281
+ this.#je = e(this, n, t, this.#Pe);
1282
+ }
1283
+ if (this.#Me !== !1) {
1284
+ let e = this.#Me === !0 ? {} : this.#Me;
1285
+ this.#Ne = t(this, n, e, this.#Pe);
1286
+ }
1080
1287
  } catch {}
1081
1288
  }
1082
- #lt() {
1083
- if (!this.#x || globalThis.location === void 0) return;
1289
+ #en() {
1290
+ if (!this.#V || globalThis.location === void 0) return;
1084
1291
  let e = globalThis;
1085
- this.#C = w(e, (e) => {
1086
- e !== this.#D && this.flipTo(e);
1087
- }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1088
- this.#C?.push(e);
1292
+ this.#U = ee(e, (e) => {
1293
+ e !== this.#q && this.flipTo(e);
1294
+ }), this.#U.push(this.#q), this.#W = this.#n.on("pageChanged", ({ page: e }) => {
1295
+ this.#U?.push(e);
1089
1296
  });
1090
1297
  }
1091
- pageLink(e = this.#D) {
1298
+ pageLink(e = this.#q) {
1092
1299
  let t = globalThis.location?.href ?? "";
1093
1300
  if (!t) return "";
1094
1301
  let n = new URL(t);
1095
- return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1302
+ return n.hash = C(n.hash, X(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1096
1303
  }
1097
- #ut() {
1304
+ #tn() {
1098
1305
  let e = this.#e, t = e.ownerDocument;
1099
1306
  if (!t || typeof e.setAttribute != "function") return null;
1100
1307
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1101
- let n = (e) => this.#dt(e);
1308
+ let n = (e) => this.#nn(e);
1102
1309
  e.addEventListener("keydown", n);
1103
1310
  let r = t.createElement("div");
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, () => {
1105
- e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1311
+ 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.#be = r, () => {
1312
+ e.removeEventListener("keydown", n), r.remove(), this.#be = null;
1106
1313
  };
1107
1314
  }
1108
- #dt(e) {
1315
+ #nn(e) {
1109
1316
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1110
1317
  switch (e.key) {
1111
1318
  case "ArrowRight":
@@ -1121,92 +1328,98 @@ var J = class {
1121
1328
  default: break;
1122
1329
  }
1123
1330
  }
1124
- #ft() {
1125
- this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1331
+ #rn() {
1332
+ this.#be && (this.#be.textContent = `Page ${this.#q + 1} of ${this.#t.pageCount}`);
1126
1333
  }
1127
- #pt() {
1128
- return this.#$ ? W : this.#k * (this.#h ? z : 1);
1334
+ #in() {
1335
+ return this.#ye ? B : this.#Y * (this.#F ? F : 1);
1129
1336
  }
1130
- #mt() {
1131
- return this.#$ ? "simple" : this.#c;
1337
+ #an() {
1338
+ return this.#ye ? "simple" : this.#c;
1132
1339
  }
1133
1340
  update() {
1134
- !this.#z || this.#i.state !== "idle" || (this.#gt(this.#z.measure().containerWidth), this.#vt());
1341
+ !this.#ae || this.#i.state !== "idle" || (this.#sn(this.#ae.measure().containerWidth), this.#ln(), this.#_t());
1135
1342
  }
1136
- #ht() {
1137
- return this.#_ || this.#o === "single" ? "single" : this.#o;
1343
+ #on() {
1344
+ return this.#L || this.#o === "single" ? "single" : this.#o;
1138
1345
  }
1139
- #gt(e) {
1140
- let t = this.#v && o(e, this.#m);
1141
- t !== this.#_ && (this.#_ = t, this.#_t());
1346
+ #sn(e) {
1347
+ let t = this.#R && o(e, this.#P);
1348
+ t !== this.#L && (this.#L = t, this.#cn());
1142
1349
  }
1143
- #_t() {
1144
- let e = this.#ht(), t = e !== this.#g;
1145
- this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1350
+ #cn() {
1351
+ let e = this.#on(), t = e !== this.#I;
1352
+ this.#I = e, this.#F = e === "single", this.#G = a(this.#t.pageCount, {
1146
1353
  direction: this.#a,
1147
1354
  mode: e
1148
- }), this.#E = this.#Mt(this.#D), t && this.#n.emit("spreadChanged", {
1355
+ }), this.#K = this.#Cn(this.#q), t && this.#n.emit("spreadChanged", {
1149
1356
  mode: e,
1150
- singlePage: this.#h
1357
+ singlePage: this.#F
1151
1358
  });
1152
1359
  }
1153
- async #vt() {
1154
- let e = this.#T[this.#E];
1155
- !e || !this.#z || (this.#O = await this.#kt(e), this.#yt(e, this.#O));
1360
+ async #ln() {
1361
+ let e = this.#G[this.#K];
1362
+ !e || !this.#ae || (this.#J = await this.#bn(e), this.#un(e, this.#J));
1156
1363
  }
1157
- #yt(e, t) {
1158
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#bt(), this.#ge = 1, this.#St();
1364
+ #un(e, t) {
1365
+ this.#ae?.renderSpread(e, t, { fill: this.#F }), this.#dn(), this.#ze = 1, this.#pn();
1159
1366
  }
1160
- #bt() {
1161
- let e = this.#z?.measure().book;
1367
+ #dn() {
1368
+ let e = this.#ae?.measure().book;
1162
1369
  if (!e || e.width <= 0 || e.height <= 0) return;
1163
- let t = (e.width / e.height).toFixed(4);
1164
- t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1370
+ let t = e.width / e.height;
1371
+ this.#z !== null && Math.abs(t - this.#z) < .005 || (this.#z = t, this.#e.style.aspectRatio = t.toFixed(4));
1165
1372
  }
1166
- #xt(e) {
1373
+ #fn(e) {
1167
1374
  if (this.#i.state !== "idle") {
1168
- this.#le.add(e);
1375
+ this.#ke.add(e);
1169
1376
  return;
1170
1377
  }
1171
- let t = this.#T[this.#E];
1172
- t && (t.left === e || t.right === e) && this.#vt();
1378
+ let t = this.#G[this.#K];
1379
+ if (!(!t || !(t.left === e || t.right === e))) {
1380
+ if (this.#ne > 1) {
1381
+ this.#pn();
1382
+ return;
1383
+ }
1384
+ this.#ln();
1385
+ }
1173
1386
  }
1174
- #St() {
1175
- this.#ve !== null && clearTimeout(this.#ve);
1176
- let e = this.#wt();
1177
- if (e !== this.#ge) {
1387
+ #pn() {
1388
+ this.#Ve !== null && clearTimeout(this.#Ve);
1389
+ let e = this.#hn();
1390
+ if (e !== this.#ze) {
1178
1391
  if (e === 1) {
1179
- this.#_e++, this.#ge = 1, this.#vt();
1392
+ this.#Be++, this.#ze = 1, this.#ln();
1180
1393
  return;
1181
1394
  }
1182
- this.#ve = setTimeout(() => {
1183
- this.#ve = null, this.#Tt();
1184
- }, V);
1395
+ this.#Ve = setTimeout(() => {
1396
+ this.#Ve = null, this.#gn();
1397
+ }, L);
1185
1398
  }
1186
1399
  }
1187
- #Ct() {
1188
- let e = this.#z?.measure(), t = e?.content ?? e?.book;
1400
+ #mn() {
1401
+ let e = this.#ae?.measure(), t = e?.content ?? e?.book;
1189
1402
  if (!t || t.width <= 0) return 1;
1190
- let n = this.#O, r = +!!n.left + +!!n.right;
1403
+ let n = this.#J, r = +!!n.left + +!!n.right;
1191
1404
  if (r === 0) return 1;
1192
1405
  let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
1193
1406
  for (let e of [n.left, n.right]) {
1194
1407
  if (!e || e.width <= 0) continue;
1195
- let t = e.width / this.#ge;
1408
+ let t = e.width / this.#ze;
1196
1409
  o = Math.max(o, i * a / t);
1197
1410
  }
1198
1411
  return o === 0 ? 1 : o;
1199
1412
  }
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);
1202
- return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1203
- }
1204
- async #Tt() {
1205
- let e = this.#T[this.#E];
1206
- if (!this.#z || !e) return;
1207
- let t = this.#wt();
1208
- if (t === 1 || t === this.#ge || this.#i.state !== "idle") return;
1209
- let n = ++this.#_e, r = {
1413
+ #hn() {
1414
+ let e = Math.max(1, z / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#ne <= 1 ? 1 : this.#ne, n = this.#mn() * Math.max(t, e);
1415
+ return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, R);
1416
+ }
1417
+ async #gn() {
1418
+ let e = this.#G[this.#K];
1419
+ if (!this.#ae || !e) return;
1420
+ let t = this.#hn();
1421
+ if (t === 1 || t === this.#ze || this.#i.state !== "idle") return;
1422
+ let n = ++this.#Be, r = {
1210
1423
  x: 0,
1211
1424
  y: 0,
1212
1425
  width: 1,
@@ -1216,7 +1429,8 @@ var J = class {
1216
1429
  try {
1217
1430
  return await this.#t.get(e, {
1218
1431
  scale: t,
1219
- region: r
1432
+ region: r,
1433
+ maxSize: this.#ae?.maxTextureSize
1220
1434
  });
1221
1435
  } catch (t) {
1222
1436
  return this.#n.emit("sourceError", {
@@ -1225,34 +1439,34 @@ var J = class {
1225
1439
  }), null;
1226
1440
  }
1227
1441
  }));
1228
- if (n !== this.#_e || this.#wt() !== t || this.#i.state !== "idle") return;
1229
- let a = i[0] ?? null, o = i[1] ?? null;
1230
- a === this.#O.left && o === this.#O.right || (this.#ge = t, this.#O = {
1442
+ if (n !== this.#Be || this.#hn() !== t || this.#i.state !== "idle") return;
1443
+ let a = i[0] ?? this.#J.left, o = i[1] ?? this.#J.right;
1444
+ a === this.#J.left && o === this.#J.right || (this.#ze = t, this.#J = {
1231
1445
  left: a,
1232
1446
  right: o
1233
- }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1447
+ }, this.#ae.renderSpread(e, this.#J, { fill: this.#F }));
1234
1448
  }
1235
- #Et() {
1236
- if (this.#le.size === 0) return;
1237
- let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1238
- this.#le.clear(), t && this.#vt();
1449
+ #_n() {
1450
+ if (this.#ke.size === 0) return;
1451
+ let e = this.#G[this.#K], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#ke.has(e));
1452
+ this.#ke.clear(), t && (this.#ne > 1 ? this.#pn() : this.#ln());
1239
1453
  }
1240
- #Dt() {
1241
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Ot()), this.#P.observe(this.#e));
1454
+ #vn() {
1455
+ typeof ResizeObserver > "u" || (this.#ee = new ResizeObserver(() => this.#yn()), this.#ee.observe(this.#e));
1242
1456
  }
1243
- #Ot() {
1244
- this.#F || (this.#F = !0, requestAnimationFrame(() => {
1245
- this.#F = !1, this.update();
1457
+ #yn() {
1458
+ this.#te || (this.#te = !0, requestAnimationFrame(() => {
1459
+ this.#te = !1, this.update();
1246
1460
  }));
1247
1461
  }
1248
- async #kt(e) {
1249
- let [t, n] = await Promise.all([this.#At(e.left), this.#At(e.right)]);
1462
+ async #bn(e) {
1463
+ let [t, n] = await Promise.all([this.#xn(e.left), this.#xn(e.right)]);
1250
1464
  return {
1251
1465
  left: t,
1252
1466
  right: n
1253
1467
  };
1254
1468
  }
1255
- async #At(e) {
1469
+ async #xn(e) {
1256
1470
  if (e === null) return null;
1257
1471
  try {
1258
1472
  return await this.#t.get(e);
@@ -1263,52 +1477,49 @@ var J = class {
1263
1477
  }), null;
1264
1478
  }
1265
1479
  }
1266
- #jt() {
1267
- let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1480
+ #Sn() {
1481
+ let { toMount: e } = this.#r.update(this.#K, this.#G.length), t = [];
1268
1482
  for (let n of e) {
1269
- let e = this.#T[n];
1483
+ let e = this.#G[n];
1270
1484
  e?.left != null && t.push(e.left), e?.right != null && t.push(e.right);
1271
1485
  }
1272
1486
  this.#t.prefetch(t);
1273
1487
  }
1274
- #Mt(e) {
1275
- let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1488
+ #Cn(e) {
1489
+ let t = this.#G.findIndex((t) => t.left === e || t.right === e);
1276
1490
  return t === -1 ? 0 : t;
1277
1491
  }
1278
- #Nt() {
1492
+ #wn() {
1279
1493
  let e = this.#t.pageCount;
1280
1494
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1281
- let t = this.#b;
1495
+ let t = this.#B;
1282
1496
  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}).`);
1283
- let n = this.#ht();
1284
- this.#h = n === "single", this.#T = a(e, {
1497
+ let n = this.#on();
1498
+ this.#F = n === "single", this.#G = a(e, {
1285
1499
  direction: this.#a,
1286
1500
  mode: n
1287
1501
  });
1288
- let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1289
- this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#Mt(this.#D);
1502
+ let r = this.#V ? S(globalThis.location?.hash ?? "") : null;
1503
+ this.#q = X(r ?? t ?? 0, 0, e - 1), this.#K = this.#Cn(this.#q);
1290
1504
  }
1291
1505
  };
1292
- function Y(e, t, n) {
1506
+ function X(e, t, n) {
1293
1507
  return e < t ? t : e > n ? n : e;
1294
1508
  }
1295
- function X(e, t, n) {
1509
+ function Z(e, t, n) {
1296
1510
  if (t <= n) {
1297
1511
  let r = (n - t) / 2 - e;
1298
1512
  return [r, r];
1299
1513
  }
1300
1514
  return [n - (e + t), -e];
1301
1515
  }
1302
- function Z(e) {
1516
+ function le(e) {
1303
1517
  return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1304
1518
  }
1305
- function ne(e) {
1306
- return 1 - (1 - Z(e)) ** 1.3;
1307
- }
1308
1519
  function Q(e) {
1309
1520
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
1310
1521
  }
1311
- function re(n, r) {
1522
+ function ue(n, r) {
1312
1523
  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)}.`);
1313
1524
  if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
1314
1525
  let i = r, a = i.source;
@@ -1353,25 +1564,45 @@ function re(n, r) {
1353
1564
  ].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
1354
1565
  let p = u?.arrows;
1355
1566
  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)}.`);
1356
- let m = i.spreadMode;
1357
- if (m !== void 0 && ![
1567
+ let m = i.contextMenu;
1568
+ if (m !== void 0 && typeof m != "boolean" && (typeof m != "object" || !m)) throw Error(`Zine: contextMenu must be a boolean or an options object; got ${Q(m)}.`);
1569
+ let h = m?.colorScheme;
1570
+ if (h !== void 0 && ![
1571
+ "light",
1572
+ "dark",
1573
+ "auto"
1574
+ ].includes(h)) throw Error(`Zine: contextMenu.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(h)}.`);
1575
+ if (i.disableContextMenu === !0 && m !== void 0 && m !== !1) throw Error("Zine: disableContextMenu and contextMenu are mutually exclusive — one removes the browser's right-click menu, the other replaces it. Enable only one.");
1576
+ let g = i.hideControls;
1577
+ if (g !== void 0 && (!Array.isArray(g) || g.some((e) => typeof e != "string"))) throw Error(`Zine: hideControls must be an array of control-id strings; got ${Q(g)}.`);
1578
+ let _ = i.sound;
1579
+ if (_ !== void 0 && typeof _ != "boolean" && (typeof _ != "object" || !_)) throw Error(`Zine: sound must be a boolean or an options object; got ${Q(_)}.`);
1580
+ if (typeof _ == "object" && _) {
1581
+ let e = _;
1582
+ if (e.url !== void 0 && typeof e.url != "string") throw Error(`Zine: sound.url must be a string URL; got ${Q(e.url)}.`);
1583
+ if (e.volume !== void 0 && (typeof e.volume != "number" || e.volume < 0 || e.volume > 1)) throw Error(`Zine: sound.volume must be a number between 0 and 1; got ${JSON.stringify(e.volume)}.`);
1584
+ if (e.muted !== void 0 && typeof e.muted != "boolean") throw Error(`Zine: sound.muted must be a boolean; got ${Q(e.muted)}.`);
1585
+ if (e.persist !== void 0 && typeof e.persist != "boolean") throw Error(`Zine: sound.persist must be a boolean; got ${Q(e.persist)}.`);
1586
+ }
1587
+ let v = i.spreadMode;
1588
+ if (v !== void 0 && ![
1358
1589
  "double",
1359
1590
  "single",
1360
1591
  "cover",
1361
1592
  "book"
1362
- ].includes(m)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(m)}.`);
1593
+ ].includes(v)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(v)}.`);
1363
1594
  for (let e of ["frontCover", "backCover"]) {
1364
1595
  let t = i[e];
1365
1596
  if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
1366
1597
  }
1367
- let h = i.pages;
1368
- 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.");
1369
- $(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);
1598
+ let y = i.pages;
1599
+ if (y !== void 0 && (typeof y != "object" || !y || Array.isArray(y))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1600
+ $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), de(i.zoom), fe(i.renderer);
1370
1601
  }
1371
1602
  function $(e, t, n) {
1372
1603
  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)}.`);
1373
1604
  }
1374
- function ie(e) {
1605
+ function de(e) {
1375
1606
  if (e === void 0) return;
1376
1607
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
1377
1608
  let t = e;
@@ -1384,7 +1615,7 @@ function ie(e) {
1384
1615
  }
1385
1616
  $(t.max, "zoom.max", 1);
1386
1617
  }
1387
- function ae(e) {
1618
+ function fe(e) {
1388
1619
  if (e !== void 0) {
1389
1620
  if (typeof e == "string") {
1390
1621
  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.`);
@@ -1399,7 +1630,7 @@ function ae(e) {
1399
1630
  }
1400
1631
  //#endregion
1401
1632
  //#region src/source/imageSource.ts
1402
- var oe = class {
1633
+ var pe = class {
1403
1634
  pageCount;
1404
1635
  fit;
1405
1636
  #e;
@@ -1436,6 +1667,6 @@ var oe = class {
1436
1667
  }
1437
1668
  };
1438
1669
  //#endregion
1439
- 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 };
1670
+ export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, pe as ImageSource, ce as Zine, n as defineControl, r as getControl };
1440
1671
 
1441
1672
  //# sourceMappingURL=index.js.map