@readium/navigator-html-injectables 2.2.5 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/index.js +1107 -548
  2. package/dist/index.umd.cjs +23 -9
  3. package/package.json +1 -1
  4. package/src/comms/keys.ts +22 -3
  5. package/src/index.ts +2 -1
  6. package/src/modules/ModuleLibrary.ts +10 -4
  7. package/src/modules/Peripherals.ts +458 -13
  8. package/src/modules/snapper/ColumnSnapper.ts +63 -2
  9. package/src/modules/snapper/ScrollSnapper.ts +59 -1
  10. package/src/modules/snapper/WebPubSnapper.ts +57 -3
  11. package/src/protection/BulkCopyProtector.ts +134 -0
  12. package/src/protection/KeyCombinationManager.ts +139 -0
  13. package/src/protection/KeyboardCombinations.ts +60 -0
  14. package/src/protection/PatternAnalyzer.ts +117 -0
  15. package/src/protection/PrintProtector.ts +87 -0
  16. package/src/protection/SelectionAnalyzer.ts +133 -0
  17. package/src/protection/config.ts +33 -0
  18. package/src/protection/index.ts +6 -0
  19. package/types/src/comms/keys.d.ts +3 -2
  20. package/types/src/index.d.ts +1 -0
  21. package/types/src/modules/ModuleLibrary.d.ts +1 -1
  22. package/types/src/modules/Peripherals.d.ts +102 -2
  23. package/types/src/modules/snapper/ColumnSnapper.d.ts +10 -0
  24. package/types/src/modules/snapper/ScrollSnapper.d.ts +13 -0
  25. package/types/src/modules/snapper/WebPubSnapper.d.ts +6 -0
  26. package/types/src/protection/BulkCopyProtector.d.ts +20 -0
  27. package/types/src/protection/KeyCombinationManager.d.ts +33 -0
  28. package/types/src/protection/KeyboardCombinations.d.ts +15 -0
  29. package/types/src/protection/PatternAnalyzer.d.ts +18 -0
  30. package/types/src/protection/PrintProtector.d.ts +20 -0
  31. package/types/src/protection/SelectionAnalyzer.d.ts +20 -0
  32. package/types/src/protection/config.d.ts +7 -0
  33. package/types/src/protection/index.d.ts +6 -0
  34. package/src/types/protection.ts +0 -16
  35. package/types/src/types/protection.d.ts +0 -7
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- const Ce = Math.pow(2, 32), Wt = () => Math.round(Math.random() * Ce).toString(36), Ne = () => `${Math.round(performance.now())}-${Wt()}-${Wt()}`, Y = 1;
2
- class Oe {
1
+ const Ie = Math.pow(2, 32), Ht = () => Math.round(Math.random() * Ie).toString(36), De = () => `${Math.round(performance.now())}-${Ht()}-${Ht()}`, K = 1;
2
+ class ze {
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 Oe {
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 !== Y) {
14
- e._readium > Y ? this.send("error", `received comms version ${e._readium} higher than ${Y}`) : this.send("error", `received comms version ${e._readium} lower than ${Y}`), this.destination = null, this.origin = "", this.channelId = "";
13
+ if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== K) {
14
+ e._readium > K ? this.send("error", `received comms version ${e._readium} higher than ${K}`) : this.send("error", `received comms version ${e._readium} lower than ${K}`), 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 Oe {
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: Y,
74
+ _readium: K,
75
75
  _channel: this.channelId,
76
- id: i ?? Ne(),
76
+ id: i ?? De(),
77
77
  // scrict,
78
78
  key: t,
79
79
  data: e
@@ -89,7 +89,7 @@ class Oe {
89
89
  }
90
90
  }
91
91
  }
92
- const b = class b {
92
+ const y = class y {
93
93
  constructor(t) {
94
94
  this.uri = t;
95
95
  }
@@ -98,7 +98,7 @@ const b = class b {
98
98
  */
99
99
  static deserialize(t) {
100
100
  if (!(!t || typeof t != "string"))
101
- return new b(t);
101
+ return new y(t);
102
102
  }
103
103
  /**
104
104
  * Serializes an [AccessibilityProfile] to its RWPM JSON representation.
@@ -110,23 +110,23 @@ const b = class b {
110
110
  * Returns true if the profile is a WCAG Level A profile.
111
111
  */
112
112
  get isWCAGLevelA() {
113
- return this === b.EPUB_A11Y_10_WCAG_20_A || this === b.EPUB_A11Y_11_WCAG_20_A || this === b.EPUB_A11Y_11_WCAG_21_A || this === b.EPUB_A11Y_11_WCAG_22_A;
113
+ return this === y.EPUB_A11Y_10_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_21_A || this === y.EPUB_A11Y_11_WCAG_22_A;
114
114
  }
115
115
  /**
116
116
  * Returns true if the profile is a WCAG Level AA profile.
117
117
  */
118
118
  get isWCAGLevelAA() {
119
- return this === b.EPUB_A11Y_10_WCAG_20_AA || this === b.EPUB_A11Y_11_WCAG_20_AA || this === b.EPUB_A11Y_11_WCAG_21_AA || this === b.EPUB_A11Y_11_WCAG_22_AA;
119
+ return this === y.EPUB_A11Y_10_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_21_AA || this === y.EPUB_A11Y_11_WCAG_22_AA;
120
120
  }
121
121
  /**
122
122
  * Returns true if the profile is a WCAG Level AAA profile.
123
123
  */
124
124
  get isWCAGLevelAAA() {
125
- return this === b.EPUB_A11Y_10_WCAG_20_AAA || this === b.EPUB_A11Y_11_WCAG_20_AAA || this === b.EPUB_A11Y_11_WCAG_21_AAA || this === b.EPUB_A11Y_11_WCAG_22_AAA;
125
+ return this === y.EPUB_A11Y_10_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_21_AAA || this === y.EPUB_A11Y_11_WCAG_22_AAA;
126
126
  }
127
127
  };
128
- b.EPUB_A11Y_10_WCAG_20_A = new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"), b.EPUB_A11Y_10_WCAG_20_AA = new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"), b.EPUB_A11Y_10_WCAG_20_AAA = new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"), b.EPUB_A11Y_11_WCAG_20_A = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"), b.EPUB_A11Y_11_WCAG_20_AA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"), b.EPUB_A11Y_11_WCAG_20_AAA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"), b.EPUB_A11Y_11_WCAG_21_A = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"), b.EPUB_A11Y_11_WCAG_21_AA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"), b.EPUB_A11Y_11_WCAG_21_AAA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"), b.EPUB_A11Y_11_WCAG_22_A = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"), b.EPUB_A11Y_11_WCAG_22_AA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"), b.EPUB_A11Y_11_WCAG_22_AAA = new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");
129
- let Ut = b;
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 _t = y;
130
130
  const w = class w {
131
131
  constructor(t) {
132
132
  this.value = t;
@@ -146,7 +146,7 @@ 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 kt = w;
149
+ let Vt = w;
150
150
  const T = class T {
151
151
  constructor(t) {
152
152
  if (typeof t == "string") {
@@ -182,7 +182,7 @@ const T = class T {
182
182
  }
183
183
  };
184
184
  T.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), T.AUDITORY = new T("auditory"), T.TACTILE = new T("tactile"), T.TEXTUAL = new T("textual"), T.VISUAL = new T("visual");
185
- let Bt = T;
185
+ let Gt = T;
186
186
  const c = class c {
187
187
  constructor(t) {
188
188
  this.value = t;
@@ -202,8 +202,8 @@ const c = class c {
202
202
  }
203
203
  };
204
204
  c.NONE = new c("none"), c.ANNOTATIONS = new c("annotations"), c.ARIA = new c("ARIA"), c.INDEX = new c("index"), c.PAGE_BREAK_MARKERS = new c("pageBreakMarkers"), c.PAGE_NAVIGATION = new c("pageNavigation"), c.PRINT_PAGE_NUMBERS = new c("printPageNumbers"), c.READING_ORDER = new c("readingOrder"), c.STRUCTURAL_NAVIGATION = new c("structuralNavigation"), c.TABLE_OF_CONTENTS = new c("tableOfContents"), c.TAGGED_PDF = new c("taggedPDF"), c.ALTERNATIVE_TEXT = new c("alternativeText"), c.AUDIO_DESCRIPTION = new c("audioDescription"), c.CAPTIONS = new c("captions"), c.CLOSED_CAPTIONS = new c("closedCaptions"), c.DESCRIBED_MATH = new c("describedMath"), c.LONG_DESCRIPTION = new c("longDescription"), c.OPEN_CAPTIONS = new c("openCaptions"), c.SIGN_LANGUAGE = new c("signLanguage"), c.TRANSCRIPT = new c("transcript"), c.DISPLAY_TRANSFORMABILITY = new c("displayTransformability"), c.SYNCHRONIZED_AUDIO_TEXT = new c("synchronizedAudioText"), c.TIMING_CONTROL = new c("timingControl"), c.UNLOCKED = new c("unlocked"), c.CHEM_ML = new c("ChemML"), c.LATEX = new c("latex"), c.LATEX_CHEMISTRY = new c("latex-chemistry"), c.MATH_ML = new c("MathML"), c.MATH_ML_CHEMISTRY = new c("MathML-chemistry"), c.TTS_MARKUP = new c("ttsMarkup"), c.HIGH_CONTRAST_AUDIO = new c("highContrastAudio"), c.HIGH_CONTRAST_DISPLAY = new c("highContrastDisplay"), c.LARGE_PRINT = new c("largePrint"), c.BRAILLE = new c("braille"), c.TACTILE_GRAPHIC = new c("tactileGraphic"), c.TACTILE_OBJECT = new c("tactileObject"), c.FULL_RUBY_ANNOTATIONS = new c("fullRubyAnnotations"), c.HORIZONTAL_WRITING = new c("horizontalWriting"), c.RUBY_ANNOTATIONS = new c("rubyAnnotations"), c.VERTICAL_WRITING = new c("verticalWriting"), c.WITH_ADDITIONAL_WORD_SEGMENTATION = new c("withAdditionalWordSegmentation"), c.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new c("withoutAdditionalWordSegmentation");
205
- let Ht = c;
206
- const A = class A {
205
+ let Ft = c;
206
+ const S = class S {
207
207
  constructor(t) {
208
208
  this.value = t;
209
209
  }
@@ -212,7 +212,7 @@ const A = class A {
212
212
  */
213
213
  static deserialize(t) {
214
214
  if (!(!t || typeof t != "string"))
215
- return new A(t);
215
+ return new S(t);
216
216
  }
217
217
  /**
218
218
  * Serializes a [Hazard] to its RWPM JSON representation.
@@ -221,8 +221,8 @@ const A = class A {
221
221
  return this.value;
222
222
  }
223
223
  };
224
- A.FLASHING = new A("flashing"), A.NO_FLASHING_HAZARD = new A("noFlashingHazard"), A.UNKNOWN_FLASHING_HAZARD = new A("unknownFlashingHazard"), A.MOTION_SIMULATION = new A("motionSimulation"), A.NO_MOTION_SIMULATION_HAZARD = new A("noMotionSimulationHazard"), A.UNKNOWN_MOTION_SIMULATION_HAZARD = new A("unknownMotionSimulationHazard"), A.SOUND = new A("sound"), A.NO_SOUND_HAZARD = new A("noSoundHazard"), A.UNKNOWN_SOUND_HAZARD = new A("unknownSoundHazard"), A.UNKNOWN = new A("unknown"), A.NONE = new A("none");
225
- let Gt = A;
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 $t = S;
226
226
  const E = class E {
227
227
  constructor(t) {
228
228
  this.value = t;
@@ -242,10 +242,10 @@ const E = class E {
242
242
  }
243
243
  };
244
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 _t = E;
246
- const Vt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Pe = /* @__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"}}`), Le = {
247
- publication: Pe
248
- }, Ft = {
245
+ let Yt = E;
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: Me
248
+ }, qt = {
249
249
  fr: () => import("./fr-C5HEel98.js"),
250
250
  ar: () => import("./ar-DyHX_uy2.js"),
251
251
  da: () => import("./da-Dct0PS3E.js"),
@@ -256,10 +256,10 @@ const Vt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Pe = /* @__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
- }, $t = Le?.publication?.metadata?.accessibility?.["display-guide"] || {};
259
+ }, Kt = ke?.publication?.metadata?.accessibility?.["display-guide"] || {};
260
260
  class F {
261
261
  constructor() {
262
- this.currentLocaleCode = "en", this.locale = $t, this.loadedLocales = {}, this.loadedLocales.en = $t;
262
+ this.currentLocaleCode = "en", this.locale = Kt, this.loadedLocales = {}, this.loadedLocales.en = Kt;
263
263
  }
264
264
  static getInstance() {
265
265
  return F.instance || (F.instance = new F()), F.instance;
@@ -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 (!Vt.includes(t))
273
+ if (!Xt.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 Ft))
278
+ if (!(t in qt))
279
279
  return console.warn(`Locale file not found for: ${t}`), !1;
280
- const s = (await Ft[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
280
+ const s = (await qt[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 Vt;
314
+ return Xt;
315
315
  }
316
316
  getNestedValue(t, e) {
317
317
  const i = e.split(".");
@@ -334,7 +334,7 @@ class F {
334
334
  }
335
335
  }
336
336
  F.getInstance();
337
- class Nt {
337
+ class Rt {
338
338
  /**
339
339
  * Creates a [Encryption].
340
340
  */
@@ -346,7 +346,7 @@ class Nt {
346
346
  */
347
347
  static deserialize(t) {
348
348
  if (t && t.algorithm)
349
- return new Nt({
349
+ return new Rt({
350
350
  algorithm: t.algorithm,
351
351
  compression: t.compression,
352
352
  originalLength: t.originalLength,
@@ -362,7 +362,7 @@ class Nt {
362
362
  return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
363
363
  }
364
364
  }
365
- class I {
365
+ class R {
366
366
  constructor(t) {
367
367
  this.otherProperties = t;
368
368
  }
@@ -374,7 +374,7 @@ class I {
374
374
  */
375
375
  static deserialize(t) {
376
376
  if (t)
377
- return new I(t);
377
+ return new R(t);
378
378
  }
379
379
  /**
380
380
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -389,30 +389,30 @@ class I {
389
389
  const e = Object.assign({}, this.otherProperties);
390
390
  for (const i in t)
391
391
  e[i] = t[i];
392
- return new I(e);
392
+ return new R(e);
393
393
  }
394
394
  }
395
- Object.defineProperty(I.prototype, "encryption", {
395
+ Object.defineProperty(R.prototype, "encryption", {
396
396
  get: function() {
397
- return Nt.deserialize(this.otherProperties.encrypted);
397
+ return Rt.deserialize(this.otherProperties.encrypted);
398
398
  }
399
399
  });
400
- function Ie(r) {
400
+ function We(r) {
401
401
  return r && Array.isArray(r) ? r : void 0;
402
402
  }
403
- function pe(r) {
404
- return r && typeof r == "string" ? [r] : Ie(r);
403
+ function ye(r) {
404
+ return r && typeof r == "string" ? [r] : We(r);
405
405
  }
406
- function Yt(r) {
406
+ function Zt(r) {
407
407
  return typeof r == "string" ? new Date(r) : void 0;
408
408
  }
409
- function rt(r) {
409
+ function at(r) {
410
410
  return isNaN(r) ? void 0 : r;
411
411
  }
412
- function L(r) {
413
- return rt(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
412
+ function O(r) {
413
+ return at(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
414
414
  }
415
- function Re(r) {
415
+ function Ue(r) {
416
416
  const t = new Array();
417
417
  return r.forEach((e) => t.push(e)), t;
418
418
  }
@@ -427,19 +427,19 @@ class l {
427
427
  } else
428
428
  throw new Error("Invalid media type");
429
429
  const o = {};
430
- for (let p = 1; p < s.length; p++) {
431
- const y = s[p].split("=");
432
- if (y.length === 2) {
433
- const f = y[0].toLocaleLowerCase(), m = f === "charset" ? y[1].toUpperCase() : y[1];
434
- o[f] = m;
430
+ for (let m = 1; m < s.length; m++) {
431
+ const v = s[m].split("=");
432
+ if (v.length === 2) {
433
+ const f = v[0].toLocaleLowerCase(), p = f === "charset" ? v[1].toUpperCase() : v[1];
434
+ o[f] = p;
435
435
  }
436
436
  }
437
437
  const a = {}, d = Object.keys(o);
438
- d.sort((p, y) => p.localeCompare(y)), d.forEach((p) => a[p] = o[p]);
438
+ d.sort((m, v) => m.localeCompare(v)), d.forEach((m) => a[m] = o[m]);
439
439
  let h = "";
440
- for (const p in a) {
441
- const y = a[p];
442
- h += `;${p}=${y}`;
440
+ for (const m in a) {
441
+ const v = a[m];
442
+ h += `;${m}=${v}`;
443
443
  }
444
444
  const u = `${e}/${i}${h}`, g = a.encoding;
445
445
  this.string = u, this.type = e, this.subtype = i, this.parameters = a, this.encoding = g, this.name = t.name, this.fileExtension = t.fileExtension;
@@ -871,7 +871,7 @@ class l {
871
871
  });
872
872
  }
873
873
  }
874
- class qt {
874
+ class Jt {
875
875
  constructor(t) {
876
876
  this.uri = t, this.parameters = this.getParameters(t);
877
877
  }
@@ -899,7 +899,7 @@ class qt {
899
899
  return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
900
900
  }
901
901
  }
902
- class x {
902
+ class C {
903
903
  /**
904
904
  * Creates a [Locations].
905
905
  */
@@ -911,7 +911,7 @@ class x {
911
911
  */
912
912
  static deserialize(t) {
913
913
  if (!t) return;
914
- const e = rt(t.progression), i = rt(t.totalProgression), s = rt(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
914
+ const e = at(t.progression), i = at(t.totalProgression), s = at(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
915
915
  "fragment",
916
916
  "fragments",
917
917
  "progression",
@@ -920,8 +920,8 @@ class x {
920
920
  ]);
921
921
  return Object.entries(t).forEach(([a, d]) => {
922
922
  o.has(a) || n.set(a, d);
923
- }), new x({
924
- fragments: pe(t.fragments || t.fragment),
923
+ }), new C({
924
+ fragments: ye(t.fragments || t.fragment),
925
925
  progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
926
926
  totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
927
927
  position: s !== void 0 && s > 0 ? s : void 0,
@@ -962,23 +962,23 @@ class H {
962
962
  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;
963
963
  }
964
964
  }
965
- class U {
965
+ class W {
966
966
  /**
967
967
  * Creates a [Locator].
968
968
  */
969
969
  constructor(t) {
970
- this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new x({}), this.text = t.text;
970
+ this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new C({}), this.text = t.text;
971
971
  }
972
972
  /**
973
973
  * Parses a [Link] from its RWPM JSON representation.
974
974
  */
975
975
  static deserialize(t) {
976
976
  if (t && t.href && t.type)
977
- return new U({
977
+ return new W({
978
978
  href: t.href,
979
979
  type: t.type,
980
980
  title: t.title,
981
- locations: x.deserialize(t.locations),
981
+ locations: C.deserialize(t.locations),
982
982
  text: H.deserialize(t.text)
983
983
  });
984
984
  }
@@ -993,16 +993,16 @@ class U {
993
993
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
994
994
  */
995
995
  copyWithLocations(t) {
996
- return new U({
996
+ return new W({
997
997
  href: this.href,
998
998
  type: this.type,
999
999
  title: this.title,
1000
1000
  text: this.text,
1001
- locations: new x({ ...this.locations, ...t })
1001
+ locations: new C({ ...this.locations, ...t })
1002
1002
  });
1003
1003
  }
1004
1004
  }
1005
- class $ {
1005
+ class Y {
1006
1006
  /**
1007
1007
  * Creates a [Link].
1008
1008
  */
@@ -1014,21 +1014,21 @@ class $ {
1014
1014
  */
1015
1015
  static deserialize(t) {
1016
1016
  if (!(!t || typeof t.href != "string"))
1017
- return new $({
1017
+ return new Y({
1018
1018
  href: t.href,
1019
1019
  templated: t.templated,
1020
1020
  type: t.type,
1021
1021
  title: t.title,
1022
1022
  rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
1023
- properties: I.deserialize(t.properties),
1024
- height: L(t.height),
1025
- width: L(t.width),
1026
- size: L(t.size),
1027
- duration: L(t.duration),
1028
- bitrate: L(t.bitrate),
1029
- languages: pe(t.language),
1030
- alternates: nt.deserialize(t.alternate),
1031
- children: nt.deserialize(t.children)
1023
+ properties: R.deserialize(t.properties),
1024
+ height: O(t.height),
1025
+ width: O(t.width),
1026
+ size: O(t.size),
1027
+ duration: O(t.duration),
1028
+ bitrate: O(t.bitrate),
1029
+ languages: ye(t.language),
1030
+ alternates: lt.deserialize(t.alternate),
1031
+ children: lt.deserialize(t.children)
1032
1032
  });
1033
1033
  }
1034
1034
  /**
@@ -1036,7 +1036,7 @@ class $ {
1036
1036
  */
1037
1037
  serialize() {
1038
1038
  const t = { href: this.href };
1039
- 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 = Re(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;
1039
+ 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 = Ue(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;
1040
1040
  }
1041
1041
  /** MediaType of the linked resource. */
1042
1042
  get mediaType() {
@@ -1053,14 +1053,14 @@ class $ {
1053
1053
  }
1054
1054
  /** List of URI template parameter keys, if the `Link` is templated. */
1055
1055
  get templateParameters() {
1056
- return this.templated ? new qt(this.href).parameters : /* @__PURE__ */ new Set();
1056
+ return this.templated ? new Jt(this.href).parameters : /* @__PURE__ */ new Set();
1057
1057
  }
1058
1058
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
1059
1059
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
1060
1060
  */
1061
1061
  expandTemplate(t) {
1062
- return new $({
1063
- href: new qt(this.href).expand(t),
1062
+ return new Y({
1063
+ href: new Jt(this.href).expand(t),
1064
1064
  templated: !1
1065
1065
  });
1066
1066
  }
@@ -1068,25 +1068,25 @@ class $ {
1068
1068
  * Makes a copy of this [Link] after merging in the given additional other [properties].
1069
1069
  */
1070
1070
  addProperties(t) {
1071
- const e = $.deserialize(this.serialize());
1072
- return e.properties = e.properties ? e.properties?.add(t) : new I(t), e;
1071
+ const e = Y.deserialize(this.serialize());
1072
+ return e.properties = e.properties ? e.properties?.add(t) : new R(t), e;
1073
1073
  }
1074
1074
  /**
1075
1075
  * Creates a [Locator] from a reading order [Link].
1076
1076
  */
1077
1077
  get locator() {
1078
1078
  let t = this.href.split("#");
1079
- return new U({
1079
+ return new W({
1080
1080
  href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
1081
1081
  type: this.type ?? "",
1082
1082
  title: this.title,
1083
- locations: new x({
1083
+ locations: new C({
1084
1084
  fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
1085
1085
  })
1086
1086
  });
1087
1087
  }
1088
1088
  }
1089
- class nt {
1089
+ class lt {
1090
1090
  /**
1091
1091
  * Creates a [Links].
1092
1092
  */
@@ -1098,8 +1098,8 @@ class nt {
1098
1098
  */
1099
1099
  static deserialize(t) {
1100
1100
  if (t && Array.isArray(t))
1101
- return new nt(
1102
- t.map((e) => $.deserialize(e)).filter((e) => e !== void 0)
1101
+ return new lt(
1102
+ t.map((e) => Y.deserialize(e)).filter((e) => e !== void 0)
1103
1103
  );
1104
1104
  }
1105
1105
  /**
@@ -1180,10 +1180,10 @@ class nt {
1180
1180
  return this.items.filter((t) => t.type);
1181
1181
  }
1182
1182
  }
1183
- I.prototype.getContains = function() {
1183
+ R.prototype.getContains = function() {
1184
1184
  return new Set(this.otherProperties.contains || []);
1185
1185
  };
1186
- class ot {
1186
+ class ct {
1187
1187
  /**
1188
1188
  * Creates a [DomRange].
1189
1189
  */
@@ -1195,10 +1195,10 @@ class ot {
1195
1195
  */
1196
1196
  static deserialize(t) {
1197
1197
  if (!(t && t.cssSelector)) return;
1198
- let e = L(t.textNodeIndex);
1198
+ let e = O(t.textNodeIndex);
1199
1199
  if (e === void 0) return;
1200
- let i = L(t.charOffset);
1201
- return i === void 0 && (i = L(t.offset)), new ot({
1200
+ let i = O(t.charOffset);
1201
+ return i === void 0 && (i = O(t.offset)), new ct({
1202
1202
  cssSelector: t.cssSelector,
1203
1203
  textNodeIndex: e,
1204
1204
  charOffset: i
@@ -1215,7 +1215,7 @@ class ot {
1215
1215
  return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1216
1216
  }
1217
1217
  }
1218
- class Ot {
1218
+ class It {
1219
1219
  /**
1220
1220
  * Creates a [DomRange].
1221
1221
  */
@@ -1227,11 +1227,11 @@ class Ot {
1227
1227
  */
1228
1228
  static deserialize(t) {
1229
1229
  if (!t) return;
1230
- let e = ot.deserialize(t.start);
1230
+ let e = ct.deserialize(t.start);
1231
1231
  if (e)
1232
- return new Ot({
1232
+ return new It({
1233
1233
  start: e,
1234
- end: ot.deserialize(t.end)
1234
+ end: ct.deserialize(t.end)
1235
1235
  });
1236
1236
  }
1237
1237
  /**
@@ -1242,16 +1242,16 @@ class Ot {
1242
1242
  return this.end && (t.end = this.end.serialize()), t;
1243
1243
  }
1244
1244
  }
1245
- x.prototype.getCssSelector = function() {
1245
+ C.prototype.getCssSelector = function() {
1246
1246
  return this.otherLocations?.get("cssSelector");
1247
1247
  };
1248
- x.prototype.getPartialCfi = function() {
1248
+ C.prototype.getPartialCfi = function() {
1249
1249
  return this.otherLocations?.get("partialCfi");
1250
1250
  };
1251
- x.prototype.getDomRange = function() {
1252
- return Ot.deserialize(this.otherLocations?.get("domRange"));
1251
+ C.prototype.getDomRange = function() {
1252
+ return It.deserialize(this.otherLocations?.get("domRange"));
1253
1253
  };
1254
- x.prototype.fragmentParameters = function() {
1254
+ C.prototype.fragmentParameters = function() {
1255
1255
  return new Map(
1256
1256
  this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
1257
1257
  r[0].trim().toLowerCase(),
@@ -1259,7 +1259,7 @@ x.prototype.fragmentParameters = function() {
1259
1259
  ])
1260
1260
  );
1261
1261
  };
1262
- x.prototype.htmlId = function() {
1262
+ C.prototype.htmlId = function() {
1263
1263
  if (!this.fragments.length) return;
1264
1264
  let r = this.fragments.find((t) => t.length && !t.includes("="));
1265
1265
  if (!r) {
@@ -1268,22 +1268,22 @@ x.prototype.htmlId = function() {
1268
1268
  }
1269
1269
  return r?.startsWith("#") ? r.slice(1) : r;
1270
1270
  };
1271
- x.prototype.page = function() {
1271
+ C.prototype.page = function() {
1272
1272
  const r = parseInt(this.fragmentParameters().get("page"));
1273
1273
  if (!isNaN(r) && r >= 0) return r;
1274
1274
  };
1275
- x.prototype.time = function() {
1275
+ C.prototype.time = function() {
1276
1276
  const r = parseInt(this.fragmentParameters().get("t"));
1277
1277
  if (!isNaN(r)) return r;
1278
1278
  };
1279
- x.prototype.space = function() {
1279
+ C.prototype.space = function() {
1280
1280
  const r = this.fragmentParameters();
1281
1281
  if (!r.has("xywh")) return;
1282
1282
  const t = r.get("xywh").split(",").map((e) => parseInt(e));
1283
1283
  if (t.length === 4 && !t.some(isNaN))
1284
1284
  return t;
1285
1285
  };
1286
- class Pt {
1286
+ class Dt {
1287
1287
  /** Creates a [Price]. */
1288
1288
  constructor(t) {
1289
1289
  this.currency = t.currency, this.value = t.value;
@@ -1296,9 +1296,9 @@ class Pt {
1296
1296
  let e = t.currency;
1297
1297
  if (!(e && typeof e == "string" && e.length > 0))
1298
1298
  return;
1299
- let i = L(t.value);
1299
+ let i = O(t.value);
1300
1300
  if (i !== void 0)
1301
- return new Pt({ currency: e, value: i });
1301
+ return new Dt({ currency: e, value: i });
1302
1302
  }
1303
1303
  /**
1304
1304
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1307,7 +1307,7 @@ class Pt {
1307
1307
  return { currency: this.currency, value: this.value };
1308
1308
  }
1309
1309
  }
1310
- class X {
1310
+ class J {
1311
1311
  /** Creates a [Acquisition]. */
1312
1312
  constructor(t) {
1313
1313
  this.type = t.type, this.children = t.children;
@@ -1317,14 +1317,14 @@ class X {
1317
1317
  */
1318
1318
  static deserialize(t) {
1319
1319
  if (t && t.type)
1320
- return new X({
1320
+ return new J({
1321
1321
  type: t.type,
1322
- children: X.deserializeArray(t.children)
1322
+ children: J.deserializeArray(t.children)
1323
1323
  });
1324
1324
  }
1325
1325
  static deserializeArray(t) {
1326
1326
  if (Array.isArray(t))
1327
- return t.map((e) => X.deserialize(e)).filter((e) => e !== void 0);
1327
+ return t.map((e) => J.deserialize(e)).filter((e) => e !== void 0);
1328
1328
  }
1329
1329
  /**
1330
1330
  * Serializes a [Acquisition] to its RWPM JSON representation.
@@ -1334,7 +1334,7 @@ class X {
1334
1334
  return this.children && (t.children = this.children.map((e) => e.serialize())), t;
1335
1335
  }
1336
1336
  }
1337
- class Lt {
1337
+ class zt {
1338
1338
  /** Creates a [Price]. */
1339
1339
  constructor(t) {
1340
1340
  this.total = t.total, this.position = t.position;
@@ -1344,9 +1344,9 @@ class Lt {
1344
1344
  */
1345
1345
  static deserialize(t) {
1346
1346
  if (t)
1347
- return new Lt({
1348
- total: L(t.total),
1349
- position: L(t.position)
1347
+ return new zt({
1348
+ total: O(t.total),
1349
+ position: O(t.position)
1350
1350
  });
1351
1351
  }
1352
1352
  /**
@@ -1357,7 +1357,7 @@ class Lt {
1357
1357
  return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
1358
1358
  }
1359
1359
  }
1360
- class It {
1360
+ class Mt {
1361
1361
  /** Creates a [Copies]. */
1362
1362
  constructor(t) {
1363
1363
  this.total = t.total, this.available = t.available;
@@ -1367,9 +1367,9 @@ class It {
1367
1367
  */
1368
1368
  static deserialize(t) {
1369
1369
  if (t)
1370
- return new It({
1371
- total: L(t.total),
1372
- available: L(t.available)
1370
+ return new Mt({
1371
+ total: O(t.total),
1372
+ available: O(t.available)
1373
1373
  });
1374
1374
  }
1375
1375
  /**
@@ -1380,7 +1380,7 @@ class It {
1380
1380
  return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
1381
1381
  }
1382
1382
  }
1383
- class Rt {
1383
+ class kt {
1384
1384
  /** Creates a [Availability]. */
1385
1385
  constructor(t) {
1386
1386
  this.state = t.state, this.since = t.since, this.until = t.until;
@@ -1390,10 +1390,10 @@ class Rt {
1390
1390
  */
1391
1391
  static deserialize(t) {
1392
1392
  if (t && t.state)
1393
- return new Rt({
1393
+ return new kt({
1394
1394
  state: t.state,
1395
- since: Yt(t.since),
1396
- until: Yt(t.until)
1395
+ since: Zt(t.since),
1396
+ until: Zt(t.until)
1397
1397
  });
1398
1398
  }
1399
1399
  /**
@@ -1404,89 +1404,89 @@ class Rt {
1404
1404
  return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
1405
1405
  }
1406
1406
  }
1407
- I.prototype.getNumberOfItems = function() {
1408
- return L(this.otherProperties.numberOfItems);
1407
+ R.prototype.getNumberOfItems = function() {
1408
+ return O(this.otherProperties.numberOfItems);
1409
1409
  };
1410
- I.prototype.getPrice = function() {
1411
- return Pt.deserialize(this.otherProperties.price);
1410
+ R.prototype.getPrice = function() {
1411
+ return Dt.deserialize(this.otherProperties.price);
1412
1412
  };
1413
- I.prototype.getIndirectAcquisitions = function() {
1413
+ R.prototype.getIndirectAcquisitions = function() {
1414
1414
  const r = this.otherProperties.indirectAcquisition;
1415
1415
  if (r && Array.isArray(r))
1416
- return r.map((t) => X.deserialize(t)).filter((t) => t !== void 0);
1416
+ return r.map((t) => J.deserialize(t)).filter((t) => t !== void 0);
1417
1417
  };
1418
- I.prototype.getHolds = function() {
1419
- return Lt.deserialize(this.otherProperties.holds);
1418
+ R.prototype.getHolds = function() {
1419
+ return zt.deserialize(this.otherProperties.holds);
1420
1420
  };
1421
- I.prototype.getCopies = function() {
1422
- return It.deserialize(this.otherProperties.copies);
1421
+ R.prototype.getCopies = function() {
1422
+ return Mt.deserialize(this.otherProperties.copies);
1423
1423
  };
1424
- I.prototype.getAvailability = function() {
1425
- return Rt.deserialize(this.otherProperties.availability);
1424
+ R.prototype.getAvailability = function() {
1425
+ return kt.deserialize(this.otherProperties.availability);
1426
1426
  };
1427
- I.prototype.getAuthenticate = function() {
1428
- return $.deserialize(this.otherProperties.authenticate);
1427
+ R.prototype.getAuthenticate = function() {
1428
+ return Y.deserialize(this.otherProperties.authenticate);
1429
1429
  };
1430
- const ze = "CssSelectorGenerator";
1431
- function Xt(r = "unknown problem", ...t) {
1432
- console.warn(`${ze}: ${r}`, ...t);
1430
+ const Be = "CssSelectorGenerator";
1431
+ function Qt(r = "unknown problem", ...t) {
1432
+ console.warn(`${Be}: ${r}`, ...t);
1433
1433
  }
1434
- function De(r) {
1434
+ function He(r) {
1435
1435
  return r instanceof RegExp;
1436
1436
  }
1437
- function Me(r) {
1437
+ function _e(r) {
1438
1438
  return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1439
1439
  }
1440
- function We(r) {
1440
+ function Ve(r) {
1441
1441
  const t = r.map((e) => {
1442
- if (De(e))
1442
+ if (He(e))
1443
1443
  return (i) => e.test(i);
1444
1444
  if (typeof e == "function")
1445
1445
  return (i) => {
1446
1446
  const s = e(i);
1447
- return typeof s != "boolean" ? (Xt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
1447
+ return typeof s != "boolean" ? (Qt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
1448
1448
  };
1449
1449
  if (typeof e == "string") {
1450
- const i = new RegExp("^" + Me(e) + "$");
1450
+ const i = new RegExp("^" + _e(e) + "$");
1451
1451
  return (s) => i.test(s);
1452
1452
  }
1453
- return Xt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
1453
+ return Qt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
1454
1454
  });
1455
1455
  return (e) => t.some((i) => i(e));
1456
1456
  }
1457
- We([
1457
+ Ve([
1458
1458
  "class",
1459
1459
  "id",
1460
1460
  // Angular attributes
1461
1461
  "ng-*"
1462
1462
  ]);
1463
- class tt {
1463
+ class X {
1464
1464
  }
1465
- function Kt(r) {
1465
+ function jt(r) {
1466
1466
  return r.split("").reverse().join("");
1467
1467
  }
1468
- function Ue(r, t, e) {
1469
- const i = Kt(t);
1468
+ function Ge(r, t, e) {
1469
+ const i = jt(t);
1470
1470
  return e.map((s) => {
1471
- const n = Math.max(0, s.end - t.length - s.errors), o = Kt(r.slice(n, s.end));
1471
+ const n = Math.max(0, s.end - t.length - s.errors), o = jt(r.slice(n, s.end));
1472
1472
  return {
1473
- start: fe(o, i, s.errors).reduce((d, h) => s.end - h.end < d ? s.end - h.end : d, s.end),
1473
+ start: be(o, i, s.errors).reduce((d, h) => s.end - h.end < d ? s.end - h.end : d, s.end),
1474
1474
  end: s.end,
1475
1475
  errors: s.errors
1476
1476
  };
1477
1477
  });
1478
1478
  }
1479
- function dt(r) {
1479
+ function ft(r) {
1480
1480
  return (r | -r) >> 31 & 1;
1481
1481
  }
1482
- function Zt(r, t, e, i) {
1482
+ function te(r, t, e, i) {
1483
1483
  let s = r.P[e], n = r.M[e];
1484
1484
  const o = i >>> 31, a = t[e] | o, d = a | n, h = (a & s) + s ^ s | a;
1485
1485
  let u = n | ~(h | s), g = s & h;
1486
- const p = dt(u & r.lastRowMask[e]) - dt(g & r.lastRowMask[e]);
1487
- return u <<= 1, g <<= 1, g |= o, u |= dt(i) - o, s = g | ~(d | u), n = u & d, r.P[e] = s, r.M[e] = n, p;
1486
+ const m = ft(u & r.lastRowMask[e]) - ft(g & r.lastRowMask[e]);
1487
+ return u <<= 1, g <<= 1, g |= o, u |= ft(i) - o, s = g | ~(d | u), n = u & d, r.P[e] = s, r.M[e] = n, m;
1488
1488
  }
1489
- function fe(r, t, e) {
1489
+ function be(r, t, e) {
1490
1490
  if (t.length === 0)
1491
1491
  return [];
1492
1492
  e = Math.min(e, t.length);
@@ -1497,63 +1497,63 @@ function fe(r, t, e) {
1497
1497
  };
1498
1498
  o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
1499
1499
  const a = new Uint32Array(n + 1), d = /* @__PURE__ */ new Map(), h = [];
1500
- for (let p = 0; p < 256; p++)
1500
+ for (let m = 0; m < 256; m++)
1501
1501
  h.push(a);
1502
- for (let p = 0; p < t.length; p += 1) {
1503
- const y = t.charCodeAt(p);
1504
- if (d.has(y))
1502
+ for (let m = 0; m < t.length; m += 1) {
1503
+ const v = t.charCodeAt(m);
1504
+ if (d.has(v))
1505
1505
  continue;
1506
1506
  const f = new Uint32Array(n + 1);
1507
- d.set(y, f), y < h.length && (h[y] = f);
1508
- for (let m = 0; m <= n; m += 1) {
1509
- f[m] = 0;
1510
- for (let v = 0; v < s; v += 1) {
1511
- const C = m * s + v;
1512
- if (C >= t.length)
1507
+ d.set(v, f), v < h.length && (h[v] = f);
1508
+ for (let p = 0; p <= n; p += 1) {
1509
+ f[p] = 0;
1510
+ for (let b = 0; b < s; b += 1) {
1511
+ const x = p * s + b;
1512
+ if (x >= t.length)
1513
1513
  continue;
1514
- t.charCodeAt(C) === y && (f[m] |= 1 << v);
1514
+ t.charCodeAt(x) === v && (f[p] |= 1 << b);
1515
1515
  }
1516
1516
  }
1517
1517
  }
1518
1518
  let u = Math.max(0, Math.ceil(e / s) - 1);
1519
1519
  const g = new Uint32Array(n + 1);
1520
- for (let p = 0; p <= u; p += 1)
1521
- g[p] = (p + 1) * s;
1520
+ for (let m = 0; m <= u; m += 1)
1521
+ g[m] = (m + 1) * s;
1522
1522
  g[n] = t.length;
1523
- for (let p = 0; p <= u; p += 1)
1524
- o.P[p] = -1, o.M[p] = 0;
1525
- for (let p = 0; p < r.length; p += 1) {
1526
- const y = r.charCodeAt(p);
1523
+ for (let m = 0; m <= u; m += 1)
1524
+ o.P[m] = -1, o.M[m] = 0;
1525
+ for (let m = 0; m < r.length; m += 1) {
1526
+ const v = r.charCodeAt(m);
1527
1527
  let f;
1528
- y < h.length ? f = h[y] : (f = d.get(y), typeof f > "u" && (f = a));
1529
- let m = 0;
1530
- for (let v = 0; v <= u; v += 1)
1531
- m = Zt(o, f, v, m), g[v] += m;
1532
- if (g[u] - m <= e && u < n && (f[u + 1] & 1 || m < 0)) {
1528
+ v < h.length ? f = h[v] : (f = d.get(v), typeof f > "u" && (f = a));
1529
+ let p = 0;
1530
+ for (let b = 0; b <= u; b += 1)
1531
+ p = te(o, f, b, p), g[b] += p;
1532
+ if (g[u] - p <= e && u < n && (f[u + 1] & 1 || p < 0)) {
1533
1533
  u += 1, o.P[u] = -1, o.M[u] = 0;
1534
- let v;
1534
+ let b;
1535
1535
  if (u === n) {
1536
- const C = t.length % s;
1537
- v = C === 0 ? s : C;
1536
+ const x = t.length % s;
1537
+ b = x === 0 ? s : x;
1538
1538
  } else
1539
- v = s;
1540
- g[u] = g[u - 1] + v - m + Zt(o, f, u, m);
1539
+ b = s;
1540
+ g[u] = g[u - 1] + b - p + te(o, f, u, p);
1541
1541
  } else
1542
1542
  for (; u > 0 && g[u] >= e + s; )
1543
1543
  u -= 1;
1544
1544
  u === n && g[u] <= e && (g[u] < e && i.splice(0, i.length), i.push({
1545
1545
  start: -1,
1546
- end: p + 1,
1546
+ end: m + 1,
1547
1547
  errors: g[u]
1548
1548
  }), e = g[u]);
1549
1549
  }
1550
1550
  return i;
1551
1551
  }
1552
- function ke(r, t, e) {
1553
- const i = fe(r, t, e);
1554
- return Ue(r, t, i);
1552
+ function Fe(r, t, e) {
1553
+ const i = be(r, t, e);
1554
+ return Ge(r, t, i);
1555
1555
  }
1556
- function me(r, t, e) {
1556
+ function ve(r, t, e) {
1557
1557
  let i = 0;
1558
1558
  const s = [];
1559
1559
  for (; i !== -1; )
@@ -1562,30 +1562,30 @@ function me(r, t, e) {
1562
1562
  end: i + t.length,
1563
1563
  errors: 0
1564
1564
  }), i += 1);
1565
- return s.length > 0 ? s : ke(r, t, e);
1565
+ return s.length > 0 ? s : Fe(r, t, e);
1566
1566
  }
1567
- function Jt(r, t) {
1568
- return t.length === 0 || r.length === 0 ? 0 : 1 - me(r, t, t.length)[0].errors / t.length;
1567
+ function ee(r, t) {
1568
+ return t.length === 0 || r.length === 0 ? 0 : 1 - ve(r, t, t.length)[0].errors / t.length;
1569
1569
  }
1570
- function Be(r, t, e = {}) {
1570
+ function $e(r, t, e = {}) {
1571
1571
  if (t.length === 0)
1572
1572
  return null;
1573
- const i = Math.min(256, t.length / 2), s = me(r, t, i);
1573
+ const i = Math.min(256, t.length / 2), s = ve(r, t, i);
1574
1574
  if (s.length === 0)
1575
1575
  return null;
1576
1576
  const n = (a) => {
1577
- const p = 1 - a.errors / t.length, y = e.prefix ? Jt(
1577
+ const m = 1 - a.errors / t.length, v = e.prefix ? ee(
1578
1578
  r.slice(
1579
1579
  Math.max(0, a.start - e.prefix.length),
1580
1580
  a.start
1581
1581
  ),
1582
1582
  e.prefix
1583
- ) : 1, f = e.suffix ? Jt(
1583
+ ) : 1, f = e.suffix ? ee(
1584
1584
  r.slice(a.end, a.end + e.suffix.length),
1585
1585
  e.suffix
1586
1586
  ) : 1;
1587
- let m = 1;
1588
- return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) / r.length), (50 * p + 20 * y + 20 * f + 2 * m) / 92;
1587
+ let p = 1;
1588
+ return typeof e.hint == "number" && (p = 1 - Math.abs(a.start - e.hint) / r.length), (50 * m + 20 * v + 20 * f + 2 * p) / 92;
1589
1589
  }, o = s.map((a) => ({
1590
1590
  start: a.start,
1591
1591
  end: a.end,
@@ -1593,7 +1593,7 @@ function Be(r, t, e = {}) {
1593
1593
  }));
1594
1594
  return o.sort((a, d) => d.score - a.score), o[0];
1595
1595
  }
1596
- function gt(r, t, e) {
1596
+ function vt(r, t, e) {
1597
1597
  const i = e === 1 ? t : t - 1;
1598
1598
  if (r.charAt(i).trim() !== "")
1599
1599
  return t;
@@ -1603,7 +1603,7 @@ function gt(r, t, e) {
1603
1603
  const o = s.length - n.length;
1604
1604
  return e === 2 ? t - o : t + o;
1605
1605
  }
1606
- function Qt(r, t) {
1606
+ function ie(r, t) {
1607
1607
  const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1608
1608
  r.commonAncestorContainer,
1609
1609
  NodeFilter.SHOW_TEXT
@@ -1616,7 +1616,7 @@ function Qt(r, t) {
1616
1616
  const a = () => {
1617
1617
  if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
1618
1618
  const d = n.textContent, h = t === 1 ? 0 : d.length;
1619
- o = gt(d, h, t);
1619
+ o = vt(d, h, t);
1620
1620
  }
1621
1621
  };
1622
1622
  for (; n && o === -1 && n !== s; )
@@ -1625,7 +1625,7 @@ function Qt(r, t) {
1625
1625
  return { node: n, offset: o };
1626
1626
  throw new RangeError("No text nodes with non-whitespace text found in range");
1627
1627
  }
1628
- function He(r) {
1628
+ function Ye(r) {
1629
1629
  if (!r.toString().trim().length)
1630
1630
  throw new RangeError("Range contains no non-whitespace text");
1631
1631
  if (r.startContainer.nodeType !== Node.TEXT_NODE)
@@ -1635,13 +1635,13 @@ function He(r) {
1635
1635
  const t = r.cloneRange();
1636
1636
  let e = !1, i = !1;
1637
1637
  const s = {
1638
- start: gt(
1638
+ start: vt(
1639
1639
  r.startContainer.textContent,
1640
1640
  r.startOffset,
1641
1641
  1
1642
1642
  /* Forwards */
1643
1643
  ),
1644
- end: gt(
1644
+ end: vt(
1645
1645
  r.endContainer.textContent,
1646
1646
  r.endOffset,
1647
1647
  2
@@ -1651,7 +1651,7 @@ function He(r) {
1651
1651
  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)
1652
1652
  return t;
1653
1653
  if (!e) {
1654
- const { node: n, offset: o } = Qt(
1654
+ const { node: n, offset: o } = ie(
1655
1655
  t,
1656
1656
  1
1657
1657
  /* Forwards */
@@ -1659,7 +1659,7 @@ function He(r) {
1659
1659
  n && o >= 0 && t.setStart(n, o);
1660
1660
  }
1661
1661
  if (!i) {
1662
- const { node: n, offset: o } = Qt(
1662
+ const { node: n, offset: o } = ie(
1663
1663
  t,
1664
1664
  2
1665
1665
  /* Backwards */
@@ -1668,7 +1668,7 @@ function He(r) {
1668
1668
  }
1669
1669
  return t;
1670
1670
  }
1671
- function ge(r) {
1671
+ function we(r) {
1672
1672
  switch (r.nodeType) {
1673
1673
  case Node.ELEMENT_NODE:
1674
1674
  case Node.TEXT_NODE:
@@ -1677,13 +1677,13 @@ function ge(r) {
1677
1677
  return 0;
1678
1678
  }
1679
1679
  }
1680
- function jt(r) {
1680
+ function se(r) {
1681
1681
  let t = r.previousSibling, e = 0;
1682
1682
  for (; t; )
1683
- e += ge(t), t = t.previousSibling;
1683
+ e += we(t), t = t.previousSibling;
1684
1684
  return e;
1685
1685
  }
1686
- function be(r, ...t) {
1686
+ function Se(r, ...t) {
1687
1687
  let e = t.shift();
1688
1688
  const i = r.ownerDocument.createNodeIterator(
1689
1689
  r,
@@ -1698,7 +1698,7 @@ function be(r, ...t) {
1698
1698
  throw new RangeError("Offset exceeds text length");
1699
1699
  return s;
1700
1700
  }
1701
- class D {
1701
+ class z {
1702
1702
  constructor(t, e) {
1703
1703
  if (e < 0)
1704
1704
  throw new Error("Offset is invalid");
@@ -1715,8 +1715,8 @@ class D {
1715
1715
  throw new Error("Parent is not an ancestor of current element");
1716
1716
  let e = this.element, i = this.offset;
1717
1717
  for (; e !== t; )
1718
- i += jt(e), e = e.parentElement;
1719
- return new D(e, i);
1718
+ i += se(e), e = e.parentElement;
1719
+ return new z(e, i);
1720
1720
  }
1721
1721
  /**
1722
1722
  * Resolve the position to a specific text node and offset within that node.
@@ -1737,7 +1737,7 @@ class D {
1737
1737
  */
1738
1738
  resolve(t = {}) {
1739
1739
  try {
1740
- return be(this.element, this.offset)[0];
1740
+ return Se(this.element, this.offset)[0];
1741
1741
  } catch (e) {
1742
1742
  if (this.offset === 0 && t.direction !== void 0) {
1743
1743
  const i = document.createTreeWalker(
@@ -1760,9 +1760,9 @@ class D {
1760
1760
  static fromCharOffset(t, e) {
1761
1761
  switch (t.nodeType) {
1762
1762
  case Node.TEXT_NODE:
1763
- return D.fromPoint(t, e);
1763
+ return z.fromPoint(t, e);
1764
1764
  case Node.ELEMENT_NODE:
1765
- return new D(t, e);
1765
+ return new z(t, e);
1766
1766
  default:
1767
1767
  throw new Error("Node is not an element or text node");
1768
1768
  }
@@ -1780,23 +1780,23 @@ class D {
1780
1780
  throw new Error("Text node offset is out of range");
1781
1781
  if (!t.parentElement)
1782
1782
  throw new Error("Text node has no parent");
1783
- const i = jt(t) + e;
1784
- return new D(t.parentElement, i);
1783
+ const i = se(t) + e;
1784
+ return new z(t.parentElement, i);
1785
1785
  }
1786
1786
  case Node.ELEMENT_NODE: {
1787
1787
  if (e < 0 || e > t.childNodes.length)
1788
1788
  throw new Error("Child node offset is out of range");
1789
1789
  let i = 0;
1790
1790
  for (let s = 0; s < e; s++)
1791
- i += ge(t.childNodes[s]);
1792
- return new D(t, i);
1791
+ i += we(t.childNodes[s]);
1792
+ return new z(t, i);
1793
1793
  }
1794
1794
  default:
1795
1795
  throw new Error("Point is not in an element or text node");
1796
1796
  }
1797
1797
  }
1798
1798
  }
1799
- class k {
1799
+ class U {
1800
1800
  constructor(t, e) {
1801
1801
  this.start = t, this.end = e;
1802
1802
  }
@@ -1806,7 +1806,7 @@ class k {
1806
1806
  * `end.element`.
1807
1807
  */
1808
1808
  relativeTo(t) {
1809
- return new k(
1809
+ return new U(
1810
1810
  this.start.relativeTo(t),
1811
1811
  this.end.relativeTo(t)
1812
1812
  );
@@ -1822,7 +1822,7 @@ class k {
1822
1822
  */
1823
1823
  toRange() {
1824
1824
  let t, e;
1825
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = be(
1825
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Se(
1826
1826
  this.start.element,
1827
1827
  this.start.offset,
1828
1828
  this.end.offset
@@ -1840,20 +1840,20 @@ class k {
1840
1840
  * Create a TextRange from a (DOM) Range
1841
1841
  */
1842
1842
  static fromRange(t) {
1843
- const e = D.fromPoint(
1843
+ const e = z.fromPoint(
1844
1844
  t.startContainer,
1845
1845
  t.startOffset
1846
- ), i = D.fromPoint(t.endContainer, t.endOffset);
1847
- return new k(e, i);
1846
+ ), i = z.fromPoint(t.endContainer, t.endOffset);
1847
+ return new U(e, i);
1848
1848
  }
1849
1849
  /**
1850
1850
  * Create a TextRange representing the `start`th to `end`th characters in
1851
1851
  * `root`
1852
1852
  */
1853
1853
  static fromOffsets(t, e, i) {
1854
- return new k(
1855
- new D(t, e),
1856
- new D(t, i)
1854
+ return new U(
1855
+ new z(t, e),
1856
+ new z(t, i)
1857
1857
  );
1858
1858
  }
1859
1859
  /**
@@ -1861,23 +1861,23 @@ class k {
1861
1861
  * whitespace
1862
1862
  */
1863
1863
  static trimmedRange(t) {
1864
- return He(k.fromRange(t).toRange());
1864
+ return Ye(U.fromRange(t).toRange());
1865
1865
  }
1866
1866
  }
1867
- class at {
1867
+ class ht {
1868
1868
  constructor(t, e, i) {
1869
1869
  this.root = t, this.start = e, this.end = i;
1870
1870
  }
1871
1871
  static fromRange(t, e) {
1872
- const i = k.fromRange(e).relativeTo(t);
1873
- return new at(
1872
+ const i = U.fromRange(e).relativeTo(t);
1873
+ return new ht(
1874
1874
  t,
1875
1875
  i.start.offset,
1876
1876
  i.end.offset
1877
1877
  );
1878
1878
  }
1879
1879
  static fromSelector(t, e) {
1880
- return new at(t, e.start, e.end);
1880
+ return new ht(t, e.start, e.end);
1881
1881
  }
1882
1882
  toSelector() {
1883
1883
  return {
@@ -1887,10 +1887,10 @@ class at {
1887
1887
  };
1888
1888
  }
1889
1889
  toRange() {
1890
- return k.fromOffsets(this.root, this.start, this.end).toRange();
1890
+ return U.fromOffsets(this.root, this.start, this.end).toRange();
1891
1891
  }
1892
1892
  }
1893
- class lt {
1893
+ class dt {
1894
1894
  /**
1895
1895
  * @param root - A root element from which to anchor.
1896
1896
  */
@@ -1903,15 +1903,15 @@ class lt {
1903
1903
  * Will throw if `range` does not contain any text nodes.
1904
1904
  */
1905
1905
  static fromRange(t, e) {
1906
- const i = t.textContent, s = k.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
1907
- return new lt(t, i.slice(n, o), {
1906
+ const i = t.textContent, s = U.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
1907
+ return new dt(t, i.slice(n, o), {
1908
1908
  prefix: i.slice(Math.max(0, n - a), n),
1909
1909
  suffix: i.slice(o, Math.min(i.length, o + a))
1910
1910
  });
1911
1911
  }
1912
1912
  static fromSelector(t, e) {
1913
1913
  const { prefix: i, suffix: s } = e;
1914
- return new lt(t, e.exact, { prefix: i, suffix: s });
1914
+ return new dt(t, e.exact, { prefix: i, suffix: s });
1915
1915
  }
1916
1916
  toSelector() {
1917
1917
  return {
@@ -1925,26 +1925,26 @@ class lt {
1925
1925
  return this.toPositionAnchor(t).toRange();
1926
1926
  }
1927
1927
  toPositionAnchor(t = {}) {
1928
- const e = this.root.textContent, i = Be(e, this.exact, {
1928
+ const e = this.root.textContent, i = $e(e, this.exact, {
1929
1929
  ...this.context,
1930
1930
  hint: t.hint
1931
1931
  });
1932
1932
  if (!i)
1933
1933
  throw new Error("Quote not found");
1934
- return new at(this.root, i.start, i.end);
1934
+ return new ht(this.root, i.start, i.end);
1935
1935
  }
1936
1936
  }
1937
- function Ge(r) {
1937
+ function Xe(r) {
1938
1938
  const t = r.tagName.toUpperCase();
1939
1939
  return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
1940
1940
  }
1941
- function ht(r, t) {
1941
+ function pt(r, t) {
1942
1942
  try {
1943
1943
  const e = t.locations, i = t.text;
1944
1944
  if (i && i.highlight) {
1945
1945
  let s;
1946
1946
  e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
1947
- const n = new lt(s, i.highlight, {
1947
+ const n = new dt(s, i.highlight, {
1948
1948
  prefix: i.before,
1949
1949
  suffix: i.after
1950
1950
  });
@@ -1963,7 +1963,7 @@ function ht(r, t) {
1963
1963
  }
1964
1964
  if (s) {
1965
1965
  const n = r.createRange();
1966
- return s.childNodes.length === 0 || Ge(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1966
+ return s.childNodes.length === 0 || Xe(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1967
1967
  }
1968
1968
  }
1969
1969
  } catch (e) {
@@ -1971,7 +1971,7 @@ function ht(r, t) {
1971
1971
  }
1972
1972
  return null;
1973
1973
  }
1974
- function _e(r, t) {
1974
+ function qe(r, t) {
1975
1975
  let e = r.getClientRects();
1976
1976
  e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
1977
1977
  const i = 1, s = [];
@@ -1984,10 +1984,10 @@ function _e(r, t) {
1984
1984
  top: h.top,
1985
1985
  width: h.width
1986
1986
  });
1987
- const n = ve(
1987
+ const n = Ee(
1988
1988
  s,
1989
1989
  i
1990
- ), o = Fe(n, i), a = ye(o), d = 4;
1990
+ ), o = Ze(n, i), a = Ae(o), d = 4;
1991
1991
  for (let h = a.length - 1; h >= 0; h--) {
1992
1992
  const u = a[h];
1993
1993
  if (!(u.width * u.height > d))
@@ -1998,16 +1998,16 @@ function _e(r, t) {
1998
1998
  }
1999
1999
  return a;
2000
2000
  }
2001
- function ve(r, t, e) {
2001
+ function Ee(r, t, e) {
2002
2002
  for (let i = 0; i < r.length; i++)
2003
2003
  for (let s = i + 1; s < r.length; s++) {
2004
2004
  const n = r[i], o = r[s];
2005
2005
  if (n === o)
2006
2006
  continue;
2007
- const a = R(n.top, o.top, t) && R(n.bottom, o.bottom, t), d = R(n.left, o.left, t) && R(n.right, o.right, t);
2008
- if (a && !d && we(n, o, t)) {
2009
- const g = r.filter((y) => y !== n && y !== o), p = Ve(n, o);
2010
- return g.push(p), ve(
2007
+ const a = I(n.top, o.top, t) && I(n.bottom, o.bottom, t), d = I(n.left, o.left, t) && I(n.right, o.right, t);
2008
+ if (a && !d && Ce(n, o, t)) {
2009
+ const g = r.filter((v) => v !== n && v !== o), m = Ke(n, o);
2010
+ return g.push(m), Ee(
2011
2011
  g,
2012
2012
  t
2013
2013
  );
@@ -2015,7 +2015,7 @@ function ve(r, t, e) {
2015
2015
  }
2016
2016
  return r;
2017
2017
  }
2018
- function Ve(r, t) {
2018
+ function Ke(r, t) {
2019
2019
  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);
2020
2020
  return {
2021
2021
  bottom: n,
@@ -2026,7 +2026,7 @@ function Ve(r, t) {
2026
2026
  width: i - e
2027
2027
  };
2028
2028
  }
2029
- function Fe(r, t) {
2029
+ function Ze(r, t) {
2030
2030
  const e = new Set(r);
2031
2031
  for (const i of r) {
2032
2032
  if (!(i.width > 1 && i.height > 1)) {
@@ -2034,40 +2034,40 @@ function Fe(r, t) {
2034
2034
  continue;
2035
2035
  }
2036
2036
  for (const n of r)
2037
- if (i !== n && e.has(n) && $e(n, i, t)) {
2037
+ if (i !== n && e.has(n) && Je(n, i, t)) {
2038
2038
  e.delete(i);
2039
2039
  break;
2040
2040
  }
2041
2041
  }
2042
2042
  return Array.from(e);
2043
2043
  }
2044
- function $e(r, t, e) {
2045
- return et(r, t.left, t.top, e) && et(r, t.right, t.top, e) && et(r, t.left, t.bottom, e) && et(r, t.right, t.bottom, e);
2044
+ function Je(r, t, e) {
2045
+ return nt(r, t.left, t.top, e) && nt(r, t.right, t.top, e) && nt(r, t.left, t.bottom, e) && nt(r, t.right, t.bottom, e);
2046
2046
  }
2047
- function et(r, t, e, i) {
2048
- return (r.left < t || R(r.left, t, i)) && (r.right > t || R(r.right, t, i)) && (r.top < e || R(r.top, e, i)) && (r.bottom > e || R(r.bottom, e, i));
2047
+ function nt(r, t, e, i) {
2048
+ 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));
2049
2049
  }
2050
- function ye(r) {
2050
+ function Ae(r) {
2051
2051
  for (let t = 0; t < r.length; t++)
2052
2052
  for (let e = t + 1; e < r.length; e++) {
2053
2053
  const i = r[t], s = r[e];
2054
- if (i !== s && we(i, s, -1)) {
2054
+ if (i !== s && Ce(i, s, -1)) {
2055
2055
  let n = [], o;
2056
- const a = te(i, s);
2056
+ const a = ne(i, s);
2057
2057
  if (a.length === 1)
2058
2058
  n = a, o = i;
2059
2059
  else {
2060
- const h = te(s, i);
2060
+ const h = ne(s, i);
2061
2061
  a.length < h.length ? (n = a, o = i) : (n = h, o = s);
2062
2062
  }
2063
2063
  const d = r.filter((h) => h !== o);
2064
- return Array.prototype.push.apply(d, n), ye(d);
2064
+ return Array.prototype.push.apply(d, n), Ae(d);
2065
2065
  }
2066
2066
  }
2067
2067
  return r;
2068
2068
  }
2069
- function te(r, t) {
2070
- const e = Ye(t, r);
2069
+ function ne(r, t) {
2070
+ const e = Qe(t, r);
2071
2071
  if (e.height === 0 || e.width === 0)
2072
2072
  return [r];
2073
2073
  const i = [];
@@ -2117,7 +2117,7 @@ function te(r, t) {
2117
2117
  }
2118
2118
  return i;
2119
2119
  }
2120
- function Ye(r, t) {
2120
+ function Qe(r, t) {
2121
2121
  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);
2122
2122
  return {
2123
2123
  bottom: n,
@@ -2128,52 +2128,52 @@ function Ye(r, t) {
2128
2128
  width: Math.max(0, i - e)
2129
2129
  };
2130
2130
  }
2131
- function we(r, t, e) {
2132
- return (r.left < t.right || e >= 0 && R(r.left, t.right, e)) && (t.left < r.right || e >= 0 && R(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && R(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && R(t.top, r.bottom, e));
2131
+ function Ce(r, t, e) {
2132
+ 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));
2133
2133
  }
2134
- function R(r, t, e) {
2134
+ function I(r, t, e) {
2135
2135
  return Math.abs(r - t) <= e;
2136
2136
  }
2137
- function zt(r) {
2137
+ function Wt(r) {
2138
2138
  const t = {}, e = r.document.documentElement.style;
2139
2139
  for (const i in r.document.documentElement.style)
2140
2140
  Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
2141
2141
  return t;
2142
2142
  }
2143
- function Ae(r, t) {
2144
- const e = zt(r);
2143
+ function xe(r, t) {
2144
+ const e = Wt(r);
2145
2145
  Object.keys(e).forEach((i) => {
2146
- t.hasOwnProperty(i) || ut(r, i);
2146
+ t.hasOwnProperty(i) || mt(r, i);
2147
2147
  }), Object.entries(t).forEach(([i, s]) => {
2148
- e[i] !== s && Q(r, i, s);
2148
+ e[i] !== s && it(r, i, s);
2149
2149
  });
2150
2150
  }
2151
- function pt(r, t) {
2151
+ function gt(r, t) {
2152
2152
  return r.document.documentElement.style.getPropertyValue(t);
2153
2153
  }
2154
- function Q(r, t, e) {
2154
+ function it(r, t, e) {
2155
2155
  r.document.documentElement.style.setProperty(t, e);
2156
2156
  }
2157
- function ut(r, t) {
2157
+ function mt(r, t) {
2158
2158
  r.document.documentElement.style.removeProperty(t);
2159
2159
  }
2160
- let it = null, ft = null, q = 0;
2161
- const V = { r: 255, g: 255, b: 255, a: 1 }, _ = /* @__PURE__ */ new Map(), qe = () => {
2162
- if (!it)
2160
+ let rt = null, yt = null, Z = 0;
2161
+ const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), je = () => {
2162
+ if (!rt)
2163
2163
  if (typeof OffscreenCanvas < "u")
2164
- it = new OffscreenCanvas(5, 5), ft = it.getContext("2d", {
2164
+ rt = new OffscreenCanvas(5, 5), yt = rt.getContext("2d", {
2165
2165
  willReadFrequently: !0,
2166
2166
  desynchronized: !0
2167
2167
  });
2168
2168
  else {
2169
2169
  const r = document.createElement("canvas");
2170
- r.width = 5, r.height = 5, it = r, ft = r.getContext("2d", {
2170
+ r.width = 5, r.height = 5, rt = r, yt = r.getContext("2d", {
2171
2171
  willReadFrequently: !0,
2172
2172
  desynchronized: !0
2173
2173
  });
2174
2174
  }
2175
- return ft;
2176
- }, Xe = (r) => {
2175
+ return yt;
2176
+ }, ti = (r) => {
2177
2177
  if (!r) return !0;
2178
2178
  const t = r.trim().toLowerCase();
2179
2179
  return t.startsWith("var(") || [
@@ -2192,56 +2192,56 @@ const V = { r: 255, g: 255, b: 255, a: 1 }, _ = /* @__PURE__ */ new Map(), qe =
2192
2192
  "repeating-radial-gradient",
2193
2193
  "repeating-conic-gradient"
2194
2194
  ].some((s) => t.includes(s));
2195
- }, st = (r, t) => {
2195
+ }, ot = (r, t) => {
2196
2196
  console.warn(
2197
- `[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(V)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
2197
+ `[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).`
2198
2198
  );
2199
- }, bt = (r, t = null) => {
2200
- const e = t ? `${r}|${t}` : r, i = _.get(e);
2199
+ }, wt = (r, t = null) => {
2200
+ const e = t ? `${r}|${t}` : r, i = V.get(e);
2201
2201
  if (i !== void 0)
2202
- return i ?? V;
2203
- if (Xe(r))
2204
- return st(r, "Unsupported color format or special value."), _.set(e, null), V;
2205
- const s = qe();
2202
+ return i ?? G;
2203
+ if (ti(r))
2204
+ return ot(r, "Unsupported color format or special value."), V.set(e, null), G;
2205
+ const s = je();
2206
2206
  if (!s)
2207
- return st(r, "Could not get canvas context."), _.set(e, null), V;
2207
+ return ot(r, "Could not get canvas context."), V.set(e, null), G;
2208
2208
  try {
2209
- q === 0 && s.clearRect(0, 0, 5, 5);
2210
- const n = q % 5, o = Math.floor(q / 5);
2209
+ Z === 0 && s.clearRect(0, 0, 5, 5);
2210
+ const n = Z % 5, o = Math.floor(Z / 5);
2211
2211
  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);
2212
2212
  const a = s.getImageData(n, o, 1, 1);
2213
- q = (q + 1) % 25;
2213
+ Z = (Z + 1) % 25;
2214
2214
  const [d, h, u, g] = a.data;
2215
2215
  if (g === 0)
2216
- return st(r, "Fully transparent color."), _.set(e, null), V;
2217
- const p = { r: d, g: h, b: u, a: g / 255 };
2218
- return _.set(e, p), p;
2216
+ return ot(r, "Fully transparent color."), V.set(e, null), G;
2217
+ const m = { r: d, g: h, b: u, a: g / 255 };
2218
+ return V.set(e, m), m;
2219
2219
  } catch (n) {
2220
- return st(r, `Error: ${n instanceof Error ? n.message : String(n)}`), _.set(e, null), V;
2220
+ return ot(r, `Error: ${n instanceof Error ? n.message : String(n)}`), V.set(e, null), G;
2221
2221
  }
2222
- }, mt = (r) => {
2222
+ }, bt = (r) => {
2223
2223
  const t = r / 255;
2224
2224
  return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
2225
- }, ee = (r) => {
2226
- const t = mt(r.r), e = mt(r.g), i = mt(r.b);
2225
+ }, re = (r) => {
2226
+ const t = bt(r.r), e = bt(r.g), i = bt(r.b);
2227
2227
  return 0.2126 * t + 0.7152 * e + 0.0722 * i;
2228
- }, ie = (r, t) => {
2229
- const e = typeof r == "string" ? bt(r) : r, i = typeof t == "string" ? bt(t) : t, s = ee(e), n = ee(i), o = Math.max(s, n), a = Math.min(s, n);
2228
+ }, oe = (r, t) => {
2229
+ const e = typeof r == "string" ? wt(r) : r, i = typeof t == "string" ? wt(t) : t, s = re(e), n = re(i), o = Math.max(s, n), a = Math.min(s, n);
2230
2230
  return (o + 0.05) / (a + 0.05);
2231
- }, vt = (r, t = null) => {
2232
- const e = bt(r, t), i = ie(e, { r: 255, g: 255, b: 255, a: 1 }), s = ie(e, { r: 0, g: 0, b: 0, a: 1 });
2231
+ }, St = (r, t = null) => {
2232
+ const e = wt(r, t), i = oe(e, { r: 255, g: 255, b: 255, a: 1 }), s = oe(e, { r: 0, g: 0, b: 0, a: 1 });
2233
2233
  return i > s;
2234
- }, Ke = (r, t = null) => vt(r, t) ? "white" : "black", se = "#FFFF00";
2235
- var Ze = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(Ze || {}), Je = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Je || {});
2236
- const Qe = () => "Highlight" in window, re = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2237
- class je {
2234
+ }, ei = (r, t = null) => St(r, t) ? "white" : "black", ae = "#FFFF00";
2235
+ var ii = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(ii || {}), si = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(si || {});
2236
+ const ni = () => "Highlight" in window, le = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2237
+ class ri {
2238
2238
  /**
2239
2239
  * Creates a DecorationGroup object
2240
2240
  * @param id Unique HTML ID-adhering name of the group
2241
2241
  * @param name Human-readable name of the group
2242
2242
  */
2243
2243
  constructor(t, e, i, s) {
2244
- 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, Qe() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2244
+ 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, ni() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2245
2245
  }
2246
2246
  get activeable() {
2247
2247
  return this.activateable;
@@ -2254,13 +2254,13 @@ class je {
2254
2254
  * @param decoration Decoration to add
2255
2255
  */
2256
2256
  add(t) {
2257
- const e = `${this.id}-${this.lastItemId++}`, i = ht(this.wnd.document, t.locator);
2257
+ const e = `${this.id}-${this.lastItemId++}`, i = pt(this.wnd.document, t.locator);
2258
2258
  if (!i) {
2259
2259
  this.comms.log("Can't locate DOM range for decoration", t);
2260
2260
  return;
2261
2261
  }
2262
2262
  const s = i.commonAncestorContainer;
2263
- s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (re.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(re.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
2263
+ s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (le.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(le.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
2264
2264
  const n = {
2265
2265
  decoration: t,
2266
2266
  id: e,
@@ -2301,10 +2301,10 @@ class je {
2301
2301
  experimentalLayout(t) {
2302
2302
  const [e, i] = this.requireContainer(!0);
2303
2303
  i.add(t.range);
2304
- const s = pt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? se;
2304
+ const s = gt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? ae;
2305
2305
  e.innerHTML = `
2306
2306
  ::highlight(${this.id}) {
2307
- color: ${Ke(n, s)};
2307
+ color: ${ei(n, s)};
2308
2308
  background-color: ${n};
2309
2309
  }`;
2310
2310
  }
@@ -2321,48 +2321,48 @@ class je {
2321
2321
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2322
2322
  "column-count"
2323
2323
  )
2324
- ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f, m, v) => {
2324
+ ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f, p, b) => {
2325
2325
  if (f.style.position = "absolute", t.decoration?.style?.width === "viewport") {
2326
- f.style.width = `${i}px`, f.style.height = `${m.height}px`;
2327
- let C = Math.floor(m.left / i) * i;
2328
- f.style.left = `${C + a}px`, f.style.top = `${m.top + d}px`;
2326
+ f.style.width = `${i}px`, f.style.height = `${p.height}px`;
2327
+ let x = Math.floor(p.left / i) * i;
2328
+ f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
2329
2329
  } else if (t.decoration?.style?.width === "bounds")
2330
- f.style.width = `${v.width}px`, f.style.height = `${m.height}px`, f.style.left = `${v.left + a}px`, f.style.top = `${m.top + d}px`;
2330
+ f.style.width = `${b.width}px`, f.style.height = `${p.height}px`, f.style.left = `${b.left + a}px`, f.style.top = `${p.top + d}px`;
2331
2331
  else if (t.decoration?.style?.width === "page") {
2332
- f.style.width = `${n}px`, f.style.height = `${m.height}px`;
2333
- let C = Math.floor(m.left / n) * n;
2334
- f.style.left = `${C + a}px`, f.style.top = `${m.top + d}px`;
2332
+ f.style.width = `${n}px`, f.style.height = `${p.height}px`;
2333
+ let x = Math.floor(p.left / n) * n;
2334
+ f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
2335
2335
  } else
2336
- f.style.width = `${m.width}px`, f.style.height = `${m.height}px`, f.style.left = `${m.left + a}px`, f.style.top = `${m.top + d}px`;
2336
+ f.style.width = `${p.width}px`, f.style.height = `${p.height}px`, f.style.left = `${p.left + a}px`, f.style.top = `${p.top + d}px`;
2337
2337
  }, u = t.range.getBoundingClientRect();
2338
2338
  let g = this.wnd.document.createElement("template");
2339
- const p = this.getCurrentDarkMode();
2339
+ const m = this.getCurrentDarkMode();
2340
2340
  g.innerHTML = `
2341
2341
  <div
2342
2342
  data-readium="true"
2343
2343
  class="readium-highlight"
2344
2344
  style="${[
2345
- `background-color: ${t.decoration?.style?.tint ?? se} !important`,
2345
+ `background-color: ${t.decoration?.style?.tint ?? ae} !important`,
2346
2346
  //"opacity: 0.3 !important",
2347
- `mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
2347
+ `mix-blend-mode: ${m ? "exclusion" : "multiply"} !important`,
2348
2348
  "opacity: 1 !important",
2349
2349
  "box-sizing: border-box !important"
2350
2350
  ].join("; ")}"
2351
2351
  >
2352
2352
  </div>
2353
2353
  `.trim();
2354
- const y = g.content.firstElementChild;
2354
+ const v = g.content.firstElementChild;
2355
2355
  if (t.decoration?.style?.layout === "bounds") {
2356
- const f = y.cloneNode(!0);
2356
+ const f = v.cloneNode(!0);
2357
2357
  f.style.setProperty("pointer-events", "none"), h(f, u, u), e.append(f);
2358
2358
  } else {
2359
- let f = _e(
2359
+ let f = qe(
2360
2360
  t.range
2361
2361
  );
2362
- f = f.sort((m, v) => m.top < v.top ? -1 : m.top > v.top ? 1 : 0);
2363
- for (let m of f) {
2364
- const v = y.cloneNode(!0);
2365
- v.style.setProperty("pointer-events", "none"), h(v, m, u), e.append(v);
2362
+ f = f.sort((p, b) => p.top < b.top ? -1 : p.top > b.top ? 1 : 0);
2363
+ for (let p of f) {
2364
+ const b = v.cloneNode(!0);
2365
+ b.style.setProperty("pointer-events", "none"), h(b, p, u), e.append(b);
2366
2366
  }
2367
2367
  }
2368
2368
  t.container = e, t.clickableElements = Array.from(
@@ -2389,7 +2389,7 @@ class je {
2389
2389
  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;
2390
2390
  }
2391
2391
  getCurrentDarkMode() {
2392
- return pt(this.wnd, "--USER__appearance") === "readium-night-on" || vt(pt(this.wnd, "--USER__backgroundColor")) || vt(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
2392
+ return gt(this.wnd, "--USER__appearance") === "readium-night-on" || St(gt(this.wnd, "--USER__backgroundColor")) || St(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
2393
2393
  }
2394
2394
  /**
2395
2395
  * Removes the group container.
@@ -2398,7 +2398,7 @@ class je {
2398
2398
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2399
2399
  }
2400
2400
  }
2401
- const K = class K extends tt {
2401
+ const Q = class Q extends X {
2402
2402
  constructor() {
2403
2403
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2404
2404
  }
@@ -2423,9 +2423,9 @@ const K = class K extends tt {
2423
2423
  }, 50);
2424
2424
  }
2425
2425
  mount(t, e) {
2426
- return this.wnd = t, e.register("decorate", K.moduleName, (i, s) => {
2426
+ return this.wnd = t, e.register("decorate", Q.moduleName, (i, s) => {
2427
2427
  const n = i;
2428
- n.decoration && n.decoration.locator && (n.decoration.locator = U.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new je(
2428
+ n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new ri(
2429
2429
  t,
2430
2430
  e,
2431
2431
  `readium-decoration-${this.lastGroupId++}`,
@@ -2450,8 +2450,8 @@ const K = class K extends tt {
2450
2450
  }), 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) => {
2451
2451
  i.some((n) => {
2452
2452
  if (n.type === "attributes" && n.attributeName === "style") {
2453
- const o = n.target, a = n.oldValue, d = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(d, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"), p = this.extractCustomProperty(d, "--USER__backgroundColor");
2454
- return h !== u || g !== p;
2453
+ const o = n.target, a = n.oldValue, d = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(d, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"), m = this.extractCustomProperty(d, "--USER__backgroundColor");
2454
+ return h !== u || g !== m;
2455
2455
  }
2456
2456
  return !1;
2457
2457
  }) && this.updateHighlightStyles();
@@ -2463,12 +2463,12 @@ const K = class K extends tt {
2463
2463
  }), e.log("Decorator Mounted"), !0;
2464
2464
  }
2465
2465
  unmount(t, e) {
2466
- return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(K.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
2466
+ return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
2467
2467
  }
2468
2468
  };
2469
- K.moduleName = "decorator";
2470
- let yt = K;
2471
- const ne = "readium-snapper-style", Z = class Z extends tt {
2469
+ Q.moduleName = "decorator";
2470
+ let Et = Q;
2471
+ const ce = "readium-snapper-style", j = class j extends X {
2472
2472
  constructor() {
2473
2473
  super(...arguments), this.protected = !1;
2474
2474
  }
@@ -2481,34 +2481,34 @@ const ne = "readium-snapper-style", Z = class Z extends tt {
2481
2481
  }
2482
2482
  mount(t, e) {
2483
2483
  const i = t.document.createElement("style");
2484
- return i.dataset.readium = "true", i.id = ne, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", Z.moduleName, (s, n) => {
2484
+ return i.dataset.readium = "true", i.id = ce, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", j.moduleName, (s, n) => {
2485
2485
  this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2486
- }), e.register("unprotect", Z.moduleName, (s, n) => {
2486
+ }), e.register("unprotect", j.moduleName, (s, n) => {
2487
2487
  this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2488
2488
  }), e.log("Snapper Mounted"), !0;
2489
2489
  }
2490
2490
  unmount(t, e) {
2491
- return t.document.getElementById(ne)?.remove(), e.log("Snapper Unmounted"), !0;
2491
+ return t.document.getElementById(ce)?.remove(), e.log("Snapper Unmounted"), !0;
2492
2492
  }
2493
2493
  };
2494
- Z.moduleName = "snapper";
2495
- let j = Z;
2494
+ j.moduleName = "snapper";
2495
+ let st = j;
2496
2496
  function B(r) {
2497
2497
  return r.document.body.dir.toLowerCase() === "rtl";
2498
2498
  }
2499
- function Ee(r) {
2499
+ function Te(r) {
2500
2500
  return parseInt(
2501
2501
  r.getComputedStyle(
2502
2502
  r.document.documentElement
2503
2503
  ).getPropertyValue("column-count")
2504
2504
  );
2505
2505
  }
2506
- function oe(r) {
2506
+ function he(r) {
2507
2507
  const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
2508
2508
  return r.clientHeight - e - i;
2509
2509
  }
2510
- function ae(r) {
2511
- const t = Ee(r);
2510
+ function de(r) {
2511
+ const t = Te(r);
2512
2512
  if (!t)
2513
2513
  return !1;
2514
2514
  const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
@@ -2518,22 +2518,22 @@ function ae(r) {
2518
2518
  if (d > 0)
2519
2519
  for (let h = 0; h < d; h++) {
2520
2520
  const u = r.document.createElement("div");
2521
- u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = oe(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2521
+ u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = he(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2522
2522
  }
2523
2523
  return i !== d;
2524
2524
  }
2525
- function Se(r) {
2525
+ function Pe(r) {
2526
2526
  const t = r.document.createElement("style");
2527
2527
  t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
2528
2528
  }
2529
- function ti(r) {
2529
+ function oi(r) {
2530
2530
  return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2531
2531
  }
2532
- function S(r) {
2532
+ function A(r) {
2533
2533
  const t = r.getSelection();
2534
2534
  t && t.removeAllRanges();
2535
2535
  }
2536
- const ei = [
2536
+ const ai = [
2537
2537
  "a",
2538
2538
  "audio",
2539
2539
  "button",
@@ -2547,17 +2547,17 @@ const ei = [
2547
2547
  "textarea",
2548
2548
  "video"
2549
2549
  ];
2550
- function xe(r) {
2551
- return ei.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? xe(r.parentElement) : null;
2550
+ function Ne(r) {
2551
+ return ai.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Ne(r.parentElement) : null;
2552
2552
  }
2553
- function Dt(r, t) {
2554
- const e = Te(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
2553
+ function Ut(r, t) {
2554
+ const e = Le(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
2555
2555
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2556
2556
  });
2557
- return new U({
2557
+ return new W({
2558
2558
  href: "#",
2559
2559
  type: "application/xhtml+xml",
2560
- locations: new x({
2560
+ locations: new C({
2561
2561
  otherLocations: /* @__PURE__ */ new Map([
2562
2562
  ["cssSelector", i]
2563
2563
  ])
@@ -2567,15 +2567,15 @@ function Dt(r, t) {
2567
2567
  })
2568
2568
  });
2569
2569
  }
2570
- function Te(r, t, e) {
2570
+ function Le(r, t, e) {
2571
2571
  for (var i = 0; i < t.children.length; i++) {
2572
2572
  const s = t.children[i];
2573
- if (!ri(s) && ii(r, s, e))
2574
- return si(r, s) ? s : Te(r, s, e);
2573
+ if (!hi(s) && li(r, s, e))
2574
+ return ci(r, s) ? s : Le(r, s, e);
2575
2575
  }
2576
2576
  return t;
2577
2577
  }
2578
- function ii(r, t, e) {
2578
+ function li(r, t, e) {
2579
2579
  if (t === document.body || t === document.documentElement)
2580
2580
  return !0;
2581
2581
  if (!document || !document.documentElement || !document.body)
@@ -2583,11 +2583,11 @@ function ii(r, t, e) {
2583
2583
  const i = t.getBoundingClientRect();
2584
2584
  return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2585
2585
  }
2586
- function si(r, t) {
2586
+ function ci(r, t) {
2587
2587
  const e = t.getBoundingClientRect();
2588
2588
  return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
2589
2589
  }
2590
- function ri(r) {
2590
+ function hi(r) {
2591
2591
  const t = getComputedStyle(r);
2592
2592
  if (t) {
2593
2593
  const e = t.getPropertyValue("display");
@@ -2596,9 +2596,75 @@ function ri(r) {
2596
2596
  }
2597
2597
  return !1;
2598
2598
  }
2599
- const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2599
+ const di = {
2600
+ maxVelocity: 200,
2601
+ // Reasonable default for human-like scrolling (pixels/ms)
2602
+ minVariance: 0.01,
2603
+ // Default variance threshold
2604
+ historySize: 20,
2605
+ // Balanced history size for performance
2606
+ minDirectionChanges: 0.2,
2607
+ // Reasonable default for detecting patterns
2608
+ maxConsistentScrolls: 15
2609
+ // Balanced threshold for flagging
2610
+ }, Oe = {
2611
+ maxVelocity: 200,
2612
+ // Extremely fast scrolling (pixels/ms)
2613
+ minVariance: 1e-5,
2614
+ // Near-perfect consistency
2615
+ historySize: 100,
2616
+ // Large history window
2617
+ minDirectionChanges: 0.1,
2618
+ // Only trigger on near-perfect patterns
2619
+ maxConsistentScrolls: 20
2620
+ // Need many consistent scrolls
2621
+ }, Re = {
2622
+ maxSelectionsPerSecond: 500,
2623
+ minVariance: 50,
2624
+ historySize: 20
2625
+ }, ui = {
2626
+ enabled: !0,
2627
+ maxSelectionPercent: 0.1,
2628
+ minThreshold: 100,
2629
+ absoluteMaxChars: 5e3,
2630
+ historySize: 20
2631
+ };
2632
+ class Bt {
2633
+ constructor(t = {}) {
2634
+ this.history = [], this.consistentScrollCount = 0, this.options = { ...di, ...t };
2635
+ }
2636
+ analyze(t, e, i) {
2637
+ if (i <= 0) return !1;
2638
+ const s = Math.abs(e) / i, n = Date.now();
2639
+ if (this.history.push({
2640
+ timestamp: n,
2641
+ direction: t,
2642
+ velocity: s,
2643
+ distance: Math.abs(e)
2644
+ }), this.history = this.history.filter((p) => n - p.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
2645
+ if (s > this.options.maxVelocity)
2646
+ return this.resetAfterDetection(), !0;
2647
+ const o = this.history.map((p) => p.velocity), a = this.history.map((p) => p.distance), d = o.reduce((p, b) => p + b, 0) / o.length, h = a.reduce((p, b) => p + b, 0) / a.length, u = o.reduce((p, b) => p + Math.pow(b - d, 2), 0) / o.length, g = a.reduce((p, b) => p + Math.pow(b - h, 2), 0) / a.length;
2648
+ if (u < this.options.minVariance && g < h * 0.1) {
2649
+ if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
2650
+ return this.resetAfterDetection(), !0;
2651
+ } else
2652
+ this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
2653
+ let m = 0, v = this.history[0].direction;
2654
+ for (let p = 1; p < this.history.length; p++)
2655
+ this.history[p].direction !== v && (m++, v = this.history[p].direction);
2656
+ return m / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
2657
+ }
2658
+ resetAfterDetection() {
2659
+ this.history = this.history.slice(-3), this.consistentScrollCount = 0;
2660
+ }
2661
+ clear() {
2662
+ this.history = [], this.consistentScrollCount = 0;
2663
+ }
2664
+ }
2665
+ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
2600
2666
  constructor() {
2601
- super(...arguments), 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);
2667
+ 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);
2602
2668
  }
2603
2669
  doc() {
2604
2670
  return this.wnd.document.scrollingElement;
@@ -2634,24 +2700,24 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2634
2700
  }
2635
2701
  // Snaps the current offset to the page width.
2636
2702
  snapCurrentOffset(t = !1, e = !1) {
2637
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ee(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), d = B(this.wnd) ? -1 : 1, h = (
2703
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Te(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), d = B(this.wnd) ? -1 : 1, h = (
2638
2704
  // The hurdle to overcome in order to change pages
2639
2705
  d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
2640
- ), u = this.snapOffset(a + h);
2641
- if (t && u !== this.scrollOffset()) {
2706
+ ), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
2707
+ if (this.checkSuspiciousSnap(g, Math.abs(u - this.scrollOffset())), t && u !== this.scrollOffset()) {
2642
2708
  this.snappingCancelled = !1;
2643
- const g = (m, v, C, G) => C > G ? v : m + (v - m) * ti(C / G), p = (
2709
+ const m = (b, x, _, q) => _ > q ? x : b + (x - b) * oi(_ / q), v = (
2644
2710
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2645
- ni * o
2711
+ pi * o
2646
2712
  );
2647
- let y;
2648
- const f = (m) => {
2713
+ let f;
2714
+ const p = (b) => {
2649
2715
  if (this.snappingCancelled) return;
2650
- y || (y = m);
2651
- const v = m - y, C = g(this.overscroll, 0, v, p), G = g(i, u, v, p);
2652
- s.scrollLeft = G, this.overscroll !== 0 && (s.style.transform = `translate3d(${-C}px, 0px, 0px)`), v < p ? this.wnd.requestAnimationFrame(f) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
2716
+ f || (f = b);
2717
+ const x = b - f, _ = m(this.overscroll, 0, x, v), q = m(i, u, x, v);
2718
+ s.scrollLeft = q, this.overscroll !== 0 && (s.style.transform = `translate3d(${-_}px, 0px, 0px)`), x < v ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
2653
2719
  };
2654
- this.wnd.requestAnimationFrame(f);
2720
+ this.wnd.requestAnimationFrame(p);
2655
2721
  } else
2656
2722
  s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2657
2723
  s.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
@@ -2689,15 +2755,38 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2689
2755
  }
2690
2756
  onTouchMove(t) {
2691
2757
  if (this.touchState === 0) return;
2692
- this.touchState === 1 && (this.touchState = 2, S(this.wnd)), this.endingX = t.touches[0].clientX;
2758
+ this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
2693
2759
  const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
2694
2760
  i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
2695
2761
  }
2762
+ enableSnapProtection() {
2763
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt({
2764
+ maxVelocity: this.wnd.innerWidth,
2765
+ // page width
2766
+ minVariance: 0.1,
2767
+ // Allow for some variation in swipe speed
2768
+ historySize: 5,
2769
+ // Fewer samples needed for swipe detection
2770
+ maxConsistentScrolls: 3,
2771
+ // Lower threshold for consistent scrolling
2772
+ minDirectionChanges: 0.3
2773
+ // Require more direction changes
2774
+ }), this.isSnapProtectionEnabled = !0, this.comms?.log("Snap protection enabled"));
2775
+ }
2776
+ checkSuspiciousSnap(t, e) {
2777
+ if (!this.isSnapProtectionEnabled || !this.patternAnalyzer) return;
2778
+ const i = Date.now(), s = i - (this.lastTurnTime || i);
2779
+ this.lastTurnTime = i, this.patternAnalyzer.analyze(t, e, s) && this.comms?.send("content_protection", {
2780
+ type: "suspicious_snapping",
2781
+ timestamp: Date.now(),
2782
+ event: null
2783
+ });
2784
+ }
2696
2785
  mount(t, e) {
2697
2786
  if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
2698
2787
  t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
2699
2788
  const i = t.document.createElement("style");
2700
- i.dataset.readium = "true", i.id = le, i.textContent = `
2789
+ i.dataset.readium = "true", i.id = ue, i.textContent = `
2701
2790
  @keyframes readium-bounce-l-animation {
2702
2791
  0%, 100% {transform: translate3d(0, 0, 0);}
2703
2792
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2733,23 +2822,25 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2733
2822
  }
2734
2823
  `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2735
2824
  t.requestAnimationFrame(() => {
2736
- t && ae(t);
2825
+ t && de(t);
2737
2826
  }), this.onWidthChange();
2738
2827
  }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
2739
2828
  for (const o of n)
2740
2829
  if (o.target === this.wnd.document.documentElement) {
2741
2830
  const a = o.oldValue, d = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a?.match(h), g = d?.match(h);
2742
2831
  (!u && !g || u && !g || u && g && u[1] !== g[1]) && (t.requestAnimationFrame(() => {
2743
- t && ae(t);
2832
+ t && de(t);
2744
2833
  }), this.onWidthChange());
2745
2834
  } else
2746
2835
  t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2747
- }), 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"] });
2836
+ }), 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", P.moduleName, (n, o) => {
2837
+ this.enableSnapProtection(), o(!0);
2838
+ });
2748
2839
  const s = (n) => {
2749
2840
  const o = this.doc().scrollLeft;
2750
2841
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2751
2842
  };
2752
- return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", N.moduleName, (n, o) => {
2843
+ return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", P.moduleName, (n, o) => {
2753
2844
  const a = n;
2754
2845
  if (a < 0 || a > 1) {
2755
2846
  e.send("error", {
@@ -2760,25 +2851,25 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2760
2851
  this.wnd.requestAnimationFrame(() => {
2761
2852
  this.cachedScrollWidth = this.doc().scrollWidth;
2762
2853
  const d = this.cachedScrollWidth, h = B(t) ? -1 : 1, u = d * a * h;
2763
- this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), S(this.wnd), o(!0);
2854
+ this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), A(this.wnd), o(!0);
2764
2855
  });
2765
- }), e.register("go_id", N.moduleName, (n, o) => {
2856
+ }), e.register("go_id", P.moduleName, (n, o) => {
2766
2857
  const a = t.document.getElementById(n);
2767
2858
  if (!a) {
2768
2859
  o(!1);
2769
2860
  return;
2770
2861
  }
2771
2862
  this.wnd.requestAnimationFrame(() => {
2772
- this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2863
+ this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2773
2864
  });
2774
- }), e.register("go_text", N.moduleName, (n, o) => {
2865
+ }), e.register("go_text", P.moduleName, (n, o) => {
2775
2866
  let a;
2776
2867
  Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
2777
- const d = H.deserialize(n), h = ht(this.wnd.document, new U({
2868
+ const d = H.deserialize(n), h = pt(this.wnd.document, new W({
2778
2869
  href: t.location.href,
2779
2870
  type: "text/html",
2780
2871
  text: d,
2781
- locations: a ? new x({
2872
+ locations: a ? new C({
2782
2873
  otherLocations: /* @__PURE__ */ new Map([
2783
2874
  ["cssSelector", a]
2784
2875
  ])
@@ -2789,56 +2880,56 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2789
2880
  return;
2790
2881
  }
2791
2882
  this.wnd.requestAnimationFrame(() => {
2792
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2883
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2793
2884
  });
2794
- }), e.register("go_end", N.moduleName, (n, o) => {
2885
+ }), e.register("go_end", P.moduleName, (n, o) => {
2795
2886
  const a = B(t) ? -1 : 1;
2796
2887
  this.wnd.requestAnimationFrame(() => {
2797
2888
  this.cachedScrollWidth = this.doc().scrollWidth;
2798
2889
  const d = this.cachedScrollWidth * a;
2799
2890
  if (this.doc().scrollLeft === d) return o(!1);
2800
- this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), S(this.wnd), o(!0);
2891
+ this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), A(this.wnd), o(!0);
2801
2892
  });
2802
- }), e.register("go_start", N.moduleName, (n, o) => {
2893
+ }), e.register("go_start", P.moduleName, (n, o) => {
2803
2894
  this.wnd.requestAnimationFrame(() => {
2804
2895
  if (this.doc().scrollLeft === 0) return o(!1);
2805
- this.doc().scrollLeft = 0, this.reportProgress(), S(this.wnd), o(!0);
2896
+ this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), o(!0);
2806
2897
  });
2807
- }), e.register("go_prev", N.moduleName, (n, o) => {
2898
+ }), e.register("go_prev", P.moduleName, (n, o) => {
2808
2899
  this.wnd.requestAnimationFrame(() => {
2809
2900
  this.cachedScrollWidth = this.doc().scrollWidth;
2810
2901
  const a = t.scrollX - t.innerWidth, d = B(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = s(Math.max(a, d));
2811
- h && (this.reportProgress(), S(this.wnd)), o(h);
2902
+ h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(h);
2812
2903
  });
2813
- }), e.register("go_next", N.moduleName, (n, o) => {
2904
+ }), e.register("go_next", P.moduleName, (n, o) => {
2814
2905
  this.wnd.requestAnimationFrame(() => {
2815
2906
  this.cachedScrollWidth = this.doc().scrollWidth;
2816
2907
  const a = t.scrollX + t.innerWidth, d = B(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = s(Math.min(a, d));
2817
- h && (this.reportProgress(), S(this.wnd)), o(h);
2908
+ h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(h);
2818
2909
  });
2819
- }), e.register("unfocus", N.moduleName, (n, o) => {
2820
- this.snappingCancelled = !0, S(this.wnd), o(!0);
2821
- }), e.register("shake", N.moduleName, (n, o) => {
2910
+ }), e.register("unfocus", P.moduleName, (n, o) => {
2911
+ this.snappingCancelled = !0, A(this.wnd), o(!0);
2912
+ }), e.register("shake", P.moduleName, (n, o) => {
2822
2913
  this.shake(), o(!0);
2823
- }), e.register("focus", N.moduleName, (n, o) => {
2914
+ }), e.register("focus", P.moduleName, (n, o) => {
2824
2915
  this.wnd.requestAnimationFrame(() => {
2825
2916
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2826
2917
  });
2827
- }), e.register("first_visible_locator", N.moduleName, (n, o) => {
2828
- const a = Dt(t, !1);
2918
+ }), e.register("first_visible_locator", P.moduleName, (n, o) => {
2919
+ const a = Ut(t, !1);
2829
2920
  this.comms.send("first_visible_locator", a.serialize()), o(!0);
2830
2921
  }), 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", () => {
2831
2922
  }), e.log("ColumnSnapper Mounted"), !0;
2832
2923
  }
2833
2924
  unmount(t, e) {
2834
- return this.snappingCancelled = !0, e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), 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(le)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
2925
+ return this.snappingCancelled = !0, e.unregisterAll(P.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(ue)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
2835
2926
  }
2836
2927
  };
2837
- N.moduleName = "column_snapper";
2838
- let wt = N;
2839
- const ce = "readium-scroll-snapper-style", O = class O extends j {
2928
+ P.moduleName = "column_snapper";
2929
+ let At = P;
2930
+ const pe = "readium-scroll-snapper-style", N = class N extends st {
2840
2931
  constructor() {
2841
- super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
2932
+ 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) => {
2842
2933
  if (this.comms.ready && !this.isResizing) {
2843
2934
  if (!this.initialScrollHandled) {
2844
2935
  this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
@@ -2846,8 +2937,26 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
2846
2937
  }
2847
2938
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2848
2939
  this.reportProgress();
2849
- const t = this.doc().scrollTop, e = t - this.lastScrollTop;
2850
- this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;
2940
+ const e = this.doc().scrollTop, i = e - this.lastScrollTop;
2941
+ if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
2942
+ const s = Date.now(), n = s - (this.lastScrollTime || s);
2943
+ if (this.patternAnalyzer && this.patternAnalyzer.analyze(
2944
+ i > 0 ? "down" : "up",
2945
+ Math.abs(i),
2946
+ n
2947
+ )) {
2948
+ const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
2949
+ this.comms?.send("content_protection", {
2950
+ type: "suspicious_scrolling",
2951
+ timestamp: Date.now(),
2952
+ scrollDelta: i,
2953
+ scrollDirection: i > 0 ? "down" : "up",
2954
+ targetElement: a
2955
+ });
2956
+ }
2957
+ this.lastScrollTime = s;
2958
+ }
2959
+ this.comms.send("scroll", i), this.isScrolling = !1;
2851
2960
  }));
2852
2961
  }
2853
2962
  };
@@ -2863,10 +2972,13 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
2863
2972
  end: n
2864
2973
  });
2865
2974
  }
2975
+ enableScrollProtection() {
2976
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt(Oe), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
2977
+ }
2866
2978
  mount(t, e) {
2867
2979
  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");
2868
2980
  const i = t.document.createElement("style");
2869
- return i.dataset.readium = "true", i.id = ce, i.textContent = `
2981
+ return i.dataset.readium = "true", i.id = pe, i.textContent = `
2870
2982
  * {
2871
2983
  scrollbar-width: none; /* for Firefox */
2872
2984
  }
@@ -2878,11 +2990,11 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
2878
2990
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2879
2991
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2880
2992
  }, 50);
2881
- }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", O.moduleName, () => {
2882
- Se(this.wnd);
2993
+ }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
2994
+ Pe(this.wnd);
2883
2995
  const s = this.doc().scrollTop;
2884
2996
  s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
2885
- }), e.register("go_progression", O.moduleName, (s, n) => {
2997
+ }), e.register("go_progression", N.moduleName, (s, n) => {
2886
2998
  const o = s;
2887
2999
  if (o < 0 || o > 1) {
2888
3000
  e.send("error", {
@@ -2891,25 +3003,25 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
2891
3003
  return;
2892
3004
  }
2893
3005
  this.wnd.requestAnimationFrame(() => {
2894
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), S(this.wnd), n(!0);
3006
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), n(!0);
2895
3007
  });
2896
- }), e.register("go_id", O.moduleName, (s, n) => {
3008
+ }), e.register("go_id", N.moduleName, (s, n) => {
2897
3009
  const o = t.document.getElementById(s);
2898
3010
  if (!o) {
2899
3011
  n(!1);
2900
3012
  return;
2901
3013
  }
2902
3014
  this.wnd.requestAnimationFrame(() => {
2903
- this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
3015
+ this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
2904
3016
  });
2905
- }), e.register("go_text", O.moduleName, (s, n) => {
3017
+ }), e.register("go_text", N.moduleName, (s, n) => {
2906
3018
  let o;
2907
3019
  Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
2908
- const a = H.deserialize(s), d = ht(this.wnd.document, new U({
3020
+ const a = H.deserialize(s), d = pt(this.wnd.document, new W({
2909
3021
  href: t.location.href,
2910
3022
  type: "text/html",
2911
3023
  text: a,
2912
- locations: o ? new x({
3024
+ locations: o ? new C({
2913
3025
  otherLocations: /* @__PURE__ */ new Map([
2914
3026
  ["cssSelector", o]
2915
3027
  ])
@@ -2920,35 +3032,37 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
2920
3032
  return;
2921
3033
  }
2922
3034
  this.wnd.requestAnimationFrame(() => {
2923
- this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
3035
+ this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
2924
3036
  });
2925
- }), e.register("go_start", O.moduleName, (s, n) => {
3037
+ }), e.register("go_start", N.moduleName, (s, n) => {
2926
3038
  if (this.doc().scrollTop === 0) return n(!1);
2927
3039
  this.doc().scrollTop = 0, this.reportProgress(), n(!0);
2928
- }), e.register("go_end", O.moduleName, (s, n) => {
3040
+ }), e.register("go_end", N.moduleName, (s, n) => {
2929
3041
  if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
2930
3042
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
2931
- }), e.register("unfocus", O.moduleName, (s, n) => {
2932
- S(this.wnd), n(!0);
3043
+ }), e.register("unfocus", N.moduleName, (s, n) => {
3044
+ A(this.wnd), n(!0);
3045
+ }), e.register("scroll_protection", N.moduleName, (s, n) => {
3046
+ this.enableScrollProtection(), n(!0);
2933
3047
  }), e.register([
2934
3048
  "go_next",
2935
3049
  "go_prev"
2936
- ], O.moduleName, (s, n) => n(!1)), e.register("focus", O.moduleName, (s, n) => {
3050
+ ], N.moduleName, (s, n) => n(!1)), e.register("focus", N.moduleName, (s, n) => {
2937
3051
  this.reportProgress(), n(!0);
2938
- }), e.register("first_visible_locator", O.moduleName, (s, n) => {
2939
- const o = Dt(t, !0);
3052
+ }), e.register("first_visible_locator", N.moduleName, (s, n) => {
3053
+ const o = Ut(t, !0);
2940
3054
  this.comms.send("first_visible_locator", o.serialize()), n(!0);
2941
3055
  }), e.log("ScrollSnapper Mounted"), !0;
2942
3056
  }
2943
3057
  unmount(t, e) {
2944
- return e.unregisterAll(O.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(ce)?.remove(), e.log("ScrollSnapper Unmounted"), !0;
3058
+ return e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(pe)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
2945
3059
  }
2946
3060
  };
2947
- O.moduleName = "scroll_snapper";
2948
- let At = O;
2949
- const P = class P extends j {
3061
+ N.moduleName = "scroll_snapper";
3062
+ let Ct = N;
3063
+ const L = class L extends st {
2950
3064
  constructor() {
2951
- super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
3065
+ 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) => {
2952
3066
  if (this.comms.ready && !this.isResizing) {
2953
3067
  if (!this.initialScrollHandled) {
2954
3068
  this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
@@ -2956,8 +3070,26 @@ const P = class P extends j {
2956
3070
  }
2957
3071
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2958
3072
  this.reportProgress();
2959
- const t = this.doc().scrollTop, e = t - this.lastScrollTop;
2960
- this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;
3073
+ const e = this.doc().scrollTop, i = e - this.lastScrollTop;
3074
+ if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
3075
+ const s = Date.now(), n = s - (this.lastScrollTime || s);
3076
+ if (this.patternAnalyzer && this.patternAnalyzer.analyze(
3077
+ i > 0 ? "down" : "up",
3078
+ Math.abs(i),
3079
+ n
3080
+ )) {
3081
+ const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
3082
+ this.comms?.send("content_protection", {
3083
+ type: "suspicious_scrolling",
3084
+ timestamp: Date.now(),
3085
+ scrollDelta: i,
3086
+ scrollDirection: i > 0 ? "down" : "up",
3087
+ targetElement: a
3088
+ });
3089
+ }
3090
+ this.lastScrollTime = s;
3091
+ }
3092
+ this.comms.send("scroll", i), this.isScrolling = !1;
2961
3093
  }));
2962
3094
  }
2963
3095
  };
@@ -2973,16 +3105,19 @@ const P = class P extends j {
2973
3105
  end: n
2974
3106
  });
2975
3107
  }
3108
+ enableScrollProtection() {
3109
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt(Oe), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
3110
+ }
2976
3111
  mount(t, e) {
2977
3112
  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(() => {
2978
3113
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2979
3114
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2980
3115
  }, 50);
2981
- }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", P.moduleName, () => {
2982
- Se(this.wnd);
3116
+ }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
3117
+ Pe(this.wnd);
2983
3118
  const i = this.doc().scrollTop;
2984
3119
  i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
2985
- }), e.register("go_progression", P.moduleName, (i, s) => {
3120
+ }), e.register("go_progression", L.moduleName, (i, s) => {
2986
3121
  const n = i;
2987
3122
  if (n < 0 || n > 1) {
2988
3123
  e.send("error", {
@@ -2991,25 +3126,25 @@ const P = class P extends j {
2991
3126
  return;
2992
3127
  }
2993
3128
  this.wnd.requestAnimationFrame(() => {
2994
- this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), S(this.wnd), s(!0);
3129
+ this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), A(this.wnd), s(!0);
2995
3130
  });
2996
- }), this.comms.register("go_id", P.moduleName, (i, s) => {
3131
+ }), e.register("go_id", L.moduleName, (i, s) => {
2997
3132
  const n = t.document.getElementById(i);
2998
3133
  if (!n) {
2999
3134
  s(!1);
3000
3135
  return;
3001
3136
  }
3002
3137
  this.wnd.requestAnimationFrame(() => {
3003
- this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), s(!0);
3138
+ this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
3004
3139
  });
3005
- }), e.register("go_text", P.moduleName, (i, s) => {
3140
+ }), e.register("go_text", L.moduleName, (i, s) => {
3006
3141
  let n;
3007
3142
  Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
3008
- const o = H.deserialize(i), a = ht(this.wnd.document, new U({
3143
+ const o = H.deserialize(i), a = pt(this.wnd.document, new W({
3009
3144
  href: t.location.href,
3010
3145
  type: "text/html",
3011
3146
  text: o,
3012
- locations: n ? new x({
3147
+ locations: n ? new C({
3013
3148
  otherLocations: /* @__PURE__ */ new Map([
3014
3149
  ["cssSelector", n]
3015
3150
  ])
@@ -3020,35 +3155,330 @@ const P = class P extends j {
3020
3155
  return;
3021
3156
  }
3022
3157
  this.wnd.requestAnimationFrame(() => {
3023
- this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), s(!0);
3158
+ this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
3024
3159
  });
3025
- }), e.register("go_start", P.moduleName, (i, s) => {
3160
+ }), e.register("go_start", L.moduleName, (i, s) => {
3026
3161
  if (this.doc().scrollTop === 0) return s(!1);
3027
3162
  this.doc().scrollTop = 0, this.reportProgress(), s(!0);
3028
- }), e.register("go_end", P.moduleName, (i, s) => {
3163
+ }), e.register("go_end", L.moduleName, (i, s) => {
3029
3164
  if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
3030
3165
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
3031
- }), e.register("unfocus", P.moduleName, (i, s) => {
3032
- S(this.wnd), s(!0);
3166
+ }), e.register("unfocus", L.moduleName, (i, s) => {
3167
+ A(this.wnd), s(!0);
3168
+ }), e.register("scroll_protection", L.moduleName, (i, s) => {
3169
+ this.enableScrollProtection(), s(!0);
3033
3170
  }), e.register([
3034
3171
  "go_next",
3035
3172
  "go_prev"
3036
- ], P.moduleName, (i, s) => s(!1)), e.register("focus", P.moduleName, (i, s) => {
3173
+ ], L.moduleName, (i, s) => s(!1)), e.register("focus", L.moduleName, (i, s) => {
3037
3174
  this.reportProgress(), s(!0);
3038
- }), e.register("first_visible_locator", P.moduleName, (i, s) => {
3039
- const n = Dt(t, !0);
3175
+ }), e.register("first_visible_locator", L.moduleName, (i, s) => {
3176
+ const n = Ut(t, !0);
3040
3177
  e.send("first_visible_locator", n.serialize()), s(!0);
3041
3178
  }), e.log("WebPubSnapper Mounted"), !0;
3042
3179
  }
3043
3180
  unmount(t, e) {
3044
- return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), e.log("WebPubSnapper Unmounted"), !0;
3181
+ return e.unregisterAll(L.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;
3045
3182
  }
3046
3183
  };
3047
- P.moduleName = "webpub_snapper";
3048
- let Et = P;
3049
- const Mt = class Mt extends tt {
3184
+ L.moduleName = "webpub_snapper";
3185
+ let xt = L;
3186
+ class mi {
3187
+ constructor(t, e) {
3188
+ this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
3189
+ }
3190
+ cleanupOldHistory(t) {
3191
+ this.copyHistory = this.copyHistory.filter(
3192
+ (i) => t - i.timestamp < 1e4
3193
+ ), this.copyHistory.length > this.options.historySize && (this.copyHistory = this.copyHistory.slice(-this.options.historySize));
3194
+ }
3195
+ isSuspiciousPattern(t) {
3196
+ return this.copyHistory.length < 3 ? !1 : this.copyHistory.filter(
3197
+ (s) => t - s.timestamp < 2e3
3198
+ // Last 2 seconds
3199
+ ).length >= 3 ? !0 : this.copyHistory.slice().sort((s, n) => s.timestamp - n.timestamp).every((s, n, o) => n === 0 ? !0 : s.length > o[n - 1].length * 1.5);
3200
+ }
3201
+ shouldAllowCopy(t) {
3202
+ if (!this.options.enabled) return !0;
3203
+ const e = this.window.getSelection();
3204
+ if (!e) return !0;
3205
+ const s = e.toString().length, n = this.window.document.body.innerText.length, o = Date.now();
3206
+ if (this.cleanupOldHistory(o), s < this.options.minThreshold)
3207
+ return this.copyHistory.push({
3208
+ timestamp: o,
3209
+ length: s,
3210
+ wasBlocked: !1
3211
+ }), !0;
3212
+ const d = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, h = Math.min(
3213
+ n * this.options.maxSelectionPercent,
3214
+ this.options.absoluteMaxChars
3215
+ ), u = this.isSuspiciousPattern(o), g = s > h || d || u;
3216
+ return this.copyHistory.push({
3217
+ timestamp: o,
3218
+ length: s,
3219
+ wasBlocked: g
3220
+ }), g ? (t?.preventDefault(), !1) : (this.lastSelectionLength = s, this.lastSelectionTime = o, !0);
3221
+ }
3222
+ destroy() {
3223
+ this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
3224
+ }
3225
+ }
3226
+ class fi {
3227
+ constructor(t = Re) {
3228
+ this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
3229
+ }
3230
+ analyze(t) {
3231
+ if (!t)
3232
+ return this.clear(), !1;
3233
+ const e = t.toString();
3234
+ if (e.length === 0)
3235
+ return this.clear(), !1;
3236
+ if (t.type !== "Range" || !t.rangeCount)
3237
+ return !1;
3238
+ const i = Date.now();
3239
+ if (e.length <= 50 || e === this.lastSelectedText)
3240
+ return !1;
3241
+ if (this.selectionStartTime === 0)
3242
+ return this.selectionStartTime = i, this.lastSelectedText = e, !1;
3243
+ if (i - this.selectionStartTime < 500)
3244
+ return !1;
3245
+ i - this.lastSelectionTime > 1e3 && (this.lastSelectionTime = i), this.selectionStartTime === 0 && (this.selectionStartTime = i), this.lastSelectedText = e;
3246
+ const n = this.analyzeSelectionPattern(t, i);
3247
+ return this.cleanup(i), n;
3248
+ }
3249
+ analyzeSelectionPattern(t, e) {
3250
+ if (!t.rangeCount) return !1;
3251
+ const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
3252
+ if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
3253
+ const a = i.startOffset, d = Math.abs(a - this.lastSelectionPosition);
3254
+ return this.selectionPatterns.push(d), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
3255
+ }
3256
+ calculateVariance(t) {
3257
+ if (t.length === 0) return 0;
3258
+ const e = t.reduce((i, s) => i + s, 0) / t.length;
3259
+ return t.reduce((i, s) => i + Math.pow(s - e, 2), 0) / t.length;
3260
+ }
3261
+ cleanup(t) {
3262
+ this.events = this.events.filter((e) => t - e.timestamp <= 1e3);
3263
+ }
3264
+ clear() {
3265
+ this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
3266
+ }
3267
+ }
3268
+ class gi {
3269
+ /**
3270
+ * Checks if the given keyboard event matches any of the provided key combinations
3271
+ */
3272
+ match(t, e) {
3273
+ for (const i of e) {
3274
+ 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, d = i.meta === void 0 || t.metaKey === i.meta;
3275
+ if (s && n && o && a && d)
3276
+ return !0;
3277
+ }
3278
+ return !1;
3279
+ }
3280
+ /**
3281
+ * Creates an event handler that will call the provided handler when any of the key combinations match
3282
+ */
3283
+ createKeyHandler(t, e) {
3284
+ return (i) => {
3285
+ this.match(i, t) && (i.preventDefault(), i.stopPropagation(), e(i));
3286
+ };
3287
+ }
3288
+ /**
3289
+ * Creates a standardized activity event for keyboard shortcuts
3290
+ */
3291
+ createActivityEvent(t, e, i, s) {
3292
+ let n;
3293
+ if (s) {
3294
+ const o = s.getSelection(), a = o?.toString() || "", h = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3295
+ h && a && (n = {
3296
+ text: a,
3297
+ x: h.x,
3298
+ y: h.y,
3299
+ width: h.width,
3300
+ height: h.height
3301
+ });
3302
+ }
3303
+ return {
3304
+ type: e,
3305
+ timestamp: Date.now(),
3306
+ key: t.key,
3307
+ code: t.code,
3308
+ keyCode: t.keyCode,
3309
+ ctrlKey: t.ctrlKey,
3310
+ altKey: t.altKey,
3311
+ shiftKey: t.shiftKey,
3312
+ metaKey: t.metaKey,
3313
+ targetFrameSrc: i,
3314
+ selectedText: n
3315
+ };
3316
+ }
3317
+ /**
3318
+ * Creates handlers for keyboard shortcuts with centralized activity event dispatch
3319
+ */
3320
+ createKeyboardHandlers(t, e, i, s) {
3321
+ const n = [];
3322
+ return e.forEach((o) => {
3323
+ n.push(...o.keyCombos.map((a) => ({
3324
+ ...a,
3325
+ handler: (d) => {
3326
+ const h = o.type, u = this.createActivityEvent(d, h, t, s);
3327
+ i(u);
3328
+ }
3329
+ })));
3330
+ }), n;
3331
+ }
3332
+ /**
3333
+ * Creates a unified keyboard event handler that processes all shortcuts
3334
+ */
3335
+ createUnifiedHandler(t, e, i, s) {
3336
+ const n = this.createKeyboardHandlers(t, e, i, s);
3337
+ return (o) => {
3338
+ for (const a of n)
3339
+ if (this.match(o, [a])) {
3340
+ o.preventDefault(), o.stopPropagation(), a.handler(o);
3341
+ return;
3342
+ }
3343
+ };
3344
+ }
3345
+ }
3346
+ const $ = class $ extends X {
3050
3347
  constructor() {
3051
- super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
3348
+ 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 gi(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
3349
+ if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
3350
+ return !0;
3351
+ if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
3352
+ t.preventDefault();
3353
+ const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i ? e?.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
3354
+ type: "bulk_copy",
3355
+ timestamp: Date.now(),
3356
+ clipboardTypes: t.clipboardData?.types ? [...t.clipboardData.types] : [],
3357
+ selectedText: n ? {
3358
+ text: i,
3359
+ x: n.x,
3360
+ y: n.y,
3361
+ width: n.width,
3362
+ height: n.height
3363
+ } : void 0,
3364
+ selectionLength: i.length,
3365
+ targetFrameSrc: this.wnd.location.href
3366
+ };
3367
+ return this.comms?.send("content_protection", o), !1;
3368
+ }
3369
+ return !0;
3370
+ }, this.handleSelection = (t) => {
3371
+ if (!this.isSelectionMonitoringEnabled || !this.wnd || !this.selectionAnalyzer)
3372
+ return;
3373
+ const e = this.wnd.getSelection();
3374
+ if (e) {
3375
+ if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
3376
+ const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], d = {
3377
+ type: "suspicious_selection",
3378
+ timestamp: Date.now(),
3379
+ selectionLength: n.length,
3380
+ selectedText: {
3381
+ text: n,
3382
+ x: a?.x ?? 0,
3383
+ y: a?.y ?? 0,
3384
+ width: a?.width ?? 0,
3385
+ height: a?.height ?? 0
3386
+ },
3387
+ eventType: t?.type || "selectionchange",
3388
+ targetFrameSrc: this.wnd.location.href
3389
+ };
3390
+ this.comms?.send("content_protection", d);
3391
+ }
3392
+ } else
3393
+ this.currentSelection = null;
3394
+ }, this.onDragStart = (t) => {
3395
+ if (this.isDragAndDropEnabled) {
3396
+ t.preventDefault();
3397
+ const e = {
3398
+ type: "drag_detected",
3399
+ timestamp: Date.now(),
3400
+ dataTransferTypes: t.dataTransfer?.types ? [...t.dataTransfer.types] : [],
3401
+ targetFrameSrc: this.wnd.location.href
3402
+ };
3403
+ return this.comms?.send("content_protection", e), !1;
3404
+ } else
3405
+ return !0;
3406
+ }, this.onDrop = (t) => {
3407
+ if (this.isDragAndDropEnabled) {
3408
+ t.preventDefault();
3409
+ const e = t.dataTransfer, i = {
3410
+ type: "drop_detected",
3411
+ timestamp: Date.now(),
3412
+ dataTransferTypes: e?.types ? [...e.types] : [],
3413
+ fileCount: e?.files?.length || 0,
3414
+ targetFrameSrc: this.wnd.location.href
3415
+ };
3416
+ return this.comms?.send("content_protection", i), !1;
3417
+ } else
3418
+ return !0;
3419
+ }, this.onContext = (t) => {
3420
+ if (this.isContextMenuEnabled) {
3421
+ t.preventDefault();
3422
+ const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i && e?.rangeCount ? e.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
3423
+ timestamp: Date.now(),
3424
+ clientX: t.clientX,
3425
+ clientY: t.clientY,
3426
+ ...n && {
3427
+ selectedText: {
3428
+ text: i,
3429
+ x: n.x,
3430
+ y: n.y,
3431
+ width: n.width,
3432
+ height: n.height
3433
+ }
3434
+ },
3435
+ targetFrameSrc: this.wnd.location.href
3436
+ };
3437
+ this.comms?.send("context_menu", o);
3438
+ }
3439
+ }, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onClicker = this.onClick.bind(this);
3440
+ }
3441
+ addContextMenuPrevention() {
3442
+ this.isContextMenuEnabled || !this.wnd || (this.wnd.document.addEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !0);
3443
+ }
3444
+ removeContextMenuPrevention() {
3445
+ !this.isContextMenuEnabled || !this.wnd || (this.wnd.document.removeEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !1);
3446
+ }
3447
+ addDragAndDropPrevention() {
3448
+ this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
3449
+ }
3450
+ removeDragAndDropPrevention() {
3451
+ !this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
3452
+ }
3453
+ enableKeyboardPeripherals(t = []) {
3454
+ this.disableKeyboardPeripherals();
3455
+ const e = (i) => {
3456
+ this.comms?.send("keyboard_peripherals", i);
3457
+ };
3458
+ this.keyDownHandler = this.keyManager.createUnifiedHandler(this.wnd.location.href, t, e, this.wnd), this.wnd && this.wnd.document.addEventListener("keydown", this.keyDownHandler, {
3459
+ capture: !0
3460
+ });
3461
+ }
3462
+ disableKeyboardPeripherals() {
3463
+ this.wnd && this.keyDownHandler && (this.wnd.document.removeEventListener("keydown", this.keyDownHandler, {
3464
+ capture: !0
3465
+ }), this.keyDownHandler = null);
3466
+ }
3467
+ addBulkCopyProtection(t = {}) {
3468
+ if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
3469
+ const e = ui, i = t ? { ...e, ...t } : e;
3470
+ this.bulkCopyProtector = new mi(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
3471
+ }
3472
+ removeBulkCopyProtection() {
3473
+ !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);
3474
+ }
3475
+ addSelectionMonitoring(t) {
3476
+ if (this.isSelectionMonitoringEnabled || !this.wnd) return;
3477
+ const e = t || Re;
3478
+ this.selectionAnalyzer = new fi(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
3479
+ }
3480
+ removeSelectionMonitoring() {
3481
+ !this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
3052
3482
  }
3053
3483
  onPointUp(t) {
3054
3484
  const e = this.wnd.getSelection();
@@ -3078,7 +3508,7 @@ const Mt = class Mt extends tt {
3078
3508
  y: t.clientY * i,
3079
3509
  targetFrameSrc: this.wnd.location.href,
3080
3510
  targetElement: t.target.outerHTML,
3081
- interactiveElement: xe(t.target)?.outerHTML,
3511
+ interactiveElement: Ne(t.target)?.outerHTML,
3082
3512
  cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
3083
3513
  }), this.pointerMoved = !1;
3084
3514
  }
@@ -3092,9 +3522,6 @@ const Mt = class Mt extends tt {
3092
3522
  onPointDown() {
3093
3523
  this.pointerMoved = !1;
3094
3524
  }
3095
- onContext(t) {
3096
- this.onPointUp(t), this.pointerMoved = !1;
3097
- }
3098
3525
  onClick(t) {
3099
3526
  if (t.preventDefault(), !t.isTrusted) {
3100
3527
  const e = new PointerEvent("pointerup", {
@@ -3107,16 +3534,40 @@ const Mt = class Mt extends tt {
3107
3534
  Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
3108
3535
  }
3109
3536
  }
3537
+ registerProtectionHandlers() {
3538
+ this.comms?.register("peripherals_protection", $.moduleName, (t, e) => {
3539
+ const i = t;
3540
+ if (!this.configApplied) {
3541
+ if (this.configApplied = !0, i.monitorSelection) {
3542
+ const s = typeof i.monitorSelection == "boolean" ? void 0 : i.monitorSelection;
3543
+ this.addSelectionMonitoring(s), this.comms?.log("Selection monitoring enabled");
3544
+ }
3545
+ typeof i.protectCopy == "object" ? (this.addBulkCopyProtection({
3546
+ enabled: !0,
3547
+ ...i.protectCopy
3548
+ }), this.comms?.log("Copy protection enabled (limited)")) : i.protectCopy === !0 && (this.addBulkCopyProtection({
3549
+ enabled: !0,
3550
+ maxSelectionPercent: 0,
3551
+ minThreshold: 0,
3552
+ absoluteMaxChars: 0
3553
+ }), 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"));
3554
+ }
3555
+ e(!0);
3556
+ }), this.comms?.register("keyboard_peripherals", $.moduleName, (t, e) => {
3557
+ const i = t;
3558
+ i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
3559
+ });
3560
+ }
3110
3561
  mount(t, e) {
3111
- return this.wnd = t, this.comms = e, t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("contextmenu", this.onContextMenu), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
3562
+ 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;
3112
3563
  }
3113
3564
  unmount(t, e) {
3114
- return t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("contextmenu", this.onContextMenu), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.log("Peripherals Unmounted"), !0;
3565
+ 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($.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
3115
3566
  }
3116
3567
  };
3117
- Mt.moduleName = "peripherals";
3118
- let St = Mt;
3119
- const J = class J extends tt {
3568
+ $.moduleName = "peripherals";
3569
+ let Tt = $;
3570
+ const tt = class tt extends X {
3120
3571
  constructor() {
3121
3572
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
3122
3573
  }
@@ -3166,7 +3617,7 @@ const J = class J extends tt {
3166
3617
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3167
3618
  value: {
3168
3619
  name: "readium-ts-toolkit",
3169
- version: "2.2.5",
3620
+ version: "2.3.0",
3170
3621
  hasFeature: (s, n = "") => {
3171
3622
  switch (s) {
3172
3623
  case "dom-manipulation":
@@ -3191,11 +3642,11 @@ const J = class J extends tt {
3191
3642
  writable: !1
3192
3643
  }), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
3193
3644
  s.cancel(), this.allAnimations.add(s);
3194
- }), e.register("activate", J.moduleName, (s, n) => {
3645
+ }), e.register("activate", tt.moduleName, (s, n) => {
3195
3646
  this.allAnimations.forEach((o) => {
3196
3647
  o.cancel(), o.play();
3197
3648
  }), n(!0);
3198
- }), e.register("unfocus", J.moduleName, (s, n) => {
3649
+ }), e.register("unfocus", tt.moduleName, (s, n) => {
3199
3650
  this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
3200
3651
  });
3201
3652
  const i = t.document.querySelectorAll("audio,video");
@@ -3213,46 +3664,46 @@ const J = class J extends tt {
3213
3664
  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;
3214
3665
  }
3215
3666
  };
3216
- J.moduleName = "setup";
3217
- let ct = J;
3218
- const he = "readium-viewport", M = class M extends ct {
3667
+ tt.moduleName = "setup";
3668
+ let ut = tt;
3669
+ const me = "readium-viewport", M = class M extends ut {
3219
3670
  onViewportWidthChanged(t) {
3220
3671
  const e = t.target;
3221
- Q(e, "--RS__viewportWidth", `${e.innerWidth}px`);
3672
+ it(e, "--RS__viewportWidth", `${e.innerWidth}px`);
3222
3673
  }
3223
3674
  mount(t, e) {
3224
3675
  if (!super.mount(t, e)) return !1;
3225
3676
  const i = t.document.createElement("meta");
3226
- return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", he), i.setAttribute(
3677
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", me), i.setAttribute(
3227
3678
  "content",
3228
3679
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
3229
3680
  ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3230
3681
  target: t
3231
3682
  }), e.register("get_properties", M.moduleName, (s, n) => {
3232
- zt(t), n(!0);
3683
+ Wt(t), n(!0);
3233
3684
  }), e.register("update_properties", M.moduleName, (s, n) => {
3234
- s["--RS__viewportWidth"] = `${t.innerWidth}px`, Ae(t, s), n(!0);
3685
+ s["--RS__viewportWidth"] = `${t.innerWidth}px`, xe(t, s), n(!0);
3235
3686
  }), e.register("set_property", M.moduleName, (s, n) => {
3236
3687
  const o = s;
3237
- Q(t, o[0], o[1]), n(!0);
3688
+ it(t, o[0], o[1]), n(!0);
3238
3689
  }), e.register("remove_property", M.moduleName, (s, n) => {
3239
- ut(t, s), n(!0);
3690
+ mt(t, s), n(!0);
3240
3691
  }), e.register("activate", M.moduleName, (s, n) => {
3241
3692
  this.unblock(t), n(!0);
3242
3693
  }), e.log("ReflowableSetup Mounted"), !0;
3243
3694
  }
3244
3695
  unmount(t, e) {
3245
- return e.unregisterAll(M.moduleName), t.document.head.querySelector(`#${he}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
3696
+ return e.unregisterAll(M.moduleName), t.document.head.querySelector(`#${me}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
3246
3697
  }
3247
3698
  };
3248
3699
  M.moduleName = "reflowable_setup";
3249
- let xt = M;
3250
- const ue = "readium-fixed-style", z = class z extends ct {
3700
+ let Pt = M;
3701
+ const fe = "readium-fixed-style", D = class D extends ut {
3251
3702
  mount(t, e) {
3252
3703
  if (!super.mount(t, e)) return !1;
3253
3704
  t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
3254
3705
  const i = t.document.createElement("style");
3255
- return i.id = ue, i.dataset.readium = "true", i.textContent = `
3706
+ return i.id = fe, i.dataset.readium = "true", i.textContent = `
3256
3707
  html, body {
3257
3708
  text-size-adjust: none;
3258
3709
  -ms-text-size-adjust: none;
@@ -3264,13 +3715,13 @@ const ue = "readium-fixed-style", z = class z extends ct {
3264
3715
  min-height: 100%;
3265
3716
 
3266
3717
  /*cursor: var() TODO*/
3267
- }`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s, n) => {
3718
+ }`, t.document.head.appendChild(i), e.register("set_property", D.moduleName, (s, n) => {
3268
3719
  const o = s;
3269
- Q(t, o[0], o[1]), n(!0);
3270
- }), e.register("remove_property", z.moduleName, (s, n) => {
3271
- ut(t, s), n(!0);
3272
- }), e.register("first_visible_locator", z.moduleName, (s, n) => n(!1)), e.register("unfocus", z.moduleName, (s, n) => {
3273
- S(t), n(!0);
3720
+ it(t, o[0], o[1]), n(!0);
3721
+ }), e.register("remove_property", D.moduleName, (s, n) => {
3722
+ mt(t, s), n(!0);
3723
+ }), e.register("first_visible_locator", D.moduleName, (s, n) => n(!1)), e.register("unfocus", D.moduleName, (s, n) => {
3724
+ A(t), n(!0);
3274
3725
  }), e.register([
3275
3726
  "focus",
3276
3727
  "go_next",
@@ -3280,17 +3731,17 @@ const ue = "readium-fixed-style", z = class z extends ct {
3280
3731
  "go_start",
3281
3732
  "go_text",
3282
3733
  "go_progression"
3283
- ], z.moduleName, (s, n) => n(!0)), e.register("activate", z.moduleName, (s, n) => {
3734
+ ], D.moduleName, (s, n) => n(!0)), e.register("activate", D.moduleName, (s, n) => {
3284
3735
  this.unblock(t), n(!0);
3285
3736
  }), e.log("FixedSetup Mounted"), !0;
3286
3737
  }
3287
3738
  unmount(t, e) {
3288
- return e.unregisterAll(z.moduleName), t.document.getElementById(ue)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
3739
+ return e.unregisterAll(D.moduleName), t.document.getElementById(fe)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
3289
3740
  }
3290
3741
  };
3291
- z.moduleName = "fixed_setup";
3292
- let Tt = z;
3293
- const W = class W extends tt {
3742
+ D.moduleName = "fixed_setup";
3743
+ let Nt = D;
3744
+ const k = class k extends X {
3294
3745
  wndOnErr(t) {
3295
3746
  this.comms?.send("error", {
3296
3747
  message: t.message,
@@ -3304,58 +3755,100 @@ const W = class W extends tt {
3304
3755
  "error",
3305
3756
  this.wndOnErr,
3306
3757
  !1
3307
- ), e.register("get_properties", W.moduleName, (i, s) => {
3308
- zt(t), s(!0);
3309
- }), e.register("update_properties", W.moduleName, (i, s) => {
3310
- Ae(t, i), s(!0);
3311
- }), e.register("set_property", W.moduleName, (i, s) => {
3758
+ ), e.register("get_properties", k.moduleName, (i, s) => {
3759
+ Wt(t), s(!0);
3760
+ }), e.register("update_properties", k.moduleName, (i, s) => {
3761
+ xe(t, i), s(!0);
3762
+ }), e.register("set_property", k.moduleName, (i, s) => {
3312
3763
  const n = i;
3313
- Q(t, n[0], n[1]), s(!0);
3314
- }), e.register("remove_property", W.moduleName, (i, s) => {
3315
- ut(t, i), s(!0);
3316
- }), e.register("activate", W.moduleName, (i, s) => {
3764
+ it(t, n[0], n[1]), s(!0);
3765
+ }), e.register("remove_property", k.moduleName, (i, s) => {
3766
+ mt(t, i), s(!0);
3767
+ }), e.register("activate", k.moduleName, (i, s) => {
3317
3768
  s(!0);
3318
3769
  }), e.log("WebPubSetup Mounted"), !0;
3319
3770
  }
3320
3771
  unmount(t, e) {
3321
- return e.unregisterAll(W.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
3772
+ return e.unregisterAll(k.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
3322
3773
  }
3323
3774
  };
3324
- W.moduleName = "webpub_setup";
3325
- let Ct = W;
3326
- const ai = [
3775
+ k.moduleName = "webpub_setup";
3776
+ let Lt = k;
3777
+ const et = class et extends X {
3778
+ constructor() {
3779
+ super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
3780
+ }
3781
+ setupPrintProtection(t, e) {
3782
+ if (!e.disable) return;
3783
+ const i = t.document.createElement("style");
3784
+ i.textContent = `
3785
+ @media print {
3786
+ body * {
3787
+ display: none !important;
3788
+ }
3789
+ body::after {
3790
+ content: "${e.watermark || "Printing has been disabled"}";
3791
+ font-size: 200%;
3792
+ display: block;
3793
+ text-align: center;
3794
+ margin-top: 50vh;
3795
+ transform: translateY(-50%);
3796
+ }
3797
+ }
3798
+ `, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
3799
+ }
3800
+ registerPrintHandlers() {
3801
+ this.comms?.register("print_protection", et.moduleName, (t) => {
3802
+ const e = t;
3803
+ return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
3804
+ });
3805
+ }
3806
+ mount(t, e) {
3807
+ return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
3808
+ }
3809
+ unmount(t, e) {
3810
+ 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(et.moduleName), this.configApplied = !1, !0;
3811
+ }
3812
+ };
3813
+ et.moduleName = "print_protection";
3814
+ let Ot = et;
3815
+ const yi = [
3327
3816
  "fixed_setup",
3328
3817
  "decorator",
3329
- "peripherals"
3330
- ], li = [
3818
+ "peripherals",
3819
+ "print_protection"
3820
+ ], bi = [
3331
3821
  "reflowable_setup",
3332
3822
  "decorator",
3333
3823
  "peripherals",
3334
3824
  "column_snapper",
3335
- "scroll_snapper"
3336
- ], ci = [
3825
+ "scroll_snapper",
3826
+ "print_protection"
3827
+ ], vi = [
3337
3828
  "webpub_setup",
3338
3829
  "webpub_snapper",
3339
3830
  "decorator",
3340
- "peripherals"
3341
- ], de = new Map([
3831
+ "peripherals",
3832
+ "print_protection"
3833
+ ], ge = new Map([
3342
3834
  // All modules go here
3343
- Tt,
3835
+ Nt,
3836
+ Pt,
3837
+ Lt,
3344
3838
  xt,
3345
- Ct,
3839
+ Tt,
3346
3840
  Et,
3347
- St,
3348
- yt,
3349
- wt,
3350
- At
3841
+ At,
3842
+ Ct,
3843
+ Ot
3351
3844
  ].map((r) => [r.moduleName, r]));
3352
- class hi {
3845
+ class wi {
3353
3846
  /**
3354
3847
  * @param wnd Window instance to operate on
3355
3848
  * @param initialModules List of initial modules to load
3356
3849
  */
3357
3850
  constructor(t = window, e = []) {
3358
- this.loadedModules = [], this.wnd = t, this.comms = new Oe(t);
3851
+ this.loadedModules = [], this.wnd = t, this.comms = new ze(t);
3359
3852
  const i = [...new Set(e)];
3360
3853
  if (i.length) {
3361
3854
  if (typeof t > "u")
@@ -3368,7 +3861,7 @@ class hi {
3368
3861
  }
3369
3862
  }
3370
3863
  loadModule(t) {
3371
- const e = de.get(t);
3864
+ const e = ge.get(t);
3372
3865
  return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
3373
3866
  }
3374
3867
  /**
@@ -3386,7 +3879,7 @@ class hi {
3386
3879
  * @returns Success
3387
3880
  */
3388
3881
  removeModule(t) {
3389
- const e = de.get(t);
3882
+ const e = ge.get(t);
3390
3883
  if (e === void 0)
3391
3884
  return this.comms.log(`Module "${t}" does not exist in the library`), !1;
3392
3885
  const i = this.loadedModules.findIndex((s) => s instanceof e);
@@ -3399,18 +3892,84 @@ class hi {
3399
3892
  this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
3400
3893
  }
3401
3894
  }
3895
+ const Si = {
3896
+ type: "developer_tools",
3897
+ keyCombos: [
3898
+ { keyCode: 73, meta: !0, alt: !0 },
3899
+ // I key
3900
+ { keyCode: 74, meta: !0, alt: !0 },
3901
+ // J key
3902
+ { keyCode: 85, meta: !0, alt: !0 },
3903
+ // U key
3904
+ { keyCode: 67, meta: !0, alt: !0 },
3905
+ // C key
3906
+ { keyCode: 67, meta: !0, shift: !0 },
3907
+ // C key (Cmd+Shift+C)
3908
+ { keyCode: 67, ctrl: !0, shift: !0 },
3909
+ // C key (Ctrl+Shift+C)
3910
+ { keyCode: 123 },
3911
+ // F12
3912
+ { keyCode: 123, shift: !0 },
3913
+ // F12+Shift
3914
+ { keyCode: 123, ctrl: !0, shift: !0 },
3915
+ // F12+Ctrl+Shift
3916
+ { keyCode: 123, meta: !0, alt: !0 }
3917
+ // F12+Meta+Alt
3918
+ ]
3919
+ }, Ei = {
3920
+ type: "select_all",
3921
+ keyCombos: [
3922
+ { keyCode: 65, meta: !0 },
3923
+ // A key (Cmd+A)
3924
+ { keyCode: 65, ctrl: !0 }
3925
+ // A key (Ctrl+A)
3926
+ ]
3927
+ }, Ai = {
3928
+ type: "print",
3929
+ keyCombos: [
3930
+ { keyCode: 80, meta: !0 },
3931
+ // P key (Cmd+P)
3932
+ { keyCode: 80, ctrl: !0 },
3933
+ // P key (Ctrl+P)
3934
+ { keyCode: 80, meta: !0, shift: !0 },
3935
+ // P key (Cmd+Shift+P)
3936
+ { keyCode: 80, ctrl: !0, shift: !0 },
3937
+ // P key (Ctrl+Shift+P)
3938
+ { keyCode: 80, meta: !0, alt: !0 },
3939
+ // P key (Cmd+Alt+P)
3940
+ { keyCode: 80, ctrl: !0, alt: !0 }
3941
+ // P key (Ctrl+Alt+P)
3942
+ ]
3943
+ }, Ci = {
3944
+ type: "save",
3945
+ keyCombos: [
3946
+ { keyCode: 83, meta: !0 },
3947
+ // S key (Cmd+S)
3948
+ { keyCode: 83, ctrl: !0 }
3949
+ // S key (Ctrl+S)
3950
+ ]
3951
+ };
3402
3952
  export {
3403
- Y as COMMS_VERSION,
3404
- Oe as Comms,
3405
- yt as Decorator,
3406
- ai as FXLModules,
3407
- Je as Layout,
3408
- hi as Loader,
3409
- tt as Module,
3410
- de as ModuleLibrary,
3411
- St as Peripherals,
3412
- li as ReflowableModules,
3413
- ci as WebPubModules,
3414
- Ze as Width,
3415
- Ne as mid
3953
+ mi as BulkCopyProtector,
3954
+ K as COMMS_VERSION,
3955
+ ze as Comms,
3956
+ Si as DEV_TOOLS,
3957
+ Et as Decorator,
3958
+ yi as FXLModules,
3959
+ gi as KeyCombinationManager,
3960
+ si as Layout,
3961
+ wi as Loader,
3962
+ X as Module,
3963
+ ge as ModuleLibrary,
3964
+ Ai as PRINT,
3965
+ Bt as PatternAnalyzer,
3966
+ Tt as Peripherals,
3967
+ Ot as PrintProtector,
3968
+ bi as ReflowableModules,
3969
+ Ci as SAVE,
3970
+ Ei as SELECT_ALL,
3971
+ fi as SelectionAnalyzer,
3972
+ vi as WebPubModules,
3973
+ ii as Width,
3974
+ De as mid
3416
3975
  };