@zinejs/core 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { t as e } from "./types-CcPVyhOJ.js";
2
+ import { n as t, r as n, t as r } from "./registry-5nuYFMd4.js";
2
3
  //#region src/engine/spread.ts
3
- function t(e, t = {}) {
4
+ function i(e, t = {}) {
4
5
  let { direction: n = "ltr", mode: r = "cover" } = t;
5
6
  if (e <= 0) return [];
6
7
  let i = (t) => t >= 0 && t < e ? t : null, a = [];
@@ -39,17 +40,17 @@ function t(e, t = {}) {
39
40
  right: e.left
40
41
  })) : a;
41
42
  }
42
- function n(e, t) {
43
+ function a(e, t) {
43
44
  return e < t;
44
45
  }
45
46
  //#endregion
46
47
  //#region src/engine/virtualizer.ts
47
- function r(e, t, n) {
48
+ function o(e, t, n) {
48
49
  let r = [], i = Math.max(0, e - n), a = Math.min(t - 1, e + n);
49
50
  for (let e = i; e <= a; e++) r.push(e);
50
51
  return r;
51
52
  }
52
- var i = class {
53
+ var s = class {
53
54
  #e;
54
55
  #t = /* @__PURE__ */ new Set();
55
56
  constructor(e = 2) {
@@ -59,15 +60,15 @@ var i = class {
59
60
  return [...this.#t].sort((e, t) => e - t);
60
61
  }
61
62
  update(e, t) {
62
- let n = new Set(r(e, t, this.#e)), i = [...n].filter((e) => !this.#t.has(e)).sort((e, t) => e - t), a = [...this.#t].filter((e) => !n.has(e)).sort((e, t) => e - t);
63
- for (let e of a) this.#t.delete(e);
64
- for (let e of i) this.#t.add(e);
63
+ let n = new Set(o(e, t, this.#e)), r = [...n].filter((e) => !this.#t.has(e)).sort((e, t) => e - t), i = [...this.#t].filter((e) => !n.has(e)).sort((e, t) => e - t);
64
+ for (let e of i) this.#t.delete(e);
65
+ for (let e of r) this.#t.add(e);
65
66
  return {
66
- toMount: i,
67
- toEvict: a
67
+ toMount: r,
68
+ toEvict: i
68
69
  };
69
70
  }
70
- }, a = class {
71
+ }, c = class {
71
72
  #e = /* @__PURE__ */ new Map();
72
73
  on(e, t) {
73
74
  let n = this.#e.get(e);
@@ -83,7 +84,7 @@ var i = class {
83
84
  clear() {
84
85
  this.#e.clear();
85
86
  }
86
- }, o = {
87
+ }, l = {
87
88
  idle: {
88
89
  grab: "dragging",
89
90
  panStart: "zoomed-panning",
@@ -93,10 +94,10 @@ var i = class {
93
94
  animating: { settle: "idle" },
94
95
  "zoomed-panning": { panEnd: "idle" }
95
96
  };
96
- function s(e, t) {
97
- return o[e][t] ?? null;
97
+ function u(e, t) {
98
+ return l[e][t] ?? null;
98
99
  }
99
- var c = class {
100
+ var d = class {
100
101
  #e;
101
102
  constructor(e = "idle") {
102
103
  this.#e = e;
@@ -105,10 +106,10 @@ var c = class {
105
106
  return this.#e;
106
107
  }
107
108
  send(e) {
108
- let t = s(this.#e, e);
109
+ let t = u(this.#e, e);
109
110
  return t !== null && (this.#e = t), t;
110
111
  }
111
- }, l = .3, u = class {
112
+ }, f = .3, p = class {
112
113
  #e;
113
114
  #t = null;
114
115
  #n = null;
@@ -154,16 +155,16 @@ var c = class {
154
155
  }
155
156
  #a(e, t, n, r, i) {
156
157
  if (e !== this.#t || this.#n === null) return;
157
- let a = this.#n, o = this.#i ?? a, s = this.#r ?? a, c = o.t - s.t, u = c > 0 ? (o.x - s.x) / c : 0, d = c > 0 ? (o.y - s.y) / c : 0, f = Math.hypot(u, d);
158
+ let a = this.#n, o = this.#i ?? a, s = this.#r ?? a, c = o.t - s.t, l = c > 0 ? (o.x - s.x) / c : 0, u = c > 0 ? (o.y - s.y) / c : 0, d = Math.hypot(l, u);
158
159
  this.#o(), this.#e.onEnd?.({
159
160
  x: t,
160
161
  y: n,
161
162
  dx: t - a.x,
162
163
  dy: n - a.y,
163
164
  dt: r - a.t,
164
- vx: u,
165
- vy: d,
166
- swipe: !i && f > l,
165
+ vx: l,
166
+ vy: u,
167
+ swipe: !i && d > f,
167
168
  canceled: i
168
169
  });
169
170
  }
@@ -171,7 +172,7 @@ var c = class {
171
172
  this.#t = null, this.#n = null, this.#r = null, this.#i = null;
172
173
  }
173
174
  };
174
- function d(e, t) {
175
+ function m(e, t) {
175
176
  let { pointer: n, pinch: r } = t, i = (e) => {
176
177
  let t = e;
177
178
  n?.down(t.pointerId, t.clientX, t.clientY, t.timeStamp), r?.down(t.pointerId, t.clientX, t.clientY);
@@ -189,10 +190,10 @@ function d(e, t) {
189
190
  e.removeEventListener("pointerdown", i), e.removeEventListener("pointermove", a), e.removeEventListener("pointerup", o), e.removeEventListener("pointercancel", s);
190
191
  };
191
192
  }
192
- function f(e, t) {
193
+ function h(e, t) {
193
194
  return Math.hypot(e.x - t.x, e.y - t.y);
194
195
  }
195
- var p = class {
196
+ var g = class {
196
197
  #e;
197
198
  #t = /* @__PURE__ */ new Map();
198
199
  #n = 0;
@@ -209,7 +210,7 @@ var p = class {
209
210
  y: n
210
211
  }), this.#t.size === 2)) {
211
212
  let { a: e, b: t } = this.#a();
212
- this.#n = f(e, t), this.#r = !0, this.#e.onPinchStart?.({
213
+ this.#n = h(e, t), this.#r = !0, this.#e.onPinchStart?.({
213
214
  centerX: (e.x + t.x) / 2,
214
215
  centerY: (e.y + t.y) / 2,
215
216
  distance: this.#n
@@ -223,7 +224,7 @@ var p = class {
223
224
  this.#e.onPinchMove?.({
224
225
  centerX: (i.x + a.x) / 2,
225
226
  centerY: (i.y + a.y) / 2,
226
- scale: this.#n > 0 ? f(i, a) / this.#n : 1
227
+ scale: this.#n > 0 ? h(i, a) / this.#n : 1
227
228
  });
228
229
  }
229
230
  up(e) {
@@ -246,57 +247,171 @@ var p = class {
246
247
  };
247
248
  //#endregion
248
249
  //#region src/geometry/hitTest.ts
249
- function m(e, t, n) {
250
+ function _(e, t, n) {
250
251
  let { width: r, height: i } = t;
251
252
  if (e.x < 0 || e.x > r || e.y < 0 || e.y > i) return "outside";
252
253
  let a = e.x <= n || e.x >= r - n, o = e.y <= n || e.y >= i - n;
253
254
  return a && o ? "corner" : "page";
254
255
  }
255
256
  //#endregion
257
+ //#region src/engine/deeplink.ts
258
+ var v = "page", y = !1;
259
+ function b() {
260
+ return y ? !1 : (y = !0, !0);
261
+ }
262
+ function x() {
263
+ y = !1;
264
+ }
265
+ function S(e) {
266
+ let t = new URLSearchParams(e.replace(/^#/, "")).get(v);
267
+ if (t === null) return null;
268
+ let n = Number(t);
269
+ return Number.isInteger(n) && n >= 1 ? n - 1 : null;
270
+ }
271
+ function C(e, t) {
272
+ let n = new URLSearchParams(e.replace(/^#/, ""));
273
+ return n.set(v, String(t + 1)), `#${n.toString()}`;
274
+ }
275
+ function w(e, t) {
276
+ let n = null, r = () => {
277
+ let r = S(e.location.hash);
278
+ r === null || r === n || (n = r, t(r));
279
+ };
280
+ return e.addEventListener("hashchange", r), {
281
+ push(t) {
282
+ if (t === n) return;
283
+ n = t;
284
+ let r = C(e.location.hash, t);
285
+ r !== e.location.hash && e.history?.replaceState?.(e.history.state, "", r);
286
+ },
287
+ stop() {
288
+ e.removeEventListener("hashchange", r);
289
+ }
290
+ };
291
+ }
292
+ //#endregion
256
293
  //#region src/renderer/select.ts
257
- var h = {
294
+ var T = {
258
295
  css: async () => new (await (import("./cssRenderer-OzRRoEa4.js"))).CssRenderer(),
259
296
  webgl2: async () => new (await (import("./webglRenderer-BK-ArG1G.js"))).WebglRenderer()
260
- }, g = !0;
261
- function _(e) {
297
+ }, E = !0;
298
+ function D(e) {
262
299
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
263
300
  }
264
- function v(e) {
265
- return e.gpu && g ? ["webgl2", "css"] : ["css"];
301
+ function O(e) {
302
+ return e.gpu && E ? ["webgl2", "css"] : ["css"];
266
303
  }
267
- function y() {
268
- return { gpu: b() };
304
+ function k() {
305
+ return { gpu: A() };
269
306
  }
270
- function b() {
307
+ function A() {
271
308
  try {
272
309
  return !!document.createElement("canvas").getContext("webgl2");
273
310
  } catch {
274
311
  return !1;
275
312
  }
276
313
  }
277
- async function x(e = "auto", t = y()) {
278
- if (_(e)) return e;
279
- let n = Array.isArray(e) ? e : e === "auto" ? v(t) : [e];
314
+ async function j(e = "auto", t = k()) {
315
+ if (D(e)) return e;
316
+ let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
280
317
  for (let e of n) {
281
318
  if (e === "webgl2" && !t.gpu) continue;
282
- let n = h[e];
319
+ let n = T[e];
283
320
  if (n) return n();
284
321
  }
285
322
  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'.`);
286
323
  }
287
324
  //#endregion
325
+ //#region src/engine/zoomTile.ts
326
+ function M(e, t) {
327
+ let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y), i = Math.min(e.x + e.width, t.x + t.width), a = Math.min(e.y + e.height, t.y + t.height);
328
+ return i <= n || a <= r ? null : {
329
+ x: n,
330
+ y: r,
331
+ width: i - n,
332
+ height: a - r
333
+ };
334
+ }
335
+ function N(e, t, n) {
336
+ let { scale: r, tx: i, ty: a } = t;
337
+ if (r <= 1) return [];
338
+ let o = {
339
+ x: (n.x - i) / r,
340
+ y: (n.y - a) / r,
341
+ width: n.width / r,
342
+ height: n.height / r
343
+ }, s = [];
344
+ for (let t of e) {
345
+ let e = M(t.rect, o);
346
+ !e || t.rect.width <= 0 || t.rect.height <= 0 || s.push({
347
+ index: t.index,
348
+ request: {
349
+ scale: r,
350
+ region: {
351
+ x: (e.x - t.rect.x) / t.rect.width,
352
+ y: (e.y - t.rect.y) / t.rect.height,
353
+ width: e.width / t.rect.width,
354
+ height: e.height / t.rect.height
355
+ }
356
+ },
357
+ dest: e
358
+ });
359
+ }
360
+ return s;
361
+ }
362
+ function P(e, t) {
363
+ if (e.index !== t.index || e.request.scale !== t.request.scale) return !1;
364
+ let n = e.request.region, r = t.request.region, i = 1e-4;
365
+ return Math.abs(n.x - r.x) < i && Math.abs(n.y - r.y) < i && Math.abs(n.width - r.width) < i && Math.abs(n.height - r.height) < i;
366
+ }
367
+ var F = class {
368
+ #e;
369
+ #t;
370
+ #n = [];
371
+ constructor(e, t) {
372
+ this.#e = e.createElement("canvas"), this.#e.className = "zine-zoom-overlay", this.#e.style.cssText = "position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity 120ms linear;", t.append(this.#e), this.#t = this.#e.getContext("2d");
373
+ }
374
+ clear() {
375
+ if (this.#n.length === 0) return;
376
+ this.#n = [], this.#e.style.opacity = "0";
377
+ let e = this.#t;
378
+ e && e.clearRect(0, 0, this.#e.width, this.#e.height);
379
+ }
380
+ get shown() {
381
+ return this.#n;
382
+ }
383
+ draw(e, t, n) {
384
+ let r = this.#t;
385
+ if (!r) return;
386
+ if (e.length === 0) {
387
+ this.clear();
388
+ return;
389
+ }
390
+ let i = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, a = Math.max(1, Math.ceil(n.width * i)), o = Math.max(1, Math.ceil(n.height * i));
391
+ (this.#e.width !== a || this.#e.height !== o) && (this.#e.width = a, this.#e.height = o), r.setTransform(i, 0, 0, i, 0, 0), r.clearRect(0, 0, n.width, n.height), r.translate(t.tx, t.ty), r.scale(t.scale, t.scale);
392
+ for (let { plan: t, content: n } of e) {
393
+ let e = t.dest;
394
+ r.drawImage(n, e.x, e.y, e.width, e.height);
395
+ }
396
+ this.#n = e.map((e) => e.plan), this.#e.style.opacity = "1";
397
+ }
398
+ destroy() {
399
+ this.#e.remove(), this.#t = null;
400
+ }
401
+ };
402
+ //#endregion
288
403
  //#region src/source/compose.ts
289
- function S(e, t) {
404
+ function I(e, t) {
290
405
  let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
291
- return !n && !r && !i ? e : new w(e, t);
406
+ return !n && !r && !i ? e : new R(e, t);
292
407
  }
293
- function C(e) {
408
+ function L(e) {
294
409
  return fetch(e).then((t) => {
295
410
  if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
296
411
  return t.blob();
297
412
  }).then((e) => createImageBitmap(e));
298
413
  }
299
- var w = class {
414
+ var R = class {
300
415
  #e;
301
416
  #t;
302
417
  #n;
@@ -305,22 +420,39 @@ var w = class {
305
420
  #a = /* @__PURE__ */ new Map();
306
421
  open;
307
422
  onPageUpdate;
423
+ getText;
424
+ getDownload;
425
+ getOutline;
308
426
  constructor(e, t) {
309
427
  this.#e = e, this.#t = typeof t.frontCover == "string" ? t.frontCover : null, this.#n = typeof t.backCover == "string" ? t.backCover : null, this.#r = t.pages ?? {}, typeof e.open == "function" ? this.open = async () => {
310
428
  await e.open(), this.#o();
311
429
  } : this.#o(), typeof e.onPageUpdate == "function" && (this.onPageUpdate = (t) => {
312
430
  e.onPageUpdate((e) => t(e + (this.#t === null ? 0 : 1)));
431
+ }), typeof e.getText == "function" && (this.getText = async (t) => {
432
+ let n = this.#t === null ? 0 : 1;
433
+ if (this.#t !== null && t === 0 || this.#n !== null && t === this.pageCount - 1) return "";
434
+ let r = t - n;
435
+ return this.#i.has(r) ? "" : e.getText(r);
436
+ }), typeof e.getDownload == "function" && (this.getDownload = () => e.getDownload()), typeof e.getOutline == "function" && (this.getOutline = async () => {
437
+ let t = await e.getOutline(), n = this.#t === null ? 0 : 1;
438
+ if (n === 0) return t;
439
+ let r = (e) => e.map((e) => ({
440
+ ...e,
441
+ page: e.page === null ? null : e.page + n,
442
+ children: r(e.children)
443
+ }));
444
+ return r(t);
313
445
  });
314
446
  }
315
447
  get pageCount() {
316
448
  return this.#e.pageCount + (this.#t === null ? 0 : 1) + (this.#n === null ? 0 : 1);
317
449
  }
318
- get(e) {
319
- let t = this.#t === null ? 0 : 1;
450
+ get(e, t) {
451
+ let n = this.#t === null ? 0 : 1;
320
452
  if (this.#t !== null && e === 0) return this.#s(this.#t);
321
453
  if (this.#n !== null && e === this.pageCount - 1) return this.#s(this.#n);
322
- let n = e - t, r = this.#i.get(n);
323
- return r === void 0 ? this.#e.get(n) : this.#s(r);
454
+ let r = e - n, i = this.#i.get(r);
455
+ return i === void 0 ? this.#e.get(r, t) : this.#s(i);
324
456
  }
325
457
  prefetch(e) {
326
458
  let t = this.#t === null ? 0 : 1, n = [];
@@ -347,162 +479,323 @@ var w = class {
347
479
  }
348
480
  #s(e) {
349
481
  let t = this.#a.get(e);
350
- return t === void 0 && (t = C(e).catch((t) => {
482
+ return t === void 0 && (t = L(e).catch((t) => {
351
483
  throw this.#a.delete(e), t;
352
484
  }), this.#a.set(e, t)), t;
353
485
  }
354
- }, T = .25, E = .0015, D = 6, O = 250, k = 1.55, A = class {
486
+ }, z = .25, B = .0015, V = 6, H = 250, U = 1.55, W = 32, G = 120;
487
+ function K(e, t, n) {
488
+ let r = Math.max(0, t - W), i = Math.min(e.length, t + n + W), a = e.slice(r, i).replace(/\s+/g, " ").trim();
489
+ return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
490
+ }
491
+ var q = class {
355
492
  #e;
356
493
  #t;
357
- #n = new a();
358
- #r = new i(2);
359
- #i = new c();
494
+ #n = new c();
495
+ #r = new s(2);
496
+ #i = new d();
360
497
  #a;
361
498
  #o;
362
499
  #s;
363
- #c = 1;
364
- #l;
500
+ #c;
501
+ #l = 1;
365
502
  #u;
366
503
  #d;
367
504
  #f;
368
505
  #p;
369
- #m = !1;
506
+ #m;
370
507
  #h = !1;
371
- #g = "";
372
- #_;
373
- #v = [];
374
- #y = 0;
375
- #b = 0;
376
- #x = {
508
+ #g = null;
509
+ #_ = !1;
510
+ #v;
511
+ #y = "";
512
+ #b;
513
+ #x;
514
+ #S;
515
+ #C = null;
516
+ #w = null;
517
+ #T = [];
518
+ #E = 0;
519
+ #D = 0;
520
+ #O = {
377
521
  left: null,
378
522
  right: null
379
523
  };
380
- #S;
381
- #C;
382
- #w;
383
- #T;
384
- #E;
385
- #D = null;
386
- #O = !1;
387
- #k = 1;
388
- #A = 0;
389
- #j = 0;
390
- #M = null;
391
- #N = !1;
392
- #P = !1;
393
- #F = null;
394
- #I = null;
395
- #L = null;
396
- #R = null;
524
+ #k;
525
+ #A;
526
+ #j;
527
+ #M;
528
+ #N;
529
+ #P = null;
530
+ #F = !1;
531
+ #I = 1;
532
+ #L = 0;
533
+ #R = 0;
397
534
  #z = null;
398
- #B = null;
399
- #V = null;
535
+ #B = !1;
536
+ #V = !1;
400
537
  #H = null;
401
- #U = !1;
402
- #W = 1;
403
- #G = !1;
538
+ #U = null;
539
+ #W = null;
540
+ #G = null;
404
541
  #K = null;
405
542
  #q = null;
406
543
  #J = null;
407
- #Y = null;
544
+ #Y = 0;
408
545
  #X = null;
409
- #Z;
546
+ #Z = !1;
547
+ #Q = 1;
548
+ #$ = !1;
549
+ #ee = null;
550
+ #te = null;
551
+ #ne = null;
552
+ #re = null;
553
+ #ie = null;
554
+ #ae = null;
555
+ #oe = null;
556
+ #se = /* @__PURE__ */ new Set();
557
+ #ce;
558
+ #le = null;
559
+ #ue = null;
560
+ #de = 0;
561
+ #fe = null;
562
+ #pe;
410
563
  debug = { setFlipProgress: (e, t) => {
411
- this.#M?.setFlipProgress(e, t);
564
+ this.#z?.setFlipProgress(e, t);
412
565
  } };
413
566
  constructor(e, t) {
414
- F(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 = S(t.source, {
567
+ Q(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = I(t.source, {
415
568
  frontCover: t.frontCover,
416
569
  backCover: t.backCover,
417
570
  pages: t.pages
418
571
  });
419
572
  let n = t.direction ?? "ltr";
420
- this.#a = n, this.#o = t.spreadMode ?? "cover", this.#s = t.curl ?? "cone", this.#l = t.clickToFlip ?? "edge", this.#u = t.clickZoneSize ?? 64, this.#p = t.singlePageThreshold ?? 640, this.#_ = t.startPage, typeof this.#t.open != "function" && this.#He(), this.#S = t.flipDuration ?? 800, this.#C = t.zoom?.enabled ?? !0, this.#w = t.zoom?.wheel ?? !0;
573
+ 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.#ce = t.controls ?? !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;
421
574
  let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
422
575
  1,
423
576
  2,
424
577
  4
425
578
  ]].sort((e, t) => e - t);
426
- this.#T = i.length > 0 ? i : null, this.#E = t.zoom?.max ?? 4;
427
- let a = this.#C && this.#T !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#l === "half";
428
- this.#d = this.#l !== "off" && a && o && t.clickFlipDelay !== 0, this.#f = this.#d ? t.clickFlipDelay ?? O : 0, this.#Z = this.#Se(t.renderer ?? "auto");
579
+ this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
580
+ let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
581
+ this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? H : 0, this.#pe = this.#Ve(t.renderer ?? "auto");
429
582
  }
430
583
  get ready() {
431
- return this.#Z;
584
+ return this.#pe;
432
585
  }
433
586
  getPageCount() {
434
587
  return this.#t.pageCount;
435
588
  }
436
589
  getPage() {
437
- return this.#b;
590
+ return this.#D;
591
+ }
592
+ get container() {
593
+ return this.#e;
594
+ }
595
+ getSpreads() {
596
+ return this.#T;
597
+ }
598
+ getSpreadIndex() {
599
+ return this.#E;
600
+ }
601
+ getDirection() {
602
+ return this.#a;
603
+ }
604
+ getSpreadMode() {
605
+ return this.#o;
606
+ }
607
+ isSinglePage() {
608
+ return this.#h;
609
+ }
610
+ setSpreadMode(e) {
611
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#$e(), this.#et());
612
+ }
613
+ toggleSpreadMode() {
614
+ this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
615
+ }
616
+ getResponsiveSpread() {
617
+ return this.#v;
618
+ }
619
+ isResponsiveSingle() {
620
+ return this.#_ && this.#o !== "single";
621
+ }
622
+ setResponsiveSpread(e) {
623
+ if (e !== this.#v) {
624
+ if (this.#v = e, e) {
625
+ let e = this.#z?.measure().containerWidth;
626
+ if (e === void 0) return;
627
+ this.#_ = !1, this.#Qe(e);
628
+ } else {
629
+ if (!this.#_) return;
630
+ this.#_ = !1, this.#$e();
631
+ }
632
+ this.#et();
633
+ }
634
+ }
635
+ getPageImage(e) {
636
+ return this.#dt(e);
637
+ }
638
+ canFlipNext() {
639
+ return this.#E + 1 < this.#T.length;
640
+ }
641
+ canFlipPrev() {
642
+ return this.#E > 0;
643
+ }
644
+ getMaxZoom() {
645
+ return this.#N;
646
+ }
647
+ canSearch() {
648
+ return typeof this.#t.getText == "function";
649
+ }
650
+ canDownload() {
651
+ return typeof this.#t.getDownload == "function";
652
+ }
653
+ isDocument() {
654
+ return typeof this.#t.getOutline == "function" || typeof this.#t.getText == "function";
655
+ }
656
+ canPrint() {
657
+ return typeof this.#t.getDownload == "function";
658
+ }
659
+ async print() {
660
+ let e = await this.getSourceFile(), t = this.#e.ownerDocument;
661
+ if (!e || !t) return !1;
662
+ let n = t.createElement("iframe");
663
+ 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) => {
664
+ let i = !1, a = (t) => {
665
+ i || (i = !0, setTimeout(() => {
666
+ n.remove(), e.revoke && URL.revokeObjectURL(e.url);
667
+ }, 6e4), r(t));
668
+ };
669
+ n.addEventListener("load", () => {
670
+ try {
671
+ let e = n.contentWindow;
672
+ if (!e) return a(!1);
673
+ e.focus(), e.print(), a(!0);
674
+ } catch {
675
+ a(!1);
676
+ }
677
+ }), n.addEventListener("error", () => a(!1)), t.body.appendChild(n);
678
+ });
679
+ }
680
+ canOutline() {
681
+ return typeof this.#t.getOutline == "function";
682
+ }
683
+ getOutline() {
684
+ if (!this.#oe) {
685
+ let e = this.#t.getOutline;
686
+ this.#oe = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
687
+ }
688
+ return this.#oe;
689
+ }
690
+ async getSourceFile() {
691
+ let e = this.#t.getDownload;
692
+ return typeof e == "function" ? await e.call(this.#t) ?? null : null;
693
+ }
694
+ async download() {
695
+ let e = await this.getSourceFile();
696
+ if (!e) return !1;
697
+ let t = this.#e.ownerDocument;
698
+ if (!t) return !1;
699
+ let n = t.createElement("a");
700
+ return n.href = e.url, n.download = e.filename, n.rel = "noopener", t.body.appendChild(n), n.click(), n.remove(), e.revoke && setTimeout(() => URL.revokeObjectURL(e.url), 1e4), !0;
701
+ }
702
+ async search(e, t = {}) {
703
+ let n = this.#t.getText, r = e.trim().toLowerCase();
704
+ if (typeof n != "function" || r === "") return [];
705
+ let i = t.limit ?? 50, a = [];
706
+ for (let e = 0; e < this.#t.pageCount && a.length < i; e++) {
707
+ let t;
708
+ try {
709
+ t = await n.call(this.#t, e);
710
+ } catch (t) {
711
+ this.#n.emit("sourceError", {
712
+ index: e,
713
+ error: t
714
+ });
715
+ continue;
716
+ }
717
+ let i = t.toLowerCase().indexOf(r);
718
+ i < 0 || a.push({
719
+ page: e,
720
+ excerpt: K(t, i, r.length)
721
+ });
722
+ }
723
+ return a;
438
724
  }
439
725
  flipNext() {
440
- this.#Q(() => this.#ne(this.#y + 1));
726
+ this.#me(1);
441
727
  }
442
728
  flipPrev() {
443
- this.#Q(() => this.#ne(this.#y - 1));
729
+ this.#me(-1);
730
+ }
731
+ #me(e) {
732
+ this.#he(() => this.#ye(this.#E + e));
444
733
  }
445
734
  flipTo(e) {
446
- let t = j(e, 0, Math.max(0, this.#t.pageCount - 1));
447
- this.#Q(() => this.#ne(this.#Ve(t)));
735
+ let t = J(e, 0, Math.max(0, this.#t.pageCount - 1));
736
+ this.#he(() => this.#ye(this.#pt(t)));
448
737
  }
449
- #Q(e) {
450
- this.#i.state === "idle" ? e() : this.#V ? (this.#$(), e()) : this.#B = e;
738
+ #he(e) {
739
+ this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ge(), e()) : this.#q = e;
451
740
  }
452
- #$() {
453
- let e = this.#V;
454
- e && (this.#V = null, this.#F !== null && (cancelAnimationFrame(this.#F), this.#F = null), this.#M?.setFlipProgress(e.toT, e.direction), e.onDone());
741
+ #ge() {
742
+ let e = this.#J;
743
+ e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
455
744
  }
456
- #ee() {
457
- let e = this.#B;
458
- e && (this.#B = null, e());
745
+ #_e() {
746
+ let e = this.#q;
747
+ if (!e) {
748
+ this.#st();
749
+ return;
750
+ }
751
+ this.#q = null, e();
459
752
  }
460
753
  getZoom() {
461
- return this.#k;
754
+ return this.#I;
462
755
  }
463
756
  setZoom(e, t) {
464
- if (!this.#M || !this.#C) return;
465
- let n = j(e, 1, this.#E), r = this.#M.measure(), i = t ?? {
757
+ if (!this.#z || !this.#A) return;
758
+ let n = J(e, 1, this.#N), r = this.#z.measure(), i = t ?? {
466
759
  x: r.containerWidth / 2,
467
760
  y: r.containerHeight / 2
468
- }, a = this.#k, o = n === 1 ? 0 : i.x - n / a * (i.x - this.#A), s = n === 1 ? 0 : i.y - n / a * (i.y - this.#j);
469
- [o, s] = this.#te(o, s, n, r.containerWidth, r.containerHeight), this.#k = n, this.#A = o, this.#j = s, this.#M.setViewTransform(n, o, s), this.#n.emit("zoomChanged", { scale: n });
761
+ }, a = this.#I, o = n === 1 ? 0 : i.x - n / a * (i.x - this.#L), s = n === 1 ? 0 : i.y - n / a * (i.y - this.#R);
762
+ [o, s] = this.#ve(o, s, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = o, this.#R = s, this.#z.setViewTransform(n, o, s), this.#it(), this.#n.emit("zoomChanged", { scale: n });
470
763
  }
471
764
  resetZoom() {
472
765
  this.setZoom(1);
473
766
  }
474
- #te(e, t, n, r, i) {
475
- return [j(e, r * (1 - n), 0), j(t, i * (1 - n), 0)];
767
+ #ve(e, t, n, r, i) {
768
+ return [J(e, r * (1 - n), 0), J(t, i * (1 - n), 0)];
476
769
  }
477
770
  on(e, t) {
478
771
  return this.#n.on(e, t);
479
772
  }
480
773
  destroy() {
481
- this.#P = !0, this.#F !== null && cancelAnimationFrame(this.#F), this.#V = null, this.#B = null, this.#he(), this.#D?.disconnect(), this.#X?.(), this.#J?.(), this.#Y?.(), this.#q?.(), this.#M?.destroy(), this.#M = null, this.#t.destroy(), this.#n.clear();
774
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ne(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#le?.(), this.#ae?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#fe !== null && clearTimeout(this.#fe), this.#de++, this.#ue?.destroy(), this.#ue = null, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
482
775
  }
483
- #ne(e) {
484
- if (e < 0 || e >= this.#v.length || e === this.#y || this.#i.send("flip") === null) return;
485
- let t = e > this.#y ? "forward" : "backward", n = this.#oe(e);
776
+ #ye(e) {
777
+ if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
778
+ let t = e > this.#E ? "forward" : "backward", n = this.#Ce(e);
486
779
  this.#n.emit("flipStart", {
487
- from: this.#b,
780
+ from: this.#D,
488
781
  to: n
489
- }), this.#re(e, t, n);
782
+ }), this.#be(e, t, n, ++this.#Y);
490
783
  }
491
- async #re(e, t, n) {
492
- let r = this.#v[e], i = r ? await this.#Re(r) : {
784
+ async #be(e, t, n, r) {
785
+ let i = this.#T[e], a = i ? await this.#ut(i) : {
493
786
  left: null,
494
787
  right: null
495
788
  };
496
- this.#M?.beginFlip(this.#x, i, t, {
497
- fill: this.#m,
498
- curl: this.#s,
499
- anchor: { y: this.#c }
500
- }), this.#ie(0, 1, t, () => this.#ae(e, n, i));
501
- }
502
- #ie(e, t, n, r) {
503
- let i = this.#ke() * Math.abs(t - e);
789
+ r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
790
+ fill: this.#h,
791
+ curl: this.#c,
792
+ anchor: { y: this.#l }
793
+ }), this.#xe(0, 1, t, () => this.#Se(e, n, a)));
794
+ }
795
+ #xe(e, t, n, r) {
796
+ let i = this.#Xe() * Math.abs(t - e);
504
797
  if (i <= 0) {
505
- this.#M?.setFlipProgress(t, n), r();
798
+ this.#z?.setFlipProgress(t, n), r();
506
799
  return;
507
800
  }
508
801
  let a = {
@@ -510,56 +803,56 @@ var w = class {
510
803
  direction: n,
511
804
  onDone: r
512
805
  };
513
- this.#V = a;
806
+ this.#J = a;
514
807
  let o = performance.now(), s = (c) => {
515
- if (this.#V !== a) return;
516
- let l = Math.min(1, (c - o) / i), u = this.#m ? N(l) : M(l);
517
- this.#M?.setFlipProgress(e + (t - e) * u, n), l < 1 ? this.#F = requestAnimationFrame(s) : (this.#F = null, this.#V = null, r());
808
+ if (this.#J !== a) return;
809
+ let l = Math.min(1, (c - o) / i), u = this.#h ? X(l) : Y(l);
810
+ this.#z?.setFlipProgress(e + (t - e) * u, n), l < 1 ? this.#H = requestAnimationFrame(s) : (this.#H = null, this.#J = null, r());
518
811
  };
519
- this.#F = requestAnimationFrame(s);
812
+ this.#H = requestAnimationFrame(s);
520
813
  }
521
- #ae(e, t, n) {
522
- let r = this.#v[e];
523
- this.#y = e, this.#b = t, this.#x = n, r && this.#Ne(r, n), this.#Be(), this.#i.send("settle"), this.#Oe(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#ee();
814
+ #Se(e, t, n) {
815
+ let r = this.#T[e];
816
+ this.#E = e, this.#D = t, this.#O = n, r && this.#tt(r, n), this.#ft(), this.#i.send("settle"), this.#Ye(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#_e();
524
817
  }
525
- #oe(e) {
526
- let t = this.#v[e];
527
- if (!t) return this.#b;
818
+ #Ce(e) {
819
+ let t = this.#T[e];
820
+ if (!t) return this.#D;
528
821
  let n = [t.left, t.right].filter((e) => e !== null);
529
- return n.length > 0 ? Math.min(...n) : this.#b;
822
+ return n.length > 0 ? Math.min(...n) : this.#D;
530
823
  }
531
- #se(e, t) {
532
- if (this.#U || !this.#M || this.#i.state !== "idle") return;
533
- if (this.#he(), this.#k > 1) {
824
+ #we(e, t) {
825
+ if (this.#Z || !this.#z) return;
826
+ if (this.#Ne(), this.#I > 1) {
534
827
  if (this.#i.send("panStart") === null) return;
535
- this.#H = {
536
- baseTx: this.#A,
537
- baseTy: this.#j
828
+ this.#X = {
829
+ baseTx: this.#L,
830
+ baseTy: this.#R
538
831
  };
539
832
  return;
540
833
  }
541
- let n = this.#e.getBoundingClientRect(), r = this.#pe(), i = {
542
- x: e - n.left - r.x,
543
- y: t - n.top - r.y
544
- };
545
- this.#R = i;
546
- let a = Math.min(r.width, r.height) * T;
547
- if (m(i, {
548
- width: r.width,
549
- height: r.height
550
- }, a) !== "corner") return;
551
- this.#c = j(i.y / r.height, 0, 1);
552
- let o = i.x > r.width / 2, s = this.#a === "rtl" ? !o : o, c = this.#y + (s ? 1 : -1);
553
- c < 0 || c >= this.#v.length || (this.#L = {
554
- direction: s ? "forward" : "backward",
555
- targetIndex: c,
556
- toPage: this.#oe(c),
557
- width: r.width
834
+ let n = this.#Ae(), r = this.#je(e, t);
835
+ if (this.#G = r, this.#i.state !== "idle") {
836
+ this.#W = null;
837
+ return;
838
+ }
839
+ let i = Math.min(n.width, n.height) * z;
840
+ if (_(r, {
841
+ width: n.width,
842
+ height: n.height
843
+ }, i) !== "corner") return;
844
+ this.#l = J(r.y / n.height, 0, 1);
845
+ let a = r.x > n.width / 2, o = this.#a === "rtl" ? !a : a, s = this.#E + (o ? 1 : -1);
846
+ s < 0 || s >= this.#T.length || (this.#W = {
847
+ direction: o ? "forward" : "backward",
848
+ targetIndex: s,
849
+ toPage: this.#Ce(s),
850
+ width: n.width
558
851
  });
559
852
  }
560
- #ce() {
561
- let e = this.#L;
562
- e && (this.#L = null, this.#i.send("grab") !== null && (this.#I = {
853
+ #Te() {
854
+ let e = this.#W;
855
+ e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
563
856
  direction: e.direction,
564
857
  targetIndex: e.targetIndex,
565
858
  toPage: e.toPage,
@@ -570,66 +863,66 @@ var w = class {
570
863
  width: e.width,
571
864
  t: 0
572
865
  }, this.#n.emit("flipStart", {
573
- from: this.#b,
866
+ from: this.#D,
574
867
  to: e.toPage
575
- }), this.#le(e.targetIndex, e.direction)));
868
+ }), this.#Ee(e.targetIndex, e.direction)));
576
869
  }
577
- async #le(e, t) {
578
- let n = this.#v[e], r = n ? await this.#Re(n) : {
870
+ async #Ee(e, t) {
871
+ let n = this.#T[e], r = n ? await this.#ut(n) : {
579
872
  left: null,
580
873
  right: null
581
874
  };
582
- this.#I?.targetIndex === e && (this.#I.toContent = r, this.#M?.beginFlip(this.#x, r, t, {
583
- fill: this.#m,
584
- curl: this.#s,
585
- anchor: { y: this.#c }
586
- }), this.#M?.setFlipProgress(this.#I.t, t));
587
- }
588
- #ue(e, t) {
589
- if (this.#U) return;
590
- if (this.#H) {
591
- if (!this.#M) return;
592
- let n = this.#M.measure(), [r, i] = this.#te(this.#H.baseTx + e, this.#H.baseTy + t, this.#k, n.containerWidth, n.containerHeight);
593
- this.#A = r, this.#j = i, this.#M.setViewTransform(this.#k, r, i);
875
+ this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
876
+ fill: this.#h,
877
+ curl: this.#c,
878
+ anchor: { y: this.#l }
879
+ }), this.#z?.setFlipProgress(this.#U.t, t));
880
+ }
881
+ #De(e, t) {
882
+ if (this.#Z) return;
883
+ if (this.#X) {
884
+ if (!this.#z) return;
885
+ let n = this.#z.measure(), [r, i] = this.#ve(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
886
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#it();
594
887
  return;
595
888
  }
596
- this.#L && Math.hypot(e, t) > D && this.#ce();
597
- let n = this.#I;
598
- n && (n.t = j((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#M?.setFlipProgress(n.t, n.direction));
599
- }
600
- #de(e) {
601
- if (this.#U) return;
602
- if (this.#H) {
603
- this.#H = null, this.#i.send("panEnd");
889
+ this.#W && Math.hypot(e, t) > V && this.#Te();
890
+ let n = this.#U;
891
+ n && (n.t = J((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
892
+ }
893
+ #Oe(e) {
894
+ if (this.#Z) return;
895
+ if (this.#X) {
896
+ this.#X = null, this.#i.send("panEnd");
604
897
  return;
605
898
  }
606
- let t = this.#I;
899
+ let t = this.#U;
607
900
  if (!t) {
608
- this.#L = null, this.#fe(e);
901
+ this.#W = null, this.#ke(e);
609
902
  return;
610
903
  }
611
- this.#I = null, this.#i.send("release");
904
+ this.#U = null, this.#i.send("release");
612
905
  let n = e.swipe && (t.direction === "forward" ? e.dx < 0 : e.dx > 0);
613
- t.t >= .5 || n ? this.#ie(t.t, 1, t.direction, () => this.#ae(t.targetIndex, t.toPage, t.toContent)) : this.#ie(t.t, 0, t.direction, () => this.#ge());
906
+ t.t >= .5 || n ? this.#xe(t.t, 1, t.direction, () => this.#Se(t.targetIndex, t.toPage, t.toContent)) : this.#xe(t.t, 0, t.direction, () => this.#Pe());
614
907
  }
615
- #fe(e) {
616
- if (this.#l === "off" || this.#k > 1 || !this.#R || Math.abs(e.dx) > D || Math.abs(e.dy) > D) return;
617
- let t = this.#me(this.#R);
908
+ #ke(e) {
909
+ if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > V || Math.abs(e.dy) > V) return;
910
+ let t = this.#Me(this.#G);
618
911
  if (!t) return;
619
912
  let n = t === "forward" ? 1 : -1;
620
- if (this.#y + n < 0 || this.#y + n >= this.#v.length) return;
621
- this.#c = j(this.#R.y / this.#pe().height, 0, 1);
622
- let r = () => this.#ne(this.#y + n);
623
- if (this.#he(), this.#f <= 0) {
624
- this.#Q(r);
913
+ if (this.#E + n < 0 || this.#E + n >= this.#T.length) return;
914
+ this.#l = J(this.#G.y / this.#Ae().height, 0, 1);
915
+ let r = () => this.#ye(this.#E + n);
916
+ if (this.#Ne(), this.#p <= 0) {
917
+ this.#he(r);
625
918
  return;
626
919
  }
627
- this.#z = setTimeout(() => {
628
- this.#z = null, this.#Q(r);
629
- }, this.#f);
920
+ this.#K = setTimeout(() => {
921
+ this.#K = null, this.#he(r);
922
+ }, this.#p);
630
923
  }
631
- #pe() {
632
- let e = this.#M.measure();
924
+ #Ae() {
925
+ let e = this.#z.measure();
633
926
  return e.content ?? e.book ?? {
634
927
  x: 0,
635
928
  y: 0,
@@ -637,136 +930,170 @@ var w = class {
637
930
  height: e.containerHeight
638
931
  };
639
932
  }
640
- #me(e) {
641
- if (!this.#M) return null;
642
- let t = this.#pe().width, n;
643
- if (n = this.#l === "half" ? e.x > t / 2 ? "right" : "left" : e.x <= this.#u ? "left" : e.x >= t - this.#u ? "right" : null, !n) return null;
933
+ #je(e, t) {
934
+ let n = this.#e.getBoundingClientRect(), r = this.#Ae();
935
+ return {
936
+ x: e - n.left - r.x,
937
+ y: t - n.top - r.y
938
+ };
939
+ }
940
+ #Me(e) {
941
+ if (!this.#z) return null;
942
+ let t = this.#Ae().width, n;
943
+ 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;
644
944
  let r = this.#a === "rtl" ? "left" : "right";
645
945
  return n === r ? "forward" : "backward";
646
946
  }
647
- #he() {
648
- this.#z !== null && (clearTimeout(this.#z), this.#z = null);
649
- }
650
- #ge() {
651
- let e = this.#v[this.#y];
652
- e && this.#Ne(e, this.#x), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#b }), this.#ee();
947
+ #Ne() {
948
+ this.#K !== null && (clearTimeout(this.#K), this.#K = null);
653
949
  }
654
- #_e() {
655
- if (this.#L = null, this.#he(), this.#I) {
656
- this.#I = null, this.#i.send("release"), this.#i.send("settle");
657
- let e = this.#v[this.#y];
658
- e && this.#Ne(e, this.#x);
659
- } else this.#H && (this.#H = null, this.#i.send("panEnd"));
660
- this.#U = !0, this.#W = this.#k;
661
- }
662
- #ve(e, t, n) {
663
- if (!this.#U) return;
950
+ #Pe() {
951
+ let e = this.#T[this.#E];
952
+ e && this.#tt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#_e();
953
+ }
954
+ #Fe() {
955
+ if (this.#W = null, this.#Ne(), this.#U) {
956
+ this.#U = null, this.#i.send("release"), this.#i.send("settle");
957
+ let e = this.#T[this.#E];
958
+ e && this.#tt(e, this.#O);
959
+ } else this.#X && (this.#X = null, this.#i.send("panEnd"));
960
+ this.#Z = !0, this.#Q = this.#I;
961
+ }
962
+ #Ie(e, t, n) {
963
+ if (!this.#Z) return;
664
964
  let r = this.#e.getBoundingClientRect();
665
- this.setZoom(this.#W * n, {
965
+ this.setZoom(this.#Q * n, {
666
966
  x: e - r.left,
667
967
  y: t - r.top
668
968
  });
669
969
  }
670
- #ye() {
671
- this.#U = !1;
970
+ #Le() {
971
+ this.#Z = !1;
972
+ }
973
+ #Re() {
974
+ if (!this.#S) return;
975
+ let e = (e) => e.preventDefault();
976
+ this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
672
977
  }
673
- #be() {
978
+ #ze() {
674
979
  let e = (e) => {
675
- if (!this.#w || !this.#C || !(e.ctrlKey || e.metaKey)) return;
980
+ if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
676
981
  e.preventDefault();
677
- let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * E);
678
- this.setZoom(this.#k * n, {
982
+ let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * B);
983
+ this.setZoom(this.#I * n, {
679
984
  x: e.clientX - t.left,
680
985
  y: e.clientY - t.top
681
986
  });
682
987
  };
683
- this.#e.addEventListener("wheel", e, { passive: !1 }), this.#J = () => this.#e.removeEventListener("wheel", e);
988
+ this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
684
989
  }
685
- #xe() {
990
+ #Be() {
686
991
  let e = (e) => {
687
- let t = this.#T;
688
- if (!this.#C || t === null) return;
689
- if (this.#k <= 1 && this.#l !== "off" && !this.#d) {
690
- let t = this.#e.getBoundingClientRect(), n = {
691
- x: e.clientX - t.left,
692
- y: e.clientY - t.top
693
- };
694
- if (this.#me(n) !== null) return;
992
+ let t = this.#M;
993
+ if (!this.#A || t === null || !this.#z) return;
994
+ if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
995
+ let t = this.#je(e.clientX, e.clientY);
996
+ if (this.#Me(t) !== null) return;
695
997
  }
696
- this.#he(), e.preventDefault();
697
- let n = t.find((e) => e > this.#k + 1e-6) ?? t[0] ?? this.#k, r = this.#e.getBoundingClientRect();
998
+ this.#Ne(), e.preventDefault();
999
+ let n = t.find((e) => e > this.#I + 1e-6) ?? t[0] ?? this.#I, r = this.#e.getBoundingClientRect();
698
1000
  this.setZoom(n, {
699
1001
  x: e.clientX - r.left,
700
1002
  y: e.clientY - r.top
701
1003
  });
702
1004
  };
703
- this.#e.addEventListener("dblclick", e), this.#Y = () => this.#e.removeEventListener("dblclick", e);
704
- }
705
- async #Se(e) {
706
- let t = x(e);
707
- typeof this.#t.open == "function" && (await this.#t.open(), this.#He()), this.#t.prefetch([this.#b]);
708
- let n = await t, r = await this.#Ce(n);
709
- this.#M = r, this.#t.onPageUpdate?.((e) => this.#Fe(e)), this.#je(r.measure().containerWidth);
710
- let i = new u({
711
- onStart: (e) => this.#se(e.x, e.y),
712
- onMove: (e) => this.#ue(e.dx, e.dy),
713
- onEnd: (e) => this.#de(e)
714
- }), a = new p({
715
- onPinchStart: () => this.#_e(),
716
- onPinchMove: (e) => this.#ve(e.centerX, e.centerY, e.scale),
717
- onPinchEnd: () => this.#ye()
1005
+ this.#e.addEventListener("dblclick", e), this.#ie = () => this.#e.removeEventListener("dblclick", e);
1006
+ }
1007
+ async #Ve(e) {
1008
+ let t = j(e);
1009
+ typeof this.#t.open == "function" && (await this.#t.open(), this.#mt()), this.#t.prefetch([this.#D]);
1010
+ let n = await t, r = await this.#He(n);
1011
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#rt(e)), this.#Qe(r.measure().containerWidth);
1012
+ let i = new p({
1013
+ onStart: (e) => this.#we(e.x, e.y),
1014
+ onMove: (e) => this.#De(e.dx, e.dy),
1015
+ onEnd: (e) => this.#Oe(e)
1016
+ }), a = new g({
1017
+ onPinchStart: () => this.#Fe(),
1018
+ onPinchMove: (e) => this.#Ie(e.centerX, e.centerY, e.scale),
1019
+ onPinchEnd: () => this.#Le()
718
1020
  });
719
- this.#q = d(this.#e, {
1021
+ this.#te = m(this.#e, {
720
1022
  pointer: i,
721
1023
  pinch: a
722
- }), this.#be(), this.#xe(), this.#Te(), this.#X = this.#Ee(), await this.#Me(), this.#Ie(), this.#Be(), this.#Oe(), this.#n.emit("ready");
1024
+ }), this.#ze(), this.#Be(), this.#Re(), this.#We(), this.#ae = this.#qe(), await this.#et(), this.#ct(), this.#ft(), this.#Ye(), this.#Ke(), await this.#Ge(), this.#n.emit("ready");
723
1025
  }
724
- async #Ce(e) {
1026
+ async #He(e) {
725
1027
  try {
726
1028
  return await e.mount(this.#e), e.onFatal?.(() => {
727
- this.#we();
1029
+ this.#Ue();
728
1030
  }), e;
729
1031
  } catch {
730
1032
  e.destroy();
731
- let t = await x("css");
732
- return await t.mount(this.#e), this.#N = !0, this.#n.emit("rendererFallback", {
1033
+ let t = await j("css");
1034
+ return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
733
1035
  from: "webgl2",
734
1036
  to: "css"
735
1037
  }), t;
736
1038
  }
737
1039
  }
738
- async #we() {
739
- if (this.#N || this.#P) return;
740
- this.#N = !0, this.#M?.destroy(), this.#M = null;
741
- let e = await x("css");
742
- if (this.#P) {
1040
+ async #Ue() {
1041
+ if (this.#B || this.#V) return;
1042
+ this.#B = !0, this.#z?.destroy(), this.#z = null;
1043
+ let e = await j("css");
1044
+ if (this.#V) {
743
1045
  e.destroy();
744
1046
  return;
745
1047
  }
746
- await e.mount(this.#e), this.#M = e, this.#je(e.measure().containerWidth), await this.#Me(), this.#n.emit("rendererFallback", {
1048
+ await e.mount(this.#e), this.#z = e, this.#Qe(e.measure().containerWidth), await this.#et(), this.#n.emit("rendererFallback", {
747
1049
  from: "webgl2",
748
1050
  to: "css"
749
1051
  });
750
1052
  }
751
- #Te() {
1053
+ #We() {
752
1054
  if (typeof matchMedia != "function") return;
753
1055
  let e = matchMedia("(prefers-reduced-motion: reduce)");
754
- this.#G = e.matches, e.addEventListener?.("change", (e) => {
755
- this.#G = e.matches;
1056
+ this.#$ = e.matches, e.addEventListener?.("change", (e) => {
1057
+ this.#$ = e.matches;
1058
+ });
1059
+ }
1060
+ async #Ge() {
1061
+ if (this.#ce === !1 || this.#V) return;
1062
+ let e = this.#e;
1063
+ if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1064
+ let { mountControls: t } = await import("./controls-BrPo8pKL.js");
1065
+ if (this.#V) return;
1066
+ let n = this.#ce === !0 ? {} : this.#ce;
1067
+ this.#le = t(this, e, n);
1068
+ } catch {}
1069
+ }
1070
+ #Ke() {
1071
+ if (!this.#x || globalThis.location === void 0) return;
1072
+ let e = globalThis;
1073
+ this.#C = w(e, (e) => {
1074
+ e !== this.#D && this.flipTo(e);
1075
+ }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1076
+ this.#C?.push(e);
756
1077
  });
757
1078
  }
758
- #Ee() {
1079
+ pageLink(e = this.#D) {
1080
+ let t = globalThis.location?.href ?? "";
1081
+ if (!t) return "";
1082
+ let n = new URL(t);
1083
+ return n.hash = C(n.hash, J(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1084
+ }
1085
+ #qe() {
759
1086
  let e = this.#e, t = e.ownerDocument;
760
1087
  if (!t || typeof e.setAttribute != "function") return null;
761
1088
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
762
- let n = (e) => this.#De(e);
1089
+ let n = (e) => this.#Je(e);
763
1090
  e.addEventListener("keydown", n);
764
1091
  let r = t.createElement("div");
765
- 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.#K = r, () => {
766
- e.removeEventListener("keydown", n), r.remove(), this.#K = null;
1092
+ 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, () => {
1093
+ e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
767
1094
  };
768
1095
  }
769
- #De(e) {
1096
+ #Je(e) {
770
1097
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
771
1098
  switch (e.key) {
772
1099
  case "ArrowRight":
@@ -782,62 +1109,136 @@ var w = class {
782
1109
  default: break;
783
1110
  }
784
1111
  }
785
- #Oe() {
786
- this.#K && (this.#K.textContent = `Page ${this.#b + 1} of ${this.#t.pageCount}`);
1112
+ #Ye() {
1113
+ this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
787
1114
  }
788
- #ke() {
789
- return this.#G ? 0 : this.#S * (this.#m ? k : 1);
1115
+ #Xe() {
1116
+ return this.#$ ? 0 : this.#k * (this.#h ? U : 1);
790
1117
  }
791
1118
  update() {
792
- !this.#M || this.#i.state !== "idle" || (this.#je(this.#M.measure().containerWidth), this.#Me());
1119
+ !this.#z || this.#i.state !== "idle" || (this.#Qe(this.#z.measure().containerWidth), this.#et());
793
1120
  }
794
- #Ae() {
795
- return this.#h || this.#o === "single" ? "single" : this.#o;
796
- }
797
- #je(e) {
798
- let r = n(e, this.#p);
799
- if (r === this.#h) return;
800
- this.#h = r;
801
- let i = this.#Ae();
802
- this.#m = i === "single", this.#v = t(this.#t.pageCount, {
1121
+ #Ze() {
1122
+ return this.#_ || this.#o === "single" ? "single" : this.#o;
1123
+ }
1124
+ #Qe(e) {
1125
+ let t = this.#v && a(e, this.#m);
1126
+ t !== this.#_ && (this.#_ = t, this.#$e());
1127
+ }
1128
+ #$e() {
1129
+ let e = this.#Ze(), t = e !== this.#g;
1130
+ this.#g = e, this.#h = e === "single", this.#T = i(this.#t.pageCount, {
803
1131
  direction: this.#a,
804
- mode: i
805
- }), this.#y = this.#Ve(this.#b);
1132
+ mode: e
1133
+ }), this.#E = this.#pt(this.#D), t && this.#n.emit("spreadChanged", {
1134
+ mode: e,
1135
+ singlePage: this.#h
1136
+ });
806
1137
  }
807
- async #Me() {
808
- let e = this.#v[this.#y];
809
- !e || !this.#M || (this.#x = await this.#Re(e), this.#Ne(e, this.#x));
1138
+ async #et() {
1139
+ let e = this.#T[this.#E];
1140
+ !e || !this.#z || (this.#O = await this.#ut(e), this.#tt(e, this.#O));
810
1141
  }
811
- #Ne(e, t) {
812
- this.#M?.renderSpread(e, t, { fill: this.#m }), this.#Pe();
1142
+ #tt(e, t) {
1143
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#nt(), this.#ue?.clear(), this.#it();
813
1144
  }
814
- #Pe() {
815
- let e = this.#M?.measure().book;
1145
+ #nt() {
1146
+ let e = this.#z?.measure().book;
816
1147
  if (!e || e.width <= 0 || e.height <= 0) return;
817
1148
  let t = (e.width / e.height).toFixed(4);
818
- t !== this.#g && (this.#g = t, this.#e.style.aspectRatio = t);
1149
+ t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1150
+ }
1151
+ #rt(e) {
1152
+ if (this.#i.state !== "idle") {
1153
+ this.#se.add(e);
1154
+ return;
1155
+ }
1156
+ let t = this.#T[this.#E];
1157
+ t && (t.left === e || t.right === e) && this.#et();
1158
+ }
1159
+ #it() {
1160
+ if (this.#fe !== null && clearTimeout(this.#fe), this.#I <= 1) {
1161
+ this.#ue?.clear(), this.#de++;
1162
+ return;
1163
+ }
1164
+ this.#fe = setTimeout(() => {
1165
+ this.#fe = null, this.#at();
1166
+ }, G);
1167
+ }
1168
+ async #at() {
1169
+ let e = this.#z, t = this.#T[this.#E];
1170
+ if (!e || !t || this.#I <= 1) return;
1171
+ let n = e.measure(), r = n.content ?? n.book;
1172
+ if (!r) return;
1173
+ let i = [], a = t.left === null || t.right === null, o = a ? r.width : r.width / 2;
1174
+ t.left !== null && i.push({
1175
+ index: t.left,
1176
+ rect: {
1177
+ ...r,
1178
+ width: o
1179
+ }
1180
+ }), t.right !== null && i.push({
1181
+ index: t.right,
1182
+ rect: {
1183
+ ...r,
1184
+ x: r.x + (a ? 0 : o),
1185
+ width: o
1186
+ }
1187
+ });
1188
+ let s = {
1189
+ scale: this.#I,
1190
+ tx: this.#L,
1191
+ ty: this.#R
1192
+ }, c = {
1193
+ x: 0,
1194
+ y: 0,
1195
+ width: n.containerWidth,
1196
+ height: n.containerHeight
1197
+ }, l = N(i, s, c), u = this.#ue?.shown ?? [];
1198
+ if (l.length === u.length && l.every((e, t) => P(e, u[t]))) return;
1199
+ let d = ++this.#de, f = await Promise.all(l.map(async (e) => {
1200
+ try {
1201
+ let t = await this.#t.get(e.index, e.request), n = e.dest.width / e.dest.height * 1, r = t.width / t.height;
1202
+ return Math.abs(n - r) / n > .02 ? null : {
1203
+ plan: e,
1204
+ content: t
1205
+ };
1206
+ } catch (t) {
1207
+ return this.#n.emit("sourceError", {
1208
+ index: e.index,
1209
+ error: t
1210
+ }), null;
1211
+ }
1212
+ }));
1213
+ if (d !== this.#de || this.#I <= 1) return;
1214
+ let p = f.filter((e) => e !== null);
1215
+ p.length !== 0 && (this.#ue ??= this.#ot(), this.#ue?.draw(p, s, c));
819
1216
  }
820
- #Fe(e) {
821
- if (this.#i.state !== "idle") return;
822
- let t = this.#v[this.#y];
823
- t && (t.left === e || t.right === e) && this.#Me();
1217
+ #ot() {
1218
+ let e = this.#e.ownerDocument;
1219
+ return !e || typeof this.#e.append != "function" ? null : new F(e, this.#e);
824
1220
  }
825
- #Ie() {
826
- typeof ResizeObserver > "u" || (this.#D = new ResizeObserver(() => this.#Le()), this.#D.observe(this.#e));
1221
+ #st() {
1222
+ if (this.#se.size === 0) return;
1223
+ let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#se.has(e));
1224
+ this.#se.clear(), t && this.#et();
827
1225
  }
828
- #Le() {
829
- this.#O || (this.#O = !0, requestAnimationFrame(() => {
830
- this.#O = !1, this.update();
1226
+ #ct() {
1227
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#lt()), this.#P.observe(this.#e));
1228
+ }
1229
+ #lt() {
1230
+ this.#F || (this.#F = !0, requestAnimationFrame(() => {
1231
+ this.#F = !1, this.update();
831
1232
  }));
832
1233
  }
833
- async #Re(e) {
834
- let [t, n] = await Promise.all([this.#ze(e.left), this.#ze(e.right)]);
1234
+ async #ut(e) {
1235
+ let [t, n] = await Promise.all([this.#dt(e.left), this.#dt(e.right)]);
835
1236
  return {
836
1237
  left: t,
837
1238
  right: n
838
1239
  };
839
1240
  }
840
- async #ze(e) {
1241
+ async #dt(e) {
841
1242
  if (e === null) return null;
842
1243
  try {
843
1244
  return await this.#t.get(e);
@@ -848,44 +1249,46 @@ var w = class {
848
1249
  }), null;
849
1250
  }
850
1251
  }
851
- #Be() {
852
- let { toMount: e } = this.#r.update(this.#y, this.#v.length), t = [];
1252
+ #ft() {
1253
+ let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
853
1254
  for (let n of e) {
854
- let e = this.#v[n];
1255
+ let e = this.#T[n];
855
1256
  e?.left != null && t.push(e.left), e?.right != null && t.push(e.right);
856
1257
  }
857
1258
  this.#t.prefetch(t);
858
1259
  }
859
- #Ve(e) {
860
- let t = this.#v.findIndex((t) => t.left === e || t.right === e);
1260
+ #pt(e) {
1261
+ let t = this.#T.findIndex((t) => t.left === e || t.right === e);
861
1262
  return t === -1 ? 0 : t;
862
1263
  }
863
- #He() {
1264
+ #mt() {
864
1265
  let e = this.#t.pageCount;
865
1266
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
866
- let n = this.#_;
867
- if (n !== void 0 && (!Number.isInteger(n) || n < 0 || n >= e)) throw Error(`Zine: startPage ${JSON.stringify(n)} is out of range for a ${e}-page book (valid 0..${e - 1}).`);
868
- let r = this.#Ae();
869
- this.#m = r === "single", this.#v = t(e, {
1267
+ let t = this.#b;
1268
+ 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}).`);
1269
+ let n = this.#Ze();
1270
+ this.#h = n === "single", this.#T = i(e, {
870
1271
  direction: this.#a,
871
- mode: r
872
- }), this.#b = j(n ?? 0, 0, e - 1), this.#y = this.#Ve(this.#b);
1272
+ mode: n
1273
+ });
1274
+ let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1275
+ this.#D = J(r ?? t ?? 0, 0, e - 1), this.#E = this.#pt(this.#D);
873
1276
  }
874
1277
  };
875
- function j(e, t, n) {
1278
+ function J(e, t, n) {
876
1279
  return e < t ? t : e > n ? n : e;
877
1280
  }
878
- function M(e) {
1281
+ function Y(e) {
879
1282
  return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
880
1283
  }
881
- function N(e) {
882
- return 1 - (1 - M(e)) ** 1.3;
1284
+ function X(e) {
1285
+ return 1 - (1 - Y(e)) ** 1.3;
883
1286
  }
884
- function P(e) {
1287
+ function Z(e) {
885
1288
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
886
1289
  }
887
- function F(t, n) {
888
- if (typeof t != "object" || !t || typeof t.appendChild != "function" || typeof t.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${P(t)}.`);
1290
+ function Q(t, n) {
1291
+ if (typeof t != "object" || !t || typeof t.appendChild != "function" || typeof t.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Z(t)}.`);
889
1292
  if (typeof n != "object" || !n) throw Error("Zine: an options object with a `source` is required.");
890
1293
  let r = n, i = r.source;
891
1294
  if (typeof i != "object" || !i || typeof i.get != "function" || typeof i.pageCount != "number") throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");
@@ -901,25 +1304,39 @@ function F(t, n) {
901
1304
  ].includes(s)) throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(s)}.`);
902
1305
  let c = r.curl;
903
1306
  if (c !== void 0 && !e.includes(c)) throw Error(`Zine: curl must be one of ${e.join(", ")}; got ${JSON.stringify(c)}.`);
904
- let l = r.spreadMode;
905
- if (l !== void 0 && ![
1307
+ for (let e of [
1308
+ "deepLink",
1309
+ "disableContextMenu",
1310
+ "responsiveSpread"
1311
+ ]) if (r[e] !== void 0 && typeof r[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Z(r[e])}.`);
1312
+ let l = r.controls;
1313
+ if (l !== void 0 && typeof l != "boolean" && (typeof l != "object" || !l)) throw Error(`Zine: controls must be a boolean or an options object; got ${Z(l)}.`);
1314
+ let u = l?.position;
1315
+ if (u !== void 0 && ![
1316
+ "top",
1317
+ "bottom",
1318
+ "left",
1319
+ "right"
1320
+ ].includes(u)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(u)}.`);
1321
+ let d = r.spreadMode;
1322
+ if (d !== void 0 && ![
906
1323
  "double",
907
1324
  "single",
908
1325
  "cover",
909
1326
  "book"
910
- ].includes(l)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(l)}.`);
1327
+ ].includes(d)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(d)}.`);
911
1328
  for (let e of ["frontCover", "backCover"]) {
912
1329
  let t = r[e];
913
1330
  if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
914
1331
  }
915
- let u = r.pages;
916
- if (u !== void 0 && (typeof u != "object" || !u || Array.isArray(u))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
917
- I(r.width, "width", 1), I(r.height, "height", 1), I(r.flipDuration, "flipDuration", 0), I(r.clickZoneSize, "clickZoneSize", 0), I(r.clickFlipDelay, "clickFlipDelay", 0), I(r.singlePageThreshold, "singlePageThreshold", 0), L(r.zoom), R(r.renderer);
1332
+ let f = r.pages;
1333
+ if (f !== void 0 && (typeof f != "object" || !f || Array.isArray(f))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1334
+ $(r.width, "width", 1), $(r.height, "height", 1), $(r.flipDuration, "flipDuration", 0), $(r.clickZoneSize, "clickZoneSize", 0), $(r.clickFlipDelay, "clickFlipDelay", 0), $(r.singlePageThreshold, "singlePageThreshold", 0), ee(r.zoom), te(r.renderer);
918
1335
  }
919
- function I(e, t, n) {
1336
+ function $(e, t, n) {
920
1337
  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)}.`);
921
1338
  }
922
- function L(e) {
1339
+ function ee(e) {
923
1340
  if (e === void 0) return;
924
1341
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
925
1342
  let t = e;
@@ -930,9 +1347,9 @@ function L(e) {
930
1347
  let e = t.doubleClick;
931
1348
  if (!Array.isArray(e) || e.some((e) => typeof e != "number" || !Number.isFinite(e) || e < 1)) throw Error("Zine: zoom.doubleClick must be false or an array of zoom levels >= 1, e.g. [1, 2, 4].");
932
1349
  }
933
- I(t.max, "zoom.max", 1);
1350
+ $(t.max, "zoom.max", 1);
934
1351
  }
935
- function R(e) {
1352
+ function te(e) {
936
1353
  if (e !== void 0) {
937
1354
  if (typeof e == "string") {
938
1355
  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.`);
@@ -947,7 +1364,7 @@ function R(e) {
947
1364
  }
948
1365
  //#endregion
949
1366
  //#region src/source/imageSource.ts
950
- var z = class {
1367
+ var ne = class {
951
1368
  pageCount;
952
1369
  fit;
953
1370
  #e;
@@ -984,6 +1401,6 @@ var z = class {
984
1401
  }
985
1402
  };
986
1403
  //#endregion
987
- export { e as CURL_TYPES, z as ImageSource, A as Zine };
1404
+ export { e as CURL_TYPES, r as DEFAULT_ITEMS, ne as ImageSource, q as Zine, t as defineControl, n as getControl };
988
1405
 
989
1406
  //# sourceMappingURL=index.js.map