@prose-reader/core 1.59.0 → 1.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/createReaderWithEnhancer.d.ts +4 -45
  2. package/dist/enhancers/fonts/SettingsManager.d.ts +10 -0
  3. package/dist/enhancers/fonts/fonts.d.ts +7 -0
  4. package/dist/enhancers/fonts/types.d.ts +9 -0
  5. package/dist/enhancers/layoutEnhancer/SettingsManager.d.ts +10 -0
  6. package/dist/enhancers/layoutEnhancer/layoutEnhancer.d.ts +5 -8
  7. package/dist/enhancers/layoutEnhancer/types.d.ts +5 -7
  8. package/dist/enhancers/pagination/spine.d.ts +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1220 -507
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.umd.cjs +1157 -444
  13. package/dist/index.umd.cjs.map +1 -1
  14. package/dist/pagination/pagination.d.ts +1 -1
  15. package/dist/reader.d.ts +2 -2
  16. package/dist/settings/ReaderSettingsManager.d.ts +20 -0
  17. package/dist/settings/SettingsInterface.d.ts +13 -0
  18. package/dist/settings/SettingsManager.d.ts +17 -11
  19. package/dist/settings/SettingsManagerOverload.d.ts +23 -0
  20. package/dist/settings/types.d.ts +6 -5
  21. package/dist/spine/cfiLocator.d.ts +3 -3
  22. package/dist/spine/createSpine.d.ts +2 -2
  23. package/dist/spine/locationResolver.d.ts +6 -6
  24. package/dist/spine/navigationResolver.d.ts +2 -2
  25. package/dist/spineItem/commonSpineItem.d.ts +3 -3
  26. package/dist/spineItem/createSpineItem.d.ts +3 -3
  27. package/dist/spineItem/frameItem/frameItem.d.ts +3 -4
  28. package/dist/spineItem/frameItem/loader.d.ts +3 -4
  29. package/dist/spineItem/navigationResolver.d.ts +3 -3
  30. package/dist/spineItem/prePaginatedSpineItem.d.ts +3 -3
  31. package/dist/spineItem/reflowableSpineItem.d.ts +3 -3
  32. package/dist/spineItemManager.d.ts +6 -6
  33. package/dist/types/reader.d.ts +4 -4
  34. package/dist/utils/objects.d.ts +1 -0
  35. package/dist/viewportNavigator/manualViewportNavigator.d.ts +2 -2
  36. package/dist/viewportNavigator/panViewportNavigator.d.ts +2 -2
  37. package/dist/viewportNavigator/scrollViewportNavigator.d.ts +2 -2
  38. package/dist/viewportNavigator/viewportNavigator.d.ts +4 -4
  39. package/package.json +3 -3
  40. package/dist/enhancers/fonts.d.ts +0 -19
  41. package/dist/settings/defaultSettings.d.ts +0 -3
  42. package/dist/settings/getComputedSettings.d.ts +0 -4
  43. package/dist/utils/compose.d.ts +0 -8
@@ -73,21 +73,109 @@
73
73
  reader.readAsDataURL(data);
74
74
  });
75
75
  };
76
+ function shallowMergeIfDefined(obj1, obj2) {
77
+ const result = { ...obj1 };
78
+ for (const key in obj2) {
79
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
80
+ const value = obj2[key];
81
+ if (value !== void 0 || !(key in obj1)) {
82
+ result[key] = value;
83
+ }
84
+ }
85
+ }
86
+ return result;
87
+ }
88
+ class SettingsManagerOverload {
89
+ constructor(initialSettings, settingsManager) {
90
+ this.settingsManager = settingsManager;
91
+ const inputSettings = shallowMergeIfDefined(
92
+ this.getDefaultSettings(),
93
+ initialSettings
94
+ );
95
+ this.outputSettings = this.computeOutputSettings(inputSettings);
96
+ this.inputSettings = shallowMergeIfDefined(
97
+ this.getDefaultSettings(),
98
+ initialSettings
99
+ );
100
+ this.outputSettingsUpdateSubject = new rxjs.Subject();
101
+ this.settings$ = rxjs.combineLatest([
102
+ this.settingsManager.settings$,
103
+ this.outputSettingsUpdateSubject.pipe(operators.startWith(this.outputSettings))
104
+ ]).pipe(
105
+ operators.map(([parentSettings, settings]) => ({ ...parentSettings, ...settings })),
106
+ operators.shareReplay(1)
107
+ );
108
+ this.settings$.subscribe();
109
+ }
110
+ _prepareUpdate(settings) {
111
+ const parentInputSettings = this.getCleanedParentInputSettings(settings);
112
+ const parentManagerPreparedUpdate = this.settingsManager._prepareUpdate(parentInputSettings);
113
+ const inputSettings = shallowMergeIfDefined(this.inputSettings, settings);
114
+ const outputSettings = this.computeOutputSettings(inputSettings);
115
+ const hasChanged = this.hasSettingsChanged(outputSettings);
116
+ return {
117
+ hasChanged: hasChanged || parentManagerPreparedUpdate.hasChanged,
118
+ commit: () => {
119
+ this.inputSettings = inputSettings;
120
+ this.outputSettings = outputSettings;
121
+ if (!parentManagerPreparedUpdate.hasChanged && hasChanged) {
122
+ this.outputSettingsUpdateSubject.next(outputSettings);
123
+ }
124
+ const parentOutputSettings = parentManagerPreparedUpdate.commit();
125
+ return {
126
+ ...parentOutputSettings,
127
+ ...outputSettings
128
+ };
129
+ }
130
+ };
131
+ }
132
+ update(settings) {
133
+ const { commit } = this._prepareUpdate(settings);
134
+ commit();
135
+ }
136
+ get settings() {
137
+ return {
138
+ ...this.settingsManager.settings,
139
+ ...this.outputSettings
140
+ };
141
+ }
142
+ destroy() {
143
+ this.outputSettingsUpdateSubject.complete();
144
+ }
145
+ }
146
+ let SettingsManager$2 = class SettingsManager extends SettingsManagerOverload {
147
+ computeOutputSettings(settings) {
148
+ return settings;
149
+ }
150
+ hasSettingsChanged(newOutputSettings) {
151
+ return !isShallowEqual(this.outputSettings, newOutputSettings);
152
+ }
153
+ getCleanedParentInputSettings(settings) {
154
+ const { fontJustification, fontScale, fontWeight, lineHeight, ...rest } = settings;
155
+ return rest;
156
+ }
157
+ getDefaultSettings() {
158
+ return {
159
+ fontScale: 1,
160
+ fontWeight: "publisher",
161
+ lineHeight: "publisher",
162
+ fontJustification: "publisher"
163
+ };
164
+ }
165
+ };
76
166
  const fontsEnhancer = (next) => (options) => {
77
- const {
78
- fontScale = 1,
79
- lineHeight = `publisher`,
80
- fontWeight = `publisher`,
81
- fontJustification = `publisher`
82
- } = options;
167
+ const { fontScale, lineHeight, fontWeight, fontJustification } = options;
83
168
  const changes$ = new rxjs.Subject();
84
- const settings$ = new rxjs.BehaviorSubject({
85
- fontScale,
86
- lineHeight,
87
- fontWeight,
88
- fontJustification
89
- });
90
169
  const reader = next(options);
170
+ const settingsManager = new SettingsManager$2(
171
+ {
172
+ fontScale,
173
+ lineHeight,
174
+ fontWeight,
175
+ fontJustification
176
+ },
177
+ reader.settings
178
+ );
91
179
  const getStyle = () => `
92
180
  ${/*
93
181
  Ideally, we would like to use !important but it could break publisher specific
@@ -99,10 +187,10 @@
99
187
  */
100
188
  ``}
101
189
  body {
102
- ${settings$.value.fontScale !== 1 ? `font-size: ${settings$.value.fontScale}em !important;` : ``}
103
- ${settings$.value.lineHeight !== `publisher` ? `line-height: ${settings$.value.lineHeight} !important;` : ``}
104
- ${settings$.value.fontWeight !== `publisher` ? `font-weight: ${settings$.value.fontWeight} !important;` : ``}
105
- ${settings$.value.fontJustification !== `publisher` ? `text-align: ${settings$.value.fontJustification} !important;` : ``}
190
+ ${settingsManager.settings.fontScale !== 1 ? `font-size: ${settingsManager.settings.fontScale}em !important;` : ``}
191
+ ${settingsManager.settings.lineHeight !== `publisher` ? `line-height: ${settingsManager.settings.lineHeight} !important;` : ``}
192
+ ${settingsManager.settings.fontWeight !== `publisher` ? `font-weight: ${settingsManager.settings.fontWeight} !important;` : ``}
193
+ ${settingsManager.settings.fontJustification !== `publisher` ? `text-align: ${settingsManager.settings.fontJustification} !important;` : ``}
106
194
  }
107
195
  `;
108
196
  const applyChangeToSpineItem = (requireLayout) => {
@@ -132,42 +220,19 @@
132
220
  return false;
133
221
  })
134
222
  );
135
- const newSettings$ = changes$.pipe(
136
- operators.withLatestFrom(settings$),
137
- rxjs.map(([changes, settings]) => ({
138
- fontJustification: changes.fontJustification ?? settings.fontJustification,
139
- fontWeight: changes.fontWeight ?? settings.fontWeight,
140
- lineHeight: changes.lineHeight ?? settings.lineHeight,
141
- fontScale: Math.max(0.01, changes.fontScale ?? settings.fontScale)
142
- })),
143
- operators.distinctUntilChanged(isShallowEqual),
144
- operators.shareReplay(1)
145
- );
146
- newSettings$.subscribe(settings$);
147
- settings$.pipe(shouldRequireLayout, operators.tap(applyChangeToSpineItem), rxjs.takeUntil(reader.$.destroy$)).subscribe();
148
- const settingsMerge$ = rxjs.combineLatest([reader.settings.settings$, settings$]).pipe(
149
- rxjs.map(([innerSettings, settings]) => ({
150
- ...innerSettings,
151
- ...settings
152
- }))
153
- );
154
- const setSettings = (settings) => {
155
- const { fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2, ...passthroughSettings } = settings;
156
- changes$.next({ fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2 });
157
- reader.settings.setSettings(passthroughSettings);
158
- };
223
+ settingsManager.settings$.pipe(
224
+ shouldRequireLayout,
225
+ operators.tap(applyChangeToSpineItem),
226
+ rxjs.takeUntil(reader.$.destroy$)
227
+ ).subscribe();
159
228
  return {
160
229
  ...reader,
161
230
  destroy: () => {
162
231
  changes$.complete();
163
- settings$.complete();
232
+ settingsManager.destroy();
164
233
  reader.destroy();
165
234
  },
166
- settings: {
167
- ...reader.settings,
168
- setSettings,
169
- settings$: settingsMerge$
170
- }
235
+ settings: settingsManager
171
236
  };
172
237
  };
173
238
  const hotkeysEnhancer = (next) => (options) => {
@@ -200,7 +265,9 @@
200
265
  (spineItems) => rxjs.merge(
201
266
  ...spineItems.map(
202
267
  (item) => item.$.loaded$.pipe(
203
- rxjs.switchMap((iframe) => (iframe == null ? void 0 : iframe.contentDocument) ? navigateOnKey(iframe.contentDocument) : rxjs.EMPTY)
268
+ rxjs.switchMap(
269
+ (iframe) => (iframe == null ? void 0 : iframe.contentDocument) ? navigateOnKey(iframe.contentDocument) : rxjs.EMPTY
270
+ )
204
271
  )
205
272
  )
206
273
  )
@@ -234,14 +301,24 @@
234
301
  );
235
302
  const createResetLock$ = (source) => rxjs.scheduled(source, rxjs.animationFrameScheduler).pipe(
236
303
  operators.tap(() => {
237
- iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(`visibility`, `hidden`);
304
+ iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(
305
+ `visibility`,
306
+ `hidden`
307
+ );
238
308
  })
239
309
  );
240
- const viewportFree$ = reader.viewportNavigator.$.state$.pipe(operators.filter((data) => data === `free`));
241
- const viewportBusy$ = reader.viewportNavigator.$.state$.pipe(operators.filter((data) => data === `busy`));
310
+ const viewportFree$ = reader.viewportNavigator.$.state$.pipe(
311
+ operators.filter((data) => data === `free`)
312
+ );
313
+ const viewportBusy$ = reader.viewportNavigator.$.state$.pipe(
314
+ operators.filter((data) => data === `busy`)
315
+ );
242
316
  const lockAfterViewportBusy$ = viewportBusy$.pipe(
243
317
  operators.tap(() => {
244
- iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(`visibility`, `visible`);
318
+ iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(
319
+ `visibility`,
320
+ `visible`
321
+ );
245
322
  })
246
323
  );
247
324
  const resetLockViewportFree$ = createResetLock$(viewportFree$).pipe(operators.take(1));
@@ -274,33 +351,70 @@
274
351
  });
275
352
  };
276
353
  const fixReflowable = (reader) => {
277
- reader.hookManager.register(`item.onAfterLayout`, ({ item, blankPagePosition, minimumWidth }) => {
278
- var _a;
279
- const spineItem = reader.spineItemManager.get(item.id);
280
- if (!((spineItem == null ? void 0 : spineItem.item.renditionLayout) === `reflowable`)) return;
281
- const { viewportDimensions } = (spineItem == null ? void 0 : spineItem.getViewPortInformation()) ?? {};
282
- const { width: pageWidth } = reader.context.getPageSize();
283
- const frameElement = (_a = spineItem == null ? void 0 : spineItem.spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.frame;
284
- if (viewportDimensions) {
285
- const spineManagerWantAFullWidthItem = pageWidth < minimumWidth;
286
- const noBlankPageAsked = blankPagePosition === `none`;
287
- if (noBlankPageAsked && spineManagerWantAFullWidthItem) {
288
- frameElement == null ? void 0 : frameElement.style.setProperty(`left`, reader.context.isRTL() ? `75%` : `25%`);
354
+ reader.hookManager.register(
355
+ `item.onAfterLayout`,
356
+ ({ item, blankPagePosition, minimumWidth }) => {
357
+ var _a;
358
+ const spineItem = reader.spineItemManager.get(item.id);
359
+ if (!((spineItem == null ? void 0 : spineItem.item.renditionLayout) === `reflowable`)) return;
360
+ const { viewportDimensions } = (spineItem == null ? void 0 : spineItem.getViewPortInformation()) ?? {};
361
+ const { width: pageWidth } = reader.context.getPageSize();
362
+ const frameElement = (_a = spineItem == null ? void 0 : spineItem.spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.frame;
363
+ if (viewportDimensions) {
364
+ const spineManagerWantAFullWidthItem = pageWidth < minimumWidth;
365
+ const noBlankPageAsked = blankPagePosition === `none`;
366
+ if (noBlankPageAsked && spineManagerWantAFullWidthItem) {
367
+ frameElement == null ? void 0 : frameElement.style.setProperty(
368
+ `left`,
369
+ reader.context.isRTL() ? `75%` : `25%`
370
+ );
371
+ }
289
372
  }
290
373
  }
291
- });
374
+ );
292
375
  };
293
376
  function isDefined(arg) {
294
377
  return arg !== null && arg !== void 0;
295
378
  }
379
+ let SettingsManager$1 = class SettingsManager extends SettingsManagerOverload {
380
+ computeOutputSettings(inputSettings) {
381
+ return inputSettings;
382
+ }
383
+ hasSettingsChanged(newOutputSettings) {
384
+ return !isShallowEqual(this.outputSettings, newOutputSettings);
385
+ }
386
+ getCleanedParentInputSettings(settings) {
387
+ const {
388
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
389
+ layoutAutoResize,
390
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
391
+ pageHorizontalMargin,
392
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
393
+ pageVerticalMargin,
394
+ ...rest
395
+ } = settings;
396
+ return rest;
397
+ }
398
+ getDefaultSettings() {
399
+ return {
400
+ layoutAutoResize: "container",
401
+ pageHorizontalMargin: 24,
402
+ pageVerticalMargin: 24
403
+ };
404
+ }
405
+ };
296
406
  const SHOULD_NOT_LAYOUT = false;
297
407
  const layoutEnhancer = (next) => (options) => {
298
- const { pageHorizontalMargin = 24, pageVerticalMargin = 24 } = options;
408
+ const { pageHorizontalMargin, pageVerticalMargin, layoutAutoResize } = options;
299
409
  const reader = next(options);
300
- const settingsSubject$ = new rxjs.BehaviorSubject({
301
- pageHorizontalMargin,
302
- pageVerticalMargin
303
- });
410
+ const settingsManager = new SettingsManager$1(
411
+ {
412
+ pageHorizontalMargin,
413
+ pageVerticalMargin,
414
+ layoutAutoResize
415
+ },
416
+ reader.settings
417
+ );
304
418
  reader.hookManager.register(`onViewportOffsetAdjust`, () => {
305
419
  let hasRedrawn = false;
306
420
  reader.spine.manipulateSpineItems(({ frame }) => {
@@ -311,24 +425,26 @@
311
425
  return SHOULD_NOT_LAYOUT;
312
426
  });
313
427
  });
314
- reader.hookManager.register(`item.onLayoutBeforeMeasurement`, ({ frame, minimumWidth, item, isImageType }) => {
315
- var _a, _b;
316
- const { pageHorizontalMargin: pageHorizontalMargin2 = 0, pageVerticalMargin: pageVerticalMargin2 = 0 } = settingsSubject$.value;
317
- const pageSize = reader.context.getPageSize();
318
- if (item.renditionLayout === `reflowable` && frame.getIsReady() && !isImageType() && !frame.getViewportDimensions()) {
319
- let columnWidth = pageSize.width - pageHorizontalMargin2 * 2;
320
- const columnHeight = pageSize.height - pageVerticalMargin2 * 2;
321
- let width = pageSize.width - pageHorizontalMargin2 * 2;
322
- let columnGap = pageHorizontalMargin2 * 2;
323
- if (frame.isUsingVerticalWriting()) {
324
- width = minimumWidth - pageHorizontalMargin2 * 2;
325
- columnWidth = columnHeight;
326
- columnGap = pageVerticalMargin2 * 2;
327
- }
328
- (_a = frame.getManipulableFrame()) == null ? void 0 : _a.removeStyle(`prose-layout-enhancer-css`);
329
- (_b = frame.getManipulableFrame()) == null ? void 0 : _b.addStyle(
330
- `prose-layout-enhancer-css`,
331
- `
428
+ reader.hookManager.register(
429
+ `item.onLayoutBeforeMeasurement`,
430
+ ({ frame, minimumWidth, item, isImageType }) => {
431
+ var _a, _b;
432
+ const { pageHorizontalMargin: pageHorizontalMargin2 = 0, pageVerticalMargin: pageVerticalMargin2 = 0 } = settingsManager.settings;
433
+ const pageSize = reader.context.getPageSize();
434
+ if (item.renditionLayout === `reflowable` && frame.getIsReady() && !isImageType() && !frame.getViewportDimensions()) {
435
+ let columnWidth = pageSize.width - pageHorizontalMargin2 * 2;
436
+ const columnHeight = pageSize.height - pageVerticalMargin2 * 2;
437
+ let width = pageSize.width - pageHorizontalMargin2 * 2;
438
+ let columnGap = pageHorizontalMargin2 * 2;
439
+ if (frame.isUsingVerticalWriting()) {
440
+ width = minimumWidth - pageHorizontalMargin2 * 2;
441
+ columnWidth = columnHeight;
442
+ columnGap = pageVerticalMargin2 * 2;
443
+ }
444
+ (_a = frame.getManipulableFrame()) == null ? void 0 : _a.removeStyle(`prose-layout-enhancer-css`);
445
+ (_b = frame.getManipulableFrame()) == null ? void 0 : _b.addStyle(
446
+ `prose-layout-enhancer-css`,
447
+ `
332
448
  body {
333
449
  width: ${width}px !important;
334
450
  margin: ${pageVerticalMargin2}px ${pageHorizontalMargin2}px !important;
@@ -347,9 +463,10 @@
347
463
  max-width: ${columnWidth}px;
348
464
  }
349
465
  `
350
- );
466
+ );
467
+ }
351
468
  }
352
- });
469
+ );
353
470
  fixReflowable(reader);
354
471
  let observer;
355
472
  if (options.layoutAutoResize === `container`) {
@@ -367,7 +484,7 @@
367
484
  }
368
485
  const movingSafePan$ = createMovingSafePan$(reader);
369
486
  movingSafePan$.subscribe();
370
- settingsSubject$.pipe(
487
+ settingsManager.settings$.pipe(
371
488
  mapKeysTo([`pageHorizontalMargin`, `pageVerticalMargin`]),
372
489
  operators.distinctUntilChanged(isShallowEqual),
373
490
  operators.skip(1),
@@ -376,32 +493,14 @@
376
493
  }),
377
494
  operators.takeUntil(reader.$.destroy$)
378
495
  ).subscribe();
379
- const settings$ = rxjs.combineLatest([reader.settings.settings$, settingsSubject$.asObservable()]).pipe(
380
- operators.map(([innerSettings, settings]) => ({
381
- ...innerSettings,
382
- ...settings
383
- }))
384
- );
385
- const setSettings = ({ pageVerticalMargin: pageVerticalMargin2, pageHorizontalMargin: pageHorizontalMargin2, ...rest }) => {
386
- if (pageHorizontalMargin2 !== void 0 || pageVerticalMargin2 !== void 0) {
387
- settingsSubject$.next({
388
- pageHorizontalMargin: pageHorizontalMargin2 ?? settingsSubject$.value.pageHorizontalMargin,
389
- pageVerticalMargin: pageVerticalMargin2 ?? settingsSubject$.value.pageVerticalMargin
390
- });
391
- }
392
- reader.settings.setSettings(rest);
393
- };
394
496
  return {
395
497
  ...reader,
396
498
  destroy: () => {
499
+ settingsManager.destroy();
397
500
  reader.destroy();
398
501
  observer == null ? void 0 : observer.disconnect();
399
502
  },
400
- settings: {
401
- ...reader.settings,
402
- setSettings,
403
- settings$
404
- }
503
+ settings: settingsManager
405
504
  };
406
505
  };
407
506
  const ROOT_NAMESPACE = `@prose-reader/core`;
@@ -418,7 +517,10 @@
418
517
  return () => {
419
518
  tick++;
420
519
  const t1 = performance.now();
421
- Report.logMetric({ name: `${name} - tick ${tick}`, duration: t1 - t0 }, targetDuration);
520
+ Report.logMetric(
521
+ { name: `${name} - tick ${tick}`, duration: t1 - t0 },
522
+ targetDuration
523
+ );
422
524
  };
423
525
  };
424
526
  const createReport = (namespace) => ({
@@ -434,7 +536,8 @@
434
536
  warn: (...data) => {
435
537
  var _a;
436
538
  if ((_a = getWindow()) == null ? void 0 : _a.__PROSE_READER_DEBUG) {
437
- if (namespace) console.warn(wrap(ROOT_NAMESPACE), wrap(namespace), ...data);
539
+ if (namespace)
540
+ console.warn(wrap(ROOT_NAMESPACE), wrap(namespace), ...data);
438
541
  else console.warn(wrap(ROOT_NAMESPACE), ...data);
439
542
  }
440
543
  },
@@ -499,7 +602,9 @@
499
602
  if (!element.href) return false;
500
603
  const hrefUrl = new URL(element.href);
501
604
  const hrefWithoutAnchor = `${hrefUrl.origin}${hrefUrl.pathname}`;
502
- const hasExistingSpineItem = (_a = reader.context.manifest) == null ? void 0 : _a.spineItems.some((item) => item.href === hrefWithoutAnchor);
605
+ const hasExistingSpineItem = (_a = reader.context.manifest) == null ? void 0 : _a.spineItems.some(
606
+ (item) => item.href === hrefWithoutAnchor
607
+ );
503
608
  if (hasExistingSpineItem) {
504
609
  reader.viewportNavigator.goToUrl(hrefUrl);
505
610
  return true;
@@ -514,7 +619,11 @@
514
619
  Report.warn(`prevented click on`, element, e);
515
620
  e.preventDefault();
516
621
  const isNavigable = handleNavigationForClick(element);
517
- subject.next({ event: `linkClicked`, data: element, isNavigable });
622
+ subject.next({
623
+ event: `linkClicked`,
624
+ data: element,
625
+ isNavigable
626
+ });
518
627
  }
519
628
  })
520
629
  );
@@ -555,14 +664,16 @@
555
664
  goToNextSpineItem,
556
665
  goToPreviousSpineItem,
557
666
  goToLeftSpineItem: () => {
558
- if (reader.settings.settings.computedPageTurnDirection === "vertical") return;
667
+ if (reader.settings.settings.computedPageTurnDirection === "vertical")
668
+ return;
559
669
  if (reader.context.isRTL()) {
560
670
  return goToNextSpineItem();
561
671
  }
562
672
  return goToPreviousSpineItem();
563
673
  },
564
674
  goToRightSpineItem: () => {
565
- if (reader.settings.settings.computedPageTurnDirection === "vertical") return;
675
+ if (reader.settings.settings.computedPageTurnDirection === "vertical")
676
+ return;
566
677
  if (reader.context.isRTL()) {
567
678
  return goToPreviousSpineItem();
568
679
  }
@@ -600,17 +711,24 @@
600
711
  };
601
712
  };
602
713
  const buildChaptersInfo = (href, tocItem, manifest) => {
603
- const spineItemIndex = manifest.spineItems.findIndex((item) => item.href === href);
714
+ const spineItemIndex = manifest.spineItems.findIndex(
715
+ (item) => item.href === href
716
+ );
604
717
  return tocItem.reduce((acc, tocItem2) => {
605
718
  const indexOfHash = tocItem2.href.indexOf(`#`);
606
719
  const tocItemPathWithoutAnchor = indexOfHash > 0 ? tocItem2.href.substr(0, indexOfHash) : tocItem2.href;
607
- const tocItemHrefWithoutFilename = tocItemPathWithoutAnchor.substring(0, tocItemPathWithoutAnchor.lastIndexOf("/"));
720
+ const tocItemHrefWithoutFilename = tocItemPathWithoutAnchor.substring(
721
+ 0,
722
+ tocItemPathWithoutAnchor.lastIndexOf("/")
723
+ );
608
724
  const hrefWithoutFilename = href.substring(0, href.lastIndexOf("/"));
609
725
  const hrefIsChapterHref = href.endsWith(tocItemPathWithoutAnchor);
610
726
  const hrefIsWithinChapter = hrefWithoutFilename !== "" && hrefWithoutFilename.endsWith(tocItemHrefWithoutFilename);
611
727
  const isPossibleTocItemCandidate = hrefIsChapterHref || hrefIsWithinChapter;
612
728
  if (isPossibleTocItemCandidate) {
613
- const spineItemIndexOfPossibleCandidate = manifest.spineItems.findIndex((item) => item.href === tocItem2.href);
729
+ const spineItemIndexOfPossibleCandidate = manifest.spineItems.findIndex(
730
+ (item) => item.href === tocItem2.href
731
+ );
614
732
  const spineItemIsBeforeThisTocItem = spineItemIndex < spineItemIndexOfPossibleCandidate;
615
733
  if (spineItemIsBeforeThisTocItem) return acc;
616
734
  const info = {
@@ -655,7 +773,9 @@
655
773
  );
656
774
  };
657
775
  const NAMESPACE$6 = `pagination`;
658
- const createPagination = ({ context }) => {
776
+ const createPagination = ({
777
+ context
778
+ }) => {
659
779
  const paginationSubject$ = new rxjs.BehaviorSubject({
660
780
  beginPageIndexInSpineItem: void 0,
661
781
  beginNumberOfPagesInSpineItem: 0,
@@ -708,7 +828,9 @@
708
828
  const getPaginationInfo = () => paginationSubject$.value;
709
829
  const paginationInfo$ = paginationSubject$.pipe(
710
830
  rxjs.distinctUntilChanged(isShallowEqual),
711
- rxjs.filter(({ beginPageIndexInSpineItem }) => beginPageIndexInSpineItem !== void 0)
831
+ rxjs.filter(
832
+ ({ beginPageIndexInSpineItem }) => beginPageIndexInSpineItem !== void 0
833
+ )
712
834
  );
713
835
  const destroy = () => {
714
836
  paginationSubject$.complete();
@@ -732,10 +854,14 @@
732
854
  const getClosestValidOffsetFromApproximateOffsetInPages = (offset, pageWidth, itemWidth) => {
733
855
  const numberOfPages = calculateNumberOfPagesForItem(itemWidth, pageWidth);
734
856
  const offsetValues = [...Array(numberOfPages)].map((_, i) => i * pageWidth);
735
- if (offset >= numberOfPages * pageWidth) return offsetValues[offsetValues.length - 1] || 0;
857
+ if (offset >= numberOfPages * pageWidth)
858
+ return offsetValues[offsetValues.length - 1] || 0;
736
859
  return offsetValues.find((offsetRange) => offset < offsetRange + pageWidth) || 0;
737
860
  };
738
- const getSpineItemNumberOfPages = ({ spineItem, reader }) => {
861
+ const getSpineItemNumberOfPages = ({
862
+ spineItem,
863
+ reader
864
+ }) => {
739
865
  const writingMode = spineItem.spineItemFrame.getWritingMode();
740
866
  const { width, height } = spineItem.getElementDimensions();
741
867
  const settings = reader.settings.settings;
@@ -743,9 +869,15 @@
743
869
  return 1;
744
870
  }
745
871
  if (writingMode === `vertical-rl`) {
746
- return calculateNumberOfPagesForItem(height, reader.context.getPageSize().height);
872
+ return calculateNumberOfPagesForItem(
873
+ height,
874
+ reader.context.getPageSize().height
875
+ );
747
876
  }
748
- return calculateNumberOfPagesForItem(width, reader.context.getPageSize().width);
877
+ return calculateNumberOfPagesForItem(
878
+ width,
879
+ reader.context.getPageSize().width
880
+ );
749
881
  };
750
882
  const getNumberOfPagesForAllSpineItems = (reader) => reader.spineItemManager.getAll().map((item) => {
751
883
  return getSpineItemNumberOfPages({ spineItem: item, reader });
@@ -761,7 +893,10 @@
761
893
  /**
762
894
  * This may be not accurate for reflowable due to dynamic load / unload.
763
895
  */
764
- numberOfTotalPages: numberOfPagesPerItems.reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, 0)
896
+ numberOfTotalPages: numberOfPagesPerItems.reduce(
897
+ (acc, numberOfPagesForItem) => acc + numberOfPagesForItem,
898
+ 0
899
+ )
765
900
  };
766
901
  }),
767
902
  rxjs.distinctUntilChanged(isShallowEqual),
@@ -818,7 +953,10 @@
818
953
  const totalPages$ = trackTotalPages(reader);
819
954
  const currentValue = new rxjs.BehaviorSubject({
820
955
  ...reader.pagination.getPaginationInfo(),
821
- ...mapPaginationInfoToExtendedInfo(reader)(reader.pagination.getPaginationInfo(), getChaptersInfo(reader)),
956
+ ...mapPaginationInfoToExtendedInfo(reader)(
957
+ reader.pagination.getPaginationInfo(),
958
+ getChaptersInfo(reader)
959
+ ),
822
960
  beginAbsolutePageIndex: 0,
823
961
  endAbsolutePageIndex: 0,
824
962
  numberOfTotalPages: 0
@@ -838,8 +976,14 @@
838
976
  rxjs.map(([pageInfo, totalPageInfo]) => ({
839
977
  ...pageInfo,
840
978
  ...totalPageInfo,
841
- beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.beginPageIndexInSpineItem ?? 0),
842
- endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.endPageIndexInSpineItem ?? 0)
979
+ beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce(
980
+ (acc, numberOfPagesForItem) => acc + numberOfPagesForItem,
981
+ pageInfo.beginPageIndexInSpineItem ?? 0
982
+ ),
983
+ endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce(
984
+ (acc, numberOfPagesForItem) => acc + numberOfPagesForItem,
985
+ pageInfo.endPageIndexInSpineItem ?? 0
986
+ )
843
987
  })),
844
988
  rxjs.tap((value) => {
845
989
  currentValue.next(value);
@@ -881,9 +1025,13 @@
881
1025
  ];
882
1026
  const themeEnhancer = (next) => (options) => {
883
1027
  const reader = next(options);
884
- const currentThemeSubject$ = new rxjs.BehaviorSubject(options.theme ?? `bright`);
1028
+ const currentThemeSubject$ = new rxjs.BehaviorSubject(
1029
+ options.theme ?? `bright`
1030
+ );
885
1031
  const getStyle = () => {
886
- const foundTheme = defaultThemes.find((entry) => entry.name === currentThemeSubject$.value);
1032
+ const foundTheme = defaultThemes.find(
1033
+ (entry) => entry.name === currentThemeSubject$.value
1034
+ );
887
1035
  return `
888
1036
  body {
889
1037
  ${foundTheme !== void 0 ? `background-color: ${foundTheme.backgroundColor} !important;` : ``}
@@ -900,21 +1048,30 @@
900
1048
  ` : ``}
901
1049
  `;
902
1050
  };
903
- const applyChangeToSpineItemElement = ({ container }) => {
904
- const foundTheme = defaultThemes.find((entry) => entry.name === currentThemeSubject$.value);
1051
+ const applyChangeToSpineItemElement = ({
1052
+ container
1053
+ }) => {
1054
+ const foundTheme = defaultThemes.find(
1055
+ (entry) => entry.name === currentThemeSubject$.value
1056
+ );
905
1057
  if (foundTheme) {
906
- container.style.setProperty(`background-color`, foundTheme.backgroundColor);
1058
+ container.style.setProperty(
1059
+ `background-color`,
1060
+ foundTheme.backgroundColor
1061
+ );
907
1062
  }
908
1063
  return () => {
909
1064
  };
910
1065
  };
911
1066
  const applyChangeToSpineItem = () => {
912
- reader.spine.manipulateSpineItems(({ removeStyle, addStyle, container }) => {
913
- removeStyle(`prose-reader-theme`);
914
- addStyle(`prose-reader-theme`, getStyle());
915
- applyChangeToSpineItemElement({ container });
916
- return false;
917
- });
1067
+ reader.spine.manipulateSpineItems(
1068
+ ({ removeStyle, addStyle, container }) => {
1069
+ removeStyle(`prose-reader-theme`);
1070
+ addStyle(`prose-reader-theme`, getStyle());
1071
+ applyChangeToSpineItemElement({ container });
1072
+ return false;
1073
+ }
1074
+ );
918
1075
  };
919
1076
  reader.hookManager.register(`item.onLoad`, ({ itemId }) => {
920
1077
  const item = reader.spineItemManager.get(itemId);
@@ -925,7 +1082,11 @@
925
1082
  });
926
1083
  });
927
1084
  reader.spine.$.spineItems$.pipe(
928
- operators.tap((items) => items.map(({ element }) => applyChangeToSpineItemElement({ container: element }))),
1085
+ operators.tap(
1086
+ (items) => items.map(
1087
+ ({ element }) => applyChangeToSpineItemElement({ container: element })
1088
+ )
1089
+ ),
929
1090
  operators.takeUntil(reader.$.destroy$)
930
1091
  ).subscribe();
931
1092
  currentThemeSubject$.pipe(
@@ -992,7 +1153,9 @@
992
1153
  };
993
1154
  const scale = (userScale) => {
994
1155
  const imgElement = imageMagnifierContainer == null ? void 0 : imageMagnifierContainer.querySelector(`img`);
995
- const roundedScale = Math.ceil((userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100) / 100;
1156
+ const roundedScale = Math.ceil(
1157
+ (userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100
1158
+ ) / 100;
996
1159
  const newScale = Math.max(roundedScale, 1);
997
1160
  if (roundedScale < 1) {
998
1161
  imgLastPosition = { x: 0, y: 0 };
@@ -1088,7 +1251,9 @@
1088
1251
  const spineElement = reader.spine.getElement();
1089
1252
  const viewportElement = reader.viewportNavigator.getElement();
1090
1253
  if (!spineElement || !viewportElement) return;
1091
- const roundedScale = Math.ceil((userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100) / 100;
1254
+ const roundedScale = Math.ceil(
1255
+ (userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100
1256
+ ) / 100;
1092
1257
  const newScale = Math.max(roundedScale, 1);
1093
1258
  const currentScale = spineElement.getBoundingClientRect().width / spineElement.offsetWidth;
1094
1259
  const currentScrollTop = viewportElement.scrollTop;
@@ -1197,7 +1362,9 @@
1197
1362
  isUsingScrollableZoom: isUsingScrollableViewport,
1198
1363
  setCurrentScaleAsBase,
1199
1364
  $: {
1200
- isZooming$: currentZoomerSubject$.pipe(rxjs.switchMap((zoomer) => (zoomer == null ? void 0 : zoomer.isZooming$) || rxjs.of(false)))
1365
+ isZooming$: currentZoomerSubject$.pipe(
1366
+ rxjs.switchMap((zoomer) => (zoomer == null ? void 0 : zoomer.isZooming$) || rxjs.of(false))
1367
+ )
1201
1368
  }
1202
1369
  }
1203
1370
  };
@@ -1344,15 +1511,21 @@
1344
1511
  return event[__UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT_KEY];
1345
1512
  };
1346
1513
  const attachOriginalFrameEventToDocumentEvent = (event, frameEvent) => {
1347
- Object.defineProperty(event, __UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT_KEY, { value: frameEvent, enumerable: true });
1514
+ Object.defineProperty(event, __UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT_KEY, {
1515
+ value: frameEvent,
1516
+ enumerable: true
1517
+ });
1348
1518
  };
1349
- const createFrame$ = Report.measurePerformance(`SpineItemFrame createFrame`, Infinity, () => {
1350
- const frame = document.createElement(`iframe`);
1351
- frame.frameBorder = `no`;
1352
- frame.tabIndex = 0;
1353
- frame.setAttribute(`sandbox`, `allow-same-origin allow-scripts`);
1354
- frame.scrolling = `no`;
1355
- frame.style.cssText = `
1519
+ const createFrame$ = Report.measurePerformance(
1520
+ `SpineItemFrame createFrame`,
1521
+ Infinity,
1522
+ () => {
1523
+ const frame = document.createElement(`iframe`);
1524
+ frame.frameBorder = `no`;
1525
+ frame.tabIndex = 0;
1526
+ frame.setAttribute(`sandbox`, `allow-same-origin allow-scripts`);
1527
+ frame.scrolling = `no`;
1528
+ frame.style.cssText = `
1356
1529
  visibility: hidden;
1357
1530
  overflow: hidden;
1358
1531
  background-color: transparent;
@@ -1361,8 +1534,9 @@
1361
1534
  transition: opacity 300ms;
1362
1535
  opacity: 0;
1363
1536
  `;
1364
- return rxjs.of(frame);
1365
- });
1537
+ return rxjs.of(frame);
1538
+ }
1539
+ );
1366
1540
  const getIntrinsicDimensionsFromBase64Img = (data) => new Promise((resolve, reject) => {
1367
1541
  const image = new Image();
1368
1542
  image.src = data;
@@ -1374,7 +1548,9 @@
1374
1548
  const createHtmlPageFromResource = async (resourceResponse, item) => {
1375
1549
  if (typeof resourceResponse === `string`) return resourceResponse;
1376
1550
  const contentType = shared.parseContentType(resourceResponse.headers.get(`Content-Type`) || ``) || shared.detectMimeTypeFromName(item.href);
1377
- if ([`image/jpg`, `image/jpeg`, `image/png`, `image/webp`].some((mime) => mime === contentType)) {
1551
+ if ([`image/jpg`, `image/jpeg`, `image/png`, `image/webp`].some(
1552
+ (mime) => mime === contentType
1553
+ )) {
1378
1554
  const data = await getBase64FromBlob(await resourceResponse.blob());
1379
1555
  const { height, width } = await getIntrinsicDimensionsFromBase64Img(data);
1380
1556
  return `
@@ -1417,7 +1593,6 @@
1417
1593
  const createLoader = ({
1418
1594
  item,
1419
1595
  parent,
1420
- fetchResource,
1421
1596
  context,
1422
1597
  viewportState$,
1423
1598
  settings,
@@ -1462,9 +1637,17 @@
1462
1637
  operators.mergeMap((frame) => {
1463
1638
  parent.appendChild(frame);
1464
1639
  frameElementSubject$.next(frame);
1640
+ const { fetchResource } = settings.settings;
1465
1641
  if (!fetchResource && item.href.startsWith(window.location.origin) && // we have an encoding and it's a valid html
1466
- (item.mediaType && [`application/xhtml+xml`, `application/xml`, `text/html`, `text/xml`].includes(item.mediaType) || // no encoding ? then try to detect html
1467
- !item.mediaType && ITEM_EXTENSION_VALID_FOR_FRAME_SRC.some((extension) => item.href.endsWith(extension)))) {
1642
+ (item.mediaType && [
1643
+ `application/xhtml+xml`,
1644
+ `application/xml`,
1645
+ `text/html`,
1646
+ `text/xml`
1647
+ ].includes(item.mediaType) || // no encoding ? then try to detect html
1648
+ !item.mediaType && ITEM_EXTENSION_VALID_FOR_FRAME_SRC.some(
1649
+ (extension) => item.href.endsWith(extension)
1650
+ ))) {
1468
1651
  frame == null ? void 0 : frame.setAttribute(`src`, item.href);
1469
1652
  return rxjs.of(frame);
1470
1653
  } else {
@@ -1478,7 +1661,9 @@
1478
1661
  }),
1479
1662
  operators.map(() => frame),
1480
1663
  operators.catchError((e) => {
1481
- Report.error(`Error while trying to fetch or load resource for item ${item.id}`);
1664
+ Report.error(
1665
+ `Error while trying to fetch or load resource for item ${item.id}`
1666
+ );
1482
1667
  console.error(e);
1483
1668
  return rxjs.of(frame);
1484
1669
  })
@@ -1506,8 +1691,12 @@
1506
1691
  const hookResults = hookManager.execute(`item.onLoad`, item.id, {
1507
1692
  itemId: item.id,
1508
1693
  frame
1509
- }).filter((result) => result instanceof rxjs.Observable);
1510
- return rxjs.combineLatest([rxjs.of(null), ...hookResults]).pipe(operators.map(() => frame));
1694
+ }).filter(
1695
+ (result) => result instanceof rxjs.Observable
1696
+ );
1697
+ return rxjs.combineLatest([rxjs.of(null), ...hookResults]).pipe(
1698
+ operators.map(() => frame)
1699
+ );
1511
1700
  })
1512
1701
  );
1513
1702
  }),
@@ -1520,10 +1709,14 @@
1520
1709
  operators.takeUntil(destroySubject$)
1521
1710
  );
1522
1711
  const ready$ = load$.pipe(
1523
- operators.switchMap((frame) => {
1524
- var _a;
1525
- return rxjs.from(((_a = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _a.fonts.ready) || rxjs.of(void 0)).pipe(operators.takeUntil(unloadSubject$));
1526
- }),
1712
+ operators.switchMap(
1713
+ (frame) => {
1714
+ var _a;
1715
+ return rxjs.from(((_a = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _a.fonts.ready) || rxjs.of(void 0)).pipe(
1716
+ operators.takeUntil(unloadSubject$)
1717
+ );
1718
+ }
1719
+ ),
1527
1720
  operators.share(),
1528
1721
  makeItHot,
1529
1722
  operators.takeUntil(destroySubject$)
@@ -1564,7 +1757,6 @@
1564
1757
  const createFrameItem = ({
1565
1758
  item,
1566
1759
  parent,
1567
- fetchResource,
1568
1760
  context,
1569
1761
  viewportState$,
1570
1762
  settings,
@@ -1572,12 +1764,27 @@
1572
1764
  }) => {
1573
1765
  const destroySubject$ = new rxjs.Subject();
1574
1766
  const {
1575
- $: { unload$, loaded$, isLoaded$, isReady$, unloaded$, frameElement$, ready$ },
1767
+ $: {
1768
+ unload$,
1769
+ loaded$,
1770
+ isLoaded$,
1771
+ isReady$,
1772
+ unloaded$,
1773
+ frameElement$,
1774
+ ready$
1775
+ },
1576
1776
  load,
1577
1777
  unload,
1578
1778
  destroy: loaderDestroy,
1579
1779
  getComputedStyleAfterLoad
1580
- } = createLoader({ context, hookManager, item, parent, fetchResource, viewportState$, settings });
1780
+ } = createLoader({
1781
+ context,
1782
+ hookManager,
1783
+ item,
1784
+ parent,
1785
+ viewportState$,
1786
+ settings
1787
+ });
1581
1788
  let isLoadedSync = false;
1582
1789
  let isReadySync = false;
1583
1790
  isLoaded$.subscribe({
@@ -1605,7 +1812,10 @@
1605
1812
  const viewPortMetaInfos = viewPortMeta.getAttribute(`content`);
1606
1813
  if (viewPortMetaInfos) {
1607
1814
  const width = getAttributeValueFromString(viewPortMetaInfos, `width`);
1608
- const height = getAttributeValueFromString(viewPortMetaInfos, `height`);
1815
+ const height = getAttributeValueFromString(
1816
+ viewPortMetaInfos,
1817
+ `height`
1818
+ );
1609
1819
  if (width > 0 && height > 0) {
1610
1820
  return {
1611
1821
  width,
@@ -1680,7 +1890,8 @@
1680
1890
  return `rtl`;
1681
1891
  }
1682
1892
  const direction = (_a = getComputedStyleAfterLoad()) == null ? void 0 : _a.direction;
1683
- if ([`ltr`, `rtl`].includes(direction || ``)) return direction;
1893
+ if ([`ltr`, `rtl`].includes(direction || ``))
1894
+ return direction;
1684
1895
  return void 0;
1685
1896
  },
1686
1897
  isUsingVerticalWriting,
@@ -1752,7 +1963,10 @@
1752
1963
  });
1753
1964
  (_a = frameToTrack.contentDocument) == null ? void 0 : _a.addEventListener(`selectionchange`, () => {
1754
1965
  var _a2;
1755
- subject.next({ event: `selectionchange`, data: ((_a2 = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _a2.getSelection()) || null });
1966
+ subject.next({
1967
+ event: `selectionchange`,
1968
+ data: ((_a2 = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _a2.getSelection()) || null
1969
+ });
1756
1970
  });
1757
1971
  (_b = frameToTrack.contentWindow) == null ? void 0 : _b.addEventListener(`selectstart`, () => {
1758
1972
  isSelecting = true;
@@ -1767,7 +1981,8 @@
1767
1981
  getSelection: () => {
1768
1982
  var _a;
1769
1983
  const selection = (_a = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _a.getSelection();
1770
- if (!(selection == null ? void 0 : selection.anchorNode) || selection.type === `None` || selection.type === `Caret`) return void 0;
1984
+ if (!(selection == null ? void 0 : selection.anchorNode) || selection.type === `None` || selection.type === `Caret`)
1985
+ return void 0;
1771
1986
  return selection;
1772
1987
  },
1773
1988
  $: subject.asObservable()
@@ -1782,7 +1997,11 @@
1782
1997
  hookManager
1783
1998
  }) => {
1784
1999
  const destroySubject$ = new rxjs.Subject();
1785
- const containerElement = createContainerElement$1(parentElement, item, hookManager);
2000
+ const containerElement = createContainerElement$1(
2001
+ parentElement,
2002
+ item,
2003
+ hookManager
2004
+ );
1786
2005
  const overlayElement = createOverlayElement(parentElement, item);
1787
2006
  const fingerTracker = createFingerTracker();
1788
2007
  const selectionTracker = createSelectionTracker();
@@ -1821,7 +2040,11 @@
1821
2040
  (_a = spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.removeStyle(`prose-reader-css`);
1822
2041
  (_b = spineItemFrame.getManipulableFrame()) == null ? void 0 : _b.addStyle(`prose-reader-css`, cssText);
1823
2042
  };
1824
- const adjustPositionOfElement = ({ right, left, top }) => {
2043
+ const adjustPositionOfElement = ({
2044
+ right,
2045
+ left,
2046
+ top
2047
+ }) => {
1825
2048
  if (right !== void 0) {
1826
2049
  containerElement.style.right = `${right}px`;
1827
2050
  } else {
@@ -1845,7 +2068,10 @@
1845
2068
  const frameElement = (_a = spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.frame;
1846
2069
  if (containerElement && (frameElement == null ? void 0 : frameElement.contentDocument) && (frameElement == null ? void 0 : frameElement.contentWindow) && viewportDimensions) {
1847
2070
  const computedWidthScale = pageWidth / viewportDimensions.width;
1848
- const computedScale = Math.min(computedWidthScale, pageHeight / viewportDimensions.height);
2071
+ const computedScale = Math.min(
2072
+ computedWidthScale,
2073
+ pageHeight / viewportDimensions.height
2074
+ );
1849
2075
  return { computedScale, computedWidthScale, viewportDimensions };
1850
2076
  }
1851
2077
  };
@@ -1898,7 +2124,11 @@
1898
2124
  }) => {
1899
2125
  containerElement.style.width = `${width}px`;
1900
2126
  containerElement.style.height = `${height}px`;
1901
- hookManager.execute(`item.onAfterLayout`, void 0, { blankPagePosition, item, minimumWidth });
2127
+ hookManager.execute(`item.onAfterLayout`, void 0, {
2128
+ blankPagePosition,
2129
+ item,
2130
+ minimumWidth
2131
+ });
1902
2132
  setLayoutDirty();
1903
2133
  };
1904
2134
  const translateFramePositionIntoPage = (position) => {
@@ -2112,8 +2342,14 @@
2112
2342
  }
2113
2343
  const transformTranslateX = spreadPosition !== `none` ? `0` : `-50%`;
2114
2344
  const transformOriginX = spreadPosition === `right` && blankPagePosition !== `before` ? `left` : spreadPosition === `left` || blankPagePosition === `before` && context.isRTL() ? `right` : `center`;
2115
- frameElement == null ? void 0 : frameElement.style.setProperty(`transform`, `translate(${transformTranslateX}, -50%) scale(${computedScale})`);
2116
- frameElement == null ? void 0 : frameElement.style.setProperty(`transform-origin`, `${transformOriginX} center`);
2345
+ frameElement == null ? void 0 : frameElement.style.setProperty(
2346
+ `transform`,
2347
+ `translate(${transformTranslateX}, -50%) scale(${computedScale})`
2348
+ );
2349
+ frameElement == null ? void 0 : frameElement.style.setProperty(
2350
+ `transform-origin`,
2351
+ `${transformOriginX} center`
2352
+ );
2117
2353
  commonSpineItem.executeOnLayoutBeforeMeasurementHook({ minimumWidth });
2118
2354
  } else {
2119
2355
  commonSpineItem.injectStyle(cssLink);
@@ -2133,11 +2369,21 @@
2133
2369
  }
2134
2370
  }
2135
2371
  commonSpineItem.executeOnLayoutBeforeMeasurementHook({ minimumWidth });
2136
- commonSpineItem.layout({ width: minimumWidth, height: contentHeight, blankPagePosition, minimumWidth });
2372
+ commonSpineItem.layout({
2373
+ width: minimumWidth,
2374
+ height: contentHeight,
2375
+ blankPagePosition,
2376
+ minimumWidth
2377
+ });
2137
2378
  return { width: minimumWidth, height: contentHeight };
2138
2379
  } else {
2139
2380
  commonSpineItem.executeOnLayoutBeforeMeasurementHook({ minimumWidth });
2140
- commonSpineItem.layout({ width: minimumWidth, height: pageHeight, blankPagePosition, minimumWidth });
2381
+ commonSpineItem.layout({
2382
+ width: minimumWidth,
2383
+ height: pageHeight,
2384
+ blankPagePosition,
2385
+ minimumWidth
2386
+ });
2141
2387
  }
2142
2388
  return { width: minimumWidth, height: pageHeight };
2143
2389
  };
@@ -2266,19 +2512,27 @@
2266
2512
  `left`,
2267
2513
  blankPagePosition === `before` ? context.isRTL() ? `25%` : `75%` : blankPagePosition === `after` ? context.isRTL() ? `75%` : `25%` : `50%`
2268
2514
  );
2269
- frameElement == null ? void 0 : frameElement.style.setProperty(`transform`, `translate(-50%, -50%) scale(${computedScale})`);
2515
+ frameElement == null ? void 0 : frameElement.style.setProperty(
2516
+ `transform`,
2517
+ `translate(-50%, -50%) scale(${computedScale})`
2518
+ );
2270
2519
  frameElement == null ? void 0 : frameElement.style.setProperty(`transform-origin`, `center center`);
2271
2520
  } else {
2272
2521
  const frameStyle = commonSpineItem.isImageType() ? buildStyleForReflowableImageOnly({
2273
2522
  isScrollable: ((_g = context.manifest) == null ? void 0 : _g.renditionFlow) === `scrolled-continuous`,
2274
2523
  enableTouch: settings.settings.computedPageTurnMode !== `scrollable`
2275
2524
  }) : buildStyleWithMultiColumn(
2276
- commonSpineItem.getDimensionsForReflowableContent(spineItemFrame.isUsingVerticalWriting(), minimumWidth)
2525
+ commonSpineItem.getDimensionsForReflowableContent(
2526
+ spineItemFrame.isUsingVerticalWriting(),
2527
+ minimumWidth
2528
+ )
2277
2529
  );
2278
2530
  commonSpineItem.injectStyle(frameStyle);
2279
2531
  commonSpineItem.executeOnLayoutBeforeMeasurementHook({ minimumWidth });
2280
2532
  if (spineItemFrame.isUsingVerticalWriting()) {
2281
- const pages = Math.ceil(frameElement.contentDocument.documentElement.scrollHeight / pageHeight);
2533
+ const pages = Math.ceil(
2534
+ frameElement.contentDocument.documentElement.scrollHeight / pageHeight
2535
+ );
2282
2536
  contentHeight = pages * pageHeight;
2283
2537
  spineItemFrame.staticLayout({
2284
2538
  width: minimumWidth,
@@ -2292,7 +2546,9 @@
2292
2546
  height: contentHeight
2293
2547
  });
2294
2548
  } else {
2295
- const pages = Math.ceil(frameElement.contentDocument.documentElement.scrollWidth / pageWidth);
2549
+ const pages = Math.ceil(
2550
+ frameElement.contentDocument.documentElement.scrollWidth / pageWidth
2551
+ );
2296
2552
  if (isGloballyPrePaginated) {
2297
2553
  contentWidth = pageWidth;
2298
2554
  } else {
@@ -2313,13 +2569,23 @@
2313
2569
  } else {
2314
2570
  frameElement == null ? void 0 : frameElement.style.setProperty(`margin-left`, `0px`);
2315
2571
  }
2316
- commonSpineItem.layout({ width: contentWidth, height: contentHeight, blankPagePosition, minimumWidth });
2572
+ commonSpineItem.layout({
2573
+ width: contentWidth,
2574
+ height: contentHeight,
2575
+ blankPagePosition,
2576
+ minimumWidth
2577
+ });
2317
2578
  return { width: contentWidth, height: contentHeight };
2318
2579
  } else {
2319
2580
  commonSpineItem.executeOnLayoutBeforeMeasurementHook({ minimumWidth });
2320
2581
  }
2321
2582
  const height = latestContentHeightWhenLoaded || pageHeight;
2322
- commonSpineItem.layout({ width: minimumWidth, height, blankPagePosition, minimumWidth });
2583
+ commonSpineItem.layout({
2584
+ width: minimumWidth,
2585
+ height,
2586
+ blankPagePosition,
2587
+ minimumWidth
2588
+ });
2323
2589
  return { width: minimumWidth, height };
2324
2590
  };
2325
2591
  return {
@@ -2639,7 +2905,10 @@
2639
2905
  while (str.length) {
2640
2906
  ({ parsed, offset, newDoc } = this.parse(str));
2641
2907
  if (!parsed || offset === null) throw new Error(`Parsing failed`);
2642
- if (sawComma && newDoc) throw new Error(`CFI is a range that spans multiple documents. This is not allowed`);
2908
+ if (sawComma && newDoc)
2909
+ throw new Error(
2910
+ `CFI is a range that spans multiple documents. This is not allowed`
2911
+ );
2643
2912
  subParts.push(parsed);
2644
2913
  if (newDoc || str.length - offset <= 0) {
2645
2914
  if (sawComma === 2) {
@@ -2707,7 +2976,8 @@
2707
2976
  while (node.parentNode) {
2708
2977
  o = calcSiblingCount(node.parentNode.childNodes, node, offset);
2709
2978
  if (!cfi && o.offset) cfi = `:` + o.offset;
2710
- cfi = `/` + o.count + (node.id ? `[` + cfiEscape(node.id) + `]` : ``) + cfi;
2979
+ cfi = // @ts-ignore
2980
+ `/` + o.count + (node.id ? `[` + cfiEscape(node.id) + `]` : ``) + cfi;
2711
2981
  node = node.parentNode;
2712
2982
  }
2713
2983
  return cfi;
@@ -2810,7 +3080,8 @@
2810
3080
  return this.decodeEntities(dom, str).length;
2811
3081
  }
2812
3082
  getFrom() {
2813
- if (!this.isRange) throw new Error(`Trying to get beginning of non-range CFI`);
3083
+ if (!this.isRange)
3084
+ throw new Error(`Trying to get beginning of non-range CFI`);
2814
3085
  if (!this.from) {
2815
3086
  return this.deepClone(this.parts);
2816
3087
  }
@@ -2995,10 +3266,13 @@
2995
3266
  }
2996
3267
  if (cur === `:` || cur === `~` || cur === `@`) {
2997
3268
  if (this.opts.stricter) {
2998
- if (cur === `:` && (typeof o.temporal !== `undefined` || typeof o.spatial !== `undefined`)) {
3269
+ if (cur === `:` && // @ts-ignore
3270
+ (typeof o.temporal !== `undefined` || // @ts-ignore
3271
+ typeof o.spatial !== `undefined`)) {
2999
3272
  break;
3000
3273
  }
3001
- if ((cur === `~` || cur === `@`) && typeof o.offset !== `undefined`) {
3274
+ if ((cur === `~` || cur === `@`) && // @ts-ignore
3275
+ typeof o.offset !== `undefined`) {
3002
3276
  break;
3003
3277
  }
3004
3278
  }
@@ -3061,7 +3335,8 @@
3061
3335
  }
3062
3336
  escape = false;
3063
3337
  }
3064
- if (!o.nodeIndex && o.nodeIndex !== 0) throw new Error(`Missing child node index in CFI`);
3338
+ if (!o.nodeIndex && o.nodeIndex !== 0)
3339
+ throw new Error(`Missing child node index in CFI`);
3065
3340
  return { parsed: o, offset: i, newDoc: state === `!` };
3066
3341
  }
3067
3342
  // The CFI counts child nodes differently from the DOM
@@ -3099,7 +3374,11 @@
3099
3374
  if (!lastChild) {
3100
3375
  return { node: parentNode, offset: 0 };
3101
3376
  }
3102
- return { node: lastChild, offset: this.trueLength(dom, lastChild.textContent) };
3377
+ return {
3378
+ node: lastChild,
3379
+ // @ts-ignore
3380
+ offset: this.trueLength(dom, lastChild.textContent)
3381
+ };
3103
3382
  }
3104
3383
  }
3105
3384
  lastChild = child;
@@ -3186,7 +3465,8 @@
3186
3465
  newOffset -= nodeLengths[i];
3187
3466
  if (newOffset < 0) return { node, offset };
3188
3467
  const nodeOffsets = [];
3189
- if (!curNode.nextSibling || i + 1 >= nodeOffsets.length) return { node, offset };
3468
+ if (!curNode.nextSibling || i + 1 >= nodeOffsets.length)
3469
+ return { node, offset };
3190
3470
  i++;
3191
3471
  curNode = curNode.nextSibling;
3192
3472
  }
@@ -3215,7 +3495,12 @@
3215
3495
  let subpart;
3216
3496
  for (i = subparts.length - 1; i >= 0; i--) {
3217
3497
  subpart = subparts[i];
3218
- if (!opts.ignoreIDs && subpart.nodeID && (node = dom.getElementById(subpart.nodeID))) {
3498
+ if (
3499
+ // @ts-ignore
3500
+ !opts.ignoreIDs && // @ts-ignore
3501
+ subpart.nodeID && // @ts-ignore
3502
+ (node = dom.getElementById(subpart.nodeID))
3503
+ ) {
3219
3504
  startFrom = i + 1;
3220
3505
  break;
3221
3506
  }
@@ -3227,9 +3512,22 @@
3227
3512
  for (i = startFrom; i < subparts.length; i++) {
3228
3513
  subpart = subparts[i];
3229
3514
  if (subpart) {
3230
- o = this.getChildNodeByCFIIndex(dom, o.node, subpart.nodeIndex, subpart.offset);
3515
+ o = this.getChildNodeByCFIIndex(
3516
+ dom,
3517
+ // @ts-ignore
3518
+ o.node,
3519
+ subpart.nodeIndex,
3520
+ subpart.offset
3521
+ );
3231
3522
  if (subpart.textLocationAssertion) {
3232
- o = this.correctOffset(dom, o.node, subpart.offset, subpart.textLocationAssertion);
3523
+ o = this.correctOffset(
3524
+ dom,
3525
+ // @ts-ignore
3526
+ o.node,
3527
+ subpart.offset,
3528
+ // @ts-ignore
3529
+ subpart.textLocationAssertion
3530
+ );
3233
3531
  }
3234
3532
  }
3235
3533
  }
@@ -3271,12 +3569,14 @@
3271
3569
  }
3272
3570
  if (tagName === `object`) {
3273
3571
  const data = node.getAttribute(`data`);
3274
- if (!data) throw new Error(tagName + ` element is missing 'data' attribute`);
3572
+ if (!data)
3573
+ throw new Error(tagName + ` element is missing 'data' attribute`);
3275
3574
  return data;
3276
3575
  }
3277
3576
  if (tagName === `image` || tagName === `use`) {
3278
3577
  const href = node.getAttribute(`xlink:href`);
3279
- if (!href) throw new Error(tagName + ` element is missing 'xlink:href' attribute`);
3578
+ if (!href)
3579
+ throw new Error(tagName + ` element is missing 'xlink:href' attribute`);
3280
3580
  return href;
3281
3581
  }
3282
3582
  throw new Error(`No URI found`);
@@ -3448,17 +3748,26 @@
3448
3748
  spineItemsFromPosition.beginPosition,
3449
3749
  beginSpineItem
3450
3750
  );
3451
- const beginPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(beginPosition, beginSpineItem);
3751
+ const beginPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(
3752
+ beginPosition,
3753
+ beginSpineItem
3754
+ );
3452
3755
  const endPosition = spineLocator.getSpineItemPositionFromSpinePosition(
3453
3756
  spineItemsFromPosition.endPosition,
3454
3757
  endSpineItem
3455
3758
  );
3456
- const endPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(endPosition, endSpineItem);
3759
+ const endPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(
3760
+ endPosition,
3761
+ endSpineItem
3762
+ );
3457
3763
  pagination.updateBeginAndEnd(
3458
3764
  {
3459
3765
  spineItem: beginSpineItem,
3460
3766
  spineItemIndex: spineItemManager.getSpineItemIndex(beginSpineItem) ?? 0,
3461
- pageIndex: spineItemLocator.getSpineItemPageIndexFromPosition(beginPosition, beginSpineItem),
3767
+ pageIndex: spineItemLocator.getSpineItemPageIndexFromPosition(
3768
+ beginPosition,
3769
+ beginSpineItem
3770
+ ),
3462
3771
  cfi: shouldUpdateBeginCfi ? cfiLocator.getCfi(beginPageIndex, beginSpineItem) : beginLastCfi,
3463
3772
  options: {
3464
3773
  isAtEndOfChapter: false
@@ -3467,7 +3776,10 @@
3467
3776
  {
3468
3777
  spineItem: endSpineItem,
3469
3778
  spineItemIndex: spineItemManager.getSpineItemIndex(endSpineItem) ?? 0,
3470
- pageIndex: spineItemLocator.getSpineItemPageIndexFromPosition(endPosition, endSpineItem),
3779
+ pageIndex: spineItemLocator.getSpineItemPageIndexFromPosition(
3780
+ endPosition,
3781
+ endSpineItem
3782
+ ),
3471
3783
  cfi: shouldUpdateEndCfi ? cfiLocator.getCfi(endPageIndex, endSpineItem) : endLastCfi,
3472
3784
  options: {
3473
3785
  isAtEndOfChapter: false
@@ -3504,7 +3816,11 @@
3504
3816
  () => fingerTracker$.pipe(
3505
3817
  operators.filter(({ event: event2 }) => event2 === `fingermove`),
3506
3818
  operators.debounce(() => rxjs.interval(1e3)),
3507
- operators.takeUntil(fingerTracker$.pipe(operators.filter(({ event: event2 }) => event2 === `fingerout`))),
3819
+ operators.takeUntil(
3820
+ fingerTracker$.pipe(
3821
+ operators.filter(({ event: event2 }) => event2 === `fingerout`)
3822
+ )
3823
+ ),
3508
3824
  operators.tap(({ data }) => {
3509
3825
  })
3510
3826
  )
@@ -3541,12 +3857,18 @@
3541
3857
  spineItemsFromPosition.beginPosition,
3542
3858
  beginSpineItem
3543
3859
  );
3544
- const beginPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(beginPosition, beginSpineItem);
3860
+ const beginPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(
3861
+ beginPosition,
3862
+ beginSpineItem
3863
+ );
3545
3864
  const endPosition = spineLocator.getSpineItemPositionFromSpinePosition(
3546
3865
  spineItemsFromPosition.endPosition,
3547
3866
  endSpineItem
3548
3867
  );
3549
- const endPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(endPosition, endSpineItem);
3868
+ const endPageIndex = spineItemLocator.getSpineItemPageIndexFromPosition(
3869
+ endPosition,
3870
+ endSpineItem
3871
+ );
3550
3872
  const endItemIndex = spineItemManager.getSpineItemIndex(endSpineItem) ?? 0;
3551
3873
  pagination.updateBeginAndEnd(
3552
3874
  {
@@ -3605,7 +3927,9 @@
3605
3927
  );
3606
3928
  itemUpdateOnNavigation$.pipe(
3607
3929
  operators.switchMap((data) => {
3608
- return adjustPagination(data.position).pipe(operators.takeUntil(spineItemManager.$.layout$));
3930
+ return adjustPagination(data.position).pipe(
3931
+ operators.takeUntil(spineItemManager.$.layout$)
3932
+ );
3609
3933
  }),
3610
3934
  operators.takeUntil(context.destroy$)
3611
3935
  ).subscribe();
@@ -3629,10 +3953,20 @@
3629
3953
  const focusedSpineItemIndex = spineItemManager.getFocusedSpineItemIndex();
3630
3954
  report.log(`update contents`, { focusedSpineItemIndex });
3631
3955
  if (focusedSpineItemIndex === void 0) return;
3632
- const { begin = focusedSpineItemIndex, end = focusedSpineItemIndex } = spineLocator.getSpineItemsFromReadingOrderPosition(currentNavigationPosition) || {};
3956
+ const {
3957
+ begin = focusedSpineItemIndex,
3958
+ end = focusedSpineItemIndex
3959
+ } = spineLocator.getSpineItemsFromReadingOrderPosition(
3960
+ currentNavigationPosition
3961
+ ) || {};
3633
3962
  if (begin !== focusedSpineItemIndex && end !== focusedSpineItemIndex) {
3634
- Report.warn(`Current viewport is not in sync with focus item, load from focus item rather than viewport`);
3635
- spineItemManager.loadContents([focusedSpineItemIndex, focusedSpineItemIndex]);
3963
+ Report.warn(
3964
+ `Current viewport is not in sync with focus item, load from focus item rather than viewport`
3965
+ );
3966
+ spineItemManager.loadContents([
3967
+ focusedSpineItemIndex,
3968
+ focusedSpineItemIndex
3969
+ ]);
3636
3970
  } else {
3637
3971
  spineItemManager.loadContents([begin, end]);
3638
3972
  }
@@ -3691,7 +4025,10 @@
3691
4025
  return element;
3692
4026
  };
3693
4027
  const NAMESPACE$4 = `spineItemManager`;
3694
- const createSpineItemManager = ({ context, settings }) => {
4028
+ const createSpineItemManager = ({
4029
+ context,
4030
+ settings
4031
+ }) => {
3695
4032
  const focus$ = new rxjs.Subject();
3696
4033
  const layout$ = new rxjs.Subject();
3697
4034
  let itemLayoutInformation = [];
@@ -3802,30 +4139,36 @@
3802
4139
  focusedSpineItemIndex = newActiveSpineItemIndex;
3803
4140
  focus$.next({ data: spineItemToFocus });
3804
4141
  };
3805
- const loadContents = Report.measurePerformance(`loadContents`, 10, (rangeOfIndex) => {
3806
- var _a;
3807
- const [leftIndex, rightIndex] = rangeOfIndex;
3808
- const numberOfAdjacentSpineItemToPreLoad = settings.settings.numberOfAdjacentSpineItemToPreLoad;
3809
- const isPrePaginated = ((_a = context.manifest) == null ? void 0 : _a.renditionLayout) === `pre-paginated`;
3810
- const isUsingFreeScroll = settings.settings.computedPageTurnMode === `scrollable`;
3811
- orderedSpineItemsSubject$.value.forEach((orderedSpineItem, index) => {
3812
- const isBeforeFocusedWithPreload = (
3813
- // we never want to preload anything before on free scroll on flow because it could offset the cursor
3814
- index < leftIndex && !isPrePaginated && isUsingFreeScroll ? true : index < leftIndex - numberOfAdjacentSpineItemToPreLoad
3815
- );
3816
- const isAfterTailWithPreload = index > rightIndex + numberOfAdjacentSpineItemToPreLoad;
3817
- if (!isBeforeFocusedWithPreload && !isAfterTailWithPreload) {
3818
- orderedSpineItem.loadContent();
3819
- } else {
3820
- orderedSpineItem.unloadContent();
3821
- }
3822
- });
3823
- });
4142
+ const loadContents = Report.measurePerformance(
4143
+ `loadContents`,
4144
+ 10,
4145
+ (rangeOfIndex) => {
4146
+ var _a;
4147
+ const [leftIndex, rightIndex] = rangeOfIndex;
4148
+ const numberOfAdjacentSpineItemToPreLoad = settings.settings.numberOfAdjacentSpineItemToPreLoad;
4149
+ const isPrePaginated = ((_a = context.manifest) == null ? void 0 : _a.renditionLayout) === `pre-paginated`;
4150
+ const isUsingFreeScroll = settings.settings.computedPageTurnMode === `scrollable`;
4151
+ orderedSpineItemsSubject$.value.forEach((orderedSpineItem, index) => {
4152
+ const isBeforeFocusedWithPreload = (
4153
+ // we never want to preload anything before on free scroll on flow because it could offset the cursor
4154
+ index < leftIndex && !isPrePaginated && isUsingFreeScroll ? true : index < leftIndex - numberOfAdjacentSpineItemToPreLoad
4155
+ );
4156
+ const isAfterTailWithPreload = index > rightIndex + numberOfAdjacentSpineItemToPreLoad;
4157
+ if (!isBeforeFocusedWithPreload && !isAfterTailWithPreload) {
4158
+ orderedSpineItem.loadContent();
4159
+ } else {
4160
+ orderedSpineItem.unloadContent();
4161
+ }
4162
+ });
4163
+ }
4164
+ );
3824
4165
  const get = (indexOrId) => {
3825
4166
  if (typeof indexOrId === `number`) {
3826
4167
  return orderedSpineItemsSubject$.value[indexOrId];
3827
4168
  }
3828
- return orderedSpineItemsSubject$.value.find(({ item }) => item.id === indexOrId);
4169
+ return orderedSpineItemsSubject$.value.find(
4170
+ ({ item }) => item.id === indexOrId
4171
+ );
3829
4172
  };
3830
4173
  const getAbsolutePositionOf = (spineItemOrIndex) => {
3831
4174
  const indexOfItem = typeof spineItemOrIndex === `number` ? spineItemOrIndex : orderedSpineItemsSubject$.value.indexOf(spineItemOrIndex);
@@ -3910,7 +4253,9 @@
3910
4253
  itemIsReady$: orderedSpineItemsSubject$.asObservable().pipe(
3911
4254
  operators.switchMap((items) => {
3912
4255
  const itemsIsReady$ = items.map(
3913
- (item) => item.$.isReady$.pipe(operators.map((isReady) => ({ item: item.item, isReady })))
4256
+ (item) => item.$.isReady$.pipe(
4257
+ operators.map((isReady) => ({ item: item.item, isReady }))
4258
+ )
3914
4259
  );
3915
4260
  return rxjs.merge(...itemsIsReady$);
3916
4261
  })
@@ -3981,7 +4326,10 @@
3981
4326
  );
3982
4327
  const getFirstVisibleElementForViewport = (element, viewport) => {
3983
4328
  let lastValidElement;
3984
- const positionFromViewport = getElementOrNodePositionFromViewPort(element.getBoundingClientRect(), viewport);
4329
+ const positionFromViewport = getElementOrNodePositionFromViewPort(
4330
+ element.getBoundingClientRect(),
4331
+ viewport
4332
+ );
3985
4333
  if (positionFromViewport !== `before` && positionFromViewport !== `after`) {
3986
4334
  lastValidElement = element;
3987
4335
  }
@@ -3997,7 +4345,8 @@
3997
4345
  };
3998
4346
  function getElementOrNodePositionFromViewPort(domRect, { left, right }) {
3999
4347
  if (domRect.left <= left && domRect.right <= left) return `before`;
4000
- if (domRect.left <= left && domRect.right > left && domRect.right <= right) return `partially-before`;
4348
+ if (domRect.left <= left && domRect.right > left && domRect.right <= right)
4349
+ return `partially-before`;
4001
4350
  if (domRect.left <= right && domRect.right > right) return `partially-after`;
4002
4351
  if (domRect.left > right) return `after`;
4003
4352
  return `within`;
@@ -4081,19 +4430,33 @@
4081
4430
  };
4082
4431
  const createLocationResolver$1 = ({ context }) => {
4083
4432
  const getSafePosition = (unsafeSpineItemPosition, spineItem) => ({
4084
- x: Math.min(spineItem.getElementDimensions().width, Math.max(0, unsafeSpineItemPosition.x)),
4085
- y: Math.min(spineItem.getElementDimensions().height, Math.max(0, unsafeSpineItemPosition.y))
4433
+ x: Math.min(
4434
+ spineItem.getElementDimensions().width,
4435
+ Math.max(0, unsafeSpineItemPosition.x)
4436
+ ),
4437
+ y: Math.min(
4438
+ spineItem.getElementDimensions().height,
4439
+ Math.max(0, unsafeSpineItemPosition.y)
4440
+ )
4086
4441
  });
4087
4442
  const getSpineItemPositionFromPageIndex = (pageIndex, spineItem) => {
4088
4443
  const { width: itemWidth, height: itemHeight } = spineItem.getElementDimensions();
4089
4444
  if (spineItem.isUsingVerticalWriting()) {
4090
- const ltrRelativeOffset2 = getItemOffsetFromPageIndex(context.getPageSize().height, pageIndex, itemHeight);
4445
+ const ltrRelativeOffset2 = getItemOffsetFromPageIndex(
4446
+ context.getPageSize().height,
4447
+ pageIndex,
4448
+ itemHeight
4449
+ );
4091
4450
  return {
4092
4451
  x: 0,
4093
4452
  y: ltrRelativeOffset2
4094
4453
  };
4095
4454
  }
4096
- const ltrRelativeOffset = getItemOffsetFromPageIndex(context.getPageSize().width, pageIndex, itemWidth);
4455
+ const ltrRelativeOffset = getItemOffsetFromPageIndex(
4456
+ context.getPageSize().width,
4457
+ pageIndex,
4458
+ itemWidth
4459
+ );
4097
4460
  if (context.isRTL()) {
4098
4461
  return {
4099
4462
  x: itemWidth - ltrRelativeOffset - context.getPageSize().width,
@@ -4112,7 +4475,10 @@
4112
4475
  const safePosition = getSafePosition(position, spineItem);
4113
4476
  const offset = context.isRTL() ? itemWidth - safePosition.x - context.getPageSize().width : safePosition.x;
4114
4477
  if (spineItem.isUsingVerticalWriting()) {
4115
- const numberOfPages = calculateNumberOfPagesForItem(itemHeight, pageHeight);
4478
+ const numberOfPages = calculateNumberOfPagesForItem(
4479
+ itemHeight,
4480
+ pageHeight
4481
+ );
4116
4482
  return getPageFromOffset(position.y, pageHeight, numberOfPages);
4117
4483
  } else {
4118
4484
  const numberOfPages = calculateNumberOfPagesForItem(itemWidth, pageWidth);
@@ -4126,7 +4492,11 @@
4126
4492
  const pageWidth = context.getPageSize().width;
4127
4493
  const anchorElementBoundingRect = spineItem.getBoundingRectOfElementFromSelector(anchor);
4128
4494
  const offsetOfAnchor = (anchorElementBoundingRect == null ? void 0 : anchorElementBoundingRect.x) || 0;
4129
- return getClosestValidOffsetFromApproximateOffsetInPages(offsetOfAnchor, pageWidth, itemWidth);
4495
+ return getClosestValidOffsetFromApproximateOffsetInPages(
4496
+ offsetOfAnchor,
4497
+ pageWidth,
4498
+ itemWidth
4499
+ );
4130
4500
  };
4131
4501
  const getSpineItemPositionFromNode = (node, offset, spineItem) => {
4132
4502
  var _a;
@@ -4140,7 +4510,11 @@
4140
4510
  const spineItemWidth = ((_a = spineItem.getElementDimensions()) == null ? void 0 : _a.width) || 0;
4141
4511
  const pageWidth = context.getPageSize().width;
4142
4512
  if (offsetOfNodeInSpineItem) {
4143
- const val = getClosestValidOffsetFromApproximateOffsetInPages(offsetOfNodeInSpineItem, pageWidth, spineItemWidth);
4513
+ const val = getClosestValidOffsetFromApproximateOffsetInPages(
4514
+ offsetOfNodeInSpineItem,
4515
+ pageWidth,
4516
+ spineItemWidth
4517
+ );
4144
4518
  return { x: val, y: 0 };
4145
4519
  }
4146
4520
  return void 0;
@@ -4151,14 +4525,20 @@
4151
4525
  const frame = (_b = (_a = spineItem.spineItemFrame) == null ? void 0 : _a.getManipulableFrame()) == null ? void 0 : _b.frame;
4152
4526
  if (((_c = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _c.document) && // very important because it is being used by next functions
4153
4527
  frame.contentWindow.document.body !== null) {
4154
- const { x: left, y: top } = getSpineItemPositionFromPageIndex(pageIndex, spineItem);
4528
+ const { x: left, y: top } = getSpineItemPositionFromPageIndex(
4529
+ pageIndex,
4530
+ spineItem
4531
+ );
4155
4532
  const viewport = {
4156
4533
  left,
4157
4534
  right: left + pageSize.width,
4158
4535
  top,
4159
4536
  bottom: top + pageSize.height
4160
4537
  };
4161
- const res = getFirstVisibleNodeForViewport(frame.contentWindow.document, viewport);
4538
+ const res = getFirstVisibleNodeForViewport(
4539
+ frame.contentWindow.document,
4540
+ viewport
4541
+ );
4162
4542
  return res;
4163
4543
  }
4164
4544
  return void 0;
@@ -4166,8 +4546,16 @@
4166
4546
  const getSpineItemClosestPositionFromUnsafePosition = (unsafePosition, spineItem) => {
4167
4547
  const { width, height } = spineItem.getElementDimensions();
4168
4548
  const adjustedPosition = {
4169
- x: getClosestValidOffsetFromApproximateOffsetInPages(unsafePosition.x, context.getPageSize().width, width),
4170
- y: getClosestValidOffsetFromApproximateOffsetInPages(unsafePosition.y, context.getPageSize().height, height)
4549
+ x: getClosestValidOffsetFromApproximateOffsetInPages(
4550
+ unsafePosition.x,
4551
+ context.getPageSize().width,
4552
+ width
4553
+ ),
4554
+ y: getClosestValidOffsetFromApproximateOffsetInPages(
4555
+ unsafePosition.y,
4556
+ context.getPageSize().height,
4557
+ height
4558
+ )
4171
4559
  };
4172
4560
  return adjustedPosition;
4173
4561
  };
@@ -4201,7 +4589,9 @@
4201
4589
  this.y = position.y;
4202
4590
  }
4203
4591
  }
4204
- const createNavigationResolver$1 = ({ context }) => {
4592
+ const createNavigationResolver$1 = ({
4593
+ context
4594
+ }) => {
4205
4595
  const spineItemLocator = createLocationResolver$1({ context });
4206
4596
  const getNavigationForLeftPage = (position, spineItem) => {
4207
4597
  let nextPotentialPosition = {
@@ -4240,20 +4630,33 @@
4240
4630
  const getNavigationForLastPage = (spineItem) => {
4241
4631
  if (spineItem.isUsingVerticalWriting()) {
4242
4632
  const pageHeight = context.getPageSize().height;
4243
- const numberOfPages = calculateNumberOfPagesForItem(spineItem.getElementDimensions().height, pageHeight);
4633
+ const numberOfPages = calculateNumberOfPagesForItem(
4634
+ spineItem.getElementDimensions().height,
4635
+ pageHeight
4636
+ );
4244
4637
  return getNavigationForPage(numberOfPages - 1, spineItem);
4245
4638
  } else {
4246
4639
  const pageWidth = context.getPageSize().width;
4247
- const numberOfPages = calculateNumberOfPagesForItem(spineItem.getElementDimensions().width, pageWidth);
4640
+ const numberOfPages = calculateNumberOfPagesForItem(
4641
+ spineItem.getElementDimensions().width,
4642
+ pageWidth
4643
+ );
4248
4644
  return getNavigationForPage(numberOfPages - 1, spineItem);
4249
4645
  }
4250
4646
  };
4251
4647
  const getNavigationForPage = (pageIndex, spineItem) => {
4252
- const { x, y } = spineItemLocator.getSpineItemPositionFromPageIndex(pageIndex, spineItem);
4648
+ const { x, y } = spineItemLocator.getSpineItemPositionFromPageIndex(
4649
+ pageIndex,
4650
+ spineItem
4651
+ );
4253
4652
  return new SpineItemNavigationPosition({ x, y });
4254
4653
  };
4255
4654
  const getNavigationFromNode = (spineItem, node, offset) => {
4256
- const position = spineItemLocator.getSpineItemPositionFromNode(node, offset, spineItem);
4655
+ const position = spineItemLocator.getSpineItemPositionFromNode(
4656
+ node,
4657
+ offset,
4658
+ spineItem
4659
+ );
4257
4660
  return new SpineItemNavigationPosition(position || { x: 0, y: 0 });
4258
4661
  };
4259
4662
  const getNavigationForPosition = (spineItem, position) => {
@@ -4287,8 +4690,12 @@
4287
4690
  `${NAMESPACE$3} wrapPositionWithSafeEdge`,
4288
4691
  1,
4289
4692
  (position) => {
4290
- const lastSpineItem = spineItemManager.get(spineItemManager.getLength() - 1);
4291
- const distanceOfLastSpineItem = spineItemManager.getAbsolutePositionOf(lastSpineItem || 0);
4693
+ const lastSpineItem = spineItemManager.get(
4694
+ spineItemManager.getLength() - 1
4695
+ );
4696
+ const distanceOfLastSpineItem = spineItemManager.getAbsolutePositionOf(
4697
+ lastSpineItem || 0
4698
+ );
4292
4699
  const maximumYOffset = distanceOfLastSpineItem.bottom - context.getPageSize().height;
4293
4700
  const y = Math.min(Math.max(0, position.y), maximumYOffset);
4294
4701
  if (context.isRTL()) {
@@ -4305,7 +4712,10 @@
4305
4712
  },
4306
4713
  { disable: true }
4307
4714
  );
4308
- const getAdjustedPositionForSpread = ({ x, y }) => {
4715
+ const getAdjustedPositionForSpread = ({
4716
+ x,
4717
+ y
4718
+ }) => {
4309
4719
  const isOffsetNotAtEdge = x % context.state.visibleAreaRect.width !== 0;
4310
4720
  const correctedX = isOffsetNotAtEdge ? x - context.getPageSize().width : x;
4311
4721
  return { x: correctedX, y };
@@ -4317,7 +4727,10 @@
4317
4727
  Report.warn(NAMESPACE$3, `unable to detect item id from cfi ${cfi}`);
4318
4728
  } else {
4319
4729
  const spineItemNavigation = node ? spineItemNavigator.getNavigationFromNode(spineItem, node, offset) : new SpineItemNavigationPosition({ x: 0, y: 0 });
4320
- const readingPosition = locator.getSpinePositionFromSpineItemPosition(spineItemNavigation, spineItem);
4730
+ const readingPosition = locator.getSpinePositionFromSpineItemPosition(
4731
+ spineItemNavigation,
4732
+ spineItem
4733
+ );
4321
4734
  return { ...getAdjustedPositionForSpread(readingPosition), spineItem };
4322
4735
  }
4323
4736
  return { x: 0, y: 0 };
@@ -4327,13 +4740,22 @@
4327
4740
  const xPositionForPageIndex = pageIndex * context.getPageSize().width;
4328
4741
  return getNavigationForPosition({ x: xPositionForPageIndex, y: 0 });
4329
4742
  }
4330
- const spineItemNavigation = spineItemNavigator.getNavigationForPage(pageIndex, spineItem);
4331
- const readingOffset = locator.getSpinePositionFromSpineItemPosition(spineItemNavigation, spineItem);
4743
+ const spineItemNavigation = spineItemNavigator.getNavigationForPage(
4744
+ pageIndex,
4745
+ spineItem
4746
+ );
4747
+ const readingOffset = locator.getSpinePositionFromSpineItemPosition(
4748
+ spineItemNavigation,
4749
+ spineItem
4750
+ );
4332
4751
  return getAdjustedPositionForSpread(readingOffset);
4333
4752
  };
4334
4753
  const getNavigationForLastPage = (spineItem) => {
4335
4754
  const spineItemNavigation = spineItemNavigator.getNavigationForLastPage(spineItem);
4336
- const position = locator.getSpinePositionFromSpineItemPosition(spineItemNavigation, spineItem);
4755
+ const position = locator.getSpinePositionFromSpineItemPosition(
4756
+ spineItemNavigation,
4757
+ spineItem
4758
+ );
4337
4759
  return getAdjustedPositionForSpread(position);
4338
4760
  };
4339
4761
  const getNavigationForSpineIndexOrId = (indexOrId) => {
@@ -4351,9 +4773,15 @@
4351
4773
  if (!spineItem) {
4352
4774
  return defaultNavigation;
4353
4775
  }
4354
- const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(position, spineItem);
4776
+ const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(
4777
+ position,
4778
+ spineItem
4779
+ );
4355
4780
  const spineItemNavigationForRightPage = spineItemNavigator.getNavigationForRightPage(spineItemPosition, spineItem);
4356
- const isNewNavigationInCurrentItem = arePositionsDifferent(spineItemNavigationForRightPage, spineItemPosition);
4781
+ const isNewNavigationInCurrentItem = arePositionsDifferent(
4782
+ spineItemNavigationForRightPage,
4783
+ spineItemPosition
4784
+ );
4357
4785
  if (!isNewNavigationInCurrentItem) {
4358
4786
  return wrapPositionWithSafeEdge(
4359
4787
  pageTurnDirection === `horizontal` ? { x: position.x + context.getPageSize().width, y: 0 } : { y: position.y + context.getPageSize().height, x: 0 }
@@ -4373,15 +4801,27 @@
4373
4801
  if (!spineItem) {
4374
4802
  return defaultNavigation;
4375
4803
  }
4376
- const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(position, spineItem);
4377
- const spineItemNavigation = spineItemNavigator.getNavigationForLeftPage(spineItemPosition, spineItem);
4378
- const isNewNavigationInCurrentItem = arePositionsDifferent(spineItemNavigation, spineItemPosition);
4804
+ const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(
4805
+ position,
4806
+ spineItem
4807
+ );
4808
+ const spineItemNavigation = spineItemNavigator.getNavigationForLeftPage(
4809
+ spineItemPosition,
4810
+ spineItem
4811
+ );
4812
+ const isNewNavigationInCurrentItem = arePositionsDifferent(
4813
+ spineItemNavigation,
4814
+ spineItemPosition
4815
+ );
4379
4816
  if (!isNewNavigationInCurrentItem) {
4380
4817
  return wrapPositionWithSafeEdge(
4381
4818
  pageTurnDirection === `horizontal` ? { x: position.x - context.getPageSize().width, y: 0 } : { y: position.y - context.getPageSize().height, x: 0 }
4382
4819
  );
4383
4820
  } else {
4384
- const readingOrderPosition = locator.getSpinePositionFromSpineItemPosition(spineItemNavigation, spineItem);
4821
+ const readingOrderPosition = locator.getSpinePositionFromSpineItemPosition(
4822
+ spineItemNavigation,
4823
+ spineItem
4824
+ );
4385
4825
  return readingOrderPosition;
4386
4826
  }
4387
4827
  };
@@ -4423,7 +4863,10 @@
4423
4863
  if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x !== navigation.x) {
4424
4864
  return getAdjustedPositionForSpread(
4425
4865
  wrapPositionWithSafeEdge(
4426
- context.isRTL() ? { ...navigation, x: navigation.x + context.getPageSize().width } : { ...navigation, x: navigation.x - context.getPageSize().width }
4866
+ context.isRTL() ? { ...navigation, x: navigation.x + context.getPageSize().width } : {
4867
+ ...navigation,
4868
+ x: navigation.x - context.getPageSize().width
4869
+ }
4427
4870
  )
4428
4871
  );
4429
4872
  }
@@ -4440,7 +4883,9 @@
4440
4883
  try {
4441
4884
  const validUrl = url instanceof URL ? url : new URL(url);
4442
4885
  const urlWithoutAnchor = `${validUrl.origin}${validUrl.pathname}`;
4443
- const existingSpineItem = (_a = context.manifest) == null ? void 0 : _a.spineItems.find((item) => item.href === urlWithoutAnchor);
4886
+ const existingSpineItem = (_a = context.manifest) == null ? void 0 : _a.spineItems.find(
4887
+ (item) => item.href === urlWithoutAnchor
4888
+ );
4444
4889
  if (existingSpineItem) {
4445
4890
  const spineItem = spineItemManager.get(existingSpineItem.id);
4446
4891
  if (spineItem) {
@@ -4455,15 +4900,27 @@
4455
4900
  }
4456
4901
  };
4457
4902
  const getNavigationForAnchor = (anchor, spineItem) => {
4458
- const position = locator.getSpinePositionFromSpineItemAnchor(anchor, spineItem);
4903
+ const position = locator.getSpinePositionFromSpineItemAnchor(
4904
+ anchor,
4905
+ spineItem
4906
+ );
4459
4907
  return getAdjustedPositionForSpread(position);
4460
4908
  };
4461
4909
  const getNavigationForPosition = (viewportPosition) => {
4462
4910
  const spineItem = locator.getSpineItemFromPosition(viewportPosition);
4463
4911
  if (spineItem) {
4464
- const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(viewportPosition, spineItem);
4465
- const spineItemValidPosition = spineItemNavigator.getNavigationForPosition(spineItem, spineItemPosition);
4466
- const viewportNavigation = locator.getSpinePositionFromSpineItemPosition(spineItemValidPosition, spineItem);
4912
+ const spineItemPosition = locator.getSpineItemPositionFromSpinePosition(
4913
+ viewportPosition,
4914
+ spineItem
4915
+ );
4916
+ const spineItemValidPosition = spineItemNavigator.getNavigationForPosition(
4917
+ spineItem,
4918
+ spineItemPosition
4919
+ );
4920
+ const viewportNavigation = locator.getSpinePositionFromSpineItemPosition(
4921
+ spineItemValidPosition,
4922
+ spineItem
4923
+ );
4467
4924
  return getAdjustedPositionForSpread(viewportNavigation);
4468
4925
  }
4469
4926
  return { x: 0, y: 0 };
@@ -4473,7 +4930,10 @@
4473
4930
  const triggerPercentage = 0.5;
4474
4931
  const triggerXPosition = pageTurnDirection === `horizontal` ? viewportPosition.x + context.state.visibleAreaRect.width * triggerPercentage : 0;
4475
4932
  const triggerYPosition = pageTurnDirection === `horizontal` ? 0 : viewportPosition.y + context.state.visibleAreaRect.height * triggerPercentage;
4476
- const midScreenPositionSafePosition = wrapPositionWithSafeEdge({ x: triggerXPosition, y: triggerYPosition });
4933
+ const midScreenPositionSafePosition = wrapPositionWithSafeEdge({
4934
+ x: triggerXPosition,
4935
+ y: triggerYPosition
4936
+ });
4477
4937
  return getNavigationForPosition(midScreenPositionSafePosition);
4478
4938
  };
4479
4939
  const isNavigationGoingForwardFrom = (to, from) => {
@@ -4568,7 +5028,10 @@
4568
5028
  };
4569
5029
  const getCurrentViewportPosition = () => {
4570
5030
  var _a, _b;
4571
- return getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 });
5031
+ return getScaledDownPosition({
5032
+ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0,
5033
+ y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0
5034
+ });
4572
5035
  };
4573
5036
  const navigationOnScroll$ = userScroll$.pipe(
4574
5037
  operators.debounceTime(SCROLL_FINISHED_DEBOUNCE_TIMEOUT, rxjs.animationFrameScheduler),
@@ -4576,9 +5039,16 @@
4576
5039
  operators.switchMap(() => {
4577
5040
  var _a, _b;
4578
5041
  const navigation = getNavigationForPosition(
4579
- getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 })
5042
+ getScaledDownPosition({
5043
+ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0,
5044
+ y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0
5045
+ })
4580
5046
  );
4581
- return rxjs.of({ position: navigation, animate: false, lastUserExpectedNavigation: void 0 });
5047
+ return rxjs.of({
5048
+ position: navigation,
5049
+ animate: false,
5050
+ lastUserExpectedNavigation: void 0
5051
+ });
4582
5052
  }),
4583
5053
  operators.share()
4584
5054
  );
@@ -4616,16 +5086,29 @@
4616
5086
  }) => {
4617
5087
  const stateSubject$ = new rxjs.BehaviorSubject(`end`);
4618
5088
  const navigationTriggerSubject$ = new rxjs.Subject();
4619
- const turnLeft = ({ allowSpineItemChange = true } = {}) => navigationTriggerSubject$.next({ type: `leftPage`, data: { allowSpineItemChange } });
4620
- const turnRight = ({ allowSpineItemChange = true } = {}) => {
4621
- navigationTriggerSubject$.next({ type: `rightPage`, data: { allowSpineItemChange } });
5089
+ const turnLeft = ({
5090
+ allowSpineItemChange = true
5091
+ } = {}) => navigationTriggerSubject$.next({
5092
+ type: `leftPage`,
5093
+ data: { allowSpineItemChange }
5094
+ });
5095
+ const turnRight = ({
5096
+ allowSpineItemChange = true
5097
+ } = {}) => {
5098
+ navigationTriggerSubject$.next({
5099
+ type: `rightPage`,
5100
+ data: { allowSpineItemChange }
5101
+ });
4622
5102
  };
4623
5103
  const goToPageOfCurrentChapter = (pageIndex) => navigationTriggerSubject$.next({ type: `chapterPage`, data: { pageIndex } });
4624
5104
  const goToPage = (pageIndex) => navigationTriggerSubject$.next({ type: `pageIndex`, data: { pageIndex } });
4625
5105
  const goToCfi = (cfi, options = { animate: true }) => navigationTriggerSubject$.next({ type: `cfi`, data: { cfi, ...options } });
4626
5106
  const goToUrl = (url) => navigationTriggerSubject$.next({ type: `url`, data: url });
4627
5107
  const goToSpineItem = (indexOrId, options = { animate: true }) => {
4628
- navigationTriggerSubject$.next({ type: `spineItem`, data: { indexOrId, ...options } });
5108
+ navigationTriggerSubject$.next({
5109
+ type: `spineItem`,
5110
+ data: { indexOrId, ...options }
5111
+ });
4629
5112
  };
4630
5113
  const urlNavigation$ = navigationTriggerSubject$.pipe(
4631
5114
  operators.filter((e) => e.type === `url`),
@@ -4636,7 +5119,10 @@
4636
5119
  return rxjs.of({
4637
5120
  ...navigation,
4638
5121
  animate: true,
4639
- lastUserExpectedNavigation: { type: `navigate-from-anchor`, data: navigation.url.hash }
5122
+ lastUserExpectedNavigation: {
5123
+ type: `navigate-from-anchor`,
5124
+ data: navigation.url.hash
5125
+ }
4640
5126
  });
4641
5127
  }
4642
5128
  return rxjs.EMPTY;
@@ -4646,7 +5132,9 @@
4646
5132
  operators.filter((e) => e.type === `spineItem`),
4647
5133
  operators.switchMap(({ data: { animate, indexOrId } }) => {
4648
5134
  const navigation = navigator2.getNavigationForSpineIndexOrId(indexOrId);
4649
- const lastUserExpectedNavigation = { type: `navigate-from-previous-item` };
5135
+ const lastUserExpectedNavigation = {
5136
+ type: `navigate-from-previous-item`
5137
+ };
4650
5138
  Report.log(NAMESPACE$2, `goToSpineItem`, { indexOrId, animate, navigation });
4651
5139
  return rxjs.of({ ...navigation, animate, lastUserExpectedNavigation });
4652
5140
  })
@@ -4659,7 +5147,10 @@
4659
5147
  return {
4660
5148
  ...navigation,
4661
5149
  animate,
4662
- lastUserExpectedNavigation: { type: `navigate-from-cfi`, data: cfi }
5150
+ lastUserExpectedNavigation: {
5151
+ type: `navigate-from-cfi`,
5152
+ data: cfi
5153
+ }
4663
5154
  };
4664
5155
  })
4665
5156
  );
@@ -4669,7 +5160,11 @@
4669
5160
  const spineItem = spineItemManager.getFocusedSpineItem();
4670
5161
  if (spineItem) {
4671
5162
  const navigation = navigator2.getNavigationForPage(pageIndex, spineItem);
4672
- return rxjs.of({ ...navigation, lastUserExpectedNavigation: void 0, animate: true });
5163
+ return rxjs.of({
5164
+ ...navigation,
5165
+ lastUserExpectedNavigation: void 0,
5166
+ animate: true
5167
+ });
4673
5168
  }
4674
5169
  return rxjs.EMPTY;
4675
5170
  })
@@ -4702,26 +5197,31 @@
4702
5197
  const spineItemHasChanged = newSpineItem !== currentSpineItem;
4703
5198
  if (spineItemHasChanged) {
4704
5199
  if (allowSpineItemChange) {
4705
- const positionOfNewSpineItemComparedToCurrentOne = spineItemManager.comparePositionOf(
4706
- newSpineItem,
4707
- currentSpineItem
4708
- );
5200
+ const positionOfNewSpineItemComparedToCurrentOne = spineItemManager.comparePositionOf(newSpineItem, currentSpineItem);
4709
5201
  if (positionOfNewSpineItemComparedToCurrentOne === `before`) {
4710
5202
  return rxjs.of({
4711
5203
  ...navigation,
4712
- lastUserExpectedNavigation: { type: `navigate-from-next-item` },
5204
+ lastUserExpectedNavigation: {
5205
+ type: `navigate-from-next-item`
5206
+ },
4713
5207
  animate: true
4714
5208
  });
4715
5209
  } else {
4716
5210
  return rxjs.of({
4717
5211
  ...navigation,
4718
- lastUserExpectedNavigation: { type: `navigate-from-previous-item` },
5212
+ lastUserExpectedNavigation: {
5213
+ type: `navigate-from-previous-item`
5214
+ },
4719
5215
  animate: true
4720
5216
  });
4721
5217
  }
4722
5218
  }
4723
5219
  } else {
4724
- return rxjs.of({ ...navigation, lastUserExpectedNavigation: void 0, animate: true });
5220
+ return rxjs.of({
5221
+ ...navigation,
5222
+ lastUserExpectedNavigation: void 0,
5223
+ animate: true
5224
+ });
4725
5225
  }
4726
5226
  return rxjs.EMPTY;
4727
5227
  }
@@ -4737,7 +5237,11 @@
4737
5237
  currentNavigation
4738
5238
  ]) => {
4739
5239
  const navigation = navigator2.getNavigationForLeftPage(currentNavigation);
4740
- Report.log(NAMESPACE$2, `turnLeft`, { currentNavigation, navigation, allowSpineItemChange });
5240
+ Report.log(NAMESPACE$2, `turnLeft`, {
5241
+ currentNavigation,
5242
+ navigation,
5243
+ allowSpineItemChange
5244
+ });
4741
5245
  return turnPageTo$(navigation, { allowSpineItemChange });
4742
5246
  }
4743
5247
  )
@@ -4753,7 +5257,11 @@
4753
5257
  currentNavigation
4754
5258
  ]) => {
4755
5259
  const navigation = navigator2.getNavigationForRightPage(currentNavigation);
4756
- Report.log(NAMESPACE$2, `turnRight`, { currentNavigation, navigation, allowSpineItemChange });
5260
+ Report.log(NAMESPACE$2, `turnRight`, {
5261
+ currentNavigation,
5262
+ navigation,
5263
+ allowSpineItemChange
5264
+ });
4757
5265
  return turnPageTo$(navigation, { allowSpineItemChange });
4758
5266
  }
4759
5267
  )
@@ -4773,7 +5281,9 @@
4773
5281
  * navigation would theoretically always move to different items.
4774
5282
  */
4775
5283
  operators.withLatestFrom(currentNavigationSubject$),
4776
- operators.filter(([navigation, currentNavigation]) => navigator2.areNavigationDifferent(navigation, currentNavigation)),
5284
+ operators.filter(
5285
+ ([navigation, currentNavigation]) => navigator2.areNavigationDifferent(navigation, currentNavigation)
5286
+ ),
4777
5287
  operators.map(([navigation]) => navigation)
4778
5288
  );
4779
5289
  return {
@@ -4864,7 +5374,10 @@
4864
5374
  const spineItemHasChanged = newSpineItem !== currentSpineItem;
4865
5375
  if (spineItemHasChanged) {
4866
5376
  if (allowSpineItemChange) {
4867
- if (spineItemManager.comparePositionOf(newSpineItem, currentSpineItem) === `before`) {
5377
+ if (spineItemManager.comparePositionOf(
5378
+ newSpineItem,
5379
+ currentSpineItem
5380
+ ) === `before`) {
4868
5381
  return { type: `navigate-from-next-item` };
4869
5382
  } else {
4870
5383
  return { type: `navigate-from-previous-item` };
@@ -4894,7 +5407,9 @@
4894
5407
  x: triggerXPosition,
4895
5408
  y: triggerYPosition
4896
5409
  });
4897
- const finalNavigation = navigator2.getNavigationForPosition(midScreenPositionSafePosition);
5410
+ const finalNavigation = navigator2.getNavigationForPosition(
5411
+ midScreenPositionSafePosition
5412
+ );
4898
5413
  const lastUserExpectedNavigation = getLastUserExpectedNavigation(finalNavigation);
4899
5414
  return rxjs.of({ ...finalNavigation, lastUserExpectedNavigation });
4900
5415
  }
@@ -4946,23 +5461,30 @@
4946
5461
  locator: spineLocator
4947
5462
  });
4948
5463
  const adjustNavigationSubject$ = new rxjs.Subject();
4949
- const getCurrentViewportPosition = Report.measurePerformance(`${NAMESPACE} getCurrentViewportPosition`, 1, () => {
4950
- var _a;
4951
- if (settings.settings.computedPageTurnMode === `scrollable`) {
4952
- return scrollViewportNavigator.getCurrentViewportPosition();
5464
+ const getCurrentViewportPosition = Report.measurePerformance(
5465
+ `${NAMESPACE} getCurrentViewportPosition`,
5466
+ 1,
5467
+ () => {
5468
+ var _a;
5469
+ if (settings.settings.computedPageTurnMode === `scrollable`) {
5470
+ return scrollViewportNavigator.getCurrentViewportPosition();
5471
+ }
5472
+ const { x, y } = ((_a = element$.getValue()) == null ? void 0 : _a.getBoundingClientRect()) ?? {
5473
+ x: 0,
5474
+ y: 0
5475
+ };
5476
+ const newValue = {
5477
+ // we want to round to first decimal because it's possible to have half pixel
5478
+ // however browser engine can also gives back x.yyyy based on their precision
5479
+ // @see https://stackoverflow.com/questions/13847053/difference-between-and-math-floor for ~~
5480
+ x: ~~(x * -1 * 10) / 10,
5481
+ // x: ~~(x * 10) / 10,
5482
+ y: ~~(Math.abs(y) * 10) / 10
5483
+ };
5484
+ currentViewportPositionMemoUnused = newValue;
5485
+ return currentViewportPositionMemoUnused;
4953
5486
  }
4954
- const { x, y } = ((_a = element$.getValue()) == null ? void 0 : _a.getBoundingClientRect()) ?? { x: 0, y: 0 };
4955
- const newValue = {
4956
- // we want to round to first decimal because it's possible to have half pixel
4957
- // however browser engine can also gives back x.yyyy based on their precision
4958
- // @see https://stackoverflow.com/questions/13847053/difference-between-and-math-floor for ~~
4959
- x: ~~(x * -1 * 10) / 10,
4960
- // x: ~~(x * 10) / 10,
4961
- y: ~~(Math.abs(y) * 10) / 10
4962
- };
4963
- currentViewportPositionMemoUnused = newValue;
4964
- return currentViewportPositionMemoUnused;
4965
- });
5487
+ );
4966
5488
  const panViewportNavigator = createPanViewportNavigator({
4967
5489
  context,
4968
5490
  settings,
@@ -4988,8 +5510,14 @@
4988
5510
  spineItemManager,
4989
5511
  locator: spineLocator
4990
5512
  });
4991
- const viewportNavigators = [scrollViewportNavigator, panViewportNavigator, manualViewportNavigator];
4992
- const viewportNavigatorsSharedState$ = rxjs.merge(...viewportNavigators.map(({ $: { state$: state$2 } }) => state$2));
5513
+ const viewportNavigators = [
5514
+ scrollViewportNavigator,
5515
+ panViewportNavigator,
5516
+ manualViewportNavigator
5517
+ ];
5518
+ const viewportNavigatorsSharedState$ = rxjs.merge(
5519
+ ...viewportNavigators.map(({ $: { state$: state$2 } }) => state$2)
5520
+ );
4993
5521
  let lastUserExpectedNavigation;
4994
5522
  const makeItHot = (source$) => {
4995
5523
  source$.pipe(operators.takeUntil(context.destroy$)).subscribe();
@@ -5017,28 +5545,51 @@
5017
5545
  let adjustedSpinePosition = currentNavigationPositionSubject$.value;
5018
5546
  const offsetInSpineItem = 0;
5019
5547
  if (settings.settings.computedPageTurnMode === `scrollable`) {
5020
- adjustedSpinePosition = scrollViewportNavigator.getNavigationForPosition(getCurrentViewportPosition());
5548
+ adjustedSpinePosition = scrollViewportNavigator.getNavigationForPosition(
5549
+ getCurrentViewportPosition()
5550
+ );
5021
5551
  } else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-cfi`) {
5022
- adjustedSpinePosition = navigator2.getNavigationForCfi(lastUserExpectedNavigation.data);
5023
- Report.log(NAMESPACE, `adjustNavigation`, `navigate-from-cfi`, `use last cfi`);
5552
+ adjustedSpinePosition = navigator2.getNavigationForCfi(
5553
+ lastUserExpectedNavigation.data
5554
+ );
5555
+ Report.log(
5556
+ NAMESPACE,
5557
+ `adjustNavigation`,
5558
+ `navigate-from-cfi`,
5559
+ `use last cfi`
5560
+ );
5024
5561
  } else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-next-item`) {
5025
5562
  adjustedSpinePosition = navigator2.getNavigationForLastPage(spineItem);
5026
5563
  Report.log(NAMESPACE, `adjustNavigation`, `navigate-from-next-item`, {});
5027
5564
  } else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-previous-item`) {
5028
5565
  adjustedSpinePosition = navigator2.getNavigationForPage(0, spineItem);
5029
- Report.log(NAMESPACE, `adjustNavigation`, `navigate-from-previous-item`, {});
5566
+ Report.log(
5567
+ NAMESPACE,
5568
+ `adjustNavigation`,
5569
+ `navigate-from-previous-item`,
5570
+ {}
5571
+ );
5030
5572
  } else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-anchor`) {
5031
5573
  const anchor = lastUserExpectedNavigation.data;
5032
- adjustedSpinePosition = navigator2.getNavigationForAnchor(anchor, spineItem);
5574
+ adjustedSpinePosition = navigator2.getNavigationForAnchor(
5575
+ anchor,
5576
+ spineItem
5577
+ );
5033
5578
  } else if (lastCfi) {
5034
5579
  adjustedSpinePosition = navigator2.getNavigationForCfi(lastCfi);
5035
5580
  Report.log(NAMESPACE, `adjustNavigation`, `use last cfi`);
5036
5581
  } else {
5037
5582
  const currentPageIndex = pagination.getPaginationInfo().beginPageIndexInSpineItem || 0;
5038
- adjustedSpinePosition = navigator2.getNavigationForPage(currentPageIndex, spineItem);
5583
+ adjustedSpinePosition = navigator2.getNavigationForPage(
5584
+ currentPageIndex,
5585
+ spineItem
5586
+ );
5039
5587
  Report.log(NAMESPACE, `adjustNavigation`, `use guess strategy`, {});
5040
5588
  }
5041
- const areDifferent = navigator2.arePositionsDifferent(adjustedSpinePosition, currentNavigationPositionSubject$.value);
5589
+ const areDifferent = navigator2.arePositionsDifferent(
5590
+ adjustedSpinePosition,
5591
+ currentNavigationPositionSubject$.value
5592
+ );
5042
5593
  Report.log(NAMESPACE, `adjustNavigation`, {
5043
5594
  areDifferent,
5044
5595
  offsetInSpineItem,
@@ -5062,7 +5613,11 @@
5062
5613
  currentViewportPositionMemoUnused = void 0;
5063
5614
  });
5064
5615
  const layoutChangeSettings$ = settings.settings$.pipe(
5065
- mapKeysTo([`computedPageTurnDirection`, `computedPageTurnMode`, `numberOfAdjacentSpineItemToPreLoad`]),
5616
+ mapKeysTo([
5617
+ `computedPageTurnDirection`,
5618
+ `computedPageTurnMode`,
5619
+ `numberOfAdjacentSpineItemToPreLoad`
5620
+ ]),
5066
5621
  operators.distinctUntilChanged(isShallowEqual),
5067
5622
  operators.skip(1)
5068
5623
  );
@@ -5174,10 +5729,16 @@
5174
5729
  const noAdjustmentNeeded = false;
5175
5730
  if (data.shouldAnimate && !noAdjustmentNeeded) {
5176
5731
  if (pageTurnAnimation === `fade`) {
5177
- element$.getValue().style.setProperty(`transition`, `opacity ${animationDuration / 2}ms`);
5732
+ element$.getValue().style.setProperty(
5733
+ `transition`,
5734
+ `opacity ${animationDuration / 2}ms`
5735
+ );
5178
5736
  element$.getValue().style.setProperty(`opacity`, `0`);
5179
5737
  } else if (currentEvent.animation === `snap` || pageTurnAnimation === `slide`) {
5180
- element$.getValue().style.setProperty(`transition`, `transform ${animationDuration}ms`);
5738
+ element$.getValue().style.setProperty(
5739
+ `transition`,
5740
+ `transform ${animationDuration}ms`
5741
+ );
5181
5742
  element$.getValue().style.setProperty(`opacity`, `1`);
5182
5743
  }
5183
5744
  } else {
@@ -5226,8 +5787,13 @@
5226
5787
  rxjs.merge(manualAdjust$).pipe(operators.map(() => `start`)),
5227
5788
  rxjs.merge(processManualAdjust$).pipe(operators.map(() => `end`))
5228
5789
  );
5229
- const state$ = rxjs.combineLatest([...viewportNavigators.map(({ $: { state$: state$2 } }) => state$2), adjustmentState$]).pipe(
5230
- operators.map((states) => states.every((state) => state === `end`) ? `free` : `busy`),
5790
+ const state$ = rxjs.combineLatest([
5791
+ ...viewportNavigators.map(({ $: { state$: state$2 } }) => state$2),
5792
+ adjustmentState$
5793
+ ]).pipe(
5794
+ operators.map(
5795
+ (states) => states.every((state) => state === `end`) ? `free` : `busy`
5796
+ ),
5231
5797
  operators.distinctUntilChanged(),
5232
5798
  operators.shareReplay(1),
5233
5799
  /**
@@ -5317,7 +5883,9 @@
5317
5883
  position: relative;
5318
5884
  `;
5319
5885
  element.className = `${HTML_PREFIX$1}-viewport-navigator`;
5320
- hookManager.execute("viewportNavigator.onBeforeContainerCreated", void 0, { element });
5886
+ hookManager.execute("viewportNavigator.onBeforeContainerCreated", void 0, {
5887
+ element
5888
+ });
5321
5889
  return element;
5322
5890
  };
5323
5891
  const createLocationResolver = ({
@@ -5376,8 +5944,14 @@
5376
5944
  return getSpinePositionFromSpineItemPosition({ x: 0, y: 0 }, spineItem);
5377
5945
  };
5378
5946
  const getSpinePositionFromSpineItemAnchor = (anchor, spineItem) => {
5379
- const spineItemOffset = spineItemLocator.getSpineItemOffsetFromAnchor(anchor, spineItem);
5380
- const position = getSpinePositionFromSpineItemPosition({ x: spineItemOffset, y: 0 }, spineItem);
5947
+ const spineItemOffset = spineItemLocator.getSpineItemOffsetFromAnchor(
5948
+ anchor,
5949
+ spineItem
5950
+ );
5951
+ const position = getSpinePositionFromSpineItemPosition(
5952
+ { x: spineItemOffset, y: 0 },
5953
+ spineItem
5954
+ );
5381
5955
  return position;
5382
5956
  };
5383
5957
  const getSpineItemsFromReadingOrderPosition = (position) => {
@@ -5386,7 +5960,10 @@
5386
5960
  if (itemAtPositionIndex === void 0) return void 0;
5387
5961
  let endPosition = position;
5388
5962
  if (context.state.isUsingSpreadMode) {
5389
- endPosition = { x: position.x + context.getPageSize().width, y: position.y };
5963
+ endPosition = {
5964
+ x: position.x + context.getPageSize().width,
5965
+ y: position.y
5966
+ };
5390
5967
  }
5391
5968
  const endItemIndex = spineItemManager.getSpineItemIndex(
5392
5969
  getSpineItemFromPosition(endPosition) || spineItemManager.getFocusedSpineItem()
@@ -5414,9 +5991,17 @@
5414
5991
  const getSpineItemPageIndexFromNode = (node, offset, spineItemOrIndex) => {
5415
5992
  if (typeof spineItemOrIndex === `number`) {
5416
5993
  const spineItem = spineItemManager.get(spineItemOrIndex);
5417
- return spineItem ? spineItemLocator.getSpineItemPageIndexFromNode(node, offset || 0, spineItem) : void 0;
5994
+ return spineItem ? spineItemLocator.getSpineItemPageIndexFromNode(
5995
+ node,
5996
+ offset || 0,
5997
+ spineItem
5998
+ ) : void 0;
5418
5999
  }
5419
- return spineItemLocator.getSpineItemPageIndexFromNode(node, offset || 0, spineItemOrIndex);
6000
+ return spineItemLocator.getSpineItemPageIndexFromNode(
6001
+ node,
6002
+ offset || 0,
6003
+ spineItemOrIndex
6004
+ );
5420
6005
  };
5421
6006
  return {
5422
6007
  getSpinePositionFromSpineItemPosition,
@@ -5434,18 +6019,29 @@
5434
6019
  spineItemLocator
5435
6020
  }) => {
5436
6021
  const getItemAnchor = (spineItem) => `|[prose~anchor~${encodeURIComponent(spineItem.item.id)}]`;
5437
- const getCfi = Report.measurePerformance(`getCfi`, 10, (pageIndex, spineItem) => {
5438
- var _a, _b, _c;
5439
- const nodeOrRange = spineItemLocator.getFirstNodeOrRangeAtPage(pageIndex, spineItem);
5440
- const doc = (_c = (_b = (_a = spineItem.spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.frame) == null ? void 0 : _b.contentWindow) == null ? void 0 : _c.document;
5441
- const itemAnchor = getItemAnchor(spineItem);
5442
- const offset = `|[prose~offset~${(nodeOrRange == null ? void 0 : nodeOrRange.offset) || 0}]`;
5443
- if (nodeOrRange && doc) {
5444
- const cfiString = CFI.generate(nodeOrRange.node, 0, `${itemAnchor}${offset}`);
5445
- return cfiString;
6022
+ const getCfi = Report.measurePerformance(
6023
+ `getCfi`,
6024
+ 10,
6025
+ (pageIndex, spineItem) => {
6026
+ var _a, _b, _c;
6027
+ const nodeOrRange = spineItemLocator.getFirstNodeOrRangeAtPage(
6028
+ pageIndex,
6029
+ spineItem
6030
+ );
6031
+ const doc = (_c = (_b = (_a = spineItem.spineItemFrame.getManipulableFrame()) == null ? void 0 : _a.frame) == null ? void 0 : _b.contentWindow) == null ? void 0 : _c.document;
6032
+ const itemAnchor = getItemAnchor(spineItem);
6033
+ const offset = `|[prose~offset~${(nodeOrRange == null ? void 0 : nodeOrRange.offset) || 0}]`;
6034
+ if (nodeOrRange && doc) {
6035
+ const cfiString = CFI.generate(
6036
+ nodeOrRange.node,
6037
+ 0,
6038
+ `${itemAnchor}${offset}`
6039
+ );
6040
+ return cfiString;
6041
+ }
6042
+ return getRootCfi(spineItem);
5446
6043
  }
5447
- return getRootCfi(spineItem);
5448
- });
6044
+ );
5449
6045
  const getRootCfi = (spineItem) => {
5450
6046
  const itemAnchor = getItemAnchor(spineItem);
5451
6047
  return `epubcfi(/0${itemAnchor}) `;
@@ -5492,9 +6088,22 @@
5492
6088
  spineItemIndex
5493
6089
  };
5494
6090
  };
5495
- const generateFromRange = ({ startNode, start, end, endNode }, item) => {
5496
- const startCFI = CFI.generate(startNode, start, `|[prose~anchor~${encodeURIComponent(item.id)}]`);
5497
- const endCFI = CFI.generate(endNode, end, `|[prose~anchor~${encodeURIComponent(item.id)}]`);
6091
+ const generateFromRange = ({
6092
+ startNode,
6093
+ start,
6094
+ end,
6095
+ endNode
6096
+ }, item) => {
6097
+ const startCFI = CFI.generate(
6098
+ startNode,
6099
+ start,
6100
+ `|[prose~anchor~${encodeURIComponent(item.id)}]`
6101
+ );
6102
+ const endCFI = CFI.generate(
6103
+ endNode,
6104
+ end,
6105
+ `|[prose~anchor~${encodeURIComponent(item.id)}]`
6106
+ );
5498
6107
  return { start: startCFI, end: endCFI };
5499
6108
  };
5500
6109
  return {
@@ -5506,93 +6115,124 @@
5506
6115
  generateFromRange
5507
6116
  };
5508
6117
  };
5509
- const getComputedSettings = (settings, context) => {
5510
- const manifest = context.manifest;
5511
- const hasVerticalWriting = context.state.hasVerticalWriting ?? false;
5512
- const computedSettings = {
5513
- computedPageTurnDirection: settings.pageTurnDirection,
5514
- computedPageTurnAnimation: settings.pageTurnAnimation,
5515
- computedPageTurnMode: `controlled`,
5516
- computedPageTurnAnimationDuration: 0
5517
- };
5518
- if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) {
5519
- computedSettings.computedPageTurnMode = `scrollable`;
5520
- computedSettings.computedPageTurnDirection = `vertical`;
5521
- } else if (manifest && settings.pageTurnMode === `scrollable` && (manifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(manifest))) {
5522
- Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
5523
- computedSettings.computedPageTurnAnimation = `none`;
5524
- computedSettings.computedPageTurnMode = `controlled`;
5525
- } else if (settings.pageTurnMode === `scrollable`) {
5526
- computedSettings.computedPageTurnMode = `scrollable`;
5527
- computedSettings.computedPageTurnDirection = `vertical`;
5528
- }
5529
- if (hasVerticalWriting && computedSettings.computedPageTurnAnimation === `slide`) {
5530
- Report.warn(
5531
- `pageTurnAnimation ${computedSettings.computedPageTurnAnimation} incompatible with current book, switching back to default`
5532
- );
5533
- computedSettings.computedPageTurnAnimation = `none`;
5534
- }
5535
- if (computedSettings.computedPageTurnMode === `scrollable`) {
5536
- computedSettings.computedPageTurnAnimationDuration = 0;
5537
- computedSettings.computedPageTurnAnimation = `none`;
5538
- } else {
5539
- computedSettings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
5540
- }
5541
- return computedSettings;
5542
- };
5543
- const defaultSettings = {
5544
- forceSinglePageMode: false,
5545
- pageTurnAnimation: `none`,
5546
- // computedPageTurnAnimation: `none`,
5547
- pageTurnDirection: `horizontal`,
5548
- // computedPageTurnDirection: `horizontal`,
5549
- pageTurnAnimationDuration: void 0,
5550
- // computedPageTurnAnimationDuration: 0,
5551
- pageTurnMode: `controlled`,
5552
- // computedPageTurnMode: `controlled`,
5553
- snapAnimationDuration: 300,
5554
- navigationSnapThreshold: 0.3,
5555
- numberOfAdjacentSpineItemToPreLoad: 0
5556
- };
5557
6118
  class SettingsManager {
5558
- constructor(initialSettings, context) {
5559
- this._context = context;
6119
+ constructor(initialSettings) {
5560
6120
  const settingsWithDefaults = {
5561
- ...defaultSettings,
6121
+ ...this.getDefaultSettings(),
5562
6122
  ...initialSettings
5563
6123
  };
5564
- const computedSettings = getComputedSettings(settingsWithDefaults, context);
5565
- const settings = { ...settingsWithDefaults, ...computedSettings };
5566
- this._settingsSubject$ = new rxjs.BehaviorSubject(settings);
5567
- this.settings$ = this._settingsSubject$.asObservable().pipe(operators.distinctUntilChanged(isShallowEqual));
5568
- const recomputeSettingsOnContextChange$ = rxjs.combineLatest([context.hasVerticalWriting$, context.manifest$]).pipe(
6124
+ this.inputSettings = settingsWithDefaults;
6125
+ this.outputSettingsUpdateSubject = new rxjs.Subject();
6126
+ this.settings$ = this.outputSettingsUpdateSubject.asObservable().pipe(operators.shareReplay(1));
6127
+ this.settings$.subscribe();
6128
+ }
6129
+ _prepareUpdate(settings) {
6130
+ const newInputSettings = shallowMergeIfDefined(this.inputSettings, settings);
6131
+ const state = this.getOutputSettings(newInputSettings);
6132
+ const hasChanged = !isShallowEqual(this.outputSettings, state);
6133
+ return {
6134
+ hasChanged,
6135
+ state,
6136
+ commit: () => {
6137
+ this.inputSettings = newInputSettings;
6138
+ this.outputSettings = state;
6139
+ if (hasChanged) {
6140
+ this.outputSettingsUpdateSubject.next(state);
6141
+ }
6142
+ return state;
6143
+ }
6144
+ };
6145
+ }
6146
+ update(settings) {
6147
+ const { commit } = this._prepareUpdate(settings);
6148
+ commit();
6149
+ }
6150
+ get settings() {
6151
+ if (!this.outputSettings) {
6152
+ const { commit } = this._prepareUpdate(this.inputSettings);
6153
+ return commit();
6154
+ }
6155
+ return this.outputSettings;
6156
+ }
6157
+ destroy() {
6158
+ this.outputSettingsUpdateSubject.complete();
6159
+ }
6160
+ }
6161
+ class ReaderSettingsManager extends SettingsManager {
6162
+ constructor(initialSettings, context) {
6163
+ super(initialSettings);
6164
+ this.context = context;
6165
+ const recomputeSettingsOnContextChange$ = rxjs.combineLatest([
6166
+ context.hasVerticalWriting$,
6167
+ context.manifest$
6168
+ ]).pipe(
5569
6169
  operators.tap(() => {
5570
- this._updateSettings(this.settings);
6170
+ this.update(this.settings);
5571
6171
  })
5572
6172
  );
5573
- const updateContextOnSettingsChanges$ = this._settingsSubject$.pipe(
6173
+ const updateContextOnSettingsChanges$ = this.settings$.pipe(
5574
6174
  operators.tap(({ forceSinglePageMode }) => {
5575
6175
  context.update({ forceSinglePageMode });
5576
6176
  })
5577
6177
  );
5578
6178
  rxjs.merge(recomputeSettingsOnContextChange$, updateContextOnSettingsChanges$).pipe(operators.takeUntil(context.destroy$)).subscribe();
6179
+ this.settings$.subscribe();
5579
6180
  }
5580
- // @see https://github.com/microsoft/TypeScript/issues/17293
5581
- _updateSettings(settings) {
5582
- const computed = getComputedSettings(settings, this._context);
5583
- const newMergedSettings = { ...settings, ...computed };
5584
- this._settingsSubject$.next(newMergedSettings);
5585
- }
5586
- setSettings(settings) {
5587
- if (Object.keys(settings).length === 0) return;
5588
- const newMergedSettings = { ...this._settingsSubject$.value, ...settings };
5589
- this._updateSettings(newMergedSettings);
6181
+ getComputedSettings(settings) {
6182
+ const manifest = this.context.manifest;
6183
+ const hasVerticalWriting = this.context.state.hasVerticalWriting ?? false;
6184
+ const computedSettings = {
6185
+ computedPageTurnDirection: settings.pageTurnDirection,
6186
+ computedPageTurnAnimation: settings.pageTurnAnimation,
6187
+ computedPageTurnMode: `controlled`,
6188
+ computedPageTurnAnimationDuration: 0
6189
+ };
6190
+ if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) {
6191
+ computedSettings.computedPageTurnMode = `scrollable`;
6192
+ computedSettings.computedPageTurnDirection = `vertical`;
6193
+ } else if (manifest && settings.pageTurnMode === `scrollable` && (manifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(manifest))) {
6194
+ Report.warn(
6195
+ `pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`
6196
+ );
6197
+ computedSettings.computedPageTurnAnimation = `none`;
6198
+ computedSettings.computedPageTurnMode = `controlled`;
6199
+ } else if (settings.pageTurnMode === `scrollable`) {
6200
+ computedSettings.computedPageTurnMode = `scrollable`;
6201
+ computedSettings.computedPageTurnDirection = `vertical`;
6202
+ }
6203
+ if (hasVerticalWriting && computedSettings.computedPageTurnAnimation === `slide`) {
6204
+ Report.warn(
6205
+ `pageTurnAnimation ${computedSettings.computedPageTurnAnimation} incompatible with current book, switching back to default`
6206
+ );
6207
+ computedSettings.computedPageTurnAnimation = `none`;
6208
+ }
6209
+ if (computedSettings.computedPageTurnMode === `scrollable`) {
6210
+ computedSettings.computedPageTurnAnimationDuration = 0;
6211
+ computedSettings.computedPageTurnAnimation = `none`;
6212
+ } else {
6213
+ computedSettings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
6214
+ }
6215
+ return computedSettings;
5590
6216
  }
5591
- get settings() {
5592
- return this._settingsSubject$.getValue();
6217
+ getOutputSettings(inputSettings) {
6218
+ const computedSettings = this.getComputedSettings(inputSettings);
6219
+ return { ...this.outputSettings, ...inputSettings, ...computedSettings };
5593
6220
  }
5594
- destroy() {
5595
- this._settingsSubject$.complete();
6221
+ getDefaultSettings() {
6222
+ return {
6223
+ forceSinglePageMode: false,
6224
+ pageTurnAnimation: `none`,
6225
+ // computedPageTurnAnimation: `none`,
6226
+ pageTurnDirection: `horizontal`,
6227
+ // computedPageTurnDirection: `horizontal`,
6228
+ pageTurnAnimationDuration: void 0,
6229
+ // computedPageTurnAnimationDuration: 0,
6230
+ pageTurnMode: `controlled`,
6231
+ // computedPageTurnMode: `controlled`,
6232
+ snapAnimationDuration: 300,
6233
+ navigationSnapThreshold: 0.3,
6234
+ numberOfAdjacentSpineItemToPreLoad: 0
6235
+ };
5596
6236
  }
5597
6237
  }
5598
6238
  class HookManager {
@@ -5625,7 +6265,9 @@
5625
6265
  };
5626
6266
  }
5627
6267
  execute(name, id, params) {
5628
- const hooks = this._hooks.filter((hook) => name === hook.name);
6268
+ const hooks = this._hooks.filter(
6269
+ (hook) => name === hook.name
6270
+ );
5629
6271
  const fnResults = hooks.map((hook) => {
5630
6272
  let userDestroyFn = () => rxjs.of(void 0);
5631
6273
  const destroySubject = new rxjs.Subject();
@@ -5638,7 +6280,11 @@
5638
6280
  const result = userDestroyFn();
5639
6281
  return result ?? rxjs.of(void 0);
5640
6282
  };
5641
- const fnResult = hook.runFn({ ...params, destroy$: destroySubject.asObservable(), destroy });
6283
+ const fnResult = hook.runFn({
6284
+ ...params,
6285
+ destroy$: destroySubject.asObservable(),
6286
+ destroy
6287
+ });
5642
6288
  this._hookExecutions.push({
5643
6289
  name,
5644
6290
  id,
@@ -5657,7 +6303,9 @@
5657
6303
  name === hookInstance.name && (!id || id && id === hookInstance.id)
5658
6304
  )
5659
6305
  );
5660
- this._hookExecutions = this._hookExecutions.filter((instance) => !instances.includes(instance));
6306
+ this._hookExecutions = this._hookExecutions.filter(
6307
+ (instance) => !instances.includes(instance)
6308
+ );
5661
6309
  const destroyFns = instances.map(({ destroyFn }) => destroyFn());
5662
6310
  return rxjs.combineLatest(destroyFns);
5663
6311
  }
@@ -5677,10 +6325,15 @@
5677
6325
  const viewportStateSubject = new rxjs.BehaviorSubject(`free`);
5678
6326
  const hookManager = new HookManager();
5679
6327
  const context = new Context();
5680
- const settingsManager = new SettingsManager(inputSettings, context);
5681
- const spineItemManager = createSpineItemManager({ context, settings: settingsManager });
6328
+ const settingsManager = new ReaderSettingsManager(inputSettings, context);
6329
+ const spineItemManager = createSpineItemManager({
6330
+ context,
6331
+ settings: settingsManager
6332
+ });
5682
6333
  const pagination = createPagination({ context, spineItemManager });
5683
- const elementSubject$ = new rxjs.BehaviorSubject(void 0);
6334
+ const elementSubject$ = new rxjs.BehaviorSubject(
6335
+ void 0
6336
+ );
5684
6337
  const element$ = elementSubject$.pipe(operators.filter(isDefined));
5685
6338
  const spineItemLocator = createLocationResolver$1({ context });
5686
6339
  const spineLocator = createLocationResolver({
@@ -5723,8 +6376,12 @@
5723
6376
  });
5724
6377
  viewportNavigator.$.state$.subscribe(viewportStateSubject);
5725
6378
  viewportNavigator.$.navigation$.subscribe(navigationSubject);
5726
- viewportNavigator.$.navigationAdjustedAfterLayout$.subscribe(navigationAdjustedSubject);
5727
- viewportNavigator.$.currentNavigationPosition$.subscribe(currentNavigationPositionSubject$);
6379
+ viewportNavigator.$.navigationAdjustedAfterLayout$.subscribe(
6380
+ navigationAdjustedSubject
6381
+ );
6382
+ viewportNavigator.$.currentNavigationPosition$.subscribe(
6383
+ currentNavigationPositionSubject$
6384
+ );
5728
6385
  const layout = () => {
5729
6386
  var _a;
5730
6387
  const containerElement = (_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement;
@@ -5766,7 +6423,11 @@
5766
6423
  elementSubject$.next(element);
5767
6424
  loadOptions.containerElement.appendChild(element);
5768
6425
  }
5769
- context.update({ manifest, ...loadOptions, forceSinglePageMode: settingsManager.settings.forceSinglePageMode });
6426
+ context.update({
6427
+ manifest,
6428
+ ...loadOptions,
6429
+ forceSinglePageMode: settingsManager.settings.forceSinglePageMode
6430
+ });
5770
6431
  layout();
5771
6432
  if (!loadOptions.cfi) {
5772
6433
  viewportNavigator.goToSpineItem(0, { animate: false });
@@ -5851,7 +6512,9 @@
5851
6512
  * have an effect.
5852
6513
  * It can typically be used to hide a loading indicator.
5853
6514
  */
5854
- loadStatus$: context.manifest$.pipe(operators.map((manifest) => manifest ? "ready" : "idle")),
6515
+ loadStatus$: context.manifest$.pipe(
6516
+ operators.map((manifest) => manifest ? "ready" : "idle")
6517
+ ),
5855
6518
  /**
5856
6519
  * Dispatched when a change in selection happens
5857
6520
  */
@@ -6018,7 +6681,9 @@
6018
6681
  operators.mergeMap(({ id, data }) => {
6019
6682
  const item = retrieveItem(id);
6020
6683
  if (!item) return rxjs.EMPTY;
6021
- return rxjs.from(rxjs.forkJoin([openDatabase(`prose-reader`), rxjs.from(data.blob())])).pipe(
6684
+ return rxjs.from(
6685
+ rxjs.forkJoin([openDatabase(`prose-reader`), rxjs.from(data.blob())])
6686
+ ).pipe(
6022
6687
  operators.switchMap(([db, blob]) => {
6023
6688
  return rxjs.from(db.put(`${uniqueID}_${item.id}`, blob));
6024
6689
  }),
@@ -6041,7 +6706,9 @@
6041
6706
  return rxjs.from(openDatabase(`prose-reader`)).pipe(
6042
6707
  operators.switchMap(
6043
6708
  (db) => rxjs.from(db.keys()).pipe(
6044
- operators.map((keys) => keys.filter((key) => !key.toString().startsWith(uniqueID))),
6709
+ operators.map(
6710
+ (keys) => keys.filter((key) => !key.toString().startsWith(uniqueID))
6711
+ ),
6045
6712
  operators.switchMap((keysToRemove) => {
6046
6713
  const promises = keysToRemove.map((key) => db.remove(key));
6047
6714
  return rxjs.from(Promise.all(promises));
@@ -6088,7 +6755,9 @@
6088
6755
  entries.forEach((entry) => {
6089
6756
  var _a;
6090
6757
  const frame = entry.target;
6091
- const audios = Array.from(((_a = frame.contentDocument) == null ? void 0 : _a.body.getElementsByTagName(`audio`)) || []);
6758
+ const audios = Array.from(
6759
+ ((_a = frame.contentDocument) == null ? void 0 : _a.body.getElementsByTagName(`audio`)) || []
6760
+ );
6092
6761
  if (!entry.isIntersecting) {
6093
6762
  audios.forEach((audioElement) => {
6094
6763
  audioElement.pause();
@@ -6167,7 +6836,11 @@
6167
6836
  let totalProgress = estimateBeforeThisItem + progressWithinThisItem;
6168
6837
  if (((_f = context.manifest) == null ? void 0 : _f.renditionFlow) === `scrolled-continuous`) {
6169
6838
  if (currentItem.isReady()) {
6170
- progressWithinThisItem = getScrollPercentageWithinItem(context, currentPosition, currentItem);
6839
+ progressWithinThisItem = getScrollPercentageWithinItem(
6840
+ context,
6841
+ currentPosition,
6842
+ currentItem
6843
+ );
6171
6844
  } else {
6172
6845
  progressWithinThisItem = 0;
6173
6846
  }
@@ -6189,9 +6862,21 @@
6189
6862
  const { height, width } = currentItem.getElementDimensions();
6190
6863
  const { top, left } = reader.spineItemManager.getAbsolutePositionOf(currentItem);
6191
6864
  if (reader.settings.settings.computedPageTurnDirection === `vertical`) {
6192
- return Math.max(0, Math.min(1, (currentPosition.y - top + context.state.visibleAreaRect.height) / height));
6865
+ return Math.max(
6866
+ 0,
6867
+ Math.min(
6868
+ 1,
6869
+ (currentPosition.y - top + context.state.visibleAreaRect.height) / height
6870
+ )
6871
+ );
6193
6872
  } else {
6194
- return Math.max(0, Math.min(1, (currentPosition.x - left + context.state.visibleAreaRect.width) / width));
6873
+ return Math.max(
6874
+ 0,
6875
+ Math.min(
6876
+ 1,
6877
+ (currentPosition.x - left + context.state.visibleAreaRect.width) / width
6878
+ )
6879
+ );
6195
6880
  }
6196
6881
  };
6197
6882
  return {
@@ -6251,19 +6936,25 @@
6251
6936
  const webkitEnhancer = (createReader2) => (options) => {
6252
6937
  const reader = createReader2(options);
6253
6938
  if (IS_SAFARI) {
6254
- reader.hookManager.register("viewportNavigator.onBeforeContainerCreated", ({ element }) => {
6255
- element.style.cssText = `
6939
+ reader.hookManager.register(
6940
+ "viewportNavigator.onBeforeContainerCreated",
6941
+ ({ element }) => {
6942
+ element.style.cssText = `
6256
6943
  ${element.style.cssText}
6257
6944
  -webkit-transform-style: preserve-3d;
6258
6945
  `;
6259
- });
6260
- reader.hookManager.register("item.onBeforeContainerCreated", ({ element }) => {
6261
- element.style.cssText = `
6946
+ }
6947
+ );
6948
+ reader.hookManager.register(
6949
+ "item.onBeforeContainerCreated",
6950
+ ({ element }) => {
6951
+ element.style.cssText = `
6262
6952
  ${element.style.cssText}
6263
6953
  -webkit-transform-style: preserve-3d;
6264
6954
  -webkit-backface-visibility: hidden;
6265
6955
  `;
6266
- });
6956
+ }
6957
+ );
6267
6958
  }
6268
6959
  return reader;
6269
6960
  };
@@ -6294,14 +6985,20 @@
6294
6985
  operators.tap(({ width, theme }) => {
6295
6986
  Object.values(entries).forEach((element) => {
6296
6987
  element.style.setProperty(`max-width`, `${width}px`);
6297
- element.style.setProperty(`color`, theme === `sepia` ? `#939393` : `rgb(202, 202, 202)`);
6988
+ element.style.setProperty(
6989
+ `color`,
6990
+ theme === `sepia` ? `#939393` : `rgb(202, 202, 202)`
6991
+ );
6298
6992
  });
6299
6993
  })
6300
6994
  );
6301
6995
  const updateEntriesVisibility$ = (entries) => reader.spineItemManager.$.itemIsReady$.pipe(
6302
6996
  operators.tap(({ item, isReady }) => {
6303
6997
  var _a;
6304
- (_a = entries[item.id]) == null ? void 0 : _a.style.setProperty(`visibility`, isReady ? `hidden` : `visible`);
6998
+ (_a = entries[item.id]) == null ? void 0 : _a.style.setProperty(
6999
+ `visibility`,
7000
+ isReady ? `hidden` : `visible`
7001
+ );
6305
7002
  })
6306
7003
  );
6307
7004
  const destroyEntries$ = (entries) => reader.spine.$.itemsBeforeDestroy$.pipe(
@@ -6317,7 +7014,12 @@
6317
7014
  );
6318
7015
  items$.pipe(
6319
7016
  operators.switchMap((entries) => rxjs.merge(rxjs.of(entries), destroyEntries$(entries))),
6320
- operators.switchMap((entries) => rxjs.merge(updateEntriesLayout$(entries), updateEntriesVisibility$(entries))),
7017
+ operators.switchMap(
7018
+ (entries) => rxjs.merge(
7019
+ updateEntriesLayout$(entries),
7020
+ updateEntriesVisibility$(entries)
7021
+ )
7022
+ ),
6321
7023
  operators.takeUntil(reader.$.destroy$)
6322
7024
  ).subscribe();
6323
7025
  return {
@@ -6387,7 +7089,8 @@
6387
7089
  const eventIsComingFromBridge = event.target === iframeEventBridgeElement$.getValue();
6388
7090
  const iframeOriginalEvent = getOriginalFrameEventFromDocumentEvent(event);
6389
7091
  const originalFrame = (_a = iframeOriginalEvent == null ? void 0 : iframeOriginalEvent.view) == null ? void 0 : _a.frameElement;
6390
- if (!eventIsComingFromBridge || !iframeOriginalEvent || !originalFrame) return event;
7092
+ if (!eventIsComingFromBridge || !iframeOriginalEvent || !originalFrame)
7093
+ return event;
6391
7094
  const spineItem = locator.getSpineItemFromIframe(originalFrame);
6392
7095
  if (!spineItem) return event;
6393
7096
  if (isPointerEvent(event)) {
@@ -6398,7 +7101,10 @@
6398
7101
  clientX,
6399
7102
  clientY
6400
7103
  });
6401
- Object.defineProperty(newEvent, `target`, { value: iframeOriginalEvent.target, enumerable: true });
7104
+ Object.defineProperty(newEvent, `target`, {
7105
+ value: iframeOriginalEvent.target,
7106
+ enumerable: true
7107
+ });
6402
7108
  return newEvent;
6403
7109
  }
6404
7110
  if (isMouseEvent(event)) {
@@ -6408,7 +7114,10 @@
6408
7114
  clientX,
6409
7115
  clientY
6410
7116
  });
6411
- Object.defineProperty(newEvent, `target`, { value: iframeOriginalEvent.target, enumerable: true });
7117
+ Object.defineProperty(newEvent, `target`, {
7118
+ value: iframeOriginalEvent.target,
7119
+ enumerable: true
7120
+ });
6412
7121
  return newEvent;
6413
7122
  }
6414
7123
  if (isTouchEvent(event)) {
@@ -6426,7 +7135,10 @@
6426
7135
  changedTouches: touches,
6427
7136
  targetTouches: touches
6428
7137
  });
6429
- Object.defineProperty(newEvent, `target`, { value: iframeOriginalEvent.target, enumerable: true });
7138
+ Object.defineProperty(newEvent, `target`, {
7139
+ value: iframeOriginalEvent.target,
7140
+ enumerable: true
7141
+ });
6430
7142
  return newEvent;
6431
7143
  }
6432
7144
  return event;
@@ -6567,6 +7279,7 @@
6567
7279
  );
6568
7280
  exports2.HookManager = HookManager;
6569
7281
  exports2.Report = Report;
7282
+ exports2.SettingsManager = SettingsManager;
6570
7283
  exports2.createReader = createReaderWithEnhancers;
6571
7284
  exports2.groupBy = groupBy;
6572
7285
  exports2.isShallowEqual = isShallowEqual;