flipbookengine 0.6.0 → 1.0.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +37 -3
  2. package/README.md +150 -11
  3. package/dist/components/App.d.ts +19 -0
  4. package/dist/components/HotspotLayer.d.ts +14 -0
  5. package/dist/components/NotesPanel.d.ts +14 -0
  6. package/dist/components/PluginPanels.d.ts +5 -0
  7. package/dist/components/SearchPanel.d.ts +11 -0
  8. package/dist/components/Toolbar.d.ts +6 -0
  9. package/dist/components/Viewer.d.ts +6 -0
  10. package/dist/core/LayoutManager.d.ts +1 -1
  11. package/dist/core/PdfRenderer.d.ts +23 -2
  12. package/dist/core-entry.d.ts +13 -0
  13. package/dist/core.d.ts +1 -0
  14. package/dist/embed.d.ts +80 -0
  15. package/dist/engine-Dt2Fn6O-.js +4060 -0
  16. package/dist/engine-Dt2Fn6O-.js.map +1 -0
  17. package/dist/engine.d.ts +111 -1
  18. package/dist/feature-Cicli9ie.js +17 -0
  19. package/dist/feature-Cicli9ie.js.map +1 -0
  20. package/dist/flipbook-engine.core.js +8 -0
  21. package/dist/flipbook-engine.core.js.map +1 -0
  22. package/dist/flipbook-engine.css +1 -1
  23. package/dist/flipbook-engine.iife.js +56 -47
  24. package/dist/flipbook-engine.iife.js.map +1 -1
  25. package/dist/flipbook-engine.js +9 -4
  26. package/dist/flipbook-engine.js.map +1 -1
  27. package/dist/flipbook-engine.plugins-annotations.js +14 -0
  28. package/dist/flipbook-engine.plugins-annotations.js.map +1 -0
  29. package/dist/flipbook-engine.plugins-bookmarks.js +16 -0
  30. package/dist/flipbook-engine.plugins-bookmarks.js.map +1 -0
  31. package/dist/flipbook-engine.plugins-deep-link.js +14 -0
  32. package/dist/flipbook-engine.plugins-deep-link.js.map +1 -0
  33. package/dist/flipbook-engine.plugins-hotspots.js +15 -0
  34. package/dist/flipbook-engine.plugins-hotspots.js.map +1 -0
  35. package/dist/flipbook-engine.plugins-notes.js +16 -0
  36. package/dist/flipbook-engine.plugins-notes.js.map +1 -0
  37. package/dist/flipbook-engine.plugins-search.js +15 -0
  38. package/dist/flipbook-engine.plugins-search.js.map +1 -0
  39. package/dist/flipbook-engine.plugins-share.js +13 -0
  40. package/dist/flipbook-engine.plugins-share.js.map +1 -0
  41. package/dist/flipbook-engine.plugins-toc.js +14 -0
  42. package/dist/flipbook-engine.plugins-toc.js.map +1 -0
  43. package/dist/flipbook-engine.plugins.js +5 -0
  44. package/dist/flipbook-engine.plugins.js.map +1 -0
  45. package/dist/flipbook-engine.react.js +1 -1
  46. package/dist/flipbook-engine.vue.js +1 -1
  47. package/dist/i18n/locales/en.d.ts +17 -0
  48. package/dist/i18n/locales/tr.d.ts +17 -0
  49. package/dist/i18n/service.d.ts +51 -0
  50. package/dist/index-BhTR2SK6.js +366 -0
  51. package/dist/index-BhTR2SK6.js.map +1 -0
  52. package/dist/index.d.ts +10 -1
  53. package/dist/model/annotations.d.ts +14 -0
  54. package/dist/model/hotspots.d.ts +40 -0
  55. package/dist/model/pages.d.ts +2 -0
  56. package/dist/model/search.d.ts +25 -0
  57. package/dist/plugins/annotations.d.ts +4 -0
  58. package/dist/plugins/bookmarks.d.ts +4 -0
  59. package/dist/plugins/deep-link.d.ts +4 -0
  60. package/dist/plugins/feature.d.ts +5 -0
  61. package/dist/plugins/hotspots.d.ts +4 -0
  62. package/dist/plugins/index.d.ts +65 -0
  63. package/dist/plugins/notes.d.ts +4 -0
  64. package/dist/plugins/search.d.ts +4 -0
  65. package/dist/plugins/share.d.ts +4 -0
  66. package/dist/plugins/toc.d.ts +4 -0
  67. package/dist/plugins-annotations.d.ts +1 -0
  68. package/dist/plugins-bookmarks.d.ts +1 -0
  69. package/dist/plugins-deep-link.d.ts +1 -0
  70. package/dist/plugins-hotspots.d.ts +1 -0
  71. package/dist/plugins-notes.d.ts +1 -0
  72. package/dist/plugins-search.d.ts +1 -0
  73. package/dist/plugins-share.d.ts +1 -0
  74. package/dist/plugins-toc.d.ts +1 -0
  75. package/dist/plugins.d.ts +1 -0
  76. package/dist/state/store.d.ts +19 -5
  77. package/dist/theme/theme.d.ts +16 -0
  78. package/dist/vue/index.d.ts +1 -1
  79. package/docs/api-reference.md +206 -0
  80. package/docs/frameworks.md +73 -0
  81. package/docs/getting-started.md +128 -0
  82. package/docs/i18n.md +47 -0
  83. package/docs/migration-0.4.0.md +24 -0
  84. package/docs/migration-0.5.0.md +25 -0
  85. package/docs/migration-1.0.0.md +59 -0
  86. package/docs/plugin-architecture.md +103 -0
  87. package/docs/release-checklist.md +37 -0
  88. package/docs/theming.md +61 -0
  89. package/package.json +165 -114
  90. package/dist/engine-MdZzt6R9.js +0 -3474
  91. package/dist/engine-MdZzt6R9.js.map +0 -1
@@ -1,3474 +0,0 @@
1
- var Se = Object.defineProperty;
2
- var Nt = (e) => {
3
- throw TypeError(e);
4
- };
5
- var Te = (e, t, s) => t in e ? Se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
6
- var v = (e, t, s) => Te(e, typeof t != "symbol" ? t + "" : t, s), yt = (e, t, s) => t.has(e) || Nt("Cannot " + s);
7
- var _ = (e, t, s) => (yt(e, t, "read from private field"), s ? s.call(e) : t.get(e)), rt = (e, t, s) => t.has(e) ? Nt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), at = (e, t, s, o) => (yt(e, t, "write to private field"), o ? o.call(e, s) : t.set(e, s), s), J = (e, t, s) => (yt(e, t, "access private method"), s);
8
- import * as Bt from "pdfjs-dist";
9
- var ke = Symbol.for("preact-signals");
10
- function It() {
11
- if (j > 1)
12
- j--;
13
- else {
14
- var e, t = !1;
15
- for (function() {
16
- var r = ct;
17
- for (ct = void 0; r !== void 0; )
18
- r.S.v === r.v && (r.S.i = r.i), r = r.o;
19
- }(); tt !== void 0; ) {
20
- var s = tt;
21
- for (tt = void 0, lt++; s !== void 0; ) {
22
- var o = s.u;
23
- if (s.u = void 0, s.f &= -3, !(8 & s.f) && ie(s)) try {
24
- s.c();
25
- } catch (r) {
26
- t || (e = r, t = !0);
27
- }
28
- s = o;
29
- }
30
- }
31
- if (lt = 0, j--, t) throw e;
32
- }
33
- }
34
- var A = void 0;
35
- function wt(e) {
36
- var t = A;
37
- A = void 0;
38
- try {
39
- return e();
40
- } finally {
41
- A = t;
42
- }
43
- }
44
- var tt = void 0, j = 0, lt = 0, _t = 0, ct = void 0, dt = 0;
45
- function ee(e) {
46
- if (A !== void 0) {
47
- var t = e.n;
48
- if (t === void 0 || t.t !== A)
49
- return t = { i: 0, S: e, p: A.s, n: void 0, t: A, e: void 0, x: void 0, r: t }, A.s !== void 0 && (A.s.n = t), A.s = t, e.n = t, 32 & A.f && e.S(t), t;
50
- if (t.i === -1)
51
- return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = A.s, t.n = void 0, A.s.n = t, A.s = t), t;
52
- }
53
- }
54
- function L(e, t) {
55
- this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
56
- }
57
- L.prototype.brand = ke;
58
- L.prototype.h = function() {
59
- return !0;
60
- };
61
- L.prototype.S = function(e) {
62
- var t = this, s = this.t;
63
- s !== e && e.e === void 0 && (e.x = s, this.t = e, s !== void 0 ? s.e = e : wt(function() {
64
- var o;
65
- (o = t.W) == null || o.call(t);
66
- }));
67
- };
68
- L.prototype.U = function(e) {
69
- var t = this;
70
- if (this.t !== void 0) {
71
- var s = e.e, o = e.x;
72
- s !== void 0 && (s.x = o, e.e = void 0), o !== void 0 && (o.e = s, e.x = void 0), e === this.t && (this.t = o, o === void 0 && wt(function() {
73
- var r;
74
- (r = t.Z) == null || r.call(t);
75
- }));
76
- }
77
- };
78
- L.prototype.subscribe = function(e) {
79
- var t = this;
80
- return G(function() {
81
- var s = t.value;
82
- wt(function() {
83
- return e(s);
84
- });
85
- }, { name: "sub" });
86
- };
87
- L.prototype.valueOf = function() {
88
- return this.value;
89
- };
90
- L.prototype.toString = function() {
91
- return this.value + "";
92
- };
93
- L.prototype.toJSON = function() {
94
- return this.value;
95
- };
96
- L.prototype.peek = function() {
97
- var e = this;
98
- return wt(function() {
99
- return e.value;
100
- });
101
- };
102
- Object.defineProperty(L.prototype, "value", { get: function() {
103
- var e = ee(this);
104
- return e !== void 0 && (e.i = this.i), this.v;
105
- }, set: function(e) {
106
- if (e !== this.v) {
107
- if (lt > 100) throw new Error("Cycle detected");
108
- (function(s) {
109
- j !== 0 && lt === 0 && s.l !== _t && (s.l = _t, ct = { S: s, v: s.v, i: s.i, o: ct });
110
- })(this), this.v = e, this.i++, dt++, j++;
111
- try {
112
- for (var t = this.t; t !== void 0; t = t.x) t.t.N();
113
- } finally {
114
- It();
115
- }
116
- }
117
- } });
118
- function D(e, t) {
119
- return new L(e, t);
120
- }
121
- function ie(e) {
122
- for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
123
- return !1;
124
- }
125
- function se(e) {
126
- for (var t = e.s; t !== void 0; t = t.n) {
127
- var s = t.S.n;
128
- if (s !== void 0 && (t.r = s), t.S.n = t, t.i = -1, t.n === void 0) {
129
- e.s = t;
130
- break;
131
- }
132
- }
133
- }
134
- function ne(e) {
135
- for (var t = e.s, s = void 0; t !== void 0; ) {
136
- var o = t.p;
137
- t.i === -1 ? (t.S.U(t), o !== void 0 && (o.n = t.n), t.n !== void 0 && (t.n.p = o)) : s = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = o;
138
- }
139
- e.s = s;
140
- }
141
- function q(e, t) {
142
- L.call(this, void 0, t), this.x = e, this.s = void 0, this.g = dt - 1, this.f = 4;
143
- }
144
- q.prototype = new L();
145
- q.prototype.h = function() {
146
- if (this.f &= -3, 1 & this.f) return !1;
147
- if ((36 & this.f) == 32 || (this.f &= -5, this.g === dt)) return !0;
148
- if (this.g = dt, this.f |= 1, this.i > 0 && !ie(this))
149
- return this.f &= -2, !0;
150
- var e = A;
151
- try {
152
- se(this), A = this;
153
- var t = this.x();
154
- (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
155
- } catch (s) {
156
- this.v = s, this.f |= 16, this.i++;
157
- }
158
- return A = e, ne(this), this.f &= -2, !0;
159
- };
160
- q.prototype.S = function(e) {
161
- if (this.t === void 0) {
162
- this.f |= 36;
163
- for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
164
- }
165
- L.prototype.S.call(this, e);
166
- };
167
- q.prototype.U = function(e) {
168
- if (this.t !== void 0 && (L.prototype.U.call(this, e), this.t === void 0)) {
169
- this.f &= -33;
170
- for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
171
- }
172
- };
173
- q.prototype.N = function() {
174
- if (!(2 & this.f)) {
175
- this.f |= 6;
176
- for (var e = this.t; e !== void 0; e = e.x) e.t.N();
177
- }
178
- };
179
- Object.defineProperty(q.prototype, "value", { get: function() {
180
- if (1 & this.f) throw new Error("Cycle detected");
181
- var e = ee(this);
182
- if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
183
- return this.v;
184
- } });
185
- function w(e, t) {
186
- return new q(e, t);
187
- }
188
- function oe(e) {
189
- var t = e.m;
190
- if (e.m = void 0, typeof t == "function") {
191
- j++;
192
- var s = A;
193
- A = void 0;
194
- try {
195
- t();
196
- } catch (o) {
197
- throw e.f &= -2, e.f |= 8, Lt(e), o;
198
- } finally {
199
- A = s, It();
200
- }
201
- }
202
- }
203
- function Lt(e) {
204
- for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
205
- e.x = void 0, e.s = void 0, oe(e);
206
- }
207
- function Ce(e) {
208
- if (A !== this) throw new Error("Out-of-order effect");
209
- ne(this), A = e, this.f &= -2, 8 & this.f && Lt(this), It();
210
- }
211
- function X(e, t) {
212
- this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t == null ? void 0 : t.name;
213
- }
214
- X.prototype.c = function() {
215
- var e = this.S();
216
- try {
217
- if (8 & this.f || this.x === void 0) return;
218
- var t = this.x();
219
- typeof t == "function" && (this.m = t);
220
- } finally {
221
- e();
222
- }
223
- };
224
- X.prototype.S = function() {
225
- if (1 & this.f) throw new Error("Cycle detected");
226
- this.f |= 1, this.f &= -9, oe(this), se(this), j++;
227
- var e = A;
228
- return A = this, Ce.bind(this, e);
229
- };
230
- X.prototype.N = function() {
231
- 2 & this.f || (this.f |= 2, this.u = tt, tt = this);
232
- };
233
- X.prototype.d = function() {
234
- this.f |= 8, 1 & this.f || Lt(this);
235
- };
236
- X.prototype.dispose = function() {
237
- this.d();
238
- };
239
- function G(e, t) {
240
- var s = new X(e, t);
241
- try {
242
- s.c();
243
- } catch (r) {
244
- throw s.d(), r;
245
- }
246
- var o = s.d.bind(s);
247
- return o[Symbol.dispose] = o, o;
248
- }
249
- var re = /* @__PURE__ */ Symbol.for("Serenity.initPropHook");
250
- function Ae(e) {
251
- return !!(e && typeof e.nodeType == "number");
252
- }
253
- function vt(e) {
254
- return typeof e == "string";
255
- }
256
- function ae(e) {
257
- return typeof e == "number";
258
- }
259
- function O(e) {
260
- return typeof e == "object" && e !== null;
261
- }
262
- function Ee(e) {
263
- return !!(e && e.isComponent);
264
- }
265
- function zt(e) {
266
- return O(e) && typeof e.length == "number" && typeof e.nodeType != "number";
267
- }
268
- function Me(e) {
269
- return typeof e == "function" && typeof e[re] == "function";
270
- }
271
- function it(e) {
272
- return e != null && typeof e != "boolean";
273
- }
274
- function st(e) {
275
- return Array.isArray(e) ? e.map(st).filter(Boolean).join(" ") : O(e) ? Symbol.iterator in e ? st(Array.from(e)) : Object.keys(e).filter((t) => e[t]).join(" ") : it(e) ? "" + e : "";
276
- }
277
- function De(e) {
278
- return e != null && typeof e == "object" && "current" in e;
279
- }
280
- function Ft(e, t) {
281
- De(e) ? e.current = t : typeof e == "function" && e(t);
282
- }
283
- function Re(e, t, s) {
284
- t = { ...t, children: s };
285
- const o = new e(t), r = o.render();
286
- return "ref" in t && Ft(t.ref, o), r;
287
- }
288
- var Ie = "http://www.w3.org/1998/Math/MathML", Le = /* @__PURE__ */ new Set(["math", "annotation", "annotation-xml", "maction", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics", "menclose", "mfenced"]), ze = /* @__PURE__ */ new Set([
289
- // "a",
290
- "animate",
291
- "animateMotion",
292
- "animateTransform",
293
- "circle",
294
- "clipPath",
295
- "defs",
296
- "desc",
297
- "ellipse",
298
- "feBlend",
299
- "feColorMatrix",
300
- "feComponentTransfer",
301
- "feComposite",
302
- "feConvolveMatrix",
303
- "feDiffuseLighting",
304
- "feDisplacementMap",
305
- "feDistantLight",
306
- "feDropShadow",
307
- "feFlood",
308
- "feFuncA",
309
- "feFuncB",
310
- "feFuncG",
311
- "feFuncR",
312
- "feGaussianBlur",
313
- "feImage",
314
- "feMerge",
315
- "feMergeNode",
316
- "feMorphology",
317
- "feOffset",
318
- "fePointLight",
319
- "feSpecularLighting",
320
- "feSpotLight",
321
- "feTile",
322
- "feTurbulence",
323
- "filter",
324
- "foreignObject",
325
- "g",
326
- "image",
327
- "line",
328
- "linearGradient",
329
- "marker",
330
- "mask",
331
- "metadata",
332
- "mpath",
333
- "path",
334
- "pattern",
335
- "polygon",
336
- "polyline",
337
- "radialGradient",
338
- "rect",
339
- // "script",
340
- "set",
341
- "stop",
342
- // "style",
343
- "svg",
344
- "switch",
345
- "symbol",
346
- "text",
347
- "textPath",
348
- // "title",
349
- "tref",
350
- "tspan",
351
- "use",
352
- "view"
353
- ]), Gt = /^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/, Fe = "http://www.w3.org/2000/svg", Ut = /* @__PURE__ */ Symbol.for("Serenity.jsxNamespaceURI");
354
- function Oe(e) {
355
- const t = globalThis[Ut];
356
- return arguments.length && (globalThis[Ut] = e), t;
357
- }
358
- var We = /* @__PURE__ */ Symbol.for("Serenity.jsxTypeKey"), $e = "ShadowRoot";
359
- function He(e) {
360
- return e != null && e[We] === $e;
361
- }
362
- var bt = /* @__PURE__ */ Symbol.for("Serenity.disposingListeners"), xt = /* @__PURE__ */ Symbol.for("Serenity.lifecycleRoot");
363
- function Ot() {
364
- return globalThis[bt] || (globalThis[bt] = /* @__PURE__ */ new WeakMap());
365
- }
366
- function Wt(e) {
367
- e && e.target && (!e.currentTarget || e.currentTarget === e.target) && Ne(e == null ? void 0 : e.target);
368
- }
369
- function Ne(e, t) {
370
- if (!e)
371
- return;
372
- const s = Ot();
373
- function o(r) {
374
- const h = s.get(r);
375
- if (h) {
376
- s.delete(r), r.removeEventListener("disposing", Wt);
377
- for (const u of h)
378
- try {
379
- u.callback(r);
380
- } catch {
381
- }
382
- }
383
- }
384
- o(e);
385
- }
386
- function kt(e, t, s) {
387
- if (!e || !t)
388
- return e;
389
- const o = Ot();
390
- let r = o.get(e);
391
- if (!r)
392
- return typeof e.addEventListener != "function" || (o.set(e, r = [{
393
- callback: t,
394
- regKey: s
395
- }]), e.addEventListener("disposing", Wt, { once: !0 })), e;
396
- const h = r.find((u) => u.callback === t);
397
- return h ? (h.regKey, e) : (r.push({ callback: t, regKey: s }), e);
398
- }
399
- function jt(e, t, s) {
400
- if (!e || !t)
401
- return e;
402
- const o = Ot(), r = o.get(e);
403
- if (r) {
404
- for (let h = r.length - 1; h >= 0; h--) {
405
- const u = r[h];
406
- t && t === u.callback && r.splice(h, 1);
407
- }
408
- r.length === 0 && (o.delete(e), typeof e.removeEventListener == "function" && e.removeEventListener("disposing", Wt));
409
- }
410
- return e;
411
- }
412
- function Be(...e) {
413
- if (e.length > 0) {
414
- const t = globalThis[xt] || null;
415
- return globalThis[xt] = e[0] || null, t;
416
- }
417
- return globalThis[xt] || null;
418
- }
419
- function Z(e) {
420
- return e != null && typeof e == "object" && typeof e.subscribe == "function" && typeof e.peek == "function" && "value" in e;
421
- }
422
- var ot, $, U, Ct, At, te, _e = (te = class {
423
- constructor(e, t, s) {
424
- rt(this, U);
425
- rt(this, ot);
426
- rt(this, $);
427
- this.signal = e, this.isInitial = !0, this.hasChanged = !1, this.lifecycleRoot = t, at(this, $, s);
428
- }
429
- get lifecycleNode() {
430
- return _(this, $);
431
- }
432
- get effectDisposer() {
433
- return _(this, ot);
434
- }
435
- set effectDisposer(e) {
436
- J(this, U, Ct).call(this), at(this, ot, e), J(this, U, At).call(this);
437
- }
438
- set lifecycleNode(e) {
439
- e !== _(this, $) && (J(this, U, Ct).call(this), at(this, $, e), J(this, U, At).call(this));
440
- }
441
- }, ot = new WeakMap(), $ = new WeakMap(), U = new WeakSet(), Ct = function() {
442
- var e;
443
- jt(_(this, $), this.effectDisposer), jt(_(this, $), (e = this.signal) == null ? void 0 : e.derivedDisposer);
444
- }, At = function() {
445
- var e;
446
- kt(_(this, $), this.effectDisposer), kt(_(this, $), (e = this.signal) == null ? void 0 : e.derivedDisposer);
447
- }, te);
448
- function nt(e, t, s) {
449
- const o = s != null && s.useLifecycleRoot ? Be() : void 0, r = new _e(e, o, s == null ? void 0 : s.lifecycleNode), h = r.signal.subscribe(function(u) {
450
- r.newValue = u, r.isInitial && (this != null && this.dispose) && (r.effectDisposer = this.dispose.bind(this)), r.hasChanged = !r.isInitial && r.prevValue !== r.newValue;
451
- try {
452
- t(r);
453
- } finally {
454
- r.prevValue = r.newValue, r.isInitial = !1;
455
- }
456
- });
457
- return h && !r.effectDisposer && (r.effectDisposer = h), r.effectDisposer;
458
- }
459
- function Vt(e, t) {
460
- e instanceof window.HTMLTemplateElement ? e.content.appendChild(t) : e.appendChild(t);
461
- }
462
- var Pt = 0, Et = "__domwisefrag_";
463
- function he(e) {
464
- return e instanceof Comment && e.data.startsWith(Et);
465
- }
466
- function Zt(e) {
467
- return e instanceof DocumentFragment && he(e.firstChild);
468
- }
469
- function Ge(e, t) {
470
- var s;
471
- typeof e.replaceWith == "function" ? e.replaceWith(t) : (s = e.parentNode) == null || s.replaceChild(t, e);
472
- }
473
- function qt(e) {
474
- return e instanceof DocumentFragment ? (++Pt, e.prepend(document.createComment(Et + Pt)), e.append(document.createComment(Et + Pt)), e) : e instanceof Node ? e : it(e) ? document.createTextNode(e) : document.createComment("");
475
- }
476
- function Ue(e, t) {
477
- let s;
478
- nt(t, (o) => {
479
- var u;
480
- if (o.isInitial) {
481
- s = qt(o.newValue);
482
- let p = Zt(s) ? s.firstChild : s;
483
- ut(e, s), o.lifecycleNode = (s = p) ?? e;
484
- return;
485
- }
486
- if (!o.hasChanged)
487
- return;
488
- const r = qt(o.newValue);
489
- if (he(s)) {
490
- let p;
491
- for (; (p = s.nextSibling) && ((u = p.parentNode) == null || u.removeChild(p), !(p instanceof Comment && p.data === s.data)); )
492
- ;
493
- }
494
- let h = Zt(r) ? r.firstChild : r;
495
- Ge(s, r), o.lifecycleNode = (s = h) ?? e;
496
- });
497
- }
498
- function ut(e, t) {
499
- if (it(t))
500
- if (zt(t))
501
- for (const s of [...t])
502
- ut(e, s);
503
- else if (vt(t) || ae(t))
504
- Vt(e, document.createTextNode(t));
505
- else if (Ae(t))
506
- Vt(e, t);
507
- else if (He(t)) {
508
- const s = e.attachShadow(t.attr);
509
- ut(s, t.children), Ft(t.ref, s);
510
- } else Z(t) && Ue(e, t);
511
- }
512
- function le(e) {
513
- return e == null || (zt(e) ? e = Array.from(e).map((t) => Z(t) ? t.peek() : t) : O(e) && (e = { ...e }, Object.entries(e).forEach(([t, s]) => {
514
- Z(s) && (e[t] = s.peek());
515
- }))), e;
516
- }
517
- function je(e, t) {
518
- if (t == null || t === !1 || t === !0)
519
- return;
520
- t = le(t);
521
- const s = (st(t) ?? "").split(" ");
522
- for (let o of s)
523
- o && e.classList.remove(o);
524
- }
525
- function Ve(e, t, s) {
526
- if (t == null || t === !1) {
527
- je(e, s);
528
- return;
529
- }
530
- s = le(s), zt(t) ? t = Array.from(t).map((o) => {
531
- let r = o;
532
- return Z(o) && nt(o, (h) => {
533
- if (h.isInitial) {
534
- r = h.newValue;
535
- return;
536
- }
537
- St(e, h.newValue, h.prevValue);
538
- }, {
539
- lifecycleNode: e
540
- }), r;
541
- }) : O(t) && (t = { ...t }, Object.entries(t).forEach(([o, r]) => {
542
- Z(r) && nt(r, (h) => {
543
- if (h.isInitial) {
544
- t[o] = h.newValue;
545
- return;
546
- }
547
- St(e, !!h.newValue && o, !!h.prevValue && o);
548
- }, {
549
- lifecycleNode: e
550
- });
551
- })), St(e, t, s);
552
- }
553
- function St(e, t, s) {
554
- const o = (st(t) ?? "").split(" ");
555
- if (s) {
556
- const r = (st(s) ?? "").split(" ");
557
- for (let h of r)
558
- h && !o.includes(h) && e.classList.remove(h);
559
- }
560
- for (let r of o)
561
- r && e.classList.add(r);
562
- }
563
- function Ze(e, t) {
564
- return e + t.charAt(0).toUpperCase() + t.substring(1);
565
- }
566
- var qe = /* @__PURE__ */ (() => {
567
- let e = {
568
- animationIterationCount: 0,
569
- borderImageOutset: 0,
570
- borderImageSlice: 0,
571
- borderImageWidth: 0,
572
- boxFlex: 0,
573
- boxFlexGroup: 0,
574
- boxOrdinalGroup: 0,
575
- columnCount: 0,
576
- columns: 0,
577
- flex: 0,
578
- flexGrow: 0,
579
- flexPositive: 0,
580
- flexShrink: 0,
581
- flexNegative: 0,
582
- flexOrder: 0,
583
- gridArea: 0,
584
- gridRow: 0,
585
- gridRowEnd: 0,
586
- gridRowSpan: 0,
587
- gridRowStart: 0,
588
- gridColumn: 0,
589
- gridColumnEnd: 0,
590
- gridColumnSpan: 0,
591
- gridColumnStart: 0,
592
- fontWeight: 0,
593
- lineClamp: 0,
594
- lineHeight: 0,
595
- opacity: 0,
596
- order: 0,
597
- orphans: 0,
598
- tabSize: 0,
599
- widows: 0,
600
- zIndex: 0,
601
- zoom: 0,
602
- // SVG-related properties
603
- fillOpacity: 0,
604
- floodOpacity: 0,
605
- stopOpacity: 0,
606
- strokeDasharray: 0,
607
- strokeDashoffset: 0,
608
- strokeMiterlimit: 0,
609
- strokeOpacity: 0,
610
- strokeWidth: 0
611
- };
612
- const t = ["Webkit", "ms", "Moz", "O"];
613
- return Object.keys(e).forEach((s) => {
614
- t.forEach((o) => {
615
- e[Ze(o, s)] = 0;
616
- });
617
- }), e;
618
- })();
619
- function Mt(e, t, s) {
620
- t.indexOf("-") === 0 ? e.style.setProperty(t, s) : ae(s) && qe[t] !== 0 ? e.style[t] = s + "px" : e.style[t] = s;
621
- }
622
- function Xt(e, t) {
623
- if (!(t == null || t === !1 || t === !0)) {
624
- if (vt(t)) {
625
- e.removeAttribute("style");
626
- return;
627
- }
628
- O(t) && Object.keys(t).forEach((s) => {
629
- Mt(e, s, "");
630
- });
631
- }
632
- }
633
- function Xe(e, t, s) {
634
- if (t == null || t === !1 || t === !0) {
635
- Xt(e, s);
636
- return;
637
- }
638
- if (vt(t)) {
639
- e.setAttribute("style", t);
640
- return;
641
- }
642
- if (O(t)) {
643
- O(s) ? (t = { ...t }, Object.keys(s).forEach((o) => {
644
- o in t || (t[o] = "");
645
- })) : Xt(e, s), Object.entries(t).forEach(([o, r]) => {
646
- Z(r) ? nt(r, (h) => Mt(e, o, h.newValue), {
647
- lifecycleNode: e
648
- }) : Mt(e, o, r);
649
- });
650
- return;
651
- }
652
- }
653
- var Ye = "http://www.w3.org/1999/xlink", Qe = "http://www.w3.org/XML/1998/namespace";
654
- function ht(e, t) {
655
- return e.replace(/[A-Z]/g, (s) => t + s.toLowerCase());
656
- }
657
- var Ke = /* @__PURE__ */ new Map([
658
- ["autoComplete", "autocomplete"],
659
- ["autoFocus", "autofocus"],
660
- ["className", "class"],
661
- ["colSpan", "colspan"],
662
- ["contentEditable", "contenteditable"],
663
- ["formNoValidate", "formnovalidate"],
664
- ["htmlFor", "for"],
665
- ["innerText", "textContent"],
666
- ["minLength", "minlength"],
667
- ["maxLength", "maxlength"],
668
- ["readOnly", "readonly"],
669
- ["reffererPolicy", "referrerpolicy"],
670
- ["rowSpan", "rowspan"],
671
- ["spellCheck", "spellcheck"],
672
- ["tabIndex", "tabindex"],
673
- ["onDoubleClick", "onDblClick"],
674
- ["onDoubleClickCapture", "onDblClickCapture"]
675
- ]);
676
- function Yt(e, t, s, o) {
677
- switch (t) {
678
- case "dataset":
679
- o != null && Object.entries(o).forEach(([h, u]) => {
680
- u != null && delete e.dataset[h];
681
- }), Object.entries(s).forEach(([h, u]) => {
682
- u != null && (e.dataset[h] = u);
683
- });
684
- return;
685
- case "textContent":
686
- it(s) ? e[t] = s : it(o) && (e[t] = "");
687
- return;
688
- case "dangerouslySetInnerHTML":
689
- O(s) ? e.innerHTML = s.__html : O(o) && (e.innerHTML = "");
690
- return;
691
- case "value":
692
- if (s == null) {
693
- o != null && (e[t] = null);
694
- return;
695
- } else {
696
- if (e instanceof window.HTMLSelectElement)
697
- return;
698
- if (e instanceof window.HTMLTextAreaElement) {
699
- e.value = s;
700
- return;
701
- }
702
- }
703
- break;
704
- case "class":
705
- Ve(e, s, o);
706
- return;
707
- case "spellcheck":
708
- e.spellcheck = s === "" || s === !0 || s === "true" ? !0 : s === !1 || s === "false" ? !1 : s;
709
- return;
710
- case "draggable":
711
- s === !1 || s === "false" ? s = "false" : s === "" ? s = null : (s === !0 || s === "true") && (s = "true");
712
- break;
713
- case "contenteditable":
714
- s === !1 ? s = "false" : (s === "" || s === !0) && (s = "true");
715
- break;
716
- case "ref":
717
- case "namespaceURI":
718
- return;
719
- case "style":
720
- Xe(e, s, o);
721
- return;
722
- case "on":
723
- case "onCapture":
724
- const r = t === "onCapture";
725
- o != null && Object.entries(o).forEach(([h, u]) => {
726
- (s == null || s[h] !== u) && e.removeEventListener(h, u, r);
727
- }), Object.entries(s).forEach(([h, u]) => {
728
- (o == null || o[h] !== u) && e.addEventListener(h, u, r);
729
- });
730
- return;
731
- case "xlinkActuate":
732
- case "xlinkArcrole":
733
- case "xlinkHref":
734
- case "xlinkRole":
735
- case "xlinkShow":
736
- case "xlinkTitle":
737
- case "xlinkType":
738
- e.setAttributeNS(Ye, ht(t, ":"), s);
739
- return;
740
- case "xmlnsXlink":
741
- e.setAttribute("xmlns:xlink", s);
742
- return;
743
- case "xmlBase":
744
- case "xmlLang":
745
- case "xmlSpace":
746
- e.setAttributeNS(Qe, ht(t, ":"), s);
747
- return;
748
- }
749
- if (typeof s == "function") {
750
- if (t[0] === "o" && t[1] === "n") {
751
- if (o != null && o === s)
752
- return;
753
- let r = t.toLowerCase();
754
- const h = r.endsWith("capture");
755
- let u;
756
- !h && (e[r] === null || o != null && e[r] === o) ? (e[r] = s, kt(e, ti.bind(e, r))) : h ? (u = r.substring(2, r.length - 7), o != null && e.removeEventListener(u, o, !0), e.addEventListener(u, s, !0)) : (r in window ? u = r.substring(2) : u = r[2] + t.slice(3), o != null && e.removeEventListener(u, o), e.addEventListener(u, s));
757
- } else
758
- console.warn(`A function was provided for JSX ${e.tagName} element ${t} which does not start with "on":`, s, e.tagName);
759
- return;
760
- }
761
- if (O(o)) {
762
- if (o === s)
763
- return;
764
- delete e[t];
765
- }
766
- if (o === !0) {
767
- if (o === s)
768
- return;
769
- e.removeAttribute(t);
770
- }
771
- if (o !== !1 && o != null) {
772
- if (o === s)
773
- return;
774
- e instanceof SVGElement && !Gt.test(t) ? e.removeAttributeNS(ht(t, "-"), s) : e.removeAttribute(t);
775
- }
776
- if (O(s)) {
777
- e[t] = s;
778
- return;
779
- }
780
- if (s === !0) {
781
- e.setAttribute(t, "");
782
- return;
783
- }
784
- s !== !1 && s != null && (e instanceof SVGElement && !Gt.test(t) ? e.setAttribute(ht(t, "-"), s) : e.setAttribute(t, s));
785
- }
786
- function Je(e, t) {
787
- for (let [s, o] of Object.entries(t))
788
- s = Ke.get(s) ?? s, Z(o) ? nt(o, (r) => Yt(e, s, r.newValue, r.prevValue), {
789
- lifecycleNode: e
790
- }) : Me(o) ? o[re](e, s) : Yt(e, s, o);
791
- return e;
792
- }
793
- function ti(e) {
794
- this[e] = null;
795
- }
796
- function d(e, t) {
797
- let { children: s, ...o } = t || {}, r = o.namespaceURI;
798
- r || (ze.has(e) ? r = Fe : Le.has(e) ? r = Ie : r = Oe());
799
- let h;
800
- if (vt(e)) {
801
- if (h = r ? document.createElementNS(r, e) : document.createElement(e), Je(h, o), ut(h, s), h instanceof window.HTMLSelectElement && o.value != null)
802
- if (o.multiple === !0 && Array.isArray(o.value)) {
803
- const u = o.value.map((p) => String(p));
804
- h.querySelectorAll("option").forEach((p) => p.selected = u.includes(p.value));
805
- } else
806
- h.value = o.value;
807
- Ft(o.ref, h);
808
- } else if (typeof e == "function")
809
- O(e.defaultProps) && (o = { ...e.defaultProps, ...o }), h = Ee(e) ? Re(e, o, s) : e({ ...o, children: s });
810
- else
811
- throw new TypeError(`Invalid JSX element type: ${e}`);
812
- return h;
813
- }
814
- var ei = /* @__PURE__ */ Symbol.for("preact-signals");
815
- function $t() {
816
- if (V > 1)
817
- V--;
818
- else {
819
- var e, t = !1;
820
- for (function() {
821
- var r = pt;
822
- for (pt = void 0; r !== void 0; )
823
- r.S.v === r.v && (r.S.i = r.i), r = r.o;
824
- }(); et !== void 0; ) {
825
- var s = et;
826
- for (et = void 0, gt++; s !== void 0; ) {
827
- var o = s.u;
828
- if (s.u = void 0, s.f &= -3, !(8 & s.f) && ue(s)) try {
829
- s.c();
830
- } catch (r) {
831
- t || (e = r, t = !0);
832
- }
833
- s = o;
834
- }
835
- }
836
- if (gt = 0, V--, t) throw e;
837
- }
838
- }
839
- var P = void 0;
840
- function ce(e) {
841
- var t = P;
842
- P = void 0;
843
- try {
844
- return e();
845
- } finally {
846
- P = t;
847
- }
848
- }
849
- var et = void 0, V = 0, gt = 0, Qt = 0, pt = void 0, ft = 0;
850
- function de(e) {
851
- if (P !== void 0) {
852
- var t = e.n;
853
- if (t === void 0 || t.t !== P)
854
- return t = { i: 0, S: e, p: P.s, n: void 0, t: P, e: void 0, x: void 0, r: t }, P.s !== void 0 && (P.s.n = t), P.s = t, e.n = t, 32 & P.f && e.S(t), t;
855
- if (t.i === -1)
856
- return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = P.s, t.n = void 0, P.s.n = t, P.s = t), t;
857
- }
858
- }
859
- function z(e, t) {
860
- this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
861
- }
862
- z.prototype.brand = ei;
863
- z.prototype.h = function() {
864
- return !0;
865
- };
866
- z.prototype.S = function(e) {
867
- var t = this, s = this.t;
868
- s !== e && e.e === void 0 && (e.x = s, this.t = e, s !== void 0 ? s.e = e : ce(function() {
869
- var o;
870
- (o = t.W) == null || o.call(t);
871
- }));
872
- };
873
- z.prototype.U = function(e) {
874
- var t = this;
875
- if (this.t !== void 0) {
876
- var s = e.e, o = e.x;
877
- s !== void 0 && (s.x = o, e.e = void 0), o !== void 0 && (o.e = s, e.x = void 0), e === this.t && (this.t = o, o === void 0 && ce(function() {
878
- var r;
879
- (r = t.Z) == null || r.call(t);
880
- }));
881
- }
882
- };
883
- z.prototype.subscribe = function(e) {
884
- var t = this;
885
- return si(function() {
886
- var s = t.value, o = P;
887
- P = void 0;
888
- try {
889
- e(s);
890
- } finally {
891
- P = o;
892
- }
893
- }, { name: "sub" });
894
- };
895
- z.prototype.valueOf = function() {
896
- return this.value;
897
- };
898
- z.prototype.toString = function() {
899
- return this.value + "";
900
- };
901
- z.prototype.toJSON = function() {
902
- return this.value;
903
- };
904
- z.prototype.peek = function() {
905
- var e = P;
906
- P = void 0;
907
- try {
908
- return this.value;
909
- } finally {
910
- P = e;
911
- }
912
- };
913
- Object.defineProperty(z.prototype, "value", { get: function() {
914
- var e = de(this);
915
- return e !== void 0 && (e.i = this.i), this.v;
916
- }, set: function(e) {
917
- if (e !== this.v) {
918
- if (gt > 100) throw new Error("Cycle detected");
919
- (function(s) {
920
- V !== 0 && gt === 0 && s.l !== Qt && (s.l = Qt, pt = { S: s, v: s.v, i: s.i, o: pt });
921
- })(this), this.v = e, this.i++, ft++, V++;
922
- try {
923
- for (var t = this.t; t !== void 0; t = t.x) t.t.N();
924
- } finally {
925
- $t();
926
- }
927
- }
928
- } });
929
- function ue(e) {
930
- for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
931
- return !1;
932
- }
933
- function ge(e) {
934
- for (var t = e.s; t !== void 0; t = t.n) {
935
- var s = t.S.n;
936
- if (s !== void 0 && (t.r = s), t.S.n = t, t.i = -1, t.n === void 0) {
937
- e.s = t;
938
- break;
939
- }
940
- }
941
- }
942
- function pe(e) {
943
- for (var t = e.s, s = void 0; t !== void 0; ) {
944
- var o = t.p;
945
- t.i === -1 ? (t.S.U(t), o !== void 0 && (o.n = t.n), t.n !== void 0 && (t.n.p = o)) : s = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = o;
946
- }
947
- e.s = s;
948
- }
949
- function Y(e, t) {
950
- z.call(this, void 0), this.x = e, this.s = void 0, this.g = ft - 1, this.f = 4, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
951
- }
952
- Y.prototype = new z();
953
- Y.prototype.h = function() {
954
- if (this.f &= -3, 1 & this.f) return !1;
955
- if ((36 & this.f) == 32 || (this.f &= -5, this.g === ft)) return !0;
956
- if (this.g = ft, this.f |= 1, this.i > 0 && !ue(this))
957
- return this.f &= -2, !0;
958
- var e = P;
959
- try {
960
- ge(this), P = this;
961
- var t = this.x();
962
- (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
963
- } catch (s) {
964
- this.v = s, this.f |= 16, this.i++;
965
- }
966
- return P = e, pe(this), this.f &= -2, !0;
967
- };
968
- Y.prototype.S = function(e) {
969
- if (this.t === void 0) {
970
- this.f |= 36;
971
- for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
972
- }
973
- z.prototype.S.call(this, e);
974
- };
975
- Y.prototype.U = function(e) {
976
- if (this.t !== void 0 && (z.prototype.U.call(this, e), this.t === void 0)) {
977
- this.f &= -33;
978
- for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
979
- }
980
- };
981
- Y.prototype.N = function() {
982
- if (!(2 & this.f)) {
983
- this.f |= 6;
984
- for (var e = this.t; e !== void 0; e = e.x) e.t.N();
985
- }
986
- };
987
- Object.defineProperty(Y.prototype, "value", { get: function() {
988
- if (1 & this.f) throw new Error("Cycle detected");
989
- var e = de(this);
990
- if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
991
- return this.v;
992
- } });
993
- function fe(e) {
994
- var t = e.m;
995
- if (e.m = void 0, typeof t == "function") {
996
- V++;
997
- var s = P;
998
- P = void 0;
999
- try {
1000
- t();
1001
- } catch (o) {
1002
- throw e.f &= -2, e.f |= 8, Ht(e), o;
1003
- } finally {
1004
- P = s, $t();
1005
- }
1006
- }
1007
- }
1008
- function Ht(e) {
1009
- for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
1010
- e.x = void 0, e.s = void 0, fe(e);
1011
- }
1012
- function ii(e) {
1013
- if (P !== this) throw new Error("Out-of-order effect");
1014
- pe(this), P = e, this.f &= -2, 8 & this.f && Ht(this), $t();
1015
- }
1016
- function Q(e, t) {
1017
- this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t == null ? void 0 : t.name;
1018
- }
1019
- Q.prototype.c = function() {
1020
- var e = this.S();
1021
- try {
1022
- if (8 & this.f || this.x === void 0) return;
1023
- var t = this.x();
1024
- typeof t == "function" && (this.m = t);
1025
- } finally {
1026
- e();
1027
- }
1028
- };
1029
- Q.prototype.S = function() {
1030
- if (1 & this.f) throw new Error("Cycle detected");
1031
- this.f |= 1, this.f &= -9, fe(this), ge(this), V++;
1032
- var e = P;
1033
- return P = this, ii.bind(this, e);
1034
- };
1035
- Q.prototype.N = function() {
1036
- 2 & this.f || (this.f |= 2, this.u = et, et = this);
1037
- };
1038
- Q.prototype.d = function() {
1039
- this.f |= 8, 1 & this.f || Ht(this);
1040
- };
1041
- Q.prototype.dispose = function() {
1042
- this.d();
1043
- };
1044
- function si(e, t) {
1045
- var s = new Q(e, t);
1046
- try {
1047
- s.c();
1048
- } catch (r) {
1049
- throw s.d(), r;
1050
- }
1051
- var o = s.d.bind(s);
1052
- return o[Symbol.dispose] = o, o;
1053
- }
1054
- const ni = {
1055
- emptyStateTitle: "No data available.",
1056
- thumbnails: "Thumbnails",
1057
- singlePageMode: "Single Page Mode",
1058
- pages: "Pages",
1059
- previous: "Previous",
1060
- next: "Next",
1061
- zoomOut: "Zoom Out",
1062
- zoomIn: "Zoom In",
1063
- fullscreen: "Fullscreen",
1064
- settings: "Settings",
1065
- downloadCatalog: "Download Catalog",
1066
- play: "Play",
1067
- pause: "Pause",
1068
- tableOfContents: "Table of Contents"
1069
- }, oi = {
1070
- emptyStateTitle: "Veri bulunamadi.",
1071
- thumbnails: "Küçük Resimler",
1072
- singlePageMode: "Tek Sayfa Modu",
1073
- pages: "Sayfalar",
1074
- previous: "Önceki",
1075
- next: "Sonraki",
1076
- zoomOut: "Uzaklaş",
1077
- zoomIn: "Yaklaş",
1078
- fullscreen: "Tam Ekran",
1079
- settings: "Ayarlar",
1080
- downloadCatalog: "Kataloğu İndir",
1081
- play: "Otomatik Oynat",
1082
- pause: "Duraklat",
1083
- tableOfContents: "İçindekiler"
1084
- }, Tt = {
1085
- en: ni,
1086
- tr: oi
1087
- };
1088
- function me(e = {}) {
1089
- var r;
1090
- const t = e.locale ?? "en", s = Tt[t] ?? Tt.en, o = ((r = e.messages) == null ? void 0 : r[t]) ?? {};
1091
- return {
1092
- ...Tt.en,
1093
- ...s,
1094
- ...o
1095
- };
1096
- }
1097
- function ri(e) {
1098
- const t = w(() => me({ locale: e.store.locale.value, messages: e.store.messages.value }));
1099
- return /* @__PURE__ */ d("div", { class: "bk-toolbar", role: "toolbar", "aria-label": "Flipbook controls", children: [
1100
- /* @__PURE__ */ d("div", { class: "bk-btn-group", children: [
1101
- /* @__PURE__ */ d(
1102
- "button",
1103
- {
1104
- type: "button",
1105
- class: w(() => `bk-btn ${e.store.showThumbs.value ? "active" : ""}`),
1106
- onClick: e.onToggleThumbs,
1107
- "aria-label": w(() => t.value.thumbnails || "Thumbnails"),
1108
- "aria-pressed": w(() => e.store.showThumbs.value ? "true" : "false"),
1109
- title: w(() => t.value.thumbnails || "Thumbnails"),
1110
- children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1111
- /* @__PURE__ */ d("rect", { x: "3", y: "3", width: "7", height: "7" }),
1112
- /* @__PURE__ */ d("rect", { x: "14", y: "3", width: "7", height: "7" }),
1113
- /* @__PURE__ */ d("rect", { x: "14", y: "14", width: "7", height: "7" }),
1114
- /* @__PURE__ */ d("rect", { x: "3", y: "14", width: "7", height: "7" })
1115
- ] })
1116
- }
1117
- ),
1118
- w(() => e.store.toc.value.length ? /* @__PURE__ */ d(
1119
- "button",
1120
- {
1121
- type: "button",
1122
- class: w(() => e.store.showToc.value ? "bk-btn active" : "bk-btn"),
1123
- onClick: e.onToggleToc,
1124
- "aria-label": w(() => t.value.tableOfContents || "Table of Contents"),
1125
- "aria-pressed": w(() => e.store.showToc.value ? "true" : "false"),
1126
- title: w(() => t.value.tableOfContents || "Table of Contents"),
1127
- children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1128
- /* @__PURE__ */ d("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
1129
- /* @__PURE__ */ d("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
1130
- /* @__PURE__ */ d("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
1131
- /* @__PURE__ */ d("line", { x1: "3", y1: "6", x2: "3.01", y2: "6" }),
1132
- /* @__PURE__ */ d("line", { x1: "3", y1: "12", x2: "3.01", y2: "12" }),
1133
- /* @__PURE__ */ d("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
1134
- ] })
1135
- }
1136
- ) : null),
1137
- /* @__PURE__ */ d(
1138
- "button",
1139
- {
1140
- type: "button",
1141
- class: w(() => `bk-btn bz-hide-mobile ${e.store.isSingleMode.value ? "active" : ""}`),
1142
- onClick: e.onToggleSingleMode,
1143
- "aria-label": w(() => t.value.singlePageMode || "Single Page"),
1144
- "aria-pressed": w(() => e.store.isSingleMode.value ? "true" : "false"),
1145
- title: w(() => t.value.singlePageMode || "Single Page"),
1146
- children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1147
- /* @__PURE__ */ d("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1148
- /* @__PURE__ */ d("polyline", { points: "14 2 14 8 20 8" }),
1149
- /* @__PURE__ */ d("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1150
- /* @__PURE__ */ d("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1151
- /* @__PURE__ */ d("polyline", { points: "10 9 9 9 8 9" })
1152
- ] })
1153
- }
1154
- ),
1155
- /* @__PURE__ */ d(
1156
- "button",
1157
- {
1158
- type: "button",
1159
- class: w(() => `bk-btn ${e.store.isAutoPlaying.value ? "active" : ""}`),
1160
- onClick: e.onToggleAutoPlay,
1161
- "aria-label": w(() => e.store.isAutoPlaying.value ? t.value.pause || "Pause" : t.value.play || "Play"),
1162
- "aria-pressed": w(() => e.store.isAutoPlaying.value ? "true" : "false"),
1163
- title: w(() => e.store.isAutoPlaying.value ? t.value.pause || "Pause" : t.value.play || "Play"),
1164
- children: [
1165
- /* @__PURE__ */ d("svg", { style: { display: w(() => e.store.isAutoPlaying.value ? "block" : "none") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1166
- /* @__PURE__ */ d("rect", { x: "6", y: "4", width: "4", height: "16" }),
1167
- /* @__PURE__ */ d("rect", { x: "14", y: "4", width: "4", height: "16" })
1168
- ] }),
1169
- /* @__PURE__ */ d("svg", { style: { display: w(() => e.store.isAutoPlaying.value ? "none" : "block") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ d("polygon", { points: "5 3 19 12 5 21 5 3" }) })
1170
- ]
1171
- }
1172
- )
1173
- ] }),
1174
- /* @__PURE__ */ d("div", { class: "bk-btn-group bk-btn-group--center", children: [
1175
- /* @__PURE__ */ d("button", { type: "button", class: "bk-btn", onClick: e.onPrevPage, "aria-label": w(() => t.value.previous || "Previous"), title: w(() => t.value.previous || "Previous"), children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ d("polyline", { points: "15 18 9 12 15 6" }) }) }),
1176
- /* @__PURE__ */ d("span", { class: "bz-page-info", "aria-live": "polite", "aria-atomic": "true", children: w(() => {
1177
- const s = e.store.currentPage.value, o = e.store.totalPages.value;
1178
- if (e.store.isSingleMode.value || s === 0 || s >= o - 1)
1179
- return `${s + 1} / ${o}`;
1180
- const r = s % 2 === 1 ? s : s - 1;
1181
- return `${r + 1}-${r + 2} / ${o}`;
1182
- }) }),
1183
- /* @__PURE__ */ d("button", { type: "button", class: "bk-btn", onClick: e.onNextPage, "aria-label": w(() => t.value.next || "Next"), title: w(() => t.value.next || "Next"), children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ d("polyline", { points: "9 18 15 12 9 6" }) }) })
1184
- ] }),
1185
- /* @__PURE__ */ d("div", { class: "bk-btn-group", children: [
1186
- /* @__PURE__ */ d("button", { type: "button", class: "bk-btn", onClick: e.onZoomIn, "aria-label": w(() => t.value.zoomIn || "Zoom In"), title: w(() => t.value.zoomIn || "Zoom In"), children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1187
- /* @__PURE__ */ d("circle", { cx: "11", cy: "11", r: "8" }),
1188
- /* @__PURE__ */ d("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
1189
- /* @__PURE__ */ d("line", { x1: "11", y1: "8", x2: "11", y2: "14" }),
1190
- /* @__PURE__ */ d("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
1191
- ] }) }),
1192
- /* @__PURE__ */ d(
1193
- "button",
1194
- {
1195
- type: "button",
1196
- class: w(() => `bk-btn ${e.store.isZoomed.value ? "active" : ""}`),
1197
- onClick: e.onZoomOut,
1198
- "aria-label": w(() => t.value.zoomOut || "Zoom Out"),
1199
- title: w(() => t.value.zoomOut || "Zoom Out"),
1200
- children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1201
- /* @__PURE__ */ d("circle", { cx: "11", cy: "11", r: "8" }),
1202
- /* @__PURE__ */ d("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
1203
- /* @__PURE__ */ d("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
1204
- ] })
1205
- }
1206
- ),
1207
- /* @__PURE__ */ d("button", { type: "button", class: "bk-btn bk-btn--fullscreen", onClick: e.onToggleFullscreen, "aria-label": w(() => t.value.fullscreen || "Fullscreen"), title: w(() => t.value.fullscreen || "Fullscreen"), children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ d("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" }) }) }),
1208
- w(() => e.store.allowDownload.value && e.store.hasDownloadUrl.value && e.onDownload ? /* @__PURE__ */ d("button", { type: "button", class: "bk-btn bk-btn--download", onClick: e.onDownload, "aria-label": w(() => t.value.downloadCatalog || "Download"), title: w(() => t.value.downloadCatalog || "Download"), children: /* @__PURE__ */ d("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1209
- /* @__PURE__ */ d("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
1210
- /* @__PURE__ */ d("polyline", { points: "7 10 12 15 17 10" }),
1211
- /* @__PURE__ */ d("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
1212
- ] }) }) : null),
1213
- /* @__PURE__ */ d(
1214
- "button",
1215
- {
1216
- type: "button",
1217
- class: w(() => `bk-btn ${e.store.soundEnabled.value ? "" : "muted"}`),
1218
- onClick: e.onSoundToggle,
1219
- "aria-label": "Sound",
1220
- "aria-pressed": w(() => e.store.soundEnabled.value ? "true" : "false"),
1221
- title: "Sound",
1222
- children: [
1223
- /* @__PURE__ */ d("svg", { style: { display: w(() => e.store.soundEnabled.value ? "block" : "none") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1224
- /* @__PURE__ */ d("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1225
- /* @__PURE__ */ d("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" }),
1226
- /* @__PURE__ */ d("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" })
1227
- ] }),
1228
- /* @__PURE__ */ d("svg", { style: { display: w(() => e.store.soundEnabled.value ? "none" : "block") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1229
- /* @__PURE__ */ d("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1230
- /* @__PURE__ */ d("line", { x1: "23", y1: "9", x2: "17", y2: "15" }),
1231
- /* @__PURE__ */ d("line", { x1: "17", y1: "9", x2: "23", y2: "15" })
1232
- ] })
1233
- ]
1234
- }
1235
- )
1236
- ] })
1237
- ] });
1238
- }
1239
- function ai(e) {
1240
- return /* @__PURE__ */ d("div", { class: "bk-thumbs", style: w(() => e.store.showThumbs.value ? "display:flex;" : "display:none;"), children: e.store.pages.value.map((t, s) => {
1241
- const o = () => {
1242
- const r = e.store.currentPage.value;
1243
- if (e.store.isSingleMode.value || r === 0 || r >= e.store.pages.value.length - 1)
1244
- return r === s;
1245
- const h = r % 2 === 1 ? r : r - 1;
1246
- return s === h || s === h + 1;
1247
- };
1248
- return /* @__PURE__ */ d(
1249
- "div",
1250
- {
1251
- class: w(() => `thumb-item ${o() ? "active" : ""}`),
1252
- role: "button",
1253
- tabindex: "0",
1254
- "aria-label": `Go to page ${s + 1}`,
1255
- "aria-current": w(() => o() ? "page" : void 0),
1256
- onClick: () => e.onThumbClick(s),
1257
- onKeyDown: (r) => {
1258
- (r.key === "Enter" || r.key === " ") && (r.preventDefault(), e.onThumbClick(s));
1259
- },
1260
- children: [
1261
- /* @__PURE__ */ d("div", { class: "thumb-img-wrapper", children: /* @__PURE__ */ d(
1262
- "img",
1263
- {
1264
- "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1265
- class: "thumb-img",
1266
- src: t.thumb || t.low || t.normal,
1267
- alt: `Page ${s + 1}`,
1268
- loading: "lazy",
1269
- onError: (r) => {
1270
- r.currentTarget.style.display = "none";
1271
- }
1272
- }
1273
- ) }),
1274
- /* @__PURE__ */ d("span", { children: s + 1 })
1275
- ]
1276
- }
1277
- );
1278
- }) });
1279
- }
1280
- function we(e, t, s) {
1281
- return /* @__PURE__ */ d("ol", { class: "bk-toc-list", children: e.map((o) => {
1282
- var r;
1283
- return /* @__PURE__ */ d("li", { class: "bk-toc-item", children: [
1284
- /* @__PURE__ */ d(
1285
- "button",
1286
- {
1287
- type: "button",
1288
- class: w(() => t.currentPage.value === o.pageIndex ? "bk-toc-entry active" : "bk-toc-entry"),
1289
- "aria-current": w(() => t.currentPage.value === o.pageIndex ? "page" : void 0),
1290
- onClick: () => s(o.pageIndex),
1291
- children: [
1292
- /* @__PURE__ */ d("span", { class: "bk-toc-title", children: o.title }),
1293
- /* @__PURE__ */ d("span", { class: "bk-toc-page", children: o.pageIndex + 1 })
1294
- ]
1295
- }
1296
- ),
1297
- (r = o.children) != null && r.length ? we(o.children, t, s) : null
1298
- ] });
1299
- }) });
1300
- }
1301
- function hi(e) {
1302
- const t = w(() => me({ locale: e.store.locale.value, messages: e.store.messages.value }));
1303
- return /* @__PURE__ */ d(
1304
- "nav",
1305
- {
1306
- class: "bk-toc",
1307
- "aria-label": w(() => t.value.tableOfContents || "Table of Contents"),
1308
- style: w(() => e.store.showToc.value && e.store.toc.value.length ? "display:flex;" : "display:none;"),
1309
- children: [
1310
- /* @__PURE__ */ d("div", { class: "bk-toc-heading", children: w(() => t.value.tableOfContents || "Table of Contents") }),
1311
- we(e.store.toc.value, e.store, e.onEntryClick)
1312
- ]
1313
- }
1314
- );
1315
- }
1316
- function li(e) {
1317
- return /* @__PURE__ */ d(
1318
- "div",
1319
- {
1320
- role: "region",
1321
- "aria-label": "Flipbook viewer",
1322
- class: w(() => {
1323
- let t = "bk-book-wrapper ";
1324
- return e.store.isDoublePageLayout.value && (t += "double-mode "), e.store.isFrontCover.value && (t += "bk-is-cover "), e.store.isBackCover.value && (t += "bk-is-back-cover "), e.store.zoomState.value.isActive && (t += "zoomed "), t.trim();
1325
- }),
1326
- ref: e.bookWrapperRef,
1327
- children: /* @__PURE__ */ d(
1328
- "div",
1329
- {
1330
- class: "bk-book-sizer",
1331
- ref: e.bookSizerRef,
1332
- children: [
1333
- /* @__PURE__ */ d(
1334
- "div",
1335
- {
1336
- ref: e.bookContainerRef,
1337
- class: w(() => "bk-book " + (e.store.flipState.value !== "read" ? "is-flipping" : "")),
1338
- style: w(() => `display: ${e.store.isSingleMode.value ? "none" : "block"};`),
1339
- children: e.store.pages.value.map((t, s) => {
1340
- const o = s === 0 || s === e.store.pages.value.length - 1;
1341
- return /* @__PURE__ */ d(
1342
- "div",
1343
- {
1344
- class: `bz-page ${s === 0 ? "bz-page--cover" : ""} ${s === e.store.pages.value.length - 1 ? "bz-page--back" : ""}`,
1345
- "data-density": o ? "hard" : "soft",
1346
- "data-idx": s,
1347
- children: /* @__PURE__ */ d("div", { class: "bz-page-content", style: "position:relative; width:100%; height:100%; overflow:hidden;", children: [
1348
- /* @__PURE__ */ d(
1349
- "img",
1350
- {
1351
- "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1352
- src: t.low || t.normal,
1353
- "data-src": t.normal,
1354
- class: `page-content ${t.cropMode !== "full" ? "page-content--split page-content--" + t.cropMode : ""}`,
1355
- alt: `Page ${s + 1}`,
1356
- loading: "lazy"
1357
- }
1358
- ),
1359
- /* @__PURE__ */ d("div", { class: "page-shadow" })
1360
- ] })
1361
- }
1362
- );
1363
- })
1364
- }
1365
- ),
1366
- /* @__PURE__ */ d(
1367
- "div",
1368
- {
1369
- class: "bk-single-view",
1370
- style: w(() => `display: ${e.store.isSingleMode.value ? "flex" : "none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),
1371
- children: w(() => {
1372
- const t = e.store.pages.value[e.store.currentPage.value];
1373
- return t ? /* @__PURE__ */ d(
1374
- "img",
1375
- {
1376
- "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1377
- class: `bk-single-img page-content ${t.cropMode !== "full" ? "page-content--split page-content--" + t.cropMode : ""}`,
1378
- src: e.store.zoomState.value.isActive ? t.normal : t.low || t.normal,
1379
- alt: `Page ${e.store.currentPage.value + 1}`,
1380
- style: "opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"
1381
- }
1382
- ) : null;
1383
- })
1384
- }
1385
- )
1386
- ]
1387
- }
1388
- )
1389
- }
1390
- );
1391
- }
1392
- function ci(e) {
1393
- const t = w(() => e.store.showArrows.value && e.store.currentPage.value > 0), s = w(() => !e.store.showArrows.value || e.store.totalPages.value <= 1 ? !1 : e.store.currentPage.value < e.store.totalPages.value - 1);
1394
- return /* @__PURE__ */ d("div", { class: "bk-nav-arrows", style: w(() => e.store.showArrows.value ? "display: flex;" : "display: none;"), children: [
1395
- /* @__PURE__ */ d(
1396
- "button",
1397
- {
1398
- type: "button",
1399
- class: "bk-nav-arrow bk-nav-prev",
1400
- style: w(() => t.value ? "visibility: visible;" : "visibility: hidden;"),
1401
- onClick: (o) => {
1402
- o.preventDefault(), e.onPrevPage();
1403
- },
1404
- "aria-label": "Previous Page",
1405
- children: /* @__PURE__ */ d("div", { class: "bk-arrow-icon bk-arrow-left" })
1406
- }
1407
- ),
1408
- /* @__PURE__ */ d(
1409
- "button",
1410
- {
1411
- type: "button",
1412
- class: "bk-nav-arrow bk-nav-next",
1413
- style: w(() => s.value ? "visibility: visible;" : "visibility: hidden;"),
1414
- onClick: (o) => {
1415
- o.preventDefault(), e.onNextPage();
1416
- },
1417
- "aria-label": "Next Page",
1418
- children: /* @__PURE__ */ d("div", { class: "bk-arrow-icon bk-arrow-right" })
1419
- }
1420
- )
1421
- ] });
1422
- }
1423
- function di(e) {
1424
- const t = () => {
1425
- e.store.showThumbs.value = !e.store.showThumbs.value;
1426
- }, s = () => {
1427
- e.store.showToc.value = !e.store.showToc.value;
1428
- }, o = () => {
1429
- e.store.isSingleMode.value = !e.store.isSingleMode.value;
1430
- }, r = () => {
1431
- e.store.isAutoPlaying.value = !e.store.isAutoPlaying.value;
1432
- }, h = () => {
1433
- var S;
1434
- (S = e.interactionManagerRef.current) == null || S.zoomIn();
1435
- }, u = () => {
1436
- var S;
1437
- (S = e.interactionManagerRef.current) == null || S.zoomOut();
1438
- }, p = () => e.onToggleFullscreen(), b = (S) => {
1439
- e.store.currentPage.value = S, e.store.showToc.value = !1;
1440
- }, x = (S) => {
1441
- var T;
1442
- e.store.currentPage.value !== S && (e.store.currentPage.value = S, (T = e.pageFlipAdapterRef.current) == null || T.playSound());
1443
- }, M = () => {
1444
- var S;
1445
- (S = e.pageFlipAdapterRef.current) == null || S.turnToNextPage();
1446
- }, I = () => {
1447
- var S;
1448
- (S = e.pageFlipAdapterRef.current) == null || S.turnToPrevPage();
1449
- };
1450
- return /* @__PURE__ */ d(
1451
- "div",
1452
- {
1453
- class: w(() => `bk-wrapper bk-theme-${e.store.themeMode.value} ${e.className || ""}`),
1454
- children: [
1455
- /* @__PURE__ */ d("div", { class: "bk-main-area", children: [
1456
- /* @__PURE__ */ d(
1457
- li,
1458
- {
1459
- store: e.store,
1460
- bookWrapperRef: e.bookWrapperRef,
1461
- bookSizerRef: e.bookSizerRef,
1462
- bookContainerRef: e.bookContainerRef
1463
- }
1464
- ),
1465
- /* @__PURE__ */ d(
1466
- ci,
1467
- {
1468
- store: e.store,
1469
- onPrevPage: I,
1470
- onNextPage: M
1471
- }
1472
- ),
1473
- e.store.whiteLabel.value ? null : /* @__PURE__ */ d("div", { class: "bk-watermark", children: [
1474
- "Powered by ",
1475
- /* @__PURE__ */ d("a", { href: "https://flipbookengine.com", target: "_blank", rel: "noopener", style: "text-decoration: underline;", children: "FlipbookEngine" })
1476
- ] }),
1477
- /* @__PURE__ */ d(hi, { store: e.store, onEntryClick: b })
1478
- ] }),
1479
- /* @__PURE__ */ d(
1480
- ri,
1481
- {
1482
- store: e.store,
1483
- onToggleThumbs: t,
1484
- onToggleToc: s,
1485
- onToggleSingleMode: o,
1486
- onZoomIn: h,
1487
- onZoomOut: u,
1488
- onDownload: e.onDownload,
1489
- onNextPage: M,
1490
- onPrevPage: I,
1491
- onSoundToggle: () => e.store.soundEnabled.value = !e.store.soundEnabled.value,
1492
- onToggleAutoPlay: r,
1493
- onToggleFullscreen: p
1494
- }
1495
- ),
1496
- /* @__PURE__ */ d(
1497
- ai,
1498
- {
1499
- store: e.store,
1500
- onThumbClick: x
1501
- }
1502
- )
1503
- ]
1504
- }
1505
- );
1506
- }
1507
- var ui = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Dt = { exports: {} };
1508
- (function(e, t) {
1509
- (function(s, o) {
1510
- o(t);
1511
- })(ui, function(s) {
1512
- class o {
1513
- constructor(i, n) {
1514
- this.state = { angle: 0, area: [], position: { x: 0, y: 0 }, hardAngle: 0, hardDrawingAngle: 0 }, this.createdDensity = n, this.nowDrawingDensity = this.createdDensity, this.render = i;
1515
- }
1516
- setDensity(i) {
1517
- this.createdDensity = i, this.nowDrawingDensity = i;
1518
- }
1519
- setDrawingDensity(i) {
1520
- this.nowDrawingDensity = i;
1521
- }
1522
- setPosition(i) {
1523
- this.state.position = i;
1524
- }
1525
- setAngle(i) {
1526
- this.state.angle = i;
1527
- }
1528
- setArea(i) {
1529
- this.state.area = i;
1530
- }
1531
- setHardDrawingAngle(i) {
1532
- this.state.hardDrawingAngle = i;
1533
- }
1534
- setHardAngle(i) {
1535
- this.state.hardAngle = i, this.state.hardDrawingAngle = i;
1536
- }
1537
- setOrientation(i) {
1538
- this.orientation = i;
1539
- }
1540
- getDrawingDensity() {
1541
- return this.nowDrawingDensity;
1542
- }
1543
- getDensity() {
1544
- return this.createdDensity;
1545
- }
1546
- getHardAngle() {
1547
- return this.state.hardAngle;
1548
- }
1549
- }
1550
- class r extends o {
1551
- constructor(i, n, a) {
1552
- super(i, a), this.image = null, this.isLoad = !1, this.loadingAngle = 0, this.image = new Image(), this.image.src = n;
1553
- }
1554
- draw(i) {
1555
- const n = this.render.getContext(), a = this.render.convertToGlobal(this.state.position), l = this.render.getRect().pageWidth, c = this.render.getRect().height;
1556
- n.save(), n.translate(a.x, a.y), n.beginPath();
1557
- for (let g of this.state.area) g !== null && (g = this.render.convertToGlobal(g), n.lineTo(g.x - a.x, g.y - a.y));
1558
- n.rotate(this.state.angle), n.clip(), this.isLoad ? n.drawImage(this.image, 0, 0, l, c) : this.drawLoader(n, { x: 0, y: 0 }, l, c), n.restore();
1559
- }
1560
- simpleDraw(i) {
1561
- const n = this.render.getRect(), a = this.render.getContext(), l = n.pageWidth, c = n.height, g = i === 1 ? n.left + n.pageWidth : n.left, y = n.top;
1562
- this.isLoad ? a.drawImage(this.image, g, y, l, c) : this.drawLoader(a, { x: g, y }, l, c);
1563
- }
1564
- drawLoader(i, n, a, l) {
1565
- i.beginPath(), i.strokeStyle = "rgb(200, 200, 200)", i.fillStyle = "rgb(255, 255, 255)", i.lineWidth = 1, i.rect(n.x + 1, n.y + 1, a - 1, l - 1), i.stroke(), i.fill();
1566
- const c = { x: n.x + a / 2, y: n.y + l / 2 };
1567
- i.beginPath(), i.lineWidth = 10, i.arc(c.x, c.y, 20, this.loadingAngle, 3 * Math.PI / 2 + this.loadingAngle), i.stroke(), i.closePath(), this.loadingAngle += 0.07, this.loadingAngle >= 2 * Math.PI && (this.loadingAngle = 0);
1568
- }
1569
- load() {
1570
- this.isLoad || (this.image.onload = () => {
1571
- this.isLoad = !0;
1572
- });
1573
- }
1574
- newTemporaryCopy() {
1575
- return this;
1576
- }
1577
- getTemporaryCopy() {
1578
- return this;
1579
- }
1580
- hideTemporaryCopy() {
1581
- }
1582
- }
1583
- class h {
1584
- constructor(i, n) {
1585
- this.pages = [], this.currentPageIndex = 0, this.currentSpreadIndex = 0, this.landscapeSpread = [], this.portraitSpread = [], this.render = n, this.app = i, this.currentPageIndex = 0, this.isShowCover = this.app.getSettings().showCover;
1586
- }
1587
- destroy() {
1588
- this.pages = [];
1589
- }
1590
- createSpread() {
1591
- this.landscapeSpread = [], this.portraitSpread = [];
1592
- for (let n = 0; n < this.pages.length; n++) this.portraitSpread.push([n]);
1593
- let i = 0;
1594
- this.isShowCover && (this.pages[0].setDensity("hard"), this.landscapeSpread.push([i]), i++);
1595
- for (let n = i; n < this.pages.length; n += 2) n < this.pages.length - 1 ? this.landscapeSpread.push([n, n + 1]) : (this.landscapeSpread.push([n]), this.pages[n].setDensity("hard"));
1596
- }
1597
- getSpread() {
1598
- return this.render.getOrientation() === "landscape" ? this.landscapeSpread : this.portraitSpread;
1599
- }
1600
- getSpreadIndexByPage(i) {
1601
- const n = this.getSpread();
1602
- for (let a = 0; a < n.length; a++) if (i === n[a][0] || i === n[a][1]) return a;
1603
- return null;
1604
- }
1605
- getPageCount() {
1606
- return this.pages.length;
1607
- }
1608
- getPages() {
1609
- return this.pages;
1610
- }
1611
- getPage(i) {
1612
- if (i >= 0 && i < this.pages.length) return this.pages[i];
1613
- throw new Error("Invalid page number");
1614
- }
1615
- nextBy(i) {
1616
- const n = this.pages.indexOf(i);
1617
- return n < this.pages.length - 1 ? this.pages[n + 1] : null;
1618
- }
1619
- prevBy(i) {
1620
- const n = this.pages.indexOf(i);
1621
- return n > 0 ? this.pages[n - 1] : null;
1622
- }
1623
- getFlippingPage(i) {
1624
- const n = this.currentSpreadIndex;
1625
- if (this.render.getOrientation() === "portrait") return i === 0 ? this.pages[n].newTemporaryCopy() : this.pages[n - 1];
1626
- {
1627
- const a = i === 0 ? this.getSpread()[n + 1] : this.getSpread()[n - 1];
1628
- return a.length === 1 || i === 0 ? this.pages[a[0]] : this.pages[a[1]];
1629
- }
1630
- }
1631
- getBottomPage(i) {
1632
- const n = this.currentSpreadIndex;
1633
- if (this.render.getOrientation() === "portrait") return i === 0 ? this.pages[n + 1] : this.pages[n - 1];
1634
- {
1635
- const a = i === 0 ? this.getSpread()[n + 1] : this.getSpread()[n - 1];
1636
- return a.length === 1 ? this.pages[a[0]] : i === 0 ? this.pages[a[1]] : this.pages[a[0]];
1637
- }
1638
- }
1639
- showNext() {
1640
- this.currentSpreadIndex < this.getSpread().length && (this.currentSpreadIndex++, this.showSpread());
1641
- }
1642
- showPrev() {
1643
- this.currentSpreadIndex > 0 && (this.currentSpreadIndex--, this.showSpread());
1644
- }
1645
- getCurrentPageIndex() {
1646
- return this.currentPageIndex;
1647
- }
1648
- show(i = null) {
1649
- if (i === null && (i = this.currentPageIndex), i < 0 || i >= this.pages.length) return;
1650
- const n = this.getSpreadIndexByPage(i);
1651
- n !== null && (this.currentSpreadIndex = n, this.showSpread());
1652
- }
1653
- getCurrentSpreadIndex() {
1654
- return this.currentSpreadIndex;
1655
- }
1656
- setCurrentSpreadIndex(i) {
1657
- if (!(i >= 0 && i < this.getSpread().length)) throw new Error("Invalid page");
1658
- this.currentSpreadIndex = i;
1659
- }
1660
- showSpread() {
1661
- const i = this.getSpread()[this.currentSpreadIndex];
1662
- i.length === 2 ? (this.render.setLeftPage(this.pages[i[0]]), this.render.setRightPage(this.pages[i[1]])) : this.render.getOrientation() === "landscape" && i[0] === this.pages.length - 1 ? (this.render.setLeftPage(this.pages[i[0]]), this.render.setRightPage(null)) : (this.render.setLeftPage(null), this.render.setRightPage(this.pages[i[0]])), this.currentPageIndex = i[0], this.app.updatePageIndex(this.currentPageIndex);
1663
- }
1664
- }
1665
- class u extends h {
1666
- constructor(i, n, a) {
1667
- super(i, n), this.imagesHref = a;
1668
- }
1669
- load() {
1670
- for (const i of this.imagesHref) {
1671
- const n = new r(this.render, i, "soft");
1672
- n.load(), this.pages.push(n);
1673
- }
1674
- this.createSpread();
1675
- }
1676
- }
1677
- class p {
1678
- static GetDistanceBetweenTwoPoint(i, n) {
1679
- return i === null || n === null ? 1 / 0 : Math.sqrt(Math.pow(n.x - i.x, 2) + Math.pow(n.y - i.y, 2));
1680
- }
1681
- static GetSegmentLength(i) {
1682
- return p.GetDistanceBetweenTwoPoint(i[0], i[1]);
1683
- }
1684
- static GetAngleBetweenTwoLine(i, n) {
1685
- const a = i[0].y - i[1].y, l = n[0].y - n[1].y, c = i[1].x - i[0].x, g = n[1].x - n[0].x;
1686
- return Math.acos((a * l + c * g) / (Math.sqrt(a * a + c * c) * Math.sqrt(l * l + g * g)));
1687
- }
1688
- static PointInRect(i, n) {
1689
- return n === null ? null : n.x >= i.left && n.x <= i.width + i.left && n.y >= i.top && n.y <= i.top + i.height ? n : null;
1690
- }
1691
- static GetRotatedPoint(i, n, a) {
1692
- return { x: i.x * Math.cos(a) + i.y * Math.sin(a) + n.x, y: i.y * Math.cos(a) - i.x * Math.sin(a) + n.y };
1693
- }
1694
- static LimitPointToCircle(i, n, a) {
1695
- if (p.GetDistanceBetweenTwoPoint(i, a) <= n) return a;
1696
- const l = i.x, c = i.y, g = a.x, y = a.y;
1697
- let f = Math.sqrt(Math.pow(n, 2) * Math.pow(l - g, 2) / (Math.pow(l - g, 2) + Math.pow(c - y, 2))) + l;
1698
- a.x < 0 && (f *= -1);
1699
- let C = (f - l) * (c - y) / (l - g) + c;
1700
- return l - g + c === 0 && (C = n), { x: f, y: C };
1701
- }
1702
- static GetIntersectBetweenTwoSegment(i, n, a) {
1703
- return p.PointInRect(i, p.GetIntersectBeetwenTwoLine(n, a));
1704
- }
1705
- static GetIntersectBeetwenTwoLine(i, n) {
1706
- const a = i[0].y - i[1].y, l = n[0].y - n[1].y, c = i[1].x - i[0].x, g = n[1].x - n[0].x, y = i[0].x * i[1].y - i[1].x * i[0].y, f = n[0].x * n[1].y - n[1].x * n[0].y, C = a * f - l * y, R = c * f - g * y, F = -(y * g - f * c) / (a * g - l * c), K = -(a * f - l * y) / (a * g - l * c);
1707
- if (isFinite(F) && isFinite(K)) return { x: F, y: K };
1708
- if (Math.abs(C - R) < 0.1) throw new Error("Segment included");
1709
- return null;
1710
- }
1711
- static GetCordsFromTwoPoint(i, n) {
1712
- const a = Math.abs(i.x - n.x), l = Math.abs(i.y - n.y), c = Math.max(a, l), g = [i];
1713
- function y(f, C, R, F, K) {
1714
- return C > f ? f + K * (R / F) : C < f ? f - K * (R / F) : f;
1715
- }
1716
- for (let f = 1; f <= c; f += 1) g.push({ x: y(i.x, n.x, a, c, f), y: y(i.y, n.y, l, c, f) });
1717
- return g;
1718
- }
1719
- }
1720
- class b extends o {
1721
- constructor(i, n, a) {
1722
- super(i, a), this.copiedElement = null, this.temporaryCopy = null, this.isLoad = !1, this.element = n, this.element.classList.add("stf__item"), this.element.classList.add("--" + a);
1723
- }
1724
- newTemporaryCopy() {
1725
- return this.nowDrawingDensity === "hard" ? this : (this.temporaryCopy === null && (this.copiedElement = this.element.cloneNode(!0), this.element.parentElement.appendChild(this.copiedElement), this.temporaryCopy = new b(this.render, this.copiedElement, this.nowDrawingDensity)), this.getTemporaryCopy());
1726
- }
1727
- getTemporaryCopy() {
1728
- return this.temporaryCopy;
1729
- }
1730
- hideTemporaryCopy() {
1731
- this.temporaryCopy !== null && (this.copiedElement.remove(), this.copiedElement = null, this.temporaryCopy = null);
1732
- }
1733
- draw(i) {
1734
- const n = i || this.nowDrawingDensity, a = this.render.convertToGlobal(this.state.position), l = this.render.getRect().pageWidth, c = this.render.getRect().height;
1735
- this.element.classList.remove("--simple");
1736
- const g = `
1737
- display: block;
1738
- z-index: ${this.element.style.zIndex};
1739
- left: 0;
1740
- top: 0;
1741
- width: ${l}px;
1742
- height: ${c}px;
1743
- `;
1744
- n === "hard" ? this.drawHard(g) : this.drawSoft(a, g);
1745
- }
1746
- drawHard(i = "") {
1747
- const n = this.render.getRect().left + this.render.getRect().width / 2, a = this.state.hardDrawingAngle, l = i + `
1748
- backface-visibility: hidden;
1749
- -webkit-backface-visibility: hidden;
1750
- clip-path: none;
1751
- -webkit-clip-path: none;
1752
- ` + (this.orientation === 0 ? `transform-origin: ${this.render.getRect().pageWidth}px 0;
1753
- transform: translate3d(0, 0, 0) rotateY(${a}deg);` : `transform-origin: 0 0;
1754
- transform: translate3d(${n}px, 0, 0) rotateY(${a}deg);`);
1755
- this.element.style.cssText = l;
1756
- }
1757
- drawSoft(i, n = "") {
1758
- let a = "polygon( ";
1759
- for (const c of this.state.area) if (c !== null) {
1760
- let g = this.render.getDirection() === 1 ? { x: -c.x + this.state.position.x, y: c.y - this.state.position.y } : { x: c.x - this.state.position.x, y: c.y - this.state.position.y };
1761
- g = p.GetRotatedPoint(g, { x: 0, y: 0 }, this.state.angle), a += g.x + "px " + g.y + "px, ";
1762
- }
1763
- a = a.slice(0, -2), a += ")";
1764
- const l = n + `transform-origin: 0 0; clip-path: ${a}; -webkit-clip-path: ${a};` + (this.render.isSafari() && this.state.angle === 0 ? `transform: translate(${i.x}px, ${i.y}px);` : `transform: translate3d(${i.x}px, ${i.y}px, 0) rotate(${this.state.angle}rad);`);
1765
- this.element.style.cssText = l;
1766
- }
1767
- simpleDraw(i) {
1768
- const n = this.render.getRect(), a = n.pageWidth, l = n.height, c = i === 1 ? n.left + n.pageWidth : n.left, g = n.top;
1769
- this.element.classList.add("--simple"), this.element.style.cssText = `
1770
- position: absolute;
1771
- display: block;
1772
- height: ${l}px;
1773
- left: ${c}px;
1774
- top: ${g}px;
1775
- width: ${a}px;
1776
- z-index: ${this.render.getSettings().startZIndex + 1};`;
1777
- }
1778
- getElement() {
1779
- return this.element;
1780
- }
1781
- load() {
1782
- this.isLoad = !0;
1783
- }
1784
- setOrientation(i) {
1785
- super.setOrientation(i), this.element.classList.remove("--left", "--right"), this.element.classList.add(i === 1 ? "--right" : "--left");
1786
- }
1787
- setDrawingDensity(i) {
1788
- this.element.classList.remove("--soft", "--hard"), this.element.classList.add("--" + i), super.setDrawingDensity(i);
1789
- }
1790
- }
1791
- class x extends h {
1792
- constructor(i, n, a, l) {
1793
- super(i, n), this.element = a, this.pagesElement = l;
1794
- }
1795
- load() {
1796
- for (const i of this.pagesElement) {
1797
- const n = new b(this.render, i, i.dataset.density === "hard" ? "hard" : "soft");
1798
- n.load(), this.pages.push(n);
1799
- }
1800
- this.createSpread();
1801
- }
1802
- }
1803
- class M {
1804
- constructor(i, n, a, l) {
1805
- this.direction = i, this.corner = n, this.topIntersectPoint = null, this.sideIntersectPoint = null, this.bottomIntersectPoint = null, this.pageWidth = parseInt(a, 10), this.pageHeight = parseInt(l, 10);
1806
- }
1807
- calc(i) {
1808
- try {
1809
- return this.position = this.calcAngleAndPosition(i), this.calculateIntersectPoint(this.position), !0;
1810
- } catch {
1811
- return !1;
1812
- }
1813
- }
1814
- getFlippingClipArea() {
1815
- const i = [];
1816
- let n = !1;
1817
- return i.push(this.rect.topLeft), i.push(this.topIntersectPoint), this.sideIntersectPoint === null ? n = !0 : (i.push(this.sideIntersectPoint), this.bottomIntersectPoint === null && (n = !1)), i.push(this.bottomIntersectPoint), (n || this.corner === "bottom") && i.push(this.rect.bottomLeft), i;
1818
- }
1819
- getBottomClipArea() {
1820
- const i = [];
1821
- return i.push(this.topIntersectPoint), this.corner === "top" ? i.push({ x: this.pageWidth, y: 0 }) : (this.topIntersectPoint !== null && i.push({ x: this.pageWidth, y: 0 }), i.push({ x: this.pageWidth, y: this.pageHeight })), this.sideIntersectPoint !== null ? p.GetDistanceBetweenTwoPoint(this.sideIntersectPoint, this.topIntersectPoint) >= 10 && i.push(this.sideIntersectPoint) : this.corner === "top" && i.push({ x: this.pageWidth, y: this.pageHeight }), i.push(this.bottomIntersectPoint), i.push(this.topIntersectPoint), i;
1822
- }
1823
- getAngle() {
1824
- return this.direction === 0 ? -this.angle : this.angle;
1825
- }
1826
- getRect() {
1827
- return this.rect;
1828
- }
1829
- getPosition() {
1830
- return this.position;
1831
- }
1832
- getActiveCorner() {
1833
- return this.direction === 0 ? this.rect.topLeft : this.rect.topRight;
1834
- }
1835
- getDirection() {
1836
- return this.direction;
1837
- }
1838
- getFlippingProgress() {
1839
- return Math.abs((this.position.x - this.pageWidth) / (2 * this.pageWidth) * 100);
1840
- }
1841
- getCorner() {
1842
- return this.corner;
1843
- }
1844
- getBottomPagePosition() {
1845
- return this.direction === 1 ? { x: this.pageWidth, y: 0 } : { x: 0, y: 0 };
1846
- }
1847
- getShadowStartPoint() {
1848
- return this.corner === "top" ? this.topIntersectPoint : this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.topIntersectPoint;
1849
- }
1850
- getShadowAngle() {
1851
- const i = p.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(), [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]);
1852
- return this.direction === 0 ? i : Math.PI - i;
1853
- }
1854
- calcAngleAndPosition(i) {
1855
- let n = i;
1856
- if (this.updateAngleAndGeometry(n), n = this.corner === "top" ? this.checkPositionAtCenterLine(n, { x: 0, y: 0 }, { x: 0, y: this.pageHeight }) : this.checkPositionAtCenterLine(n, { x: 0, y: this.pageHeight }, { x: 0, y: 0 }), Math.abs(n.x - this.pageWidth) < 1 && Math.abs(n.y) < 1) throw new Error("Point is too small");
1857
- return n;
1858
- }
1859
- updateAngleAndGeometry(i) {
1860
- this.angle = this.calculateAngle(i), this.rect = this.getPageRect(i);
1861
- }
1862
- calculateAngle(i) {
1863
- const n = this.pageWidth - i.x + 1, a = this.corner === "bottom" ? this.pageHeight - i.y : i.y;
1864
- let l = 2 * Math.acos(n / Math.sqrt(a * a + n * n));
1865
- a < 0 && (l = -l);
1866
- const c = Math.PI - l;
1867
- if (!isFinite(l) || c >= 0 && c < 3e-3) throw new Error("The G point is too small");
1868
- return this.corner === "bottom" && (l = -l), l;
1869
- }
1870
- getPageRect(i) {
1871
- return this.corner === "top" ? this.getRectFromBasePoint([{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }, { x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }], i) : this.getRectFromBasePoint([{ x: 0, y: -this.pageHeight }, { x: this.pageWidth, y: -this.pageHeight }, { x: 0, y: 0 }, { x: this.pageWidth, y: 0 }], i);
1872
- }
1873
- getRectFromBasePoint(i, n) {
1874
- return { topLeft: this.getRotatedPoint(i[0], n), topRight: this.getRotatedPoint(i[1], n), bottomLeft: this.getRotatedPoint(i[2], n), bottomRight: this.getRotatedPoint(i[3], n) };
1875
- }
1876
- getRotatedPoint(i, n) {
1877
- return { x: i.x * Math.cos(this.angle) + i.y * Math.sin(this.angle) + n.x, y: i.y * Math.cos(this.angle) - i.x * Math.sin(this.angle) + n.y };
1878
- }
1879
- calculateIntersectPoint(i) {
1880
- const n = { left: -1, top: -1, width: this.pageWidth + 2, height: this.pageHeight + 2 };
1881
- this.corner === "top" ? (this.topIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.bottomLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }])) : (this.topIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.topLeft, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.topLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }]));
1882
- }
1883
- checkPositionAtCenterLine(i, n, a) {
1884
- let l = i;
1885
- const c = p.LimitPointToCircle(n, this.pageWidth, l);
1886
- l !== c && (l = c, this.updateAngleAndGeometry(l));
1887
- const g = Math.sqrt(Math.pow(this.pageWidth, 2) + Math.pow(this.pageHeight, 2));
1888
- let y = this.rect.bottomRight, f = this.rect.topLeft;
1889
- if (this.corner === "bottom" && (y = this.rect.topRight, f = this.rect.bottomLeft), y.x <= 0) {
1890
- const C = p.LimitPointToCircle(a, g, f);
1891
- C !== l && (l = C, this.updateAngleAndGeometry(l));
1892
- }
1893
- return l;
1894
- }
1895
- getSegmentToShadowLine() {
1896
- const i = this.getShadowStartPoint();
1897
- return [i, i !== this.sideIntersectPoint && this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.bottomIntersectPoint];
1898
- }
1899
- }
1900
- class I {
1901
- constructor(i, n) {
1902
- this.flippingPage = null, this.bottomPage = null, this.calc = null, this.state = "read", this.render = i, this.app = n;
1903
- }
1904
- fold(i) {
1905
- this.setState("user_fold"), this.calc === null && this.start(i), this.do(this.render.convertToPage(i));
1906
- }
1907
- flip(i) {
1908
- if (this.app.getSettings().disableFlipByClick && !this.isPointOnCorners(i) || (this.calc !== null && this.render.finishAnimation(), !this.start(i))) return;
1909
- const n = this.getBoundsRect();
1910
- this.setState("flipping");
1911
- const a = n.height / 10, l = this.calc.getCorner() === "bottom" ? n.height - a : a, c = this.calc.getCorner() === "bottom" ? n.height : 0;
1912
- this.calc.calc({ x: n.pageWidth - a, y: l }), this.animateFlippingTo({ x: n.pageWidth - a, y: l }, { x: -n.pageWidth, y: c }, !0);
1913
- }
1914
- start(i) {
1915
- this.reset();
1916
- const n = this.render.convertToBook(i), a = this.getBoundsRect(), l = this.getDirectionByPoint(n), c = n.y >= a.height / 2 ? "bottom" : "top";
1917
- if (!this.checkDirection(l)) return !1;
1918
- try {
1919
- if (this.flippingPage = this.app.getPageCollection().getFlippingPage(l), this.bottomPage = this.app.getPageCollection().getBottomPage(l), this.render.getOrientation() === "landscape") if (l === 1) {
1920
- const g = this.app.getPageCollection().nextBy(this.flippingPage);
1921
- g !== null && this.flippingPage.getDensity() !== g.getDensity() && (this.flippingPage.setDrawingDensity("hard"), g.setDrawingDensity("hard"));
1922
- } else {
1923
- const g = this.app.getPageCollection().prevBy(this.flippingPage);
1924
- g !== null && this.flippingPage.getDensity() !== g.getDensity() && (this.flippingPage.setDrawingDensity("hard"), g.setDrawingDensity("hard"));
1925
- }
1926
- return this.render.setDirection(l), this.calc = new M(l, c, a.pageWidth.toString(10), a.height.toString(10)), !0;
1927
- } catch {
1928
- return !1;
1929
- }
1930
- }
1931
- do(i) {
1932
- if (this.calc !== null && this.calc.calc(i)) {
1933
- const n = this.calc.getFlippingProgress();
1934
- this.bottomPage.setArea(this.calc.getBottomClipArea()), this.bottomPage.setPosition(this.calc.getBottomPagePosition()), this.bottomPage.setAngle(0), this.bottomPage.setHardAngle(0), this.flippingPage.setArea(this.calc.getFlippingClipArea()), this.flippingPage.setPosition(this.calc.getActiveCorner()), this.flippingPage.setAngle(this.calc.getAngle()), this.calc.getDirection() === 0 ? this.flippingPage.setHardAngle(90 * (200 - 2 * n) / 100) : this.flippingPage.setHardAngle(-90 * (200 - 2 * n) / 100), this.render.setPageRect(this.calc.getRect()), this.render.setBottomPage(this.bottomPage), this.render.setFlippingPage(this.flippingPage), this.render.setShadowData(this.calc.getShadowStartPoint(), this.calc.getShadowAngle(), n, this.calc.getDirection());
1935
- }
1936
- }
1937
- flipToPage(i, n) {
1938
- const a = this.app.getPageCollection().getCurrentSpreadIndex(), l = this.app.getPageCollection().getSpreadIndexByPage(i);
1939
- try {
1940
- l > a && (this.app.getPageCollection().setCurrentSpreadIndex(l - 1), this.flipNext(n)), l < a && (this.app.getPageCollection().setCurrentSpreadIndex(l + 1), this.flipPrev(n));
1941
- } catch {
1942
- }
1943
- }
1944
- flipNext(i) {
1945
- this.flip({ x: this.render.getRect().left + 2 * this.render.getRect().pageWidth - 10, y: i === "top" ? 1 : this.render.getRect().height - 2 });
1946
- }
1947
- flipPrev(i) {
1948
- this.flip({ x: 10, y: i === "top" ? 1 : this.render.getRect().height - 2 });
1949
- }
1950
- stopMove() {
1951
- if (this.calc === null) return;
1952
- const i = this.calc.getPosition(), n = this.getBoundsRect(), a = this.calc.getCorner() === "bottom" ? n.height : 0;
1953
- i.x <= 0 ? this.animateFlippingTo(i, { x: -n.pageWidth, y: a }, !0) : this.animateFlippingTo(i, { x: n.pageWidth, y: a }, !1);
1954
- }
1955
- showCorner(i) {
1956
- if (!this.checkState("read", "fold_corner")) return;
1957
- const n = this.getBoundsRect(), a = n.pageWidth;
1958
- if (this.isPointOnCorners(i)) if (this.calc === null) {
1959
- if (!this.start(i)) return;
1960
- this.setState("fold_corner"), this.calc.calc({ x: a - 1, y: 1 });
1961
- const l = 50, c = this.calc.getCorner() === "bottom" ? n.height - 1 : 1, g = this.calc.getCorner() === "bottom" ? n.height - l : l;
1962
- this.animateFlippingTo({ x: a - 1, y: c }, { x: a - l, y: g }, !1, !1);
1963
- } else this.do(this.render.convertToPage(i));
1964
- else this.setState("read"), this.render.finishAnimation(), this.stopMove();
1965
- }
1966
- animateFlippingTo(i, n, a, l = !0) {
1967
- const c = p.GetCordsFromTwoPoint(i, n), g = [];
1968
- for (const f of c) g.push(() => this.do(f));
1969
- const y = this.getAnimationDuration(c.length);
1970
- this.render.startAnimation(g, y, () => {
1971
- this.calc && (a && (this.calc.getDirection() === 1 ? this.app.turnToPrevPage() : this.app.turnToNextPage()), l && (this.render.setBottomPage(null), this.render.setFlippingPage(null), this.render.clearShadow(), this.setState("read"), this.reset()));
1972
- });
1973
- }
1974
- getCalculation() {
1975
- return this.calc;
1976
- }
1977
- getState() {
1978
- return this.state;
1979
- }
1980
- setState(i) {
1981
- this.state !== i && (this.app.updateState(i), this.state = i);
1982
- }
1983
- getDirectionByPoint(i) {
1984
- const n = this.getBoundsRect();
1985
- if (this.render.getOrientation() === "portrait") {
1986
- if (i.x - n.pageWidth <= n.width / 5) return 1;
1987
- } else if (i.x < n.width / 2) return 1;
1988
- return 0;
1989
- }
1990
- getAnimationDuration(i) {
1991
- const n = this.app.getSettings().flippingTime;
1992
- return i >= 1e3 ? n : i / 1e3 * n;
1993
- }
1994
- checkDirection(i) {
1995
- return i === 0 ? this.app.getCurrentPageIndex() < this.app.getPageCount() - 1 : this.app.getCurrentPageIndex() >= 1;
1996
- }
1997
- reset() {
1998
- this.calc = null, this.flippingPage = null, this.bottomPage = null;
1999
- }
2000
- getBoundsRect() {
2001
- return this.render.getRect();
2002
- }
2003
- checkState(...i) {
2004
- for (const n of i) if (this.state === n) return !0;
2005
- return !1;
2006
- }
2007
- isPointOnCorners(i) {
2008
- const n = this.getBoundsRect(), a = n.pageWidth, l = Math.sqrt(Math.pow(a, 2) + Math.pow(n.height, 2)) / 5, c = this.render.convertToBook(i);
2009
- return c.x > 0 && c.y > 0 && c.x < n.width && c.y < n.height && (c.x < l || c.x > n.width - l) && (c.y < l || c.y > n.height - l);
2010
- }
2011
- }
2012
- class S {
2013
- constructor(i, n) {
2014
- this.leftPage = null, this.rightPage = null, this.flippingPage = null, this.bottomPage = null, this.direction = null, this.orientation = null, this.shadow = null, this.animation = null, this.pageRect = null, this.boundsRect = null, this.timer = 0, this.safari = !1, this.setting = n, this.app = i;
2015
- const a = new RegExp("Version\\/[\\d\\.]+.*Safari/");
2016
- this.safari = a.exec(window.navigator.userAgent) !== null;
2017
- }
2018
- render(i) {
2019
- if (this.animation !== null) {
2020
- const n = Math.round((i - this.animation.startedAt) / this.animation.durationFrame);
2021
- n < this.animation.frames.length ? this.animation.frames[n]() : (this.animation.onAnimateEnd(), this.animation = null);
2022
- }
2023
- this.timer = i, this.drawFrame();
2024
- }
2025
- start() {
2026
- this.update();
2027
- const i = (n) => {
2028
- this.render(n), requestAnimationFrame(i);
2029
- };
2030
- requestAnimationFrame(i);
2031
- }
2032
- startAnimation(i, n, a) {
2033
- this.finishAnimation(), this.animation = { frames: i, duration: n, durationFrame: n / i.length, onAnimateEnd: a, startedAt: this.timer };
2034
- }
2035
- finishAnimation() {
2036
- this.animation !== null && (this.animation.frames[this.animation.frames.length - 1](), this.animation.onAnimateEnd !== null && this.animation.onAnimateEnd()), this.animation = null;
2037
- }
2038
- update() {
2039
- this.boundsRect = null;
2040
- const i = this.calculateBoundsRect();
2041
- this.orientation !== i && (this.orientation = i, this.app.updateOrientation(i));
2042
- }
2043
- calculateBoundsRect() {
2044
- let i = "landscape";
2045
- const n = this.getBlockWidth(), a = n / 2, l = this.getBlockHeight() / 2, c = this.setting.width / this.setting.height;
2046
- let g = this.setting.width, y = this.setting.height, f = a - g;
2047
- return this.setting.size === "stretch" ? (n < 2 * this.setting.minWidth && this.app.getSettings().usePortrait && (i = "portrait"), g = i === "portrait" ? this.getBlockWidth() : this.getBlockWidth() / 2, g > this.setting.maxWidth && (g = this.setting.maxWidth), y = g / c, y > this.getBlockHeight() && (y = this.getBlockHeight(), g = y * c), f = i === "portrait" ? a - g / 2 - g : a - g) : n < 2 * g && this.app.getSettings().usePortrait && (i = "portrait", f = a - g / 2 - g), this.boundsRect = { left: f, top: l - y / 2, width: 2 * g, height: y, pageWidth: g }, i;
2048
- }
2049
- setShadowData(i, n, a, l) {
2050
- if (!this.app.getSettings().drawShadow) return;
2051
- const c = 100 * this.getSettings().maxShadowOpacity;
2052
- this.shadow = { pos: i, angle: n, width: 3 * this.getRect().pageWidth / 4 * a / 100, opacity: (100 - a) * c / 100 / 100, direction: l, progress: 2 * a };
2053
- }
2054
- clearShadow() {
2055
- this.shadow = null;
2056
- }
2057
- getBlockWidth() {
2058
- return this.app.getUI().getDistElement().offsetWidth;
2059
- }
2060
- getBlockHeight() {
2061
- return this.app.getUI().getDistElement().offsetHeight;
2062
- }
2063
- getDirection() {
2064
- return this.direction;
2065
- }
2066
- getRect() {
2067
- return this.boundsRect === null && this.calculateBoundsRect(), this.boundsRect;
2068
- }
2069
- getSettings() {
2070
- return this.app.getSettings();
2071
- }
2072
- getOrientation() {
2073
- return this.orientation;
2074
- }
2075
- setPageRect(i) {
2076
- this.pageRect = i;
2077
- }
2078
- setDirection(i) {
2079
- this.direction = i;
2080
- }
2081
- setRightPage(i) {
2082
- i !== null && i.setOrientation(1), this.rightPage = i;
2083
- }
2084
- setLeftPage(i) {
2085
- i !== null && i.setOrientation(0), this.leftPage = i;
2086
- }
2087
- setBottomPage(i) {
2088
- i !== null && i.setOrientation(this.direction === 1 ? 0 : 1), this.bottomPage = i;
2089
- }
2090
- setFlippingPage(i) {
2091
- i !== null && i.setOrientation(this.direction === 0 && this.orientation !== "portrait" ? 0 : 1), this.flippingPage = i;
2092
- }
2093
- convertToBook(i) {
2094
- const n = this.getRect();
2095
- return { x: i.x - n.left, y: i.y - n.top };
2096
- }
2097
- isSafari() {
2098
- return this.safari;
2099
- }
2100
- convertToPage(i, n) {
2101
- n || (n = this.direction);
2102
- const a = this.getRect();
2103
- return { x: n === 0 ? i.x - a.left - a.width / 2 : a.width / 2 - i.x + a.left, y: i.y - a.top };
2104
- }
2105
- convertToGlobal(i, n) {
2106
- if (n || (n = this.direction), i == null) return null;
2107
- const a = this.getRect();
2108
- return { x: n === 0 ? i.x + a.left + a.width / 2 : a.width / 2 - i.x + a.left, y: i.y + a.top };
2109
- }
2110
- convertRectToGlobal(i, n) {
2111
- return n || (n = this.direction), { topLeft: this.convertToGlobal(i.topLeft, n), topRight: this.convertToGlobal(i.topRight, n), bottomLeft: this.convertToGlobal(i.bottomLeft, n), bottomRight: this.convertToGlobal(i.bottomRight, n) };
2112
- }
2113
- }
2114
- class T extends S {
2115
- constructor(i, n, a) {
2116
- super(i, n), this.canvas = a, this.ctx = a.getContext("2d");
2117
- }
2118
- getContext() {
2119
- return this.ctx;
2120
- }
2121
- reload() {
2122
- }
2123
- drawFrame() {
2124
- this.clear(), this.orientation !== "portrait" && this.leftPage != null && this.leftPage.simpleDraw(0), this.rightPage != null && this.rightPage.simpleDraw(1), this.bottomPage != null && this.bottomPage.draw(), this.drawBookShadow(), this.flippingPage != null && this.flippingPage.draw(), this.shadow != null && (this.drawOuterShadow(), this.drawInnerShadow());
2125
- const i = this.getRect();
2126
- this.orientation === "portrait" && (this.ctx.beginPath(), this.ctx.rect(i.left + i.pageWidth, i.top, i.width, i.height), this.ctx.clip());
2127
- }
2128
- drawBookShadow() {
2129
- const i = this.getRect();
2130
- this.ctx.save(), this.ctx.beginPath();
2131
- const n = i.width / 20;
2132
- this.ctx.rect(i.left, i.top, i.width, i.height);
2133
- const a = { x: i.left + i.width / 2 - n / 2, y: 0 };
2134
- this.ctx.translate(a.x, a.y);
2135
- const l = this.ctx.createLinearGradient(0, 0, n, 0);
2136
- l.addColorStop(0, "rgba(0, 0, 0, 0)"), l.addColorStop(0.4, "rgba(0, 0, 0, 0.2)"), l.addColorStop(0.49, "rgba(0, 0, 0, 0.1)"), l.addColorStop(0.5, "rgba(0, 0, 0, 0.5)"), l.addColorStop(0.51, "rgba(0, 0, 0, 0.4)"), l.addColorStop(1, "rgba(0, 0, 0, 0)"), this.ctx.clip(), this.ctx.fillStyle = l, this.ctx.fillRect(0, 0, n, 2 * i.height), this.ctx.restore();
2137
- }
2138
- drawOuterShadow() {
2139
- const i = this.getRect();
2140
- this.ctx.save(), this.ctx.beginPath(), this.ctx.rect(i.left, i.top, i.width, i.height);
2141
- const n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y });
2142
- this.ctx.translate(n.x, n.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
2143
- const a = this.ctx.createLinearGradient(0, 0, this.shadow.width, 0);
2144
- this.shadow.direction === 0 ? (this.ctx.translate(0, -100), a.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), a.addColorStop(1, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(-this.shadow.width, -100), a.addColorStop(0, "rgba(0, 0, 0, 0)"), a.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")")), this.ctx.clip(), this.ctx.fillStyle = a, this.ctx.fillRect(0, 0, this.shadow.width, 2 * i.height), this.ctx.restore();
2145
- }
2146
- drawInnerShadow() {
2147
- const i = this.getRect();
2148
- this.ctx.save(), this.ctx.beginPath();
2149
- const n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), a = this.convertRectToGlobal(this.pageRect);
2150
- this.ctx.moveTo(a.topLeft.x, a.topLeft.y), this.ctx.lineTo(a.topRight.x, a.topRight.y), this.ctx.lineTo(a.bottomRight.x, a.bottomRight.y), this.ctx.lineTo(a.bottomLeft.x, a.bottomLeft.y), this.ctx.translate(n.x, n.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
2151
- const l = 3 * this.shadow.width / 4, c = this.ctx.createLinearGradient(0, 0, l, 0);
2152
- this.shadow.direction === 0 ? (this.ctx.translate(-l, -100), c.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), c.addColorStop(0.9, "rgba(0, 0, 0, 0.05)"), c.addColorStop(0.7, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), c.addColorStop(0, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(0, -100), c.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), c.addColorStop(0.1, "rgba(0, 0, 0, 0.05)"), c.addColorStop(0.3, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), c.addColorStop(1, "rgba(0, 0, 0, 0)")), this.ctx.clip(), this.ctx.fillStyle = c, this.ctx.fillRect(0, 0, l, 2 * i.height), this.ctx.restore();
2153
- }
2154
- clear() {
2155
- this.ctx.fillStyle = "white", this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
2156
- }
2157
- }
2158
- class E {
2159
- constructor(i, n, a) {
2160
- this.touchPoint = null, this.swipeTimeout = 250, this.onResize = () => {
2161
- this.update();
2162
- }, this.onMouseDown = (c) => {
2163
- if (this.checkTarget(c.target)) {
2164
- const g = this.getMousePos(c.clientX, c.clientY);
2165
- this.app.startUserTouch(g), c.preventDefault();
2166
- }
2167
- }, this.onTouchStart = (c) => {
2168
- if (this.checkTarget(c.target) && c.changedTouches.length > 0) {
2169
- const g = c.changedTouches[0], y = this.getMousePos(g.clientX, g.clientY);
2170
- this.touchPoint = { point: y, time: Date.now() }, setTimeout(() => {
2171
- this.touchPoint !== null && this.app.startUserTouch(y);
2172
- }, this.swipeTimeout), this.app.getSettings().mobileScrollSupport || c.preventDefault();
2173
- }
2174
- }, this.onMouseUp = (c) => {
2175
- const g = this.getMousePos(c.clientX, c.clientY);
2176
- this.app.userStop(g);
2177
- }, this.onMouseMove = (c) => {
2178
- const g = this.getMousePos(c.clientX, c.clientY);
2179
- this.app.userMove(g, !1);
2180
- }, this.onTouchMove = (c) => {
2181
- if (c.changedTouches.length > 0) {
2182
- const g = c.changedTouches[0], y = this.getMousePos(g.clientX, g.clientY);
2183
- this.app.getSettings().mobileScrollSupport ? (this.touchPoint !== null && (Math.abs(this.touchPoint.point.x - y.x) > 10 || this.app.getState() !== "read") && c.cancelable && this.app.userMove(y, !0), this.app.getState() !== "read" && c.preventDefault()) : this.app.userMove(y, !0);
2184
- }
2185
- }, this.onTouchEnd = (c) => {
2186
- if (c.changedTouches.length > 0) {
2187
- const g = c.changedTouches[0], y = this.getMousePos(g.clientX, g.clientY);
2188
- let f = !1;
2189
- if (this.touchPoint !== null) {
2190
- const C = y.x - this.touchPoint.point.x, R = Math.abs(y.y - this.touchPoint.point.y);
2191
- Math.abs(C) > this.swipeDistance && R < 2 * this.swipeDistance && Date.now() - this.touchPoint.time < this.swipeTimeout && (C > 0 ? this.app.flipPrev(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom") : this.app.flipNext(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom"), f = !0), this.touchPoint = null;
2192
- }
2193
- this.app.userStop(y, f);
2194
- }
2195
- }, this.parentElement = i, i.classList.add("stf__parent"), i.insertAdjacentHTML("afterbegin", '<div class="stf__wrapper"></div>'), this.wrapper = i.querySelector(".stf__wrapper"), this.app = n;
2196
- const l = this.app.getSettings().usePortrait ? 1 : 2;
2197
- i.style.minWidth = a.minWidth * l + "px", i.style.minHeight = a.minHeight + "px", a.size === "fixed" && (i.style.minWidth = a.width * l + "px", i.style.minHeight = a.height + "px"), a.autoSize && (i.style.width = "100%", i.style.maxWidth = 2 * a.maxWidth + "px"), i.style.display = "block", window.addEventListener("resize", this.onResize, !1), this.swipeDistance = a.swipeDistance;
2198
- }
2199
- destroy() {
2200
- this.app.getSettings().useMouseEvents && this.removeHandlers(), this.distElement.remove(), this.wrapper.remove();
2201
- }
2202
- getDistElement() {
2203
- return this.distElement;
2204
- }
2205
- getWrapper() {
2206
- return this.wrapper;
2207
- }
2208
- setOrientationStyle(i) {
2209
- this.wrapper.classList.remove("--portrait", "--landscape"), i === "portrait" ? (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / this.app.getSettings().width * 100 + "%"), this.wrapper.classList.add("--portrait")) : (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / (2 * this.app.getSettings().width) * 100 + "%"), this.wrapper.classList.add("--landscape")), this.update();
2210
- }
2211
- removeHandlers() {
2212
- window.removeEventListener("resize", this.onResize), this.distElement.removeEventListener("mousedown", this.onMouseDown), this.distElement.removeEventListener("touchstart", this.onTouchStart), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("touchend", this.onTouchEnd);
2213
- }
2214
- setHandlers() {
2215
- window.addEventListener("resize", this.onResize, !1), this.app.getSettings().useMouseEvents && (this.distElement.addEventListener("mousedown", this.onMouseDown), this.distElement.addEventListener("touchstart", this.onTouchStart), window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("touchmove", this.onTouchMove, { passive: !this.app.getSettings().mobileScrollSupport }), window.addEventListener("mouseup", this.onMouseUp), window.addEventListener("touchend", this.onTouchEnd));
2216
- }
2217
- getMousePos(i, n) {
2218
- const a = this.distElement.getBoundingClientRect();
2219
- return { x: i - a.left, y: n - a.top };
2220
- }
2221
- checkTarget(i) {
2222
- return !this.app.getSettings().clickEventForward || !["a", "button"].includes(i.tagName.toLowerCase());
2223
- }
2224
- }
2225
- class W extends E {
2226
- constructor(i, n, a, l) {
2227
- super(i, n, a), this.wrapper.insertAdjacentHTML("afterbegin", '<div class="stf__block"></div>'), this.distElement = i.querySelector(".stf__block"), this.items = l;
2228
- for (const c of l) this.distElement.appendChild(c);
2229
- this.setHandlers();
2230
- }
2231
- clear() {
2232
- for (const i of this.items) this.parentElement.appendChild(i);
2233
- }
2234
- updateItems(i) {
2235
- this.removeHandlers(), this.distElement.innerHTML = "";
2236
- for (const n of i) this.distElement.appendChild(n);
2237
- this.items = i, this.setHandlers();
2238
- }
2239
- update() {
2240
- this.app.getRender().update();
2241
- }
2242
- }
2243
- class B extends E {
2244
- constructor(i, n, a) {
2245
- super(i, n, a), this.wrapper.innerHTML = '<canvas class="stf__canvas"></canvas>', this.canvas = i.querySelectorAll("canvas")[0], this.distElement = this.canvas, this.resizeCanvas(), this.setHandlers();
2246
- }
2247
- resizeCanvas() {
2248
- const i = getComputedStyle(this.canvas), n = parseInt(i.getPropertyValue("width"), 10), a = parseInt(i.getPropertyValue("height"), 10);
2249
- this.canvas.width = n, this.canvas.height = a;
2250
- }
2251
- getCanvas() {
2252
- return this.canvas;
2253
- }
2254
- update() {
2255
- this.resizeCanvas(), this.app.getRender().update();
2256
- }
2257
- }
2258
- class N extends S {
2259
- constructor(i, n, a) {
2260
- super(i, n), this.outerShadow = null, this.innerShadow = null, this.hardShadow = null, this.hardInnerShadow = null, this.element = a, this.createShadows();
2261
- }
2262
- createShadows() {
2263
- this.element.insertAdjacentHTML("beforeend", `<div class="stf__outerShadow"></div>
2264
- <div class="stf__innerShadow"></div>
2265
- <div class="stf__hardShadow"></div>
2266
- <div class="stf__hardInnerShadow"></div>`), this.outerShadow = this.element.querySelector(".stf__outerShadow"), this.innerShadow = this.element.querySelector(".stf__innerShadow"), this.hardShadow = this.element.querySelector(".stf__hardShadow"), this.hardInnerShadow = this.element.querySelector(".stf__hardInnerShadow");
2267
- }
2268
- clearShadow() {
2269
- super.clearShadow(), this.outerShadow.style.cssText = "display: none", this.innerShadow.style.cssText = "display: none", this.hardShadow.style.cssText = "display: none", this.hardInnerShadow.style.cssText = "display: none";
2270
- }
2271
- reload() {
2272
- this.element.querySelector(".stf__outerShadow") || this.createShadows();
2273
- }
2274
- drawHardInnerShadow() {
2275
- const i = this.getRect(), n = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
2276
- let a = (100 - n) * (2.5 * i.pageWidth) / 100 + 20;
2277
- a > i.pageWidth && (a = i.pageWidth);
2278
- let l = `
2279
- display: block;
2280
- z-index: ${(this.getSettings().startZIndex + 5).toString(10)};
2281
- width: ${a}px;
2282
- height: ${i.height}px;
2283
- background: linear-gradient(to right,
2284
- rgba(0, 0, 0, ${this.shadow.opacity * n / 100}) 5%,
2285
- rgba(0, 0, 0, 0) 100%);
2286
- left: ${i.left + i.width / 2}px;
2287
- transform-origin: 0 0;
2288
- `;
2289
- l += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0);" : "transform: translate3d(0, 0, 0) rotateY(180deg);", this.hardInnerShadow.style.cssText = l;
2290
- }
2291
- drawHardOuterShadow() {
2292
- const i = this.getRect();
2293
- let n = (100 - (this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress)) * (2.5 * i.pageWidth) / 100 + 20;
2294
- n > i.pageWidth && (n = i.pageWidth);
2295
- let a = `
2296
- display: block;
2297
- z-index: ${(this.getSettings().startZIndex + 4).toString(10)};
2298
- width: ${n}px;
2299
- height: ${i.height}px;
2300
- background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
2301
- left: ${i.left + i.width / 2}px;
2302
- transform-origin: 0 0;
2303
- `;
2304
- a += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0) rotateY(180deg);" : "transform: translate3d(0, 0, 0);", this.hardShadow.style.cssText = a;
2305
- }
2306
- drawInnerShadow() {
2307
- const i = this.getRect(), n = 3 * this.shadow.width / 4, a = this.getDirection() === 0 ? n : 0, l = this.getDirection() === 0 ? "to left" : "to right", c = this.convertToGlobal(this.shadow.pos), g = this.shadow.angle + 3 * Math.PI / 2, y = [this.pageRect.topLeft, this.pageRect.topRight, this.pageRect.bottomRight, this.pageRect.bottomLeft];
2308
- let f = "polygon( ";
2309
- for (const R of y) {
2310
- let F = this.getDirection() === 1 ? { x: -R.x + this.shadow.pos.x, y: R.y - this.shadow.pos.y } : { x: R.x - this.shadow.pos.x, y: R.y - this.shadow.pos.y };
2311
- F = p.GetRotatedPoint(F, { x: a, y: 100 }, g), f += F.x + "px " + F.y + "px, ";
2312
- }
2313
- f = f.slice(0, -2), f += ")";
2314
- const C = `
2315
- display: block;
2316
- z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
2317
- width: ${n}px;
2318
- height: ${2 * i.height}px;
2319
- background: linear-gradient(${l},
2320
- rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
2321
- rgba(0, 0, 0, 0.05) 15%,
2322
- rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
2323
- rgba(0, 0, 0, 0) 100%);
2324
- transform-origin: ${a}px 100px;
2325
- transform: translate3d(${c.x - a}px, ${c.y - 100}px, 0) rotate(${g}rad);
2326
- clip-path: ${f};
2327
- -webkit-clip-path: ${f};
2328
- `;
2329
- this.innerShadow.style.cssText = C;
2330
- }
2331
- drawOuterShadow() {
2332
- const i = this.getRect(), n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), a = this.shadow.angle + 3 * Math.PI / 2, l = this.getDirection() === 1 ? this.shadow.width : 0, c = this.getDirection() === 0 ? "to right" : "to left", g = [{ x: 0, y: 0 }, { x: i.pageWidth, y: 0 }, { x: i.pageWidth, y: i.height }, { x: 0, y: i.height }];
2333
- let y = "polygon( ";
2334
- for (const C of g) if (C !== null) {
2335
- let R = this.getDirection() === 1 ? { x: -C.x + this.shadow.pos.x, y: C.y - this.shadow.pos.y } : { x: C.x - this.shadow.pos.x, y: C.y - this.shadow.pos.y };
2336
- R = p.GetRotatedPoint(R, { x: l, y: 100 }, a), y += R.x + "px " + R.y + "px, ";
2337
- }
2338
- y = y.slice(0, -2), y += ")";
2339
- const f = `
2340
- display: block;
2341
- z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
2342
- width: ${this.shadow.width}px;
2343
- height: ${2 * i.height}px;
2344
- background: linear-gradient(${c}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
2345
- transform-origin: ${l}px 100px;
2346
- transform: translate3d(${n.x - l}px, ${n.y - 100}px, 0) rotate(${a}rad);
2347
- clip-path: ${y};
2348
- -webkit-clip-path: ${y};
2349
- `;
2350
- this.outerShadow.style.cssText = f;
2351
- }
2352
- drawLeftPage() {
2353
- this.orientation !== "portrait" && this.leftPage !== null && (this.direction === 1 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.leftPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.leftPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.leftPage.draw(this.flippingPage.getDrawingDensity())) : this.leftPage.simpleDraw(0));
2354
- }
2355
- drawRightPage() {
2356
- this.rightPage !== null && (this.direction === 0 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.rightPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.rightPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.rightPage.draw(this.flippingPage.getDrawingDensity())) : this.rightPage.simpleDraw(1));
2357
- }
2358
- drawBottomPage() {
2359
- if (this.bottomPage === null) return;
2360
- const i = this.flippingPage != null ? this.flippingPage.getDrawingDensity() : null;
2361
- this.orientation === "portrait" && this.direction === 1 || (this.bottomPage.getElement().style.zIndex = (this.getSettings().startZIndex + 3).toString(10), this.bottomPage.draw(i));
2362
- }
2363
- drawFrame() {
2364
- this.clear(), this.drawLeftPage(), this.drawRightPage(), this.drawBottomPage(), this.flippingPage != null && (this.flippingPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.flippingPage.draw()), this.shadow != null && this.flippingPage !== null && (this.flippingPage.getDrawingDensity() === "soft" ? (this.drawOuterShadow(), this.drawInnerShadow()) : (this.drawHardOuterShadow(), this.drawHardInnerShadow()));
2365
- }
2366
- clear() {
2367
- for (const i of this.app.getPageCollection().getPages()) i !== this.leftPage && i !== this.rightPage && i !== this.flippingPage && i !== this.bottomPage && (i.getElement().style.cssText = "display: none"), i.getTemporaryCopy() !== this.flippingPage && i.hideTemporaryCopy();
2368
- }
2369
- update() {
2370
- super.update(), this.rightPage !== null && this.rightPage.setOrientation(1), this.leftPage !== null && this.leftPage.setOrientation(0);
2371
- }
2372
- }
2373
- class H {
2374
- constructor() {
2375
- this._default = { startPage: 0, size: "fixed", width: 0, height: 0, minWidth: 0, maxWidth: 0, minHeight: 0, maxHeight: 0, drawShadow: !0, flippingTime: 1e3, usePortrait: !0, startZIndex: 0, autoSize: !0, maxShadowOpacity: 1, showCover: !1, mobileScrollSupport: !0, swipeDistance: 30, clickEventForward: !0, useMouseEvents: !0, showPageCorners: !0, disableFlipByClick: !1 };
2376
- }
2377
- getSettings(i) {
2378
- const n = this._default;
2379
- if (Object.assign(n, i), n.size !== "stretch" && n.size !== "fixed") throw new Error('Invalid size type. Available only "fixed" and "stretch" value');
2380
- if (n.width <= 0 || n.height <= 0) throw new Error("Invalid width or height");
2381
- if (n.flippingTime <= 0) throw new Error("Invalid flipping time");
2382
- return n.size === "stretch" ? (n.minWidth <= 0 && (n.minWidth = 100), n.maxWidth < n.minWidth && (n.maxWidth = 2e3), n.minHeight <= 0 && (n.minHeight = 100), n.maxHeight < n.minHeight && (n.maxHeight = 2e3)) : (n.minWidth = n.width, n.maxWidth = n.width, n.minHeight = n.height, n.maxHeight = n.height), n;
2383
- }
2384
- }
2385
- (function(m, i) {
2386
- i === void 0 && (i = {});
2387
- var n = i.insertAt;
2388
- if (typeof document < "u") {
2389
- var a = document.head || document.getElementsByTagName("head")[0], l = document.createElement("style");
2390
- l.type = "text/css", n === "top" && a.firstChild ? a.insertBefore(l, a.firstChild) : a.appendChild(l), l.styleSheet ? l.styleSheet.cssText = m : l.appendChild(document.createTextNode(m));
2391
- }
2392
- })(`.stf__parent {
2393
- position: relative;
2394
- display: block;
2395
- box-sizing: border-box;
2396
- transform: translateZ(0);
2397
-
2398
- -ms-touch-action: pan-y;
2399
- touch-action: pan-y;
2400
- }
2401
-
2402
- .sft__wrapper {
2403
- position: relative;
2404
- width: 100%;
2405
- box-sizing: border-box;
2406
- }
2407
-
2408
- .stf__parent canvas {
2409
- position: absolute;
2410
- width: 100%;
2411
- height: 100%;
2412
- left: 0;
2413
- top: 0;
2414
- }
2415
-
2416
- .stf__block {
2417
- position: absolute;
2418
- width: 100%;
2419
- height: 100%;
2420
- box-sizing: border-box;
2421
- perspective: 2000px;
2422
- }
2423
-
2424
- .stf__item {
2425
- display: none;
2426
- position: absolute;
2427
- transform-style: preserve-3d;
2428
- }
2429
-
2430
- .stf__outerShadow {
2431
- position: absolute;
2432
- left: 0;
2433
- top: 0;
2434
- }
2435
-
2436
- .stf__innerShadow {
2437
- position: absolute;
2438
- left: 0;
2439
- top: 0;
2440
- }
2441
-
2442
- .stf__hardShadow {
2443
- position: absolute;
2444
- left: 0;
2445
- top: 0;
2446
- }
2447
-
2448
- .stf__hardInnerShadow {
2449
- position: absolute;
2450
- left: 0;
2451
- top: 0;
2452
- }`), s.PageFlip = class extends class {
2453
- constructor() {
2454
- this.events = /* @__PURE__ */ new Map();
2455
- }
2456
- on(m, i) {
2457
- return this.events.has(m) ? this.events.get(m).push(i) : this.events.set(m, [i]), this;
2458
- }
2459
- off(m) {
2460
- this.events.delete(m);
2461
- }
2462
- trigger(m, i, n = null) {
2463
- if (this.events.has(m)) for (const a of this.events.get(m)) a({ data: n, object: i });
2464
- }
2465
- } {
2466
- constructor(m, i) {
2467
- super(), this.isUserTouch = !1, this.isUserMove = !1, this.setting = null, this.pages = null, this.setting = new H().getSettings(i), this.block = m;
2468
- }
2469
- destroy() {
2470
- this.ui.destroy(), this.block.remove();
2471
- }
2472
- update() {
2473
- this.render.update(), this.pages.show();
2474
- }
2475
- loadFromImages(m) {
2476
- this.ui = new B(this.block, this, this.setting);
2477
- const i = this.ui.getCanvas();
2478
- this.render = new T(this, this.setting, i), this.flipController = new I(this.render, this), this.pages = new u(this, this.render, m), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
2479
- this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
2480
- }, 1);
2481
- }
2482
- loadFromHTML(m) {
2483
- this.ui = new W(this.block, this, this.setting, m), this.render = new N(this, this.setting, this.ui.getDistElement()), this.flipController = new I(this.render, this), this.pages = new x(this, this.render, this.ui.getDistElement(), m), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
2484
- this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
2485
- }, 1);
2486
- }
2487
- updateFromImages(m) {
2488
- const i = this.pages.getCurrentPageIndex();
2489
- this.pages.destroy(), this.pages = new u(this, this.render, m), this.pages.load(), this.pages.show(i), this.trigger("update", this, { page: i, mode: this.render.getOrientation() });
2490
- }
2491
- updateFromHtml(m) {
2492
- const i = this.pages.getCurrentPageIndex();
2493
- this.pages.destroy(), this.pages = new x(this, this.render, this.ui.getDistElement(), m), this.pages.load(), this.ui.updateItems(m), this.render.reload(), this.pages.show(i), this.trigger("update", this, { page: i, mode: this.render.getOrientation() });
2494
- }
2495
- clear() {
2496
- this.pages.destroy(), this.ui.clear();
2497
- }
2498
- turnToPrevPage() {
2499
- this.pages.showPrev();
2500
- }
2501
- turnToNextPage() {
2502
- this.pages.showNext();
2503
- }
2504
- turnToPage(m) {
2505
- this.pages.show(m);
2506
- }
2507
- flipNext(m = "top") {
2508
- this.flipController.flipNext(m);
2509
- }
2510
- flipPrev(m = "top") {
2511
- this.flipController.flipPrev(m);
2512
- }
2513
- flip(m, i = "top") {
2514
- this.flipController.flipToPage(m, i);
2515
- }
2516
- updateState(m) {
2517
- this.trigger("changeState", this, m);
2518
- }
2519
- updatePageIndex(m) {
2520
- this.trigger("flip", this, m);
2521
- }
2522
- updateOrientation(m) {
2523
- this.ui.setOrientationStyle(m), this.update(), this.trigger("changeOrientation", this, m);
2524
- }
2525
- getPageCount() {
2526
- return this.pages.getPageCount();
2527
- }
2528
- getCurrentPageIndex() {
2529
- return this.pages.getCurrentPageIndex();
2530
- }
2531
- getPage(m) {
2532
- return this.pages.getPage(m);
2533
- }
2534
- getRender() {
2535
- return this.render;
2536
- }
2537
- getFlipController() {
2538
- return this.flipController;
2539
- }
2540
- getOrientation() {
2541
- return this.render.getOrientation();
2542
- }
2543
- getBoundsRect() {
2544
- return this.render.getRect();
2545
- }
2546
- getSettings() {
2547
- return this.setting;
2548
- }
2549
- getUI() {
2550
- return this.ui;
2551
- }
2552
- getState() {
2553
- return this.flipController.getState();
2554
- }
2555
- getPageCollection() {
2556
- return this.pages;
2557
- }
2558
- startUserTouch(m) {
2559
- this.mousePosition = m, this.isUserTouch = !0, this.isUserMove = !1;
2560
- }
2561
- userMove(m, i) {
2562
- this.isUserTouch || i || !this.setting.showPageCorners ? this.isUserTouch && p.GetDistanceBetweenTwoPoint(this.mousePosition, m) > 5 && (this.isUserMove = !0, this.flipController.fold(m)) : this.flipController.showCorner(m);
2563
- }
2564
- userStop(m, i = !1) {
2565
- this.isUserTouch && (this.isUserTouch = !1, i || (this.isUserMove ? this.flipController.stopMove() : this.flipController.flip(m)));
2566
- }
2567
- }, Object.defineProperty(s, "__esModule", { value: !0 });
2568
- });
2569
- })(Dt, Dt.exports);
2570
- var gi = Dt.exports;
2571
- /**
2572
- * @license FlipbookEngine v0.6.0
2573
- * Copyright (c) 2026 Murat Dogan
2574
- *
2575
- * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2576
- *
2577
- * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2578
- * under the terms of the GNU Affero General Public License v3.0.
2579
- *
2580
- * 2. Commercial License: If you wish to use this software in commercial,
2581
- * closed-source, or SaaS products without the AGPLv3 obligations,
2582
- * you must purchase a Commercial License from:
2583
- * https://flipbookengine.com/pricing
2584
- */
2585
- function pi() {
2586
- return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2587
- }
2588
- function fi(e, t = pi()) {
2589
- return t ? 0 : typeof e == "number" && e >= 0 ? e : 1e3;
2590
- }
2591
- class mi {
2592
- constructor(t, s, o) {
2593
- v(this, "pageFlip", null);
2594
- v(this, "bookContainer");
2595
- v(this, "options");
2596
- v(this, "store");
2597
- v(this, "unsubs", []);
2598
- v(this, "audioEl", null);
2599
- v(this, "audioUnlockHandler", null);
2600
- v(this, "isLibraryFlipping", !1);
2601
- v(this, "autoPlayTimer", null);
2602
- v(this, "layoutUpdateTimer", null);
2603
- this.bookContainer = t, this.options = s, this.store = o, s.soundUrl && (this.audioEl = new Audio(s.soundUrl), this.unlockAudio());
2604
- }
2605
- unlockAudio() {
2606
- if (!this.audioEl) return;
2607
- const t = () => {
2608
- if (this.audioEl) {
2609
- const s = this.audioEl.play();
2610
- s && typeof s.then == "function" && s.then(() => {
2611
- this.audioEl.pause(), this.audioEl.currentTime = 0;
2612
- }).catch(() => {
2613
- });
2614
- }
2615
- document.removeEventListener("touchstart", t), document.removeEventListener("click", t), this.audioUnlockHandler = null;
2616
- };
2617
- this.audioUnlockHandler = t, document.addEventListener("touchstart", t, { once: !0 }), document.addEventListener("click", t, { once: !0 });
2618
- }
2619
- init(t, s) {
2620
- this.pageFlip = new gi.PageFlip(this.bookContainer, {
2621
- width: t,
2622
- height: s,
2623
- size: "stretch",
2624
- minWidth: 100,
2625
- maxWidth: 3e3,
2626
- minHeight: 100,
2627
- maxHeight: 3e3,
2628
- drawShadow: !0,
2629
- showCover: !0,
2630
- usePortrait: !0,
2631
- mobileScrollSupport: !1,
2632
- maxShadowOpacity: this.options.maxShadowOpacity || 0.5,
2633
- flippingTime: fi(this.options.flippingTime)
2634
- });
2635
- const o = this.bookContainer.querySelectorAll(".bz-page");
2636
- this.pageFlip.loadFromHTML(Array.from(o)), this.bindEvents(), this.setupSignalSync();
2637
- }
2638
- bindEvents() {
2639
- this.pageFlip.on("flip", (t) => {
2640
- this.store.currentPage.value !== t.data && (this.isLibraryFlipping = !0, this.store.currentPage.value = t.data, this.playSound(), this.isLibraryFlipping = !1);
2641
- }), this.pageFlip.on("changeState", (t) => {
2642
- this.store.flipState.value = t.data;
2643
- }), this.pageFlip.on("changeOrientation", (t) => {
2644
- this.store.orientation.value !== t.data && (this.store.orientation.value = t.data);
2645
- });
2646
- }
2647
- setupSignalSync() {
2648
- this.unsubs.push(
2649
- G(() => {
2650
- const t = this.store.currentPage.value, s = this.store.flipState.peek();
2651
- if (!this.pageFlip || this.isLibraryFlipping || s !== "read") return;
2652
- const o = this.pageFlip.getCurrentPageIndex();
2653
- if (o !== t && !this.store.isSingleMode.value) {
2654
- const r = (p) => p === 0 ? 0 : Math.ceil(p / 2), h = r(t), u = r(o);
2655
- h === u + 1 ? this.pageFlip.flipNext() : h === u - 1 ? this.pageFlip.flipPrev() : h !== u && this.pageFlip.turnToPage(t);
2656
- }
2657
- })
2658
- ), this.unsubs.push(
2659
- G(() => {
2660
- this.store.isSingleMode.value, this.pageFlip && (this.layoutUpdateTimer && clearTimeout(this.layoutUpdateTimer), this.layoutUpdateTimer = setTimeout(() => {
2661
- this.layoutUpdateTimer = null, this.pageFlip && this.pageFlip.update(), window.dispatchEvent(new Event("resize"));
2662
- }, 50));
2663
- })
2664
- ), this.unsubs.push(
2665
- G(() => {
2666
- const t = this.store.isAutoPlaying.value, s = this.store.autoPlayInterval.value || 3e3;
2667
- this.autoPlayTimer && (clearInterval(this.autoPlayTimer), this.autoPlayTimer = null), t && (this.autoPlayTimer = setInterval(() => {
2668
- const o = this.store.pages.value.length - 1;
2669
- if (this.store.currentPage.peek() >= o || this.store.currentPage.peek() >= o - 1 && !this.store.isSingleMode.peek()) {
2670
- this.store.isAutoPlaying.value = !1;
2671
- return;
2672
- }
2673
- this.turnToNextPage();
2674
- }, s));
2675
- })
2676
- );
2677
- }
2678
- turnToNextPage() {
2679
- if (this.store.isSingleMode.value) {
2680
- const t = this.store.currentPage.value + 1;
2681
- t < this.store.pages.value.length && (this.store.currentPage.value = t, this.playSound());
2682
- } else this.pageFlip && this.pageFlip.flipNext();
2683
- }
2684
- turnToPrevPage() {
2685
- if (this.store.isSingleMode.value) {
2686
- const t = this.store.currentPage.value - 1;
2687
- t >= 0 && (this.store.currentPage.value = t, this.playSound());
2688
- } else this.pageFlip && this.pageFlip.flipPrev();
2689
- }
2690
- playSound() {
2691
- if (this.store.soundEnabled.value && this.audioEl) {
2692
- this.audioEl.currentTime = 0;
2693
- const t = this.audioEl.play();
2694
- t && typeof t.catch == "function" && t.catch((s) => console.warn("Flipbook Audio Play Error:", s));
2695
- }
2696
- }
2697
- update() {
2698
- this.pageFlip && this.pageFlip.update(), this.layoutUpdateTimer && (clearTimeout(this.layoutUpdateTimer), this.layoutUpdateTimer = null);
2699
- }
2700
- destroy() {
2701
- this.autoPlayTimer && (clearInterval(this.autoPlayTimer), this.autoPlayTimer = null), this.audioUnlockHandler && (document.removeEventListener("touchstart", this.audioUnlockHandler), document.removeEventListener("click", this.audioUnlockHandler), this.audioUnlockHandler = null), this.unsubs.forEach((t) => t()), this.unsubs = [], this.pageFlip && (this.pageFlip.destroy(), this.pageFlip = null);
2702
- }
2703
- }
2704
- /**
2705
- * @license FlipbookEngine v0.6.0
2706
- * Copyright (c) 2026 Murat Dogan
2707
- *
2708
- * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2709
- *
2710
- * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2711
- * under the terms of the GNU Affero General Public License v3.0.
2712
- *
2713
- * 2. Commercial License: If you wish to use this software in commercial,
2714
- * closed-source, or SaaS products without the AGPLv3 obligations,
2715
- * you must purchase a Commercial License from:
2716
- * https://flipbookengine.com/pricing
2717
- */
2718
- class wi {
2719
- constructor(t, s) {
2720
- v(this, "wrapperElement", null);
2721
- v(this, "sizerElement", null);
2722
- v(this, "pageViewport");
2723
- v(this, "store");
2724
- v(this, "resizeObserver", null);
2725
- v(this, "orientationMediaQuery", null);
2726
- v(this, "orientationChangeHandler", null);
2727
- v(this, "unsubs", []);
2728
- v(this, "updateTimer", null);
2729
- v(this, "onResizeCallback");
2730
- this.pageViewport = t, this.store = s;
2731
- }
2732
- init(t, s) {
2733
- this.wrapperElement = t, this.sizerElement = s, this.setupResizeObserver(), this.setupOrientationMedia(), this.setupStateSync(), this.updateBookAspectRatio();
2734
- }
2735
- setupStateSync() {
2736
- this.unsubs.push(
2737
- G(() => {
2738
- this.store.isSingleMode.value, this.store.orientation.value, this.scheduleAspectRatioUpdate();
2739
- })
2740
- );
2741
- }
2742
- setupResizeObserver() {
2743
- typeof ResizeObserver < "u" && this.wrapperElement && (this.resizeObserver = new ResizeObserver(() => {
2744
- this.updateBookAspectRatio();
2745
- }), this.resizeObserver.observe(this.wrapperElement));
2746
- }
2747
- setupOrientationMedia() {
2748
- if (typeof window < "u" && window.matchMedia) {
2749
- this.orientationMediaQuery = window.matchMedia("(orientation: portrait)");
2750
- const t = (s) => {
2751
- s.matches, this.updateBookAspectRatio();
2752
- };
2753
- this.orientationChangeHandler = t, this.orientationMediaQuery.addEventListener ? this.orientationMediaQuery.addEventListener("change", t) : this.orientationMediaQuery.addListener(t), t(this.orientationMediaQuery);
2754
- }
2755
- }
2756
- updateBookAspectRatio() {
2757
- if (!this.wrapperElement || !this.sizerElement) return;
2758
- const t = this.wrapperElement.clientWidth, s = this.wrapperElement.clientHeight;
2759
- if (t === 0 || s === 0) return;
2760
- const o = this.pageViewport.width, r = this.pageViewport.height, u = this.store.isDoublePageLayout.value ? o * 2 / r : o / r;
2761
- let p = t, b = t / u;
2762
- b > s && (b = s, p = s * u);
2763
- let x = Math.ceil(p);
2764
- x % 2 !== 0 && (x += 1), this.sizerElement.style.width = `${x}px`, this.sizerElement.style.height = `${Math.floor(b)}px`, this.sizerElement.style.aspectRatio = "", this.onResizeCallback && this.onResizeCallback();
2765
- }
2766
- destroy() {
2767
- this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null), this.unsubs.forEach((t) => t()), this.unsubs = [], this.resizeObserver && this.wrapperElement && (this.resizeObserver.unobserve(this.wrapperElement), this.resizeObserver.disconnect(), this.resizeObserver = null), this.orientationMediaQuery && (this.orientationChangeHandler && (this.orientationMediaQuery.removeEventListener ? this.orientationMediaQuery.removeEventListener("change", this.orientationChangeHandler) : this.orientationMediaQuery.removeListener(this.orientationChangeHandler)), this.orientationChangeHandler = null, this.orientationMediaQuery = null);
2768
- }
2769
- scheduleAspectRatioUpdate() {
2770
- this.updateTimer && clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
2771
- this.updateTimer = null, this.updateBookAspectRatio();
2772
- }, 10);
2773
- }
2774
- }
2775
- /**
2776
- * @license FlipbookEngine v0.6.0
2777
- * Copyright (c) 2026 Murat Dogan
2778
- *
2779
- * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2780
- *
2781
- * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2782
- * under the terms of the GNU Affero General Public License v3.0.
2783
- *
2784
- * 2. Commercial License: If you wish to use this software in commercial,
2785
- * closed-source, or SaaS products without the AGPLv3 obligations,
2786
- * you must purchase a Commercial License from:
2787
- * https://flipbookengine.com/pricing
2788
- */
2789
- class vi {
2790
- constructor(t, s, o) {
2791
- v(this, "container");
2792
- v(this, "pageFlipAdapter");
2793
- v(this, "store");
2794
- v(this, "touchStartX", null);
2795
- v(this, "unsubs", []);
2796
- v(this, "listenerAbortController");
2797
- var h;
2798
- this.container = t, this.pageFlipAdapter = s, this.store = o;
2799
- const r = ((h = t.ownerDocument.defaultView) == null ? void 0 : h.AbortController) ?? globalThis.AbortController;
2800
- this.listenerAbortController = new r();
2801
- }
2802
- init() {
2803
- this.bindWheel(), this.bindMouseDrag(), this.bindTouch(), this.setupStateSync();
2804
- }
2805
- setupStateSync() {
2806
- this.unsubs.push(
2807
- G(() => {
2808
- this.store.isZoomed.value = this.store.zoomState.value.isActive, this.store.zoomState.value.isActive ? (this.container.style.transform = `translate(${this.store.zoomState.value.translateX}px, ${this.store.zoomState.value.translateY}px) scale(${this.store.zoomState.value.scale})`, this.container.style.transition = "none") : (this.container.style.transform = "", this.container.style.transition = "transform 0.3s ease");
2809
- })
2810
- );
2811
- }
2812
- bindWheel() {
2813
- this.container.addEventListener("wheel", (t) => {
2814
- this.store.zoomState.value.isActive && (t.preventDefault(), this.updateZoomPan(
2815
- this.store.zoomState.value.translateX - t.deltaX,
2816
- this.store.zoomState.value.translateY - t.deltaY
2817
- ));
2818
- }, { passive: !1, signal: this.listenerAbortController.signal });
2819
- }
2820
- bindMouseDrag() {
2821
- let t = !1, s = 0, o = 0, r = 0, h = 0;
2822
- this.container.addEventListener("mousedown", (u) => {
2823
- this.store.zoomState.value.isActive && (t = !0, s = u.clientX, o = u.clientY, r = this.store.zoomState.value.translateX, h = this.store.zoomState.value.translateY, this.container.style.cursor = "grabbing");
2824
- }, { signal: this.listenerAbortController.signal }), window.addEventListener("mousemove", (u) => {
2825
- if (!t || !this.store.zoomState.value.isActive) return;
2826
- const p = u.clientX - s, b = u.clientY - o;
2827
- this.updateZoomPan(r + p, h + b);
2828
- }, { signal: this.listenerAbortController.signal }), window.addEventListener("mouseup", () => {
2829
- t && (t = !1, this.container.style.cursor = this.store.zoomState.value.isActive ? "grab" : "");
2830
- }, { signal: this.listenerAbortController.signal });
2831
- }
2832
- bindTouch() {
2833
- let t = !1, s = 0, o = 0;
2834
- this.container.addEventListener("touchstart", (r) => {
2835
- if (r.touches.length === 1)
2836
- if (!this.store.zoomState.value.isActive)
2837
- this.touchStartX = r.touches[0].clientX;
2838
- else {
2839
- t = !0, this.touchStartX = r.touches[0].clientX;
2840
- const h = r.touches[0].clientY;
2841
- s = this.store.zoomState.value.translateX, o = this.store.zoomState.value.translateY, this.container._touchStartY = h;
2842
- }
2843
- }, { passive: !0, signal: this.listenerAbortController.signal }), this.container.addEventListener("touchmove", (r) => {
2844
- if (t && this.store.zoomState.value.isActive && r.touches.length === 1 && this.touchStartX !== null) {
2845
- r.preventDefault();
2846
- const h = r.touches[0].clientX - this.touchStartX, u = r.touches[0].clientY - this.container._touchStartY;
2847
- this.updateZoomPan(s + h, o + u);
2848
- }
2849
- }, { passive: !1, signal: this.listenerAbortController.signal }), this.container.addEventListener("touchend", (r) => {
2850
- if (this.touchStartX !== null && !this.store.zoomState.value.isActive && this.store.isSingleMode.value && r.changedTouches.length === 1) {
2851
- const h = r.changedTouches[0].clientX - this.touchStartX;
2852
- h > 50 && this.store.currentPage.value > 0 ? this.pageFlipAdapter.turnToPrevPage() : h < -50 && this.store.currentPage.value < this.store.totalPages.value - 1 && this.pageFlipAdapter.turnToNextPage();
2853
- }
2854
- this.touchStartX = null, t = !1;
2855
- }, { passive: !0, signal: this.listenerAbortController.signal });
2856
- }
2857
- zoomIn() {
2858
- let t = this.store.zoomState.value.scale + 0.5;
2859
- t > 5 && (t = 5), this.store.zoomState.value = {
2860
- ...this.store.zoomState.value,
2861
- isActive: t > 1,
2862
- scale: t
2863
- }, t > 1 && (this.container.style.cursor = "grab");
2864
- }
2865
- zoomOut() {
2866
- let t = this.store.zoomState.value.scale - 0.5;
2867
- t <= 1 ? (t = 1, this.store.zoomState.value = { ...this.store.zoomState.value, isActive: !1, translateX: 0, translateY: 0, scale: 1 }, this.container.style.cursor = "") : this.store.zoomState.value = { ...this.store.zoomState.value, isActive: !0, scale: t };
2868
- }
2869
- updateZoomPan(t, s) {
2870
- this.store.zoomState.value = {
2871
- ...this.store.zoomState.value,
2872
- translateX: t,
2873
- translateY: s
2874
- };
2875
- }
2876
- destroy() {
2877
- this.listenerAbortController.abort(), this.unsubs.forEach((t) => t()), this.unsubs = [];
2878
- }
2879
- }
2880
- function ve(e, t, s) {
2881
- if (!e || typeof e.title != "string" || !e.title.trim() || !Number.isFinite(e.pageIndex)) return null;
2882
- const o = Math.max(0, t - 1), r = Array.isArray(e.children) ? e.children.map((h, u) => ve(h, t, s + "-" + u)).filter((h) => h !== null) : [];
2883
- return {
2884
- id: e.id ?? s,
2885
- title: e.title.trim(),
2886
- pageIndex: Math.max(0, Math.min(o, Math.trunc(e.pageIndex))),
2887
- ...r.length ? { children: r } : {}
2888
- };
2889
- }
2890
- function ye(e, t) {
2891
- return Array.isArray(e) ? e.map((s, o) => ve(s, t, "toc-" + o)).filter((s) => s !== null) : [];
2892
- }
2893
- /**
2894
- * @license FlipbookEngine v0.6.0
2895
- * Copyright (c) 2026 Murat Dogan
2896
- *
2897
- * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2898
- */
2899
- const Kt = () => ({ isActive: !1, translateX: 0, translateY: 0, isDragging: !1, scale: 1 });
2900
- function be() {
2901
- const e = D(0), t = D(0), s = D(!1), o = D(!0), r = D(!1), h = D(!0), u = D("landscape"), p = D("read"), b = D("auto"), x = D(!0), M = D(!1), I = D("#7367f0"), S = D(!1), T = D(!1), E = D(!1), W = D(3e3), B = D(!0), N = D("en"), H = D({}), m = D(Kt()), i = D([]), n = D([]), a = w(() => !s.value && u.value === "landscape"), l = w(() => a.value && e.value === 0), c = w(() => a.value && e.value >= t.value - 1);
2902
- return { currentPage: e, totalPages: t, isSingleMode: s, showThumbs: o, showToc: r, showArrows: h, orientation: u, flipState: p, themeMode: b, allowDownload: x, hasDownloadUrl: M, primaryColor: I, whiteLabel: S, isZoomed: T, isAutoPlaying: E, autoPlayInterval: W, soundEnabled: B, locale: N, messages: H, zoomState: m, pages: i, toc: n, isDoublePageLayout: a, isFrontCover: l, isBackCover: c, init: (f, C, R, F) => {
2903
- t.value = C, i.value = R, M.value = F, f.theme !== void 0 && (b.value = f.theme), f.primaryColor !== void 0 && (I.value = f.primaryColor), f.showThumbs !== void 0 && (o.value = f.showThumbs), f.showToc !== void 0 && (r.value = f.showToc), n.value = ye(f.toc ?? [], C), f.showArrows !== void 0 && (h.value = f.showArrows), f.allowDownload !== void 0 && (x.value = f.allowDownload), f.whiteLabel !== void 0 && (S.value = f.whiteLabel), f.soundEnabled !== void 0 && (B.value = f.soundEnabled), f.locale !== void 0 && (N.value = f.locale), f.messages !== void 0 && (H.value = f.messages), f.isSingleMode !== void 0 && (s.value = f.isSingleMode), f.singleMode !== void 0 && (s.value = f.singleMode), f.autoPlay !== void 0 && (E.value = f.autoPlay), f.autoPlayInterval !== void 0 && (W.value = f.autoPlayInterval), e.value = 0;
2904
- }, reset: () => {
2905
- e.value = 0, t.value = 0, s.value = !1, o.value = !0, h.value = !0, u.value = "landscape", p.value = "read", b.value = "auto", x.value = !0, M.value = !1, I.value = "#7367f0", S.value = !1, T.value = !1, E.value = !1, W.value = 3e3, B.value = !0, N.value = "en", H.value = {}, m.value = Kt(), i.value = [], n.value = [];
2906
- } };
2907
- }
2908
- const k = be();
2909
- k.currentPage;
2910
- k.totalPages;
2911
- k.isSingleMode;
2912
- k.showThumbs;
2913
- k.showToc;
2914
- k.showArrows;
2915
- k.orientation;
2916
- k.flipState;
2917
- k.themeMode;
2918
- k.allowDownload;
2919
- k.hasDownloadUrl;
2920
- k.primaryColor;
2921
- k.whiteLabel;
2922
- k.isZoomed;
2923
- k.isAutoPlaying;
2924
- k.autoPlayInterval;
2925
- k.soundEnabled;
2926
- k.locale;
2927
- k.messages;
2928
- k.zoomState;
2929
- k.pages;
2930
- k.toc;
2931
- k.isDoublePageLayout;
2932
- k.isFrontCover;
2933
- k.isBackCover;
2934
- function yi(e) {
2935
- if (!e || typeof e != "object") return !1;
2936
- const t = e;
2937
- return typeof t.normal == "string" && typeof t.low == "string" && typeof t.thumb == "string";
2938
- }
2939
- function bi(e) {
2940
- return Array.isArray(e.pageNumbers) && e.pageNumbers.length > 0 ? e.pageNumbers : typeof e.pageNumber == "number" ? e.kind === "spread" ? [e.pageNumber, e.pageNumber + 1] : [e.pageNumber] : [];
2941
- }
2942
- function xi(e) {
2943
- return e === "rtl" ? ["right", "left"] : ["left", "right"];
2944
- }
2945
- function Pi(e) {
2946
- const t = [];
2947
- let s = 1;
2948
- return e.forEach((o, r) => {
2949
- const h = o.kind ?? "single", u = o.id ?? `asset-${r}`, p = o.splitDirection ?? "ltr", b = bi(o);
2950
- if (h === "spread") {
2951
- const M = b.length >= 2 ? b.slice(0, 2) : [s, s + 1], I = xi(p);
2952
- M.forEach((S, T) => {
2953
- t.push({
2954
- index: t.length,
2955
- assetId: u,
2956
- pageNumber: S,
2957
- cropMode: I[T] ?? "full",
2958
- normal: o.normal,
2959
- low: o.low,
2960
- thumb: o.thumb
2961
- });
2962
- }), s = M[M.length - 1] + 1;
2963
- return;
2964
- }
2965
- const x = b[0] ?? s;
2966
- t.push({
2967
- index: t.length,
2968
- assetId: u,
2969
- pageNumber: x,
2970
- cropMode: "full",
2971
- normal: o.normal,
2972
- low: o.low,
2973
- thumb: o.thumb
2974
- }), s = x + 1;
2975
- }), t;
2976
- }
2977
- function Jt(e, t) {
2978
- e.classList.add("bk-container"), e.classList.remove("bk-theme-light", "bk-theme-dark"), t.theme === "light" && e.classList.add("bk-theme-light"), t.theme === "dark" && e.classList.add("bk-theme-dark"), t.primaryColor && e.style.setProperty("--flipbook-accent", t.primaryColor);
2979
- const s = t.cssVariables ?? {};
2980
- Object.entries(s).forEach(([o, r]) => {
2981
- const h = o.startsWith("--") ? o : `--${o}`;
2982
- e.style.setProperty(h, r);
2983
- });
2984
- }
2985
- class Si {
2986
- constructor(t = 32) {
2987
- v(this, "entries", /* @__PURE__ */ new Map());
2988
- v(this, "hits", 0);
2989
- v(this, "misses", 0);
2990
- if (this.maxEntries = t, !Number.isInteger(t) || t < 0)
2991
- throw new RangeError("PDF render cache size must be a non-negative integer.");
2992
- }
2993
- get(t) {
2994
- const s = this.entries.get(t);
2995
- if (s === void 0) {
2996
- this.misses++;
2997
- return;
2998
- }
2999
- return this.hits++, this.entries.delete(t), this.entries.set(t, s), s;
3000
- }
3001
- set(t, s) {
3002
- if (!(this.maxEntries === 0 || !s))
3003
- for (this.entries.delete(t), this.entries.set(t, s); this.entries.size > this.maxEntries; ) {
3004
- const o = this.entries.keys().next().value;
3005
- if (o === void 0) break;
3006
- this.entries.delete(o);
3007
- }
3008
- }
3009
- clear() {
3010
- this.entries.clear(), this.hits = 0, this.misses = 0;
3011
- }
3012
- get size() {
3013
- return this.entries.size;
3014
- }
3015
- getStats() {
3016
- return { size: this.size, maxEntries: this.maxEntries, hits: this.hits, misses: this.misses };
3017
- }
3018
- }
3019
- class Ti {
3020
- constructor(t = {}) {
3021
- v(this, "pdfDoc", null);
3022
- v(this, "loadingTask", null);
3023
- v(this, "options");
3024
- v(this, "cache");
3025
- const s = Number.isFinite(t.cacheSize) ? Math.max(0, Math.floor(t.cacheSize)) : 32;
3026
- this.options = {
3027
- scale: t.scale || 1.5,
3028
- quality: t.quality || 0.85,
3029
- format: t.format || "image/webp",
3030
- workerSrc: t.workerSrc || "",
3031
- concurrency: Math.max(1, Math.floor(t.concurrency || 3)),
3032
- cacheSize: s
3033
- }, this.cache = new Si(this.options.cacheSize), this.options.workerSrc && (Bt.GlobalWorkerOptions.workerSrc = this.options.workerSrc);
3034
- }
3035
- /** Loads a PDF document and cancels PDF.js loading when the signal aborts. */
3036
- async loadDocument(t, s) {
3037
- this.throwIfAborted(s), this.cache.clear();
3038
- const o = Bt.getDocument(t);
3039
- this.loadingTask = o;
3040
- const r = () => {
3041
- var h;
3042
- return (h = o.destroy) == null ? void 0 : h.call(o);
3043
- };
3044
- s == null || s.addEventListener("abort", r, { once: !0 });
3045
- try {
3046
- return this.pdfDoc = await o.promise, this.throwIfAborted(s), this.pdfDoc.numPages;
3047
- } catch (h) {
3048
- throw s != null && s.aborted ? this.createAbortError() : h;
3049
- } finally {
3050
- s == null || s.removeEventListener("abort", r), this.loadingTask === o && (this.loadingTask = null);
3051
- }
3052
- }
3053
- /** Renders a specific page to a Data URL. The page index is 1-based. */
3054
- async renderPageToDataUrl(t, s) {
3055
- if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
3056
- this.throwIfAborted(s);
3057
- const o = this.cache.get(t);
3058
- if (o !== void 0) return o;
3059
- try {
3060
- const r = await this.pdfDoc.getPage(t);
3061
- this.throwIfAborted(s);
3062
- const h = r.getViewport({ scale: this.options.scale }), u = document.createElement("canvas");
3063
- u.width = h.width, u.height = h.height;
3064
- const p = u.getContext("2d");
3065
- if (p) {
3066
- const b = r.render({ canvasContext: p, viewport: h }), x = () => {
3067
- var I;
3068
- return (I = b.cancel) == null ? void 0 : I.call(b);
3069
- };
3070
- s == null || s.addEventListener("abort", x, { once: !0 });
3071
- try {
3072
- await b.promise, this.throwIfAborted(s);
3073
- } finally {
3074
- s == null || s.removeEventListener("abort", x);
3075
- }
3076
- const M = u.toDataURL(this.options.format, this.options.quality);
3077
- return this.cache.set(t, M), M;
3078
- }
3079
- throw new Error("Unable to create a PDF canvas rendering context.");
3080
- } catch (r) {
3081
- throw s != null && s.aborted ? this.createAbortError() : r;
3082
- }
3083
- }
3084
- /** Calculates the best viewport dimensions based on the first page. */
3085
- async calculateViewportDimensions(t = 420) {
3086
- if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
3087
- const o = (await this.pdfDoc.getPage(1)).getViewport({ scale: 1 }), r = o.width / o.height;
3088
- return r >= 1 ? { width: Math.round(t * r), height: t } : { width: t, height: Math.round(t / r) };
3089
- }
3090
- /** Renders pages concurrently with a bounded worker pool and preserves page order. */
3091
- async renderAllPages(t, s) {
3092
- if (!this.pdfDoc) return [];
3093
- this.throwIfAborted(t);
3094
- const o = this.pdfDoc.numPages, r = new Array(o);
3095
- let h = 1, u = 0;
3096
- const p = async () => {
3097
- for (; ; ) {
3098
- this.throwIfAborted(t);
3099
- const x = h++;
3100
- if (x > o) return;
3101
- const M = await this.renderPageToDataUrl(x, t);
3102
- r[x - 1] = {
3103
- index: x - 1,
3104
- assetId: `pdf-page-${x}`,
3105
- pageNumber: x,
3106
- cropMode: "full",
3107
- normal: M,
3108
- low: M,
3109
- thumb: M
3110
- }, u++, s == null || s({ completed: u, total: o });
3111
- }
3112
- }, b = Math.min(this.options.concurrency, o);
3113
- return await Promise.all(Array.from({ length: b }, () => p())), this.throwIfAborted(t), r;
3114
- }
3115
- getCacheStats() {
3116
- return this.cache.getStats();
3117
- }
3118
- throwIfAborted(t) {
3119
- if (t != null && t.aborted) throw this.createAbortError();
3120
- }
3121
- createAbortError() {
3122
- const t = new Error("PDF rendering was aborted.");
3123
- return t.name = "AbortError", t;
3124
- }
3125
- destroy() {
3126
- var t, s, o, r;
3127
- (s = (t = this.loadingTask) == null ? void 0 : t.destroy) == null || s.call(t), this.loadingTask = null, this.pdfDoc && ((r = (o = this.pdfDoc).destroy) == null || r.call(o), this.pdfDoc = null), this.cache.clear();
3128
- }
3129
- }
3130
- /**
3131
- * @license FlipbookEngine v0.6.0
3132
- * Copyright (c) 2026 Murat Dogan
3133
- *
3134
- * This source code is dual-licensed under the AGPLv3 and a Commercial License.
3135
- *
3136
- * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
3137
- * under the terms of the GNU Affero General Public License v3.0.
3138
- *
3139
- * 2. Commercial License: If you wish to use this software in commercial,
3140
- * closed-source, or SaaS products without the AGPLv3 obligations,
3141
- * you must purchase a Commercial License from:
3142
- * https://flipbookengine.com/pricing
3143
- */
3144
- const mt = class mt {
3145
- constructor(t, s = {}) {
3146
- v(this, "container", null);
3147
- v(this, "options");
3148
- v(this, "store", be());
3149
- // Core Managers
3150
- v(this, "pageFlipAdapter", null);
3151
- v(this, "layoutManager", null);
3152
- v(this, "interactionManager", null);
3153
- v(this, "pdfRenderer", null);
3154
- v(this, "listeners", {});
3155
- v(this, "initializationTimer", null);
3156
- v(this, "initGeneration", 0);
3157
- v(this, "initAbortController", null);
3158
- v(this, "eventsReady", !1);
3159
- v(this, "lastEventState", { currentPage: 0, zoom: 1, zoomActive: !1, showThumbs: !0, showToc: !1, isSingle: !1, orientation: "" });
3160
- v(this, "eventSyncStop", null);
3161
- v(this, "qualityObserver", null);
3162
- v(this, "pdfLazyStop", null);
3163
- v(this, "hasActiveSession", !1);
3164
- v(this, "pdfPageRequests", /* @__PURE__ */ new Map());
3165
- v(this, "pdfRenderedPages", /* @__PURE__ */ new Set());
3166
- this.selector = t, this.options = {
3167
- allowDownload: !0,
3168
- showThumbs: !0,
3169
- primaryColor: "#7367f0",
3170
- theme: "auto",
3171
- soundUrl: "https://flipbookengine.com/Content/page-flip.mp3",
3172
- autoPlayInterval: 3e3,
3173
- pdfRenderScale: 1.5,
3174
- pdfRenderQuality: 0.85,
3175
- pdfRenderFormat: "image/webp",
3176
- pdfRenderConcurrency: 3,
3177
- pdfRenderCacheSize: 32,
3178
- ...s
3179
- }, this.setupEventSync();
3180
- }
3181
- async init(t, s) {
3182
- if (typeof this.selector == "string" ? this.container = document.querySelector(this.selector) : this.container = this.selector, !this.container) return;
3183
- this.eventsReady = !1, this.destroy(!0);
3184
- const o = this.initGeneration, r = new AbortController();
3185
- this.initAbortController = r;
3186
- let h = [], u = { ...mt.DEFAULT_PAGE_VIEWPORT };
3187
- if (s && s.length > 0) {
3188
- if (r.signal.aborted) return;
3189
- const T = s.filter(yi);
3190
- h = Pi(T);
3191
- const E = h[0];
3192
- if (E) {
3193
- const W = await this.loadImageSize(E.low || E.normal);
3194
- if (W) {
3195
- const N = (E.cropMode !== "full" ? W.width / 2 : W.width) / W.height, H = 420;
3196
- u = N >= 1 ? { width: Math.round(H * N), height: H } : { width: H, height: Math.round(H / N) };
3197
- }
3198
- }
3199
- } else if (t) {
3200
- if (r.signal.aborted) return;
3201
- let T = "load";
3202
- try {
3203
- this.pdfRenderer = new Ti({
3204
- scale: this.options.pdfRenderScale,
3205
- quality: this.options.pdfRenderQuality,
3206
- format: this.options.pdfRenderFormat,
3207
- concurrency: this.options.pdfRenderConcurrency,
3208
- cacheSize: this.options.pdfRenderCacheSize,
3209
- workerSrc: this.options.pdfWorkerSrc
3210
- }), this.emit("progress", { phase: "loading", completed: 0, total: 0 });
3211
- const E = await this.pdfRenderer.loadDocument(t, r.signal);
3212
- T = "render", this.emit("progress", { phase: "loading", completed: 1, total: E }), u = await this.pdfRenderer.calculateViewportDimensions(), h = Array.from({ length: E }, (W, B) => this.createPdfPlaceholder(B + 1));
3213
- } catch (E) {
3214
- r.signal.aborted || (console.error("PDF load failed:", E), this.emit("error", {
3215
- code: T === "load" ? "PDF_LOAD_FAILED" : "PDF_RENDER_FAILED",
3216
- message: E instanceof Error ? E.message : "Unable to load PDF.",
3217
- cause: E
3218
- }));
3219
- return;
3220
- }
3221
- }
3222
- if (r.signal.aborted || o !== this.initGeneration || !h.length) return;
3223
- this.store.init(this.options, h.length, h, !!t), Jt(this.container, this.options), this.container.innerHTML = "";
3224
- let p, b, x;
3225
- const M = { current: null }, I = { current: null }, S = di({
3226
- pageFlipAdapterRef: M,
3227
- interactionManagerRef: I,
3228
- bookWrapperRef: (T) => p = T,
3229
- bookSizerRef: (T) => b = T,
3230
- bookContainerRef: (T) => x = T,
3231
- className: this.options.className,
3232
- store: this.store,
3233
- onToggleFullscreen: () => this.toggleFullscreen(),
3234
- onDownload: () => {
3235
- t && (this.options.onDownload ? this.options.onDownload(t) : window.open(t, "_blank"));
3236
- }
3237
- });
3238
- this.container.appendChild(S), this.setupQualityLoading(), this.layoutManager = new wi(u, this.store), this.layoutManager.onResizeCallback = () => {
3239
- this.pageFlipAdapter && this.pageFlipAdapter.update();
3240
- }, this.layoutManager.init(p, b), this.pageFlipAdapter = new mi(x, this.options, this.store), M.current = this.pageFlipAdapter, await new Promise((T) => {
3241
- const E = () => {
3242
- r.signal.removeEventListener("abort", E), T();
3243
- };
3244
- r.signal.addEventListener("abort", E, { once: !0 }), this.initializationTimer = setTimeout(async () => {
3245
- if (this.initializationTimer = null, r.signal.removeEventListener("abort", E), r.signal.aborted || o !== this.initGeneration || !this.pageFlipAdapter) {
3246
- T();
3247
- return;
3248
- }
3249
- if (this.pageFlipAdapter.init(u.width, u.height), this.interactionManager = new vi(p, this.pageFlipAdapter, this.store), this.interactionManager.init(), I.current = this.interactionManager, this.setupPdfLazyLoading(), this.pdfRenderer && t)
3250
- try {
3251
- await this.renderPdfPage(1, r.signal);
3252
- } catch {
3253
- T();
3254
- return;
3255
- }
3256
- if (r.signal.aborted || o !== this.initGeneration) {
3257
- T();
3258
- return;
3259
- }
3260
- this.eventsReady = !0, this.captureEventState(), this.hasActiveSession = !0, this.emit("init", { totalPages: h.length }), T();
3261
- }, 10);
3262
- }), this.initAbortController === r && (this.initAbortController = null);
3263
- }
3264
- createPdfPlaceholder(t) {
3265
- const s = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
3266
- return {
3267
- index: t - 1,
3268
- assetId: "pdf-page-" + t,
3269
- pageNumber: t,
3270
- cropMode: "full",
3271
- normal: s,
3272
- low: s,
3273
- thumb: s
3274
- };
3275
- }
3276
- renderPdfPage(t, s) {
3277
- const o = this.pdfRenderer, r = this.initGeneration;
3278
- if (!o) return Promise.resolve("");
3279
- const h = this.pdfPageRequests.get(t);
3280
- if (h) return h;
3281
- if (this.pdfRenderedPages.has(t)) return Promise.resolve("");
3282
- const u = o.renderPageToDataUrl(t, s).then((p) => {
3283
- var b;
3284
- if (r !== this.initGeneration || s != null && s.aborted) throw this.createAbortError();
3285
- if (!p) throw new Error("PDF page " + t + " produced no image.");
3286
- return this.pdfRenderedPages.add(t), (b = this.container) == null || b.querySelectorAll('img[data-pdf-page="' + t + '"]').forEach((x) => {
3287
- x.src = p, delete x.dataset.pdfPage;
3288
- }), this.emit("progress", {
3289
- phase: "rendering",
3290
- completed: this.pdfRenderedPages.size,
3291
- total: this.store.totalPages.value
3292
- }), p;
3293
- }).catch((p) => {
3294
- throw r !== this.initGeneration && (p == null ? void 0 : p.name) !== "AbortError" ? this.createAbortError() : ((p == null ? void 0 : p.name) === "AbortError" || this.emit("error", {
3295
- code: "PDF_RENDER_FAILED",
3296
- message: p instanceof Error ? p.message : "Unable to render PDF page.",
3297
- cause: p
3298
- }), p);
3299
- }).finally(() => {
3300
- this.pdfPageRequests.get(t) === u && this.pdfPageRequests.delete(t);
3301
- });
3302
- return this.pdfPageRequests.set(t, u), u;
3303
- }
3304
- setupPdfLazyLoading() {
3305
- var t;
3306
- (t = this.pdfLazyStop) == null || t.call(this), this.pdfLazyStop = null, this.pdfRenderer && (this.pdfLazyStop = G(() => {
3307
- const s = this.store.currentPage.value + 1, o = this.store.totalPages.value;
3308
- [s, s + 1].filter((r) => r <= o).forEach((r) => {
3309
- this.renderPdfPage(r).catch(() => {
3310
- });
3311
- });
3312
- }));
3313
- }
3314
- loadImageSize(t) {
3315
- return new Promise((s) => {
3316
- const o = new Image();
3317
- o.onload = () => s({ width: o.naturalWidth || o.width, height: o.naturalHeight || o.height }), o.onerror = () => s(null), o.src = t;
3318
- });
3319
- }
3320
- goToPage(t) {
3321
- const s = Math.max(0, this.store.totalPages.value - 1);
3322
- this.store.currentPage.value = Math.max(0, Math.min(s, Math.trunc(t)));
3323
- }
3324
- getTotalPages() {
3325
- return this.store.totalPages.value;
3326
- }
3327
- getCurrentPage() {
3328
- return this.store.currentPage.value;
3329
- }
3330
- getZoom() {
3331
- return this.store.zoomState.value.scale;
3332
- }
3333
- setZoom(t) {
3334
- const s = Number.isFinite(t) ? t : 1, o = Math.max(0.5, Math.min(5, s));
3335
- this.store.zoomState.value = {
3336
- ...this.store.zoomState.value,
3337
- scale: o,
3338
- isActive: o > 1,
3339
- ...o <= 1 ? { translateX: 0, translateY: 0 } : {}
3340
- }, this.store.isZoomed.value = o > 1;
3341
- }
3342
- nextPage() {
3343
- this.pageFlipAdapter && this.pageFlipAdapter.turnToNextPage();
3344
- }
3345
- toggleFullscreen() {
3346
- var s, o;
3347
- const t = this.container;
3348
- t && (document.fullscreenElement ? (o = document.exitFullscreen) == null || o.call(document).catch((r) => console.warn("Exit fullscreen err:", r)) : (s = t.requestFullscreen) == null || s.call(t).catch((r) => console.warn("Fullscreen err:", r)));
3349
- }
3350
- setLocale(t, s) {
3351
- const o = s ? { ...this.options.messages, [t]: s[t] ?? s } : this.options.messages;
3352
- this.options = { ...this.options, locale: t, messages: o }, this.store.locale.value = t, o && (this.store.messages.value = o);
3353
- }
3354
- prevPage() {
3355
- this.pageFlipAdapter && this.pageFlipAdapter.turnToPrevPage();
3356
- }
3357
- setSingleMode(t) {
3358
- this.store.isSingleMode.value = t;
3359
- }
3360
- updateOptions(t) {
3361
- this.options = { ...this.options, ...t }, t.theme !== void 0 && (this.store.themeMode.value = t.theme), t.primaryColor !== void 0 && (this.store.primaryColor.value = t.primaryColor), t.showThumbs !== void 0 && (this.store.showThumbs.value = t.showThumbs), t.showToc !== void 0 && (this.store.showToc.value = t.showToc), t.toc !== void 0 && (this.store.toc.value = ye(t.toc, this.store.totalPages.value)), t.showArrows !== void 0 && (this.store.showArrows.value = t.showArrows), t.allowDownload !== void 0 && (this.store.allowDownload.value = t.allowDownload), t.whiteLabel !== void 0 && (this.store.whiteLabel.value = t.whiteLabel), t.soundEnabled !== void 0 && (this.store.soundEnabled.value = t.soundEnabled), t.locale !== void 0 && (this.store.locale.value = t.locale), t.messages !== void 0 && (this.store.messages.value = t.messages), t.singleMode !== void 0 && (this.store.isSingleMode.value = t.singleMode), t.isSingleMode !== void 0 && (this.store.isSingleMode.value = t.isSingleMode), t.autoPlay !== void 0 && (this.store.isAutoPlaying.value = t.autoPlay), t.autoPlayInterval !== void 0 && (this.store.autoPlayInterval.value = t.autoPlayInterval), this.container && Jt(this.container, this.options);
3362
- }
3363
- async setPages(t, s) {
3364
- if (!(t != null && t.length)) {
3365
- s && await this.init(s);
3366
- return;
3367
- }
3368
- await this.init(s || "", t);
3369
- }
3370
- setupQualityLoading() {
3371
- var r;
3372
- if (this.teardownQualityLoading(), !this.container) return;
3373
- const t = Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")), s = (h) => {
3374
- const u = Number(h.dataset.pdfPage);
3375
- if (Number.isInteger(u) && u > 0) {
3376
- this.renderPdfPage(u).catch(() => {
3377
- });
3378
- return;
3379
- }
3380
- const p = h.dataset.src;
3381
- p && (h.src = p, delete h.dataset.src);
3382
- }, o = (r = this.container.ownerDocument.defaultView) == null ? void 0 : r.IntersectionObserver;
3383
- if (!o) {
3384
- const h = /* @__PURE__ */ new Set();
3385
- t.forEach((u) => {
3386
- const p = Number(u.dataset.pdfPage);
3387
- Number.isInteger(p) && p > 0 ? h.size < 2 && (h.add(p), s(u)) : s(u);
3388
- });
3389
- return;
3390
- }
3391
- this.qualityObserver = new o((h) => {
3392
- h.forEach((u) => {
3393
- var p;
3394
- u.isIntersecting && (s(u.target), (p = this.qualityObserver) == null || p.unobserve(u.target));
3395
- });
3396
- }, { root: this.container, rootMargin: "240px" }), t.forEach((h) => {
3397
- var u;
3398
- return (u = this.qualityObserver) == null ? void 0 : u.observe(h);
3399
- });
3400
- }
3401
- teardownQualityLoading() {
3402
- var t;
3403
- (t = this.qualityObserver) == null || t.disconnect(), this.qualityObserver = null;
3404
- }
3405
- setupEventSync() {
3406
- this.eventSyncStop = G(() => {
3407
- const t = {
3408
- currentPage: this.store.currentPage.value,
3409
- zoom: this.store.zoomState.value.scale,
3410
- zoomActive: this.store.zoomState.value.isActive,
3411
- showThumbs: this.store.showThumbs.value,
3412
- showToc: this.store.showToc.value,
3413
- isSingle: this.store.isSingleMode.value,
3414
- orientation: this.store.orientation.value
3415
- };
3416
- if (!this.eventsReady) {
3417
- this.lastEventState = t;
3418
- return;
3419
- }
3420
- t.currentPage !== this.lastEventState.currentPage && this.emit("pageChange", {
3421
- currentPage: t.currentPage,
3422
- pageNumber: t.currentPage + 1,
3423
- totalPages: this.store.totalPages.value,
3424
- isSingle: t.isSingle
3425
- }), (t.zoom !== this.lastEventState.zoom || t.zoomActive !== this.lastEventState.zoomActive) && this.emit("zoomChange", { zoom: t.zoom, isActive: t.zoomActive }), t.showThumbs !== this.lastEventState.showThumbs && this.emit("thumbsToggle", { showThumbs: t.showThumbs }), t.showToc !== this.lastEventState.showToc && this.emit("tocToggle", { showToc: t.showToc }), t.isSingle !== this.lastEventState.isSingle && this.emit("singlePageModeChange", { isSingle: t.isSingle }), t.orientation !== this.lastEventState.orientation && this.emit("orientationChange", { orientation: t.orientation }), this.lastEventState = t;
3426
- });
3427
- }
3428
- captureEventState() {
3429
- this.lastEventState = {
3430
- currentPage: this.store.currentPage.value,
3431
- zoom: this.store.zoomState.value.scale,
3432
- zoomActive: this.store.zoomState.value.isActive,
3433
- showThumbs: this.store.showThumbs.value,
3434
- showToc: this.store.showToc.value,
3435
- isSingle: this.store.isSingleMode.value,
3436
- orientation: this.store.orientation.value
3437
- };
3438
- }
3439
- destroy(t = !1) {
3440
- var o, r;
3441
- const s = this.hasActiveSession || !!this.initAbortController || !!this.pageFlipAdapter || !!this.layoutManager || !!this.interactionManager || !!this.pdfRenderer;
3442
- this.initGeneration++, (o = this.initAbortController) == null || o.abort(), this.initAbortController = null, this.initializationTimer && (clearTimeout(this.initializationTimer), this.initializationTimer = null), this.pageFlipAdapter && this.pageFlipAdapter.destroy(), this.layoutManager && this.layoutManager.destroy(), this.interactionManager && this.interactionManager.destroy(), this.teardownQualityLoading(), (r = this.pdfLazyStop) == null || r.call(this), this.pdfLazyStop = null, this.pdfPageRequests.clear(), this.pdfRenderedPages.clear(), this.pdfRenderer && this.pdfRenderer.destroy(), this.pageFlipAdapter = null, this.layoutManager = null, this.interactionManager = null, this.pdfRenderer = null, this.eventsReady = !1, this.hasActiveSession = !1, this.store.reset(), !t && this.container && (this.container.innerHTML = ""), s && this.emit("destroy", void 0);
3443
- }
3444
- createAbortError() {
3445
- const t = new Error("Flipbook initialization was aborted.");
3446
- return t.name = "AbortError", t;
3447
- }
3448
- on(t, s) {
3449
- const o = this.listeners[t] ?? /* @__PURE__ */ new Set();
3450
- return o.add(s), this.listeners[t] = o, () => this.off(t, s);
3451
- }
3452
- off(t, s) {
3453
- var o;
3454
- (o = this.listeners[t]) == null || o.delete(s);
3455
- }
3456
- emit(t, s) {
3457
- var o;
3458
- (o = this.listeners[t]) == null || o.forEach((r) => {
3459
- r(s);
3460
- });
3461
- }
3462
- };
3463
- v(mt, "DEFAULT_PAGE_VIEWPORT", { width: 420, height: 594 });
3464
- let Rt = mt;
3465
- const xe = globalThis, Pe = xe.FlipbookEngine || {};
3466
- Pe.FlipbookEngine = Rt;
3467
- xe.FlipbookEngine = Pe;
3468
- export {
3469
- Rt as F,
3470
- ye as a,
3471
- yi as i,
3472
- Pi as n
3473
- };
3474
- //# sourceMappingURL=engine-MdZzt6R9.js.map