react-book-reader 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1720 @@
1
+ var xr = Object.defineProperty;
2
+ var Tr = (o, s, e) => s in o ? xr(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
3
+ var ve = (o, s, e) => (Tr(o, typeof s != "symbol" ? s + "" : s, e), e), Me = (o, s, e) => {
4
+ if (!s.has(o))
5
+ throw TypeError("Cannot " + e);
6
+ };
7
+ var v = (o, s, e) => (Me(o, s, "read from private field"), e ? e.call(o) : s.get(o)), A = (o, s, e) => {
8
+ if (s.has(o))
9
+ throw TypeError("Cannot add the same private member more than once");
10
+ s instanceof WeakSet ? s.add(o) : s.set(o, e);
11
+ }, L = (o, s, e, t) => (Me(o, s, "write to private field"), t ? t.call(o, e) : s.set(o, e), e);
12
+ var yt = (o, s, e, t) => ({
13
+ set _(r) {
14
+ L(o, s, r, e);
15
+ },
16
+ get _() {
17
+ return v(o, s, t);
18
+ }
19
+ }), k = (o, s, e) => (Me(o, s, "access private method"), e);
20
+ import jt, { forwardRef as Rr, useState as te, useRef as Ot, useImperativeHandle as Cr, useEffect as Et } from "react";
21
+ var We = { exports: {} }, ae = {};
22
+ /**
23
+ * @license React
24
+ * react-jsx-runtime.production.min.js
25
+ *
26
+ * Copyright (c) Facebook, Inc. and its affiliates.
27
+ *
28
+ * This source code is licensed under the MIT license found in the
29
+ * LICENSE file in the root directory of this source tree.
30
+ */
31
+ var xt;
32
+ function Ar() {
33
+ if (xt)
34
+ return ae;
35
+ xt = 1;
36
+ var o = jt, s = Symbol.for("react.element"), e = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
37
+ function a(c, l, d) {
38
+ var u, h = {}, g = null, b = null;
39
+ d !== void 0 && (g = "" + d), l.key !== void 0 && (g = "" + l.key), l.ref !== void 0 && (b = l.ref);
40
+ for (u in l)
41
+ t.call(l, u) && !i.hasOwnProperty(u) && (h[u] = l[u]);
42
+ if (c && c.defaultProps)
43
+ for (u in l = c.defaultProps, l)
44
+ h[u] === void 0 && (h[u] = l[u]);
45
+ return { $$typeof: s, type: c, key: g, ref: b, props: h, _owner: r.current };
46
+ }
47
+ return ae.Fragment = e, ae.jsx = a, ae.jsxs = a, ae;
48
+ }
49
+ var ce = {};
50
+ /**
51
+ * @license React
52
+ * react-jsx-runtime.development.js
53
+ *
54
+ * Copyright (c) Facebook, Inc. and its affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */
59
+ var Tt;
60
+ function Sr() {
61
+ return Tt || (Tt = 1, process.env.NODE_ENV !== "production" && function() {
62
+ var o = jt, s = Symbol.for("react.element"), e = Symbol.for("react.portal"), t = Symbol.for("react.fragment"), r = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), u = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), R = Symbol.iterator, j = "@@iterator";
63
+ function M(n) {
64
+ if (n === null || typeof n != "object")
65
+ return null;
66
+ var f = R && n[R] || n[j];
67
+ return typeof f == "function" ? f : null;
68
+ }
69
+ var B = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
70
+ function S(n) {
71
+ {
72
+ for (var f = arguments.length, p = new Array(f > 1 ? f - 1 : 0), m = 1; m < f; m++)
73
+ p[m - 1] = arguments[m];
74
+ se("error", n, p);
75
+ }
76
+ }
77
+ function se(n, f, p) {
78
+ {
79
+ var m = B.ReactDebugCurrentFrame, x = m.getStackAddendum();
80
+ x !== "" && (f += "%s", p = p.concat([x]));
81
+ var T = p.map(function(y) {
82
+ return String(y);
83
+ });
84
+ T.unshift("Warning: " + f), Function.prototype.apply.call(console[n], console, T);
85
+ }
86
+ }
87
+ var E = !1, N = !1, W = !1, ue = !1, Gt = !1, Xe;
88
+ Xe = Symbol.for("react.module.reference");
89
+ function Jt(n) {
90
+ return !!(typeof n == "string" || typeof n == "function" || n === t || n === i || Gt || n === r || n === d || n === u || ue || n === b || E || N || W || typeof n == "object" && n !== null && (n.$$typeof === g || n.$$typeof === h || n.$$typeof === a || n.$$typeof === c || n.$$typeof === l || // This needs to include all possible module reference object
91
+ // types supported by any Flight configuration anywhere since
92
+ // we don't know which Flight build this will end up being used
93
+ // with.
94
+ n.$$typeof === Xe || n.getModuleId !== void 0));
95
+ }
96
+ function Xt(n, f, p) {
97
+ var m = n.displayName;
98
+ if (m)
99
+ return m;
100
+ var x = f.displayName || f.name || "";
101
+ return x !== "" ? p + "(" + x + ")" : p;
102
+ }
103
+ function Ke(n) {
104
+ return n.displayName || "Context";
105
+ }
106
+ function H(n) {
107
+ if (n == null)
108
+ return null;
109
+ if (typeof n.tag == "number" && S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof n == "function")
110
+ return n.displayName || n.name || null;
111
+ if (typeof n == "string")
112
+ return n;
113
+ switch (n) {
114
+ case t:
115
+ return "Fragment";
116
+ case e:
117
+ return "Portal";
118
+ case i:
119
+ return "Profiler";
120
+ case r:
121
+ return "StrictMode";
122
+ case d:
123
+ return "Suspense";
124
+ case u:
125
+ return "SuspenseList";
126
+ }
127
+ if (typeof n == "object")
128
+ switch (n.$$typeof) {
129
+ case c:
130
+ var f = n;
131
+ return Ke(f) + ".Consumer";
132
+ case a:
133
+ var p = n;
134
+ return Ke(p._context) + ".Provider";
135
+ case l:
136
+ return Xt(n, n.render, "ForwardRef");
137
+ case h:
138
+ var m = n.displayName || null;
139
+ return m !== null ? m : H(n.type) || "Memo";
140
+ case g: {
141
+ var x = n, T = x._payload, y = x._init;
142
+ try {
143
+ return H(y(T));
144
+ } catch {
145
+ return null;
146
+ }
147
+ }
148
+ }
149
+ return null;
150
+ }
151
+ var Z = Object.assign, oe = 0, Ze, Qe, et, tt, rt, nt, st;
152
+ function ot() {
153
+ }
154
+ ot.__reactDisabledLog = !0;
155
+ function Kt() {
156
+ {
157
+ if (oe === 0) {
158
+ Ze = console.log, Qe = console.info, et = console.warn, tt = console.error, rt = console.group, nt = console.groupCollapsed, st = console.groupEnd;
159
+ var n = {
160
+ configurable: !0,
161
+ enumerable: !0,
162
+ value: ot,
163
+ writable: !0
164
+ };
165
+ Object.defineProperties(console, {
166
+ info: n,
167
+ log: n,
168
+ warn: n,
169
+ error: n,
170
+ group: n,
171
+ groupCollapsed: n,
172
+ groupEnd: n
173
+ });
174
+ }
175
+ oe++;
176
+ }
177
+ }
178
+ function Zt() {
179
+ {
180
+ if (oe--, oe === 0) {
181
+ var n = {
182
+ configurable: !0,
183
+ enumerable: !0,
184
+ writable: !0
185
+ };
186
+ Object.defineProperties(console, {
187
+ log: Z({}, n, {
188
+ value: Ze
189
+ }),
190
+ info: Z({}, n, {
191
+ value: Qe
192
+ }),
193
+ warn: Z({}, n, {
194
+ value: et
195
+ }),
196
+ error: Z({}, n, {
197
+ value: tt
198
+ }),
199
+ group: Z({}, n, {
200
+ value: rt
201
+ }),
202
+ groupCollapsed: Z({}, n, {
203
+ value: nt
204
+ }),
205
+ groupEnd: Z({}, n, {
206
+ value: st
207
+ })
208
+ });
209
+ }
210
+ oe < 0 && S("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
211
+ }
212
+ }
213
+ var je = B.ReactCurrentDispatcher, Oe;
214
+ function fe(n, f, p) {
215
+ {
216
+ if (Oe === void 0)
217
+ try {
218
+ throw Error();
219
+ } catch (x) {
220
+ var m = x.stack.trim().match(/\n( *(at )?)/);
221
+ Oe = m && m[1] || "";
222
+ }
223
+ return `
224
+ ` + Oe + n;
225
+ }
226
+ }
227
+ var Fe = !1, de;
228
+ {
229
+ var Qt = typeof WeakMap == "function" ? WeakMap : Map;
230
+ de = new Qt();
231
+ }
232
+ function it(n, f) {
233
+ if (!n || Fe)
234
+ return "";
235
+ {
236
+ var p = de.get(n);
237
+ if (p !== void 0)
238
+ return p;
239
+ }
240
+ var m;
241
+ Fe = !0;
242
+ var x = Error.prepareStackTrace;
243
+ Error.prepareStackTrace = void 0;
244
+ var T;
245
+ T = je.current, je.current = null, Kt();
246
+ try {
247
+ if (f) {
248
+ var y = function() {
249
+ throw Error();
250
+ };
251
+ if (Object.defineProperty(y.prototype, "props", {
252
+ set: function() {
253
+ throw Error();
254
+ }
255
+ }), typeof Reflect == "object" && Reflect.construct) {
256
+ try {
257
+ Reflect.construct(y, []);
258
+ } catch (q) {
259
+ m = q;
260
+ }
261
+ Reflect.construct(n, [], y);
262
+ } else {
263
+ try {
264
+ y.call();
265
+ } catch (q) {
266
+ m = q;
267
+ }
268
+ n.call(y.prototype);
269
+ }
270
+ } else {
271
+ try {
272
+ throw Error();
273
+ } catch (q) {
274
+ m = q;
275
+ }
276
+ n();
277
+ }
278
+ } catch (q) {
279
+ if (q && m && typeof q.stack == "string") {
280
+ for (var w = q.stack.split(`
281
+ `), O = m.stack.split(`
282
+ `), _ = w.length - 1, P = O.length - 1; _ >= 1 && P >= 0 && w[_] !== O[P]; )
283
+ P--;
284
+ for (; _ >= 1 && P >= 0; _--, P--)
285
+ if (w[_] !== O[P]) {
286
+ if (_ !== 1 || P !== 1)
287
+ do
288
+ if (_--, P--, P < 0 || w[_] !== O[P]) {
289
+ var $ = `
290
+ ` + w[_].replace(" at new ", " at ");
291
+ return n.displayName && $.includes("<anonymous>") && ($ = $.replace("<anonymous>", n.displayName)), typeof n == "function" && de.set(n, $), $;
292
+ }
293
+ while (_ >= 1 && P >= 0);
294
+ break;
295
+ }
296
+ }
297
+ } finally {
298
+ Fe = !1, je.current = T, Zt(), Error.prepareStackTrace = x;
299
+ }
300
+ var ee = n ? n.displayName || n.name : "", wt = ee ? fe(ee) : "";
301
+ return typeof n == "function" && de.set(n, wt), wt;
302
+ }
303
+ function er(n, f, p) {
304
+ return it(n, !1);
305
+ }
306
+ function tr(n) {
307
+ var f = n.prototype;
308
+ return !!(f && f.isReactComponent);
309
+ }
310
+ function he(n, f, p) {
311
+ if (n == null)
312
+ return "";
313
+ if (typeof n == "function")
314
+ return it(n, tr(n));
315
+ if (typeof n == "string")
316
+ return fe(n);
317
+ switch (n) {
318
+ case d:
319
+ return fe("Suspense");
320
+ case u:
321
+ return fe("SuspenseList");
322
+ }
323
+ if (typeof n == "object")
324
+ switch (n.$$typeof) {
325
+ case l:
326
+ return er(n.render);
327
+ case h:
328
+ return he(n.type, f, p);
329
+ case g: {
330
+ var m = n, x = m._payload, T = m._init;
331
+ try {
332
+ return he(T(x), f, p);
333
+ } catch {
334
+ }
335
+ }
336
+ }
337
+ return "";
338
+ }
339
+ var pe = Object.prototype.hasOwnProperty, at = {}, ct = B.ReactDebugCurrentFrame;
340
+ function ge(n) {
341
+ if (n) {
342
+ var f = n._owner, p = he(n.type, n._source, f ? f.type : null);
343
+ ct.setExtraStackFrame(p);
344
+ } else
345
+ ct.setExtraStackFrame(null);
346
+ }
347
+ function rr(n, f, p, m, x) {
348
+ {
349
+ var T = Function.call.bind(pe);
350
+ for (var y in n)
351
+ if (T(n, y)) {
352
+ var w = void 0;
353
+ try {
354
+ if (typeof n[y] != "function") {
355
+ var O = Error((m || "React class") + ": " + p + " type `" + y + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof n[y] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
356
+ throw O.name = "Invariant Violation", O;
357
+ }
358
+ w = n[y](f, y, m, p, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
359
+ } catch (_) {
360
+ w = _;
361
+ }
362
+ w && !(w instanceof Error) && (ge(x), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", m || "React class", p, y, typeof w), ge(null)), w instanceof Error && !(w.message in at) && (at[w.message] = !0, ge(x), S("Failed %s type: %s", p, w.message), ge(null));
363
+ }
364
+ }
365
+ }
366
+ var nr = Array.isArray;
367
+ function Ie(n) {
368
+ return nr(n);
369
+ }
370
+ function sr(n) {
371
+ {
372
+ var f = typeof Symbol == "function" && Symbol.toStringTag, p = f && n[Symbol.toStringTag] || n.constructor.name || "Object";
373
+ return p;
374
+ }
375
+ }
376
+ function or(n) {
377
+ try {
378
+ return lt(n), !1;
379
+ } catch {
380
+ return !0;
381
+ }
382
+ }
383
+ function lt(n) {
384
+ return "" + n;
385
+ }
386
+ function ut(n) {
387
+ if (or(n))
388
+ return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", sr(n)), lt(n);
389
+ }
390
+ var ie = B.ReactCurrentOwner, ir = {
391
+ key: !0,
392
+ ref: !0,
393
+ __self: !0,
394
+ __source: !0
395
+ }, ft, dt, Ne;
396
+ Ne = {};
397
+ function ar(n) {
398
+ if (pe.call(n, "ref")) {
399
+ var f = Object.getOwnPropertyDescriptor(n, "ref").get;
400
+ if (f && f.isReactWarning)
401
+ return !1;
402
+ }
403
+ return n.ref !== void 0;
404
+ }
405
+ function cr(n) {
406
+ if (pe.call(n, "key")) {
407
+ var f = Object.getOwnPropertyDescriptor(n, "key").get;
408
+ if (f && f.isReactWarning)
409
+ return !1;
410
+ }
411
+ return n.key !== void 0;
412
+ }
413
+ function lr(n, f) {
414
+ if (typeof n.ref == "string" && ie.current && f && ie.current.stateNode !== f) {
415
+ var p = H(ie.current.type);
416
+ Ne[p] || (S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', H(ie.current.type), n.ref), Ne[p] = !0);
417
+ }
418
+ }
419
+ function ur(n, f) {
420
+ {
421
+ var p = function() {
422
+ ft || (ft = !0, S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", f));
423
+ };
424
+ p.isReactWarning = !0, Object.defineProperty(n, "key", {
425
+ get: p,
426
+ configurable: !0
427
+ });
428
+ }
429
+ }
430
+ function fr(n, f) {
431
+ {
432
+ var p = function() {
433
+ dt || (dt = !0, S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", f));
434
+ };
435
+ p.isReactWarning = !0, Object.defineProperty(n, "ref", {
436
+ get: p,
437
+ configurable: !0
438
+ });
439
+ }
440
+ }
441
+ var dr = function(n, f, p, m, x, T, y) {
442
+ var w = {
443
+ // This tag allows us to uniquely identify this as a React Element
444
+ $$typeof: s,
445
+ // Built-in properties that belong on the element
446
+ type: n,
447
+ key: f,
448
+ ref: p,
449
+ props: y,
450
+ // Record the component responsible for creating this element.
451
+ _owner: T
452
+ };
453
+ return w._store = {}, Object.defineProperty(w._store, "validated", {
454
+ configurable: !1,
455
+ enumerable: !1,
456
+ writable: !0,
457
+ value: !1
458
+ }), Object.defineProperty(w, "_self", {
459
+ configurable: !1,
460
+ enumerable: !1,
461
+ writable: !1,
462
+ value: m
463
+ }), Object.defineProperty(w, "_source", {
464
+ configurable: !1,
465
+ enumerable: !1,
466
+ writable: !1,
467
+ value: x
468
+ }), Object.freeze && (Object.freeze(w.props), Object.freeze(w)), w;
469
+ };
470
+ function hr(n, f, p, m, x) {
471
+ {
472
+ var T, y = {}, w = null, O = null;
473
+ p !== void 0 && (ut(p), w = "" + p), cr(f) && (ut(f.key), w = "" + f.key), ar(f) && (O = f.ref, lr(f, x));
474
+ for (T in f)
475
+ pe.call(f, T) && !ir.hasOwnProperty(T) && (y[T] = f[T]);
476
+ if (n && n.defaultProps) {
477
+ var _ = n.defaultProps;
478
+ for (T in _)
479
+ y[T] === void 0 && (y[T] = _[T]);
480
+ }
481
+ if (w || O) {
482
+ var P = typeof n == "function" ? n.displayName || n.name || "Unknown" : n;
483
+ w && ur(y, P), O && fr(y, P);
484
+ }
485
+ return dr(n, w, O, x, m, ie.current, y);
486
+ }
487
+ }
488
+ var Le = B.ReactCurrentOwner, ht = B.ReactDebugCurrentFrame;
489
+ function Q(n) {
490
+ if (n) {
491
+ var f = n._owner, p = he(n.type, n._source, f ? f.type : null);
492
+ ht.setExtraStackFrame(p);
493
+ } else
494
+ ht.setExtraStackFrame(null);
495
+ }
496
+ var $e;
497
+ $e = !1;
498
+ function De(n) {
499
+ return typeof n == "object" && n !== null && n.$$typeof === s;
500
+ }
501
+ function pt() {
502
+ {
503
+ if (Le.current) {
504
+ var n = H(Le.current.type);
505
+ if (n)
506
+ return `
507
+
508
+ Check the render method of \`` + n + "`.";
509
+ }
510
+ return "";
511
+ }
512
+ }
513
+ function pr(n) {
514
+ {
515
+ if (n !== void 0) {
516
+ var f = n.fileName.replace(/^.*[\\\/]/, ""), p = n.lineNumber;
517
+ return `
518
+
519
+ Check your code at ` + f + ":" + p + ".";
520
+ }
521
+ return "";
522
+ }
523
+ }
524
+ var gt = {};
525
+ function gr(n) {
526
+ {
527
+ var f = pt();
528
+ if (!f) {
529
+ var p = typeof n == "string" ? n : n.displayName || n.name;
530
+ p && (f = `
531
+
532
+ Check the top-level render call using <` + p + ">.");
533
+ }
534
+ return f;
535
+ }
536
+ }
537
+ function vt(n, f) {
538
+ {
539
+ if (!n._store || n._store.validated || n.key != null)
540
+ return;
541
+ n._store.validated = !0;
542
+ var p = gr(f);
543
+ if (gt[p])
544
+ return;
545
+ gt[p] = !0;
546
+ var m = "";
547
+ n && n._owner && n._owner !== Le.current && (m = " It was passed a child from " + H(n._owner.type) + "."), Q(n), S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', p, m), Q(null);
548
+ }
549
+ }
550
+ function mt(n, f) {
551
+ {
552
+ if (typeof n != "object")
553
+ return;
554
+ if (Ie(n))
555
+ for (var p = 0; p < n.length; p++) {
556
+ var m = n[p];
557
+ De(m) && vt(m, f);
558
+ }
559
+ else if (De(n))
560
+ n._store && (n._store.validated = !0);
561
+ else if (n) {
562
+ var x = M(n);
563
+ if (typeof x == "function" && x !== n.entries)
564
+ for (var T = x.call(n), y; !(y = T.next()).done; )
565
+ De(y.value) && vt(y.value, f);
566
+ }
567
+ }
568
+ }
569
+ function vr(n) {
570
+ {
571
+ var f = n.type;
572
+ if (f == null || typeof f == "string")
573
+ return;
574
+ var p;
575
+ if (typeof f == "function")
576
+ p = f.propTypes;
577
+ else if (typeof f == "object" && (f.$$typeof === l || // Note: Memo only checks outer props here.
578
+ // Inner props are checked in the reconciler.
579
+ f.$$typeof === h))
580
+ p = f.propTypes;
581
+ else
582
+ return;
583
+ if (p) {
584
+ var m = H(f);
585
+ rr(p, n.props, "prop", m, n);
586
+ } else if (f.PropTypes !== void 0 && !$e) {
587
+ $e = !0;
588
+ var x = H(f);
589
+ S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", x || "Unknown");
590
+ }
591
+ typeof f.getDefaultProps == "function" && !f.getDefaultProps.isReactClassApproved && S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
592
+ }
593
+ }
594
+ function mr(n) {
595
+ {
596
+ for (var f = Object.keys(n.props), p = 0; p < f.length; p++) {
597
+ var m = f[p];
598
+ if (m !== "children" && m !== "key") {
599
+ Q(n), S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", m), Q(null);
600
+ break;
601
+ }
602
+ }
603
+ n.ref !== null && (Q(n), S("Invalid attribute `ref` supplied to `React.Fragment`."), Q(null));
604
+ }
605
+ }
606
+ function bt(n, f, p, m, x, T) {
607
+ {
608
+ var y = Jt(n);
609
+ if (!y) {
610
+ var w = "";
611
+ (n === void 0 || typeof n == "object" && n !== null && Object.keys(n).length === 0) && (w += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
612
+ var O = pr(x);
613
+ O ? w += O : w += pt();
614
+ var _;
615
+ n === null ? _ = "null" : Ie(n) ? _ = "array" : n !== void 0 && n.$$typeof === s ? (_ = "<" + (H(n.type) || "Unknown") + " />", w = " Did you accidentally export a JSX literal instead of a component?") : _ = typeof n, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _, w);
616
+ }
617
+ var P = hr(n, f, p, x, T);
618
+ if (P == null)
619
+ return P;
620
+ if (y) {
621
+ var $ = f.children;
622
+ if ($ !== void 0)
623
+ if (m)
624
+ if (Ie($)) {
625
+ for (var ee = 0; ee < $.length; ee++)
626
+ mt($[ee], n);
627
+ Object.freeze && Object.freeze($);
628
+ } else
629
+ S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
630
+ else
631
+ mt($, n);
632
+ }
633
+ return n === t ? mr(P) : vr(P), P;
634
+ }
635
+ }
636
+ function br(n, f, p) {
637
+ return bt(n, f, p, !0);
638
+ }
639
+ function wr(n, f, p) {
640
+ return bt(n, f, p, !1);
641
+ }
642
+ var yr = wr, Er = br;
643
+ ce.Fragment = t, ce.jsx = yr, ce.jsxs = Er;
644
+ }()), ce;
645
+ }
646
+ process.env.NODE_ENV === "production" ? We.exports = Ar() : We.exports = Sr();
647
+ var C = We.exports;
648
+ const _r = (o, s) => o.map((e, t, r) => s(e, t, r) ? t : null).filter((e) => e != null), Ft = (o, s) => [-1, ...s, o.length].reduce(({ xs: e, a: t }, r) => ({ xs: (e == null ? void 0 : e.concat([o.slice(t + 1, r)])) ?? [], a: r }), {}).xs, Pr = (o, s) => o.slice(0, -1).concat([o[o.length - 1].concat(s[0])]).concat(s.slice(1)), Be = /\d/, Pe = /^epubcfi\((.*)\)$/, Rt = (o) => o.replace(/[\^[\](),;=]/g, "^$&"), It = (o) => Pe.test(o) ? o : `epubcfi(${o})`, kr = (o) => {
649
+ var s;
650
+ return ((s = o.match(Pe)) == null ? void 0 : s[1]) ?? o;
651
+ }, jr = (o) => (...s) => `epubcfi(${o(...s.map((e) => {
652
+ var t;
653
+ return ((t = e.match(Pe)) == null ? void 0 : t[1]) ?? e;
654
+ }))})`, Or = jr((...o) => o.join("!")), Fr = (o) => {
655
+ const s = [];
656
+ let e, t, r = "";
657
+ const i = (c) => (s.push(c), e = null, r = ""), a = (c) => (r += c, t = !1);
658
+ for (const c of Array.from(o.trim()).concat("")) {
659
+ if (c === "^" && !t) {
660
+ t = !0;
661
+ continue;
662
+ }
663
+ if (e === "!")
664
+ i(["!"]);
665
+ else if (e === ",")
666
+ i([","]);
667
+ else if (e === "/" || e === ":")
668
+ if (Be.test(c)) {
669
+ a(c);
670
+ continue;
671
+ } else
672
+ i([e, parseInt(r)]);
673
+ else if (e === "~")
674
+ if (Be.test(c) || c === ".") {
675
+ a(c);
676
+ continue;
677
+ } else
678
+ i(["~", parseFloat(r)]);
679
+ else if (e === "@") {
680
+ if (c === ":") {
681
+ i(["@", parseFloat(r)]), e = "@";
682
+ continue;
683
+ }
684
+ if (Be.test(c) || c === ".") {
685
+ a(c);
686
+ continue;
687
+ } else
688
+ i(["@", parseFloat(r)]);
689
+ } else if (e === "[") {
690
+ c === ";" && !t ? (i(["[", r]), e = ";") : c === "," && !t ? (i(["[", r]), e = "[") : c === "]" && !t ? i(["[", r]) : a(c);
691
+ continue;
692
+ } else if (e != null && e.startsWith(";")) {
693
+ c === "=" && !t ? (e = `;${r}`, r = "") : c === ";" && !t ? (i([e, r]), e = ";") : c === "]" && !t ? i([e, r]) : a(c);
694
+ continue;
695
+ }
696
+ (c === "/" || c === ":" || c === "~" || c === "@" || c === "[" || c === "!" || c === ",") && (e = c);
697
+ }
698
+ return s;
699
+ }, Nt = (o, s) => _r(o, ([e]) => e === s), Ir = (o) => {
700
+ const s = [];
701
+ let e;
702
+ for (const [t, r] of o) {
703
+ if (t === "/")
704
+ s.push({ index: r });
705
+ else {
706
+ const i = s[s.length - 1];
707
+ if (t === ":")
708
+ i.offset = r;
709
+ else if (t === "~")
710
+ i.temporal = r;
711
+ else if (t === "@")
712
+ i.spatial = (i.spatial ?? []).concat(r);
713
+ else if (t === ";s")
714
+ i.side = r;
715
+ else if (t === "[")
716
+ if (e === "/" && r)
717
+ i.id = r;
718
+ else {
719
+ i.text = (i.text ?? []).concat(r);
720
+ continue;
721
+ }
722
+ }
723
+ e = t;
724
+ }
725
+ return s;
726
+ }, Ct = (o) => Ft(o, Nt(o, "!")).map(Ir), we = (o) => {
727
+ const s = Fr(kr(o)), e = Nt(s, ",");
728
+ if (!e.length)
729
+ return Ct(s);
730
+ const [t, r, i] = Ft(s, e).map(Ct);
731
+ return { parent: t, start: r, end: i };
732
+ }, Nr = ({ index: o, id: s, offset: e, temporal: t, spatial: r, text: i, side: a }) => {
733
+ var l;
734
+ const c = a ? `;s=${a}` : "";
735
+ return `/${o}` + (s ? `[${Rt(s)}${c}]` : "") + (e != null && o % 2 ? `:${e}` : "") + (t ? `~${t}` : "") + (r ? `@${r.join(":")}` : "") + (i || !s && a ? "[" + (((l = i == null ? void 0 : i.map(Rt)) == null ? void 0 : l.join(",")) ?? "") + c + "]" : "");
736
+ }, Lt = (o) => o.parent ? [o.parent, o.start, o.end].map(Lt).join(",") : o.map((s) => s.map(Nr).join("")).join("!"), ke = (o) => It(Lt(o)), ne = (o, s) => typeof o == "string" ? ke(ne(we(o), s)) : o.parent ? Pr(o.parent, o[s ? "end" : "start"]) : o, Lr = (o, s) => {
737
+ typeof o == "string" && (o = we(o)), typeof s == "string" && (s = we(s)), o = ne(o), s = ne(s, !0);
738
+ const e = o[o.length - 1], t = s[s.length - 1], r = [], i = [], a = [];
739
+ let c = !0;
740
+ const l = Math.max(e.length, t.length);
741
+ for (let u = 0; u < l; u++) {
742
+ const h = e[u], g = t[u];
743
+ c && (c = (h == null ? void 0 : h.index) === (g == null ? void 0 : g.index) && !(h != null && h.offset) && !(g != null && g.offset)), c ? r.push(h) : (h && i.push(h), g && a.push(g));
744
+ }
745
+ const d = o.slice(0, -1).concat([r]);
746
+ return ke({ parent: d, start: [i], end: [a] });
747
+ }, ze = ({ nodeType: o }) => o === 3 || o === 4, me = ({ nodeType: o }) => o === 1, $t = (o, s) => {
748
+ const e = Array.from(o.childNodes).filter((t) => ze(t) || me(t));
749
+ return s ? e.map((t) => {
750
+ const r = s(t);
751
+ return r === NodeFilter.FILTER_REJECT ? null : r === NodeFilter.FILTER_SKIP ? $t(t, s) : t;
752
+ }).flat().filter((t) => t) : e;
753
+ }, Je = (o, s) => {
754
+ const e = $t(o, s).reduce((t, r) => {
755
+ let i = t[t.length - 1];
756
+ return i ? ze(r) ? Array.isArray(i) ? i.push(r) : ze(i) ? t[t.length - 1] = [i, r] : t.push(r) : me(i) ? t.push(null, r) : t.push(r) : t.push(r), t;
757
+ }, []);
758
+ return me(e[0]) && e.unshift("first"), me(e[e.length - 1]) && e.push("last"), e.unshift("before"), e.push("after"), e;
759
+ }, Ve = (o, s, e) => {
760
+ const { id: t } = s[s.length - 1];
761
+ if (t) {
762
+ const a = o.ownerDocument.getElementById(t);
763
+ if (a)
764
+ return { node: a, offset: 0 };
765
+ }
766
+ for (const { index: a } of s) {
767
+ const c = o ? Je(o, e)[a] : null;
768
+ if (c === "first")
769
+ return { node: o.firstChild ?? o };
770
+ if (c === "last")
771
+ return { node: o.lastChild ?? o };
772
+ if (c === "before")
773
+ return { node: o, before: !0 };
774
+ if (c === "after")
775
+ return { node: o, after: !0 };
776
+ o = c;
777
+ }
778
+ const { offset: r } = s[s.length - 1];
779
+ if (!Array.isArray(o))
780
+ return { node: o, offset: r };
781
+ let i = 0;
782
+ for (const a of o) {
783
+ const { length: c } = a.nodeValue;
784
+ if (i + c >= r)
785
+ return { node: a, offset: r - i };
786
+ i += c;
787
+ }
788
+ }, ye = (o, s, e) => {
789
+ const { parentNode: t, id: r } = o, i = Je(t, e), a = i.findIndex((d) => Array.isArray(d) ? d.some((u) => u === o) : d === o), c = i[a];
790
+ if (Array.isArray(c)) {
791
+ let d = 0;
792
+ for (const u of c)
793
+ if (u === o) {
794
+ d += s;
795
+ break;
796
+ } else
797
+ d += u.nodeValue.length;
798
+ s = d;
799
+ }
800
+ const l = { id: r, index: a, offset: s };
801
+ return (t !== o.ownerDocument.documentElement ? ye(t, null, e).concat(l) : [l]).filter((d) => d.index !== -1);
802
+ }, $r = (o, s) => {
803
+ const { startContainer: e, startOffset: t, endContainer: r, endOffset: i } = o, a = ye(e, t, s);
804
+ if (o.collapsed)
805
+ return ke([a]);
806
+ const c = ye(r, i, s);
807
+ return Lr([a], [c]);
808
+ }, Dr = (o, s, e) => {
809
+ const t = ne(s), r = ne(s, !0), i = o.documentElement, a = Ve(i, t[0], e), c = Ve(i, r[0], e), l = o.createRange();
810
+ return a.before ? l.setStartBefore(a.node) : a.after ? l.setStartAfter(a.node) : l.setStart(a.node, a.offset), c.before ? l.setEndBefore(c.node) : c.after ? l.setEndAfter(c.node) : l.setEnd(c.node, c.offset), l;
811
+ }, cn = (o) => {
812
+ const s = [], { parentNode: e } = o[0], t = ye(e);
813
+ for (const [r, i] of Je(e).entries()) {
814
+ const a = o[s.length];
815
+ i === a && s.push(ke([t.concat({ id: a.id, index: r })]));
816
+ }
817
+ return s;
818
+ }, ln = (o, s) => Ve(o.documentElement, ne(s)).node, At = {
819
+ fromIndex: (o) => It(`/6/${(o + 1) * 2}`),
820
+ toIndex: (o) => (o == null ? void 0 : o.at(-1).index) / 2 - 1
821
+ }, Mr = (o) => {
822
+ let s = 0;
823
+ const e = (t) => {
824
+ if (t.id = s++, t.subitems)
825
+ for (const r of t.subitems)
826
+ e(r);
827
+ };
828
+ for (const t of o)
829
+ e(t);
830
+ return o;
831
+ }, Dt = (o) => o.map((s) => {
832
+ var e;
833
+ return (e = s.subitems) != null && e.length ? [s, Dt(s.subitems)].flat() : s;
834
+ }).flat();
835
+ class St {
836
+ async init({ toc: s, ids: e, splitHref: t, getFragment: r }) {
837
+ Mr(s);
838
+ const i = Dt(s), a = /* @__PURE__ */ new Map();
839
+ for (const [l, d] of i.entries()) {
840
+ const [u, h] = await t(d == null ? void 0 : d.href) ?? [], g = { fragment: h, item: d };
841
+ a.has(u) ? a.get(u).items.push(g) : a.set(u, { prev: i[l - 1], items: [g] });
842
+ }
843
+ const c = /* @__PURE__ */ new Map();
844
+ for (const [l, d] of e.entries())
845
+ a.has(d) ? c.set(d, a.get(d)) : c.set(d, c.get(e[l - 1]));
846
+ this.ids = e, this.map = c, this.getFragment = r;
847
+ }
848
+ getProgress(s, e) {
849
+ var l;
850
+ if (!this.ids)
851
+ return;
852
+ const t = this.ids[s], r = this.map.get(t);
853
+ if (!r)
854
+ return null;
855
+ const { prev: i, items: a } = r;
856
+ if (!a)
857
+ return i;
858
+ if (!e || a.length === 1 && !a[0].fragment)
859
+ return a[0].item;
860
+ const c = e.startContainer.getRootNode();
861
+ for (const [d, { fragment: u }] of a.entries()) {
862
+ const h = this.getFragment(c, u);
863
+ if (h && e.comparePoint(h, 0) > 0)
864
+ return ((l = a[d - 1]) == null ? void 0 : l.item) ?? i;
865
+ }
866
+ return a[a.length - 1].item;
867
+ }
868
+ }
869
+ var Ee, Mt;
870
+ class Br {
871
+ constructor(s, e, t) {
872
+ A(this, Ee);
873
+ this.sizes = s.map((r) => r.linear != "no" && r.size > 0 ? r.size : 0), this.sizePerLoc = e, this.sizePerTimeUnit = t, this.sizeTotal = this.sizes.reduce((r, i) => r + i, 0), this.sectionFractions = k(this, Ee, Mt).call(this);
874
+ }
875
+ // get progress given index of and fractions within a section
876
+ getProgress(s, e, t = 0) {
877
+ const { sizes: r, sizePerLoc: i, sizePerTimeUnit: a, sizeTotal: c } = this, l = r[s] ?? 0, u = r.slice(0, s).reduce((R, j) => R + j, 0) + e * l, h = u + t * l, g = c - u, b = (1 - e) * l;
878
+ return {
879
+ fraction: h / c,
880
+ section: {
881
+ current: s,
882
+ total: r.length
883
+ },
884
+ location: {
885
+ current: Math.floor(u / i),
886
+ next: Math.floor(h / i),
887
+ total: Math.ceil(c / i)
888
+ },
889
+ time: {
890
+ section: b / a,
891
+ total: g / a
892
+ }
893
+ };
894
+ }
895
+ // the inverse of `getProgress`
896
+ // get index of and fraction in section based on total fraction
897
+ getSection(s) {
898
+ if (s <= 0)
899
+ return [0, 0];
900
+ if (s >= 1)
901
+ return [this.sizes.length - 1, 1];
902
+ s = s + Number.EPSILON;
903
+ const { sizeTotal: e } = this;
904
+ let t = this.sectionFractions.findIndex((i) => i > s) - 1;
905
+ if (t < 0)
906
+ return [0, 0];
907
+ for (; !this.sizes[t]; )
908
+ t++;
909
+ const r = (s - this.sectionFractions[t]) / (this.sizes[t] / e);
910
+ return [t, r];
911
+ }
912
+ }
913
+ Ee = new WeakSet(), Mt = function() {
914
+ const { sizeTotal: s } = this, e = [0];
915
+ let t = 0;
916
+ for (const r of this.sizes)
917
+ e.push((t += r) / s);
918
+ return e;
919
+ };
920
+ const F = (o) => document.createElementNS("http://www.w3.org/2000/svg", o);
921
+ var Y, U;
922
+ class _t {
923
+ constructor() {
924
+ A(this, Y, F("svg"));
925
+ A(this, U, /* @__PURE__ */ new Map());
926
+ Object.assign(v(this, Y).style, {
927
+ position: "absolute",
928
+ top: "0",
929
+ left: "0",
930
+ width: "100%",
931
+ height: "100%",
932
+ pointerEvents: "none"
933
+ });
934
+ }
935
+ get element() {
936
+ return v(this, Y);
937
+ }
938
+ add(s, e, t, r) {
939
+ v(this, U).has(s) && this.remove(s), typeof e == "function" && (e = e(v(this, Y).getRootNode()));
940
+ const i = e.getClientRects(), a = t(i, r);
941
+ v(this, Y).append(a), v(this, U).set(s, { range: e, draw: t, options: r, element: a, rects: i });
942
+ }
943
+ remove(s) {
944
+ v(this, U).has(s) && (v(this, Y).removeChild(v(this, U).get(s).element), v(this, U).delete(s));
945
+ }
946
+ redraw() {
947
+ for (const s of v(this, U).values()) {
948
+ const { range: e, draw: t, options: r, element: i } = s;
949
+ v(this, Y).removeChild(i);
950
+ const a = e.getClientRects(), c = t(a, r);
951
+ v(this, Y).append(c), s.element = c, s.rects = a;
952
+ }
953
+ }
954
+ hitTest({ x: s, y: e }) {
955
+ const t = Array.from(v(this, U).entries());
956
+ for (let r = t.length - 1; r >= 0; r--) {
957
+ const [i, a] = t[r];
958
+ for (const { left: c, top: l, right: d, bottom: u } of a.rects)
959
+ if (l <= e && c <= s && u > e && d > s)
960
+ return [i, a.range];
961
+ }
962
+ return [];
963
+ }
964
+ static underline(s, e = {}) {
965
+ const { color: t = "red", width: r = 2, writingMode: i } = e, a = F("g");
966
+ if (a.setAttribute("fill", t), i === "vertical-rl" || i === "vertical-lr")
967
+ for (const { right: c, top: l, height: d } of s) {
968
+ const u = F("rect");
969
+ u.setAttribute("x", c - r), u.setAttribute("y", l), u.setAttribute("height", d), u.setAttribute("width", r), a.append(u);
970
+ }
971
+ else
972
+ for (const { left: c, bottom: l, width: d } of s) {
973
+ const u = F("rect");
974
+ u.setAttribute("x", c), u.setAttribute("y", l - r), u.setAttribute("height", r), u.setAttribute("width", d), a.append(u);
975
+ }
976
+ return a;
977
+ }
978
+ static strikethrough(s, e = {}) {
979
+ const { color: t = "red", width: r = 2, writingMode: i } = e, a = F("g");
980
+ if (a.setAttribute("fill", t), i === "vertical-rl" || i === "vertical-lr")
981
+ for (const { right: c, left: l, top: d, height: u } of s) {
982
+ const h = F("rect");
983
+ h.setAttribute("x", (c + l) / 2), h.setAttribute("y", d), h.setAttribute("height", u), h.setAttribute("width", r), a.append(h);
984
+ }
985
+ else
986
+ for (const { left: c, top: l, bottom: d, width: u } of s) {
987
+ const h = F("rect");
988
+ h.setAttribute("x", c), h.setAttribute("y", (l + d) / 2), h.setAttribute("height", r), h.setAttribute("width", u), a.append(h);
989
+ }
990
+ return a;
991
+ }
992
+ static squiggly(s, e = {}) {
993
+ const { color: t = "red", width: r = 2, writingMode: i } = e, a = F("g");
994
+ a.setAttribute("fill", "none"), a.setAttribute("stroke", t), a.setAttribute("stroke-width", r);
995
+ const c = r * 1.5;
996
+ if (i === "vertical-rl" || i === "vertical-lr")
997
+ for (const { right: l, top: d, height: u } of s) {
998
+ const h = F("path"), g = Math.round(u / c / 1.5), b = u / g, R = Array.from(
999
+ { length: g },
1000
+ (j, M) => `l${M % 2 ? -c : c} ${b}`
1001
+ ).join("");
1002
+ h.setAttribute("d", `M${l} ${d}${R}`), a.append(h);
1003
+ }
1004
+ else
1005
+ for (const { left: l, bottom: d, width: u } of s) {
1006
+ const h = F("path"), g = Math.round(u / c / 1.5), b = u / g, R = Array.from(
1007
+ { length: g },
1008
+ (j, M) => `l${b} ${M % 2 ? c : -c}`
1009
+ ).join("");
1010
+ h.setAttribute("d", `M${l} ${d}${R}`), a.append(h);
1011
+ }
1012
+ return a;
1013
+ }
1014
+ static highlight(s, e = {}) {
1015
+ const { color: t = "red" } = e, r = F("g");
1016
+ r.setAttribute("fill", t), r.style.opacity = "var(--overlayer-highlight-opacity, .3)", r.style.mixBlendMode = "var(--overlayer-highlight-blend-mode, normal)";
1017
+ for (const { left: i, top: a, height: c, width: l } of s) {
1018
+ const d = F("rect");
1019
+ d.setAttribute("x", i), d.setAttribute("y", a), d.setAttribute("height", c), d.setAttribute("width", l), r.append(d);
1020
+ }
1021
+ return r;
1022
+ }
1023
+ static outline(s, e = {}) {
1024
+ const { color: t = "red", width: r = 3, radius: i = 3 } = e, a = F("g");
1025
+ a.setAttribute("fill", "none"), a.setAttribute("stroke", t), a.setAttribute("stroke-width", r);
1026
+ for (const { left: c, top: l, height: d, width: u } of s) {
1027
+ const h = F("rect");
1028
+ h.setAttribute("x", c), h.setAttribute("y", l), h.setAttribute("height", d), h.setAttribute("width", u), h.setAttribute("rx", i), a.append(h);
1029
+ }
1030
+ return a;
1031
+ }
1032
+ // make an exact copy of an image in the overlay
1033
+ // one can then apply filters to the entire element, without affecting them;
1034
+ // it's a bit silly and probably better to just invert images twice
1035
+ // (though the color will be off in that case if you do heu-rotate)
1036
+ static copyImage([s], e = {}) {
1037
+ const { src: t } = e, r = F("image"), { left: i, top: a, height: c, width: l } = s;
1038
+ return r.setAttribute("href", t), r.setAttribute("x", i), r.setAttribute("y", a), r.setAttribute("height", c), r.setAttribute("width", l), r;
1039
+ }
1040
+ }
1041
+ Y = new WeakMap(), U = new WeakMap();
1042
+ const Wr = (o, s) => {
1043
+ const e = [];
1044
+ for (let t = s.currentNode; t; t = s.nextNode()) {
1045
+ const r = o.comparePoint(t, 0);
1046
+ if (r === 0)
1047
+ e.push(t);
1048
+ else if (r > 0)
1049
+ break;
1050
+ }
1051
+ return e;
1052
+ }, zr = (o, s) => {
1053
+ const e = [];
1054
+ for (let t = s.nextNode(); t; t = s.nextNode())
1055
+ e.push(t);
1056
+ return e;
1057
+ }, Vr = NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_CDATA_SECTION, Yr = (o) => {
1058
+ if (o.nodeType === 1) {
1059
+ const s = o.tagName.toLowerCase();
1060
+ return s === "script" || s === "style" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_SKIP;
1061
+ }
1062
+ return NodeFilter.FILTER_ACCEPT;
1063
+ }, Pt = function* (o, s) {
1064
+ const e = o.commonAncestorContainer ?? o.body ?? o, t = document.createTreeWalker(e, Vr, { acceptNode: Yr }), i = (o.commonAncestorContainer ? Wr : zr)(o, t), a = i.map((l) => l.nodeValue), c = (l, d, u, h) => {
1065
+ const g = document.createRange();
1066
+ return g.setStart(i[l], d), g.setEnd(i[u], h), g;
1067
+ };
1068
+ for (const l of s(a, c))
1069
+ yield l;
1070
+ }, le = "foliate-search:";
1071
+ var D, I;
1072
+ class Ur extends EventTarget {
1073
+ constructor() {
1074
+ super(...arguments);
1075
+ A(this, D, []);
1076
+ A(this, I, -1);
1077
+ }
1078
+ pushState(e) {
1079
+ const t = v(this, D)[v(this, I)];
1080
+ t === e || t != null && t.fraction && t.fraction === e.fraction || (v(this, D)[++yt(this, I)._] = e, v(this, D).length = v(this, I) + 1, this.dispatchEvent(new Event("index-change")));
1081
+ }
1082
+ replaceState(e) {
1083
+ const t = v(this, I);
1084
+ v(this, D)[t] = e;
1085
+ }
1086
+ back() {
1087
+ const e = v(this, I);
1088
+ if (e <= 0)
1089
+ return;
1090
+ const t = { state: v(this, D)[e - 1] };
1091
+ L(this, I, e - 1), this.dispatchEvent(new CustomEvent("popstate", { detail: t })), this.dispatchEvent(new Event("index-change"));
1092
+ }
1093
+ forward() {
1094
+ const e = v(this, I);
1095
+ if (e >= v(this, D).length - 1)
1096
+ return;
1097
+ const t = { state: v(this, D)[e + 1] };
1098
+ L(this, I, e + 1), this.dispatchEvent(new CustomEvent("popstate", { detail: t })), this.dispatchEvent(new Event("index-change"));
1099
+ }
1100
+ get canGoBack() {
1101
+ return v(this, I) > 0;
1102
+ }
1103
+ get canGoForward() {
1104
+ return v(this, I) < v(this, D).length - 1;
1105
+ }
1106
+ clear() {
1107
+ L(this, D, []), L(this, I, -1);
1108
+ }
1109
+ }
1110
+ D = new WeakMap(), I = new WeakMap();
1111
+ const Hr = (o) => {
1112
+ var s, e;
1113
+ if (!o)
1114
+ return {};
1115
+ try {
1116
+ const t = Intl.getCanonicalLocales(o)[0], r = new Intl.Locale(t), i = ["zh", "ja", "kr"].includes(r.language), a = (e = ((s = r.getTextInfo) == null ? void 0 : s.call(r)) ?? r.textInfo) == null ? void 0 : e.direction;
1117
+ return { canonical: t, locale: r, isCJK: i, direction: a };
1118
+ } catch (t) {
1119
+ return console.warn(t), {};
1120
+ }
1121
+ };
1122
+ var xe, J, z, K, X, Ye, Ue, He, qe, Ge, V, G, Te, Bt, Re, Wt, Ce, zt, re, be, Ae, Vt, Se, Yt, _e, Ut;
1123
+ class qr extends HTMLElement {
1124
+ constructor() {
1125
+ super();
1126
+ A(this, V);
1127
+ A(this, Te);
1128
+ A(this, Re);
1129
+ A(this, Ce);
1130
+ A(this, re);
1131
+ A(this, Ae);
1132
+ A(this, Se);
1133
+ A(this, _e);
1134
+ A(this, xe, this.attachShadow({ mode: "closed" }));
1135
+ A(this, J, void 0);
1136
+ A(this, z, void 0);
1137
+ A(this, K, void 0);
1138
+ A(this, X, /* @__PURE__ */ new Map());
1139
+ A(this, Ye, void 0);
1140
+ A(this, Ue, void 0);
1141
+ A(this, He, void 0);
1142
+ A(this, qe, void 0);
1143
+ A(this, Ge, void 0);
1144
+ ve(this, "isFixedLayout", !1);
1145
+ ve(this, "lastLocation");
1146
+ ve(this, "history", new Ur());
1147
+ this.history.addEventListener("popstate", ({ detail: e }) => {
1148
+ const t = this.resolveNavigation(e.state);
1149
+ this.renderer.goTo(t);
1150
+ });
1151
+ }
1152
+ async open(e) {
1153
+ var t, r, i;
1154
+ if (this.book = e, this.language = Hr((t = e.metadata) == null ? void 0 : t.language), e.splitTOCHref && e.getTOCFragment) {
1155
+ const a = e.sections.map((d) => d.id);
1156
+ L(this, J, new Br(e.sections, 1500, 1600));
1157
+ const c = e.splitTOCHref.bind(e), l = e.getTOCFragment.bind(e);
1158
+ L(this, z, new St()), await v(this, z).init({
1159
+ toc: e.toc ?? [],
1160
+ ids: a,
1161
+ splitHref: c,
1162
+ getFragment: l
1163
+ }), L(this, K, new St()), await v(this, K).init({
1164
+ toc: e.pageList ?? [],
1165
+ ids: a,
1166
+ splitHref: c,
1167
+ getFragment: l
1168
+ });
1169
+ }
1170
+ if (this.isFixedLayout = ((r = this.book.rendition) == null ? void 0 : r.layout) === "pre-paginated", this.isFixedLayout ? (await import("./fixed-layout-DpOZsuor.js"), this.renderer = document.createElement("foliate-fxl")) : (await import("./paginator-zvlJVmJl.js"), this.renderer = document.createElement("foliate-paginator")), this.renderer.setAttribute("exportparts", "head,foot,filter"), this.renderer.addEventListener("load", (a) => k(this, Re, Wt).call(this, a.detail)), this.renderer.addEventListener("relocate", (a) => k(this, Te, Bt).call(this, a.detail)), this.renderer.addEventListener("create-overlayer", (a) => a.detail.attach(k(this, Ae, Vt).call(this, a.detail))), this.renderer.open(e), v(this, xe).append(this.renderer), e.sections.some((a) => a.mediaOverlay)) {
1171
+ (i = e.media).activeClass || (i.activeClass = "-epub-media-overlay-active");
1172
+ const a = e.media.activeClass;
1173
+ this.mediaOverlay = e.getMediaOverlay();
1174
+ let c;
1175
+ this.mediaOverlay.addEventListener("highlight", (l) => {
1176
+ const d = this.resolveNavigation(l.detail.text);
1177
+ this.renderer.goTo(d).then(() => {
1178
+ const { doc: u } = this.renderer.getContents().find((g) => g.index = d.index), h = d.anchor(u);
1179
+ h.classList.add(a), c = new WeakRef(h);
1180
+ });
1181
+ }), this.mediaOverlay.addEventListener("unhighlight", () => {
1182
+ var l, d;
1183
+ (d = (l = c == null ? void 0 : c.deref()) == null ? void 0 : l.classList) == null || d.remove(a);
1184
+ });
1185
+ }
1186
+ }
1187
+ close() {
1188
+ var e, t;
1189
+ (e = this.renderer) == null || e.destroy(), (t = this.renderer) == null || t.remove(), L(this, J, null), L(this, z, null), L(this, K, null), L(this, X, /* @__PURE__ */ new Map()), this.lastLocation = null, this.history.clear(), this.tts = null, this.mediaOverlay = null;
1190
+ }
1191
+ goToTextStart() {
1192
+ var e, t;
1193
+ return this.goTo(((t = (e = this.book.landmarks) == null ? void 0 : e.find((r) => r.type.includes("bodymatter") || r.type.includes("text"))) == null ? void 0 : t.href) ?? this.book.sections.findIndex((r) => r.linear !== "no"));
1194
+ }
1195
+ async init({ lastLocation: e, showTextStart: t }) {
1196
+ const r = e ? this.resolveNavigation(e) : null;
1197
+ r ? (await this.renderer.goTo(r), this.history.pushState(e)) : t ? await this.goToTextStart() : (this.history.pushState(0), await this.next());
1198
+ }
1199
+ async addAnnotation(e, t) {
1200
+ var d;
1201
+ const { value: r } = e;
1202
+ if (r.startsWith(le)) {
1203
+ const u = r.replace(le, ""), { index: h, anchor: g } = await this.resolveNavigation(u), b = k(this, re, be).call(this, h);
1204
+ if (b) {
1205
+ const { overlayer: R, doc: j } = b;
1206
+ if (t) {
1207
+ R.remove(r);
1208
+ return;
1209
+ }
1210
+ const M = j ? g(j) : g;
1211
+ R.add(r, M, _t.outline);
1212
+ }
1213
+ return;
1214
+ }
1215
+ const { index: i, anchor: a } = await this.resolveNavigation(r), c = k(this, re, be).call(this, i);
1216
+ if (c) {
1217
+ const { overlayer: u, doc: h } = c;
1218
+ if (u.remove(r), !t) {
1219
+ const g = h ? a(h) : a, b = (R, j) => u.add(r, g, R, j);
1220
+ k(this, V, G).call(this, "draw-annotation", { draw: b, annotation: e, doc: h, range: g });
1221
+ }
1222
+ }
1223
+ const l = ((d = v(this, z).getProgress(i)) == null ? void 0 : d.label) ?? "";
1224
+ return { index: i, label: l };
1225
+ }
1226
+ deleteAnnotation(e) {
1227
+ return this.addAnnotation(e, !0);
1228
+ }
1229
+ async showAnnotation(e) {
1230
+ const { value: t } = e, r = await this.goTo(t);
1231
+ if (r) {
1232
+ const { index: i, anchor: a } = r, { doc: c } = k(this, re, be).call(this, i), l = a(c);
1233
+ k(this, V, G).call(this, "show-annotation", { value: t, index: i, range: l });
1234
+ }
1235
+ }
1236
+ getCFI(e, t) {
1237
+ const r = this.book.sections[e].cfi ?? At.fromIndex(e);
1238
+ return t ? Or(r, $r(t)) : r;
1239
+ }
1240
+ resolveCFI(e) {
1241
+ if (this.book.resolveCFI)
1242
+ return this.book.resolveCFI(e);
1243
+ {
1244
+ const t = we(e);
1245
+ return { index: At.toIndex((t.parent ?? t).shift()), anchor: (a) => Dr(a, t) };
1246
+ }
1247
+ }
1248
+ resolveNavigation(e) {
1249
+ try {
1250
+ if (typeof e == "number")
1251
+ return { index: e };
1252
+ if (typeof e.fraction == "number") {
1253
+ const [t, r] = v(this, J).getSection(e.fraction);
1254
+ return { index: t, anchor: r };
1255
+ }
1256
+ return Pe.test(e) ? this.resolveCFI(e) : this.book.resolveHref(e);
1257
+ } catch (t) {
1258
+ console.error(t), console.error(`Could not resolve target ${e}`);
1259
+ }
1260
+ }
1261
+ async goTo(e) {
1262
+ const t = this.resolveNavigation(e);
1263
+ try {
1264
+ return await this.renderer.goTo(t), this.history.pushState(e), t;
1265
+ } catch (r) {
1266
+ console.error(r), console.error(`Could not go to ${e}`);
1267
+ }
1268
+ }
1269
+ async goToFraction(e) {
1270
+ const [t, r] = v(this, J).getSection(e);
1271
+ await this.renderer.goTo({ index: t, anchor: r }), this.history.pushState({ fraction: e });
1272
+ }
1273
+ async select(e) {
1274
+ try {
1275
+ const t = await this.resolveNavigation(e);
1276
+ await this.renderer.goTo({ ...t, select: !0 }), this.history.pushState(e);
1277
+ } catch (t) {
1278
+ console.error(t), console.error(`Could not go to ${e}`);
1279
+ }
1280
+ }
1281
+ deselect() {
1282
+ for (const { doc: e } of this.renderer.getContents())
1283
+ e.defaultView.getSelection().removeAllRanges();
1284
+ }
1285
+ getSectionFractions() {
1286
+ var e;
1287
+ return (((e = v(this, J)) == null ? void 0 : e.sectionFractions) ?? []).map((t) => t + Number.EPSILON);
1288
+ }
1289
+ getProgressOf(e, t) {
1290
+ var a, c;
1291
+ const r = (a = v(this, z)) == null ? void 0 : a.getProgress(e, t), i = (c = v(this, K)) == null ? void 0 : c.getProgress(e, t);
1292
+ return { tocItem: r, pageItem: i };
1293
+ }
1294
+ async getTOCItemOf(e) {
1295
+ try {
1296
+ const { index: t, anchor: r } = await this.resolveNavigation(e), i = await this.book.sections[t].createDocument(), a = r(i), c = a instanceof Range, l = c ? a : i.createRange();
1297
+ return c || l.selectNodeContents(a), v(this, z).getProgress(t, l);
1298
+ } catch (t) {
1299
+ console.error(t), console.error(`Could not get ${e}`);
1300
+ }
1301
+ }
1302
+ async prev(e) {
1303
+ await this.renderer.prev(e);
1304
+ }
1305
+ async next(e) {
1306
+ await this.renderer.next(e);
1307
+ }
1308
+ goLeft() {
1309
+ return this.book.dir === "rtl" ? this.next() : this.prev();
1310
+ }
1311
+ goRight() {
1312
+ return this.book.dir === "rtl" ? this.prev() : this.next();
1313
+ }
1314
+ async *search(e) {
1315
+ var d;
1316
+ this.clearSearch();
1317
+ const { searchMatcher: t } = await import("./search-Dw1WQJVD.js"), { query: r, index: i } = e, a = t(
1318
+ Pt,
1319
+ { defaultLocale: this.language, ...e }
1320
+ ), c = i != null ? k(this, Se, Yt).call(this, a, r, i) : k(this, _e, Ut).call(this, a, r), l = [];
1321
+ v(this, X).set(i, l);
1322
+ for await (const u of c)
1323
+ if (u.subitems) {
1324
+ const h = u.subitems.map(({ cfi: g }) => ({ value: le + g }));
1325
+ v(this, X).set(u.index, h);
1326
+ for (const g of h)
1327
+ this.addAnnotation(g);
1328
+ yield {
1329
+ label: ((d = v(this, z).getProgress(u.index)) == null ? void 0 : d.label) ?? "",
1330
+ subitems: u.subitems
1331
+ };
1332
+ } else {
1333
+ if (u.cfi) {
1334
+ const h = { value: le + u.cfi };
1335
+ l.push(h), this.addAnnotation(h);
1336
+ }
1337
+ yield u;
1338
+ }
1339
+ yield "done";
1340
+ }
1341
+ clearSearch() {
1342
+ for (const e of v(this, X).values())
1343
+ for (const t of e)
1344
+ this.deleteAnnotation(t);
1345
+ v(this, X).clear();
1346
+ }
1347
+ async initTTS() {
1348
+ const e = this.renderer.getContents()[0].doc;
1349
+ if (this.tts && this.tts.doc === e)
1350
+ return;
1351
+ const { TTS: t } = await import("./tts-CuDZu6rz.js");
1352
+ this.tts = new t(e, Pt, (r) => this.renderer.scrollToAnchor(r, !0));
1353
+ }
1354
+ startMediaOverlay() {
1355
+ const { index: e } = this.renderer.getContents()[0];
1356
+ return this.mediaOverlay.start(e);
1357
+ }
1358
+ }
1359
+ xe = new WeakMap(), J = new WeakMap(), z = new WeakMap(), K = new WeakMap(), X = new WeakMap(), Ye = new WeakMap(), Ue = new WeakMap(), He = new WeakMap(), qe = new WeakMap(), Ge = new WeakMap(), V = new WeakSet(), G = function(e, t, r) {
1360
+ return this.dispatchEvent(new CustomEvent(e, { detail: t, cancelable: r }));
1361
+ }, Te = new WeakSet(), Bt = function({ reason: e, range: t, index: r, fraction: i, size: a }) {
1362
+ var h, g, b;
1363
+ const c = ((h = v(this, J)) == null ? void 0 : h.getProgress(r, i, a)) ?? {}, l = (g = v(this, z)) == null ? void 0 : g.getProgress(r, t), d = (b = v(this, K)) == null ? void 0 : b.getProgress(r, t), u = this.getCFI(r, t);
1364
+ this.lastLocation = { ...c, tocItem: l, pageItem: d, cfi: u, range: t }, (e === "snap" || e === "page" || e === "scroll") && this.history.replaceState(u), k(this, V, G).call(this, "relocate", this.lastLocation);
1365
+ }, Re = new WeakSet(), Wt = function({ doc: e, index: t }) {
1366
+ var r, i;
1367
+ (r = e.documentElement).lang || (r.lang = this.language.canonical ?? ""), this.language.isCJK || (i = e.documentElement).dir || (i.dir = this.language.direction ?? ""), k(this, Ce, zt).call(this, e, t), k(this, V, G).call(this, "load", { doc: e, index: t });
1368
+ }, Ce = new WeakSet(), zt = function(e, t) {
1369
+ const { book: r } = this, i = r.sections[t];
1370
+ for (const a of e.querySelectorAll("a[href]"))
1371
+ a.addEventListener("click", (c) => {
1372
+ var u, h;
1373
+ c.preventDefault();
1374
+ const l = a.getAttribute("href"), d = ((u = i == null ? void 0 : i.resolveHref) == null ? void 0 : u.call(i, l)) ?? l;
1375
+ (h = r == null ? void 0 : r.isExternal) != null && h.call(r, d) ? Promise.resolve(k(this, V, G).call(this, "external-link", { a, href: d }, !0)).then((g) => g ? globalThis.open(d, "_blank") : null).catch((g) => console.error(g)) : Promise.resolve(k(this, V, G).call(this, "link", { a, href: d }, !0)).then((g) => g ? this.goTo(d) : null).catch((g) => console.error(g));
1376
+ });
1377
+ }, re = new WeakSet(), be = function(e) {
1378
+ return this.renderer.getContents().find((t) => t.index === e && t.overlayer);
1379
+ }, Ae = new WeakSet(), Vt = function({ doc: e, index: t }) {
1380
+ const r = new _t();
1381
+ e.addEventListener("click", (a) => {
1382
+ const [c, l] = r.hitTest(a);
1383
+ c && !c.startsWith(le) && k(this, V, G).call(this, "show-annotation", { value: c, index: t, range: l });
1384
+ }, !1);
1385
+ const i = v(this, X).get(t);
1386
+ if (i)
1387
+ for (const a of i)
1388
+ this.addAnnotation(a);
1389
+ return k(this, V, G).call(this, "create-overlay", { index: t }), r;
1390
+ }, Se = new WeakSet(), Yt = async function* (e, t, r) {
1391
+ const i = await this.book.sections[r].createDocument();
1392
+ for (const { range: a, excerpt: c } of e(i, t))
1393
+ yield { cfi: this.getCFI(r, a), excerpt: c };
1394
+ }, _e = new WeakSet(), Ut = async function* (e, t) {
1395
+ const { sections: r } = this.book;
1396
+ for (const [i, { createDocument: a }] of r.entries()) {
1397
+ if (!a)
1398
+ continue;
1399
+ const c = await a(), l = Array.from(e(c, t), ({ range: u, excerpt: h }) => ({ cfi: this.getCFI(i, u), excerpt: h }));
1400
+ yield { progress: (i + 1) / r.length }, l.length && (yield { index: i, subitems: l });
1401
+ }
1402
+ };
1403
+ customElements.define("foliate-view", qr);
1404
+ const Gr = async (o) => {
1405
+ const s = new Uint8Array(await o.slice(0, 4).arrayBuffer());
1406
+ return s[0] === 80 && s[1] === 75 && s[2] === 3 && s[3] === 4;
1407
+ }, Jr = async (o) => {
1408
+ const s = new Uint8Array(await o.slice(0, 5).arrayBuffer());
1409
+ return s[0] === 37 && s[1] === 80 && s[2] === 68 && s[3] === 70 && s[4] === 45;
1410
+ }, Xr = async (o) => {
1411
+ const { configure: s, ZipReader: e, BlobReader: t, TextWriter: r, BlobWriter: i } = await import("./zip-BLPDOR3v.js");
1412
+ s({ useWebWorkers: !1 });
1413
+ const c = await new e(new t(o)).getEntries(), l = new Map(c.map((b) => [b.filename, b])), d = (b) => (R, ...j) => l.has(R) ? b(l.get(R), ...j) : null, u = d((b) => b.getData(new r())), h = d((b, R) => b.getData(new i(R)));
1414
+ return { entries: c, loadText: u, loadBlob: h, getSize: (b) => {
1415
+ var R;
1416
+ return ((R = l.get(b)) == null ? void 0 : R.uncompressedSize) ?? 0;
1417
+ } };
1418
+ }, Ht = async (o) => o.isFile ? o : (await Promise.all(
1419
+ Array.from(
1420
+ await new Promise(
1421
+ (s, e) => o.createReader().readEntries(
1422
+ (t) => s(t),
1423
+ (t) => e(t)
1424
+ )
1425
+ ),
1426
+ Ht
1427
+ )
1428
+ )).flat(), Kr = async (o) => {
1429
+ const s = await Ht(o), e = await Promise.all(
1430
+ s.map(
1431
+ (u) => new Promise(
1432
+ (h, g) => u.file(
1433
+ (b) => h([b, u.fullPath]),
1434
+ (b) => g(b)
1435
+ )
1436
+ )
1437
+ )
1438
+ ), t = new Map(
1439
+ e.map(([u, h]) => [h.replace(o.fullPath + "/", ""), u])
1440
+ ), r = new TextDecoder(), i = (u) => u ? r.decode(u) : null, a = (u) => {
1441
+ var h;
1442
+ return ((h = t.get(u)) == null ? void 0 : h.arrayBuffer()) ?? null;
1443
+ };
1444
+ return { loadText: async (u) => i(await a(u)), loadBlob: (u) => t.get(u), getSize: (u) => {
1445
+ var h;
1446
+ return ((h = t.get(u)) == null ? void 0 : h.size) ?? 0;
1447
+ } };
1448
+ }, Zr = ({ name: o, type: s }) => s === "application/vnd.comicbook+zip" || o.endsWith(".cbz"), Qr = ({ name: o, type: s }) => s === "application/x-fictionbook+xml" || o.endsWith(".fb2"), en = ({ name: o, type: s }) => s === "application/x-zip-compressed-fb2" || o.endsWith(".fb2.zip") || o.endsWith(".fbz"), kt = async (o, s) => {
1449
+ let e;
1450
+ if (o.isDirectory) {
1451
+ const r = await Kr(o), { EPUB: i } = await import("./epub-BZxdKHA1.js");
1452
+ e = await new i(r).init();
1453
+ } else if (o.size)
1454
+ if (await Gr(o)) {
1455
+ const r = await Xr(o);
1456
+ if (Zr(o)) {
1457
+ const { makeComicBook: i } = await import("./comic-book-D2H5riQt.js");
1458
+ e = i(r, o);
1459
+ } else if (en(o)) {
1460
+ const { makeFB2: i } = await import("./fb2-DHUjllK8.js"), { entries: a } = r, c = a.find((d) => d.filename.endsWith(".fb2")), l = await r.loadBlob((c ?? a[0]).filename);
1461
+ e = await i(l);
1462
+ } else {
1463
+ const { EPUB: i } = await import("./epub-BZxdKHA1.js");
1464
+ e = await new i(r).init();
1465
+ }
1466
+ } else if (await Jr(o)) {
1467
+ const { makePDF: r } = await import("./pdf-7wZ7-Bhj.js");
1468
+ e = await r(o);
1469
+ } else {
1470
+ const { isMOBI: r, MOBI: i } = await import("./mobi-Di0D6QEl.js");
1471
+ if (await r(o)) {
1472
+ const a = await import("./fflate-9VGFqnqw.js");
1473
+ e = await new i({ unzlib: a.unzlibSync }).open(o);
1474
+ } else if (Qr(o)) {
1475
+ const { makeFB2: a } = await import("./fb2-DHUjllK8.js");
1476
+ e = await a(o);
1477
+ }
1478
+ }
1479
+ else
1480
+ throw new Error("File not found");
1481
+ if (!e)
1482
+ throw new Error("File type not supported");
1483
+ const t = document.createElement("foliate-view");
1484
+ return s.append(t), await t.open(e), t;
1485
+ };
1486
+ function tn(o, s) {
1487
+ o.addEventListener(
1488
+ "keyup",
1489
+ (e) => {
1490
+ e.key === "ArrowUp" || e.key === "ArrowRight" ? s("next") : (e.key === "ArrowDown" || e.key === "ArrowLeft") && s("prev");
1491
+ },
1492
+ !1
1493
+ );
1494
+ }
1495
+ function rn(o, s) {
1496
+ let r = 0, i;
1497
+ o.addEventListener("wheel", (a) => {
1498
+ a.ignore || (a.ignore = !0, clearTimeout(i), r += a.deltaY, i = setTimeout(() => {
1499
+ if (Math.abs(r) >= 750) {
1500
+ let c = Math.sign(r) > 0 ? "next" : "prev";
1501
+ s(c), r = 0;
1502
+ }
1503
+ r = 0;
1504
+ }, 50));
1505
+ });
1506
+ }
1507
+ function nn(o, s) {
1508
+ let i, a, c;
1509
+ o.addEventListener(
1510
+ "touchstart",
1511
+ (l) => {
1512
+ l.ignore || (l.ignore = !0, i = l.changedTouches[0].pageX, a = l.changedTouches[0].pageY, c = Date.now());
1513
+ },
1514
+ !1
1515
+ ), o.addEventListener(
1516
+ "touchend",
1517
+ (l) => {
1518
+ var g, b;
1519
+ if (l.ignore)
1520
+ return;
1521
+ l.ignore = !0;
1522
+ const d = l.changedTouches[0].pageX - i, u = l.changedTouches[0].pageY - a;
1523
+ Date.now() - c <= 500 && (Math.abs(d) >= 50 && Math.abs(u) <= 200 ? s(d < 0 ? "prev" : "next") : Math.abs(u) >= 50 && Math.abs(d) <= 200 ? s(u < 0 ? "up" : "down") : ((b = (g = o == null ? void 0 : o.defaultView) == null ? void 0 : g.getSelection()) == null || b.removeAllRanges(), o.dispatchEvent(
1524
+ new MouseEvent("click", {
1525
+ clientX: i,
1526
+ clientY: a
1527
+ })
1528
+ ), l.preventDefault()));
1529
+ },
1530
+ !1
1531
+ );
1532
+ }
1533
+ const sn = Rr((o, s) => {
1534
+ const { url: e, getRendition: t, tocChanged: r } = o, [i, a] = te(!1), c = Ot(null), [l, d] = te(null), u = ({ spacing: E, justify: N, hyphenate: W }) => `
1535
+ @namespace epub "http://www.idpf.org/2007/ops";
1536
+ html {
1537
+ color-scheme: light dark;
1538
+ }
1539
+ /* https://github.com/whatwg/html/issues/5426 */
1540
+ @media (prefers-color-scheme: dark) {
1541
+ a:link {
1542
+ color: lightblue;
1543
+ }
1544
+ }
1545
+ p, li, blockquote, dd {
1546
+ line-height: ${E};
1547
+ text-align: ${N ? "justify" : "start"};
1548
+ -webkit-hyphens: ${W ? "auto" : "manual"};
1549
+ hyphens: ${W ? "auto" : "manual"};
1550
+ -webkit-hyphenate-limit-before: 3;
1551
+ -webkit-hyphenate-limit-after: 2;
1552
+ -webkit-hyphenate-limit-lines: 2;
1553
+ hanging-punctuation: allow-end last;
1554
+ widows: 2;
1555
+ }
1556
+ /* prevent the above from overriding the align attribute */
1557
+ [align="left"] { text-align: left; }
1558
+ [align="right"] { text-align: right; }
1559
+ [align="center"] { text-align: center; }
1560
+ [align="justify"] { text-align: justify; }
1561
+
1562
+ pre {
1563
+ white-space: pre-wrap !important;
1564
+ }
1565
+ aside[epub|type~="endnote"],
1566
+ aside[epub|type~="footnote"],
1567
+ aside[epub|type~="note"],
1568
+ aside[epub|type~="rearnote"] {
1569
+ display: none;
1570
+ }
1571
+ `, h = async () => {
1572
+ if (e)
1573
+ if (l && l.close(), typeof e == "string")
1574
+ fetch(e).then((E) => E.blob()).then(async (E) => {
1575
+ const N = e.split("/"), W = await kt(
1576
+ new File([E], N[N.length - 1]),
1577
+ c.current
1578
+ );
1579
+ d(W), g();
1580
+ }).catch((E) => console.error(E));
1581
+ else {
1582
+ const E = await kt(e, c.current);
1583
+ d(E), g();
1584
+ }
1585
+ }, g = () => {
1586
+ var N, W;
1587
+ if (!l)
1588
+ return;
1589
+ a(!0);
1590
+ const { book: E } = l;
1591
+ (W = (N = l.renderer).setStyles) == null || W.call(
1592
+ N,
1593
+ u({
1594
+ spacing: 1.4,
1595
+ justify: !0,
1596
+ hyphenate: !0
1597
+ })
1598
+ ), R(), t && t(l), r && r(E.toc), l.renderer.next();
1599
+ }, b = (E) => {
1600
+ E === "next" ? B() : E === "prev" && S();
1601
+ }, R = () => {
1602
+ l.addEventListener("load", j), l.addEventListener("relocate", M);
1603
+ }, j = ({ detail: { doc: E } }) => {
1604
+ rn(E, b), nn(E, b), tn(E, b);
1605
+ }, M = ({ detail: E }) => {
1606
+ }, B = () => l == null ? void 0 : l.next(), S = () => l == null ? void 0 : l.prev(), se = (E) => l == null ? void 0 : l.goTo(E);
1607
+ return Cr(s, () => ({ prevPage: S, nextPage: B, setLocation: se })), Et(() => {
1608
+ h();
1609
+ }, []), Et(() => {
1610
+ l && g();
1611
+ }, [l]), /* @__PURE__ */ C.jsx("div", { className: "reader", children: /* @__PURE__ */ C.jsxs("div", { className: "viewHolder", children: [
1612
+ /* @__PURE__ */ C.jsx(
1613
+ "div",
1614
+ {
1615
+ ref: c,
1616
+ id: "viewer",
1617
+ style: { display: i ? "" : "none" }
1618
+ }
1619
+ ),
1620
+ i && /* @__PURE__ */ C.jsx("div", { children: /* @__PURE__ */ C.jsx("slot", { name: "loadingView", children: " " }) })
1621
+ ] }) });
1622
+ }, []), qt = (o) => {
1623
+ const { toc: s = [], current: e = "", setLocation: t, isSubmenu: r = !1 } = o;
1624
+ return /* @__PURE__ */ C.jsx(C.Fragment, { children: s.map((i, a) => /* @__PURE__ */ C.jsxs("div", { children: [
1625
+ /* @__PURE__ */ C.jsxs(
1626
+ "button",
1627
+ {
1628
+ className: `tocAreaButton ${i.href === e ? "active" : ""}`,
1629
+ onClick: () => {
1630
+ i.subitems && i.subitems.length > 0 ? (i.expansion = !i.expansion, t(i.href, !1)) : t(i.href);
1631
+ },
1632
+ children: [
1633
+ r ? " ".repeat(4) + i.label : i.label,
1634
+ // 展开
1635
+ i.subitems && i.subitems.length > 0 && /* @__PURE__ */ C.jsx(
1636
+ "div",
1637
+ {
1638
+ className: `expansion ${i.expansion ? "open" : ""}`
1639
+ }
1640
+ )
1641
+ ]
1642
+ }
1643
+ ),
1644
+ //多级目录
1645
+ i.subitems && i.subitems.length > 0 && /* @__PURE__ */ C.jsx("div", { "v-show": i.expansion, children: /* @__PURE__ */ C.jsx(
1646
+ qt,
1647
+ {
1648
+ toc: i.subitems,
1649
+ current: e,
1650
+ setLocation: t,
1651
+ isSubmenu: !0
1652
+ }
1653
+ ) })
1654
+ ] }, a)) });
1655
+ }, un = (o) => {
1656
+ const { showToc: s = !0, url: e, getRendition: t, ...r } = o, i = Ot(null), [a, c] = te([]), [l, d] = te(!1), [u, h] = te(""), [g, b] = te(""), R = (E) => {
1657
+ var ue;
1658
+ t && t(E);
1659
+ const { book: N } = E, W = (ue = N.metadata) == null ? void 0 : ue.title;
1660
+ h(W || "");
1661
+ }, j = (E) => {
1662
+ c(E);
1663
+ }, M = () => {
1664
+ i.current.nextPage();
1665
+ }, B = () => {
1666
+ i.current.nextPage();
1667
+ }, S = () => {
1668
+ d(!l);
1669
+ }, se = (E, N = !0) => {
1670
+ i.current.setLocation(E), b(E), d(!N);
1671
+ };
1672
+ return /* @__PURE__ */ C.jsxs("div", { className: "container", children: [
1673
+ /* @__PURE__ */ C.jsxs("div", { className: `readerArea ${l ? "containerExpanded" : ""}`, children: [
1674
+ s && /* @__PURE__ */ C.jsxs(
1675
+ "button",
1676
+ {
1677
+ className: `tocButton ${l ? "tocButtonExpanded" : ""}`,
1678
+ onClick: S,
1679
+ children: [
1680
+ /* @__PURE__ */ C.jsx("span", { className: "tocButtonBar", style: { top: "35%" } }),
1681
+ /* @__PURE__ */ C.jsx("span", { className: "tocButtonBar", style: { top: "66%" } })
1682
+ ]
1683
+ }
1684
+ ),
1685
+ /* @__PURE__ */ C.jsx("div", { className: "titleArea", title: u }),
1686
+ /* @__PURE__ */ C.jsx(
1687
+ sn,
1688
+ {
1689
+ ref: i,
1690
+ url: e,
1691
+ onGetRendition: R,
1692
+ tocChanged: j,
1693
+ ...r
1694
+ }
1695
+ ),
1696
+ /* @__PURE__ */ C.jsx("button", { className: "arrow pre", onClick: M, children: "‹" }),
1697
+ /* @__PURE__ */ C.jsx("button", { className: "arrow next", onClick: B, children: "›" })
1698
+ ] }),
1699
+ s && /* @__PURE__ */ C.jsxs("div", { children: [
1700
+ /* @__PURE__ */ C.jsx("div", { className: "tocArea", children: /* @__PURE__ */ C.jsx(
1701
+ qt,
1702
+ {
1703
+ toc: a,
1704
+ current: g,
1705
+ setLocation: se
1706
+ }
1707
+ ) }),
1708
+ l && //目录遮罩
1709
+ /* @__PURE__ */ C.jsx("div", { className: "tocBackground", onClick: S })
1710
+ ] })
1711
+ ] });
1712
+ };
1713
+ export {
1714
+ sn as B,
1715
+ un as R,
1716
+ Dr as a,
1717
+ cn as f,
1718
+ we as p,
1719
+ ln as t
1720
+ };