@readium/navigator 2.5.0-beta.3 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +90 -80
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -132,7 +132,7 @@ const L = class L {
|
|
|
132
132
|
};
|
|
133
133
|
L.FLASHING = new L("flashing"), L.NO_FLASHING_HAZARD = new L("noFlashingHazard"), L.UNKNOWN_FLASHING_HAZARD = new L("unknownFlashingHazard"), L.MOTION_SIMULATION = new L("motionSimulation"), L.NO_MOTION_SIMULATION_HAZARD = new L("noMotionSimulationHazard"), L.UNKNOWN_MOTION_SIMULATION_HAZARD = new L("unknownMotionSimulationHazard"), L.SOUND = new L("sound"), L.NO_SOUND_HAZARD = new L("noSoundHazard"), L.UNKNOWN_SOUND_HAZARD = new L("unknownSoundHazard"), L.UNKNOWN = new L("unknown"), L.NONE = new L("none");
|
|
134
134
|
let ti = L;
|
|
135
|
-
const
|
|
135
|
+
const k = class k {
|
|
136
136
|
constructor(t) {
|
|
137
137
|
this.value = t;
|
|
138
138
|
}
|
|
@@ -141,7 +141,7 @@ const O = class O {
|
|
|
141
141
|
*/
|
|
142
142
|
static deserialize(t) {
|
|
143
143
|
if (!(!t || typeof t != "string"))
|
|
144
|
-
return new
|
|
144
|
+
return new k(t);
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* Serializes an [Exemption] to its RWPM JSON representation.
|
|
@@ -150,8 +150,8 @@ const O = class O {
|
|
|
150
150
|
return this.value;
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
|
-
|
|
154
|
-
let ei =
|
|
153
|
+
k.NONE = new k("none"), k.DOCUMENTED = new k("documented"), k.LEGAL = new k("legal"), k.TEMPORARY = new k("temporary"), k.TECHNICAL = new k("technical"), k.EAA_DISPROPORTIONATE_BURDEN = new k("eaa-disproportionate-burden"), k.EAA_FUNDAMENTAL_ALTERATION = new k("eaa-fundamental-alteration"), k.EAA_MICROENTERPRISE = new k("eaa-microenterprise"), k.EAA_TECHNICAL_IMPOSSIBILITY = new k("eaa-technical-impossibility"), k.EAA_TEMPORARY = new k("eaa-temporary");
|
|
154
|
+
let ei = k;
|
|
155
155
|
const ii = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Ln = /* @__PURE__ */ JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`), xn = {
|
|
156
156
|
publication: Ln
|
|
157
157
|
}, ni = {
|
|
@@ -308,11 +308,11 @@ Object.defineProperty(G.prototype, "encryption", {
|
|
|
308
308
|
return ze.deserialize(this.otherProperties.encrypted);
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
|
-
function
|
|
311
|
+
function kn(r) {
|
|
312
312
|
return r && Array.isArray(r) ? r : void 0;
|
|
313
313
|
}
|
|
314
314
|
function Xi(r) {
|
|
315
|
-
return r && typeof r == "string" ? [r] :
|
|
315
|
+
return r && typeof r == "string" ? [r] : kn(r);
|
|
316
316
|
}
|
|
317
317
|
function ri(r) {
|
|
318
318
|
return typeof r == "string" ? new Date(r) : void 0;
|
|
@@ -323,7 +323,7 @@ function Ut(r) {
|
|
|
323
323
|
function V(r) {
|
|
324
324
|
return Ut(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function On(r) {
|
|
327
327
|
const t = new Array();
|
|
328
328
|
return r.forEach((e) => t.push(e)), t;
|
|
329
329
|
}
|
|
@@ -951,7 +951,7 @@ class $ {
|
|
|
951
951
|
*/
|
|
952
952
|
serialize() {
|
|
953
953
|
const t = { href: this.href };
|
|
954
|
-
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel =
|
|
954
|
+
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = On(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
|
|
955
955
|
}
|
|
956
956
|
/** MediaType of the linked resource. */
|
|
957
957
|
get mediaType() {
|
|
@@ -2403,7 +2403,7 @@ class Kn {
|
|
|
2403
2403
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2404
2404
|
}
|
|
2405
2405
|
}
|
|
2406
|
-
const
|
|
2406
|
+
const Ot = class Ot extends Et {
|
|
2407
2407
|
constructor() {
|
|
2408
2408
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2409
2409
|
}
|
|
@@ -2428,7 +2428,7 @@ const kt = class kt extends Et {
|
|
|
2428
2428
|
}, 50);
|
|
2429
2429
|
}
|
|
2430
2430
|
mount(t, e) {
|
|
2431
|
-
return this.wnd = t, e.register("decorate",
|
|
2431
|
+
return this.wnd = t, e.register("decorate", Ot.moduleName, (i, n) => {
|
|
2432
2432
|
const s = i;
|
|
2433
2433
|
s.decoration && s.decoration.locator && (s.decoration.locator = I.deserialize(s.decoration.locator)), this.groups.has(s.group) || this.groups.set(s.group, new Kn(
|
|
2434
2434
|
t,
|
|
@@ -2468,11 +2468,11 @@ const kt = class kt extends Et {
|
|
|
2468
2468
|
}), e.log("Decorator Mounted"), !0;
|
|
2469
2469
|
}
|
|
2470
2470
|
unmount(t, e) {
|
|
2471
|
-
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(
|
|
2471
|
+
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(Ot.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2472
2472
|
}
|
|
2473
2473
|
};
|
|
2474
|
-
|
|
2475
|
-
let Ee =
|
|
2474
|
+
Ot.moduleName = "decorator";
|
|
2475
|
+
let Ee = Ot;
|
|
2476
2476
|
const wi = "readium-snapper-style", Rt = class Rt extends Et {
|
|
2477
2477
|
constructor() {
|
|
2478
2478
|
super(...arguments), this.protected = !1;
|
|
@@ -2537,7 +2537,7 @@ function He(r) {
|
|
|
2537
2537
|
function Qn(r) {
|
|
2538
2538
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2539
2539
|
}
|
|
2540
|
-
function
|
|
2540
|
+
function O(r) {
|
|
2541
2541
|
const t = r.getSelection();
|
|
2542
2542
|
t && t.removeAllRanges();
|
|
2543
2543
|
}
|
|
@@ -2775,7 +2775,7 @@ const Pi = "readium-column-snapper-style", os = 200, F = class F extends St {
|
|
|
2775
2775
|
}
|
|
2776
2776
|
onTouchMove(t) {
|
|
2777
2777
|
if (this.touchState === 0) return;
|
|
2778
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2778
|
+
this.touchState === 1 && (this.touchState = 2, O(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2779
2779
|
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, n = this.rtl ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0, s = this.rtl ? 0 : this.cachedScrollWidth - this.wnd.innerWidth;
|
|
2780
2780
|
i < n ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i > s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = i);
|
|
2781
2781
|
}
|
|
@@ -2874,7 +2874,7 @@ const Pi = "readium-column-snapper-style", os = 200, F = class F extends St {
|
|
|
2874
2874
|
this.wnd.requestAnimationFrame(() => {
|
|
2875
2875
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2876
2876
|
const c = (this.cachedScrollWidth - t.innerWidth) * l;
|
|
2877
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c) : this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(),
|
|
2877
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c) : this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), O(this.wnd), a(!0);
|
|
2878
2878
|
});
|
|
2879
2879
|
}), e.register("go_id", F.moduleName, (o, a) => {
|
|
2880
2880
|
const l = t.document.getElementById(o);
|
|
@@ -2883,7 +2883,7 @@ const Pi = "readium-column-snapper-style", os = 200, F = class F extends St {
|
|
|
2883
2883
|
return;
|
|
2884
2884
|
}
|
|
2885
2885
|
this.wnd.requestAnimationFrame(() => {
|
|
2886
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(l.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + t.scrollX), this.reportProgress(),
|
|
2886
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(l.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + t.scrollX), this.reportProgress(), O(this.wnd), a(!0);
|
|
2887
2887
|
});
|
|
2888
2888
|
}), e.register("go_text", F.moduleName, (o, a) => {
|
|
2889
2889
|
let l;
|
|
@@ -2903,34 +2903,34 @@ const Pi = "readium-column-snapper-style", os = 200, F = class F extends St {
|
|
|
2903
2903
|
return;
|
|
2904
2904
|
}
|
|
2905
2905
|
this.wnd.requestAnimationFrame(() => {
|
|
2906
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(),
|
|
2906
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), O(this.wnd), a(!0);
|
|
2907
2907
|
});
|
|
2908
2908
|
}), e.register("go_end", F.moduleName, (o, a) => {
|
|
2909
2909
|
this.wnd.requestAnimationFrame(() => {
|
|
2910
2910
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2911
2911
|
let l;
|
|
2912
2912
|
if (this.rtl ? l = -this.snapNormOffset(this.cachedScrollWidth - t.innerWidth) : l = this.snapOffset(this.cachedScrollWidth), this.doc().scrollLeft === l) return a(!1);
|
|
2913
|
-
this.doc().scrollLeft = l, this.reportProgress(),
|
|
2913
|
+
this.doc().scrollLeft = l, this.reportProgress(), O(this.wnd), a(!0);
|
|
2914
2914
|
});
|
|
2915
2915
|
}), e.register("go_start", F.moduleName, (o, a) => {
|
|
2916
2916
|
this.wnd.requestAnimationFrame(() => {
|
|
2917
2917
|
if (this.doc().scrollLeft === 0) return a(!1);
|
|
2918
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2918
|
+
this.doc().scrollLeft = 0, this.reportProgress(), O(this.wnd), a(!0);
|
|
2919
2919
|
});
|
|
2920
2920
|
}), e.register("go_prev", F.moduleName, (o, a) => {
|
|
2921
2921
|
this.wnd.requestAnimationFrame(() => {
|
|
2922
2922
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2923
2923
|
let l;
|
|
2924
|
-
this.rtl ? l = s(this.normScroll() - t.innerWidth) : l = n(t.scrollX - t.innerWidth), this.reportProgress(), l && (
|
|
2924
|
+
this.rtl ? l = s(this.normScroll() - t.innerWidth) : l = n(t.scrollX - t.innerWidth), this.reportProgress(), l && (O(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), a(l);
|
|
2925
2925
|
});
|
|
2926
2926
|
}), e.register("go_next", F.moduleName, (o, a) => {
|
|
2927
2927
|
this.wnd.requestAnimationFrame(() => {
|
|
2928
2928
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2929
2929
|
let l;
|
|
2930
|
-
this.rtl ? l = s(this.normScroll() + t.innerWidth) : l = n(t.scrollX + t.innerWidth), this.reportProgress(), l && (
|
|
2930
|
+
this.rtl ? l = s(this.normScroll() + t.innerWidth) : l = n(t.scrollX + t.innerWidth), this.reportProgress(), l && (O(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), a(l);
|
|
2931
2931
|
});
|
|
2932
2932
|
}), e.register("unfocus", F.moduleName, (o, a) => {
|
|
2933
|
-
this.snappingCancelled = !0,
|
|
2933
|
+
this.snappingCancelled = !0, O(this.wnd), a(!0);
|
|
2934
2934
|
}), e.register("shake", F.moduleName, (o, a) => {
|
|
2935
2935
|
this.shake(), a(!0);
|
|
2936
2936
|
}), e.register("focus", F.moduleName, (o, a) => {
|
|
@@ -3025,7 +3025,7 @@ const Ei = "readium-scroll-snapper-style", U = class U extends St {
|
|
|
3025
3025
|
return;
|
|
3026
3026
|
}
|
|
3027
3027
|
this.wnd.requestAnimationFrame(() => {
|
|
3028
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(),
|
|
3028
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), O(this.wnd), s(!0);
|
|
3029
3029
|
});
|
|
3030
3030
|
}), e.register("go_id", U.moduleName, (n, s) => {
|
|
3031
3031
|
const o = t.document.getElementById(n);
|
|
@@ -3034,7 +3034,7 @@ const Ei = "readium-scroll-snapper-style", U = class U extends St {
|
|
|
3034
3034
|
return;
|
|
3035
3035
|
}
|
|
3036
3036
|
this.wnd.requestAnimationFrame(() => {
|
|
3037
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3037
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), O(this.wnd), s(!0);
|
|
3038
3038
|
});
|
|
3039
3039
|
}), e.register("go_text", U.moduleName, (n, s) => {
|
|
3040
3040
|
let o;
|
|
@@ -3054,7 +3054,7 @@ const Ei = "readium-scroll-snapper-style", U = class U extends St {
|
|
|
3054
3054
|
return;
|
|
3055
3055
|
}
|
|
3056
3056
|
this.wnd.requestAnimationFrame(() => {
|
|
3057
|
-
this.doc().scrollTop = l.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3057
|
+
this.doc().scrollTop = l.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), O(this.wnd), s(!0);
|
|
3058
3058
|
});
|
|
3059
3059
|
}), e.register("go_start", U.moduleName, (n, s) => {
|
|
3060
3060
|
if (this.doc().scrollTop === 0) return s(!1);
|
|
@@ -3063,7 +3063,7 @@ const Ei = "readium-scroll-snapper-style", U = class U extends St {
|
|
|
3063
3063
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3064
3064
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3065
3065
|
}), e.register("unfocus", U.moduleName, (n, s) => {
|
|
3066
|
-
|
|
3066
|
+
O(this.wnd), s(!0);
|
|
3067
3067
|
}), e.register("scroll_protection", U.moduleName, (n, s) => {
|
|
3068
3068
|
this.enableScrollProtection(), s(!0);
|
|
3069
3069
|
}), e.register([
|
|
@@ -3148,7 +3148,7 @@ const B = class B extends St {
|
|
|
3148
3148
|
return;
|
|
3149
3149
|
}
|
|
3150
3150
|
this.wnd.requestAnimationFrame(() => {
|
|
3151
|
-
this.doc().scrollTop = this.doc().offsetHeight * s, this.reportProgress(),
|
|
3151
|
+
this.doc().scrollTop = this.doc().offsetHeight * s, this.reportProgress(), O(this.wnd), n(!0);
|
|
3152
3152
|
});
|
|
3153
3153
|
}), e.register("go_id", B.moduleName, (i, n) => {
|
|
3154
3154
|
const s = t.document.getElementById(i);
|
|
@@ -3157,7 +3157,7 @@ const B = class B extends St {
|
|
|
3157
3157
|
return;
|
|
3158
3158
|
}
|
|
3159
3159
|
this.wnd.requestAnimationFrame(() => {
|
|
3160
|
-
this.doc().scrollTop = s.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3160
|
+
this.doc().scrollTop = s.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), O(this.wnd), n(!0);
|
|
3161
3161
|
});
|
|
3162
3162
|
}), e.register("go_text", B.moduleName, (i, n) => {
|
|
3163
3163
|
let s;
|
|
@@ -3177,7 +3177,7 @@ const B = class B extends St {
|
|
|
3177
3177
|
return;
|
|
3178
3178
|
}
|
|
3179
3179
|
this.wnd.requestAnimationFrame(() => {
|
|
3180
|
-
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3180
|
+
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), O(this.wnd), n(!0);
|
|
3181
3181
|
});
|
|
3182
3182
|
}), e.register("go_start", B.moduleName, (i, n) => {
|
|
3183
3183
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
@@ -3186,7 +3186,7 @@ const B = class B extends St {
|
|
|
3186
3186
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
3187
3187
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
3188
3188
|
}), e.register("unfocus", B.moduleName, (i, n) => {
|
|
3189
|
-
|
|
3189
|
+
O(this.wnd), n(!0);
|
|
3190
3190
|
}), e.register("scroll_protection", B.moduleName, (i, n) => {
|
|
3191
3191
|
this.enableScrollProtection(), n(!0);
|
|
3192
3192
|
}), e.register([
|
|
@@ -3641,7 +3641,7 @@ const At = class At extends Et {
|
|
|
3641
3641
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3642
3642
|
value: {
|
|
3643
3643
|
name: "readium-ts-toolkit",
|
|
3644
|
-
version: "2.5.
|
|
3644
|
+
version: "2.5.1",
|
|
3645
3645
|
hasFeature: (n, s = "") => {
|
|
3646
3646
|
switch (n) {
|
|
3647
3647
|
case "dom-manipulation":
|
|
@@ -3721,7 +3721,7 @@ const _i = "readium-viewport", Z = class Z extends Xt {
|
|
|
3721
3721
|
}
|
|
3722
3722
|
};
|
|
3723
3723
|
Z.moduleName = "reflowable_setup";
|
|
3724
|
-
let
|
|
3724
|
+
let ke = Z;
|
|
3725
3725
|
const Ci = "readium-fixed-style", q = class q extends Xt {
|
|
3726
3726
|
mount(t, e) {
|
|
3727
3727
|
if (!super.mount(t, e)) return !1;
|
|
@@ -3745,7 +3745,7 @@ const Ci = "readium-fixed-style", q = class q extends Xt {
|
|
|
3745
3745
|
}), e.register("remove_property", q.moduleName, (n, s) => {
|
|
3746
3746
|
re(t, n), s(!0);
|
|
3747
3747
|
}), e.register("first_visible_locator", q.moduleName, (n, s) => s(!1)), e.register("unfocus", q.moduleName, (n, s) => {
|
|
3748
|
-
|
|
3748
|
+
O(t), s(!0);
|
|
3749
3749
|
}), e.register([
|
|
3750
3750
|
"focus",
|
|
3751
3751
|
"go_next",
|
|
@@ -3764,7 +3764,7 @@ const Ci = "readium-fixed-style", q = class q extends Xt {
|
|
|
3764
3764
|
}
|
|
3765
3765
|
};
|
|
3766
3766
|
q.moduleName = "fixed_setup";
|
|
3767
|
-
let
|
|
3767
|
+
let Oe = q;
|
|
3768
3768
|
const Q = class Q extends Et {
|
|
3769
3769
|
wndOnErr(t) {
|
|
3770
3770
|
this.comms?.send("error", {
|
|
@@ -3921,7 +3921,7 @@ const Li = "readium-cjk-vertical-snapper-style", H = class H extends St {
|
|
|
3921
3921
|
}
|
|
3922
3922
|
this.wnd.requestAnimationFrame(() => {
|
|
3923
3923
|
const a = this.scrollable() * o;
|
|
3924
|
-
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(),
|
|
3924
|
+
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(), O(this.wnd), s(!0);
|
|
3925
3925
|
});
|
|
3926
3926
|
}), e.register("go_id", H.moduleName, (n, s) => {
|
|
3927
3927
|
const o = t.document.getElementById(n);
|
|
@@ -3930,7 +3930,7 @@ const Li = "readium-cjk-vertical-snapper-style", H = class H extends St {
|
|
|
3930
3930
|
return;
|
|
3931
3931
|
}
|
|
3932
3932
|
this.wnd.requestAnimationFrame(() => {
|
|
3933
|
-
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(),
|
|
3933
|
+
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), O(this.wnd), s(!0);
|
|
3934
3934
|
});
|
|
3935
3935
|
}), e.register("go_text", H.moduleName, (n, s) => {
|
|
3936
3936
|
let o;
|
|
@@ -3948,7 +3948,7 @@ const Li = "readium-cjk-vertical-snapper-style", H = class H extends St {
|
|
|
3948
3948
|
return;
|
|
3949
3949
|
}
|
|
3950
3950
|
this.wnd.requestAnimationFrame(() => {
|
|
3951
|
-
this.doc().scrollLeft += l.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(),
|
|
3951
|
+
this.doc().scrollLeft += l.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), O(this.wnd), s(!0);
|
|
3952
3952
|
});
|
|
3953
3953
|
}), e.register("go_start", H.moduleName, (n, s) => {
|
|
3954
3954
|
if (this.doc().scrollLeft === 0) return s(!1);
|
|
@@ -3960,7 +3960,7 @@ const Li = "readium-cjk-vertical-snapper-style", H = class H extends St {
|
|
|
3960
3960
|
"go_next",
|
|
3961
3961
|
"go_prev"
|
|
3962
3962
|
], H.moduleName, (n, s) => s(!1)), e.register("unfocus", H.moduleName, (n, s) => {
|
|
3963
|
-
|
|
3963
|
+
O(this.wnd), s(!0);
|
|
3964
3964
|
}), e.register("scroll_protection", H.moduleName, (n, s) => {
|
|
3965
3965
|
this.enableScrollProtection(), s(!0);
|
|
3966
3966
|
}), e.register("focus", H.moduleName, (n, s) => {
|
|
@@ -3997,8 +3997,8 @@ const cs = [
|
|
|
3997
3997
|
"print_protection"
|
|
3998
3998
|
], Te = new Map([
|
|
3999
3999
|
// All modules go here
|
|
4000
|
-
ke,
|
|
4001
4000
|
Oe,
|
|
4001
|
+
ke,
|
|
4002
4002
|
Re,
|
|
4003
4003
|
Le,
|
|
4004
4004
|
xe,
|
|
@@ -4062,57 +4062,67 @@ const ps = {
|
|
|
4062
4062
|
type: "developer_tools",
|
|
4063
4063
|
keyCombos: [
|
|
4064
4064
|
{ keyCode: 73, meta: !0, alt: !0 },
|
|
4065
|
-
// I
|
|
4065
|
+
// Cmd+Option+I
|
|
4066
|
+
{ keyCode: 73, ctrl: !0, shift: !0 },
|
|
4067
|
+
// Ctrl+Shift+I
|
|
4066
4068
|
{ keyCode: 74, meta: !0, alt: !0 },
|
|
4067
|
-
// J
|
|
4069
|
+
// Cmd+Option+J
|
|
4070
|
+
{ keyCode: 74, ctrl: !0, shift: !0 },
|
|
4071
|
+
// Ctrl+Shift+J
|
|
4068
4072
|
{ keyCode: 85, meta: !0, alt: !0 },
|
|
4069
|
-
// U
|
|
4073
|
+
// Cmd+Option+U
|
|
4070
4074
|
{ keyCode: 67, meta: !0, alt: !0 },
|
|
4071
|
-
// C
|
|
4075
|
+
// Cmd+Option+C
|
|
4072
4076
|
{ keyCode: 67, meta: !0, shift: !0 },
|
|
4073
|
-
//
|
|
4077
|
+
// Cmd+Shift+C
|
|
4074
4078
|
{ keyCode: 67, ctrl: !0, shift: !0 },
|
|
4075
|
-
//
|
|
4079
|
+
// Ctrl+Shift+C
|
|
4080
|
+
{ keyCode: 65, meta: !0, alt: !0 },
|
|
4081
|
+
// Cmd+Option+A
|
|
4082
|
+
{ keyCode: 84, meta: !0, shift: !0, alt: !0 },
|
|
4083
|
+
// Cmd+Shift+Option+T
|
|
4084
|
+
{ keyCode: 67, shift: !0, alt: !0 },
|
|
4085
|
+
// Shift+Option+C
|
|
4076
4086
|
{ keyCode: 123 },
|
|
4077
4087
|
// F12
|
|
4078
4088
|
{ keyCode: 123, shift: !0 },
|
|
4079
|
-
// F12
|
|
4089
|
+
// Shift+F12
|
|
4080
4090
|
{ keyCode: 123, ctrl: !0, shift: !0 },
|
|
4081
|
-
//
|
|
4091
|
+
// Ctrl+Shift+F12
|
|
4082
4092
|
{ keyCode: 123, meta: !0, alt: !0 }
|
|
4083
|
-
//
|
|
4093
|
+
// Cmd+Option+F12
|
|
4084
4094
|
]
|
|
4085
4095
|
}, fs = {
|
|
4086
4096
|
type: "select_all",
|
|
4087
4097
|
keyCombos: [
|
|
4088
4098
|
{ keyCode: 65, meta: !0 },
|
|
4089
|
-
//
|
|
4099
|
+
// Cmd+A
|
|
4090
4100
|
{ keyCode: 65, ctrl: !0 }
|
|
4091
|
-
//
|
|
4101
|
+
// Ctrl+A
|
|
4092
4102
|
]
|
|
4093
4103
|
}, ms = {
|
|
4094
4104
|
type: "print",
|
|
4095
4105
|
keyCombos: [
|
|
4096
4106
|
{ keyCode: 80, meta: !0 },
|
|
4097
|
-
//
|
|
4107
|
+
// Cmd+P
|
|
4098
4108
|
{ keyCode: 80, ctrl: !0 },
|
|
4099
|
-
//
|
|
4109
|
+
// Ctrl+P
|
|
4100
4110
|
{ keyCode: 80, meta: !0, shift: !0 },
|
|
4101
|
-
//
|
|
4111
|
+
// Cmd+Shift+P
|
|
4102
4112
|
{ keyCode: 80, ctrl: !0, shift: !0 },
|
|
4103
|
-
//
|
|
4113
|
+
// Ctrl+Shift+P
|
|
4104
4114
|
{ keyCode: 80, meta: !0, alt: !0 },
|
|
4105
|
-
//
|
|
4115
|
+
// Cmd+Alt+P
|
|
4106
4116
|
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
4107
|
-
//
|
|
4117
|
+
// Ctrl+Alt+P
|
|
4108
4118
|
]
|
|
4109
4119
|
}, gs = {
|
|
4110
4120
|
type: "save",
|
|
4111
4121
|
keyCombos: [
|
|
4112
4122
|
{ keyCode: 83, meta: !0 },
|
|
4113
|
-
//
|
|
4123
|
+
// Cmd+S
|
|
4114
4124
|
{ keyCode: 83, ctrl: !0 }
|
|
4115
|
-
//
|
|
4125
|
+
// Ctrl+S
|
|
4116
4126
|
]
|
|
4117
4127
|
};
|
|
4118
4128
|
class ln {
|
|
@@ -4290,9 +4300,9 @@ class Mt {
|
|
|
4290
4300
|
const vs = "'Iowan Old Style', Sitka, 'Sitka Text', Palatino, 'Book Antiqua', 'URW Palladio L', P052, serif", Ss = {
|
|
4291
4301
|
RS__oldStyleTf: vs
|
|
4292
4302
|
}, Ps = 16, xi = Ss.RS__oldStyleTf;
|
|
4293
|
-
class
|
|
4303
|
+
class kt {
|
|
4294
4304
|
constructor(t) {
|
|
4295
|
-
this._optimalLineLength = null, this._canvas = document.createElement("canvas"), this._optimalChars = t.optimalChars, this._minChars = t.minChars, this._maxChars = t.maxChars, this._baseFontSize = t.baseFontSize || Ps, this._fontFace = t.fontFace || xi, this._sample = t.sample || null, this._padding = t.padding ?? 0, this._letterSpacing = t.letterSpacing ? Math.round(t.letterSpacing * this._baseFontSize) : 0, this._wordSpacing = t.wordSpacing ? Math.round(t.wordSpacing * this._baseFontSize) : 0, this._isCJK = t.isCJK || !1, this._getRelative = t.getRelative || !1, this._minDivider = this._minChars && this._minChars < this._optimalChars ? this._optimalChars / this._minChars : this._minChars === null ? null : 1, this._maxMultiplier = this._maxChars && this._maxChars > this._optimalChars ? this._maxChars / this._optimalChars : this._maxChars === null ? null : 1, this._approximatedWordSpaces =
|
|
4305
|
+
this._optimalLineLength = null, this._canvas = document.createElement("canvas"), this._optimalChars = t.optimalChars, this._minChars = t.minChars, this._maxChars = t.maxChars, this._baseFontSize = t.baseFontSize || Ps, this._fontFace = t.fontFace || xi, this._sample = t.sample || null, this._padding = t.padding ?? 0, this._letterSpacing = t.letterSpacing ? Math.round(t.letterSpacing * this._baseFontSize) : 0, this._wordSpacing = t.wordSpacing ? Math.round(t.wordSpacing * this._baseFontSize) : 0, this._isCJK = t.isCJK || !1, this._getRelative = t.getRelative || !1, this._minDivider = this._minChars && this._minChars < this._optimalChars ? this._optimalChars / this._minChars : this._minChars === null ? null : 1, this._maxMultiplier = this._maxChars && this._maxChars > this._optimalChars ? this._maxChars / this._optimalChars : this._maxChars === null ? null : 1, this._approximatedWordSpaces = kt.approximateWordSpaces(this._optimalChars, this._sample);
|
|
4296
4306
|
}
|
|
4297
4307
|
updateMultipliers() {
|
|
4298
4308
|
this._minDivider = this._minChars && this._minChars < this._optimalChars ? this._optimalChars / this._minChars : this._minChars === null ? null : 1, this._maxMultiplier = this._maxChars && this._maxChars > this._optimalChars ? this._maxChars / this._optimalChars : this._maxChars === null ? null : 1;
|
|
@@ -4301,7 +4311,7 @@ class Ot {
|
|
|
4301
4311
|
// Not filtering because pretty much everything can
|
|
4302
4312
|
// trigger a recomputation anyway.
|
|
4303
4313
|
update(t) {
|
|
4304
|
-
t.optimalChars && (this._optimalChars = t.optimalChars), t.minChars !== void 0 && (this._minChars = t.minChars), t.maxChars !== void 0 && (this._maxChars = t.maxChars), t.baseFontSize && (this._baseFontSize = t.baseFontSize), t.fontFace !== void 0 && (this._fontFace = t.fontFace || xi), t.letterSpacing && (this._letterSpacing = t.letterSpacing), t.wordSpacing && (this._wordSpacing = t.wordSpacing), t.isCJK != null && (this._isCJK = t.isCJK), t.padding !== void 0 && (this._padding = t.padding ?? 0), t.getRelative && (this._getRelative = t.getRelative), t.sample && (this._sample = t.sample, this._approximatedWordSpaces =
|
|
4314
|
+
t.optimalChars && (this._optimalChars = t.optimalChars), t.minChars !== void 0 && (this._minChars = t.minChars), t.maxChars !== void 0 && (this._maxChars = t.maxChars), t.baseFontSize && (this._baseFontSize = t.baseFontSize), t.fontFace !== void 0 && (this._fontFace = t.fontFace || xi), t.letterSpacing && (this._letterSpacing = t.letterSpacing), t.wordSpacing && (this._wordSpacing = t.wordSpacing), t.isCJK != null && (this._isCJK = t.isCJK), t.padding !== void 0 && (this._padding = t.padding ?? 0), t.getRelative && (this._getRelative = t.getRelative), t.sample && (this._sample = t.sample, this._approximatedWordSpaces = kt.approximateWordSpaces(this._optimalChars, this._sample)), this.updateMultipliers(), this._optimalLineLength = this.getOptimalLineLength();
|
|
4305
4315
|
}
|
|
4306
4316
|
get baseFontSize() {
|
|
4307
4317
|
return this._baseFontSize;
|
|
@@ -4357,7 +4367,7 @@ class Ot {
|
|
|
4357
4367
|
if (e.font = `${this._baseFontSize}px ${t}`, this._sample && this._sample.length >= this._optimalChars && (i = this._sample.slice(0, this._optimalChars)), Object.hasOwn(e, "letterSpacing") && Object.hasOwn(e, "wordSpacing"))
|
|
4358
4368
|
return e.letterSpacing = this._letterSpacing.toString() + "px", e.wordSpacing = this._wordSpacing.toString() + "px", e.measureText(i).width;
|
|
4359
4369
|
{
|
|
4360
|
-
const n = this._letterSpacing * (this._optimalChars - 1), s = this._wordSpacing *
|
|
4370
|
+
const n = this._letterSpacing * (this._optimalChars - 1), s = this._wordSpacing * kt.approximateWordSpaces(this._optimalChars, this._sample);
|
|
4361
4371
|
return e.measureText(i).width + n + s;
|
|
4362
4372
|
}
|
|
4363
4373
|
} else
|
|
@@ -4625,10 +4635,10 @@ class Cs {
|
|
|
4625
4635
|
}), t;
|
|
4626
4636
|
}
|
|
4627
4637
|
}
|
|
4628
|
-
var me,
|
|
4638
|
+
var me, ki;
|
|
4629
4639
|
function Ls() {
|
|
4630
|
-
if (
|
|
4631
|
-
|
|
4640
|
+
if (ki) return me;
|
|
4641
|
+
ki = 1;
|
|
4632
4642
|
function r(n) {
|
|
4633
4643
|
if (typeof n != "string")
|
|
4634
4644
|
throw new TypeError("Path must be a string. Received " + JSON.stringify(n));
|
|
@@ -4814,10 +4824,10 @@ function Ls() {
|
|
|
4814
4824
|
return i.posix = i, me = i, me;
|
|
4815
4825
|
}
|
|
4816
4826
|
var Gt = Ls();
|
|
4817
|
-
const xs = { description: "Attempts to filter out paragraphs that are implicitly headings or part of headers", scope: "RS", value: "readium-experimentalHeaderFiltering-on" },
|
|
4827
|
+
const xs = { description: "Attempts to filter out paragraphs that are implicitly headings or part of headers", scope: "RS", value: "readium-experimentalHeaderFiltering-on" }, ks = { description: "Attemps to filter out elements that are sized using viewport units and should not be scaled directly e.g. tables, images, iframes, etc.", scope: "RS", value: "readium-experimentalZoom-on" }, Os = {
|
|
4818
4828
|
experimentalHeaderFiltering: xs,
|
|
4819
|
-
experimentalZoom:
|
|
4820
|
-
}, je =
|
|
4829
|
+
experimentalZoom: ks
|
|
4830
|
+
}, je = Os;
|
|
4821
4831
|
var tt = /* @__PURE__ */ ((r) => (r.start = "start", r.left = "left", r.right = "right", r.justify = "justify", r))(tt || {});
|
|
4822
4832
|
const dt = {
|
|
4823
4833
|
range: [0, 100],
|
|
@@ -5001,7 +5011,7 @@ class Ns {
|
|
|
5001
5011
|
this.fontFamily = W(t.fontFamily) || null, this.fontWeight = z(t.fontWeight, st.range) || null, this.hyphens = E(t.hyphens) ?? null, this.iOSPatch = t.iOSPatch === !1 ? !1 : (T.OS.iOS || T.OS.iPadOS) && T.iOSRequest === "mobile", this.iPadOSPatch = t.iPadOSPatch === !1 ? !1 : T.OS.iPadOS && T.iOSRequest === "desktop", this.letterSpacing = v(t.letterSpacing) || null, this.ligatures = E(t.ligatures) ?? null, this.lineHeight = v(t.lineHeight) || null, this.noRuby = E(t.noRuby) ?? !1, this.paragraphIndent = v(t.paragraphIndent) ?? null, this.paragraphSpacing = v(t.paragraphSpacing) ?? null, this.textAlign = he(t.textAlign, tt) || null, this.textNormalization = E(t.textNormalization) ?? !1, this.wordSpacing = v(t.wordSpacing) || null, this.zoom = z(t.zoom, ee.range) || 1, this.experiments = fn(t.experiments) ?? null;
|
|
5002
5012
|
}
|
|
5003
5013
|
}
|
|
5004
|
-
class
|
|
5014
|
+
class Oi {
|
|
5005
5015
|
constructor(t, e, i) {
|
|
5006
5016
|
this.fontFamily = null, this.fontWeight = null, this.hyphens = null, this.iOSPatch = null, this.iPadOSPatch = null, this.letterSpacing = null, this.ligatures = null, this.lineHeight = null, this.noRuby = null, this.paragraphIndent = null, this.paragraphSpacing = null, this.textAlign = null, this.textNormalization = null, this.wordSpacing = null, i && (this.fontFamily = t.fontFamily || e.fontFamily || null, this.fontWeight = t.fontWeight !== void 0 ? t.fontWeight : e.fontWeight !== void 0 ? e.fontWeight : null, this.hyphens = typeof t.hyphens == "boolean" ? t.hyphens : e.hyphens ?? null, this.iOSPatch = t.iOSPatch === !1 ? !1 : t.iOSPatch === !0 ? (T.OS.iOS || T.OS.iPadOS) && T.iOSRequest === "mobile" : e.iOSPatch, this.iPadOSPatch = t.iPadOSPatch === !1 ? !1 : t.iPadOSPatch === !0 ? T.OS.iPadOS && T.iOSRequest === "desktop" : e.iPadOSPatch, this.letterSpacing = t.letterSpacing !== void 0 ? t.letterSpacing : e.letterSpacing !== void 0 ? e.letterSpacing : null, this.ligatures = typeof t.ligatures == "boolean" ? t.ligatures : e.ligatures ?? null, this.lineHeight = t.lineHeight !== void 0 ? t.lineHeight : e.lineHeight !== void 0 ? e.lineHeight : null, this.noRuby = typeof t.noRuby == "boolean" ? t.noRuby : e.noRuby ?? null, this.paragraphIndent = t.paragraphIndent !== void 0 ? t.paragraphIndent : e.paragraphIndent !== void 0 ? e.paragraphIndent : null, this.paragraphSpacing = t.paragraphSpacing !== void 0 ? t.paragraphSpacing : e.paragraphSpacing !== void 0 ? e.paragraphSpacing : null, this.textAlign = t.textAlign || e.textAlign || null, this.textNormalization = typeof t.textNormalization == "boolean" ? t.textNormalization : e.textNormalization ?? null, this.wordSpacing = t.wordSpacing !== void 0 ? t.wordSpacing : e.wordSpacing !== void 0 ? e.wordSpacing : null), this.zoom = t.zoom !== void 0 ? t.zoom : e.zoom !== void 0 ? e.zoom : null, this.experiments = e.experiments || null;
|
|
5007
5017
|
}
|
|
@@ -6241,7 +6251,7 @@ class Js extends hn {
|
|
|
6241
6251
|
readingOrder: [],
|
|
6242
6252
|
progressions: /* @__PURE__ */ new Map(),
|
|
6243
6253
|
positions: null
|
|
6244
|
-
}, this.pub = e, this.container = t, this.listeners = Ks(i), this._preferences = new Nt(s.preferences), this._defaults = new Ns(s.defaults), this._settings = new
|
|
6254
|
+
}, this.pub = e, this.container = t, this.listeners = Ks(i), this._preferences = new Nt(s.preferences), this._defaults = new Ns(s.defaults), this._settings = new Oi(this._preferences, this._defaults, this.hasDisplayTransformability), this._css = new As({
|
|
6245
6255
|
rsProperties: new Rs({ experiments: this._settings.experiments || null }),
|
|
6246
6256
|
userProperties: new pn({ zoom: this._settings.zoom })
|
|
6247
6257
|
});
|
|
@@ -6289,7 +6299,7 @@ class Js extends hn {
|
|
|
6289
6299
|
this._preferences = this._preferences.merging(t), await this.applyPreferences();
|
|
6290
6300
|
}
|
|
6291
6301
|
async applyPreferences() {
|
|
6292
|
-
this._settings = new
|
|
6302
|
+
this._settings = new Oi(this._preferences, this._defaults, this.hasDisplayTransformability), this._preferencesEditor !== null && (this._preferencesEditor = new Ri(this._preferences, this.settings, this.pub.metadata)), await this.updateCSS(!0);
|
|
6293
6303
|
}
|
|
6294
6304
|
async updateCSS(t) {
|
|
6295
6305
|
this._css.update(this._settings), t && await this.commitCSS(this._css);
|
|
@@ -8544,7 +8554,7 @@ class _n extends hn {
|
|
|
8544
8554
|
this._css = new Pr({
|
|
8545
8555
|
rsProperties: new Sr({ noVerticalPagination: u || void 0 }),
|
|
8546
8556
|
userProperties: new En({}),
|
|
8547
|
-
lineLengths: new
|
|
8557
|
+
lineLengths: new kt({
|
|
8548
8558
|
optimalChars: this._settings.optimalLineLength,
|
|
8549
8559
|
minChars: this._settings.minimalLineLength,
|
|
8550
8560
|
maxChars: this._settings.maximalLineLength,
|
|
@@ -9510,7 +9520,7 @@ class ce {
|
|
|
9510
9520
|
return new ce(e);
|
|
9511
9521
|
}
|
|
9512
9522
|
}
|
|
9513
|
-
class
|
|
9523
|
+
class kr {
|
|
9514
9524
|
constructor(t = {}) {
|
|
9515
9525
|
this.volume = z(t.volume, ie.range) ?? 1, this.playbackRate = z(t.playbackRate, ne.range) ?? 1, this.preservePitch = E(t.preservePitch) ?? !0, this.skipBackwardInterval = z(t.skipBackwardInterval, it.range) ?? 10, this.skipForwardInterval = z(t.skipForwardInterval, it.range) ?? 10, this.pollInterval = v(t.pollInterval) ?? 1e3, this.autoPlay = E(t.autoPlay) ?? !0, this.enableMediaSession = E(t.enableMediaSession) ?? !0;
|
|
9516
9526
|
}
|
|
@@ -9620,7 +9630,7 @@ class Vi {
|
|
|
9620
9630
|
}
|
|
9621
9631
|
}
|
|
9622
9632
|
const ji = 1, $i = 1;
|
|
9623
|
-
class
|
|
9633
|
+
class Or {
|
|
9624
9634
|
constructor(t, e, i = {}) {
|
|
9625
9635
|
this.pool = /* @__PURE__ */ new Map(), this._audioEngine = t, this._publication = e, this._supportedAudioTypes = this.detectSupportedAudioTypes(), i.disableRemotePlayback && (this._audioEngine.getMediaElement().disableRemotePlayback = !0);
|
|
9626
9636
|
}
|
|
@@ -9779,7 +9789,7 @@ class zr extends ys {
|
|
|
9779
9789
|
preferences: {},
|
|
9780
9790
|
defaults: {}
|
|
9781
9791
|
}) {
|
|
9782
|
-
if (super(), this.positionPollInterval = null, this.navigationId = 0, this._playIntent = !1, this._preferencesEditor = null, this._mediaSessionEnabled = !1, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this._isNavigating = !1, this._isStalled = !1, this._stalledWatchdog = null, this._stalledCheckTime = 0, this.pub = t, this.listeners = Mr(e), this._preferences = new ce(n.preferences), this._defaults = new
|
|
9792
|
+
if (super(), this.positionPollInterval = null, this.navigationId = 0, this._playIntent = !1, this._preferencesEditor = null, this._mediaSessionEnabled = !1, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this._isNavigating = !1, this._isStalled = !1, this._stalledWatchdog = null, this._stalledCheckTime = 0, this.pub = t, this.listeners = Mr(e), this._preferences = new ce(n.preferences), this._defaults = new kr(n.defaults), this._settings = new Hi(this._preferences, this._defaults), t.readingOrder.items.length === 0)
|
|
9783
9793
|
throw new Error("AudioNavigator: publication has an empty reading order");
|
|
9784
9794
|
if (i)
|
|
9785
9795
|
this.currentLocation = this.ensureLocatorLocations(i);
|
|
@@ -9810,7 +9820,7 @@ class zr extends ys {
|
|
|
9810
9820
|
index: o
|
|
9811
9821
|
}
|
|
9812
9822
|
});
|
|
9813
|
-
this.pool = new
|
|
9823
|
+
this.pool = new Or(l, t, n.contentProtection);
|
|
9814
9824
|
const h = n.contentProtection || {};
|
|
9815
9825
|
this._contentProtection = h;
|
|
9816
9826
|
const c = this.mergeKeyboardPeripherals(
|
|
@@ -10134,7 +10144,7 @@ class zr extends ys {
|
|
|
10134
10144
|
}
|
|
10135
10145
|
}
|
|
10136
10146
|
export {
|
|
10137
|
-
|
|
10147
|
+
kr as AudioDefaults,
|
|
10138
10148
|
zr as AudioNavigator,
|
|
10139
10149
|
ce as AudioPreferences,
|
|
10140
10150
|
Vi as AudioPreferencesEditor,
|
|
@@ -10157,7 +10167,7 @@ export {
|
|
|
10157
10167
|
Qs as FramePoolManager,
|
|
10158
10168
|
er as HorizontalThird,
|
|
10159
10169
|
bn as Injector,
|
|
10160
|
-
|
|
10170
|
+
kt as LineLengths,
|
|
10161
10171
|
ys as MediaNavigator,
|
|
10162
10172
|
ln as Navigator,
|
|
10163
10173
|
Me as Orientation,
|
|
@@ -10180,7 +10190,7 @@ export {
|
|
|
10180
10190
|
Js as WebPubNavigator,
|
|
10181
10191
|
Nt as WebPubPreferences,
|
|
10182
10192
|
Ri as WebPubPreferencesEditor,
|
|
10183
|
-
|
|
10193
|
+
Oi as WebPubSettings,
|
|
10184
10194
|
Rs as WebRSProperties,
|
|
10185
10195
|
pn as WebUserProperties,
|
|
10186
10196
|
E as ensureBoolean,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
body::-webkit-scrollbar {
|
|
56
56
|
display: none; /* for Chrome, Safari, and Opera */
|
|
57
57
|
}
|
|
58
|
-
`,e.document.head.appendChild(n),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",W.moduleName,()=>{Ut(this.wnd);const i=this.doc().scrollTop;i>1?this.doc().scrollTop=i-1:this.doc().scrollTop=i+1,this.doc().scrollTop=i}),t.register("go_progression",W.moduleName,(i,o)=>{const a=i;if(a<0||a>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*a,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_id",W.moduleName,(i,o)=>{const a=e.document.getElementById(i);if(!a){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_text",W.moduleName,(i,o)=>{let a;Array.isArray(i)&&(i.length>1&&(a=i[1]),i=i[0]);const s=oe.deserialize(i),l=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:s,locations:a?new k({otherLocations:new Map([["cssSelector",a]])}):void 0}));if(!l){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=l.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_start",W.moduleName,(i,o)=>{if(this.doc().scrollTop===0)return o(!1);this.doc().scrollTop=0,this.reportProgress(),o(!0)}),t.register("go_end",W.moduleName,(i,o)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return o(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),o(!0)}),t.register("unfocus",W.moduleName,(i,o)=>{z(this.wnd),o(!0)}),t.register("scroll_protection",W.moduleName,(i,o)=>{this.enableScrollProtection(),o(!0)}),t.register(["go_next","go_prev"],W.moduleName,(i,o)=>o(!1)),t.register("focus",W.moduleName,(i,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",W.moduleName,(i,o)=>{const a=lt(e,!0);this.comms.send("first_visible_locator",a.serialize()),o(!0)}),t.log("ScrollSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(W.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(Qn)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("ScrollSnapper Unmounted"),!0}};W.moduleName="scroll_snapper";let Ft=W;const B=class B extends be{constructor(){super(...arguments),this.patternAnalyzer=null,this.lastScrollTime=0,this.isScrollProtectionEnabled=!1,this.initialScrollHandled=!1,this.isScrolling=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce=null,this.handleScroll=e=>{if(this.comms.ready&&!this.isResizing){if(!this.initialScrollHandled){this.lastScrollTop=this.doc().scrollTop,this.initialScrollHandled=!0,this.reportProgress();return}this.isScrolling||(this.isScrolling=!0,this.wnd.requestAnimationFrame(()=>{this.reportProgress();const t=this.doc().scrollTop,n=t-this.lastScrollTop;if(this.lastScrollTop=t,this.isScrollProtectionEnabled&&Math.abs(n)>5){const i=Date.now(),o=i-(this.lastScrollTime||i);if(this.patternAnalyzer&&this.patternAnalyzer.analyze(n>0?"down":"up",Math.abs(n),o)){const s=e.target&&"tagName"in e.target?{tagName:e.target.tagName}:null;this.comms?.send("content_protection",{type:"suspicious_scrolling",timestamp:Date.now(),scrollDelta:n,scrollDirection:n>0?"down":"up",targetElement:s})}this.lastScrollTime=i}this.comms.send("scroll",n),this.isScrolling=!1}))}}}doc(){return this.wnd.document.scrollingElement}reportProgress(){if(!this.comms.ready)return;const e=Math.ceil(this.doc().scrollTop),t=this.doc().scrollHeight,n=this.wnd.innerHeight,i=Math.max(0,Math.min(1,e/t)),o=Math.max(0,Math.min(1,(e+n)/t));this.comms.send("progress",{start:i,end:o})}enableScrollProtection(){this.patternAnalyzer||(this.patternAnalyzer=new ct(Tt),this.isScrollProtectionEnabled=!0,this.comms?.log("Scroll protection enabled"))}mount(e,t){return this.wnd=e,this.comms=t,this.initialScrollHandled=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce&&(this.wnd.clearTimeout(this.resizeDebounce),this.resizeDebounce=null),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",B.moduleName,()=>{Ut(this.wnd);const n=this.doc().scrollTop;n>1?this.doc().scrollTop=n-1:this.doc().scrollTop=n+1,this.doc().scrollTop=n}),t.register("go_progression",B.moduleName,(n,i)=>{const o=n;if(o<0||o>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*o,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_id",B.moduleName,(n,i)=>{const o=e.document.getElementById(n);if(!o){i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=o.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_text",B.moduleName,(n,i)=>{let o;Array.isArray(n)&&(n.length>1&&(o=n[1]),n=n[0]);const a=oe.deserialize(n),s=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:a,locations:o?new k({otherLocations:new Map([["cssSelector",o]])}):void 0}));if(!s){i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_start",B.moduleName,(n,i)=>{if(this.doc().scrollTop===0)return i(!1);this.doc().scrollTop=0,this.reportProgress(),i(!0)}),t.register("go_end",B.moduleName,(n,i)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return i(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),i(!0)}),t.register("unfocus",B.moduleName,(n,i)=>{z(this.wnd),i(!0)}),t.register("scroll_protection",B.moduleName,(n,i)=>{this.enableScrollProtection(),i(!0)}),t.register(["go_next","go_prev"],B.moduleName,(n,i)=>i(!1)),t.register("focus",B.moduleName,(n,i)=>{this.reportProgress(),i(!0)}),t.register("first_visible_locator",B.moduleName,(n,i)=>{const o=lt(e,!0);t.send("first_visible_locator",o.serialize()),i(!0)}),t.log("WebPubSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(B.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("WebPubSnapper Unmounted"),!0}};B.moduleName="webpub_snapper";let Nt=B;class Fo{constructor(e,t){this.window=e,this.copyHistory=[],this.lastSelectionLength=0,this.lastSelectionTime=0,this.options=t}cleanupOldHistory(e){this.copyHistory=this.copyHistory.filter(n=>e-n.timestamp<1e4),this.copyHistory.length>this.options.historySize&&(this.copyHistory=this.copyHistory.slice(-this.options.historySize))}isSuspiciousPattern(e){return this.copyHistory.length<3?!1:this.copyHistory.filter(i=>e-i.timestamp<2e3).length>=3?!0:this.copyHistory.slice().sort((i,o)=>i.timestamp-o.timestamp).every((i,o,a)=>o===0?!0:i.length>a[o-1].length*1.5)}shouldAllowCopy(e){if(!this.options.enabled)return!0;const t=this.window.getSelection();if(!t)return!0;const i=t.toString().length,o=this.window.document.body.innerText.length,a=Date.now();if(this.cleanupOldHistory(a),i<this.options.minThreshold)return this.copyHistory.push({timestamp:a,length:i,wasBlocked:!1}),!0;const l=a-this.lastSelectionTime<100&&i>this.lastSelectionLength*1.5,c=Math.min(o*this.options.maxSelectionPercent,this.options.absoluteMaxChars),h=this.isSuspiciousPattern(a),u=i>c||l||h;return this.copyHistory.push({timestamp:a,length:i,wasBlocked:u}),u?(e?.preventDefault(),!1):(this.lastSelectionLength=i,this.lastSelectionTime=a,!0)}destroy(){this.lastSelectionLength=0,this.lastSelectionTime=0,this.copyHistory=[],this.options.enabled=!1}}class No{constructor(e=Zn){this.options=e,this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}analyze(e){if(!e)return this.clear(),!1;const t=e.toString();if(t.length===0)return this.clear(),!1;if(e.type!=="Range"||!e.rangeCount)return!1;const n=Date.now();if(t.length<=50||t===this.lastSelectedText)return!1;if(this.selectionStartTime===0)return this.selectionStartTime=n,this.lastSelectedText=t,!1;if(n-this.selectionStartTime<500)return!1;n-this.lastSelectionTime>1e3&&(this.lastSelectionTime=n),this.selectionStartTime===0&&(this.selectionStartTime=n),this.lastSelectedText=t;const o=this.analyzeSelectionPattern(e,n);return this.cleanup(n),o}analyzeSelectionPattern(e,t){if(!e.rangeCount)return!1;const n=e.getRangeAt(0),i=n.toString(),o=(t-this.selectionStartTime)/1e3;if(i.length/Math.max(1,o)>this.options.maxSelectionsPerSecond)return!0;const s=n.startOffset,l=Math.abs(s-this.lastSelectionPosition);return this.selectionPatterns.push(l),this.selectionPatterns.length>this.options.historySize&&(this.selectionPatterns.shift(),this.calculateVariance(this.selectionPatterns)<this.options.minVariance)?!0:(this.lastSelectionPosition=s,!1)}calculateVariance(e){if(e.length===0)return 0;const t=e.reduce((n,i)=>n+i,0)/e.length;return e.reduce((n,i)=>n+Math.pow(i-t,2),0)/e.length}cleanup(e){this.events=this.events.filter(t=>e-t.timestamp<=1e3)}clear(){this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}}class ei{match(e,t){for(const n of t){const i=e.keyCode===n.keyCode,o=n.ctrl===void 0||e.ctrlKey===n.ctrl,a=n.shift===void 0||e.shiftKey===n.shift,s=n.alt===void 0||e.altKey===n.alt,l=n.meta===void 0||e.metaKey===n.meta;if(i&&o&&a&&s&&l)return!0}return!1}createKeyHandler(e,t){return n=>{this.match(n,e)&&(n.preventDefault(),n.stopPropagation(),t(n))}}createActivityEvent(e,t,n,i){let o;if(i){const a=i.getSelection(),s=a?.toString()||"",c=(s&&a?.rangeCount?a.getRangeAt(0)?.getClientRects():null)?.[0];c&&s&&(o={text:s,x:c.x,y:c.y,width:c.width,height:c.height})}return{type:t,timestamp:Date.now(),key:e.key,code:e.code,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,targetFrameSrc:n,selectedText:o}}createKeyboardHandlers(e,t,n,i){const o=[];return t.forEach(a=>{o.push(...a.keyCombos.map(s=>({...s,handler:l=>{const c=a.type,h=this.createActivityEvent(l,c,e,i);n(h)}})))}),o}createUnifiedHandler(e,t,n,i){const o=this.createKeyboardHandlers(e,t,n,i);return a=>{for(const s of o)if(this.match(a,[s])){a.preventDefault(),a.stopPropagation(),s.handler(a);return}}}}const Ce=class Ce extends fe{constructor(){super(...arguments),this.configApplied=!1,this.cleanupCallbacks=[],this.pointerMoved=!1,this.isContextMenuEnabled=!1,this.isDragAndDropEnabled=!1,this.isSelectionMonitoringEnabled=!1,this.isBulkCopyProtectionEnabled=!1,this.selectionAnalyzer=null,this.currentSelection=null,this.bulkCopyProtector=null,this.keyManager=new ei,this.keyDownHandler=null,this.preventBulkCopy=e=>{if(!this.isBulkCopyProtectionEnabled||!this.bulkCopyProtector)return!0;if(!this.bulkCopyProtector.shouldAllowCopy(e)){e.preventDefault();const t=this.wnd.getSelection(),n=t?.toString()||"",o=(n?t?.getRangeAt(0)?.getClientRects():null)?.[0],a={type:"bulk_copy",timestamp:Date.now(),clipboardTypes:e.clipboardData?.types?[...e.clipboardData.types]:[],selectedText:o?{text:n,x:o.x,y:o.y,width:o.width,height:o.height}:void 0,selectionLength:n.length,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",a),!1}return!0},this.handleSelection=e=>{if(!this.isSelectionMonitoringEnabled||!this.wnd||!this.selectionAnalyzer)return;const t=this.wnd.getSelection();if(t){if(this.currentSelection=t.toString(),this.selectionAnalyzer.analyze(t)&&this.currentSelection){const i=this.wnd.getSelection(),o=i?.toString()||"",s=(o&&i?.rangeCount?i.getRangeAt(0)?.getClientRects():null)?.[0],l={type:"suspicious_selection",timestamp:Date.now(),selectionLength:o.length,selectedText:{text:o,x:s?.x??0,y:s?.y??0,width:s?.width??0,height:s?.height??0},eventType:e?.type||"selectionchange",targetFrameSrc:this.wnd.location.href};this.comms?.send("content_protection",l)}}else this.currentSelection=null},this.onDragOver=e=>{this.isDragAndDropEnabled&&(e.preventDefault(),e.stopPropagation())},this.onDragStart=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t={type:"drag_detected",timestamp:Date.now(),dataTransferTypes:e.dataTransfer?.types?[...e.dataTransfer.types]:[],targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",t),!1}else return!0},this.onDrop=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t=e.dataTransfer,n={type:"drop_detected",timestamp:Date.now(),dataTransferTypes:t?.types?[...t.types]:[],fileCount:t?.files?.length||0,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",n),!1}else return!0},this.onContext=e=>{if(this.isContextMenuEnabled){e.preventDefault();const t=this.wnd.getSelection(),n=t?.toString()||"",o=(n&&t?.rangeCount?t.getRangeAt(0)?.getClientRects():null)?.[0],a={timestamp:Date.now(),clientX:e.clientX,clientY:e.clientY,...o&&{selectedText:{text:n,x:o.x,y:o.y,width:o.width,height:o.height}},targetFrameSrc:this.wnd.location.href};this.comms?.send("context_menu",a)}},this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onClicker=this.onClick.bind(this)}addContextMenuPrevention(){this.isContextMenuEnabled||!this.wnd||(this.wnd.document.addEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!0)}removeContextMenuPrevention(){!this.isContextMenuEnabled||!this.wnd||(this.wnd.document.removeEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!1)}addDragAndDropPrevention(){this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.addEventListener("dragstart",this.onDragStart),this.wnd.document.addEventListener("dragover",this.onDragOver),this.wnd.document.addEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!0)}removeDragAndDropPrevention(){!this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.removeEventListener("dragstart",this.onDragStart),this.wnd.document.removeEventListener("dragover",this.onDragOver),this.wnd.document.removeEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!1)}enableKeyboardPeripherals(e=[]){this.disableKeyboardPeripherals();const t=n=>{this.comms?.send("keyboard_peripherals",n)};this.keyDownHandler=this.keyManager.createUnifiedHandler(this.wnd.location.href,e,t,this.wnd),this.wnd&&this.wnd.document.addEventListener("keydown",this.keyDownHandler,{capture:!0})}disableKeyboardPeripherals(){this.wnd&&this.keyDownHandler&&(this.wnd.document.removeEventListener("keydown",this.keyDownHandler,{capture:!0}),this.keyDownHandler=null)}addBulkCopyProtection(e={}){if(this.isBulkCopyProtectionEnabled||!this.wnd)return;const t=To,n=e?{...t,...e}:t;this.bulkCopyProtector=new Fo(this.wnd,n),this.wnd.document.addEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.addEventListener("cut",this.preventBulkCopy,!0),this.isBulkCopyProtectionEnabled=!0}removeBulkCopyProtection(){!this.isBulkCopyProtectionEnabled||!this.wnd||(this.wnd.document.removeEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.removeEventListener("cut",this.preventBulkCopy,!0),this.bulkCopyProtector?.destroy(),this.bulkCopyProtector=null,this.isBulkCopyProtectionEnabled=!1)}addSelectionMonitoring(e){if(this.isSelectionMonitoringEnabled||!this.wnd)return;const t=e||Zn;this.selectionAnalyzer=new No(t),this.wnd.document.addEventListener("selectionchange",this.handleSelection),this.isSelectionMonitoringEnabled=!0}removeSelectionMonitoring(){!this.isSelectionMonitoringEnabled||!this.wnd||(this.wnd.document.removeEventListener("selectionchange",this.handleSelection),this.selectionAnalyzer?.clear(),this.selectionAnalyzer=null,this.isSelectionMonitoringEnabled=!1)}onPointUp(e){const t=this.wnd.getSelection();if(t&&t.toString()?.length>0){const i=t.getRangeAt(0)?.getClientRects();if(!i||i.length===0)return;const o=i[0],a={text:t.toString(),x:o.x,y:o.y,width:o.width,height:o.height,targetFrameSrc:this.wnd?.location?.href};this.comms.send("text_selected",a)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!t?.isCollapsed||!e.isPrimary)return;const n=this.wnd.devicePixelRatio;e.preventDefault(),this.comms.send(e.pointerType==="touch"?"tap":"click",{defaultPrevented:e.defaultPrevented,x:e.clientX*n,y:e.clientY*n,targetFrameSrc:this.wnd.location.href,targetElement:e.target.outerHTML,interactiveElement:qn(e.target)?.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)}),this.pointerMoved=!1}onPointMove(e){if(e.movementY!==void 0&&e.movementX!==void 0){(Math.abs(e.movementX)>1||Math.abs(e.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onClick(e){if(e.preventDefault(),!e.isTrusted){const t=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:e.clientX,clientY:e.clientY});Object.defineProperty(t,"target",{writable:!1,value:e.target}),Object.defineProperty(t,"defaultPrevented",{writable:!1,value:e.defaultPrevented}),this.onPointUp(t)}}registerProtectionHandlers(){this.comms?.register("peripherals_protection",Ce.moduleName,(e,t)=>{const n=e;if(!this.configApplied){if(this.configApplied=!0,n.monitorSelection){const i=typeof n.monitorSelection=="boolean"?void 0:n.monitorSelection;this.addSelectionMonitoring(i),this.comms?.log("Selection monitoring enabled")}typeof n.protectCopy=="object"?(this.addBulkCopyProtection({enabled:!0,...n.protectCopy}),this.comms?.log("Copy protection enabled (limited)")):n.protectCopy===!0&&(this.addBulkCopyProtection({enabled:!0,maxSelectionPercent:0,minThreshold:0,absoluteMaxChars:0}),this.comms?.log("Copy protection enabled")),n.disableContextMenu&&(this.addContextMenuPrevention(),this.comms?.log("Context menu protection enabled")),n.disableDragAndDrop&&(this.addDragAndDropPrevention(),this.comms?.log("Drag and drop protection enabled"))}t(!0)}),this.comms?.register("keyboard_peripherals",Ce.moduleName,(e,t)=>{const n=e;n&&n.length>0&&(this.enableKeyboardPeripherals(n),this.comms?.log(`Keyboard peripherals enabled: ${n.map(i=>i.type).join(", ")}`)),t(!0)})}mount(e,t){return this.wnd=e,this.comms=t,this.registerProtectionHandlers(),e.document.addEventListener("pointerdown",this.onPointerDown),e.document.addEventListener("pointerup",this.onPointerUp),e.document.addEventListener("pointermove",this.onPointerMove),e.document.addEventListener("click",this.onClicker),t.log("Peripherals Mounted"),!0}unmount(e,t){return this.removeBulkCopyProtection(),this.removeSelectionMonitoring(),this.removeContextMenuPrevention(),this.removeDragAndDropPrevention(),this.disableKeyboardPeripherals(),this.cleanupCallbacks.forEach(n=>n()),this.cleanupCallbacks=[],e.document.removeEventListener("pointerdown",this.onPointerDown),e.document.removeEventListener("pointerup",this.onPointerUp),e.document.removeEventListener("pointermove",this.onPointerMove),e.document.removeEventListener("click",this.onClicker),t.unregisterAll(Ce.moduleName),this.configApplied=!1,t.log("Peripherals Unmounted"),!0}};Ce.moduleName="peripherals";let It=Ce;const Ze=class Ze extends fe{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(e){this.comms?.send("error",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno})}unblock(e){for(e._readium_blockEvents=!1;e._readium_blockedEvents?.length>0;){const t=e._readium_blockedEvents.shift();switch(t[0]){case 0:Reflect.apply(t[1],t[2],t[3]);break;case 1:const n=t[1],i=t[2];e.removeEventListener(n.type,e._readium_eventBlocker,!0);const o=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});i?i.dispatchEvent(o):e.dispatchEvent(o);break}}}onMediaPlayEvent(){this.mediaPlayingCount++,this.comms?.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){this.mediaPlayingCount>0&&this.mediaPlayingCount--,this.comms?.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(e){const t=e.document.querySelectorAll("audio,video");for(let n=0;n<t.length;n++)t[n].pause()}mount(e,t){this.comms=t,e.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(e.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.5.0-beta.3",hasFeature:(i,o="")=>{switch(i){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!0;case"embedded-web-content":return!0;default:return!1}}},writable:!1}),"getAnimations"in e.document&&e.document.getAnimations().forEach(i=>{i.cancel(),this.allAnimations.add(i)}),t.register("activate",Ze.moduleName,(i,o)=>{this.allAnimations.forEach(a=>{a.cancel(),a.play()}),o(!0)}),t.register("unfocus",Ze.moduleName,(i,o)=>{this.pauseAllMedia(e),this.allAnimations.forEach(a=>a.pause()),o(!0)});const n=e.document.querySelectorAll("audio,video");for(let i=0;i<n.length;i++){const o=n[i];o.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),o.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return t.log("Setup Mounted"),!0}unmount(e,t){return e.removeEventListener("error",this.wndOnErr),e.removeEventListener("play",this.onMediaPlayEvent),e.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(n=>n.cancel()),this.allAnimations.clear(),t.log("Setup Unmounted"),!0}};Ze.moduleName="setup";let ht=Ze;const ti="readium-viewport",ne=class ne extends ht{onViewportWidthChanged(e){const t=e.target;Ae(t,"--RS__viewportWidth",`${t.innerWidth}px`)}mount(e,t){if(!super.mount(e,t))return!1;const n=e.document.createElement("meta");return n.dataset.readium="true",n.setAttribute("name","viewport"),n.setAttribute("id",ti),n.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),e.document.head.appendChild(n),e.addEventListener("orientationchange",this.onViewportWidthChanged),e.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:e}),t.register("get_properties",ne.moduleName,(i,o)=>{Et(e),o(!0)}),t.register("update_properties",ne.moduleName,(i,o)=>{i["--RS__viewportWidth"]=`${e.innerWidth}px`,Hn(e,i),o(!0)}),t.register("set_property",ne.moduleName,(i,o)=>{const a=i;Ae(e,a[0],a[1]),o(!0)}),t.register("remove_property",ne.moduleName,(i,o)=>{rt(e,i),o(!0)}),t.register("activate",ne.moduleName,(i,o)=>{this.unblock(e),o(!0)}),t.log("ReflowableSetup Mounted"),!0}unmount(e,t){return t.unregisterAll(ne.moduleName),e.document.head.querySelector(`#${ti}`)?.remove(),e.removeEventListener("orientationchange",this.onViewportWidthChanged),t.log("ReflowableSetup Unmounted"),super.unmount(e,t)}};ne.moduleName="reflowable_setup";let Dt=ne;const ni="readium-fixed-style",J=class J extends ht{mount(e,t){if(!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const n=e.document.createElement("style");return n.id=ni,n.dataset.readium="true",n.textContent=`
|
|
58
|
+
`,e.document.head.appendChild(n),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",W.moduleName,()=>{Ut(this.wnd);const i=this.doc().scrollTop;i>1?this.doc().scrollTop=i-1:this.doc().scrollTop=i+1,this.doc().scrollTop=i}),t.register("go_progression",W.moduleName,(i,o)=>{const a=i;if(a<0||a>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*a,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_id",W.moduleName,(i,o)=>{const a=e.document.getElementById(i);if(!a){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_text",W.moduleName,(i,o)=>{let a;Array.isArray(i)&&(i.length>1&&(a=i[1]),i=i[0]);const s=oe.deserialize(i),l=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:s,locations:a?new k({otherLocations:new Map([["cssSelector",a]])}):void 0}));if(!l){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=l.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_start",W.moduleName,(i,o)=>{if(this.doc().scrollTop===0)return o(!1);this.doc().scrollTop=0,this.reportProgress(),o(!0)}),t.register("go_end",W.moduleName,(i,o)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return o(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),o(!0)}),t.register("unfocus",W.moduleName,(i,o)=>{z(this.wnd),o(!0)}),t.register("scroll_protection",W.moduleName,(i,o)=>{this.enableScrollProtection(),o(!0)}),t.register(["go_next","go_prev"],W.moduleName,(i,o)=>o(!1)),t.register("focus",W.moduleName,(i,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",W.moduleName,(i,o)=>{const a=lt(e,!0);this.comms.send("first_visible_locator",a.serialize()),o(!0)}),t.log("ScrollSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(W.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(Qn)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("ScrollSnapper Unmounted"),!0}};W.moduleName="scroll_snapper";let Ft=W;const B=class B extends be{constructor(){super(...arguments),this.patternAnalyzer=null,this.lastScrollTime=0,this.isScrollProtectionEnabled=!1,this.initialScrollHandled=!1,this.isScrolling=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce=null,this.handleScroll=e=>{if(this.comms.ready&&!this.isResizing){if(!this.initialScrollHandled){this.lastScrollTop=this.doc().scrollTop,this.initialScrollHandled=!0,this.reportProgress();return}this.isScrolling||(this.isScrolling=!0,this.wnd.requestAnimationFrame(()=>{this.reportProgress();const t=this.doc().scrollTop,n=t-this.lastScrollTop;if(this.lastScrollTop=t,this.isScrollProtectionEnabled&&Math.abs(n)>5){const i=Date.now(),o=i-(this.lastScrollTime||i);if(this.patternAnalyzer&&this.patternAnalyzer.analyze(n>0?"down":"up",Math.abs(n),o)){const s=e.target&&"tagName"in e.target?{tagName:e.target.tagName}:null;this.comms?.send("content_protection",{type:"suspicious_scrolling",timestamp:Date.now(),scrollDelta:n,scrollDirection:n>0?"down":"up",targetElement:s})}this.lastScrollTime=i}this.comms.send("scroll",n),this.isScrolling=!1}))}}}doc(){return this.wnd.document.scrollingElement}reportProgress(){if(!this.comms.ready)return;const e=Math.ceil(this.doc().scrollTop),t=this.doc().scrollHeight,n=this.wnd.innerHeight,i=Math.max(0,Math.min(1,e/t)),o=Math.max(0,Math.min(1,(e+n)/t));this.comms.send("progress",{start:i,end:o})}enableScrollProtection(){this.patternAnalyzer||(this.patternAnalyzer=new ct(Tt),this.isScrollProtectionEnabled=!0,this.comms?.log("Scroll protection enabled"))}mount(e,t){return this.wnd=e,this.comms=t,this.initialScrollHandled=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce&&(this.wnd.clearTimeout(this.resizeDebounce),this.resizeDebounce=null),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",B.moduleName,()=>{Ut(this.wnd);const n=this.doc().scrollTop;n>1?this.doc().scrollTop=n-1:this.doc().scrollTop=n+1,this.doc().scrollTop=n}),t.register("go_progression",B.moduleName,(n,i)=>{const o=n;if(o<0||o>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*o,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_id",B.moduleName,(n,i)=>{const o=e.document.getElementById(n);if(!o){i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=o.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_text",B.moduleName,(n,i)=>{let o;Array.isArray(n)&&(n.length>1&&(o=n[1]),n=n[0]);const a=oe.deserialize(n),s=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:a,locations:o?new k({otherLocations:new Map([["cssSelector",o]])}):void 0}));if(!s){i(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),z(this.wnd),i(!0)})}),t.register("go_start",B.moduleName,(n,i)=>{if(this.doc().scrollTop===0)return i(!1);this.doc().scrollTop=0,this.reportProgress(),i(!0)}),t.register("go_end",B.moduleName,(n,i)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return i(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),i(!0)}),t.register("unfocus",B.moduleName,(n,i)=>{z(this.wnd),i(!0)}),t.register("scroll_protection",B.moduleName,(n,i)=>{this.enableScrollProtection(),i(!0)}),t.register(["go_next","go_prev"],B.moduleName,(n,i)=>i(!1)),t.register("focus",B.moduleName,(n,i)=>{this.reportProgress(),i(!0)}),t.register("first_visible_locator",B.moduleName,(n,i)=>{const o=lt(e,!0);t.send("first_visible_locator",o.serialize()),i(!0)}),t.log("WebPubSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(B.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("WebPubSnapper Unmounted"),!0}};B.moduleName="webpub_snapper";let Nt=B;class Fo{constructor(e,t){this.window=e,this.copyHistory=[],this.lastSelectionLength=0,this.lastSelectionTime=0,this.options=t}cleanupOldHistory(e){this.copyHistory=this.copyHistory.filter(n=>e-n.timestamp<1e4),this.copyHistory.length>this.options.historySize&&(this.copyHistory=this.copyHistory.slice(-this.options.historySize))}isSuspiciousPattern(e){return this.copyHistory.length<3?!1:this.copyHistory.filter(i=>e-i.timestamp<2e3).length>=3?!0:this.copyHistory.slice().sort((i,o)=>i.timestamp-o.timestamp).every((i,o,a)=>o===0?!0:i.length>a[o-1].length*1.5)}shouldAllowCopy(e){if(!this.options.enabled)return!0;const t=this.window.getSelection();if(!t)return!0;const i=t.toString().length,o=this.window.document.body.innerText.length,a=Date.now();if(this.cleanupOldHistory(a),i<this.options.minThreshold)return this.copyHistory.push({timestamp:a,length:i,wasBlocked:!1}),!0;const l=a-this.lastSelectionTime<100&&i>this.lastSelectionLength*1.5,c=Math.min(o*this.options.maxSelectionPercent,this.options.absoluteMaxChars),h=this.isSuspiciousPattern(a),u=i>c||l||h;return this.copyHistory.push({timestamp:a,length:i,wasBlocked:u}),u?(e?.preventDefault(),!1):(this.lastSelectionLength=i,this.lastSelectionTime=a,!0)}destroy(){this.lastSelectionLength=0,this.lastSelectionTime=0,this.copyHistory=[],this.options.enabled=!1}}class No{constructor(e=Zn){this.options=e,this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}analyze(e){if(!e)return this.clear(),!1;const t=e.toString();if(t.length===0)return this.clear(),!1;if(e.type!=="Range"||!e.rangeCount)return!1;const n=Date.now();if(t.length<=50||t===this.lastSelectedText)return!1;if(this.selectionStartTime===0)return this.selectionStartTime=n,this.lastSelectedText=t,!1;if(n-this.selectionStartTime<500)return!1;n-this.lastSelectionTime>1e3&&(this.lastSelectionTime=n),this.selectionStartTime===0&&(this.selectionStartTime=n),this.lastSelectedText=t;const o=this.analyzeSelectionPattern(e,n);return this.cleanup(n),o}analyzeSelectionPattern(e,t){if(!e.rangeCount)return!1;const n=e.getRangeAt(0),i=n.toString(),o=(t-this.selectionStartTime)/1e3;if(i.length/Math.max(1,o)>this.options.maxSelectionsPerSecond)return!0;const s=n.startOffset,l=Math.abs(s-this.lastSelectionPosition);return this.selectionPatterns.push(l),this.selectionPatterns.length>this.options.historySize&&(this.selectionPatterns.shift(),this.calculateVariance(this.selectionPatterns)<this.options.minVariance)?!0:(this.lastSelectionPosition=s,!1)}calculateVariance(e){if(e.length===0)return 0;const t=e.reduce((n,i)=>n+i,0)/e.length;return e.reduce((n,i)=>n+Math.pow(i-t,2),0)/e.length}cleanup(e){this.events=this.events.filter(t=>e-t.timestamp<=1e3)}clear(){this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}}class ei{match(e,t){for(const n of t){const i=e.keyCode===n.keyCode,o=n.ctrl===void 0||e.ctrlKey===n.ctrl,a=n.shift===void 0||e.shiftKey===n.shift,s=n.alt===void 0||e.altKey===n.alt,l=n.meta===void 0||e.metaKey===n.meta;if(i&&o&&a&&s&&l)return!0}return!1}createKeyHandler(e,t){return n=>{this.match(n,e)&&(n.preventDefault(),n.stopPropagation(),t(n))}}createActivityEvent(e,t,n,i){let o;if(i){const a=i.getSelection(),s=a?.toString()||"",c=(s&&a?.rangeCount?a.getRangeAt(0)?.getClientRects():null)?.[0];c&&s&&(o={text:s,x:c.x,y:c.y,width:c.width,height:c.height})}return{type:t,timestamp:Date.now(),key:e.key,code:e.code,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,targetFrameSrc:n,selectedText:o}}createKeyboardHandlers(e,t,n,i){const o=[];return t.forEach(a=>{o.push(...a.keyCombos.map(s=>({...s,handler:l=>{const c=a.type,h=this.createActivityEvent(l,c,e,i);n(h)}})))}),o}createUnifiedHandler(e,t,n,i){const o=this.createKeyboardHandlers(e,t,n,i);return a=>{for(const s of o)if(this.match(a,[s])){a.preventDefault(),a.stopPropagation(),s.handler(a);return}}}}const Ce=class Ce extends fe{constructor(){super(...arguments),this.configApplied=!1,this.cleanupCallbacks=[],this.pointerMoved=!1,this.isContextMenuEnabled=!1,this.isDragAndDropEnabled=!1,this.isSelectionMonitoringEnabled=!1,this.isBulkCopyProtectionEnabled=!1,this.selectionAnalyzer=null,this.currentSelection=null,this.bulkCopyProtector=null,this.keyManager=new ei,this.keyDownHandler=null,this.preventBulkCopy=e=>{if(!this.isBulkCopyProtectionEnabled||!this.bulkCopyProtector)return!0;if(!this.bulkCopyProtector.shouldAllowCopy(e)){e.preventDefault();const t=this.wnd.getSelection(),n=t?.toString()||"",o=(n?t?.getRangeAt(0)?.getClientRects():null)?.[0],a={type:"bulk_copy",timestamp:Date.now(),clipboardTypes:e.clipboardData?.types?[...e.clipboardData.types]:[],selectedText:o?{text:n,x:o.x,y:o.y,width:o.width,height:o.height}:void 0,selectionLength:n.length,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",a),!1}return!0},this.handleSelection=e=>{if(!this.isSelectionMonitoringEnabled||!this.wnd||!this.selectionAnalyzer)return;const t=this.wnd.getSelection();if(t){if(this.currentSelection=t.toString(),this.selectionAnalyzer.analyze(t)&&this.currentSelection){const i=this.wnd.getSelection(),o=i?.toString()||"",s=(o&&i?.rangeCount?i.getRangeAt(0)?.getClientRects():null)?.[0],l={type:"suspicious_selection",timestamp:Date.now(),selectionLength:o.length,selectedText:{text:o,x:s?.x??0,y:s?.y??0,width:s?.width??0,height:s?.height??0},eventType:e?.type||"selectionchange",targetFrameSrc:this.wnd.location.href};this.comms?.send("content_protection",l)}}else this.currentSelection=null},this.onDragOver=e=>{this.isDragAndDropEnabled&&(e.preventDefault(),e.stopPropagation())},this.onDragStart=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t={type:"drag_detected",timestamp:Date.now(),dataTransferTypes:e.dataTransfer?.types?[...e.dataTransfer.types]:[],targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",t),!1}else return!0},this.onDrop=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t=e.dataTransfer,n={type:"drop_detected",timestamp:Date.now(),dataTransferTypes:t?.types?[...t.types]:[],fileCount:t?.files?.length||0,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",n),!1}else return!0},this.onContext=e=>{if(this.isContextMenuEnabled){e.preventDefault();const t=this.wnd.getSelection(),n=t?.toString()||"",o=(n&&t?.rangeCount?t.getRangeAt(0)?.getClientRects():null)?.[0],a={timestamp:Date.now(),clientX:e.clientX,clientY:e.clientY,...o&&{selectedText:{text:n,x:o.x,y:o.y,width:o.width,height:o.height}},targetFrameSrc:this.wnd.location.href};this.comms?.send("context_menu",a)}},this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onClicker=this.onClick.bind(this)}addContextMenuPrevention(){this.isContextMenuEnabled||!this.wnd||(this.wnd.document.addEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!0)}removeContextMenuPrevention(){!this.isContextMenuEnabled||!this.wnd||(this.wnd.document.removeEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!1)}addDragAndDropPrevention(){this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.addEventListener("dragstart",this.onDragStart),this.wnd.document.addEventListener("dragover",this.onDragOver),this.wnd.document.addEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!0)}removeDragAndDropPrevention(){!this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.removeEventListener("dragstart",this.onDragStart),this.wnd.document.removeEventListener("dragover",this.onDragOver),this.wnd.document.removeEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!1)}enableKeyboardPeripherals(e=[]){this.disableKeyboardPeripherals();const t=n=>{this.comms?.send("keyboard_peripherals",n)};this.keyDownHandler=this.keyManager.createUnifiedHandler(this.wnd.location.href,e,t,this.wnd),this.wnd&&this.wnd.document.addEventListener("keydown",this.keyDownHandler,{capture:!0})}disableKeyboardPeripherals(){this.wnd&&this.keyDownHandler&&(this.wnd.document.removeEventListener("keydown",this.keyDownHandler,{capture:!0}),this.keyDownHandler=null)}addBulkCopyProtection(e={}){if(this.isBulkCopyProtectionEnabled||!this.wnd)return;const t=To,n=e?{...t,...e}:t;this.bulkCopyProtector=new Fo(this.wnd,n),this.wnd.document.addEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.addEventListener("cut",this.preventBulkCopy,!0),this.isBulkCopyProtectionEnabled=!0}removeBulkCopyProtection(){!this.isBulkCopyProtectionEnabled||!this.wnd||(this.wnd.document.removeEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.removeEventListener("cut",this.preventBulkCopy,!0),this.bulkCopyProtector?.destroy(),this.bulkCopyProtector=null,this.isBulkCopyProtectionEnabled=!1)}addSelectionMonitoring(e){if(this.isSelectionMonitoringEnabled||!this.wnd)return;const t=e||Zn;this.selectionAnalyzer=new No(t),this.wnd.document.addEventListener("selectionchange",this.handleSelection),this.isSelectionMonitoringEnabled=!0}removeSelectionMonitoring(){!this.isSelectionMonitoringEnabled||!this.wnd||(this.wnd.document.removeEventListener("selectionchange",this.handleSelection),this.selectionAnalyzer?.clear(),this.selectionAnalyzer=null,this.isSelectionMonitoringEnabled=!1)}onPointUp(e){const t=this.wnd.getSelection();if(t&&t.toString()?.length>0){const i=t.getRangeAt(0)?.getClientRects();if(!i||i.length===0)return;const o=i[0],a={text:t.toString(),x:o.x,y:o.y,width:o.width,height:o.height,targetFrameSrc:this.wnd?.location?.href};this.comms.send("text_selected",a)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!t?.isCollapsed||!e.isPrimary)return;const n=this.wnd.devicePixelRatio;e.preventDefault(),this.comms.send(e.pointerType==="touch"?"tap":"click",{defaultPrevented:e.defaultPrevented,x:e.clientX*n,y:e.clientY*n,targetFrameSrc:this.wnd.location.href,targetElement:e.target.outerHTML,interactiveElement:qn(e.target)?.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)}),this.pointerMoved=!1}onPointMove(e){if(e.movementY!==void 0&&e.movementX!==void 0){(Math.abs(e.movementX)>1||Math.abs(e.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onClick(e){if(e.preventDefault(),!e.isTrusted){const t=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:e.clientX,clientY:e.clientY});Object.defineProperty(t,"target",{writable:!1,value:e.target}),Object.defineProperty(t,"defaultPrevented",{writable:!1,value:e.defaultPrevented}),this.onPointUp(t)}}registerProtectionHandlers(){this.comms?.register("peripherals_protection",Ce.moduleName,(e,t)=>{const n=e;if(!this.configApplied){if(this.configApplied=!0,n.monitorSelection){const i=typeof n.monitorSelection=="boolean"?void 0:n.monitorSelection;this.addSelectionMonitoring(i),this.comms?.log("Selection monitoring enabled")}typeof n.protectCopy=="object"?(this.addBulkCopyProtection({enabled:!0,...n.protectCopy}),this.comms?.log("Copy protection enabled (limited)")):n.protectCopy===!0&&(this.addBulkCopyProtection({enabled:!0,maxSelectionPercent:0,minThreshold:0,absoluteMaxChars:0}),this.comms?.log("Copy protection enabled")),n.disableContextMenu&&(this.addContextMenuPrevention(),this.comms?.log("Context menu protection enabled")),n.disableDragAndDrop&&(this.addDragAndDropPrevention(),this.comms?.log("Drag and drop protection enabled"))}t(!0)}),this.comms?.register("keyboard_peripherals",Ce.moduleName,(e,t)=>{const n=e;n&&n.length>0&&(this.enableKeyboardPeripherals(n),this.comms?.log(`Keyboard peripherals enabled: ${n.map(i=>i.type).join(", ")}`)),t(!0)})}mount(e,t){return this.wnd=e,this.comms=t,this.registerProtectionHandlers(),e.document.addEventListener("pointerdown",this.onPointerDown),e.document.addEventListener("pointerup",this.onPointerUp),e.document.addEventListener("pointermove",this.onPointerMove),e.document.addEventListener("click",this.onClicker),t.log("Peripherals Mounted"),!0}unmount(e,t){return this.removeBulkCopyProtection(),this.removeSelectionMonitoring(),this.removeContextMenuPrevention(),this.removeDragAndDropPrevention(),this.disableKeyboardPeripherals(),this.cleanupCallbacks.forEach(n=>n()),this.cleanupCallbacks=[],e.document.removeEventListener("pointerdown",this.onPointerDown),e.document.removeEventListener("pointerup",this.onPointerUp),e.document.removeEventListener("pointermove",this.onPointerMove),e.document.removeEventListener("click",this.onClicker),t.unregisterAll(Ce.moduleName),this.configApplied=!1,t.log("Peripherals Unmounted"),!0}};Ce.moduleName="peripherals";let It=Ce;const Ze=class Ze extends fe{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(e){this.comms?.send("error",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno})}unblock(e){for(e._readium_blockEvents=!1;e._readium_blockedEvents?.length>0;){const t=e._readium_blockedEvents.shift();switch(t[0]){case 0:Reflect.apply(t[1],t[2],t[3]);break;case 1:const n=t[1],i=t[2];e.removeEventListener(n.type,e._readium_eventBlocker,!0);const o=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});i?i.dispatchEvent(o):e.dispatchEvent(o);break}}}onMediaPlayEvent(){this.mediaPlayingCount++,this.comms?.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){this.mediaPlayingCount>0&&this.mediaPlayingCount--,this.comms?.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(e){const t=e.document.querySelectorAll("audio,video");for(let n=0;n<t.length;n++)t[n].pause()}mount(e,t){this.comms=t,e.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(e.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.5.1",hasFeature:(i,o="")=>{switch(i){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!0;case"embedded-web-content":return!0;default:return!1}}},writable:!1}),"getAnimations"in e.document&&e.document.getAnimations().forEach(i=>{i.cancel(),this.allAnimations.add(i)}),t.register("activate",Ze.moduleName,(i,o)=>{this.allAnimations.forEach(a=>{a.cancel(),a.play()}),o(!0)}),t.register("unfocus",Ze.moduleName,(i,o)=>{this.pauseAllMedia(e),this.allAnimations.forEach(a=>a.pause()),o(!0)});const n=e.document.querySelectorAll("audio,video");for(let i=0;i<n.length;i++){const o=n[i];o.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),o.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return t.log("Setup Mounted"),!0}unmount(e,t){return e.removeEventListener("error",this.wndOnErr),e.removeEventListener("play",this.onMediaPlayEvent),e.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(n=>n.cancel()),this.allAnimations.clear(),t.log("Setup Unmounted"),!0}};Ze.moduleName="setup";let ht=Ze;const ti="readium-viewport",ne=class ne extends ht{onViewportWidthChanged(e){const t=e.target;Ae(t,"--RS__viewportWidth",`${t.innerWidth}px`)}mount(e,t){if(!super.mount(e,t))return!1;const n=e.document.createElement("meta");return n.dataset.readium="true",n.setAttribute("name","viewport"),n.setAttribute("id",ti),n.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),e.document.head.appendChild(n),e.addEventListener("orientationchange",this.onViewportWidthChanged),e.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:e}),t.register("get_properties",ne.moduleName,(i,o)=>{Et(e),o(!0)}),t.register("update_properties",ne.moduleName,(i,o)=>{i["--RS__viewportWidth"]=`${e.innerWidth}px`,Hn(e,i),o(!0)}),t.register("set_property",ne.moduleName,(i,o)=>{const a=i;Ae(e,a[0],a[1]),o(!0)}),t.register("remove_property",ne.moduleName,(i,o)=>{rt(e,i),o(!0)}),t.register("activate",ne.moduleName,(i,o)=>{this.unblock(e),o(!0)}),t.log("ReflowableSetup Mounted"),!0}unmount(e,t){return t.unregisterAll(ne.moduleName),e.document.head.querySelector(`#${ti}`)?.remove(),e.removeEventListener("orientationchange",this.onViewportWidthChanged),t.log("ReflowableSetup Unmounted"),super.unmount(e,t)}};ne.moduleName="reflowable_setup";let Dt=ne;const ni="readium-fixed-style",J=class J extends ht{mount(e,t){if(!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const n=e.document.createElement("style");return n.id=ni,n.dataset.readium="true",n.textContent=`
|
|
59
59
|
html, body {
|
|
60
60
|
text-size-adjust: none;
|
|
61
61
|
-ms-text-size-adjust: none;
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
overflow-x: auto !important;
|
|
93
93
|
overflow-y: hidden !important;
|
|
94
94
|
}
|
|
95
|
-
`,e.document.head.appendChild(n),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",j.moduleName,()=>{Ut(this.wnd);const i=this.doc().scrollLeft;this.verticalLR?this.doc().scrollLeft=i>1?i-1:i+1:this.doc().scrollLeft=i<-1?i+1:i-1,this.doc().scrollLeft=i}),t.register("go_progression",j.moduleName,(i,o)=>{const a=i;if(a<0||a>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{const s=this.scrollable()*a;this.doc().scrollLeft=this.verticalLR?s:-s,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_id",j.moduleName,(i,o)=>{const a=e.document.getElementById(i);if(!a){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft+=a.getBoundingClientRect().left-e.innerWidth/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_text",j.moduleName,(i,o)=>{let a;Array.isArray(i)&&(i.length>1&&(a=i[1]),i=i[0]);const s=oe.deserialize(i),l=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:s,locations:a?new k({otherLocations:new Map([["cssSelector",a]])}):void 0}));if(!l){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft+=l.getBoundingClientRect().left-e.innerWidth/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_start",j.moduleName,(i,o)=>{if(this.doc().scrollLeft===0)return o(!1);this.doc().scrollLeft=0,this.reportProgress(),o(!0)}),t.register("go_end",j.moduleName,(i,o)=>{if(Math.abs(this.doc().scrollLeft)===this.scrollable())return o(!1);this.doc().scrollLeft=this.verticalLR?this.scrollable():-this.scrollable(),this.reportProgress(),o(!0)}),t.register(["go_next","go_prev"],j.moduleName,(i,o)=>o(!1)),t.register("unfocus",j.moduleName,(i,o)=>{z(this.wnd),o(!0)}),t.register("scroll_protection",j.moduleName,(i,o)=>{this.enableScrollProtection(),o(!0)}),t.register("focus",j.moduleName,(i,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",j.moduleName,(i,o)=>{const a=lt(e,!0);this.comms.send("first_visible_locator",a.serialize()),o(!0)}),t.log("CJKVerticalSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(j.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(ii)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("CJKVerticalSnapper Unmounted"),!0}};j.moduleName="cjk_vertical_snapper";let Bt=j;const Do=["fixed_setup","decorator","peripherals","print_protection"],Ho=["reflowable_setup","decorator","peripherals","column_snapper","scroll_snapper","cjk_vertical_snapper","print_protection"],Wo=["webpub_setup","webpub_snapper","decorator","peripherals","print_protection"],jt=new Map([Ht,Dt,Wt,Nt,It,At,Mt,Ft,Bt,Io].map(r=>[r.moduleName,r]));class _e{constructor(e=window,t=[]){this.loadedModules=[],this.wnd=e,this.comms=new co(e);const n=[...new Set(t)];if(n.length){if(typeof e>"u")throw Error("Loader is not in a web browser");e.parent!==e&&this.comms.log("Loader is probably in a frame"),this.loadedModules=n.map(i=>{const o=this.loadModule(i);if(o)return o.mount(this.wnd,this.comms),o}).filter(i=>i!==void 0)}}loadModule(e){const t=jt.get(e);return t===void 0?(this.comms.log(`Module "${name}" does not exist in the library`),t):new t}addModule(e){const t=this.loadModule(e);return!t||!t.mount(this.wnd,this.comms)?!1:(this.loadedModules.push(t),!0)}removeModule(e){const t=jt.get(e);if(t===void 0)return this.comms.log(`Module "${e}" does not exist in the library`),!1;const n=this.loadedModules.findIndex(i=>i instanceof t);return n<0?!1:(this.loadedModules[n].unmount(this.wnd,this.comms),this.loadedModules.splice(n,1),!0)}destroy(){this.comms.destroy(),this.loadedModules.forEach(e=>e.unmount(this.wnd,this.comms)),this.loadedModules=[]}}const Bo={type:"developer_tools",keyCombos:[{keyCode:73,meta:!0,alt:!0},{keyCode:74,meta:!0,alt:!0},{keyCode:85,meta:!0,alt:!0},{keyCode:67,meta:!0,alt:!0},{keyCode:67,meta:!0,shift:!0},{keyCode:67,ctrl:!0,shift:!0},{keyCode:123},{keyCode:123,shift:!0},{keyCode:123,ctrl:!0,shift:!0},{keyCode:123,meta:!0,alt:!0}]},jo={type:"select_all",keyCombos:[{keyCode:65,meta:!0},{keyCode:65,ctrl:!0}]},Go={type:"print",keyCombos:[{keyCode:80,meta:!0},{keyCode:80,ctrl:!0},{keyCode:80,meta:!0,shift:!0},{keyCode:80,ctrl:!0,shift:!0},{keyCode:80,meta:!0,alt:!0},{keyCode:80,ctrl:!0,alt:!0}]},Vo={type:"save",keyCombos:[{keyCode:83,meta:!0},{keyCode:83,ctrl:!0}]};class Gt{mergeKeyboardPeripherals(e,t=[]){const n=[],i=t.filter(o=>!["developer_tools","select_all","print","save"].includes(o.type));e.disableSelectAll&&n.push(jo),e.disableSave&&n.push(Vo),e.monitorDevTools&&n.push(Bo),e.protectPrinting?.disable&&n.push(Go);for(const o of i){const a=o.keyCombos.filter(s=>!n.some(l=>l.keyCombos.some(c=>s.keyCode===c.keyCode&&s.ctrl===c.ctrl&&s.shift===c.shift&&s.alt===c.alt&&s.meta===c.meta)));a.length>0&&n.push({...o,keyCombos:a})}return n}}class Vt extends Gt{goLeft(e=!1,t){this.readingProgression===N.ltr?this.goBackward(e,t):this.readingProgression===N.rtl&&this.goForward(e,t)}goRight(e=!1,t){this.readingProgression===N.ltr?this.goForward(e,t):this.readingProgression===N.rtl&&this.goBackward(e,t)}}class oi extends Gt{}class ri{constructor(e,t,n,i){this.injector=null,this.pub=e,this.item=n,this.burl=n.toURL(t)||"",this.cssProperties=i.cssProperties,this.injector=i.injector??null}async build(){if(!this.item.mediaType.isHTML)throw new Error(`Unsupported media type for WebPub: ${this.item.mediaType.string}`);return await this.buildHtmlFrame()}async buildHtmlFrame(){const e=await this.pub.get(this.item).readAsString();if(!e)throw new Error(`Failed reading item ${this.item.href}`);const t=new DOMParser().parseFromString(e,this.item.mediaType.string),n=t.querySelector("parsererror");if(n){const i=n.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${i?.textContent||n.textContent}`)}return this.injector&&await this.injector.injectForDocument(t,this.item),this.finalizeDOM(t,this.burl,this.item.mediaType,e,this.cssProperties)}setProperties(e,t){for(const n in e){const i=e[n];i&&t.documentElement.style.setProperty(n,i)}}finalizeDOM(e,t,n,i,o){if(!e)return"";if(o&&this.setProperties(o,e),e.body.querySelectorAll("img").forEach(s=>{s.setAttribute("fetchpriority","high")}),t!==void 0){const s=e.createElement("base");s.href=t,s.dataset.readium="true",e.head.firstChild.before(s)}let a;return n.string==="application/xhtml+xml"?a=new XMLSerializer().serializeToString(e):a=this.serializeAsHTML(e,i||""),URL.createObjectURL(new Blob([a],{type:n.isHTML?n.string:"application/xhtml+xml"}))}serializeAsHTML(e,t){const n=t.match(/<!DOCTYPE[^>]*>/i),i=n?n[0]+`
|
|
95
|
+
`,e.document.head.appendChild(n),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",j.moduleName,()=>{Ut(this.wnd);const i=this.doc().scrollLeft;this.verticalLR?this.doc().scrollLeft=i>1?i-1:i+1:this.doc().scrollLeft=i<-1?i+1:i-1,this.doc().scrollLeft=i}),t.register("go_progression",j.moduleName,(i,o)=>{const a=i;if(a<0||a>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{const s=this.scrollable()*a;this.doc().scrollLeft=this.verticalLR?s:-s,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_id",j.moduleName,(i,o)=>{const a=e.document.getElementById(i);if(!a){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft+=a.getBoundingClientRect().left-e.innerWidth/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_text",j.moduleName,(i,o)=>{let a;Array.isArray(i)&&(i.length>1&&(a=i[1]),i=i[0]);const s=oe.deserialize(i),l=Oe(this.wnd.document,new F({href:e.location.href,type:"text/html",text:s,locations:a?new k({otherLocations:new Map([["cssSelector",a]])}):void 0}));if(!l){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft+=l.getBoundingClientRect().left-e.innerWidth/2,this.reportProgress(),z(this.wnd),o(!0)})}),t.register("go_start",j.moduleName,(i,o)=>{if(this.doc().scrollLeft===0)return o(!1);this.doc().scrollLeft=0,this.reportProgress(),o(!0)}),t.register("go_end",j.moduleName,(i,o)=>{if(Math.abs(this.doc().scrollLeft)===this.scrollable())return o(!1);this.doc().scrollLeft=this.verticalLR?this.scrollable():-this.scrollable(),this.reportProgress(),o(!0)}),t.register(["go_next","go_prev"],j.moduleName,(i,o)=>o(!1)),t.register("unfocus",j.moduleName,(i,o)=>{z(this.wnd),o(!0)}),t.register("scroll_protection",j.moduleName,(i,o)=>{this.enableScrollProtection(),o(!0)}),t.register("focus",j.moduleName,(i,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",j.moduleName,(i,o)=>{const a=lt(e,!0);this.comms.send("first_visible_locator",a.serialize()),o(!0)}),t.log("CJKVerticalSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(j.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(ii)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("CJKVerticalSnapper Unmounted"),!0}};j.moduleName="cjk_vertical_snapper";let Bt=j;const Do=["fixed_setup","decorator","peripherals","print_protection"],Ho=["reflowable_setup","decorator","peripherals","column_snapper","scroll_snapper","cjk_vertical_snapper","print_protection"],Wo=["webpub_setup","webpub_snapper","decorator","peripherals","print_protection"],jt=new Map([Ht,Dt,Wt,Nt,It,At,Mt,Ft,Bt,Io].map(r=>[r.moduleName,r]));class _e{constructor(e=window,t=[]){this.loadedModules=[],this.wnd=e,this.comms=new co(e);const n=[...new Set(t)];if(n.length){if(typeof e>"u")throw Error("Loader is not in a web browser");e.parent!==e&&this.comms.log("Loader is probably in a frame"),this.loadedModules=n.map(i=>{const o=this.loadModule(i);if(o)return o.mount(this.wnd,this.comms),o}).filter(i=>i!==void 0)}}loadModule(e){const t=jt.get(e);return t===void 0?(this.comms.log(`Module "${name}" does not exist in the library`),t):new t}addModule(e){const t=this.loadModule(e);return!t||!t.mount(this.wnd,this.comms)?!1:(this.loadedModules.push(t),!0)}removeModule(e){const t=jt.get(e);if(t===void 0)return this.comms.log(`Module "${e}" does not exist in the library`),!1;const n=this.loadedModules.findIndex(i=>i instanceof t);return n<0?!1:(this.loadedModules[n].unmount(this.wnd,this.comms),this.loadedModules.splice(n,1),!0)}destroy(){this.comms.destroy(),this.loadedModules.forEach(e=>e.unmount(this.wnd,this.comms)),this.loadedModules=[]}}const Bo={type:"developer_tools",keyCombos:[{keyCode:73,meta:!0,alt:!0},{keyCode:73,ctrl:!0,shift:!0},{keyCode:74,meta:!0,alt:!0},{keyCode:74,ctrl:!0,shift:!0},{keyCode:85,meta:!0,alt:!0},{keyCode:67,meta:!0,alt:!0},{keyCode:67,meta:!0,shift:!0},{keyCode:67,ctrl:!0,shift:!0},{keyCode:65,meta:!0,alt:!0},{keyCode:84,meta:!0,shift:!0,alt:!0},{keyCode:67,shift:!0,alt:!0},{keyCode:123},{keyCode:123,shift:!0},{keyCode:123,ctrl:!0,shift:!0},{keyCode:123,meta:!0,alt:!0}]},jo={type:"select_all",keyCombos:[{keyCode:65,meta:!0},{keyCode:65,ctrl:!0}]},Go={type:"print",keyCombos:[{keyCode:80,meta:!0},{keyCode:80,ctrl:!0},{keyCode:80,meta:!0,shift:!0},{keyCode:80,ctrl:!0,shift:!0},{keyCode:80,meta:!0,alt:!0},{keyCode:80,ctrl:!0,alt:!0}]},Vo={type:"save",keyCombos:[{keyCode:83,meta:!0},{keyCode:83,ctrl:!0}]};class Gt{mergeKeyboardPeripherals(e,t=[]){const n=[],i=t.filter(o=>!["developer_tools","select_all","print","save"].includes(o.type));e.disableSelectAll&&n.push(jo),e.disableSave&&n.push(Vo),e.monitorDevTools&&n.push(Bo),e.protectPrinting?.disable&&n.push(Go);for(const o of i){const a=o.keyCombos.filter(s=>!n.some(l=>l.keyCombos.some(c=>s.keyCode===c.keyCode&&s.ctrl===c.ctrl&&s.shift===c.shift&&s.alt===c.alt&&s.meta===c.meta)));a.length>0&&n.push({...o,keyCombos:a})}return n}}class Vt extends Gt{goLeft(e=!1,t){this.readingProgression===N.ltr?this.goBackward(e,t):this.readingProgression===N.rtl&&this.goForward(e,t)}goRight(e=!1,t){this.readingProgression===N.ltr?this.goForward(e,t):this.readingProgression===N.rtl&&this.goBackward(e,t)}}class oi extends Gt{}class ri{constructor(e,t,n,i){this.injector=null,this.pub=e,this.item=n,this.burl=n.toURL(t)||"",this.cssProperties=i.cssProperties,this.injector=i.injector??null}async build(){if(!this.item.mediaType.isHTML)throw new Error(`Unsupported media type for WebPub: ${this.item.mediaType.string}`);return await this.buildHtmlFrame()}async buildHtmlFrame(){const e=await this.pub.get(this.item).readAsString();if(!e)throw new Error(`Failed reading item ${this.item.href}`);const t=new DOMParser().parseFromString(e,this.item.mediaType.string),n=t.querySelector("parsererror");if(n){const i=n.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${i?.textContent||n.textContent}`)}return this.injector&&await this.injector.injectForDocument(t,this.item),this.finalizeDOM(t,this.burl,this.item.mediaType,e,this.cssProperties)}setProperties(e,t){for(const n in e){const i=e[n];i&&t.documentElement.style.setProperty(n,i)}}finalizeDOM(e,t,n,i,o){if(!e)return"";if(o&&this.setProperties(o,e),e.body.querySelectorAll("img").forEach(s=>{s.setAttribute("fetchpriority","high")}),t!==void 0){const s=e.createElement("base");s.href=t,s.dataset.readium="true",e.head.firstChild.before(s)}let a;return n.string==="application/xhtml+xml"?a=new XMLSerializer().serializeToString(e):a=this.serializeAsHTML(e,i||""),URL.createObjectURL(new Blob([a],{type:n.isHTML?n.string:"application/xhtml+xml"}))}serializeAsHTML(e,t){const n=t.match(/<!DOCTYPE[^>]*>/i),i=n?n[0]+`
|
|
96
96
|
`:"";let a=e.documentElement.outerHTML;return i+a}}const $o=1e4;class ve{constructor(e,t){this.registry=new Map,this._ready=!1,this.listenerBuffer=[],this.handler=this.handle.bind(this),this.wnd=e,this.origin=t;try{this.channelId=window.crypto.randomUUID()}catch{this.channelId=Pt()}this.gc=setInterval(()=>{this.registry.forEach((n,i)=>{performance.now()-n.time>$o&&(console.warn(i,"event for",n.key,"was never handled!"),this.registry.delete(i))})},5e3),window.addEventListener("message",this.handler),this.send("_ping",void 0)}set listener(e){this.listenerBuffer.length>0&&this.listenerBuffer.forEach(t=>e(t[0],t[1])),this.listenerBuffer=[],this._listener=e}clearListener(){typeof this._listener=="function"&&(this._listener=void 0)}halt(){this._ready=!1,window.removeEventListener("message",this.handler),clearInterval(this.gc),this._listener=void 0,this.registry.clear()}resume(){window.addEventListener("message",this.handler),this._ready=!0}handle(e){const t=e.data;if(!t._readium){console.warn("Ignoring",t);return}if(t._channel===this.channelId)switch(t.key){case"_ack":{if(!t.id)return;const n=this.registry.get(t.id);if(!n)return;this.registry.delete(t.id),n.cb(!!t.data);return}case"_pong":this._ready=!0;default:{if(!this.ready)return;typeof this._listener=="function"?this._listener(t.key,t.data):this.listenerBuffer.push([t.key,t.data])}}}get ready(){return this._ready}send(e,t,n,i=!1,o=[]){const a=Pt();return n&&this.registry.set(a,{cb:n,time:performance.now(),key:e}),this.wnd.postMessage({_readium:ge,_channel:this.channelId,id:a,data:t,key:e,strict:i},"/",o),a}}const Xo={RS__oldStyleTf:"'Iowan Old Style', Sitka, 'Sitka Text', Palatino, 'Book Antiqua', 'URW Palladio L', P052, serif"},Yo=16,ai=Xo.RS__oldStyleTf;class we{constructor(e){this._optimalLineLength=null,this._canvas=document.createElement("canvas"),this._optimalChars=e.optimalChars,this._minChars=e.minChars,this._maxChars=e.maxChars,this._baseFontSize=e.baseFontSize||Yo,this._fontFace=e.fontFace||ai,this._sample=e.sample||null,this._padding=e.padding??0,this._letterSpacing=e.letterSpacing?Math.round(e.letterSpacing*this._baseFontSize):0,this._wordSpacing=e.wordSpacing?Math.round(e.wordSpacing*this._baseFontSize):0,this._isCJK=e.isCJK||!1,this._getRelative=e.getRelative||!1,this._minDivider=this._minChars&&this._minChars<this._optimalChars?this._optimalChars/this._minChars:this._minChars===null?null:1,this._maxMultiplier=this._maxChars&&this._maxChars>this._optimalChars?this._maxChars/this._optimalChars:this._maxChars===null?null:1,this._approximatedWordSpaces=we.approximateWordSpaces(this._optimalChars,this._sample)}updateMultipliers(){this._minDivider=this._minChars&&this._minChars<this._optimalChars?this._optimalChars/this._minChars:this._minChars===null?null:1,this._maxMultiplier=this._maxChars&&this._maxChars>this._optimalChars?this._maxChars/this._optimalChars:this._maxChars===null?null:1}update(e){e.optimalChars&&(this._optimalChars=e.optimalChars),e.minChars!==void 0&&(this._minChars=e.minChars),e.maxChars!==void 0&&(this._maxChars=e.maxChars),e.baseFontSize&&(this._baseFontSize=e.baseFontSize),e.fontFace!==void 0&&(this._fontFace=e.fontFace||ai),e.letterSpacing&&(this._letterSpacing=e.letterSpacing),e.wordSpacing&&(this._wordSpacing=e.wordSpacing),e.isCJK!=null&&(this._isCJK=e.isCJK),e.padding!==void 0&&(this._padding=e.padding??0),e.getRelative&&(this._getRelative=e.getRelative),e.sample&&(this._sample=e.sample,this._approximatedWordSpaces=we.approximateWordSpaces(this._optimalChars,this._sample)),this.updateMultipliers(),this._optimalLineLength=this.getOptimalLineLength()}get baseFontSize(){return this._baseFontSize}get minimalLineLength(){return this._optimalLineLength||(this._optimalLineLength=this.getOptimalLineLength()),this._minDivider!==null?Math.round(this._optimalLineLength/this._minDivider+this._padding)/(this._getRelative?this._baseFontSize:1):null}get maximalLineLength(){return this._optimalLineLength||(this._optimalLineLength=this.getOptimalLineLength()),this._maxMultiplier!==null?Math.round(this._optimalLineLength*this._maxMultiplier+this._padding)/(this._getRelative?this._baseFontSize:1):null}get optimalLineLength(){return this._optimalLineLength||(this._optimalLineLength=this.getOptimalLineLength()),Math.round(this._optimalLineLength+this._padding)/(this._getRelative?this._baseFontSize:1)}get all(){return this._optimalLineLength||(this._optimalLineLength=this.getOptimalLineLength()),{min:this.minimalLineLength,max:this.maximalLineLength,optimal:this.optimalLineLength,baseFontSize:this._baseFontSize}}static approximateWordSpaces(e,t){let n=0;if(t&&t.length>=e){const i=t.match(/([\s]+)/gi);n=(i?i.length:0)*(e/t.length)}return n}getLineLengthFallback(){const e=this._letterSpacing*(this._optimalChars-1),t=this._wordSpacing*this._approximatedWordSpaces;return this._optimalChars*(this._baseFontSize*.5)+e+t}getOptimalLineLength(){if(this._fontFace){if(typeof this._fontFace=="string")return this.measureText(this._fontFace);{const e=new FontFace(this._fontFace.name,`url(${this._fontFace.url})`);e.load().then(()=>(document.fonts.add(e),this.measureText(e.family)),t=>{})}}return this.getLineLengthFallback()}measureText(e){const t=this._canvas.getContext("2d");if(t&&e){let n=this._isCJK?"水".repeat(this._optimalChars):"0".repeat(this._optimalChars);if(t.font=`${this._baseFontSize}px ${e}`,this._sample&&this._sample.length>=this._optimalChars&&(n=this._sample.slice(0,this._optimalChars)),Object.hasOwn(t,"letterSpacing")&&Object.hasOwn(t,"wordSpacing"))return t.letterSpacing=this._letterSpacing.toString()+"px",t.wordSpacing=this._wordSpacing.toString()+"px",t.measureText(n).width;{const i=this._letterSpacing*(this._optimalChars-1),o=this._wordSpacing*we.approximateWordSpaces(this._optimalChars,this._sample);return t.measureText(n).width+i+o}}else return this.getLineLengthFallback()}}const si=()=>typeof navigator>"u"?"":navigator.userAgent||"",li=()=>typeof navigator>"u"?void 0:navigator.userAgentData||void 0;class ci{constructor(){const e=li(),t=si(),n=o=>(typeof o=="string"||typeof o=="number")&&o?String(o).replace(/_/g,".").split(".").map(a=>parseInt(a)||0):[],i=(o="")=>{if(!o)return[];const a=new RegExp("^.*"+o+"[ :\\/]?(\\d+([\\._]\\d+)*).*$");return a.test(t)?n(t.replace(a,"$1")):[]};this.OS=(o=>(/(macOS|Mac OS X)/.test(t)?(/\(iP(hone|od touch);/.test(t)&&(o.iOS=i("CPU (?:iPhone )?OS ")),/\(iPad;/.test(t)?o.iOS=o.iPadOS=i("CPU (?:iPhone )?OS "):/(macOS|Mac OS X) \d/.test(t)&&(document.ontouchend!==void 0?o.iOS=o.iPadOS=i():o.macOS=i("(?:macOS|Mac OS X) "))):/Windows( NT)? \d/.test(t)?o.Windows=(a=>a[0]!==6||!a[1]?a:a[1]===1?[7]:a[1]===2?[8]:[8,1])(i("Windows(?: NT)?")):/Android \d/.test(t)?o.Android=i("Android"):/CrOS/.test(t)?o.ChromeOS=i():/X11;/.test(t)&&(o.Linux=i()),o))({}),e&&e.getHighEntropyValues(["architecture","model","platform","platformVersion","uaFullVersion"]).then(o=>(a=>{const s=o.platform,l=o.platformVersion;if(!(!s||!l)){if(/^i(OS|P(hone|od touch))$/.test(s))a.iOS=n(l);else if(/^iPad(OS)?$/.test(s))a.iOS=a.iPadOS=n(l);else if(/^(macOS|(Mac )?OS X|Mac(Intel)?)$/.test(s))document.ontouchend!==void 0?a.iOS=a.iPadOS=n():a.macOS=n(l);else if(/^(Microsoft )?Windows$/.test(s))a.Windows=n(l);else if(/^(Google )?Android$/.test(s))a.Android=n(l);else if(/^((Google )?Chrome OS|CrOS)$/.test(s))a.ChromeOS=n(l);else if(/^(Linux|Ubuntu|X11)$/.test(s))a.Linux=n(l);else return;Object.keys(this.OS).forEach(c=>delete this.OS[c]),Object.assign(this.OS,a)}})({})),this.UA=(o=>{let a=!1;if(e&&Array.isArray(e.brands)){const s=e.brands.reduce((l,c)=>(l[c.brand]=[c.version*1],l),{});s["Google Chrome"]?(a=!0,o.Blink=o.Chromium=s.Chromium||[],o.Chrome=s["Google Chrome"]):s["Microsoft Edge"]?(a=!0,o.Blink=o.Chromium=s.Chromium||[],o.Edge=s["Microsoft Edge"]):s.Opera&&(a=!0,o.Blink=o.Chromium=s.Chromium||[],o.Opera=s.Opera)}return a||(/ Gecko\/\d/.test(t)?(o.Gecko=i("rv"),/ Waterfox\/\d/.test(t)?o.Waterfox=i("Waterfox"):/ Firefox\/\d/.test(t)&&(o.Firefox=i("Firefox"))):/ Edge\/\d/.test(t)?(o.EdgeHTML=i("Edge"),o.Edge=o.EdgeHTML):/ Chrom(ium|e)\/\d/.test(t)?(o.Blink=o.Chromium=(s=>s[0]?s:i("Chrome"))(i("Chromium")),/ EdgA?\/\d/.test(t)?o.Edge=(s=>s[0]?s:i("Edg"))(i("EdgA")):/ OPR\/\d/.test(t)?o.Opera=i("OPR"):/ Vivaldi\/\d/.test(t)?o.Vivaldi=i("Vivaldi"):/ Silk\/\d/.test(t)?o.Silk=i("Silk"):/ UCBrowser\/\d/.test(t)?o.UCBrowser=i("UCBrowser"):/ Phoebe\/\d/.test(t)?o.Phoebe=i("Phoebe"):o.Chrome=(s=>s[0]?s:o.Chromium)(i("Chrome"))):/ AppleWebKit\/\d/.test(t)?(o.WebKit=i("AppleWebKit"),/ CriOS \d/.test(t)?o.Chrome=i("CriOS"):/ FxiOS \d/.test(t)?o.Firefox=i("FxiOS"):/ EdgiOS\/\d/.test(t)?o.Edge=i("EdgiOS"):/ Version\/\d/.test(t)&&(o.Safari=i("Version"))):/ Trident\/\d/.test(t)&&(o.Trident=i("Trident"),o.InternetExplorer=(s=>s[0]?s:i("MSIE"))(i("rv")))),/[\[; ]FB(AN|_IAB)\//.test(t)&&(o.Facebook=i("FBAV")),/ Line\/\d/.test(t)&&(o.LINE=i("Line")),o})({}),this.Env={get:()=>[this.OS,this.UA].reduce((o,a)=>{for(const s in a)a[s]&&o.push(s);return o},[])}}}class qo extends ci{get iOSRequest(){const e=li(),t=si();if(this.OS.iOS&&!this.OS.iPadOS)return"mobile";if(this.OS.iPadOS)return/\(iPad;/.test(t)||e&&/^iPad(OS)?$/.test(e.platform)?"mobile":"desktop"}}const q=new ci,O=new qo;function se(r){const e=r.languages?.[0]?.toLowerCase(),t=r.readingProgression;if(e){if(e.startsWith("zh")||e.startsWith("ja")||e.startsWith("ko"))return t===N.rtl?"cjk-vertical":"cjk-horizontal";if(e.startsWith("mn-mong"))return"mongolian-vertical";if(e.startsWith("ar")||e.startsWith("fa")||e.startsWith("he"))return"rtl"}return"ltr"}class hi{constructor(e,t={},n=[]){this.hidden=!0,this.destroyed=!1,this.currModules=[],this.frame=document.createElement("iframe"),this.frame.classList.add("readium-navigator-iframe"),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transition="visibility 0s, opacity 0.1s linear",this.frame.style.backgroundColor="#FFFFFF",this.source=e,this.contentProtectionConfig={...t},this.keyboardPeripheralsConfig=[...n]}async load(e=[]){return new Promise((t,n)=>{if(this.loader){const i=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...e].sort().join("|")){try{t(i)}catch{}return}this.comms?.halt(),this.loader.destroy(),this.loader=new _e(i,e),this.currModules=e,this.comms=void 0;try{t(i)}catch{}return}this.frame.onload=()=>{const i=this.frame.contentWindow;this.loader=new _e(i,e),this.currModules=e;try{t(i)}catch{}},this.frame.onerror=i=>{try{n(i)}catch{}},this.frame.contentWindow.location.replace(this.source)})}applyContentProtection(){this.comms||this.comms.resume(),this.comms.send("peripherals_protection",this.contentProtectionConfig),this.keyboardPeripheralsConfig&&this.keyboardPeripheralsConfig.length>0&&this.comms.send("keyboard_peripherals",this.keyboardPeripheralsConfig),this.contentProtectionConfig.monitorScrollingExperimental&&this.comms.send("scroll_protection",{}),this.contentProtectionConfig.protectPrinting?.disable&&this.comms.send("print_protection",this.contentProtectionConfig.protectPrinting)}async destroy(){await this.hide(),this.loader?.destroy(),this.frame.remove(),this.destroyed=!0}async hide(){if(!this.destroyed){if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.hidden=!0,this.frame.parentElement)return this.comms===void 0||!this.comms.ready?void 0:new Promise((e,t)=>{this.comms?.send("unfocus",void 0,n=>{this.comms?.halt(),e()})});this.comms?.halt()}}async show(e){if(this.destroyed)throw Error("Trying to show frame when it doesn't exist");if(!this.frame.parentElement)throw Error("Trying to show frame that is not attached to the DOM");return this.comms?this.comms.resume():this.comms=new ve(this.frame.contentWindow,this.source),new Promise((t,n)=>{this.comms?.send("activate",void 0,()=>{this.comms?.send("focus",void 0,()=>{this.applyContentProtection();const i=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),this.hidden=!1,q.UA.WebKit&&this.comms?.send("force_webkit_recalc",void 0),t()};e!==void 0?this.comms?.send("go_progression",e,i):i()})})})}setCSSProperties(e){this.destroyed||!this.frame.contentWindow||(this.hidden&&(this.comms?this.comms?.resume():this.comms=new ve(this.frame.contentWindow,this.source)),this.comms?.send("update_properties",e),this.hidden&&this.comms?.halt())}get iframe(){if(this.destroyed)throw Error("Trying to use frame when it doesn't exist");return this.frame}get realSize(){if(this.destroyed)throw Error("Trying to use frame client rect when it doesn't exist");return this.frame.getBoundingClientRect()}get window(){if(this.destroyed||!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get msg(){return this.comms}get ldr(){return this.loader}}class di{constructor(e,t,n,i={},o=[]){this.pool=new Map,this.blobs=new Map,this.inprogress=new Map,this.pendingUpdates=new Map,this.injector=null,this.container=e,this.currentCssProperties=t,this.injector=n,this.contentProtectionConfig=i,this.keyboardPeripheralsConfig=[...o]}async destroy(){let e=this.inprogress.values(),t=e.next();const n=[];for(;t.value;)n.push(t.value),t=e.next();n.length>0&&await Promise.allSettled(n),this.inprogress.clear();let i=this.pool.values(),o=i.next();for(;o.value;)await o.value.destroy(),o=i.next();this.pool.clear(),this.blobs.forEach(a=>{this.injector?.releaseBlobUrl?.(a),URL.revokeObjectURL(a)}),this.blobs.clear(),this.injector?.dispose(),this.container.childNodes.forEach(a=>{(a.nodeType===Node.ELEMENT_NODE||a.nodeType===Node.TEXT_NODE)&&a.remove()})}async update(e,t,n){const i=e.readingOrder.items;let o=i.findIndex(l=>l.href===t.href);if(o<0)throw Error(`Locator not found in reading order: ${t.href}`);const a=i[o].href;this.inprogress.has(a)&&await this.inprogress.get(a);const s=new Promise(async(l,c)=>{const h=[],u=[];e.readingOrder.items.forEach((d,p)=>{p!==o&&p!==o-1&&p!==o+1&&(h.includes(d.href)||h.push(d.href)),p===o&&(u.includes(d.href)||u.push(d.href))}),h.forEach(async d=>{u.includes(d)||this.pool.has(d)&&(await this.pool.get(d)?.destroy(),this.pool.delete(d))}),this.currentBaseURL!==void 0&&e.baseURL!==this.currentBaseURL&&(this.blobs.forEach(d=>{this.injector?.releaseBlobUrl?.(d),URL.revokeObjectURL(d)}),this.blobs.clear()),this.currentBaseURL=e.baseURL;const m=async d=>{if(this.pendingUpdates.has(d)&&this.pendingUpdates.get(d)?.inPool===!1){const R=this.blobs.get(d);R&&(this.injector?.releaseBlobUrl?.(R),URL.revokeObjectURL(R),this.blobs.delete(d),this.pendingUpdates.delete(d))}if(this.pool.has(d)){const R=this.pool.get(d);if(!this.blobs.has(d))await R.destroy(),this.pool.delete(d),this.pendingUpdates.delete(d);else{await R.load(n);return}}const p=e.readingOrder.findWithHref(d);if(!p)return;if(!this.blobs.has(d)){const U=await new ri(e,this.currentBaseURL||"",p,{cssProperties:this.currentCssProperties,injector:this.injector}).build();this.blobs.set(d,U)}const _=new hi(this.blobs.get(d),this.contentProtectionConfig,this.keyboardPeripheralsConfig);d!==a&&await _.hide(),this.container.appendChild(_.iframe),await _.load(n),this.pool.set(d,_)};try{await Promise.all(u.map(d=>m(d)))}catch(d){c(d)}const f=this.pool.get(a);f?.source!==this._currentFrame?.source&&(await this._currentFrame?.hide(),f&&await f.load(n),f&&await f.show(t.locations.progression),this._currentFrame=f),l()});this.inprogress.set(a,s),await s,this.inprogress.delete(a)}setCSSProperties(e){if(!((n,i)=>{const o=Object.keys(n),a=Object.keys(i);if(o.length!==a.length)return!1;for(const s of o)if(n[s]!==i[s])return!1;return!0})(this.currentCssProperties||{},e)){this.currentCssProperties=e,this.pool.forEach(n=>{n.setCSSProperties(e)});for(const n of this.blobs.keys())this.pendingUpdates.set(n,{inPool:this.pool.has(n)})}}get currentFrames(){return[this._currentFrame]}get currentBounds(){const e={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON(){return this}};return this.currentFrames.forEach(t=>{if(!t)return;const n=t.realSize;e.x=Math.min(e.x,n.x),e.y=Math.min(e.y,n.y),e.width+=n.width,e.height=Math.max(e.height,n.height),e.top=Math.min(e.top,n.top),e.right=Math.min(e.right,n.right),e.bottom=Math.min(e.bottom,n.bottom),e.left=Math.min(e.left,n.left)}),e}}var $t,ui;function Ko(){if(ui)return $t;ui=1;function r(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function e(i,o){for(var a="",s=0,l=-1,c=0,h,u=0;u<=i.length;++u){if(u<i.length)h=i.charCodeAt(u);else{if(h===47)break;h=47}if(h===47){if(!(l===u-1||c===1))if(l!==u-1&&c===2){if(a.length<2||s!==2||a.charCodeAt(a.length-1)!==46||a.charCodeAt(a.length-2)!==46){if(a.length>2){var m=a.lastIndexOf("/");if(m!==a.length-1){m===-1?(a="",s=0):(a=a.slice(0,m),s=a.length-1-a.lastIndexOf("/")),l=u,c=0;continue}}else if(a.length===2||a.length===1){a="",s=0,l=u,c=0;continue}}o&&(a.length>0?a+="/..":a="..",s=2)}else a.length>0?a+="/"+i.slice(l+1,u):a=i.slice(l+1,u),s=u-l-1;l=u,c=0}else h===46&&c!==-1?++c:c=-1}return a}function t(i,o){var a=o.dir||o.root,s=o.base||(o.name||"")+(o.ext||"");return a?a===o.root?a+s:a+i+s:s}var n={resolve:function(){for(var o="",a=!1,s,l=arguments.length-1;l>=-1&&!a;l--){var c;l>=0?c=arguments[l]:(s===void 0&&(s=process.cwd()),c=s),r(c),c.length!==0&&(o=c+"/"+o,a=c.charCodeAt(0)===47)}return o=e(o,!a),a?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(r(o),o.length===0)return".";var a=o.charCodeAt(0)===47,s=o.charCodeAt(o.length-1)===47;return o=e(o,!a),o.length===0&&!a&&(o="."),o.length>0&&s&&(o+="/"),a?"/"+o:o},isAbsolute:function(o){return r(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,a=0;a<arguments.length;++a){var s=arguments[a];r(s),s.length>0&&(o===void 0?o=s:o+="/"+s)}return o===void 0?".":n.normalize(o)},relative:function(o,a){if(r(o),r(a),o===a||(o=n.resolve(o),a=n.resolve(a),o===a))return"";for(var s=1;s<o.length&&o.charCodeAt(s)===47;++s);for(var l=o.length,c=l-s,h=1;h<a.length&&a.charCodeAt(h)===47;++h);for(var u=a.length,m=u-h,f=c<m?c:m,d=-1,p=0;p<=f;++p){if(p===f){if(m>f){if(a.charCodeAt(h+p)===47)return a.slice(h+p+1);if(p===0)return a.slice(h+p)}else c>f&&(o.charCodeAt(s+p)===47?d=p:p===0&&(d=0));break}var _=o.charCodeAt(s+p),R=a.charCodeAt(h+p);if(_!==R)break;_===47&&(d=p)}var U="";for(p=s+d+1;p<=l;++p)(p===l||o.charCodeAt(p)===47)&&(U.length===0?U+="..":U+="/..");return U.length>0?U+a.slice(h+d):(h+=d,a.charCodeAt(h)===47&&++h,a.slice(h))},_makeLong:function(o){return o},dirname:function(o){if(r(o),o.length===0)return".";for(var a=o.charCodeAt(0),s=a===47,l=-1,c=!0,h=o.length-1;h>=1;--h)if(a=o.charCodeAt(h),a===47){if(!c){l=h;break}}else c=!1;return l===-1?s?"/":".":s&&l===1?"//":o.slice(0,l)},basename:function(o,a){if(a!==void 0&&typeof a!="string")throw new TypeError('"ext" argument must be a string');r(o);var s=0,l=-1,c=!0,h;if(a!==void 0&&a.length>0&&a.length<=o.length){if(a.length===o.length&&a===o)return"";var u=a.length-1,m=-1;for(h=o.length-1;h>=0;--h){var f=o.charCodeAt(h);if(f===47){if(!c){s=h+1;break}}else m===-1&&(c=!1,m=h+1),u>=0&&(f===a.charCodeAt(u)?--u===-1&&(l=h):(u=-1,l=m))}return s===l?l=m:l===-1&&(l=o.length),o.slice(s,l)}else{for(h=o.length-1;h>=0;--h)if(o.charCodeAt(h)===47){if(!c){s=h+1;break}}else l===-1&&(c=!1,l=h+1);return l===-1?"":o.slice(s,l)}},extname:function(o){r(o);for(var a=-1,s=0,l=-1,c=!0,h=0,u=o.length-1;u>=0;--u){var m=o.charCodeAt(u);if(m===47){if(!c){s=u+1;break}continue}l===-1&&(c=!1,l=u+1),m===46?a===-1?a=u:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===s+1?"":o.slice(a,l)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return t("/",o)},parse:function(o){r(o);var a={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return a;var s=o.charCodeAt(0),l=s===47,c;l?(a.root="/",c=1):c=0;for(var h=-1,u=0,m=-1,f=!0,d=o.length-1,p=0;d>=c;--d){if(s=o.charCodeAt(d),s===47){if(!f){u=d+1;break}continue}m===-1&&(f=!1,m=d+1),s===46?h===-1?h=d:p!==1&&(p=1):h!==-1&&(p=-1)}return h===-1||m===-1||p===0||p===1&&h===m-1&&h===u+1?m!==-1&&(u===0&&l?a.base=a.name=o.slice(1,m):a.base=a.name=o.slice(u,m)):(u===0&&l?(a.name=o.slice(1,h),a.base=o.slice(1,m)):(a.name=o.slice(u,h),a.base=o.slice(u,m)),a.ext=o.slice(h,m)),u>0?a.dir=o.slice(0,u-1):l&&(a.dir="/"),a},sep:"/",delimiter:":",win32:null,posix:null};return n.posix=n,$t=n,$t}var dt=Ko();const ut={experimentalHeaderFiltering:{description:"Attempts to filter out paragraphs that are implicitly headings or part of headers",scope:"RS",value:"readium-experimentalHeaderFiltering-on"},experimentalZoom:{description:"Attemps to filter out elements that are sized using viewport units and should not be scaled directly e.g. tables, images, iframes, etc.",scope:"RS",value:"readium-experimentalZoom-on"}};var Z=(r=>(r.start="start",r.left="left",r.right="right",r.justify="justify",r))(Z||{});const le={range:[0,100],step:1},Te={range:[.7,4],step:.05},ee={range:[100,1e3],step:100},Me={range:[50,250],step:10},Fe={range:[0,1],step:.125},Ne={range:[1,2],step:.1},ce={range:[20,100],step:1},Ie={range:[0,3],step:.25},De={range:[0,3],step:.25},He={range:[0,2],step:.125},We={range:[.7,4],step:.05},Be={range:[0,1],step:.1},je={range:[.5,4],step:.1},te={range:[5,60],step:5};class Ge{constructor(){}toFlag(e){return`readium-${e}-on`}toUnitless(e){return e.toString()}toPercentage(e,t=!1){return t||e>0&&e<=1?`${Math.round(e*100)}%`:`${e}%`}toVw(e){const t=Math.round(e*100);return`${Math.min(t,100)}vw`}toVh(e){const t=Math.round(e*100);return`${Math.min(t,100)}vh`}toPx(e){return`${e}px`}toRem(e){return`${e}rem`}}class Xt extends Ge{constructor(e){super(),this.a11yNormalize=e.a11yNormalize??null,this.bodyHyphens=e.bodyHyphens??null,this.fontFamily=e.fontFamily??null,this.fontWeight=e.fontWeight??null,this.iOSPatch=e.iOSPatch??null,this.iPadOSPatch=e.iPadOSPatch??null,this.letterSpacing=e.letterSpacing??null,this.ligatures=e.ligatures??null,this.lineHeight=e.lineHeight??null,this.noRuby=e.noRuby??null,this.paraIndent=e.paraIndent??null,this.paraSpacing=e.paraSpacing??null,this.textAlign=e.textAlign??null,this.wordSpacing=e.wordSpacing??null,this.zoom=e.zoom??null}toCSSProperties(){const e={};return this.a11yNormalize&&(e["--USER__a11yNormalize"]=this.toFlag("a11y")),this.bodyHyphens&&(e["--USER__bodyHyphens"]=this.bodyHyphens),this.fontFamily&&(e["--USER__fontFamily"]=this.fontFamily),this.fontWeight!=null&&(e["--USER__fontWeight"]=this.toUnitless(this.fontWeight)),this.iOSPatch&&(e["--USER__iOSPatch"]=this.toFlag("iOSPatch")),this.iPadOSPatch&&(e["--USER__iPadOSPatch"]=this.toFlag("iPadOSPatch")),this.letterSpacing!=null&&(e["--USER__letterSpacing"]=this.toRem(this.letterSpacing)),this.ligatures&&(e["--USER__ligatures"]=this.ligatures),this.lineHeight!=null&&(e["--USER__lineHeight"]=this.toUnitless(this.lineHeight)),this.noRuby&&(e["--USER__noRuby"]=this.toFlag("noRuby")),this.paraIndent!=null&&(e["--USER__paraIndent"]=this.toRem(this.paraIndent)),this.paraSpacing!=null&&(e["--USER__paraSpacing"]=this.toRem(this.paraSpacing)),this.textAlign&&(e["--USER__textAlign"]=this.textAlign),this.wordSpacing!=null&&(e["--USER__wordSpacing"]=this.toRem(this.wordSpacing)),this.zoom!==null&&(e["--USER__zoom"]=this.toPercentage(this.zoom,!0)),e}}class mi extends Ge{constructor(e){super(),this.experiments=e.experiments??null}toCSSProperties(){const e={};return this.experiments&&this.experiments.forEach(t=>{e["--RS__"+t]=ut[t].value}),e}}class pi{constructor(e){this.rsProperties=e.rsProperties,this.userProperties=e.userProperties}update(e){e.experiments&&(this.rsProperties.experiments=e.experiments);const t={a11yNormalize:e.textNormalization,bodyHyphens:typeof e.hyphens!="boolean"?null:e.hyphens?"auto":"none",fontFamily:e.fontFamily,fontWeight:e.fontWeight,iOSPatch:e.iOSPatch,iPadOSPatch:e.iPadOSPatch,letterSpacing:e.letterSpacing,ligatures:typeof e.ligatures!="boolean"?null:e.ligatures?"common-ligatures":"none",lineHeight:e.lineHeight,noRuby:e.noRuby,paraIndent:e.paragraphIndent,paraSpacing:e.paragraphSpacing,textAlign:e.textAlign,wordSpacing:e.wordSpacing,zoom:e.zoom};this.userProperties=new Xt(t)}}function gi(r,e){return r==null||e==null||r<=e?r:void 0}function fi(r,e){return r==null||e==null||r>=e?r:void 0}function I(r){return typeof r=="string"?r:r===null?null:void 0}function P(r){return typeof r=="boolean"||r==null?r:void 0}function Ve(r,e){if(r!==void 0)return r===null?null:e[r]!==void 0?r:void 0}function he(r){return typeof r=="boolean"||typeof r=="number"&&r>=0?r:r===null?null:void 0}function v(r){if(r!==void 0)return r===null?null:r<0?void 0:r}function M(r,e){if(r===void 0)return;if(r===null)return null;const t=Math.min(...e),n=Math.max(...e);return r>=t&&r<=n?r:void 0}function mt(r,e){return r===void 0?e:r}function Yt(r){if(r!==void 0)return r===null?null:r.filter(e=>e in ut)}class Pe{constructor(e={}){this.fontFamily=I(e.fontFamily),this.fontWeight=M(e.fontWeight,ee.range),this.hyphens=P(e.hyphens),this.iOSPatch=P(e.iOSPatch),this.iPadOSPatch=P(e.iPadOSPatch),this.letterSpacing=v(e.letterSpacing),this.ligatures=P(e.ligatures),this.lineHeight=v(e.lineHeight),this.noRuby=P(e.noRuby),this.paragraphIndent=v(e.paragraphIndent),this.paragraphSpacing=v(e.paragraphSpacing),this.textAlign=Ve(e.textAlign,Z),this.textNormalization=P(e.textNormalization),this.wordSpacing=v(e.wordSpacing),this.zoom=M(e.zoom,We.range)}static serialize(e){const{...t}=e;return JSON.stringify(t)}static deserialize(e){try{const t=JSON.parse(e);return new Pe(t)}catch(t){return console.error("Failed to deserialize preferences:",t),null}}merging(e){const t={...this};for(const n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return new Pe(t)}}class yi{constructor(e){this.fontFamily=I(e.fontFamily)||null,this.fontWeight=M(e.fontWeight,ee.range)||null,this.hyphens=P(e.hyphens)??null,this.iOSPatch=e.iOSPatch===!1?!1:(O.OS.iOS||O.OS.iPadOS)&&O.iOSRequest==="mobile",this.iPadOSPatch=e.iPadOSPatch===!1?!1:O.OS.iPadOS&&O.iOSRequest==="desktop",this.letterSpacing=v(e.letterSpacing)||null,this.ligatures=P(e.ligatures)??null,this.lineHeight=v(e.lineHeight)||null,this.noRuby=P(e.noRuby)??!1,this.paragraphIndent=v(e.paragraphIndent)??null,this.paragraphSpacing=v(e.paragraphSpacing)??null,this.textAlign=Ve(e.textAlign,Z)||null,this.textNormalization=P(e.textNormalization)??!1,this.wordSpacing=v(e.wordSpacing)||null,this.zoom=M(e.zoom,We.range)||1,this.experiments=Yt(e.experiments)??null}}class qt{constructor(e,t,n){this.fontFamily=null,this.fontWeight=null,this.hyphens=null,this.iOSPatch=null,this.iPadOSPatch=null,this.letterSpacing=null,this.ligatures=null,this.lineHeight=null,this.noRuby=null,this.paragraphIndent=null,this.paragraphSpacing=null,this.textAlign=null,this.textNormalization=null,this.wordSpacing=null,n&&(this.fontFamily=e.fontFamily||t.fontFamily||null,this.fontWeight=e.fontWeight!==void 0?e.fontWeight:t.fontWeight!==void 0?t.fontWeight:null,this.hyphens=typeof e.hyphens=="boolean"?e.hyphens:t.hyphens??null,this.iOSPatch=e.iOSPatch===!1?!1:e.iOSPatch===!0?(O.OS.iOS||O.OS.iPadOS)&&O.iOSRequest==="mobile":t.iOSPatch,this.iPadOSPatch=e.iPadOSPatch===!1?!1:e.iPadOSPatch===!0?O.OS.iPadOS&&O.iOSRequest==="desktop":t.iPadOSPatch,this.letterSpacing=e.letterSpacing!==void 0?e.letterSpacing:t.letterSpacing!==void 0?t.letterSpacing:null,this.ligatures=typeof e.ligatures=="boolean"?e.ligatures:t.ligatures??null,this.lineHeight=e.lineHeight!==void 0?e.lineHeight:t.lineHeight!==void 0?t.lineHeight:null,this.noRuby=typeof e.noRuby=="boolean"?e.noRuby:t.noRuby??null,this.paragraphIndent=e.paragraphIndent!==void 0?e.paragraphIndent:t.paragraphIndent!==void 0?t.paragraphIndent:null,this.paragraphSpacing=e.paragraphSpacing!==void 0?e.paragraphSpacing:t.paragraphSpacing!==void 0?t.paragraphSpacing:null,this.textAlign=e.textAlign||t.textAlign||null,this.textNormalization=typeof e.textNormalization=="boolean"?e.textNormalization:t.textNormalization??null,this.wordSpacing=e.wordSpacing!==void 0?e.wordSpacing:t.wordSpacing!==void 0?t.wordSpacing:null),this.zoom=e.zoom!==void 0?e.zoom:t.zoom!==void 0?t.zoom:null,this.experiments=t.experiments||null}}class T{constructor({initialValue:e=null,effectiveValue:t,isEffective:n,onChange:i}){this._value=e,this._effectiveValue=t,this._isEffective=n,this._onChange=i}set value(e){this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}clear(){this._value=null}}class A extends T{set value(e){this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}clear(){this._value=null}toggle(){this._value=!this._value,this._onChange(this._value)}}class Kt extends T{constructor({initialValue:e=null,effectiveValue:t,isEffective:n,onChange:i,supportedValues:o}){super({initialValue:e,effectiveValue:t,isEffective:n,onChange:i}),this._supportedValues=o}set value(e){if(e&&!this._supportedValues.includes(e))throw new Error(`Value '${String(e)}' is not in the supported values for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}get supportedValues(){return this._supportedValues}clear(){this._value=null}}class E extends T{constructor({initialValue:e=null,effectiveValue:t,isEffective:n,onChange:i,supportedRange:o,step:a}){super({initialValue:e,effectiveValue:t,isEffective:n,onChange:i}),this._supportedRange=o,this._step=a,this._decimals=this._step.toString().includes(".")?this._step.toString().split(".")[1].length:0}set value(e){if(e&&(e<this._supportedRange[0]||e>this._supportedRange[1]))throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}get supportedRange(){return this._supportedRange}get step(){return this._step}increment(){this._value&&this._value<this._supportedRange[1]&&(this._value=Math.min(Math.round((this._value+this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[1]),this._onChange(this._value))}decrement(){this._value&&this._value>this._supportedRange[0]&&(this._value=Math.max(Math.round((this._value-this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[0]),this._onChange(this._value))}format(e){return e.toString()}clear(){this._value=null}}class Zt{constructor(e,t,n){this.preferences=e,this.settings=t,this.metadata=n}clear(){this.preferences=new Pe({})}updatePreference(e,t){this.preferences[e]=t}get isDisplayTransformable(){return this.metadata?.accessibility?.feature?.some(e=>e.value===Je.DISPLAY_TRANSFORMABILITY.value)??!1}get fontFamily(){return new T({initialValue:this.preferences.fontFamily,effectiveValue:this.settings.fontFamily||null,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontFamily",e??null)}})}get fontWeight(){return new E({initialValue:this.preferences.fontWeight,effectiveValue:this.settings.fontWeight||400,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontWeight",e??null)},supportedRange:ee.range,step:ee.step})}get hyphens(){return new A({initialValue:this.preferences.hyphens,effectiveValue:this.settings.hyphens||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("hyphens",e??null)}})}get iOSPatch(){return new A({initialValue:this.preferences.iOSPatch,effectiveValue:this.settings.iOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iOSPatch",e??null)}})}get iPadOSPatch(){return new A({initialValue:this.preferences.iPadOSPatch,effectiveValue:this.settings.iPadOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iPadOSPatch",e??null)}})}get letterSpacing(){return new E({initialValue:this.preferences.letterSpacing,effectiveValue:this.settings.letterSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("letterSpacing",e??null)},supportedRange:Fe.range,step:Fe.step})}get ligatures(){return new A({initialValue:this.preferences.ligatures,effectiveValue:this.settings.ligatures||!0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("ligatures",e??null)}})}get lineHeight(){return new E({initialValue:this.preferences.lineHeight,effectiveValue:this.settings.lineHeight,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("lineHeight",e??null)},supportedRange:Ne.range,step:Ne.step})}get noRuby(){return new A({initialValue:this.preferences.noRuby,effectiveValue:this.settings.noRuby||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("noRuby",e??null)}})}get paragraphIndent(){return new E({initialValue:this.preferences.paragraphIndent,effectiveValue:this.settings.paragraphIndent||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphIndent",e??null)},supportedRange:Ie.range,step:Ie.step})}get paragraphSpacing(){return new E({initialValue:this.preferences.paragraphSpacing,effectiveValue:this.settings.paragraphSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphSpacing",e??null)},supportedRange:De.range,step:De.step})}get textAlign(){return new Kt({initialValue:this.preferences.textAlign,effectiveValue:this.settings.textAlign||Z.start,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textAlign",e??null)},supportedValues:Object.values(Z)})}get textNormalization(){return new A({initialValue:this.preferences.textNormalization,effectiveValue:this.settings.textNormalization||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textNormalization",e??null)}})}get wordSpacing(){return new E({initialValue:this.preferences.wordSpacing,effectiveValue:this.settings.wordSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("wordSpacing",e??null)},supportedRange:He.range,step:He.step})}get zoom(){return new E({initialValue:this.preferences.zoom,effectiveValue:this.settings.zoom||1,isEffective:CSS.supports("zoom","1")??!1,onChange:e=>{this.updatePreference("zoom",e??null)},supportedRange:We.range,step:We.step})}}const Si=r=>{if("blob"in r&&r.blob.type)return r.blob.type;if(r.as==="script")return"text/javascript";if(r.as==="link"&&"url"in r){const e=r.url.toLowerCase();if(e.endsWith(".css"))return"text/css";if([".js",".mjs",".cjs"].some(t=>e.endsWith(t)))return"text/javascript"}},bi=(r,e)=>{e.attributes&&Object.entries(e.attributes).forEach(([t,n])=>{t==="type"||t==="rel"||t==="href"||t==="src"||n!=null&&(typeof n=="boolean"?n&&r.setAttribute(t,""):r.setAttribute(t,n))})},Zo=(r,e,t)=>{const n=r.createElement("script");n.dataset.readium="true",e.id&&(n.id=e.id);const i=e.type||Si(e);return i&&(n.type=i),bi(n,e),n.src=t,n},_i=(r,e,t)=>{const n=r.createElement("link");n.dataset.readium="true",e.id&&(n.id=e.id),e.rel&&(n.rel=e.rel);const i=e.type||Si(e);return i&&(n.type=i),bi(n,e),n.href=t,n};class Jt{constructor(e){this.blobStore=new Map,this.createdBlobUrls=new Set,this.allowedDomains=[],this.injectableIdCounter=0,this.allowedDomains=(e.allowedDomains||[]).map(t=>{try{return new URL(t),t}catch{throw new Error(`Invalid allowed domain: "${t}". Must be a valid URL (e.g., "https://fonts.googleapis.com").`)}}),this.rules=e.rules.map(t=>{const n={...t};return t.prepend&&(n.prepend=t.prepend.map(i=>({...i,id:i.id||`injectable-${this.injectableIdCounter++}`})).reverse()),t.append&&(n.append=t.append.map(i=>({...i,id:i.id||`injectable-${this.injectableIdCounter++}`}))),n})}dispose(){for(const e of this.createdBlobUrls)try{URL.revokeObjectURL(e)}catch(t){console.warn("Failed to revoke blob URL:",e,t)}this.createdBlobUrls.clear()}getAllowedDomains(){return[...this.allowedDomains]}async injectForDocument(e,t){for(const n of this.rules)this.matchesRule(n,t)&&await this.applyRule(e,n)}matchesRule(e,t){const n=t.href;return e.resources.some(i=>i instanceof RegExp?i.test(n):n===i)}async getOrCreateBlobUrl(e){const t=e.id;if(this.blobStore.has(t)){const n=this.blobStore.get(t);return n.refCount++,n.url}if("blob"in e){const n=URL.createObjectURL(e.blob);return this.blobStore.set(t,{url:n,refCount:1}),this.createdBlobUrls.add(n),n}throw new Error("Resource must have a blob property")}async releaseBlobUrl(e){if(!this.createdBlobUrls.has(e))return;const t=Array.from(this.blobStore.values()).find(n=>n.url===e);if(t&&(t.refCount--,t.refCount<=0)){URL.revokeObjectURL(e),this.createdBlobUrls.delete(e);for(const[n,i]of this.blobStore.entries())if(i.url===e){this.blobStore.delete(n);break}}}async getResourceUrl(e,t){if("url"in e){const n=new URL(e.url,t.baseURI).toString();if(!this.isValidUrl(n,t))throw new Error(`Invalid URL: Only HTTPS, data:, blob:, or localhost HTTP URLs are allowed. Got: ${e.url}`);return n}else return this.getOrCreateBlobUrl(e)}createPreloadLink(e,t,n){if(t.as!=="link"||t.rel!=="preload")return;const i={...t,rel:"preload",attributes:{...t.attributes,as:t.as}},o=_i(e,i,n);e.head.appendChild(o)}createElement(e,t,n){if(t.as==="script")return Zo(e,t,n);if(t.as==="link")return _i(e,t,n);throw new Error(`Unsupported element type: ${t.as}`)}async applyRule(e,t){const n=[],i=t.prepend?t.prepend.filter(a=>!a.condition||a.condition(e)):[],o=t.append?t.append.filter(a=>!a.condition||a.condition(e)):[];try{for(const a of i)await this.processInjectable(a,e,n,"prepend");for(const a of o)await this.processInjectable(a,e,n,"append")}catch(a){for(const{element:s,url:l}of n)try{s.remove(),await this.releaseBlobUrl(l)}catch(c){console.error("Error during cleanup:",c)}throw a}}async processInjectable(e,t,n,i){const o=e.target==="body"?t.body:t.head;if(!o)return;let a=null;try{if(a=await this.getResourceUrl(e,t),e.rel==="preload"&&"url"in e)this.createPreloadLink(t,e,a);else{const s=this.createElement(t,e,a);n.push({element:s,url:a}),i==="prepend"?o.prepend(s):o.append(s)}}catch(s){throw console.error("Failed to process resource:",s),a&&"blob"in e&&await this.releaseBlobUrl(a),s}}isValidUrl(e,t){try{const n=new URL(e,t.baseURI);if(n.protocol==="data:"||n.protocol==="blob:"&&this.createdBlobUrls.has(e))return!0;if(this.allowedDomains.length>0){const i=n.origin;return this.allowedDomains.some(o=>{const a=new URL(o).origin;return i===a})}return!1}catch{return!1}}}const Re=r=>r.replace(/\/\/.*/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\n/g,"").replace(/\s+/g," "),$e=r=>r.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,"").replace(/ {2,}/g," "),Jo=`/*!
|
|
97
97
|
* Readium CSS v.2.0.2
|
|
98
98
|
* Copyright (c) 2017–2026. Readium Foundation. All rights reserved.
|