@readium/navigator-html-injectables 2.3.1 → 2.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +818 -658
- package/dist/index.umd.cjs +22 -11
- package/package.json +1 -1
- package/src/Loader.ts +3 -3
- package/src/helpers/document.ts +10 -1
- package/src/modules/ModuleLibrary.ts +4 -0
- package/src/modules/snapper/CJKVerticalSnapper.ts +333 -0
- package/src/modules/snapper/ColumnSnapper.ts +139 -59
- package/types/src/Loader.d.ts +2 -2
- package/types/src/helpers/document.d.ts +1 -0
- package/types/src/modules/ModuleLibrary.d.ts +1 -1
- package/types/src/modules/snapper/CJKVerticalSnapper.d.ts +58 -0
- package/types/src/modules/snapper/ColumnSnapper.d.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const ke = Math.pow(2, 32), $t = () => Math.round(Math.random() * ke).toString(36), We = () => `${Math.round(performance.now())}-${$t()}-${$t()}`, Z = 1;
|
|
2
|
+
class Ue {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
@@ -10,8 +10,8 @@ class ze {
|
|
|
10
10
|
if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
|
|
11
11
|
if (e.key === "_ping") {
|
|
12
12
|
if (!this.destination) {
|
|
13
|
-
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !==
|
|
14
|
-
e._readium >
|
|
13
|
+
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== Z) {
|
|
14
|
+
e._readium > Z ? this.send("error", `received comms version ${e._readium} higher than ${Z}`) : this.send("error", `received comms version ${e._readium} lower than ${Z}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
@@ -71,9 +71,9 @@ class ze {
|
|
|
71
71
|
send(t, e, i = void 0, s = []) {
|
|
72
72
|
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
73
|
const n = {
|
|
74
|
-
_readium:
|
|
74
|
+
_readium: Z,
|
|
75
75
|
_channel: this.channelId,
|
|
76
|
-
id: i ??
|
|
76
|
+
id: i ?? We(),
|
|
77
77
|
// scrict,
|
|
78
78
|
key: t,
|
|
79
79
|
data: e
|
|
@@ -126,7 +126,7 @@ const y = class y {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
y.EPUB_A11Y_10_WCAG_20_A = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"), y.EPUB_A11Y_10_WCAG_20_AA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"), y.EPUB_A11Y_10_WCAG_20_AAA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"), y.EPUB_A11Y_11_WCAG_20_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"), y.EPUB_A11Y_11_WCAG_20_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"), y.EPUB_A11Y_11_WCAG_20_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"), y.EPUB_A11Y_11_WCAG_21_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"), y.EPUB_A11Y_11_WCAG_21_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"), y.EPUB_A11Y_11_WCAG_21_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"), y.EPUB_A11Y_11_WCAG_22_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"), y.EPUB_A11Y_11_WCAG_22_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"), y.EPUB_A11Y_11_WCAG_22_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");
|
|
129
|
-
let
|
|
129
|
+
let Yt = y;
|
|
130
130
|
const w = class w {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.value = t;
|
|
@@ -146,16 +146,16 @@ const w = class w {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
w.AUDITORY = new w("auditory"), w.CHART_ON_VISUAL = new w("chartOnVisual"), w.CHEM_ON_VISUAL = new w("chemOnVisual"), w.COLOR_DEPENDENT = new w("colorDependent"), w.DIAGRAM_ON_VISUAL = new w("diagramOnVisual"), w.MATH_ON_VISUAL = new w("mathOnVisual"), w.MUSIC_ON_VISUAL = new w("musicOnVisual"), w.TACTILE = new w("tactile"), w.TEXT_ON_VISUAL = new w("textOnVisual"), w.TEXTUAL = new w("textual"), w.VISUAL = new w("visual");
|
|
149
|
-
let
|
|
150
|
-
const
|
|
149
|
+
let qt = w;
|
|
150
|
+
const x = class x {
|
|
151
151
|
constructor(t) {
|
|
152
152
|
if (typeof t == "string") {
|
|
153
|
-
if (!
|
|
153
|
+
if (!x.VALID_MODES.has(t.toLowerCase()))
|
|
154
154
|
return;
|
|
155
155
|
this.value = t.toLowerCase();
|
|
156
156
|
} else {
|
|
157
157
|
const e = t.filter(
|
|
158
|
-
(i) =>
|
|
158
|
+
(i) => x.VALID_MODES.has(i.toLowerCase())
|
|
159
159
|
);
|
|
160
160
|
if (e.length === 0)
|
|
161
161
|
return;
|
|
@@ -168,11 +168,11 @@ const T = class T {
|
|
|
168
168
|
static deserialize(t) {
|
|
169
169
|
if (!t) return;
|
|
170
170
|
if (typeof t == "string")
|
|
171
|
-
return new
|
|
171
|
+
return new x(t);
|
|
172
172
|
if (!Array.isArray(t)) return;
|
|
173
|
-
const e = t.filter((i) => i ?
|
|
173
|
+
const e = t.filter((i) => i ? x.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
174
174
|
if (e.length !== 0)
|
|
175
|
-
return new
|
|
175
|
+
return new x(e);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
@@ -181,9 +181,9 @@ const T = class T {
|
|
|
181
181
|
return this.value;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
|
|
185
|
-
let
|
|
186
|
-
const
|
|
184
|
+
x.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), x.AUDITORY = new x("auditory"), x.TACTILE = new x("tactile"), x.TEXTUAL = new x("textual"), x.VISUAL = new x("visual");
|
|
185
|
+
let Xt = x;
|
|
186
|
+
const h = class h {
|
|
187
187
|
constructor(t) {
|
|
188
188
|
this.value = t;
|
|
189
189
|
}
|
|
@@ -192,7 +192,7 @@ const c = class c {
|
|
|
192
192
|
*/
|
|
193
193
|
static deserialize(t) {
|
|
194
194
|
if (!(!t || typeof t != "string"))
|
|
195
|
-
return new
|
|
195
|
+
return new h(t);
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* Serializes a [Feature] to its RWPM JSON representation.
|
|
@@ -201,9 +201,9 @@ const c = class c {
|
|
|
201
201
|
return this.value;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
const
|
|
204
|
+
h.NONE = new h("none"), h.ANNOTATIONS = new h("annotations"), h.ARIA = new h("ARIA"), h.INDEX = new h("index"), h.PAGE_BREAK_MARKERS = new h("pageBreakMarkers"), h.PAGE_NAVIGATION = new h("pageNavigation"), h.PRINT_PAGE_NUMBERS = new h("printPageNumbers"), h.READING_ORDER = new h("readingOrder"), h.STRUCTURAL_NAVIGATION = new h("structuralNavigation"), h.TABLE_OF_CONTENTS = new h("tableOfContents"), h.TAGGED_PDF = new h("taggedPDF"), h.ALTERNATIVE_TEXT = new h("alternativeText"), h.AUDIO_DESCRIPTION = new h("audioDescription"), h.CAPTIONS = new h("captions"), h.CLOSED_CAPTIONS = new h("closedCaptions"), h.DESCRIBED_MATH = new h("describedMath"), h.LONG_DESCRIPTION = new h("longDescription"), h.OPEN_CAPTIONS = new h("openCaptions"), h.SIGN_LANGUAGE = new h("signLanguage"), h.TRANSCRIPT = new h("transcript"), h.DISPLAY_TRANSFORMABILITY = new h("displayTransformability"), h.SYNCHRONIZED_AUDIO_TEXT = new h("synchronizedAudioText"), h.TIMING_CONTROL = new h("timingControl"), h.UNLOCKED = new h("unlocked"), h.CHEM_ML = new h("ChemML"), h.LATEX = new h("latex"), h.LATEX_CHEMISTRY = new h("latex-chemistry"), h.MATH_ML = new h("MathML"), h.MATH_ML_CHEMISTRY = new h("MathML-chemistry"), h.TTS_MARKUP = new h("ttsMarkup"), h.HIGH_CONTRAST_AUDIO = new h("highContrastAudio"), h.HIGH_CONTRAST_DISPLAY = new h("highContrastDisplay"), h.LARGE_PRINT = new h("largePrint"), h.BRAILLE = new h("braille"), h.TACTILE_GRAPHIC = new h("tactileGraphic"), h.TACTILE_OBJECT = new h("tactileObject"), h.FULL_RUBY_ANNOTATIONS = new h("fullRubyAnnotations"), h.HORIZONTAL_WRITING = new h("horizontalWriting"), h.RUBY_ANNOTATIONS = new h("rubyAnnotations"), h.VERTICAL_WRITING = new h("verticalWriting"), h.WITH_ADDITIONAL_WORD_SEGMENTATION = new h("withAdditionalWordSegmentation"), h.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new h("withoutAdditionalWordSegmentation");
|
|
205
|
+
let Kt = h;
|
|
206
|
+
const S = class S {
|
|
207
207
|
constructor(t) {
|
|
208
208
|
this.value = t;
|
|
209
209
|
}
|
|
@@ -212,7 +212,7 @@ const E = class E {
|
|
|
212
212
|
*/
|
|
213
213
|
static deserialize(t) {
|
|
214
214
|
if (!(!t || typeof t != "string"))
|
|
215
|
-
return new
|
|
215
|
+
return new S(t);
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* Serializes a [Hazard] to its RWPM JSON representation.
|
|
@@ -221,9 +221,9 @@ const E = class E {
|
|
|
221
221
|
return this.value;
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
let
|
|
226
|
-
const
|
|
224
|
+
S.FLASHING = new S("flashing"), S.NO_FLASHING_HAZARD = new S("noFlashingHazard"), S.UNKNOWN_FLASHING_HAZARD = new S("unknownFlashingHazard"), S.MOTION_SIMULATION = new S("motionSimulation"), S.NO_MOTION_SIMULATION_HAZARD = new S("noMotionSimulationHazard"), S.UNKNOWN_MOTION_SIMULATION_HAZARD = new S("unknownMotionSimulationHazard"), S.SOUND = new S("sound"), S.NO_SOUND_HAZARD = new S("noSoundHazard"), S.UNKNOWN_SOUND_HAZARD = new S("unknownSoundHazard"), S.UNKNOWN = new S("unknown"), S.NONE = new S("none");
|
|
225
|
+
let Zt = S;
|
|
226
|
+
const E = class E {
|
|
227
227
|
constructor(t) {
|
|
228
228
|
this.value = t;
|
|
229
229
|
}
|
|
@@ -232,7 +232,7 @@ const S = class S {
|
|
|
232
232
|
*/
|
|
233
233
|
static deserialize(t) {
|
|
234
234
|
if (!(!t || typeof t != "string"))
|
|
235
|
-
return new
|
|
235
|
+
return new E(t);
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
238
|
* Serializes an [Exemption] to its RWPM JSON representation.
|
|
@@ -241,11 +241,11 @@ const S = class S {
|
|
|
241
241
|
return this.value;
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
|
|
245
|
-
let
|
|
246
|
-
const Xt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Me = /* @__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"}}`), ke = {
|
|
247
|
-
publication:
|
|
248
|
-
},
|
|
244
|
+
E.NONE = new E("none"), E.DOCUMENTED = new E("documented"), E.LEGAL = new E("legal"), E.TEMPORARY = new E("temporary"), E.TECHNICAL = new E("technical"), E.EAA_DISPROPORTIONATE_BURDEN = new E("eaa-disproportionate-burden"), E.EAA_FUNDAMENTAL_ALTERATION = new E("eaa-fundamental-alteration"), E.EAA_MICROENTERPRISE = new E("eaa-microenterprise"), E.EAA_TECHNICAL_IMPOSSIBILITY = new E("eaa-technical-impossibility"), E.EAA_TEMPORARY = new E("eaa-temporary");
|
|
245
|
+
let Jt = E;
|
|
246
|
+
const Qt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Be = /* @__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"}}`), He = {
|
|
247
|
+
publication: Be
|
|
248
|
+
}, jt = {
|
|
249
249
|
fr: () => import("./fr-C5HEel98.js"),
|
|
250
250
|
ar: () => import("./ar-DyHX_uy2.js"),
|
|
251
251
|
da: () => import("./da-Dct0PS3E.js"),
|
|
@@ -256,13 +256,13 @@ const Xt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Me = /* @__PURE__ */ J
|
|
|
256
256
|
sv: () => import("./sv-BfzAFsVN.js")
|
|
257
257
|
// 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
|
|
258
258
|
// 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
|
|
259
|
-
},
|
|
260
|
-
class
|
|
259
|
+
}, te = He?.publication?.metadata?.accessibility?.["display-guide"] || {};
|
|
260
|
+
class $ {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.currentLocaleCode = "en", this.locale =
|
|
262
|
+
this.currentLocaleCode = "en", this.locale = te, this.loadedLocales = {}, this.loadedLocales.en = te;
|
|
263
263
|
}
|
|
264
264
|
static getInstance() {
|
|
265
|
-
return
|
|
265
|
+
return $.instance || ($.instance = new $()), $.instance;
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
268
268
|
* Loads a locale dynamically
|
|
@@ -270,14 +270,14 @@ class F {
|
|
|
270
270
|
* @returns Promise indicating if the locale was loaded successfully
|
|
271
271
|
*/
|
|
272
272
|
async loadLocale(t) {
|
|
273
|
-
if (!
|
|
273
|
+
if (!Qt.includes(t))
|
|
274
274
|
return console.warn(`Locale '${t}' is not enabled`), !1;
|
|
275
275
|
if (t in this.loadedLocales)
|
|
276
276
|
return !0;
|
|
277
277
|
try {
|
|
278
|
-
if (!(t in
|
|
278
|
+
if (!(t in jt))
|
|
279
279
|
return console.warn(`Locale file not found for: ${t}`), !1;
|
|
280
|
-
const s = (await
|
|
280
|
+
const s = (await jt[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
|
|
281
281
|
return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
|
|
282
282
|
} catch (e) {
|
|
283
283
|
return console.warn(`Failed to load locale ${t}:`, e), !1;
|
|
@@ -311,7 +311,7 @@ class F {
|
|
|
311
311
|
* Gets a list of available locale codes
|
|
312
312
|
*/
|
|
313
313
|
getAvailableLocales() {
|
|
314
|
-
return
|
|
314
|
+
return Qt;
|
|
315
315
|
}
|
|
316
316
|
getNestedValue(t, e) {
|
|
317
317
|
const i = e.split(".");
|
|
@@ -333,8 +333,8 @@ class F {
|
|
|
333
333
|
return e === void 0 && this.currentLocaleCode !== "en" && (e = this.getNestedValue(this.loadedLocales.en, t)), e !== void 0 ? typeof e == "string" ? { compact: e, descriptive: e } : e : (console.warn(`Missing localization for key: ${t}`), { compact: "", descriptive: "" });
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
class
|
|
336
|
+
$.getInstance();
|
|
337
|
+
class kt {
|
|
338
338
|
/**
|
|
339
339
|
* Creates a [Encryption].
|
|
340
340
|
*/
|
|
@@ -346,7 +346,7 @@ class Rt {
|
|
|
346
346
|
*/
|
|
347
347
|
static deserialize(t) {
|
|
348
348
|
if (t && t.algorithm)
|
|
349
|
-
return new
|
|
349
|
+
return new kt({
|
|
350
350
|
algorithm: t.algorithm,
|
|
351
351
|
compression: t.compression,
|
|
352
352
|
originalLength: t.originalLength,
|
|
@@ -394,25 +394,25 @@ class R {
|
|
|
394
394
|
}
|
|
395
395
|
Object.defineProperty(R.prototype, "encryption", {
|
|
396
396
|
get: function() {
|
|
397
|
-
return
|
|
397
|
+
return kt.deserialize(this.otherProperties.encrypted);
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
|
-
function
|
|
400
|
+
function _e(r) {
|
|
401
401
|
return r && Array.isArray(r) ? r : void 0;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return r && typeof r == "string" ? [r] :
|
|
403
|
+
function Ae(r) {
|
|
404
|
+
return r && typeof r == "string" ? [r] : _e(r);
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function ee(r) {
|
|
407
407
|
return typeof r == "string" ? new Date(r) : void 0;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function ht(r) {
|
|
410
410
|
return isNaN(r) ? void 0 : r;
|
|
411
411
|
}
|
|
412
412
|
function O(r) {
|
|
413
|
-
return
|
|
413
|
+
return ht(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ve(r) {
|
|
416
416
|
const t = new Array();
|
|
417
417
|
return r.forEach((e) => t.push(e)), t;
|
|
418
418
|
}
|
|
@@ -427,22 +427,22 @@ class l {
|
|
|
427
427
|
} else
|
|
428
428
|
throw new Error("Invalid media type");
|
|
429
429
|
const o = {};
|
|
430
|
-
for (let
|
|
431
|
-
const v = s[
|
|
430
|
+
for (let p = 1; p < s.length; p++) {
|
|
431
|
+
const v = s[p].split("=");
|
|
432
432
|
if (v.length === 2) {
|
|
433
|
-
const
|
|
434
|
-
o[
|
|
433
|
+
const g = v[0].toLocaleLowerCase(), m = g === "charset" ? v[1].toUpperCase() : v[1];
|
|
434
|
+
o[g] = m;
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
const a = {},
|
|
438
|
-
|
|
439
|
-
let
|
|
440
|
-
for (const
|
|
441
|
-
const v = a[
|
|
442
|
-
|
|
437
|
+
const a = {}, c = Object.keys(o);
|
|
438
|
+
c.sort((p, v) => p.localeCompare(v)), c.forEach((p) => a[p] = o[p]);
|
|
439
|
+
let u = "";
|
|
440
|
+
for (const p in a) {
|
|
441
|
+
const v = a[p];
|
|
442
|
+
u += `;${p}=${v}`;
|
|
443
443
|
}
|
|
444
|
-
const
|
|
445
|
-
this.string =
|
|
444
|
+
const d = `${e}/${i}${u}`, f = a.encoding;
|
|
445
|
+
this.string = d, this.type = e, this.subtype = i, this.parameters = a, this.encoding = f, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
446
446
|
}
|
|
447
447
|
static parse(t) {
|
|
448
448
|
return new l(t);
|
|
@@ -875,7 +875,7 @@ class l {
|
|
|
875
875
|
});
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
class
|
|
878
|
+
class ie {
|
|
879
879
|
constructor(t) {
|
|
880
880
|
this.uri = t, this.parameters = this.getParameters(t);
|
|
881
881
|
}
|
|
@@ -915,17 +915,17 @@ class C {
|
|
|
915
915
|
*/
|
|
916
916
|
static deserialize(t) {
|
|
917
917
|
if (!t) return;
|
|
918
|
-
const e =
|
|
918
|
+
const e = ht(t.progression), i = ht(t.totalProgression), s = ht(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
919
919
|
"fragment",
|
|
920
920
|
"fragments",
|
|
921
921
|
"progression",
|
|
922
922
|
"totalProgression",
|
|
923
923
|
"position"
|
|
924
924
|
]);
|
|
925
|
-
return Object.entries(t).forEach(([a,
|
|
926
|
-
o.has(a) || n.set(a,
|
|
925
|
+
return Object.entries(t).forEach(([a, c]) => {
|
|
926
|
+
o.has(a) || n.set(a, c);
|
|
927
927
|
}), new C({
|
|
928
|
-
fragments:
|
|
928
|
+
fragments: Ae(t.fragments || t.fragment),
|
|
929
929
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
930
930
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
931
931
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
@@ -966,7 +966,7 @@ class H {
|
|
|
966
966
|
return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
|
-
class
|
|
969
|
+
class k {
|
|
970
970
|
/**
|
|
971
971
|
* Creates a [Locator].
|
|
972
972
|
*/
|
|
@@ -978,7 +978,7 @@ class W {
|
|
|
978
978
|
*/
|
|
979
979
|
static deserialize(t) {
|
|
980
980
|
if (t && t.href && t.type)
|
|
981
|
-
return new
|
|
981
|
+
return new k({
|
|
982
982
|
href: t.href,
|
|
983
983
|
type: t.type,
|
|
984
984
|
title: t.title,
|
|
@@ -997,7 +997,7 @@ class W {
|
|
|
997
997
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
998
998
|
*/
|
|
999
999
|
copyWithLocations(t) {
|
|
1000
|
-
return new
|
|
1000
|
+
return new k({
|
|
1001
1001
|
href: this.href,
|
|
1002
1002
|
type: this.type,
|
|
1003
1003
|
title: this.title,
|
|
@@ -1006,7 +1006,7 @@ class W {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
class
|
|
1009
|
+
class q {
|
|
1010
1010
|
/**
|
|
1011
1011
|
* Creates a [Link].
|
|
1012
1012
|
*/
|
|
@@ -1018,7 +1018,7 @@ class Y {
|
|
|
1018
1018
|
*/
|
|
1019
1019
|
static deserialize(t) {
|
|
1020
1020
|
if (!(!t || typeof t.href != "string"))
|
|
1021
|
-
return new
|
|
1021
|
+
return new q({
|
|
1022
1022
|
href: t.href,
|
|
1023
1023
|
templated: t.templated,
|
|
1024
1024
|
type: t.type,
|
|
@@ -1030,9 +1030,9 @@ class Y {
|
|
|
1030
1030
|
size: O(t.size),
|
|
1031
1031
|
duration: O(t.duration),
|
|
1032
1032
|
bitrate: O(t.bitrate),
|
|
1033
|
-
languages:
|
|
1034
|
-
alternates:
|
|
1035
|
-
children:
|
|
1033
|
+
languages: Ae(t.language),
|
|
1034
|
+
alternates: dt.deserialize(t.alternate),
|
|
1035
|
+
children: dt.deserialize(t.children)
|
|
1036
1036
|
});
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
@@ -1040,7 +1040,7 @@ class Y {
|
|
|
1040
1040
|
*/
|
|
1041
1041
|
serialize() {
|
|
1042
1042
|
const t = { href: this.href };
|
|
1043
|
-
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 =
|
|
1043
|
+
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 = Ve(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;
|
|
1044
1044
|
}
|
|
1045
1045
|
/** MediaType of the linked resource. */
|
|
1046
1046
|
get mediaType() {
|
|
@@ -1057,14 +1057,14 @@ class Y {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
1059
1059
|
get templateParameters() {
|
|
1060
|
-
return this.templated ? new
|
|
1060
|
+
return this.templated ? new ie(this.href).parameters : /* @__PURE__ */ new Set();
|
|
1061
1061
|
}
|
|
1062
1062
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
1063
1063
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
1064
1064
|
*/
|
|
1065
1065
|
expandTemplate(t) {
|
|
1066
|
-
return new
|
|
1067
|
-
href: new
|
|
1066
|
+
return new q({
|
|
1067
|
+
href: new ie(this.href).expand(t),
|
|
1068
1068
|
templated: !1
|
|
1069
1069
|
});
|
|
1070
1070
|
}
|
|
@@ -1072,7 +1072,7 @@ class Y {
|
|
|
1072
1072
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
1073
1073
|
*/
|
|
1074
1074
|
addProperties(t) {
|
|
1075
|
-
const e =
|
|
1075
|
+
const e = q.deserialize(this.serialize());
|
|
1076
1076
|
return e.properties = e.properties ? e.properties?.add(t) : new R(t), e;
|
|
1077
1077
|
}
|
|
1078
1078
|
/**
|
|
@@ -1080,7 +1080,7 @@ class Y {
|
|
|
1080
1080
|
*/
|
|
1081
1081
|
get locator() {
|
|
1082
1082
|
let t = this.href.split("#");
|
|
1083
|
-
return new
|
|
1083
|
+
return new k({
|
|
1084
1084
|
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
1085
1085
|
type: this.type ?? "",
|
|
1086
1086
|
title: this.title,
|
|
@@ -1090,7 +1090,7 @@ class Y {
|
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
|
-
class
|
|
1093
|
+
class dt {
|
|
1094
1094
|
/**
|
|
1095
1095
|
* Creates a [Links].
|
|
1096
1096
|
*/
|
|
@@ -1102,8 +1102,8 @@ class lt {
|
|
|
1102
1102
|
*/
|
|
1103
1103
|
static deserialize(t) {
|
|
1104
1104
|
if (t && Array.isArray(t))
|
|
1105
|
-
return new
|
|
1106
|
-
t.map((e) =>
|
|
1105
|
+
return new dt(
|
|
1106
|
+
t.map((e) => q.deserialize(e)).filter((e) => e !== void 0)
|
|
1107
1107
|
);
|
|
1108
1108
|
}
|
|
1109
1109
|
/**
|
|
@@ -1187,7 +1187,7 @@ class lt {
|
|
|
1187
1187
|
R.prototype.getContains = function() {
|
|
1188
1188
|
return new Set(this.otherProperties.contains || []);
|
|
1189
1189
|
};
|
|
1190
|
-
class
|
|
1190
|
+
class ut {
|
|
1191
1191
|
/**
|
|
1192
1192
|
* Creates a [DomRange].
|
|
1193
1193
|
*/
|
|
@@ -1202,7 +1202,7 @@ class ct {
|
|
|
1202
1202
|
let e = O(t.textNodeIndex);
|
|
1203
1203
|
if (e === void 0) return;
|
|
1204
1204
|
let i = O(t.charOffset);
|
|
1205
|
-
return i === void 0 && (i = O(t.offset)), new
|
|
1205
|
+
return i === void 0 && (i = O(t.offset)), new ut({
|
|
1206
1206
|
cssSelector: t.cssSelector,
|
|
1207
1207
|
textNodeIndex: e,
|
|
1208
1208
|
charOffset: i
|
|
@@ -1219,7 +1219,7 @@ class ct {
|
|
|
1219
1219
|
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
|
-
class
|
|
1222
|
+
class Wt {
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Creates a [DomRange].
|
|
1225
1225
|
*/
|
|
@@ -1231,11 +1231,11 @@ class It {
|
|
|
1231
1231
|
*/
|
|
1232
1232
|
static deserialize(t) {
|
|
1233
1233
|
if (!t) return;
|
|
1234
|
-
let e =
|
|
1234
|
+
let e = ut.deserialize(t.start);
|
|
1235
1235
|
if (e)
|
|
1236
|
-
return new
|
|
1236
|
+
return new Wt({
|
|
1237
1237
|
start: e,
|
|
1238
|
-
end:
|
|
1238
|
+
end: ut.deserialize(t.end)
|
|
1239
1239
|
});
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
@@ -1253,7 +1253,7 @@ C.prototype.getPartialCfi = function() {
|
|
|
1253
1253
|
return this.otherLocations?.get("partialCfi");
|
|
1254
1254
|
};
|
|
1255
1255
|
C.prototype.getDomRange = function() {
|
|
1256
|
-
return
|
|
1256
|
+
return Wt.deserialize(this.otherLocations?.get("domRange"));
|
|
1257
1257
|
};
|
|
1258
1258
|
C.prototype.fragmentParameters = function() {
|
|
1259
1259
|
return new Map(
|
|
@@ -1287,7 +1287,7 @@ C.prototype.space = function() {
|
|
|
1287
1287
|
if (t.length === 4 && !t.some(isNaN))
|
|
1288
1288
|
return t;
|
|
1289
1289
|
};
|
|
1290
|
-
class
|
|
1290
|
+
class Ut {
|
|
1291
1291
|
/** Creates a [Price]. */
|
|
1292
1292
|
constructor(t) {
|
|
1293
1293
|
this.currency = t.currency, this.value = t.value;
|
|
@@ -1302,7 +1302,7 @@ class Dt {
|
|
|
1302
1302
|
return;
|
|
1303
1303
|
let i = O(t.value);
|
|
1304
1304
|
if (i !== void 0)
|
|
1305
|
-
return new
|
|
1305
|
+
return new Ut({ currency: e, value: i });
|
|
1306
1306
|
}
|
|
1307
1307
|
/**
|
|
1308
1308
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1311,7 +1311,7 @@ class Dt {
|
|
|
1311
1311
|
return { currency: this.currency, value: this.value };
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
|
-
class
|
|
1314
|
+
class Q {
|
|
1315
1315
|
/** Creates a [Acquisition]. */
|
|
1316
1316
|
constructor(t) {
|
|
1317
1317
|
this.type = t.type, this.children = t.children;
|
|
@@ -1321,14 +1321,14 @@ class J {
|
|
|
1321
1321
|
*/
|
|
1322
1322
|
static deserialize(t) {
|
|
1323
1323
|
if (t && t.type)
|
|
1324
|
-
return new
|
|
1324
|
+
return new Q({
|
|
1325
1325
|
type: t.type,
|
|
1326
|
-
children:
|
|
1326
|
+
children: Q.deserializeArray(t.children)
|
|
1327
1327
|
});
|
|
1328
1328
|
}
|
|
1329
1329
|
static deserializeArray(t) {
|
|
1330
1330
|
if (Array.isArray(t))
|
|
1331
|
-
return t.map((e) =>
|
|
1331
|
+
return t.map((e) => Q.deserialize(e)).filter((e) => e !== void 0);
|
|
1332
1332
|
}
|
|
1333
1333
|
/**
|
|
1334
1334
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1338,7 +1338,7 @@ class J {
|
|
|
1338
1338
|
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1339
1339
|
}
|
|
1340
1340
|
}
|
|
1341
|
-
class
|
|
1341
|
+
class Bt {
|
|
1342
1342
|
/** Creates a [Price]. */
|
|
1343
1343
|
constructor(t) {
|
|
1344
1344
|
this.total = t.total, this.position = t.position;
|
|
@@ -1348,7 +1348,7 @@ class zt {
|
|
|
1348
1348
|
*/
|
|
1349
1349
|
static deserialize(t) {
|
|
1350
1350
|
if (t)
|
|
1351
|
-
return new
|
|
1351
|
+
return new Bt({
|
|
1352
1352
|
total: O(t.total),
|
|
1353
1353
|
position: O(t.position)
|
|
1354
1354
|
});
|
|
@@ -1361,7 +1361,7 @@ class zt {
|
|
|
1361
1361
|
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
|
-
class
|
|
1364
|
+
class Ht {
|
|
1365
1365
|
/** Creates a [Copies]. */
|
|
1366
1366
|
constructor(t) {
|
|
1367
1367
|
this.total = t.total, this.available = t.available;
|
|
@@ -1371,7 +1371,7 @@ class Mt {
|
|
|
1371
1371
|
*/
|
|
1372
1372
|
static deserialize(t) {
|
|
1373
1373
|
if (t)
|
|
1374
|
-
return new
|
|
1374
|
+
return new Ht({
|
|
1375
1375
|
total: O(t.total),
|
|
1376
1376
|
available: O(t.available)
|
|
1377
1377
|
});
|
|
@@ -1384,7 +1384,7 @@ class Mt {
|
|
|
1384
1384
|
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
|
-
class
|
|
1387
|
+
class _t {
|
|
1388
1388
|
/** Creates a [Availability]. */
|
|
1389
1389
|
constructor(t) {
|
|
1390
1390
|
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
@@ -1394,10 +1394,10 @@ class kt {
|
|
|
1394
1394
|
*/
|
|
1395
1395
|
static deserialize(t) {
|
|
1396
1396
|
if (t && t.state)
|
|
1397
|
-
return new
|
|
1397
|
+
return new _t({
|
|
1398
1398
|
state: t.state,
|
|
1399
|
-
since:
|
|
1400
|
-
until:
|
|
1399
|
+
since: ee(t.since),
|
|
1400
|
+
until: ee(t.until)
|
|
1401
1401
|
});
|
|
1402
1402
|
}
|
|
1403
1403
|
/**
|
|
@@ -1412,85 +1412,85 @@ R.prototype.getNumberOfItems = function() {
|
|
|
1412
1412
|
return O(this.otherProperties.numberOfItems);
|
|
1413
1413
|
};
|
|
1414
1414
|
R.prototype.getPrice = function() {
|
|
1415
|
-
return
|
|
1415
|
+
return Ut.deserialize(this.otherProperties.price);
|
|
1416
1416
|
};
|
|
1417
1417
|
R.prototype.getIndirectAcquisitions = function() {
|
|
1418
1418
|
const r = this.otherProperties.indirectAcquisition;
|
|
1419
1419
|
if (r && Array.isArray(r))
|
|
1420
|
-
return r.map((t) =>
|
|
1420
|
+
return r.map((t) => Q.deserialize(t)).filter((t) => t !== void 0);
|
|
1421
1421
|
};
|
|
1422
1422
|
R.prototype.getHolds = function() {
|
|
1423
|
-
return
|
|
1423
|
+
return Bt.deserialize(this.otherProperties.holds);
|
|
1424
1424
|
};
|
|
1425
1425
|
R.prototype.getCopies = function() {
|
|
1426
|
-
return
|
|
1426
|
+
return Ht.deserialize(this.otherProperties.copies);
|
|
1427
1427
|
};
|
|
1428
1428
|
R.prototype.getAvailability = function() {
|
|
1429
|
-
return
|
|
1429
|
+
return _t.deserialize(this.otherProperties.availability);
|
|
1430
1430
|
};
|
|
1431
1431
|
R.prototype.getAuthenticate = function() {
|
|
1432
|
-
return
|
|
1432
|
+
return q.deserialize(this.otherProperties.authenticate);
|
|
1433
1433
|
};
|
|
1434
|
-
const
|
|
1435
|
-
function
|
|
1436
|
-
console.warn(`${
|
|
1434
|
+
const Fe = "CssSelectorGenerator";
|
|
1435
|
+
function se(r = "unknown problem", ...t) {
|
|
1436
|
+
console.warn(`${Fe}: ${r}`, ...t);
|
|
1437
1437
|
}
|
|
1438
|
-
function
|
|
1438
|
+
function Ge(r) {
|
|
1439
1439
|
return r instanceof RegExp;
|
|
1440
1440
|
}
|
|
1441
|
-
function
|
|
1441
|
+
function $e(r) {
|
|
1442
1442
|
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1443
1443
|
}
|
|
1444
|
-
function
|
|
1444
|
+
function Ye(r) {
|
|
1445
1445
|
const t = r.map((e) => {
|
|
1446
|
-
if (
|
|
1446
|
+
if (Ge(e))
|
|
1447
1447
|
return (i) => e.test(i);
|
|
1448
1448
|
if (typeof e == "function")
|
|
1449
1449
|
return (i) => {
|
|
1450
1450
|
const s = e(i);
|
|
1451
|
-
return typeof s != "boolean" ? (
|
|
1451
|
+
return typeof s != "boolean" ? (se("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
1452
1452
|
};
|
|
1453
1453
|
if (typeof e == "string") {
|
|
1454
|
-
const i = new RegExp("^" +
|
|
1454
|
+
const i = new RegExp("^" + $e(e) + "$");
|
|
1455
1455
|
return (s) => i.test(s);
|
|
1456
1456
|
}
|
|
1457
|
-
return
|
|
1457
|
+
return se("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1458
1458
|
});
|
|
1459
1459
|
return (e) => t.some((i) => i(e));
|
|
1460
1460
|
}
|
|
1461
|
-
|
|
1461
|
+
Ye([
|
|
1462
1462
|
"class",
|
|
1463
1463
|
"id",
|
|
1464
1464
|
// Angular attributes
|
|
1465
1465
|
"ng-*"
|
|
1466
1466
|
]);
|
|
1467
|
-
class
|
|
1467
|
+
class K {
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function ne(r) {
|
|
1470
1470
|
return r.split("").reverse().join("");
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1473
|
-
const i =
|
|
1472
|
+
function qe(r, t, e) {
|
|
1473
|
+
const i = ne(t);
|
|
1474
1474
|
return e.map((s) => {
|
|
1475
|
-
const n = Math.max(0, s.end - t.length - s.errors), o =
|
|
1475
|
+
const n = Math.max(0, s.end - t.length - s.errors), o = ne(r.slice(n, s.end));
|
|
1476
1476
|
return {
|
|
1477
|
-
start:
|
|
1477
|
+
start: Ce(o, i, s.errors).reduce((c, u) => s.end - u.end < c ? s.end - u.end : c, s.end),
|
|
1478
1478
|
end: s.end,
|
|
1479
1479
|
errors: s.errors
|
|
1480
1480
|
};
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
1483
|
-
function
|
|
1483
|
+
function vt(r) {
|
|
1484
1484
|
return (r | -r) >> 31 & 1;
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1486
|
+
function re(r, t, e, i) {
|
|
1487
1487
|
let s = r.P[e], n = r.M[e];
|
|
1488
|
-
const o = i >>> 31, a = t[e] | o,
|
|
1489
|
-
let
|
|
1490
|
-
const
|
|
1491
|
-
return
|
|
1488
|
+
const o = i >>> 31, a = t[e] | o, c = a | n, u = (a & s) + s ^ s | a;
|
|
1489
|
+
let d = n | ~(u | s), f = s & u;
|
|
1490
|
+
const p = vt(d & r.lastRowMask[e]) - vt(f & r.lastRowMask[e]);
|
|
1491
|
+
return d <<= 1, f <<= 1, f |= o, d |= vt(i) - o, s = f | ~(c | d), n = d & c, r.P[e] = s, r.M[e] = n, p;
|
|
1492
1492
|
}
|
|
1493
|
-
function
|
|
1493
|
+
function Ce(r, t, e) {
|
|
1494
1494
|
if (t.length === 0)
|
|
1495
1495
|
return [];
|
|
1496
1496
|
e = Math.min(e, t.length);
|
|
@@ -1500,64 +1500,64 @@ function be(r, t, e) {
|
|
|
1500
1500
|
lastRowMask: new Uint32Array(n + 1)
|
|
1501
1501
|
};
|
|
1502
1502
|
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
|
|
1503
|
-
const a = new Uint32Array(n + 1),
|
|
1504
|
-
for (let
|
|
1505
|
-
|
|
1506
|
-
for (let
|
|
1507
|
-
const v = t.charCodeAt(
|
|
1508
|
-
if (
|
|
1503
|
+
const a = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), u = [];
|
|
1504
|
+
for (let p = 0; p < 256; p++)
|
|
1505
|
+
u.push(a);
|
|
1506
|
+
for (let p = 0; p < t.length; p += 1) {
|
|
1507
|
+
const v = t.charCodeAt(p);
|
|
1508
|
+
if (c.has(v))
|
|
1509
1509
|
continue;
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1512
|
-
for (let
|
|
1513
|
-
|
|
1510
|
+
const g = new Uint32Array(n + 1);
|
|
1511
|
+
c.set(v, g), v < u.length && (u[v] = g);
|
|
1512
|
+
for (let m = 0; m <= n; m += 1) {
|
|
1513
|
+
g[m] = 0;
|
|
1514
1514
|
for (let b = 0; b < s; b += 1) {
|
|
1515
|
-
const
|
|
1516
|
-
if (
|
|
1515
|
+
const D = m * s + b;
|
|
1516
|
+
if (D >= t.length)
|
|
1517
1517
|
continue;
|
|
1518
|
-
t.charCodeAt(
|
|
1518
|
+
t.charCodeAt(D) === v && (g[m] |= 1 << b);
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
|
-
let
|
|
1523
|
-
const
|
|
1524
|
-
for (let
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
for (let
|
|
1528
|
-
o.P[
|
|
1529
|
-
for (let
|
|
1530
|
-
const v = r.charCodeAt(
|
|
1531
|
-
let
|
|
1532
|
-
v <
|
|
1533
|
-
let
|
|
1534
|
-
for (let b = 0; b <=
|
|
1535
|
-
|
|
1536
|
-
if (
|
|
1537
|
-
|
|
1522
|
+
let d = Math.max(0, Math.ceil(e / s) - 1);
|
|
1523
|
+
const f = new Uint32Array(n + 1);
|
|
1524
|
+
for (let p = 0; p <= d; p += 1)
|
|
1525
|
+
f[p] = (p + 1) * s;
|
|
1526
|
+
f[n] = t.length;
|
|
1527
|
+
for (let p = 0; p <= d; p += 1)
|
|
1528
|
+
o.P[p] = -1, o.M[p] = 0;
|
|
1529
|
+
for (let p = 0; p < r.length; p += 1) {
|
|
1530
|
+
const v = r.charCodeAt(p);
|
|
1531
|
+
let g;
|
|
1532
|
+
v < u.length ? g = u[v] : (g = c.get(v), typeof g > "u" && (g = a));
|
|
1533
|
+
let m = 0;
|
|
1534
|
+
for (let b = 0; b <= d; b += 1)
|
|
1535
|
+
m = re(o, g, b, m), f[b] += m;
|
|
1536
|
+
if (f[d] - m <= e && d < n && (g[d + 1] & 1 || m < 0)) {
|
|
1537
|
+
d += 1, o.P[d] = -1, o.M[d] = 0;
|
|
1538
1538
|
let b;
|
|
1539
|
-
if (
|
|
1540
|
-
const
|
|
1541
|
-
b =
|
|
1539
|
+
if (d === n) {
|
|
1540
|
+
const D = t.length % s;
|
|
1541
|
+
b = D === 0 ? s : D;
|
|
1542
1542
|
} else
|
|
1543
1543
|
b = s;
|
|
1544
|
-
|
|
1544
|
+
f[d] = f[d - 1] + b - m + re(o, g, d, m);
|
|
1545
1545
|
} else
|
|
1546
|
-
for (;
|
|
1547
|
-
|
|
1548
|
-
|
|
1546
|
+
for (; d > 0 && f[d] >= e + s; )
|
|
1547
|
+
d -= 1;
|
|
1548
|
+
d === n && f[d] <= e && (f[d] < e && i.splice(0, i.length), i.push({
|
|
1549
1549
|
start: -1,
|
|
1550
|
-
end:
|
|
1551
|
-
errors:
|
|
1552
|
-
}), e =
|
|
1550
|
+
end: p + 1,
|
|
1551
|
+
errors: f[d]
|
|
1552
|
+
}), e = f[d]);
|
|
1553
1553
|
}
|
|
1554
1554
|
return i;
|
|
1555
1555
|
}
|
|
1556
|
-
function
|
|
1557
|
-
const i =
|
|
1558
|
-
return
|
|
1556
|
+
function Xe(r, t, e) {
|
|
1557
|
+
const i = Ce(r, t, e);
|
|
1558
|
+
return qe(r, t, i);
|
|
1559
1559
|
}
|
|
1560
|
-
function
|
|
1560
|
+
function xe(r, t, e) {
|
|
1561
1561
|
let i = 0;
|
|
1562
1562
|
const s = [];
|
|
1563
1563
|
for (; i !== -1; )
|
|
@@ -1566,38 +1566,38 @@ function ve(r, t, e) {
|
|
|
1566
1566
|
end: i + t.length,
|
|
1567
1567
|
errors: 0
|
|
1568
1568
|
}), i += 1);
|
|
1569
|
-
return s.length > 0 ? s :
|
|
1569
|
+
return s.length > 0 ? s : Xe(r, t, e);
|
|
1570
1570
|
}
|
|
1571
|
-
function
|
|
1572
|
-
return t.length === 0 || r.length === 0 ? 0 : 1 -
|
|
1571
|
+
function oe(r, t) {
|
|
1572
|
+
return t.length === 0 || r.length === 0 ? 0 : 1 - xe(r, t, t.length)[0].errors / t.length;
|
|
1573
1573
|
}
|
|
1574
|
-
function
|
|
1574
|
+
function Ke(r, t, e = {}) {
|
|
1575
1575
|
if (t.length === 0)
|
|
1576
1576
|
return null;
|
|
1577
|
-
const i = Math.min(256, t.length / 2), s =
|
|
1577
|
+
const i = Math.min(256, t.length / 2), s = xe(r, t, i);
|
|
1578
1578
|
if (s.length === 0)
|
|
1579
1579
|
return null;
|
|
1580
1580
|
const n = (a) => {
|
|
1581
|
-
const
|
|
1581
|
+
const p = 1 - a.errors / t.length, v = e.prefix ? oe(
|
|
1582
1582
|
r.slice(
|
|
1583
1583
|
Math.max(0, a.start - e.prefix.length),
|
|
1584
1584
|
a.start
|
|
1585
1585
|
),
|
|
1586
1586
|
e.prefix
|
|
1587
|
-
) : 1,
|
|
1587
|
+
) : 1, g = e.suffix ? oe(
|
|
1588
1588
|
r.slice(a.end, a.end + e.suffix.length),
|
|
1589
1589
|
e.suffix
|
|
1590
1590
|
) : 1;
|
|
1591
|
-
let
|
|
1592
|
-
return typeof e.hint == "number" && (
|
|
1591
|
+
let m = 1;
|
|
1592
|
+
return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) / r.length), (50 * p + 20 * v + 20 * g + 2 * m) / 92;
|
|
1593
1593
|
}, o = s.map((a) => ({
|
|
1594
1594
|
start: a.start,
|
|
1595
1595
|
end: a.end,
|
|
1596
1596
|
score: n(a)
|
|
1597
1597
|
}));
|
|
1598
|
-
return o.sort((a,
|
|
1598
|
+
return o.sort((a, c) => c.score - a.score), o[0];
|
|
1599
1599
|
}
|
|
1600
|
-
function
|
|
1600
|
+
function At(r, t, e) {
|
|
1601
1601
|
const i = e === 1 ? t : t - 1;
|
|
1602
1602
|
if (r.charAt(i).trim() !== "")
|
|
1603
1603
|
return t;
|
|
@@ -1607,7 +1607,7 @@ function vt(r, t, e) {
|
|
|
1607
1607
|
const o = s.length - n.length;
|
|
1608
1608
|
return e === 2 ? t - o : t + o;
|
|
1609
1609
|
}
|
|
1610
|
-
function
|
|
1610
|
+
function ae(r, t) {
|
|
1611
1611
|
const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1612
1612
|
r.commonAncestorContainer,
|
|
1613
1613
|
NodeFilter.SHOW_TEXT
|
|
@@ -1619,8 +1619,8 @@ function ie(r, t) {
|
|
|
1619
1619
|
let o = -1;
|
|
1620
1620
|
const a = () => {
|
|
1621
1621
|
if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
|
|
1622
|
-
const
|
|
1623
|
-
o =
|
|
1622
|
+
const c = n.textContent, u = t === 1 ? 0 : c.length;
|
|
1623
|
+
o = At(c, u, t);
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
1626
1626
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1629,7 +1629,7 @@ function ie(r, t) {
|
|
|
1629
1629
|
return { node: n, offset: o };
|
|
1630
1630
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1631
1631
|
}
|
|
1632
|
-
function
|
|
1632
|
+
function Ze(r) {
|
|
1633
1633
|
if (!r.toString().trim().length)
|
|
1634
1634
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1635
1635
|
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
@@ -1639,13 +1639,13 @@ function Ye(r) {
|
|
|
1639
1639
|
const t = r.cloneRange();
|
|
1640
1640
|
let e = !1, i = !1;
|
|
1641
1641
|
const s = {
|
|
1642
|
-
start:
|
|
1642
|
+
start: At(
|
|
1643
1643
|
r.startContainer.textContent,
|
|
1644
1644
|
r.startOffset,
|
|
1645
1645
|
1
|
|
1646
1646
|
/* Forwards */
|
|
1647
1647
|
),
|
|
1648
|
-
end:
|
|
1648
|
+
end: At(
|
|
1649
1649
|
r.endContainer.textContent,
|
|
1650
1650
|
r.endOffset,
|
|
1651
1651
|
2
|
|
@@ -1655,7 +1655,7 @@ function Ye(r) {
|
|
|
1655
1655
|
if (s.start >= 0 && (t.setStart(r.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(r.endContainer, s.end), i = !0), e && i)
|
|
1656
1656
|
return t;
|
|
1657
1657
|
if (!e) {
|
|
1658
|
-
const { node: n, offset: o } =
|
|
1658
|
+
const { node: n, offset: o } = ae(
|
|
1659
1659
|
t,
|
|
1660
1660
|
1
|
|
1661
1661
|
/* Forwards */
|
|
@@ -1663,7 +1663,7 @@ function Ye(r) {
|
|
|
1663
1663
|
n && o >= 0 && t.setStart(n, o);
|
|
1664
1664
|
}
|
|
1665
1665
|
if (!i) {
|
|
1666
|
-
const { node: n, offset: o } =
|
|
1666
|
+
const { node: n, offset: o } = ae(
|
|
1667
1667
|
t,
|
|
1668
1668
|
2
|
|
1669
1669
|
/* Backwards */
|
|
@@ -1672,7 +1672,7 @@ function Ye(r) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
return t;
|
|
1674
1674
|
}
|
|
1675
|
-
function
|
|
1675
|
+
function Te(r) {
|
|
1676
1676
|
switch (r.nodeType) {
|
|
1677
1677
|
case Node.ELEMENT_NODE:
|
|
1678
1678
|
case Node.TEXT_NODE:
|
|
@@ -1681,13 +1681,13 @@ function we(r) {
|
|
|
1681
1681
|
return 0;
|
|
1682
1682
|
}
|
|
1683
1683
|
}
|
|
1684
|
-
function
|
|
1684
|
+
function le(r) {
|
|
1685
1685
|
let t = r.previousSibling, e = 0;
|
|
1686
1686
|
for (; t; )
|
|
1687
|
-
e +=
|
|
1687
|
+
e += Te(t), t = t.previousSibling;
|
|
1688
1688
|
return e;
|
|
1689
1689
|
}
|
|
1690
|
-
function
|
|
1690
|
+
function Pe(r, ...t) {
|
|
1691
1691
|
let e = t.shift();
|
|
1692
1692
|
const i = r.ownerDocument.createNodeIterator(
|
|
1693
1693
|
r,
|
|
@@ -1702,7 +1702,7 @@ function Ee(r, ...t) {
|
|
|
1702
1702
|
throw new RangeError("Offset exceeds text length");
|
|
1703
1703
|
return s;
|
|
1704
1704
|
}
|
|
1705
|
-
class
|
|
1705
|
+
class M {
|
|
1706
1706
|
constructor(t, e) {
|
|
1707
1707
|
if (e < 0)
|
|
1708
1708
|
throw new Error("Offset is invalid");
|
|
@@ -1719,8 +1719,8 @@ class z {
|
|
|
1719
1719
|
throw new Error("Parent is not an ancestor of current element");
|
|
1720
1720
|
let e = this.element, i = this.offset;
|
|
1721
1721
|
for (; e !== t; )
|
|
1722
|
-
i +=
|
|
1723
|
-
return new
|
|
1722
|
+
i += le(e), e = e.parentElement;
|
|
1723
|
+
return new M(e, i);
|
|
1724
1724
|
}
|
|
1725
1725
|
/**
|
|
1726
1726
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1741,7 +1741,7 @@ class z {
|
|
|
1741
1741
|
*/
|
|
1742
1742
|
resolve(t = {}) {
|
|
1743
1743
|
try {
|
|
1744
|
-
return
|
|
1744
|
+
return Pe(this.element, this.offset)[0];
|
|
1745
1745
|
} catch (e) {
|
|
1746
1746
|
if (this.offset === 0 && t.direction !== void 0) {
|
|
1747
1747
|
const i = document.createTreeWalker(
|
|
@@ -1764,9 +1764,9 @@ class z {
|
|
|
1764
1764
|
static fromCharOffset(t, e) {
|
|
1765
1765
|
switch (t.nodeType) {
|
|
1766
1766
|
case Node.TEXT_NODE:
|
|
1767
|
-
return
|
|
1767
|
+
return M.fromPoint(t, e);
|
|
1768
1768
|
case Node.ELEMENT_NODE:
|
|
1769
|
-
return new
|
|
1769
|
+
return new M(t, e);
|
|
1770
1770
|
default:
|
|
1771
1771
|
throw new Error("Node is not an element or text node");
|
|
1772
1772
|
}
|
|
@@ -1784,23 +1784,23 @@ class z {
|
|
|
1784
1784
|
throw new Error("Text node offset is out of range");
|
|
1785
1785
|
if (!t.parentElement)
|
|
1786
1786
|
throw new Error("Text node has no parent");
|
|
1787
|
-
const i =
|
|
1788
|
-
return new
|
|
1787
|
+
const i = le(t) + e;
|
|
1788
|
+
return new M(t.parentElement, i);
|
|
1789
1789
|
}
|
|
1790
1790
|
case Node.ELEMENT_NODE: {
|
|
1791
1791
|
if (e < 0 || e > t.childNodes.length)
|
|
1792
1792
|
throw new Error("Child node offset is out of range");
|
|
1793
1793
|
let i = 0;
|
|
1794
1794
|
for (let s = 0; s < e; s++)
|
|
1795
|
-
i +=
|
|
1796
|
-
return new
|
|
1795
|
+
i += Te(t.childNodes[s]);
|
|
1796
|
+
return new M(t, i);
|
|
1797
1797
|
}
|
|
1798
1798
|
default:
|
|
1799
1799
|
throw new Error("Point is not in an element or text node");
|
|
1800
1800
|
}
|
|
1801
1801
|
}
|
|
1802
1802
|
}
|
|
1803
|
-
class
|
|
1803
|
+
class B {
|
|
1804
1804
|
constructor(t, e) {
|
|
1805
1805
|
this.start = t, this.end = e;
|
|
1806
1806
|
}
|
|
@@ -1810,7 +1810,7 @@ class U {
|
|
|
1810
1810
|
* `end.element`.
|
|
1811
1811
|
*/
|
|
1812
1812
|
relativeTo(t) {
|
|
1813
|
-
return new
|
|
1813
|
+
return new B(
|
|
1814
1814
|
this.start.relativeTo(t),
|
|
1815
1815
|
this.end.relativeTo(t)
|
|
1816
1816
|
);
|
|
@@ -1826,7 +1826,7 @@ class U {
|
|
|
1826
1826
|
*/
|
|
1827
1827
|
toRange() {
|
|
1828
1828
|
let t, e;
|
|
1829
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] =
|
|
1829
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Pe(
|
|
1830
1830
|
this.start.element,
|
|
1831
1831
|
this.start.offset,
|
|
1832
1832
|
this.end.offset
|
|
@@ -1844,20 +1844,20 @@ class U {
|
|
|
1844
1844
|
* Create a TextRange from a (DOM) Range
|
|
1845
1845
|
*/
|
|
1846
1846
|
static fromRange(t) {
|
|
1847
|
-
const e =
|
|
1847
|
+
const e = M.fromPoint(
|
|
1848
1848
|
t.startContainer,
|
|
1849
1849
|
t.startOffset
|
|
1850
|
-
), i =
|
|
1851
|
-
return new
|
|
1850
|
+
), i = M.fromPoint(t.endContainer, t.endOffset);
|
|
1851
|
+
return new B(e, i);
|
|
1852
1852
|
}
|
|
1853
1853
|
/**
|
|
1854
1854
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1855
1855
|
* `root`
|
|
1856
1856
|
*/
|
|
1857
1857
|
static fromOffsets(t, e, i) {
|
|
1858
|
-
return new
|
|
1859
|
-
new
|
|
1860
|
-
new
|
|
1858
|
+
return new B(
|
|
1859
|
+
new M(t, e),
|
|
1860
|
+
new M(t, i)
|
|
1861
1861
|
);
|
|
1862
1862
|
}
|
|
1863
1863
|
/**
|
|
@@ -1865,23 +1865,23 @@ class U {
|
|
|
1865
1865
|
* whitespace
|
|
1866
1866
|
*/
|
|
1867
1867
|
static trimmedRange(t) {
|
|
1868
|
-
return
|
|
1868
|
+
return Ze(B.fromRange(t).toRange());
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
-
class
|
|
1871
|
+
class pt {
|
|
1872
1872
|
constructor(t, e, i) {
|
|
1873
1873
|
this.root = t, this.start = e, this.end = i;
|
|
1874
1874
|
}
|
|
1875
1875
|
static fromRange(t, e) {
|
|
1876
|
-
const i =
|
|
1877
|
-
return new
|
|
1876
|
+
const i = B.fromRange(e).relativeTo(t);
|
|
1877
|
+
return new pt(
|
|
1878
1878
|
t,
|
|
1879
1879
|
i.start.offset,
|
|
1880
1880
|
i.end.offset
|
|
1881
1881
|
);
|
|
1882
1882
|
}
|
|
1883
1883
|
static fromSelector(t, e) {
|
|
1884
|
-
return new
|
|
1884
|
+
return new pt(t, e.start, e.end);
|
|
1885
1885
|
}
|
|
1886
1886
|
toSelector() {
|
|
1887
1887
|
return {
|
|
@@ -1891,10 +1891,10 @@ class ht {
|
|
|
1891
1891
|
};
|
|
1892
1892
|
}
|
|
1893
1893
|
toRange() {
|
|
1894
|
-
return
|
|
1894
|
+
return B.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
|
-
class
|
|
1897
|
+
class mt {
|
|
1898
1898
|
/**
|
|
1899
1899
|
* @param root - A root element from which to anchor.
|
|
1900
1900
|
*/
|
|
@@ -1907,15 +1907,15 @@ class dt {
|
|
|
1907
1907
|
* Will throw if `range` does not contain any text nodes.
|
|
1908
1908
|
*/
|
|
1909
1909
|
static fromRange(t, e) {
|
|
1910
|
-
const i = t.textContent, s =
|
|
1911
|
-
return new
|
|
1910
|
+
const i = t.textContent, s = B.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
|
|
1911
|
+
return new mt(t, i.slice(n, o), {
|
|
1912
1912
|
prefix: i.slice(Math.max(0, n - a), n),
|
|
1913
1913
|
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
1916
|
static fromSelector(t, e) {
|
|
1917
1917
|
const { prefix: i, suffix: s } = e;
|
|
1918
|
-
return new
|
|
1918
|
+
return new mt(t, e.exact, { prefix: i, suffix: s });
|
|
1919
1919
|
}
|
|
1920
1920
|
toSelector() {
|
|
1921
1921
|
return {
|
|
@@ -1929,26 +1929,26 @@ class dt {
|
|
|
1929
1929
|
return this.toPositionAnchor(t).toRange();
|
|
1930
1930
|
}
|
|
1931
1931
|
toPositionAnchor(t = {}) {
|
|
1932
|
-
const e = this.root.textContent, i =
|
|
1932
|
+
const e = this.root.textContent, i = Ke(e, this.exact, {
|
|
1933
1933
|
...this.context,
|
|
1934
1934
|
hint: t.hint
|
|
1935
1935
|
});
|
|
1936
1936
|
if (!i)
|
|
1937
1937
|
throw new Error("Quote not found");
|
|
1938
|
-
return new
|
|
1938
|
+
return new pt(this.root, i.start, i.end);
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
|
-
function
|
|
1941
|
+
function Je(r) {
|
|
1942
1942
|
const t = r.tagName.toUpperCase();
|
|
1943
1943
|
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1944
1944
|
}
|
|
1945
|
-
function
|
|
1945
|
+
function nt(r, t) {
|
|
1946
1946
|
try {
|
|
1947
1947
|
const e = t.locations, i = t.text;
|
|
1948
1948
|
if (i && i.highlight) {
|
|
1949
1949
|
let s;
|
|
1950
1950
|
e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
|
|
1951
|
-
const n = new
|
|
1951
|
+
const n = new mt(s, i.highlight, {
|
|
1952
1952
|
prefix: i.before,
|
|
1953
1953
|
suffix: i.after
|
|
1954
1954
|
});
|
|
@@ -1967,7 +1967,7 @@ function pt(r, t) {
|
|
|
1967
1967
|
}
|
|
1968
1968
|
if (s) {
|
|
1969
1969
|
const n = r.createRange();
|
|
1970
|
-
return s.childNodes.length === 0 ||
|
|
1970
|
+
return s.childNodes.length === 0 || Je(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1971
1971
|
}
|
|
1972
1972
|
}
|
|
1973
1973
|
} catch (e) {
|
|
@@ -1975,51 +1975,51 @@ function pt(r, t) {
|
|
|
1975
1975
|
}
|
|
1976
1976
|
return null;
|
|
1977
1977
|
}
|
|
1978
|
-
function
|
|
1978
|
+
function Qe(r, t) {
|
|
1979
1979
|
let e = r.getClientRects();
|
|
1980
1980
|
e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
|
|
1981
1981
|
const i = 1, s = [];
|
|
1982
|
-
for (const
|
|
1982
|
+
for (const u of e)
|
|
1983
1983
|
s.push({
|
|
1984
|
-
bottom:
|
|
1985
|
-
height:
|
|
1986
|
-
left:
|
|
1987
|
-
right:
|
|
1988
|
-
top:
|
|
1989
|
-
width:
|
|
1984
|
+
bottom: u.bottom,
|
|
1985
|
+
height: u.height,
|
|
1986
|
+
left: u.left,
|
|
1987
|
+
right: u.right,
|
|
1988
|
+
top: u.top,
|
|
1989
|
+
width: u.width
|
|
1990
1990
|
});
|
|
1991
|
-
const n =
|
|
1991
|
+
const n = Ne(
|
|
1992
1992
|
s,
|
|
1993
1993
|
i
|
|
1994
|
-
), o =
|
|
1995
|
-
for (let
|
|
1996
|
-
const
|
|
1997
|
-
if (!(
|
|
1994
|
+
), o = ti(n, i), a = Le(o), c = 4;
|
|
1995
|
+
for (let u = a.length - 1; u >= 0; u--) {
|
|
1996
|
+
const d = a[u];
|
|
1997
|
+
if (!(d.width * d.height > c))
|
|
1998
1998
|
if (a.length > 1)
|
|
1999
|
-
a.splice(
|
|
1999
|
+
a.splice(u, 1);
|
|
2000
2000
|
else
|
|
2001
2001
|
break;
|
|
2002
2002
|
}
|
|
2003
2003
|
return a;
|
|
2004
2004
|
}
|
|
2005
|
-
function
|
|
2005
|
+
function Ne(r, t, e) {
|
|
2006
2006
|
for (let i = 0; i < r.length; i++)
|
|
2007
2007
|
for (let s = i + 1; s < r.length; s++) {
|
|
2008
2008
|
const n = r[i], o = r[s];
|
|
2009
2009
|
if (n === o)
|
|
2010
2010
|
continue;
|
|
2011
|
-
const a = I(n.top, o.top, t) && I(n.bottom, o.bottom, t),
|
|
2012
|
-
if (a && !
|
|
2013
|
-
const
|
|
2014
|
-
return
|
|
2015
|
-
|
|
2011
|
+
const a = I(n.top, o.top, t) && I(n.bottom, o.bottom, t), c = I(n.left, o.left, t) && I(n.right, o.right, t);
|
|
2012
|
+
if (a && !c && Oe(n, o, t)) {
|
|
2013
|
+
const f = r.filter((v) => v !== n && v !== o), p = je(n, o);
|
|
2014
|
+
return f.push(p), Ne(
|
|
2015
|
+
f,
|
|
2016
2016
|
t
|
|
2017
2017
|
);
|
|
2018
2018
|
}
|
|
2019
2019
|
}
|
|
2020
2020
|
return r;
|
|
2021
2021
|
}
|
|
2022
|
-
function
|
|
2022
|
+
function je(r, t) {
|
|
2023
2023
|
const e = Math.min(r.left, t.left), i = Math.max(r.right, t.right), s = Math.min(r.top, t.top), n = Math.max(r.bottom, t.bottom);
|
|
2024
2024
|
return {
|
|
2025
2025
|
bottom: n,
|
|
@@ -2030,7 +2030,7 @@ function Ke(r, t) {
|
|
|
2030
2030
|
width: i - e
|
|
2031
2031
|
};
|
|
2032
2032
|
}
|
|
2033
|
-
function
|
|
2033
|
+
function ti(r, t) {
|
|
2034
2034
|
const e = new Set(r);
|
|
2035
2035
|
for (const i of r) {
|
|
2036
2036
|
if (!(i.width > 1 && i.height > 1)) {
|
|
@@ -2038,40 +2038,40 @@ function Ze(r, t) {
|
|
|
2038
2038
|
continue;
|
|
2039
2039
|
}
|
|
2040
2040
|
for (const n of r)
|
|
2041
|
-
if (i !== n && e.has(n) &&
|
|
2041
|
+
if (i !== n && e.has(n) && ei(n, i, t)) {
|
|
2042
2042
|
e.delete(i);
|
|
2043
2043
|
break;
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
return Array.from(e);
|
|
2047
2047
|
}
|
|
2048
|
-
function
|
|
2049
|
-
return
|
|
2048
|
+
function ei(r, t, e) {
|
|
2049
|
+
return at(r, t.left, t.top, e) && at(r, t.right, t.top, e) && at(r, t.left, t.bottom, e) && at(r, t.right, t.bottom, e);
|
|
2050
2050
|
}
|
|
2051
|
-
function
|
|
2051
|
+
function at(r, t, e, i) {
|
|
2052
2052
|
return (r.left < t || I(r.left, t, i)) && (r.right > t || I(r.right, t, i)) && (r.top < e || I(r.top, e, i)) && (r.bottom > e || I(r.bottom, e, i));
|
|
2053
2053
|
}
|
|
2054
|
-
function
|
|
2054
|
+
function Le(r) {
|
|
2055
2055
|
for (let t = 0; t < r.length; t++)
|
|
2056
2056
|
for (let e = t + 1; e < r.length; e++) {
|
|
2057
2057
|
const i = r[t], s = r[e];
|
|
2058
|
-
if (i !== s &&
|
|
2058
|
+
if (i !== s && Oe(i, s, -1)) {
|
|
2059
2059
|
let n = [], o;
|
|
2060
|
-
const a =
|
|
2060
|
+
const a = ce(i, s);
|
|
2061
2061
|
if (a.length === 1)
|
|
2062
2062
|
n = a, o = i;
|
|
2063
2063
|
else {
|
|
2064
|
-
const
|
|
2065
|
-
a.length <
|
|
2064
|
+
const u = ce(s, i);
|
|
2065
|
+
a.length < u.length ? (n = a, o = i) : (n = u, o = s);
|
|
2066
2066
|
}
|
|
2067
|
-
const
|
|
2068
|
-
return Array.prototype.push.apply(
|
|
2067
|
+
const c = r.filter((u) => u !== o);
|
|
2068
|
+
return Array.prototype.push.apply(c, n), Le(c);
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
2071
|
return r;
|
|
2072
2072
|
}
|
|
2073
|
-
function
|
|
2074
|
-
const e =
|
|
2073
|
+
function ce(r, t) {
|
|
2074
|
+
const e = ii(t, r);
|
|
2075
2075
|
if (e.height === 0 || e.width === 0)
|
|
2076
2076
|
return [r];
|
|
2077
2077
|
const i = [];
|
|
@@ -2121,7 +2121,7 @@ function ne(r, t) {
|
|
|
2121
2121
|
}
|
|
2122
2122
|
return i;
|
|
2123
2123
|
}
|
|
2124
|
-
function
|
|
2124
|
+
function ii(r, t) {
|
|
2125
2125
|
const e = Math.max(r.left, t.left), i = Math.min(r.right, t.right), s = Math.max(r.top, t.top), n = Math.min(r.bottom, t.bottom);
|
|
2126
2126
|
return {
|
|
2127
2127
|
bottom: n,
|
|
@@ -2132,52 +2132,52 @@ function Qe(r, t) {
|
|
|
2132
2132
|
width: Math.max(0, i - e)
|
|
2133
2133
|
};
|
|
2134
2134
|
}
|
|
2135
|
-
function
|
|
2135
|
+
function Oe(r, t, e) {
|
|
2136
2136
|
return (r.left < t.right || e >= 0 && I(r.left, t.right, e)) && (t.left < r.right || e >= 0 && I(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && I(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && I(t.top, r.bottom, e));
|
|
2137
2137
|
}
|
|
2138
2138
|
function I(r, t, e) {
|
|
2139
2139
|
return Math.abs(r - t) <= e;
|
|
2140
2140
|
}
|
|
2141
|
-
function
|
|
2141
|
+
function Vt(r) {
|
|
2142
2142
|
const t = {}, e = r.document.documentElement.style;
|
|
2143
2143
|
for (const i in r.document.documentElement.style)
|
|
2144
2144
|
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2145
2145
|
return t;
|
|
2146
2146
|
}
|
|
2147
|
-
function
|
|
2148
|
-
const e =
|
|
2147
|
+
function Re(r, t) {
|
|
2148
|
+
const e = Vt(r);
|
|
2149
2149
|
Object.keys(e).forEach((i) => {
|
|
2150
|
-
t.hasOwnProperty(i) ||
|
|
2150
|
+
t.hasOwnProperty(i) || gt(r, i);
|
|
2151
2151
|
}), Object.entries(t).forEach(([i, s]) => {
|
|
2152
|
-
e[i] !== s &&
|
|
2152
|
+
e[i] !== s && st(r, i, s);
|
|
2153
2153
|
});
|
|
2154
2154
|
}
|
|
2155
|
-
function
|
|
2155
|
+
function wt(r, t) {
|
|
2156
2156
|
return r.document.documentElement.style.getPropertyValue(t);
|
|
2157
2157
|
}
|
|
2158
|
-
function
|
|
2158
|
+
function st(r, t, e) {
|
|
2159
2159
|
r.document.documentElement.style.setProperty(t, e);
|
|
2160
2160
|
}
|
|
2161
|
-
function
|
|
2161
|
+
function gt(r, t) {
|
|
2162
2162
|
r.document.documentElement.style.removeProperty(t);
|
|
2163
2163
|
}
|
|
2164
|
-
let
|
|
2165
|
-
const G = { r: 255, g: 255, b: 255, a: 1 },
|
|
2166
|
-
if (!
|
|
2164
|
+
let lt = null, St = null, J = 0;
|
|
2165
|
+
const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), si = () => {
|
|
2166
|
+
if (!lt)
|
|
2167
2167
|
if (typeof OffscreenCanvas < "u")
|
|
2168
|
-
|
|
2168
|
+
lt = new OffscreenCanvas(5, 5), St = lt.getContext("2d", {
|
|
2169
2169
|
willReadFrequently: !0,
|
|
2170
2170
|
desynchronized: !0
|
|
2171
2171
|
});
|
|
2172
2172
|
else {
|
|
2173
2173
|
const r = document.createElement("canvas");
|
|
2174
|
-
r.width = 5, r.height = 5,
|
|
2174
|
+
r.width = 5, r.height = 5, lt = r, St = r.getContext("2d", {
|
|
2175
2175
|
willReadFrequently: !0,
|
|
2176
2176
|
desynchronized: !0
|
|
2177
2177
|
});
|
|
2178
2178
|
}
|
|
2179
|
-
return
|
|
2180
|
-
},
|
|
2179
|
+
return St;
|
|
2180
|
+
}, ni = (r) => {
|
|
2181
2181
|
if (!r) return !0;
|
|
2182
2182
|
const t = r.trim().toLowerCase();
|
|
2183
2183
|
return t.startsWith("var(") || [
|
|
@@ -2196,56 +2196,56 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), je =
|
|
|
2196
2196
|
"repeating-radial-gradient",
|
|
2197
2197
|
"repeating-conic-gradient"
|
|
2198
2198
|
].some((s) => t.includes(s));
|
|
2199
|
-
},
|
|
2199
|
+
}, ct = (r, t) => {
|
|
2200
2200
|
console.warn(
|
|
2201
2201
|
`[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(G)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
2202
2202
|
);
|
|
2203
|
-
},
|
|
2204
|
-
const e = t ? `${r}|${t}` : r, i =
|
|
2203
|
+
}, Ct = (r, t = null) => {
|
|
2204
|
+
const e = t ? `${r}|${t}` : r, i = F.get(e);
|
|
2205
2205
|
if (i !== void 0)
|
|
2206
2206
|
return i ?? G;
|
|
2207
|
-
if (
|
|
2208
|
-
return
|
|
2209
|
-
const s =
|
|
2207
|
+
if (ni(r))
|
|
2208
|
+
return ct(r, "Unsupported color format or special value."), F.set(e, null), G;
|
|
2209
|
+
const s = si();
|
|
2210
2210
|
if (!s)
|
|
2211
|
-
return
|
|
2211
|
+
return ct(r, "Could not get canvas context."), F.set(e, null), G;
|
|
2212
2212
|
try {
|
|
2213
|
-
|
|
2214
|
-
const n =
|
|
2213
|
+
J === 0 && s.clearRect(0, 0, 5, 5);
|
|
2214
|
+
const n = J % 5, o = Math.floor(J / 5);
|
|
2215
2215
|
s.clearRect(n, o, 1, 1), t && (s.fillStyle = t, s.fillRect(n, o, 1, 1)), s.fillStyle = r, s.fillRect(n, o, 1, 1);
|
|
2216
2216
|
const a = s.getImageData(n, o, 1, 1);
|
|
2217
|
-
|
|
2218
|
-
const [
|
|
2219
|
-
if (
|
|
2220
|
-
return
|
|
2221
|
-
const
|
|
2222
|
-
return
|
|
2217
|
+
J = (J + 1) % 25;
|
|
2218
|
+
const [c, u, d, f] = a.data;
|
|
2219
|
+
if (f === 0)
|
|
2220
|
+
return ct(r, "Fully transparent color."), F.set(e, null), G;
|
|
2221
|
+
const p = { r: c, g: u, b: d, a: f / 255 };
|
|
2222
|
+
return F.set(e, p), p;
|
|
2223
2223
|
} catch (n) {
|
|
2224
|
-
return
|
|
2224
|
+
return ct(r, `Error: ${n instanceof Error ? n.message : String(n)}`), F.set(e, null), G;
|
|
2225
2225
|
}
|
|
2226
|
-
},
|
|
2226
|
+
}, Et = (r) => {
|
|
2227
2227
|
const t = r / 255;
|
|
2228
2228
|
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2229
|
-
},
|
|
2230
|
-
const t =
|
|
2229
|
+
}, he = (r) => {
|
|
2230
|
+
const t = Et(r.r), e = Et(r.g), i = Et(r.b);
|
|
2231
2231
|
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2232
|
-
},
|
|
2233
|
-
const e = typeof r == "string" ?
|
|
2232
|
+
}, de = (r, t) => {
|
|
2233
|
+
const e = typeof r == "string" ? Ct(r) : r, i = typeof t == "string" ? Ct(t) : t, s = he(e), n = he(i), o = Math.max(s, n), a = Math.min(s, n);
|
|
2234
2234
|
return (o + 0.05) / (a + 0.05);
|
|
2235
|
-
},
|
|
2236
|
-
const e =
|
|
2235
|
+
}, xt = (r, t = null) => {
|
|
2236
|
+
const e = Ct(r, t), i = de(e, { r: 255, g: 255, b: 255, a: 1 }), s = de(e, { r: 0, g: 0, b: 0, a: 1 });
|
|
2237
2237
|
return i > s;
|
|
2238
|
-
},
|
|
2239
|
-
var
|
|
2240
|
-
const
|
|
2241
|
-
class
|
|
2238
|
+
}, ri = (r, t = null) => xt(r, t) ? "white" : "black", ue = "#FFFF00";
|
|
2239
|
+
var oi = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(oi || {}), ai = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(ai || {});
|
|
2240
|
+
const li = () => "Highlight" in window, pe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2241
|
+
class ci {
|
|
2242
2242
|
/**
|
|
2243
2243
|
* Creates a DecorationGroup object
|
|
2244
2244
|
* @param id Unique HTML ID-adhering name of the group
|
|
2245
2245
|
* @param name Human-readable name of the group
|
|
2246
2246
|
*/
|
|
2247
2247
|
constructor(t, e, i, s) {
|
|
2248
|
-
this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0,
|
|
2248
|
+
this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, li() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2249
2249
|
}
|
|
2250
2250
|
get activeable() {
|
|
2251
2251
|
return this.activateable;
|
|
@@ -2258,13 +2258,13 @@ class ri {
|
|
|
2258
2258
|
* @param decoration Decoration to add
|
|
2259
2259
|
*/
|
|
2260
2260
|
add(t) {
|
|
2261
|
-
const e = `${this.id}-${this.lastItemId++}`, i =
|
|
2261
|
+
const e = `${this.id}-${this.lastItemId++}`, i = nt(this.wnd.document, t.locator);
|
|
2262
2262
|
if (!i) {
|
|
2263
2263
|
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2264
2264
|
return;
|
|
2265
2265
|
}
|
|
2266
2266
|
const s = i.commonAncestorContainer;
|
|
2267
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (
|
|
2267
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (pe.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(pe.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
|
|
2268
2268
|
const n = {
|
|
2269
2269
|
decoration: t,
|
|
2270
2270
|
id: e,
|
|
@@ -2305,10 +2305,10 @@ class ri {
|
|
|
2305
2305
|
experimentalLayout(t) {
|
|
2306
2306
|
const [e, i] = this.requireContainer(!0);
|
|
2307
2307
|
i.add(t.range);
|
|
2308
|
-
const s =
|
|
2308
|
+
const s = wt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? ue;
|
|
2309
2309
|
e.innerHTML = `
|
|
2310
2310
|
::highlight(${this.id}) {
|
|
2311
|
-
color: ${
|
|
2311
|
+
color: ${ri(n, s)};
|
|
2312
2312
|
background-color: ${n};
|
|
2313
2313
|
}`;
|
|
2314
2314
|
}
|
|
@@ -2325,48 +2325,48 @@ class ri {
|
|
|
2325
2325
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2326
2326
|
"column-count"
|
|
2327
2327
|
)
|
|
2328
|
-
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft,
|
|
2329
|
-
if (
|
|
2330
|
-
|
|
2331
|
-
let
|
|
2332
|
-
|
|
2328
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, u = (g, m, b) => {
|
|
2329
|
+
if (g.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2330
|
+
g.style.width = `${i}px`, g.style.height = `${m.height}px`;
|
|
2331
|
+
let D = Math.floor(m.left / i) * i;
|
|
2332
|
+
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2333
2333
|
} else if (t.decoration?.style?.width === "bounds")
|
|
2334
|
-
|
|
2334
|
+
g.style.width = `${b.width}px`, g.style.height = `${m.height}px`, g.style.left = `${b.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2335
2335
|
else if (t.decoration?.style?.width === "page") {
|
|
2336
|
-
|
|
2337
|
-
let
|
|
2338
|
-
|
|
2336
|
+
g.style.width = `${n}px`, g.style.height = `${m.height}px`;
|
|
2337
|
+
let D = Math.floor(m.left / n) * n;
|
|
2338
|
+
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2339
2339
|
} else
|
|
2340
|
-
|
|
2341
|
-
},
|
|
2342
|
-
let
|
|
2343
|
-
const
|
|
2344
|
-
|
|
2340
|
+
g.style.width = `${m.width}px`, g.style.height = `${m.height}px`, g.style.left = `${m.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2341
|
+
}, d = t.range.getBoundingClientRect();
|
|
2342
|
+
let f = this.wnd.document.createElement("template");
|
|
2343
|
+
const p = this.getCurrentDarkMode();
|
|
2344
|
+
f.innerHTML = `
|
|
2345
2345
|
<div
|
|
2346
2346
|
data-readium="true"
|
|
2347
2347
|
class="readium-highlight"
|
|
2348
2348
|
style="${[
|
|
2349
|
-
`background-color: ${t.decoration?.style?.tint ??
|
|
2349
|
+
`background-color: ${t.decoration?.style?.tint ?? ue} !important`,
|
|
2350
2350
|
//"opacity: 0.3 !important",
|
|
2351
|
-
`mix-blend-mode: ${
|
|
2351
|
+
`mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
|
|
2352
2352
|
"opacity: 1 !important",
|
|
2353
2353
|
"box-sizing: border-box !important"
|
|
2354
2354
|
].join("; ")}"
|
|
2355
2355
|
>
|
|
2356
2356
|
</div>
|
|
2357
2357
|
`.trim();
|
|
2358
|
-
const v =
|
|
2358
|
+
const v = f.content.firstElementChild;
|
|
2359
2359
|
if (t.decoration?.style?.layout === "bounds") {
|
|
2360
|
-
const
|
|
2361
|
-
|
|
2360
|
+
const g = v.cloneNode(!0);
|
|
2361
|
+
g.style.setProperty("pointer-events", "none"), u(g, d, d), e.append(g);
|
|
2362
2362
|
} else {
|
|
2363
|
-
let
|
|
2363
|
+
let g = Qe(
|
|
2364
2364
|
t.range
|
|
2365
2365
|
);
|
|
2366
|
-
|
|
2367
|
-
for (let
|
|
2366
|
+
g = g.sort((m, b) => m.top < b.top ? -1 : m.top > b.top ? 1 : 0);
|
|
2367
|
+
for (let m of g) {
|
|
2368
2368
|
const b = v.cloneNode(!0);
|
|
2369
|
-
b.style.setProperty("pointer-events", "none"),
|
|
2369
|
+
b.style.setProperty("pointer-events", "none"), u(b, m, d), e.append(b);
|
|
2370
2370
|
}
|
|
2371
2371
|
}
|
|
2372
2372
|
t.container = e, t.clickableElements = Array.from(
|
|
@@ -2393,7 +2393,7 @@ class ri {
|
|
|
2393
2393
|
return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
|
|
2394
2394
|
}
|
|
2395
2395
|
getCurrentDarkMode() {
|
|
2396
|
-
return
|
|
2396
|
+
return wt(this.wnd, "--USER__appearance") === "readium-night-on" || xt(wt(this.wnd, "--USER__backgroundColor")) || xt(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
|
|
2397
2397
|
}
|
|
2398
2398
|
/**
|
|
2399
2399
|
* Removes the group container.
|
|
@@ -2402,7 +2402,7 @@ class ri {
|
|
|
2402
2402
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2403
2403
|
}
|
|
2404
2404
|
}
|
|
2405
|
-
const
|
|
2405
|
+
const j = class j extends K {
|
|
2406
2406
|
constructor() {
|
|
2407
2407
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2408
2408
|
}
|
|
@@ -2427,9 +2427,9 @@ const Q = class Q extends X {
|
|
|
2427
2427
|
}, 50);
|
|
2428
2428
|
}
|
|
2429
2429
|
mount(t, e) {
|
|
2430
|
-
return this.wnd = t, e.register("decorate",
|
|
2430
|
+
return this.wnd = t, e.register("decorate", j.moduleName, (i, s) => {
|
|
2431
2431
|
const n = i;
|
|
2432
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
2432
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = k.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new ci(
|
|
2433
2433
|
t,
|
|
2434
2434
|
e,
|
|
2435
2435
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2454,8 +2454,8 @@ const Q = class Q extends X {
|
|
|
2454
2454
|
}), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
|
|
2455
2455
|
i.some((n) => {
|
|
2456
2456
|
if (n.type === "attributes" && n.attributeName === "style") {
|
|
2457
|
-
const o = n.target, a = n.oldValue,
|
|
2458
|
-
return
|
|
2457
|
+
const o = n.target, a = n.oldValue, c = o.getAttribute("style"), u = this.extractCustomProperty(a, "--USER__appearance"), d = this.extractCustomProperty(c, "--USER__appearance"), f = this.extractCustomProperty(a, "--USER__backgroundColor"), p = this.extractCustomProperty(c, "--USER__backgroundColor");
|
|
2458
|
+
return u !== d || f !== p;
|
|
2459
2459
|
}
|
|
2460
2460
|
return !1;
|
|
2461
2461
|
}) && this.updateHighlightStyles();
|
|
@@ -2467,12 +2467,12 @@ const Q = class Q extends X {
|
|
|
2467
2467
|
}), e.log("Decorator Mounted"), !0;
|
|
2468
2468
|
}
|
|
2469
2469
|
unmount(t, e) {
|
|
2470
|
-
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(
|
|
2470
|
+
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(j.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2471
2471
|
}
|
|
2472
2472
|
};
|
|
2473
|
-
|
|
2474
|
-
let
|
|
2475
|
-
const
|
|
2473
|
+
j.moduleName = "decorator";
|
|
2474
|
+
let Tt = j;
|
|
2475
|
+
const me = "readium-snapper-style", tt = class tt extends K {
|
|
2476
2476
|
constructor() {
|
|
2477
2477
|
super(...arguments), this.protected = !1;
|
|
2478
2478
|
}
|
|
@@ -2485,59 +2485,62 @@ const ce = "readium-snapper-style", j = class j extends X {
|
|
|
2485
2485
|
}
|
|
2486
2486
|
mount(t, e) {
|
|
2487
2487
|
const i = t.document.createElement("style");
|
|
2488
|
-
return i.dataset.readium = "true", i.id =
|
|
2488
|
+
return i.dataset.readium = "true", i.id = me, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", tt.moduleName, (s, n) => {
|
|
2489
2489
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2490
|
-
}), e.register("unprotect",
|
|
2490
|
+
}), e.register("unprotect", tt.moduleName, (s, n) => {
|
|
2491
2491
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2492
2492
|
}), e.log("Snapper Mounted"), !0;
|
|
2493
2493
|
}
|
|
2494
2494
|
unmount(t, e) {
|
|
2495
|
-
return t.document.getElementById(
|
|
2495
|
+
return t.document.getElementById(me)?.remove(), e.log("Snapper Unmounted"), !0;
|
|
2496
2496
|
}
|
|
2497
2497
|
};
|
|
2498
|
-
|
|
2499
|
-
let
|
|
2500
|
-
function
|
|
2501
|
-
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2498
|
+
tt.moduleName = "snapper";
|
|
2499
|
+
let X = tt;
|
|
2500
|
+
function hi(r) {
|
|
2501
|
+
return (r.document.documentElement.dir || r.document.body.dir).toLowerCase() === "rtl";
|
|
2502
2502
|
}
|
|
2503
|
-
function
|
|
2503
|
+
function di(r) {
|
|
2504
|
+
return (r.getComputedStyle(r.document.documentElement).writingMode || r.getComputedStyle(r.document.body).writingMode) === "vertical-lr";
|
|
2505
|
+
}
|
|
2506
|
+
function De(r) {
|
|
2504
2507
|
return parseInt(
|
|
2505
2508
|
r.getComputedStyle(
|
|
2506
2509
|
r.document.documentElement
|
|
2507
2510
|
).getPropertyValue("column-count")
|
|
2508
2511
|
);
|
|
2509
2512
|
}
|
|
2510
|
-
function
|
|
2513
|
+
function fe(r) {
|
|
2511
2514
|
const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2512
2515
|
return r.clientHeight - e - i;
|
|
2513
2516
|
}
|
|
2514
|
-
function
|
|
2515
|
-
const t =
|
|
2517
|
+
function ge(r) {
|
|
2518
|
+
const t = De(r);
|
|
2516
2519
|
if (!t)
|
|
2517
2520
|
return !1;
|
|
2518
2521
|
const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2519
|
-
for (const
|
|
2520
|
-
|
|
2521
|
-
const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t,
|
|
2522
|
-
if (
|
|
2523
|
-
for (let
|
|
2524
|
-
const
|
|
2525
|
-
|
|
2522
|
+
for (const u of e)
|
|
2523
|
+
u.remove();
|
|
2524
|
+
const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t, c = t === 1 || a === 0 ? 0 : t - a;
|
|
2525
|
+
if (c > 0)
|
|
2526
|
+
for (let u = 0; u < c; u++) {
|
|
2527
|
+
const d = r.document.createElement("div");
|
|
2528
|
+
d.setAttribute("id", `readium-virtual-page-${u}`), d.dataset.readium = "true", CSS.supports("break-before", "column") ? d.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (d.style.breakInside = "avoid-column"), d.style.height = fe(r.document.documentElement) + "px"), d.innerHTML = "​", r.document.body.appendChild(d);
|
|
2526
2529
|
}
|
|
2527
|
-
return i !==
|
|
2530
|
+
return i !== c;
|
|
2528
2531
|
}
|
|
2529
|
-
function
|
|
2532
|
+
function Ft(r) {
|
|
2530
2533
|
const t = r.document.createElement("style");
|
|
2531
2534
|
t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
|
|
2532
2535
|
}
|
|
2533
|
-
function
|
|
2536
|
+
function ui(r) {
|
|
2534
2537
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2535
2538
|
}
|
|
2536
2539
|
function A(r) {
|
|
2537
2540
|
const t = r.getSelection();
|
|
2538
2541
|
t && t.removeAllRanges();
|
|
2539
2542
|
}
|
|
2540
|
-
const
|
|
2543
|
+
const pi = [
|
|
2541
2544
|
"a",
|
|
2542
2545
|
"audio",
|
|
2543
2546
|
"button",
|
|
@@ -2551,14 +2554,14 @@ const ai = [
|
|
|
2551
2554
|
"textarea",
|
|
2552
2555
|
"video"
|
|
2553
2556
|
];
|
|
2554
|
-
function
|
|
2555
|
-
return
|
|
2557
|
+
function Ie(r) {
|
|
2558
|
+
return pi.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Ie(r.parentElement) : null;
|
|
2556
2559
|
}
|
|
2557
|
-
function
|
|
2558
|
-
const e =
|
|
2560
|
+
function yt(r, t) {
|
|
2561
|
+
const e = ze(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2559
2562
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2560
2563
|
});
|
|
2561
|
-
return new
|
|
2564
|
+
return new k({
|
|
2562
2565
|
href: "#",
|
|
2563
2566
|
type: "application/xhtml+xml",
|
|
2564
2567
|
locations: new C({
|
|
@@ -2571,15 +2574,15 @@ function Ut(r, t) {
|
|
|
2571
2574
|
})
|
|
2572
2575
|
});
|
|
2573
2576
|
}
|
|
2574
|
-
function
|
|
2577
|
+
function ze(r, t, e) {
|
|
2575
2578
|
for (var i = 0; i < t.children.length; i++) {
|
|
2576
2579
|
const s = t.children[i];
|
|
2577
|
-
if (!
|
|
2578
|
-
return
|
|
2580
|
+
if (!gi(s) && mi(r, s, e))
|
|
2581
|
+
return fi(r, s) ? s : ze(r, s, e);
|
|
2579
2582
|
}
|
|
2580
2583
|
return t;
|
|
2581
2584
|
}
|
|
2582
|
-
function
|
|
2585
|
+
function mi(r, t, e) {
|
|
2583
2586
|
if (t === document.body || t === document.documentElement)
|
|
2584
2587
|
return !0;
|
|
2585
2588
|
if (!document || !document.documentElement || !document.body)
|
|
@@ -2587,11 +2590,11 @@ function li(r, t, e) {
|
|
|
2587
2590
|
const i = t.getBoundingClientRect();
|
|
2588
2591
|
return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2589
2592
|
}
|
|
2590
|
-
function
|
|
2593
|
+
function fi(r, t) {
|
|
2591
2594
|
const e = t.getBoundingClientRect();
|
|
2592
2595
|
return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
|
|
2593
2596
|
}
|
|
2594
|
-
function
|
|
2597
|
+
function gi(r) {
|
|
2595
2598
|
const t = getComputedStyle(r);
|
|
2596
2599
|
if (t) {
|
|
2597
2600
|
const e = t.getPropertyValue("display");
|
|
@@ -2600,7 +2603,7 @@ function hi(r) {
|
|
|
2600
2603
|
}
|
|
2601
2604
|
return !1;
|
|
2602
2605
|
}
|
|
2603
|
-
const
|
|
2606
|
+
const yi = {
|
|
2604
2607
|
maxVelocity: 200,
|
|
2605
2608
|
// Reasonable default for human-like scrolling (pixels/ms)
|
|
2606
2609
|
minVariance: 0.01,
|
|
@@ -2611,7 +2614,7 @@ const di = {
|
|
|
2611
2614
|
// Reasonable default for detecting patterns
|
|
2612
2615
|
maxConsistentScrolls: 15
|
|
2613
2616
|
// Balanced threshold for flagging
|
|
2614
|
-
},
|
|
2617
|
+
}, Gt = {
|
|
2615
2618
|
maxVelocity: 200,
|
|
2616
2619
|
// Extremely fast scrolling (pixels/ms)
|
|
2617
2620
|
minVariance: 1e-5,
|
|
@@ -2622,20 +2625,20 @@ const di = {
|
|
|
2622
2625
|
// Only trigger on near-perfect patterns
|
|
2623
2626
|
maxConsistentScrolls: 20
|
|
2624
2627
|
// Need many consistent scrolls
|
|
2625
|
-
},
|
|
2628
|
+
}, Me = {
|
|
2626
2629
|
maxSelectionsPerSecond: 500,
|
|
2627
2630
|
minVariance: 50,
|
|
2628
2631
|
historySize: 20
|
|
2629
|
-
},
|
|
2632
|
+
}, bi = {
|
|
2630
2633
|
enabled: !0,
|
|
2631
2634
|
maxSelectionPercent: 0.1,
|
|
2632
2635
|
minThreshold: 100,
|
|
2633
2636
|
absoluteMaxChars: 5e3,
|
|
2634
2637
|
historySize: 20
|
|
2635
2638
|
};
|
|
2636
|
-
class
|
|
2639
|
+
class bt {
|
|
2637
2640
|
constructor(t = {}) {
|
|
2638
|
-
this.history = [], this.consistentScrollCount = 0, this.options = { ...
|
|
2641
|
+
this.history = [], this.consistentScrollCount = 0, this.options = { ...yi, ...t };
|
|
2639
2642
|
}
|
|
2640
2643
|
analyze(t, e, i) {
|
|
2641
2644
|
if (i <= 0) return !1;
|
|
@@ -2645,19 +2648,19 @@ class Bt {
|
|
|
2645
2648
|
direction: t,
|
|
2646
2649
|
velocity: s,
|
|
2647
2650
|
distance: Math.abs(e)
|
|
2648
|
-
}), this.history = this.history.filter((
|
|
2651
|
+
}), this.history = this.history.filter((m) => n - m.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
|
|
2649
2652
|
if (s > this.options.maxVelocity)
|
|
2650
2653
|
return this.resetAfterDetection(), !0;
|
|
2651
|
-
const o = this.history.map((
|
|
2652
|
-
if (
|
|
2654
|
+
const o = this.history.map((m) => m.velocity), a = this.history.map((m) => m.distance), c = o.reduce((m, b) => m + b, 0) / o.length, u = a.reduce((m, b) => m + b, 0) / a.length, d = o.reduce((m, b) => m + Math.pow(b - c, 2), 0) / o.length, f = a.reduce((m, b) => m + Math.pow(b - u, 2), 0) / a.length;
|
|
2655
|
+
if (d < this.options.minVariance && f < u * 0.1) {
|
|
2653
2656
|
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2654
2657
|
return this.resetAfterDetection(), !0;
|
|
2655
2658
|
} else
|
|
2656
2659
|
this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
|
|
2657
|
-
let
|
|
2658
|
-
for (let
|
|
2659
|
-
this.history[
|
|
2660
|
-
return
|
|
2660
|
+
let p = 0, v = this.history[0].direction;
|
|
2661
|
+
for (let m = 1; m < this.history.length; m++)
|
|
2662
|
+
this.history[m].direction !== v && (p++, v = this.history[m].direction);
|
|
2663
|
+
return p / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
|
|
2661
2664
|
}
|
|
2662
2665
|
resetAfterDetection() {
|
|
2663
2666
|
this.history = this.history.slice(-3), this.consistentScrollCount = 0;
|
|
@@ -2666,34 +2669,52 @@ class Bt {
|
|
|
2666
2669
|
this.history = [], this.consistentScrollCount = 0;
|
|
2667
2670
|
}
|
|
2668
2671
|
}
|
|
2669
|
-
const
|
|
2672
|
+
const ye = "readium-column-snapper-style", vi = 200, T = class T extends X {
|
|
2670
2673
|
constructor() {
|
|
2671
|
-
super(...arguments), this.isSnapProtectionEnabled = !1, this.patternAnalyzer = null, this.lastTurnTime = 0, this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2674
|
+
super(...arguments), this.isSnapProtectionEnabled = !1, this.patternAnalyzer = null, this.lastTurnTime = 0, this.rtl = !1, this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2672
2675
|
}
|
|
2673
2676
|
doc() {
|
|
2674
2677
|
return this.wnd.document.scrollingElement;
|
|
2675
2678
|
}
|
|
2676
2679
|
scrollOffset() {
|
|
2677
|
-
|
|
2680
|
+
const t = this.doc().scrollLeft;
|
|
2681
|
+
return t !== 0 ? t : this.alreadyScrollLeft;
|
|
2678
2682
|
}
|
|
2679
2683
|
snapOffset(t) {
|
|
2680
|
-
const e = t + (
|
|
2684
|
+
const e = t + (this.rtl ? -1 : 1);
|
|
2681
2685
|
return e - e % this.wnd.innerWidth;
|
|
2682
2686
|
}
|
|
2687
|
+
/**
|
|
2688
|
+
* Snap a non-negative normalized offset (distance from document start) to
|
|
2689
|
+
* the nearest page boundary. Works identically regardless of reading direction.
|
|
2690
|
+
*/
|
|
2691
|
+
snapNormOffset(t) {
|
|
2692
|
+
const e = t + 1;
|
|
2693
|
+
return e - e % this.wnd.innerWidth;
|
|
2694
|
+
}
|
|
2695
|
+
/**
|
|
2696
|
+
* Normalized scroll position: distance from document start, always in
|
|
2697
|
+
* [0, scrollWidth - innerWidth] regardless of reading direction.
|
|
2698
|
+
* scrollLeft may be negative depending on the browser — Math.abs() normalizes it.
|
|
2699
|
+
*/
|
|
2700
|
+
normScroll() {
|
|
2701
|
+
const t = this.doc().scrollLeft || this.alreadyScrollLeft;
|
|
2702
|
+
return this.rtl ? Math.abs(t) : Math.max(0, this.wnd.scrollX > 0 ? this.wnd.scrollX : t);
|
|
2703
|
+
}
|
|
2683
2704
|
reportProgress() {
|
|
2684
|
-
const t = this.
|
|
2705
|
+
const t = this.cachedScrollWidth, e = this.wnd.innerWidth, i = this.normScroll(), s = Math.max(1, t - e), n = Math.max(0, Math.min(1, i / s)), o = Math.max(0, Math.min(1, (i + e) / t));
|
|
2685
2706
|
this.comms.send("progress", {
|
|
2686
|
-
start:
|
|
2687
|
-
end:
|
|
2707
|
+
start: n,
|
|
2708
|
+
end: o
|
|
2688
2709
|
});
|
|
2689
2710
|
}
|
|
2690
2711
|
shake() {
|
|
2691
2712
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2692
|
-
const t = this.doc();
|
|
2693
|
-
t.classList.add(
|
|
2694
|
-
const
|
|
2713
|
+
const t = this.doc(), e = this.normScroll() < 5, i = this.rtl ? e ? "readium-bounce-r" : "readium-bounce-l" : "readium-bounce-r";
|
|
2714
|
+
t.classList.add(i);
|
|
2715
|
+
const s = this.scrollOffset();
|
|
2695
2716
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2696
|
-
t.classList.remove(
|
|
2717
|
+
t.classList.remove(i), this.shakeTimeout = 0, this.doc().scrollLeft = s;
|
|
2697
2718
|
}, 150);
|
|
2698
2719
|
}
|
|
2699
2720
|
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
@@ -2704,27 +2725,21 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2704
2725
|
}
|
|
2705
2726
|
// Snaps the current offset to the page width.
|
|
2706
2727
|
snapCurrentOffset(t = !1, e = !1) {
|
|
2707
|
-
const i = this.
|
|
2708
|
-
|
|
2709
|
-
d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
|
|
2710
|
-
), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
|
|
2711
|
-
if (this.checkSuspiciousSnap(g, Math.abs(u - this.scrollOffset())), t && u !== this.scrollOffset()) {
|
|
2728
|
+
const i = this.doc(), s = De(this.wnd), n = this.cachedScrollWidth - this.wnd.innerWidth, o = Math.min(Math.max(0, this.normScroll()), n), a = this.dragOffset(), c = this.rtl ? -a : a, u = this.wnd.innerWidth / 3 * (c > 0 ? 2 : 1), d = Math.min(n, Math.max(0, this.snapNormOffset(o + u))), f = this.rtl ? -d : d, p = this.rtl ? -o : o, v = f > p ? "right" : "left";
|
|
2729
|
+
if (this.checkSuspiciousSnap(v, Math.abs(f - p)), t && f !== p) {
|
|
2712
2730
|
this.snappingCancelled = !1;
|
|
2713
|
-
const
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
);
|
|
2717
|
-
let f;
|
|
2718
|
-
const p = (b) => {
|
|
2731
|
+
const g = (_, V, rt, ot) => rt > ot ? V : _ + (V - _) * ui(rt / ot), m = vi * s;
|
|
2732
|
+
let b;
|
|
2733
|
+
const D = (_) => {
|
|
2719
2734
|
if (this.snappingCancelled) return;
|
|
2720
|
-
|
|
2721
|
-
const
|
|
2722
|
-
|
|
2735
|
+
b || (b = _);
|
|
2736
|
+
const V = _ - b, rt = g(this.overscroll, 0, V, m), ot = g(p, f, V, m);
|
|
2737
|
+
i.scrollLeft = ot, this.overscroll !== 0 && (i.style.transform = `translate3d(${-rt}px, 0px, 0px)`), V < m ? this.wnd.requestAnimationFrame(D) : (this.clearTouches(), i.style.removeProperty("transform"), i.scrollLeft = f, e || this.reportProgress());
|
|
2723
2738
|
};
|
|
2724
|
-
this.wnd.requestAnimationFrame(
|
|
2739
|
+
this.wnd.requestAnimationFrame(D);
|
|
2725
2740
|
} else
|
|
2726
|
-
|
|
2727
|
-
|
|
2741
|
+
i.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2742
|
+
i.scrollLeft = f, this.clearTouches(), e || this.reportProgress();
|
|
2728
2743
|
});
|
|
2729
2744
|
}
|
|
2730
2745
|
dragOffset() {
|
|
@@ -2749,8 +2764,8 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2749
2764
|
}
|
|
2750
2765
|
onTouchEnd(t) {
|
|
2751
2766
|
if (this.touchState === 2) {
|
|
2752
|
-
const e = this.dragOffset(), i = this.
|
|
2753
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(),
|
|
2767
|
+
const e = this.dragOffset(), i = this.normScroll(), s = this.cachedScrollWidth - this.wnd.innerWidth, n = this.rtl ? -e : e;
|
|
2768
|
+
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), n > 5 && this.comms.send("no_more", void 0), n < -5 && this.comms.send("no_less", void 0)) : i < 5 && n < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : s - i < 5 && n > 5 && (this.alreadyScrollLeft = this.rtl ? -s : s, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
|
|
2754
2769
|
}
|
|
2755
2770
|
this.touchState = 0;
|
|
2756
2771
|
}
|
|
@@ -2760,11 +2775,11 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2760
2775
|
onTouchMove(t) {
|
|
2761
2776
|
if (this.touchState === 0) return;
|
|
2762
2777
|
this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2763
|
-
const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
|
|
2764
|
-
i <
|
|
2778
|
+
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, s = this.rtl ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0, n = this.rtl ? 0 : this.cachedScrollWidth - this.wnd.innerWidth;
|
|
2779
|
+
i < s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i > n ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = i);
|
|
2765
2780
|
}
|
|
2766
2781
|
enableSnapProtection() {
|
|
2767
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2782
|
+
this.patternAnalyzer || (this.patternAnalyzer = new bt({
|
|
2768
2783
|
maxVelocity: this.wnd.innerWidth,
|
|
2769
2784
|
// page width
|
|
2770
2785
|
minVariance: 0.1,
|
|
@@ -2787,10 +2802,10 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2787
2802
|
});
|
|
2788
2803
|
}
|
|
2789
2804
|
mount(t, e) {
|
|
2790
|
-
if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
|
|
2805
|
+
if (this.wnd = t, this.comms = e, this.rtl = hi(t), !super.mount(t, e)) return !1;
|
|
2791
2806
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2792
2807
|
const i = t.document.createElement("style");
|
|
2793
|
-
i.dataset.readium = "true", i.id =
|
|
2808
|
+
i.dataset.readium = "true", i.id = ye, i.textContent = `
|
|
2794
2809
|
@keyframes readium-bounce-l-animation {
|
|
2795
2810
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2796
2811
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2826,112 +2841,114 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2826
2841
|
}
|
|
2827
2842
|
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2828
2843
|
t.requestAnimationFrame(() => {
|
|
2829
|
-
t &&
|
|
2844
|
+
t && ge(t);
|
|
2830
2845
|
}), this.onWidthChange();
|
|
2831
|
-
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((
|
|
2832
|
-
for (const
|
|
2833
|
-
if (
|
|
2834
|
-
const
|
|
2835
|
-
(!
|
|
2836
|
-
t &&
|
|
2846
|
+
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((o) => {
|
|
2847
|
+
for (const a of o)
|
|
2848
|
+
if (a.target === this.wnd.document.documentElement) {
|
|
2849
|
+
const c = a.oldValue, u = a.target.getAttribute("style"), d = /transform\s*:\s*([^;]+)/, f = c?.match(d), p = u?.match(d);
|
|
2850
|
+
(!f && !p || f && !p || f && p && f[1] !== p[1]) && (t.requestAnimationFrame(() => {
|
|
2851
|
+
t && ge(t);
|
|
2837
2852
|
}), this.onWidthChange());
|
|
2838
2853
|
} else
|
|
2839
2854
|
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2840
|
-
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] }), e.register("scroll_protection",
|
|
2841
|
-
this.enableSnapProtection(),
|
|
2855
|
+
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] }), e.register("scroll_protection", T.moduleName, (o, a) => {
|
|
2856
|
+
this.enableSnapProtection(), a(!0);
|
|
2842
2857
|
});
|
|
2843
|
-
const s = (
|
|
2844
|
-
const
|
|
2845
|
-
return this.doc().scrollLeft = this.snapOffset(
|
|
2858
|
+
const s = (o) => {
|
|
2859
|
+
const a = this.doc().scrollLeft;
|
|
2860
|
+
return this.doc().scrollLeft = this.snapOffset(o), a !== this.doc().scrollLeft;
|
|
2861
|
+
}, n = (o) => {
|
|
2862
|
+
const a = this.doc().scrollLeft, c = this.snapNormOffset(Math.max(0, Math.min(this.cachedScrollWidth - t.innerWidth, o)));
|
|
2863
|
+
return this.doc().scrollLeft = -c, a !== this.doc().scrollLeft;
|
|
2846
2864
|
};
|
|
2847
|
-
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression",
|
|
2848
|
-
const
|
|
2849
|
-
if (
|
|
2865
|
+
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", T.moduleName, (o, a) => {
|
|
2866
|
+
const c = o;
|
|
2867
|
+
if (c < 0 || c > 1) {
|
|
2850
2868
|
e.send("error", {
|
|
2851
2869
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2852
|
-
}),
|
|
2870
|
+
}), a(!1);
|
|
2853
2871
|
return;
|
|
2854
2872
|
}
|
|
2855
2873
|
this.wnd.requestAnimationFrame(() => {
|
|
2856
2874
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2857
|
-
const d = this.cachedScrollWidth
|
|
2858
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2875
|
+
const d = (this.cachedScrollWidth - t.innerWidth) * c;
|
|
2876
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(d) : this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), A(this.wnd), a(!0);
|
|
2859
2877
|
});
|
|
2860
|
-
}), e.register("go_id",
|
|
2861
|
-
const
|
|
2862
|
-
if (!
|
|
2863
|
-
|
|
2878
|
+
}), e.register("go_id", T.moduleName, (o, a) => {
|
|
2879
|
+
const c = t.document.getElementById(o);
|
|
2880
|
+
if (!c) {
|
|
2881
|
+
a(!1);
|
|
2864
2882
|
return;
|
|
2865
2883
|
}
|
|
2866
2884
|
this.wnd.requestAnimationFrame(() => {
|
|
2867
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2885
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2868
2886
|
});
|
|
2869
|
-
}), e.register("go_text",
|
|
2870
|
-
let
|
|
2871
|
-
Array.isArray(
|
|
2872
|
-
const
|
|
2887
|
+
}), e.register("go_text", T.moduleName, (o, a) => {
|
|
2888
|
+
let c;
|
|
2889
|
+
Array.isArray(o) && (o.length > 1 && (c = o[1]), o = o[0]);
|
|
2890
|
+
const u = H.deserialize(o), d = nt(this.wnd.document, new k({
|
|
2873
2891
|
href: t.location.href,
|
|
2874
2892
|
type: "text/html",
|
|
2875
|
-
text:
|
|
2876
|
-
locations:
|
|
2893
|
+
text: u,
|
|
2894
|
+
locations: c ? new C({
|
|
2877
2895
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2878
|
-
["cssSelector",
|
|
2896
|
+
["cssSelector", c]
|
|
2879
2897
|
])
|
|
2880
2898
|
}) : void 0
|
|
2881
2899
|
}));
|
|
2882
|
-
if (!
|
|
2883
|
-
|
|
2900
|
+
if (!d) {
|
|
2901
|
+
a(!1);
|
|
2884
2902
|
return;
|
|
2885
2903
|
}
|
|
2886
2904
|
this.wnd.requestAnimationFrame(() => {
|
|
2887
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2905
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(d.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(d.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2888
2906
|
});
|
|
2889
|
-
}), e.register("go_end",
|
|
2890
|
-
const a = B(t) ? -1 : 1;
|
|
2907
|
+
}), e.register("go_end", T.moduleName, (o, a) => {
|
|
2891
2908
|
this.wnd.requestAnimationFrame(() => {
|
|
2892
2909
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2893
|
-
|
|
2894
|
-
if (this.doc().scrollLeft ===
|
|
2895
|
-
this.doc().scrollLeft =
|
|
2910
|
+
let c;
|
|
2911
|
+
if (this.rtl ? c = -this.snapNormOffset(this.cachedScrollWidth - t.innerWidth) : c = this.snapOffset(this.cachedScrollWidth), this.doc().scrollLeft === c) return a(!1);
|
|
2912
|
+
this.doc().scrollLeft = c, this.reportProgress(), A(this.wnd), a(!0);
|
|
2896
2913
|
});
|
|
2897
|
-
}), e.register("go_start",
|
|
2914
|
+
}), e.register("go_start", T.moduleName, (o, a) => {
|
|
2898
2915
|
this.wnd.requestAnimationFrame(() => {
|
|
2899
|
-
if (this.doc().scrollLeft === 0) return
|
|
2900
|
-
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd),
|
|
2916
|
+
if (this.doc().scrollLeft === 0) return a(!1);
|
|
2917
|
+
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), a(!0);
|
|
2901
2918
|
});
|
|
2902
|
-
}), e.register("go_prev",
|
|
2919
|
+
}), e.register("go_prev", T.moduleName, (o, a) => {
|
|
2903
2920
|
this.wnd.requestAnimationFrame(() => {
|
|
2904
2921
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2905
|
-
|
|
2906
|
-
|
|
2922
|
+
let c;
|
|
2923
|
+
this.rtl ? c = n(this.normScroll() - t.innerWidth) : c = s(t.scrollX - t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), a(c);
|
|
2907
2924
|
});
|
|
2908
|
-
}), e.register("go_next",
|
|
2925
|
+
}), e.register("go_next", T.moduleName, (o, a) => {
|
|
2909
2926
|
this.wnd.requestAnimationFrame(() => {
|
|
2910
2927
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2911
|
-
|
|
2912
|
-
|
|
2928
|
+
let c;
|
|
2929
|
+
this.rtl ? c = n(this.normScroll() + t.innerWidth) : c = s(t.scrollX + t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), a(c);
|
|
2913
2930
|
});
|
|
2914
|
-
}), e.register("unfocus",
|
|
2915
|
-
this.snappingCancelled = !0, A(this.wnd),
|
|
2916
|
-
}), e.register("shake",
|
|
2917
|
-
this.shake(),
|
|
2918
|
-
}), e.register("focus",
|
|
2931
|
+
}), e.register("unfocus", T.moduleName, (o, a) => {
|
|
2932
|
+
this.snappingCancelled = !0, A(this.wnd), a(!0);
|
|
2933
|
+
}), e.register("shake", T.moduleName, (o, a) => {
|
|
2934
|
+
this.shake(), a(!0);
|
|
2935
|
+
}), e.register("focus", T.moduleName, (o, a) => {
|
|
2919
2936
|
this.wnd.requestAnimationFrame(() => {
|
|
2920
|
-
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(),
|
|
2937
|
+
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), a(!0);
|
|
2921
2938
|
});
|
|
2922
|
-
}), e.register("first_visible_locator",
|
|
2923
|
-
const
|
|
2924
|
-
this.comms.send("first_visible_locator",
|
|
2939
|
+
}), e.register("first_visible_locator", T.moduleName, (o, a) => {
|
|
2940
|
+
const c = yt(t, !1);
|
|
2941
|
+
this.comms.send("first_visible_locator", c.serialize()), a(!0);
|
|
2925
2942
|
}), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
|
|
2926
2943
|
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2927
2944
|
}
|
|
2928
2945
|
unmount(t, e) {
|
|
2929
|
-
return this.snappingCancelled = !0, e.unregisterAll(
|
|
2946
|
+
return this.snappingCancelled = !0, e.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isSnapProtectionEnabled = !1), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), t.document.getElementById(ye)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
|
|
2930
2947
|
}
|
|
2931
2948
|
};
|
|
2932
|
-
|
|
2933
|
-
let
|
|
2934
|
-
const
|
|
2949
|
+
T.moduleName = "column_snapper";
|
|
2950
|
+
let Pt = T;
|
|
2951
|
+
const be = "readium-scroll-snapper-style", P = class P extends X {
|
|
2935
2952
|
constructor() {
|
|
2936
2953
|
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 = (t) => {
|
|
2937
2954
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2977,12 +2994,12 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
2977
2994
|
});
|
|
2978
2995
|
}
|
|
2979
2996
|
enableScrollProtection() {
|
|
2980
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2997
|
+
this.patternAnalyzer || (this.patternAnalyzer = new bt(Gt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
2981
2998
|
}
|
|
2982
2999
|
mount(t, e) {
|
|
2983
3000
|
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
2984
3001
|
const i = t.document.createElement("style");
|
|
2985
|
-
return i.dataset.readium = "true", i.id =
|
|
3002
|
+
return i.dataset.readium = "true", i.id = be, i.textContent = `
|
|
2986
3003
|
* {
|
|
2987
3004
|
scrollbar-width: none; /* for Firefox */
|
|
2988
3005
|
}
|
|
@@ -2994,11 +3011,11 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
2994
3011
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2995
3012
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2996
3013
|
}, 50);
|
|
2997
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
2998
|
-
|
|
3014
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", P.moduleName, () => {
|
|
3015
|
+
Ft(this.wnd);
|
|
2999
3016
|
const s = this.doc().scrollTop;
|
|
3000
3017
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
3001
|
-
}), e.register("go_progression",
|
|
3018
|
+
}), e.register("go_progression", P.moduleName, (s, n) => {
|
|
3002
3019
|
const o = s;
|
|
3003
3020
|
if (o < 0 || o > 1) {
|
|
3004
3021
|
e.send("error", {
|
|
@@ -3009,7 +3026,7 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3009
3026
|
this.wnd.requestAnimationFrame(() => {
|
|
3010
3027
|
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), n(!0);
|
|
3011
3028
|
});
|
|
3012
|
-
}), e.register("go_id",
|
|
3029
|
+
}), e.register("go_id", P.moduleName, (s, n) => {
|
|
3013
3030
|
const o = t.document.getElementById(s);
|
|
3014
3031
|
if (!o) {
|
|
3015
3032
|
n(!1);
|
|
@@ -3018,10 +3035,10 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3018
3035
|
this.wnd.requestAnimationFrame(() => {
|
|
3019
3036
|
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3020
3037
|
});
|
|
3021
|
-
}), e.register("go_text",
|
|
3038
|
+
}), e.register("go_text", P.moduleName, (s, n) => {
|
|
3022
3039
|
let o;
|
|
3023
3040
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3024
|
-
const a = H.deserialize(s),
|
|
3041
|
+
const a = H.deserialize(s), c = nt(this.wnd.document, new k({
|
|
3025
3042
|
href: t.location.href,
|
|
3026
3043
|
type: "text/html",
|
|
3027
3044
|
text: a,
|
|
@@ -3031,40 +3048,40 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3031
3048
|
])
|
|
3032
3049
|
}) : void 0
|
|
3033
3050
|
}));
|
|
3034
|
-
if (!
|
|
3051
|
+
if (!c) {
|
|
3035
3052
|
n(!1);
|
|
3036
3053
|
return;
|
|
3037
3054
|
}
|
|
3038
3055
|
this.wnd.requestAnimationFrame(() => {
|
|
3039
|
-
this.doc().scrollTop =
|
|
3056
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3040
3057
|
});
|
|
3041
|
-
}), e.register("go_start",
|
|
3058
|
+
}), e.register("go_start", P.moduleName, (s, n) => {
|
|
3042
3059
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
3043
3060
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
3044
|
-
}), e.register("go_end",
|
|
3061
|
+
}), e.register("go_end", P.moduleName, (s, n) => {
|
|
3045
3062
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
3046
3063
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
3047
|
-
}), e.register("unfocus",
|
|
3064
|
+
}), e.register("unfocus", P.moduleName, (s, n) => {
|
|
3048
3065
|
A(this.wnd), n(!0);
|
|
3049
|
-
}), e.register("scroll_protection",
|
|
3066
|
+
}), e.register("scroll_protection", P.moduleName, (s, n) => {
|
|
3050
3067
|
this.enableScrollProtection(), n(!0);
|
|
3051
3068
|
}), e.register([
|
|
3052
3069
|
"go_next",
|
|
3053
3070
|
"go_prev"
|
|
3054
|
-
],
|
|
3071
|
+
], P.moduleName, (s, n) => n(!1)), e.register("focus", P.moduleName, (s, n) => {
|
|
3055
3072
|
this.reportProgress(), n(!0);
|
|
3056
|
-
}), e.register("first_visible_locator",
|
|
3057
|
-
const o =
|
|
3073
|
+
}), e.register("first_visible_locator", P.moduleName, (s, n) => {
|
|
3074
|
+
const o = yt(t, !0);
|
|
3058
3075
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
3059
3076
|
}), e.log("ScrollSnapper Mounted"), !0;
|
|
3060
3077
|
}
|
|
3061
3078
|
unmount(t, e) {
|
|
3062
|
-
return e.unregisterAll(
|
|
3079
|
+
return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(be)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
|
|
3063
3080
|
}
|
|
3064
3081
|
};
|
|
3065
|
-
|
|
3066
|
-
let
|
|
3067
|
-
const
|
|
3082
|
+
P.moduleName = "scroll_snapper";
|
|
3083
|
+
let Nt = P;
|
|
3084
|
+
const N = class N extends X {
|
|
3068
3085
|
constructor() {
|
|
3069
3086
|
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 = (t) => {
|
|
3070
3087
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -3110,18 +3127,18 @@ const L = class L extends st {
|
|
|
3110
3127
|
});
|
|
3111
3128
|
}
|
|
3112
3129
|
enableScrollProtection() {
|
|
3113
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
3130
|
+
this.patternAnalyzer || (this.patternAnalyzer = new bt(Gt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3114
3131
|
}
|
|
3115
3132
|
mount(t, e) {
|
|
3116
3133
|
return this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
|
|
3117
3134
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3118
3135
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3119
3136
|
}, 50);
|
|
3120
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
3121
|
-
|
|
3137
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
|
|
3138
|
+
Ft(this.wnd);
|
|
3122
3139
|
const i = this.doc().scrollTop;
|
|
3123
3140
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
3124
|
-
}), e.register("go_progression",
|
|
3141
|
+
}), e.register("go_progression", N.moduleName, (i, s) => {
|
|
3125
3142
|
const n = i;
|
|
3126
3143
|
if (n < 0 || n > 1) {
|
|
3127
3144
|
e.send("error", {
|
|
@@ -3132,7 +3149,7 @@ const L = class L extends st {
|
|
|
3132
3149
|
this.wnd.requestAnimationFrame(() => {
|
|
3133
3150
|
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), A(this.wnd), s(!0);
|
|
3134
3151
|
});
|
|
3135
|
-
}), e.register("go_id",
|
|
3152
|
+
}), e.register("go_id", N.moduleName, (i, s) => {
|
|
3136
3153
|
const n = t.document.getElementById(i);
|
|
3137
3154
|
if (!n) {
|
|
3138
3155
|
s(!1);
|
|
@@ -3141,10 +3158,10 @@ const L = class L extends st {
|
|
|
3141
3158
|
this.wnd.requestAnimationFrame(() => {
|
|
3142
3159
|
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3143
3160
|
});
|
|
3144
|
-
}), e.register("go_text",
|
|
3161
|
+
}), e.register("go_text", N.moduleName, (i, s) => {
|
|
3145
3162
|
let n;
|
|
3146
3163
|
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
3147
|
-
const o = H.deserialize(i), a =
|
|
3164
|
+
const o = H.deserialize(i), a = nt(this.wnd.document, new k({
|
|
3148
3165
|
href: t.location.href,
|
|
3149
3166
|
type: "text/html",
|
|
3150
3167
|
text: o,
|
|
@@ -3161,33 +3178,33 @@ const L = class L extends st {
|
|
|
3161
3178
|
this.wnd.requestAnimationFrame(() => {
|
|
3162
3179
|
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3163
3180
|
});
|
|
3164
|
-
}), e.register("go_start",
|
|
3181
|
+
}), e.register("go_start", N.moduleName, (i, s) => {
|
|
3165
3182
|
if (this.doc().scrollTop === 0) return s(!1);
|
|
3166
3183
|
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
3167
|
-
}), e.register("go_end",
|
|
3184
|
+
}), e.register("go_end", N.moduleName, (i, s) => {
|
|
3168
3185
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3169
3186
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3170
|
-
}), e.register("unfocus",
|
|
3187
|
+
}), e.register("unfocus", N.moduleName, (i, s) => {
|
|
3171
3188
|
A(this.wnd), s(!0);
|
|
3172
|
-
}), e.register("scroll_protection",
|
|
3189
|
+
}), e.register("scroll_protection", N.moduleName, (i, s) => {
|
|
3173
3190
|
this.enableScrollProtection(), s(!0);
|
|
3174
3191
|
}), e.register([
|
|
3175
3192
|
"go_next",
|
|
3176
3193
|
"go_prev"
|
|
3177
|
-
],
|
|
3194
|
+
], N.moduleName, (i, s) => s(!1)), e.register("focus", N.moduleName, (i, s) => {
|
|
3178
3195
|
this.reportProgress(), s(!0);
|
|
3179
|
-
}), e.register("first_visible_locator",
|
|
3180
|
-
const n =
|
|
3196
|
+
}), e.register("first_visible_locator", N.moduleName, (i, s) => {
|
|
3197
|
+
const n = yt(t, !0);
|
|
3181
3198
|
e.send("first_visible_locator", n.serialize()), s(!0);
|
|
3182
3199
|
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3183
3200
|
}
|
|
3184
3201
|
unmount(t, e) {
|
|
3185
|
-
return e.unregisterAll(
|
|
3202
|
+
return e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("WebPubSnapper Unmounted"), !0;
|
|
3186
3203
|
}
|
|
3187
3204
|
};
|
|
3188
|
-
|
|
3189
|
-
let
|
|
3190
|
-
class
|
|
3205
|
+
N.moduleName = "webpub_snapper";
|
|
3206
|
+
let Lt = N;
|
|
3207
|
+
class wi {
|
|
3191
3208
|
constructor(t, e) {
|
|
3192
3209
|
this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
|
|
3193
3210
|
}
|
|
@@ -3213,22 +3230,22 @@ class mi {
|
|
|
3213
3230
|
length: s,
|
|
3214
3231
|
wasBlocked: !1
|
|
3215
3232
|
}), !0;
|
|
3216
|
-
const
|
|
3233
|
+
const c = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, u = Math.min(
|
|
3217
3234
|
n * this.options.maxSelectionPercent,
|
|
3218
3235
|
this.options.absoluteMaxChars
|
|
3219
|
-
),
|
|
3236
|
+
), d = this.isSuspiciousPattern(o), f = s > u || c || d;
|
|
3220
3237
|
return this.copyHistory.push({
|
|
3221
3238
|
timestamp: o,
|
|
3222
3239
|
length: s,
|
|
3223
|
-
wasBlocked:
|
|
3224
|
-
}),
|
|
3240
|
+
wasBlocked: f
|
|
3241
|
+
}), f ? (t?.preventDefault(), !1) : (this.lastSelectionLength = s, this.lastSelectionTime = o, !0);
|
|
3225
3242
|
}
|
|
3226
3243
|
destroy() {
|
|
3227
3244
|
this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
|
|
3228
3245
|
}
|
|
3229
3246
|
}
|
|
3230
|
-
class
|
|
3231
|
-
constructor(t =
|
|
3247
|
+
class Si {
|
|
3248
|
+
constructor(t = Me) {
|
|
3232
3249
|
this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3233
3250
|
}
|
|
3234
3251
|
analyze(t) {
|
|
@@ -3254,8 +3271,8 @@ class fi {
|
|
|
3254
3271
|
if (!t.rangeCount) return !1;
|
|
3255
3272
|
const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
|
|
3256
3273
|
if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
|
|
3257
|
-
const a = i.startOffset,
|
|
3258
|
-
return this.selectionPatterns.push(
|
|
3274
|
+
const a = i.startOffset, c = Math.abs(a - this.lastSelectionPosition);
|
|
3275
|
+
return this.selectionPatterns.push(c), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
|
|
3259
3276
|
}
|
|
3260
3277
|
calculateVariance(t) {
|
|
3261
3278
|
if (t.length === 0) return 0;
|
|
@@ -3269,14 +3286,14 @@ class fi {
|
|
|
3269
3286
|
this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3270
3287
|
}
|
|
3271
3288
|
}
|
|
3272
|
-
class
|
|
3289
|
+
class Ei {
|
|
3273
3290
|
/**
|
|
3274
3291
|
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3275
3292
|
*/
|
|
3276
3293
|
match(t, e) {
|
|
3277
3294
|
for (const i of e) {
|
|
3278
|
-
const s = t.keyCode === i.keyCode, n = i.ctrl === void 0 || t.ctrlKey === i.ctrl, o = i.shift === void 0 || t.shiftKey === i.shift, a = i.alt === void 0 || t.altKey === i.alt,
|
|
3279
|
-
if (s && n && o && a &&
|
|
3295
|
+
const s = t.keyCode === i.keyCode, n = i.ctrl === void 0 || t.ctrlKey === i.ctrl, o = i.shift === void 0 || t.shiftKey === i.shift, a = i.alt === void 0 || t.altKey === i.alt, c = i.meta === void 0 || t.metaKey === i.meta;
|
|
3296
|
+
if (s && n && o && a && c)
|
|
3280
3297
|
return !0;
|
|
3281
3298
|
}
|
|
3282
3299
|
return !1;
|
|
@@ -3295,13 +3312,13 @@ class gi {
|
|
|
3295
3312
|
createActivityEvent(t, e, i, s) {
|
|
3296
3313
|
let n;
|
|
3297
3314
|
if (s) {
|
|
3298
|
-
const o = s.getSelection(), a = o?.toString() || "",
|
|
3299
|
-
|
|
3315
|
+
const o = s.getSelection(), a = o?.toString() || "", u = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3316
|
+
u && a && (n = {
|
|
3300
3317
|
text: a,
|
|
3301
|
-
x:
|
|
3302
|
-
y:
|
|
3303
|
-
width:
|
|
3304
|
-
height:
|
|
3318
|
+
x: u.x,
|
|
3319
|
+
y: u.y,
|
|
3320
|
+
width: u.width,
|
|
3321
|
+
height: u.height
|
|
3305
3322
|
});
|
|
3306
3323
|
}
|
|
3307
3324
|
return {
|
|
@@ -3326,9 +3343,9 @@ class gi {
|
|
|
3326
3343
|
return e.forEach((o) => {
|
|
3327
3344
|
n.push(...o.keyCombos.map((a) => ({
|
|
3328
3345
|
...a,
|
|
3329
|
-
handler: (
|
|
3330
|
-
const
|
|
3331
|
-
i(
|
|
3346
|
+
handler: (c) => {
|
|
3347
|
+
const u = o.type, d = this.createActivityEvent(c, u, t, s);
|
|
3348
|
+
i(d);
|
|
3332
3349
|
}
|
|
3333
3350
|
})));
|
|
3334
3351
|
}), n;
|
|
@@ -3347,9 +3364,9 @@ class gi {
|
|
|
3347
3364
|
};
|
|
3348
3365
|
}
|
|
3349
3366
|
}
|
|
3350
|
-
const
|
|
3367
|
+
const Y = class Y extends K {
|
|
3351
3368
|
constructor() {
|
|
3352
|
-
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
|
|
3369
|
+
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 = (t) => {
|
|
3353
3370
|
if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
|
|
3354
3371
|
return !0;
|
|
3355
3372
|
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
@@ -3377,7 +3394,7 @@ const $ = class $ extends X {
|
|
|
3377
3394
|
const e = this.wnd.getSelection();
|
|
3378
3395
|
if (e) {
|
|
3379
3396
|
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3380
|
-
const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0],
|
|
3397
|
+
const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], c = {
|
|
3381
3398
|
type: "suspicious_selection",
|
|
3382
3399
|
timestamp: Date.now(),
|
|
3383
3400
|
selectionLength: n.length,
|
|
@@ -3391,7 +3408,7 @@ const $ = class $ extends X {
|
|
|
3391
3408
|
eventType: t?.type || "selectionchange",
|
|
3392
3409
|
targetFrameSrc: this.wnd.location.href
|
|
3393
3410
|
};
|
|
3394
|
-
this.comms?.send("content_protection",
|
|
3411
|
+
this.comms?.send("content_protection", c);
|
|
3395
3412
|
}
|
|
3396
3413
|
} else
|
|
3397
3414
|
this.currentSelection = null;
|
|
@@ -3472,16 +3489,16 @@ const $ = class $ extends X {
|
|
|
3472
3489
|
}
|
|
3473
3490
|
addBulkCopyProtection(t = {}) {
|
|
3474
3491
|
if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
|
|
3475
|
-
const e =
|
|
3476
|
-
this.bulkCopyProtector = new
|
|
3492
|
+
const e = bi, i = t ? { ...e, ...t } : e;
|
|
3493
|
+
this.bulkCopyProtector = new wi(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
|
|
3477
3494
|
}
|
|
3478
3495
|
removeBulkCopyProtection() {
|
|
3479
3496
|
!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);
|
|
3480
3497
|
}
|
|
3481
3498
|
addSelectionMonitoring(t) {
|
|
3482
3499
|
if (this.isSelectionMonitoringEnabled || !this.wnd) return;
|
|
3483
|
-
const e = t ||
|
|
3484
|
-
this.selectionAnalyzer = new
|
|
3500
|
+
const e = t || Me;
|
|
3501
|
+
this.selectionAnalyzer = new Si(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
|
|
3485
3502
|
}
|
|
3486
3503
|
removeSelectionMonitoring() {
|
|
3487
3504
|
!this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
|
|
@@ -3514,7 +3531,7 @@ const $ = class $ extends X {
|
|
|
3514
3531
|
y: t.clientY * i,
|
|
3515
3532
|
targetFrameSrc: this.wnd.location.href,
|
|
3516
3533
|
targetElement: t.target.outerHTML,
|
|
3517
|
-
interactiveElement:
|
|
3534
|
+
interactiveElement: Ie(t.target)?.outerHTML,
|
|
3518
3535
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
3519
3536
|
}), this.pointerMoved = !1;
|
|
3520
3537
|
}
|
|
@@ -3541,7 +3558,7 @@ const $ = class $ extends X {
|
|
|
3541
3558
|
}
|
|
3542
3559
|
}
|
|
3543
3560
|
registerProtectionHandlers() {
|
|
3544
|
-
this.comms?.register("peripherals_protection",
|
|
3561
|
+
this.comms?.register("peripherals_protection", Y.moduleName, (t, e) => {
|
|
3545
3562
|
const i = t;
|
|
3546
3563
|
if (!this.configApplied) {
|
|
3547
3564
|
if (this.configApplied = !0, i.monitorSelection) {
|
|
@@ -3559,7 +3576,7 @@ const $ = class $ extends X {
|
|
|
3559
3576
|
}), this.comms?.log("Copy protection enabled")), i.disableContextMenu && (this.addContextMenuPrevention(), this.comms?.log("Context menu protection enabled")), i.disableDragAndDrop && (this.addDragAndDropPrevention(), this.comms?.log("Drag and drop protection enabled"));
|
|
3560
3577
|
}
|
|
3561
3578
|
e(!0);
|
|
3562
|
-
}), this.comms?.register("keyboard_peripherals",
|
|
3579
|
+
}), this.comms?.register("keyboard_peripherals", Y.moduleName, (t, e) => {
|
|
3563
3580
|
const i = t;
|
|
3564
3581
|
i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
|
|
3565
3582
|
});
|
|
@@ -3568,12 +3585,12 @@ const $ = class $ extends X {
|
|
|
3568
3585
|
return this.wnd = t, this.comms = e, this.registerProtectionHandlers(), t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
|
|
3569
3586
|
}
|
|
3570
3587
|
unmount(t, e) {
|
|
3571
|
-
return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll(
|
|
3588
|
+
return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll(Y.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
|
|
3572
3589
|
}
|
|
3573
3590
|
};
|
|
3574
|
-
|
|
3575
|
-
let
|
|
3576
|
-
const
|
|
3591
|
+
Y.moduleName = "peripherals";
|
|
3592
|
+
let Ot = Y;
|
|
3593
|
+
const et = class et extends K {
|
|
3577
3594
|
constructor() {
|
|
3578
3595
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
3579
3596
|
}
|
|
@@ -3623,7 +3640,7 @@ const tt = class tt extends X {
|
|
|
3623
3640
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3624
3641
|
value: {
|
|
3625
3642
|
name: "readium-ts-toolkit",
|
|
3626
|
-
version: "2.
|
|
3643
|
+
version: "2.4.0-beta.2",
|
|
3627
3644
|
hasFeature: (s, n = "") => {
|
|
3628
3645
|
switch (s) {
|
|
3629
3646
|
case "dom-manipulation":
|
|
@@ -3648,11 +3665,11 @@ const tt = class tt extends X {
|
|
|
3648
3665
|
writable: !1
|
|
3649
3666
|
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3650
3667
|
s.cancel(), this.allAnimations.add(s);
|
|
3651
|
-
}), e.register("activate",
|
|
3668
|
+
}), e.register("activate", et.moduleName, (s, n) => {
|
|
3652
3669
|
this.allAnimations.forEach((o) => {
|
|
3653
3670
|
o.cancel(), o.play();
|
|
3654
3671
|
}), n(!0);
|
|
3655
|
-
}), e.register("unfocus",
|
|
3672
|
+
}), e.register("unfocus", et.moduleName, (s, n) => {
|
|
3656
3673
|
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
3657
3674
|
});
|
|
3658
3675
|
const i = t.document.querySelectorAll("audio,video");
|
|
@@ -3670,46 +3687,46 @@ const tt = class tt extends X {
|
|
|
3670
3687
|
return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
|
|
3671
3688
|
}
|
|
3672
3689
|
};
|
|
3673
|
-
|
|
3674
|
-
let
|
|
3675
|
-
const
|
|
3690
|
+
et.moduleName = "setup";
|
|
3691
|
+
let ft = et;
|
|
3692
|
+
const ve = "readium-viewport", W = class W extends ft {
|
|
3676
3693
|
onViewportWidthChanged(t) {
|
|
3677
3694
|
const e = t.target;
|
|
3678
|
-
|
|
3695
|
+
st(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
3679
3696
|
}
|
|
3680
3697
|
mount(t, e) {
|
|
3681
3698
|
if (!super.mount(t, e)) return !1;
|
|
3682
3699
|
const i = t.document.createElement("meta");
|
|
3683
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
3700
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", ve), i.setAttribute(
|
|
3684
3701
|
"content",
|
|
3685
3702
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3686
3703
|
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3687
3704
|
target: t
|
|
3688
|
-
}), e.register("get_properties",
|
|
3689
|
-
|
|
3690
|
-
}), e.register("update_properties",
|
|
3691
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`,
|
|
3692
|
-
}), e.register("set_property",
|
|
3705
|
+
}), e.register("get_properties", W.moduleName, (s, n) => {
|
|
3706
|
+
Vt(t), n(!0);
|
|
3707
|
+
}), e.register("update_properties", W.moduleName, (s, n) => {
|
|
3708
|
+
s["--RS__viewportWidth"] = `${t.innerWidth}px`, Re(t, s), n(!0);
|
|
3709
|
+
}), e.register("set_property", W.moduleName, (s, n) => {
|
|
3693
3710
|
const o = s;
|
|
3694
|
-
|
|
3695
|
-
}), e.register("remove_property",
|
|
3696
|
-
|
|
3697
|
-
}), e.register("activate",
|
|
3711
|
+
st(t, o[0], o[1]), n(!0);
|
|
3712
|
+
}), e.register("remove_property", W.moduleName, (s, n) => {
|
|
3713
|
+
gt(t, s), n(!0);
|
|
3714
|
+
}), e.register("activate", W.moduleName, (s, n) => {
|
|
3698
3715
|
this.unblock(t), n(!0);
|
|
3699
3716
|
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3700
3717
|
}
|
|
3701
3718
|
unmount(t, e) {
|
|
3702
|
-
return e.unregisterAll(
|
|
3719
|
+
return e.unregisterAll(W.moduleName), t.document.head.querySelector(`#${ve}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
|
|
3703
3720
|
}
|
|
3704
3721
|
};
|
|
3705
|
-
|
|
3706
|
-
let
|
|
3707
|
-
const
|
|
3722
|
+
W.moduleName = "reflowable_setup";
|
|
3723
|
+
let Rt = W;
|
|
3724
|
+
const we = "readium-fixed-style", z = class z extends ft {
|
|
3708
3725
|
mount(t, e) {
|
|
3709
3726
|
if (!super.mount(t, e)) return !1;
|
|
3710
3727
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
3711
3728
|
const i = t.document.createElement("style");
|
|
3712
|
-
return i.id =
|
|
3729
|
+
return i.id = we, i.dataset.readium = "true", i.textContent = `
|
|
3713
3730
|
html, body {
|
|
3714
3731
|
text-size-adjust: none;
|
|
3715
3732
|
-ms-text-size-adjust: none;
|
|
@@ -3721,12 +3738,12 @@ const fe = "readium-fixed-style", D = class D extends ut {
|
|
|
3721
3738
|
min-height: 100%;
|
|
3722
3739
|
|
|
3723
3740
|
/*cursor: var() TODO*/
|
|
3724
|
-
}`, t.document.head.appendChild(i), e.register("set_property",
|
|
3741
|
+
}`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s, n) => {
|
|
3725
3742
|
const o = s;
|
|
3726
|
-
|
|
3727
|
-
}), e.register("remove_property",
|
|
3728
|
-
|
|
3729
|
-
}), e.register("first_visible_locator",
|
|
3743
|
+
st(t, o[0], o[1]), n(!0);
|
|
3744
|
+
}), e.register("remove_property", z.moduleName, (s, n) => {
|
|
3745
|
+
gt(t, s), n(!0);
|
|
3746
|
+
}), e.register("first_visible_locator", z.moduleName, (s, n) => n(!1)), e.register("unfocus", z.moduleName, (s, n) => {
|
|
3730
3747
|
A(t), n(!0);
|
|
3731
3748
|
}), e.register([
|
|
3732
3749
|
"focus",
|
|
@@ -3737,17 +3754,17 @@ const fe = "readium-fixed-style", D = class D extends ut {
|
|
|
3737
3754
|
"go_start",
|
|
3738
3755
|
"go_text",
|
|
3739
3756
|
"go_progression"
|
|
3740
|
-
],
|
|
3757
|
+
], z.moduleName, (s, n) => n(!0)), e.register("activate", z.moduleName, (s, n) => {
|
|
3741
3758
|
this.unblock(t), n(!0);
|
|
3742
3759
|
}), e.log("FixedSetup Mounted"), !0;
|
|
3743
3760
|
}
|
|
3744
3761
|
unmount(t, e) {
|
|
3745
|
-
return e.unregisterAll(
|
|
3762
|
+
return e.unregisterAll(z.moduleName), t.document.getElementById(we)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
3746
3763
|
}
|
|
3747
3764
|
};
|
|
3748
|
-
|
|
3749
|
-
let
|
|
3750
|
-
const
|
|
3765
|
+
z.moduleName = "fixed_setup";
|
|
3766
|
+
let Dt = z;
|
|
3767
|
+
const U = class U extends K {
|
|
3751
3768
|
wndOnErr(t) {
|
|
3752
3769
|
this.comms?.send("error", {
|
|
3753
3770
|
message: t.message,
|
|
@@ -3761,26 +3778,26 @@ const k = class k extends X {
|
|
|
3761
3778
|
"error",
|
|
3762
3779
|
this.wndOnErr,
|
|
3763
3780
|
!1
|
|
3764
|
-
), e.register("get_properties",
|
|
3765
|
-
|
|
3766
|
-
}), e.register("update_properties",
|
|
3767
|
-
|
|
3768
|
-
}), e.register("set_property",
|
|
3781
|
+
), e.register("get_properties", U.moduleName, (i, s) => {
|
|
3782
|
+
Vt(t), s(!0);
|
|
3783
|
+
}), e.register("update_properties", U.moduleName, (i, s) => {
|
|
3784
|
+
Re(t, i), s(!0);
|
|
3785
|
+
}), e.register("set_property", U.moduleName, (i, s) => {
|
|
3769
3786
|
const n = i;
|
|
3770
|
-
|
|
3771
|
-
}), e.register("remove_property",
|
|
3772
|
-
|
|
3773
|
-
}), e.register("activate",
|
|
3787
|
+
st(t, n[0], n[1]), s(!0);
|
|
3788
|
+
}), e.register("remove_property", U.moduleName, (i, s) => {
|
|
3789
|
+
gt(t, i), s(!0);
|
|
3790
|
+
}), e.register("activate", U.moduleName, (i, s) => {
|
|
3774
3791
|
s(!0);
|
|
3775
3792
|
}), e.log("WebPubSetup Mounted"), !0;
|
|
3776
3793
|
}
|
|
3777
3794
|
unmount(t, e) {
|
|
3778
|
-
return e.unregisterAll(
|
|
3795
|
+
return e.unregisterAll(U.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
|
|
3779
3796
|
}
|
|
3780
3797
|
};
|
|
3781
|
-
|
|
3782
|
-
let
|
|
3783
|
-
const
|
|
3798
|
+
U.moduleName = "webpub_setup";
|
|
3799
|
+
let It = U;
|
|
3800
|
+
const it = class it extends K {
|
|
3784
3801
|
constructor() {
|
|
3785
3802
|
super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
|
|
3786
3803
|
}
|
|
@@ -3804,7 +3821,7 @@ const et = class et extends X {
|
|
|
3804
3821
|
`, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
|
|
3805
3822
|
}
|
|
3806
3823
|
registerPrintHandlers() {
|
|
3807
|
-
this.comms?.register("print_protection",
|
|
3824
|
+
this.comms?.register("print_protection", it.moduleName, (t) => {
|
|
3808
3825
|
const e = t;
|
|
3809
3826
|
return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
|
|
3810
3827
|
});
|
|
@@ -3813,48 +3830,191 @@ const et = class et extends X {
|
|
|
3813
3830
|
return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
|
|
3814
3831
|
}
|
|
3815
3832
|
unmount(t, e) {
|
|
3816
|
-
return this.beforePrintHandler && (t.removeEventListener("beforeprint", this.beforePrintHandler), this.beforePrintHandler = null), this.styleElement?.parentNode && (this.styleElement.parentNode.removeChild(this.styleElement), this.styleElement = null), this.comms?.unregisterAll(
|
|
3833
|
+
return this.beforePrintHandler && (t.removeEventListener("beforeprint", this.beforePrintHandler), this.beforePrintHandler = null), this.styleElement?.parentNode && (this.styleElement.parentNode.removeChild(this.styleElement), this.styleElement = null), this.comms?.unregisterAll(it.moduleName), this.configApplied = !1, !0;
|
|
3834
|
+
}
|
|
3835
|
+
};
|
|
3836
|
+
it.moduleName = "print_protection";
|
|
3837
|
+
let zt = it;
|
|
3838
|
+
const Se = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
3839
|
+
constructor() {
|
|
3840
|
+
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.resizeDebounce = null, this.verticalLR = !1, this.handleScroll = (t) => {
|
|
3841
|
+
if (this.comms.ready && !this.isResizing) {
|
|
3842
|
+
if (!this.initialScrollHandled) {
|
|
3843
|
+
this.lastScrollLeft = Math.abs(this.doc().scrollLeft), this.initialScrollHandled = !0, this.reportProgress();
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
3847
|
+
this.reportProgress();
|
|
3848
|
+
const e = Math.abs(this.doc().scrollLeft), i = e - this.lastScrollLeft;
|
|
3849
|
+
if (this.lastScrollLeft = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3850
|
+
const s = Date.now(), n = s - (this.lastScrollTime || s);
|
|
3851
|
+
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3852
|
+
// In vertical-rl, norm increases when scrolling forward (toward left/end),
|
|
3853
|
+
// so deltaX > 0 = going forward.
|
|
3854
|
+
i > 0 ? "down" : "up",
|
|
3855
|
+
Math.abs(i),
|
|
3856
|
+
n
|
|
3857
|
+
)) {
|
|
3858
|
+
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3859
|
+
this.comms?.send("content_protection", {
|
|
3860
|
+
type: "suspicious_scrolling",
|
|
3861
|
+
timestamp: Date.now(),
|
|
3862
|
+
scrollDelta: i,
|
|
3863
|
+
scrollDirection: i > 0 ? "left" : "right",
|
|
3864
|
+
targetElement: a
|
|
3865
|
+
});
|
|
3866
|
+
}
|
|
3867
|
+
this.lastScrollTime = s;
|
|
3868
|
+
}
|
|
3869
|
+
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
3870
|
+
}));
|
|
3871
|
+
}
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
doc() {
|
|
3875
|
+
return this.wnd.document.scrollingElement;
|
|
3876
|
+
}
|
|
3877
|
+
/** Total horizontally scrollable distance (magnitude). */
|
|
3878
|
+
scrollable() {
|
|
3879
|
+
return Math.max(0, this.doc().scrollWidth - this.wnd.innerWidth);
|
|
3880
|
+
}
|
|
3881
|
+
reportProgress() {
|
|
3882
|
+
if (!this.comms.ready) return;
|
|
3883
|
+
const t = this.doc().scrollWidth, e = this.wnd.innerWidth, i = Math.max(1, t - e), s = Math.abs(this.doc().scrollLeft), n = Math.max(0, Math.min(1, s / i)), o = Math.max(0, Math.min(1, (s + e) / t));
|
|
3884
|
+
this.comms.send("progress", {
|
|
3885
|
+
start: n,
|
|
3886
|
+
end: o
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
enableScrollProtection() {
|
|
3890
|
+
this.patternAnalyzer || (this.patternAnalyzer = new bt(Gt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3891
|
+
}
|
|
3892
|
+
mount(t, e) {
|
|
3893
|
+
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.verticalLR = di(t), this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
3894
|
+
const i = t.document.createElement("style");
|
|
3895
|
+
return i.dataset.readium = "true", i.id = Se, i.textContent = `
|
|
3896
|
+
* {
|
|
3897
|
+
scrollbar-width: none;
|
|
3898
|
+
}
|
|
3899
|
+
body::-webkit-scrollbar {
|
|
3900
|
+
display: none;
|
|
3901
|
+
}
|
|
3902
|
+
html {
|
|
3903
|
+
overflow-x: auto !important;
|
|
3904
|
+
overflow-y: hidden !important;
|
|
3905
|
+
}
|
|
3906
|
+
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
3907
|
+
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3908
|
+
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3909
|
+
}, 50);
|
|
3910
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
|
|
3911
|
+
Ft(this.wnd);
|
|
3912
|
+
const s = this.doc().scrollLeft;
|
|
3913
|
+
this.verticalLR ? this.doc().scrollLeft = s > 1 ? s - 1 : s + 1 : this.doc().scrollLeft = s < -1 ? s + 1 : s - 1, this.doc().scrollLeft = s;
|
|
3914
|
+
}), e.register("go_progression", L.moduleName, (s, n) => {
|
|
3915
|
+
const o = s;
|
|
3916
|
+
if (o < 0 || o > 1) {
|
|
3917
|
+
e.send("error", {
|
|
3918
|
+
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3919
|
+
}), n(!1);
|
|
3920
|
+
return;
|
|
3921
|
+
}
|
|
3922
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3923
|
+
const a = this.scrollable() * o;
|
|
3924
|
+
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(), A(this.wnd), n(!0);
|
|
3925
|
+
});
|
|
3926
|
+
}), e.register("go_id", L.moduleName, (s, n) => {
|
|
3927
|
+
const o = t.document.getElementById(s);
|
|
3928
|
+
if (!o) {
|
|
3929
|
+
n(!1);
|
|
3930
|
+
return;
|
|
3931
|
+
}
|
|
3932
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3933
|
+
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3934
|
+
});
|
|
3935
|
+
}), e.register("go_text", L.moduleName, (s, n) => {
|
|
3936
|
+
let o;
|
|
3937
|
+
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3938
|
+
const a = H.deserialize(s), c = nt(this.wnd.document, new k({
|
|
3939
|
+
href: t.location.href,
|
|
3940
|
+
type: "text/html",
|
|
3941
|
+
text: a,
|
|
3942
|
+
locations: o ? new C({
|
|
3943
|
+
otherLocations: /* @__PURE__ */ new Map([["cssSelector", o]])
|
|
3944
|
+
}) : void 0
|
|
3945
|
+
}));
|
|
3946
|
+
if (!c) {
|
|
3947
|
+
n(!1);
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3950
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3951
|
+
this.doc().scrollLeft += c.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3952
|
+
});
|
|
3953
|
+
}), e.register("go_start", L.moduleName, (s, n) => {
|
|
3954
|
+
if (this.doc().scrollLeft === 0) return n(!1);
|
|
3955
|
+
this.doc().scrollLeft = 0, this.reportProgress(), n(!0);
|
|
3956
|
+
}), e.register("go_end", L.moduleName, (s, n) => {
|
|
3957
|
+
if (Math.abs(this.doc().scrollLeft) === this.scrollable()) return n(!1);
|
|
3958
|
+
this.doc().scrollLeft = this.verticalLR ? this.scrollable() : -this.scrollable(), this.reportProgress(), n(!0);
|
|
3959
|
+
}), e.register([
|
|
3960
|
+
"go_next",
|
|
3961
|
+
"go_prev"
|
|
3962
|
+
], L.moduleName, (s, n) => n(!1)), e.register("unfocus", L.moduleName, (s, n) => {
|
|
3963
|
+
A(this.wnd), n(!0);
|
|
3964
|
+
}), e.register("scroll_protection", L.moduleName, (s, n) => {
|
|
3965
|
+
this.enableScrollProtection(), n(!0);
|
|
3966
|
+
}), e.register("focus", L.moduleName, (s, n) => {
|
|
3967
|
+
this.reportProgress(), n(!0);
|
|
3968
|
+
}), e.register("first_visible_locator", L.moduleName, (s, n) => {
|
|
3969
|
+
const o = yt(t, !0);
|
|
3970
|
+
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
3971
|
+
}), e.log("CJKVerticalSnapper Mounted"), !0;
|
|
3972
|
+
}
|
|
3973
|
+
unmount(t, e) {
|
|
3974
|
+
return e.unregisterAll(L.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(Se)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("CJKVerticalSnapper Unmounted"), !0;
|
|
3817
3975
|
}
|
|
3818
3976
|
};
|
|
3819
|
-
|
|
3820
|
-
let
|
|
3821
|
-
const
|
|
3977
|
+
L.moduleName = "cjk_vertical_snapper";
|
|
3978
|
+
let Mt = L;
|
|
3979
|
+
const Ai = [
|
|
3822
3980
|
"fixed_setup",
|
|
3823
3981
|
"decorator",
|
|
3824
3982
|
"peripherals",
|
|
3825
3983
|
"print_protection"
|
|
3826
|
-
],
|
|
3984
|
+
], Ci = [
|
|
3827
3985
|
"reflowable_setup",
|
|
3828
3986
|
"decorator",
|
|
3829
3987
|
"peripherals",
|
|
3830
3988
|
"column_snapper",
|
|
3831
3989
|
"scroll_snapper",
|
|
3990
|
+
"cjk_vertical_snapper",
|
|
3832
3991
|
"print_protection"
|
|
3833
|
-
],
|
|
3992
|
+
], xi = [
|
|
3834
3993
|
"webpub_setup",
|
|
3835
3994
|
"webpub_snapper",
|
|
3836
3995
|
"decorator",
|
|
3837
3996
|
"peripherals",
|
|
3838
3997
|
"print_protection"
|
|
3839
|
-
],
|
|
3998
|
+
], Ee = new Map([
|
|
3840
3999
|
// All modules go here
|
|
3841
|
-
|
|
3842
|
-
|
|
4000
|
+
Dt,
|
|
4001
|
+
Rt,
|
|
4002
|
+
It,
|
|
3843
4003
|
Lt,
|
|
3844
|
-
|
|
4004
|
+
Ot,
|
|
3845
4005
|
Tt,
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
4006
|
+
Pt,
|
|
4007
|
+
Nt,
|
|
4008
|
+
Mt,
|
|
4009
|
+
zt
|
|
3850
4010
|
].map((r) => [r.moduleName, r]));
|
|
3851
|
-
class
|
|
4011
|
+
class Ti {
|
|
3852
4012
|
/**
|
|
3853
4013
|
* @param wnd Window instance to operate on
|
|
3854
4014
|
* @param initialModules List of initial modules to load
|
|
3855
4015
|
*/
|
|
3856
4016
|
constructor(t = window, e = []) {
|
|
3857
|
-
this.loadedModules = [], this.wnd = t, this.comms = new
|
|
4017
|
+
this.loadedModules = [], this.wnd = t, this.comms = new Ue(t);
|
|
3858
4018
|
const i = [...new Set(e)];
|
|
3859
4019
|
if (i.length) {
|
|
3860
4020
|
if (typeof t > "u")
|
|
@@ -3867,7 +4027,7 @@ class wi {
|
|
|
3867
4027
|
}
|
|
3868
4028
|
}
|
|
3869
4029
|
loadModule(t) {
|
|
3870
|
-
const e =
|
|
4030
|
+
const e = Ee.get(t);
|
|
3871
4031
|
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
3872
4032
|
}
|
|
3873
4033
|
/**
|
|
@@ -3885,7 +4045,7 @@ class wi {
|
|
|
3885
4045
|
* @returns Success
|
|
3886
4046
|
*/
|
|
3887
4047
|
removeModule(t) {
|
|
3888
|
-
const e =
|
|
4048
|
+
const e = Ee.get(t);
|
|
3889
4049
|
if (e === void 0)
|
|
3890
4050
|
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
3891
4051
|
const i = this.loadedModules.findIndex((s) => s instanceof e);
|
|
@@ -3898,7 +4058,7 @@ class wi {
|
|
|
3898
4058
|
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3899
4059
|
}
|
|
3900
4060
|
}
|
|
3901
|
-
const
|
|
4061
|
+
const Pi = {
|
|
3902
4062
|
type: "developer_tools",
|
|
3903
4063
|
keyCombos: [
|
|
3904
4064
|
{ keyCode: 73, meta: !0, alt: !0 },
|
|
@@ -3922,7 +4082,7 @@ const Ei = {
|
|
|
3922
4082
|
{ keyCode: 123, meta: !0, alt: !0 }
|
|
3923
4083
|
// F12+Meta+Alt
|
|
3924
4084
|
]
|
|
3925
|
-
},
|
|
4085
|
+
}, Ni = {
|
|
3926
4086
|
type: "select_all",
|
|
3927
4087
|
keyCombos: [
|
|
3928
4088
|
{ keyCode: 65, meta: !0 },
|
|
@@ -3930,7 +4090,7 @@ const Ei = {
|
|
|
3930
4090
|
{ keyCode: 65, ctrl: !0 }
|
|
3931
4091
|
// A key (Ctrl+A)
|
|
3932
4092
|
]
|
|
3933
|
-
},
|
|
4093
|
+
}, Li = {
|
|
3934
4094
|
type: "print",
|
|
3935
4095
|
keyCombos: [
|
|
3936
4096
|
{ keyCode: 80, meta: !0 },
|
|
@@ -3946,7 +4106,7 @@ const Ei = {
|
|
|
3946
4106
|
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
3947
4107
|
// P key (Ctrl+Alt+P)
|
|
3948
4108
|
]
|
|
3949
|
-
},
|
|
4109
|
+
}, Oi = {
|
|
3950
4110
|
type: "save",
|
|
3951
4111
|
keyCombos: [
|
|
3952
4112
|
{ keyCode: 83, meta: !0 },
|
|
@@ -3956,26 +4116,26 @@ const Ei = {
|
|
|
3956
4116
|
]
|
|
3957
4117
|
};
|
|
3958
4118
|
export {
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4119
|
+
wi as BulkCopyProtector,
|
|
4120
|
+
Z as COMMS_VERSION,
|
|
4121
|
+
Ue as Comms,
|
|
4122
|
+
Pi as DEV_TOOLS,
|
|
4123
|
+
Tt as Decorator,
|
|
4124
|
+
Ai as FXLModules,
|
|
4125
|
+
Ei as KeyCombinationManager,
|
|
4126
|
+
ai as Layout,
|
|
4127
|
+
Ti as Loader,
|
|
4128
|
+
K as Module,
|
|
4129
|
+
Ee as ModuleLibrary,
|
|
4130
|
+
Li as PRINT,
|
|
4131
|
+
bt as PatternAnalyzer,
|
|
4132
|
+
Ot as Peripherals,
|
|
4133
|
+
zt as PrintProtector,
|
|
4134
|
+
Ci as ReflowableModules,
|
|
4135
|
+
Oi as SAVE,
|
|
4136
|
+
Ni as SELECT_ALL,
|
|
4137
|
+
Si as SelectionAnalyzer,
|
|
4138
|
+
xi as WebPubModules,
|
|
4139
|
+
oi as Width,
|
|
4140
|
+
We as mid
|
|
3981
4141
|
};
|