flipbookengine 0.6.5 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +115 -75
- package/README.md +429 -295
- package/dist/components/AnnotationPlacement.d.ts +5 -0
- package/dist/components/AnnotationPopover.d.ts +10 -0
- package/dist/components/App.d.ts +26 -0
- package/dist/components/HotspotLayer.d.ts +14 -0
- package/dist/components/NoteEditor.d.ts +13 -0
- package/dist/components/NotePlacementLayer.d.ts +11 -0
- package/dist/components/NotesPanel.d.ts +17 -0
- package/dist/components/PluginPanels.d.ts +5 -0
- package/dist/components/ReaderHelp.d.ts +3 -0
- package/dist/components/ReaderShortcuts.d.ts +16 -0
- package/dist/components/SearchPanel.d.ts +11 -0
- package/dist/components/TableOfContents.d.ts +1 -0
- package/dist/components/TextLayer.d.ts +8 -0
- package/dist/components/Toolbar.d.ts +7 -1
- package/dist/components/ToolbarMore.d.ts +6 -0
- package/dist/components/Viewer.d.ts +8 -0
- package/dist/core/LayoutManager.d.ts +1 -1
- package/dist/core/PdfRenderer.d.ts +11 -0
- package/dist/core/TextLayerLoader.d.ts +5 -0
- package/dist/core/domSignal.d.ts +2 -0
- package/dist/core-entry.d.ts +14 -0
- package/dist/core.d.ts +1 -0
- package/dist/embed.d.ts +80 -0
- package/dist/engine-DD5qEHLm.js +4657 -0
- package/dist/engine-DD5qEHLm.js.map +1 -0
- package/dist/engine.d.ts +124 -0
- package/dist/feature-Cicli9ie.js +17 -0
- package/dist/feature-Cicli9ie.js.map +1 -0
- package/dist/flipbook-engine.core.js +8 -0
- package/dist/flipbook-engine.core.js.map +1 -0
- package/dist/flipbook-engine.css +1 -1
- package/dist/flipbook-engine.iife.js +51 -55
- package/dist/flipbook-engine.iife.js.map +1 -1
- package/dist/flipbook-engine.js +10 -6
- package/dist/flipbook-engine.js.map +1 -1
- package/dist/flipbook-engine.plugins-annotations.js +14 -0
- package/dist/flipbook-engine.plugins-annotations.js.map +1 -0
- package/dist/flipbook-engine.plugins-bookmarks.js +16 -0
- package/dist/flipbook-engine.plugins-bookmarks.js.map +1 -0
- package/dist/flipbook-engine.plugins-deep-link.js +14 -0
- package/dist/flipbook-engine.plugins-deep-link.js.map +1 -0
- package/dist/flipbook-engine.plugins-hotspots.js +15 -0
- package/dist/flipbook-engine.plugins-hotspots.js.map +1 -0
- package/dist/flipbook-engine.plugins-notes.js +16 -0
- package/dist/flipbook-engine.plugins-notes.js.map +1 -0
- package/dist/flipbook-engine.plugins-search.js +15 -0
- package/dist/flipbook-engine.plugins-search.js.map +1 -0
- package/dist/flipbook-engine.plugins-share.js +13 -0
- package/dist/flipbook-engine.plugins-share.js.map +1 -0
- package/dist/flipbook-engine.plugins-toc.js +14 -0
- package/dist/flipbook-engine.plugins-toc.js.map +1 -0
- package/dist/flipbook-engine.plugins.js +5 -0
- package/dist/flipbook-engine.plugins.js.map +1 -0
- package/dist/flipbook-engine.react.js +1 -1
- package/dist/flipbook-engine.vue.js +1 -1
- package/dist/i18n/locales/en.d.ts +39 -0
- package/dist/i18n/locales/tr.d.ts +39 -0
- package/dist/i18n/service.d.ts +117 -0
- package/dist/index-BhTR2SK6.js +366 -0
- package/dist/index-BhTR2SK6.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/model/annotations.d.ts +15 -0
- package/dist/model/backend.d.ts +8 -0
- package/dist/model/hotspots.d.ts +40 -0
- package/dist/model/note-editor.d.ts +22 -0
- package/dist/model/search.d.ts +25 -0
- package/dist/model/text-layer.d.ts +21 -0
- package/dist/plugins/annotations.d.ts +4 -0
- package/dist/plugins/bookmarks.d.ts +4 -0
- package/dist/plugins/deep-link.d.ts +4 -0
- package/dist/plugins/feature.d.ts +5 -0
- package/dist/plugins/hotspots.d.ts +4 -0
- package/dist/plugins/index.d.ts +65 -0
- package/dist/plugins/notes.d.ts +4 -0
- package/dist/plugins/search.d.ts +4 -0
- package/dist/plugins/share.d.ts +4 -0
- package/dist/plugins/toc.d.ts +4 -0
- package/dist/plugins-annotations.d.ts +1 -0
- package/dist/plugins-bookmarks.d.ts +1 -0
- package/dist/plugins-deep-link.d.ts +1 -0
- package/dist/plugins-hotspots.d.ts +1 -0
- package/dist/plugins-notes.d.ts +1 -0
- package/dist/plugins-search.d.ts +1 -0
- package/dist/plugins-share.d.ts +1 -0
- package/dist/plugins-toc.d.ts +1 -0
- package/dist/plugins.d.ts +1 -0
- package/dist/state/store.d.ts +35 -5
- package/dist/vue/index.d.ts +1 -1
- package/docs/api-reference.md +228 -0
- package/docs/backend-text-layers.md +40 -0
- package/docs/frameworks.md +73 -0
- package/docs/getting-started.md +128 -0
- package/docs/i18n.md +47 -0
- package/docs/migration-0.4.0.md +24 -0
- package/docs/migration-0.5.0.md +25 -0
- package/docs/migration-1.0.0.md +59 -0
- package/docs/plugin-architecture.md +103 -0
- package/docs/release-checklist.md +37 -0
- package/docs/theming.md +61 -0
- package/package.json +52 -1
- package/dist/engine-DhQ2zxpm.js +0 -3535
- package/dist/engine-DhQ2zxpm.js.map +0 -1
|
@@ -0,0 +1,4657 @@
|
|
|
1
|
+
var Kt = Object.defineProperty;
|
|
2
|
+
var ot = (t) => {
|
|
3
|
+
throw TypeError(t);
|
|
4
|
+
};
|
|
5
|
+
var Jt = (t, e, i) => e in t ? Kt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
6
|
+
var C = (t, e, i) => Jt(t, typeof e != "symbol" ? e + "" : e, i), Ne = (t, e, i) => e.has(t) || ot("Cannot " + i);
|
|
7
|
+
var j = (t, e, i) => (Ne(t, e, "read from private field"), i ? i.call(t) : e.get(t)), de = (t, e, i) => e.has(t) ? ot("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), ge = (t, e, i, s) => (Ne(t, e, "write to private field"), s ? s.call(t, i) : e.set(t, i), i), ne = (t, e, i) => (Ne(t, e, "access private method"), i);
|
|
8
|
+
import { j as G, g as d, y as A, F as ei } from "./index-BhTR2SK6.js";
|
|
9
|
+
import * as rt from "pdfjs-dist";
|
|
10
|
+
function ti(t, e) {
|
|
11
|
+
if (t.schemaVersion !== 1 || t.pageIndex !== e || typeof t.revision != "string" || !t.revision || typeof t.text != "string" || t.text.length > 1e5 || !Array.isArray(t.runs) || t.runs.length > 2e4)
|
|
12
|
+
throw new Error("Invalid text page");
|
|
13
|
+
let i = 0;
|
|
14
|
+
for (const s of t.runs) {
|
|
15
|
+
if (typeof s.text != "string" || !s.text.length || !Number.isInteger(s.start) || s.start < i || t.text.slice(s.start, s.start + s.text.length) !== s.text || ![s.x, s.y, s.width, s.height].every(Number.isFinite) || s.x < 0 || s.y < 0 || s.width <= 0 || s.height <= 0 || s.x + s.width > 1.000001 || s.y + s.height > 1.000001 || s.direction !== void 0 && s.direction !== "ltr" && s.direction !== "rtl") throw new Error("Invalid text run");
|
|
16
|
+
i = s.start + s.text.length;
|
|
17
|
+
}
|
|
18
|
+
return { ...t, runs: t.runs.map((s) => ({ ...s })) };
|
|
19
|
+
}
|
|
20
|
+
function ii(t, e, i) {
|
|
21
|
+
const s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), r = G(() => {
|
|
22
|
+
const c = t.currentPage.value, g = t.totalPages.value, v = new Set([c - 1, c, c + 1].filter((S) => S >= 0 && S < g));
|
|
23
|
+
for (const [S, m] of s) v.has(S) || (m.abort(), s.delete(S));
|
|
24
|
+
const y = new Map([...t.textPages.peek()].filter(([S]) => v.has(S)));
|
|
25
|
+
for (const S of [...a]) v.has(S) || a.delete(S);
|
|
26
|
+
t.textPages.value = y;
|
|
27
|
+
for (const S of v) {
|
|
28
|
+
if (s.has(S) || a.has(S) || i.aborted) continue;
|
|
29
|
+
const m = new AbortController();
|
|
30
|
+
s.set(S, m), Promise.resolve().then(() => e(S, m.signal)).then((w) => {
|
|
31
|
+
m.signal.aborted || i.aborted || s.get(S) !== m || (w && (t.textPages.value = new Map(t.textPages.peek()).set(S, ti(w, S))), a.add(S));
|
|
32
|
+
}).catch(() => {
|
|
33
|
+
m.signal.aborted || a.add(S);
|
|
34
|
+
}).finally(() => {
|
|
35
|
+
s.get(S) === m && s.delete(S);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}), h = () => {
|
|
39
|
+
r();
|
|
40
|
+
for (const c of s.values()) c.abort();
|
|
41
|
+
s.clear();
|
|
42
|
+
};
|
|
43
|
+
return i.addEventListener("abort", h, { once: !0 }), () => {
|
|
44
|
+
i.removeEventListener("abort", h), h();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var Mt = /* @__PURE__ */ Symbol.for("Serenity.initPropHook");
|
|
48
|
+
function si(t) {
|
|
49
|
+
return !!(t && typeof t.nodeType == "number");
|
|
50
|
+
}
|
|
51
|
+
function ye(t) {
|
|
52
|
+
return typeof t == "string";
|
|
53
|
+
}
|
|
54
|
+
function Et(t) {
|
|
55
|
+
return typeof t == "number";
|
|
56
|
+
}
|
|
57
|
+
function q(t) {
|
|
58
|
+
return typeof t == "object" && t !== null;
|
|
59
|
+
}
|
|
60
|
+
function ni(t) {
|
|
61
|
+
return !!(t && t.isComponent);
|
|
62
|
+
}
|
|
63
|
+
function Ze(t) {
|
|
64
|
+
return q(t) && typeof t.length == "number" && typeof t.nodeType != "number";
|
|
65
|
+
}
|
|
66
|
+
function ai(t) {
|
|
67
|
+
return typeof t == "function" && typeof t[Mt] == "function";
|
|
68
|
+
}
|
|
69
|
+
function oe(t) {
|
|
70
|
+
return t != null && typeof t != "boolean";
|
|
71
|
+
}
|
|
72
|
+
function re(t) {
|
|
73
|
+
return Array.isArray(t) ? t.map(re).filter(Boolean).join(" ") : q(t) ? Symbol.iterator in t ? re(Array.from(t)) : Object.keys(t).filter((e) => t[e]).join(" ") : oe(t) ? "" + t : "";
|
|
74
|
+
}
|
|
75
|
+
function oi(t) {
|
|
76
|
+
return t != null && typeof t == "object" && "current" in t;
|
|
77
|
+
}
|
|
78
|
+
function Qe(t, e) {
|
|
79
|
+
oi(t) ? t.current = e : typeof t == "function" && t(e);
|
|
80
|
+
}
|
|
81
|
+
function ri(t, e, i) {
|
|
82
|
+
e = { ...e, children: i };
|
|
83
|
+
const s = new t(e), a = s.render();
|
|
84
|
+
return "ref" in e && Qe(e.ref, s), a;
|
|
85
|
+
}
|
|
86
|
+
var li = "http://www.w3.org/1998/Math/MathML", hi = /* @__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"]), ci = /* @__PURE__ */ new Set([
|
|
87
|
+
// "a",
|
|
88
|
+
"animate",
|
|
89
|
+
"animateMotion",
|
|
90
|
+
"animateTransform",
|
|
91
|
+
"circle",
|
|
92
|
+
"clipPath",
|
|
93
|
+
"defs",
|
|
94
|
+
"desc",
|
|
95
|
+
"ellipse",
|
|
96
|
+
"feBlend",
|
|
97
|
+
"feColorMatrix",
|
|
98
|
+
"feComponentTransfer",
|
|
99
|
+
"feComposite",
|
|
100
|
+
"feConvolveMatrix",
|
|
101
|
+
"feDiffuseLighting",
|
|
102
|
+
"feDisplacementMap",
|
|
103
|
+
"feDistantLight",
|
|
104
|
+
"feDropShadow",
|
|
105
|
+
"feFlood",
|
|
106
|
+
"feFuncA",
|
|
107
|
+
"feFuncB",
|
|
108
|
+
"feFuncG",
|
|
109
|
+
"feFuncR",
|
|
110
|
+
"feGaussianBlur",
|
|
111
|
+
"feImage",
|
|
112
|
+
"feMerge",
|
|
113
|
+
"feMergeNode",
|
|
114
|
+
"feMorphology",
|
|
115
|
+
"feOffset",
|
|
116
|
+
"fePointLight",
|
|
117
|
+
"feSpecularLighting",
|
|
118
|
+
"feSpotLight",
|
|
119
|
+
"feTile",
|
|
120
|
+
"feTurbulence",
|
|
121
|
+
"filter",
|
|
122
|
+
"foreignObject",
|
|
123
|
+
"g",
|
|
124
|
+
"image",
|
|
125
|
+
"line",
|
|
126
|
+
"linearGradient",
|
|
127
|
+
"marker",
|
|
128
|
+
"mask",
|
|
129
|
+
"metadata",
|
|
130
|
+
"mpath",
|
|
131
|
+
"path",
|
|
132
|
+
"pattern",
|
|
133
|
+
"polygon",
|
|
134
|
+
"polyline",
|
|
135
|
+
"radialGradient",
|
|
136
|
+
"rect",
|
|
137
|
+
// "script",
|
|
138
|
+
"set",
|
|
139
|
+
"stop",
|
|
140
|
+
// "style",
|
|
141
|
+
"svg",
|
|
142
|
+
"switch",
|
|
143
|
+
"symbol",
|
|
144
|
+
"text",
|
|
145
|
+
"textPath",
|
|
146
|
+
// "title",
|
|
147
|
+
"tref",
|
|
148
|
+
"tspan",
|
|
149
|
+
"use",
|
|
150
|
+
"view"
|
|
151
|
+
]), lt = /^(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)/, ui = "http://www.w3.org/2000/svg", ht = /* @__PURE__ */ Symbol.for("Serenity.jsxNamespaceURI");
|
|
152
|
+
function di(t) {
|
|
153
|
+
const e = globalThis[ht];
|
|
154
|
+
return arguments.length && (globalThis[ht] = t), e;
|
|
155
|
+
}
|
|
156
|
+
var gi = /* @__PURE__ */ Symbol.for("Serenity.jsxTypeKey"), fi = "ShadowRoot";
|
|
157
|
+
function pi(t) {
|
|
158
|
+
return t != null && t[gi] === fi;
|
|
159
|
+
}
|
|
160
|
+
var Le = /* @__PURE__ */ Symbol.for("Serenity.disposingListeners"), ze = /* @__PURE__ */ Symbol.for("Serenity.lifecycleRoot");
|
|
161
|
+
function Ke() {
|
|
162
|
+
return globalThis[Le] || (globalThis[Le] = /* @__PURE__ */ new WeakMap());
|
|
163
|
+
}
|
|
164
|
+
function Je(t) {
|
|
165
|
+
t && t.target && (!t.currentTarget || t.currentTarget === t.target) && mi(t == null ? void 0 : t.target);
|
|
166
|
+
}
|
|
167
|
+
function mi(t, e) {
|
|
168
|
+
if (!t)
|
|
169
|
+
return;
|
|
170
|
+
const i = Ke();
|
|
171
|
+
function s(a) {
|
|
172
|
+
const r = i.get(a);
|
|
173
|
+
if (r) {
|
|
174
|
+
i.delete(a), a.removeEventListener("disposing", Je);
|
|
175
|
+
for (const h of r)
|
|
176
|
+
try {
|
|
177
|
+
h.callback(a);
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
s(t);
|
|
183
|
+
}
|
|
184
|
+
function $e(t, e, i) {
|
|
185
|
+
if (!t || !e)
|
|
186
|
+
return t;
|
|
187
|
+
const s = Ke();
|
|
188
|
+
let a = s.get(t);
|
|
189
|
+
if (!a)
|
|
190
|
+
return typeof t.addEventListener != "function" || (s.set(t, a = [{
|
|
191
|
+
callback: e,
|
|
192
|
+
regKey: i
|
|
193
|
+
}]), t.addEventListener("disposing", Je, { once: !0 })), t;
|
|
194
|
+
const r = a.find((h) => h.callback === e);
|
|
195
|
+
return r ? (r.regKey, t) : (a.push({ callback: e, regKey: i }), t);
|
|
196
|
+
}
|
|
197
|
+
function ct(t, e, i) {
|
|
198
|
+
if (!t || !e)
|
|
199
|
+
return t;
|
|
200
|
+
const s = Ke(), a = s.get(t);
|
|
201
|
+
if (a) {
|
|
202
|
+
for (let r = a.length - 1; r >= 0; r--) {
|
|
203
|
+
const h = a[r];
|
|
204
|
+
e && e === h.callback && a.splice(r, 1);
|
|
205
|
+
}
|
|
206
|
+
a.length === 0 && (s.delete(t), typeof t.removeEventListener == "function" && t.removeEventListener("disposing", Je));
|
|
207
|
+
}
|
|
208
|
+
return t;
|
|
209
|
+
}
|
|
210
|
+
function vi(...t) {
|
|
211
|
+
if (t.length > 0) {
|
|
212
|
+
const e = globalThis[ze] || null;
|
|
213
|
+
return globalThis[ze] = t[0] || null, e;
|
|
214
|
+
}
|
|
215
|
+
return globalThis[ze] || null;
|
|
216
|
+
}
|
|
217
|
+
function Q(t) {
|
|
218
|
+
return t != null && typeof t == "object" && typeof t.subscribe == "function" && typeof t.peek == "function" && "value" in t;
|
|
219
|
+
}
|
|
220
|
+
var ce, _, X, qe, _e, Tt, bi = (Tt = class {
|
|
221
|
+
constructor(t, e, i) {
|
|
222
|
+
de(this, X);
|
|
223
|
+
de(this, ce);
|
|
224
|
+
de(this, _);
|
|
225
|
+
this.signal = t, this.isInitial = !0, this.hasChanged = !1, this.lifecycleRoot = e, ge(this, _, i);
|
|
226
|
+
}
|
|
227
|
+
get lifecycleNode() {
|
|
228
|
+
return j(this, _);
|
|
229
|
+
}
|
|
230
|
+
get effectDisposer() {
|
|
231
|
+
return j(this, ce);
|
|
232
|
+
}
|
|
233
|
+
set effectDisposer(t) {
|
|
234
|
+
ne(this, X, qe).call(this), ge(this, ce, t), ne(this, X, _e).call(this);
|
|
235
|
+
}
|
|
236
|
+
set lifecycleNode(t) {
|
|
237
|
+
t !== j(this, _) && (ne(this, X, qe).call(this), ge(this, _, t), ne(this, X, _e).call(this));
|
|
238
|
+
}
|
|
239
|
+
}, ce = new WeakMap(), _ = new WeakMap(), X = new WeakSet(), qe = function() {
|
|
240
|
+
var t;
|
|
241
|
+
ct(j(this, _), this.effectDisposer), ct(j(this, _), (t = this.signal) == null ? void 0 : t.derivedDisposer);
|
|
242
|
+
}, _e = function() {
|
|
243
|
+
var t;
|
|
244
|
+
$e(j(this, _), this.effectDisposer), $e(j(this, _), (t = this.signal) == null ? void 0 : t.derivedDisposer);
|
|
245
|
+
}, Tt);
|
|
246
|
+
function le(t, e, i) {
|
|
247
|
+
const s = i != null && i.useLifecycleRoot ? vi() : void 0, a = new bi(t, s, i == null ? void 0 : i.lifecycleNode), r = a.signal.subscribe(function(h) {
|
|
248
|
+
a.newValue = h, a.isInitial && (this != null && this.dispose) && (a.effectDisposer = this.dispose.bind(this)), a.hasChanged = !a.isInitial && a.prevValue !== a.newValue;
|
|
249
|
+
try {
|
|
250
|
+
e(a);
|
|
251
|
+
} finally {
|
|
252
|
+
a.prevValue = a.newValue, a.isInitial = !1;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return r && !a.effectDisposer && (a.effectDisposer = r), a.effectDisposer;
|
|
256
|
+
}
|
|
257
|
+
function ut(t, e) {
|
|
258
|
+
t instanceof window.HTMLTemplateElement ? t.content.appendChild(e) : t.appendChild(e);
|
|
259
|
+
}
|
|
260
|
+
var Fe = 0, Ge = "__domwisefrag_";
|
|
261
|
+
function Dt(t) {
|
|
262
|
+
return t instanceof Comment && t.data.startsWith(Ge);
|
|
263
|
+
}
|
|
264
|
+
function dt(t) {
|
|
265
|
+
return t instanceof DocumentFragment && Dt(t.firstChild);
|
|
266
|
+
}
|
|
267
|
+
function wi(t, e) {
|
|
268
|
+
var i;
|
|
269
|
+
typeof t.replaceWith == "function" ? t.replaceWith(e) : (i = t.parentNode) == null || i.replaceChild(e, t);
|
|
270
|
+
}
|
|
271
|
+
function gt(t) {
|
|
272
|
+
return t instanceof DocumentFragment ? (++Fe, t.prepend(document.createComment(Ge + Fe)), t.append(document.createComment(Ge + Fe)), t) : t instanceof Node ? t : oe(t) ? document.createTextNode(t) : document.createComment("");
|
|
273
|
+
}
|
|
274
|
+
function yi(t, e) {
|
|
275
|
+
let i;
|
|
276
|
+
le(e, (s) => {
|
|
277
|
+
var h;
|
|
278
|
+
if (s.isInitial) {
|
|
279
|
+
i = gt(s.newValue);
|
|
280
|
+
let c = dt(i) ? i.firstChild : i;
|
|
281
|
+
he(t, i), s.lifecycleNode = (i = c) ?? t;
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (!s.hasChanged)
|
|
285
|
+
return;
|
|
286
|
+
const a = gt(s.newValue);
|
|
287
|
+
if (Dt(i)) {
|
|
288
|
+
let c;
|
|
289
|
+
for (; (c = i.nextSibling) && ((h = c.parentNode) == null || h.removeChild(c), !(c instanceof Comment && c.data === i.data)); )
|
|
290
|
+
;
|
|
291
|
+
}
|
|
292
|
+
let r = dt(a) ? a.firstChild : a;
|
|
293
|
+
wi(i, a), s.lifecycleNode = (i = r) ?? t;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function he(t, e) {
|
|
297
|
+
if (oe(e))
|
|
298
|
+
if (Ze(e))
|
|
299
|
+
for (const i of [...e])
|
|
300
|
+
he(t, i);
|
|
301
|
+
else if (ye(e) || Et(e))
|
|
302
|
+
ut(t, document.createTextNode(e));
|
|
303
|
+
else if (si(e))
|
|
304
|
+
ut(t, e);
|
|
305
|
+
else if (pi(e)) {
|
|
306
|
+
const i = t.attachShadow(e.attr);
|
|
307
|
+
he(i, e.children), Qe(e.ref, i);
|
|
308
|
+
} else Q(e) && yi(t, e);
|
|
309
|
+
}
|
|
310
|
+
function It(t) {
|
|
311
|
+
return t == null || (Ze(t) ? t = Array.from(t).map((e) => Q(e) ? e.peek() : e) : q(t) && (t = { ...t }, Object.entries(t).forEach(([e, i]) => {
|
|
312
|
+
Q(i) && (t[e] = i.peek());
|
|
313
|
+
}))), t;
|
|
314
|
+
}
|
|
315
|
+
function xi(t, e) {
|
|
316
|
+
if (e == null || e === !1 || e === !0)
|
|
317
|
+
return;
|
|
318
|
+
e = It(e);
|
|
319
|
+
const i = (re(e) ?? "").split(" ");
|
|
320
|
+
for (let s of i)
|
|
321
|
+
s && t.classList.remove(s);
|
|
322
|
+
}
|
|
323
|
+
function Pi(t, e, i) {
|
|
324
|
+
if (e == null || e === !1) {
|
|
325
|
+
xi(t, i);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
i = It(i), Ze(e) ? e = Array.from(e).map((s) => {
|
|
329
|
+
let a = s;
|
|
330
|
+
return Q(s) && le(s, (r) => {
|
|
331
|
+
if (r.isInitial) {
|
|
332
|
+
a = r.newValue;
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
Oe(t, r.newValue, r.prevValue);
|
|
336
|
+
}, {
|
|
337
|
+
lifecycleNode: t
|
|
338
|
+
}), a;
|
|
339
|
+
}) : q(e) && (e = { ...e }, Object.entries(e).forEach(([s, a]) => {
|
|
340
|
+
Q(a) && le(a, (r) => {
|
|
341
|
+
if (r.isInitial) {
|
|
342
|
+
e[s] = r.newValue;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
Oe(t, !!r.newValue && s, !!r.prevValue && s);
|
|
346
|
+
}, {
|
|
347
|
+
lifecycleNode: t
|
|
348
|
+
});
|
|
349
|
+
})), Oe(t, e, i);
|
|
350
|
+
}
|
|
351
|
+
function Oe(t, e, i) {
|
|
352
|
+
const s = (re(e) ?? "").split(" ");
|
|
353
|
+
if (i) {
|
|
354
|
+
const a = (re(i) ?? "").split(" ");
|
|
355
|
+
for (let r of a)
|
|
356
|
+
r && !s.includes(r) && t.classList.remove(r);
|
|
357
|
+
}
|
|
358
|
+
for (let a of s)
|
|
359
|
+
a && t.classList.add(a);
|
|
360
|
+
}
|
|
361
|
+
function Si(t, e) {
|
|
362
|
+
return t + e.charAt(0).toUpperCase() + e.substring(1);
|
|
363
|
+
}
|
|
364
|
+
var ki = /* @__PURE__ */ (() => {
|
|
365
|
+
let t = {
|
|
366
|
+
animationIterationCount: 0,
|
|
367
|
+
borderImageOutset: 0,
|
|
368
|
+
borderImageSlice: 0,
|
|
369
|
+
borderImageWidth: 0,
|
|
370
|
+
boxFlex: 0,
|
|
371
|
+
boxFlexGroup: 0,
|
|
372
|
+
boxOrdinalGroup: 0,
|
|
373
|
+
columnCount: 0,
|
|
374
|
+
columns: 0,
|
|
375
|
+
flex: 0,
|
|
376
|
+
flexGrow: 0,
|
|
377
|
+
flexPositive: 0,
|
|
378
|
+
flexShrink: 0,
|
|
379
|
+
flexNegative: 0,
|
|
380
|
+
flexOrder: 0,
|
|
381
|
+
gridArea: 0,
|
|
382
|
+
gridRow: 0,
|
|
383
|
+
gridRowEnd: 0,
|
|
384
|
+
gridRowSpan: 0,
|
|
385
|
+
gridRowStart: 0,
|
|
386
|
+
gridColumn: 0,
|
|
387
|
+
gridColumnEnd: 0,
|
|
388
|
+
gridColumnSpan: 0,
|
|
389
|
+
gridColumnStart: 0,
|
|
390
|
+
fontWeight: 0,
|
|
391
|
+
lineClamp: 0,
|
|
392
|
+
lineHeight: 0,
|
|
393
|
+
opacity: 0,
|
|
394
|
+
order: 0,
|
|
395
|
+
orphans: 0,
|
|
396
|
+
tabSize: 0,
|
|
397
|
+
widows: 0,
|
|
398
|
+
zIndex: 0,
|
|
399
|
+
zoom: 0,
|
|
400
|
+
// SVG-related properties
|
|
401
|
+
fillOpacity: 0,
|
|
402
|
+
floodOpacity: 0,
|
|
403
|
+
stopOpacity: 0,
|
|
404
|
+
strokeDasharray: 0,
|
|
405
|
+
strokeDashoffset: 0,
|
|
406
|
+
strokeMiterlimit: 0,
|
|
407
|
+
strokeOpacity: 0,
|
|
408
|
+
strokeWidth: 0
|
|
409
|
+
};
|
|
410
|
+
const e = ["Webkit", "ms", "Moz", "O"];
|
|
411
|
+
return Object.keys(t).forEach((i) => {
|
|
412
|
+
e.forEach((s) => {
|
|
413
|
+
t[Si(s, i)] = 0;
|
|
414
|
+
});
|
|
415
|
+
}), t;
|
|
416
|
+
})();
|
|
417
|
+
function Ue(t, e, i) {
|
|
418
|
+
e.indexOf("-") === 0 ? t.style.setProperty(e, i) : Et(i) && ki[e] !== 0 ? t.style[e] = i + "px" : t.style[e] = i;
|
|
419
|
+
}
|
|
420
|
+
function ft(t, e) {
|
|
421
|
+
if (!(e == null || e === !1 || e === !0)) {
|
|
422
|
+
if (ye(e)) {
|
|
423
|
+
t.removeAttribute("style");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
q(e) && Object.keys(e).forEach((i) => {
|
|
427
|
+
Ue(t, i, "");
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function Ci(t, e, i) {
|
|
432
|
+
if (e == null || e === !1 || e === !0) {
|
|
433
|
+
ft(t, i);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if (ye(e)) {
|
|
437
|
+
t.setAttribute("style", e);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (q(e)) {
|
|
441
|
+
q(i) ? (e = { ...e }, Object.keys(i).forEach((s) => {
|
|
442
|
+
s in e || (e[s] = "");
|
|
443
|
+
})) : ft(t, i), Object.entries(e).forEach(([s, a]) => {
|
|
444
|
+
Q(a) ? le(a, (r) => Ue(t, s, r.newValue), {
|
|
445
|
+
lifecycleNode: t
|
|
446
|
+
}) : Ue(t, s, a);
|
|
447
|
+
});
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
var Ai = "http://www.w3.org/1999/xlink", Ti = "http://www.w3.org/XML/1998/namespace";
|
|
452
|
+
function fe(t, e) {
|
|
453
|
+
return t.replace(/[A-Z]/g, (i) => e + i.toLowerCase());
|
|
454
|
+
}
|
|
455
|
+
var Mi = /* @__PURE__ */ new Map([
|
|
456
|
+
["autoComplete", "autocomplete"],
|
|
457
|
+
["autoFocus", "autofocus"],
|
|
458
|
+
["className", "class"],
|
|
459
|
+
["colSpan", "colspan"],
|
|
460
|
+
["contentEditable", "contenteditable"],
|
|
461
|
+
["formNoValidate", "formnovalidate"],
|
|
462
|
+
["htmlFor", "for"],
|
|
463
|
+
["innerText", "textContent"],
|
|
464
|
+
["minLength", "minlength"],
|
|
465
|
+
["maxLength", "maxlength"],
|
|
466
|
+
["readOnly", "readonly"],
|
|
467
|
+
["reffererPolicy", "referrerpolicy"],
|
|
468
|
+
["rowSpan", "rowspan"],
|
|
469
|
+
["spellCheck", "spellcheck"],
|
|
470
|
+
["tabIndex", "tabindex"],
|
|
471
|
+
["onDoubleClick", "onDblClick"],
|
|
472
|
+
["onDoubleClickCapture", "onDblClickCapture"]
|
|
473
|
+
]);
|
|
474
|
+
function pt(t, e, i, s) {
|
|
475
|
+
switch (e) {
|
|
476
|
+
case "dataset":
|
|
477
|
+
s != null && Object.entries(s).forEach(([r, h]) => {
|
|
478
|
+
h != null && delete t.dataset[r];
|
|
479
|
+
}), Object.entries(i).forEach(([r, h]) => {
|
|
480
|
+
h != null && (t.dataset[r] = h);
|
|
481
|
+
});
|
|
482
|
+
return;
|
|
483
|
+
case "textContent":
|
|
484
|
+
oe(i) ? t[e] = i : oe(s) && (t[e] = "");
|
|
485
|
+
return;
|
|
486
|
+
case "dangerouslySetInnerHTML":
|
|
487
|
+
q(i) ? t.innerHTML = i.__html : q(s) && (t.innerHTML = "");
|
|
488
|
+
return;
|
|
489
|
+
case "value":
|
|
490
|
+
if (i == null) {
|
|
491
|
+
s != null && (t[e] = null);
|
|
492
|
+
return;
|
|
493
|
+
} else {
|
|
494
|
+
if (t instanceof window.HTMLSelectElement)
|
|
495
|
+
return;
|
|
496
|
+
if (t instanceof window.HTMLTextAreaElement) {
|
|
497
|
+
t.value = i;
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
break;
|
|
502
|
+
case "class":
|
|
503
|
+
Pi(t, i, s);
|
|
504
|
+
return;
|
|
505
|
+
case "spellcheck":
|
|
506
|
+
t.spellcheck = i === "" || i === !0 || i === "true" ? !0 : i === !1 || i === "false" ? !1 : i;
|
|
507
|
+
return;
|
|
508
|
+
case "draggable":
|
|
509
|
+
i === !1 || i === "false" ? i = "false" : i === "" ? i = null : (i === !0 || i === "true") && (i = "true");
|
|
510
|
+
break;
|
|
511
|
+
case "contenteditable":
|
|
512
|
+
i === !1 ? i = "false" : (i === "" || i === !0) && (i = "true");
|
|
513
|
+
break;
|
|
514
|
+
case "ref":
|
|
515
|
+
case "namespaceURI":
|
|
516
|
+
return;
|
|
517
|
+
case "style":
|
|
518
|
+
Ci(t, i, s);
|
|
519
|
+
return;
|
|
520
|
+
case "on":
|
|
521
|
+
case "onCapture":
|
|
522
|
+
const a = e === "onCapture";
|
|
523
|
+
s != null && Object.entries(s).forEach(([r, h]) => {
|
|
524
|
+
(i == null || i[r] !== h) && t.removeEventListener(r, h, a);
|
|
525
|
+
}), Object.entries(i).forEach(([r, h]) => {
|
|
526
|
+
(s == null || s[r] !== h) && t.addEventListener(r, h, a);
|
|
527
|
+
});
|
|
528
|
+
return;
|
|
529
|
+
case "xlinkActuate":
|
|
530
|
+
case "xlinkArcrole":
|
|
531
|
+
case "xlinkHref":
|
|
532
|
+
case "xlinkRole":
|
|
533
|
+
case "xlinkShow":
|
|
534
|
+
case "xlinkTitle":
|
|
535
|
+
case "xlinkType":
|
|
536
|
+
t.setAttributeNS(Ai, fe(e, ":"), i);
|
|
537
|
+
return;
|
|
538
|
+
case "xmlnsXlink":
|
|
539
|
+
t.setAttribute("xmlns:xlink", i);
|
|
540
|
+
return;
|
|
541
|
+
case "xmlBase":
|
|
542
|
+
case "xmlLang":
|
|
543
|
+
case "xmlSpace":
|
|
544
|
+
t.setAttributeNS(Ti, fe(e, ":"), i);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (typeof i == "function") {
|
|
548
|
+
if (e[0] === "o" && e[1] === "n") {
|
|
549
|
+
if (s != null && s === i)
|
|
550
|
+
return;
|
|
551
|
+
let a = e.toLowerCase();
|
|
552
|
+
const r = a.endsWith("capture");
|
|
553
|
+
let h;
|
|
554
|
+
!r && (t[a] === null || s != null && t[a] === s) ? (t[a] = i, $e(t, Di.bind(t, a))) : r ? (h = a.substring(2, a.length - 7), s != null && t.removeEventListener(h, s, !0), t.addEventListener(h, i, !0)) : (a in window ? h = a.substring(2) : h = a[2] + e.slice(3), s != null && t.removeEventListener(h, s), t.addEventListener(h, i));
|
|
555
|
+
} else
|
|
556
|
+
console.warn(`A function was provided for JSX ${t.tagName} element ${e} which does not start with "on":`, i, t.tagName);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (q(s)) {
|
|
560
|
+
if (s === i)
|
|
561
|
+
return;
|
|
562
|
+
delete t[e];
|
|
563
|
+
}
|
|
564
|
+
if (s === !0) {
|
|
565
|
+
if (s === i)
|
|
566
|
+
return;
|
|
567
|
+
t.removeAttribute(e);
|
|
568
|
+
}
|
|
569
|
+
if (s !== !1 && s != null) {
|
|
570
|
+
if (s === i)
|
|
571
|
+
return;
|
|
572
|
+
t instanceof SVGElement && !lt.test(e) ? t.removeAttributeNS(fe(e, "-"), i) : t.removeAttribute(e);
|
|
573
|
+
}
|
|
574
|
+
if (q(i)) {
|
|
575
|
+
t[e] = i;
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (i === !0) {
|
|
579
|
+
t.setAttribute(e, "");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
i !== !1 && i != null && (t instanceof SVGElement && !lt.test(e) ? t.setAttribute(fe(e, "-"), i) : t.setAttribute(e, i));
|
|
583
|
+
}
|
|
584
|
+
function Ei(t, e) {
|
|
585
|
+
for (let [i, s] of Object.entries(e))
|
|
586
|
+
i = Mi.get(i) ?? i, Q(s) ? le(s, (a) => pt(t, i, a.newValue, a.prevValue), {
|
|
587
|
+
lifecycleNode: t
|
|
588
|
+
}) : ai(s) ? s[Mt](t, i) : pt(t, i, s);
|
|
589
|
+
return t;
|
|
590
|
+
}
|
|
591
|
+
function Di(t) {
|
|
592
|
+
this[t] = null;
|
|
593
|
+
}
|
|
594
|
+
function l(t, e) {
|
|
595
|
+
let { children: i, ...s } = e || {}, a = s.namespaceURI;
|
|
596
|
+
a || (ci.has(t) ? a = ui : hi.has(t) ? a = li : a = di());
|
|
597
|
+
let r;
|
|
598
|
+
if (ye(t)) {
|
|
599
|
+
if (r = a ? document.createElementNS(a, t) : document.createElement(t), Ei(r, s), he(r, i), r instanceof window.HTMLSelectElement && s.value != null)
|
|
600
|
+
if (s.multiple === !0 && Array.isArray(s.value)) {
|
|
601
|
+
const h = s.value.map((c) => String(c));
|
|
602
|
+
r.querySelectorAll("option").forEach((c) => c.selected = h.includes(c.value));
|
|
603
|
+
} else
|
|
604
|
+
r.value = s.value;
|
|
605
|
+
Qe(s.ref, r);
|
|
606
|
+
} else if (typeof t == "function")
|
|
607
|
+
q(t.defaultProps) && (s = { ...t.defaultProps, ...s }), r = ni(t) ? ri(t, s, i) : t({ ...s, children: i });
|
|
608
|
+
else
|
|
609
|
+
throw new TypeError(`Invalid JSX element type: ${t}`);
|
|
610
|
+
return r;
|
|
611
|
+
}
|
|
612
|
+
function pe(t) {
|
|
613
|
+
const e = document.createDocumentFragment();
|
|
614
|
+
return he(e, t.children), e;
|
|
615
|
+
}
|
|
616
|
+
var Ii = /* @__PURE__ */ Symbol.for("preact-signals");
|
|
617
|
+
function et() {
|
|
618
|
+
if (Z > 1)
|
|
619
|
+
Z--;
|
|
620
|
+
else {
|
|
621
|
+
var t, e = !1;
|
|
622
|
+
for (function() {
|
|
623
|
+
var a = ve;
|
|
624
|
+
for (ve = void 0; a !== void 0; )
|
|
625
|
+
a.S.v === a.v && (a.S.i = a.i), a = a.o;
|
|
626
|
+
}(); ae !== void 0; ) {
|
|
627
|
+
var i = ae;
|
|
628
|
+
for (ae = void 0, me++; i !== void 0; ) {
|
|
629
|
+
var s = i.u;
|
|
630
|
+
if (i.u = void 0, i.f &= -3, !(8 & i.f) && Lt(i)) try {
|
|
631
|
+
i.c();
|
|
632
|
+
} catch (a) {
|
|
633
|
+
e || (t = a, e = !0);
|
|
634
|
+
}
|
|
635
|
+
i = s;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (me = 0, Z--, e) throw t;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
var N = void 0;
|
|
642
|
+
function Rt(t) {
|
|
643
|
+
var e = N;
|
|
644
|
+
N = void 0;
|
|
645
|
+
try {
|
|
646
|
+
return t();
|
|
647
|
+
} finally {
|
|
648
|
+
N = e;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
var ae = void 0, Z = 0, me = 0, mt = 0, ve = void 0, be = 0;
|
|
652
|
+
function Nt(t) {
|
|
653
|
+
if (N !== void 0) {
|
|
654
|
+
var e = t.n;
|
|
655
|
+
if (e === void 0 || e.t !== N)
|
|
656
|
+
return e = { i: 0, S: t, p: N.s, n: void 0, t: N, e: void 0, x: void 0, r: e }, N.s !== void 0 && (N.s.n = e), N.s = e, t.n = e, 32 & N.f && t.S(e), e;
|
|
657
|
+
if (e.i === -1)
|
|
658
|
+
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = N.s, e.n = void 0, N.s.n = e, N.s = e), e;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function H(t, e) {
|
|
662
|
+
this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
663
|
+
}
|
|
664
|
+
H.prototype.brand = Ii;
|
|
665
|
+
H.prototype.h = function() {
|
|
666
|
+
return !0;
|
|
667
|
+
};
|
|
668
|
+
H.prototype.S = function(t) {
|
|
669
|
+
var e = this, i = this.t;
|
|
670
|
+
i !== t && t.e === void 0 && (t.x = i, this.t = t, i !== void 0 ? i.e = t : Rt(function() {
|
|
671
|
+
var s;
|
|
672
|
+
(s = e.W) == null || s.call(e);
|
|
673
|
+
}));
|
|
674
|
+
};
|
|
675
|
+
H.prototype.U = function(t) {
|
|
676
|
+
var e = this;
|
|
677
|
+
if (this.t !== void 0) {
|
|
678
|
+
var i = t.e, s = t.x;
|
|
679
|
+
i !== void 0 && (i.x = s, t.e = void 0), s !== void 0 && (s.e = i, t.x = void 0), t === this.t && (this.t = s, s === void 0 && Rt(function() {
|
|
680
|
+
var a;
|
|
681
|
+
(a = e.Z) == null || a.call(e);
|
|
682
|
+
}));
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
H.prototype.subscribe = function(t) {
|
|
686
|
+
var e = this;
|
|
687
|
+
return Ni(function() {
|
|
688
|
+
var i = e.value, s = N;
|
|
689
|
+
N = void 0;
|
|
690
|
+
try {
|
|
691
|
+
t(i);
|
|
692
|
+
} finally {
|
|
693
|
+
N = s;
|
|
694
|
+
}
|
|
695
|
+
}, { name: "sub" });
|
|
696
|
+
};
|
|
697
|
+
H.prototype.valueOf = function() {
|
|
698
|
+
return this.value;
|
|
699
|
+
};
|
|
700
|
+
H.prototype.toString = function() {
|
|
701
|
+
return this.value + "";
|
|
702
|
+
};
|
|
703
|
+
H.prototype.toJSON = function() {
|
|
704
|
+
return this.value;
|
|
705
|
+
};
|
|
706
|
+
H.prototype.peek = function() {
|
|
707
|
+
var t = N;
|
|
708
|
+
N = void 0;
|
|
709
|
+
try {
|
|
710
|
+
return this.value;
|
|
711
|
+
} finally {
|
|
712
|
+
N = t;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
Object.defineProperty(H.prototype, "value", { get: function() {
|
|
716
|
+
var t = Nt(this);
|
|
717
|
+
return t !== void 0 && (t.i = this.i), this.v;
|
|
718
|
+
}, set: function(t) {
|
|
719
|
+
if (t !== this.v) {
|
|
720
|
+
if (me > 100) throw new Error("Cycle detected");
|
|
721
|
+
(function(i) {
|
|
722
|
+
Z !== 0 && me === 0 && i.l !== mt && (i.l = mt, ve = { S: i, v: i.v, i: i.i, o: ve });
|
|
723
|
+
})(this), this.v = t, this.i++, be++, Z++;
|
|
724
|
+
try {
|
|
725
|
+
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
|
|
726
|
+
} finally {
|
|
727
|
+
et();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
} });
|
|
731
|
+
function Lt(t) {
|
|
732
|
+
for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
|
|
733
|
+
return !1;
|
|
734
|
+
}
|
|
735
|
+
function zt(t) {
|
|
736
|
+
for (var e = t.s; e !== void 0; e = e.n) {
|
|
737
|
+
var i = e.S.n;
|
|
738
|
+
if (i !== void 0 && (e.r = i), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
739
|
+
t.s = e;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function Ft(t) {
|
|
745
|
+
for (var e = t.s, i = void 0; e !== void 0; ) {
|
|
746
|
+
var s = e.p;
|
|
747
|
+
e.i === -1 ? (e.S.U(e), s !== void 0 && (s.n = e.n), e.n !== void 0 && (e.n.p = s)) : i = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = s;
|
|
748
|
+
}
|
|
749
|
+
t.s = i;
|
|
750
|
+
}
|
|
751
|
+
function ee(t, e) {
|
|
752
|
+
H.call(this, void 0), this.x = t, this.s = void 0, this.g = be - 1, this.f = 4, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
753
|
+
}
|
|
754
|
+
ee.prototype = new H();
|
|
755
|
+
ee.prototype.h = function() {
|
|
756
|
+
if (this.f &= -3, 1 & this.f) return !1;
|
|
757
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === be)) return !0;
|
|
758
|
+
if (this.g = be, this.f |= 1, this.i > 0 && !Lt(this))
|
|
759
|
+
return this.f &= -2, !0;
|
|
760
|
+
var t = N;
|
|
761
|
+
try {
|
|
762
|
+
zt(this), N = this;
|
|
763
|
+
var e = this.x();
|
|
764
|
+
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
765
|
+
} catch (i) {
|
|
766
|
+
this.v = i, this.f |= 16, this.i++;
|
|
767
|
+
}
|
|
768
|
+
return N = t, Ft(this), this.f &= -2, !0;
|
|
769
|
+
};
|
|
770
|
+
ee.prototype.S = function(t) {
|
|
771
|
+
if (this.t === void 0) {
|
|
772
|
+
this.f |= 36;
|
|
773
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
|
|
774
|
+
}
|
|
775
|
+
H.prototype.S.call(this, t);
|
|
776
|
+
};
|
|
777
|
+
ee.prototype.U = function(t) {
|
|
778
|
+
if (this.t !== void 0 && (H.prototype.U.call(this, t), this.t === void 0)) {
|
|
779
|
+
this.f &= -33;
|
|
780
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
ee.prototype.N = function() {
|
|
784
|
+
if (!(2 & this.f)) {
|
|
785
|
+
this.f |= 6;
|
|
786
|
+
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
Object.defineProperty(ee.prototype, "value", { get: function() {
|
|
790
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
791
|
+
var t = Nt(this);
|
|
792
|
+
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
793
|
+
return this.v;
|
|
794
|
+
} });
|
|
795
|
+
function Ot(t) {
|
|
796
|
+
var e = t.m;
|
|
797
|
+
if (t.m = void 0, typeof e == "function") {
|
|
798
|
+
Z++;
|
|
799
|
+
var i = N;
|
|
800
|
+
N = void 0;
|
|
801
|
+
try {
|
|
802
|
+
e();
|
|
803
|
+
} catch (s) {
|
|
804
|
+
throw t.f &= -2, t.f |= 8, tt(t), s;
|
|
805
|
+
} finally {
|
|
806
|
+
N = i, et();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function tt(t) {
|
|
811
|
+
for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
|
|
812
|
+
t.x = void 0, t.s = void 0, Ot(t);
|
|
813
|
+
}
|
|
814
|
+
function Ri(t) {
|
|
815
|
+
if (N !== this) throw new Error("Out-of-order effect");
|
|
816
|
+
Ft(this), N = t, this.f &= -2, 8 & this.f && tt(this), et();
|
|
817
|
+
}
|
|
818
|
+
function te(t, e) {
|
|
819
|
+
this.x = t, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = e == null ? void 0 : e.name;
|
|
820
|
+
}
|
|
821
|
+
te.prototype.c = function() {
|
|
822
|
+
var t = this.S();
|
|
823
|
+
try {
|
|
824
|
+
if (8 & this.f || this.x === void 0) return;
|
|
825
|
+
var e = this.x();
|
|
826
|
+
typeof e == "function" && (this.m = e);
|
|
827
|
+
} finally {
|
|
828
|
+
t();
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
te.prototype.S = function() {
|
|
832
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
833
|
+
this.f |= 1, this.f &= -9, Ot(this), zt(this), Z++;
|
|
834
|
+
var t = N;
|
|
835
|
+
return N = this, Ri.bind(this, t);
|
|
836
|
+
};
|
|
837
|
+
te.prototype.N = function() {
|
|
838
|
+
2 & this.f || (this.f |= 2, this.u = ae, ae = this);
|
|
839
|
+
};
|
|
840
|
+
te.prototype.d = function() {
|
|
841
|
+
this.f |= 8, 1 & this.f || tt(this);
|
|
842
|
+
};
|
|
843
|
+
te.prototype.dispose = function() {
|
|
844
|
+
this.d();
|
|
845
|
+
};
|
|
846
|
+
function Ni(t, e) {
|
|
847
|
+
var i = new te(t, e);
|
|
848
|
+
try {
|
|
849
|
+
i.c();
|
|
850
|
+
} catch (a) {
|
|
851
|
+
throw i.d(), a;
|
|
852
|
+
}
|
|
853
|
+
var s = i.d.bind(i);
|
|
854
|
+
return s[Symbol.dispose] = s, s;
|
|
855
|
+
}
|
|
856
|
+
const Li = {
|
|
857
|
+
emptyStateTitle: "No data available.",
|
|
858
|
+
thumbnails: "Thumbnails",
|
|
859
|
+
singlePageMode: "Single Page Mode",
|
|
860
|
+
pages: "Pages",
|
|
861
|
+
previous: "Previous",
|
|
862
|
+
next: "Next",
|
|
863
|
+
zoomOut: "Zoom Out",
|
|
864
|
+
zoomIn: "Zoom In",
|
|
865
|
+
fullscreen: "Fullscreen",
|
|
866
|
+
settings: "Settings",
|
|
867
|
+
downloadCatalog: "Download Catalog",
|
|
868
|
+
share: "Share",
|
|
869
|
+
bookmark: "Bookmark page",
|
|
870
|
+
removeBookmark: "Remove bookmark",
|
|
871
|
+
notes: "Page note",
|
|
872
|
+
saveNote: "Save note",
|
|
873
|
+
clearNote: "Clear note",
|
|
874
|
+
closeNote: "Close note editor",
|
|
875
|
+
editNote: "Edit",
|
|
876
|
+
deleteNote: "Delete",
|
|
877
|
+
play: "Play",
|
|
878
|
+
pause: "Pause",
|
|
879
|
+
tableOfContents: "Table of Contents",
|
|
880
|
+
search: "Search",
|
|
881
|
+
searchPlaceholder: "Search PDF text",
|
|
882
|
+
clearSearch: "Clear",
|
|
883
|
+
closeSearch: "Close search",
|
|
884
|
+
noSearchResults: "No results",
|
|
885
|
+
searchUnavailable: "Text search is available only in Direct PDF mode.",
|
|
886
|
+
closeHotspot: "Close popup",
|
|
887
|
+
annotation: "Page annotation",
|
|
888
|
+
saving: "Saving…",
|
|
889
|
+
noteFailed: "Could not save the note. Your draft is retained; try again.",
|
|
890
|
+
searching: "Searching…",
|
|
891
|
+
searchFailed: "Search failed. Try again.",
|
|
892
|
+
closeContents: "Close table of contents",
|
|
893
|
+
moreActions: "More actions",
|
|
894
|
+
sound: "Sound",
|
|
895
|
+
myNotes: "My notes",
|
|
896
|
+
currentPage: "This page",
|
|
897
|
+
allNotes: "All notes",
|
|
898
|
+
privateNotes: "Your personal notes for this document.",
|
|
899
|
+
noNotes: "No notes yet. Select a place on the page to add your first note.",
|
|
900
|
+
addNote: "Place a note",
|
|
901
|
+
pageHasNote: "This page has a note",
|
|
902
|
+
page: "Page",
|
|
903
|
+
noteSaved: "Saved",
|
|
904
|
+
confirmDeleteNote: "Delete this note?",
|
|
905
|
+
cancel: "Cancel",
|
|
906
|
+
placeNote: "Click or tap a place on the page for your note.",
|
|
907
|
+
keyboardShortcuts: "Keyboard shortcuts",
|
|
908
|
+
textSelection: "Select text",
|
|
909
|
+
resetZoom: "Fit page"
|
|
910
|
+
}, zi = {
|
|
911
|
+
emptyStateTitle: "Veri bulunamadi.",
|
|
912
|
+
thumbnails: "Küçük Resimler",
|
|
913
|
+
singlePageMode: "Tek Sayfa Modu",
|
|
914
|
+
pages: "Sayfalar",
|
|
915
|
+
previous: "Önceki",
|
|
916
|
+
next: "Sonraki",
|
|
917
|
+
zoomOut: "Uzaklaş",
|
|
918
|
+
zoomIn: "Yaklaş",
|
|
919
|
+
fullscreen: "Tam Ekran",
|
|
920
|
+
settings: "Ayarlar",
|
|
921
|
+
downloadCatalog: "Kataloğu İndir",
|
|
922
|
+
share: "Paylaş",
|
|
923
|
+
bookmark: "Sayfayı yer imlerine ekle",
|
|
924
|
+
removeBookmark: "Yer imini kaldır",
|
|
925
|
+
notes: "Sayfa notu",
|
|
926
|
+
saveNote: "Notu kaydet",
|
|
927
|
+
clearNote: "Notu temizle",
|
|
928
|
+
closeNote: "Not editörünü kapat",
|
|
929
|
+
editNote: "Düzenle",
|
|
930
|
+
deleteNote: "Sil",
|
|
931
|
+
play: "Otomatik Oynat",
|
|
932
|
+
pause: "Duraklat",
|
|
933
|
+
tableOfContents: "İçindekiler",
|
|
934
|
+
search: "Ara",
|
|
935
|
+
searchPlaceholder: "PDF metninde ara",
|
|
936
|
+
clearSearch: "Temizle",
|
|
937
|
+
closeSearch: "Aramayı kapat",
|
|
938
|
+
noSearchResults: "Sonuç bulunamadı",
|
|
939
|
+
searchUnavailable: "Metin arama yalnızca Doğrudan PDF modunda desteklenir.",
|
|
940
|
+
closeHotspot: "Açılır pencereyi kapat",
|
|
941
|
+
annotation: "Sayfa açıklaması",
|
|
942
|
+
saving: "Kaydediliyor…",
|
|
943
|
+
noteFailed: "Not kaydedilemedi. Taslağınız korundu; tekrar deneyin.",
|
|
944
|
+
searching: "Aranıyor…",
|
|
945
|
+
searchFailed: "Arama başarısız oldu. Tekrar deneyin.",
|
|
946
|
+
closeContents: "İçindekileri kapat",
|
|
947
|
+
moreActions: "Diğer işlemler",
|
|
948
|
+
sound: "Ses",
|
|
949
|
+
myNotes: "Notlarım",
|
|
950
|
+
currentPage: "Bu sayfa",
|
|
951
|
+
allNotes: "Tüm notlar",
|
|
952
|
+
privateNotes: "Bu belge için kişisel notlarınız.",
|
|
953
|
+
noNotes: "Henüz not yok. İlk notunuz için sayfada bir yer seçin.",
|
|
954
|
+
addNote: "Konuma not ekle",
|
|
955
|
+
pageHasNote: "Bu sayfada not var",
|
|
956
|
+
page: "Sayfa",
|
|
957
|
+
noteSaved: "Kaydedildi",
|
|
958
|
+
confirmDeleteNote: "Bu not silinsin mi?",
|
|
959
|
+
cancel: "Vazgeç",
|
|
960
|
+
placeNote: "Not eklemek için sayfada bir yere tıklayın veya dokunun.",
|
|
961
|
+
keyboardShortcuts: "Klavye kısayolları",
|
|
962
|
+
textSelection: "Metin seçimi",
|
|
963
|
+
resetZoom: "Sayfaya sığdır"
|
|
964
|
+
}, Be = {
|
|
965
|
+
en: Li,
|
|
966
|
+
tr: zi
|
|
967
|
+
};
|
|
968
|
+
function U(t = {}) {
|
|
969
|
+
var a;
|
|
970
|
+
const e = t.locale ?? "en", i = Be[e] ?? Be.en, s = ((a = t.messages) == null ? void 0 : a[e]) ?? {};
|
|
971
|
+
return {
|
|
972
|
+
...Be.en,
|
|
973
|
+
...i,
|
|
974
|
+
...s
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
function Bt(t, e) {
|
|
978
|
+
var g;
|
|
979
|
+
(g = t.querySelector(".bk-shortcuts-dialog")) == null || g.remove();
|
|
980
|
+
const i = U({ locale: e.locale.value, messages: e.messages.value }), s = document.createElement("dialog");
|
|
981
|
+
s.className = "bk-shortcuts-dialog", s.setAttribute("aria-label", i.keyboardShortcuts);
|
|
982
|
+
const a = document.createElement("strong");
|
|
983
|
+
a.textContent = i.keyboardShortcuts, s.append(a);
|
|
984
|
+
const r = document.createElement("dl");
|
|
985
|
+
for (const [v, y] of [["← / →", `${i.previous} / ${i.next}`], ["Home / End", i.pages], ["+ / −", `${i.zoomIn} / ${i.zoomOut}`], ["0", i.resetZoom], ["N", i.addNote], ["Shift + N", i.myNotes], ["/", i.search], ["I", i.tableOfContents], ["T", i.thumbnails], ["F", i.fullscreen], ["Esc", i.closeHotspot], ["Tab / Shift + Tab", i.moreActions]]) {
|
|
986
|
+
const S = document.createElement("dt");
|
|
987
|
+
S.textContent = v;
|
|
988
|
+
const m = document.createElement("dd");
|
|
989
|
+
m.textContent = y, r.append(S, m);
|
|
990
|
+
}
|
|
991
|
+
const h = document.createElement("button");
|
|
992
|
+
h.type = "button", h.textContent = i.closeHotspot, h.addEventListener("click", () => s.close()), s.append(r, h), t.append(s);
|
|
993
|
+
const c = t.ownerDocument.activeElement;
|
|
994
|
+
s.addEventListener("close", () => {
|
|
995
|
+
s.remove(), c != null && c.isConnected && c.focus();
|
|
996
|
+
}, { once: !0 }), s.showModal();
|
|
997
|
+
}
|
|
998
|
+
function Fi(t, e, i) {
|
|
999
|
+
const s = /* @__PURE__ */ l("div", { class: "bk-more-menu" }), a = [
|
|
1000
|
+
[".bk-btn--autoplay", "play"],
|
|
1001
|
+
[".bk-btn--single", "singlePageMode"],
|
|
1002
|
+
[".bk-btn--share", "share"],
|
|
1003
|
+
[".bk-btn--bookmark", "bookmark"],
|
|
1004
|
+
[".bk-btn--download", "downloadCatalog"],
|
|
1005
|
+
[".bk-btn--sound", "sound"]
|
|
1006
|
+
];
|
|
1007
|
+
for (const [h, c] of a) {
|
|
1008
|
+
const g = t.querySelector(h);
|
|
1009
|
+
g && (g.append(/* @__PURE__ */ l("span", { children: d(() => e.value[c]) })), s.append(g));
|
|
1010
|
+
}
|
|
1011
|
+
s.append(/* @__PURE__ */ l(
|
|
1012
|
+
"button",
|
|
1013
|
+
{
|
|
1014
|
+
type: "button",
|
|
1015
|
+
class: "bk-btn bk-btn--text-selection",
|
|
1016
|
+
style: d(() => i.textAvailable.value ? "" : "display:none;"),
|
|
1017
|
+
"aria-pressed": d(() => i.textSelection.value ? "true" : "false"),
|
|
1018
|
+
onClick: () => {
|
|
1019
|
+
i.textSelection.value = !i.textSelection.value, i.placingNote.value = !1;
|
|
1020
|
+
},
|
|
1021
|
+
children: d(() => e.value.textSelection)
|
|
1022
|
+
}
|
|
1023
|
+
)), s.append(/* @__PURE__ */ l("button", { type: "button", class: "bk-btn", onClick: () => Bt(t.closest(".bk-wrapper"), i), children: d(() => e.value.keyboardShortcuts) }));
|
|
1024
|
+
let r;
|
|
1025
|
+
r = /* @__PURE__ */ l("details", { class: "bk-more", onKeyDown: (h) => {
|
|
1026
|
+
var c;
|
|
1027
|
+
h.key === "Escape" && (r.open = !1, (c = r.querySelector("summary")) == null || c.focus());
|
|
1028
|
+
}, children: [
|
|
1029
|
+
/* @__PURE__ */ l("summary", { class: "bk-btn", "aria-label": d(() => e.value.moreActions), title: d(() => e.value.moreActions), children: "…" }),
|
|
1030
|
+
s
|
|
1031
|
+
] }), s.addEventListener("click", (h) => {
|
|
1032
|
+
h.target.closest("button") && (r.open = !1);
|
|
1033
|
+
}), t.lastElementChild.append(r);
|
|
1034
|
+
}
|
|
1035
|
+
function vt(t) {
|
|
1036
|
+
return t.registry ? (t.registry.version.value, t.registry.getToolbarButtons().filter((i) => (i.placement || "end") === t.placement).map((i) => {
|
|
1037
|
+
const s = typeof i.disabled == "function" ? i.disabled() : i.disabled;
|
|
1038
|
+
return /* @__PURE__ */ l(
|
|
1039
|
+
"button",
|
|
1040
|
+
{
|
|
1041
|
+
type: "button",
|
|
1042
|
+
class: "bk-btn bk-btn--plugin",
|
|
1043
|
+
onClick: i.onClick,
|
|
1044
|
+
disabled: s,
|
|
1045
|
+
"aria-label": i.title || i.label,
|
|
1046
|
+
title: i.title || i.label,
|
|
1047
|
+
children: [
|
|
1048
|
+
i.icon ? /* @__PURE__ */ l("span", { class: "bk-plugin-button-icon", "aria-hidden": "true", children: i.icon }) : null,
|
|
1049
|
+
/* @__PURE__ */ l("span", { class: "bk-plugin-button-label", children: i.label })
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1053
|
+
})) : [];
|
|
1054
|
+
}
|
|
1055
|
+
function Oi(t) {
|
|
1056
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value })), i = /* @__PURE__ */ l("div", { class: "bk-toolbar", role: "toolbar", "aria-label": "Flipbook controls", children: [
|
|
1057
|
+
/* @__PURE__ */ l("div", { class: "bk-btn-group", children: [
|
|
1058
|
+
vt({ registry: t.pluginRegistry, placement: "start" }),
|
|
1059
|
+
/* @__PURE__ */ l(
|
|
1060
|
+
"button",
|
|
1061
|
+
{
|
|
1062
|
+
type: "button",
|
|
1063
|
+
class: d(() => `bk-btn ${t.store.showThumbs.value ? "active" : ""}`),
|
|
1064
|
+
onClick: t.onToggleThumbs,
|
|
1065
|
+
"aria-label": d(() => e.value.thumbnails || "Thumbnails"),
|
|
1066
|
+
"aria-pressed": d(() => t.store.showThumbs.value ? "true" : "false"),
|
|
1067
|
+
title: d(() => e.value.thumbnails || "Thumbnails"),
|
|
1068
|
+
children: /* @__PURE__ */ l("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: [
|
|
1069
|
+
/* @__PURE__ */ l("rect", { x: "3", y: "3", width: "7", height: "7" }),
|
|
1070
|
+
/* @__PURE__ */ l("rect", { x: "14", y: "3", width: "7", height: "7" }),
|
|
1071
|
+
/* @__PURE__ */ l("rect", { x: "14", y: "14", width: "7", height: "7" }),
|
|
1072
|
+
/* @__PURE__ */ l("rect", { x: "3", y: "14", width: "7", height: "7" })
|
|
1073
|
+
] })
|
|
1074
|
+
}
|
|
1075
|
+
),
|
|
1076
|
+
d(() => t.store.toc.value.length ? /* @__PURE__ */ l(
|
|
1077
|
+
"button",
|
|
1078
|
+
{
|
|
1079
|
+
type: "button",
|
|
1080
|
+
class: d(() => t.store.showToc.value ? "bk-btn active" : "bk-btn"),
|
|
1081
|
+
onClick: t.onToggleToc,
|
|
1082
|
+
"aria-label": d(() => e.value.tableOfContents || "Table of Contents"),
|
|
1083
|
+
"aria-pressed": d(() => t.store.showToc.value ? "true" : "false"),
|
|
1084
|
+
title: d(() => e.value.tableOfContents || "Table of Contents"),
|
|
1085
|
+
children: /* @__PURE__ */ l("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: [
|
|
1086
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
1087
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
1088
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
|
|
1089
|
+
/* @__PURE__ */ l("line", { x1: "3", y1: "6", x2: "3.01", y2: "6" }),
|
|
1090
|
+
/* @__PURE__ */ l("line", { x1: "3", y1: "12", x2: "3.01", y2: "12" }),
|
|
1091
|
+
/* @__PURE__ */ l("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
|
|
1092
|
+
] })
|
|
1093
|
+
}
|
|
1094
|
+
) : null),
|
|
1095
|
+
/* @__PURE__ */ l(
|
|
1096
|
+
"button",
|
|
1097
|
+
{
|
|
1098
|
+
type: "button",
|
|
1099
|
+
class: d(() => t.store.showSearch.value ? "bk-btn active" : "bk-btn"),
|
|
1100
|
+
onClick: t.onToggleSearch,
|
|
1101
|
+
disabled: d(() => !t.store.searchAvailable.value),
|
|
1102
|
+
"aria-label": d(() => t.store.searchAvailable.value ? e.value.search || "Search" : e.value.searchUnavailable || "Text search is available only in Direct PDF mode."),
|
|
1103
|
+
"aria-pressed": d(() => t.store.showSearch.value ? "true" : "false"),
|
|
1104
|
+
title: d(() => t.store.searchAvailable.value ? e.value.search || "Search" : e.value.searchUnavailable || "Text search is available only in Direct PDF mode."),
|
|
1105
|
+
children: /* @__PURE__ */ l("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: [
|
|
1106
|
+
/* @__PURE__ */ l("circle", { cx: "11", cy: "11", r: "7" }),
|
|
1107
|
+
/* @__PURE__ */ l("line", { x1: "16", y1: "16", x2: "21", y2: "21" })
|
|
1108
|
+
] })
|
|
1109
|
+
}
|
|
1110
|
+
),
|
|
1111
|
+
/* @__PURE__ */ l(
|
|
1112
|
+
"button",
|
|
1113
|
+
{
|
|
1114
|
+
type: "button",
|
|
1115
|
+
class: d(() => `bk-btn bk-btn--single bz-hide-mobile ${t.store.isSingleMode.value ? "active" : ""}`),
|
|
1116
|
+
onClick: t.onToggleSingleMode,
|
|
1117
|
+
"aria-label": d(() => e.value.singlePageMode || "Single Page"),
|
|
1118
|
+
"aria-pressed": d(() => t.store.isSingleMode.value ? "true" : "false"),
|
|
1119
|
+
title: d(() => e.value.singlePageMode || "Single Page"),
|
|
1120
|
+
children: /* @__PURE__ */ l("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: [
|
|
1121
|
+
/* @__PURE__ */ l("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1122
|
+
/* @__PURE__ */ l("polyline", { points: "14 2 14 8 20 8" }),
|
|
1123
|
+
/* @__PURE__ */ l("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
|
|
1124
|
+
/* @__PURE__ */ l("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
|
|
1125
|
+
/* @__PURE__ */ l("polyline", { points: "10 9 9 9 8 9" })
|
|
1126
|
+
] })
|
|
1127
|
+
}
|
|
1128
|
+
),
|
|
1129
|
+
/* @__PURE__ */ l(
|
|
1130
|
+
"button",
|
|
1131
|
+
{
|
|
1132
|
+
type: "button",
|
|
1133
|
+
class: d(() => `bk-btn bk-btn--autoplay ${t.store.isAutoPlaying.value ? "active" : ""}`),
|
|
1134
|
+
onClick: t.onToggleAutoPlay,
|
|
1135
|
+
"aria-label": d(() => t.store.isAutoPlaying.value ? e.value.pause || "Pause" : e.value.play || "Play"),
|
|
1136
|
+
"aria-pressed": d(() => t.store.isAutoPlaying.value ? "true" : "false"),
|
|
1137
|
+
title: d(() => t.store.isAutoPlaying.value ? e.value.pause || "Pause" : e.value.play || "Play"),
|
|
1138
|
+
children: d(() => t.store.isAutoPlaying.value ? /* @__PURE__ */ l("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: [
|
|
1139
|
+
/* @__PURE__ */ l("rect", { x: "6", y: "4", width: "4", height: "16" }),
|
|
1140
|
+
/* @__PURE__ */ l("rect", { x: "14", y: "4", width: "4", height: "16" })
|
|
1141
|
+
] }) : /* @__PURE__ */ l("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__ */ l("polygon", { points: "5 3 19 12 5 21 5 3" }) }))
|
|
1142
|
+
}
|
|
1143
|
+
)
|
|
1144
|
+
] }),
|
|
1145
|
+
/* @__PURE__ */ l("div", { class: "bk-btn-group bk-btn-group--center", children: [
|
|
1146
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-btn", onClick: t.onPrevPage, "aria-label": d(() => e.value.previous || "Previous"), title: d(() => e.value.previous || "Previous"), children: /* @__PURE__ */ l("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__ */ l("polyline", { points: "15 18 9 12 15 6" }) }) }),
|
|
1147
|
+
/* @__PURE__ */ l("span", { class: "bz-page-info", "aria-live": "polite", "aria-atomic": "true", children: d(() => {
|
|
1148
|
+
const s = t.store.currentPage.value, a = t.store.totalPages.value;
|
|
1149
|
+
if (t.store.isSingleMode.value || s === 0 || s >= a - 1)
|
|
1150
|
+
return `${s + 1} / ${a}`;
|
|
1151
|
+
const r = s % 2 === 1 ? s : s - 1;
|
|
1152
|
+
return `${r + 1}-${r + 2} / ${a}`;
|
|
1153
|
+
}) }),
|
|
1154
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-btn", onClick: t.onNextPage, "aria-label": d(() => e.value.next || "Next"), title: d(() => e.value.next || "Next"), children: /* @__PURE__ */ l("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__ */ l("polyline", { points: "9 18 15 12 9 6" }) }) })
|
|
1155
|
+
] }),
|
|
1156
|
+
/* @__PURE__ */ l("div", { class: "bk-btn-group", children: [
|
|
1157
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-btn", onClick: t.onZoomIn, "aria-label": d(() => e.value.zoomIn || "Zoom In"), title: d(() => e.value.zoomIn || "Zoom In"), children: /* @__PURE__ */ l("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: [
|
|
1158
|
+
/* @__PURE__ */ l("circle", { cx: "11", cy: "11", r: "8" }),
|
|
1159
|
+
/* @__PURE__ */ l("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
|
|
1160
|
+
/* @__PURE__ */ l("line", { x1: "11", y1: "8", x2: "11", y2: "14" }),
|
|
1161
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
|
|
1162
|
+
] }) }),
|
|
1163
|
+
/* @__PURE__ */ l(
|
|
1164
|
+
"button",
|
|
1165
|
+
{
|
|
1166
|
+
type: "button",
|
|
1167
|
+
class: d(() => `bk-btn ${t.store.isZoomed.value ? "active" : ""}`),
|
|
1168
|
+
onClick: t.onZoomOut,
|
|
1169
|
+
"aria-label": d(() => e.value.zoomOut || "Zoom Out"),
|
|
1170
|
+
title: d(() => e.value.zoomOut || "Zoom Out"),
|
|
1171
|
+
children: /* @__PURE__ */ l("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: [
|
|
1172
|
+
/* @__PURE__ */ l("circle", { cx: "11", cy: "11", r: "8" }),
|
|
1173
|
+
/* @__PURE__ */ l("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
|
|
1174
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
|
|
1175
|
+
] })
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-btn bk-btn--fullscreen", onClick: t.onToggleFullscreen, "aria-label": d(() => e.value.fullscreen || "Fullscreen"), title: d(() => e.value.fullscreen || "Fullscreen"), children: /* @__PURE__ */ l("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__ */ l("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" }) }) }),
|
|
1179
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-btn bk-btn--share", onClick: t.onShare, "aria-label": d(() => e.value.share || "Share"), title: d(() => e.value.share || "Share"), children: /* @__PURE__ */ l("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: [
|
|
1180
|
+
/* @__PURE__ */ l("circle", { cx: "18", cy: "5", r: "3" }),
|
|
1181
|
+
/* @__PURE__ */ l("circle", { cx: "6", cy: "12", r: "3" }),
|
|
1182
|
+
/* @__PURE__ */ l("circle", { cx: "18", cy: "19", r: "3" }),
|
|
1183
|
+
/* @__PURE__ */ l("line", { x1: "8.59", y1: "13.51", x2: "15.42", y2: "17.49" }),
|
|
1184
|
+
/* @__PURE__ */ l("line", { x1: "15.41", y1: "6.51", x2: "8.59", y2: "10.49" })
|
|
1185
|
+
] }) }),
|
|
1186
|
+
/* @__PURE__ */ l("button", { type: "button", class: d(() => `bk-btn bk-btn--bookmark ${t.store.bookmarkedPages.value.has(t.store.currentPage.value) ? "active" : ""}`), onClick: t.onToggleBookmark, "aria-label": d(() => t.store.bookmarkedPages.value.has(t.store.currentPage.value) ? e.value.removeBookmark || "Remove bookmark" : e.value.bookmark || "Bookmark page"), title: d(() => t.store.bookmarkedPages.value.has(t.store.currentPage.value) ? e.value.removeBookmark || "Remove bookmark" : e.value.bookmark || "Bookmark page"), "aria-pressed": d(() => t.store.bookmarkedPages.value.has(t.store.currentPage.value) ? "true" : "false"), children: /* @__PURE__ */ l("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__ */ l("path", { d: "M5 4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v18l-7-4-7 4V4z" }) }) }),
|
|
1187
|
+
/* @__PURE__ */ l(
|
|
1188
|
+
"button",
|
|
1189
|
+
{
|
|
1190
|
+
type: "button",
|
|
1191
|
+
class: d(() => `bk-btn bk-btn--notes ${t.store.showNotes.value ? "active" : ""} ${t.store.pageNotes.value.has(t.store.currentPage.value) || t.store.annotations.value.some((s) => s.pageIndex === t.store.currentPage.value) ? "bk-has-page-note" : ""}`),
|
|
1192
|
+
onClick: t.onToggleNotes,
|
|
1193
|
+
"aria-label": d(() => `${e.value.myNotes} (${t.store.pageNotes.value.size + t.store.annotations.value.length})`),
|
|
1194
|
+
title: d(() => e.value.myNotes),
|
|
1195
|
+
"aria-pressed": d(() => t.store.showNotes.value ? "true" : "false"),
|
|
1196
|
+
children: [
|
|
1197
|
+
/* @__PURE__ */ l("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: [
|
|
1198
|
+
/* @__PURE__ */ l("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1199
|
+
/* @__PURE__ */ l("polyline", { points: "14 2 14 8 20 8" }),
|
|
1200
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "13", x2: "16", y2: "13" }),
|
|
1201
|
+
/* @__PURE__ */ l("line", { x1: "8", y1: "17", x2: "14", y2: "17" })
|
|
1202
|
+
] }),
|
|
1203
|
+
/* @__PURE__ */ l("span", { class: "bk-notes-count", "aria-hidden": "true", children: d(() => t.store.pageNotes.value.size + t.store.annotations.value.length || "") })
|
|
1204
|
+
]
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1207
|
+
d(() => t.store.allowDownload.value && t.store.hasDownloadUrl.value && t.onDownload ? /* @__PURE__ */ l("button", { type: "button", class: "bk-btn bk-btn--download", onClick: t.onDownload, "aria-label": d(() => e.value.downloadCatalog || "Download"), title: d(() => e.value.downloadCatalog || "Download"), children: /* @__PURE__ */ l("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: [
|
|
1208
|
+
/* @__PURE__ */ l("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1209
|
+
/* @__PURE__ */ l("polyline", { points: "7 10 12 15 17 10" }),
|
|
1210
|
+
/* @__PURE__ */ l("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1211
|
+
] }) }) : null),
|
|
1212
|
+
/* @__PURE__ */ l(
|
|
1213
|
+
"button",
|
|
1214
|
+
{
|
|
1215
|
+
type: "button",
|
|
1216
|
+
class: d(() => `bk-btn bk-btn--sound ${t.store.soundEnabled.value ? "" : "muted"}`),
|
|
1217
|
+
onClick: t.onSoundToggle,
|
|
1218
|
+
"aria-label": "Sound",
|
|
1219
|
+
"aria-pressed": d(() => t.store.soundEnabled.value ? "true" : "false"),
|
|
1220
|
+
title: "Sound",
|
|
1221
|
+
children: d(() => t.store.soundEnabled.value ? /* @__PURE__ */ l("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: [
|
|
1222
|
+
/* @__PURE__ */ l("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
|
|
1223
|
+
/* @__PURE__ */ l("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" }),
|
|
1224
|
+
/* @__PURE__ */ l("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" })
|
|
1225
|
+
] }) : /* @__PURE__ */ l("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: [
|
|
1226
|
+
/* @__PURE__ */ l("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
|
|
1227
|
+
/* @__PURE__ */ l("line", { x1: "23", y1: "9", x2: "17", y2: "15" }),
|
|
1228
|
+
/* @__PURE__ */ l("line", { x1: "17", y1: "9", x2: "23", y2: "15" })
|
|
1229
|
+
] }))
|
|
1230
|
+
}
|
|
1231
|
+
),
|
|
1232
|
+
vt({ registry: t.pluginRegistry, placement: "end" })
|
|
1233
|
+
] })
|
|
1234
|
+
] });
|
|
1235
|
+
return Fi(i, e, t.store), i;
|
|
1236
|
+
}
|
|
1237
|
+
function Bi(t) {
|
|
1238
|
+
return /* @__PURE__ */ l("div", { class: "bk-thumbs", style: d(() => t.store.showThumbs.value ? "display:flex;" : "display:none;"), children: t.store.pages.value.map((e, i) => {
|
|
1239
|
+
const s = () => {
|
|
1240
|
+
const a = t.store.currentPage.value;
|
|
1241
|
+
if (t.store.isSingleMode.value || a === 0 || a >= t.store.pages.value.length - 1)
|
|
1242
|
+
return a === i;
|
|
1243
|
+
const r = a % 2 === 1 ? a : a - 1;
|
|
1244
|
+
return i === r || i === r + 1;
|
|
1245
|
+
};
|
|
1246
|
+
return /* @__PURE__ */ l(
|
|
1247
|
+
"div",
|
|
1248
|
+
{
|
|
1249
|
+
class: d(() => `thumb-item ${s() ? "active" : ""}`),
|
|
1250
|
+
role: "button",
|
|
1251
|
+
tabindex: "0",
|
|
1252
|
+
"aria-label": `Go to page ${i + 1}`,
|
|
1253
|
+
"aria-current": d(() => s() ? "page" : void 0),
|
|
1254
|
+
onClick: () => t.onThumbClick(i),
|
|
1255
|
+
onKeyDown: (a) => {
|
|
1256
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), t.onThumbClick(i));
|
|
1257
|
+
},
|
|
1258
|
+
children: /* @__PURE__ */ l("div", { class: "thumb-img-wrapper", children: [
|
|
1259
|
+
/* @__PURE__ */ l(
|
|
1260
|
+
"img",
|
|
1261
|
+
{
|
|
1262
|
+
"data-pdf-page": e.assetId.startsWith("pdf-page-") ? e.sourcePageNumber ?? e.pageNumber : void 0,
|
|
1263
|
+
class: `thumb-img ${e.cropMode !== "full" ? "thumb-img--split thumb-img--" + e.cropMode : ""}`,
|
|
1264
|
+
src: e.thumb || e.low || e.normal,
|
|
1265
|
+
alt: `Page ${i + 1}`,
|
|
1266
|
+
loading: "lazy",
|
|
1267
|
+
onError: (a) => {
|
|
1268
|
+
a.currentTarget.style.display = "none";
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
),
|
|
1272
|
+
/* @__PURE__ */ l("span", { class: "thumb-page-number", children: i + 1 })
|
|
1273
|
+
] })
|
|
1274
|
+
}
|
|
1275
|
+
);
|
|
1276
|
+
}) });
|
|
1277
|
+
}
|
|
1278
|
+
function Ht(t, e, i) {
|
|
1279
|
+
return /* @__PURE__ */ l("ol", { class: "bk-toc-list", children: t.map((s) => {
|
|
1280
|
+
var a;
|
|
1281
|
+
return /* @__PURE__ */ l("li", { class: "bk-toc-item", children: [
|
|
1282
|
+
/* @__PURE__ */ l(
|
|
1283
|
+
"button",
|
|
1284
|
+
{
|
|
1285
|
+
type: "button",
|
|
1286
|
+
class: d(() => e.currentPage.value === s.pageIndex ? "bk-toc-entry active" : "bk-toc-entry"),
|
|
1287
|
+
"aria-current": d(() => e.currentPage.value === s.pageIndex ? "page" : void 0),
|
|
1288
|
+
onClick: () => i(s.pageIndex),
|
|
1289
|
+
children: [
|
|
1290
|
+
/* @__PURE__ */ l("span", { class: "bk-toc-title", children: s.title }),
|
|
1291
|
+
/* @__PURE__ */ l("span", { class: "bk-toc-page", children: s.pageIndex + 1 })
|
|
1292
|
+
]
|
|
1293
|
+
}
|
|
1294
|
+
),
|
|
1295
|
+
(a = s.children) != null && a.length ? Ht(s.children, e, i) : null
|
|
1296
|
+
] });
|
|
1297
|
+
}) });
|
|
1298
|
+
}
|
|
1299
|
+
function Hi(t) {
|
|
1300
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value }));
|
|
1301
|
+
return /* @__PURE__ */ l(
|
|
1302
|
+
"nav",
|
|
1303
|
+
{
|
|
1304
|
+
class: "bk-toc",
|
|
1305
|
+
onKeyDown: (i) => {
|
|
1306
|
+
var s;
|
|
1307
|
+
i.key === "Escape" && ((s = t.onClose) == null || s.call(t));
|
|
1308
|
+
},
|
|
1309
|
+
"aria-label": d(() => e.value.tableOfContents || "Table of Contents"),
|
|
1310
|
+
style: d(() => t.store.showToc.value && t.store.toc.value.length ? "display:flex;" : "display:none;"),
|
|
1311
|
+
children: [
|
|
1312
|
+
/* @__PURE__ */ l("div", { class: "bk-search-heading-row", children: [
|
|
1313
|
+
/* @__PURE__ */ l("div", { class: "bk-toc-heading", children: d(() => e.value.tableOfContents || "Table of Contents") }),
|
|
1314
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-search-close", onClick: t.onClose, "aria-label": d(() => e.value.closeContents), children: "×" })
|
|
1315
|
+
] }),
|
|
1316
|
+
Ht(t.store.toc.value, t.store, t.onEntryClick)
|
|
1317
|
+
]
|
|
1318
|
+
}
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
1321
|
+
function Wt(t) {
|
|
1322
|
+
const e = document.createElement("div");
|
|
1323
|
+
e.className = "bk-note-editor-host";
|
|
1324
|
+
let i, s;
|
|
1325
|
+
t.onReady(!1);
|
|
1326
|
+
const a = () => {
|
|
1327
|
+
var r;
|
|
1328
|
+
s == null || s.disconnect(), i && !t.signal.aborted && ((r = t.onDraft) == null || r.call(t, i.getValue())), i == null || i.destroy(), i = void 0, t.view.current = null;
|
|
1329
|
+
};
|
|
1330
|
+
return t.signal.addEventListener("abort", a, { once: !0 }), queueMicrotask(async () => {
|
|
1331
|
+
var r;
|
|
1332
|
+
if (!(t.signal.aborted || !e.isConnected)) {
|
|
1333
|
+
if (t.factory)
|
|
1334
|
+
try {
|
|
1335
|
+
i = await t.factory(e, t.value, t.signal);
|
|
1336
|
+
} catch {
|
|
1337
|
+
e.textContent = t.label, t.onReady(!1);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
else {
|
|
1341
|
+
const h = document.createElement("textarea");
|
|
1342
|
+
h.className = "bk-notes-input", h.rows = 4, h.maxLength = 4e3, h.setAttribute("aria-label", t.label), h.placeholder = t.label, h.value = t.value.text, e.append(h), i = { getValue: () => ({ text: h.value }), setReadOnly: (c) => h.disabled = c, destroy: () => h.remove() };
|
|
1343
|
+
}
|
|
1344
|
+
if (t.signal.aborted || !e.isConnected) {
|
|
1345
|
+
a();
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
t.view.current = i, t.onReady(!0), s = new e.ownerDocument.defaultView.MutationObserver(() => {
|
|
1349
|
+
e.isConnected || a();
|
|
1350
|
+
}), s.observe(e.ownerDocument.body, { childList: !0, subtree: !0 }), (r = e.querySelector('[contenteditable="true"],textarea')) == null || r.focus();
|
|
1351
|
+
}
|
|
1352
|
+
}), e;
|
|
1353
|
+
}
|
|
1354
|
+
function $t(t, e) {
|
|
1355
|
+
const i = document.createElement("div");
|
|
1356
|
+
if (i.className = "bk-note-document", !t)
|
|
1357
|
+
return i.textContent = e, i;
|
|
1358
|
+
let s = 512;
|
|
1359
|
+
const a = (r, h = 0) => {
|
|
1360
|
+
if (h > 8 || s-- <= 0) return document.createTextNode("");
|
|
1361
|
+
if (r.type === "text") {
|
|
1362
|
+
let g = document.createTextNode(r.text ?? "");
|
|
1363
|
+
for (const v of (r.marks ?? []).slice(0, 3)) {
|
|
1364
|
+
const y = document.createElement(v.type === "bold" ? "strong" : v.type === "italic" ? "em" : "span");
|
|
1365
|
+
if (v.type === "textStyle")
|
|
1366
|
+
for (const [S, m] of Object.entries(v.attrs ?? {}))
|
|
1367
|
+
m && (S === "fontSize" && /^(12|14|16|18|20|24|28|32)px$/.test(m) && (y.style.fontSize = m), (S === "color" || S === "backgroundColor") && /^#[0-9a-f]{6}$/i.test(m) && (y.style[S] = m));
|
|
1368
|
+
y.append(g), g = y;
|
|
1369
|
+
}
|
|
1370
|
+
return g;
|
|
1371
|
+
}
|
|
1372
|
+
const c = document.createElement(r.type === "hardBreak" ? "br" : r.type === "paragraph" ? "p" : "div");
|
|
1373
|
+
for (const g of r.content ?? []) {
|
|
1374
|
+
if (s <= 0) break;
|
|
1375
|
+
c.append(a(g, h + 1));
|
|
1376
|
+
}
|
|
1377
|
+
return c;
|
|
1378
|
+
};
|
|
1379
|
+
return i.append(a(t)), i;
|
|
1380
|
+
}
|
|
1381
|
+
function Wi(t) {
|
|
1382
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value })), i = A({ page: -1, text: "" }), s = A(null), a = { current: null }, r = A(!1), h = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), g = d(() => t.store.pageNotes.value.get(t.store.currentPage.value) ?? ""), v = d(() => i.value.page === t.store.currentPage.value ? i.value.text : g.value), y = d(() => s.value === t.store.currentPage.value || !g.value), S = () => {
|
|
1383
|
+
i.value = { page: t.store.currentPage.value, text: g.value }, s.value = t.store.currentPage.value;
|
|
1384
|
+
}, m = async () => {
|
|
1385
|
+
var E, I, F;
|
|
1386
|
+
const b = t.store.currentPage.value, P = (E = a.current) == null ? void 0 : E.getValue();
|
|
1387
|
+
P && (c.add(b), (I = a.current) == null || I.setReadOnly(!0), await t.onSave(P.text, P.document) && t.store.currentPage.value === b && (h.delete(b), s.value = null), (F = a.current) == null || F.setReadOnly(!1), c.delete(b));
|
|
1388
|
+
}, w = async () => {
|
|
1389
|
+
const b = t.store.currentPage.value;
|
|
1390
|
+
c.add(b), h.delete(b), await t.onClear() && (i.value = { page: b, text: "" }, t.store.currentPage.value === b && (s.value = b)), c.delete(b);
|
|
1391
|
+
};
|
|
1392
|
+
return /* @__PURE__ */ l(
|
|
1393
|
+
"aside",
|
|
1394
|
+
{
|
|
1395
|
+
class: "bk-notes-panel",
|
|
1396
|
+
style: d(() => t.store.showNotes.value ? "display:flex;" : "display:none;"),
|
|
1397
|
+
"aria-label": d(() => e.value.myNotes),
|
|
1398
|
+
onKeyDown: (b) => {
|
|
1399
|
+
b.key === "Escape" && (b.stopPropagation(), t.onClose());
|
|
1400
|
+
},
|
|
1401
|
+
children: [
|
|
1402
|
+
/* @__PURE__ */ l("div", { class: "bk-notes-heading-row", children: [
|
|
1403
|
+
/* @__PURE__ */ l("div", { class: "bk-notes-heading", children: [
|
|
1404
|
+
d(() => e.value.myNotes),
|
|
1405
|
+
" ",
|
|
1406
|
+
/* @__PURE__ */ l("span", { class: "bk-note-total", children: d(() => t.store.pageNotes.value.size + t.store.annotations.value.length) })
|
|
1407
|
+
] }),
|
|
1408
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-notes-close", onClick: t.onClose, "aria-label": d(() => e.value.closeNote), children: "×" })
|
|
1409
|
+
] }),
|
|
1410
|
+
/* @__PURE__ */ l("p", { class: "bk-note-privacy", children: d(() => e.value.privateNotes) }),
|
|
1411
|
+
/* @__PURE__ */ l("div", { class: "bk-note-tabs", role: "group", "aria-label": d(() => e.value.myNotes), children: [
|
|
1412
|
+
/* @__PURE__ */ l("button", { type: "button", "aria-pressed": d(() => t.store.notesView.value === "all" ? "true" : "false"), onClick: () => t.store.notesView.value = "all", children: d(() => e.value.allNotes) }),
|
|
1413
|
+
/* @__PURE__ */ l("button", { type: "button", "aria-pressed": d(() => t.store.notesView.value === "page" ? "true" : "false"), onClick: () => t.store.notesView.value = "page", children: d(() => `${e.value.currentPage} · ${t.store.currentPage.value + 1}`) })
|
|
1414
|
+
] }),
|
|
1415
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-add-annotation", style: d(() => t.store.canAnnotate.value ? "display:block;" : "display:none;"), onClick: t.onAdd, children: d(() => e.value.addNote) }),
|
|
1416
|
+
/* @__PURE__ */ l("div", { class: "bk-note-list", style: d(() => t.store.notesView.value === "all" ? "display:flex;" : "display:none;"), children: d(() => {
|
|
1417
|
+
const b = [...t.store.pageNotes.value].map(([P, E]) => ({ id: `page-${P}`, pageIndex: P, text: E, annotation: void 0 }));
|
|
1418
|
+
return b.push(...t.store.annotations.value.map((P) => ({ ...P, annotation: P }))), b.sort((P, E) => P.pageIndex - E.pageIndex || P.id.localeCompare(E.id)), b.length ? /* @__PURE__ */ l("div", { class: "bk-note-list-items", children: b.map((P) => /* @__PURE__ */ l("button", { type: "button", class: "bk-note-list-item", onClick: () => P.annotation ? t.onAnnotation(P.annotation) : t.onSelect(P.pageIndex), children: [
|
|
1419
|
+
/* @__PURE__ */ l("strong", { children: [
|
|
1420
|
+
e.value.page,
|
|
1421
|
+
" ",
|
|
1422
|
+
P.pageIndex + 1
|
|
1423
|
+
] }),
|
|
1424
|
+
/* @__PURE__ */ l("span", { children: P.text })
|
|
1425
|
+
] })) }) : /* @__PURE__ */ l("p", { class: "bk-note-empty", children: e.value.noNotes });
|
|
1426
|
+
}) }),
|
|
1427
|
+
/* @__PURE__ */ l("div", { class: "bk-current-note", style: d(() => t.store.notesView.value === "page" ? "display:block;" : "display:none;"), children: d(() => !t.store.showNotes.value || t.store.notesView.value !== "page" ? null : g.value && !y.value ? /* @__PURE__ */ l("div", { class: "bk-note-saved", children: [
|
|
1428
|
+
/* @__PURE__ */ l("div", { class: "bk-note-content", children: $t(t.store.pageNoteDocuments.value.get(t.store.currentPage.value), g.value) }),
|
|
1429
|
+
/* @__PURE__ */ l("div", { class: "bk-note-actions", children: [
|
|
1430
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-note-badge bk-note-badge--edit", onClick: S, disabled: t.store.notesSaving, children: d(() => e.value.editNote) }),
|
|
1431
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-note-badge bk-note-badge--delete", onClick: w, disabled: t.store.notesSaving, children: d(() => e.value.deleteNote) })
|
|
1432
|
+
] })
|
|
1433
|
+
] }) : /* @__PURE__ */ l("div", { class: "bk-notes-editor", children: [
|
|
1434
|
+
/* @__PURE__ */ l(Wt, { value: h.get(t.store.currentPage.value) ?? { text: v.value, document: t.store.pageNoteDocuments.value.get(t.store.currentPage.value) }, factory: t.store.noteEditor.value, signal: t.signal, label: e.value.notes, view: a, onReady: (b) => r.value = b, onDraft: /* @__PURE__ */ ((b) => (P) => {
|
|
1435
|
+
c.has(b) || h.set(b, P);
|
|
1436
|
+
})(t.store.currentPage.value) }),
|
|
1437
|
+
/* @__PURE__ */ l("div", { class: "bk-notes-actions", children: [
|
|
1438
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-notes-clear", onClick: w, disabled: t.store.notesSaving, children: d(() => e.value.clearNote) }),
|
|
1439
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-notes-save", onClick: m, disabled: d(() => t.store.notesSaving.value || !r.value), children: d(() => e.value.saveNote) })
|
|
1440
|
+
] })
|
|
1441
|
+
] })) }),
|
|
1442
|
+
/* @__PURE__ */ l("div", { role: "status", "aria-live": "polite", children: d(() => t.store.notesSaving.value ? e.value.saving : t.store.notesFailed.value ? e.value.noteFailed : "") })
|
|
1443
|
+
]
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
function $i(t) {
|
|
1448
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value })), i = d(() => t.store.pendingAnnotation.value ?? t.store.annotations.value.find((g) => g.id === t.store.activeAnnotationId.value)), s = /* @__PURE__ */ new Map(), a = A(null), r = A(null), h = { current: null }, c = A(!1);
|
|
1449
|
+
return /* @__PURE__ */ l(
|
|
1450
|
+
"aside",
|
|
1451
|
+
{
|
|
1452
|
+
class: "bk-note-popover",
|
|
1453
|
+
role: "dialog",
|
|
1454
|
+
"aria-label": d(() => e.value.notes),
|
|
1455
|
+
style: d(() => t.store.canAnnotate.value && i.value ? "display:flex;" : "display:none;"),
|
|
1456
|
+
onKeyDown: (g) => {
|
|
1457
|
+
g.key === "Escape" && (g.stopPropagation(), t.onClose());
|
|
1458
|
+
},
|
|
1459
|
+
children: [
|
|
1460
|
+
d(() => {
|
|
1461
|
+
const g = i.value;
|
|
1462
|
+
if (!g) return null;
|
|
1463
|
+
const v = !!t.store.pendingAnnotation.value || a.value === g.id;
|
|
1464
|
+
return /* @__PURE__ */ l(pe, { children: [
|
|
1465
|
+
/* @__PURE__ */ l("div", { class: "bk-notes-heading-row", children: [
|
|
1466
|
+
/* @__PURE__ */ l("strong", { children: [
|
|
1467
|
+
e.value.notes,
|
|
1468
|
+
" · ",
|
|
1469
|
+
e.value.page,
|
|
1470
|
+
" ",
|
|
1471
|
+
g.pageIndex + 1
|
|
1472
|
+
] }),
|
|
1473
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-notes-close", onClick: t.onClose, "aria-label": e.value.closeNote, children: "×" })
|
|
1474
|
+
] }),
|
|
1475
|
+
v ? /* @__PURE__ */ l(pe, { children: [
|
|
1476
|
+
/* @__PURE__ */ l(Wt, { value: s.get(g.id) ?? { text: g.text, document: g.document }, factory: t.store.noteEditor.value, signal: t.signal, label: e.value.notes, view: h, onReady: (y) => c.value = y, onDraft: (y) => s.set(g.id, y) }),
|
|
1477
|
+
/* @__PURE__ */ l("div", { class: "bk-notes-actions", children: [
|
|
1478
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: t.onClose, children: e.value.cancel }),
|
|
1479
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-notes-save", disabled: d(() => t.store.notesSaving.value || !c.value), onClick: async () => {
|
|
1480
|
+
var S, m, w;
|
|
1481
|
+
const y = (S = h.current) == null ? void 0 : S.getValue();
|
|
1482
|
+
y && (s.set(g.id, y), (m = h.current) == null || m.setReadOnly(!0), await t.onSave({ ...g, ...y }) && (a.value = null, s.delete(g.id)), (w = h.current) == null || w.setReadOnly(!1));
|
|
1483
|
+
}, children: e.value.saveNote })
|
|
1484
|
+
] })
|
|
1485
|
+
] }) : /* @__PURE__ */ l(pe, { children: [
|
|
1486
|
+
$t(g.document, g.text),
|
|
1487
|
+
r.value === g.id ? /* @__PURE__ */ l("div", { class: "bk-notes-actions", children: [
|
|
1488
|
+
/* @__PURE__ */ l("span", { children: e.value.confirmDeleteNote }),
|
|
1489
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: () => r.value = null, children: e.value.cancel }),
|
|
1490
|
+
/* @__PURE__ */ l("button", { type: "button", disabled: t.store.notesSaving, onClick: () => t.onDelete(g), children: e.value.deleteNote })
|
|
1491
|
+
] }) : /* @__PURE__ */ l("div", { class: "bk-notes-actions", children: [
|
|
1492
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: () => a.value = g.id, children: e.value.editNote }),
|
|
1493
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: () => r.value = g.id, children: e.value.deleteNote })
|
|
1494
|
+
] })
|
|
1495
|
+
] })
|
|
1496
|
+
] });
|
|
1497
|
+
}),
|
|
1498
|
+
/* @__PURE__ */ l("div", { role: "status", "aria-live": "polite", children: d(() => t.store.notesSaving.value ? e.value.saving : t.store.notesFailed.value ? e.value.noteFailed : "") })
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
function qi(t) {
|
|
1504
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value }));
|
|
1505
|
+
return /* @__PURE__ */ l("div", { class: "bk-note-placement-hint", style: d(() => t.store.placingNote.value ? "display:flex;" : "display:none;"), role: "status", children: [
|
|
1506
|
+
/* @__PURE__ */ l("span", { children: d(() => e.value.placeNote) }),
|
|
1507
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: (i) => {
|
|
1508
|
+
var s, a;
|
|
1509
|
+
t.store.placingNote.value = !1, (a = (s = i.currentTarget.closest(".bk-wrapper")) == null ? void 0 : s.querySelector(".bk-btn--notes")) == null || a.focus();
|
|
1510
|
+
}, children: [
|
|
1511
|
+
d(() => e.value.cancel),
|
|
1512
|
+
" (Esc)"
|
|
1513
|
+
] })
|
|
1514
|
+
] });
|
|
1515
|
+
}
|
|
1516
|
+
function it(t, e) {
|
|
1517
|
+
var a;
|
|
1518
|
+
const i = ((a = t.ownerDocument.defaultView) == null ? void 0 : a.AbortController) ?? AbortController, s = new i();
|
|
1519
|
+
return e.aborted ? s.abort() : e.addEventListener("abort", () => s.abort(), { once: !0 }), s.signal;
|
|
1520
|
+
}
|
|
1521
|
+
function _i(t, e, i, s) {
|
|
1522
|
+
s = it(t, s), t.setAttribute("aria-keyshortcuts", "ArrowLeft ArrowRight Home End + - 0 n Shift+n / i t f Escape");
|
|
1523
|
+
let a = null, r = !1;
|
|
1524
|
+
const h = G(() => {
|
|
1525
|
+
const c = e.showNotes.value || e.showSearch.value || e.showToc.value || !!e.pendingAnnotation.value || !!e.activeAnnotationId.value;
|
|
1526
|
+
c && !r && (a = t.ownerDocument.activeElement), c ? queueMicrotask(() => {
|
|
1527
|
+
if (s.aborted) return;
|
|
1528
|
+
const g = e.pendingAnnotation.value || e.activeAnnotationId.value ? ".bk-note-popover" : e.showSearch.value ? ".bk-search-panel" : e.showNotes.value ? ".bk-notes-panel" : ".bk-toc", v = t.querySelector(g), y = (v == null ? void 0 : v.querySelector('textarea:not([disabled]),input:not([disabled]),[contenteditable="true"]')) ?? (v == null ? void 0 : v.querySelector("button"));
|
|
1529
|
+
y && (v != null && v.getBoundingClientRect().width) && y.focus();
|
|
1530
|
+
}) : r && queueMicrotask(() => {
|
|
1531
|
+
!s.aborted && (a != null && a.isConnected) && a.focus();
|
|
1532
|
+
}), r = c;
|
|
1533
|
+
});
|
|
1534
|
+
s.addEventListener("abort", h, { once: !0 }), t.addEventListener("keydown", (c) => {
|
|
1535
|
+
var y, S, m, w, b, P;
|
|
1536
|
+
if (c.defaultPrevented || c.ctrlKey || c.metaKey || c.altKey || c.isComposing || c.target.closest("dialog")) return;
|
|
1537
|
+
if (c.key === "Escape") {
|
|
1538
|
+
c.preventDefault(), e.textSelection.value = !1, e.placingNote.value = !1, e.showNotes.value = !1, e.showSearch.value = !1, e.showToc.value = !1, i.onAnnotationClose(), (y = t.querySelector(".bk-btn--notes")) == null || y.focus();
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (c.target.closest('input,textarea,select,[contenteditable="true"],dialog')) return;
|
|
1542
|
+
if (c.key === "?") {
|
|
1543
|
+
c.preventDefault(), Bt(t, e);
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (c.target.closest(".bk-toolbar") && ["ArrowLeft", "ArrowRight", "Home", "End"].includes(c.key)) {
|
|
1547
|
+
const E = [...t.querySelectorAll(".bk-toolbar button,.bk-toolbar summary")].filter((k) => k.getBoundingClientRect().width > 0), I = E.indexOf(c.target), F = c.key === "Home" ? 0 : c.key === "End" ? E.length - 1 : (I + (c.key === "ArrowRight" ? 1 : -1) + E.length) % E.length;
|
|
1548
|
+
(S = E[F]) == null || S.focus(), c.preventDefault();
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
const g = e.showNotes.value || e.showSearch.value || e.showToc.value || !!e.pendingAnnotation.value || !!e.activeAnnotationId.value, v = c.key.toLowerCase();
|
|
1552
|
+
if (!(e.textSelection.value && c.shiftKey && ["arrowleft", "arrowright", "arrowup", "arrowdown", "home", "end"].includes(v))) {
|
|
1553
|
+
if (v === "n") {
|
|
1554
|
+
c.preventDefault(), c.shiftKey || !e.canAnnotate.value ? i.onToggleNotes() : i.onBeginAnnotation();
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
if (!(g || e.placingNote.value)) {
|
|
1558
|
+
switch (v) {
|
|
1559
|
+
case "arrowleft":
|
|
1560
|
+
case "pageup":
|
|
1561
|
+
(m = i.pageFlipAdapterRef.current) == null || m.turnToPrevPage();
|
|
1562
|
+
break;
|
|
1563
|
+
case "arrowright":
|
|
1564
|
+
case "pagedown":
|
|
1565
|
+
(w = i.pageFlipAdapterRef.current) == null || w.turnToNextPage();
|
|
1566
|
+
break;
|
|
1567
|
+
case "home":
|
|
1568
|
+
e.currentPage.value = 0;
|
|
1569
|
+
break;
|
|
1570
|
+
case "end":
|
|
1571
|
+
e.currentPage.value = Math.max(0, e.totalPages.value - 1);
|
|
1572
|
+
break;
|
|
1573
|
+
case "+":
|
|
1574
|
+
case "=":
|
|
1575
|
+
(b = i.interactionManagerRef.current) == null || b.zoomIn();
|
|
1576
|
+
break;
|
|
1577
|
+
case "-":
|
|
1578
|
+
(P = i.interactionManagerRef.current) == null || P.zoomOut();
|
|
1579
|
+
break;
|
|
1580
|
+
case "0":
|
|
1581
|
+
e.zoomState.value = { ...e.zoomState.value, scale: 1, isActive: !1, translateX: 0, translateY: 0 };
|
|
1582
|
+
break;
|
|
1583
|
+
case "/":
|
|
1584
|
+
e.searchAvailable.value && (e.showSearch.value = !0);
|
|
1585
|
+
break;
|
|
1586
|
+
case "i":
|
|
1587
|
+
e.showToc.value = !0;
|
|
1588
|
+
break;
|
|
1589
|
+
case "t":
|
|
1590
|
+
e.showThumbs.value = !e.showThumbs.value;
|
|
1591
|
+
break;
|
|
1592
|
+
case "f":
|
|
1593
|
+
i.onToggleFullscreen();
|
|
1594
|
+
break;
|
|
1595
|
+
default:
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
c.preventDefault();
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}, { signal: s });
|
|
1602
|
+
}
|
|
1603
|
+
function Gi(t, e) {
|
|
1604
|
+
const i = it(t, e), s = () => {
|
|
1605
|
+
const g = t.parentElement;
|
|
1606
|
+
if (g != null && g.clientWidth)
|
|
1607
|
+
for (const v of t.querySelectorAll("[data-text-width]")) {
|
|
1608
|
+
const y = v.scrollWidth;
|
|
1609
|
+
y && (v.style.transform = `scaleX(${Number(v.dataset.textWidth) * g.clientWidth / y})`);
|
|
1610
|
+
}
|
|
1611
|
+
}, a = t.ownerDocument.defaultView, r = a != null && a.ResizeObserver ? new a.ResizeObserver(s) : null;
|
|
1612
|
+
queueMicrotask(() => {
|
|
1613
|
+
!i.aborted && t.isConnected && (r == null || r.observe(t.parentElement), s());
|
|
1614
|
+
});
|
|
1615
|
+
const h = a ? new a.MutationObserver(() => {
|
|
1616
|
+
t.isConnected || c();
|
|
1617
|
+
}) : null, c = () => {
|
|
1618
|
+
r == null || r.disconnect(), h == null || h.disconnect(), i.removeEventListener("abort", c);
|
|
1619
|
+
};
|
|
1620
|
+
h == null || h.observe(t.ownerDocument.documentElement, { childList: !0, subtree: !0 }), i.addEventListener("abort", c, { once: !0 });
|
|
1621
|
+
}
|
|
1622
|
+
function bt(t) {
|
|
1623
|
+
const e = (i) => {
|
|
1624
|
+
t.store.textSelection.value && i.stopPropagation();
|
|
1625
|
+
};
|
|
1626
|
+
return /* @__PURE__ */ l(
|
|
1627
|
+
"div",
|
|
1628
|
+
{
|
|
1629
|
+
class: d(() => "bk-text-layer" + (t.store.textSelection.value ? " is-selectable" : "")),
|
|
1630
|
+
"aria-hidden": d(() => t.store.textSelection.value ? "false" : "true"),
|
|
1631
|
+
onPointerDown: e,
|
|
1632
|
+
onPointerMove: e,
|
|
1633
|
+
onPointerUp: e,
|
|
1634
|
+
onMouseDown: e,
|
|
1635
|
+
onMouseMove: e,
|
|
1636
|
+
onMouseUp: e,
|
|
1637
|
+
onTouchStart: e,
|
|
1638
|
+
onTouchMove: e,
|
|
1639
|
+
onTouchEnd: e,
|
|
1640
|
+
onClick: e,
|
|
1641
|
+
onContextMenu: e,
|
|
1642
|
+
children: d(() => {
|
|
1643
|
+
const i = t.store.textPages.value.get(t.pageIndex);
|
|
1644
|
+
return i != null && i.runs.length ? /* @__PURE__ */ l("div", { ref: (s) => Gi(s, t.signal), children: i.runs.map(
|
|
1645
|
+
(s) => /* @__PURE__ */ l(
|
|
1646
|
+
"span",
|
|
1647
|
+
{
|
|
1648
|
+
dir: s.direction ?? "ltr",
|
|
1649
|
+
"data-text-start": s.start,
|
|
1650
|
+
"data-text-width": s.width,
|
|
1651
|
+
style: `left:${s.x * 100}%;top:${s.y * 100}%;width:max-content;height:${s.height * 100}%;font-size:${s.height * 100}cqh;transform-origin:left top;`,
|
|
1652
|
+
children: s.text
|
|
1653
|
+
}
|
|
1654
|
+
)
|
|
1655
|
+
) }) : null;
|
|
1656
|
+
})
|
|
1657
|
+
}
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
function Ui(t, e) {
|
|
1661
|
+
return t.type === "image" ? /* @__PURE__ */ l("img", { class: "bk-hotspot-media-image", src: t.src, alt: t.alt || "", loading: "lazy" }) : t.type === "video" ? /* @__PURE__ */ l("video", { class: "bk-hotspot-media-video", controls: !0, preload: "metadata", poster: t.poster, "aria-label": t.alt || e, children: /* @__PURE__ */ l("source", { src: t.src }) }) : /* @__PURE__ */ l("audio", { class: "bk-hotspot-media-audio", controls: !0, preload: "metadata", "aria-label": t.alt || e, children: /* @__PURE__ */ l("source", { src: t.src }) });
|
|
1662
|
+
}
|
|
1663
|
+
function O(t) {
|
|
1664
|
+
t.stopPropagation();
|
|
1665
|
+
}
|
|
1666
|
+
function Vi(t) {
|
|
1667
|
+
const e = (i) => Math.max(0, Math.min(1, i)) * 100;
|
|
1668
|
+
return "left:" + e(t.x) + "%;top:" + e(t.y) + "%;width:" + e(t.width) + "%;height:" + e(t.height) + "%;";
|
|
1669
|
+
}
|
|
1670
|
+
function wt(t) {
|
|
1671
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value })), i = d(() => t.store.hotspots.value.filter((r) => r.pageIndex === t.pageIndex)), s = d(() => t.store.annotations.value.filter((r) => r.pageIndex === t.pageIndex)), a = A(0);
|
|
1672
|
+
return /* @__PURE__ */ l("div", { class: "bk-hotspot-layer", children: [
|
|
1673
|
+
i.value.map((r) => /* @__PURE__ */ l("button", { type: "button", class: "bk-hotspot", style: Vi(r), "aria-label": r.label, onClick: () => {
|
|
1674
|
+
a.value = 0, t.onActivate(r);
|
|
1675
|
+
}, children: /* @__PURE__ */ l("span", { class: "bk-hotspot-label", children: r.label }) })),
|
|
1676
|
+
d(() => /* @__PURE__ */ l("div", { class: "bk-annotation-markers", children: s.value.map((r) => /* @__PURE__ */ l("button", { type: "button", "data-annotation-id": r.id, class: d(() => "bk-annotation-marker" + (t.store.activeAnnotationId.value === r.id ? " active" : "")), style: "left:" + Math.max(0, Math.min(1, r.x)) * 100 + "%;top:" + Math.max(0, Math.min(1, r.y)) * 100 + "%;", "aria-label": r.text, onPointerDown: O, onTouchStart: O, onMouseDown: O, onClick: (h) => {
|
|
1677
|
+
h.stopPropagation(), t.onAnnotationActivate(r);
|
|
1678
|
+
}, children: "●" })) })),
|
|
1679
|
+
d(() => {
|
|
1680
|
+
const r = t.store.hotspots.value.find((v) => v.id === t.store.activeHotspotId.value && v.pageIndex === t.pageIndex);
|
|
1681
|
+
if (!r) return null;
|
|
1682
|
+
const h = r.gallery || [], c = h.length ? Math.min(a.value, h.length - 1) : 0, g = h[c];
|
|
1683
|
+
return /* @__PURE__ */ l("div", { class: "bk-hotspot-popup", onPointerDown: O, onPointerMove: O, onPointerUp: O, onPointerCancel: O, onTouchStart: O, onTouchMove: O, onTouchEnd: O, onMouseDown: O, role: "dialog", "aria-label": r.label, children: [
|
|
1684
|
+
/* @__PURE__ */ l("div", { class: "bk-hotspot-popup-heading", children: [
|
|
1685
|
+
/* @__PURE__ */ l("strong", { children: r.label }),
|
|
1686
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-hotspot-popup-close", onClick: t.onClose, "aria-label": d(() => e.value.closeHotspot || "Close popup"), children: "×" })
|
|
1687
|
+
] }),
|
|
1688
|
+
r.content ? /* @__PURE__ */ l("p", { children: r.content }) : null,
|
|
1689
|
+
r.media ? /* @__PURE__ */ l("div", { class: "bk-hotspot-popup-media", children: Ui(r.media, r.label) }) : null,
|
|
1690
|
+
g ? /* @__PURE__ */ l("div", { class: "bk-hotspot-gallery", "aria-label": r.label + " gallery", children: [
|
|
1691
|
+
/* @__PURE__ */ l("div", { class: "bk-hotspot-gallery-thumbs", children: h.map((v, y) => /* @__PURE__ */ l("button", { type: "button", class: d(() => "bk-hotspot-gallery-thumb" + (y === c ? " is-selected" : "")), onClick: () => {
|
|
1692
|
+
a.value = y;
|
|
1693
|
+
}, "aria-label": v.alt || "Gallery image " + (y + 1), "aria-pressed": d(() => y === c ? "true" : "false"), children: /* @__PURE__ */ l("img", { src: v.src, alt: v.alt || "", loading: "lazy" }) })) }),
|
|
1694
|
+
g.href ? /* @__PURE__ */ l("a", { href: g.href, target: g.target || "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ l("img", { class: "bk-hotspot-gallery-selected", src: g.src, alt: g.alt || "" }) }) : /* @__PURE__ */ l("img", { class: "bk-hotspot-gallery-selected", src: g.src, alt: g.alt || "" })
|
|
1695
|
+
] }) : null,
|
|
1696
|
+
r.href ? /* @__PURE__ */ l("a", { class: "bk-hotspot-link", href: r.href, target: r.target || "_blank", rel: "noopener noreferrer", children: r.kind === "commerce" ? r.label : r.href }) : null
|
|
1697
|
+
] });
|
|
1698
|
+
}),
|
|
1699
|
+
d(() => {
|
|
1700
|
+
if (t.store.canAnnotate.value) return null;
|
|
1701
|
+
const r = t.store.annotations.value.find((h) => h.id === t.store.activeAnnotationId.value && h.pageIndex === t.pageIndex);
|
|
1702
|
+
return r ? /* @__PURE__ */ l("div", { class: "bk-annotation-popup", onPointerDown: O, onPointerMove: O, onPointerUp: O, onPointerCancel: O, onTouchStart: O, onTouchMove: O, onTouchEnd: O, onMouseDown: O, role: "dialog", "aria-label": d(() => e.value.annotation || "Page annotation"), children: [
|
|
1703
|
+
/* @__PURE__ */ l("div", { class: "bk-hotspot-popup-heading", children: [
|
|
1704
|
+
/* @__PURE__ */ l("strong", { children: d(() => e.value.annotation || "Page annotation") }),
|
|
1705
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-hotspot-popup-close", onClick: t.onAnnotationClose, "aria-label": "Close", children: "×" })
|
|
1706
|
+
] }),
|
|
1707
|
+
/* @__PURE__ */ l("p", { children: r.text })
|
|
1708
|
+
] }) : null;
|
|
1709
|
+
})
|
|
1710
|
+
] });
|
|
1711
|
+
}
|
|
1712
|
+
const yt = 'button,a,input,textarea,select,[contenteditable="true"],.bk-hotspot-popup', Y = (t) => t.stopPropagation();
|
|
1713
|
+
function xt(t) {
|
|
1714
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value }));
|
|
1715
|
+
return /* @__PURE__ */ l(
|
|
1716
|
+
"button",
|
|
1717
|
+
{
|
|
1718
|
+
type: "button",
|
|
1719
|
+
class: "bk-note-placement-layer",
|
|
1720
|
+
"aria-label": d(() => e.value.placeNote),
|
|
1721
|
+
style: d(() => t.store.placingNote.value ? "display:block;" : "display:none;"),
|
|
1722
|
+
onPointerDown: Y,
|
|
1723
|
+
onPointerMove: Y,
|
|
1724
|
+
onPointerUp: Y,
|
|
1725
|
+
onTouchStart: Y,
|
|
1726
|
+
onTouchMove: Y,
|
|
1727
|
+
onTouchEnd: Y,
|
|
1728
|
+
onMouseDown: Y,
|
|
1729
|
+
onClick: (i) => {
|
|
1730
|
+
i.preventDefault(), i.stopPropagation();
|
|
1731
|
+
const s = i.currentTarget.getBoundingClientRect();
|
|
1732
|
+
t.onPlace(t.pageIndex, i.detail === 0 ? 0.5 : (i.clientX - s.left) / s.width, i.detail === 0 ? 0.5 : (i.clientY - s.top) / s.height);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
function ji(t, e, i, s) {
|
|
1738
|
+
s = it(t, s);
|
|
1739
|
+
let a, r = !1, h = 0, c = 0, g = 0;
|
|
1740
|
+
const v = () => {
|
|
1741
|
+
clearTimeout(a), a = void 0;
|
|
1742
|
+
}, y = (m) => m == null ? void 0 : m.closest(".bz-page-content,.bk-single-page"), S = (m, w, b) => {
|
|
1743
|
+
const P = y(m), E = P == null ? void 0 : P.closest("[data-idx]");
|
|
1744
|
+
if (!P || !E || !e.canAnnotate.value) return;
|
|
1745
|
+
const I = P.getBoundingClientRect();
|
|
1746
|
+
!I.width || !I.height || (e.placingNote.value = !0, i(Number(E.dataset.idx), (w - I.left) / I.width, (b - I.top) / I.height));
|
|
1747
|
+
};
|
|
1748
|
+
t.addEventListener("pointerdown", (m) => {
|
|
1749
|
+
if (v(), !(e.textSelection.value || !e.canAnnotate.value || e.placingNote.value || m.target.closest(yt))) {
|
|
1750
|
+
if (m.button === 2) {
|
|
1751
|
+
m.stopPropagation();
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
m.pointerType === "mouse" || !m.isPrimary || (h = m.clientX, c = m.clientY, r = !1, a = setTimeout(() => {
|
|
1755
|
+
r = !0, g = Date.now() + 1e3, S(m.target, h, c);
|
|
1756
|
+
}, 550));
|
|
1757
|
+
}
|
|
1758
|
+
}, { capture: !0, signal: s }), t.addEventListener("pointermove", (m) => {
|
|
1759
|
+
Math.hypot(m.clientX - h, m.clientY - c) > 10 && v();
|
|
1760
|
+
}, { capture: !0, signal: s }), t.addEventListener("pointerup", (m) => {
|
|
1761
|
+
v(), r && (m.preventDefault(), m.stopImmediatePropagation(), r = !1);
|
|
1762
|
+
}, { capture: !0, signal: s }), t.addEventListener("click", (m) => {
|
|
1763
|
+
Date.now() < g && (m.preventDefault(), m.stopImmediatePropagation());
|
|
1764
|
+
}, { capture: !0, signal: s }), t.addEventListener("touchend", (m) => {
|
|
1765
|
+
Date.now() < g && (m.preventDefault(), m.stopImmediatePropagation());
|
|
1766
|
+
}, { capture: !0, passive: !1, signal: s }), t.addEventListener("pointercancel", () => {
|
|
1767
|
+
v(), r = !1;
|
|
1768
|
+
}, { capture: !0, signal: s }), t.addEventListener("contextmenu", (m) => {
|
|
1769
|
+
e.textSelection.value || !e.canAnnotate.value || m.target.closest(yt) || (m.preventDefault(), m.stopPropagation(), v(), r || S(m.target, m.clientX, m.clientY));
|
|
1770
|
+
}, { capture: !0, signal: s }), s.addEventListener("abort", v, { once: !0 });
|
|
1771
|
+
}
|
|
1772
|
+
function Pt(t) {
|
|
1773
|
+
const e = d(() => t.store.searchResults.value.filter((i) => i.pageIndex === t.pageIndex).flatMap((i) => i.highlights ?? []));
|
|
1774
|
+
return /* @__PURE__ */ l("div", { class: "bk-search-highlight-layer", "aria-hidden": "true", children: d(() => /* @__PURE__ */ l("div", { class: "bk-search-highlight-items", children: e.value.map((i) => /* @__PURE__ */ l("span", { class: "bk-search-text-highlight", style: "left:" + i.x * 100 + "%;top:" + i.y * 100 + "%;width:" + i.width * 100 + "%;height:" + i.height * 100 + "%;" })) })) });
|
|
1775
|
+
}
|
|
1776
|
+
function Xi(t) {
|
|
1777
|
+
return /* @__PURE__ */ l(
|
|
1778
|
+
"div",
|
|
1779
|
+
{
|
|
1780
|
+
role: "region",
|
|
1781
|
+
"aria-label": "Flipbook viewer",
|
|
1782
|
+
class: d(() => {
|
|
1783
|
+
let e = "bk-book-wrapper ";
|
|
1784
|
+
return t.store.isSingleMode.value && (e += "single-mode "), t.store.isDoublePageLayout.value && (e += "double-mode "), t.store.isFrontCover.value && (e += "bk-is-cover "), t.store.isBackCover.value && (e += "bk-is-back-cover "), t.store.zoomState.value.isActive && (e += "zoomed "), e.trim();
|
|
1785
|
+
}),
|
|
1786
|
+
ref: (e) => {
|
|
1787
|
+
t.bookWrapperRef(e), ji(e, t.store, t.onPlaceAnnotation, t.signal);
|
|
1788
|
+
},
|
|
1789
|
+
children: /* @__PURE__ */ l(
|
|
1790
|
+
"div",
|
|
1791
|
+
{
|
|
1792
|
+
class: "bk-book-sizer",
|
|
1793
|
+
ref: t.bookSizerRef,
|
|
1794
|
+
children: [
|
|
1795
|
+
/* @__PURE__ */ l(
|
|
1796
|
+
"div",
|
|
1797
|
+
{
|
|
1798
|
+
ref: t.bookContainerRef,
|
|
1799
|
+
class: d(() => "bk-book " + (t.store.flipState.value !== "read" ? "is-flipping" : "")),
|
|
1800
|
+
style: d(() => `display: ${t.store.isSingleMode.value ? "none" : "block"};`),
|
|
1801
|
+
children: t.store.pages.value.map((e, i) => {
|
|
1802
|
+
const s = i === 0 || i === t.store.pages.value.length - 1;
|
|
1803
|
+
return /* @__PURE__ */ l(
|
|
1804
|
+
"div",
|
|
1805
|
+
{
|
|
1806
|
+
class: d(() => `bz-page ${i === 0 ? "bz-page--cover" : ""} ${i === t.store.pages.value.length - 1 ? "bz-page--back" : ""}`),
|
|
1807
|
+
"data-density": s ? "hard" : "soft",
|
|
1808
|
+
"data-idx": i,
|
|
1809
|
+
children: /* @__PURE__ */ l("div", { class: "bz-page-content", style: "position:relative; width:100%; height:100%; overflow:hidden;", children: [
|
|
1810
|
+
/* @__PURE__ */ l(
|
|
1811
|
+
"img",
|
|
1812
|
+
{
|
|
1813
|
+
"data-pdf-page": e.assetId.startsWith("pdf-page-") ? e.sourcePageNumber ?? e.pageNumber : void 0,
|
|
1814
|
+
src: e.low || e.normal,
|
|
1815
|
+
"data-src": e.normal,
|
|
1816
|
+
class: `page-content ${e.cropMode !== "full" ? "page-content--split page-content--" + e.cropMode : ""}`,
|
|
1817
|
+
alt: `Page ${i + 1}`
|
|
1818
|
+
}
|
|
1819
|
+
),
|
|
1820
|
+
/* @__PURE__ */ l(bt, { store: t.store, pageIndex: i, signal: t.signal }),
|
|
1821
|
+
/* @__PURE__ */ l(Pt, { store: t.store, pageIndex: i }),
|
|
1822
|
+
/* @__PURE__ */ l(wt, { store: t.store, pageIndex: i, onActivate: t.onHotspotActivate, onClose: t.onHotspotClose, onAnnotationActivate: t.onAnnotationActivate, onAnnotationClose: t.onAnnotationClose }),
|
|
1823
|
+
/* @__PURE__ */ l("div", { class: "page-shadow" }),
|
|
1824
|
+
/* @__PURE__ */ l(xt, { store: t.store, pageIndex: i, onPlace: t.onPlaceAnnotation })
|
|
1825
|
+
] })
|
|
1826
|
+
}
|
|
1827
|
+
);
|
|
1828
|
+
})
|
|
1829
|
+
}
|
|
1830
|
+
),
|
|
1831
|
+
/* @__PURE__ */ l(
|
|
1832
|
+
"div",
|
|
1833
|
+
{
|
|
1834
|
+
class: "bk-single-view",
|
|
1835
|
+
style: d(() => `display: ${t.store.isSingleMode.value ? "flex" : "none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),
|
|
1836
|
+
children: d(() => {
|
|
1837
|
+
const e = t.store.pages.value[t.store.currentPage.value];
|
|
1838
|
+
return e ? /* @__PURE__ */ l("div", { class: "bk-single-page", "data-idx": t.store.currentPage.value, children: [
|
|
1839
|
+
/* @__PURE__ */ l(
|
|
1840
|
+
"img",
|
|
1841
|
+
{
|
|
1842
|
+
"data-pdf-page": e.assetId.startsWith("pdf-page-") ? e.sourcePageNumber ?? e.pageNumber : void 0,
|
|
1843
|
+
class: d(() => `bk-single-img page-content ${e.cropMode !== "full" ? "page-content--split page-content--" + e.cropMode : ""}`),
|
|
1844
|
+
src: t.store.zoomState.value.isActive ? e.normal : e.low || e.normal,
|
|
1845
|
+
alt: `Page ${t.store.currentPage.value + 1}`,
|
|
1846
|
+
style: "opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"
|
|
1847
|
+
}
|
|
1848
|
+
),
|
|
1849
|
+
d(() => t.store.isSingleMode.value ? /* @__PURE__ */ l(pe, { children: [
|
|
1850
|
+
/* @__PURE__ */ l(bt, { store: t.store, pageIndex: t.store.currentPage.value, signal: t.signal }),
|
|
1851
|
+
/* @__PURE__ */ l(Pt, { store: t.store, pageIndex: t.store.currentPage.value }),
|
|
1852
|
+
/* @__PURE__ */ l(wt, { store: t.store, pageIndex: t.store.currentPage.value, onActivate: t.onHotspotActivate, onClose: t.onHotspotClose, onAnnotationActivate: t.onAnnotationActivate, onAnnotationClose: t.onAnnotationClose }),
|
|
1853
|
+
/* @__PURE__ */ l(xt, { store: t.store, pageIndex: t.store.currentPage.value, onPlace: t.onPlaceAnnotation })
|
|
1854
|
+
] }) : null)
|
|
1855
|
+
] }) : null;
|
|
1856
|
+
})
|
|
1857
|
+
}
|
|
1858
|
+
)
|
|
1859
|
+
]
|
|
1860
|
+
}
|
|
1861
|
+
)
|
|
1862
|
+
}
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
function Yi(t) {
|
|
1866
|
+
const e = d(() => t.store.showArrows.value && t.store.currentPage.value > 0), i = d(() => !t.store.showArrows.value || t.store.totalPages.value <= 1 ? !1 : t.store.currentPage.value < t.store.totalPages.value - 1);
|
|
1867
|
+
return /* @__PURE__ */ l("div", { class: "bk-nav-arrows", style: d(() => t.store.showArrows.value && !t.store.showToc.value && !t.store.showSearch.value && !t.store.showNotes.value && !t.store.placingNote.value && !t.store.pendingAnnotation.value && !t.store.activeAnnotationId.value ? "display: flex;" : "display: none;"), children: [
|
|
1868
|
+
/* @__PURE__ */ l(
|
|
1869
|
+
"button",
|
|
1870
|
+
{
|
|
1871
|
+
type: "button",
|
|
1872
|
+
class: "bk-nav-arrow bk-nav-prev",
|
|
1873
|
+
style: d(() => e.value ? "visibility: visible;" : "visibility: hidden;"),
|
|
1874
|
+
onClick: (s) => {
|
|
1875
|
+
s.preventDefault(), s.stopPropagation(), t.onPrevPage();
|
|
1876
|
+
},
|
|
1877
|
+
"aria-label": "Previous Page",
|
|
1878
|
+
children: /* @__PURE__ */ l("div", { class: "bk-arrow-icon bk-arrow-left" })
|
|
1879
|
+
}
|
|
1880
|
+
),
|
|
1881
|
+
/* @__PURE__ */ l(
|
|
1882
|
+
"button",
|
|
1883
|
+
{
|
|
1884
|
+
type: "button",
|
|
1885
|
+
class: "bk-nav-arrow bk-nav-next",
|
|
1886
|
+
style: d(() => i.value ? "visibility: visible;" : "visibility: hidden;"),
|
|
1887
|
+
onClick: (s) => {
|
|
1888
|
+
s.preventDefault(), s.stopPropagation(), t.onNextPage();
|
|
1889
|
+
},
|
|
1890
|
+
"aria-label": "Next Page",
|
|
1891
|
+
children: /* @__PURE__ */ l("div", { class: "bk-arrow-icon bk-arrow-right" })
|
|
1892
|
+
}
|
|
1893
|
+
)
|
|
1894
|
+
] });
|
|
1895
|
+
}
|
|
1896
|
+
function Zi(t) {
|
|
1897
|
+
const e = d(() => U({ locale: t.store.locale.value, messages: t.store.messages.value })), i = { current: null }, s = A(""), a = () => {
|
|
1898
|
+
var c;
|
|
1899
|
+
const h = ((c = i.current) == null ? void 0 : c.value) ?? s.value;
|
|
1900
|
+
s.value = h, t.onSearch(h);
|
|
1901
|
+
}, r = () => {
|
|
1902
|
+
i.current && (i.current.value = ""), s.value = "", t.onClear();
|
|
1903
|
+
};
|
|
1904
|
+
return /* @__PURE__ */ l("section", { class: "bk-search-panel", style: d(() => t.store.showSearch.value ? "display:flex;" : "display:none;"), "aria-label": d(() => e.value.search || "Search"), onKeyDown: (h) => {
|
|
1905
|
+
h.key === "Escape" && t.onClose();
|
|
1906
|
+
}, children: [
|
|
1907
|
+
/* @__PURE__ */ l("div", { class: "bk-search-heading-row", children: [
|
|
1908
|
+
/* @__PURE__ */ l("strong", { class: "bk-search-heading", children: d(() => e.value.search || "Search") }),
|
|
1909
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-search-close", onClick: t.onClose, "aria-label": d(() => e.value.closeSearch || "Close search"), children: "×" })
|
|
1910
|
+
] }),
|
|
1911
|
+
/* @__PURE__ */ l("div", { class: "bk-search-form", children: [
|
|
1912
|
+
/* @__PURE__ */ l("input", { ref: (h) => {
|
|
1913
|
+
i.current = h;
|
|
1914
|
+
}, class: "bk-search-input", type: "search", placeholder: d(() => e.value.searchPlaceholder || "Search PDF text"), value: d(() => t.store.searchQuery.value), onInput: (h) => {
|
|
1915
|
+
s.value = h.currentTarget.value;
|
|
1916
|
+
}, onKeyDown: (h) => {
|
|
1917
|
+
h.key === "Enter" && a();
|
|
1918
|
+
} }),
|
|
1919
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-search-submit", onClick: a, children: d(() => e.value.search || "Search") }),
|
|
1920
|
+
/* @__PURE__ */ l("button", { type: "button", class: "bk-search-clear", onClick: r, children: d(() => e.value.clearSearch || "Clear") })
|
|
1921
|
+
] }),
|
|
1922
|
+
/* @__PURE__ */ l("div", { class: "bk-search-results", "aria-live": "polite", children: d(() => {
|
|
1923
|
+
const h = t.store.searchResults.value;
|
|
1924
|
+
return t.store.searchBusy.value ? /* @__PURE__ */ l("div", { role: "status", children: e.value.searching }) : t.store.searchFailed.value ? /* @__PURE__ */ l("div", { role: "alert", children: e.value.searchFailed }) : t.store.searchQuery.value ? h.length ? /* @__PURE__ */ l("div", { class: "bk-search-result-list", children: h.map((c) => /* @__PURE__ */ l("button", { type: "button", class: "bk-search-result", onClick: () => t.onSelect(c.pageIndex), children: [
|
|
1925
|
+
/* @__PURE__ */ l("span", { class: "bk-search-result-page", children: c.pageNumber }),
|
|
1926
|
+
/* @__PURE__ */ l("span", { class: "bk-search-result-text", children: c.snippet }),
|
|
1927
|
+
/* @__PURE__ */ l("span", { class: "bk-search-result-count", children: c.matches })
|
|
1928
|
+
] })) }) : /* @__PURE__ */ l("div", { class: "bk-search-empty", children: e.value.noSearchResults || "No results" }) : null;
|
|
1929
|
+
}) })
|
|
1930
|
+
] });
|
|
1931
|
+
}
|
|
1932
|
+
function Qi(t) {
|
|
1933
|
+
let e;
|
|
1934
|
+
const i = (s) => {
|
|
1935
|
+
e == null || e(), e = void 0, s && (e = t.panel.render(s) || void 0);
|
|
1936
|
+
};
|
|
1937
|
+
return /* @__PURE__ */ l(
|
|
1938
|
+
"section",
|
|
1939
|
+
{
|
|
1940
|
+
class: d(() => `bk-plugin-panel ${t.registry.activePanelId.value === t.panelKey ? "is-open" : ""}`),
|
|
1941
|
+
"aria-hidden": d(() => t.registry.activePanelId.value === t.panelKey ? "false" : "true"),
|
|
1942
|
+
"aria-label": t.panel.title || t.panel.id,
|
|
1943
|
+
children: /* @__PURE__ */ l("div", { class: "bk-plugin-panel-content", ref: i })
|
|
1944
|
+
}
|
|
1945
|
+
);
|
|
1946
|
+
}
|
|
1947
|
+
function Ki(t) {
|
|
1948
|
+
const e = t.registry.getPanels();
|
|
1949
|
+
return /* @__PURE__ */ l("div", { class: "bk-plugin-panels", children: e.map((i) => /* @__PURE__ */ l(Qi, { panel: i, panelKey: i.key, registry: t.registry })) });
|
|
1950
|
+
}
|
|
1951
|
+
function Ji(t) {
|
|
1952
|
+
const e = () => {
|
|
1953
|
+
t.store.showThumbs.value = !t.store.showThumbs.value;
|
|
1954
|
+
}, i = () => {
|
|
1955
|
+
t.store.showSearch.value = !1, t.store.showNotes.value = !1, t.store.showToc.value = !t.store.showToc.value;
|
|
1956
|
+
}, s = () => {
|
|
1957
|
+
t.store.showToc.value = !1, t.store.showSearch.value = !1, t.onToggleNotes();
|
|
1958
|
+
}, a = () => {
|
|
1959
|
+
t.store.isSingleMode.value = !t.store.isSingleMode.value;
|
|
1960
|
+
}, r = () => {
|
|
1961
|
+
t.store.isAutoPlaying.value = !t.store.isAutoPlaying.value;
|
|
1962
|
+
}, h = () => {
|
|
1963
|
+
var w;
|
|
1964
|
+
(w = t.interactionManagerRef.current) == null || w.zoomIn();
|
|
1965
|
+
}, c = () => {
|
|
1966
|
+
var w;
|
|
1967
|
+
(w = t.interactionManagerRef.current) == null || w.zoomOut();
|
|
1968
|
+
}, g = () => t.onToggleFullscreen(), v = (w) => {
|
|
1969
|
+
t.store.currentPage.value = w, t.store.showToc.value = !1;
|
|
1970
|
+
}, y = (w) => {
|
|
1971
|
+
var b;
|
|
1972
|
+
t.store.currentPage.value !== w && (t.store.currentPage.value = w, (b = t.pageFlipAdapterRef.current) == null || b.playSound());
|
|
1973
|
+
}, S = () => {
|
|
1974
|
+
var w;
|
|
1975
|
+
(w = t.pageFlipAdapterRef.current) == null || w.turnToNextPage();
|
|
1976
|
+
}, m = () => {
|
|
1977
|
+
var w;
|
|
1978
|
+
(w = t.pageFlipAdapterRef.current) == null || w.turnToPrevPage();
|
|
1979
|
+
};
|
|
1980
|
+
return /* @__PURE__ */ l(
|
|
1981
|
+
"div",
|
|
1982
|
+
{
|
|
1983
|
+
class: d(() => `bk-wrapper bk-theme-${t.store.themeMode.value} ${t.className || ""}`),
|
|
1984
|
+
tabIndex: 0,
|
|
1985
|
+
ref: (w) => _i(w, t.store, t, t.signal),
|
|
1986
|
+
children: [
|
|
1987
|
+
/* @__PURE__ */ l("div", { class: "bk-main-area", children: [
|
|
1988
|
+
/* @__PURE__ */ l(
|
|
1989
|
+
Xi,
|
|
1990
|
+
{
|
|
1991
|
+
store: t.store,
|
|
1992
|
+
bookWrapperRef: t.bookWrapperRef,
|
|
1993
|
+
bookSizerRef: t.bookSizerRef,
|
|
1994
|
+
bookContainerRef: t.bookContainerRef,
|
|
1995
|
+
onHotspotActivate: t.onHotspotActivate,
|
|
1996
|
+
onHotspotClose: t.onHotspotClose,
|
|
1997
|
+
onAnnotationActivate: t.onAnnotationActivate,
|
|
1998
|
+
onAnnotationClose: t.onAnnotationClose,
|
|
1999
|
+
onPlaceAnnotation: t.onPlaceAnnotation,
|
|
2000
|
+
signal: t.signal
|
|
2001
|
+
}
|
|
2002
|
+
),
|
|
2003
|
+
/* @__PURE__ */ l(
|
|
2004
|
+
Yi,
|
|
2005
|
+
{
|
|
2006
|
+
store: t.store,
|
|
2007
|
+
onPrevPage: m,
|
|
2008
|
+
onNextPage: S
|
|
2009
|
+
}
|
|
2010
|
+
),
|
|
2011
|
+
t.store.whiteLabel.value ? null : /* @__PURE__ */ l("div", { class: "bk-watermark", children: [
|
|
2012
|
+
"Powered by ",
|
|
2013
|
+
/* @__PURE__ */ l("a", { href: "https://flipbookengine.com", target: "_blank", rel: "noopener", style: "text-decoration: underline;", children: "FlipbookEngine" })
|
|
2014
|
+
] }),
|
|
2015
|
+
/* @__PURE__ */ l(Hi, { store: t.store, onEntryClick: v, onClose: () => t.store.showToc.value = !1 }),
|
|
2016
|
+
/* @__PURE__ */ l(Zi, { store: t.store, onSearch: t.onSearch, onClear: t.onClearSearch, onClose: t.onCloseSearch, onSelect: t.onSelectSearchResult }),
|
|
2017
|
+
/* @__PURE__ */ l(Wi, { store: t.store, signal: t.signal, onSelect: t.onSelectNote, onAnnotation: t.onAnnotationActivate, onAdd: t.onBeginAnnotation, onSave: t.onSaveNote, onClear: t.onClearNote, onClose: t.onCloseNotes }),
|
|
2018
|
+
/* @__PURE__ */ l($i, { store: t.store, signal: t.signal, onSave: t.onSaveAnnotation, onDelete: t.onDeleteAnnotation, onClose: t.onAnnotationClose }),
|
|
2019
|
+
/* @__PURE__ */ l(qi, { store: t.store }),
|
|
2020
|
+
t.pluginRegistry ? /* @__PURE__ */ l(Ki, { registry: t.pluginRegistry }) : null
|
|
2021
|
+
] }),
|
|
2022
|
+
/* @__PURE__ */ l(
|
|
2023
|
+
Oi,
|
|
2024
|
+
{
|
|
2025
|
+
store: t.store,
|
|
2026
|
+
onToggleThumbs: e,
|
|
2027
|
+
onToggleToc: i,
|
|
2028
|
+
onToggleSearch: () => {
|
|
2029
|
+
t.store.showToc.value = !1, t.store.showNotes.value = !1, t.store.showSearch.value = !t.store.showSearch.value;
|
|
2030
|
+
},
|
|
2031
|
+
onToggleSingleMode: a,
|
|
2032
|
+
onZoomIn: h,
|
|
2033
|
+
onZoomOut: c,
|
|
2034
|
+
onDownload: t.onDownload,
|
|
2035
|
+
onShare: t.onShare,
|
|
2036
|
+
onToggleBookmark: t.onToggleBookmark,
|
|
2037
|
+
onToggleNotes: s,
|
|
2038
|
+
onNextPage: S,
|
|
2039
|
+
onPrevPage: m,
|
|
2040
|
+
onSoundToggle: () => t.store.soundEnabled.value = !t.store.soundEnabled.value,
|
|
2041
|
+
onToggleAutoPlay: r,
|
|
2042
|
+
onToggleFullscreen: g,
|
|
2043
|
+
pluginRegistry: t.pluginRegistry
|
|
2044
|
+
}
|
|
2045
|
+
),
|
|
2046
|
+
/* @__PURE__ */ l(
|
|
2047
|
+
Bi,
|
|
2048
|
+
{
|
|
2049
|
+
store: t.store,
|
|
2050
|
+
onThumbClick: y
|
|
2051
|
+
}
|
|
2052
|
+
)
|
|
2053
|
+
]
|
|
2054
|
+
}
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
var es = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Ve = { exports: {} };
|
|
2058
|
+
(function(t, e) {
|
|
2059
|
+
(function(i, s) {
|
|
2060
|
+
s(e);
|
|
2061
|
+
})(es, function(i) {
|
|
2062
|
+
class s {
|
|
2063
|
+
constructor(n, o) {
|
|
2064
|
+
this.state = { angle: 0, area: [], position: { x: 0, y: 0 }, hardAngle: 0, hardDrawingAngle: 0 }, this.createdDensity = o, this.nowDrawingDensity = this.createdDensity, this.render = n;
|
|
2065
|
+
}
|
|
2066
|
+
setDensity(n) {
|
|
2067
|
+
this.createdDensity = n, this.nowDrawingDensity = n;
|
|
2068
|
+
}
|
|
2069
|
+
setDrawingDensity(n) {
|
|
2070
|
+
this.nowDrawingDensity = n;
|
|
2071
|
+
}
|
|
2072
|
+
setPosition(n) {
|
|
2073
|
+
this.state.position = n;
|
|
2074
|
+
}
|
|
2075
|
+
setAngle(n) {
|
|
2076
|
+
this.state.angle = n;
|
|
2077
|
+
}
|
|
2078
|
+
setArea(n) {
|
|
2079
|
+
this.state.area = n;
|
|
2080
|
+
}
|
|
2081
|
+
setHardDrawingAngle(n) {
|
|
2082
|
+
this.state.hardDrawingAngle = n;
|
|
2083
|
+
}
|
|
2084
|
+
setHardAngle(n) {
|
|
2085
|
+
this.state.hardAngle = n, this.state.hardDrawingAngle = n;
|
|
2086
|
+
}
|
|
2087
|
+
setOrientation(n) {
|
|
2088
|
+
this.orientation = n;
|
|
2089
|
+
}
|
|
2090
|
+
getDrawingDensity() {
|
|
2091
|
+
return this.nowDrawingDensity;
|
|
2092
|
+
}
|
|
2093
|
+
getDensity() {
|
|
2094
|
+
return this.createdDensity;
|
|
2095
|
+
}
|
|
2096
|
+
getHardAngle() {
|
|
2097
|
+
return this.state.hardAngle;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
class a extends s {
|
|
2101
|
+
constructor(n, o, u) {
|
|
2102
|
+
super(n, u), this.image = null, this.isLoad = !1, this.loadingAngle = 0, this.image = new Image(), this.image.src = o;
|
|
2103
|
+
}
|
|
2104
|
+
draw(n) {
|
|
2105
|
+
const o = this.render.getContext(), u = this.render.convertToGlobal(this.state.position), f = this.render.getRect().pageWidth, p = this.render.getRect().height;
|
|
2106
|
+
o.save(), o.translate(u.x, u.y), o.beginPath();
|
|
2107
|
+
for (let x of this.state.area) x !== null && (x = this.render.convertToGlobal(x), o.lineTo(x.x - u.x, x.y - u.y));
|
|
2108
|
+
o.rotate(this.state.angle), o.clip(), this.isLoad ? o.drawImage(this.image, 0, 0, f, p) : this.drawLoader(o, { x: 0, y: 0 }, f, p), o.restore();
|
|
2109
|
+
}
|
|
2110
|
+
simpleDraw(n) {
|
|
2111
|
+
const o = this.render.getRect(), u = this.render.getContext(), f = o.pageWidth, p = o.height, x = n === 1 ? o.left + o.pageWidth : o.left, T = o.top;
|
|
2112
|
+
this.isLoad ? u.drawImage(this.image, x, T, f, p) : this.drawLoader(u, { x, y: T }, f, p);
|
|
2113
|
+
}
|
|
2114
|
+
drawLoader(n, o, u, f) {
|
|
2115
|
+
n.beginPath(), n.strokeStyle = "rgb(200, 200, 200)", n.fillStyle = "rgb(255, 255, 255)", n.lineWidth = 1, n.rect(o.x + 1, o.y + 1, u - 1, f - 1), n.stroke(), n.fill();
|
|
2116
|
+
const p = { x: o.x + u / 2, y: o.y + f / 2 };
|
|
2117
|
+
n.beginPath(), n.lineWidth = 10, n.arc(p.x, p.y, 20, this.loadingAngle, 3 * Math.PI / 2 + this.loadingAngle), n.stroke(), n.closePath(), this.loadingAngle += 0.07, this.loadingAngle >= 2 * Math.PI && (this.loadingAngle = 0);
|
|
2118
|
+
}
|
|
2119
|
+
load() {
|
|
2120
|
+
this.isLoad || (this.image.onload = () => {
|
|
2121
|
+
this.isLoad = !0;
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
newTemporaryCopy() {
|
|
2125
|
+
return this;
|
|
2126
|
+
}
|
|
2127
|
+
getTemporaryCopy() {
|
|
2128
|
+
return this;
|
|
2129
|
+
}
|
|
2130
|
+
hideTemporaryCopy() {
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
class r {
|
|
2134
|
+
constructor(n, o) {
|
|
2135
|
+
this.pages = [], this.currentPageIndex = 0, this.currentSpreadIndex = 0, this.landscapeSpread = [], this.portraitSpread = [], this.render = o, this.app = n, this.currentPageIndex = 0, this.isShowCover = this.app.getSettings().showCover;
|
|
2136
|
+
}
|
|
2137
|
+
destroy() {
|
|
2138
|
+
this.pages = [];
|
|
2139
|
+
}
|
|
2140
|
+
createSpread() {
|
|
2141
|
+
this.landscapeSpread = [], this.portraitSpread = [];
|
|
2142
|
+
for (let o = 0; o < this.pages.length; o++) this.portraitSpread.push([o]);
|
|
2143
|
+
let n = 0;
|
|
2144
|
+
this.isShowCover && (this.pages[0].setDensity("hard"), this.landscapeSpread.push([n]), n++);
|
|
2145
|
+
for (let o = n; o < this.pages.length; o += 2) o < this.pages.length - 1 ? this.landscapeSpread.push([o, o + 1]) : (this.landscapeSpread.push([o]), this.pages[o].setDensity("hard"));
|
|
2146
|
+
}
|
|
2147
|
+
getSpread() {
|
|
2148
|
+
return this.render.getOrientation() === "landscape" ? this.landscapeSpread : this.portraitSpread;
|
|
2149
|
+
}
|
|
2150
|
+
getSpreadIndexByPage(n) {
|
|
2151
|
+
const o = this.getSpread();
|
|
2152
|
+
for (let u = 0; u < o.length; u++) if (n === o[u][0] || n === o[u][1]) return u;
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2155
|
+
getPageCount() {
|
|
2156
|
+
return this.pages.length;
|
|
2157
|
+
}
|
|
2158
|
+
getPages() {
|
|
2159
|
+
return this.pages;
|
|
2160
|
+
}
|
|
2161
|
+
getPage(n) {
|
|
2162
|
+
if (n >= 0 && n < this.pages.length) return this.pages[n];
|
|
2163
|
+
throw new Error("Invalid page number");
|
|
2164
|
+
}
|
|
2165
|
+
nextBy(n) {
|
|
2166
|
+
const o = this.pages.indexOf(n);
|
|
2167
|
+
return o < this.pages.length - 1 ? this.pages[o + 1] : null;
|
|
2168
|
+
}
|
|
2169
|
+
prevBy(n) {
|
|
2170
|
+
const o = this.pages.indexOf(n);
|
|
2171
|
+
return o > 0 ? this.pages[o - 1] : null;
|
|
2172
|
+
}
|
|
2173
|
+
getFlippingPage(n) {
|
|
2174
|
+
const o = this.currentSpreadIndex;
|
|
2175
|
+
if (this.render.getOrientation() === "portrait") return n === 0 ? this.pages[o].newTemporaryCopy() : this.pages[o - 1];
|
|
2176
|
+
{
|
|
2177
|
+
const u = n === 0 ? this.getSpread()[o + 1] : this.getSpread()[o - 1];
|
|
2178
|
+
return u.length === 1 || n === 0 ? this.pages[u[0]] : this.pages[u[1]];
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
getBottomPage(n) {
|
|
2182
|
+
const o = this.currentSpreadIndex;
|
|
2183
|
+
if (this.render.getOrientation() === "portrait") return n === 0 ? this.pages[o + 1] : this.pages[o - 1];
|
|
2184
|
+
{
|
|
2185
|
+
const u = n === 0 ? this.getSpread()[o + 1] : this.getSpread()[o - 1];
|
|
2186
|
+
return u.length === 1 ? this.pages[u[0]] : n === 0 ? this.pages[u[1]] : this.pages[u[0]];
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
showNext() {
|
|
2190
|
+
this.currentSpreadIndex < this.getSpread().length && (this.currentSpreadIndex++, this.showSpread());
|
|
2191
|
+
}
|
|
2192
|
+
showPrev() {
|
|
2193
|
+
this.currentSpreadIndex > 0 && (this.currentSpreadIndex--, this.showSpread());
|
|
2194
|
+
}
|
|
2195
|
+
getCurrentPageIndex() {
|
|
2196
|
+
return this.currentPageIndex;
|
|
2197
|
+
}
|
|
2198
|
+
show(n = null) {
|
|
2199
|
+
if (n === null && (n = this.currentPageIndex), n < 0 || n >= this.pages.length) return;
|
|
2200
|
+
const o = this.getSpreadIndexByPage(n);
|
|
2201
|
+
o !== null && (this.currentSpreadIndex = o, this.showSpread());
|
|
2202
|
+
}
|
|
2203
|
+
getCurrentSpreadIndex() {
|
|
2204
|
+
return this.currentSpreadIndex;
|
|
2205
|
+
}
|
|
2206
|
+
setCurrentSpreadIndex(n) {
|
|
2207
|
+
if (!(n >= 0 && n < this.getSpread().length)) throw new Error("Invalid page");
|
|
2208
|
+
this.currentSpreadIndex = n;
|
|
2209
|
+
}
|
|
2210
|
+
showSpread() {
|
|
2211
|
+
const n = this.getSpread()[this.currentSpreadIndex];
|
|
2212
|
+
n.length === 2 ? (this.render.setLeftPage(this.pages[n[0]]), this.render.setRightPage(this.pages[n[1]])) : this.render.getOrientation() === "landscape" && n[0] === this.pages.length - 1 ? (this.render.setLeftPage(this.pages[n[0]]), this.render.setRightPage(null)) : (this.render.setLeftPage(null), this.render.setRightPage(this.pages[n[0]])), this.currentPageIndex = n[0], this.app.updatePageIndex(this.currentPageIndex);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
class h extends r {
|
|
2216
|
+
constructor(n, o, u) {
|
|
2217
|
+
super(n, o), this.imagesHref = u;
|
|
2218
|
+
}
|
|
2219
|
+
load() {
|
|
2220
|
+
for (const n of this.imagesHref) {
|
|
2221
|
+
const o = new a(this.render, n, "soft");
|
|
2222
|
+
o.load(), this.pages.push(o);
|
|
2223
|
+
}
|
|
2224
|
+
this.createSpread();
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
class c {
|
|
2228
|
+
static GetDistanceBetweenTwoPoint(n, o) {
|
|
2229
|
+
return n === null || o === null ? 1 / 0 : Math.sqrt(Math.pow(o.x - n.x, 2) + Math.pow(o.y - n.y, 2));
|
|
2230
|
+
}
|
|
2231
|
+
static GetSegmentLength(n) {
|
|
2232
|
+
return c.GetDistanceBetweenTwoPoint(n[0], n[1]);
|
|
2233
|
+
}
|
|
2234
|
+
static GetAngleBetweenTwoLine(n, o) {
|
|
2235
|
+
const u = n[0].y - n[1].y, f = o[0].y - o[1].y, p = n[1].x - n[0].x, x = o[1].x - o[0].x;
|
|
2236
|
+
return Math.acos((u * f + p * x) / (Math.sqrt(u * u + p * p) * Math.sqrt(f * f + x * x)));
|
|
2237
|
+
}
|
|
2238
|
+
static PointInRect(n, o) {
|
|
2239
|
+
return o === null ? null : o.x >= n.left && o.x <= n.width + n.left && o.y >= n.top && o.y <= n.top + n.height ? o : null;
|
|
2240
|
+
}
|
|
2241
|
+
static GetRotatedPoint(n, o, u) {
|
|
2242
|
+
return { x: n.x * Math.cos(u) + n.y * Math.sin(u) + o.x, y: n.y * Math.cos(u) - n.x * Math.sin(u) + o.y };
|
|
2243
|
+
}
|
|
2244
|
+
static LimitPointToCircle(n, o, u) {
|
|
2245
|
+
if (c.GetDistanceBetweenTwoPoint(n, u) <= o) return u;
|
|
2246
|
+
const f = n.x, p = n.y, x = u.x, T = u.y;
|
|
2247
|
+
let M = Math.sqrt(Math.pow(o, 2) * Math.pow(f - x, 2) / (Math.pow(f - x, 2) + Math.pow(p - T, 2))) + f;
|
|
2248
|
+
u.x < 0 && (M *= -1);
|
|
2249
|
+
let L = (M - f) * (p - T) / (f - x) + p;
|
|
2250
|
+
return f - x + p === 0 && (L = o), { x: M, y: L };
|
|
2251
|
+
}
|
|
2252
|
+
static GetIntersectBetweenTwoSegment(n, o, u) {
|
|
2253
|
+
return c.PointInRect(n, c.GetIntersectBeetwenTwoLine(o, u));
|
|
2254
|
+
}
|
|
2255
|
+
static GetIntersectBeetwenTwoLine(n, o) {
|
|
2256
|
+
const u = n[0].y - n[1].y, f = o[0].y - o[1].y, p = n[1].x - n[0].x, x = o[1].x - o[0].x, T = n[0].x * n[1].y - n[1].x * n[0].y, M = o[0].x * o[1].y - o[1].x * o[0].y, L = u * M - f * T, z = p * M - x * T, B = -(T * x - M * p) / (u * x - f * p), W = -(u * M - f * T) / (u * x - f * p);
|
|
2257
|
+
if (isFinite(B) && isFinite(W)) return { x: B, y: W };
|
|
2258
|
+
if (Math.abs(L - z) < 0.1) throw new Error("Segment included");
|
|
2259
|
+
return null;
|
|
2260
|
+
}
|
|
2261
|
+
static GetCordsFromTwoPoint(n, o) {
|
|
2262
|
+
const u = Math.abs(n.x - o.x), f = Math.abs(n.y - o.y), p = Math.max(u, f), x = [n];
|
|
2263
|
+
function T(M, L, z, B, W) {
|
|
2264
|
+
return L > M ? M + W * (z / B) : L < M ? M - W * (z / B) : M;
|
|
2265
|
+
}
|
|
2266
|
+
for (let M = 1; M <= p; M += 1) x.push({ x: T(n.x, o.x, u, p, M), y: T(n.y, o.y, f, p, M) });
|
|
2267
|
+
return x;
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
class g extends s {
|
|
2271
|
+
constructor(n, o, u) {
|
|
2272
|
+
super(n, u), this.copiedElement = null, this.temporaryCopy = null, this.isLoad = !1, this.element = o, this.element.classList.add("stf__item"), this.element.classList.add("--" + u);
|
|
2273
|
+
}
|
|
2274
|
+
newTemporaryCopy() {
|
|
2275
|
+
return this.nowDrawingDensity === "hard" ? this : (this.temporaryCopy === null && (this.copiedElement = this.element.cloneNode(!0), this.element.parentElement.appendChild(this.copiedElement), this.temporaryCopy = new g(this.render, this.copiedElement, this.nowDrawingDensity)), this.getTemporaryCopy());
|
|
2276
|
+
}
|
|
2277
|
+
getTemporaryCopy() {
|
|
2278
|
+
return this.temporaryCopy;
|
|
2279
|
+
}
|
|
2280
|
+
hideTemporaryCopy() {
|
|
2281
|
+
this.temporaryCopy !== null && (this.copiedElement.remove(), this.copiedElement = null, this.temporaryCopy = null);
|
|
2282
|
+
}
|
|
2283
|
+
draw(n) {
|
|
2284
|
+
const o = n || this.nowDrawingDensity, u = this.render.convertToGlobal(this.state.position), f = this.render.getRect().pageWidth, p = this.render.getRect().height;
|
|
2285
|
+
this.element.classList.remove("--simple");
|
|
2286
|
+
const x = `
|
|
2287
|
+
display: block;
|
|
2288
|
+
z-index: ${this.element.style.zIndex};
|
|
2289
|
+
left: 0;
|
|
2290
|
+
top: 0;
|
|
2291
|
+
width: ${f}px;
|
|
2292
|
+
height: ${p}px;
|
|
2293
|
+
`;
|
|
2294
|
+
o === "hard" ? this.drawHard(x) : this.drawSoft(u, x);
|
|
2295
|
+
}
|
|
2296
|
+
drawHard(n = "") {
|
|
2297
|
+
const o = this.render.getRect().left + this.render.getRect().width / 2, u = this.state.hardDrawingAngle, f = n + `
|
|
2298
|
+
backface-visibility: hidden;
|
|
2299
|
+
-webkit-backface-visibility: hidden;
|
|
2300
|
+
clip-path: none;
|
|
2301
|
+
-webkit-clip-path: none;
|
|
2302
|
+
` + (this.orientation === 0 ? `transform-origin: ${this.render.getRect().pageWidth}px 0;
|
|
2303
|
+
transform: translate3d(0, 0, 0) rotateY(${u}deg);` : `transform-origin: 0 0;
|
|
2304
|
+
transform: translate3d(${o}px, 0, 0) rotateY(${u}deg);`);
|
|
2305
|
+
this.element.style.cssText = f;
|
|
2306
|
+
}
|
|
2307
|
+
drawSoft(n, o = "") {
|
|
2308
|
+
let u = "polygon( ";
|
|
2309
|
+
for (const p of this.state.area) if (p !== null) {
|
|
2310
|
+
let x = this.render.getDirection() === 1 ? { x: -p.x + this.state.position.x, y: p.y - this.state.position.y } : { x: p.x - this.state.position.x, y: p.y - this.state.position.y };
|
|
2311
|
+
x = c.GetRotatedPoint(x, { x: 0, y: 0 }, this.state.angle), u += x.x + "px " + x.y + "px, ";
|
|
2312
|
+
}
|
|
2313
|
+
u = u.slice(0, -2), u += ")";
|
|
2314
|
+
const f = o + `transform-origin: 0 0; clip-path: ${u}; -webkit-clip-path: ${u};` + (this.render.isSafari() && this.state.angle === 0 ? `transform: translate(${n.x}px, ${n.y}px);` : `transform: translate3d(${n.x}px, ${n.y}px, 0) rotate(${this.state.angle}rad);`);
|
|
2315
|
+
this.element.style.cssText = f;
|
|
2316
|
+
}
|
|
2317
|
+
simpleDraw(n) {
|
|
2318
|
+
const o = this.render.getRect(), u = o.pageWidth, f = o.height, p = n === 1 ? o.left + o.pageWidth : o.left, x = o.top;
|
|
2319
|
+
this.element.classList.add("--simple"), this.element.style.cssText = `
|
|
2320
|
+
position: absolute;
|
|
2321
|
+
display: block;
|
|
2322
|
+
height: ${f}px;
|
|
2323
|
+
left: ${p}px;
|
|
2324
|
+
top: ${x}px;
|
|
2325
|
+
width: ${u}px;
|
|
2326
|
+
z-index: ${this.render.getSettings().startZIndex + 1};`;
|
|
2327
|
+
}
|
|
2328
|
+
getElement() {
|
|
2329
|
+
return this.element;
|
|
2330
|
+
}
|
|
2331
|
+
load() {
|
|
2332
|
+
this.isLoad = !0;
|
|
2333
|
+
}
|
|
2334
|
+
setOrientation(n) {
|
|
2335
|
+
super.setOrientation(n), this.element.classList.remove("--left", "--right"), this.element.classList.add(n === 1 ? "--right" : "--left");
|
|
2336
|
+
}
|
|
2337
|
+
setDrawingDensity(n) {
|
|
2338
|
+
this.element.classList.remove("--soft", "--hard"), this.element.classList.add("--" + n), super.setDrawingDensity(n);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
class v extends r {
|
|
2342
|
+
constructor(n, o, u, f) {
|
|
2343
|
+
super(n, o), this.element = u, this.pagesElement = f;
|
|
2344
|
+
}
|
|
2345
|
+
load() {
|
|
2346
|
+
for (const n of this.pagesElement) {
|
|
2347
|
+
const o = new g(this.render, n, n.dataset.density === "hard" ? "hard" : "soft");
|
|
2348
|
+
o.load(), this.pages.push(o);
|
|
2349
|
+
}
|
|
2350
|
+
this.createSpread();
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
class y {
|
|
2354
|
+
constructor(n, o, u, f) {
|
|
2355
|
+
this.direction = n, this.corner = o, this.topIntersectPoint = null, this.sideIntersectPoint = null, this.bottomIntersectPoint = null, this.pageWidth = parseInt(u, 10), this.pageHeight = parseInt(f, 10);
|
|
2356
|
+
}
|
|
2357
|
+
calc(n) {
|
|
2358
|
+
try {
|
|
2359
|
+
return this.position = this.calcAngleAndPosition(n), this.calculateIntersectPoint(this.position), !0;
|
|
2360
|
+
} catch {
|
|
2361
|
+
return !1;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
getFlippingClipArea() {
|
|
2365
|
+
const n = [];
|
|
2366
|
+
let o = !1;
|
|
2367
|
+
return n.push(this.rect.topLeft), n.push(this.topIntersectPoint), this.sideIntersectPoint === null ? o = !0 : (n.push(this.sideIntersectPoint), this.bottomIntersectPoint === null && (o = !1)), n.push(this.bottomIntersectPoint), (o || this.corner === "bottom") && n.push(this.rect.bottomLeft), n;
|
|
2368
|
+
}
|
|
2369
|
+
getBottomClipArea() {
|
|
2370
|
+
const n = [];
|
|
2371
|
+
return n.push(this.topIntersectPoint), this.corner === "top" ? n.push({ x: this.pageWidth, y: 0 }) : (this.topIntersectPoint !== null && n.push({ x: this.pageWidth, y: 0 }), n.push({ x: this.pageWidth, y: this.pageHeight })), this.sideIntersectPoint !== null ? c.GetDistanceBetweenTwoPoint(this.sideIntersectPoint, this.topIntersectPoint) >= 10 && n.push(this.sideIntersectPoint) : this.corner === "top" && n.push({ x: this.pageWidth, y: this.pageHeight }), n.push(this.bottomIntersectPoint), n.push(this.topIntersectPoint), n;
|
|
2372
|
+
}
|
|
2373
|
+
getAngle() {
|
|
2374
|
+
return this.direction === 0 ? -this.angle : this.angle;
|
|
2375
|
+
}
|
|
2376
|
+
getRect() {
|
|
2377
|
+
return this.rect;
|
|
2378
|
+
}
|
|
2379
|
+
getPosition() {
|
|
2380
|
+
return this.position;
|
|
2381
|
+
}
|
|
2382
|
+
getActiveCorner() {
|
|
2383
|
+
return this.direction === 0 ? this.rect.topLeft : this.rect.topRight;
|
|
2384
|
+
}
|
|
2385
|
+
getDirection() {
|
|
2386
|
+
return this.direction;
|
|
2387
|
+
}
|
|
2388
|
+
getFlippingProgress() {
|
|
2389
|
+
return Math.abs((this.position.x - this.pageWidth) / (2 * this.pageWidth) * 100);
|
|
2390
|
+
}
|
|
2391
|
+
getCorner() {
|
|
2392
|
+
return this.corner;
|
|
2393
|
+
}
|
|
2394
|
+
getBottomPagePosition() {
|
|
2395
|
+
return this.direction === 1 ? { x: this.pageWidth, y: 0 } : { x: 0, y: 0 };
|
|
2396
|
+
}
|
|
2397
|
+
getShadowStartPoint() {
|
|
2398
|
+
return this.corner === "top" ? this.topIntersectPoint : this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.topIntersectPoint;
|
|
2399
|
+
}
|
|
2400
|
+
getShadowAngle() {
|
|
2401
|
+
const n = c.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(), [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]);
|
|
2402
|
+
return this.direction === 0 ? n : Math.PI - n;
|
|
2403
|
+
}
|
|
2404
|
+
calcAngleAndPosition(n) {
|
|
2405
|
+
let o = n;
|
|
2406
|
+
if (this.updateAngleAndGeometry(o), o = this.corner === "top" ? this.checkPositionAtCenterLine(o, { x: 0, y: 0 }, { x: 0, y: this.pageHeight }) : this.checkPositionAtCenterLine(o, { x: 0, y: this.pageHeight }, { x: 0, y: 0 }), Math.abs(o.x - this.pageWidth) < 1 && Math.abs(o.y) < 1) throw new Error("Point is too small");
|
|
2407
|
+
return o;
|
|
2408
|
+
}
|
|
2409
|
+
updateAngleAndGeometry(n) {
|
|
2410
|
+
this.angle = this.calculateAngle(n), this.rect = this.getPageRect(n);
|
|
2411
|
+
}
|
|
2412
|
+
calculateAngle(n) {
|
|
2413
|
+
const o = this.pageWidth - n.x + 1, u = this.corner === "bottom" ? this.pageHeight - n.y : n.y;
|
|
2414
|
+
let f = 2 * Math.acos(o / Math.sqrt(u * u + o * o));
|
|
2415
|
+
u < 0 && (f = -f);
|
|
2416
|
+
const p = Math.PI - f;
|
|
2417
|
+
if (!isFinite(f) || p >= 0 && p < 3e-3) throw new Error("The G point is too small");
|
|
2418
|
+
return this.corner === "bottom" && (f = -f), f;
|
|
2419
|
+
}
|
|
2420
|
+
getPageRect(n) {
|
|
2421
|
+
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 }], n) : this.getRectFromBasePoint([{ x: 0, y: -this.pageHeight }, { x: this.pageWidth, y: -this.pageHeight }, { x: 0, y: 0 }, { x: this.pageWidth, y: 0 }], n);
|
|
2422
|
+
}
|
|
2423
|
+
getRectFromBasePoint(n, o) {
|
|
2424
|
+
return { topLeft: this.getRotatedPoint(n[0], o), topRight: this.getRotatedPoint(n[1], o), bottomLeft: this.getRotatedPoint(n[2], o), bottomRight: this.getRotatedPoint(n[3], o) };
|
|
2425
|
+
}
|
|
2426
|
+
getRotatedPoint(n, o) {
|
|
2427
|
+
return { x: n.x * Math.cos(this.angle) + n.y * Math.sin(this.angle) + o.x, y: n.y * Math.cos(this.angle) - n.x * Math.sin(this.angle) + o.y };
|
|
2428
|
+
}
|
|
2429
|
+
calculateIntersectPoint(n) {
|
|
2430
|
+
const o = { left: -1, top: -1, width: this.pageWidth + 2, height: this.pageHeight + 2 };
|
|
2431
|
+
this.corner === "top" ? (this.topIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [n, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [n, this.rect.bottomLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }])) : (this.topIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [this.rect.topLeft, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [n, this.rect.topLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = c.GetIntersectBetweenTwoSegment(o, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }]));
|
|
2432
|
+
}
|
|
2433
|
+
checkPositionAtCenterLine(n, o, u) {
|
|
2434
|
+
let f = n;
|
|
2435
|
+
const p = c.LimitPointToCircle(o, this.pageWidth, f);
|
|
2436
|
+
f !== p && (f = p, this.updateAngleAndGeometry(f));
|
|
2437
|
+
const x = Math.sqrt(Math.pow(this.pageWidth, 2) + Math.pow(this.pageHeight, 2));
|
|
2438
|
+
let T = this.rect.bottomRight, M = this.rect.topLeft;
|
|
2439
|
+
if (this.corner === "bottom" && (T = this.rect.topRight, M = this.rect.bottomLeft), T.x <= 0) {
|
|
2440
|
+
const L = c.LimitPointToCircle(u, x, M);
|
|
2441
|
+
L !== f && (f = L, this.updateAngleAndGeometry(f));
|
|
2442
|
+
}
|
|
2443
|
+
return f;
|
|
2444
|
+
}
|
|
2445
|
+
getSegmentToShadowLine() {
|
|
2446
|
+
const n = this.getShadowStartPoint();
|
|
2447
|
+
return [n, n !== this.sideIntersectPoint && this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.bottomIntersectPoint];
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
class S {
|
|
2451
|
+
constructor(n, o) {
|
|
2452
|
+
this.flippingPage = null, this.bottomPage = null, this.calc = null, this.state = "read", this.render = n, this.app = o;
|
|
2453
|
+
}
|
|
2454
|
+
fold(n) {
|
|
2455
|
+
this.setState("user_fold"), this.calc === null && this.start(n), this.do(this.render.convertToPage(n));
|
|
2456
|
+
}
|
|
2457
|
+
flip(n) {
|
|
2458
|
+
if (this.app.getSettings().disableFlipByClick && !this.isPointOnCorners(n) || (this.calc !== null && this.render.finishAnimation(), !this.start(n))) return;
|
|
2459
|
+
const o = this.getBoundsRect();
|
|
2460
|
+
this.setState("flipping");
|
|
2461
|
+
const u = o.height / 10, f = this.calc.getCorner() === "bottom" ? o.height - u : u, p = this.calc.getCorner() === "bottom" ? o.height : 0;
|
|
2462
|
+
this.calc.calc({ x: o.pageWidth - u, y: f }), this.animateFlippingTo({ x: o.pageWidth - u, y: f }, { x: -o.pageWidth, y: p }, !0);
|
|
2463
|
+
}
|
|
2464
|
+
start(n) {
|
|
2465
|
+
this.reset();
|
|
2466
|
+
const o = this.render.convertToBook(n), u = this.getBoundsRect(), f = this.getDirectionByPoint(o), p = o.y >= u.height / 2 ? "bottom" : "top";
|
|
2467
|
+
if (!this.checkDirection(f)) return !1;
|
|
2468
|
+
try {
|
|
2469
|
+
if (this.flippingPage = this.app.getPageCollection().getFlippingPage(f), this.bottomPage = this.app.getPageCollection().getBottomPage(f), this.render.getOrientation() === "landscape") if (f === 1) {
|
|
2470
|
+
const x = this.app.getPageCollection().nextBy(this.flippingPage);
|
|
2471
|
+
x !== null && this.flippingPage.getDensity() !== x.getDensity() && (this.flippingPage.setDrawingDensity("hard"), x.setDrawingDensity("hard"));
|
|
2472
|
+
} else {
|
|
2473
|
+
const x = this.app.getPageCollection().prevBy(this.flippingPage);
|
|
2474
|
+
x !== null && this.flippingPage.getDensity() !== x.getDensity() && (this.flippingPage.setDrawingDensity("hard"), x.setDrawingDensity("hard"));
|
|
2475
|
+
}
|
|
2476
|
+
return this.render.setDirection(f), this.calc = new y(f, p, u.pageWidth.toString(10), u.height.toString(10)), !0;
|
|
2477
|
+
} catch {
|
|
2478
|
+
return !1;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
do(n) {
|
|
2482
|
+
if (this.calc !== null && this.calc.calc(n)) {
|
|
2483
|
+
const o = this.calc.getFlippingProgress();
|
|
2484
|
+
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 * o) / 100) : this.flippingPage.setHardAngle(-90 * (200 - 2 * o) / 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(), o, this.calc.getDirection());
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
flipToPage(n, o) {
|
|
2488
|
+
const u = this.app.getPageCollection().getCurrentSpreadIndex(), f = this.app.getPageCollection().getSpreadIndexByPage(n);
|
|
2489
|
+
try {
|
|
2490
|
+
f > u && (this.app.getPageCollection().setCurrentSpreadIndex(f - 1), this.flipNext(o)), f < u && (this.app.getPageCollection().setCurrentSpreadIndex(f + 1), this.flipPrev(o));
|
|
2491
|
+
} catch {
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
flipNext(n) {
|
|
2495
|
+
this.flip({ x: this.render.getRect().left + 2 * this.render.getRect().pageWidth - 10, y: n === "top" ? 1 : this.render.getRect().height - 2 });
|
|
2496
|
+
}
|
|
2497
|
+
flipPrev(n) {
|
|
2498
|
+
this.flip({ x: 10, y: n === "top" ? 1 : this.render.getRect().height - 2 });
|
|
2499
|
+
}
|
|
2500
|
+
stopMove() {
|
|
2501
|
+
if (this.calc === null) return;
|
|
2502
|
+
const n = this.calc.getPosition(), o = this.getBoundsRect(), u = this.calc.getCorner() === "bottom" ? o.height : 0;
|
|
2503
|
+
n.x <= 0 ? this.animateFlippingTo(n, { x: -o.pageWidth, y: u }, !0) : this.animateFlippingTo(n, { x: o.pageWidth, y: u }, !1);
|
|
2504
|
+
}
|
|
2505
|
+
showCorner(n) {
|
|
2506
|
+
if (!this.checkState("read", "fold_corner")) return;
|
|
2507
|
+
const o = this.getBoundsRect(), u = o.pageWidth;
|
|
2508
|
+
if (this.isPointOnCorners(n)) if (this.calc === null) {
|
|
2509
|
+
if (!this.start(n)) return;
|
|
2510
|
+
this.setState("fold_corner"), this.calc.calc({ x: u - 1, y: 1 });
|
|
2511
|
+
const f = 50, p = this.calc.getCorner() === "bottom" ? o.height - 1 : 1, x = this.calc.getCorner() === "bottom" ? o.height - f : f;
|
|
2512
|
+
this.animateFlippingTo({ x: u - 1, y: p }, { x: u - f, y: x }, !1, !1);
|
|
2513
|
+
} else this.do(this.render.convertToPage(n));
|
|
2514
|
+
else this.setState("read"), this.render.finishAnimation(), this.stopMove();
|
|
2515
|
+
}
|
|
2516
|
+
animateFlippingTo(n, o, u, f = !0) {
|
|
2517
|
+
const p = c.GetCordsFromTwoPoint(n, o), x = [];
|
|
2518
|
+
for (const M of p) x.push(() => this.do(M));
|
|
2519
|
+
const T = this.getAnimationDuration(p.length);
|
|
2520
|
+
this.render.startAnimation(x, T, () => {
|
|
2521
|
+
this.calc && (u && (this.calc.getDirection() === 1 ? this.app.turnToPrevPage() : this.app.turnToNextPage()), f && (this.render.setBottomPage(null), this.render.setFlippingPage(null), this.render.clearShadow(), this.setState("read"), this.reset()));
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
getCalculation() {
|
|
2525
|
+
return this.calc;
|
|
2526
|
+
}
|
|
2527
|
+
getState() {
|
|
2528
|
+
return this.state;
|
|
2529
|
+
}
|
|
2530
|
+
setState(n) {
|
|
2531
|
+
this.state !== n && (this.app.updateState(n), this.state = n);
|
|
2532
|
+
}
|
|
2533
|
+
getDirectionByPoint(n) {
|
|
2534
|
+
const o = this.getBoundsRect();
|
|
2535
|
+
if (this.render.getOrientation() === "portrait") {
|
|
2536
|
+
if (n.x - o.pageWidth <= o.width / 5) return 1;
|
|
2537
|
+
} else if (n.x < o.width / 2) return 1;
|
|
2538
|
+
return 0;
|
|
2539
|
+
}
|
|
2540
|
+
getAnimationDuration(n) {
|
|
2541
|
+
const o = this.app.getSettings().flippingTime;
|
|
2542
|
+
return n >= 1e3 ? o : n / 1e3 * o;
|
|
2543
|
+
}
|
|
2544
|
+
checkDirection(n) {
|
|
2545
|
+
return n === 0 ? this.app.getCurrentPageIndex() < this.app.getPageCount() - 1 : this.app.getCurrentPageIndex() >= 1;
|
|
2546
|
+
}
|
|
2547
|
+
reset() {
|
|
2548
|
+
this.calc = null, this.flippingPage = null, this.bottomPage = null;
|
|
2549
|
+
}
|
|
2550
|
+
getBoundsRect() {
|
|
2551
|
+
return this.render.getRect();
|
|
2552
|
+
}
|
|
2553
|
+
checkState(...n) {
|
|
2554
|
+
for (const o of n) if (this.state === o) return !0;
|
|
2555
|
+
return !1;
|
|
2556
|
+
}
|
|
2557
|
+
isPointOnCorners(n) {
|
|
2558
|
+
const o = this.getBoundsRect(), u = o.pageWidth, f = Math.sqrt(Math.pow(u, 2) + Math.pow(o.height, 2)) / 5, p = this.render.convertToBook(n);
|
|
2559
|
+
return p.x > 0 && p.y > 0 && p.x < o.width && p.y < o.height && (p.x < f || p.x > o.width - f) && (p.y < f || p.y > o.height - f);
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
class m {
|
|
2563
|
+
constructor(n, o) {
|
|
2564
|
+
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 = o, this.app = n;
|
|
2565
|
+
const u = new RegExp("Version\\/[\\d\\.]+.*Safari/");
|
|
2566
|
+
this.safari = u.exec(window.navigator.userAgent) !== null;
|
|
2567
|
+
}
|
|
2568
|
+
render(n) {
|
|
2569
|
+
if (this.animation !== null) {
|
|
2570
|
+
const o = Math.round((n - this.animation.startedAt) / this.animation.durationFrame);
|
|
2571
|
+
o < this.animation.frames.length ? this.animation.frames[o]() : (this.animation.onAnimateEnd(), this.animation = null);
|
|
2572
|
+
}
|
|
2573
|
+
this.timer = n, this.drawFrame();
|
|
2574
|
+
}
|
|
2575
|
+
start() {
|
|
2576
|
+
this.update();
|
|
2577
|
+
const n = (o) => {
|
|
2578
|
+
this.render(o), requestAnimationFrame(n);
|
|
2579
|
+
};
|
|
2580
|
+
requestAnimationFrame(n);
|
|
2581
|
+
}
|
|
2582
|
+
startAnimation(n, o, u) {
|
|
2583
|
+
this.finishAnimation(), this.animation = { frames: n, duration: o, durationFrame: o / n.length, onAnimateEnd: u, startedAt: this.timer };
|
|
2584
|
+
}
|
|
2585
|
+
finishAnimation() {
|
|
2586
|
+
this.animation !== null && (this.animation.frames[this.animation.frames.length - 1](), this.animation.onAnimateEnd !== null && this.animation.onAnimateEnd()), this.animation = null;
|
|
2587
|
+
}
|
|
2588
|
+
update() {
|
|
2589
|
+
this.boundsRect = null;
|
|
2590
|
+
const n = this.calculateBoundsRect();
|
|
2591
|
+
this.orientation !== n && (this.orientation = n, this.app.updateOrientation(n));
|
|
2592
|
+
}
|
|
2593
|
+
calculateBoundsRect() {
|
|
2594
|
+
let n = "landscape";
|
|
2595
|
+
const o = this.getBlockWidth(), u = o / 2, f = this.getBlockHeight() / 2, p = this.setting.width / this.setting.height;
|
|
2596
|
+
let x = this.setting.width, T = this.setting.height, M = u - x;
|
|
2597
|
+
return this.setting.size === "stretch" ? (o < 2 * this.setting.minWidth && this.app.getSettings().usePortrait && (n = "portrait"), x = n === "portrait" ? this.getBlockWidth() : this.getBlockWidth() / 2, x > this.setting.maxWidth && (x = this.setting.maxWidth), T = x / p, T > this.getBlockHeight() && (T = this.getBlockHeight(), x = T * p), M = n === "portrait" ? u - x / 2 - x : u - x) : o < 2 * x && this.app.getSettings().usePortrait && (n = "portrait", M = u - x / 2 - x), this.boundsRect = { left: M, top: f - T / 2, width: 2 * x, height: T, pageWidth: x }, n;
|
|
2598
|
+
}
|
|
2599
|
+
setShadowData(n, o, u, f) {
|
|
2600
|
+
if (!this.app.getSettings().drawShadow) return;
|
|
2601
|
+
const p = 100 * this.getSettings().maxShadowOpacity;
|
|
2602
|
+
this.shadow = { pos: n, angle: o, width: 3 * this.getRect().pageWidth / 4 * u / 100, opacity: (100 - u) * p / 100 / 100, direction: f, progress: 2 * u };
|
|
2603
|
+
}
|
|
2604
|
+
clearShadow() {
|
|
2605
|
+
this.shadow = null;
|
|
2606
|
+
}
|
|
2607
|
+
getBlockWidth() {
|
|
2608
|
+
return this.app.getUI().getDistElement().offsetWidth;
|
|
2609
|
+
}
|
|
2610
|
+
getBlockHeight() {
|
|
2611
|
+
return this.app.getUI().getDistElement().offsetHeight;
|
|
2612
|
+
}
|
|
2613
|
+
getDirection() {
|
|
2614
|
+
return this.direction;
|
|
2615
|
+
}
|
|
2616
|
+
getRect() {
|
|
2617
|
+
return this.boundsRect === null && this.calculateBoundsRect(), this.boundsRect;
|
|
2618
|
+
}
|
|
2619
|
+
getSettings() {
|
|
2620
|
+
return this.app.getSettings();
|
|
2621
|
+
}
|
|
2622
|
+
getOrientation() {
|
|
2623
|
+
return this.orientation;
|
|
2624
|
+
}
|
|
2625
|
+
setPageRect(n) {
|
|
2626
|
+
this.pageRect = n;
|
|
2627
|
+
}
|
|
2628
|
+
setDirection(n) {
|
|
2629
|
+
this.direction = n;
|
|
2630
|
+
}
|
|
2631
|
+
setRightPage(n) {
|
|
2632
|
+
n !== null && n.setOrientation(1), this.rightPage = n;
|
|
2633
|
+
}
|
|
2634
|
+
setLeftPage(n) {
|
|
2635
|
+
n !== null && n.setOrientation(0), this.leftPage = n;
|
|
2636
|
+
}
|
|
2637
|
+
setBottomPage(n) {
|
|
2638
|
+
n !== null && n.setOrientation(this.direction === 1 ? 0 : 1), this.bottomPage = n;
|
|
2639
|
+
}
|
|
2640
|
+
setFlippingPage(n) {
|
|
2641
|
+
n !== null && n.setOrientation(this.direction === 0 && this.orientation !== "portrait" ? 0 : 1), this.flippingPage = n;
|
|
2642
|
+
}
|
|
2643
|
+
convertToBook(n) {
|
|
2644
|
+
const o = this.getRect();
|
|
2645
|
+
return { x: n.x - o.left, y: n.y - o.top };
|
|
2646
|
+
}
|
|
2647
|
+
isSafari() {
|
|
2648
|
+
return this.safari;
|
|
2649
|
+
}
|
|
2650
|
+
convertToPage(n, o) {
|
|
2651
|
+
o || (o = this.direction);
|
|
2652
|
+
const u = this.getRect();
|
|
2653
|
+
return { x: o === 0 ? n.x - u.left - u.width / 2 : u.width / 2 - n.x + u.left, y: n.y - u.top };
|
|
2654
|
+
}
|
|
2655
|
+
convertToGlobal(n, o) {
|
|
2656
|
+
if (o || (o = this.direction), n == null) return null;
|
|
2657
|
+
const u = this.getRect();
|
|
2658
|
+
return { x: o === 0 ? n.x + u.left + u.width / 2 : u.width / 2 - n.x + u.left, y: n.y + u.top };
|
|
2659
|
+
}
|
|
2660
|
+
convertRectToGlobal(n, o) {
|
|
2661
|
+
return o || (o = this.direction), { topLeft: this.convertToGlobal(n.topLeft, o), topRight: this.convertToGlobal(n.topRight, o), bottomLeft: this.convertToGlobal(n.bottomLeft, o), bottomRight: this.convertToGlobal(n.bottomRight, o) };
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
class w extends m {
|
|
2665
|
+
constructor(n, o, u) {
|
|
2666
|
+
super(n, o), this.canvas = u, this.ctx = u.getContext("2d");
|
|
2667
|
+
}
|
|
2668
|
+
getContext() {
|
|
2669
|
+
return this.ctx;
|
|
2670
|
+
}
|
|
2671
|
+
reload() {
|
|
2672
|
+
}
|
|
2673
|
+
drawFrame() {
|
|
2674
|
+
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());
|
|
2675
|
+
const n = this.getRect();
|
|
2676
|
+
this.orientation === "portrait" && (this.ctx.beginPath(), this.ctx.rect(n.left + n.pageWidth, n.top, n.width, n.height), this.ctx.clip());
|
|
2677
|
+
}
|
|
2678
|
+
drawBookShadow() {
|
|
2679
|
+
const n = this.getRect();
|
|
2680
|
+
this.ctx.save(), this.ctx.beginPath();
|
|
2681
|
+
const o = n.width / 20;
|
|
2682
|
+
this.ctx.rect(n.left, n.top, n.width, n.height);
|
|
2683
|
+
const u = { x: n.left + n.width / 2 - o / 2, y: 0 };
|
|
2684
|
+
this.ctx.translate(u.x, u.y);
|
|
2685
|
+
const f = this.ctx.createLinearGradient(0, 0, o, 0);
|
|
2686
|
+
f.addColorStop(0, "rgba(0, 0, 0, 0)"), f.addColorStop(0.4, "rgba(0, 0, 0, 0.2)"), f.addColorStop(0.49, "rgba(0, 0, 0, 0.1)"), f.addColorStop(0.5, "rgba(0, 0, 0, 0.5)"), f.addColorStop(0.51, "rgba(0, 0, 0, 0.4)"), f.addColorStop(1, "rgba(0, 0, 0, 0)"), this.ctx.clip(), this.ctx.fillStyle = f, this.ctx.fillRect(0, 0, o, 2 * n.height), this.ctx.restore();
|
|
2687
|
+
}
|
|
2688
|
+
drawOuterShadow() {
|
|
2689
|
+
const n = this.getRect();
|
|
2690
|
+
this.ctx.save(), this.ctx.beginPath(), this.ctx.rect(n.left, n.top, n.width, n.height);
|
|
2691
|
+
const o = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y });
|
|
2692
|
+
this.ctx.translate(o.x, o.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
|
|
2693
|
+
const u = this.ctx.createLinearGradient(0, 0, this.shadow.width, 0);
|
|
2694
|
+
this.shadow.direction === 0 ? (this.ctx.translate(0, -100), u.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), u.addColorStop(1, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(-this.shadow.width, -100), u.addColorStop(0, "rgba(0, 0, 0, 0)"), u.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")")), this.ctx.clip(), this.ctx.fillStyle = u, this.ctx.fillRect(0, 0, this.shadow.width, 2 * n.height), this.ctx.restore();
|
|
2695
|
+
}
|
|
2696
|
+
drawInnerShadow() {
|
|
2697
|
+
const n = this.getRect();
|
|
2698
|
+
this.ctx.save(), this.ctx.beginPath();
|
|
2699
|
+
const o = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), u = this.convertRectToGlobal(this.pageRect);
|
|
2700
|
+
this.ctx.moveTo(u.topLeft.x, u.topLeft.y), this.ctx.lineTo(u.topRight.x, u.topRight.y), this.ctx.lineTo(u.bottomRight.x, u.bottomRight.y), this.ctx.lineTo(u.bottomLeft.x, u.bottomLeft.y), this.ctx.translate(o.x, o.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
|
|
2701
|
+
const f = 3 * this.shadow.width / 4, p = this.ctx.createLinearGradient(0, 0, f, 0);
|
|
2702
|
+
this.shadow.direction === 0 ? (this.ctx.translate(-f, -100), p.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), p.addColorStop(0.9, "rgba(0, 0, 0, 0.05)"), p.addColorStop(0.7, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), p.addColorStop(0, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(0, -100), p.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), p.addColorStop(0.1, "rgba(0, 0, 0, 0.05)"), p.addColorStop(0.3, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), p.addColorStop(1, "rgba(0, 0, 0, 0)")), this.ctx.clip(), this.ctx.fillStyle = p, this.ctx.fillRect(0, 0, f, 2 * n.height), this.ctx.restore();
|
|
2703
|
+
}
|
|
2704
|
+
clear() {
|
|
2705
|
+
this.ctx.fillStyle = "white", this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
class b {
|
|
2709
|
+
constructor(n, o, u) {
|
|
2710
|
+
this.touchPoint = null, this.swipeTimeout = 250, this.onResize = () => {
|
|
2711
|
+
this.update();
|
|
2712
|
+
}, this.onMouseDown = (p) => {
|
|
2713
|
+
if (this.checkTarget(p.target)) {
|
|
2714
|
+
const x = this.getMousePos(p.clientX, p.clientY);
|
|
2715
|
+
this.app.startUserTouch(x), p.preventDefault();
|
|
2716
|
+
}
|
|
2717
|
+
}, this.onTouchStart = (p) => {
|
|
2718
|
+
if (this.checkTarget(p.target) && p.changedTouches.length > 0) {
|
|
2719
|
+
const x = p.changedTouches[0], T = this.getMousePos(x.clientX, x.clientY);
|
|
2720
|
+
this.touchPoint = { point: T, time: Date.now() }, setTimeout(() => {
|
|
2721
|
+
this.touchPoint !== null && this.app.startUserTouch(T);
|
|
2722
|
+
}, this.swipeTimeout), this.app.getSettings().mobileScrollSupport || p.preventDefault();
|
|
2723
|
+
}
|
|
2724
|
+
}, this.onMouseUp = (p) => {
|
|
2725
|
+
const x = this.getMousePos(p.clientX, p.clientY);
|
|
2726
|
+
this.app.userStop(x);
|
|
2727
|
+
}, this.onMouseMove = (p) => {
|
|
2728
|
+
const x = this.getMousePos(p.clientX, p.clientY);
|
|
2729
|
+
this.app.userMove(x, !1);
|
|
2730
|
+
}, this.onTouchMove = (p) => {
|
|
2731
|
+
if (p.changedTouches.length > 0) {
|
|
2732
|
+
const x = p.changedTouches[0], T = this.getMousePos(x.clientX, x.clientY);
|
|
2733
|
+
this.app.getSettings().mobileScrollSupport ? (this.touchPoint !== null && (Math.abs(this.touchPoint.point.x - T.x) > 10 || this.app.getState() !== "read") && p.cancelable && this.app.userMove(T, !0), this.app.getState() !== "read" && p.preventDefault()) : this.app.userMove(T, !0);
|
|
2734
|
+
}
|
|
2735
|
+
}, this.onTouchEnd = (p) => {
|
|
2736
|
+
if (p.changedTouches.length > 0) {
|
|
2737
|
+
const x = p.changedTouches[0], T = this.getMousePos(x.clientX, x.clientY);
|
|
2738
|
+
let M = !1;
|
|
2739
|
+
if (this.touchPoint !== null) {
|
|
2740
|
+
const L = T.x - this.touchPoint.point.x, z = Math.abs(T.y - this.touchPoint.point.y);
|
|
2741
|
+
Math.abs(L) > this.swipeDistance && z < 2 * this.swipeDistance && Date.now() - this.touchPoint.time < this.swipeTimeout && (L > 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"), M = !0), this.touchPoint = null;
|
|
2742
|
+
}
|
|
2743
|
+
this.app.userStop(T, M);
|
|
2744
|
+
}
|
|
2745
|
+
}, this.parentElement = n, n.classList.add("stf__parent"), n.insertAdjacentHTML("afterbegin", '<div class="stf__wrapper"></div>'), this.wrapper = n.querySelector(".stf__wrapper"), this.app = o;
|
|
2746
|
+
const f = this.app.getSettings().usePortrait ? 1 : 2;
|
|
2747
|
+
n.style.minWidth = u.minWidth * f + "px", n.style.minHeight = u.minHeight + "px", u.size === "fixed" && (n.style.minWidth = u.width * f + "px", n.style.minHeight = u.height + "px"), u.autoSize && (n.style.width = "100%", n.style.maxWidth = 2 * u.maxWidth + "px"), n.style.display = "block", window.addEventListener("resize", this.onResize, !1), this.swipeDistance = u.swipeDistance;
|
|
2748
|
+
}
|
|
2749
|
+
destroy() {
|
|
2750
|
+
this.app.getSettings().useMouseEvents && this.removeHandlers(), this.distElement.remove(), this.wrapper.remove();
|
|
2751
|
+
}
|
|
2752
|
+
getDistElement() {
|
|
2753
|
+
return this.distElement;
|
|
2754
|
+
}
|
|
2755
|
+
getWrapper() {
|
|
2756
|
+
return this.wrapper;
|
|
2757
|
+
}
|
|
2758
|
+
setOrientationStyle(n) {
|
|
2759
|
+
this.wrapper.classList.remove("--portrait", "--landscape"), n === "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();
|
|
2760
|
+
}
|
|
2761
|
+
removeHandlers() {
|
|
2762
|
+
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);
|
|
2763
|
+
}
|
|
2764
|
+
setHandlers() {
|
|
2765
|
+
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));
|
|
2766
|
+
}
|
|
2767
|
+
getMousePos(n, o) {
|
|
2768
|
+
const u = this.distElement.getBoundingClientRect();
|
|
2769
|
+
return { x: n - u.left, y: o - u.top };
|
|
2770
|
+
}
|
|
2771
|
+
checkTarget(n) {
|
|
2772
|
+
return !this.app.getSettings().clickEventForward || !["a", "button"].includes(n.tagName.toLowerCase());
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
class P extends b {
|
|
2776
|
+
constructor(n, o, u, f) {
|
|
2777
|
+
super(n, o, u), this.wrapper.insertAdjacentHTML("afterbegin", '<div class="stf__block"></div>'), this.distElement = n.querySelector(".stf__block"), this.items = f;
|
|
2778
|
+
for (const p of f) this.distElement.appendChild(p);
|
|
2779
|
+
this.setHandlers();
|
|
2780
|
+
}
|
|
2781
|
+
clear() {
|
|
2782
|
+
for (const n of this.items) this.parentElement.appendChild(n);
|
|
2783
|
+
}
|
|
2784
|
+
updateItems(n) {
|
|
2785
|
+
this.removeHandlers(), this.distElement.innerHTML = "";
|
|
2786
|
+
for (const o of n) this.distElement.appendChild(o);
|
|
2787
|
+
this.items = n, this.setHandlers();
|
|
2788
|
+
}
|
|
2789
|
+
update() {
|
|
2790
|
+
this.app.getRender().update();
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
class E extends b {
|
|
2794
|
+
constructor(n, o, u) {
|
|
2795
|
+
super(n, o, u), this.wrapper.innerHTML = '<canvas class="stf__canvas"></canvas>', this.canvas = n.querySelectorAll("canvas")[0], this.distElement = this.canvas, this.resizeCanvas(), this.setHandlers();
|
|
2796
|
+
}
|
|
2797
|
+
resizeCanvas() {
|
|
2798
|
+
const n = getComputedStyle(this.canvas), o = parseInt(n.getPropertyValue("width"), 10), u = parseInt(n.getPropertyValue("height"), 10);
|
|
2799
|
+
this.canvas.width = o, this.canvas.height = u;
|
|
2800
|
+
}
|
|
2801
|
+
getCanvas() {
|
|
2802
|
+
return this.canvas;
|
|
2803
|
+
}
|
|
2804
|
+
update() {
|
|
2805
|
+
this.resizeCanvas(), this.app.getRender().update();
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
class I extends m {
|
|
2809
|
+
constructor(n, o, u) {
|
|
2810
|
+
super(n, o), this.outerShadow = null, this.innerShadow = null, this.hardShadow = null, this.hardInnerShadow = null, this.element = u, this.createShadows();
|
|
2811
|
+
}
|
|
2812
|
+
createShadows() {
|
|
2813
|
+
this.element.insertAdjacentHTML("beforeend", `<div class="stf__outerShadow"></div>
|
|
2814
|
+
<div class="stf__innerShadow"></div>
|
|
2815
|
+
<div class="stf__hardShadow"></div>
|
|
2816
|
+
<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");
|
|
2817
|
+
}
|
|
2818
|
+
clearShadow() {
|
|
2819
|
+
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";
|
|
2820
|
+
}
|
|
2821
|
+
reload() {
|
|
2822
|
+
this.element.querySelector(".stf__outerShadow") || this.createShadows();
|
|
2823
|
+
}
|
|
2824
|
+
drawHardInnerShadow() {
|
|
2825
|
+
const n = this.getRect(), o = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
|
|
2826
|
+
let u = (100 - o) * (2.5 * n.pageWidth) / 100 + 20;
|
|
2827
|
+
u > n.pageWidth && (u = n.pageWidth);
|
|
2828
|
+
let f = `
|
|
2829
|
+
display: block;
|
|
2830
|
+
z-index: ${(this.getSettings().startZIndex + 5).toString(10)};
|
|
2831
|
+
width: ${u}px;
|
|
2832
|
+
height: ${n.height}px;
|
|
2833
|
+
background: linear-gradient(to right,
|
|
2834
|
+
rgba(0, 0, 0, ${this.shadow.opacity * o / 100}) 5%,
|
|
2835
|
+
rgba(0, 0, 0, 0) 100%);
|
|
2836
|
+
left: ${n.left + n.width / 2}px;
|
|
2837
|
+
transform-origin: 0 0;
|
|
2838
|
+
`;
|
|
2839
|
+
f += 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 = f;
|
|
2840
|
+
}
|
|
2841
|
+
drawHardOuterShadow() {
|
|
2842
|
+
const n = this.getRect();
|
|
2843
|
+
let o = (100 - (this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress)) * (2.5 * n.pageWidth) / 100 + 20;
|
|
2844
|
+
o > n.pageWidth && (o = n.pageWidth);
|
|
2845
|
+
let u = `
|
|
2846
|
+
display: block;
|
|
2847
|
+
z-index: ${(this.getSettings().startZIndex + 4).toString(10)};
|
|
2848
|
+
width: ${o}px;
|
|
2849
|
+
height: ${n.height}px;
|
|
2850
|
+
background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
|
|
2851
|
+
left: ${n.left + n.width / 2}px;
|
|
2852
|
+
transform-origin: 0 0;
|
|
2853
|
+
`;
|
|
2854
|
+
u += 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 = u;
|
|
2855
|
+
}
|
|
2856
|
+
drawInnerShadow() {
|
|
2857
|
+
const n = this.getRect(), o = 3 * this.shadow.width / 4, u = this.getDirection() === 0 ? o : 0, f = this.getDirection() === 0 ? "to left" : "to right", p = this.convertToGlobal(this.shadow.pos), x = this.shadow.angle + 3 * Math.PI / 2, T = [this.pageRect.topLeft, this.pageRect.topRight, this.pageRect.bottomRight, this.pageRect.bottomLeft];
|
|
2858
|
+
let M = "polygon( ";
|
|
2859
|
+
for (const z of T) {
|
|
2860
|
+
let B = this.getDirection() === 1 ? { x: -z.x + this.shadow.pos.x, y: z.y - this.shadow.pos.y } : { x: z.x - this.shadow.pos.x, y: z.y - this.shadow.pos.y };
|
|
2861
|
+
B = c.GetRotatedPoint(B, { x: u, y: 100 }, x), M += B.x + "px " + B.y + "px, ";
|
|
2862
|
+
}
|
|
2863
|
+
M = M.slice(0, -2), M += ")";
|
|
2864
|
+
const L = `
|
|
2865
|
+
display: block;
|
|
2866
|
+
z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
|
|
2867
|
+
width: ${o}px;
|
|
2868
|
+
height: ${2 * n.height}px;
|
|
2869
|
+
background: linear-gradient(${f},
|
|
2870
|
+
rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
|
|
2871
|
+
rgba(0, 0, 0, 0.05) 15%,
|
|
2872
|
+
rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
|
|
2873
|
+
rgba(0, 0, 0, 0) 100%);
|
|
2874
|
+
transform-origin: ${u}px 100px;
|
|
2875
|
+
transform: translate3d(${p.x - u}px, ${p.y - 100}px, 0) rotate(${x}rad);
|
|
2876
|
+
clip-path: ${M};
|
|
2877
|
+
-webkit-clip-path: ${M};
|
|
2878
|
+
`;
|
|
2879
|
+
this.innerShadow.style.cssText = L;
|
|
2880
|
+
}
|
|
2881
|
+
drawOuterShadow() {
|
|
2882
|
+
const n = this.getRect(), o = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), u = this.shadow.angle + 3 * Math.PI / 2, f = this.getDirection() === 1 ? this.shadow.width : 0, p = this.getDirection() === 0 ? "to right" : "to left", x = [{ x: 0, y: 0 }, { x: n.pageWidth, y: 0 }, { x: n.pageWidth, y: n.height }, { x: 0, y: n.height }];
|
|
2883
|
+
let T = "polygon( ";
|
|
2884
|
+
for (const L of x) if (L !== null) {
|
|
2885
|
+
let z = this.getDirection() === 1 ? { x: -L.x + this.shadow.pos.x, y: L.y - this.shadow.pos.y } : { x: L.x - this.shadow.pos.x, y: L.y - this.shadow.pos.y };
|
|
2886
|
+
z = c.GetRotatedPoint(z, { x: f, y: 100 }, u), T += z.x + "px " + z.y + "px, ";
|
|
2887
|
+
}
|
|
2888
|
+
T = T.slice(0, -2), T += ")";
|
|
2889
|
+
const M = `
|
|
2890
|
+
display: block;
|
|
2891
|
+
z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
|
|
2892
|
+
width: ${this.shadow.width}px;
|
|
2893
|
+
height: ${2 * n.height}px;
|
|
2894
|
+
background: linear-gradient(${p}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
|
|
2895
|
+
transform-origin: ${f}px 100px;
|
|
2896
|
+
transform: translate3d(${o.x - f}px, ${o.y - 100}px, 0) rotate(${u}rad);
|
|
2897
|
+
clip-path: ${T};
|
|
2898
|
+
-webkit-clip-path: ${T};
|
|
2899
|
+
`;
|
|
2900
|
+
this.outerShadow.style.cssText = M;
|
|
2901
|
+
}
|
|
2902
|
+
drawLeftPage() {
|
|
2903
|
+
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));
|
|
2904
|
+
}
|
|
2905
|
+
drawRightPage() {
|
|
2906
|
+
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));
|
|
2907
|
+
}
|
|
2908
|
+
drawBottomPage() {
|
|
2909
|
+
if (this.bottomPage === null) return;
|
|
2910
|
+
const n = this.flippingPage != null ? this.flippingPage.getDrawingDensity() : null;
|
|
2911
|
+
this.orientation === "portrait" && this.direction === 1 || (this.bottomPage.getElement().style.zIndex = (this.getSettings().startZIndex + 3).toString(10), this.bottomPage.draw(n));
|
|
2912
|
+
}
|
|
2913
|
+
drawFrame() {
|
|
2914
|
+
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()));
|
|
2915
|
+
}
|
|
2916
|
+
clear() {
|
|
2917
|
+
for (const n of this.app.getPageCollection().getPages()) n !== this.leftPage && n !== this.rightPage && n !== this.flippingPage && n !== this.bottomPage && (n.getElement().style.cssText = "display: none"), n.getTemporaryCopy() !== this.flippingPage && n.hideTemporaryCopy();
|
|
2918
|
+
}
|
|
2919
|
+
update() {
|
|
2920
|
+
super.update(), this.rightPage !== null && this.rightPage.setOrientation(1), this.leftPage !== null && this.leftPage.setOrientation(0);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
class F {
|
|
2924
|
+
constructor() {
|
|
2925
|
+
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 };
|
|
2926
|
+
}
|
|
2927
|
+
getSettings(n) {
|
|
2928
|
+
const o = this._default;
|
|
2929
|
+
if (Object.assign(o, n), o.size !== "stretch" && o.size !== "fixed") throw new Error('Invalid size type. Available only "fixed" and "stretch" value');
|
|
2930
|
+
if (o.width <= 0 || o.height <= 0) throw new Error("Invalid width or height");
|
|
2931
|
+
if (o.flippingTime <= 0) throw new Error("Invalid flipping time");
|
|
2932
|
+
return o.size === "stretch" ? (o.minWidth <= 0 && (o.minWidth = 100), o.maxWidth < o.minWidth && (o.maxWidth = 2e3), o.minHeight <= 0 && (o.minHeight = 100), o.maxHeight < o.minHeight && (o.maxHeight = 2e3)) : (o.minWidth = o.width, o.maxWidth = o.width, o.minHeight = o.height, o.maxHeight = o.height), o;
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
(function(k, n) {
|
|
2936
|
+
n === void 0 && (n = {});
|
|
2937
|
+
var o = n.insertAt;
|
|
2938
|
+
if (typeof document < "u") {
|
|
2939
|
+
var u = document.head || document.getElementsByTagName("head")[0], f = document.createElement("style");
|
|
2940
|
+
f.type = "text/css", o === "top" && u.firstChild ? u.insertBefore(f, u.firstChild) : u.appendChild(f), f.styleSheet ? f.styleSheet.cssText = k : f.appendChild(document.createTextNode(k));
|
|
2941
|
+
}
|
|
2942
|
+
})(`.stf__parent {
|
|
2943
|
+
position: relative;
|
|
2944
|
+
display: block;
|
|
2945
|
+
box-sizing: border-box;
|
|
2946
|
+
transform: translateZ(0);
|
|
2947
|
+
|
|
2948
|
+
-ms-touch-action: pan-y;
|
|
2949
|
+
touch-action: pan-y;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
.sft__wrapper {
|
|
2953
|
+
position: relative;
|
|
2954
|
+
width: 100%;
|
|
2955
|
+
box-sizing: border-box;
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
.stf__parent canvas {
|
|
2959
|
+
position: absolute;
|
|
2960
|
+
width: 100%;
|
|
2961
|
+
height: 100%;
|
|
2962
|
+
left: 0;
|
|
2963
|
+
top: 0;
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
.stf__block {
|
|
2967
|
+
position: absolute;
|
|
2968
|
+
width: 100%;
|
|
2969
|
+
height: 100%;
|
|
2970
|
+
box-sizing: border-box;
|
|
2971
|
+
perspective: 2000px;
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
.stf__item {
|
|
2975
|
+
display: none;
|
|
2976
|
+
position: absolute;
|
|
2977
|
+
transform-style: preserve-3d;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
.stf__outerShadow {
|
|
2981
|
+
position: absolute;
|
|
2982
|
+
left: 0;
|
|
2983
|
+
top: 0;
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
.stf__innerShadow {
|
|
2987
|
+
position: absolute;
|
|
2988
|
+
left: 0;
|
|
2989
|
+
top: 0;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
.stf__hardShadow {
|
|
2993
|
+
position: absolute;
|
|
2994
|
+
left: 0;
|
|
2995
|
+
top: 0;
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
.stf__hardInnerShadow {
|
|
2999
|
+
position: absolute;
|
|
3000
|
+
left: 0;
|
|
3001
|
+
top: 0;
|
|
3002
|
+
}`), i.PageFlip = class extends class {
|
|
3003
|
+
constructor() {
|
|
3004
|
+
this.events = /* @__PURE__ */ new Map();
|
|
3005
|
+
}
|
|
3006
|
+
on(k, n) {
|
|
3007
|
+
return this.events.has(k) ? this.events.get(k).push(n) : this.events.set(k, [n]), this;
|
|
3008
|
+
}
|
|
3009
|
+
off(k) {
|
|
3010
|
+
this.events.delete(k);
|
|
3011
|
+
}
|
|
3012
|
+
trigger(k, n, o = null) {
|
|
3013
|
+
if (this.events.has(k)) for (const u of this.events.get(k)) u({ data: o, object: n });
|
|
3014
|
+
}
|
|
3015
|
+
} {
|
|
3016
|
+
constructor(k, n) {
|
|
3017
|
+
super(), this.isUserTouch = !1, this.isUserMove = !1, this.setting = null, this.pages = null, this.setting = new F().getSettings(n), this.block = k;
|
|
3018
|
+
}
|
|
3019
|
+
destroy() {
|
|
3020
|
+
this.ui.destroy(), this.block.remove();
|
|
3021
|
+
}
|
|
3022
|
+
update() {
|
|
3023
|
+
this.render.update(), this.pages.show();
|
|
3024
|
+
}
|
|
3025
|
+
loadFromImages(k) {
|
|
3026
|
+
this.ui = new E(this.block, this, this.setting);
|
|
3027
|
+
const n = this.ui.getCanvas();
|
|
3028
|
+
this.render = new w(this, this.setting, n), this.flipController = new S(this.render, this), this.pages = new h(this, this.render, k), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
|
|
3029
|
+
this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
|
|
3030
|
+
}, 1);
|
|
3031
|
+
}
|
|
3032
|
+
loadFromHTML(k) {
|
|
3033
|
+
this.ui = new P(this.block, this, this.setting, k), this.render = new I(this, this.setting, this.ui.getDistElement()), this.flipController = new S(this.render, this), this.pages = new v(this, this.render, this.ui.getDistElement(), k), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
|
|
3034
|
+
this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
|
|
3035
|
+
}, 1);
|
|
3036
|
+
}
|
|
3037
|
+
updateFromImages(k) {
|
|
3038
|
+
const n = this.pages.getCurrentPageIndex();
|
|
3039
|
+
this.pages.destroy(), this.pages = new h(this, this.render, k), this.pages.load(), this.pages.show(n), this.trigger("update", this, { page: n, mode: this.render.getOrientation() });
|
|
3040
|
+
}
|
|
3041
|
+
updateFromHtml(k) {
|
|
3042
|
+
const n = this.pages.getCurrentPageIndex();
|
|
3043
|
+
this.pages.destroy(), this.pages = new v(this, this.render, this.ui.getDistElement(), k), this.pages.load(), this.ui.updateItems(k), this.render.reload(), this.pages.show(n), this.trigger("update", this, { page: n, mode: this.render.getOrientation() });
|
|
3044
|
+
}
|
|
3045
|
+
clear() {
|
|
3046
|
+
this.pages.destroy(), this.ui.clear();
|
|
3047
|
+
}
|
|
3048
|
+
turnToPrevPage() {
|
|
3049
|
+
this.pages.showPrev();
|
|
3050
|
+
}
|
|
3051
|
+
turnToNextPage() {
|
|
3052
|
+
this.pages.showNext();
|
|
3053
|
+
}
|
|
3054
|
+
turnToPage(k) {
|
|
3055
|
+
this.pages.show(k);
|
|
3056
|
+
}
|
|
3057
|
+
flipNext(k = "top") {
|
|
3058
|
+
this.flipController.flipNext(k);
|
|
3059
|
+
}
|
|
3060
|
+
flipPrev(k = "top") {
|
|
3061
|
+
this.flipController.flipPrev(k);
|
|
3062
|
+
}
|
|
3063
|
+
flip(k, n = "top") {
|
|
3064
|
+
this.flipController.flipToPage(k, n);
|
|
3065
|
+
}
|
|
3066
|
+
updateState(k) {
|
|
3067
|
+
this.trigger("changeState", this, k);
|
|
3068
|
+
}
|
|
3069
|
+
updatePageIndex(k) {
|
|
3070
|
+
this.trigger("flip", this, k);
|
|
3071
|
+
}
|
|
3072
|
+
updateOrientation(k) {
|
|
3073
|
+
this.ui.setOrientationStyle(k), this.update(), this.trigger("changeOrientation", this, k);
|
|
3074
|
+
}
|
|
3075
|
+
getPageCount() {
|
|
3076
|
+
return this.pages.getPageCount();
|
|
3077
|
+
}
|
|
3078
|
+
getCurrentPageIndex() {
|
|
3079
|
+
return this.pages.getCurrentPageIndex();
|
|
3080
|
+
}
|
|
3081
|
+
getPage(k) {
|
|
3082
|
+
return this.pages.getPage(k);
|
|
3083
|
+
}
|
|
3084
|
+
getRender() {
|
|
3085
|
+
return this.render;
|
|
3086
|
+
}
|
|
3087
|
+
getFlipController() {
|
|
3088
|
+
return this.flipController;
|
|
3089
|
+
}
|
|
3090
|
+
getOrientation() {
|
|
3091
|
+
return this.render.getOrientation();
|
|
3092
|
+
}
|
|
3093
|
+
getBoundsRect() {
|
|
3094
|
+
return this.render.getRect();
|
|
3095
|
+
}
|
|
3096
|
+
getSettings() {
|
|
3097
|
+
return this.setting;
|
|
3098
|
+
}
|
|
3099
|
+
getUI() {
|
|
3100
|
+
return this.ui;
|
|
3101
|
+
}
|
|
3102
|
+
getState() {
|
|
3103
|
+
return this.flipController.getState();
|
|
3104
|
+
}
|
|
3105
|
+
getPageCollection() {
|
|
3106
|
+
return this.pages;
|
|
3107
|
+
}
|
|
3108
|
+
startUserTouch(k) {
|
|
3109
|
+
this.mousePosition = k, this.isUserTouch = !0, this.isUserMove = !1;
|
|
3110
|
+
}
|
|
3111
|
+
userMove(k, n) {
|
|
3112
|
+
this.isUserTouch || n || !this.setting.showPageCorners ? this.isUserTouch && c.GetDistanceBetweenTwoPoint(this.mousePosition, k) > 5 && (this.isUserMove = !0, this.flipController.fold(k)) : this.flipController.showCorner(k);
|
|
3113
|
+
}
|
|
3114
|
+
userStop(k, n = !1) {
|
|
3115
|
+
this.isUserTouch && (this.isUserTouch = !1, n || (this.isUserMove ? this.flipController.stopMove() : this.flipController.flip(k)));
|
|
3116
|
+
}
|
|
3117
|
+
}, Object.defineProperty(i, "__esModule", { value: !0 });
|
|
3118
|
+
});
|
|
3119
|
+
})(Ve, Ve.exports);
|
|
3120
|
+
var ts = Ve.exports;
|
|
3121
|
+
/**
|
|
3122
|
+
* @license FlipbookEngine v1.0.0
|
|
3123
|
+
* Copyright (c) 2026 Murat Dogan
|
|
3124
|
+
*
|
|
3125
|
+
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
3126
|
+
*
|
|
3127
|
+
* 1. Open Source (AGPLv3): You may use, modify, and distribute this software
|
|
3128
|
+
* under the terms of the GNU Affero General Public License v3.0.
|
|
3129
|
+
*
|
|
3130
|
+
* 2. Commercial License: If you wish to use this software in commercial,
|
|
3131
|
+
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
3132
|
+
* you must purchase a Commercial License from:
|
|
3133
|
+
* https://flipbookengine.com/pricing
|
|
3134
|
+
*/
|
|
3135
|
+
function is() {
|
|
3136
|
+
return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
3137
|
+
}
|
|
3138
|
+
function ss(t, e = is()) {
|
|
3139
|
+
return e ? 0 : typeof t == "number" && t >= 0 ? t : 1e3;
|
|
3140
|
+
}
|
|
3141
|
+
class ns {
|
|
3142
|
+
constructor(e, i, s) {
|
|
3143
|
+
C(this, "pageFlip", null);
|
|
3144
|
+
C(this, "bookContainer");
|
|
3145
|
+
C(this, "options");
|
|
3146
|
+
C(this, "store");
|
|
3147
|
+
C(this, "unsubs", []);
|
|
3148
|
+
C(this, "audioEl", null);
|
|
3149
|
+
C(this, "audioUnlockHandler", null);
|
|
3150
|
+
C(this, "isLibraryFlipping", !1);
|
|
3151
|
+
C(this, "autoPlayTimer", null);
|
|
3152
|
+
C(this, "layoutUpdateTimer", null);
|
|
3153
|
+
this.bookContainer = e, this.options = i, this.store = s, i.soundUrl && (this.audioEl = new Audio(i.soundUrl), this.unlockAudio());
|
|
3154
|
+
}
|
|
3155
|
+
unlockAudio() {
|
|
3156
|
+
if (!this.audioEl) return;
|
|
3157
|
+
const e = () => {
|
|
3158
|
+
if (this.audioEl) {
|
|
3159
|
+
const i = this.audioEl.play();
|
|
3160
|
+
i && typeof i.then == "function" && i.then(() => {
|
|
3161
|
+
this.audioEl.pause(), this.audioEl.currentTime = 0;
|
|
3162
|
+
}).catch(() => {
|
|
3163
|
+
});
|
|
3164
|
+
}
|
|
3165
|
+
document.removeEventListener("touchstart", e), document.removeEventListener("click", e), this.audioUnlockHandler = null;
|
|
3166
|
+
};
|
|
3167
|
+
this.audioUnlockHandler = e, document.addEventListener("touchstart", e, { once: !0 }), document.addEventListener("click", e, { once: !0 });
|
|
3168
|
+
}
|
|
3169
|
+
init(e, i) {
|
|
3170
|
+
this.pageFlip = new ts.PageFlip(this.bookContainer, {
|
|
3171
|
+
width: e,
|
|
3172
|
+
height: i,
|
|
3173
|
+
size: "stretch",
|
|
3174
|
+
minWidth: 100,
|
|
3175
|
+
maxWidth: 3e3,
|
|
3176
|
+
minHeight: 100,
|
|
3177
|
+
maxHeight: 3e3,
|
|
3178
|
+
drawShadow: !0,
|
|
3179
|
+
showCover: !0,
|
|
3180
|
+
usePortrait: !0,
|
|
3181
|
+
// Keep native mobile scrolling available; this avoids preventDefault on non-cancelable touchstart events.
|
|
3182
|
+
mobileScrollSupport: !0,
|
|
3183
|
+
maxShadowOpacity: this.options.maxShadowOpacity || 0.5,
|
|
3184
|
+
flippingTime: ss(this.options.flippingTime)
|
|
3185
|
+
});
|
|
3186
|
+
const s = this.bookContainer.querySelectorAll(".bz-page");
|
|
3187
|
+
this.pageFlip.loadFromHTML(Array.from(s)), this.bindEvents(), this.setupSignalSync();
|
|
3188
|
+
}
|
|
3189
|
+
bindEvents() {
|
|
3190
|
+
this.pageFlip.on("flip", (e) => {
|
|
3191
|
+
this.store.currentPage.value !== e.data && (this.isLibraryFlipping = !0, this.store.currentPage.value = e.data, this.playSound(), this.isLibraryFlipping = !1);
|
|
3192
|
+
}), this.pageFlip.on("changeState", (e) => {
|
|
3193
|
+
this.store.flipState.value = e.data;
|
|
3194
|
+
}), this.pageFlip.on("changeOrientation", (e) => {
|
|
3195
|
+
this.store.orientation.value !== e.data && (this.store.orientation.value = e.data);
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
setupSignalSync() {
|
|
3199
|
+
this.unsubs.push(
|
|
3200
|
+
G(() => {
|
|
3201
|
+
const e = this.store.currentPage.value, i = this.store.flipState.peek();
|
|
3202
|
+
if (!this.pageFlip || this.isLibraryFlipping || i !== "read") return;
|
|
3203
|
+
const s = this.pageFlip.getCurrentPageIndex();
|
|
3204
|
+
if (s !== e && !this.store.isSingleMode.value) {
|
|
3205
|
+
const a = (c) => c === 0 ? 0 : Math.ceil(c / 2), r = a(e), h = a(s);
|
|
3206
|
+
r === h + 1 ? this.pageFlip.flipNext() : r === h - 1 ? this.pageFlip.flipPrev() : r !== h && this.pageFlip.turnToPage(e);
|
|
3207
|
+
}
|
|
3208
|
+
})
|
|
3209
|
+
), this.unsubs.push(
|
|
3210
|
+
G(() => {
|
|
3211
|
+
this.store.isSingleMode.value, this.pageFlip && (this.layoutUpdateTimer && clearTimeout(this.layoutUpdateTimer), this.layoutUpdateTimer = setTimeout(() => {
|
|
3212
|
+
this.layoutUpdateTimer = null, this.pageFlip && this.pageFlip.update(), window.dispatchEvent(new Event("resize"));
|
|
3213
|
+
}, 50));
|
|
3214
|
+
})
|
|
3215
|
+
), this.unsubs.push(
|
|
3216
|
+
G(() => {
|
|
3217
|
+
const e = this.store.isAutoPlaying.value, i = this.store.autoPlayInterval.value || 3e3;
|
|
3218
|
+
this.autoPlayTimer && (clearInterval(this.autoPlayTimer), this.autoPlayTimer = null), e && (this.autoPlayTimer = setInterval(() => {
|
|
3219
|
+
const s = this.store.pages.value.length - 1;
|
|
3220
|
+
if (this.store.currentPage.peek() >= s || this.store.currentPage.peek() >= s - 1 && !this.store.isSingleMode.peek()) {
|
|
3221
|
+
this.store.isAutoPlaying.value = !1;
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
this.turnToNextPage();
|
|
3225
|
+
}, i));
|
|
3226
|
+
})
|
|
3227
|
+
);
|
|
3228
|
+
}
|
|
3229
|
+
turnToNextPage() {
|
|
3230
|
+
if (this.store.isSingleMode.value) {
|
|
3231
|
+
const e = this.store.currentPage.value + 1;
|
|
3232
|
+
e < this.store.pages.value.length && (this.store.currentPage.value = e, this.playSound());
|
|
3233
|
+
} else this.pageFlip && this.pageFlip.flipNext();
|
|
3234
|
+
}
|
|
3235
|
+
turnToPrevPage() {
|
|
3236
|
+
if (this.store.isSingleMode.value) {
|
|
3237
|
+
const e = this.store.currentPage.value - 1;
|
|
3238
|
+
e >= 0 && (this.store.currentPage.value = e, this.playSound());
|
|
3239
|
+
} else this.pageFlip && this.pageFlip.flipPrev();
|
|
3240
|
+
}
|
|
3241
|
+
playSound() {
|
|
3242
|
+
if (this.store.soundEnabled.value && this.audioEl) {
|
|
3243
|
+
this.audioEl.currentTime = 0;
|
|
3244
|
+
const e = this.audioEl.play();
|
|
3245
|
+
e && typeof e.catch == "function" && e.catch((i) => console.warn("Flipbook Audio Play Error:", i));
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
update() {
|
|
3249
|
+
this.pageFlip && this.pageFlip.update(), this.layoutUpdateTimer && (clearTimeout(this.layoutUpdateTimer), this.layoutUpdateTimer = null);
|
|
3250
|
+
}
|
|
3251
|
+
destroy() {
|
|
3252
|
+
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((e) => e()), this.unsubs = [], this.pageFlip && (this.pageFlip.destroy(), this.pageFlip = null);
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
/**
|
|
3256
|
+
* @license FlipbookEngine v1.0.0
|
|
3257
|
+
* Copyright (c) 2026 Murat Dogan
|
|
3258
|
+
*
|
|
3259
|
+
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
3260
|
+
*
|
|
3261
|
+
* 1. Open Source (AGPLv3): You may use, modify, and distribute this software
|
|
3262
|
+
* under the terms of the GNU Affero General Public License v3.0.
|
|
3263
|
+
*
|
|
3264
|
+
* 2. Commercial License: If you wish to use this software in commercial,
|
|
3265
|
+
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
3266
|
+
* you must purchase a Commercial License from:
|
|
3267
|
+
* https://flipbookengine.com/pricing
|
|
3268
|
+
*/
|
|
3269
|
+
class as {
|
|
3270
|
+
constructor(e, i) {
|
|
3271
|
+
C(this, "wrapperElement", null);
|
|
3272
|
+
C(this, "sizerElement", null);
|
|
3273
|
+
C(this, "pageViewport");
|
|
3274
|
+
C(this, "store");
|
|
3275
|
+
C(this, "resizeObserver", null);
|
|
3276
|
+
C(this, "orientationMediaQuery", null);
|
|
3277
|
+
C(this, "orientationChangeHandler", null);
|
|
3278
|
+
C(this, "unsubs", []);
|
|
3279
|
+
C(this, "updateTimer", null);
|
|
3280
|
+
C(this, "onResizeCallback");
|
|
3281
|
+
this.pageViewport = e, this.store = i;
|
|
3282
|
+
}
|
|
3283
|
+
init(e, i) {
|
|
3284
|
+
this.wrapperElement = e, this.sizerElement = i, this.setupResizeObserver(), this.setupOrientationMedia(), this.setupStateSync(), this.updateBookAspectRatio();
|
|
3285
|
+
}
|
|
3286
|
+
setupStateSync() {
|
|
3287
|
+
this.unsubs.push(
|
|
3288
|
+
G(() => {
|
|
3289
|
+
this.store.isSingleMode.value, this.store.orientation.value, this.scheduleAspectRatioUpdate();
|
|
3290
|
+
})
|
|
3291
|
+
);
|
|
3292
|
+
}
|
|
3293
|
+
setupResizeObserver() {
|
|
3294
|
+
typeof ResizeObserver < "u" && this.wrapperElement && (this.resizeObserver = new ResizeObserver(() => {
|
|
3295
|
+
this.updateBookAspectRatio();
|
|
3296
|
+
}), this.resizeObserver.observe(this.wrapperElement));
|
|
3297
|
+
}
|
|
3298
|
+
setupOrientationMedia() {
|
|
3299
|
+
if (typeof window < "u" && window.matchMedia) {
|
|
3300
|
+
this.orientationMediaQuery = window.matchMedia("(orientation: portrait)");
|
|
3301
|
+
const e = (i) => {
|
|
3302
|
+
i.matches, this.updateBookAspectRatio();
|
|
3303
|
+
};
|
|
3304
|
+
this.orientationChangeHandler = e, this.orientationMediaQuery.addEventListener ? this.orientationMediaQuery.addEventListener("change", e) : this.orientationMediaQuery.addListener(e), e(this.orientationMediaQuery);
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
updateBookAspectRatio() {
|
|
3308
|
+
if (!this.wrapperElement || !this.sizerElement) return;
|
|
3309
|
+
const e = this.wrapperElement.clientWidth, i = this.wrapperElement.clientHeight;
|
|
3310
|
+
if (e === 0 || i === 0) return;
|
|
3311
|
+
const s = this.pageViewport.width, a = this.pageViewport.height, h = this.store.isDoublePageLayout.value ? s * 2 / a : s / a;
|
|
3312
|
+
let c = e, g = e / h;
|
|
3313
|
+
g > i && (g = i, c = i * h);
|
|
3314
|
+
let v = Math.ceil(c);
|
|
3315
|
+
v % 2 !== 0 && (v += 1), this.sizerElement.style.width = `${v}px`, this.sizerElement.style.height = `${Math.floor(g)}px`, this.sizerElement.style.aspectRatio = "", this.onResizeCallback && this.onResizeCallback();
|
|
3316
|
+
}
|
|
3317
|
+
destroy() {
|
|
3318
|
+
this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null), this.unsubs.forEach((e) => e()), 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);
|
|
3319
|
+
}
|
|
3320
|
+
scheduleAspectRatioUpdate() {
|
|
3321
|
+
this.updateTimer && clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
|
|
3322
|
+
this.updateTimer = null, this.updateBookAspectRatio();
|
|
3323
|
+
}, 10);
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
/**
|
|
3327
|
+
* @license FlipbookEngine v1.0.0
|
|
3328
|
+
* Copyright (c) 2026 Murat Dogan
|
|
3329
|
+
*
|
|
3330
|
+
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
3331
|
+
*
|
|
3332
|
+
* 1. Open Source (AGPLv3): You may use, modify, and distribute this software
|
|
3333
|
+
* under the terms of the GNU Affero General Public License v3.0.
|
|
3334
|
+
*
|
|
3335
|
+
* 2. Commercial License: If you wish to use this software in commercial,
|
|
3336
|
+
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
3337
|
+
* you must purchase a Commercial License from:
|
|
3338
|
+
* https://flipbookengine.com/pricing
|
|
3339
|
+
*/
|
|
3340
|
+
class os {
|
|
3341
|
+
constructor(e, i, s) {
|
|
3342
|
+
C(this, "container");
|
|
3343
|
+
C(this, "pageFlipAdapter");
|
|
3344
|
+
C(this, "store");
|
|
3345
|
+
C(this, "touchStartX", null);
|
|
3346
|
+
C(this, "unsubs", []);
|
|
3347
|
+
C(this, "listenerAbortController");
|
|
3348
|
+
var r;
|
|
3349
|
+
this.container = e, this.pageFlipAdapter = i, this.store = s;
|
|
3350
|
+
const a = ((r = e.ownerDocument.defaultView) == null ? void 0 : r.AbortController) ?? globalThis.AbortController;
|
|
3351
|
+
this.listenerAbortController = new a();
|
|
3352
|
+
}
|
|
3353
|
+
init() {
|
|
3354
|
+
this.bindWheel(), this.bindMouseDrag(), this.bindTouch(), this.setupStateSync();
|
|
3355
|
+
}
|
|
3356
|
+
setupStateSync() {
|
|
3357
|
+
this.unsubs.push(
|
|
3358
|
+
G(() => {
|
|
3359
|
+
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");
|
|
3360
|
+
})
|
|
3361
|
+
);
|
|
3362
|
+
}
|
|
3363
|
+
bindWheel() {
|
|
3364
|
+
this.container.addEventListener("wheel", (e) => {
|
|
3365
|
+
if (!(this.store.textSelection.value || this.store.placingNote.value || e.target.closest("button,input,textarea,select,[contenteditable=true]"))) {
|
|
3366
|
+
if (e.ctrlKey || e.metaKey) {
|
|
3367
|
+
e.preventDefault(), e.deltaY < 0 ? this.zoomIn() : this.zoomOut();
|
|
3368
|
+
return;
|
|
3369
|
+
}
|
|
3370
|
+
this.store.zoomState.value.isActive && (e.preventDefault(), this.updateZoomPan(
|
|
3371
|
+
this.store.zoomState.value.translateX - e.deltaX,
|
|
3372
|
+
this.store.zoomState.value.translateY - e.deltaY
|
|
3373
|
+
));
|
|
3374
|
+
}
|
|
3375
|
+
}, { passive: !1, signal: this.listenerAbortController.signal });
|
|
3376
|
+
}
|
|
3377
|
+
bindMouseDrag() {
|
|
3378
|
+
let e = !1, i = 0, s = 0, a = 0, r = 0;
|
|
3379
|
+
this.container.addEventListener("mousedown", (h) => {
|
|
3380
|
+
h.button !== 0 || this.store.textSelection.value || this.store.placingNote.value || h.target.closest("button,a,input,textarea,select,[contenteditable=true]") || this.store.zoomState.value.isActive && (h.preventDefault(), h.stopPropagation(), e = !0, i = h.clientX, s = h.clientY, a = this.store.zoomState.value.translateX, r = this.store.zoomState.value.translateY, this.container.style.cursor = "grabbing");
|
|
3381
|
+
}, { capture: !0, signal: this.listenerAbortController.signal }), window.addEventListener("mousemove", (h) => {
|
|
3382
|
+
if (!e || !this.store.zoomState.value.isActive) return;
|
|
3383
|
+
const c = h.clientX - i, g = h.clientY - s;
|
|
3384
|
+
this.updateZoomPan(a + c, r + g);
|
|
3385
|
+
}, { capture: !0, signal: this.listenerAbortController.signal }), window.addEventListener("mouseup", () => {
|
|
3386
|
+
e && (e = !1, this.container.style.cursor = this.store.zoomState.value.isActive ? "grab" : "");
|
|
3387
|
+
}, { capture: !0, signal: this.listenerAbortController.signal });
|
|
3388
|
+
}
|
|
3389
|
+
bindTouch() {
|
|
3390
|
+
let e = 0, i = 0, s = 0, a = 0, r = 1, h = 0, c = 0, g = 0, v = 0, y = !1;
|
|
3391
|
+
const S = this.listenerAbortController.signal, m = (b) => b == null ? void 0 : b.closest('button,a,input,textarea,select,[contenteditable="true"]');
|
|
3392
|
+
this.container.addEventListener("touchstart", (b) => {
|
|
3393
|
+
if (m(b.target) || this.store.textSelection.value || this.store.placingNote.value || this.store.pendingAnnotation.value || this.store.activeAnnotationId.value) {
|
|
3394
|
+
this.touchStartX = null;
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
if (b.touches.length === 2) {
|
|
3398
|
+
const [P, E] = Array.from(b.touches), I = this.container.parentElement.getBoundingClientRect();
|
|
3399
|
+
a = Math.hypot(P.clientX - E.clientX, P.clientY - E.clientY), r = this.store.zoomState.value.scale, h = (P.clientX + E.clientX) / 2, c = (P.clientY + E.clientY) / 2, g = I.left + I.width / 2, v = I.top + I.height / 2, i = this.store.zoomState.value.translateX, s = this.store.zoomState.value.translateY, y = !0, this.touchStartX = null, b.stopPropagation(), b.cancelable && b.preventDefault();
|
|
3400
|
+
} else b.touches.length === 1 && (y = !1, a = 0, this.touchStartX = b.touches[0].clientX, e = b.touches[0].clientY, i = this.store.zoomState.value.translateX, s = this.store.zoomState.value.translateY, this.store.zoomState.value.isActive && b.stopPropagation());
|
|
3401
|
+
}, { capture: !0, passive: !1, signal: S }), this.container.addEventListener("touchmove", (b) => {
|
|
3402
|
+
if (!(m(b.target) || this.store.placingNote.value))
|
|
3403
|
+
if (b.touches.length === 2 && a > 0) {
|
|
3404
|
+
const [P, E] = Array.from(b.touches), I = Math.max(1, Math.min(5, r * Math.hypot(P.clientX - E.clientX, P.clientY - E.clientY) / a)), F = I / r;
|
|
3405
|
+
this.store.zoomState.value = {
|
|
3406
|
+
...this.store.zoomState.value,
|
|
3407
|
+
scale: I,
|
|
3408
|
+
isActive: I > 1,
|
|
3409
|
+
translateX: i + (h - g) * (1 - F) + (P.clientX + E.clientX) / 2 - h,
|
|
3410
|
+
translateY: s + (c - v) * (1 - F) + (P.clientY + E.clientY) / 2 - c
|
|
3411
|
+
}, b.stopPropagation(), b.cancelable && b.preventDefault();
|
|
3412
|
+
} else !y && this.store.zoomState.value.isActive && this.touchStartX !== null && b.touches.length === 1 && (this.updateZoomPan(i + b.touches[0].clientX - this.touchStartX, s + b.touches[0].clientY - e), b.stopPropagation(), b.cancelable && b.preventDefault());
|
|
3413
|
+
}, { capture: !0, passive: !1, signal: S });
|
|
3414
|
+
const w = (b) => {
|
|
3415
|
+
if (!y && !this.store.placingNote.value && !this.store.pendingAnnotation.value && !this.store.activeAnnotationId.value && this.touchStartX !== null && !this.store.zoomState.value.isActive && this.store.isSingleMode.value && b.changedTouches.length === 1) {
|
|
3416
|
+
const P = b.changedTouches[0].clientX - this.touchStartX, E = b.changedTouches[0].clientY - e;
|
|
3417
|
+
Math.abs(P) > 50 && Math.abs(P) > Math.abs(E) * 1.4 && (P > 0 ? this.pageFlipAdapter.turnToPrevPage() : this.pageFlipAdapter.turnToNextPage());
|
|
3418
|
+
}
|
|
3419
|
+
(y || this.store.zoomState.value.isActive) && b.stopPropagation(), this.touchStartX = null, b.touches.length || (y = !1, a = 0);
|
|
3420
|
+
};
|
|
3421
|
+
this.container.addEventListener("touchend", w, { capture: !0, passive: !0, signal: S }), this.container.addEventListener("touchcancel", () => {
|
|
3422
|
+
this.touchStartX = null, y = !1, a = 0;
|
|
3423
|
+
}, { capture: !0, signal: S });
|
|
3424
|
+
}
|
|
3425
|
+
zoomIn() {
|
|
3426
|
+
let e = this.store.zoomState.value.scale + 0.5;
|
|
3427
|
+
e > 5 && (e = 5), this.store.zoomState.value = {
|
|
3428
|
+
...this.store.zoomState.value,
|
|
3429
|
+
isActive: e > 1,
|
|
3430
|
+
scale: e
|
|
3431
|
+
}, e > 1 && (this.container.style.cursor = "grab");
|
|
3432
|
+
}
|
|
3433
|
+
zoomOut() {
|
|
3434
|
+
let e = this.store.zoomState.value.scale - 0.5;
|
|
3435
|
+
e <= 1 ? (e = 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: e };
|
|
3436
|
+
}
|
|
3437
|
+
updateZoomPan(e, i) {
|
|
3438
|
+
this.store.zoomState.value = {
|
|
3439
|
+
...this.store.zoomState.value,
|
|
3440
|
+
translateX: e,
|
|
3441
|
+
translateY: i
|
|
3442
|
+
};
|
|
3443
|
+
}
|
|
3444
|
+
destroy() {
|
|
3445
|
+
this.listenerAbortController.abort(), this.unsubs.forEach((e) => e()), this.unsubs = [];
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
function qt(t, e, i) {
|
|
3449
|
+
if (!t || typeof t.title != "string" || !t.title.trim() || !Number.isFinite(t.pageIndex)) return null;
|
|
3450
|
+
const s = Math.max(0, e - 1), a = Array.isArray(t.children) ? t.children.map((r, h) => qt(r, e, i + "-" + h)).filter((r) => r !== null) : [];
|
|
3451
|
+
return {
|
|
3452
|
+
id: t.id ?? i,
|
|
3453
|
+
title: t.title.trim(),
|
|
3454
|
+
pageIndex: Math.max(0, Math.min(s, Math.trunc(t.pageIndex))),
|
|
3455
|
+
...a.length ? { children: a } : {}
|
|
3456
|
+
};
|
|
3457
|
+
}
|
|
3458
|
+
function je(t, e) {
|
|
3459
|
+
return Array.isArray(t) ? t.map((i, s) => qt(i, e, "toc-" + s)).filter((i) => i !== null) : [];
|
|
3460
|
+
}
|
|
3461
|
+
/**
|
|
3462
|
+
* @license FlipbookEngine v1.0.0
|
|
3463
|
+
* Copyright (c) 2026 Murat Dogan
|
|
3464
|
+
*
|
|
3465
|
+
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
3466
|
+
*/
|
|
3467
|
+
const St = () => ({ isActive: !1, translateX: 0, translateY: 0, isDragging: !1, scale: 1 });
|
|
3468
|
+
function _t() {
|
|
3469
|
+
const t = A(/* @__PURE__ */ new Map()), e = A(!1), i = A(!1), s = A(/* @__PURE__ */ new Map()), a = A(void 0), r = A(!1), h = A(!1), c = A(null), g = A("page"), v = A(!1), y = A(!1), S = A(!1), m = A(!1), w = A(!1), b = A(0), P = A(0), E = A(!1), I = A(!1), F = A(!1), k = A(!1), n = A(!1), o = A(!0), u = A("landscape"), f = A("read"), p = A("auto"), x = A(!0), T = A(!1), M = A(!1), L = A("#7367f0"), z = A(!1), B = A(!1), W = A(!1), V = A(/* @__PURE__ */ new Set()), K = A(/* @__PURE__ */ new Map()), ie = A(3e3), xe = A(!0), Pe = A(""), Se = A([]), ke = A([]), Ce = A(null), Ae = A([]), Te = A(null), Me = A("en"), Ee = A({}), st = A(St()), De = A([]), Ie = A([]), Re = d(() => !E.value && u.value === "landscape"), Yt = d(() => Re.value && b.value === 0), Zt = d(() => Re.value && b.value >= P.value - 1);
|
|
3470
|
+
return { textAvailable: i, textPages: t, textSelection: e, pageNoteDocuments: s, noteEditor: a, canAnnotate: r, placingNote: h, pendingAnnotation: c, notesView: g, searchAvailable: v, searchBusy: y, searchFailed: S, notesSaving: m, notesFailed: w, currentPage: b, totalPages: P, isSingleMode: E, showThumbs: I, showToc: F, showNotes: k, showSearch: n, showArrows: o, orientation: u, flipState: f, themeMode: p, allowDownload: x, bookmarkedPages: V, pageNotes: K, hasDownloadUrl: T, isPdfMode: M, primaryColor: L, whiteLabel: z, isZoomed: B, isAutoPlaying: W, autoPlayInterval: ie, soundEnabled: xe, searchQuery: Pe, searchResults: Se, hotspots: ke, activeHotspotId: Ce, annotations: Ae, activeAnnotationId: Te, locale: Me, messages: Ee, zoomState: st, pages: De, toc: Ie, isDoublePageLayout: Re, isFrontCover: Yt, isBackCover: Zt, init: (D, ue, Qt, nt, at = nt) => {
|
|
3471
|
+
s.value = new Map(Object.entries(D.noteDocuments ?? {}).map(([$, se]) => [Number($), se])), a.value = D.noteEditor, r.value = !!D.annotationProvider, h.value = !1, c.value = null, i.value = !!D.textLayerProvider, t.value = /* @__PURE__ */ new Map(), e.value = D.textSelection ?? !1, v.value = at || !!D.searchProvider, P.value = ue, De.value = Qt, T.value = nt, M.value = at, D.theme !== void 0 && (p.value = D.theme), D.primaryColor !== void 0 && (L.value = D.primaryColor), D.showThumbs !== void 0 && (I.value = D.showThumbs), D.showToc !== void 0 && (F.value = D.showToc), k.value = !1, g.value = "page", n.value = !1, y.value = !1, S.value = !1, m.value = !1, w.value = !1, Pe.value = "", Se.value = [], ke.value = D.hotspots ?? [], Ce.value = null, Ae.value = D.annotations ?? [], Te.value = null, Ie.value = je(D.toc ?? [], ue), D.showArrows !== void 0 && (o.value = D.showArrows), D.allowDownload !== void 0 && (x.value = D.allowDownload), D.whiteLabel !== void 0 && (z.value = D.whiteLabel), D.soundEnabled !== void 0 && (xe.value = D.soundEnabled), D.locale !== void 0 && (Me.value = D.locale), D.messages !== void 0 && (Ee.value = D.messages), D.isSingleMode !== void 0 && (E.value = D.isSingleMode), D.singleMode !== void 0 && (E.value = D.singleMode), D.autoPlay !== void 0 && (W.value = D.autoPlay), D.autoPlayInterval !== void 0 && (ie.value = D.autoPlayInterval), V.value = new Set((D.bookmarks ?? []).map(($) => Math.trunc($)).filter(($) => Number.isInteger($) && $ >= 0 && $ < ue)), K.value = new Map(Object.entries(D.notes ?? {}).map(([$, se]) => [Math.trunc(Number($)), String(se).trim()]).filter(([$, se]) => Number.isInteger($) && $ >= 0 && $ < ue && se.length > 0)), b.value = 0;
|
|
3472
|
+
}, reset: () => {
|
|
3473
|
+
t.value = /* @__PURE__ */ new Map(), e.value = !1, i.value = !1, b.value = 0, P.value = 0, E.value = !1, I.value = !1, F.value = !1, k.value = !1, g.value = "page", n.value = !1, y.value = !1, S.value = !1, m.value = !1, w.value = !1, o.value = !0, u.value = "landscape", f.value = "read", p.value = "auto", x.value = !0, T.value = !1, M.value = !1, v.value = !1, s.value = /* @__PURE__ */ new Map(), r.value = !1, h.value = !1, c.value = null, L.value = "#7367f0", z.value = !1, B.value = !1, W.value = !1, ie.value = 3e3, xe.value = !0, Me.value = "en", Ee.value = {}, st.value = St(), De.value = [], Ie.value = [], V.value = /* @__PURE__ */ new Set(), K.value = /* @__PURE__ */ new Map(), Pe.value = "", Se.value = [], ke.value = [], Ce.value = null, Ae.value = [], Te.value = null;
|
|
3474
|
+
} };
|
|
3475
|
+
}
|
|
3476
|
+
const R = _t();
|
|
3477
|
+
R.currentPage;
|
|
3478
|
+
R.totalPages;
|
|
3479
|
+
R.isSingleMode;
|
|
3480
|
+
R.showThumbs;
|
|
3481
|
+
R.showToc;
|
|
3482
|
+
R.showNotes;
|
|
3483
|
+
R.showSearch;
|
|
3484
|
+
R.showArrows;
|
|
3485
|
+
R.orientation;
|
|
3486
|
+
R.flipState;
|
|
3487
|
+
R.themeMode;
|
|
3488
|
+
R.allowDownload;
|
|
3489
|
+
R.bookmarkedPages;
|
|
3490
|
+
R.pageNotes;
|
|
3491
|
+
R.hasDownloadUrl;
|
|
3492
|
+
R.isPdfMode;
|
|
3493
|
+
R.primaryColor;
|
|
3494
|
+
R.whiteLabel;
|
|
3495
|
+
R.isZoomed;
|
|
3496
|
+
R.isAutoPlaying;
|
|
3497
|
+
R.autoPlayInterval;
|
|
3498
|
+
R.soundEnabled;
|
|
3499
|
+
R.searchQuery;
|
|
3500
|
+
R.searchResults;
|
|
3501
|
+
R.hotspots;
|
|
3502
|
+
R.activeHotspotId;
|
|
3503
|
+
R.annotations;
|
|
3504
|
+
R.activeAnnotationId;
|
|
3505
|
+
R.locale;
|
|
3506
|
+
R.messages;
|
|
3507
|
+
R.zoomState;
|
|
3508
|
+
R.pages;
|
|
3509
|
+
R.toc;
|
|
3510
|
+
R.isDoublePageLayout;
|
|
3511
|
+
R.isFrontCover;
|
|
3512
|
+
R.isBackCover;
|
|
3513
|
+
function rs(t) {
|
|
3514
|
+
if (!t || typeof t != "object") return !1;
|
|
3515
|
+
const e = t;
|
|
3516
|
+
return typeof e.normal == "string" && typeof e.low == "string" && typeof e.thumb == "string";
|
|
3517
|
+
}
|
|
3518
|
+
function ls(t) {
|
|
3519
|
+
return Array.isArray(t.pageNumbers) && t.pageNumbers.length > 0 ? t.pageNumbers : typeof t.pageNumber == "number" ? t.kind === "spread" ? [t.pageNumber, t.pageNumber + 1] : [t.pageNumber] : [];
|
|
3520
|
+
}
|
|
3521
|
+
function hs(t) {
|
|
3522
|
+
return t === "rtl" ? ["right", "left"] : ["left", "right"];
|
|
3523
|
+
}
|
|
3524
|
+
function cs(t) {
|
|
3525
|
+
const e = [];
|
|
3526
|
+
let i = 1;
|
|
3527
|
+
return t.forEach((s, a) => {
|
|
3528
|
+
const r = s.kind ?? "single", h = s.id ?? `asset-${a}`, c = s.splitDirection ?? "ltr", g = ls(s);
|
|
3529
|
+
if (r === "spread") {
|
|
3530
|
+
const y = g.length >= 2 ? g.slice(0, 2) : [i, i + 1], S = hs(c);
|
|
3531
|
+
y.forEach((m, w) => {
|
|
3532
|
+
e.push({
|
|
3533
|
+
index: e.length,
|
|
3534
|
+
assetId: h,
|
|
3535
|
+
pageNumber: m,
|
|
3536
|
+
sourcePageNumber: m,
|
|
3537
|
+
cropMode: S[w] ?? "full",
|
|
3538
|
+
normal: s.normal,
|
|
3539
|
+
low: s.low,
|
|
3540
|
+
thumb: s.thumb
|
|
3541
|
+
});
|
|
3542
|
+
}), i = y[y.length - 1] + 1;
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
const v = g[0] ?? i;
|
|
3546
|
+
e.push({
|
|
3547
|
+
index: e.length,
|
|
3548
|
+
assetId: h,
|
|
3549
|
+
pageNumber: v,
|
|
3550
|
+
sourcePageNumber: v,
|
|
3551
|
+
cropMode: "full",
|
|
3552
|
+
normal: s.normal,
|
|
3553
|
+
low: s.low,
|
|
3554
|
+
thumb: s.thumb
|
|
3555
|
+
}), i = v + 1;
|
|
3556
|
+
}), e;
|
|
3557
|
+
}
|
|
3558
|
+
function us(t) {
|
|
3559
|
+
return t ? 'url("' + t.replace(/["\\\r\n]/g, (i) => "\\" + i) + '")' : void 0;
|
|
3560
|
+
}
|
|
3561
|
+
function kt(t, e) {
|
|
3562
|
+
t.classList.add("bk-container"), t.classList.remove("bk-theme-light", "bk-theme-dark"), t.classList.add("bk-theme-" + (e.theme ?? "auto")), e.primaryColor && t.style.setProperty("--flipbook-accent", e.primaryColor);
|
|
3563
|
+
const i = e.background ?? {}, s = e.backgroundColor || e.backgroundImage ? { color: e.backgroundColor, image: e.backgroundImage } : void 0, a = (h, c) => {
|
|
3564
|
+
const g = {
|
|
3565
|
+
["--flipbook-bg-" + h + "-color"]: c == null ? void 0 : c.color,
|
|
3566
|
+
["--flipbook-bg-" + h + "-image"]: us(c == null ? void 0 : c.image),
|
|
3567
|
+
["--flipbook-bg-" + h + "-size"]: c == null ? void 0 : c.size,
|
|
3568
|
+
["--flipbook-bg-" + h + "-position"]: c == null ? void 0 : c.position,
|
|
3569
|
+
["--flipbook-bg-" + h + "-repeat"]: c == null ? void 0 : c.repeat
|
|
3570
|
+
};
|
|
3571
|
+
Object.entries(g).forEach(([v, y]) => {
|
|
3572
|
+
y ? t.style.setProperty(v, y) : t.style.removeProperty(v);
|
|
3573
|
+
});
|
|
3574
|
+
};
|
|
3575
|
+
a("light", i.light ?? s), a("dark", i.dark);
|
|
3576
|
+
const r = e.cssVariables ?? {};
|
|
3577
|
+
Object.entries(r).forEach(([h, c]) => {
|
|
3578
|
+
const g = h.startsWith("--") ? h : "--" + h;
|
|
3579
|
+
t.style.setProperty(g, c);
|
|
3580
|
+
});
|
|
3581
|
+
}
|
|
3582
|
+
class ds {
|
|
3583
|
+
constructor(e = 32) {
|
|
3584
|
+
C(this, "entries", /* @__PURE__ */ new Map());
|
|
3585
|
+
C(this, "hits", 0);
|
|
3586
|
+
C(this, "misses", 0);
|
|
3587
|
+
if (this.maxEntries = e, !Number.isInteger(e) || e < 0)
|
|
3588
|
+
throw new RangeError("PDF render cache size must be a non-negative integer.");
|
|
3589
|
+
}
|
|
3590
|
+
get(e) {
|
|
3591
|
+
const i = this.entries.get(e);
|
|
3592
|
+
if (i === void 0) {
|
|
3593
|
+
this.misses++;
|
|
3594
|
+
return;
|
|
3595
|
+
}
|
|
3596
|
+
return this.hits++, this.entries.delete(e), this.entries.set(e, i), i;
|
|
3597
|
+
}
|
|
3598
|
+
set(e, i) {
|
|
3599
|
+
if (!(this.maxEntries === 0 || !i))
|
|
3600
|
+
for (this.entries.delete(e), this.entries.set(e, i); this.entries.size > this.maxEntries; ) {
|
|
3601
|
+
const s = this.entries.keys().next().value;
|
|
3602
|
+
if (s === void 0) break;
|
|
3603
|
+
this.entries.delete(s);
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
clear() {
|
|
3607
|
+
this.entries.clear(), this.hits = 0, this.misses = 0;
|
|
3608
|
+
}
|
|
3609
|
+
get size() {
|
|
3610
|
+
return this.entries.size;
|
|
3611
|
+
}
|
|
3612
|
+
getStats() {
|
|
3613
|
+
return { size: this.size, maxEntries: this.maxEntries, hits: this.hits, misses: this.misses };
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
const He = 1190.55, We = 841.89;
|
|
3617
|
+
function gs(t, e) {
|
|
3618
|
+
const i = Math.max(t, e), s = Math.min(t, e), a = i / s, r = Math.abs(i - He) / He <= 0.08 && Math.abs(s - We) / We <= 0.08;
|
|
3619
|
+
return t >= e && r && Math.abs(a - He / We) <= 0.04;
|
|
3620
|
+
}
|
|
3621
|
+
class fs {
|
|
3622
|
+
constructor(e = {}) {
|
|
3623
|
+
C(this, "pdfDoc", null);
|
|
3624
|
+
C(this, "loadingTask", null);
|
|
3625
|
+
C(this, "options");
|
|
3626
|
+
C(this, "cache");
|
|
3627
|
+
C(this, "textCache", /* @__PURE__ */ new Map());
|
|
3628
|
+
const i = Number.isFinite(e.cacheSize) ? Math.max(0, Math.floor(e.cacheSize)) : 32;
|
|
3629
|
+
this.options = {
|
|
3630
|
+
scale: e.scale || 1.5,
|
|
3631
|
+
quality: e.quality || 0.85,
|
|
3632
|
+
format: e.format || "image/webp",
|
|
3633
|
+
workerSrc: e.workerSrc || "",
|
|
3634
|
+
concurrency: Math.max(1, Math.floor(e.concurrency || 3)),
|
|
3635
|
+
cacheSize: i
|
|
3636
|
+
}, this.cache = new ds(this.options.cacheSize), this.options.workerSrc && (rt.GlobalWorkerOptions.workerSrc = this.options.workerSrc);
|
|
3637
|
+
}
|
|
3638
|
+
/** Loads a PDF document and cancels PDF.js loading when the signal aborts. */
|
|
3639
|
+
async loadDocument(e, i) {
|
|
3640
|
+
this.throwIfAborted(i), this.cache.clear();
|
|
3641
|
+
const s = rt.getDocument(e);
|
|
3642
|
+
this.loadingTask = s;
|
|
3643
|
+
const a = () => {
|
|
3644
|
+
var r;
|
|
3645
|
+
return (r = s.destroy) == null ? void 0 : r.call(s);
|
|
3646
|
+
};
|
|
3647
|
+
i == null || i.addEventListener("abort", a, { once: !0 });
|
|
3648
|
+
try {
|
|
3649
|
+
return this.pdfDoc = await s.promise, this.throwIfAborted(i), this.pdfDoc.numPages;
|
|
3650
|
+
} catch (r) {
|
|
3651
|
+
throw i != null && i.aborted ? this.createAbortError() : r;
|
|
3652
|
+
} finally {
|
|
3653
|
+
i == null || i.removeEventListener("abort", a), this.loadingTask === s && (this.loadingTask = null);
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
/** Renders a specific page to a Data URL. The page index is 1-based. */
|
|
3657
|
+
async renderPageToDataUrl(e, i) {
|
|
3658
|
+
if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
|
|
3659
|
+
this.throwIfAborted(i);
|
|
3660
|
+
const s = this.cache.get(e);
|
|
3661
|
+
if (s !== void 0) return s;
|
|
3662
|
+
try {
|
|
3663
|
+
const a = await this.pdfDoc.getPage(e);
|
|
3664
|
+
this.throwIfAborted(i);
|
|
3665
|
+
const r = a.getViewport({ scale: this.options.scale }), h = document.createElement("canvas");
|
|
3666
|
+
h.width = r.width, h.height = r.height;
|
|
3667
|
+
const c = h.getContext("2d");
|
|
3668
|
+
if (c) {
|
|
3669
|
+
const g = a.render({ canvasContext: c, viewport: r }), v = () => {
|
|
3670
|
+
var S;
|
|
3671
|
+
return (S = g.cancel) == null ? void 0 : S.call(g);
|
|
3672
|
+
};
|
|
3673
|
+
i == null || i.addEventListener("abort", v, { once: !0 });
|
|
3674
|
+
try {
|
|
3675
|
+
await g.promise, this.throwIfAborted(i);
|
|
3676
|
+
} finally {
|
|
3677
|
+
i == null || i.removeEventListener("abort", v);
|
|
3678
|
+
}
|
|
3679
|
+
const y = h.toDataURL(this.options.format, this.options.quality);
|
|
3680
|
+
return this.cache.set(e, y), y;
|
|
3681
|
+
}
|
|
3682
|
+
throw new Error("Unable to create a PDF canvas rendering context.");
|
|
3683
|
+
} catch (a) {
|
|
3684
|
+
throw i != null && i.aborted ? this.createAbortError() : a;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
/** Extracts text from a 1-based PDF source page using PDF.js text content. */
|
|
3688
|
+
async extractPageText(e) {
|
|
3689
|
+
if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
|
|
3690
|
+
if (!Number.isInteger(e) || e < 1 || e > this.pdfDoc.numPages)
|
|
3691
|
+
throw new Error("PDF page number is out of range.");
|
|
3692
|
+
const i = this.textCache.get(e);
|
|
3693
|
+
if (i !== void 0) return i;
|
|
3694
|
+
const a = await (await this.pdfDoc.getPage(e)).getTextContent(), r = ((a == null ? void 0 : a.items) ?? []).map((h) => typeof (h == null ? void 0 : h.str) == "string" ? h.str : "").filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
3695
|
+
return this.textCache.set(e, r), r;
|
|
3696
|
+
}
|
|
3697
|
+
/** Searches all PDF source pages and returns normalized rectangles for matched text. */
|
|
3698
|
+
async searchText(e, i = {}) {
|
|
3699
|
+
const s = String(e ?? "").trim();
|
|
3700
|
+
if (!this.pdfDoc || !s) return [];
|
|
3701
|
+
const a = i.caseSensitive === !0, r = a ? s : s.toLocaleLowerCase(), h = Number.isFinite(i.maxResults) ? Math.max(1, Math.trunc(i.maxResults)) : 100, c = [];
|
|
3702
|
+
for (let g = 1; g <= this.pdfDoc.numPages && c.length < h; g++) {
|
|
3703
|
+
const v = await this.pdfDoc.getPage(g), y = await v.getTextContent(), S = ((y == null ? void 0 : y.items) ?? []).filter((p) => typeof (p == null ? void 0 : p.str) == "string" && p.str.length > 0), m = S.map((p) => p.str).join(" ").replace(/\s+/g, " ").trim(), w = a ? m : m.toLocaleLowerCase();
|
|
3704
|
+
let b = 0, P = w.indexOf(r);
|
|
3705
|
+
for (; P >= 0; )
|
|
3706
|
+
b++, P = w.indexOf(r, P + Math.max(1, r.length));
|
|
3707
|
+
if (!b) continue;
|
|
3708
|
+
const E = w.indexOf(r), I = Math.max(0, E - 70), F = Math.min(m.length, E + s.length + 100), k = [], n = typeof v.getViewport == "function" ? v.getViewport({ scale: 1 }) : null, o = Number(n == null ? void 0 : n.width), u = Number(n == null ? void 0 : n.height);
|
|
3709
|
+
o > 0 && u > 0 && S.forEach((p) => {
|
|
3710
|
+
const x = String(p.str), T = a ? x : x.toLocaleLowerCase(), M = Array.isArray(p.transform) ? p.transform : [], L = Number(M[4]), z = Number(M[5]), B = Number(p.width) || Math.abs(Number(M[0])) || 0, W = Number(p.height) || Math.abs(Number(M[3])) || 0;
|
|
3711
|
+
if (!(B > 0 && W > 0 && Number.isFinite(L) && Number.isFinite(z))) return;
|
|
3712
|
+
let V = T.indexOf(r);
|
|
3713
|
+
for (; V >= 0; ) {
|
|
3714
|
+
const K = Math.max(0, Math.min(1, V / Math.max(1, x.length))), ie = Math.max(0.02, Math.min(1 - K, r.length / Math.max(1, x.length)));
|
|
3715
|
+
k.push({
|
|
3716
|
+
x: Math.max(0, Math.min(1, (L + B * K) / o)),
|
|
3717
|
+
y: Math.max(0, Math.min(1, (u - z - W) / u)),
|
|
3718
|
+
width: Math.max(0, Math.min(1, B * ie / o)),
|
|
3719
|
+
height: Math.max(0, Math.min(1, W / u))
|
|
3720
|
+
}), V = T.indexOf(r, V + Math.max(1, r.length));
|
|
3721
|
+
}
|
|
3722
|
+
});
|
|
3723
|
+
const f = { sourcePageNumber: g, matches: b, snippet: m.slice(I, F).trim() };
|
|
3724
|
+
k.length && (f.highlights = k), c.push(f);
|
|
3725
|
+
}
|
|
3726
|
+
return c;
|
|
3727
|
+
}
|
|
3728
|
+
/** Returns source page dimensions and whether the page should be split. */
|
|
3729
|
+
async getPageLayouts(e = "auto") {
|
|
3730
|
+
if (!this.pdfDoc) return [];
|
|
3731
|
+
const i = [];
|
|
3732
|
+
for (let s = 1; s <= this.pdfDoc.numPages; s++) {
|
|
3733
|
+
const r = (await this.pdfDoc.getPage(s)).getViewport({ scale: 1 }), h = e === "split" ? r.width >= r.height : e === "auto" && gs(r.width, r.height);
|
|
3734
|
+
i.push({ width: r.width, height: r.height, split: h });
|
|
3735
|
+
}
|
|
3736
|
+
return i;
|
|
3737
|
+
}
|
|
3738
|
+
/** Calculates the best viewport dimensions based on the first logical page. */
|
|
3739
|
+
async calculateViewportDimensions(e = 420, i) {
|
|
3740
|
+
if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
|
|
3741
|
+
const s = await this.pdfDoc.getPage(1), a = i ? { width: i.split ? i.width / 2 : i.width, height: i.height } : s.getViewport({ scale: 1 }), r = a.width / a.height;
|
|
3742
|
+
return r >= 1 ? { width: Math.round(e * r), height: e } : { width: e, height: Math.round(e / r) };
|
|
3743
|
+
}
|
|
3744
|
+
/** Renders pages concurrently with a bounded worker pool and preserves page order. */
|
|
3745
|
+
async renderAllPages(e, i) {
|
|
3746
|
+
if (!this.pdfDoc) return [];
|
|
3747
|
+
this.throwIfAborted(e);
|
|
3748
|
+
const s = this.pdfDoc.numPages, a = new Array(s);
|
|
3749
|
+
let r = 1, h = 0;
|
|
3750
|
+
const c = async () => {
|
|
3751
|
+
for (; ; ) {
|
|
3752
|
+
this.throwIfAborted(e);
|
|
3753
|
+
const v = r++;
|
|
3754
|
+
if (v > s) return;
|
|
3755
|
+
const y = await this.renderPageToDataUrl(v, e);
|
|
3756
|
+
a[v - 1] = {
|
|
3757
|
+
index: v - 1,
|
|
3758
|
+
assetId: `pdf-page-${v}`,
|
|
3759
|
+
pageNumber: v,
|
|
3760
|
+
cropMode: "full",
|
|
3761
|
+
normal: y,
|
|
3762
|
+
low: y,
|
|
3763
|
+
thumb: y
|
|
3764
|
+
}, h++, i == null || i({ completed: h, total: s });
|
|
3765
|
+
}
|
|
3766
|
+
}, g = Math.min(this.options.concurrency, s);
|
|
3767
|
+
return await Promise.all(Array.from({ length: g }, () => c())), this.throwIfAborted(e), a;
|
|
3768
|
+
}
|
|
3769
|
+
getCacheStats() {
|
|
3770
|
+
return this.cache.getStats();
|
|
3771
|
+
}
|
|
3772
|
+
throwIfAborted(e) {
|
|
3773
|
+
if (e != null && e.aborted) throw this.createAbortError();
|
|
3774
|
+
}
|
|
3775
|
+
createAbortError() {
|
|
3776
|
+
const e = new Error("PDF rendering was aborted.");
|
|
3777
|
+
return e.name = "AbortError", e;
|
|
3778
|
+
}
|
|
3779
|
+
destroy() {
|
|
3780
|
+
var e, i, s, a;
|
|
3781
|
+
(i = (e = this.loadingTask) == null ? void 0 : e.destroy) == null || i.call(e), this.loadingTask = null, this.pdfDoc && ((a = (s = this.pdfDoc).destroy) == null || a.call(s), this.pdfDoc = null), this.cache.clear();
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
/**
|
|
3785
|
+
* @license FlipbookEngine v1.0.0
|
|
3786
|
+
* Copyright (c) 2026 Murat Dogan
|
|
3787
|
+
*
|
|
3788
|
+
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
3789
|
+
*/
|
|
3790
|
+
const Gt = "flipbook:command", Ut = "flipbook:event", Vt = "flipbook:response";
|
|
3791
|
+
function J() {
|
|
3792
|
+
return typeof window > "u" ? null : window;
|
|
3793
|
+
}
|
|
3794
|
+
function Ct(t, e) {
|
|
3795
|
+
var s;
|
|
3796
|
+
const i = (s = t.allowedOrigins) == null ? void 0 : s.filter(Boolean);
|
|
3797
|
+
return i != null && i.length ? i : [e];
|
|
3798
|
+
}
|
|
3799
|
+
function Xe(t) {
|
|
3800
|
+
return t && typeof t == "object" ? t : {};
|
|
3801
|
+
}
|
|
3802
|
+
function At(t, e) {
|
|
3803
|
+
if (typeof t != "number" || !Number.isFinite(t))
|
|
3804
|
+
throw new Error(`${e} must be a finite number.`);
|
|
3805
|
+
return t;
|
|
3806
|
+
}
|
|
3807
|
+
class ps {
|
|
3808
|
+
constructor(e, i = {}) {
|
|
3809
|
+
C(this, "engine");
|
|
3810
|
+
C(this, "options");
|
|
3811
|
+
C(this, "listener");
|
|
3812
|
+
C(this, "unsubs", []);
|
|
3813
|
+
C(this, "connected", !1);
|
|
3814
|
+
C(this, "parentOrigin", null);
|
|
3815
|
+
C(this, "engineEventNames", {
|
|
3816
|
+
init: !0,
|
|
3817
|
+
destroy: !0,
|
|
3818
|
+
pageChange: !0,
|
|
3819
|
+
zoomChange: !0,
|
|
3820
|
+
thumbsToggle: !0,
|
|
3821
|
+
tocToggle: !0,
|
|
3822
|
+
singlePageModeChange: !0,
|
|
3823
|
+
orientationChange: !0,
|
|
3824
|
+
progress: !0,
|
|
3825
|
+
error: !0,
|
|
3826
|
+
deepLinkChange: !0,
|
|
3827
|
+
bookmarkChange: !0,
|
|
3828
|
+
noteChange: !0,
|
|
3829
|
+
searchChange: !0,
|
|
3830
|
+
hotspotActivate: !0,
|
|
3831
|
+
annotationChange: !0,
|
|
3832
|
+
annotationActivate: !0
|
|
3833
|
+
});
|
|
3834
|
+
this.engine = e, this.options = i, this.listener = (s) => {
|
|
3835
|
+
this.handleMessage(s);
|
|
3836
|
+
};
|
|
3837
|
+
}
|
|
3838
|
+
connect() {
|
|
3839
|
+
if (this.connected) return this;
|
|
3840
|
+
const e = J();
|
|
3841
|
+
return !e || e.parent === e ? this : (this.connected = !0, e.addEventListener("message", this.listener), Object.keys(this.engineEventNames).forEach((i) => {
|
|
3842
|
+
this.unsubs.push(this.engine.on(i, (s) => {
|
|
3843
|
+
this.postEvent(i, s);
|
|
3844
|
+
}));
|
|
3845
|
+
}), this);
|
|
3846
|
+
}
|
|
3847
|
+
disconnect() {
|
|
3848
|
+
var e;
|
|
3849
|
+
this.connected && ((e = J()) == null || e.removeEventListener("message", this.listener), this.unsubs.splice(0).forEach((i) => i()), this.connected = !1, this.parentOrigin = null);
|
|
3850
|
+
}
|
|
3851
|
+
isAllowedOrigin(e) {
|
|
3852
|
+
const i = J(), s = (i == null ? void 0 : i.location.origin) ?? "";
|
|
3853
|
+
return Ct(this.options, s).includes("*") || Ct(this.options, s).includes(e);
|
|
3854
|
+
}
|
|
3855
|
+
post(e) {
|
|
3856
|
+
const i = J(), s = i == null ? void 0 : i.parent;
|
|
3857
|
+
if (!i || !s || s === i) return;
|
|
3858
|
+
const a = this.options.targetOrigin ?? this.parentOrigin ?? i.location.origin;
|
|
3859
|
+
s.postMessage(e, a);
|
|
3860
|
+
}
|
|
3861
|
+
postEvent(e, i) {
|
|
3862
|
+
this.post({ type: Ut, event: e, payload: i });
|
|
3863
|
+
}
|
|
3864
|
+
respond(e, i, s) {
|
|
3865
|
+
this.post({
|
|
3866
|
+
type: Vt,
|
|
3867
|
+
requestId: e,
|
|
3868
|
+
ok: !s,
|
|
3869
|
+
...s ? { error: s instanceof Error ? s.message : String(s) } : { result: i }
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
async handleMessage(e) {
|
|
3873
|
+
const i = J();
|
|
3874
|
+
if (!i || e.source !== i.parent || !this.isAllowedOrigin(e.origin)) return;
|
|
3875
|
+
const s = Xe(e.data);
|
|
3876
|
+
if (s.type !== Gt || typeof s.command != "string") return;
|
|
3877
|
+
this.parentOrigin = e.origin;
|
|
3878
|
+
const a = typeof s.requestId == "string" ? s.requestId : void 0;
|
|
3879
|
+
try {
|
|
3880
|
+
const r = Xe(s.payload);
|
|
3881
|
+
let h;
|
|
3882
|
+
switch (s.command) {
|
|
3883
|
+
case "goToPage":
|
|
3884
|
+
this.engine.goToPage(Math.trunc(At(r.pageIndex, "pageIndex"))), h = this.getState();
|
|
3885
|
+
break;
|
|
3886
|
+
case "nextPage":
|
|
3887
|
+
this.engine.nextPage(), h = this.getState();
|
|
3888
|
+
break;
|
|
3889
|
+
case "prevPage":
|
|
3890
|
+
this.engine.prevPage(), h = this.getState();
|
|
3891
|
+
break;
|
|
3892
|
+
case "setZoom":
|
|
3893
|
+
this.engine.setZoom(At(r.zoom, "zoom")), h = this.getState();
|
|
3894
|
+
break;
|
|
3895
|
+
case "setSingleMode":
|
|
3896
|
+
if (typeof r.isSingle != "boolean") throw new Error("isSingle must be a boolean.");
|
|
3897
|
+
this.engine.setSingleMode(r.isSingle), h = this.getState();
|
|
3898
|
+
break;
|
|
3899
|
+
case "updateOptions":
|
|
3900
|
+
this.engine.updateOptions(r.options), h = this.getState();
|
|
3901
|
+
break;
|
|
3902
|
+
case "toggleFullscreen":
|
|
3903
|
+
this.engine.toggleFullscreen(), h = this.getState();
|
|
3904
|
+
break;
|
|
3905
|
+
case "search":
|
|
3906
|
+
h = await this.engine.search(String(r.query ?? ""), r.options);
|
|
3907
|
+
break;
|
|
3908
|
+
case "clearSearch":
|
|
3909
|
+
this.engine.clearSearch(), h = this.getState();
|
|
3910
|
+
break;
|
|
3911
|
+
case "getSearchResults":
|
|
3912
|
+
h = this.engine.getSearchResults();
|
|
3913
|
+
break;
|
|
3914
|
+
case "getToc":
|
|
3915
|
+
h = this.engine.getToc();
|
|
3916
|
+
break;
|
|
3917
|
+
case "setToc":
|
|
3918
|
+
if (!Array.isArray(r.entries)) throw new Error("entries must be an array.");
|
|
3919
|
+
this.engine.setToc(r.entries, typeof r.show == "boolean" ? r.show : void 0), h = this.getState();
|
|
3920
|
+
break;
|
|
3921
|
+
case "getState":
|
|
3922
|
+
h = this.getState();
|
|
3923
|
+
break;
|
|
3924
|
+
default:
|
|
3925
|
+
throw new Error(`Unknown embed command: ${s.command}`);
|
|
3926
|
+
}
|
|
3927
|
+
this.respond(a, h);
|
|
3928
|
+
} catch (r) {
|
|
3929
|
+
this.respond(a, void 0, r);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
getState() {
|
|
3933
|
+
return {
|
|
3934
|
+
currentPage: this.engine.getCurrentPage(),
|
|
3935
|
+
totalPages: this.engine.getTotalPages(),
|
|
3936
|
+
zoom: this.engine.getZoom()
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
function ys(t, e = {}) {
|
|
3941
|
+
const i = J(), s = e.targetOrigin ?? (i == null ? void 0 : i.location.origin) ?? "*", a = e.responseTimeout ?? 5e3, r = /* @__PURE__ */ new Map(), h = {};
|
|
3942
|
+
let c = 0;
|
|
3943
|
+
const g = (m) => s === "*" || m === s, v = (m) => {
|
|
3944
|
+
var b;
|
|
3945
|
+
if (m.source !== t.contentWindow || !g(m.origin)) return;
|
|
3946
|
+
const w = Xe(m.data);
|
|
3947
|
+
if (w.type === Vt && typeof w.requestId == "string") {
|
|
3948
|
+
const P = r.get(w.requestId);
|
|
3949
|
+
if (!P) return;
|
|
3950
|
+
r.delete(w.requestId), clearTimeout(P.timer), w.ok ? P.resolve(w.result) : P.reject(new Error(typeof w.error == "string" ? w.error : "Embed command failed."));
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
w.type === Ut && typeof w.event == "string" && ((b = h[w.event]) == null || b.forEach((P) => P(w.payload)));
|
|
3954
|
+
};
|
|
3955
|
+
i == null || i.addEventListener("message", v);
|
|
3956
|
+
const y = (m, w) => {
|
|
3957
|
+
const b = `flipbook-${++c}`;
|
|
3958
|
+
return new Promise((P, E) => {
|
|
3959
|
+
if (!t.contentWindow) {
|
|
3960
|
+
E(new Error("The embed iframe is not ready."));
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
const I = setTimeout(() => {
|
|
3964
|
+
r.delete(b), E(new Error(`Embed command timed out: ${m}`));
|
|
3965
|
+
}, a);
|
|
3966
|
+
r.set(b, { resolve: P, reject: E, timer: I }), t.contentWindow.postMessage({ type: Gt, command: m, payload: w, requestId: b }, s);
|
|
3967
|
+
});
|
|
3968
|
+
};
|
|
3969
|
+
return {
|
|
3970
|
+
send: y,
|
|
3971
|
+
goToPage: (m) => y("goToPage", { pageIndex: m }),
|
|
3972
|
+
nextPage: () => y("nextPage"),
|
|
3973
|
+
prevPage: () => y("prevPage"),
|
|
3974
|
+
setZoom: (m) => y("setZoom", { zoom: m }),
|
|
3975
|
+
setSingleMode: (m) => y("setSingleMode", { isSingle: m }),
|
|
3976
|
+
updateOptions: (m) => y("updateOptions", { options: m }),
|
|
3977
|
+
toggleFullscreen: () => y("toggleFullscreen"),
|
|
3978
|
+
search: (m, w) => y("search", { query: m, options: w }),
|
|
3979
|
+
clearSearch: () => y("clearSearch"),
|
|
3980
|
+
getSearchResults: () => y("getSearchResults"),
|
|
3981
|
+
getToc: () => y("getToc"),
|
|
3982
|
+
setToc: (m, w) => y("setToc", { entries: m, show: w }),
|
|
3983
|
+
getState: () => y("getState"),
|
|
3984
|
+
on: (m, w) => {
|
|
3985
|
+
const b = h[m] ?? /* @__PURE__ */ new Set();
|
|
3986
|
+
return b.add(w), h[m] = b, () => b.delete(w);
|
|
3987
|
+
},
|
|
3988
|
+
destroy: () => {
|
|
3989
|
+
i == null || i.removeEventListener("message", v), r.forEach((m) => {
|
|
3990
|
+
clearTimeout(m.timer), m.reject(new Error("Embed controller destroyed."));
|
|
3991
|
+
}), r.clear(), Object.keys(h).forEach((m) => delete h[m]);
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
}
|
|
3995
|
+
const we = class we {
|
|
3996
|
+
constructor(e, i = {}) {
|
|
3997
|
+
C(this, "searchSequence", 0);
|
|
3998
|
+
C(this, "textLayerStop", null);
|
|
3999
|
+
C(this, "container", null);
|
|
4000
|
+
C(this, "options");
|
|
4001
|
+
C(this, "store", _t());
|
|
4002
|
+
// Core Managers
|
|
4003
|
+
C(this, "pageFlipAdapter", null);
|
|
4004
|
+
C(this, "layoutManager", null);
|
|
4005
|
+
C(this, "interactionManager", null);
|
|
4006
|
+
C(this, "pdfRenderer", null);
|
|
4007
|
+
C(this, "listeners", {});
|
|
4008
|
+
C(this, "initializationTimer", null);
|
|
4009
|
+
C(this, "initGeneration", 0);
|
|
4010
|
+
C(this, "initAbortController", null);
|
|
4011
|
+
C(this, "eventsReady", !1);
|
|
4012
|
+
C(this, "lastEventState", { currentPage: 0, zoom: 1, zoomActive: !1, showThumbs: !1, showToc: !1, isSingle: !1, orientation: "" });
|
|
4013
|
+
C(this, "eventSyncStop", null);
|
|
4014
|
+
C(this, "qualityObserver", null);
|
|
4015
|
+
C(this, "pdfLazyStop", null);
|
|
4016
|
+
C(this, "hasActiveSession", !1);
|
|
4017
|
+
C(this, "pdfPageRequests", /* @__PURE__ */ new Map());
|
|
4018
|
+
C(this, "pdfRenderedPages", /* @__PURE__ */ new Set());
|
|
4019
|
+
C(this, "pdfRenderedSources", /* @__PURE__ */ new Map());
|
|
4020
|
+
C(this, "pdfSourcePageCount", 0);
|
|
4021
|
+
C(this, "deepLinkListener", null);
|
|
4022
|
+
C(this, "pluginRegistry", new ei());
|
|
4023
|
+
this.selector = e, this.options = {
|
|
4024
|
+
allowDownload: !0,
|
|
4025
|
+
showThumbs: !1,
|
|
4026
|
+
primaryColor: "#7367f0",
|
|
4027
|
+
theme: "auto",
|
|
4028
|
+
soundUrl: "https://flipbookengine.com/Content/page-flip.mp3",
|
|
4029
|
+
autoPlayInterval: 3e3,
|
|
4030
|
+
pdfRenderScale: 1.5,
|
|
4031
|
+
pdfRenderQuality: 0.85,
|
|
4032
|
+
pdfRenderFormat: "image/webp",
|
|
4033
|
+
pdfRenderConcurrency: 3,
|
|
4034
|
+
pdfRenderCacheSize: 32,
|
|
4035
|
+
pdfPageMode: "auto",
|
|
4036
|
+
deepLink: !1,
|
|
4037
|
+
...i
|
|
4038
|
+
}, this.setupEventSync(), (i.plugins ?? []).forEach((s) => this.installPlugin(s));
|
|
4039
|
+
}
|
|
4040
|
+
async init(e, i) {
|
|
4041
|
+
if (typeof this.selector == "string" ? this.container = document.querySelector(this.selector) : this.container = this.selector, !this.container) return;
|
|
4042
|
+
this.eventsReady = !1, this.destroy(!0), this.setupDeepLinkListener();
|
|
4043
|
+
const s = this.initGeneration, a = new AbortController();
|
|
4044
|
+
this.initAbortController = a;
|
|
4045
|
+
let r = [], h = { ...we.DEFAULT_PAGE_VIEWPORT };
|
|
4046
|
+
if (i && i.length > 0) {
|
|
4047
|
+
if (a.signal.aborted) return;
|
|
4048
|
+
const w = i.filter(rs);
|
|
4049
|
+
r = cs(w);
|
|
4050
|
+
const b = r[0];
|
|
4051
|
+
if (b) {
|
|
4052
|
+
const P = await this.loadImageSize(b.low || b.normal);
|
|
4053
|
+
if (P) {
|
|
4054
|
+
const I = (b.cropMode !== "full" ? P.width / 2 : P.width) / P.height, F = 420;
|
|
4055
|
+
h = I >= 1 ? { width: Math.round(F * I), height: F } : { width: F, height: Math.round(F / I) };
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
} else if (e) {
|
|
4059
|
+
if (a.signal.aborted) return;
|
|
4060
|
+
let w = "load";
|
|
4061
|
+
try {
|
|
4062
|
+
this.pdfRenderer = new fs({
|
|
4063
|
+
scale: this.options.pdfRenderScale,
|
|
4064
|
+
quality: this.options.pdfRenderQuality,
|
|
4065
|
+
format: this.options.pdfRenderFormat,
|
|
4066
|
+
concurrency: this.options.pdfRenderConcurrency,
|
|
4067
|
+
cacheSize: this.options.pdfRenderCacheSize,
|
|
4068
|
+
workerSrc: this.options.pdfWorkerSrc
|
|
4069
|
+
}), this.emit("progress", { phase: "loading", completed: 0, total: 0 });
|
|
4070
|
+
const b = await this.pdfRenderer.loadDocument(e, a.signal);
|
|
4071
|
+
w = "render", this.emit("progress", { phase: "loading", completed: 1, total: b });
|
|
4072
|
+
const P = await this.pdfRenderer.getPageLayouts(this.options.pdfPageMode);
|
|
4073
|
+
h = P.length ? await this.pdfRenderer.calculateViewportDimensions(420, P[0]) : await this.pdfRenderer.calculateViewportDimensions(), r = P.length ? this.createPdfPlaceholders(P) : Array.from({ length: b }, (E, I) => this.createPdfPlaceholder(I + 1)), this.pdfSourcePageCount = b;
|
|
4074
|
+
} catch (b) {
|
|
4075
|
+
a.signal.aborted || (console.error("PDF load failed:", b), this.emit("error", {
|
|
4076
|
+
code: w === "load" ? "PDF_LOAD_FAILED" : "PDF_RENDER_FAILED",
|
|
4077
|
+
message: b instanceof Error ? b.message : "Unable to load PDF.",
|
|
4078
|
+
cause: b
|
|
4079
|
+
}));
|
|
4080
|
+
return;
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
if (a.signal.aborted || s !== this.initGeneration || !r.length) return;
|
|
4084
|
+
this.store.init(this.options, r.length, r, !!e, !(i != null && i.length) && !!e), this.applyInitialDeepLink(), this.options.textLayerProvider && (this.textLayerStop = ii(this.store, this.options.textLayerProvider, a.signal)), kt(this.container, this.options), this.container.innerHTML = "";
|
|
4085
|
+
let c, g, v;
|
|
4086
|
+
const y = { current: null }, S = { current: null }, m = Ji({
|
|
4087
|
+
pageFlipAdapterRef: y,
|
|
4088
|
+
interactionManagerRef: S,
|
|
4089
|
+
bookWrapperRef: (w) => c = w,
|
|
4090
|
+
bookSizerRef: (w) => g = w,
|
|
4091
|
+
bookContainerRef: (w) => v = w,
|
|
4092
|
+
className: this.options.className,
|
|
4093
|
+
store: this.store,
|
|
4094
|
+
pluginRegistry: this.pluginRegistry,
|
|
4095
|
+
signal: a.signal,
|
|
4096
|
+
onToggleFullscreen: () => this.toggleFullscreen(),
|
|
4097
|
+
onDownload: () => {
|
|
4098
|
+
e && (this.options.onDownload ? this.options.onDownload(e) : window.open(e, "_blank"));
|
|
4099
|
+
},
|
|
4100
|
+
onShare: () => {
|
|
4101
|
+
this.sharePage().then((w) => {
|
|
4102
|
+
var b, P;
|
|
4103
|
+
return (P = (b = this.options).onShare) == null ? void 0 : P.call(b, w);
|
|
4104
|
+
}).catch((w) => {
|
|
4105
|
+
console.warn("Share err:", w);
|
|
4106
|
+
});
|
|
4107
|
+
},
|
|
4108
|
+
onToggleBookmark: () => this.toggleBookmark(),
|
|
4109
|
+
onToggleNotes: () => {
|
|
4110
|
+
this.store.showNotes.value || (this.store.notesView.value = this.store.pageNotes.value.size || this.store.annotations.value.length ? "all" : "page"), this.store.showNotes.value = !this.store.showNotes.value;
|
|
4111
|
+
},
|
|
4112
|
+
onSelectNote: (w) => {
|
|
4113
|
+
this.goToPage(w), this.store.notesView.value = "page";
|
|
4114
|
+
},
|
|
4115
|
+
onBeginAnnotation: () => this.beginAnnotation(),
|
|
4116
|
+
onPlaceAnnotation: (w, b, P) => this.placeAnnotation(w, b, P),
|
|
4117
|
+
onSaveAnnotation: (w) => this.saveAnnotation(w),
|
|
4118
|
+
onDeleteAnnotation: (w) => this.saveAnnotation(w, "delete"),
|
|
4119
|
+
onSaveNote: (w, b) => this.saveNote(this.getCurrentPage(), w, b),
|
|
4120
|
+
onClearNote: () => this.saveNote(this.getCurrentPage(), null),
|
|
4121
|
+
onCloseNotes: () => {
|
|
4122
|
+
this.store.showNotes.value = !1;
|
|
4123
|
+
},
|
|
4124
|
+
onSearch: (w, b) => {
|
|
4125
|
+
this.search(w, b).catch(() => {
|
|
4126
|
+
});
|
|
4127
|
+
},
|
|
4128
|
+
onClearSearch: () => this.clearSearch(),
|
|
4129
|
+
onCloseSearch: () => {
|
|
4130
|
+
this.store.showSearch.value = !1;
|
|
4131
|
+
},
|
|
4132
|
+
onSelectSearchResult: (w) => {
|
|
4133
|
+
this.goToPage(w), this.store.showSearch.value = !1;
|
|
4134
|
+
},
|
|
4135
|
+
onHotspotActivate: (w) => this.activateHotspot(w.id),
|
|
4136
|
+
onHotspotClose: () => this.closeHotspot(),
|
|
4137
|
+
onAnnotationActivate: (w) => this.activateAnnotation(w.id),
|
|
4138
|
+
onAnnotationClose: () => this.closeAnnotation()
|
|
4139
|
+
});
|
|
4140
|
+
this.container.appendChild(m), this.setupQualityLoading(), this.layoutManager = new as(h, this.store), this.layoutManager.onResizeCallback = () => {
|
|
4141
|
+
this.pageFlipAdapter && this.pageFlipAdapter.update();
|
|
4142
|
+
}, this.layoutManager.init(c, g), this.pageFlipAdapter = new ns(v, this.options, this.store), y.current = this.pageFlipAdapter, await new Promise((w) => {
|
|
4143
|
+
const b = () => {
|
|
4144
|
+
a.signal.removeEventListener("abort", b), w();
|
|
4145
|
+
};
|
|
4146
|
+
a.signal.addEventListener("abort", b, { once: !0 }), this.initializationTimer = setTimeout(async () => {
|
|
4147
|
+
if (this.initializationTimer = null, a.signal.removeEventListener("abort", b), a.signal.aborted || s !== this.initGeneration || !this.pageFlipAdapter) {
|
|
4148
|
+
w();
|
|
4149
|
+
return;
|
|
4150
|
+
}
|
|
4151
|
+
if (this.pageFlipAdapter.init(h.width, h.height), this.interactionManager = new os(c, this.pageFlipAdapter, this.store), this.interactionManager.init(), S.current = this.interactionManager, this.setupPdfLazyLoading(), this.pdfRenderer && e)
|
|
4152
|
+
try {
|
|
4153
|
+
await this.renderPdfPage(1, a.signal);
|
|
4154
|
+
} catch {
|
|
4155
|
+
w();
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
if (a.signal.aborted || s !== this.initGeneration) {
|
|
4159
|
+
w();
|
|
4160
|
+
return;
|
|
4161
|
+
}
|
|
4162
|
+
this.eventsReady = !0, this.captureEventState(), this.hasActiveSession = !0, this.emit("init", { totalPages: r.length }), w();
|
|
4163
|
+
}, 10);
|
|
4164
|
+
}), this.initAbortController === a && (this.initAbortController = null);
|
|
4165
|
+
}
|
|
4166
|
+
createPdfPlaceholder(e) {
|
|
4167
|
+
const i = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
|
|
4168
|
+
return { index: e - 1, assetId: "pdf-page-" + e + "-full", pageNumber: e, sourcePageNumber: e, cropMode: "full", normal: i, low: i, thumb: i };
|
|
4169
|
+
}
|
|
4170
|
+
createPdfPlaceholders(e) {
|
|
4171
|
+
const i = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=", s = [];
|
|
4172
|
+
return e.forEach((a, r) => {
|
|
4173
|
+
const h = r + 1;
|
|
4174
|
+
(a.split ? ["left", "right"] : ["full"]).forEach((g) => {
|
|
4175
|
+
const v = s.length + 1;
|
|
4176
|
+
s.push({
|
|
4177
|
+
index: s.length,
|
|
4178
|
+
assetId: `pdf-page-${h}-${g}`,
|
|
4179
|
+
pageNumber: v,
|
|
4180
|
+
sourcePageNumber: h,
|
|
4181
|
+
cropMode: g,
|
|
4182
|
+
normal: i,
|
|
4183
|
+
low: i,
|
|
4184
|
+
thumb: i
|
|
4185
|
+
});
|
|
4186
|
+
});
|
|
4187
|
+
}), s;
|
|
4188
|
+
}
|
|
4189
|
+
renderPdfPage(e, i) {
|
|
4190
|
+
const s = this.pdfRenderer, a = this.initGeneration;
|
|
4191
|
+
if (!s) return Promise.resolve("");
|
|
4192
|
+
const r = this.pdfPageRequests.get(e);
|
|
4193
|
+
if (r) return r;
|
|
4194
|
+
if (this.pdfRenderedPages.has(e)) {
|
|
4195
|
+
const c = this.pdfRenderedSources.get(e);
|
|
4196
|
+
c && this.hydratePdfImages(e, c);
|
|
4197
|
+
const g = this.store.pages.value;
|
|
4198
|
+
if (c)
|
|
4199
|
+
for (const v of g)
|
|
4200
|
+
(v.sourcePageNumber ?? v.pageNumber) === e && (v.normal = c, v.low = c, v.thumb = c);
|
|
4201
|
+
return Promise.resolve(c || "");
|
|
4202
|
+
}
|
|
4203
|
+
const h = s.renderPageToDataUrl(e, i).then((c) => {
|
|
4204
|
+
if (a !== this.initGeneration || i != null && i.aborted) throw this.createAbortError();
|
|
4205
|
+
if (!c) throw new Error("PDF page " + e + " produced no image.");
|
|
4206
|
+
return this.pdfRenderedPages.add(e), this.pdfRenderedSources.set(e, c), this.hydratePdfImages(e, c), this.emit("progress", {
|
|
4207
|
+
phase: "rendering",
|
|
4208
|
+
completed: this.pdfRenderedPages.size,
|
|
4209
|
+
total: this.pdfSourcePageCount || this.store.totalPages.value
|
|
4210
|
+
}), c;
|
|
4211
|
+
}).catch((c) => {
|
|
4212
|
+
throw a !== this.initGeneration && (c == null ? void 0 : c.name) !== "AbortError" ? this.createAbortError() : ((c == null ? void 0 : c.name) === "AbortError" || this.emit("error", {
|
|
4213
|
+
code: "PDF_RENDER_FAILED",
|
|
4214
|
+
message: c instanceof Error ? c.message : "Unable to render PDF page.",
|
|
4215
|
+
cause: c
|
|
4216
|
+
}), c);
|
|
4217
|
+
}).finally(() => {
|
|
4218
|
+
this.pdfPageRequests.get(e) === h && this.pdfPageRequests.delete(e);
|
|
4219
|
+
});
|
|
4220
|
+
return this.pdfPageRequests.set(e, h), h;
|
|
4221
|
+
}
|
|
4222
|
+
hydratePdfImages(e, i) {
|
|
4223
|
+
var s;
|
|
4224
|
+
(s = this.container) == null || s.querySelectorAll("img").forEach((a) => {
|
|
4225
|
+
a.dataset.pdfPage === String(e) && (a.src = i, delete a.dataset.pdfPage);
|
|
4226
|
+
});
|
|
4227
|
+
}
|
|
4228
|
+
setupPdfLazyLoading() {
|
|
4229
|
+
var e;
|
|
4230
|
+
(e = this.pdfLazyStop) == null || e.call(this), this.pdfLazyStop = null, this.pdfRenderer && (this.pdfLazyStop = G(() => {
|
|
4231
|
+
const i = this.store.currentPage.value, s = this.store.pages.value, r = this.store.isSingleMode.value ? [i - 1, i, i + 1] : [i - 1, i, i + 1, i % 2 === 1 ? i + 2 : i + 1], h = /* @__PURE__ */ new Set();
|
|
4232
|
+
for (const c of r)
|
|
4233
|
+
if (c >= 0 && c < s.length) {
|
|
4234
|
+
const g = s[c], v = (g == null ? void 0 : g.sourcePageNumber) ?? (g == null ? void 0 : g.pageNumber);
|
|
4235
|
+
v && h.add(v);
|
|
4236
|
+
}
|
|
4237
|
+
h.forEach((c) => {
|
|
4238
|
+
c && this.renderPdfPage(c).catch(() => {
|
|
4239
|
+
});
|
|
4240
|
+
});
|
|
4241
|
+
}));
|
|
4242
|
+
}
|
|
4243
|
+
loadImageSize(e) {
|
|
4244
|
+
return new Promise((i) => {
|
|
4245
|
+
const s = new Image();
|
|
4246
|
+
s.onload = () => i({ width: s.naturalWidth || s.width, height: s.naturalHeight || s.height }), s.onerror = () => i(null), s.src = e;
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
goToPage(e) {
|
|
4250
|
+
const i = Math.max(0, this.store.totalPages.value - 1);
|
|
4251
|
+
this.store.currentPage.value = Math.max(0, Math.min(i, Math.trunc(e)));
|
|
4252
|
+
}
|
|
4253
|
+
getTotalPages() {
|
|
4254
|
+
return this.store.totalPages.value;
|
|
4255
|
+
}
|
|
4256
|
+
getCurrentPage() {
|
|
4257
|
+
return this.store.currentPage.value;
|
|
4258
|
+
}
|
|
4259
|
+
/** Returns the normalized host-provided table of contents. */
|
|
4260
|
+
getToc() {
|
|
4261
|
+
const e = (i) => ({
|
|
4262
|
+
...i,
|
|
4263
|
+
...i.children ? { children: i.children.map(e) } : {}
|
|
4264
|
+
});
|
|
4265
|
+
return this.store.toc.value.map(e);
|
|
4266
|
+
}
|
|
4267
|
+
/** Replaces the table of contents and optionally opens its panel. */
|
|
4268
|
+
setToc(e, i = this.store.showToc.value) {
|
|
4269
|
+
this.store.toc.value = je(e, this.store.totalPages.value), this.store.showToc.value = !!i && this.store.toc.value.length > 0;
|
|
4270
|
+
}
|
|
4271
|
+
/** Installs a plugin. Plugins installed after init are available to the next render. */
|
|
4272
|
+
installPlugin(e) {
|
|
4273
|
+
return this.pluginRegistry.install(this, e), this;
|
|
4274
|
+
}
|
|
4275
|
+
/** Removes an installed plugin and all of its registered contributions. */
|
|
4276
|
+
uninstallPlugin(e) {
|
|
4277
|
+
return this.pluginRegistry.uninstall(e);
|
|
4278
|
+
}
|
|
4279
|
+
/** Returns the names of installed plugins. */
|
|
4280
|
+
getPluginNames() {
|
|
4281
|
+
return this.pluginRegistry.getPluginNames();
|
|
4282
|
+
}
|
|
4283
|
+
/** Calls a namespaced API registered by a plugin. */
|
|
4284
|
+
callPluginApi(e, i, ...s) {
|
|
4285
|
+
return this.pluginRegistry.callApi(e, i, ...s);
|
|
4286
|
+
}
|
|
4287
|
+
/** Internal UI registry used by the built-in DOM renderer. */
|
|
4288
|
+
getPluginRegistry() {
|
|
4289
|
+
return this.pluginRegistry;
|
|
4290
|
+
}
|
|
4291
|
+
/** Returns the zero-based page indexes currently marked as bookmarks. */
|
|
4292
|
+
getBookmarkedPages() {
|
|
4293
|
+
return Array.from(this.store.bookmarkedPages.value).sort((e, i) => e - i);
|
|
4294
|
+
}
|
|
4295
|
+
/** Returns whether a zero-based page index is bookmarked. */
|
|
4296
|
+
isBookmarked(e = this.getCurrentPage()) {
|
|
4297
|
+
return this.store.bookmarkedPages.value.has(Math.trunc(e));
|
|
4298
|
+
}
|
|
4299
|
+
/** Sets the bookmark state for a zero-based page index and emits bookmarkChange when it changes. */
|
|
4300
|
+
setBookmark(e, i = !0) {
|
|
4301
|
+
if (this.store.totalPages.value === 0 || !Number.isFinite(e)) return;
|
|
4302
|
+
const s = Math.max(0, Math.min(this.store.totalPages.value - 1, Math.trunc(e))), a = this.store.bookmarkedPages.value;
|
|
4303
|
+
if (a.has(s) === i) return;
|
|
4304
|
+
const r = new Set(a);
|
|
4305
|
+
i ? r.add(s) : r.delete(s), this.store.bookmarkedPages.value = r, this.emit("bookmarkChange", { pageIndex: s, pageNumber: s + 1, bookmarked: i });
|
|
4306
|
+
}
|
|
4307
|
+
/** Toggles the bookmark state for a zero-based page index. */
|
|
4308
|
+
toggleBookmark(e = this.getCurrentPage()) {
|
|
4309
|
+
this.setBookmark(e, !this.isBookmarked(e));
|
|
4310
|
+
}
|
|
4311
|
+
/** Returns all non-empty host-managed notes keyed by zero-based page index. */
|
|
4312
|
+
getNotes() {
|
|
4313
|
+
return Object.fromEntries(this.store.pageNotes.value);
|
|
4314
|
+
}
|
|
4315
|
+
/** Returns the note for a zero-based page index, if one exists. */
|
|
4316
|
+
getNote(e = this.getCurrentPage()) {
|
|
4317
|
+
return this.store.pageNotes.value.get(Math.trunc(e));
|
|
4318
|
+
}
|
|
4319
|
+
/** Sets or clears a host-managed note and emits noteChange when it changes. */
|
|
4320
|
+
setNote(e, i) {
|
|
4321
|
+
if (this.store.totalPages.value === 0 || !Number.isFinite(e)) return;
|
|
4322
|
+
const s = Math.max(0, Math.min(this.store.totalPages.value - 1, Math.trunc(e))), a = String(i ?? "").trim();
|
|
4323
|
+
if (this.store.pageNotes.value.get(s) === (a || void 0)) return;
|
|
4324
|
+
const h = new Map(this.store.pageNotes.value);
|
|
4325
|
+
a ? h.set(s, a) : h.delete(s), this.store.pageNotes.value = h, this.emit("noteChange", { pageIndex: s, pageNumber: s + 1, note: a || null });
|
|
4326
|
+
}
|
|
4327
|
+
/** Clears the host-managed note for a zero-based page index. */
|
|
4328
|
+
clearNote(e = this.getCurrentPage()) {
|
|
4329
|
+
this.setNote(e, "");
|
|
4330
|
+
}
|
|
4331
|
+
/** Searches the loaded PDF text without rendering pages and updates result highlights. */
|
|
4332
|
+
async search(e, i = {}) {
|
|
4333
|
+
var g;
|
|
4334
|
+
const s = ++this.searchSequence, a = String(e ?? "").trim();
|
|
4335
|
+
if (this.store.searchBusy.value = !1, this.store.searchFailed.value = !1, this.options.searchProvider && a) {
|
|
4336
|
+
this.store.searchQuery.value = a, this.store.searchResults.value = [], this.store.searchBusy.value = !0;
|
|
4337
|
+
const v = ((g = this.initAbortController) == null ? void 0 : g.signal) ?? new AbortController().signal;
|
|
4338
|
+
try {
|
|
4339
|
+
const y = await this.options.searchProvider(a, i, v);
|
|
4340
|
+
if (v.aborted || s !== this.searchSequence) return [];
|
|
4341
|
+
const S = Number.isFinite(i.maxResults) ? Math.max(1, Math.trunc(i.maxResults)) : 100;
|
|
4342
|
+
return this.store.searchResults.value = y.filter((m) => Number.isInteger(m.pageIndex) && m.pageIndex >= 0 && m.pageIndex < this.store.totalPages.value).slice(0, S), this.emit("searchChange", { query: a, results: this.store.searchResults.value }), this.store.searchResults.value;
|
|
4343
|
+
} catch (y) {
|
|
4344
|
+
throw !v.aborted && s === this.searchSequence && (this.store.searchFailed.value = !0), y;
|
|
4345
|
+
} finally {
|
|
4346
|
+
s === this.searchSequence && (this.store.searchBusy.value = !1);
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
if (!a || !this.pdfRenderer || !this.store.isPdfMode.value)
|
|
4350
|
+
return this.store.searchQuery.value = a, this.store.searchResults.value = [], this.emit("searchChange", { query: a, results: [] }), [];
|
|
4351
|
+
const r = await this.pdfRenderer.searchText(a, i);
|
|
4352
|
+
if (s !== this.searchSequence) return [];
|
|
4353
|
+
const h = [];
|
|
4354
|
+
r.forEach((v) => {
|
|
4355
|
+
this.store.pages.value.forEach((y) => {
|
|
4356
|
+
var m;
|
|
4357
|
+
if ((y.sourcePageNumber ?? y.pageNumber) !== v.sourcePageNumber) return;
|
|
4358
|
+
const S = this.mapSearchHighlights(v.highlights, y.cropMode);
|
|
4359
|
+
(m = v.highlights) != null && m.length && !S.length || h.push({ pageIndex: y.index, pageNumber: y.pageNumber, sourcePageNumber: v.sourcePageNumber, matches: v.matches, snippet: v.snippet, ...v.highlights ? { highlights: S } : {} });
|
|
4360
|
+
});
|
|
4361
|
+
});
|
|
4362
|
+
const c = Number.isFinite(i.maxResults) ? Math.max(1, Math.trunc(i.maxResults)) : 100;
|
|
4363
|
+
return this.store.searchQuery.value = a, this.store.searchResults.value = h.slice(0, c), this.emit("searchChange", { query: a, results: this.store.searchResults.value }), this.store.searchResults.value;
|
|
4364
|
+
}
|
|
4365
|
+
mapSearchHighlights(e, i) {
|
|
4366
|
+
if (!(e != null && e.length) || i === "full") return e ?? [];
|
|
4367
|
+
const s = i === "right" ? 0.5 : 0;
|
|
4368
|
+
return e.flatMap((a) => {
|
|
4369
|
+
const r = Math.max(s, a.x), h = Math.min(s + 0.5, a.x + a.width);
|
|
4370
|
+
return h <= r ? [] : [{
|
|
4371
|
+
x: Math.max(0, Math.min(1, (r - s) * 2)),
|
|
4372
|
+
y: Math.max(0, Math.min(1, a.y)),
|
|
4373
|
+
width: Math.max(0, Math.min(1, (h - r) * 2)),
|
|
4374
|
+
height: Math.max(0, Math.min(1, a.height))
|
|
4375
|
+
}];
|
|
4376
|
+
});
|
|
4377
|
+
}
|
|
4378
|
+
/** Clears the current client-side search. */
|
|
4379
|
+
clearSearch() {
|
|
4380
|
+
this.searchSequence++, this.store.searchBusy.value = !1, this.store.searchFailed.value = !1, this.store.searchQuery.value = "", this.store.searchResults.value = [], this.emit("searchChange", { query: "", results: [] });
|
|
4381
|
+
}
|
|
4382
|
+
getSearchResults() {
|
|
4383
|
+
return this.store.searchResults.value.slice();
|
|
4384
|
+
}
|
|
4385
|
+
/** The native editor commits locally only after host persistence succeeds. */
|
|
4386
|
+
async saveNote(e, i, s) {
|
|
4387
|
+
var h, c, g;
|
|
4388
|
+
if (this.store.notesSaving.value || !Number.isInteger(e) || e < 0 || e >= this.store.totalPages.value) return !1;
|
|
4389
|
+
const a = ((h = this.initAbortController) == null ? void 0 : h.signal) ?? new AbortController().signal, r = (i == null ? void 0 : i.trim()) || null;
|
|
4390
|
+
this.store.notesSaving.value = !0, this.store.notesFailed.value = !1;
|
|
4391
|
+
try {
|
|
4392
|
+
if (await ((g = (c = this.options).noteProvider) == null ? void 0 : g.call(c, e, r, a, s)), a.aborted) return !1;
|
|
4393
|
+
this.setNote(e, r ?? "");
|
|
4394
|
+
const v = new Map(this.store.pageNoteDocuments.value);
|
|
4395
|
+
return s && r ? v.set(e, s) : v.delete(e), this.store.pageNoteDocuments.value = v, !0;
|
|
4396
|
+
} catch {
|
|
4397
|
+
return a.aborted || (this.store.notesFailed.value = !0), !1;
|
|
4398
|
+
} finally {
|
|
4399
|
+
this.store.notesSaving.value = !1;
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
getHotspots(e = this.getCurrentPage()) {
|
|
4403
|
+
return this.store.hotspots.value.filter((i) => i.pageIndex === e);
|
|
4404
|
+
}
|
|
4405
|
+
activateHotspot(e) {
|
|
4406
|
+
const i = this.store.hotspots.value.find((s) => s.id === e);
|
|
4407
|
+
i && (this.store.activeHotspotId.value = i.id, this.emit("hotspotActivate", { hotspot: i, pageIndex: i.pageIndex }));
|
|
4408
|
+
}
|
|
4409
|
+
closeHotspot() {
|
|
4410
|
+
this.store.activeHotspotId.value = null;
|
|
4411
|
+
}
|
|
4412
|
+
getAnnotations(e = this.getCurrentPage()) {
|
|
4413
|
+
return this.store.annotations.value.filter((i) => i.pageIndex === e);
|
|
4414
|
+
}
|
|
4415
|
+
activateAnnotation(e) {
|
|
4416
|
+
const i = this.store.annotations.value.find((s) => s.id === e);
|
|
4417
|
+
i && (this.goToPage(i.pageIndex), this.store.showNotes.value = !1, this.store.showToc.value = !1, this.store.showSearch.value = !1, this.store.activeAnnotationId.value = i.id, this.emit("annotationActivate", { annotation: i, pageIndex: i.pageIndex }));
|
|
4418
|
+
}
|
|
4419
|
+
closeAnnotation() {
|
|
4420
|
+
this.store.activeAnnotationId.value = null, this.store.pendingAnnotation.value = null;
|
|
4421
|
+
}
|
|
4422
|
+
beginAnnotation() {
|
|
4423
|
+
this.store.canAnnotate.value && (this.closeAnnotation(), this.store.showNotes.value = !1, this.store.showToc.value = !1, this.store.showSearch.value = !1, this.store.textSelection.value = !1, this.store.placingNote.value = !0, queueMicrotask(() => {
|
|
4424
|
+
var e, i;
|
|
4425
|
+
this.store.placingNote.value && ((i = [...((e = this.container) == null ? void 0 : e.querySelectorAll(".bk-note-placement-layer")) ?? []].find((s) => s.getBoundingClientRect().width > 0)) == null || i.focus());
|
|
4426
|
+
}));
|
|
4427
|
+
}
|
|
4428
|
+
placeAnnotation(e, i, s) {
|
|
4429
|
+
!this.store.placingNote.value || !Number.isInteger(e) || e < 0 || e >= this.store.totalPages.value || !Number.isFinite(i) || !Number.isFinite(s) || (this.goToPage(e), this.store.pendingAnnotation.value = { id: crypto.randomUUID(), pageIndex: e, x: Math.max(0, Math.min(1, i)), y: Math.max(0, Math.min(1, s)), text: "" }, this.store.placingNote.value = !1);
|
|
4430
|
+
}
|
|
4431
|
+
async saveAnnotation(e, i = "save") {
|
|
4432
|
+
var r;
|
|
4433
|
+
if (!this.options.annotationProvider || this.store.notesSaving.value || !e.id || !Number.isInteger(e.pageIndex) || e.pageIndex < 0 || e.pageIndex >= this.store.totalPages.value || !Number.isFinite(e.x) || !Number.isFinite(e.y) || e.x < 0 || e.x > 1 || e.y < 0 || e.y > 1 || i === "save" && (!e.text.trim() || e.text.length > 4e3)) return !1;
|
|
4434
|
+
const s = ((r = this.initAbortController) == null ? void 0 : r.signal) ?? new AbortController().signal, a = { ...e, text: e.text.trim() };
|
|
4435
|
+
this.store.notesSaving.value = !0, this.store.notesFailed.value = !1;
|
|
4436
|
+
try {
|
|
4437
|
+
if (await this.options.annotationProvider(a, i, s), s.aborted) return !1;
|
|
4438
|
+
const h = this.store.annotations.value.filter((c) => c.id !== a.id);
|
|
4439
|
+
return this.store.annotations.value = i === "delete" ? h : [...h, a], this.store.pendingAnnotation.value = null, this.store.activeAnnotationId.value = i === "delete" ? null : a.id, this.emit("annotationChange", { annotation: a, action: i }), !0;
|
|
4440
|
+
} catch {
|
|
4441
|
+
return s.aborted || (this.store.notesFailed.value = !0), !1;
|
|
4442
|
+
} finally {
|
|
4443
|
+
s.aborted || (this.store.notesSaving.value = !1);
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
getZoom() {
|
|
4447
|
+
return this.store.zoomState.value.scale;
|
|
4448
|
+
}
|
|
4449
|
+
setZoom(e) {
|
|
4450
|
+
const i = Number.isFinite(e) ? e : 1, s = Math.max(0.5, Math.min(5, i));
|
|
4451
|
+
this.store.zoomState.value = {
|
|
4452
|
+
...this.store.zoomState.value,
|
|
4453
|
+
scale: s,
|
|
4454
|
+
isActive: s > 1,
|
|
4455
|
+
...s <= 1 ? { translateX: 0, translateY: 0 } : {}
|
|
4456
|
+
}, this.store.isZoomed.value = s > 1;
|
|
4457
|
+
}
|
|
4458
|
+
nextPage() {
|
|
4459
|
+
this.pageFlipAdapter && this.pageFlipAdapter.turnToNextPage();
|
|
4460
|
+
}
|
|
4461
|
+
toggleFullscreen() {
|
|
4462
|
+
var i, s;
|
|
4463
|
+
const e = this.container;
|
|
4464
|
+
e && (document.fullscreenElement ? (s = document.exitFullscreen) == null || s.call(document).catch((a) => console.warn("Exit fullscreen err:", a)) : (i = e.requestFullscreen) == null || i.call(e).catch((a) => console.warn("Fullscreen err:", a)));
|
|
4465
|
+
}
|
|
4466
|
+
setLocale(e, i) {
|
|
4467
|
+
const s = i ? { ...this.options.messages, [e]: i[e] ?? i } : this.options.messages;
|
|
4468
|
+
this.options = { ...this.options, locale: e, messages: s }, this.store.locale.value = e, s && (this.store.messages.value = s);
|
|
4469
|
+
}
|
|
4470
|
+
prevPage() {
|
|
4471
|
+
this.pageFlipAdapter && this.pageFlipAdapter.turnToPrevPage();
|
|
4472
|
+
}
|
|
4473
|
+
setSingleMode(e) {
|
|
4474
|
+
this.options = { ...this.options, singleMode: e, isSingleMode: e }, this.store.isSingleMode.value = e, e && this.pdfRenderer && setTimeout(() => {
|
|
4475
|
+
const i = this.store.pages.value[this.store.currentPage.value], s = (i == null ? void 0 : i.sourcePageNumber) ?? (i == null ? void 0 : i.pageNumber);
|
|
4476
|
+
s && this.renderPdfPage(s).catch(() => {
|
|
4477
|
+
});
|
|
4478
|
+
}, 0);
|
|
4479
|
+
}
|
|
4480
|
+
updateOptions(e) {
|
|
4481
|
+
"annotationProvider" in e && (this.store.canAnnotate.value = !!e.annotationProvider), "searchProvider" in e && (this.store.searchAvailable.value = !!e.searchProvider || this.store.isPdfMode.value);
|
|
4482
|
+
const i = e.deepLink !== void 0 && e.deepLink !== this.options.deepLink;
|
|
4483
|
+
this.options = { ...this.options, ...e }, i && (this.options.deepLink ? this.setupDeepLinkListener() : this.teardownDeepLinkListener()), e.theme !== void 0 && (this.store.themeMode.value = e.theme), e.primaryColor !== void 0 && (this.store.primaryColor.value = e.primaryColor), e.showThumbs !== void 0 && (this.store.showThumbs.value = e.showThumbs), e.showToc !== void 0 && (this.store.showToc.value = e.showToc), e.toc !== void 0 && (this.store.toc.value = je(e.toc, this.store.totalPages.value)), e.showArrows !== void 0 && (this.store.showArrows.value = e.showArrows), e.allowDownload !== void 0 && (this.store.allowDownload.value = e.allowDownload), e.whiteLabel !== void 0 && (this.store.whiteLabel.value = e.whiteLabel), e.soundEnabled !== void 0 && (this.store.soundEnabled.value = e.soundEnabled), e.locale !== void 0 && (this.store.locale.value = e.locale), e.messages !== void 0 && (this.store.messages.value = e.messages), e.singleMode !== void 0 && (this.store.isSingleMode.value = e.singleMode), e.isSingleMode !== void 0 && (this.store.isSingleMode.value = e.isSingleMode), e.autoPlay !== void 0 && (this.store.isAutoPlaying.value = e.autoPlay), e.autoPlayInterval !== void 0 && (this.store.autoPlayInterval.value = e.autoPlayInterval), e.bookmarks !== void 0 && (this.store.bookmarkedPages.value = new Set(e.bookmarks.map((s) => Math.trunc(s)).filter((s) => Number.isInteger(s) && s >= 0 && s < this.store.totalPages.value))), e.notes !== void 0 && (this.store.pageNotes.value = new Map(Object.entries(e.notes).map(([s, a]) => [Math.trunc(Number(s)), String(a).trim()]).filter(([s, a]) => Number.isInteger(s) && s >= 0 && s < this.store.totalPages.value && a.length > 0))), e.hotspots !== void 0 && (this.store.hotspots.value = e.hotspots), e.annotations !== void 0 && (this.store.annotations.value = e.annotations), this.container && kt(this.container, this.options);
|
|
4484
|
+
}
|
|
4485
|
+
setupDeepLinkListener() {
|
|
4486
|
+
this.teardownDeepLinkListener(), !(!this.options.deepLink || typeof window > "u") && (this.deepLinkListener = () => {
|
|
4487
|
+
if (!this.eventsReady || this.store.totalPages.value === 0) return;
|
|
4488
|
+
const e = this.readDeepLinkPage();
|
|
4489
|
+
e !== null && e !== this.store.currentPage.value && this.goToPage(e);
|
|
4490
|
+
}, window.addEventListener("popstate", this.deepLinkListener), window.addEventListener("hashchange", this.deepLinkListener));
|
|
4491
|
+
}
|
|
4492
|
+
teardownDeepLinkListener() {
|
|
4493
|
+
!this.deepLinkListener || typeof window > "u" || (window.removeEventListener("popstate", this.deepLinkListener), window.removeEventListener("hashchange", this.deepLinkListener), this.deepLinkListener = null);
|
|
4494
|
+
}
|
|
4495
|
+
readDeepLinkPage(e = typeof window > "u" ? "" : window.location.href) {
|
|
4496
|
+
var i;
|
|
4497
|
+
if (!e || this.store.totalPages.value === 0) return null;
|
|
4498
|
+
try {
|
|
4499
|
+
const s = new URL(e, typeof document > "u" ? void 0 : document.baseURI), a = (i = s.hash.match(/(?:^#|&)page=(\d+)/i)) == null ? void 0 : i[1], r = s.searchParams.get("page") ?? a;
|
|
4500
|
+
if (r == null) return 0;
|
|
4501
|
+
const h = Number(r);
|
|
4502
|
+
return !Number.isInteger(h) || h < 1 ? null : Math.min(h - 1, this.store.totalPages.value - 1);
|
|
4503
|
+
} catch {
|
|
4504
|
+
return null;
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
applyInitialDeepLink() {
|
|
4508
|
+
if (!this.options.deepLink) return;
|
|
4509
|
+
const e = this.readDeepLinkPage();
|
|
4510
|
+
e !== null && (this.store.currentPage.value = e);
|
|
4511
|
+
}
|
|
4512
|
+
updateDeepLink(e) {
|
|
4513
|
+
if (!this.options.deepLink || typeof window > "u" || this.store.totalPages.value === 0) return;
|
|
4514
|
+
const i = Math.max(0, Math.min(this.store.totalPages.value - 1, Math.trunc(e))), s = i + 1;
|
|
4515
|
+
try {
|
|
4516
|
+
const a = new URL(window.location.href);
|
|
4517
|
+
a.searchParams.set("page", String(s));
|
|
4518
|
+
const r = a.toString();
|
|
4519
|
+
r !== window.location.href && window.history.replaceState(window.history.state, "", r), this.emit("deepLinkChange", { pageIndex: i, pageNumber: s, url: r });
|
|
4520
|
+
} catch {
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
/** Returns a shareable URL addressing a 1-based page number. */
|
|
4524
|
+
getPageUrl(e = this.getCurrentPage()) {
|
|
4525
|
+
if (typeof window > "u") return "";
|
|
4526
|
+
const i = this.getTotalPages(), s = i > 0 ? Math.max(0, Math.min(i - 1, Math.trunc(e))) : Math.max(0, Math.trunc(e)), a = new URL(window.location.href);
|
|
4527
|
+
return a.searchParams.set("page", String(s + 1)), a.toString();
|
|
4528
|
+
}
|
|
4529
|
+
/** Opens the native share dialog or copies a page URL to the clipboard. */
|
|
4530
|
+
async sharePage(e = this.getCurrentPage()) {
|
|
4531
|
+
var s;
|
|
4532
|
+
const i = this.getPageUrl(e);
|
|
4533
|
+
return typeof navigator < "u" && typeof navigator.share == "function" ? await navigator.share({ title: typeof document > "u" ? void 0 : document.title, url: i }) : typeof navigator < "u" && ((s = navigator.clipboard) != null && s.writeText) && await navigator.clipboard.writeText(i), i;
|
|
4534
|
+
}
|
|
4535
|
+
/** Connects an optional postMessage bridge for iframe/embed integrations. */
|
|
4536
|
+
connectEmbed(e = {}) {
|
|
4537
|
+
return new ps(this, e).connect();
|
|
4538
|
+
}
|
|
4539
|
+
async setPages(e, i) {
|
|
4540
|
+
if (!(e != null && e.length)) {
|
|
4541
|
+
i && await this.init(i);
|
|
4542
|
+
return;
|
|
4543
|
+
}
|
|
4544
|
+
await this.init(i || "", e);
|
|
4545
|
+
}
|
|
4546
|
+
setupQualityLoading() {
|
|
4547
|
+
var a;
|
|
4548
|
+
if (this.teardownQualityLoading(), !this.container) return;
|
|
4549
|
+
const e = Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")), i = (r) => {
|
|
4550
|
+
const h = Number(r.dataset.pdfPage);
|
|
4551
|
+
if (Number.isInteger(h) && h > 0) {
|
|
4552
|
+
this.renderPdfPage(h).catch(() => {
|
|
4553
|
+
});
|
|
4554
|
+
return;
|
|
4555
|
+
}
|
|
4556
|
+
const c = r.dataset.src;
|
|
4557
|
+
c && (r.src = c, delete r.dataset.src);
|
|
4558
|
+
}, s = (a = this.container.ownerDocument.defaultView) == null ? void 0 : a.IntersectionObserver;
|
|
4559
|
+
if (!s) {
|
|
4560
|
+
const r = /* @__PURE__ */ new Set();
|
|
4561
|
+
e.forEach((h) => {
|
|
4562
|
+
const c = Number(h.dataset.pdfPage);
|
|
4563
|
+
Number.isInteger(c) && c > 0 ? r.size < 2 && (r.add(c), i(h)) : i(h);
|
|
4564
|
+
});
|
|
4565
|
+
return;
|
|
4566
|
+
}
|
|
4567
|
+
this.qualityObserver = new s((r) => {
|
|
4568
|
+
r.forEach((h) => {
|
|
4569
|
+
var c;
|
|
4570
|
+
h.isIntersecting && (i(h.target), (c = this.qualityObserver) == null || c.unobserve(h.target));
|
|
4571
|
+
});
|
|
4572
|
+
}, { root: this.container, rootMargin: "240px" }), e.forEach((r) => {
|
|
4573
|
+
var h;
|
|
4574
|
+
return (h = this.qualityObserver) == null ? void 0 : h.observe(r);
|
|
4575
|
+
});
|
|
4576
|
+
}
|
|
4577
|
+
teardownQualityLoading() {
|
|
4578
|
+
var e;
|
|
4579
|
+
(e = this.qualityObserver) == null || e.disconnect(), this.qualityObserver = null;
|
|
4580
|
+
}
|
|
4581
|
+
setupEventSync() {
|
|
4582
|
+
this.eventSyncStop = G(() => {
|
|
4583
|
+
const e = {
|
|
4584
|
+
currentPage: this.store.currentPage.value,
|
|
4585
|
+
zoom: this.store.zoomState.value.scale,
|
|
4586
|
+
zoomActive: this.store.zoomState.value.isActive,
|
|
4587
|
+
showThumbs: this.store.showThumbs.value,
|
|
4588
|
+
showToc: this.store.showToc.value,
|
|
4589
|
+
isSingle: this.store.isSingleMode.value,
|
|
4590
|
+
orientation: this.store.orientation.value
|
|
4591
|
+
};
|
|
4592
|
+
if (!this.eventsReady) {
|
|
4593
|
+
this.lastEventState = e;
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
e.currentPage !== this.lastEventState.currentPage && (this.emit("pageChange", {
|
|
4597
|
+
currentPage: e.currentPage,
|
|
4598
|
+
pageNumber: e.currentPage + 1,
|
|
4599
|
+
totalPages: this.store.totalPages.value,
|
|
4600
|
+
isSingle: e.isSingle
|
|
4601
|
+
}), this.updateDeepLink(e.currentPage)), (e.zoom !== this.lastEventState.zoom || e.zoomActive !== this.lastEventState.zoomActive) && this.emit("zoomChange", { zoom: e.zoom, isActive: e.zoomActive }), e.showThumbs !== this.lastEventState.showThumbs && this.emit("thumbsToggle", { showThumbs: e.showThumbs }), e.showToc !== this.lastEventState.showToc && this.emit("tocToggle", { showToc: e.showToc }), e.isSingle !== this.lastEventState.isSingle && this.emit("singlePageModeChange", { isSingle: e.isSingle }), e.orientation !== this.lastEventState.orientation && this.emit("orientationChange", { orientation: e.orientation }), this.lastEventState = e;
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
captureEventState() {
|
|
4605
|
+
this.lastEventState = {
|
|
4606
|
+
currentPage: this.store.currentPage.value,
|
|
4607
|
+
zoom: this.store.zoomState.value.scale,
|
|
4608
|
+
zoomActive: this.store.zoomState.value.isActive,
|
|
4609
|
+
showThumbs: this.store.showThumbs.value,
|
|
4610
|
+
showToc: this.store.showToc.value,
|
|
4611
|
+
isSingle: this.store.isSingleMode.value,
|
|
4612
|
+
orientation: this.store.orientation.value
|
|
4613
|
+
};
|
|
4614
|
+
}
|
|
4615
|
+
setTextSelection(e) {
|
|
4616
|
+
this.store.textSelection.value = !!e;
|
|
4617
|
+
}
|
|
4618
|
+
destroy(e = !1) {
|
|
4619
|
+
var s, a, r;
|
|
4620
|
+
(s = this.textLayerStop) == null || s.call(this), this.textLayerStop = null;
|
|
4621
|
+
const i = this.hasActiveSession || !!this.initAbortController || !!this.pageFlipAdapter || !!this.layoutManager || !!this.interactionManager || !!this.pdfRenderer;
|
|
4622
|
+
this.initGeneration++, this.teardownDeepLinkListener(), (a = this.initAbortController) == null || a.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.pdfRenderedSources.clear(), this.pdfSourcePageCount = 0, 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(), !e && this.container && (this.container.innerHTML = ""), i && this.emit("destroy", void 0), e || this.pluginRegistry.clear();
|
|
4623
|
+
}
|
|
4624
|
+
createAbortError() {
|
|
4625
|
+
const e = new Error("Flipbook initialization was aborted.");
|
|
4626
|
+
return e.name = "AbortError", e;
|
|
4627
|
+
}
|
|
4628
|
+
on(e, i) {
|
|
4629
|
+
const s = this.listeners[e] ?? /* @__PURE__ */ new Set();
|
|
4630
|
+
return s.add(i), this.listeners[e] = s, () => this.off(e, i);
|
|
4631
|
+
}
|
|
4632
|
+
off(e, i) {
|
|
4633
|
+
var s;
|
|
4634
|
+
(s = this.listeners[e]) == null || s.delete(i);
|
|
4635
|
+
}
|
|
4636
|
+
emit(e, i) {
|
|
4637
|
+
var s;
|
|
4638
|
+
(s = this.listeners[e]) == null || s.forEach((a) => {
|
|
4639
|
+
a(i);
|
|
4640
|
+
});
|
|
4641
|
+
}
|
|
4642
|
+
};
|
|
4643
|
+
C(we, "DEFAULT_PAGE_VIEWPORT", { width: 420, height: 594 });
|
|
4644
|
+
let Ye = we;
|
|
4645
|
+
const jt = globalThis, Xt = jt.FlipbookEngine || {};
|
|
4646
|
+
Xt.FlipbookEngine = Ye;
|
|
4647
|
+
jt.FlipbookEngine = Xt;
|
|
4648
|
+
export {
|
|
4649
|
+
ps as F,
|
|
4650
|
+
Ye as a,
|
|
4651
|
+
rs as b,
|
|
4652
|
+
ys as c,
|
|
4653
|
+
je as d,
|
|
4654
|
+
gs as i,
|
|
4655
|
+
cs as n
|
|
4656
|
+
};
|
|
4657
|
+
//# sourceMappingURL=engine-DD5qEHLm.js.map
|