@prose-reader/core 1.270.0 → 1.271.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { switchMap as w, of as v, fromEvent as q, take as Tt, map as S, from as A, takeUntil as $, Observable as se, defer as Ft, Subject as R, combineLatest as O, merge as P, EMPTY as _, NEVER as he, tap as x, share as j, BehaviorSubject as Y, distinctUntilChanged as k, filter as M, mergeMap as ge, first as V, endWith as ye, catchError as Ue, finalize as pe, lastValueFrom as rn, scheduled as an, animationFrameScheduler as ce, exhaustMap as ze, debounceTime as be, withLatestFrom as z, throttleTime as cn, startWith as ne, shareReplay as J, switchScan as un, defaultIfEmpty as ln, forkJoin as dn, delay as Pe, timer as Te, skip as Lt, ReplaySubject as ot, identity as xe, reduce as pn, concatMap as st } from "rxjs";
2
- import { Report as gn, isShallowEqual as U, shallowMergeIfDefined as $e, getParentPath as hn, parseContentType as mn, detectMimeTypeFromName as Me, arrayEqual as fn } from "@prose-reader/shared";
3
- import { isShallowEqual as nr } from "@prose-reader/shared";
4
- import { switchMap as X, first as Mt, map as ie, distinctUntilChanged as fe, startWith as yn, shareReplay as Ze, tap as N, pairwise as Sn, take as In, takeUntil as K, filter as ae, debounceTime as bn, skip as Ct, mergeMap as vn, catchError as rt } from "rxjs/operators";
5
- import { generate as We, parse as Et, isIndirectionOnly as wn, isParsedCfiRange as Pn, resolve as xn } from "@prose-reader/cfi";
6
- const $n = "@prose-reader/core", D = gn.namespace($n, void 0, {
1
+ import { switchMap as w, of as v, fromEvent as X, take as $t, map as S, from as k, takeUntil as T, Observable as ce, defer as Tt, Subject as R, combineLatest as j, merge as P, EMPTY as _, NEVER as ge, tap as $, share as D, BehaviorSubject as q, distinctUntilChanged as N, filter as C, mergeMap as pe, first as U, endWith as fe, catchError as ze, finalize as me, lastValueFrom as nn, scheduled as on, animationFrameScheduler as re, exhaustMap as sn, debounceTime as Ie, withLatestFrom as z, throttleTime as rn, startWith as ne, shareReplay as J, switchScan as an, defaultIfEmpty as cn, forkJoin as un, delay as Pe, timer as Te, skip as Ft, ReplaySubject as ot, identity as xe, concatMap as ln } from "rxjs";
2
+ import { Report as dn, isShallowEqual as O, shallowMergeIfDefined as $e, getParentPath as pn, parseContentType as gn, detectMimeTypeFromName as Me, arrayEqual as hn } from "@prose-reader/shared";
3
+ import { isShallowEqual as tr } from "@prose-reader/shared";
4
+ import { switchMap as Y, first as mn, map as ie, distinctUntilChanged as be, startWith as fn, shareReplay as Ge, tap as V, pairwise as yn, take as Sn, takeUntil as K, filter as de, debounceTime as In, skip as Lt, mergeMap as bn, catchError as st, share as vn } from "rxjs/operators";
5
+ import { generate as We, parse as Mt, isIndirectionOnly as wn, isParsedCfiRange as Pn, resolve as xn } from "@prose-reader/cfi";
6
+ const $n = "@prose-reader/core", A = dn.namespace($n, void 0, {
7
7
  color: "#98cde7"
8
8
  }), Tn = [
9
9
  "pointercancel",
@@ -25,17 +25,19 @@ function Fn(n, e, t) {
25
25
  return n.caretRangeFromPoint(e, t);
26
26
  }
27
27
  const Ln = (n, e) => {
28
- const t = "body" in n ? _e(n.body, e) : _e(n, e), i = "createRange" in n ? n : n.ownerDocument;
29
- if (t) {
28
+ const t = "createRange" in n ? n : n.ownerDocument;
29
+ if (!t) return;
30
+ const i = "body" in n ? _e(n.body, e) : _e(n, e);
31
+ if (i) {
30
32
  let o, s = 0;
31
- const r = i.createRange();
32
- return Array.from(t.childNodes).some((a) => {
33
+ const r = t.createRange();
34
+ return Array.from(i.childNodes).some((a) => {
33
35
  r.selectNodeContents(a);
34
36
  const c = r.getClientRects(), u = Mn(c, e);
35
37
  if (u) {
36
38
  o = r.cloneRange();
37
39
  const l = Fn(
38
- i,
40
+ t,
39
41
  Math.ceil(u.left),
40
42
  Math.ceil(u.top)
41
43
  );
@@ -45,10 +47,10 @@ const Ln = (n, e) => {
45
47
  }), o ? {
46
48
  node: o.startContainer,
47
49
  offset: s
48
- } : { node: t, offset: 0 };
50
+ } : { node: i, offset: 0 };
49
51
  }
50
52
  }, _e = (n, e) => {
51
- const t = n.getBoundingClientRect(), i = Dt(
53
+ const t = n.getBoundingClientRect(), i = Ct(
52
54
  t,
53
55
  e
54
56
  );
@@ -61,12 +63,12 @@ const Ln = (n, e) => {
61
63
  }
62
64
  return o;
63
65
  };
64
- function Dt(n, { left: e, right: t }) {
66
+ function Ct(n, { left: e, right: t }) {
65
67
  return n.left <= e && n.right <= e ? "before" : n.left <= e && n.right > e && n.right <= t ? "partially-before" : n.left <= t && n.right > t ? "partially-after" : n.left > t ? "after" : "within";
66
68
  }
67
69
  function Mn(n, e) {
68
70
  return Array.from(n).find((t) => {
69
- const i = Dt(t, e);
71
+ const i = Ct(t, e);
70
72
  return i !== "before" && i !== "after";
71
73
  });
72
74
  }
@@ -77,11 +79,11 @@ const Cn = (n, e) => {
77
79
  try {
78
80
  e <= (t?.endOffset || 0) && t?.setStart(n, e || 0);
79
81
  } catch (i) {
80
- D.error(i);
82
+ A.error(i);
81
83
  }
82
84
  return t;
83
85
  }
84
- }, Je = (n) => {
86
+ }, Ze = (n) => {
85
87
  if (n?.target && n?.target?.ownerDocument?.defaultView) {
86
88
  const e = n?.target?.ownerDocument?.defaultView;
87
89
  if (e.PointerEvent && n instanceof e.PointerEvent)
@@ -94,7 +96,7 @@ const Cn = (n, e) => {
94
96
  }
95
97
  return !!Tn.includes(n.type);
96
98
  }, En = (n) => {
97
- if (Je(n)) return !1;
99
+ if (Ze(n)) return !1;
98
100
  if (n?.target && n?.target?.ownerDocument?.defaultView) {
99
101
  const e = n?.target?.ownerDocument?.defaultView;
100
102
  if (e.MouseEvent)
@@ -118,7 +120,7 @@ const Cn = (n, e) => {
118
120
  return n instanceof e.TouchEvent;
119
121
  }
120
122
  return !1;
121
- }, Rn = () => document.createElement("div"), Rt = (n) => {
123
+ }, An = () => document.createElement("div"), Et = (n) => {
122
124
  const e = [
123
125
  "img",
124
126
  // Images
@@ -134,8 +136,8 @@ const Cn = (n, e) => {
134
136
  // JavaScript files
135
137
  ].join(",");
136
138
  return Array.from(n?.querySelectorAll(e) || []);
137
- }, An = (n) => {
138
- if (Rt(n).forEach((t) => {
139
+ }, Rn = (n) => {
140
+ if (Et(n).forEach((t) => {
139
141
  const i = t.getAttribute("src") || t.getAttribute("href");
140
142
  i?.startsWith("blob:") && n?.defaultView?.URL.revokeObjectURL(i);
141
143
  }), n) {
@@ -152,7 +154,7 @@ const Cn = (n, e) => {
152
154
  }
153
155
  }
154
156
  };
155
- function At(n, e, t = []) {
157
+ function Dt(n, e, t = []) {
156
158
  if (typeof n != "object" || n === null) return !1;
157
159
  for (const i of e)
158
160
  if (!(i in n)) return !1;
@@ -161,8 +163,8 @@ function At(n, e, t = []) {
161
163
  return !1;
162
164
  return !0;
163
165
  }
164
- function Nt(n) {
165
- return At(
166
+ function At(n) {
167
+ return Dt(
166
168
  n,
167
169
  ["nodeType"],
168
170
  []
@@ -170,10 +172,10 @@ function Nt(n) {
170
172
  ) && n.nodeType === Node.ELEMENT_NODE;
171
173
  }
172
174
  function Nn(n, e) {
173
- return Nt(n) && n.tagName.toLowerCase() === e.toLowerCase();
175
+ return At(n) && n.tagName.toLowerCase() === e.toLowerCase();
174
176
  }
175
177
  function On(n) {
176
- return At(
178
+ return Dt(
177
179
  n,
178
180
  [
179
181
  "startContainer",
@@ -196,12 +198,12 @@ const Ce = (n, e, t, i) => {
196
198
  const t = n.getElementById(e);
197
199
  t && t.remove();
198
200
  }
199
- }, at = (n, e) => {
201
+ }, rt = (n, e) => {
200
202
  const t = new RegExp(`${e}\\s*=\\s*([0-9.]+)`, "i"), i = n.match(t) || [], o = i[1] || "0";
201
203
  return i && Number.parseFloat(o) || 0;
202
204
  }, Vn = (n, e, t, i) => {
203
205
  n?.contentDocument?.head && Ce(n.contentDocument, e, t, i);
204
- }, _s = (n, e) => {
206
+ }, Ws = (n, e) => {
205
207
  n?.contentDocument && Ee(n.contentDocument, e);
206
208
  }, oe = (n, e, t, i) => {
207
209
  if (!n) return;
@@ -213,13 +215,13 @@ const Ce = (n, e, t, i) => {
213
215
  return;
214
216
  }
215
217
  Vn(n, e, t, i);
216
- }, Ke = (n) => {
218
+ }, Je = (n) => {
217
219
  if (n?.contentDocument) {
218
220
  const t = n.contentDocument.querySelector("meta[name='viewport']");
219
221
  if (t) {
220
222
  const i = t.getAttribute("content");
221
223
  if (i) {
222
- const o = at(i, "width"), s = at(i, "height");
224
+ const o = rt(i, "width"), s = rt(i, "height");
223
225
  return o > 0 && s > 0 ? {
224
226
  hasViewport: !0,
225
227
  width: o,
@@ -230,14 +232,14 @@ const Ce = (n, e, t, i) => {
230
232
  }
231
233
  return { hasViewport: !1 };
232
234
  }, jn = (n) => n.pipe(
233
- w((e) => e.src === "about:blank" && e.contentDocument?.readyState === "complete" && e.contentDocument.body ? v(e) : q(e, "load").pipe(
234
- Tt(1),
235
+ w((e) => e.src === "about:blank" && e.contentDocument?.readyState === "complete" && e.contentDocument.body ? v(e) : X(e, "load").pipe(
236
+ $t(1),
235
237
  S(() => e)
236
238
  ))
237
239
  ), kn = (n) => n.pipe(
238
240
  w((e) => {
239
241
  const t = e?.contentDocument?.fonts.ready;
240
- return t ? A(t).pipe(S(() => e)) : v(void 0);
242
+ return t ? k(t).pipe(S(() => e)) : v(void 0);
241
243
  })
242
244
  ), Un = (n) => (e) => {
243
245
  const t = n(e), i = new IntersectionObserver((o) => {
@@ -276,7 +278,7 @@ const Ce = (n, e, t, i) => {
276
278
  };
277
279
  }, zn = (n) => (e) => {
278
280
  const t = n(e);
279
- return t.context.watch("rootElement").pipe($(t.context.destroy$)).subscribe((i) => {
281
+ return t.context.watch("rootElement").pipe(T(t.context.destroy$)).subscribe((i) => {
280
282
  if (!i) return;
281
283
  const o = () => {
282
284
  t.settings.values.computedPageTurnMode === "controlled" && i.scrollTo(0, 0);
@@ -286,7 +288,7 @@ const Ce = (n, e, t, i) => {
286
288
  const s = t.spineItemsManager.get(i)?.renderer.getDocumentFrame();
287
289
  s && s.contentDocument?.body.setAttribute("tabindex", "-1");
288
290
  }), t;
289
- }, Ae = ({
291
+ }, Re = ({
290
292
  position: n,
291
293
  frameElement: e
292
294
  }) => {
@@ -300,8 +302,8 @@ const Ce = (n, e, t, i) => {
300
302
  if (!e || !o) return n;
301
303
  const s = t.getSpineItemFromIframe(o), r = o, { height: a, width: c } = i.pageSize;
302
304
  if (!s || !(r instanceof HTMLIFrameElement)) return n;
303
- if (Je(n)) {
304
- const { clientX: u, clientY: l } = Ae({
305
+ if (Ze(n)) {
306
+ const { clientX: u, clientY: l } = Re({
305
307
  position: n,
306
308
  frameElement: r
307
309
  }), d = new PointerEvent(n.type, {
@@ -316,7 +318,7 @@ const Ce = (n, e, t, i) => {
316
318
  }), d;
317
319
  }
318
320
  if (En(n)) {
319
- const { clientX: u, clientY: l } = Ae({
321
+ const { clientX: u, clientY: l } = Re({
320
322
  position: n,
321
323
  frameElement: r
322
324
  }), d = new MouseEvent(n.type, {
@@ -331,7 +333,7 @@ const Ce = (n, e, t, i) => {
331
333
  }
332
334
  if (Dn(n)) {
333
335
  const u = Array.from(n.touches).map((d) => {
334
- const { clientX: p, clientY: g } = Ae({
336
+ const { clientX: p, clientY: g } = Re({
335
337
  position: d,
336
338
  frameElement: r
337
339
  });
@@ -374,7 +376,7 @@ const Ce = (n, e, t, i) => {
374
376
  const a = Hn.map((c) => {
375
377
  const u = (l) => {
376
378
  let d = l;
377
- if (Je(l) && (d = new PointerEvent(l.type, l)), d !== l) {
379
+ if (Ze(l) && (d = new PointerEvent(l.type, l)), d !== l) {
378
380
  const p = Wn(
379
381
  d,
380
382
  l,
@@ -395,15 +397,15 @@ const Ce = (n, e, t, i) => {
395
397
  });
396
398
  }
397
399
  ), t;
398
- }, Ot = (n) => ie((e) => Object.entries(e).reduce(
400
+ }, Rt = (n) => ie((e) => Object.entries(e).reduce(
399
401
  (t, [i, o]) => n.includes(i) ? {
400
402
  ...t,
401
403
  [i]: o
402
404
  } : t,
403
405
  {}
404
- )), Qe = (n) => (e) => e.pipe(Ot(n), fe(U));
405
- function et(n) {
406
- return new se((e) => {
406
+ )), Ke = (n) => (e) => e.pipe(Rt(n), be(O));
407
+ function Qe(n) {
408
+ return new ce((e) => {
407
409
  const t = new ResizeObserver((i) => {
408
410
  e.next(i);
409
411
  });
@@ -413,9 +415,9 @@ function et(n) {
413
415
  });
414
416
  }
415
417
  const De = (n) => (e) => e.pipe(
416
- X(
418
+ Y(
417
419
  (t) => n.pipe(
418
- Mt(),
420
+ mn(),
419
421
  ie(() => t)
420
422
  )
421
423
  )
@@ -426,8 +428,8 @@ const De = (n) => (e) => e.pipe(
426
428
  });
427
429
  return () => (t.unsubscribe(), e ? v(e.result) : n);
428
430
  };
429
- function Vt() {
430
- return new se((n) => {
431
+ function et() {
432
+ return new ce((n) => {
431
433
  if (window.requestIdleCallback) {
432
434
  const t = window.requestIdleCallback(() => {
433
435
  n.next(), n.complete();
@@ -440,17 +442,17 @@ function Vt() {
440
442
  return () => clearTimeout(e);
441
443
  });
442
444
  }
443
- function ct(n) {
444
- return Ft(() => Vt().pipe(X(n)));
445
+ function at(n) {
446
+ return Tt(() => et().pipe(Y(n)));
445
447
  }
446
- const ut = (n, e) => new se((t) => {
448
+ const ct = (n, e) => new ce((t) => {
447
449
  const i = new MutationObserver((o) => {
448
450
  t.next(o);
449
451
  });
450
452
  return i.observe(n, e), () => i.disconnect();
451
453
  });
452
- function Hs(n, e) {
453
- return new se((t) => {
454
+ function _s(n, e) {
455
+ return new ce((t) => {
454
456
  const i = new IntersectionObserver((o) => {
455
457
  t.next(o);
456
458
  }, e);
@@ -459,7 +461,7 @@ function Hs(n, e) {
459
461
  };
460
462
  });
461
463
  }
462
- class jt {
464
+ class Nt {
463
465
  constructor(e, t) {
464
466
  this.settingsManager = t;
465
467
  const i = $e(
@@ -469,12 +471,12 @@ class jt {
469
471
  this.outputSettings = this.computeOutputSettings(i), this.inputSettings = $e(
470
472
  this.getDefaultSettings(),
471
473
  e
472
- ), this.outputSettingsUpdateSubject = new R(), this.values$ = O([
474
+ ), this.outputSettingsUpdateSubject = new R(), this.values$ = j([
473
475
  this.settingsManager.values$,
474
- this.outputSettingsUpdateSubject.pipe(yn(this.outputSettings))
476
+ this.outputSettingsUpdateSubject.pipe(fn(this.outputSettings))
475
477
  ]).pipe(
476
478
  ie(([o, s]) => ({ ...o, ...s })),
477
- Ze(1)
479
+ Ge(1)
478
480
  ), this.values$.subscribe();
479
481
  }
480
482
  _prepareUpdate(e) {
@@ -498,16 +500,16 @@ class jt {
498
500
  };
499
501
  }
500
502
  watch(e) {
501
- return Array.isArray(e) ? this.values$.pipe(Qe(e)) : this.values$.pipe(
503
+ return Array.isArray(e) ? this.values$.pipe(Ke(e)) : this.values$.pipe(
502
504
  ie((t) => t[e]),
503
- fe(U)
505
+ be(O)
504
506
  );
505
507
  }
506
508
  destroy() {
507
509
  this.outputSettingsUpdateSubject.complete();
508
510
  }
509
511
  }
510
- const Bs = (n) => {
512
+ const Hs = (n) => {
511
513
  const e = new FileReader();
512
514
  return new Promise((t) => {
513
515
  e.addEventListener(
@@ -519,12 +521,12 @@ const Bs = (n) => {
519
521
  ), e.readAsDataURL(n);
520
522
  });
521
523
  };
522
- let Yn = class extends jt {
524
+ let Yn = class extends Nt {
523
525
  computeOutputSettings(e) {
524
526
  return e;
525
527
  }
526
528
  hasSettingsChanged(e) {
527
- return !U(this.outputSettings, e);
529
+ return !O(this.outputSettings, e);
528
530
  }
529
531
  getCleanedParentInputSettings(e) {
530
532
  const {
@@ -578,13 +580,13 @@ const qn = (n) => (e) => {
578
580
  }
579
581
  });
580
582
  const d = (p) => p.pipe(
581
- Sn(),
583
+ yn(),
582
584
  S(([g, h]) => h.fontScale !== g.fontScale || h.lineHeight !== g.lineHeight)
583
585
  );
584
586
  return c.values$.pipe(
585
587
  d,
586
- N(l),
587
- $(a.$.destroy$)
588
+ V(l),
589
+ T(a.$.destroy$)
588
590
  ).subscribe(), {
589
591
  ...a,
590
592
  destroy: () => {
@@ -593,7 +595,7 @@ const qn = (n) => (e) => {
593
595
  settings: c
594
596
  };
595
597
  }, Gn = (n) => (e) => {
596
- const t = n(e), i = (o) => q(o, "keyup").pipe(
598
+ const t = n(e), i = (o) => X(o, "keyup").pipe(
597
599
  S((s) => {
598
600
  const { pageTurnDirection: r, computedPageTurnMode: a } = t.settings.values;
599
601
  if (a === "scrollable")
@@ -613,7 +615,7 @@ const qn = (n) => (e) => {
613
615
  return s;
614
616
  })
615
617
  );
616
- return i(document).pipe($(t.$.destroy$)).subscribe(), t.spineItemsManager.items$.pipe(
618
+ return i(document).pipe(T(t.$.destroy$)).subscribe(), t.spineItemsManager.items$.pipe(
617
619
  w(
618
620
  (o) => P(
619
621
  ...o.map(
@@ -626,7 +628,7 @@ const qn = (n) => (e) => {
626
628
  )
627
629
  )
628
630
  ),
629
- $(t.$.destroy$)
631
+ T(t.$.destroy$)
630
632
  ).subscribe(), t;
631
633
  }, Zn = (n) => n.spine.spineItemsManager.items$.pipe(
632
634
  w(
@@ -634,25 +636,25 @@ const qn = (n) => (e) => {
634
636
  ...e.map((t) => t.watch("isLoaded").pipe(
635
637
  w(() => {
636
638
  const i = t.renderer.getDocumentFrame();
637
- if (!i || !i?.contentDocument) return he;
639
+ if (!i || !i?.contentDocument) return ge;
638
640
  const s = Array.from(
639
641
  i.contentDocument.querySelectorAll("a")
640
642
  ).map(
641
- (r) => q(r, "click")
643
+ (r) => X(r, "click")
642
644
  );
643
645
  return P(...s);
644
646
  })
645
647
  ))
646
648
  )
647
649
  ),
648
- x((e) => {
650
+ $((e) => {
649
651
  e.preventDefault();
650
652
  }),
651
- j()
653
+ D()
652
654
  );
653
- class Q extends se {
655
+ class Q extends ce {
654
656
  constructor(e) {
655
- super((t) => this.stateSubject.pipe($(this._destroy$)).subscribe(t)), this._destroy$ = new R(), this.destroy$ = this._destroy$.asObservable(), this.stateSubject = new Y(e);
657
+ super((t) => this.stateSubject.pipe(T(this._destroy$)).subscribe(t)), this._destroy$ = new R(), this.destroy$ = this._destroy$.asObservable(), this.stateSubject = new q(e);
656
658
  }
657
659
  next(e) {
658
660
  this.stateSubject.next(e);
@@ -662,12 +664,12 @@ class Q extends se {
662
664
  */
663
665
  mergeCompare(e) {
664
666
  const t = { ...this.value, ...e };
665
- U(this.value, t) || this.stateSubject.next(t);
667
+ O(this.value, t) || this.stateSubject.next(t);
666
668
  }
667
669
  watch(e) {
668
- return Array.isArray(e) ? this.stateSubject.pipe(Qe(e)) : this.stateSubject.pipe(
670
+ return Array.isArray(e) ? this.stateSubject.pipe(Ke(e)) : this.stateSubject.pipe(
669
671
  S((t) => t[e]),
670
- k(U)
672
+ N(O)
671
673
  );
672
674
  }
673
675
  get value() {
@@ -684,50 +686,49 @@ const Le = class Le extends Q {
684
686
  error: void 0
685
687
  }), this.triggerSubject = new R(), this.context = e.context, this.settings = e.settings, this.hookManager = e.hookManager, this.item = e.item, this.containerElement = e.containerElement, this.resourcesHandler = e.resourcesHandler, this.viewport = e.viewport;
686
688
  const t = this.triggerSubject.pipe(
687
- M((s) => s.type === "unload")
689
+ C((o) => o.type === "unload")
688
690
  ), i = this.triggerSubject.pipe(
689
- M((s) => s.type === "load")
691
+ C((o) => o.type === "load")
690
692
  );
691
693
  this.loaded$ = i.pipe(
692
- ge(() => this.value.state === "loaded" || this.value.state === "loading" ? _ : (this.next({ state: "loading", error: void 0 }), this.onCreateDocument().pipe(V()).pipe(
693
- ge((a) => (this.hookManager.execute("item.onDocumentCreated", this.item.id, {
694
+ pe(() => this.value.state === "loaded" || this.value.state === "loading" ? _ : (this.next({ state: "loading", error: void 0 }), this.onCreateDocument().pipe(U()).pipe(
695
+ pe((r) => (this.hookManager.execute("item.onDocumentCreated", this.item.id, {
694
696
  itemId: this.item.id,
695
- documentContainer: a
697
+ documentContainer: r
696
698
  }), this.onLoadDocument().pipe(
697
- ye(null),
698
- V()
699
+ fe(null),
700
+ U()
699
701
  ).pipe(
700
702
  De(this.context.bridgeEvent.viewportFree$),
701
703
  w(() => {
702
- const u = this.hookManager.execute("item.onDocumentLoad", this.item.id, {
704
+ const c = this.hookManager.execute("item.onDocumentLoad", this.item.id, {
703
705
  itemId: this.item.id,
704
- documentContainer: a
706
+ documentContainer: r
705
707
  }).filter(
706
- (l) => l instanceof se
708
+ (u) => u instanceof ce
707
709
  );
708
- return O([v(null), ...u]).pipe(V());
710
+ return j([v(null), ...c]).pipe(U());
709
711
  })
710
712
  ))),
711
713
  S(() => {
712
714
  this.next({ state: "loaded", error: void 0 });
713
715
  }),
714
- $(t)
716
+ T(t)
715
717
  ))),
716
- j()
717
- );
718
- const o = t.pipe(
719
- ge(() => this.value.state === "unloading" || this.value.state === "idle" ? _ : (this.next({ state: "unloading", error: void 0 }), this.context.bridgeEvent.viewportFree$.pipe(
720
- V(),
721
- w(() => (this.hookManager.destroy("item.onDocumentLoad", this.item.id), this.onUnload().pipe(ye(null), V()))),
722
- x(() => {
718
+ D()
719
+ ), this.unloaded$ = t.pipe(
720
+ pe(() => this.value.state === "unloading" || this.value.state === "idle" ? _ : (this.next({ state: "unloading", error: void 0 }), this.context.bridgeEvent.viewportFree$.pipe(
721
+ U(),
722
+ w(() => (this.hookManager.destroy("item.onDocumentLoad", this.item.id), this.onUnload().pipe(fe(null), U()))),
723
+ S(() => {
723
724
  this.next({ state: "idle", error: void 0 });
724
725
  }),
725
- $(i)
726
- )))
727
- );
728
- P(this.loaded$, o).pipe(
729
- Ue((s) => (this.next({ state: "error", error: s }), _)),
730
- $(this.destroy$)
726
+ T(i)
727
+ ))),
728
+ D()
729
+ ), P(this.loaded$, this.unloaded$).pipe(
730
+ ze((o) => (this.next({ state: "error", error: o }), _)),
731
+ T(this.destroy$)
731
732
  ).subscribe();
732
733
  }
733
734
  setDocumentContainer(e) {
@@ -758,9 +759,9 @@ const Le = class Le extends Q {
758
759
  */
759
760
  renderHeadless() {
760
761
  const e = new R();
761
- return Ft(() => this.onRenderHeadless({ release: e })).pipe(
762
- ye(void 0),
763
- V(),
762
+ return Tt(() => this.onRenderHeadless({ release: e })).pipe(
763
+ fe(void 0),
764
+ U(),
764
765
  S((t) => {
765
766
  if (t)
766
767
  return {
@@ -770,10 +771,10 @@ const Le = class Le extends Q {
770
771
  }
771
772
  };
772
773
  }),
773
- pe(() => {
774
+ me(() => {
774
775
  e.complete();
775
776
  }),
776
- Ue((t) => (D.error(t), v(void 0)))
777
+ ze((t) => (A.error(t), v(void 0)))
777
778
  );
778
779
  }
779
780
  layout(e) {
@@ -794,21 +795,21 @@ const Le = class Le extends Q {
794
795
  if (e) return e;
795
796
  const t = this.getDocumentFrame();
796
797
  if (t) {
797
- const { hasViewport: i } = Ke(t);
798
+ const { hasViewport: i } = Je(t);
798
799
  if (i) return "pre-paginated";
799
800
  }
800
801
  return this.context.manifest?.renditionLayout ?? "reflowable";
801
802
  }
802
803
  };
803
804
  Le.DOCUMENT_CONTAINER_CLASS_NAME = "prose-reader-document-container";
804
- let Se = Le;
805
+ let ye = Le;
805
806
  const Jn = (n) => new URL(n.href);
806
807
  class tt {
807
808
  constructor(e, t) {
808
809
  this.item = e, this.settings = t;
809
810
  }
810
811
  async getResource() {
811
- return await rn(
812
+ return await nn(
812
813
  this.settings.values.getResource?.(this.item) ?? v(void 0)
813
814
  ) ?? Jn(this.item);
814
815
  }
@@ -817,7 +818,7 @@ class tt {
817
818
  return e instanceof Response ? e : e instanceof URL ? fetch(e) : e;
818
819
  }
819
820
  }
820
- const kt = (n, e) => {
821
+ const Ot = (n, e) => {
821
822
  const t = n.startsWith("file://"), i = t ? n.replace("file://", "http://") : n, o = new URL(e, i).toString();
822
823
  return t ? o.replace("http://", "file://") : o;
823
824
  }, Kn = async (n, e, t, i, o) => {
@@ -837,7 +838,7 @@ const kt = (n, e) => {
837
838
  return h;
838
839
  const m = h.match(/url\(['"]?([^'"]+)['"]?\)/);
839
840
  if (!m) return h;
840
- const y = m[1] ?? "", f = i.manifest?.items.find(({ href: I }) => `${kt(t, y).toLowerCase()}`.endsWith(
841
+ const y = m[1] ?? "", f = i.manifest?.items.find(({ href: I }) => `${Ot(t, y).toLowerCase()}`.endsWith(
841
842
  `${I.toLowerCase()}`
842
843
  ));
843
844
  if (f) {
@@ -845,10 +846,10 @@ const kt = (n, e) => {
845
846
  try {
846
847
  const b = await I.getResource();
847
848
  if (b instanceof Response) {
848
- const F = await b.blob(), T = n.defaultView?.URL.createObjectURL(F);
849
+ const F = await b.blob(), x = n.defaultView?.URL.createObjectURL(F);
849
850
  return h.replace(
850
851
  m[0],
851
- `url("${T}")`
852
+ `url("${x}")`
852
853
  );
853
854
  }
854
855
  } catch (b) {
@@ -871,23 +872,23 @@ const kt = (n, e) => {
871
872
  }, Qn = (n, e, t, i, o) => {
872
873
  const s = e.getAttribute("src") || e.getAttribute("href");
873
874
  if (!s) return v(null);
874
- const r = i.manifest?.items.find(({ href: c }) => `${kt(t, s).toLowerCase()}`.endsWith(
875
+ const r = i.manifest?.items.find(({ href: c }) => `${Ot(t, s).toLowerCase()}`.endsWith(
875
876
  `${c.toLowerCase()}`
876
877
  ));
877
878
  if (!r) return v(null);
878
879
  const a = new tt(r, o);
879
- return A(a.getResource()).pipe(
880
- ge(
881
- (c) => c instanceof Response ? A(c.blob()) : v(void 0)
880
+ return k(a.getResource()).pipe(
881
+ pe(
882
+ (c) => c instanceof Response ? k(c.blob()) : v(void 0)
882
883
  ),
883
- ge((c) => {
884
+ pe((c) => {
884
885
  if (!c)
885
886
  return v(null);
886
887
  const u = n?.defaultView?.URL.createObjectURL(c) ?? "";
887
888
  if (e.hasAttribute("src"))
888
889
  e.setAttribute("src", u);
889
890
  else if (e.hasAttribute("href") && (e.setAttribute("href", u), n?.defaultView && e instanceof n.defaultView.HTMLLinkElement))
890
- return new se((l) => {
891
+ return new ce((l) => {
891
892
  e.onload = async () => {
892
893
  try {
893
894
  e.sheet && await Kn(
@@ -911,9 +912,9 @@ const kt = (n, e) => {
911
912
  context: t
912
913
  }) => (i) => i.pipe(
913
914
  w((o) => {
914
- const s = Rt(
915
+ const s = Et(
915
916
  o.contentDocument
916
- ), r = hn(e.href), a = s.map(
917
+ ), r = pn(e.href), a = s.map(
917
918
  (c) => Qn(
918
919
  o.contentDocument,
919
920
  c,
@@ -922,13 +923,13 @@ const kt = (n, e) => {
922
923
  n
923
924
  )
924
925
  );
925
- return O(a).pipe(S(() => o));
926
+ return j(a).pipe(S(() => o));
926
927
  })
927
928
  ), ti = (n) => {
928
- An(n?.contentDocument);
929
- }, Ys = "@prose-reader/core", qs = 0, Gs = 200, ni = [".xhtml", ".html", ".htm"], W = "prose-reader", Ut = `${W}-style`, ii = `data-${W}-id`, oi = `${W}-viewport`, si = `${W}-scroll-navigator`, ri = async (n, e) => {
929
+ Rn(n?.contentDocument);
930
+ }, Xs = "@prose-reader/core", Ys = 0, qs = 200, ni = [".xhtml", ".html", ".htm"], W = "prose-reader", Vt = `${W}-style`, ii = `data-${W}-id`, oi = `${W}-viewport`, si = `${W}-scroll-navigator`, ri = async (n, e) => {
930
931
  if (typeof n == "string") return n;
931
- const t = mn(n.headers.get("Content-Type") || "") || Me(e.href);
932
+ const t = gn(n.headers.get("Content-Type") || "") || Me(e.href);
932
933
  if (["image/jpg", "image/jpeg", "image/png", "image/webp"].some(
933
934
  (o) => o === t
934
935
  )) {
@@ -970,7 +971,7 @@ const kt = (n, e) => {
970
971
  }) => {
971
972
  const t = (i) => ri(i, n);
972
973
  return (i) => i.pipe(
973
- w((o) => A(e.getResource()).pipe(
974
+ w((o) => k(e.getResource()).pipe(
974
975
  w((s) => s instanceof URL && n.href.startsWith(window.location.origin) && // we have an encoding and it's a valid html
975
976
  (n.mediaType && [
976
977
  "application/xhtml+xml",
@@ -980,23 +981,23 @@ const kt = (n, e) => {
980
981
  ].includes(n.mediaType) || // no encoding ? then try to detect html
981
982
  !n.mediaType && ni.some(
982
983
  (a) => n.href.endsWith(a)
983
- )) ? (o?.setAttribute("src", n.href), v(o)) : (s instanceof URL ? A(e.fetchResource()) : v(s)).pipe(
984
+ )) ? (o?.setAttribute("src", n.href), v(o)) : (s instanceof URL ? k(e.fetchResource()) : v(s)).pipe(
984
985
  w((a) => {
985
986
  if (!(a instanceof Response))
986
987
  throw new Error("Invalid resource");
987
- return A(t(a));
988
+ return k(t(a));
988
989
  }),
989
- x((a) => {
990
+ $((a) => {
990
991
  if (a) {
991
992
  const c = new Blob([a], { type: "text/html" }), u = URL.createObjectURL(c);
992
993
  o?.setAttribute("src", u);
993
994
  }
994
995
  }),
995
996
  S(() => o),
996
- Ue((a) => (D.error(
997
+ ze((a) => (A.error(
997
998
  `Error while trying to fetch or load resource for item ${n.id}`,
998
999
  s
999
- ), D.error(a), v(o)))
1000
+ ), A.error(a), v(o)))
1000
1001
  ))
1001
1002
  ))
1002
1003
  );
@@ -1015,12 +1016,12 @@ const kt = (n, e) => {
1015
1016
  border: 0px none transparent;
1016
1017
  padding: 0px;
1017
1018
  `, n.setAttribute("role", "main"), n;
1018
- }, ui = "body{margin:0}html,body{height:100%;width:100%}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] body{display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=left] body{justify-content:flex-end}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=right] body{justify-content:flex-start}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=none] body{justify-content:center}:not(html.prose-reader-html-renderer-touch-enabled),:not(html.prose-reader-html-renderer-touch-enabled) body{touch-action:none}img{-webkit-user-select:none;user-select:none;-webkit-user-drag:none;-khtml-user-drag:none;-moz-user-drag:none;-o-user-drag:none;display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] img{max-width:100%;height:100%;object-fit:contain}", zt = ({
1019
+ }, ui = "body{margin:0}html,body{height:100%;width:100%}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] body{display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=left] body{justify-content:flex-end}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=right] body{justify-content:flex-start}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=none] body{justify-content:center}:not(html.prose-reader-html-renderer-touch-enabled),:not(html.prose-reader-html-renderer-touch-enabled) body{touch-action:none}img{-webkit-user-select:none;user-select:none;-webkit-user-drag:none;-khtml-user-drag:none;-moz-user-drag:none;-o-user-drag:none;display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] img{max-width:100%;height:100%;object-fit:contain}", jt = ({
1019
1020
  pageHeight: n,
1020
1021
  pageWidth: e,
1021
1022
  frameElement: t
1022
1023
  }) => {
1023
- const i = Ke(t);
1024
+ const i = Je(t);
1024
1025
  if (t?.contentDocument && t.contentWindow && i) {
1025
1026
  const o = e / (i.width ?? 1);
1026
1027
  return { computedScale: Math.min(
@@ -1028,7 +1029,7 @@ const kt = (n, e) => {
1028
1029
  n / (i.height ?? 1)
1029
1030
  ), computedWidthScale: o, viewportDimensions: i };
1030
1031
  }
1031
- }, lt = (n, e) => {
1032
+ }, ut = (n, e) => {
1032
1033
  n.style.width = `${e.width}px`, n.style.height = `${e.height}px`;
1033
1034
  }, li = ({
1034
1035
  minPageSpread: n,
@@ -1041,14 +1042,14 @@ const kt = (n, e) => {
1041
1042
  }) => {
1042
1043
  const a = n * o;
1043
1044
  if (s?.contentDocument && s?.contentWindow) {
1044
- const { viewportDimensions: c, computedScale: u = 1 } = zt({ frameElement: s, pageHeight: i, pageWidth: o }) ?? {}, l = !!c, d = o, p = i;
1045
+ const { viewportDimensions: c, computedScale: u = 1 } = jt({ frameElement: s, pageHeight: i, pageWidth: o }) ?? {}, l = !!c, d = o, p = i;
1045
1046
  if (s.contentDocument?.documentElement && s.contentDocument?.documentElement.setAttribute(
1046
1047
  "data-prose-reader-html-renderer-has-viewport-dimensions",
1047
1048
  l.toString()
1048
- ), c ? lt(s, {
1049
+ ), c ? ut(s, {
1049
1050
  width: c.width ?? 1,
1050
1051
  height: c.height ?? 1
1051
- }) : lt(s, {
1052
+ }) : ut(s, {
1052
1053
  width: d,
1053
1054
  height: p
1054
1055
  }), c) {
@@ -1209,7 +1210,7 @@ const kt = (n, e) => {
1209
1210
  }) => {
1210
1211
  const l = o * e, d = i?.renditionLayout === "reflowable" && i?.renditionFlow === "scrolled-continuous", p = d ? Math.min(400, n) : n;
1211
1212
  t?.style.setProperty("width", `${e}px`), d ? t?.style.removeProperty("height") : t?.style.setProperty("height", `${p}px`);
1212
- const { viewportDimensions: g, computedScale: h = 1 } = zt({
1213
+ const { viewportDimensions: g, computedScale: h = 1 } = jt({
1213
1214
  frameElement: t,
1214
1215
  pageHeight: p,
1215
1216
  pageWidth: e
@@ -1268,7 +1269,7 @@ const kt = (n, e) => {
1268
1269
  return y % l === 0 ? t?.style.setProperty("margin-left", "0px") : (y = y + e, s && !u && t?.style.setProperty("margin-left", `${e}px`)), { width: y, height: f };
1269
1270
  }
1270
1271
  };
1271
- class fi extends Se {
1272
+ class fi extends ye {
1272
1273
  constructor() {
1273
1274
  super(...arguments), this.isPrePaginated = () => this.item.renditionLayout === "pre-paginated" || !this.item.renditionLayout && this.context.manifest?.renditionLayout === "pre-paginated", this.isImageType = () => !!(this.item.mediaType ?? Me(this.item.href))?.startsWith("image/");
1274
1275
  }
@@ -1286,11 +1287,11 @@ class fi extends Se {
1286
1287
  settings: this.settings
1287
1288
  }),
1288
1289
  De(this.context.bridgeEvent.viewportFree$),
1289
- x(() => {
1290
+ $(() => {
1290
1291
  this.attach();
1291
1292
  }),
1292
1293
  jn,
1293
- x((t) => {
1294
+ $((t) => {
1294
1295
  this.isPrePaginated() ? oe(t, "prose-reader-css", ui) : this.isImageType();
1295
1296
  }),
1296
1297
  ei({
@@ -1351,7 +1352,7 @@ class fi extends Se {
1351
1352
  return v(u);
1352
1353
  }
1353
1354
  onRenderHeadless() {
1354
- return A(this.resourcesHandler.fetchResource()).pipe(
1355
+ return k(this.resourcesHandler.fetchResource()).pipe(
1355
1356
  w((e) => {
1356
1357
  if (e instanceof Response) {
1357
1358
  const t = e.headers.get("content-type") ?? "";
@@ -1361,7 +1362,7 @@ class fi extends Se {
1361
1362
  "text/html",
1362
1363
  "text/xml"
1363
1364
  ].includes(t))
1364
- return A(e.text()).pipe(
1365
+ return k(e.text()).pipe(
1365
1366
  S((o) => new DOMParser().parseFromString(
1366
1367
  o,
1367
1368
  t
@@ -1411,7 +1412,7 @@ const yi = (n) => (e) => {
1411
1412
  return e.getRenderer?.(o) ?? ((r) => new fi(r));
1412
1413
  }
1413
1414
  }), i = Zn(t);
1414
- return i.pipe($(t.$.destroy$)).subscribe(), {
1415
+ return i.pipe(T(t.$.destroy$)).subscribe(), {
1415
1416
  ...t,
1416
1417
  links$: i
1417
1418
  };
@@ -1424,7 +1425,7 @@ class nt {
1424
1425
  this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.width = e.width, this.height = e.height, this.x = e.x, this.y = e.y;
1425
1426
  }
1426
1427
  }
1427
- class C {
1428
+ class E {
1428
1429
  constructor(e) {
1429
1430
  this.__symbol = /* @__PURE__ */ Symbol("SpineItemPosition"), this.x = e.x, this.y = e.y;
1430
1431
  }
@@ -1439,7 +1440,7 @@ class Si extends nt {
1439
1440
  super(...arguments), this.__symbol = "SpineItemPageLayout";
1440
1441
  }
1441
1442
  }
1442
- class He extends nt {
1443
+ class Oe extends nt {
1443
1444
  constructor() {
1444
1445
  super(...arguments), this.__symbol = "SpineItemSpineLayout";
1445
1446
  }
@@ -1449,25 +1450,25 @@ class Ii extends nt {
1449
1450
  super(...arguments), this.__symbol = "SpineItemPageSpineLayout";
1450
1451
  }
1451
1452
  }
1452
- class Wt {
1453
+ class kt {
1453
1454
  constructor(e) {
1454
1455
  this.x = e.x, this.y = e.y;
1455
1456
  }
1456
1457
  }
1457
- class L extends Wt {
1458
+ class M extends kt {
1458
1459
  constructor() {
1459
1460
  super(...arguments), this.__symbol = "SpinePosition";
1460
1461
  }
1461
1462
  static from(e) {
1462
- return new L(e);
1463
+ return new M(e);
1463
1464
  }
1464
1465
  }
1465
- class ue extends Wt {
1466
+ class ae extends kt {
1466
1467
  constructor() {
1467
1468
  super(...arguments), this.__symbol = "UnboundSpinePosition";
1468
1469
  }
1469
1470
  static from(e) {
1470
- return new ue(e);
1471
+ return new ae(e);
1471
1472
  }
1472
1473
  }
1473
1474
  const bi = (n, e) => {
@@ -1476,14 +1477,14 @@ const bi = (n, e) => {
1476
1477
  x: u / a,
1477
1478
  y: l / c
1478
1479
  };
1479
- }, vi = (n, e) => new ue(
1480
+ }, vi = (n, e) => new ae(
1480
1481
  bi(n, e)
1481
1482
  ), wi = (n) => ({
1482
1483
  getSpinePositionFromClientPosition: (e) => n.spine.element ? vi(e, n.spine.element) : void 0
1483
1484
  }), Pi = (n) => {
1484
1485
  let e;
1485
1486
  const t = n.context.watch("rootElement").pipe(
1486
- X((c) => c ? new se(() => (e = c.ownerDocument.createElement("div"), e.style.cssText = `
1487
+ Y((c) => c ? new ce(() => (e = c.ownerDocument.createElement("div"), e.style.cssText = `
1487
1488
  position: absolute;
1488
1489
  left: 0;
1489
1490
  top: 0;
@@ -1492,40 +1493,40 @@ const bi = (n, e) => {
1492
1493
  visibility: hidden;
1493
1494
  `, c.appendChild(e), () => {
1494
1495
  e?.remove(), e = void 0;
1495
- })) : he)
1496
- ), i = (c) => an(c, ce).pipe(
1497
- N(() => {
1496
+ })) : ge)
1497
+ ), i = (c) => on(c, re).pipe(
1498
+ V(() => {
1498
1499
  e?.style.setProperty(
1499
1500
  "visibility",
1500
1501
  "hidden"
1501
1502
  );
1502
1503
  })
1503
1504
  ), o = n.context.bridgeEvent.viewportBusy$.pipe(
1504
- N(() => {
1505
+ V(() => {
1505
1506
  e?.style.setProperty(
1506
1507
  "visibility",
1507
1508
  "visible"
1508
1509
  );
1509
1510
  })
1510
1511
  ), s = i(n.viewportFree$).pipe(
1511
- In(1)
1512
+ Sn(1)
1512
1513
  ), a = n.settings.values$.pipe(
1513
1514
  ie(() => n.settings.values.computedPageTurnMode),
1514
- fe()
1515
+ be()
1515
1516
  ).pipe(
1516
- X(
1517
- (c) => c === "controlled" ? o.pipe(X(() => s)) : i(v(void 0))
1517
+ Y(
1518
+ (c) => c === "controlled" ? o.pipe(Y(() => s)) : i(v(void 0))
1518
1519
  ),
1519
1520
  K(n.$.destroy$)
1520
1521
  );
1521
1522
  return P(t, a);
1522
- }, xi = `${W}-enhancer-loading`, _t = `${xi}-container`, $i = ({
1523
+ }, xi = `${W}-enhancer-loading`, Ut = `${xi}-container`, $i = ({
1523
1524
  container: n,
1524
1525
  item: e,
1525
1526
  viewport: t
1526
1527
  }) => {
1527
1528
  const i = n.ownerDocument.createElement("div");
1528
- i.classList.add(_t), i.style.cssText = `
1529
+ i.classList.add(Ut), i.style.cssText = `
1529
1530
  height: 100%;
1530
1531
  width: 100%;
1531
1532
  max-width: ${t.absoluteViewport.width}px;
@@ -1555,12 +1556,12 @@ const bi = (n, e) => {
1555
1556
  width: 80%;
1556
1557
  `, i.appendChild(o), i.appendChild(s), i;
1557
1558
  }, Ti = (n) => n.spineItemsManager.items$.pipe(
1558
- X(
1559
+ Y(
1559
1560
  (e) => P(
1560
1561
  ...e.map((t) => {
1561
1562
  t.containerElement.style.zIndex = "0";
1562
1563
  const i = t.containerElement.querySelector(
1563
- `.${_t}`
1564
+ `.${Ut}`
1564
1565
  ), o = i instanceof HTMLElement ? i : $i({
1565
1566
  container: t.containerElement,
1566
1567
  item: t.item,
@@ -1568,7 +1569,7 @@ const bi = (n, e) => {
1568
1569
  });
1569
1570
  return t.containerElement.appendChild(o), P(
1570
1571
  t.pipe(
1571
- N((s) => {
1572
+ V((s) => {
1572
1573
  if (o.style.setProperty(
1573
1574
  "visibility",
1574
1575
  s.isReady ? "hidden" : "visible"
@@ -1583,8 +1584,8 @@ const bi = (n, e) => {
1583
1584
  }
1584
1585
  })
1585
1586
  ),
1586
- O([n.spine.layout$, n.theme.$.theme$]).pipe(
1587
- N(([, s]) => {
1587
+ j([n.spine.layout$, n.theme.$.theme$]).pipe(
1588
+ V(([, s]) => {
1588
1589
  const r = n.viewport.absoluteViewport.width;
1589
1590
  o.style.setProperty(
1590
1591
  "max-width",
@@ -1610,7 +1611,7 @@ const bi = (n, e) => {
1610
1611
  const o = n.spineItemsManager.get(e.id), s = o?.renderer.getDocumentFrame();
1611
1612
  if (o?.renditionLayout !== "reflowable" || !(s instanceof HTMLIFrameElement))
1612
1613
  return;
1613
- const { hasViewport: r } = Ke(s), { width: a } = n.viewport.pageSize, c = o?.renderer.getDocumentFrame();
1614
+ const { hasViewport: r } = Je(s), { width: a } = n.viewport.pageSize, c = o?.renderer.getDocumentFrame();
1614
1615
  if (r) {
1615
1616
  const u = a < i;
1616
1617
  t === "none" && u && c instanceof HTMLIFrameElement && c?.style.setProperty(
@@ -1620,25 +1621,17 @@ const bi = (n, e) => {
1620
1621
  }
1621
1622
  }
1622
1623
  );
1623
- }, Mi = (n) => n.spineItemsManager.items$.pipe(
1624
- w(
1625
- (e) => P(
1626
- ...e.map(
1627
- (t) => t.pipe(
1628
- x((i) => {
1629
- t.containerElement.dataset.isDirty = i.iDirty.toString(), t.containerElement.dataset.isReady = i.isReady.toString();
1630
- })
1631
- )
1632
- )
1633
- )
1634
- )
1624
+ }, Mi = (n) => n.spineItemsObserver.states$.pipe(
1625
+ $(({ item: e, isReady: t, isDirty: i }) => {
1626
+ e.containerElement.dataset.isDirty = i.toString(), e.containerElement.dataset.isReady = t.toString();
1627
+ })
1635
1628
  );
1636
- let Ci = class extends jt {
1629
+ let Ci = class extends Nt {
1637
1630
  computeOutputSettings(e) {
1638
1631
  return e;
1639
1632
  }
1640
1633
  hasSettingsChanged(e) {
1641
- return !U(this.outputSettings, e);
1634
+ return !O(this.outputSettings, e);
1642
1635
  }
1643
1636
  getCleanedParentInputSettings(e) {
1644
1637
  const {
@@ -1659,11 +1652,11 @@ let Ci = class extends jt {
1659
1652
  };
1660
1653
  }
1661
1654
  };
1662
- const Ei = (n) => O([
1655
+ const Ei = (n) => j([
1663
1656
  n.viewport.watch(["width", "height"]),
1664
1657
  n.context.watch("manifest")
1665
1658
  ]).pipe(
1666
- x(([{ width: e, height: t }, i]) => {
1659
+ $(([{ width: e, height: t }, i]) => {
1667
1660
  const o = e > t;
1668
1661
  return !o && i?.renditionSpread === "portrait" ? n.settings.update({ spreadMode: !0 }) : o && (i?.renditionSpread === void 0 || i?.renditionSpread === "auto" || i?.renditionSpread === "landscape" || i?.renditionSpread === "both") ? n.settings.update({ spreadMode: !0 }) : n.settings.update({ spreadMode: !1 });
1669
1662
  })
@@ -1689,33 +1682,33 @@ const Ei = (n) => O([
1689
1682
  !m && f && (f.getBoundingClientRect().left, m = !0);
1690
1683
  });
1691
1684
  }), r.hookManager.register("item.onBeforeLayout", ({ item: m }) => {
1692
- const y = r.spineItemsManager.get(m.id), I = !!(m.mediaType ?? Me(m.href))?.startsWith("image/"), { pageHorizontalMargin: b = 0, pageVerticalMargin: F = 0 } = a.values, T = r.viewport.pageSize;
1685
+ const y = r.spineItemsManager.get(m.id), I = !!(m.mediaType ?? Me(m.href))?.startsWith("image/"), { pageHorizontalMargin: b = 0, pageVerticalMargin: F = 0 } = a.values, x = r.viewport.pageSize;
1693
1686
  if (y?.renditionLayout === "reflowable" && !I) {
1694
- let E = T.width - b * 2;
1695
- const H = T.height - F * 2;
1696
- let B = T.width - b * 2, re = b * 2;
1697
- y.isUsingVerticalWriting() && (B = T.width - b * 2, E = H, re = F * 2);
1698
- const le = y?.renderer.getDocumentFrame();
1699
- le && oe(
1700
- le,
1687
+ let L = x.width - b * 2;
1688
+ const H = x.height - F * 2;
1689
+ let B = x.width - b * 2, se = b * 2;
1690
+ y.isUsingVerticalWriting() && (B = x.width - b * 2, L = H, se = F * 2);
1691
+ const ue = y?.renderer.getDocumentFrame();
1692
+ ue && oe(
1693
+ ue,
1701
1694
  "prose-layout-enhancer-css",
1702
1695
  `
1703
1696
  body {
1704
1697
  width: ${B}px !important;
1705
1698
  margin: ${F}px ${b}px !important;
1706
- column-gap: ${re}px !important;
1707
- column-width: ${E}px !important;
1699
+ column-gap: ${se}px !important;
1700
+ column-width: ${L}px !important;
1708
1701
  height: ${H}px !important;
1709
1702
  }
1710
1703
  img, video, audio, object, svg {
1711
- -max-width: ${E}px !important;
1704
+ -max-width: ${L}px !important;
1712
1705
  -max-height: ${H}px !important;
1713
1706
  }
1714
1707
  table {
1715
- max-width: ${E}px !important;
1708
+ max-width: ${L}px !important;
1716
1709
  }
1717
1710
  td {
1718
- max-width: ${E}px;
1711
+ max-width: ${L}px;
1719
1712
  }
1720
1713
  `
1721
1714
  );
@@ -1729,32 +1722,32 @@ const Ei = (n) => O([
1729
1722
  const f = r.spineItemsManager.get(m.id)?.renderer.documentContainer;
1730
1723
  r.settings.values.computedPageTurnMode !== "scrollable" && f?.setAttribute("tab-index", "0");
1731
1724
  });
1732
- const c = r.spineItemsObserver.itemIsReady$.pipe(
1733
- ae(({ isReady: m }) => m),
1734
- N(({ item: m }) => {
1725
+ const c = r.spineItemsObserver.states$.pipe(
1726
+ de(({ isReady: m }) => m),
1727
+ V(({ item: m }) => {
1735
1728
  const y = m.renderer.documentContainer;
1736
1729
  y && (y.style.opacity = "1");
1737
1730
  })
1738
1731
  ), u = a.values$.pipe(
1739
- ae(({ layoutAutoResize: m }) => m === "container"),
1740
- X(() => r.context.watch("rootElement")),
1741
- ae(Z),
1742
- X((m) => et(m)),
1743
- bn(100),
1744
- ae(Z),
1745
- N(() => {
1732
+ de(({ layoutAutoResize: m }) => m === "container"),
1733
+ Y(() => r.context.watch("rootElement")),
1734
+ de(Z),
1735
+ Y((m) => Qe(m)),
1736
+ In(100),
1737
+ de(Z),
1738
+ V(() => {
1746
1739
  r?.layout();
1747
1740
  })
1748
1741
  ), l = Pi(r);
1749
1742
  a.watch(["pageHorizontalMargin", "pageVerticalMargin"]).pipe(
1750
- Ct(1),
1751
- N(() => {
1743
+ Lt(1),
1744
+ V(() => {
1752
1745
  r.layout();
1753
1746
  }),
1754
1747
  K(r.$.destroy$)
1755
1748
  ).subscribe();
1756
1749
  const d = r.spine.pages.pipe(
1757
- Ze({ refCount: !0, bufferSize: 1 })
1750
+ Ge({ refCount: !0, bufferSize: 1 })
1758
1751
  ), p = Mi(r), g = Ei(r), h = Ti(r);
1759
1752
  return P(
1760
1753
  c,
@@ -1775,7 +1768,7 @@ const Ei = (n) => O([
1775
1768
  coordinates: wi(r)
1776
1769
  };
1777
1770
  };
1778
- class Ri extends Se {
1771
+ class Ai extends ye {
1779
1772
  getImageElement() {
1780
1773
  const e = this.documentContainer;
1781
1774
  if (e instanceof HTMLImageElement)
@@ -1783,12 +1776,12 @@ class Ri extends Se {
1783
1776
  }
1784
1777
  onCreateDocument() {
1785
1778
  const e = this.containerElement.ownerDocument.createElement("img");
1786
- return A(this.resourcesHandler.getResource()).pipe(
1779
+ return k(this.resourcesHandler.getResource()).pipe(
1787
1780
  w((t) => {
1788
1781
  if (this.setDocumentContainer(e), e.style.objectFit = "contain", e.style.userSelect = "none", t instanceof URL)
1789
1782
  return v(t.href);
1790
1783
  if (t instanceof Response)
1791
- return A(t.blob()).pipe(
1784
+ return k(t.blob()).pipe(
1792
1785
  S((i) => URL.createObjectURL(i))
1793
1786
  );
1794
1787
  throw new Error("Invalid resource");
@@ -1802,7 +1795,7 @@ class Ri extends Se {
1802
1795
  onLoadDocument() {
1803
1796
  const e = this.getImageElement();
1804
1797
  if (!e) throw new Error("invalid element");
1805
- return this.attach(), q(e, "load");
1798
+ return this.attach(), X(e, "load");
1806
1799
  }
1807
1800
  onUnload() {
1808
1801
  const e = this.getImageElement();
@@ -1827,12 +1820,12 @@ class Ri extends Se {
1827
1820
  getDocumentFrame() {
1828
1821
  }
1829
1822
  }
1830
- const Ai = (n) => (e) => {
1823
+ const Ri = (n) => (e) => {
1831
1824
  const t = n({
1832
1825
  ...e,
1833
1826
  getRenderer(r) {
1834
1827
  const a = e.getRenderer?.(r), u = !!(r.mediaType ?? Me(r.href))?.startsWith("image/");
1835
- return !a && u ? (l) => new Ri(l) : a;
1828
+ return !a && u ? (l) => new Ai(l) : a;
1836
1829
  }
1837
1830
  }), i = new IntersectionObserver(
1838
1831
  (r) => {
@@ -1883,32 +1876,32 @@ const Ai = (n) => (e) => {
1883
1876
  }
1884
1877
  };
1885
1878
  }, Ni = (n, e) => n.links$.pipe(
1886
- x((t) => {
1879
+ $((t) => {
1887
1880
  if (!Nn(t.target, "a") || t.type !== "click") return;
1888
1881
  const i = new URL(t.target.href), o = `${i.origin}${i.pathname}`;
1889
1882
  n.context.manifest?.spineItems.some(
1890
1883
  (r) => r.href === o
1891
1884
  ) && e.goToUrl(i);
1892
1885
  })
1893
- ), ee = D.namespace("navigation"), Oi = ({
1886
+ ), ee = A.namespace("navigation"), Oi = ({
1894
1887
  position: n,
1895
1888
  spineItem: e,
1896
1889
  pageHeight: t,
1897
1890
  pageWidth: i,
1898
1891
  spineItemLocator: o
1899
1892
  }) => {
1900
- let s = new C({
1893
+ let s = new E({
1901
1894
  x: n.x - i,
1902
1895
  y: n.y
1903
1896
  });
1904
- return e.isUsingVerticalWriting() && (s = new C({
1897
+ return e.isUsingVerticalWriting() && (s = new E({
1905
1898
  x: n.x,
1906
1899
  y: n.y + t
1907
1900
  })), o.getSpineItemClosestPositionFromUnsafePosition(
1908
1901
  s,
1909
1902
  e
1910
1903
  );
1911
- }, dt = ({
1904
+ }, lt = ({
1912
1905
  position: n,
1913
1906
  navigationResolver: e,
1914
1907
  computedPageTurnDirection: t,
@@ -1936,10 +1929,10 @@ const Ai = (n) => (e) => {
1936
1929
  spineItemPosition: l,
1937
1930
  spineItem: a
1938
1931
  }) : e.fromUnboundSpinePosition(
1939
- r === "horizontal" ? new L({
1932
+ r === "horizontal" ? new M({
1940
1933
  x: n.x - s.pageSize.width,
1941
1934
  y: 0
1942
- }) : new L({
1935
+ }) : new M({
1943
1936
  y: n.y - s.pageSize.height,
1944
1937
  x: 0
1945
1938
  })
@@ -1955,7 +1948,7 @@ const Ai = (n) => (e) => {
1955
1948
  viewport: a,
1956
1949
  settings: c
1957
1950
  }) => {
1958
- const u = dt({
1951
+ const u = lt({
1959
1952
  position: n,
1960
1953
  viewport: a,
1961
1954
  navigationResolver: i,
@@ -1977,7 +1970,7 @@ const Ai = (n) => (e) => {
1977
1970
  );
1978
1971
  if (r === "vertical" && n.y !== u.y)
1979
1972
  return i.getAdjustedPositionForSpread(u);
1980
- const l = dt({
1973
+ const l = lt({
1981
1974
  position: u,
1982
1975
  viewport: a,
1983
1976
  navigationResolver: i,
@@ -1995,18 +1988,18 @@ const Ai = (n) => (e) => {
1995
1988
  pageWidth: i,
1996
1989
  spineItemLocator: o
1997
1990
  }) => {
1998
- let s = new C({
1991
+ let s = new E({
1999
1992
  x: n.x + i,
2000
1993
  y: n.y
2001
1994
  });
2002
- return e.isUsingVerticalWriting() && (s = new C({
1995
+ return e.isUsingVerticalWriting() && (s = new E({
2003
1996
  x: n.x,
2004
1997
  y: n.y - t
2005
1998
  })), o.getSpineItemClosestPositionFromUnsafePosition(
2006
1999
  s,
2007
2000
  e
2008
2001
  );
2009
- }, pt = ({
2002
+ }, dt = ({
2010
2003
  position: n,
2011
2004
  navigationResolver: e,
2012
2005
  computedPageTurnDirection: t,
@@ -2034,10 +2027,10 @@ const Ai = (n) => (e) => {
2034
2027
  spineItemPosition: l,
2035
2028
  spineItem: a
2036
2029
  }) : e.fromUnboundSpinePosition(
2037
- r === "horizontal" ? new ue({
2030
+ r === "horizontal" ? new ae({
2038
2031
  x: n.x + s.pageSize.width,
2039
2032
  y: 0
2040
- }) : new ue({
2033
+ }) : new ae({
2041
2034
  y: n.y + s.pageSize.height,
2042
2035
  x: 0
2043
2036
  })
@@ -2053,7 +2046,7 @@ const Ai = (n) => (e) => {
2053
2046
  viewport: a,
2054
2047
  settings: c
2055
2048
  }) => {
2056
- const u = pt({
2049
+ const u = dt({
2057
2050
  position: n,
2058
2051
  viewport: a,
2059
2052
  navigationResolver: i,
@@ -2078,7 +2071,7 @@ const Ai = (n) => (e) => {
2078
2071
  );
2079
2072
  if (r === "vertical" && n.y !== u.y)
2080
2073
  return i.getAdjustedPositionForSpread(u);
2081
- const l = pt({
2074
+ const l = dt({
2082
2075
  position: u,
2083
2076
  viewport: a,
2084
2077
  navigationResolver: i,
@@ -2092,7 +2085,7 @@ const Ai = (n) => (e) => {
2092
2085
  };
2093
2086
  class Ui {
2094
2087
  constructor(e) {
2095
- this.reader = e, this.movingLastDelta = { x: 0, y: 0 }, this.movingLastPosition = new L({ x: 0, y: 0 }), this.unlock = void 0;
2088
+ this.reader = e, this.movingLastDelta = { x: 0, y: 0 }, this.movingLastPosition = new M({ x: 0, y: 0 }), this.unlock = void 0;
2096
2089
  }
2097
2090
  turnRight() {
2098
2091
  return this.turnRightOrBottom();
@@ -2273,8 +2266,8 @@ class zi extends Q {
2273
2266
  constructor(e) {
2274
2267
  super({
2275
2268
  lastDelta: { x: 0, y: 0 },
2276
- lastPosition: new L({ x: 0, y: 0 }),
2277
- lastStartPosition: new L({ x: 0, y: 0 }),
2269
+ lastPosition: new M({ x: 0, y: 0 }),
2270
+ lastStartPosition: new M({ x: 0, y: 0 }),
2278
2271
  isStarted: !1
2279
2272
  }), this.reader = e, this.unlock = void 0;
2280
2273
  }
@@ -2310,7 +2303,7 @@ class zi extends Q {
2310
2303
  ), c = Math.floor(
2311
2304
  t === "horizontal" ? 0 : this.value.lastPosition.y - r / o
2312
2305
  );
2313
- i = new L({
2306
+ i = new M({
2314
2307
  x: a,
2315
2308
  y: c
2316
2309
  }), this.mergeCompare({
@@ -2339,18 +2332,18 @@ class _i extends G {
2339
2332
  constructor(e, t) {
2340
2333
  super(), this.scrollNavigationController = e, this.locker = t, this.navigationSubject = new R(), this.navigation$ = this.navigationSubject.asObservable();
2341
2334
  const i = this.scrollNavigationController.userScroll$.pipe(
2342
- ze((o) => {
2335
+ sn((o) => {
2343
2336
  const s = this.locker.lock();
2344
2337
  return P(
2345
2338
  this.scrollNavigationController.userScroll$,
2346
2339
  v(o)
2347
2340
  ).pipe(
2348
- be(
2341
+ Ie(
2349
2342
  Wi,
2350
- ce
2343
+ re
2351
2344
  ),
2352
- V(),
2353
- x(() => {
2345
+ U(),
2346
+ $(() => {
2354
2347
  const r = this.scrollNavigationController.fromScrollPosition(
2355
2348
  this.scrollNavigationController.scrollPosition
2356
2349
  );
@@ -2360,13 +2353,13 @@ class _i extends G {
2360
2353
  position: r
2361
2354
  });
2362
2355
  }),
2363
- pe(() => {
2356
+ me(() => {
2364
2357
  s();
2365
2358
  })
2366
2359
  );
2367
2360
  })
2368
2361
  );
2369
- P(i).pipe($(this.destroy$)).subscribe();
2362
+ P(i).pipe(T(this.destroy$)).subscribe();
2370
2363
  }
2371
2364
  }
2372
2365
  const Hi = (n) => n.pagination.state$.pipe(
@@ -2388,33 +2381,33 @@ const Hi = (n) => n.pagination.state$.pipe(
2388
2381
  };
2389
2382
  }
2390
2383
  ),
2391
- k(U)
2384
+ N(O)
2392
2385
  ), Bi = ({ reader: n, duration: e }) => (t) => {
2393
2386
  let i;
2394
2387
  const o = () => {
2395
2388
  i?.(), i = void 0;
2396
2389
  };
2397
2390
  return t.pipe(
2398
- x(() => {
2391
+ $(() => {
2399
2392
  i || (i = n?.navigation.lock());
2400
2393
  }),
2401
- cn(e, ce, {
2394
+ rn(e, re, {
2402
2395
  trailing: !0,
2403
2396
  leading: !0
2404
2397
  }),
2405
- x(o),
2406
- pe(o)
2398
+ $(o),
2399
+ me(o)
2407
2400
  );
2408
2401
  }, Xi = (n) => (e) => {
2409
2402
  const t = n(e), i = Hi(t), o = new Ui(t), s = new zi(t), r = new _i(
2410
2403
  t.navigation.scrollNavigationController,
2411
2404
  t.navigation.locker
2412
2405
  ), a = Ni(t, o), c = r.navigation$.pipe(
2413
- x((d) => {
2406
+ $((d) => {
2414
2407
  t.navigation.navigate(d);
2415
2408
  })
2416
2409
  );
2417
- return P(a, c).pipe($(t.$.destroy$)).subscribe(), {
2410
+ return P(a, c).pipe(T(t.$.destroy$)).subscribe(), {
2418
2411
  ...t,
2419
2412
  load: (d) => {
2420
2413
  const { cfi: p, ...g } = d;
@@ -2449,7 +2442,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2449
2442
  goToAbsolutePageIndex: o.goToAbsolutePageIndex.bind(o)
2450
2443
  }
2451
2444
  };
2452
- }, Ht = (n, e, t) => {
2445
+ }, zt = (n, e, t) => {
2453
2446
  const i = t.spineItems.findIndex(
2454
2447
  (o) => o.href === n
2455
2448
  );
@@ -2466,7 +2459,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2466
2459
  const m = {
2467
2460
  title: s.title,
2468
2461
  path: s.path
2469
- }, y = Ht(n, s.contents, t);
2462
+ }, y = zt(n, s.contents, t);
2470
2463
  return y ? {
2471
2464
  ...m,
2472
2465
  subChapter: y
@@ -2476,7 +2469,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2476
2469
  }, void 0);
2477
2470
  }, Yi = (n, e) => {
2478
2471
  const { href: t } = e;
2479
- return Ht(t, n.nav?.toc ?? [], n);
2472
+ return zt(t, n.nav?.toc ?? [], n);
2480
2473
  }, qi = (n) => {
2481
2474
  const e = n.context.manifest, t = n.spineItemsManager.items;
2482
2475
  return e ? t.reduce(
@@ -2487,7 +2480,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2487
2480
  ne([]),
2488
2481
  S(() => qi(n))
2489
2482
  ), Zi = (n, e, t) => n + e * t, Ji = (n, e, t) => {
2490
- const { height: i, width: o } = t.layout.layoutInfo, { top: s, left: r } = n.spine.getSpineItemSpineLayoutInfo(t);
2483
+ const { height: i, width: o } = t.layoutInfo, { top: s, left: r } = n.spine.getSpineItemSpineLayoutInfo(t);
2491
2484
  return n.settings.values.computedPageTurnDirection === "vertical" ? Math.max(
2492
2485
  0,
2493
2486
  Math.min(
@@ -2502,7 +2495,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2502
2495
  )
2503
2496
  );
2504
2497
  }, Ki = (n, e, t, i, o) => o.isReady$.pipe(
2505
- V(),
2498
+ U(),
2506
2499
  z(n.layoutInfo$),
2507
2500
  S(([s, r]) => {
2508
2501
  const a = n.context, c = a.manifest?.renditionLayout === "pre-paginated", u = a.manifest?.spineItems.length || 0, l = a.manifest?.spineItems.slice(0, e).reduce((f, I) => f + (I.progressionWeight ?? 0), 0) || 0, d = n.spineItemsManager.getSpineItemIndex(o) ?? 0, p = n.context.manifest?.spineItems.length ?? 0, g = r.pages.filter((f) => f.itemIndex === d).length ?? 0, h = a.manifest?.spineItems[e]?.progressionWeight ?? // if no progressionWeight is defined we "assume" the document weight to be
@@ -2522,7 +2515,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2522
2515
  )), e === u - 1 && t === g - 1 && y > 0.99 ? 1 : y;
2523
2516
  })
2524
2517
  ), Qi = (n) => n.spine.layout$.pipe(
2525
- be(10, ce),
2518
+ Ie(10, re),
2526
2519
  z(n.pagination.state$),
2527
2520
  S(() => ({
2528
2521
  numberOfPagesPerItems: n.spineItemsManager.items.reduce(
@@ -2534,7 +2527,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2534
2527
  */
2535
2528
  numberOfTotalPages: n.spine.pages.value.pages.length
2536
2529
  })),
2537
- k(U),
2530
+ N(O),
2538
2531
  ne({
2539
2532
  numberOfPagesPerItems: [],
2540
2533
  numberOfTotalPages: 0
@@ -2570,7 +2563,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2570
2563
  // hasPreviousChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
2571
2564
  // numberOfSpineItems: context.manifest?.readingOrder.length,
2572
2565
  });
2573
- }, to = (n) => O([
2566
+ }, to = (n) => j([
2574
2567
  n.pagination.state$,
2575
2568
  // Usually pagination change if layout changes (number of pages) however it is especially
2576
2569
  // useful for like webtoon where you still have one page but only the layout will give you the final size
@@ -2588,7 +2581,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2588
2581
  ) : v(0);
2589
2582
  })
2590
2583
  ), no = (n) => {
2591
- const e = Gi(n), t = Qi(n), i = new Y({
2584
+ const e = Gi(n), t = Qi(n), i = new q({
2592
2585
  ...n.pagination.state,
2593
2586
  beginChapterInfo: void 0,
2594
2587
  beginCfi: void 0,
@@ -2603,7 +2596,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2603
2596
  endChapterInfo: void 0,
2604
2597
  endSpineItemReadingDirection: void 0,
2605
2598
  percentageEstimateOfBook: 0
2606
- }), o = O([
2599
+ }), o = j([
2607
2600
  n.pagination.state$,
2608
2601
  e,
2609
2602
  to(n)
@@ -2621,9 +2614,9 @@ const Hi = (n) => n.pagination.state$.pipe(
2621
2614
  }))
2622
2615
  )
2623
2616
  ),
2624
- k(U)
2617
+ N(O)
2625
2618
  );
2626
- return { paginationInfo$: O([
2619
+ return { paginationInfo$: j([
2627
2620
  o,
2628
2621
  t
2629
2622
  ]).pipe(
@@ -2639,21 +2632,21 @@ const Hi = (n) => n.pagination.state$.pipe(
2639
2632
  r.endPageIndexInSpineItem ?? 0
2640
2633
  )
2641
2634
  })),
2642
- x((r) => {
2635
+ $((r) => {
2643
2636
  i.next(r);
2644
2637
  }),
2645
2638
  J(1)
2646
2639
  ), getPaginationInfo: () => i.value };
2647
- }, me = (n) => We({
2640
+ }, he = (n) => We({
2648
2641
  spineIndex: n.index,
2649
2642
  spineId: n.id
2650
- }), Bt = ({
2643
+ }), Wt = ({
2651
2644
  nodeOrRange: n,
2652
2645
  offset: e,
2653
2646
  item: t
2654
2647
  }) => {
2655
2648
  const i = "ownerDocument" in n ? n.ownerDocument : n.startContainer.ownerDocument;
2656
- return !i || !i?.documentElement || n === i ? me(t) : On(n) ? We({
2649
+ return !i || !i?.documentElement || n === i ? he(t) : On(n) ? We({
2657
2650
  start: {
2658
2651
  node: n.startContainer,
2659
2652
  offset: n.startOffset,
@@ -2672,7 +2665,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2672
2665
  spineIndex: t.index,
2673
2666
  spineId: t.id
2674
2667
  });
2675
- }, Be = ({
2668
+ }, He = ({
2676
2669
  pageIndex: n,
2677
2670
  spineItem: e,
2678
2671
  spine: t
@@ -2680,25 +2673,25 @@ const Hi = (n) => n.pagination.state$.pipe(
2680
2673
  const o = t.pages.value.pages.find(
2681
2674
  (r) => r.itemIndex === e.index && r.pageIndex === n
2682
2675
  )?.firstVisibleNode, s = e.renderer.getDocumentFrame();
2683
- return o && s instanceof HTMLIFrameElement && s.contentWindow?.document ? Bt({
2676
+ return o && s instanceof HTMLIFrameElement && s.contentWindow?.document ? Wt({
2684
2677
  nodeOrRange: o.node,
2685
2678
  offset: o.offset,
2686
2679
  item: e.item
2687
- }).trim() : me(e.item);
2688
- }, io = (n, e) => Bt({
2680
+ }).trim() : he(e.item);
2681
+ }, io = (n, e) => Wt({
2689
2682
  nodeOrRange: n,
2690
2683
  item: e
2691
- }), Js = (n) => n.index.toString(), gt = (n) => n[0]?.index === 6 && n.length > 1, Xe = (n) => {
2692
- const e = Et(n);
2684
+ }), Zs = (n) => n.index.toString(), pt = (n) => n[0]?.index === 6 && n.length > 1, Be = (n) => {
2685
+ const e = Mt(n);
2693
2686
  return wn(e);
2694
- }, oo = (n) => Array.isArray(n) ? n[0] && gt(n[0]) ? n[0] : void 0 : n.parent[0] && gt(n.parent[0]) ? n.parent[0] : void 0, it = (n) => {
2695
- const e = Et(n), s = ((oo(e) ?? [])[1]?.index ?? 2) / 2 - 1, r = Pn(e), a = r ? e.end.at(-1)?.at(-1)?.offset : e.at(-1)?.at(-1)?.offset;
2687
+ }, oo = (n) => Array.isArray(n) ? n[0] && pt(n[0]) ? n[0] : void 0 : n.parent[0] && pt(n.parent[0]) ? n.parent[0] : void 0, it = (n) => {
2688
+ const e = Mt(n), s = ((oo(e) ?? [])[1]?.index ?? 2) / 2 - 1, r = Pn(e), a = r ? e.end.at(-1)?.at(-1)?.offset : e.at(-1)?.at(-1)?.offset;
2696
2689
  return {
2697
2690
  isCfiRange: r,
2698
2691
  itemIndex: s,
2699
2692
  offset: a ?? 0
2700
2693
  };
2701
- }, Xt = ({
2694
+ }, _t = ({
2702
2695
  cfi: n,
2703
2696
  spineItemsManager: e
2704
2697
  }) => {
@@ -2727,7 +2720,7 @@ const Hi = (n) => n.pagination.state$.pipe(
2727
2720
  spineItem: o
2728
2721
  };
2729
2722
  } catch (a) {
2730
- return D.warn(`Error resolving cfi: ${n}.`), D.warn(a), {
2723
+ return A.warn(`Error resolving cfi: ${n}.`), A.warn(a), {
2731
2724
  ...i,
2732
2725
  spineItem: o,
2733
2726
  itemIndex: t,
@@ -2754,17 +2747,17 @@ const Hi = (n) => n.pagination.state$.pipe(
2754
2747
  const t = n.spineItemsManager.get(e);
2755
2748
  if (!t)
2756
2749
  throw new Error("Spine item not found");
2757
- const i = me(t.item);
2750
+ const i = he(t.item);
2758
2751
  return {
2759
2752
  ...n.cfi.parseCfi(i),
2760
- cfi: me(t.item),
2753
+ cfi: he(t.item),
2761
2754
  itemIndex: t.index,
2762
2755
  node: null
2763
2756
  };
2764
2757
  }, ro = (n, e) => {
2765
2758
  let t = n?.itemPageIndex;
2766
2759
  const { itemIndex: i, ...o } = e.cfi.parseCfi(n.cfi), s = e.spineItemsManager.get(i);
2767
- return s ? Vt().pipe(
2760
+ return s ? et().pipe(
2768
2761
  z(s.isReady$),
2769
2762
  S(([, r]) => {
2770
2763
  const {
@@ -2804,12 +2797,12 @@ class ao {
2804
2797
  resource: t,
2805
2798
  meta: so(this.reader, t)
2806
2799
  };
2807
- return ct(() => {
2800
+ return at(() => {
2808
2801
  const s = this.reader.spineItemsManager.get(
2809
2802
  o.meta.itemIndex ?? 0
2810
2803
  ), r = s?.renditionLayout === "reflowable", a = i.mode === "shallow" || !r || !s ? () => {
2811
2804
  } : this.reader.spine.spineItemsLoader.forceOpen([s.index]), c = "cfi" in t ? t.cfi : void 0, u = c ? this.locatorsByKey.get(c) : void 0, l = (p) => p.pipe(
2812
- pe(() => {
2805
+ me(() => {
2813
2806
  c && this.deregisterMemoizedStream(c), setTimeout(() => {
2814
2807
  a();
2815
2808
  }, 1e3);
@@ -2825,9 +2818,9 @@ class ao {
2825
2818
  )
2826
2819
  );
2827
2820
  const d = this.reader.spine.layout$.pipe(
2828
- be(10),
2821
+ Ie(10),
2829
2822
  ne(o),
2830
- un((p) => ro(p.meta, this.reader).pipe(
2823
+ an((p) => ro(p.meta, this.reader).pipe(
2831
2824
  S((g) => ({
2832
2825
  ...p,
2833
2826
  meta: g
@@ -2843,16 +2836,16 @@ class ao {
2843
2836
  };
2844
2837
  }
2845
2838
  locateResource(e, t) {
2846
- return Array.isArray(e) ? ct(
2847
- () => O(
2839
+ return Array.isArray(e) ? at(
2840
+ () => j(
2848
2841
  e.map((i) => this.locate(i, t ?? {}))
2849
- ).pipe(ln([]))
2842
+ ).pipe(cn([]))
2850
2843
  ) : this.locate(e, t ?? {});
2851
2844
  }
2852
2845
  }
2853
2846
  const co = (n) => (e) => {
2854
2847
  const t = n(e), { paginationInfo$: i, getPaginationInfo: o } = no(t);
2855
- i.pipe($(t.$.destroy$)).subscribe();
2848
+ i.pipe(T(t.$.destroy$)).subscribe();
2856
2849
  const s = new ao(t);
2857
2850
  return {
2858
2851
  ...t,
@@ -2919,7 +2912,7 @@ const co = (n) => (e) => {
2919
2912
  a(d);
2920
2913
  };
2921
2914
  })
2922
- }), Oe = async (n) => new Promise((e, t) => {
2915
+ }), Ve = async (n) => new Promise((e, t) => {
2923
2916
  const i = window.indexedDB.open(n);
2924
2917
  i.onerror = (o) => {
2925
2918
  t(o);
@@ -2939,7 +2932,7 @@ const co = (n) => (e) => {
2939
2932
  }, o = async (c, u) => {
2940
2933
  const l = i(c);
2941
2934
  if (!l) return new Response("Item not found", { status: 404 });
2942
- const p = await (await Oe("prose-reader")).get(`${e}_${l.id}`);
2935
+ const p = await (await Ve("prose-reader")).get(`${e}_${l.id}`);
2943
2936
  if (p)
2944
2937
  return new Response(p, { status: 200 });
2945
2938
  const g = u && await u(l) || await fetch(l.href);
@@ -2948,36 +2941,36 @@ const co = (n) => (e) => {
2948
2941
  t.next({ id: c, data: u });
2949
2942
  };
2950
2943
  t.asObservable().pipe(
2951
- vn(({ id: c, data: u }) => {
2944
+ bn(({ id: c, data: u }) => {
2952
2945
  const l = i(c);
2953
- return l ? A(
2954
- dn([Oe("prose-reader"), A(u.blob())])
2946
+ return l ? k(
2947
+ un([Ve("prose-reader"), k(u.blob())])
2955
2948
  ).pipe(
2956
- X(([d, p]) => A(d.put(`${e}_${l.id}`, p))),
2957
- rt((d) => (D.error(d), _))
2949
+ Y(([d, p]) => k(d.put(`${e}_${l.id}`, p))),
2950
+ st((d) => (A.error(d), _))
2958
2951
  ) : _;
2959
2952
  }),
2960
2953
  K(n.destroy$)
2961
2954
  ).subscribe();
2962
2955
  const r = n.manifest$.pipe(
2963
- N(() => {
2956
+ V(() => {
2964
2957
  e = Date.now().toString();
2965
2958
  })
2966
2959
  );
2967
2960
  return P(r).pipe(
2968
- X(() => (D.debug("Cleanup up old cache..."), A(Oe("prose-reader")).pipe(
2969
- X(
2970
- (c) => A(c.keys()).pipe(
2961
+ Y(() => (A.debug("Cleanup up old cache..."), k(Ve("prose-reader")).pipe(
2962
+ Y(
2963
+ (c) => k(c.keys()).pipe(
2971
2964
  ie(
2972
2965
  (u) => u.filter((l) => !l.toString().startsWith(e))
2973
2966
  ),
2974
- X((u) => {
2967
+ Y((u) => {
2975
2968
  const l = u.map((d) => c.remove(d));
2976
- return A(Promise.all(l));
2969
+ return k(Promise.all(l));
2977
2970
  })
2978
2971
  )
2979
2972
  ),
2980
- rt((c) => (D.error(c), _))
2973
+ st((c) => (A.error(c), _))
2981
2974
  ))),
2982
2975
  K(n.destroy$)
2983
2976
  ).subscribe(), {
@@ -3012,7 +3005,7 @@ const co = (n) => (e) => {
3012
3005
  t.setStart(n.node, o), t.setEnd(n.node, s);
3013
3006
  }
3014
3007
  } catch (o) {
3015
- D.warn("Failed to create range from selection", o, {
3008
+ A.warn("Failed to create range from selection", o, {
3016
3009
  anchor: n,
3017
3010
  focus: e
3018
3011
  });
@@ -3031,7 +3024,7 @@ const co = (n) => (e) => {
3031
3024
  { node: o, offset: s }
3032
3025
  );
3033
3026
  } catch (r) {
3034
- D.warn("Failed to create range from selection", r, {
3027
+ A.warn("Failed to create range from selection", r, {
3035
3028
  selection: n,
3036
3029
  spineItem: e
3037
3030
  });
@@ -3043,39 +3036,39 @@ class mo extends G {
3043
3036
  super();
3044
3037
  const t = e.contentDocument || e.contentWindow?.document;
3045
3038
  if (!t)
3046
- this.selectionChange$ = he, this.selectionOver$ = he;
3039
+ this.selectionChange$ = ge, this.selectionOver$ = ge;
3047
3040
  else {
3048
- const i = ut(t.body, {
3041
+ const i = ct(t.body, {
3049
3042
  childList: !0,
3050
3043
  subtree: !0
3051
3044
  }).pipe(
3052
- M(
3045
+ C(
3053
3046
  (s) => !!s.find((r) => r.type === "childList" && r.removedNodes.length)
3054
3047
  )
3055
- ), o = e.parentElement ? ut(e.parentElement, {
3048
+ ), o = e.parentElement ? ct(e.parentElement, {
3056
3049
  childList: !0
3057
3050
  }).pipe(
3058
- M(
3051
+ C(
3059
3052
  (s) => !!s.find(
3060
3053
  (r) => Array.from(r.removedNodes).includes(e)
3061
3054
  )
3062
3055
  )
3063
3056
  ) : v(null);
3064
3057
  this.selectionChange$ = P(
3065
- q(t, "selectionchange"),
3058
+ X(t, "selectionchange"),
3066
3059
  i
3067
3060
  ).pipe(
3068
3061
  S(() => t.getSelection()),
3069
- $(P(o, this.destroy$)),
3070
- ye(null)
3071
- ), this.selectionOver$ = q(t, "pointerdown").pipe(
3062
+ T(P(o, this.destroy$)),
3063
+ fe(null)
3064
+ ), this.selectionOver$ = X(t, "pointerdown").pipe(
3072
3065
  w(
3073
3066
  () => P(
3074
- q(t, "pointerup"),
3075
- q(t, "pointercancel"),
3076
- q(t, "contextmenu")
3067
+ X(t, "pointerup"),
3068
+ X(t, "pointercancel"),
3069
+ X(t, "contextmenu")
3077
3070
  ).pipe(
3078
- V(),
3071
+ U(),
3079
3072
  /**
3080
3073
  * The selection is still valid during the event even if it will
3081
3074
  * be discarded. The timeout make sure to detect this edge case.
@@ -3085,10 +3078,10 @@ class mo extends G {
3085
3078
  const r = t.getSelection();
3086
3079
  return r && !r.isCollapsed ? [s, r] : void 0;
3087
3080
  }),
3088
- M(Z)
3081
+ C(Z)
3089
3082
  )
3090
3083
  ),
3091
- $(P(o, this.destroy$))
3084
+ T(P(o, this.destroy$))
3092
3085
  );
3093
3086
  }
3094
3087
  }
@@ -3096,7 +3089,7 @@ class mo extends G {
3096
3089
  const fo = (n) => n.watch("isLoaded").pipe(
3097
3090
  w(() => {
3098
3091
  const e = n.renderer.getDocumentFrame(), t = e?.contentDocument || e?.contentWindow?.document;
3099
- if (!e || !t) return he;
3092
+ if (!e || !t) return ge;
3100
3093
  const i = new mo(e);
3101
3094
  return P(
3102
3095
  i.selectionChange$.pipe(
@@ -3116,14 +3109,14 @@ const fo = (n) => n.watch("isLoaded").pipe(
3116
3109
  }))
3117
3110
  )
3118
3111
  ).pipe(
3119
- $(n.unloaded$),
3120
- ye(void 0),
3121
- pe(() => {
3112
+ T(n.unloaded$),
3113
+ fe(void 0),
3114
+ me(() => {
3122
3115
  i.destroy();
3123
3116
  })
3124
3117
  );
3125
3118
  }),
3126
- k()
3119
+ N()
3127
3120
  ), yo = (n) => (e) => {
3128
3121
  const t = n(e);
3129
3122
  let i;
@@ -3144,33 +3137,33 @@ const fo = (n) => n.watch("isLoaded").pipe(
3144
3137
  return P(...d);
3145
3138
  }),
3146
3139
  ne(void 0),
3147
- k(),
3148
- x((l) => {
3140
+ N(),
3141
+ $((l) => {
3149
3142
  i = l;
3150
3143
  }),
3151
3144
  J({ refCount: !0, bufferSize: 1 })
3152
3145
  ), s = o, r = o.pipe(
3153
3146
  S((l) => !!l),
3154
- k(),
3155
- M((l) => l),
3156
- j()
3147
+ N(),
3148
+ C((l) => l),
3149
+ D()
3157
3150
  ), a = r.pipe(
3158
3151
  w(() => s),
3159
- k(),
3160
- M((l) => !l),
3161
- j()
3152
+ N(),
3153
+ C((l) => !l),
3154
+ D()
3162
3155
  ), c = o.pipe(
3163
- M((l) => l?.type === "over"),
3164
- j()
3156
+ C((l) => l?.type === "over"),
3157
+ D()
3165
3158
  ), u = t.context.watch("rootElement").pipe(
3166
- M(Z),
3167
- w((l) => q(l, "pointerdown")),
3159
+ C(Z),
3160
+ w((l) => X(l, "pointerdown")),
3168
3161
  z(s),
3169
3162
  S(([, l]) => l),
3170
3163
  ne(void 0),
3171
3164
  J({ refCount: !0, bufferSize: 1 })
3172
3165
  );
3173
- return P(s, u).pipe($(t.$.destroy$)).subscribe(), {
3166
+ return P(s, u).pipe(T(t.$.destroy$)).subscribe(), {
3174
3167
  ...t,
3175
3168
  selection: {
3176
3169
  selection$: s,
@@ -3182,7 +3175,7 @@ const fo = (n) => n.watch("isLoaded").pipe(
3182
3175
  createOrderedRangeFromSelection: ho
3183
3176
  }
3184
3177
  };
3185
- }, ht = [
3178
+ }, gt = [
3186
3179
  {
3187
3180
  name: "bright",
3188
3181
  backgroundColor: "white"
@@ -3198,10 +3191,10 @@ const fo = (n) => n.watch("isLoaded").pipe(
3198
3191
  foregroundColor: "#f1ebeb"
3199
3192
  }
3200
3193
  ], So = (n) => (e) => {
3201
- const t = n(e), i = new Y(
3194
+ const t = n(e), i = new q(
3202
3195
  e.theme ?? "bright"
3203
3196
  ), o = () => {
3204
- const a = ht.find(
3197
+ const a = gt.find(
3205
3198
  (c) => c.name === i.value
3206
3199
  );
3207
3200
  return `
@@ -3218,7 +3211,7 @@ const fo = (n) => n.watch("isLoaded").pipe(
3218
3211
  }, s = ({
3219
3212
  container: a
3220
3213
  }) => {
3221
- const c = ht.find(
3214
+ const c = gt.find(
3222
3215
  (u) => u.name === i.value
3223
3216
  );
3224
3217
  return c && a.style.setProperty(
@@ -3239,14 +3232,14 @@ const fo = (n) => n.watch("isLoaded").pipe(
3239
3232
  u && oe(u, "prose-reader-theme", o());
3240
3233
  }
3241
3234
  }), t.spineItemsManager.items$.pipe(
3242
- N(
3235
+ V(
3243
3236
  (a) => a.map(
3244
3237
  ({ element: c }) => s({ container: c })
3245
3238
  )
3246
3239
  ),
3247
3240
  K(t.$.destroy$)
3248
3241
  ).subscribe(), i.pipe(
3249
- N(() => {
3242
+ V(() => {
3250
3243
  r();
3251
3244
  }),
3252
3245
  K(t.$.destroy$)
@@ -3267,7 +3260,7 @@ const fo = (n) => n.watch("isLoaded").pipe(
3267
3260
  return {
3268
3261
  ...t,
3269
3262
  utils: {
3270
- isOrIsWithinValidLink: (s) => !!(Nt(s) && (s.nodeName === "a" ? s : s.closest("a"))?.getAttribute("href")),
3263
+ isOrIsWithinValidLink: (s) => !!(At(s) && (s.nodeName === "a" ? s : s.closest("a"))?.getAttribute("href")),
3271
3264
  injectScopedCSS: (s, r, a) => {
3272
3265
  const c = a.replace("${id}", t.id);
3273
3266
  return Ce(s, `${r}-${t.id}`, c);
@@ -3276,7 +3269,7 @@ const fo = (n) => n.watch("isLoaded").pipe(
3276
3269
  };
3277
3270
  };
3278
3271
  navigator.userAgent.indexOf("") > -1 && navigator.userAgent.indexOf("Chrome") <= -1;
3279
- const bo = (n) => (e) => n(e), vo = "[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true]{overflow:scroll}[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true][data-prose-reader-zooming-direction=down]{overflow-x:auto}", mt = (n, e, t) => {
3272
+ const bo = (n) => (e) => n(e), vo = "[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true]{overflow:scroll}[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true][data-prose-reader-zooming-direction=down]{overflow-x:auto}", ht = (n, e, t) => {
3280
3273
  const { clientWidth: i, clientHeight: o } = t.value.element, s = {
3281
3274
  maxX: 0,
3282
3275
  minX: i * (1 - e),
@@ -3298,14 +3291,14 @@ const bo = (n) => (e) => n(e), vo = "[data-prose-reader-scroll-navigator][data-p
3298
3291
  y: i.y + c * (1 - o)
3299
3292
  };
3300
3293
  };
3301
- class Yt {
3294
+ class Ht {
3302
3295
  constructor(e) {
3303
3296
  this.x = e.x, this.y = e.y;
3304
3297
  }
3305
3298
  }
3306
- class ft extends Yt {
3299
+ class mt extends Ht {
3307
3300
  }
3308
- class xo extends Yt {
3301
+ class xo extends Ht {
3309
3302
  constructor() {
3310
3303
  super(...arguments), this.__symbol = /* @__PURE__ */ Symbol("UnboundScrollPosition");
3311
3304
  }
@@ -3314,7 +3307,7 @@ class $o extends Q {
3314
3307
  constructor(e, t, i, o, s) {
3315
3308
  super({
3316
3309
  element: void 0
3317
- }), this.viewport = e, this.settings = t, this.hookManager = i, this.spine = o, this.context = s, this.navigateSubject = new R(), this.scrollingSubject = new Y(!1), this.isScrolling$ = this.scrollingSubject.asObservable(), this.setViewportPosition = ({
3310
+ }), this.viewport = e, this.settings = t, this.hookManager = i, this.spine = o, this.context = s, this.navigateSubject = new R(), this.scrollingSubject = new q(!1), this.isScrolling$ = this.scrollingSubject.asObservable(), this.setViewportPosition = ({
3318
3311
  position: d
3319
3312
  }) => {
3320
3313
  const p = this.value.element;
@@ -3325,27 +3318,27 @@ class $o extends Q {
3325
3318
  top: g.y,
3326
3319
  behavior: "instant"
3327
3320
  }), Te(1).pipe(
3328
- x(() => {
3321
+ $(() => {
3329
3322
  this.scrollingSubject.next(!1);
3330
3323
  }),
3331
- $(P(this.scrollingSubject.pipe(Lt(1)), this.destroy$))
3324
+ T(P(this.scrollingSubject.pipe(Ft(1)), this.destroy$))
3332
3325
  ).subscribe(), this.hookManager.execute("onViewportOffsetAdjust", void 0, {});
3333
3326
  };
3334
3327
  const r = this.context.pipe(
3335
- Qe(["rootElement"]),
3336
- x(({ rootElement: d }) => {
3328
+ Ke(["rootElement"]),
3329
+ $(({ rootElement: d }) => {
3337
3330
  if (!d) return;
3338
3331
  const p = document.createElement("div");
3339
3332
  p.setAttribute(`data-${si}`, ""), p.appendChild(this.viewport.value.element), d.appendChild(p), this.update({ element: p });
3340
3333
  })
3341
- ), a = O([
3334
+ ), a = j([
3342
3335
  t.watch(["computedPageTurnMode"]),
3343
3336
  this.watch("element")
3344
3337
  ]).pipe(
3345
- x(([{ computedPageTurnMode: d }, p]) => {
3338
+ $(([{ computedPageTurnMode: d }, p]) => {
3346
3339
  p && (d === "scrollable" ? p.style.display = "block" : p.style.display = "contents");
3347
3340
  })
3348
- ), c = this.navigateSubject.pipe(x(this.setViewportPosition));
3341
+ ), c = this.navigateSubject.pipe($(this.setViewportPosition));
3349
3342
  this.isNavigating$ = this.navigateSubject.pipe(
3350
3343
  ne(!1),
3351
3344
  w(() => P(v(!0), v(!1))),
@@ -3353,12 +3346,12 @@ class $o extends Q {
3353
3346
  );
3354
3347
  const u = P(
3355
3348
  o.element$.pipe(
3356
- M(Z),
3357
- w((d) => et(d))
3349
+ C(Z),
3350
+ w((d) => Qe(d))
3358
3351
  ),
3359
3352
  o.element$.pipe(
3360
- M(Z),
3361
- w((d) => q(d, "scroll"))
3353
+ C(Z),
3354
+ w((d) => X(d, "scroll"))
3362
3355
  ),
3363
3356
  o.spineItemsObserver.itemResize$
3364
3357
  ).pipe(
@@ -3368,9 +3361,9 @@ class $o extends Q {
3368
3361
  ne(!0)
3369
3362
  )
3370
3363
  ),
3371
- k(),
3364
+ N(),
3372
3365
  ne(!1)
3373
- ), l = O([
3366
+ ), l = j([
3374
3367
  u,
3375
3368
  this.isScrolling$
3376
3369
  ]).pipe(
@@ -3380,13 +3373,13 @@ class $o extends Q {
3380
3373
  J(1)
3381
3374
  );
3382
3375
  this.userScroll$ = this.watch("element").pipe(
3383
- M(Z),
3376
+ C(Z),
3384
3377
  w(
3385
3378
  (d) => t.watch(["computedPageTurnMode"]).pipe(
3386
3379
  w(
3387
- ({ computedPageTurnMode: p }) => p === "controlled" ? he : q(d, "scroll").pipe(
3380
+ ({ computedPageTurnMode: p }) => p === "controlled" ? ge : X(d, "scroll").pipe(
3388
3381
  z(l),
3389
- M(
3382
+ C(
3390
3383
  ([, g]) => !g
3391
3384
  ),
3392
3385
  S(([g]) => g)
@@ -3394,8 +3387,8 @@ class $o extends Q {
3394
3387
  )
3395
3388
  )
3396
3389
  ),
3397
- j()
3398
- ), P(r, a, c).pipe($(this.destroy$)).subscribe();
3390
+ D()
3391
+ ), P(r, a, c).pipe(T(this.destroy$)).subscribe();
3399
3392
  }
3400
3393
  update(e) {
3401
3394
  this.mergeCompare(e);
@@ -3405,21 +3398,21 @@ class $o extends Q {
3405
3398
  }
3406
3399
  fromScrollPosition(e) {
3407
3400
  const t = this.viewport.scaleFactor;
3408
- return new ue({
3401
+ return new ae({
3409
3402
  x: e.x / t,
3410
3403
  y: e.y / t
3411
3404
  });
3412
3405
  }
3413
3406
  fromSpinePosition(e) {
3414
3407
  const t = this.viewport.scaleFactor;
3415
- return new ft({
3408
+ return new mt({
3416
3409
  x: e.x * t,
3417
3410
  y: e.y * t
3418
3411
  });
3419
3412
  }
3420
3413
  get scrollPosition() {
3421
3414
  const e = this.value.element;
3422
- return new ft({
3415
+ return new mt({
3423
3416
  x: e?.scrollLeft ?? 0,
3424
3417
  y: e?.scrollTop ?? 0
3425
3418
  });
@@ -3433,7 +3426,7 @@ const To = (n, e, t, i, o) => {
3433
3426
  });
3434
3427
  }, Fo = (n, e) => {
3435
3428
  const t = e.viewport, i = e.navigation.scrollNavigationController, o = t.value.element, s = i.value.element, r = i.value.element, a = Math.round(t.scaleFactor * 100) / 100, c = o.offsetLeft, u = o.offsetTop, l = To(
3436
- s ?? Rn(),
3429
+ s ?? An(),
3437
3430
  a,
3438
3431
  n,
3439
3432
  c,
@@ -3471,7 +3464,7 @@ class Lo extends Q {
3471
3464
  currentScale: 1,
3472
3465
  currentPosition: { x: 0, y: 0 }
3473
3466
  }), this.updateZoom(s), s !== 1 && this.isControlled ? Te(o?.animate ? we : 0).pipe(
3474
- x(() => {
3467
+ $(() => {
3475
3468
  this.reader.layout();
3476
3469
  })
3477
3470
  ) : _;
@@ -3490,15 +3483,15 @@ class Lo extends Q {
3490
3483
  ), o?.animate && this.isControlled && (s.style.transition = `transform ${we}ms`), this.updateZoom(1, { x: 0, y: 0 }), s.style.transform = "", this.mergeCompare({
3491
3484
  isZooming: !1
3492
3485
  }), Te(o?.animate ? we : 0).pipe(
3493
- x(() => {
3486
+ $(() => {
3494
3487
  const r = this.reader.viewport.value.element;
3495
3488
  r.style.transformOrigin = "", r.style.transition = "", this.isControlled && this.reader.layout();
3496
3489
  }),
3497
- $(this.enterSubject)
3490
+ T(this.enterSubject)
3498
3491
  );
3499
3492
  })
3500
3493
  );
3501
- P(t, i).pipe($(this.destroy$)).subscribe();
3494
+ P(t, i).pipe(T(this.destroy$)).subscribe();
3502
3495
  }
3503
3496
  enter(e) {
3504
3497
  this.enterSubject.next(e);
@@ -3508,14 +3501,14 @@ class Lo extends Q {
3508
3501
  }
3509
3502
  move(e, t) {
3510
3503
  this.isControlled && (this.viewport.element.style.transition = "", this.updateZoom(this.value.currentScale, e, {
3511
- constraints: t?.constrain === "within-viewport" ? (...i) => mt(...i, this.reader.viewport) : void 0
3504
+ constraints: t?.constrain === "within-viewport" ? (...i) => ht(...i, this.reader.viewport) : void 0
3512
3505
  }));
3513
3506
  }
3514
3507
  scaleAt(e, t) {
3515
3508
  this.viewport.element.style.transition = "";
3516
3509
  const o = Math.ceil(e * 100) / 100;
3517
3510
  this.updateZoom(o, void 0, {
3518
- constraints: t?.constrain === "within-viewport" ? (...s) => mt(...s, this.reader.viewport) : void 0
3511
+ constraints: t?.constrain === "within-viewport" ? (...s) => ht(...s, this.reader.viewport) : void 0
3519
3512
  });
3520
3513
  }
3521
3514
  updateZoom(e, t, i) {
@@ -3552,11 +3545,11 @@ class Lo extends Q {
3552
3545
  return this.reader.viewport.value;
3553
3546
  }
3554
3547
  }
3555
- const yt = `${Ut}-enhancer-zoom`, Mo = (n) => (e) => {
3548
+ const ft = `${Vt}-enhancer-zoom`, Mo = (n) => (e) => {
3556
3549
  const t = n(e), i = new Lo(t);
3557
- Ce(document, yt, vo);
3550
+ Ce(document, ft, vo);
3558
3551
  const o = () => {
3559
- Ee(document, yt), i.destroy(), t.destroy();
3552
+ Ee(document, ft), i.destroy(), t.destroy();
3560
3553
  }, s = i;
3561
3554
  return {
3562
3555
  ...t,
@@ -3572,16 +3565,16 @@ const yt = `${Ut}-enhancer-zoom`, Mo = (n) => (e) => {
3572
3565
  }
3573
3566
  }
3574
3567
  };
3575
- }, qt = (n) => n?.renditionLayout === "pre-paginated" || n?.spineItems.every((e) => e.renditionLayout === "pre-paginated");
3568
+ }, Bt = (n) => n?.renditionLayout === "pre-paginated" || n?.spineItems.every((e) => e.renditionLayout === "pre-paginated");
3576
3569
  class Co {
3577
3570
  constructor() {
3578
- this.navigationSubject = new ot(1), this.viewportStateSubject = new Y("free"), this.paginationSubject = new ot(), this.navigationIsLockedSubject = new Y(!1), this.pagination$ = this.paginationSubject.asObservable(), this.navigationUnlocked$ = this.navigationIsLockedSubject.pipe(
3579
- k(),
3580
- M((e) => !e)
3571
+ this.navigationSubject = new ot(1), this.viewportStateSubject = new q("free"), this.paginationSubject = new ot(), this.navigationIsLockedSubject = new q(!1), this.pagination$ = this.paginationSubject.asObservable(), this.navigationUnlocked$ = this.navigationIsLockedSubject.pipe(
3572
+ N(),
3573
+ C((e) => !e)
3581
3574
  ), this.viewportState$ = this.viewportStateSubject.asObservable(), this.viewportFree$ = this.viewportState$.pipe(
3582
- M((e) => e === "free")
3575
+ C((e) => e === "free")
3583
3576
  ), this.viewportBusy$ = this.viewportState$.pipe(
3584
- M((e) => e === "busy")
3577
+ C((e) => e === "busy")
3585
3578
  ), this.navigation$ = this.navigationSubject.asObservable();
3586
3579
  }
3587
3580
  }
@@ -3591,8 +3584,8 @@ class Eo extends Q {
3591
3584
  assumedRenditionLayout: "reflowable"
3592
3585
  }), this.bridgeEvent = new Co(), this.manifest$ = this.pipe(
3593
3586
  ie((e) => e.manifest),
3594
- ae(Z),
3595
- fe()
3587
+ de(Z),
3588
+ be()
3596
3589
  ), this.isRTL = () => this.value.manifest?.readingDirection === "rtl";
3597
3590
  }
3598
3591
  update(e) {
@@ -3600,7 +3593,7 @@ class Eo extends Q {
3600
3593
  ...t,
3601
3594
  ...e,
3602
3595
  ...e.manifest && {
3603
- isFullyPrePaginated: qt(i),
3596
+ isFullyPrePaginated: Bt(i),
3604
3597
  assumedRenditionLayout: i?.renditionLayout ?? "reflowable"
3605
3598
  }
3606
3599
  };
@@ -3620,7 +3613,7 @@ class Do extends Q {
3620
3613
  supportedPageTurnMode: ["controlled", "scrollable"],
3621
3614
  supportedPageTurnDirection: ["horizontal", "vertical"],
3622
3615
  supportedComputedPageTurnDirection: ["horizontal", "vertical"]
3623
- }), O([
3616
+ }), j([
3624
3617
  e.watch(["manifest", "hasVerticalWriting"]),
3625
3618
  t.watch(["computedPageTurnMode"])
3626
3619
  ]).pipe(
@@ -3630,7 +3623,7 @@ class Do extends Q {
3630
3623
  renditionLayout: i?.renditionLayout,
3631
3624
  computedPageTurnMode: s
3632
3625
  })),
3633
- k(U),
3626
+ N(O),
3634
3627
  S(
3635
3628
  ({
3636
3629
  hasVerticalWriting: i,
@@ -3644,11 +3637,11 @@ class Do extends Q {
3644
3637
  supportedPageTurnDirection: r === "scrollable" ? ["vertical"] : s === "reflowable" ? ["horizontal"] : ["horizontal", "vertical"]
3645
3638
  })
3646
3639
  ),
3647
- $(this.destroy$)
3640
+ T(this.destroy$)
3648
3641
  ).subscribe(this.next.bind(this));
3649
3642
  }
3650
3643
  }
3651
- class Ro {
3644
+ class Ao {
3652
3645
  constructor() {
3653
3646
  this._hooks = [], this._hookExecutions = [];
3654
3647
  }
@@ -3707,28 +3700,28 @@ class Ro {
3707
3700
  (r) => !o.includes(r)
3708
3701
  );
3709
3702
  const s = o.map(({ destroyFn: r }) => r());
3710
- return O(s);
3703
+ return j(s);
3711
3704
  }
3712
3705
  }
3713
- const Ao = "[data-prose-reader-scroll-navigator]{height:100%;width:100%;position:relative;overflow-y:scroll;overflow-x:hidden}[data-prose-reader-viewport]{background-color:#fff;position:relative;height:100%;width:100%}", No = (n) => ({
3706
+ const Ro = "[data-prose-reader-scroll-navigator]{height:100%;width:100%;position:relative;overflow-y:scroll;overflow-x:hidden}[data-prose-reader-viewport]{background-color:#fff;position:relative;height:100%;width:100%}", No = (n) => ({
3714
3707
  x: -n.x,
3715
3708
  y: -n.y
3716
- }), Oo = (n) => n instanceof DOMMatrix ? new L({
3709
+ }), Oo = (n) => n instanceof DOMMatrix ? new M({
3717
3710
  x: -n.e,
3718
3711
  y: -n.f
3719
- }) : new L({
3712
+ }) : new M({
3720
3713
  x: -n.x,
3721
3714
  y: -n.y
3722
- }), Vo = "navigation/ViewportNavigator", St = D.namespace(Vo);
3715
+ }), Vo = "navigation/ViewportNavigator", yt = A.namespace(Vo);
3723
3716
  class jo extends G {
3724
3717
  constructor(e, t, i, o, s) {
3725
- super(), this.settings = e, this.hookManager = t, this.context = i, this.spine = o, this.viewport = s, this.navigateSubject = new R(), this.element$ = new Y(
3718
+ super(), this.settings = e, this.hookManager = t, this.context = i, this.spine = o, this.viewport = s, this.navigateSubject = new R(), this.element$ = new q(
3726
3719
  document.createElement("div")
3727
3720
  );
3728
3721
  const r = this.spine.element$.pipe(
3729
- M(Z),
3722
+ C(Z),
3730
3723
  z(this.element$),
3731
- x(([l, d]) => {
3724
+ $(([l, d]) => {
3732
3725
  d.style.cssText = `
3733
3726
  height: 100%;
3734
3727
  width: 100%;
@@ -3739,23 +3732,23 @@ class jo extends G {
3739
3732
  "computedPageTurnDirection",
3740
3733
  "computedPageTurnMode",
3741
3734
  "numberOfAdjacentSpineItemToPreLoad"
3742
- ]), c = O([
3735
+ ]), c = j([
3743
3736
  a,
3744
3737
  this.element$
3745
3738
  ]).pipe(
3746
- x(([, l]) => {
3739
+ $(([, l]) => {
3747
3740
  e.values.computedPageTurnMode === "scrollable" ? l.style.display = "contents" : l.style.display = "block";
3748
3741
  })
3749
3742
  );
3750
3743
  this.layout$ = c.pipe(
3751
- x(() => {
3752
- St.info("layout", e.values);
3744
+ $(() => {
3745
+ yt.info("layout", e.values);
3753
3746
  }),
3754
- j()
3747
+ D()
3755
3748
  );
3756
3749
  const u = this.navigateSubject.pipe(
3757
- x((l) => {
3758
- St.info("Navigation requested", l);
3750
+ $((l) => {
3751
+ yt.info("Navigation requested", l);
3759
3752
  })
3760
3753
  );
3761
3754
  this.isNavigating$ = u.pipe(
@@ -3770,7 +3763,7 @@ class jo extends G {
3770
3763
  return d.style.setProperty("transition", "none"), d.style.setProperty("opacity", "1"), P(
3771
3764
  v(!0),
3772
3765
  v(null).pipe(
3773
- ge(() => {
3766
+ pe(() => {
3774
3767
  if (l?.type !== "manualAdjust") return v(!1);
3775
3768
  const p = l.animation === "snap" ? e.values.snapAnimationDuration : e.values.computedPageTurnAnimationDuration, g = l.animation === "snap" ? "slide" : e.values.computedPageTurnAnimation;
3776
3769
  return v(l).pipe(
@@ -3782,8 +3775,8 @@ class jo extends G {
3782
3775
  * anything for x ms while we effectively adjust. We want it to be immediate.
3783
3776
  * However when user is repeatedly turning page, we can improve smoothness by delaying a bit the adjustment
3784
3777
  */
3785
- l.shouldAnimate ? Pe(1, ce) : xe,
3786
- x((h) => {
3778
+ l.shouldAnimate ? Pe(1, re) : xe,
3779
+ $((h) => {
3787
3780
  const m = this.element$.getValue();
3788
3781
  h.shouldAnimate ? g === "fade" ? (m.style.setProperty(
3789
3782
  "transition",
@@ -3801,16 +3794,16 @@ class jo extends G {
3801
3794
  * need to adjust to anchor to the payload position. This is because we use viewport computed position,
3802
3795
  * not the value set by `setProperty`
3803
3796
  */
3804
- x((h) => {
3797
+ $((h) => {
3805
3798
  g !== "fade" && this.setViewportPosition(h.position);
3806
3799
  }),
3807
- l.shouldAnimate ? Pe(p / 2, ce) : xe,
3808
- x((h) => {
3800
+ l.shouldAnimate ? Pe(p / 2, re) : xe,
3801
+ $((h) => {
3809
3802
  const m = this.element$.getValue();
3810
3803
  g === "fade" && (this.setViewportPosition(h.position), m.style.setProperty("opacity", "1"));
3811
3804
  }),
3812
- l.shouldAnimate ? Pe(p / 2, ce) : xe,
3813
- x((h) => {
3805
+ l.shouldAnimate ? Pe(p / 2, re) : xe,
3806
+ $((h) => {
3814
3807
  g === "fade" && this.setViewportPosition(h.position);
3815
3808
  })
3816
3809
  );
@@ -3821,7 +3814,7 @@ class jo extends G {
3821
3814
  }),
3822
3815
  ne(!1),
3823
3816
  J(1)
3824
- ), P(r, this.isNavigating$, this.layout$).pipe($(this.destroy$)).subscribe();
3817
+ ), P(r, this.isNavigating$, this.layout$).pipe(T(this.destroy$)).subscribe();
3825
3818
  }
3826
3819
  /**
3827
3820
  * Programmatically set the viewport position.
@@ -3845,7 +3838,7 @@ class jo extends G {
3845
3838
  get viewportPosition() {
3846
3839
  const e = this.element$.getValue(), t = window.getComputedStyle(e), i = t.transform || t.webkitTransform;
3847
3840
  if (!i || i === "none")
3848
- return new L({ x: 0, y: 0 });
3841
+ return new M({ x: 0, y: 0 });
3849
3842
  const o = new DOMMatrix(i);
3850
3843
  return Oo(o);
3851
3844
  }
@@ -3860,7 +3853,7 @@ const ko = () => (n) => n.pipe(
3860
3853
  }))
3861
3854
  ), Uo = (n, e, t) => n.bridgeEvent.pagination$.pipe(
3862
3855
  z(e),
3863
- M(
3856
+ C(
3864
3857
  ([i, o]) => i.navigationId === o.id
3865
3858
  ),
3866
3859
  /**
@@ -3868,15 +3861,15 @@ const ko = () => (n) => n.pipe(
3868
3861
  * Otherwise we might save something incomplete and thus restore
3869
3862
  * the user to an invalid location.
3870
3863
  */
3871
- w(([i, o]) => (t.spineItemsManager.get(o.spineItem)?.isReady$.pipe(V()) ?? v(!1)).pipe(
3872
- M((r) => r),
3864
+ w(([i, o]) => (t.spineItemsManager.get(o.spineItem)?.isReady$.pipe(U()) ?? v(!1)).pipe(
3865
+ C((r) => r),
3873
3866
  S(() => ({
3874
3867
  pagination: i,
3875
3868
  navigation: o
3876
3869
  }))
3877
3870
  )),
3878
3871
  ko(),
3879
- k(
3872
+ N(
3880
3873
  (i, o) => i.navigation.paginationBeginCfi === o.navigation.paginationBeginCfi
3881
3874
  ),
3882
3875
  S(
@@ -3995,7 +3988,7 @@ const ko = () => (n) => n.pipe(
3995
3988
  },
3996
3989
  ...s
3997
3990
  };
3998
- const a = e.getNavigationForSpineIndexOrId(r), c = t.values.computedPageTurnMode === "scrollable" ? new ue({
3991
+ const a = e.getNavigationForSpineIndexOrId(r), c = t.values.computedPageTurnMode === "scrollable" ? new ae({
3999
3992
  x: a.x + s.previousNavigation.position.x,
4000
3993
  y: a.y
4001
3994
  }) : e.fromUnboundSpinePosition(a);
@@ -4007,7 +4000,7 @@ const ko = () => (n) => n.pipe(
4007
4000
  ...s
4008
4001
  };
4009
4002
  })
4010
- ), It = ({
4003
+ ), St = ({
4011
4004
  settings: n,
4012
4005
  spineItemsManager: e,
4013
4006
  navigationResolver: t,
@@ -4045,12 +4038,12 @@ const ko = () => (n) => n.pipe(
4045
4038
  }) ?? {}, b = (l === "forward" || l === "anchor" ? f : I) ?? 0, F = t.getNavigationForSpineItemPage({
4046
4039
  pageIndex: b,
4047
4040
  spineItemId: y
4048
- }), T = i.getVisibleSpineItemsFromPosition({
4041
+ }), x = i.getVisibleSpineItemsFromPosition({
4049
4042
  position: F,
4050
4043
  threshold: d,
4051
4044
  restrictToScreen: !1
4052
- }), E = l === "forward" || l === "anchor" ? T?.beginIndex : T?.endIndex;
4053
- return e.get(E);
4045
+ }), L = l === "forward" || l === "anchor" ? x?.beginIndex : x?.endIndex;
4046
+ return e.get(L);
4054
4047
  }
4055
4048
  return a && p === "scrollable" ? i.getSpineItemFromPosition(a) : e.get(0);
4056
4049
  };
@@ -4066,13 +4059,13 @@ const ko = () => (n) => n.pipe(
4066
4059
  };
4067
4060
  })
4068
4061
  );
4069
- }, bt = ({ spine: n }) => (e) => e.pipe(
4062
+ }, It = ({ spine: n }) => (e) => e.pipe(
4070
4063
  w(({ navigation: t, ...i }) => {
4071
4064
  const o = n.getSpineItemSpineLayoutInfo(
4072
4065
  t.spineItem
4073
4066
  ), s = n.spineItemsManager.get(t.spineItem);
4074
4067
  return (s?.isReady$ ?? v(!1)).pipe(
4075
- V(),
4068
+ U(),
4076
4069
  S(
4077
4070
  (r) => ({
4078
4071
  navigation: {
@@ -4089,7 +4082,7 @@ const ko = () => (n) => n.pipe(
4089
4082
  )
4090
4083
  );
4091
4084
  })
4092
- ), Ve = ({
4085
+ ), je = ({
4093
4086
  settings: n,
4094
4087
  spineItemsManager: e,
4095
4088
  spineLocator: t,
@@ -4152,11 +4145,11 @@ const ko = () => (n) => n.pipe(
4152
4145
  return t;
4153
4146
  })
4154
4147
  );
4155
- class Gt {
4148
+ class Xt {
4156
4149
  constructor() {
4157
- this.isLockedSubject = new Y(0), this.isLocked$ = this.isLockedSubject.pipe(
4150
+ this.isLockedSubject = new q(0), this.isLocked$ = this.isLockedSubject.pipe(
4158
4151
  S((e) => !!e),
4159
- k()
4152
+ N()
4160
4153
  );
4161
4154
  }
4162
4155
  lock() {
@@ -4175,7 +4168,7 @@ const Yo = ({
4175
4168
  }) => {
4176
4169
  const s = i.get(e.spineItem);
4177
4170
  return s ? s.isReady$.pipe(
4178
- V(),
4171
+ U(),
4179
4172
  S((r) => {
4180
4173
  const a = o.getSpineItemSpineLayoutInfo(s), c = n.isPositionWithinSpineItem(
4181
4174
  e.position,
@@ -4191,7 +4184,7 @@ const Yo = ({
4191
4184
  return g.position;
4192
4185
  }
4193
4186
  const p = e.cfi ?? e.paginationBeginCfi;
4194
- if (p !== void 0 && !Xe(p) && (u || l || // when spine item is ready dimensions may have not changed but the position
4187
+ if (p !== void 0 && !Be(p) && (u || l || // when spine item is ready dimensions may have not changed but the position
4195
4188
  // of dom elements may have!
4196
4189
  r && !e.spineItemIsReady)) {
4197
4190
  const g = t.getNavigationForCfi(p);
@@ -4199,7 +4192,7 @@ const Yo = ({
4199
4192
  return g;
4200
4193
  }
4201
4194
  if (c && d && e.directionFromLastNavigation === "backward") {
4202
- const g = new C({
4195
+ const g = new E({
4203
4196
  x: (e.positionInSpineItem?.x ?? 0) + u,
4204
4197
  y: (e.positionInSpineItem?.y ?? 0) + l
4205
4198
  });
@@ -4222,7 +4215,7 @@ const Yo = ({
4222
4215
  }
4223
4216
  return c ? t.getNavigationForPosition(e.position) : t.getNavigationForSpineIndexOrId(s);
4224
4217
  })
4225
- ) : v(new L({ x: 0, y: 0 }));
4218
+ ) : v(new M({ x: 0, y: 0 }));
4226
4219
  }, qo = ({
4227
4220
  navigation: n,
4228
4221
  spineLocator: e,
@@ -4232,11 +4225,11 @@ const Yo = ({
4232
4225
  spine: s
4233
4226
  }) => {
4234
4227
  const { spineItem: r } = n, a = t.get(r);
4235
- if (!a) return new L({ x: 0, y: 0 });
4228
+ if (!a) return new M({ x: 0, y: 0 });
4236
4229
  const { height: c, top: u } = s.getSpineItemSpineLayoutInfo(a), l = e.isPositionWithinSpineItem(
4237
4230
  n.position,
4238
4231
  a
4239
- ), d = n.positionInSpineItem ?? new C({
4232
+ ), d = n.positionInSpineItem ?? new E({
4240
4233
  y: 0,
4241
4234
  x: 0
4242
4235
  });
@@ -4247,7 +4240,7 @@ const Yo = ({
4247
4240
  return o.getNavigationForSpineIndexOrId(a);
4248
4241
  if (u !== n.spineItemTop) {
4249
4242
  const p = e.getSafeSpineItemPositionFromUnsafeSpineItemPosition(
4250
- n.positionInSpineItem ?? new C({
4243
+ n.positionInSpineItem ?? new E({
4251
4244
  x: 0,
4252
4245
  y: 0
4253
4246
  }),
@@ -4259,7 +4252,7 @@ const Yo = ({
4259
4252
  });
4260
4253
  }
4261
4254
  if (u === n.spineItemTop && c !== n.spineItemHeight) {
4262
- const p = (n.spineItemHeight ?? d.y) - d.y, g = new C({
4255
+ const p = (n.spineItemHeight ?? d.y) - d.y, g = new E({
4263
4256
  y: n.directionFromLastNavigation === "backward" ? c - p : d.y,
4264
4257
  x: n.position.x
4265
4258
  });
@@ -4275,7 +4268,7 @@ const Yo = ({
4275
4268
  }
4276
4269
  if (!l) {
4277
4270
  if (!(n.position.y < u)) {
4278
- const m = new C({
4271
+ const m = new E({
4279
4272
  y: c - p,
4280
4273
  x: n.position.x
4281
4274
  });
@@ -4314,7 +4307,7 @@ const Yo = ({
4314
4307
  navigationResolver: o,
4315
4308
  spineItemsManager: e,
4316
4309
  spine: s
4317
- }), vt = ({
4310
+ }), bt = ({
4318
4311
  settings: n,
4319
4312
  navigationResolver: e,
4320
4313
  context: t,
@@ -4337,28 +4330,28 @@ const Yo = ({
4337
4330
  }
4338
4331
  }))
4339
4332
  ))
4340
- ), Zo = "navigation/InternalNavigator", Jo = D.namespace(Zo);
4333
+ ), Zo = "navigation/InternalNavigator", Jo = A.namespace(Zo);
4341
4334
  class Ko extends G {
4342
4335
  constructor(e, t, i, o, s, r, a, c) {
4343
- super(), this.settings = e, this.context = t, this.userNavigation$ = i, this.controlledNavigationController = o, this.scrollNavigationController = s, this.navigationResolver = r, this.spine = a, this.isRestorationLocked$ = c, this.navigationSubject = new Y({
4336
+ super(), this.settings = e, this.context = t, this.userNavigation$ = i, this.controlledNavigationController = o, this.scrollNavigationController = s, this.navigationResolver = r, this.spine = a, this.isRestorationLocked$ = c, this.navigationSubject = new q({
4344
4337
  animation: !1,
4345
- position: new L({ x: 0, y: 0 }),
4338
+ position: new M({ x: 0, y: 0 }),
4346
4339
  meta: {
4347
4340
  triggeredBy: "user"
4348
4341
  },
4349
4342
  spineItemIsReady: !1,
4350
4343
  type: "api",
4351
4344
  id: /* @__PURE__ */ Symbol()
4352
- }), this.navigated$ = this.navigationSubject.pipe(Lt(1)), this.navigation$ = this.navigationSubject.pipe(
4345
+ }), this.navigated$ = this.navigationSubject.pipe(Ft(1)), this.navigation$ = this.navigationSubject.pipe(
4353
4346
  S(({ position: f, id: I }) => ({
4354
4347
  position: f,
4355
4348
  id: I
4356
4349
  })),
4357
- k(
4358
- ({ position: f, ...I }, { position: b, ...F }) => U(I, F) && U(f, b)
4350
+ N(
4351
+ ({ position: f, ...I }, { position: b, ...F }) => O(I, F) && O(f, b)
4359
4352
  ),
4360
4353
  J(1)
4361
- ), this.locker = new Gt();
4354
+ ), this.locker = new Xt();
4362
4355
  const u = i.pipe(
4363
4356
  z(this.navigationSubject),
4364
4357
  zo({
@@ -4379,19 +4372,19 @@ class Ko extends G {
4379
4372
  navigationResolver: r
4380
4373
  }),
4381
4374
  Ho({ context: t, settings: e }),
4382
- It({
4375
+ St({
4383
4376
  navigationResolver: r,
4384
4377
  settings: e,
4385
4378
  spineItemsManager: a.spineItemsManager,
4386
4379
  spineLocator: a.locator
4387
4380
  }),
4388
- Ve({
4381
+ je({
4389
4382
  navigationResolver: r,
4390
4383
  settings: e,
4391
4384
  spineItemsManager: a.spineItemsManager,
4392
4385
  spineLocator: a.locator
4393
4386
  }),
4394
- bt({
4387
+ It({
4395
4388
  spine: a
4396
4389
  })
4397
4390
  ).pipe(
@@ -4404,7 +4397,7 @@ class Ko extends G {
4404
4397
  w(([f, I]) => {
4405
4398
  const b = f.navigation.cfi || f.navigation.url || e.values.computedPageTurnMode === "scrollable" || I;
4406
4399
  return v(f).pipe(
4407
- b ? xe : vt({
4400
+ b ? xe : bt({
4408
4401
  navigationResolver: r,
4409
4402
  settings: e,
4410
4403
  spine: a,
@@ -4412,35 +4405,35 @@ class Ko extends G {
4412
4405
  })
4413
4406
  );
4414
4407
  }),
4415
- Ve({
4408
+ je({
4416
4409
  spineItemsManager: a.spineItemsManager,
4417
4410
  spineLocator: a.locator,
4418
4411
  settings: e,
4419
4412
  navigationResolver: r
4420
4413
  }),
4421
4414
  S((f) => f.navigation),
4422
- j()
4415
+ D()
4423
4416
  ), l = u.pipe(
4424
4417
  z(c),
4425
- M(([, f]) => f),
4418
+ C(([, f]) => f),
4426
4419
  w(([f]) => {
4427
4420
  const I = this.locker.lock();
4428
4421
  return c.pipe(
4429
- M((b) => !b),
4430
- V(),
4422
+ C((b) => !b),
4423
+ U(),
4431
4424
  S(
4432
4425
  () => ({
4433
4426
  ...f,
4434
4427
  animation: "snap"
4435
4428
  })
4436
4429
  ),
4437
- pe(() => {
4430
+ me(() => {
4438
4431
  I();
4439
4432
  }),
4440
- $(u)
4433
+ T(u)
4441
4434
  );
4442
4435
  }),
4443
- j()
4436
+ D()
4444
4437
  ), d = P(
4445
4438
  o.layout$,
4446
4439
  a.layout$
@@ -4448,8 +4441,8 @@ class Ko extends G {
4448
4441
  w(() => v(null).pipe(
4449
4442
  w(
4450
4443
  () => c.pipe(
4451
- M((f) => !f),
4452
- V()
4444
+ C((f) => !f),
4445
+ U()
4453
4446
  )
4454
4447
  ),
4455
4448
  S(
@@ -4463,7 +4456,7 @@ class Ko extends G {
4463
4456
  * another navigation. Whether it's user or internal, it means
4464
4457
  * it has been controlled outside.
4465
4458
  */
4466
- $(
4459
+ T(
4467
4460
  P(l, u)
4468
4461
  )
4469
4462
  ))
@@ -4472,7 +4465,7 @@ class Ko extends G {
4472
4465
  l
4473
4466
  ).pipe(
4474
4467
  S((f) => ({ navigation: f })),
4475
- vt({
4468
+ bt({
4476
4469
  navigationResolver: r,
4477
4470
  settings: e,
4478
4471
  context: t,
@@ -4495,23 +4488,23 @@ class Ko extends G {
4495
4488
  * eg: after the reader load and the user has never navigated
4496
4489
  * yet.
4497
4490
  */
4498
- It({
4491
+ St({
4499
4492
  navigationResolver: r,
4500
4493
  settings: e,
4501
4494
  spineItemsManager: a.spineItemsManager,
4502
4495
  spineLocator: a.locator
4503
4496
  }),
4504
- bt({
4497
+ It({
4505
4498
  spine: a
4506
4499
  }),
4507
- Ve({
4500
+ je({
4508
4501
  spineItemsManager: a.spineItemsManager,
4509
4502
  spineLocator: a.locator,
4510
4503
  settings: e,
4511
4504
  navigationResolver: r
4512
4505
  }),
4513
4506
  S(({ navigation: f }) => f),
4514
- j()
4507
+ D()
4515
4508
  ), g = Uo(
4516
4509
  t,
4517
4510
  this.navigationSubject,
@@ -4521,7 +4514,7 @@ class Ko extends G {
4521
4514
  u,
4522
4515
  g
4523
4516
  ), m = (f) => f.pipe(
4524
- x(([I, b]) => {
4517
+ $(([I, b]) => {
4525
4518
  Jo.info(
4526
4519
  `navigation updated from ${I.meta.triggeredBy} of type ${I.type}`,
4527
4520
  {
@@ -4531,12 +4524,12 @@ class Ko extends G {
4531
4524
  ), this.navigationSubject.next(I);
4532
4525
  })
4533
4526
  ), y = (f) => f.pipe(
4534
- x(([I, b]) => {
4535
- const F = I.type === "scroll", T = I.meta.triggeredBy === "pagination", E = I.meta.triggeredBy === "restoration", H = U(
4527
+ $(([I, b]) => {
4528
+ const F = I.type === "scroll", x = I.meta.triggeredBy === "pagination", L = I.meta.triggeredBy === "restoration", H = O(
4536
4529
  b.position,
4537
4530
  I.position
4538
4531
  );
4539
- if (F && !E || T || H)
4532
+ if (F && !L || x || H)
4540
4533
  return;
4541
4534
  const B = {
4542
4535
  position: I.position,
@@ -4549,7 +4542,7 @@ class Ko extends G {
4549
4542
  * Explicitly trust the unbound position to be valid at this point.
4550
4543
  * Thanks to consolidation and restoration.
4551
4544
  */
4552
- position: L.from(B.position)
4545
+ position: M.from(B.position)
4553
4546
  });
4554
4547
  })
4555
4548
  );
@@ -4564,7 +4557,7 @@ class Ko extends G {
4564
4557
  */
4565
4558
  y,
4566
4559
  m,
4567
- $(this.destroy$)
4560
+ T(this.destroy$)
4568
4561
  ).subscribe();
4569
4562
  }
4570
4563
  get navigation() {
@@ -4574,20 +4567,20 @@ class Ko extends G {
4574
4567
  const Fe = (n, e, t) => {
4575
4568
  const i = t - n, o = t * (e * n) / (t || 1);
4576
4569
  return Math.max(0, Math.min(i, o));
4577
- }, Ye = (n, e) => (e || 0) === 0 || (n || 0) === 0 ? 1 : Math.floor(Math.max(1, n / e)), je = (n, e, t) => {
4578
- const i = Ye(t, e), o = [...Array(i)].map((s, r) => r * e);
4570
+ }, Xe = (n, e) => (e || 0) === 0 || (n || 0) === 0 ? 1 : Math.floor(Math.max(1, n / e)), ke = (n, e, t) => {
4571
+ const i = Xe(t, e), o = [...Array(i)].map((s, r) => r * e);
4579
4572
  return n >= i * e ? o[o.length - 1] || 0 : o.find((s) => n < s + e) || 0;
4580
- }, wt = (n, e, t) => {
4573
+ }, vt = (n, e, t) => {
4581
4574
  const i = [...Array(t)].map((o, s) => s * e);
4582
4575
  return n <= 0 || t === 0 ? 0 : n >= t * e ? t - 1 : i.findIndex((o) => n < o + e) ?? 0;
4583
4576
  }, Qo = ({
4584
4577
  itemWidth: n,
4585
4578
  itemHeight: e,
4586
4579
  spineItemPosition: t
4587
- }) => new C({
4580
+ }) => new E({
4588
4581
  x: Math.min(n, Math.max(0, t.x)),
4589
4582
  y: Math.min(e, Math.max(0, t.y))
4590
- }), Zt = ({
4583
+ }), Yt = ({
4591
4584
  itemHeight: n,
4592
4585
  itemWidth: e,
4593
4586
  isUsingVerticalWriting: t,
@@ -4595,7 +4588,7 @@ const Fe = (n, e, t) => {
4595
4588
  pageHeight: o,
4596
4589
  pageTurnDirection: s,
4597
4590
  pageTurnMode: r
4598
- }) => s === "vertical" && r === "scrollable" ? 1 : t || s === "vertical" ? Ye(n, o) : Ye(e, i), Pt = ({
4591
+ }) => s === "vertical" && r === "scrollable" ? 1 : t || s === "vertical" ? Xe(n, o) : Xe(e, i), wt = ({
4599
4592
  itemWidth: n,
4600
4593
  itemHeight: e,
4601
4594
  position: t,
@@ -4610,7 +4603,7 @@ const Fe = (n, e, t) => {
4610
4603
  spineItemPosition: t,
4611
4604
  itemHeight: e,
4612
4605
  itemWidth: n
4613
- }).x, d = Zt({
4606
+ }).x, d = Yt({
4614
4607
  isUsingVerticalWriting: i,
4615
4608
  itemHeight: e,
4616
4609
  itemWidth: n,
@@ -4620,8 +4613,8 @@ const Fe = (n, e, t) => {
4620
4613
  pageTurnMode: a
4621
4614
  });
4622
4615
  if (i)
4623
- return wt(t.y, s, d);
4624
- const p = wt(l, o, d);
4616
+ return vt(t.y, s, d);
4617
+ const p = vt(l, o, d);
4625
4618
  return c ? d - 1 - p : p;
4626
4619
  }, es = ({
4627
4620
  pageIndex: n,
@@ -4636,7 +4629,7 @@ const Fe = (n, e, t) => {
4636
4629
  n,
4637
4630
  e.height
4638
4631
  );
4639
- return new C({
4632
+ return new E({
4640
4633
  x: 0,
4641
4634
  y: r
4642
4635
  });
@@ -4646,14 +4639,14 @@ const Fe = (n, e, t) => {
4646
4639
  n,
4647
4640
  e.width
4648
4641
  );
4649
- return t.isRTL() ? new C({
4642
+ return t.isRTL() ? new E({
4650
4643
  x: e.width - s - o.pageSize.width,
4651
4644
  y: 0
4652
- }) : new C({
4645
+ }) : new E({
4653
4646
  x: s,
4654
4647
  y: 0
4655
4648
  });
4656
- }, Jt = ({
4649
+ }, qt = ({
4657
4650
  context: n,
4658
4651
  settings: e,
4659
4652
  viewport: t
@@ -4661,14 +4654,14 @@ const Fe = (n, e, t) => {
4661
4654
  const i = (a, c, u) => {
4662
4655
  let l;
4663
4656
  a?.nodeName === "img" || a?.textContent === "" && a.nodeType === Node.ELEMENT_NODE ? l = a.getBoundingClientRect().x : a && (l = (a ? Cn(a, c) : void 0)?.getBoundingClientRect().x || l);
4664
- const d = u.layout.layoutInfo?.width || 0, p = t.pageSize.width;
4657
+ const d = u.layoutInfo?.width || 0, p = t.pageSize.width;
4665
4658
  if (l !== void 0) {
4666
- const g = je(
4659
+ const g = ke(
4667
4660
  l,
4668
4661
  p,
4669
4662
  d
4670
4663
  );
4671
- return new C({ x: g, y: 0 });
4664
+ return new E({ x: g, y: 0 });
4672
4665
  }
4673
4666
  };
4674
4667
  return {
@@ -4679,11 +4672,11 @@ const Fe = (n, e, t) => {
4679
4672
  }) => es({
4680
4673
  context: n,
4681
4674
  isUsingVerticalWriting: !!c.isUsingVerticalWriting(),
4682
- itemLayout: c.layout.layoutInfo,
4675
+ itemLayout: c.layoutInfo,
4683
4676
  pageIndex: a,
4684
4677
  viewport: t
4685
4678
  }),
4686
- getSpineItemPageIndexFromPosition: (a) => Pt({
4679
+ getSpineItemPageIndexFromPosition: (a) => wt({
4687
4680
  ...a,
4688
4681
  isRTL: n.isRTL(),
4689
4682
  pageWidth: t.pageSize.width,
@@ -4692,8 +4685,8 @@ const Fe = (n, e, t) => {
4692
4685
  pageTurnMode: e.values.pageTurnMode
4693
4686
  }),
4694
4687
  getSpineItemPageIndexFromNode: (a, c, u) => {
4695
- const l = i(a, c, u), { height: d, width: p } = u.layout.layoutInfo;
4696
- return l ? Pt({
4688
+ const l = i(a, c, u), { height: d, width: p } = u.layoutInfo;
4689
+ return l ? wt({
4697
4690
  isUsingVerticalWriting: !!u.isUsingVerticalWriting(),
4698
4691
  position: l,
4699
4692
  itemHeight: d,
@@ -4706,14 +4699,14 @@ const Fe = (n, e, t) => {
4706
4699
  }) : void 0;
4707
4700
  },
4708
4701
  getSpineItemClosestPositionFromUnsafePosition: (a, c) => {
4709
- const { width: u, height: l } = c.layout.layoutInfo;
4710
- return new C({
4711
- x: je(
4702
+ const { width: u, height: l } = c.layoutInfo;
4703
+ return new E({
4704
+ x: ke(
4712
4705
  a.x,
4713
4706
  t.pageSize.width,
4714
4707
  u
4715
4708
  ),
4716
- y: je(
4709
+ y: ke(
4717
4710
  a.y,
4718
4711
  t.pageSize.height,
4719
4712
  l
@@ -4721,7 +4714,7 @@ const Fe = (n, e, t) => {
4721
4714
  });
4722
4715
  },
4723
4716
  getSpineItemPagePositionFromSpineItemPosition: (a, c, u) => {
4724
- const { width: l, height: d } = u.layout.layoutInfo, p = t.pageSize.width, g = t.pageSize.height;
4717
+ const { width: l, height: d } = u.layoutInfo, p = t.pageSize.width, g = t.pageSize.height;
4725
4718
  if (!!u.isUsingVerticalWriting()) {
4726
4719
  const y = Fe(
4727
4720
  g,
@@ -4752,7 +4745,7 @@ const Fe = (n, e, t) => {
4752
4745
  settings: e,
4753
4746
  viewport: t
4754
4747
  }) => {
4755
- const i = Jt({
4748
+ const i = qt({
4756
4749
  context: n,
4757
4750
  settings: e,
4758
4751
  viewport: t
@@ -4773,10 +4766,10 @@ const Fe = (n, e, t) => {
4773
4766
  c,
4774
4767
  u,
4775
4768
  a
4776
- ) || new C({ x: 0, y: 0 })
4769
+ ) || new E({ x: 0, y: 0 })
4777
4770
  };
4778
4771
  };
4779
- function Kt({
4772
+ function Gt({
4780
4773
  position: n,
4781
4774
  isRTL: e,
4782
4775
  spineItemsManager: t,
@@ -4790,18 +4783,18 @@ function Kt({
4790
4783
  ), a = r.bottom - 1, c = Math.max(0, n.y), u = Math.min(c, a);
4791
4784
  if (e) {
4792
4785
  const g = Math.min(o, n.x), h = Math.max(g, r.left);
4793
- return new L({
4786
+ return new M({
4794
4787
  x: h,
4795
4788
  y: u
4796
4789
  });
4797
4790
  }
4798
4791
  const l = r.right - 1, d = Math.max(0, n.x), p = Math.min(d, l);
4799
- return new L({
4792
+ return new M({
4800
4793
  x: p,
4801
4794
  y: u
4802
4795
  });
4803
4796
  }
4804
- const xt = ({
4797
+ const Pt = ({
4805
4798
  position: n,
4806
4799
  isRTL: e,
4807
4800
  pageSizeHeight: t,
@@ -4809,7 +4802,7 @@ const xt = ({
4809
4802
  visibleAreaRectWidth: o,
4810
4803
  spine: s
4811
4804
  }) => {
4812
- const r = Kt({
4805
+ const r = Gt({
4813
4806
  position: n,
4814
4807
  isRTL: e,
4815
4808
  spineItemsManager: i,
@@ -4820,13 +4813,13 @@ const xt = ({
4820
4813
  ), c = s.getSpineItemSpineLayoutInfo(a), u = c.bottom - t, l = Math.min(r.y, u);
4821
4814
  if (e) {
4822
4815
  const p = Math.min(0, r.x);
4823
- return new L({
4816
+ return new M({
4824
4817
  x: p,
4825
4818
  y: l
4826
4819
  });
4827
4820
  }
4828
4821
  const d = c.right - o;
4829
- return new L({
4822
+ return new M({
4830
4823
  x: Math.min(r.x, d),
4831
4824
  y: l
4832
4825
  });
@@ -4836,8 +4829,8 @@ const xt = ({
4836
4829
  visibleAreaRectWidth: i
4837
4830
  }) => {
4838
4831
  const s = n % i !== 0 ? n - t : n;
4839
- return new L({ x: s, y: e });
4840
- }, qe = ({
4832
+ return new M({ x: s, y: e });
4833
+ }, Ye = ({
4841
4834
  viewportPosition: n,
4842
4835
  spineLocator: e,
4843
4836
  spineItemNavigationResolver: t,
@@ -4861,7 +4854,7 @@ const xt = ({
4861
4854
  visibleAreaRectWidth: i.absoluteViewport.width
4862
4855
  });
4863
4856
  }
4864
- return new L({ x: 0, y: 0 });
4857
+ return new M({ x: 0, y: 0 });
4865
4858
  }, ns = ({
4866
4859
  pageIndex: n,
4867
4860
  spineItemsManager: e,
@@ -4873,8 +4866,8 @@ const xt = ({
4873
4866
  const r = e.get(t);
4874
4867
  if (!r) {
4875
4868
  const u = n * s.pageSize.width;
4876
- return qe({
4877
- viewportPosition: new L({ x: u, y: 0 }),
4869
+ return Ye({
4870
+ viewportPosition: new M({ x: u, y: 0 }),
4878
4871
  spineItemNavigationResolver: o,
4879
4872
  spineLocator: i,
4880
4873
  viewport: s
@@ -4919,7 +4912,7 @@ const xt = ({
4919
4912
  spine: i
4920
4913
  });
4921
4914
  return t.getSpinePositionFromSpineItemPosition({
4922
- spineItemPosition: new C({ x: o, y: 0 }),
4915
+ spineItemPosition: new E({ x: o, y: 0 }),
4923
4916
  spineItem: e
4924
4917
  });
4925
4918
  }, rs = ({
@@ -5036,15 +5029,15 @@ const xt = ({
5036
5029
  viewport: s
5037
5030
  }),
5038
5031
  getNavigationForCfi: (g) => {
5039
- const h = e.getSpineItemFromCfi(g), { node: m, offset: y = 0 } = Xt({
5032
+ const h = e.getSpineItemFromCfi(g), { node: m, offset: y = 0 } = _t({
5040
5033
  cfi: g,
5041
5034
  spineItemsManager: e
5042
5035
  });
5043
5036
  if (!h) {
5044
- D.warn(us, `unable to detect item id from cfi ${g}`);
5037
+ A.warn(us, `unable to detect item id from cfi ${g}`);
5045
5038
  return;
5046
5039
  }
5047
- const f = m ? r.getNavigationFromNode(h, m, y) : new C({ x: 0, y: 0 }), I = t.getSpinePositionFromSpineItemPosition({
5040
+ const f = m ? r.getNavigationFromNode(h, m, y) : new E({ x: 0, y: 0 }), I = t.getSpinePositionFromSpineItemPosition({
5048
5041
  spineItemPosition: f,
5049
5042
  spineItem: h
5050
5043
  });
@@ -5075,17 +5068,17 @@ const xt = ({
5075
5068
  visibleAreaRectWidth: s.absoluteViewport.width
5076
5069
  });
5077
5070
  }
5078
- return new L({ x: 0, y: 0 });
5071
+ return new M({ x: 0, y: 0 });
5079
5072
  },
5080
- getNavigationForPosition: (g) => qe({
5073
+ getNavigationForPosition: (g) => Ye({
5081
5074
  viewportPosition: g,
5082
5075
  spineItemNavigationResolver: r,
5083
5076
  spineLocator: t,
5084
5077
  viewport: s
5085
5078
  }),
5086
5079
  getMostPredominantNavigationForPosition: (g) => {
5087
- const h = i.values.computedPageTurnDirection, m = 0.5, y = h === "horizontal" ? g.x + s.absoluteViewport.width * m : 0, f = h === "horizontal" ? 0 : g.y + s.absoluteViewport.height * m, I = xt({
5088
- position: new L({
5080
+ const h = i.values.computedPageTurnDirection, m = 0.5, y = h === "horizontal" ? g.x + s.absoluteViewport.width * m : 0, f = h === "horizontal" ? 0 : g.y + s.absoluteViewport.height * m, I = Pt({
5081
+ position: new M({
5089
5082
  x: y,
5090
5083
  y: f
5091
5084
  }),
@@ -5095,14 +5088,14 @@ const xt = ({
5095
5088
  spineItemsManager: e,
5096
5089
  spine: o
5097
5090
  });
5098
- return qe({
5091
+ return Ye({
5099
5092
  spineItemNavigationResolver: r,
5100
5093
  spineLocator: t,
5101
5094
  viewportPosition: I,
5102
5095
  viewport: s
5103
5096
  });
5104
5097
  },
5105
- fromUnboundSpinePosition: (g) => xt({
5098
+ fromUnboundSpinePosition: (g) => Pt({
5106
5099
  position: g,
5107
5100
  isRTL: n.isRTL(),
5108
5101
  pageSizeHeight: s.pageSize.height,
@@ -5110,7 +5103,7 @@ const xt = ({
5110
5103
  spineItemsManager: e,
5111
5104
  spine: o
5112
5105
  }),
5113
- fromOutOfBoundsSpinePosition: (g) => Kt({
5106
+ fromOutOfBoundsSpinePosition: (g) => Gt({
5114
5107
  position: g,
5115
5108
  isRTL: n.isRTL(),
5116
5109
  spineItemsManager: e,
@@ -5134,7 +5127,7 @@ const xt = ({
5134
5127
  settings: o,
5135
5128
  viewport: s
5136
5129
  }) => {
5137
- const r = new R(), a = r.asObservable(), c = new Gt(), u = ls({
5130
+ const r = new R(), a = r.asObservable(), c = new Xt(), u = ls({
5138
5131
  context: e,
5139
5132
  settings: o,
5140
5133
  spineItemsManager: n,
@@ -5162,15 +5155,15 @@ const xt = ({
5162
5155
  u,
5163
5156
  i,
5164
5157
  c.isLocked$
5165
- ), g = O([
5158
+ ), g = j([
5166
5159
  l.isNavigating$,
5167
5160
  d.isNavigating$,
5168
5161
  c.isLocked$,
5169
5162
  p.locker.isLocked$
5170
5163
  ]).pipe(
5171
5164
  ie((y) => y.some((f) => f) ? "busy" : "free"),
5172
- fe(),
5173
- Ze(1)
5165
+ be(),
5166
+ Ge(1)
5174
5167
  );
5175
5168
  return {
5176
5169
  destroy: () => {
@@ -5231,9 +5224,9 @@ class gs extends G {
5231
5224
  threshold: { type: "percentage", value: 0.5 }
5232
5225
  });
5233
5226
  return this.context.bridgeEvent.navigationUnlocked$.pipe(
5234
- Tt(1),
5227
+ $t(1),
5235
5228
  z(this.context.bridgeEvent.navigation$),
5236
- x(([, u]) => {
5229
+ $(([, u]) => {
5237
5230
  const { position: l } = u, d = this.pagination.value, {
5238
5231
  beginIndex: p,
5239
5232
  endIndex: g
@@ -5248,14 +5241,14 @@ class gs extends G {
5248
5241
  }) ?? {}, { endPageIndex: b = 0 } = c({
5249
5242
  spineItem: m,
5250
5243
  position: l
5251
- }) ?? {}, F = y === void 0 || Xe(y) || d.beginSpineItemIndex !== p, T = d.endSpineItemIndex !== g || f === void 0 || Xe(f), E = F ? me(h.item) : y, H = T ? me(m.item) : f, B = h.numberOfPages, re = m.numberOfPages;
5244
+ }) ?? {}, F = y === void 0 || Be(y) || d.beginSpineItemIndex !== p, x = d.endSpineItemIndex !== g || f === void 0 || Be(f), L = F ? he(h.item) : y, H = x ? he(m.item) : f, B = h.numberOfPages, se = m.numberOfPages;
5252
5245
  this.pagination.update({
5253
- beginCfi: E,
5246
+ beginCfi: L,
5254
5247
  beginNumberOfPagesInSpineItem: B,
5255
5248
  beginPageIndexInSpineItem: I,
5256
5249
  beginSpineItemIndex: p,
5257
5250
  endCfi: H,
5258
- endNumberOfPagesInSpineItem: re,
5251
+ endNumberOfPagesInSpineItem: se,
5259
5252
  endPageIndexInSpineItem: b,
5260
5253
  endSpineItemIndex: g,
5261
5254
  navigationId: u.id
@@ -5265,7 +5258,7 @@ class gs extends G {
5265
5258
  })
5266
5259
  ), a = r.pipe(
5267
5260
  De(this.context.bridgeEvent.viewportFree$),
5268
- x(() => {
5261
+ $(() => {
5269
5262
  const {
5270
5263
  beginSpineItemIndex: c,
5271
5264
  endSpineItemIndex: u,
@@ -5276,12 +5269,12 @@ class gs extends G {
5276
5269
  return;
5277
5270
  const p = this.spineItemsManager.get(c), g = this.spineItemsManager.get(u);
5278
5271
  p === void 0 || g === void 0 || this.pagination.update({
5279
- beginCfi: Be({
5272
+ beginCfi: He({
5280
5273
  pageIndex: l,
5281
5274
  spineItem: p,
5282
5275
  spine: this.spine
5283
5276
  }),
5284
- endCfi: Be({
5277
+ endCfi: He({
5285
5278
  pageIndex: d,
5286
5279
  spineItem: g,
5287
5280
  spine: this.spine
@@ -5289,7 +5282,7 @@ class gs extends G {
5289
5282
  });
5290
5283
  })
5291
5284
  );
5292
- P(r, a).pipe($(this.destroy$)).subscribe();
5285
+ P(r, a).pipe(T(this.destroy$)).subscribe();
5293
5286
  }
5294
5287
  }
5295
5288
  const hs = ({
@@ -5306,7 +5299,7 @@ class ms extends G {
5306
5299
  this.inputSettings = t, this.outputSettingsUpdateSubject = new R(), this._settings$ = this.outputSettingsUpdateSubject.asObservable().pipe(J(1)), this._settings$.subscribe();
5307
5300
  }
5308
5301
  _prepareUpdate(e) {
5309
- const t = $e(this.inputSettings, e), i = this.getOutputSettings(t), o = !U(this.outputSettings, i);
5302
+ const t = $e(this.inputSettings, e), i = this.getOutputSettings(t), o = !O(this.outputSettings, i);
5310
5303
  return {
5311
5304
  hasChanged: o,
5312
5305
  state: i,
@@ -5333,8 +5326,8 @@ class ms extends G {
5333
5326
  }
5334
5327
  watch(e) {
5335
5328
  return this.values$.pipe(
5336
- Ot(e),
5337
- k(U)
5329
+ Rt(e),
5330
+ N(O)
5338
5331
  );
5339
5332
  }
5340
5333
  destroy() {
@@ -5344,8 +5337,8 @@ class ms extends G {
5344
5337
  class fs extends ms {
5345
5338
  constructor(e, t) {
5346
5339
  super(e), this.context = t, t.watch(["manifest", "hasVerticalWriting"]).pipe(
5347
- x(() => this.update(this.values)),
5348
- $(this.destroy$)
5340
+ $(() => this.update(this.values)),
5341
+ T(this.destroy$)
5349
5342
  ).subscribe();
5350
5343
  }
5351
5344
  getComputedSettings(e) {
@@ -5359,7 +5352,7 @@ class fs extends ms {
5359
5352
  manifest: t
5360
5353
  })
5361
5354
  };
5362
- return t?.renditionFlow === "scrolled-continuous" && (o.computedPageTurnMode = "scrollable"), o.computedPageTurnMode === "scrollable" && (o.computedPageTurnDirection = "vertical"), i && o.computedPageTurnAnimation === "slide" && (D.warn(
5355
+ return t?.renditionFlow === "scrolled-continuous" && (o.computedPageTurnMode = "scrollable"), o.computedPageTurnMode === "scrollable" && (o.computedPageTurnDirection = "vertical"), i && o.computedPageTurnAnimation === "slide" && (A.warn(
5363
5356
  `pageTurnAnimation ${o.computedPageTurnAnimation} incompatible with current book, switching back to default`
5364
5357
  ), o.computedPageTurnAnimation = "none"), o.computedPageTurnMode === "scrollable" ? (o.computedPageTurnAnimationDuration = 0, o.computedPageTurnAnimation = "none") : o.computedPageTurnAnimationDuration = e.pageTurnAnimationDuration !== void 0 ? e.pageTurnAnimationDuration : 300, o;
5365
5358
  }
@@ -5380,7 +5373,7 @@ class fs extends ms {
5380
5373
  };
5381
5374
  }
5382
5375
  }
5383
- class ys extends Se {
5376
+ class ys extends ye {
5384
5377
  onUnload() {
5385
5378
  return _;
5386
5379
  }
@@ -5401,74 +5394,105 @@ class ys extends Se {
5401
5394
  }
5402
5395
  class Ss extends G {
5403
5396
  constructor(e, t, i, o, s, r, a) {
5404
- super(), this.item = e, this.containerElement = t, this.context = i, this.hookManager = o, this.renderer = s, this.settings = r, this.viewport = a, this.layoutTriggerSubject = new R(), this.lastLayout = null, this.applyDimsAfterLayout = ({
5405
- blankPagePosition: c,
5406
- minimumWidth: u
5407
- }) => (l) => l.pipe(
5408
- S((d) => {
5409
- const p = U(
5397
+ super(), this.item = e, this.containerElement = t, this.context = i, this.hookManager = o, this.renderer = s, this.settings = r, this.viewport = a, this.layoutTriggerSubject = new R(), this.lastLayout = null, this.computeLayoutInformation = ({
5398
+ isLastItem: u,
5399
+ horizontalOffset: l
5400
+ }) => {
5401
+ let d = this.viewport.value.pageSize.width, p = "none";
5402
+ const g = l % this.viewport.absoluteViewport.width === 0, h = this.context.manifest, m = Bt(h) ?? !1;
5403
+ if (this.settings.values.computedSpreadMode) {
5404
+ !m && this.renderer.renditionLayout === "reflowable" && !u && (d = this.viewport.value.pageSize.width * 2), !m && this.renderer.renditionLayout === "reflowable" && u && g && (d = this.viewport.value.pageSize.width * 2);
5405
+ const y = g && u && m;
5406
+ this.item.pageSpreadRight && g && !this.context.isRTL() ? (p = "before", d = this.viewport.value.pageSize.width * 2) : this.item.pageSpreadLeft && g && this.context.isRTL() ? (p = "before", d = this.viewport.value.pageSize.width * 2) : y && (this.context.isRTL() ? p = "before" : p = "after", d = this.viewport.value.pageSize.width * 2);
5407
+ }
5408
+ return {
5409
+ minimumWidth: d,
5410
+ blankPagePosition: p
5411
+ };
5412
+ }, this.adjustPositionOfElement = ({
5413
+ right: u,
5414
+ left: l,
5415
+ top: d
5416
+ }) => {
5417
+ u !== void 0 ? this.containerElement.style.right = `${u}px` : this.containerElement.style.removeProperty("right"), l !== void 0 ? this.containerElement.style.left = `${l}px` : this.containerElement.style.removeProperty("left"), d !== void 0 ? this.containerElement.style.top = `${d}px` : this.containerElement.style.removeProperty("top");
5418
+ }, this.updateContainerLayout = ({
5419
+ minimumWidth: u,
5420
+ edgeX: l,
5421
+ edgeY: d
5422
+ }) => (p) => p.pipe(
5423
+ S((g) => {
5424
+ const h = O(
5410
5425
  this.lastLayout?.pageSize,
5411
5426
  this.viewport.pageSize
5412
- ) ? this.lastLayout : void 0, { width: g, height: h } = p ?? {}, { width: m = g, height: y = h } = d ?? {}, { width: f, height: I } = this.viewport.pageSize, b = this.validateDimension(
5413
- m ?? f,
5414
- f,
5427
+ ) ? this.lastLayout : void 0, { width: m, height: y } = h ?? {}, { width: f = m, height: I = y } = g ?? {}, { width: b, height: F } = this.viewport.pageSize, x = this.validateDimension(
5428
+ f ?? b,
5429
+ b,
5415
5430
  u
5416
- ), F = this.settings.values.computedPageTurnMode === "scrollable" ? y ?? I : this.validateDimension(
5417
- y ?? I,
5418
- I,
5419
- I
5431
+ ), L = this.settings.values.computedPageTurnMode === "scrollable" ? I ?? F : this.validateDimension(
5432
+ I ?? F,
5433
+ F,
5434
+ F
5420
5435
  );
5421
5436
  return this.lastLayout = {
5422
- width: b,
5423
- height: F,
5437
+ width: x,
5438
+ height: L,
5424
5439
  pageSize: this.viewport.pageSize
5425
- }, this.containerElement.style.width = `${b}px`, this.containerElement.style.height = `${F}px`, this.hookManager.execute("item.onAfterLayout", void 0, {
5426
- blankPagePosition: c,
5427
- item: this.item,
5428
- minimumWidth: u
5429
- }), { width: b, height: F };
5440
+ }, this.containerElement.style.width = `${x}px`, this.containerElement.style.height = `${L}px`, this.settings.values.computedPageTurnDirection === "vertical" ? (this.adjustPositionOfElement({
5441
+ top: d,
5442
+ left: l
5443
+ }), { width: x, height: L }) : (this.adjustPositionOfElement(
5444
+ this.context.isRTL() ? { right: l, top: 0 } : { left: l, top: 0 }
5445
+ ), { width: x, height: L });
5430
5446
  })
5431
- ), this.layout = (c) => {
5432
- const u = Xn(this.layout$.pipe(V()));
5433
- return this.layoutTriggerSubject.next(c), u();
5434
- }, this.adjustPositionOfElement = ({
5435
- right: c,
5436
- left: u,
5437
- top: l
5438
- }) => {
5439
- c !== void 0 ? this.containerElement.style.right = `${c}px` : this.containerElement.style.removeProperty("right"), u !== void 0 ? this.containerElement.style.left = `${u}px` : this.containerElement.style.removeProperty("left"), l !== void 0 ? this.containerElement.style.top = `${l}px` : this.containerElement.style.removeProperty("top");
5440
- }, this.layoutProcess$ = this.layoutTriggerSubject.pipe(
5441
- w((c) => {
5442
- const { blankPagePosition: u, minimumWidth: l, spreadPosition: d } = c;
5443
- this.hookManager.execute("item.onBeforeLayout", void 0, {
5444
- blankPagePosition: u,
5445
- item: this.item,
5446
- minimumWidth: l
5447
- });
5448
- const p = this.renderer.layout({
5449
- blankPagePosition: u,
5450
- minPageSpread: l / this.viewport.pageSize.width,
5451
- minimumWidth: l,
5452
- spreadPosition: d
5453
- });
5454
- return P(
5455
- v({ type: "start" }),
5456
- p.pipe(
5457
- this.applyDimsAfterLayout(c),
5458
- S(
5459
- (g) => ({
5447
+ ), this.layout = (u) => {
5448
+ const l = Xn(this.didLayout$.pipe(U()));
5449
+ return this.layoutTriggerSubject.next(u), l();
5450
+ };
5451
+ const c = this.layoutTriggerSubject.pipe(
5452
+ w(
5453
+ ({ spreadPosition: u, horizontalOffset: l, isLastItem: d, edgeX: p, edgeY: g }) => {
5454
+ const { blankPagePosition: h, minimumWidth: m } = this.computeLayoutInformation({ horizontalOffset: l, isLastItem: d });
5455
+ this.hookManager.execute("item.onBeforeLayout", void 0, {
5456
+ blankPagePosition: h,
5457
+ item: this.item,
5458
+ minimumWidth: m
5459
+ });
5460
+ const y = this.renderer.layout({
5461
+ blankPagePosition: h,
5462
+ minPageSpread: m / this.viewport.pageSize.width,
5463
+ minimumWidth: m,
5464
+ spreadPosition: u
5465
+ });
5466
+ return P(
5467
+ v({ type: "start" }),
5468
+ y.pipe(
5469
+ /**
5470
+ * Now that inner layout is done from the renderer, we adjust the dimensions
5471
+ * of the outer container element
5472
+ */
5473
+ this.updateContainerLayout({
5474
+ minimumWidth: m,
5475
+ edgeX: p,
5476
+ edgeY: g
5477
+ }),
5478
+ S((f) => (this.hookManager.execute("item.onAfterLayout", void 0, {
5479
+ blankPagePosition: h,
5480
+ item: this.item,
5481
+ minimumWidth: m
5482
+ }), {
5460
5483
  type: "end",
5461
- data: g
5462
- })
5484
+ data: f
5485
+ }))
5463
5486
  )
5464
- )
5465
- );
5466
- }),
5467
- j()
5468
- ), this.layout$ = this.layoutProcess$.pipe(
5469
- M((c) => c.type === "end"),
5470
- S((c) => c.data),
5471
- j()
5487
+ );
5488
+ }
5489
+ ),
5490
+ D()
5491
+ );
5492
+ this.didLayout$ = c.pipe(
5493
+ C((u) => u.type === "end"),
5494
+ S((u) => u.data),
5495
+ D()
5472
5496
  );
5473
5497
  }
5474
5498
  validateDimension(e, t, i) {
@@ -5484,12 +5508,12 @@ class Ss extends G {
5484
5508
  };
5485
5509
  }
5486
5510
  }
5487
- class Qt extends Q {
5511
+ class Zt extends Q {
5488
5512
  constructor(e, t, i, o, s, r, a) {
5489
5513
  super({
5490
5514
  isLoaded: !1,
5491
5515
  isReady: !1,
5492
- iDirty: !1,
5516
+ isDirty: !1,
5493
5517
  isError: !1,
5494
5518
  error: void 0
5495
5519
  }), this.item = e, this.parentElement = t, this.context = i, this.settings = o, this.hookManager = s, this.index = r, this.viewport = a, this.load = () => {
@@ -5498,11 +5522,11 @@ class Qt extends Q {
5498
5522
  this.renderer.unload();
5499
5523
  }, this.markDirty = () => {
5500
5524
  this.mergeCompare({
5501
- iDirty: !0
5525
+ isDirty: !0
5502
5526
  });
5503
5527
  }, this.destroy = () => {
5504
5528
  super.destroy(), this.containerElement.remove(), this.renderer.destroy();
5505
- }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.containerElement = Is(
5529
+ }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.layout = (d) => this._layout.layout(d), this.containerElement = Is(
5506
5530
  t,
5507
5531
  e,
5508
5532
  s
@@ -5518,7 +5542,7 @@ class Qt extends Q {
5518
5542
  resourcesHandler: this.resourcesHandler,
5519
5543
  viewport: this.viewport
5520
5544
  };
5521
- this.renderer = c ? c(u) : new ys(u), this.layout = new Ss(
5545
+ this.renderer = c ? c(u) : new ys(u), this._layout = new Ss(
5522
5546
  e,
5523
5547
  this.containerElement,
5524
5548
  i,
@@ -5528,22 +5552,23 @@ class Qt extends Q {
5528
5552
  this.viewport
5529
5553
  );
5530
5554
  const l = this.renderer.state$.pipe(
5531
- N(({ state: p, error: g }) => {
5555
+ V(({ state: d, error: p }) => {
5532
5556
  this.mergeCompare({
5533
- isLoaded: p === "loaded",
5534
- isError: p === "error",
5535
- error: p === "error" ? g : void 0
5557
+ isLoaded: d === "loaded",
5558
+ isError: d === "error",
5559
+ error: d === "error" ? p : void 0
5536
5560
  });
5537
5561
  })
5538
- ), d = this.layout.layout$.pipe(
5539
- N(() => {
5562
+ );
5563
+ this.didLayout$ = this._layout.didLayout$.pipe(
5564
+ V(() => {
5540
5565
  this.mergeCompare({
5541
- iDirty: !1,
5566
+ isDirty: !1,
5542
5567
  isReady: this.renderer.state$.value.state === "loaded"
5543
5568
  });
5544
- })
5545
- );
5546
- this.needsLayout$ = P(this.unloaded$, this.loaded$), P(
5569
+ }),
5570
+ vn()
5571
+ ), P(
5547
5572
  /**
5548
5573
  * @important
5549
5574
  * The order is important here. We want to ensure the state value
@@ -5551,8 +5576,7 @@ class Qt extends Q {
5551
5576
  * to layout changes may rely on the state value to be updated.
5552
5577
  */
5553
5578
  l,
5554
- d,
5555
- this.layout.layout$
5579
+ this.didLayout$
5556
5580
  ).pipe(K(this.destroy$)).subscribe();
5557
5581
  }
5558
5582
  /**
@@ -5576,29 +5600,29 @@ class Qt extends Q {
5576
5600
  get readingDirection() {
5577
5601
  return this.renderer.readingDirection;
5578
5602
  }
5603
+ /**
5604
+ * Note that this is dispatched AFTER the state has been updated.
5605
+ */
5579
5606
  get loaded$() {
5580
5607
  return this.renderer.loaded$;
5581
5608
  }
5609
+ /**
5610
+ * Note that this is dispatched AFTER the state has been updated.
5611
+ */
5582
5612
  get unloaded$() {
5583
- return this.renderer.state$.pipe(
5584
- fe(),
5585
- ae(({ state: e }) => e !== "idle"),
5586
- X(
5587
- () => this.renderer.state$.pipe(
5588
- ae(({ state: e }) => e === "idle"),
5589
- Mt()
5590
- )
5591
- )
5592
- );
5613
+ return this.renderer.unloaded$;
5593
5614
  }
5594
5615
  get renditionLayout() {
5595
5616
  return this.renderer.renditionLayout;
5596
5617
  }
5618
+ get layoutInfo() {
5619
+ return this._layout.layoutInfo;
5620
+ }
5597
5621
  get numberOfPages() {
5598
- return Zt({
5622
+ return Yt({
5599
5623
  isUsingVerticalWriting: !!this.isUsingVerticalWriting(),
5600
- itemHeight: this.layout.layoutInfo.height,
5601
- itemWidth: this.layout.layoutInfo.width,
5624
+ itemHeight: this._layout.layoutInfo.height,
5625
+ itemWidth: this._layout.layoutInfo.width,
5602
5626
  pageWidth: this.viewport.pageSize.width,
5603
5627
  pageHeight: this.viewport.pageSize.height,
5604
5628
  pageTurnDirection: this.settings.values.computedPageTurnDirection,
@@ -5615,12 +5639,12 @@ const Is = (n, e, t) => {
5615
5639
  };
5616
5640
  class bs extends G {
5617
5641
  constructor(e, t, i, o, s) {
5618
- super(), this.context = e, this.spineItemsManager = t, this.spineLocator = i, this.settings = o, this.spineLayout = s, this.forcedOpenSubject = new Y(
5642
+ super(), this.context = e, this.spineItemsManager = t, this.spineLocator = i, this.settings = o, this.spineLayout = s, this.forcedOpenSubject = new q(
5619
5643
  /* @__PURE__ */ new Map()
5620
5644
  );
5621
5645
  const r = this.forcedOpenSubject.pipe(
5622
5646
  S((u) => Array.from(u.keys()).sort((l, d) => l - d)),
5623
- k(fn),
5647
+ N(hn),
5624
5648
  J({ bufferSize: 1, refCount: !0 })
5625
5649
  );
5626
5650
  P(
@@ -5632,7 +5656,7 @@ class bs extends G {
5632
5656
  // this can be changed by whatever we want and SHOULD not break navigation.
5633
5657
  // Ideally loading faster is better but loading too close to user navigating can
5634
5658
  // be dangerous.
5635
- be(100, ce),
5659
+ Ie(100, re),
5636
5660
  De(this.context.bridgeEvent.viewportFree$),
5637
5661
  z(this.context.bridgeEvent.navigation$, r),
5638
5662
  S(([, u, l]) => {
@@ -5648,7 +5672,7 @@ class bs extends G {
5648
5672
  f.includes(b) ? I.load() : I.unload();
5649
5673
  });
5650
5674
  })
5651
- ).pipe($(this.destroy$)).subscribe();
5675
+ ).pipe(T(this.destroy$)).subscribe();
5652
5676
  }
5653
5677
  forceOpen(e) {
5654
5678
  const t = e.map(
@@ -5668,21 +5692,21 @@ class bs extends G {
5668
5692
  super.destroy(), this.forcedOpenSubject.complete();
5669
5693
  }
5670
5694
  }
5671
- const en = (n, e, t) => {
5695
+ const Jt = (n, e, t) => {
5672
5696
  const i = (t.width - e.width) / 2, o = (t.height - e.height) / 2;
5673
- return new ue({
5697
+ return new ae({
5674
5698
  x: n.x - i,
5675
5699
  y: n.y - o
5676
5700
  });
5677
5701
  };
5678
- class Ie extends DOMRect {
5702
+ class Se extends DOMRect {
5679
5703
  constructor() {
5680
5704
  super(...arguments), this.__symbol = /* @__PURE__ */ Symbol("ViewportPosition");
5681
5705
  }
5682
5706
  static from(e, t) {
5683
5707
  if (t) {
5684
5708
  const o = e;
5685
- return new Ie(
5709
+ return new Se(
5686
5710
  o.x,
5687
5711
  o.y,
5688
5712
  t.width,
@@ -5690,7 +5714,7 @@ class Ie extends DOMRect {
5690
5714
  );
5691
5715
  }
5692
5716
  const i = e;
5693
- return new Ie(i.x, i.y, i.width, i.height);
5717
+ return new Se(i.x, i.y, i.width, i.height);
5694
5718
  }
5695
5719
  }
5696
5720
  class vs {
@@ -5742,7 +5766,7 @@ const Ps = ({
5742
5766
  }) => {
5743
5767
  const o = n / i.width, s = e / i.height;
5744
5768
  return t.type === "percentage" ? s >= t.value && o >= t.value : e >= t.value && n >= t.value;
5745
- }, tn = ({
5769
+ }, Kt = ({
5746
5770
  itemPosition: {
5747
5771
  bottom: n,
5748
5772
  left: e,
@@ -5781,7 +5805,7 @@ const Ps = ({
5781
5805
  visibleWidthOfItem: g
5782
5806
  }) || y
5783
5807
  };
5784
- }, Ge = ({
5808
+ }, qe = ({
5785
5809
  position: n,
5786
5810
  spineItemsManager: e,
5787
5811
  spineLayout: t
@@ -5791,10 +5815,10 @@ const Ps = ({
5791
5815
  return u && l;
5792
5816
  });
5793
5817
  return n.x === 0 && !i ? e.items[0] : i;
5794
- }, ke = ({
5818
+ }, Ue = ({
5795
5819
  spineItemPosition: n,
5796
5820
  itemLayout: { left: e, top: t }
5797
- }) => new L({
5821
+ }) => new M({
5798
5822
  x: e + n.x,
5799
5823
  y: t + n.y
5800
5824
  }), Ts = ({
@@ -5806,20 +5830,20 @@ const Ps = ({
5806
5830
  useAbsoluteViewport: s = !0,
5807
5831
  viewport: r
5808
5832
  }) => {
5809
- const a = Ge({
5833
+ const a = qe({
5810
5834
  position: n,
5811
5835
  spineItemsManager: i,
5812
5836
  spineLayout: o
5813
5837
  }) || i.get(0), c = i.items.reduce(
5814
5838
  (g, h) => {
5815
- const m = o.getSpineItemSpineLayoutInfo(h), y = s ? r.absoluteViewport : r.relativeViewport, f = en(
5839
+ const m = o.getSpineItemSpineLayoutInfo(h), y = s ? r.absoluteViewport : r.relativeViewport, f = Jt(
5816
5840
  n,
5817
5841
  r.absoluteViewport,
5818
5842
  y
5819
- ), I = Ie.from(
5843
+ ), I = Se.from(
5820
5844
  f,
5821
5845
  y
5822
- ), { visible: b } = tn({
5846
+ ), { visible: b } = Kt({
5823
5847
  itemPosition: m,
5824
5848
  threshold: e,
5825
5849
  viewportPosition: I,
@@ -5845,7 +5869,7 @@ const Ps = ({
5845
5869
  }) => {
5846
5870
  const r = (h, m) => {
5847
5871
  const { left: y, top: f } = o.getSpineItemSpineLayoutInfo(m);
5848
- return new C({
5872
+ return new E({
5849
5873
  /**
5850
5874
  * when using spread the item could be on the right and therefore will be negative
5851
5875
  * @example
@@ -5856,8 +5880,8 @@ const Ps = ({
5856
5880
  x: Math.max(h.x - y, 0),
5857
5881
  y: Math.max(h.y - f, 0)
5858
5882
  });
5859
- }, a = (h) => ke({
5860
- spineItemPosition: new C({ x: 0, y: 0 }),
5883
+ }, a = (h) => Ue({
5884
+ spineItemPosition: new E({ x: 0, y: 0 }),
5861
5885
  itemLayout: o.getSpineItemSpineLayoutInfo(h)
5862
5886
  }), c = (h) => n.items.find((m) => m.renderer.getDocumentFrame() === h), u = (h, m, y) => {
5863
5887
  if (typeof y == "number") {
@@ -5881,44 +5905,44 @@ const Ps = ({
5881
5905
  useAbsoluteViewport: I = !0,
5882
5906
  viewport: b
5883
5907
  }) => {
5884
- const F = y.numberOfPages, E = Array.from(Array(F)).map((re, le) => {
5885
- const Re = t.getSpineItemPositionFromPageIndex({
5886
- pageIndex: le,
5908
+ const F = y.numberOfPages, L = Array.from(Array(F)).map((se, ue) => {
5909
+ const Ae = t.getSpineItemPositionFromPageIndex({
5910
+ pageIndex: ue,
5887
5911
  spineItem: y
5888
- }), de = ke({
5889
- spineItemPosition: Re,
5912
+ }), le = Ue({
5913
+ spineItemPosition: Ae,
5890
5914
  itemLayout: o.getSpineItemSpineLayoutInfo(y)
5891
5915
  });
5892
5916
  return {
5893
- index: le,
5917
+ index: ue,
5894
5918
  absolutePosition: {
5895
5919
  width: b.pageSize.width,
5896
5920
  height: b.pageSize.height,
5897
- left: de.x,
5898
- top: de.y,
5899
- bottom: de.y + b.pageSize.height,
5900
- right: de.x + b.pageSize.width
5921
+ left: le.x,
5922
+ top: le.y,
5923
+ bottom: le.y + b.pageSize.height,
5924
+ right: le.x + b.pageSize.width
5901
5925
  }
5902
5926
  };
5903
5927
  }).reduce(
5904
- (re, { absolutePosition: le, index: Re }) => {
5905
- const de = I ? b.absoluteViewport : b.relativeViewport, nn = en(
5928
+ (se, { absolutePosition: ue, index: Ae }) => {
5929
+ const le = I ? b.absoluteViewport : b.relativeViewport, Qt = Jt(
5906
5930
  h,
5907
5931
  b.absoluteViewport,
5908
- de
5909
- ), on = Ie.from(
5910
- nn,
5911
- de
5912
- ), { visible: sn } = tn({
5913
- viewportPosition: on,
5932
+ le
5933
+ ), en = Se.from(
5934
+ Qt,
5935
+ le
5936
+ ), { visible: tn } = Kt({
5937
+ viewportPosition: en,
5914
5938
  restrictToScreen: f,
5915
5939
  threshold: m,
5916
- itemPosition: le
5940
+ itemPosition: ue
5917
5941
  });
5918
- return sn ? [...re, Re] : re;
5942
+ return tn ? [...se, Ae] : se;
5919
5943
  },
5920
5944
  []
5921
- ), H = E[0], B = E[E.length - 1] ?? H;
5945
+ ), H = L[0], B = L[L.length - 1] ?? H;
5922
5946
  if (!(H === void 0 || B === void 0))
5923
5947
  return {
5924
5948
  beginPageIndex: H,
@@ -5931,7 +5955,7 @@ const Ps = ({
5931
5955
  spineItemPosition: m
5932
5956
  }) => {
5933
5957
  const y = o.getSpineItemSpineLayoutInfo(h);
5934
- return ke({
5958
+ return Ue({
5935
5959
  itemLayout: y,
5936
5960
  spineItemPosition: m
5937
5961
  });
@@ -5944,7 +5968,7 @@ const Ps = ({
5944
5968
  spineItemsManager: n
5945
5969
  }),
5946
5970
  getSpineItemPagePositionFromSpinePosition: (h) => {
5947
- const m = Ge({
5971
+ const m = qe({
5948
5972
  position: h,
5949
5973
  spineItemsManager: n,
5950
5974
  spineLayout: o
@@ -5955,8 +5979,8 @@ const Ps = ({
5955
5979
  h,
5956
5980
  m
5957
5981
  ), f = t.getSpineItemPageIndexFromPosition({
5958
- itemWidth: m.layout.layoutInfo.width,
5959
- itemHeight: m.layout.layoutInfo.height,
5982
+ itemWidth: m.layoutInfo.width,
5983
+ itemHeight: m.layoutInfo.height,
5960
5984
  position: y,
5961
5985
  isUsingVerticalWriting: !!m.isUsingVerticalWriting()
5962
5986
  }), I = t.getSpineItemPagePositionFromSpineItemPosition(
@@ -5973,7 +5997,7 @@ const Ps = ({
5973
5997
  },
5974
5998
  getSpinePositionFromSpineItem: a,
5975
5999
  getSpineItemPositionFromSpinePosition: r,
5976
- getSpineItemFromPosition: (h) => Ge({
6000
+ getSpineItemFromPosition: (h) => qe({
5977
6001
  position: h,
5978
6002
  spineItemsManager: n,
5979
6003
  spineLayout: o
@@ -5997,13 +6021,13 @@ const Ps = ({
5997
6021
  spineItemLocator: t,
5998
6022
  getSafeSpineItemPositionFromUnsafeSpineItemPosition: (h, m) => {
5999
6023
  const { height: y, width: f } = o.getSpineItemSpineLayoutInfo(m);
6000
- return new C({
6024
+ return new E({
6001
6025
  x: Math.min(Math.max(0, h.x), f),
6002
6026
  y: Math.min(Math.max(0, h.y), y)
6003
6027
  });
6004
6028
  }
6005
6029
  };
6006
- }, Ls = D.namespace("spine"), Ms = ({
6030
+ }, Ls = A.namespace("spine"), Ms = ({
6007
6031
  position: n,
6008
6032
  pageSize: e
6009
6033
  }) => new Ii({
@@ -6019,7 +6043,9 @@ class Cs extends Q {
6019
6043
  constructor(e, t, i, o, s, r) {
6020
6044
  super({ pages: [] }), this.spineLayout = e, this.spineItemsManager = t, this.spineItemLocator = i, this.context = o, this.locator = s, this.viewport = r, this.fromSpineItemPageIndex = (a, c) => this.value.pages.find(
6021
6045
  (u) => u.itemIndex === a.index && u.pageIndex === c
6022
- ), this.fromAbsolutePageIndex = (a) => this.value.pages.reduce((c, u) => c || (u.absolutePageIndex === a ? u : c), void 0), this.observeFromAbsolutePageIndex = (a) => this.pipe(S(() => this.fromAbsolutePageIndex(a))), this.layout$ = e.layout$.pipe(
6046
+ ), this.fromAbsolutePageIndex = (a) => this.value.pages.find(
6047
+ (c) => c.absolutePageIndex === a
6048
+ ), this.observeFromAbsolutePageIndex = (a) => this.pipe(S(() => this.fromAbsolutePageIndex(a))), this.layout$ = e.layout$.pipe(
6023
6049
  z(r),
6024
6050
  w(([, { pageSize: a }]) => {
6025
6051
  const c = t.items.reduce(
@@ -6057,209 +6083,148 @@ class Cs extends Q {
6057
6083
  },
6058
6084
  []
6059
6085
  );
6060
- return O(
6086
+ return j(
6061
6087
  c.map((l) => {
6062
6088
  const { spineItem: d, ...p } = l;
6063
- return new se((g) => {
6064
- const h = l.spineItem.renderer?.getDocumentFrame();
6065
- let m;
6066
- h && h?.contentWindow?.document && // very important because it is being used by next functions
6067
- h.contentWindow.document.body !== null && (m = Ln(
6068
- h.contentWindow.document,
6069
- l.layout
6070
- )), g.next({ ...p, firstVisibleNode: m });
6071
- });
6089
+ if (l.spineItem.value.isLoaded) {
6090
+ const g = l.spineItem.renderer?.getDocumentFrame();
6091
+ if (g && g?.contentWindow?.document && g.contentWindow.document.body !== null) {
6092
+ const h = g.contentWindow.document;
6093
+ return et().pipe(
6094
+ S(() => {
6095
+ const m = Ln(
6096
+ h,
6097
+ l.layout
6098
+ );
6099
+ return {
6100
+ ...p,
6101
+ firstVisibleNode: m
6102
+ };
6103
+ })
6104
+ );
6105
+ }
6106
+ }
6107
+ return v({ ...p, firstVisibleNode: void 0 });
6072
6108
  })
6073
6109
  );
6074
6110
  }),
6075
6111
  S((a) => (Ls.info("Pages layout", a), { pages: a })),
6076
- j()
6077
- ), this.layout$.pipe($(this.destroy$)).subscribe(this.next.bind(this));
6112
+ D()
6113
+ ), this.layout$.pipe(T(this.destroy$)).subscribe(this.next.bind(this));
6078
6114
  }
6079
6115
  }
6080
6116
  class Es extends G {
6081
- constructor(e, t) {
6082
- super(), this.spineItemsManager = e, this.spineLocator = t, this.itemIsReady$ = this.spineItemsManager.items$.pipe(
6083
- w((i) => {
6084
- const o = i.map(
6085
- (s) => s.isReady$.pipe(S((r) => ({ item: s, isReady: r })))
6086
- );
6087
- return P(...o);
6088
- }),
6089
- j()
6117
+ constructor(e) {
6118
+ super(), this.spineItemsManager = e, this.states$ = this.spineItemsManager.items$.pipe(
6119
+ w((t) => P(
6120
+ ...t.map(
6121
+ (i) => i.pipe(
6122
+ S((o) => ({ item: i, ...o })),
6123
+ N(O)
6124
+ )
6125
+ )
6126
+ )),
6127
+ D()
6090
6128
  ), this.itemResize$ = this.spineItemsManager.items$.pipe(
6091
- w((i) => {
6092
- const o = i.map(
6093
- (s) => et(s.element).pipe(
6094
- S((r) => ({ entries: r, item: s }))
6129
+ w((t) => {
6130
+ const i = t.map(
6131
+ (o) => Qe(o.element).pipe(
6132
+ S((s) => ({ entries: s, item: o }))
6095
6133
  )
6096
6134
  );
6097
- return P(...o);
6135
+ return P(...i);
6098
6136
  }),
6099
- j()
6137
+ D()
6138
+ ), this.itemLoad$ = this.spineItemsManager.items$.pipe(
6139
+ w((t) => P(...t.map((i) => i.loaded$.pipe(S(() => i))))),
6140
+ D()
6141
+ ), this.itemUnload$ = this.spineItemsManager.items$.pipe(
6142
+ w((t) => P(
6143
+ ...t.map((i) => i.unloaded$.pipe(S(() => i)))
6144
+ )),
6145
+ D()
6100
6146
  );
6101
6147
  }
6102
6148
  }
6103
- const Ds = ({
6104
- horizontalOffset: n,
6105
- verticalOffset: e,
6106
- context: t,
6107
- spineItemsManager: i,
6108
- isGloballyPrePaginated: o,
6109
- settings: s,
6110
- index: r,
6111
- item: a,
6112
- viewport: c
6113
- }) => {
6114
- let u = c.value.pageSize.width, l = "none";
6115
- const d = n % c.absoluteViewport.width === 0, p = r === i.items.length - 1;
6116
- if (s.values.computedSpreadMode) {
6117
- !o && a.renditionLayout === "reflowable" && !p && (u = c.value.pageSize.width * 2), !o && a.renditionLayout === "reflowable" && p && d && (u = c.value.pageSize.width * 2);
6118
- const h = d && p && o;
6119
- a.item.pageSpreadRight && d && !t.isRTL() || a.item.pageSpreadLeft && d && t.isRTL() ? (l = "before", u = c.value.pageSize.width * 2) : h && (t.isRTL() ? l = "before" : l = "after", u = c.value.pageSize.width * 2);
6120
- }
6121
- return a.layout.layout({
6122
- minimumWidth: u,
6123
- blankPagePosition: l,
6124
- spreadPosition: s.values.computedSpreadMode ? d ? t.isRTL() ? "right" : "left" : t.isRTL() ? "left" : "right" : "none"
6125
- }).pipe(
6126
- S(({ width: h, height: m }) => {
6127
- if (s.values.computedPageTurnDirection === "vertical") {
6128
- const I = d ? e : e - c.absoluteViewport.height, b = d ? 0 : n;
6129
- t.isRTL() ? a.layout.adjustPositionOfElement({
6130
- top: I,
6131
- left: b
6132
- }) : a.layout.adjustPositionOfElement({
6133
- top: I,
6134
- left: b
6135
- });
6136
- const F = h + b, T = m + I, E = new He({
6137
- left: b,
6138
- right: F,
6139
- top: I,
6140
- bottom: T,
6141
- height: m,
6142
- width: h,
6143
- x: b,
6144
- y: I
6149
+ class Ds extends G {
6150
+ constructor(e, t, i, o, s) {
6151
+ super(), this.spineItemsManager = e, this.spineItemsObserver = t, this.context = i, this.settings = o, this.viewport = s, this.externalLayoutTrigger = new R(), this.spineItemsRelativeLayouts = [];
6152
+ const r = P(
6153
+ t.itemLoad$,
6154
+ t.itemUnload$
6155
+ ), a = P(
6156
+ this.externalLayoutTrigger,
6157
+ r
6158
+ );
6159
+ this.layout$ = a.pipe(
6160
+ $(() => {
6161
+ this.spineItemsManager.items.forEach((c) => {
6162
+ c.markDirty();
6145
6163
  });
6146
- return {
6147
- horizontalOffset: F,
6148
- verticalOffset: T,
6149
- layoutPosition: E
6150
- };
6151
- }
6152
- a.layout.adjustPositionOfElement(
6153
- t.isRTL() ? { right: n, top: 0 } : { left: n, top: 0 }
6154
- );
6155
- const y = t.isRTL() ? c.absoluteViewport.width - n - h : n, f = new He({
6156
- right: t.isRTL() ? c.absoluteViewport.width - n : n + h,
6157
- left: y,
6158
- x: y,
6159
- top: e,
6160
- bottom: m,
6161
- height: m,
6162
- width: h,
6163
- y: e
6164
- });
6165
- return {
6166
- horizontalOffset: n + h,
6167
- verticalOffset: 0,
6168
- layoutPosition: f
6169
- };
6170
- })
6171
- );
6172
- };
6173
- class Rs extends G {
6174
- constructor(e, t, i, o) {
6175
- super(), this.spineItemsManager = e, this.context = t, this.settings = i, this.viewport = o, this.layoutSubject = new R(), this.spineItemsRelativeLayouts = [], e.items$.pipe(
6176
- x(() => {
6177
- this.spineItemsRelativeLayouts = [];
6178
6164
  }),
6179
- w((r) => {
6180
- const a = r.map(
6181
- (u) => u.needsLayout$.pipe(
6182
- x(() => {
6183
- this.layout();
6184
- })
6185
- )
6186
- ), c = r.map(
6187
- (u) => u.loaded$.pipe(
6188
- x(() => {
6189
- u.isUsingVerticalWriting() ? this.context.update({
6190
- hasVerticalWriting: !0
6191
- }) : this.context.update({
6192
- hasVerticalWriting: !1
6193
- });
6165
+ Ie(50),
6166
+ w(
6167
+ () => this.spineItemsManager.items.reduce(
6168
+ (c, u, l) => c.pipe(
6169
+ ln(({ horizontalOffset: d, verticalOffset: p }) => {
6170
+ const g = d % s.absoluteViewport.width === 0, h = l === e.items.length - 1, m = o.values.computedPageTurnDirection === "vertical", y = i.isRTL(), f = this.getSpreadPosition(
6171
+ g,
6172
+ y
6173
+ ), { edgeX: I, edgeY: b } = this.getStartEdges(
6174
+ m,
6175
+ g,
6176
+ d,
6177
+ p,
6178
+ s.absoluteViewport.height
6179
+ );
6180
+ return u.layout({
6181
+ spreadPosition: f,
6182
+ horizontalOffset: d,
6183
+ isLastItem: h,
6184
+ edgeX: I,
6185
+ edgeY: b
6186
+ }).pipe(
6187
+ S(({ width: F, height: x }) => {
6188
+ const L = this.createSpineItemLayout(
6189
+ m,
6190
+ y,
6191
+ I,
6192
+ b,
6193
+ F,
6194
+ x,
6195
+ s.absoluteViewport.width
6196
+ );
6197
+ return this.spineItemsRelativeLayouts[l] = L, {
6198
+ horizontalOffset: I + F,
6199
+ verticalOffset: m ? b + x : 0
6200
+ };
6201
+ })
6202
+ );
6194
6203
  })
6195
- )
6196
- );
6197
- return P(...a, ...c);
6198
- })
6199
- ).pipe($(this.destroy$)).subscribe();
6200
- const s = new Y(!1);
6201
- this.layout$ = this.layoutSubject.pipe(
6202
- x(() => {
6203
- this.spineItemsManager.items.forEach((r) => {
6204
- r.markDirty();
6205
- });
6206
- }),
6207
- be(50),
6208
- // queue layout until previous layout is done
6209
- ze(
6210
- () => s.pipe(
6211
- M((r) => !r),
6212
- V()
6204
+ ),
6205
+ v({ horizontalOffset: 0, verticalOffset: 0 })
6213
6206
  )
6214
6207
  ),
6215
- ze(() => {
6216
- s.next(!0);
6217
- const r = this.context.manifest, a = qt(r) ?? !1;
6218
- return A(this.spineItemsManager.items).pipe(
6219
- pn(
6220
- (u, l, d) => u.pipe(
6221
- st(
6222
- ({ horizontalOffset: p, verticalOffset: g }) => Ds({
6223
- context: this.context,
6224
- horizontalOffset: p,
6225
- index: d,
6226
- isGloballyPrePaginated: a,
6227
- item: l,
6228
- settings: this.settings,
6229
- spineItemsManager: this.spineItemsManager,
6230
- verticalOffset: g,
6231
- viewport: o
6232
- }).pipe(
6233
- S(
6234
- ({
6235
- horizontalOffset: h,
6236
- verticalOffset: m,
6237
- layoutPosition: y
6238
- }) => (this.spineItemsRelativeLayouts[d] = y, {
6239
- horizontalOffset: h,
6240
- verticalOffset: m
6241
- })
6242
- )
6243
- )
6244
- )
6245
- ),
6246
- v({ horizontalOffset: 0, verticalOffset: 0 })
6247
- ),
6248
- st((u) => u),
6249
- pe(() => {
6250
- s.next(!1);
6251
- })
6252
- );
6208
+ T(this.destroy$),
6209
+ D()
6210
+ ), this.layout$.subscribe(), this.watchForVerticalWritingUpdate();
6211
+ }
6212
+ watchForVerticalWritingUpdate() {
6213
+ this.spineItemsObserver.itemLoad$.pipe(
6214
+ $((e) => {
6215
+ this.context.update({
6216
+ hasVerticalWriting: e.isUsingVerticalWriting()
6217
+ });
6253
6218
  }),
6254
- j()
6255
- ), P(this.layout$).pipe($(this.destroy$)).subscribe();
6219
+ T(this.destroy$)
6220
+ ).subscribe();
6256
6221
  }
6257
6222
  layout() {
6258
- this.layoutSubject.next(void 0);
6223
+ this.externalLayoutTrigger.next(void 0);
6259
6224
  }
6260
6225
  getSpineItemSpineLayoutInfo(e) {
6261
6226
  const t = this.spineItemsManager.getSpineItemIndex(e) ?? 0;
6262
- return this.spineItemsRelativeLayouts[t] || new He({
6227
+ return this.spineItemsRelativeLayouts[t] || new Oe({
6263
6228
  left: 0,
6264
6229
  right: 0,
6265
6230
  top: 0,
@@ -6274,15 +6239,54 @@ class Rs extends G {
6274
6239
  return this.spineItemsManager.items.reduce((e, t) => e + t.numberOfPages, 0);
6275
6240
  }
6276
6241
  destroy() {
6277
- super.destroy(), this.layoutSubject.complete();
6242
+ super.destroy(), this.externalLayoutTrigger.complete();
6243
+ }
6244
+ getSpreadPosition(e, t) {
6245
+ return this.settings.values.computedSpreadMode ? e ? t ? "right" : "left" : t ? "left" : "right" : "none";
6246
+ }
6247
+ getStartEdges(e, t, i, o, s) {
6248
+ return e ? {
6249
+ edgeX: t ? 0 : i,
6250
+ edgeY: t ? o : o - s
6251
+ } : {
6252
+ edgeX: i,
6253
+ edgeY: 0
6254
+ };
6255
+ }
6256
+ createSpineItemLayout(e, t, i, o, s, r, a) {
6257
+ if (e) {
6258
+ const u = s + i, l = r + o;
6259
+ return new Oe({
6260
+ left: i,
6261
+ right: u,
6262
+ top: o,
6263
+ bottom: l,
6264
+ height: r,
6265
+ width: s,
6266
+ x: i,
6267
+ y: o
6268
+ });
6269
+ }
6270
+ const c = t ? a - i - s : i;
6271
+ return new Oe({
6272
+ right: t ? a - i : i + s,
6273
+ left: c,
6274
+ x: c,
6275
+ top: o,
6276
+ bottom: r,
6277
+ height: r,
6278
+ width: s,
6279
+ y: o
6280
+ });
6278
6281
  }
6279
6282
  }
6280
6283
  class As extends G {
6281
6284
  constructor(e, t, i, o, s, r, a) {
6282
- super(), this.context = e, this.pagination = t, this.spineItemsManager = i, this.spineItemLocator = o, this.settings = s, this.hookManager = r, this.viewport = a, this.elementSubject = new Y(
6285
+ super(), this.context = e, this.pagination = t, this.spineItemsManager = i, this.spineItemLocator = o, this.settings = s, this.hookManager = r, this.viewport = a, this.elementSubject = new q(
6283
6286
  void 0
6284
- ), this.element$ = this.elementSubject.asObservable(), this.spineLayout = new Rs(
6287
+ ), this.element$ = this.elementSubject.asObservable(), this.spineItemsObserver = new Es(i), this.spineLayout = new Ds(
6285
6288
  i,
6289
+ this.spineItemsObserver,
6286
6290
  e,
6287
6291
  s,
6288
6292
  a
@@ -6299,9 +6303,6 @@ class As extends G {
6299
6303
  this.locator,
6300
6304
  s,
6301
6305
  this.spineLayout
6302
- ), this.spineItemsObserver = new Es(
6303
- i,
6304
- this.locator
6305
6306
  ), this.pages = new Cs(
6306
6307
  this.spineLayout,
6307
6308
  this.spineItemsManager,
@@ -6311,23 +6312,23 @@ class As extends G {
6311
6312
  this.viewport
6312
6313
  );
6313
6314
  const c = e.watch("rootElement").pipe(
6314
- ae(Z),
6315
- N((l) => {
6315
+ de(Z),
6316
+ V((l) => {
6316
6317
  const d = l.ownerDocument.createElement("div");
6317
6318
  d.style.cssText = `
6318
6319
  height: 100%;
6319
6320
  position: relative;
6320
6321
  `, d.className = `${W}-spine`, this.elementSubject.next(d);
6321
6322
  })
6322
- ), u = O([
6323
+ ), u = j([
6323
6324
  this.context.manifest$,
6324
6325
  this.element$
6325
6326
  ]).pipe(
6326
- N(([l, d]) => {
6327
+ V(([l, d]) => {
6327
6328
  if (!d) return;
6328
6329
  this.spineItemsManager.destroyItems();
6329
6330
  const p = l.spineItems.map(
6330
- (g, h) => new Qt(
6331
+ (g, h) => new Zt(
6331
6332
  g,
6332
6333
  d,
6333
6334
  this.context,
@@ -6358,9 +6359,9 @@ class As extends G {
6358
6359
  super.destroy(), this.pages.destroy(), this.spineItemsLoader.destroy(), this.elementSubject.getValue()?.remove(), this.elementSubject.complete();
6359
6360
  }
6360
6361
  }
6361
- class Ns extends G {
6362
+ class Rs extends G {
6362
6363
  constructor(e, t) {
6363
- super(), this.context = e, this.settings = t, this.orderedSpineItemsSubject = new Y([]), this.items$ = this.orderedSpineItemsSubject.asObservable();
6364
+ super(), this.context = e, this.settings = t, this.orderedSpineItemsSubject = new q([]), this.items$ = this.orderedSpineItemsSubject.asObservable();
6364
6365
  }
6365
6366
  get(e) {
6366
6367
  return typeof e == "number" ? this.orderedSpineItemsSubject.value[e] : typeof e == "string" ? this.orderedSpineItemsSubject.value.find(
@@ -6372,7 +6373,7 @@ class Ns extends G {
6372
6373
  return i > o ? "after" : i === o ? "same" : "before";
6373
6374
  }
6374
6375
  getSpineItemIndex(e) {
6375
- const t = e instanceof Qt ? e : this.get(e);
6376
+ const t = e instanceof Zt ? e : this.get(e);
6376
6377
  if (!t) return;
6377
6378
  const i = this.orderedSpineItemsSubject.value.indexOf(t);
6378
6379
  return i < 0 ? void 0 : i;
@@ -6401,7 +6402,7 @@ class Ns extends G {
6401
6402
  });
6402
6403
  }
6403
6404
  }
6404
- class Os extends Q {
6405
+ class Ns extends Q {
6405
6406
  constructor(e, t) {
6406
6407
  const i = document.createElement("div");
6407
6408
  i.setAttribute(`data-${oi}`, ""), super({
@@ -6414,17 +6415,17 @@ class Os extends Q {
6414
6415
  height: 1
6415
6416
  }), this.context = e, this.settingsManager = t;
6416
6417
  const o = this.settingsManager.watch(["computedSpreadMode"]).pipe(
6417
- x(() => {
6418
+ $(() => {
6418
6419
  this.mergeCompare({
6419
6420
  pageSize: this.calculatePageSize(this.value)
6420
6421
  });
6421
6422
  })
6422
6423
  ), s = this.context.watch("rootElement").pipe(
6423
- x(() => {
6424
+ $(() => {
6424
6425
  this.layout();
6425
6426
  })
6426
6427
  );
6427
- P(o, s).pipe($(this.destroy$)).subscribe();
6428
+ P(o, s).pipe(T(this.destroy$)).subscribe();
6428
6429
  }
6429
6430
  calculatePageSize(e) {
6430
6431
  const { computedSpreadMode: t } = this.settingsManager.values;
@@ -6478,8 +6479,8 @@ class Os extends Q {
6478
6479
  });
6479
6480
  }
6480
6481
  }
6481
- const $t = `${Ut}-core`, Vs = (n) => {
6482
- const e = crypto.randomUUID(), t = new R(), i = new R(), o = new Ro(), s = new Eo(), r = new fs(n, s), a = new Do(s, r), c = new Ns(s, r), u = new Os(s, r), l = Jt({
6482
+ const xt = `${Vt}-core`, Os = (n) => {
6483
+ const e = crypto.randomUUID(), t = new R(), i = new R(), o = new Ao(), s = new Eo(), r = new fs(n, s), a = new Do(s, r), c = new Rs(s, r), u = new Ns(s, r), l = qt({
6483
6484
  context: s,
6484
6485
  settings: r,
6485
6486
  viewport: u
@@ -6510,28 +6511,28 @@ const $t = `${Ut}-core`, Vs = (n) => {
6510
6511
  ), d.subscribe(s.bridgeEvent.paginationSubject);
6511
6512
  const m = () => {
6512
6513
  t.next();
6513
- }, y = (T) => {
6514
- const { containerElement: E, manifest: H } = T;
6514
+ }, y = (x) => {
6515
+ const { containerElement: L, manifest: H } = x;
6515
6516
  if (s.manifest) {
6516
- D.warn("loading a new book is not supported yet");
6517
+ A.warn("loading a new book is not supported yet");
6517
6518
  return;
6518
6519
  }
6519
- D.log("load", { options: T });
6520
- const B = js(E, e);
6520
+ A.log("load", { options: x });
6521
+ const B = Vs(L, e);
6521
6522
  s.update({
6522
6523
  manifest: H,
6523
6524
  rootElement: B
6524
6525
  }), m();
6525
- }, f = r.watch(["computedSpreadMode"]).pipe(Ct(1), N(m)), I = t.pipe(
6526
- N(() => {
6527
- const T = s.value.rootElement;
6528
- T && (T.style.setProperty("overflow", "hidden"), u.layout(), p.layout());
6526
+ }, f = r.watch(["computedSpreadMode"]).pipe(Lt(1), V(m)), I = t.pipe(
6527
+ V(() => {
6528
+ const x = s.value.rootElement;
6529
+ x && (x.style.setProperty("overflow", "hidden"), u.layout(), p.layout());
6529
6530
  }),
6530
6531
  K(i)
6531
6532
  ), b = P(I, f).subscribe();
6532
- Ce(document, $t, Ao);
6533
+ Ce(document, xt, Ro);
6533
6534
  const F = () => {
6534
- Ee(document, $t), b.unsubscribe(), c.destroy(), h.destroy(), r.destroy(), d.destroy(), s.destroy(), g.destroy(), p.destroy(), a.destroy(), i.next(), i.complete(), u.destroy();
6535
+ Ee(document, xt), b.unsubscribe(), c.destroy(), h.destroy(), r.destroy(), d.destroy(), s.destroy(), g.destroy(), p.destroy(), a.destroy(), i.next(), i.complete(), u.destroy();
6535
6536
  };
6536
6537
  return {
6537
6538
  id: e,
@@ -6541,11 +6542,11 @@ const $t = `${Ut}-core`, Vs = (n) => {
6541
6542
  cfi: {
6542
6543
  generateCfiFromRange: io,
6543
6544
  parseCfi: it,
6544
- generateCfiForSpineItemPage: (T) => Be({
6545
- ...T,
6545
+ generateCfiForSpineItemPage: (x) => He({
6546
+ ...x,
6546
6547
  spine: p
6547
6548
  }),
6548
- resolveCfi: (T) => Xt({ ...T, spineItemsManager: c })
6549
+ resolveCfi: (x) => _t({ ...x, spineItemsManager: c })
6549
6550
  },
6550
6551
  navigation: g,
6551
6552
  spineItemsObserver: p.spineItemsObserver,
@@ -6562,7 +6563,7 @@ const $t = `${Ut}-core`, Vs = (n) => {
6562
6563
  }
6563
6564
  },
6564
6565
  settings: r,
6565
- renderHeadless: (T) => c.get(T)?.renderer.renderHeadless() ?? v(void 0),
6566
+ renderHeadless: (x) => c.get(x)?.renderer.renderHeadless() ?? v(void 0),
6566
6567
  viewport: u,
6567
6568
  viewportState$: s.bridgeEvent.viewportState$,
6568
6569
  viewportFree$: s.bridgeEvent.viewportFree$,
@@ -6573,18 +6574,18 @@ const $t = `${Ut}-core`, Vs = (n) => {
6573
6574
  * It can typically be used to hide a loading indicator.
6574
6575
  */
6575
6576
  state$: s.manifest$.pipe(
6576
- ie((T) => T ? "ready" : "idle")
6577
+ ie((x) => x ? "ready" : "idle")
6577
6578
  ),
6578
6579
  features: a,
6579
6580
  $: {
6580
6581
  destroy$: i
6581
6582
  }
6582
6583
  };
6583
- }, js = (n, e) => (n.style.cssText = `
6584
+ }, Vs = (n, e) => (n.style.cssText = `
6584
6585
  ${n.style.cssText}
6585
6586
  background-color: white;
6586
6587
  position: relative;
6587
- `, n.classList.add(`${W}-reader`), n.setAttribute(ii, e), n.setAttribute("data-prose-reader-container", e), n), Ks = (
6588
+ `, n.classList.add(`${W}-reader`), n.setAttribute(ii, e), n.setAttribute("data-prose-reader-container", e), n), Js = (
6588
6589
  //__
6589
6590
  yo(
6590
6591
  Gn(
@@ -6596,14 +6597,14 @@ const $t = `${Ut}-core`, Vs = (n) => {
6596
6597
  Mo(
6597
6598
  Xi(
6598
6599
  yi(
6599
- Ai(
6600
+ Ri(
6600
6601
  zn(
6601
6602
  Bn(
6602
6603
  co(
6603
6604
  Di(
6604
6605
  So(
6605
6606
  // __
6606
- Vs
6607
+ Os
6607
6608
  )
6608
6609
  )
6609
6610
  )
@@ -6620,26 +6621,26 @@ const $t = `${Ut}-core`, Vs = (n) => {
6620
6621
  )
6621
6622
  )
6622
6623
  )
6623
- ), Qs = (n) => (e) => n(e);
6624
+ ), Ks = (n) => (e) => n(e);
6624
6625
  export {
6625
- Wt as AbstractSpinePosition,
6626
+ kt as AbstractSpinePosition,
6626
6627
  Eo as Context,
6627
6628
  jo as ControlledNavigationController,
6628
6629
  G as DestroyableClass,
6629
- Se as DocumentRenderer,
6630
+ ye as DocumentRenderer,
6630
6631
  Do as Features,
6631
6632
  ii as HTML_ATTRIBUTE_DATA_READER_ID,
6632
6633
  W as HTML_PREFIX,
6633
6634
  si as HTML_PREFIX_SCROLL_NAVIGATOR,
6634
6635
  oi as HTML_PREFIX_VIEWPORT,
6635
- Ut as HTML_STYLE_PREFIX,
6636
- Ro as HookManager,
6636
+ Vt as HTML_STYLE_PREFIX,
6637
+ Ao as HookManager,
6637
6638
  ni as ITEM_EXTENSION_VALID_FOR_FRAME_SRC,
6638
6639
  Ko as InternalNavigator,
6639
6640
  nt as LayoutEntry,
6640
- Gt as Locker,
6641
- Gs as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE,
6642
- Ys as PROSE_READER_NAMESPACE,
6641
+ Xt as Locker,
6642
+ qs as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE,
6643
+ Xs as PROSE_READER_NAMESPACE,
6643
6644
  Cs as Pages,
6644
6645
  ps as Pagination,
6645
6646
  gs as PaginationController,
@@ -6647,56 +6648,56 @@ export {
6647
6648
  tt as ResourceHandler,
6648
6649
  ao as ResourcesLocator,
6649
6650
  $o as ScrollNavigationController,
6650
- ft as ScrollPosition,
6651
+ mt as ScrollPosition,
6651
6652
  ms as SettingsManager,
6652
6653
  As as Spine,
6653
- Qt as SpineItem,
6654
+ Zt as SpineItem,
6654
6655
  Si as SpineItemPageLayout,
6655
6656
  Ii as SpineItemPageSpineLayout,
6656
- C as SpineItemPosition,
6657
- He as SpineItemSpineLayout,
6658
- Ns as SpineItemsManager,
6657
+ E as SpineItemPosition,
6658
+ Oe as SpineItemSpineLayout,
6659
+ Rs as SpineItemsManager,
6659
6660
  Es as SpineItemsObserver,
6660
- L as SpinePosition,
6661
+ M as SpinePosition,
6661
6662
  xo as UnboundScrollPosition,
6662
6663
  Ne as UnboundSpineItemPagePosition,
6663
- ue as UnboundSpinePosition,
6664
- qs as VIEWPORT_ADJUSTMENT_THROTTLE,
6665
- Os as Viewport,
6664
+ ae as UnboundSpinePosition,
6665
+ Ys as VIEWPORT_ADJUSTMENT_THROTTLE,
6666
+ Ns as Viewport,
6666
6667
  ro as consolidate,
6667
- Ks as createReader,
6668
- ct as deferIdle,
6668
+ Js as createReader,
6669
+ at as deferIdle,
6669
6670
  Xn as deferNextResult,
6670
- Be as generateCfiForSpineItemPage,
6671
+ He as generateCfiForSpineItemPage,
6671
6672
  io as generateCfiFromRange,
6672
- me as generateRootCfi,
6673
- at as getAttributeValueFromString,
6674
- Bs as getBase64FromBlob,
6675
- Ke as getFrameViewportInfo,
6676
- Js as getItemAnchor,
6673
+ he as generateRootCfi,
6674
+ rt as getAttributeValueFromString,
6675
+ Hs as getBase64FromBlob,
6676
+ Je as getFrameViewportInfo,
6677
+ Zs as getItemAnchor,
6677
6678
  yi as htmlEnhancer,
6678
- Vt as idle,
6679
+ et as idle,
6679
6680
  Vn as injectCSSToFrame,
6680
6681
  Z as isDefined,
6681
- Nt as isHtmlElement,
6682
+ At as isHtmlElement,
6682
6683
  Nn as isHtmlTagElement,
6683
- Xe as isRootCfi,
6684
- nr as isShallowEqual,
6684
+ Be as isRootCfi,
6685
+ tr as isShallowEqual,
6685
6686
  Di as layoutEnhancer,
6686
- Ot as mapKeysTo,
6687
- Hs as observeIntersection,
6688
- ut as observeMutation,
6689
- et as observeResize,
6687
+ Rt as mapKeysTo,
6688
+ _s as observeIntersection,
6689
+ ct as observeMutation,
6690
+ Qe as observeResize,
6690
6691
  co as paginationEnhancer,
6691
6692
  it as parseCfi,
6692
- _s as removeCSS,
6693
- Xt as resolveCfi,
6694
- Qs as rootEnhancer,
6693
+ Ws as removeCSS,
6694
+ _t as resolveCfi,
6695
+ Ks as rootEnhancer,
6695
6696
  Ms as spinePositionToSpineItemSpineLayout,
6696
6697
  oe as upsertCSSToFrame,
6697
6698
  jn as waitForFrameLoad,
6698
6699
  kn as waitForFrameReady,
6699
6700
  De as waitForSwitch,
6700
- Qe as watchKeys
6701
+ Ke as watchKeys
6701
6702
  };
6702
6703
  //# sourceMappingURL=index.js.map