@readium/navigator-html-injectables 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,66 +1,66 @@
1
- const dt = Math.pow(2, 32), Le = () => Math.round(Math.random() * dt).toString(36), pt = () => `${Math.round(performance.now())}-${Le()}-${Le()}`, k = 1;
2
- class ft {
3
- constructor(e) {
4
- this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
5
- }
6
- receive(e) {
7
- if (e.source === null) throw Error("Event source is null");
8
- if (typeof e.data != "object") return;
9
- const t = e.data;
10
- if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
11
- if (t.key === "_ping") {
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 {
3
+ constructor(t) {
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
+ }
6
+ receive(t) {
7
+ if (t.source === null) throw Error("Event source is null");
8
+ if (typeof t.data != "object") return;
9
+ const e = t.data;
10
+ if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
11
+ if (e.key === "_ping") {
12
12
  if (!this.destination) {
13
- if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== k) {
14
- t._readium > k ? this.send("error", `received comms version ${t._readium} higher than ${k}`) : this.send("error", `received comms version ${t._readium} lower than ${k}`), this.destination = null, this.origin = "", this.channelId = "";
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 = "";
15
15
  return;
16
16
  }
17
17
  this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
18
18
  }
19
19
  return;
20
20
  } else if (this.channelId) {
21
- if (t._channel !== this.channelId || e.origin !== this.origin) return;
21
+ if (e._channel !== this.channelId || t.origin !== this.origin) return;
22
22
  } else
23
23
  return;
24
- this.handle(t);
24
+ this.handle(e);
25
25
  }
26
26
  }
27
- handle(e) {
28
- const t = this.registrar.get(e.key);
29
- if (!t || t.length === 0) {
30
- e.strict && this.send("_unhandled", e);
27
+ handle(t) {
28
+ const e = this.registrar.get(t.key);
29
+ if (!e || e.length === 0) {
30
+ t.strict && this.send("_unhandled", t);
31
31
  return;
32
32
  }
33
- t.forEach((i) => i.cb(e.data, (r) => {
34
- this.send("_ack", r, e.id);
33
+ e.forEach((i) => i.cb(t.data, (s) => {
34
+ this.send("_ack", s, t.id);
35
35
  }));
36
36
  }
37
- register(e, t, i) {
38
- Array.isArray(e) || (e = [e]), e.forEach((r) => {
39
- const n = this.registrar.get(r);
37
+ register(t, e, i) {
38
+ Array.isArray(t) || (t = [t]), t.forEach((s) => {
39
+ const n = this.registrar.get(s);
40
40
  if (n && n.length >= 0) {
41
- if (n.find((a) => a.module === t)) throw new Error(`Trying to register another callback for combination of event ${r} and module ${t}`);
41
+ if (n.find((a) => a.module === e)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${e}`);
42
42
  n.push({
43
43
  cb: i,
44
- module: t
45
- }), this.registrar.set(r, n);
44
+ module: e
45
+ }), this.registrar.set(s, n);
46
46
  } else
47
- this.registrar.set(r, [{
47
+ this.registrar.set(s, [{
48
48
  cb: i,
49
- module: t
49
+ module: e
50
50
  }]);
51
51
  });
52
52
  }
53
- unregister(e, t) {
54
- Array.isArray(e) || (e = [e]), e.forEach((i) => {
55
- const r = this.registrar.get(i);
56
- !r || r.length === 0 || r.splice(r.findIndex((n) => n.module === t), 1);
53
+ unregister(t, e) {
54
+ Array.isArray(t) || (t = [t]), t.forEach((i) => {
55
+ const s = this.registrar.get(i);
56
+ !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === e), 1);
57
57
  });
58
58
  }
59
- unregisterAll(e) {
60
- this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((r) => r.module !== e)));
59
+ unregisterAll(t) {
60
+ this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((s) => s.module !== t)));
61
61
  }
62
- log(...e) {
63
- this.destination ? this.send("log", e) : this.preLog.push(e);
62
+ log(...t) {
63
+ this.destination ? this.send("log", t) : this.preLog.push(t);
64
64
  }
65
65
  get ready() {
66
66
  return !!this.destination;
@@ -68,53 +68,111 @@ class ft {
68
68
  destroy() {
69
69
  this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
70
70
  }
71
- send(e, t, i = void 0, r = []) {
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: k,
74
+ _readium: Y,
75
75
  _channel: this.channelId,
76
- id: i ?? pt(),
76
+ id: i ?? Ne(),
77
77
  // scrict,
78
- key: e,
79
- data: t
78
+ key: t,
79
+ data: e
80
80
  };
81
81
  try {
82
82
  this.destination.postMessage(n, {
83
83
  targetOrigin: this.origin,
84
- transfer: r
84
+ transfer: s
85
85
  });
86
86
  } catch (o) {
87
- if (r.length > 0) throw o;
88
- this.destination.postMessage(n, this.origin, r);
87
+ if (s.length > 0) throw o;
88
+ this.destination.postMessage(n, this.origin, s);
89
89
  }
90
90
  }
91
91
  }
92
- const N = class U {
93
- constructor(e) {
94
- if (typeof e == "string") {
95
- if (!U.VALID_MODES.has(e.toLowerCase()))
92
+ const b = class b {
93
+ constructor(t) {
94
+ this.uri = t;
95
+ }
96
+ /**
97
+ * Parses an [AccessibilityProfile] from its RWPM JSON representation.
98
+ */
99
+ static deserialize(t) {
100
+ if (!(!t || typeof t != "string"))
101
+ return new b(t);
102
+ }
103
+ /**
104
+ * Serializes an [AccessibilityProfile] to its RWPM JSON representation.
105
+ */
106
+ serialize() {
107
+ return this.uri;
108
+ }
109
+ /**
110
+ * Returns true if the profile is a WCAG Level A profile.
111
+ */
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;
114
+ }
115
+ /**
116
+ * Returns true if the profile is a WCAG Level AA profile.
117
+ */
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;
120
+ }
121
+ /**
122
+ * Returns true if the profile is a WCAG Level AAA profile.
123
+ */
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;
126
+ }
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;
130
+ const w = class w {
131
+ constructor(t) {
132
+ this.value = t;
133
+ }
134
+ /**
135
+ * Parses an [AccessMode] from its RWPM JSON representation.
136
+ */
137
+ static deserialize(t) {
138
+ if (!(!t || typeof t != "string"))
139
+ return new w(t);
140
+ }
141
+ /**
142
+ * Serializes an [AccessMode] to its RWPM JSON representation.
143
+ */
144
+ serialize() {
145
+ return this.value;
146
+ }
147
+ };
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;
150
+ const T = class T {
151
+ constructor(t) {
152
+ if (typeof t == "string") {
153
+ if (!T.VALID_MODES.has(t.toLowerCase()))
96
154
  return;
97
- this.value = e.toLowerCase();
155
+ this.value = t.toLowerCase();
98
156
  } else {
99
- const t = e.filter(
100
- (i) => U.VALID_MODES.has(i.toLowerCase())
157
+ const e = t.filter(
158
+ (i) => T.VALID_MODES.has(i.toLowerCase())
101
159
  );
102
- if (t.length === 0)
160
+ if (e.length === 0)
103
161
  return;
104
- this.value = Array.from(new Set(t));
162
+ this.value = Array.from(new Set(e));
105
163
  }
106
164
  }
107
165
  /**
108
166
  * Parses a [PrimaryAccessMode] from its RWPM JSON representation.
109
167
  */
110
- static deserialize(e) {
111
- if (!e) return;
112
- if (typeof e == "string")
113
- return new U(e);
114
- if (!Array.isArray(e)) return;
115
- const t = e.filter((i) => i ? U.VALID_MODES.has(i.toLowerCase()) : !1);
116
- if (t.length !== 0)
117
- return new U(t);
168
+ static deserialize(t) {
169
+ if (!t) return;
170
+ if (typeof t == "string")
171
+ return new T(t);
172
+ if (!Array.isArray(t)) return;
173
+ const e = t.filter((i) => i ? T.VALID_MODES.has(i.toLowerCase()) : !1);
174
+ if (e.length !== 0)
175
+ return new T(e);
118
176
  }
119
177
  /**
120
178
  * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
@@ -123,38 +181,190 @@ const N = class U {
123
181
  return this.value;
124
182
  }
125
183
  };
126
- N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
127
- class Te {
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;
186
+ const c = class c {
187
+ constructor(t) {
188
+ this.value = t;
189
+ }
190
+ /**
191
+ * Parses a [Feature] from its RWPM JSON representation.
192
+ */
193
+ static deserialize(t) {
194
+ if (!(!t || typeof t != "string"))
195
+ return new c(t);
196
+ }
197
+ /**
198
+ * Serializes a [Feature] to its RWPM JSON representation.
199
+ */
200
+ serialize() {
201
+ return this.value;
202
+ }
203
+ };
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 {
207
+ constructor(t) {
208
+ this.value = t;
209
+ }
210
+ /**
211
+ * Parses a [Hazard] from its RWPM JSON representation.
212
+ */
213
+ static deserialize(t) {
214
+ if (!(!t || typeof t != "string"))
215
+ return new A(t);
216
+ }
217
+ /**
218
+ * Serializes a [Hazard] to its RWPM JSON representation.
219
+ */
220
+ serialize() {
221
+ return this.value;
222
+ }
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;
226
+ const E = class E {
227
+ constructor(t) {
228
+ this.value = t;
229
+ }
230
+ /**
231
+ * Parses an [Exemption] from its RWPM JSON representation.
232
+ */
233
+ static deserialize(t) {
234
+ if (!(!t || typeof t != "string"))
235
+ return new E(t);
236
+ }
237
+ /**
238
+ * Serializes an [Exemption] to its RWPM JSON representation.
239
+ */
240
+ serialize() {
241
+ return this.value;
242
+ }
243
+ };
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 = {
249
+ fr: () => import("./fr-C5HEel98.js"),
250
+ ar: () => import("./ar-DyHX_uy2.js"),
251
+ da: () => import("./da-Dct0PS3E.js"),
252
+ // 'el': () => import('@edrlab/thorium-locales/publication-metadata/el.json'),
253
+ // 'et': () => import('@edrlab/thorium-locales/publication-metadata/et.json'),
254
+ it: () => import("./it-DFOBoXGy.js"),
255
+ pt_PT: () => import("./pt_PT-Di3sVjze.js"),
256
+ sv: () => import("./sv-BfzAFsVN.js")
257
+ // 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
258
+ // 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
259
+ }, $t = Le?.publication?.metadata?.accessibility?.["display-guide"] || {};
260
+ class F {
261
+ constructor() {
262
+ this.currentLocaleCode = "en", this.locale = $t, this.loadedLocales = {}, this.loadedLocales.en = $t;
263
+ }
264
+ static getInstance() {
265
+ return F.instance || (F.instance = new F()), F.instance;
266
+ }
267
+ /**
268
+ * Loads a locale dynamically
269
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr')
270
+ * @returns Promise indicating if the locale was loaded successfully
271
+ */
272
+ async loadLocale(t) {
273
+ if (!Vt.includes(t))
274
+ return console.warn(`Locale '${t}' is not enabled`), !1;
275
+ if (t in this.loadedLocales)
276
+ return !0;
277
+ try {
278
+ if (!(t in Ft))
279
+ return console.warn(`Locale file not found for: ${t}`), !1;
280
+ const s = (await Ft[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
281
+ return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
282
+ } catch (e) {
283
+ return console.warn(`Failed to load locale ${t}:`, e), !1;
284
+ }
285
+ }
286
+ /**
287
+ * Registers a new locale or updates an existing one
288
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr-FR')
289
+ * @param localeData The locale data to register
290
+ */
291
+ registerLocale(t, e) {
292
+ if (!t || typeof t != "string")
293
+ throw new Error("Locale code must be a non-empty string");
294
+ this.loadedLocales[t] = e;
295
+ }
296
+ /**
297
+ * Sets the current locale by language code, loading it dynamically if needed
298
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr')
299
+ * @returns Promise indicating if the locale was set successfully
300
+ */
301
+ async setLocale(t) {
302
+ return t in this.loadedLocales || await this.loadLocale(t), t in this.loadedLocales ? (this.locale = this.loadedLocales[t], this.currentLocaleCode = t, !0) : (console.warn(`Locale '${t}' is not available`), !1);
303
+ }
304
+ /**
305
+ * Gets the current locale code (BCP 47)
306
+ */
307
+ getCurrentLocale() {
308
+ return this.currentLocaleCode;
309
+ }
310
+ /**
311
+ * Gets a list of available locale codes
312
+ */
313
+ getAvailableLocales() {
314
+ return Vt;
315
+ }
316
+ getNestedValue(t, e) {
317
+ const i = e.split(".");
318
+ let s = t;
319
+ for (const n of i) {
320
+ if (s == null)
321
+ return;
322
+ s = s[n];
323
+ }
324
+ return s;
325
+ }
326
+ /**
327
+ * Gets a localized string by key
328
+ * @param key The key for the string to retrieve
329
+ * @returns The localized string as a [L10nString], or an empty string if not found
330
+ */
331
+ getString(t) {
332
+ let e = this.getNestedValue(this.locale, t);
333
+ return e === void 0 && this.currentLocaleCode !== "en" && (e = this.getNestedValue(this.loadedLocales.en, t)), e !== void 0 ? typeof e == "string" ? { compact: e, descriptive: e } : e : (console.warn(`Missing localization for key: ${t}`), { compact: "", descriptive: "" });
334
+ }
335
+ }
336
+ F.getInstance();
337
+ class Nt {
128
338
  /**
129
339
  * Creates a [Encryption].
130
340
  */
131
- constructor(e) {
132
- this.algorithm = e.algorithm, this.compression = e.compression, this.originalLength = e.originalLength, this.profile = e.profile, this.scheme = e.scheme;
341
+ constructor(t) {
342
+ this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
133
343
  }
134
344
  /**
135
345
  * Parses a [Encryption] from its RWPM JSON representation.
136
346
  */
137
- static deserialize(e) {
138
- if (e && e.algorithm)
139
- return new Te({
140
- algorithm: e.algorithm,
141
- compression: e.compression,
142
- originalLength: e.originalLength,
143
- profile: e.profile,
144
- scheme: e.scheme
347
+ static deserialize(t) {
348
+ if (t && t.algorithm)
349
+ return new Nt({
350
+ algorithm: t.algorithm,
351
+ compression: t.compression,
352
+ originalLength: t.originalLength,
353
+ profile: t.profile,
354
+ scheme: t.scheme
145
355
  });
146
356
  }
147
357
  /**
148
358
  * Serializes a [Encryption] to its RWPM JSON representation.
149
359
  */
150
360
  serialize() {
151
- const e = { algorithm: this.algorithm };
152
- return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
361
+ const t = { algorithm: this.algorithm };
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;
153
363
  }
154
364
  }
155
- class C {
156
- constructor(e) {
157
- this.otherProperties = e;
365
+ class I {
366
+ constructor(t) {
367
+ this.otherProperties = t;
158
368
  }
159
369
  get page() {
160
370
  return this.otherProperties.page;
@@ -162,9 +372,9 @@ class C {
162
372
  /**
163
373
  * Creates a [Properties] from its RWPM JSON representation.
164
374
  */
165
- static deserialize(e) {
166
- if (e)
167
- return new C(e);
375
+ static deserialize(t) {
376
+ if (t)
377
+ return new I(t);
168
378
  }
169
379
  /**
170
380
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -175,75 +385,75 @@ class C {
175
385
  /**
176
386
  * Makes a copy of this [Properties] after merging in the given additional other [properties].
177
387
  */
178
- add(e) {
179
- const t = Object.assign({}, this.otherProperties);
180
- for (const i in e)
181
- t[i] = e[i];
182
- return new C(t);
388
+ add(t) {
389
+ const e = Object.assign({}, this.otherProperties);
390
+ for (const i in t)
391
+ e[i] = t[i];
392
+ return new I(e);
183
393
  }
184
394
  }
185
- Object.defineProperty(C.prototype, "encryption", {
395
+ Object.defineProperty(I.prototype, "encryption", {
186
396
  get: function() {
187
- return Te.deserialize(this.otherProperties.encrypted);
397
+ return Nt.deserialize(this.otherProperties.encrypted);
188
398
  }
189
399
  });
190
- function mt(s) {
191
- return s && Array.isArray(s) ? s : void 0;
400
+ function Ie(r) {
401
+ return r && Array.isArray(r) ? r : void 0;
192
402
  }
193
- function Qe(s) {
194
- return s && typeof s == "string" ? [s] : mt(s);
403
+ function pe(r) {
404
+ return r && typeof r == "string" ? [r] : Ie(r);
195
405
  }
196
- function Re(s) {
197
- return typeof s == "string" ? new Date(s) : void 0;
406
+ function Yt(r) {
407
+ return typeof r == "string" ? new Date(r) : void 0;
198
408
  }
199
- function Q(s) {
200
- return isNaN(s) ? void 0 : s;
409
+ function rt(r) {
410
+ return isNaN(r) ? void 0 : r;
201
411
  }
202
- function S(s) {
203
- return Q(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
412
+ function L(r) {
413
+ return rt(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
204
414
  }
205
- function gt(s) {
206
- const e = new Array();
207
- return s.forEach((t) => e.push(t)), e;
415
+ function Re(r) {
416
+ const t = new Array();
417
+ return r.forEach((e) => t.push(e)), t;
208
418
  }
209
419
  class l {
210
420
  /** Creates a MediaType object. */
211
- constructor(e) {
212
- let t, i, r = e.mediaType.replace(/\s/g, "").split(";");
213
- const n = r[0].split("/");
421
+ constructor(t) {
422
+ let e, i, s = t.mediaType.replace(/\s/g, "").split(";");
423
+ const n = s[0].split("/");
214
424
  if (n.length === 2) {
215
- if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
425
+ if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
216
426
  throw new Error("Invalid media type");
217
427
  } else
218
428
  throw new Error("Invalid media type");
219
429
  const o = {};
220
- for (let d = 1; d < r.length; d++) {
221
- const y = r[d].split("=");
430
+ for (let p = 1; p < s.length; p++) {
431
+ const y = s[p].split("=");
222
432
  if (y.length === 2) {
223
- const p = y[0].toLocaleLowerCase(), f = p === "charset" ? y[1].toUpperCase() : y[1];
224
- o[p] = f;
433
+ const f = y[0].toLocaleLowerCase(), m = f === "charset" ? y[1].toUpperCase() : y[1];
434
+ o[f] = m;
225
435
  }
226
436
  }
227
- const a = {}, u = Object.keys(o);
228
- u.sort((d, y) => d.localeCompare(y)), u.forEach((d) => a[d] = o[d]);
437
+ const a = {}, d = Object.keys(o);
438
+ d.sort((p, y) => p.localeCompare(y)), d.forEach((p) => a[p] = o[p]);
229
439
  let h = "";
230
- for (const d in a) {
231
- const y = a[d];
232
- h += `;${d}=${y}`;
440
+ for (const p in a) {
441
+ const y = a[p];
442
+ h += `;${p}=${y}`;
233
443
  }
234
- const c = `${t}/${i}${h}`, m = a.encoding;
235
- this.string = c, this.type = t, this.subtype = i, this.parameters = a, this.encoding = m, this.name = e.name, this.fileExtension = e.fileExtension;
444
+ const u = `${e}/${i}${h}`, g = a.encoding;
445
+ this.string = u, this.type = e, this.subtype = i, this.parameters = a, this.encoding = g, this.name = t.name, this.fileExtension = t.fileExtension;
236
446
  }
237
- static parse(e) {
238
- return new l(e);
447
+ static parse(t) {
448
+ return new l(t);
239
449
  }
240
450
  /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
241
451
  * Gives a hint on the underlying structure of this media type.
242
452
  * See. https://tools.ietf.org/html/rfc6838#section-4.2.8
243
453
  */
244
454
  get structuredSyntaxSuffix() {
245
- const e = this.subtype.split("+");
246
- return e.length > 1 ? `+${e[e.length - 1]}` : void 0;
455
+ const t = this.subtype.split("+");
456
+ return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
247
457
  }
248
458
  /** Parameter values might or might not be case-sensitive, depending on the semantics of
249
459
  * the parameter name.
@@ -264,17 +474,17 @@ class l {
264
474
  * - Order of parameters is ignored.
265
475
  * - Wildcards are supported, meaning that `image/*` contains `image/png`
266
476
  */
267
- contains(e) {
268
- const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
269
- if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
477
+ contains(t) {
478
+ const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
479
+ if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
270
480
  return !1;
271
481
  const i = new Set(
272
482
  Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
273
- ), r = new Set(
274
- Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
483
+ ), s = new Set(
484
+ Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
275
485
  );
276
486
  for (const n of Array.from(i.values()))
277
- if (!r.has(n))
487
+ if (!s.has(n))
278
488
  return !1;
279
489
  return !0;
280
490
  }
@@ -283,22 +493,22 @@ class l {
283
493
  * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
284
494
  * doesn't. This is basically like `contains`, but working in both direction.
285
495
  */
286
- matches(e) {
287
- const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
288
- return this.contains(t) || t.contains(this);
496
+ matches(t) {
497
+ const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
498
+ return this.contains(e) || e.contains(this);
289
499
  }
290
500
  /**
291
501
  * Returns whether this media type matches any of the [others] media types.
292
502
  */
293
- matchesAny(...e) {
294
- for (const t of e)
295
- if (this.matches(t))
503
+ matchesAny(...t) {
504
+ for (const e of t)
505
+ if (this.matches(e))
296
506
  return !0;
297
507
  return !1;
298
508
  }
299
509
  /** Checks the MediaType equals another one (comparing their string) */
300
- equals(e) {
301
- return this.string === e.string;
510
+ equals(t) {
511
+ return this.string === t.string;
302
512
  }
303
513
  /** Returns whether this media type is structured as a ZIP archive. */
304
514
  get isZIP() {
@@ -661,60 +871,60 @@ class l {
661
871
  });
662
872
  }
663
873
  }
664
- class Ie {
665
- constructor(e) {
666
- this.uri = e, this.parameters = this.getParameters(e);
874
+ class qt {
875
+ constructor(t) {
876
+ this.uri = t, this.parameters = this.getParameters(t);
667
877
  }
668
878
  /**
669
879
  * List of URI template parameter keys, if the [Link] is templated.
670
880
  */
671
- getParameters(e) {
672
- const t = /\{\??([^}]+)\}/g, i = e.match(t);
881
+ getParameters(t) {
882
+ const e = /\{\??([^}]+)\}/g, i = t.match(e);
673
883
  return i ? new Set(
674
- i.join(",").replace(t, "$1").split(",").map((r) => r.trim())
884
+ i.join(",").replace(e, "$1").split(",").map((s) => s.trim())
675
885
  ) : /* @__PURE__ */ new Set();
676
886
  }
677
887
  /** Expands the URI by replacing the template variables by the given parameters.
678
888
  * Any extra parameter is appended as query parameters.
679
889
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
680
890
  */
681
- expand(e) {
682
- const t = (r) => r.split(",").map((n) => {
683
- const o = e[n];
891
+ expand(t) {
892
+ const e = (s) => s.split(",").map((n) => {
893
+ const o = t[n];
684
894
  return o ? encodeURIComponent(o) : "";
685
- }).join(","), i = (r) => "?" + r.split(",").map((n) => {
686
- const o = n.split("=")[0], a = e[o];
895
+ }).join(","), i = (s) => "?" + s.split(",").map((n) => {
896
+ const o = n.split("=")[0], a = t[o];
687
897
  return a ? `${o}=${encodeURIComponent(a)}` : "";
688
898
  }).join("&");
689
- return this.uri.replace(/\{(\??)([^}]+)\}/g, (...r) => r[1] ? i(r[2]) : t(r[2]));
899
+ return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
690
900
  }
691
901
  }
692
- class b {
902
+ class x {
693
903
  /**
694
904
  * Creates a [Locations].
695
905
  */
696
- constructor(e) {
697
- this.fragments = e.fragments ? e.fragments : new Array(), this.progression = e.progression, this.totalProgression = e.totalProgression, this.position = e.position, this.otherLocations = e.otherLocations;
906
+ constructor(t) {
907
+ this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
698
908
  }
699
909
  /**
700
910
  * Parses a [Locations] from its RWPM JSON representation.
701
911
  */
702
- static deserialize(e) {
703
- if (!e) return;
704
- const t = Q(e.progression), i = Q(e.totalProgression), r = Q(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
912
+ static deserialize(t) {
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([
705
915
  "fragment",
706
916
  "fragments",
707
917
  "progression",
708
918
  "totalProgression",
709
919
  "position"
710
920
  ]);
711
- return Object.entries(e).forEach(([a, u]) => {
712
- o.has(a) || n.set(a, u);
713
- }), new b({
714
- fragments: Qe(e.fragments || e.fragment),
715
- progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
921
+ return Object.entries(t).forEach(([a, d]) => {
922
+ o.has(a) || n.set(a, d);
923
+ }), new x({
924
+ fragments: pe(t.fragments || t.fragment),
925
+ progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
716
926
  totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
717
- position: r !== void 0 && r > 0 ? r : void 0,
927
+ position: s !== void 0 && s > 0 ? s : void 0,
718
928
  otherLocations: n.size === 0 ? void 0 : n
719
929
  });
720
930
  }
@@ -722,111 +932,111 @@ class b {
722
932
  * Serializes a [Locations] to its RWPM JSON representation.
723
933
  */
724
934
  serialize() {
725
- const e = {};
726
- return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
935
+ const t = {};
936
+ return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
727
937
  }
728
938
  }
729
- class D {
939
+ class H {
730
940
  /**
731
941
  * Creates a [Text].
732
942
  */
733
- constructor(e) {
734
- this.after = e.after, this.before = e.before, this.highlight = e.highlight;
943
+ constructor(t) {
944
+ this.after = t.after, this.before = t.before, this.highlight = t.highlight;
735
945
  }
736
946
  /**
737
947
  * Parses a [Locations] from its RWPM JSON representation.
738
948
  */
739
- static deserialize(e) {
740
- if (e)
741
- return new D({
742
- after: e.after,
743
- before: e.before,
744
- highlight: e.highlight
949
+ static deserialize(t) {
950
+ if (t)
951
+ return new H({
952
+ after: t.after,
953
+ before: t.before,
954
+ highlight: t.highlight
745
955
  });
746
956
  }
747
957
  /**
748
958
  * Serializes a [Locations] to its RWPM JSON representation.
749
959
  */
750
960
  serialize() {
751
- const e = {};
752
- return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;
961
+ const t = {};
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;
753
963
  }
754
964
  }
755
- class R {
965
+ class U {
756
966
  /**
757
967
  * Creates a [Locator].
758
968
  */
759
- constructor(e) {
760
- this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new b({}), this.text = e.text;
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;
761
971
  }
762
972
  /**
763
973
  * Parses a [Link] from its RWPM JSON representation.
764
974
  */
765
- static deserialize(e) {
766
- if (e && e.href && e.type)
767
- return new R({
768
- href: e.href,
769
- type: e.type,
770
- title: e.title,
771
- locations: b.deserialize(e.locations),
772
- text: D.deserialize(e.text)
975
+ static deserialize(t) {
976
+ if (t && t.href && t.type)
977
+ return new U({
978
+ href: t.href,
979
+ type: t.type,
980
+ title: t.title,
981
+ locations: x.deserialize(t.locations),
982
+ text: H.deserialize(t.text)
773
983
  });
774
984
  }
775
985
  /**
776
986
  * Serializes a [Link] to its RWPM JSON representation.
777
987
  */
778
988
  serialize() {
779
- const e = { href: this.href, type: this.type };
780
- return this.title !== void 0 && (e.title = this.title), this.locations && (e.locations = this.locations.serialize()), this.text && (e.text = this.text.serialize()), e;
989
+ const t = { href: this.href, type: this.type };
990
+ return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
781
991
  }
782
992
  /**
783
993
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
784
994
  */
785
- copyWithLocations(e) {
786
- return new R({
995
+ copyWithLocations(t) {
996
+ return new U({
787
997
  href: this.href,
788
998
  type: this.type,
789
999
  title: this.title,
790
1000
  text: this.text,
791
- locations: new b({ ...this.locations, ...e })
1001
+ locations: new x({ ...this.locations, ...t })
792
1002
  });
793
1003
  }
794
1004
  }
795
- class H {
1005
+ class $ {
796
1006
  /**
797
1007
  * Creates a [Link].
798
1008
  */
799
- constructor(e) {
800
- this.href = e.href, this.templated = e.templated, this.type = e.type, this.title = e.title, this.rels = e.rels, this.properties = e.properties, this.height = e.height, this.width = e.width, this.size = e.size, this.duration = e.duration, this.bitrate = e.bitrate, this.languages = e.languages, this.alternates = e.alternates, this.children = e.children;
1009
+ constructor(t) {
1010
+ this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.size = t.size, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
801
1011
  }
802
1012
  /**
803
1013
  * Parses a [Link] from its RWPM JSON representation.
804
1014
  */
805
- static deserialize(e) {
806
- if (!(!e || typeof e.href != "string"))
807
- return new H({
808
- href: e.href,
809
- templated: e.templated,
810
- type: e.type,
811
- title: e.title,
812
- rels: e.rel ? Array.isArray(e.rel) ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
813
- properties: C.deserialize(e.properties),
814
- height: S(e.height),
815
- width: S(e.width),
816
- size: S(e.size),
817
- duration: S(e.duration),
818
- bitrate: S(e.bitrate),
819
- languages: Qe(e.language),
820
- alternates: ee.deserialize(e.alternate),
821
- children: ee.deserialize(e.children)
1015
+ static deserialize(t) {
1016
+ if (!(!t || typeof t.href != "string"))
1017
+ return new $({
1018
+ href: t.href,
1019
+ templated: t.templated,
1020
+ type: t.type,
1021
+ title: t.title,
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)
822
1032
  });
823
1033
  }
824
1034
  /**
825
1035
  * Serializes a [Link] to its RWPM JSON representation.
826
1036
  */
827
1037
  serialize() {
828
- const e = { href: this.href };
829
- return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = gt(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.size !== void 0 && (e.size = this.size), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;
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;
830
1040
  }
831
1041
  /** MediaType of the linked resource. */
832
1042
  get mediaType() {
@@ -835,162 +1045,162 @@ class H {
835
1045
  /** Computes an absolute URL to the link, relative to the given `baseURL`.
836
1046
  * If the link's `href` is already absolute, the `baseURL` is ignored.
837
1047
  */
838
- toURL(e) {
839
- const t = this.href.replace(/^(\/)/, "");
840
- if (t.length === 0) return;
841
- let i = e || "/";
842
- return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
1048
+ toURL(t) {
1049
+ const e = this.href.replace(/^(\/)/, "");
1050
+ if (e.length === 0) return;
1051
+ let i = t || "/";
1052
+ return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
843
1053
  }
844
1054
  /** List of URI template parameter keys, if the `Link` is templated. */
845
1055
  get templateParameters() {
846
- return this.templated ? new Ie(this.href).parameters : /* @__PURE__ */ new Set();
1056
+ return this.templated ? new qt(this.href).parameters : /* @__PURE__ */ new Set();
847
1057
  }
848
1058
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
849
1059
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
850
1060
  */
851
- expandTemplate(e) {
852
- return new H({
853
- href: new Ie(this.href).expand(e),
1061
+ expandTemplate(t) {
1062
+ return new $({
1063
+ href: new qt(this.href).expand(t),
854
1064
  templated: !1
855
1065
  });
856
1066
  }
857
1067
  /**
858
1068
  * Makes a copy of this [Link] after merging in the given additional other [properties].
859
1069
  */
860
- addProperties(e) {
861
- const t = H.deserialize(this.serialize());
862
- return t.properties = t.properties ? t.properties?.add(e) : new C(e), t;
1070
+ addProperties(t) {
1071
+ const e = $.deserialize(this.serialize());
1072
+ return e.properties = e.properties ? e.properties?.add(t) : new I(t), e;
863
1073
  }
864
1074
  /**
865
1075
  * Creates a [Locator] from a reading order [Link].
866
1076
  */
867
1077
  get locator() {
868
- let e = this.href.split("#");
869
- return new R({
870
- href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
1078
+ let t = this.href.split("#");
1079
+ return new U({
1080
+ href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
871
1081
  type: this.type ?? "",
872
1082
  title: this.title,
873
- locations: new b({
874
- fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
1083
+ locations: new x({
1084
+ fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
875
1085
  })
876
1086
  });
877
1087
  }
878
1088
  }
879
- class ee {
1089
+ class nt {
880
1090
  /**
881
1091
  * Creates a [Links].
882
1092
  */
883
- constructor(e) {
884
- this.items = e;
1093
+ constructor(t) {
1094
+ this.items = t;
885
1095
  }
886
1096
  /**
887
1097
  * Creates a list of [Link] from its RWPM JSON representation.
888
1098
  */
889
- static deserialize(e) {
890
- if (e && Array.isArray(e))
891
- return new ee(
892
- e.map((t) => H.deserialize(t)).filter((t) => t !== void 0)
1099
+ static deserialize(t) {
1100
+ if (t && Array.isArray(t))
1101
+ return new nt(
1102
+ t.map((e) => $.deserialize(e)).filter((e) => e !== void 0)
893
1103
  );
894
1104
  }
895
1105
  /**
896
1106
  * Serializes an array of [Link] to its RWPM JSON representation.
897
1107
  */
898
1108
  serialize() {
899
- return this.items.map((e) => e.serialize());
1109
+ return this.items.map((t) => t.serialize());
900
1110
  }
901
1111
  /** Finds the first link with the given relation. */
902
- findWithRel(e) {
903
- const t = (i) => i.rels && i.rels.has(e);
904
- return this.items.find(t);
1112
+ findWithRel(t) {
1113
+ const e = (i) => i.rels && i.rels.has(t);
1114
+ return this.items.find(e);
905
1115
  }
906
1116
  /** Finds all the links with the given relation. */
907
- filterByRel(e) {
908
- const t = (i) => i.rels && i.rels.has(e);
909
- return this.items.filter(t);
1117
+ filterByRel(t) {
1118
+ const e = (i) => i.rels && i.rels.has(t);
1119
+ return this.items.filter(e);
910
1120
  }
911
1121
  /** Finds the first link matching the given HREF. */
912
- findWithHref(e) {
913
- const t = (i) => i.href === e;
914
- return this.items.find(t);
1122
+ findWithHref(t) {
1123
+ const e = (i) => i.href === t;
1124
+ return this.items.find(e);
915
1125
  }
916
1126
  /** Finds the index of the first link matching the given HREF. */
917
- findIndexWithHref(e) {
918
- const t = (i) => i.href === e;
919
- return this.items.findIndex(t);
1127
+ findIndexWithHref(t) {
1128
+ const e = (i) => i.href === t;
1129
+ return this.items.findIndex(e);
920
1130
  }
921
1131
  /** Finds the first link matching the given media type. */
922
- findWithMediaType(e) {
923
- const t = (i) => i.mediaType.matches(e);
924
- return this.items.find(t);
1132
+ findWithMediaType(t) {
1133
+ const e = (i) => i.mediaType.matches(t);
1134
+ return this.items.find(e);
925
1135
  }
926
1136
  /** Finds all the links matching the given media type. */
927
- filterByMediaType(e) {
928
- const t = (i) => i.mediaType.matches(e);
929
- return this.items.filter(t);
1137
+ filterByMediaType(t) {
1138
+ const e = (i) => i.mediaType.matches(t);
1139
+ return this.items.filter(e);
930
1140
  }
931
1141
  /** Finds all the links matching any of the given media types. */
932
- filterByMediaTypes(e) {
933
- const t = (i) => {
934
- for (const r of e)
935
- if (i.mediaType.matches(r))
1142
+ filterByMediaTypes(t) {
1143
+ const e = (i) => {
1144
+ for (const s of t)
1145
+ if (i.mediaType.matches(s))
936
1146
  return !0;
937
1147
  return !1;
938
1148
  };
939
- return this.items.filter(t);
1149
+ return this.items.filter(e);
940
1150
  }
941
1151
  /** Returns whether all the resources in the collection are audio clips. */
942
1152
  everyIsAudio() {
943
- const e = (t) => t.mediaType.isAudio;
944
- return this.items.length > 0 && this.items.every(e);
1153
+ const t = (e) => e.mediaType.isAudio;
1154
+ return this.items.length > 0 && this.items.every(t);
945
1155
  }
946
1156
  /** Returns whether all the resources in the collection are bitmaps. */
947
1157
  everyIsBitmap() {
948
- const e = (t) => t.mediaType.isBitmap;
949
- return this.items.length > 0 && this.items.every(e);
1158
+ const t = (e) => e.mediaType.isBitmap;
1159
+ return this.items.length > 0 && this.items.every(t);
950
1160
  }
951
1161
  /** Returns whether all the resources in the collection are HTML documents. */
952
1162
  everyIsHTML() {
953
- const e = (t) => t.mediaType.isHTML;
954
- return this.items.length > 0 && this.items.every(e);
1163
+ const t = (e) => e.mediaType.isHTML;
1164
+ return this.items.length > 0 && this.items.every(t);
955
1165
  }
956
1166
  /** Returns whether all the resources in the collection are video clips. */
957
1167
  everyIsVideo() {
958
- const e = (t) => t.mediaType.isVideo;
959
- return this.items.length > 0 && this.items.every(e);
1168
+ const t = (e) => e.mediaType.isVideo;
1169
+ return this.items.length > 0 && this.items.every(t);
960
1170
  }
961
1171
  /** Returns whether all the resources in the collection are matching any of the given media types. */
962
- everyMatchesMediaType(e) {
963
- return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {
964
- for (const i of e)
965
- return t.mediaType.matches(i);
1172
+ everyMatchesMediaType(t) {
1173
+ return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
1174
+ for (const i of t)
1175
+ return e.mediaType.matches(i);
966
1176
  return !1;
967
- }) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));
1177
+ }) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
968
1178
  }
969
1179
  filterLinksHasType() {
970
- return this.items.filter((e) => e.type);
1180
+ return this.items.filter((t) => t.type);
971
1181
  }
972
1182
  }
973
- C.prototype.getContains = function() {
1183
+ I.prototype.getContains = function() {
974
1184
  return new Set(this.otherProperties.contains || []);
975
1185
  };
976
- class te {
1186
+ class ot {
977
1187
  /**
978
1188
  * Creates a [DomRange].
979
1189
  */
980
- constructor(e) {
981
- this.cssSelector = e.cssSelector, this.textNodeIndex = e.textNodeIndex, this.charOffset = e.charOffset;
1190
+ constructor(t) {
1191
+ this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
982
1192
  }
983
1193
  /**
984
1194
  * Parses a [DomRangePoint] from its RWPM JSON representation.
985
1195
  */
986
- static deserialize(e) {
987
- if (!(e && e.cssSelector)) return;
988
- let t = S(e.textNodeIndex);
989
- if (t === void 0) return;
990
- let i = S(e.charOffset);
991
- return i === void 0 && (i = S(e.offset)), new te({
992
- cssSelector: e.cssSelector,
993
- textNodeIndex: t,
1196
+ static deserialize(t) {
1197
+ if (!(t && t.cssSelector)) return;
1198
+ let e = L(t.textNodeIndex);
1199
+ if (e === void 0) return;
1200
+ let i = L(t.charOffset);
1201
+ return i === void 0 && (i = L(t.offset)), new ot({
1202
+ cssSelector: t.cssSelector,
1203
+ textNodeIndex: e,
994
1204
  charOffset: i
995
1205
  });
996
1206
  }
@@ -998,97 +1208,97 @@ class te {
998
1208
  * Serializes a [DomRangePoint] to its RWPM JSON representation.
999
1209
  */
1000
1210
  serialize() {
1001
- const e = {
1211
+ const t = {
1002
1212
  cssSelector: this.cssSelector,
1003
1213
  textNodeIndex: this.textNodeIndex
1004
1214
  };
1005
- return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
1215
+ return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1006
1216
  }
1007
1217
  }
1008
- class we {
1218
+ class Ot {
1009
1219
  /**
1010
1220
  * Creates a [DomRange].
1011
1221
  */
1012
- constructor(e) {
1013
- this.start = e.start, this.end = e.end;
1222
+ constructor(t) {
1223
+ this.start = t.start, this.end = t.end;
1014
1224
  }
1015
1225
  /**
1016
1226
  * Parses a [DomRange] from its RWPM JSON representation.
1017
1227
  */
1018
- static deserialize(e) {
1019
- if (!e) return;
1020
- let t = te.deserialize(e.start);
1021
- if (t)
1022
- return new we({
1023
- start: t,
1024
- end: te.deserialize(e.end)
1228
+ static deserialize(t) {
1229
+ if (!t) return;
1230
+ let e = ot.deserialize(t.start);
1231
+ if (e)
1232
+ return new Ot({
1233
+ start: e,
1234
+ end: ot.deserialize(t.end)
1025
1235
  });
1026
1236
  }
1027
1237
  /**
1028
1238
  * Serializes a [DomRange] to its RWPM JSON representation.
1029
1239
  */
1030
1240
  serialize() {
1031
- const e = { start: this.start.serialize() };
1032
- return this.end && (e.end = this.end.serialize()), e;
1241
+ const t = { start: this.start.serialize() };
1242
+ return this.end && (t.end = this.end.serialize()), t;
1033
1243
  }
1034
1244
  }
1035
- b.prototype.getCssSelector = function() {
1245
+ x.prototype.getCssSelector = function() {
1036
1246
  return this.otherLocations?.get("cssSelector");
1037
1247
  };
1038
- b.prototype.getPartialCfi = function() {
1248
+ x.prototype.getPartialCfi = function() {
1039
1249
  return this.otherLocations?.get("partialCfi");
1040
1250
  };
1041
- b.prototype.getDomRange = function() {
1042
- return we.deserialize(this.otherLocations?.get("domRange"));
1251
+ x.prototype.getDomRange = function() {
1252
+ return Ot.deserialize(this.otherLocations?.get("domRange"));
1043
1253
  };
1044
- b.prototype.fragmentParameters = function() {
1254
+ x.prototype.fragmentParameters = function() {
1045
1255
  return new Map(
1046
- this.fragments.map((s) => s.startsWith("#") ? s.slice(1) : s).join("&").split("&").filter((s) => !s.startsWith("#")).map((s) => s.split("=")).filter((s) => s.length === 2).map((s) => [
1047
- s[0].trim().toLowerCase(),
1048
- s[1].trim()
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
+ r[0].trim().toLowerCase(),
1258
+ r[1].trim()
1049
1259
  ])
1050
1260
  );
1051
1261
  };
1052
- b.prototype.htmlId = function() {
1262
+ x.prototype.htmlId = function() {
1053
1263
  if (!this.fragments.length) return;
1054
- let s = this.fragments.find((e) => e.length && !e.includes("="));
1055
- if (!s) {
1056
- const e = this.fragmentParameters();
1057
- e.has("id") ? s = e.get("id") : e.has("name") && (s = e.get("name"));
1264
+ let r = this.fragments.find((t) => t.length && !t.includes("="));
1265
+ if (!r) {
1266
+ const t = this.fragmentParameters();
1267
+ t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));
1058
1268
  }
1059
- return s?.startsWith("#") ? s.slice(1) : s;
1269
+ return r?.startsWith("#") ? r.slice(1) : r;
1060
1270
  };
1061
- b.prototype.page = function() {
1062
- const s = parseInt(this.fragmentParameters().get("page"));
1063
- if (!isNaN(s) && s >= 0) return s;
1271
+ x.prototype.page = function() {
1272
+ const r = parseInt(this.fragmentParameters().get("page"));
1273
+ if (!isNaN(r) && r >= 0) return r;
1064
1274
  };
1065
- b.prototype.time = function() {
1066
- const s = parseInt(this.fragmentParameters().get("t"));
1067
- if (!isNaN(s)) return s;
1275
+ x.prototype.time = function() {
1276
+ const r = parseInt(this.fragmentParameters().get("t"));
1277
+ if (!isNaN(r)) return r;
1068
1278
  };
1069
- b.prototype.space = function() {
1070
- const s = this.fragmentParameters();
1071
- if (!s.has("xywh")) return;
1072
- const e = s.get("xywh").split(",").map((t) => parseInt(t));
1073
- if (e.length === 4 && !e.some(isNaN))
1074
- return e;
1279
+ x.prototype.space = function() {
1280
+ const r = this.fragmentParameters();
1281
+ if (!r.has("xywh")) return;
1282
+ const t = r.get("xywh").split(",").map((e) => parseInt(e));
1283
+ if (t.length === 4 && !t.some(isNaN))
1284
+ return t;
1075
1285
  };
1076
- class Se {
1286
+ class Pt {
1077
1287
  /** Creates a [Price]. */
1078
- constructor(e) {
1079
- this.currency = e.currency, this.value = e.value;
1288
+ constructor(t) {
1289
+ this.currency = t.currency, this.value = t.value;
1080
1290
  }
1081
1291
  /**
1082
1292
  * Parses a [Price] from its RWPM JSON representation.
1083
1293
  */
1084
- static deserialize(e) {
1085
- if (!e) return;
1086
- let t = e.currency;
1087
- if (!(t && typeof t == "string" && t.length > 0))
1294
+ static deserialize(t) {
1295
+ if (!t) return;
1296
+ let e = t.currency;
1297
+ if (!(e && typeof e == "string" && e.length > 0))
1088
1298
  return;
1089
- let i = S(e.value);
1299
+ let i = L(t.value);
1090
1300
  if (i !== void 0)
1091
- return new Se({ currency: t, value: i });
1301
+ return new Pt({ currency: e, value: i });
1092
1302
  }
1093
1303
  /**
1094
1304
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1097,402 +1307,402 @@ class Se {
1097
1307
  return { currency: this.currency, value: this.value };
1098
1308
  }
1099
1309
  }
1100
- class V {
1310
+ class X {
1101
1311
  /** Creates a [Acquisition]. */
1102
- constructor(e) {
1103
- this.type = e.type, this.children = e.children;
1312
+ constructor(t) {
1313
+ this.type = t.type, this.children = t.children;
1104
1314
  }
1105
1315
  /**
1106
1316
  * Parses a [Acquisition] from its RWPM JSON representation.
1107
1317
  */
1108
- static deserialize(e) {
1109
- if (e && e.type)
1110
- return new V({
1111
- type: e.type,
1112
- children: V.deserializeArray(e.children)
1318
+ static deserialize(t) {
1319
+ if (t && t.type)
1320
+ return new X({
1321
+ type: t.type,
1322
+ children: X.deserializeArray(t.children)
1113
1323
  });
1114
1324
  }
1115
- static deserializeArray(e) {
1116
- if (Array.isArray(e))
1117
- return e.map((t) => V.deserialize(t)).filter((t) => t !== void 0);
1325
+ static deserializeArray(t) {
1326
+ if (Array.isArray(t))
1327
+ return t.map((e) => X.deserialize(e)).filter((e) => e !== void 0);
1118
1328
  }
1119
1329
  /**
1120
1330
  * Serializes a [Acquisition] to its RWPM JSON representation.
1121
1331
  */
1122
1332
  serialize() {
1123
- const e = { type: this.type };
1124
- return this.children && (e.children = this.children.map((t) => t.serialize())), e;
1333
+ const t = { type: this.type };
1334
+ return this.children && (t.children = this.children.map((e) => e.serialize())), t;
1125
1335
  }
1126
1336
  }
1127
- class Ce {
1337
+ class Lt {
1128
1338
  /** Creates a [Price]. */
1129
- constructor(e) {
1130
- this.total = e.total, this.position = e.position;
1339
+ constructor(t) {
1340
+ this.total = t.total, this.position = t.position;
1131
1341
  }
1132
1342
  /**
1133
1343
  * Parses a [Holds] from its RWPM JSON representation.
1134
1344
  */
1135
- static deserialize(e) {
1136
- if (e)
1137
- return new Ce({
1138
- total: S(e.total),
1139
- position: S(e.position)
1345
+ static deserialize(t) {
1346
+ if (t)
1347
+ return new Lt({
1348
+ total: L(t.total),
1349
+ position: L(t.position)
1140
1350
  });
1141
1351
  }
1142
1352
  /**
1143
1353
  * Serializes a [Holds] to its RWPM JSON representation.
1144
1354
  */
1145
1355
  serialize() {
1146
- const e = {};
1147
- return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
1356
+ const t = {};
1357
+ return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
1148
1358
  }
1149
1359
  }
1150
- class Pe {
1360
+ class It {
1151
1361
  /** Creates a [Copies]. */
1152
- constructor(e) {
1153
- this.total = e.total, this.available = e.available;
1362
+ constructor(t) {
1363
+ this.total = t.total, this.available = t.available;
1154
1364
  }
1155
1365
  /**
1156
1366
  * Parses a [Copies] from its RWPM JSON representation.
1157
1367
  */
1158
- static deserialize(e) {
1159
- if (e)
1160
- return new Pe({
1161
- total: S(e.total),
1162
- available: S(e.available)
1368
+ static deserialize(t) {
1369
+ if (t)
1370
+ return new It({
1371
+ total: L(t.total),
1372
+ available: L(t.available)
1163
1373
  });
1164
1374
  }
1165
1375
  /**
1166
1376
  * Serializes a [Copies] to its RWPM JSON representation.
1167
1377
  */
1168
1378
  serialize() {
1169
- const e = {};
1170
- return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
1379
+ const t = {};
1380
+ return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
1171
1381
  }
1172
1382
  }
1173
- class Ae {
1383
+ class Rt {
1174
1384
  /** Creates a [Availability]. */
1175
- constructor(e) {
1176
- this.state = e.state, this.since = e.since, this.until = e.until;
1385
+ constructor(t) {
1386
+ this.state = t.state, this.since = t.since, this.until = t.until;
1177
1387
  }
1178
1388
  /**
1179
1389
  * Parses a [Availability] from its RWPM JSON representation.
1180
1390
  */
1181
- static deserialize(e) {
1182
- if (e && e.state)
1183
- return new Ae({
1184
- state: e.state,
1185
- since: Re(e.since),
1186
- until: Re(e.until)
1391
+ static deserialize(t) {
1392
+ if (t && t.state)
1393
+ return new Rt({
1394
+ state: t.state,
1395
+ since: Yt(t.since),
1396
+ until: Yt(t.until)
1187
1397
  });
1188
1398
  }
1189
1399
  /**
1190
1400
  * Serializes a [Availability] to its RWPM JSON representation.
1191
1401
  */
1192
1402
  serialize() {
1193
- const e = { state: this.state };
1194
- return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
1403
+ const t = { state: this.state };
1404
+ return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
1195
1405
  }
1196
1406
  }
1197
- C.prototype.getNumberOfItems = function() {
1198
- return S(this.otherProperties.numberOfItems);
1407
+ I.prototype.getNumberOfItems = function() {
1408
+ return L(this.otherProperties.numberOfItems);
1199
1409
  };
1200
- C.prototype.getPrice = function() {
1201
- return Se.deserialize(this.otherProperties.price);
1410
+ I.prototype.getPrice = function() {
1411
+ return Pt.deserialize(this.otherProperties.price);
1202
1412
  };
1203
- C.prototype.getIndirectAcquisitions = function() {
1204
- const s = this.otherProperties.indirectAcquisition;
1205
- if (s && Array.isArray(s))
1206
- return s.map((e) => V.deserialize(e)).filter((e) => e !== void 0);
1413
+ I.prototype.getIndirectAcquisitions = function() {
1414
+ const r = this.otherProperties.indirectAcquisition;
1415
+ if (r && Array.isArray(r))
1416
+ return r.map((t) => X.deserialize(t)).filter((t) => t !== void 0);
1207
1417
  };
1208
- C.prototype.getHolds = function() {
1209
- return Ce.deserialize(this.otherProperties.holds);
1418
+ I.prototype.getHolds = function() {
1419
+ return Lt.deserialize(this.otherProperties.holds);
1210
1420
  };
1211
- C.prototype.getCopies = function() {
1212
- return Pe.deserialize(this.otherProperties.copies);
1421
+ I.prototype.getCopies = function() {
1422
+ return It.deserialize(this.otherProperties.copies);
1213
1423
  };
1214
- C.prototype.getAvailability = function() {
1215
- return Ae.deserialize(this.otherProperties.availability);
1424
+ I.prototype.getAvailability = function() {
1425
+ return Rt.deserialize(this.otherProperties.availability);
1216
1426
  };
1217
- C.prototype.getAuthenticate = function() {
1218
- return H.deserialize(this.otherProperties.authenticate);
1427
+ I.prototype.getAuthenticate = function() {
1428
+ return $.deserialize(this.otherProperties.authenticate);
1219
1429
  };
1220
- const yt = "CssSelectorGenerator";
1221
- function ze(s = "unknown problem", ...e) {
1222
- console.warn(`${yt}: ${s}`, ...e);
1430
+ const ze = "CssSelectorGenerator";
1431
+ function Xt(r = "unknown problem", ...t) {
1432
+ console.warn(`${ze}: ${r}`, ...t);
1223
1433
  }
1224
- function vt(s) {
1225
- return s instanceof RegExp;
1434
+ function De(r) {
1435
+ return r instanceof RegExp;
1226
1436
  }
1227
- function bt(s) {
1228
- return s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1437
+ function Me(r) {
1438
+ return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1229
1439
  }
1230
- function Et(s) {
1231
- const e = s.map((t) => {
1232
- if (vt(t))
1233
- return (i) => t.test(i);
1234
- if (typeof t == "function")
1440
+ function We(r) {
1441
+ const t = r.map((e) => {
1442
+ if (De(e))
1443
+ return (i) => e.test(i);
1444
+ if (typeof e == "function")
1235
1445
  return (i) => {
1236
- const r = t(i);
1237
- return typeof r != "boolean" ? (ze("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : r;
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;
1238
1448
  };
1239
- if (typeof t == "string") {
1240
- const i = new RegExp("^" + bt(t) + "$");
1241
- return (r) => i.test(r);
1449
+ if (typeof e == "string") {
1450
+ const i = new RegExp("^" + Me(e) + "$");
1451
+ return (s) => i.test(s);
1242
1452
  }
1243
- return ze("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
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;
1244
1454
  });
1245
- return (t) => e.some((i) => i(t));
1455
+ return (e) => t.some((i) => i(e));
1246
1456
  }
1247
- Et([
1457
+ We([
1248
1458
  "class",
1249
1459
  "id",
1250
1460
  // Angular attributes
1251
1461
  "ng-*"
1252
1462
  ]);
1253
- class Y {
1463
+ class tt {
1254
1464
  }
1255
- function De(s) {
1256
- return s.split("").reverse().join("");
1465
+ function Kt(r) {
1466
+ return r.split("").reverse().join("");
1257
1467
  }
1258
- function xt(s, e, t) {
1259
- const i = De(e);
1260
- return t.map((r) => {
1261
- const n = Math.max(0, r.end - e.length - r.errors), o = De(s.slice(n, r.end));
1468
+ function Ue(r, t, e) {
1469
+ const i = Kt(t);
1470
+ return e.map((s) => {
1471
+ const n = Math.max(0, s.end - t.length - s.errors), o = Kt(r.slice(n, s.end));
1262
1472
  return {
1263
- start: et(o, i, r.errors).reduce((u, h) => r.end - h.end < u ? r.end - h.end : u, r.end),
1264
- end: r.end,
1265
- errors: r.errors
1473
+ start: fe(o, i, s.errors).reduce((d, h) => s.end - h.end < d ? s.end - h.end : d, s.end),
1474
+ end: s.end,
1475
+ errors: s.errors
1266
1476
  };
1267
1477
  });
1268
1478
  }
1269
- function ae(s) {
1270
- return (s | -s) >> 31 & 1;
1479
+ function dt(r) {
1480
+ return (r | -r) >> 31 & 1;
1271
1481
  }
1272
- function We(s, e, t, i) {
1273
- let r = s.P[t], n = s.M[t];
1274
- const o = i >>> 31, a = e[t] | o, u = a | n, h = (a & r) + r ^ r | a;
1275
- let c = n | ~(h | r), m = r & h;
1276
- const d = ae(c & s.lastRowMask[t]) - ae(m & s.lastRowMask[t]);
1277
- return c <<= 1, m <<= 1, m |= o, c |= ae(i) - o, r = m | ~(u | c), n = c & u, s.P[t] = r, s.M[t] = n, d;
1482
+ function Zt(r, t, e, i) {
1483
+ let s = r.P[e], n = r.M[e];
1484
+ const o = i >>> 31, a = t[e] | o, d = a | n, h = (a & s) + s ^ s | a;
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;
1278
1488
  }
1279
- function et(s, e, t) {
1280
- if (e.length === 0)
1489
+ function fe(r, t, e) {
1490
+ if (t.length === 0)
1281
1491
  return [];
1282
- t = Math.min(t, e.length);
1283
- const i = [], r = 32, n = Math.ceil(e.length / r) - 1, o = {
1492
+ e = Math.min(e, t.length);
1493
+ const i = [], s = 32, n = Math.ceil(t.length / s) - 1, o = {
1284
1494
  P: new Uint32Array(n + 1),
1285
1495
  M: new Uint32Array(n + 1),
1286
1496
  lastRowMask: new Uint32Array(n + 1)
1287
1497
  };
1288
- o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % r;
1289
- const a = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];
1290
- for (let d = 0; d < 256; d++)
1498
+ o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
1499
+ const a = new Uint32Array(n + 1), d = /* @__PURE__ */ new Map(), h = [];
1500
+ for (let p = 0; p < 256; p++)
1291
1501
  h.push(a);
1292
- for (let d = 0; d < e.length; d += 1) {
1293
- const y = e.charCodeAt(d);
1294
- if (u.has(y))
1502
+ for (let p = 0; p < t.length; p += 1) {
1503
+ const y = t.charCodeAt(p);
1504
+ if (d.has(y))
1295
1505
  continue;
1296
- const p = new Uint32Array(n + 1);
1297
- u.set(y, p), y < h.length && (h[y] = p);
1298
- for (let f = 0; f <= n; f += 1) {
1299
- p[f] = 0;
1300
- for (let g = 0; g < r; g += 1) {
1301
- const E = f * r + g;
1302
- if (E >= e.length)
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)
1303
1513
  continue;
1304
- e.charCodeAt(E) === y && (p[f] |= 1 << g);
1514
+ t.charCodeAt(C) === y && (f[m] |= 1 << v);
1305
1515
  }
1306
1516
  }
1307
1517
  }
1308
- let c = Math.max(0, Math.ceil(t / r) - 1);
1309
- const m = new Uint32Array(n + 1);
1310
- for (let d = 0; d <= c; d += 1)
1311
- m[d] = (d + 1) * r;
1312
- m[n] = e.length;
1313
- for (let d = 0; d <= c; d += 1)
1314
- o.P[d] = -1, o.M[d] = 0;
1315
- for (let d = 0; d < s.length; d += 1) {
1316
- const y = s.charCodeAt(d);
1317
- let p;
1318
- y < h.length ? p = h[y] : (p = u.get(y), typeof p > "u" && (p = a));
1319
- let f = 0;
1320
- for (let g = 0; g <= c; g += 1)
1321
- f = We(o, p, g, f), m[g] += f;
1322
- if (m[c] - f <= t && c < n && (p[c + 1] & 1 || f < 0)) {
1323
- c += 1, o.P[c] = -1, o.M[c] = 0;
1324
- let g;
1325
- if (c === n) {
1326
- const E = e.length % r;
1327
- g = E === 0 ? r : E;
1518
+ let u = Math.max(0, Math.ceil(e / s) - 1);
1519
+ const g = new Uint32Array(n + 1);
1520
+ for (let p = 0; p <= u; p += 1)
1521
+ g[p] = (p + 1) * s;
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);
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)) {
1533
+ u += 1, o.P[u] = -1, o.M[u] = 0;
1534
+ let v;
1535
+ if (u === n) {
1536
+ const C = t.length % s;
1537
+ v = C === 0 ? s : C;
1328
1538
  } else
1329
- g = r;
1330
- m[c] = m[c - 1] + g - f + We(o, p, c, f);
1539
+ v = s;
1540
+ g[u] = g[u - 1] + v - m + Zt(o, f, u, m);
1331
1541
  } else
1332
- for (; c > 0 && m[c] >= t + r; )
1333
- c -= 1;
1334
- c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({
1542
+ for (; u > 0 && g[u] >= e + s; )
1543
+ u -= 1;
1544
+ u === n && g[u] <= e && (g[u] < e && i.splice(0, i.length), i.push({
1335
1545
  start: -1,
1336
- end: d + 1,
1337
- errors: m[c]
1338
- }), t = m[c]);
1546
+ end: p + 1,
1547
+ errors: g[u]
1548
+ }), e = g[u]);
1339
1549
  }
1340
1550
  return i;
1341
1551
  }
1342
- function Tt(s, e, t) {
1343
- const i = et(s, e, t);
1344
- return xt(s, e, i);
1552
+ function ke(r, t, e) {
1553
+ const i = fe(r, t, e);
1554
+ return Ue(r, t, i);
1345
1555
  }
1346
- function tt(s, e, t) {
1556
+ function me(r, t, e) {
1347
1557
  let i = 0;
1348
- const r = [];
1558
+ const s = [];
1349
1559
  for (; i !== -1; )
1350
- i = s.indexOf(e, i), i !== -1 && (r.push({
1560
+ i = r.indexOf(t, i), i !== -1 && (s.push({
1351
1561
  start: i,
1352
- end: i + e.length,
1562
+ end: i + t.length,
1353
1563
  errors: 0
1354
1564
  }), i += 1);
1355
- return r.length > 0 ? r : Tt(s, e, t);
1565
+ return s.length > 0 ? s : ke(r, t, e);
1356
1566
  }
1357
- function Fe(s, e) {
1358
- return e.length === 0 || s.length === 0 ? 0 : 1 - tt(s, e, e.length)[0].errors / e.length;
1567
+ function Jt(r, t) {
1568
+ return t.length === 0 || r.length === 0 ? 0 : 1 - me(r, t, t.length)[0].errors / t.length;
1359
1569
  }
1360
- function wt(s, e, t = {}) {
1361
- if (e.length === 0)
1570
+ function Be(r, t, e = {}) {
1571
+ if (t.length === 0)
1362
1572
  return null;
1363
- const i = Math.min(256, e.length / 2), r = tt(s, e, i);
1364
- if (r.length === 0)
1573
+ const i = Math.min(256, t.length / 2), s = me(r, t, i);
1574
+ if (s.length === 0)
1365
1575
  return null;
1366
1576
  const n = (a) => {
1367
- const d = 1 - a.errors / e.length, y = t.prefix ? Fe(
1368
- s.slice(
1369
- Math.max(0, a.start - t.prefix.length),
1577
+ const p = 1 - a.errors / t.length, y = e.prefix ? Jt(
1578
+ r.slice(
1579
+ Math.max(0, a.start - e.prefix.length),
1370
1580
  a.start
1371
1581
  ),
1372
- t.prefix
1373
- ) : 1, p = t.suffix ? Fe(
1374
- s.slice(a.end, a.end + t.suffix.length),
1375
- t.suffix
1582
+ e.prefix
1583
+ ) : 1, f = e.suffix ? Jt(
1584
+ r.slice(a.end, a.end + e.suffix.length),
1585
+ e.suffix
1376
1586
  ) : 1;
1377
- let f = 1;
1378
- return typeof t.hint == "number" && (f = 1 - Math.abs(a.start - t.hint) / s.length), (50 * d + 20 * y + 20 * p + 2 * f) / 92;
1379
- }, o = r.map((a) => ({
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;
1589
+ }, o = s.map((a) => ({
1380
1590
  start: a.start,
1381
1591
  end: a.end,
1382
1592
  score: n(a)
1383
1593
  }));
1384
- return o.sort((a, u) => u.score - a.score), o[0];
1385
- }
1386
- function ue(s, e, t) {
1387
- const i = t === 1 ? e : e - 1;
1388
- if (s.charAt(i).trim() !== "")
1389
- return e;
1390
- let r, n;
1391
- if (t === 2 ? (r = s.substring(0, e), n = r.trimEnd()) : (r = s.substring(e), n = r.trimStart()), !n.length)
1594
+ return o.sort((a, d) => d.score - a.score), o[0];
1595
+ }
1596
+ function gt(r, t, e) {
1597
+ const i = e === 1 ? t : t - 1;
1598
+ if (r.charAt(i).trim() !== "")
1599
+ return t;
1600
+ let s, n;
1601
+ if (e === 2 ? (s = r.substring(0, t), n = s.trimEnd()) : (s = r.substring(t), n = s.trimStart()), !n.length)
1392
1602
  return -1;
1393
- const o = r.length - n.length;
1394
- return t === 2 ? e - o : e + o;
1603
+ const o = s.length - n.length;
1604
+ return e === 2 ? t - o : t + o;
1395
1605
  }
1396
- function Ue(s, e) {
1397
- const t = s.commonAncestorContainer.ownerDocument.createNodeIterator(
1398
- s.commonAncestorContainer,
1606
+ function Qt(r, t) {
1607
+ const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1608
+ r.commonAncestorContainer,
1399
1609
  NodeFilter.SHOW_TEXT
1400
- ), i = e === 1 ? s.startContainer : s.endContainer, r = e === 1 ? s.endContainer : s.startContainer;
1401
- let n = t.nextNode();
1610
+ ), i = t === 1 ? r.startContainer : r.endContainer, s = t === 1 ? r.endContainer : r.startContainer;
1611
+ let n = e.nextNode();
1402
1612
  for (; n && n !== i; )
1403
- n = t.nextNode();
1404
- e === 2 && (n = t.previousNode());
1613
+ n = e.nextNode();
1614
+ t === 2 && (n = e.previousNode());
1405
1615
  let o = -1;
1406
1616
  const a = () => {
1407
- if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
1408
- const u = n.textContent, h = e === 1 ? 0 : u.length;
1409
- o = ue(u, h, e);
1617
+ if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
1618
+ const d = n.textContent, h = t === 1 ? 0 : d.length;
1619
+ o = gt(d, h, t);
1410
1620
  }
1411
1621
  };
1412
- for (; n && o === -1 && n !== r; )
1622
+ for (; n && o === -1 && n !== s; )
1413
1623
  a();
1414
1624
  if (n && o >= 0)
1415
1625
  return { node: n, offset: o };
1416
1626
  throw new RangeError("No text nodes with non-whitespace text found in range");
1417
1627
  }
1418
- function St(s) {
1419
- if (!s.toString().trim().length)
1628
+ function He(r) {
1629
+ if (!r.toString().trim().length)
1420
1630
  throw new RangeError("Range contains no non-whitespace text");
1421
- if (s.startContainer.nodeType !== Node.TEXT_NODE)
1631
+ if (r.startContainer.nodeType !== Node.TEXT_NODE)
1422
1632
  throw new RangeError("Range startContainer is not a text node");
1423
- if (s.endContainer.nodeType !== Node.TEXT_NODE)
1633
+ if (r.endContainer.nodeType !== Node.TEXT_NODE)
1424
1634
  throw new RangeError("Range endContainer is not a text node");
1425
- const e = s.cloneRange();
1426
- let t = !1, i = !1;
1427
- const r = {
1428
- start: ue(
1429
- s.startContainer.textContent,
1430
- s.startOffset,
1635
+ const t = r.cloneRange();
1636
+ let e = !1, i = !1;
1637
+ const s = {
1638
+ start: gt(
1639
+ r.startContainer.textContent,
1640
+ r.startOffset,
1431
1641
  1
1432
1642
  /* Forwards */
1433
1643
  ),
1434
- end: ue(
1435
- s.endContainer.textContent,
1436
- s.endOffset,
1644
+ end: gt(
1645
+ r.endContainer.textContent,
1646
+ r.endOffset,
1437
1647
  2
1438
1648
  /* Backwards */
1439
1649
  )
1440
1650
  };
1441
- if (r.start >= 0 && (e.setStart(s.startContainer, r.start), t = !0), r.end > 0 && (e.setEnd(s.endContainer, r.end), i = !0), t && i)
1442
- return e;
1443
- if (!t) {
1444
- const { node: n, offset: o } = Ue(
1445
- e,
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
+ return t;
1653
+ if (!e) {
1654
+ const { node: n, offset: o } = Qt(
1655
+ t,
1446
1656
  1
1447
1657
  /* Forwards */
1448
1658
  );
1449
- n && o >= 0 && e.setStart(n, o);
1659
+ n && o >= 0 && t.setStart(n, o);
1450
1660
  }
1451
1661
  if (!i) {
1452
- const { node: n, offset: o } = Ue(
1453
- e,
1662
+ const { node: n, offset: o } = Qt(
1663
+ t,
1454
1664
  2
1455
1665
  /* Backwards */
1456
1666
  );
1457
- n && o > 0 && e.setEnd(n, o);
1667
+ n && o > 0 && t.setEnd(n, o);
1458
1668
  }
1459
- return e;
1669
+ return t;
1460
1670
  }
1461
- function it(s) {
1462
- switch (s.nodeType) {
1671
+ function ge(r) {
1672
+ switch (r.nodeType) {
1463
1673
  case Node.ELEMENT_NODE:
1464
1674
  case Node.TEXT_NODE:
1465
- return s.textContent?.length ?? 0;
1675
+ return r.textContent?.length ?? 0;
1466
1676
  default:
1467
1677
  return 0;
1468
1678
  }
1469
1679
  }
1470
- function Be(s) {
1471
- let e = s.previousSibling, t = 0;
1472
- for (; e; )
1473
- t += it(e), e = e.previousSibling;
1474
- return t;
1680
+ function jt(r) {
1681
+ let t = r.previousSibling, e = 0;
1682
+ for (; t; )
1683
+ e += ge(t), t = t.previousSibling;
1684
+ return e;
1475
1685
  }
1476
- function rt(s, ...e) {
1477
- let t = e.shift();
1478
- const i = s.ownerDocument.createNodeIterator(
1479
- s,
1686
+ function be(r, ...t) {
1687
+ let e = t.shift();
1688
+ const i = r.ownerDocument.createNodeIterator(
1689
+ r,
1480
1690
  NodeFilter.SHOW_TEXT
1481
- ), r = [];
1691
+ ), s = [];
1482
1692
  let n = i.nextNode(), o, a = 0;
1483
- for (; t !== void 0 && n; )
1484
- o = n, a + o.data.length > t ? (r.push({ node: o, offset: t - a }), t = e.shift()) : (n = i.nextNode(), a += o.data.length);
1485
- for (; t !== void 0 && o && a === t; )
1486
- r.push({ node: o, offset: o.data.length }), t = e.shift();
1487
- if (t !== void 0)
1693
+ for (; e !== void 0 && n; )
1694
+ o = n, a + o.data.length > e ? (s.push({ node: o, offset: e - a }), e = t.shift()) : (n = i.nextNode(), a += o.data.length);
1695
+ for (; e !== void 0 && o && a === e; )
1696
+ s.push({ node: o, offset: o.data.length }), e = t.shift();
1697
+ if (e !== void 0)
1488
1698
  throw new RangeError("Offset exceeds text length");
1489
- return r;
1699
+ return s;
1490
1700
  }
1491
- class M {
1492
- constructor(e, t) {
1493
- if (t < 0)
1701
+ class D {
1702
+ constructor(t, e) {
1703
+ if (e < 0)
1494
1704
  throw new Error("Offset is invalid");
1495
- this.element = e, this.offset = t;
1705
+ this.element = t, this.offset = e;
1496
1706
  }
1497
1707
  /**
1498
1708
  * Return a copy of this position with offset relative to a given ancestor
@@ -1500,13 +1710,13 @@ class M {
1500
1710
  *
1501
1711
  * @param parent - Ancestor of `this.element`
1502
1712
  */
1503
- relativeTo(e) {
1504
- if (!e.contains(this.element))
1713
+ relativeTo(t) {
1714
+ if (!t.contains(this.element))
1505
1715
  throw new Error("Parent is not an ancestor of current element");
1506
- let t = this.element, i = this.offset;
1507
- for (; t !== e; )
1508
- i += Be(t), t = t.parentElement;
1509
- return new M(t, i);
1716
+ let e = this.element, i = this.offset;
1717
+ for (; e !== t; )
1718
+ i += jt(e), e = e.parentElement;
1719
+ return new D(e, i);
1510
1720
  }
1511
1721
  /**
1512
1722
  * Resolve the position to a specific text node and offset within that node.
@@ -1525,34 +1735,34 @@ class M {
1525
1735
  *
1526
1736
  * @throws {RangeError}
1527
1737
  */
1528
- resolve(e = {}) {
1738
+ resolve(t = {}) {
1529
1739
  try {
1530
- return rt(this.element, this.offset)[0];
1531
- } catch (t) {
1532
- if (this.offset === 0 && e.direction !== void 0) {
1740
+ return be(this.element, this.offset)[0];
1741
+ } catch (e) {
1742
+ if (this.offset === 0 && t.direction !== void 0) {
1533
1743
  const i = document.createTreeWalker(
1534
1744
  this.element.getRootNode(),
1535
1745
  NodeFilter.SHOW_TEXT
1536
1746
  );
1537
1747
  i.currentNode = this.element;
1538
- const r = e.direction === 1, n = r ? i.nextNode() : i.previousNode();
1748
+ const s = t.direction === 1, n = s ? i.nextNode() : i.previousNode();
1539
1749
  if (!n)
1540
- throw t;
1541
- return { node: n, offset: r ? 0 : n.data.length };
1750
+ throw e;
1751
+ return { node: n, offset: s ? 0 : n.data.length };
1542
1752
  } else
1543
- throw t;
1753
+ throw e;
1544
1754
  }
1545
1755
  }
1546
1756
  /**
1547
1757
  * Construct a `TextPosition` that refers to the `offset`th character within
1548
1758
  * `node`.
1549
1759
  */
1550
- static fromCharOffset(e, t) {
1551
- switch (e.nodeType) {
1760
+ static fromCharOffset(t, e) {
1761
+ switch (t.nodeType) {
1552
1762
  case Node.TEXT_NODE:
1553
- return M.fromPoint(e, t);
1763
+ return D.fromPoint(t, e);
1554
1764
  case Node.ELEMENT_NODE:
1555
- return new M(e, t);
1765
+ return new D(t, e);
1556
1766
  default:
1557
1767
  throw new Error("Node is not an element or text node");
1558
1768
  }
@@ -1563,42 +1773,42 @@ class M {
1563
1773
  * @param node
1564
1774
  * @param offset - Offset within the node
1565
1775
  */
1566
- static fromPoint(e, t) {
1567
- switch (e.nodeType) {
1776
+ static fromPoint(t, e) {
1777
+ switch (t.nodeType) {
1568
1778
  case Node.TEXT_NODE: {
1569
- if (t < 0 || t > e.data.length)
1779
+ if (e < 0 || e > t.data.length)
1570
1780
  throw new Error("Text node offset is out of range");
1571
- if (!e.parentElement)
1781
+ if (!t.parentElement)
1572
1782
  throw new Error("Text node has no parent");
1573
- const i = Be(e) + t;
1574
- return new M(e.parentElement, i);
1783
+ const i = jt(t) + e;
1784
+ return new D(t.parentElement, i);
1575
1785
  }
1576
1786
  case Node.ELEMENT_NODE: {
1577
- if (t < 0 || t > e.childNodes.length)
1787
+ if (e < 0 || e > t.childNodes.length)
1578
1788
  throw new Error("Child node offset is out of range");
1579
1789
  let i = 0;
1580
- for (let r = 0; r < t; r++)
1581
- i += it(e.childNodes[r]);
1582
- return new M(e, i);
1790
+ for (let s = 0; s < e; s++)
1791
+ i += ge(t.childNodes[s]);
1792
+ return new D(t, i);
1583
1793
  }
1584
1794
  default:
1585
1795
  throw new Error("Point is not in an element or text node");
1586
1796
  }
1587
1797
  }
1588
1798
  }
1589
- class I {
1590
- constructor(e, t) {
1591
- this.start = e, this.end = t;
1799
+ class k {
1800
+ constructor(t, e) {
1801
+ this.start = t, this.end = e;
1592
1802
  }
1593
1803
  /**
1594
1804
  * Create a new TextRange whose `start` and `end` are computed relative to
1595
1805
  * `element`. `element` must be an ancestor of both `start.element` and
1596
1806
  * `end.element`.
1597
1807
  */
1598
- relativeTo(e) {
1599
- return new I(
1600
- this.start.relativeTo(e),
1601
- this.end.relativeTo(e)
1808
+ relativeTo(t) {
1809
+ return new k(
1810
+ this.start.relativeTo(t),
1811
+ this.end.relativeTo(t)
1602
1812
  );
1603
1813
  }
1604
1814
  /**
@@ -1611,63 +1821,63 @@ class I {
1611
1821
  * May throw if the `start` or `end` positions cannot be resolved to a range.
1612
1822
  */
1613
1823
  toRange() {
1614
- let e, t;
1615
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = rt(
1824
+ let t, e;
1825
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = be(
1616
1826
  this.start.element,
1617
1827
  this.start.offset,
1618
1828
  this.end.offset
1619
- ) : (e = this.start.resolve({
1829
+ ) : (t = this.start.resolve({
1620
1830
  direction: 1
1621
1831
  /* FORWARDS */
1622
- }), t = this.end.resolve({
1832
+ }), e = this.end.resolve({
1623
1833
  direction: 2
1624
1834
  /* BACKWARDS */
1625
1835
  }));
1626
1836
  const i = new Range();
1627
- return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
1837
+ return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;
1628
1838
  }
1629
1839
  /**
1630
1840
  * Create a TextRange from a (DOM) Range
1631
1841
  */
1632
- static fromRange(e) {
1633
- const t = M.fromPoint(
1634
- e.startContainer,
1635
- e.startOffset
1636
- ), i = M.fromPoint(e.endContainer, e.endOffset);
1637
- return new I(t, i);
1842
+ static fromRange(t) {
1843
+ const e = D.fromPoint(
1844
+ t.startContainer,
1845
+ t.startOffset
1846
+ ), i = D.fromPoint(t.endContainer, t.endOffset);
1847
+ return new k(e, i);
1638
1848
  }
1639
1849
  /**
1640
1850
  * Create a TextRange representing the `start`th to `end`th characters in
1641
1851
  * `root`
1642
1852
  */
1643
- static fromOffsets(e, t, i) {
1644
- return new I(
1645
- new M(e, t),
1646
- new M(e, i)
1853
+ static fromOffsets(t, e, i) {
1854
+ return new k(
1855
+ new D(t, e),
1856
+ new D(t, i)
1647
1857
  );
1648
1858
  }
1649
1859
  /**
1650
1860
  * Return a new Range representing `range` trimmed of any leading or trailing
1651
1861
  * whitespace
1652
1862
  */
1653
- static trimmedRange(e) {
1654
- return St(I.fromRange(e).toRange());
1863
+ static trimmedRange(t) {
1864
+ return He(k.fromRange(t).toRange());
1655
1865
  }
1656
1866
  }
1657
- class ie {
1658
- constructor(e, t, i) {
1659
- this.root = e, this.start = t, this.end = i;
1867
+ class at {
1868
+ constructor(t, e, i) {
1869
+ this.root = t, this.start = e, this.end = i;
1660
1870
  }
1661
- static fromRange(e, t) {
1662
- const i = I.fromRange(t).relativeTo(e);
1663
- return new ie(
1664
- e,
1871
+ static fromRange(t, e) {
1872
+ const i = k.fromRange(e).relativeTo(t);
1873
+ return new at(
1874
+ t,
1665
1875
  i.start.offset,
1666
1876
  i.end.offset
1667
1877
  );
1668
1878
  }
1669
- static fromSelector(e, t) {
1670
- return new ie(e, t.start, t.end);
1879
+ static fromSelector(t, e) {
1880
+ return new at(t, e.start, e.end);
1671
1881
  }
1672
1882
  toSelector() {
1673
1883
  return {
@@ -1677,31 +1887,31 @@ class ie {
1677
1887
  };
1678
1888
  }
1679
1889
  toRange() {
1680
- return I.fromOffsets(this.root, this.start, this.end).toRange();
1890
+ return k.fromOffsets(this.root, this.start, this.end).toRange();
1681
1891
  }
1682
1892
  }
1683
- class re {
1893
+ class lt {
1684
1894
  /**
1685
1895
  * @param root - A root element from which to anchor.
1686
1896
  */
1687
- constructor(e, t, i = {}) {
1688
- this.root = e, this.exact = t, this.context = i;
1897
+ constructor(t, e, i = {}) {
1898
+ this.root = t, this.exact = e, this.context = i;
1689
1899
  }
1690
1900
  /**
1691
1901
  * Create a `TextQuoteAnchor` from a range.
1692
1902
  *
1693
1903
  * Will throw if `range` does not contain any text nodes.
1694
1904
  */
1695
- static fromRange(e, t) {
1696
- const i = e.textContent, r = I.fromRange(t).relativeTo(e), n = r.start.offset, o = r.end.offset, a = 32;
1697
- return new re(e, i.slice(n, o), {
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), {
1698
1908
  prefix: i.slice(Math.max(0, n - a), n),
1699
1909
  suffix: i.slice(o, Math.min(i.length, o + a))
1700
1910
  });
1701
1911
  }
1702
- static fromSelector(e, t) {
1703
- const { prefix: i, suffix: r } = t;
1704
- return new re(e, t.exact, { prefix: i, suffix: r });
1912
+ static fromSelector(t, e) {
1913
+ const { prefix: i, suffix: s } = e;
1914
+ return new lt(t, e.exact, { prefix: i, suffix: s });
1705
1915
  }
1706
1916
  toSelector() {
1707
1917
  return {
@@ -1711,30 +1921,30 @@ class re {
1711
1921
  suffix: this.context.suffix
1712
1922
  };
1713
1923
  }
1714
- toRange(e = {}) {
1715
- return this.toPositionAnchor(e).toRange();
1924
+ toRange(t = {}) {
1925
+ return this.toPositionAnchor(t).toRange();
1716
1926
  }
1717
- toPositionAnchor(e = {}) {
1718
- const t = this.root.textContent, i = wt(t, this.exact, {
1927
+ toPositionAnchor(t = {}) {
1928
+ const e = this.root.textContent, i = Be(e, this.exact, {
1719
1929
  ...this.context,
1720
- hint: e.hint
1930
+ hint: t.hint
1721
1931
  });
1722
1932
  if (!i)
1723
1933
  throw new Error("Quote not found");
1724
- return new ie(this.root, i.start, i.end);
1934
+ return new at(this.root, i.start, i.end);
1725
1935
  }
1726
1936
  }
1727
- function Ct(s) {
1728
- const e = s.tagName.toUpperCase();
1729
- return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
1937
+ function Ge(r) {
1938
+ const t = r.tagName.toUpperCase();
1939
+ return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
1730
1940
  }
1731
- function ne(s, e) {
1941
+ function ht(r, t) {
1732
1942
  try {
1733
- const t = e.locations, i = e.text;
1943
+ const e = t.locations, i = t.text;
1734
1944
  if (i && i.highlight) {
1735
- let r;
1736
- t && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), r || (r = s.body);
1737
- const n = new re(r, i.highlight, {
1945
+ let s;
1946
+ e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
1947
+ const n = new lt(s, i.highlight, {
1738
1948
  prefix: i.before,
1739
1949
  suffix: i.after
1740
1950
  });
@@ -1744,29 +1954,29 @@ function ne(s, e) {
1744
1954
  return console.warn("Quote not found:", n), null;
1745
1955
  }
1746
1956
  }
1747
- if (t) {
1748
- let r = null;
1749
- if (!r && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), !r && t.fragments) {
1750
- for (const n of t.fragments)
1751
- if (r = s.getElementById(n), r)
1957
+ if (e) {
1958
+ let s = null;
1959
+ if (!s && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), !s && e.fragments) {
1960
+ for (const n of e.fragments)
1961
+ if (s = r.getElementById(n), s)
1752
1962
  break;
1753
1963
  }
1754
- if (r) {
1755
- const n = s.createRange();
1756
- return r.childNodes.length === 0 || Ct(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
1964
+ if (s) {
1965
+ const n = r.createRange();
1966
+ return s.childNodes.length === 0 || Ge(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1757
1967
  }
1758
1968
  }
1759
- } catch (t) {
1760
- console.error(t);
1969
+ } catch (e) {
1970
+ console.error(e);
1761
1971
  }
1762
1972
  return null;
1763
1973
  }
1764
- function Pt(s, e) {
1765
- let t = s.getClientRects();
1766
- t.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = s.commonAncestorContainer.getClientRects());
1767
- const i = 1, r = [];
1768
- for (const h of t)
1769
- r.push({
1974
+ function _e(r, t) {
1975
+ let e = r.getClientRects();
1976
+ e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
1977
+ const i = 1, s = [];
1978
+ for (const h of e)
1979
+ s.push({
1770
1980
  bottom: h.bottom,
1771
1981
  height: h.height,
1772
1982
  left: h.left,
@@ -1774,13 +1984,13 @@ function Pt(s, e) {
1774
1984
  top: h.top,
1775
1985
  width: h.width
1776
1986
  });
1777
- const n = st(
1778
- r,
1987
+ const n = ve(
1988
+ s,
1779
1989
  i
1780
- ), o = Mt(n, i), a = nt(o), u = 4;
1990
+ ), o = Fe(n, i), a = ye(o), d = 4;
1781
1991
  for (let h = a.length - 1; h >= 0; h--) {
1782
- const c = a[h];
1783
- if (!(c.width * c.height > u))
1992
+ const u = a[h];
1993
+ if (!(u.width * u.height > d))
1784
1994
  if (a.length > 1)
1785
1995
  a.splice(h, 1);
1786
1996
  else
@@ -1788,185 +1998,185 @@ function Pt(s, e) {
1788
1998
  }
1789
1999
  return a;
1790
2000
  }
1791
- function st(s, e, t) {
1792
- for (let i = 0; i < s.length; i++)
1793
- for (let r = i + 1; r < s.length; r++) {
1794
- const n = s[i], o = s[r];
2001
+ function ve(r, t, e) {
2002
+ for (let i = 0; i < r.length; i++)
2003
+ for (let s = i + 1; s < r.length; s++) {
2004
+ const n = r[i], o = r[s];
1795
2005
  if (n === o)
1796
2006
  continue;
1797
- const a = P(n.top, o.top, e) && P(n.bottom, o.bottom, e), u = P(n.left, o.left, e) && P(n.right, o.right, e);
1798
- if (a && !u && ot(n, o, e)) {
1799
- const m = s.filter((y) => y !== n && y !== o), d = At(n, o);
1800
- return m.push(d), st(
1801
- m,
1802
- e
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(
2011
+ g,
2012
+ t
1803
2013
  );
1804
2014
  }
1805
2015
  }
1806
- return s;
2016
+ return r;
1807
2017
  }
1808
- function At(s, e) {
1809
- const t = Math.min(s.left, e.left), i = Math.max(s.right, e.right), r = Math.min(s.top, e.top), n = Math.max(s.bottom, e.bottom);
2018
+ function Ve(r, t) {
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);
1810
2020
  return {
1811
2021
  bottom: n,
1812
- height: n - r,
1813
- left: t,
2022
+ height: n - s,
2023
+ left: e,
1814
2024
  right: i,
1815
- top: r,
1816
- width: i - t
2025
+ top: s,
2026
+ width: i - e
1817
2027
  };
1818
2028
  }
1819
- function Mt(s, e) {
1820
- const t = new Set(s);
1821
- for (const i of s) {
2029
+ function Fe(r, t) {
2030
+ const e = new Set(r);
2031
+ for (const i of r) {
1822
2032
  if (!(i.width > 1 && i.height > 1)) {
1823
- t.delete(i);
2033
+ e.delete(i);
1824
2034
  continue;
1825
2035
  }
1826
- for (const n of s)
1827
- if (i !== n && t.has(n) && Nt(n, i, e)) {
1828
- t.delete(i);
2036
+ for (const n of r)
2037
+ if (i !== n && e.has(n) && $e(n, i, t)) {
2038
+ e.delete(i);
1829
2039
  break;
1830
2040
  }
1831
2041
  }
1832
- return Array.from(t);
2042
+ return Array.from(e);
1833
2043
  }
1834
- function Nt(s, e, t) {
1835
- return K(s, e.left, e.top, t) && K(s, e.right, e.top, t) && K(s, e.left, e.bottom, t) && K(s, e.right, e.bottom, t);
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);
1836
2046
  }
1837
- function K(s, e, t, i) {
1838
- return (s.left < e || P(s.left, e, i)) && (s.right > e || P(s.right, e, i)) && (s.top < t || P(s.top, t, i)) && (s.bottom > t || P(s.bottom, t, i));
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));
1839
2049
  }
1840
- function nt(s) {
1841
- for (let e = 0; e < s.length; e++)
1842
- for (let t = e + 1; t < s.length; t++) {
1843
- const i = s[e], r = s[t];
1844
- if (i !== r && ot(i, r, -1)) {
2050
+ function ye(r) {
2051
+ for (let t = 0; t < r.length; t++)
2052
+ for (let e = t + 1; e < r.length; e++) {
2053
+ const i = r[t], s = r[e];
2054
+ if (i !== s && we(i, s, -1)) {
1845
2055
  let n = [], o;
1846
- const a = He(i, r);
2056
+ const a = te(i, s);
1847
2057
  if (a.length === 1)
1848
2058
  n = a, o = i;
1849
2059
  else {
1850
- const h = He(r, i);
1851
- a.length < h.length ? (n = a, o = i) : (n = h, o = r);
2060
+ const h = te(s, i);
2061
+ a.length < h.length ? (n = a, o = i) : (n = h, o = s);
1852
2062
  }
1853
- const u = s.filter((h) => h !== o);
1854
- return Array.prototype.push.apply(u, n), nt(u);
2063
+ const d = r.filter((h) => h !== o);
2064
+ return Array.prototype.push.apply(d, n), ye(d);
1855
2065
  }
1856
2066
  }
1857
- return s;
2067
+ return r;
1858
2068
  }
1859
- function He(s, e) {
1860
- const t = Ot(e, s);
1861
- if (t.height === 0 || t.width === 0)
1862
- return [s];
2069
+ function te(r, t) {
2070
+ const e = Ye(t, r);
2071
+ if (e.height === 0 || e.width === 0)
2072
+ return [r];
1863
2073
  const i = [];
1864
2074
  {
1865
- const r = {
1866
- bottom: s.bottom,
2075
+ const s = {
2076
+ bottom: r.bottom,
1867
2077
  height: 0,
1868
- left: s.left,
1869
- right: t.left,
1870
- top: s.top,
2078
+ left: r.left,
2079
+ right: e.left,
2080
+ top: r.top,
1871
2081
  width: 0
1872
2082
  };
1873
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2083
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1874
2084
  }
1875
2085
  {
1876
- const r = {
1877
- bottom: t.top,
2086
+ const s = {
2087
+ bottom: e.top,
1878
2088
  height: 0,
1879
- left: t.left,
1880
- right: t.right,
1881
- top: s.top,
2089
+ left: e.left,
2090
+ right: e.right,
2091
+ top: r.top,
1882
2092
  width: 0
1883
2093
  };
1884
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2094
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1885
2095
  }
1886
2096
  {
1887
- const r = {
1888
- bottom: s.bottom,
2097
+ const s = {
2098
+ bottom: r.bottom,
1889
2099
  height: 0,
1890
- left: t.left,
1891
- right: t.right,
1892
- top: t.bottom,
2100
+ left: e.left,
2101
+ right: e.right,
2102
+ top: e.bottom,
1893
2103
  width: 0
1894
2104
  };
1895
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2105
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1896
2106
  }
1897
2107
  {
1898
- const r = {
1899
- bottom: s.bottom,
2108
+ const s = {
2109
+ bottom: r.bottom,
1900
2110
  height: 0,
1901
- left: t.right,
1902
- right: s.right,
1903
- top: s.top,
2111
+ left: e.right,
2112
+ right: r.right,
2113
+ top: r.top,
1904
2114
  width: 0
1905
2115
  };
1906
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2116
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1907
2117
  }
1908
2118
  return i;
1909
2119
  }
1910
- function Ot(s, e) {
1911
- const t = Math.max(s.left, e.left), i = Math.min(s.right, e.right), r = Math.max(s.top, e.top), n = Math.min(s.bottom, e.bottom);
2120
+ function Ye(r, t) {
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);
1912
2122
  return {
1913
2123
  bottom: n,
1914
- height: Math.max(0, n - r),
1915
- left: t,
2124
+ height: Math.max(0, n - s),
2125
+ left: e,
1916
2126
  right: i,
1917
- top: r,
1918
- width: Math.max(0, i - t)
2127
+ top: s,
2128
+ width: Math.max(0, i - e)
1919
2129
  };
1920
2130
  }
1921
- function ot(s, e, t) {
1922
- return (s.left < e.right || t >= 0 && P(s.left, e.right, t)) && (e.left < s.right || t >= 0 && P(e.left, s.right, t)) && (s.top < e.bottom || t >= 0 && P(s.top, e.bottom, t)) && (e.top < s.bottom || t >= 0 && P(e.top, s.bottom, t));
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));
1923
2133
  }
1924
- function P(s, e, t) {
1925
- return Math.abs(s - e) <= t;
2134
+ function R(r, t, e) {
2135
+ return Math.abs(r - t) <= e;
1926
2136
  }
1927
- function Me(s) {
1928
- const e = {}, t = s.document.documentElement.style;
1929
- for (const i in s.document.documentElement.style)
1930
- Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
1931
- return e;
2137
+ function zt(r) {
2138
+ const t = {}, e = r.document.documentElement.style;
2139
+ for (const i in r.document.documentElement.style)
2140
+ Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
2141
+ return t;
1932
2142
  }
1933
- function at(s, e) {
1934
- const t = Me(s);
1935
- Object.keys(t).forEach((i) => {
1936
- e.hasOwnProperty(i) || oe(s, i);
1937
- }), Object.entries(e).forEach(([i, r]) => {
1938
- t[i] !== r && X(s, i, r);
2143
+ function Ae(r, t) {
2144
+ const e = zt(r);
2145
+ Object.keys(e).forEach((i) => {
2146
+ t.hasOwnProperty(i) || ut(r, i);
2147
+ }), Object.entries(t).forEach(([i, s]) => {
2148
+ e[i] !== s && Q(r, i, s);
1939
2149
  });
1940
2150
  }
1941
- function le(s, e) {
1942
- return s.document.documentElement.style.getPropertyValue(e);
2151
+ function pt(r, t) {
2152
+ return r.document.documentElement.style.getPropertyValue(t);
1943
2153
  }
1944
- function X(s, e, t) {
1945
- s.document.documentElement.style.setProperty(e, t);
2154
+ function Q(r, t, e) {
2155
+ r.document.documentElement.style.setProperty(t, e);
1946
2156
  }
1947
- function oe(s, e) {
1948
- s.document.documentElement.style.removeProperty(e);
2157
+ function ut(r, t) {
2158
+ r.document.documentElement.style.removeProperty(t);
1949
2159
  }
1950
- let Z = null, he = null, $ = 0;
1951
- const B = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), Lt = () => {
1952
- if (!Z)
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)
1953
2163
  if (typeof OffscreenCanvas < "u")
1954
- Z = new OffscreenCanvas(5, 5), he = Z.getContext("2d", {
2164
+ it = new OffscreenCanvas(5, 5), ft = it.getContext("2d", {
1955
2165
  willReadFrequently: !0,
1956
2166
  desynchronized: !0
1957
2167
  });
1958
2168
  else {
1959
- const s = document.createElement("canvas");
1960
- s.width = 5, s.height = 5, Z = s, he = s.getContext("2d", {
2169
+ const r = document.createElement("canvas");
2170
+ r.width = 5, r.height = 5, it = r, ft = r.getContext("2d", {
1961
2171
  willReadFrequently: !0,
1962
2172
  desynchronized: !0
1963
2173
  });
1964
2174
  }
1965
- return he;
1966
- }, Rt = (s) => {
1967
- if (!s) return !0;
1968
- const e = s.trim().toLowerCase();
1969
- return e.startsWith("var(") || [
2175
+ return ft;
2176
+ }, Xe = (r) => {
2177
+ if (!r) return !0;
2178
+ const t = r.trim().toLowerCase();
2179
+ return t.startsWith("var(") || [
1970
2180
  "transparent",
1971
2181
  "currentcolor",
1972
2182
  "inherit",
@@ -1974,86 +2184,86 @@ const B = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), Lt =
1974
2184
  "revert",
1975
2185
  "unset",
1976
2186
  "revert-layer"
1977
- ].includes(e) ? !0 : [
2187
+ ].includes(t) ? !0 : [
1978
2188
  "linear-gradient",
1979
2189
  "radial-gradient",
1980
2190
  "conic-gradient",
1981
2191
  "repeating-linear-gradient",
1982
2192
  "repeating-radial-gradient",
1983
2193
  "repeating-conic-gradient"
1984
- ].some((r) => e.includes(r));
1985
- }, J = (s, e) => {
2194
+ ].some((s) => t.includes(s));
2195
+ }, st = (r, t) => {
1986
2196
  console.warn(
1987
- `[Decorator] Could not parse color: "${s}". ${e} Falling back to ${JSON.stringify(B)} 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(V)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
1988
2198
  );
1989
- }, de = (s, e = null) => {
1990
- const t = e ? `${s}|${e}` : s, i = F.get(t);
2199
+ }, bt = (r, t = null) => {
2200
+ const e = t ? `${r}|${t}` : r, i = _.get(e);
1991
2201
  if (i !== void 0)
1992
- return i ?? B;
1993
- if (Rt(s))
1994
- return J(s, "Unsupported color format or special value."), F.set(t, null), B;
1995
- const r = Lt();
1996
- if (!r)
1997
- return J(s, "Could not get canvas context."), F.set(t, null), B;
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();
2206
+ if (!s)
2207
+ return st(r, "Could not get canvas context."), _.set(e, null), V;
1998
2208
  try {
1999
- $ === 0 && r.clearRect(0, 0, 5, 5);
2000
- const n = $ % 5, o = Math.floor($ / 5);
2001
- r.clearRect(n, o, 1, 1), e && (r.fillStyle = e, r.fillRect(n, o, 1, 1)), r.fillStyle = s, r.fillRect(n, o, 1, 1);
2002
- const a = r.getImageData(n, o, 1, 1);
2003
- $ = ($ + 1) % 25;
2004
- const [u, h, c, m] = a.data;
2005
- if (m === 0)
2006
- return J(s, "Fully transparent color."), F.set(t, null), B;
2007
- const d = { r: u, g: h, b: c, a: m / 255 };
2008
- return F.set(t, d), d;
2209
+ q === 0 && s.clearRect(0, 0, 5, 5);
2210
+ const n = q % 5, o = Math.floor(q / 5);
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
+ const a = s.getImageData(n, o, 1, 1);
2213
+ q = (q + 1) % 25;
2214
+ const [d, h, u, g] = a.data;
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;
2009
2219
  } catch (n) {
2010
- return J(s, `Error: ${n instanceof Error ? n.message : String(n)}`), F.set(t, null), B;
2011
- }
2012
- }, ce = (s) => {
2013
- const e = s / 255;
2014
- return e <= 0.03928 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
2015
- }, ke = (s) => {
2016
- const e = ce(s.r), t = ce(s.g), i = ce(s.b);
2017
- return 0.2126 * e + 0.7152 * t + 0.0722 * i;
2018
- }, $e = (s, e) => {
2019
- const t = typeof s == "string" ? de(s) : s, i = typeof e == "string" ? de(e) : e, r = ke(t), n = ke(i), o = Math.max(r, n), a = Math.min(r, n);
2220
+ return st(r, `Error: ${n instanceof Error ? n.message : String(n)}`), _.set(e, null), V;
2221
+ }
2222
+ }, mt = (r) => {
2223
+ const t = r / 255;
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);
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);
2020
2230
  return (o + 0.05) / (a + 0.05);
2021
- }, pe = (s, e = null) => {
2022
- const t = de(s, e), i = $e(t, { r: 255, g: 255, b: 255, a: 1 }), r = $e(t, { r: 0, g: 0, b: 0, a: 1 });
2023
- return i > r;
2024
- }, It = (s, e = null) => pe(s, e) ? "white" : "black", Ve = "#FFFF00";
2025
- var zt = /* @__PURE__ */ ((s) => (s.Wrap = "wrap", s.Viewport = "viewport", s.Bounds = "bounds", s.Page = "page", s))(zt || {}), Dt = /* @__PURE__ */ ((s) => (s.Boxes = "boxes", s.Bounds = "bounds", s))(Dt || {});
2026
- const Wt = () => "Highlight" in window, qe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2027
- class Ft {
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 });
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 {
2028
2238
  /**
2029
2239
  * Creates a DecorationGroup object
2030
2240
  * @param id Unique HTML ID-adhering name of the group
2031
2241
  * @param name Human-readable name of the group
2032
2242
  */
2033
- constructor(e, t, i, r) {
2034
- this.wnd = e, this.comms = t, this.id = i, this.name = r, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Wt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
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());
2035
2245
  }
2036
2246
  get activeable() {
2037
2247
  return this.activateable;
2038
2248
  }
2039
- set activeable(e) {
2040
- this.activateable = e;
2249
+ set activeable(t) {
2250
+ this.activateable = t;
2041
2251
  }
2042
2252
  /**
2043
2253
  * Adds a new decoration to the group.
2044
2254
  * @param decoration Decoration to add
2045
2255
  */
2046
- add(e) {
2047
- const t = `${this.id}-${this.lastItemId++}`, i = ne(this.wnd.document, e.locator);
2256
+ add(t) {
2257
+ const e = `${this.id}-${this.lastItemId++}`, i = ht(this.wnd.document, t.locator);
2048
2258
  if (!i) {
2049
- this.comms.log("Can't locate DOM range for decoration", e);
2259
+ this.comms.log("Can't locate DOM range for decoration", t);
2050
2260
  return;
2051
2261
  }
2052
- const r = i.commonAncestorContainer;
2053
- r.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (qe.includes(r.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), i.cloneContents().querySelector(qe.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (r.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));
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));
2054
2264
  const n = {
2055
- decoration: e,
2056
- id: t,
2265
+ decoration: t,
2266
+ id: e,
2057
2267
  range: i
2058
2268
  };
2059
2269
  this.items.push(n), this.layout(n), this.renderLayout([n]);
@@ -2062,18 +2272,18 @@ class Ft {
2062
2272
  * Removes the decoration with given ID from the group.
2063
2273
  * @param identifier ID of item to remove
2064
2274
  */
2065
- remove(e) {
2066
- const t = this.items.findIndex((r) => r.decoration.id === e);
2067
- if (t < 0) return;
2068
- const i = this.items[t];
2069
- this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
2275
+ remove(t) {
2276
+ const e = this.items.findIndex((s) => s.decoration.id === t);
2277
+ if (e < 0) return;
2278
+ const i = this.items[e];
2279
+ this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
2070
2280
  }
2071
2281
  /**
2072
2282
  * Notifies that the given decoration was modified and needs to be updated.
2073
2283
  * @param decoration Decoration to update
2074
2284
  */
2075
- update(e) {
2076
- this.remove(e.id), this.add(e);
2285
+ update(t) {
2286
+ this.remove(t.id), this.add(t);
2077
2287
  }
2078
2288
  /**
2079
2289
  * Removes all decorations from this group.
@@ -2086,15 +2296,15 @@ class Ft {
2086
2296
  * To be called after reflowing the resource, for example.
2087
2297
  */
2088
2298
  requestLayout() {
2089
- this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
2299
+ this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);
2090
2300
  }
2091
- experimentalLayout(e) {
2092
- const [t, i] = this.requireContainer(!0);
2093
- i.add(e.range);
2094
- const r = le(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = e.decoration?.style?.tint ?? Ve;
2095
- t.innerHTML = `
2301
+ experimentalLayout(t) {
2302
+ const [e, i] = this.requireContainer(!0);
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;
2305
+ e.innerHTML = `
2096
2306
  ::highlight(${this.id}) {
2097
- color: ${It(n, r)};
2307
+ color: ${Ke(n, s)};
2098
2308
  background-color: ${n};
2099
2309
  }`;
2100
2310
  }
@@ -2102,84 +2312,84 @@ class Ft {
2102
2312
  * Layouts a single DecorationItem.
2103
2313
  * @param item
2104
2314
  */
2105
- layout(e) {
2106
- if (this.experimentalHighlights && !this.notTextFlag?.has(e.id))
2107
- return this.experimentalLayout(e);
2108
- const t = this.wnd.document.createElement("div");
2109
- t.setAttribute("id", e.id), t.dataset.highlightId = e.decoration.id, t.style.setProperty("pointer-events", "none");
2110
- const i = this.wnd.innerWidth, r = parseInt(
2315
+ layout(t) {
2316
+ if (this.experimentalHighlights && !this.notTextFlag?.has(t.id))
2317
+ return this.experimentalLayout(t);
2318
+ const e = this.wnd.document.createElement("div");
2319
+ e.setAttribute("id", t.id), e.dataset.highlightId = t.decoration.id, e.style.setProperty("pointer-events", "none");
2320
+ const i = this.wnd.innerWidth, s = parseInt(
2111
2321
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2112
2322
  "column-count"
2113
2323
  )
2114
- ), n = i / (r || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, u = o.scrollTop, h = (p, f, g) => {
2115
- if (p.style.position = "absolute", e.decoration?.style?.width === "viewport") {
2116
- p.style.width = `${i}px`, p.style.height = `${f.height}px`;
2117
- let E = Math.floor(f.left / i) * i;
2118
- p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
2119
- } else if (e.decoration?.style?.width === "bounds")
2120
- p.style.width = `${g.width}px`, p.style.height = `${f.height}px`, p.style.left = `${g.left + a}px`, p.style.top = `${f.top + u}px`;
2121
- else if (e.decoration?.style?.width === "page") {
2122
- p.style.width = `${n}px`, p.style.height = `${f.height}px`;
2123
- let E = Math.floor(f.left / n) * n;
2124
- p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
2324
+ ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f, m, v) => {
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`;
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`;
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`;
2125
2335
  } else
2126
- p.style.width = `${f.width}px`, p.style.height = `${f.height}px`, p.style.left = `${f.left + a}px`, p.style.top = `${f.top + u}px`;
2127
- }, c = e.range.getBoundingClientRect();
2128
- let m = this.wnd.document.createElement("template");
2129
- const d = this.getCurrentDarkMode();
2130
- m.innerHTML = `
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`;
2337
+ }, u = t.range.getBoundingClientRect();
2338
+ let g = this.wnd.document.createElement("template");
2339
+ const p = this.getCurrentDarkMode();
2340
+ g.innerHTML = `
2131
2341
  <div
2132
2342
  data-readium="true"
2133
2343
  class="readium-highlight"
2134
2344
  style="${[
2135
- `background-color: ${e.decoration?.style?.tint ?? Ve} !important`,
2345
+ `background-color: ${t.decoration?.style?.tint ?? se} !important`,
2136
2346
  //"opacity: 0.3 !important",
2137
- `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2347
+ `mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
2138
2348
  "opacity: 1 !important",
2139
2349
  "box-sizing: border-box !important"
2140
2350
  ].join("; ")}"
2141
2351
  >
2142
2352
  </div>
2143
2353
  `.trim();
2144
- const y = m.content.firstElementChild;
2145
- if (e.decoration?.style?.layout === "bounds") {
2146
- const p = y.cloneNode(!0);
2147
- p.style.setProperty("pointer-events", "none"), h(p, c, c), t.append(p);
2354
+ const y = g.content.firstElementChild;
2355
+ if (t.decoration?.style?.layout === "bounds") {
2356
+ const f = y.cloneNode(!0);
2357
+ f.style.setProperty("pointer-events", "none"), h(f, u, u), e.append(f);
2148
2358
  } else {
2149
- let p = Pt(
2150
- e.range
2359
+ let f = _e(
2360
+ t.range
2151
2361
  );
2152
- p = p.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);
2153
- for (let f of p) {
2154
- const g = y.cloneNode(!0);
2155
- g.style.setProperty("pointer-events", "none"), h(g, f, c), t.append(g);
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);
2156
2366
  }
2157
2367
  }
2158
- e.container = t, e.clickableElements = Array.from(
2159
- t.querySelectorAll("[data-activable='1']")
2160
- ), e.clickableElements.length || (e.clickableElements = Array.from(t.children));
2368
+ t.container = e, t.clickableElements = Array.from(
2369
+ e.querySelectorAll("[data-activable='1']")
2370
+ ), t.clickableElements.length || (t.clickableElements = Array.from(e.children));
2161
2371
  }
2162
- renderLayout(e) {
2372
+ renderLayout(t) {
2163
2373
  this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
2164
- if (e = e.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !e || e.length === 0) return;
2165
- this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
2374
+ if (t = t.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !t || t.length === 0) return;
2375
+ this.requireContainer().append(...t.map((i) => i.container).filter((i) => !!i));
2166
2376
  });
2167
2377
  }
2168
2378
  /**
2169
2379
  * Returns the group container element, after making sure it exists.
2170
2380
  * @returns Group's container
2171
2381
  */
2172
- requireContainer(e = !1) {
2173
- if (e) {
2174
- let t;
2175
- this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));
2382
+ requireContainer(t = !1) {
2383
+ if (t) {
2384
+ let e;
2385
+ this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));
2176
2386
  let i;
2177
- return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];
2387
+ return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];
2178
2388
  }
2179
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;
2180
2390
  }
2181
2391
  getCurrentDarkMode() {
2182
- return le(this.wnd, "--USER__appearance") === "readium-night-on" || pe(le(this.wnd, "--USER__backgroundColor")) || pe(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
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"));
2183
2393
  }
2184
2394
  /**
2185
2395
  * Removes the group container.
@@ -2188,36 +2398,36 @@ class Ft {
2188
2398
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2189
2399
  }
2190
2400
  }
2191
- const q = class q extends Y {
2401
+ const K = class K extends tt {
2192
2402
  constructor() {
2193
2403
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2194
2404
  }
2195
2405
  cleanup() {
2196
- this.groups.forEach((e) => e.clear()), this.groups.clear();
2406
+ this.groups.forEach((t) => t.clear()), this.groups.clear();
2197
2407
  }
2198
2408
  updateHighlightStyles() {
2199
- this.groups.forEach((e) => {
2200
- e.requestLayout();
2409
+ this.groups.forEach((t) => {
2410
+ t.requestLayout();
2201
2411
  });
2202
2412
  }
2203
- extractCustomProperty(e, t) {
2204
- if (!e) return null;
2205
- const i = e.match(new RegExp(`${t}:\\s*([^;]+)`));
2413
+ extractCustomProperty(t, e) {
2414
+ if (!t) return null;
2415
+ const i = t.match(new RegExp(`${e}:\\s*([^;]+)`));
2206
2416
  return i ? i[1].trim() : null;
2207
2417
  }
2208
2418
  handleResize() {
2209
2419
  this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
2210
- this.groups.forEach((e) => {
2211
- e.experimentalHighlights || e.requestLayout();
2420
+ this.groups.forEach((t) => {
2421
+ t.experimentalHighlights || t.requestLayout();
2212
2422
  });
2213
2423
  }, 50);
2214
2424
  }
2215
- mount(e, t) {
2216
- return this.wnd = e, t.register("decorate", q.moduleName, (i, r) => {
2425
+ mount(t, e) {
2426
+ return this.wnd = t, e.register("decorate", K.moduleName, (i, s) => {
2217
2427
  const n = i;
2218
- n.decoration && n.decoration.locator && (n.decoration.locator = R.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Ft(
2219
- e,
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(
2220
2429
  t,
2430
+ e,
2221
2431
  `readium-decoration-${this.lastGroupId++}`,
2222
2432
  n.group
2223
2433
  ));
@@ -2236,29 +2446,29 @@ const q = class q extends Y {
2236
2446
  o?.update(n.decoration);
2237
2447
  break;
2238
2448
  }
2239
- r(!0);
2240
- }), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
2449
+ s(!0);
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) => {
2241
2451
  i.some((n) => {
2242
2452
  if (n.type === "attributes" && n.attributeName === "style") {
2243
- const o = n.target, a = n.oldValue, u = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), c = this.extractCustomProperty(u, "--USER__appearance"), m = this.extractCustomProperty(a, "--USER__backgroundColor"), d = this.extractCustomProperty(u, "--USER__backgroundColor");
2244
- return h !== c || m !== d;
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;
2245
2455
  }
2246
2456
  return !1;
2247
2457
  }) && this.updateHighlightStyles();
2248
- }), this.backgroundObserver.observe(e.document.documentElement, {
2458
+ }), this.backgroundObserver.observe(t.document.documentElement, {
2249
2459
  attributes: !0,
2250
2460
  attributeFilter: ["style"],
2251
2461
  attributeOldValue: !0,
2252
2462
  subtree: !0
2253
- }), t.log("Decorator Mounted"), !0;
2463
+ }), e.log("Decorator Mounted"), !0;
2254
2464
  }
2255
- unmount(e, t) {
2256
- return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
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;
2257
2467
  }
2258
2468
  };
2259
- q.moduleName = "decorator";
2260
- let fe = q;
2261
- const je = "readium-snapper-style", j = class j extends Y {
2469
+ K.moduleName = "decorator";
2470
+ let yt = K;
2471
+ const ne = "readium-snapper-style", Z = class Z extends tt {
2262
2472
  constructor() {
2263
2473
  super(...arguments), this.protected = !1;
2264
2474
  }
@@ -2269,61 +2479,61 @@ const je = "readium-snapper-style", j = class j extends Y {
2269
2479
  user-select: ${this.protected ? "none" : "auto"};
2270
2480
  }`;
2271
2481
  }
2272
- mount(e, t) {
2273
- const i = e.document.createElement("style");
2274
- return i.dataset.readium = "true", i.id = je, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", j.moduleName, (r, n) => {
2482
+ mount(t, e) {
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) => {
2275
2485
  this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2276
- }), t.register("unprotect", j.moduleName, (r, n) => {
2486
+ }), e.register("unprotect", Z.moduleName, (s, n) => {
2277
2487
  this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2278
- }), t.log("Snapper Mounted"), !0;
2488
+ }), e.log("Snapper Mounted"), !0;
2279
2489
  }
2280
- unmount(e, t) {
2281
- return e.document.getElementById(je)?.remove(), t.log("Snapper Unmounted"), !0;
2490
+ unmount(t, e) {
2491
+ return t.document.getElementById(ne)?.remove(), e.log("Snapper Unmounted"), !0;
2282
2492
  }
2283
2493
  };
2284
- j.moduleName = "snapper";
2285
- let G = j;
2286
- function z(s) {
2287
- return s.document.body.dir.toLowerCase() === "rtl";
2494
+ Z.moduleName = "snapper";
2495
+ let j = Z;
2496
+ function B(r) {
2497
+ return r.document.body.dir.toLowerCase() === "rtl";
2288
2498
  }
2289
- function lt(s) {
2499
+ function Ee(r) {
2290
2500
  return parseInt(
2291
- s.getComputedStyle(
2292
- s.document.documentElement
2501
+ r.getComputedStyle(
2502
+ r.document.documentElement
2293
2503
  ).getPropertyValue("column-count")
2294
2504
  );
2295
2505
  }
2296
- function _e(s) {
2297
- const e = getComputedStyle(s), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
2298
- return s.clientHeight - t - i;
2506
+ function oe(r) {
2507
+ const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
2508
+ return r.clientHeight - e - i;
2299
2509
  }
2300
- function Xe(s) {
2301
- const e = lt(s);
2302
- if (!e)
2510
+ function ae(r) {
2511
+ const t = Ee(r);
2512
+ if (!t)
2303
2513
  return !1;
2304
- const t = s.document.querySelectorAll("div[id^='readium-virtual-page']");
2305
- for (const h of t)
2514
+ const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2515
+ for (const h of e)
2306
2516
  h.remove();
2307
- const i = t.length, r = s.document.scrollingElement.scrollWidth, n = s.visualViewport.width, a = Math.round(r / n * e) % e, u = e === 1 || a === 0 ? 0 : e - a;
2308
- if (u > 0)
2309
- for (let h = 0; h < u; h++) {
2310
- const c = s.document.createElement("div");
2311
- c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = _e(s.document.documentElement) + "px"), c.innerHTML = "&#8203;", s.document.body.appendChild(c);
2517
+ const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t, d = t === 1 || a === 0 ? 0 : t - a;
2518
+ if (d > 0)
2519
+ for (let h = 0; h < d; h++) {
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);
2312
2522
  }
2313
- return i !== u;
2523
+ return i !== d;
2314
2524
  }
2315
- function ht(s) {
2316
- const e = s.document.createElement("style");
2317
- e.appendChild(s.document.createTextNode("*{}")), s.document.body.appendChild(e), s.document.body.removeChild(e);
2525
+ function Se(r) {
2526
+ const t = r.document.createElement("style");
2527
+ t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
2318
2528
  }
2319
- function Ut(s) {
2320
- return s < 0.5 ? 2 * s * s : -1 + (4 - 2 * s) * s;
2529
+ function ti(r) {
2530
+ return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2321
2531
  }
2322
- function v(s) {
2323
- const e = s.getSelection();
2324
- e && e.removeAllRanges();
2532
+ function S(r) {
2533
+ const t = r.getSelection();
2534
+ t && t.removeAllRanges();
2325
2535
  }
2326
- const Bt = [
2536
+ const ei = [
2327
2537
  "a",
2328
2538
  "audio",
2329
2539
  "button",
@@ -2337,56 +2547,56 @@ const Bt = [
2337
2547
  "textarea",
2338
2548
  "video"
2339
2549
  ];
2340
- function ct(s) {
2341
- return Bt.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && s.getAttribute("contenteditable")?.toLowerCase() !== "false" ? s : s.parentElement ? ct(s.parentElement) : null;
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;
2342
2552
  }
2343
- function Ne(s, e) {
2344
- const t = ut(s, s.document.body, e), i = s._readium_cssSelectorGenerator.getCssSelector(t, {
2553
+ function Dt(r, t) {
2554
+ const e = Te(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
2345
2555
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2346
2556
  });
2347
- return new R({
2557
+ return new U({
2348
2558
  href: "#",
2349
2559
  type: "application/xhtml+xml",
2350
- locations: new b({
2560
+ locations: new x({
2351
2561
  otherLocations: /* @__PURE__ */ new Map([
2352
2562
  ["cssSelector", i]
2353
2563
  ])
2354
2564
  }),
2355
- text: new D({
2356
- highlight: t.textContent || void 0
2565
+ text: new H({
2566
+ highlight: e.textContent || void 0
2357
2567
  })
2358
2568
  });
2359
2569
  }
2360
- function ut(s, e, t) {
2361
- for (var i = 0; i < e.children.length; i++) {
2362
- const r = e.children[i];
2363
- if (!$t(r) && Ht(s, r, t))
2364
- return kt(s, r) ? r : ut(s, r, t);
2570
+ function Te(r, t, e) {
2571
+ for (var i = 0; i < t.children.length; i++) {
2572
+ const s = t.children[i];
2573
+ if (!ri(s) && ii(r, s, e))
2574
+ return si(r, s) ? s : Te(r, s, e);
2365
2575
  }
2366
- return e;
2576
+ return t;
2367
2577
  }
2368
- function Ht(s, e, t) {
2369
- if (e === document.body || e === document.documentElement)
2578
+ function ii(r, t, e) {
2579
+ if (t === document.body || t === document.documentElement)
2370
2580
  return !0;
2371
2581
  if (!document || !document.documentElement || !document.body)
2372
2582
  return !1;
2373
- const i = e.getBoundingClientRect();
2374
- return t ? i.bottom > 0 && i.top < s.innerHeight : i.right > 0 && i.left < s.innerWidth;
2375
- }
2376
- function kt(s, e) {
2377
- const t = e.getBoundingClientRect();
2378
- return t.top >= 0 && t.left >= 0 && t.bottom <= s.innerHeight && t.right <= s.innerWidth;
2379
- }
2380
- function $t(s) {
2381
- const e = getComputedStyle(s);
2382
- if (e) {
2383
- const t = e.getPropertyValue("display");
2384
- if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
2583
+ const i = t.getBoundingClientRect();
2584
+ return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2585
+ }
2586
+ function si(r, t) {
2587
+ const e = t.getBoundingClientRect();
2588
+ return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
2589
+ }
2590
+ function ri(r) {
2591
+ const t = getComputedStyle(r);
2592
+ if (t) {
2593
+ const e = t.getPropertyValue("display");
2594
+ if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
2385
2595
  return !0;
2386
2596
  }
2387
2597
  return !1;
2388
2598
  }
2389
- const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2599
+ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
2390
2600
  constructor() {
2391
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);
2392
2602
  }
@@ -2396,55 +2606,55 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2396
2606
  scrollOffset() {
2397
2607
  return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
2398
2608
  }
2399
- snapOffset(e) {
2400
- const t = e + (z(this.wnd) ? -1 : 1);
2401
- return t - t % this.wnd.innerWidth;
2609
+ snapOffset(t) {
2610
+ const e = t + (B(this.wnd) ? -1 : 1);
2611
+ return e - e % this.wnd.innerWidth;
2402
2612
  }
2403
2613
  reportProgress() {
2404
- const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)), r = Math.max(0, Math.min(1, (e + this.wnd.innerWidth) / t));
2614
+ const t = this.wnd.scrollX, e = this.cachedScrollWidth, i = Math.max(0, Math.min(1, t / e)), s = Math.max(0, Math.min(1, (t + this.wnd.innerWidth) / e));
2405
2615
  this.comms.send("progress", {
2406
2616
  start: i,
2407
- end: r
2617
+ end: s
2408
2618
  });
2409
2619
  }
2410
2620
  shake() {
2411
2621
  if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
2412
- const e = this.doc();
2413
- e.classList.add(z(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2414
- const t = this.scrollOffset();
2622
+ const t = this.doc();
2623
+ t.classList.add(B(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2624
+ const e = this.scrollOffset();
2415
2625
  this.shakeTimeout = this.wnd.setTimeout(() => {
2416
- e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
2626
+ t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;
2417
2627
  }, 150);
2418
2628
  }
2419
2629
  // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
2420
2630
  takeOverSnap() {
2421
2631
  this.snappingCancelled = !0, this.clearTouches();
2422
- const e = this.doc();
2423
- this.overscroll = e.style.transform?.length > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;
2632
+ const t = this.doc();
2633
+ this.overscroll = t.style.transform?.length > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;
2424
2634
  }
2425
2635
  // Snaps the current offset to the page width.
2426
- snapCurrentOffset(e = !1, t = !1) {
2427
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, r = this.doc(), n = this.dragOffset(), o = lt(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), u = z(this.wnd) ? -1 : 1, h = (
2636
+ 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 = (
2428
2638
  // The hurdle to overcome in order to change pages
2429
- u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)
2430
- ), c = this.snapOffset(a + h);
2431
- if (e && c !== this.scrollOffset()) {
2639
+ d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
2640
+ ), u = this.snapOffset(a + h);
2641
+ if (t && u !== this.scrollOffset()) {
2432
2642
  this.snappingCancelled = !1;
2433
- const m = (f, g, E, W) => E > W ? g : f + (g - f) * Ut(E / W), d = (
2643
+ const g = (m, v, C, G) => C > G ? v : m + (v - m) * ti(C / G), p = (
2434
2644
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2435
- Vt * o
2645
+ ni * o
2436
2646
  );
2437
2647
  let y;
2438
- const p = (f) => {
2648
+ const f = (m) => {
2439
2649
  if (this.snappingCancelled) return;
2440
- y || (y = f);
2441
- const g = f - y, E = m(this.overscroll, 0, g, d), W = m(i, c, g, d);
2442
- r.scrollLeft = W, this.overscroll !== 0 && (r.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < d ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), r.style.removeProperty("transform"), r.scrollLeft = c, t || this.reportProgress());
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());
2443
2653
  };
2444
- this.wnd.requestAnimationFrame(p);
2654
+ this.wnd.requestAnimationFrame(f);
2445
2655
  } else
2446
- r.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2447
- r.scrollLeft = c, this.clearTouches(), t || this.reportProgress();
2656
+ s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2657
+ s.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
2448
2658
  });
2449
2659
  }
2450
2660
  dragOffset() {
@@ -2453,41 +2663,41 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2453
2663
  clearTouches() {
2454
2664
  this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
2455
2665
  }
2456
- onTouchStart(e) {
2457
- switch (e.stopPropagation(), this.takeOverSnap(), e.touches.length) {
2666
+ onTouchStart(t) {
2667
+ switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {
2458
2668
  case 1:
2459
2669
  break;
2460
2670
  case 2:
2461
- this.onTouchEnd(e);
2671
+ this.onTouchEnd(t);
2462
2672
  return;
2463
2673
  default: {
2464
- this.onTouchEnd(e), this.comms.send("tap_more", e.touches.length);
2674
+ this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);
2465
2675
  return;
2466
2676
  }
2467
2677
  }
2468
- this.startingX = e.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2678
+ this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2469
2679
  }
2470
- onTouchEnd(e) {
2680
+ onTouchEnd(t) {
2471
2681
  if (this.touchState === 2) {
2472
- const t = this.dragOffset(), i = this.scrollOffset();
2473
- this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
2682
+ const e = this.dragOffset(), i = this.scrollOffset();
2683
+ this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), e > 5 && this.comms.send("no_more", void 0), e < -5 && this.comms.send("no_less", void 0)) : i < 5 && e < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && e > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
2474
2684
  }
2475
2685
  this.touchState = 0;
2476
2686
  }
2477
2687
  onWidthChange() {
2478
2688
  this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
2479
2689
  }
2480
- onTouchMove(e) {
2690
+ onTouchMove(t) {
2481
2691
  if (this.touchState === 0) return;
2482
- this.touchState === 1 && (this.touchState = 2, v(this.wnd)), this.endingX = e.touches[0].clientX;
2483
- const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2484
- 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 + t);
2485
- }
2486
- mount(e, t) {
2487
- if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;
2488
- e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
2489
- const i = e.document.createElement("style");
2490
- i.dataset.readium = "true", i.id = Ge, i.textContent = `
2692
+ this.touchState === 1 && (this.touchState = 2, S(this.wnd)), this.endingX = t.touches[0].clientX;
2693
+ const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
2694
+ 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
+ }
2696
+ mount(t, e) {
2697
+ if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
2698
+ t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
2699
+ const i = t.document.createElement("style");
2700
+ i.dataset.readium = "true", i.id = le, i.textContent = `
2491
2701
  @keyframes readium-bounce-l-animation {
2492
2702
  0%, 100% {transform: translate3d(0, 0, 0);}
2493
2703
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2521,54 +2731,54 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2521
2731
  body::-webkit-scrollbar {
2522
2732
  display: none; /* for Chrome, Safari, and Opera */
2523
2733
  }
2524
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2525
- e.requestAnimationFrame(() => {
2526
- e && Xe(e);
2734
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2735
+ t.requestAnimationFrame(() => {
2736
+ t && ae(t);
2527
2737
  }), this.onWidthChange();
2528
- }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2738
+ }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
2529
2739
  for (const o of n)
2530
2740
  if (o.target === this.wnd.document.documentElement) {
2531
- const a = o.oldValue, u = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = a?.match(h), m = u?.match(h);
2532
- (!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {
2533
- e && Xe(e);
2741
+ const a = o.oldValue, d = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a?.match(h), g = d?.match(h);
2742
+ (!u && !g || u && !g || u && g && u[1] !== g[1]) && (t.requestAnimationFrame(() => {
2743
+ t && ae(t);
2534
2744
  }), this.onWidthChange());
2535
2745
  } else
2536
- e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2537
- }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
2538
- const r = (n) => {
2746
+ 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"] });
2748
+ const s = (n) => {
2539
2749
  const o = this.doc().scrollLeft;
2540
2750
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2541
2751
  };
2542
- return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", x.moduleName, (n, o) => {
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) => {
2543
2753
  const a = n;
2544
2754
  if (a < 0 || a > 1) {
2545
- t.send("error", {
2755
+ e.send("error", {
2546
2756
  message: "go_progression must be given a position from 0.0 to 1.0"
2547
2757
  }), o(!1);
2548
2758
  return;
2549
2759
  }
2550
2760
  this.wnd.requestAnimationFrame(() => {
2551
2761
  this.cachedScrollWidth = this.doc().scrollWidth;
2552
- const u = this.cachedScrollWidth, h = z(e) ? -1 : 1, c = u * a * h;
2553
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), v(this.wnd), o(!0);
2762
+ 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);
2554
2764
  });
2555
- }), t.register("go_id", x.moduleName, (n, o) => {
2556
- const a = e.document.getElementById(n);
2765
+ }), e.register("go_id", N.moduleName, (n, o) => {
2766
+ const a = t.document.getElementById(n);
2557
2767
  if (!a) {
2558
2768
  o(!1);
2559
2769
  return;
2560
2770
  }
2561
2771
  this.wnd.requestAnimationFrame(() => {
2562
- this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
2772
+ this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2563
2773
  });
2564
- }), t.register("go_text", x.moduleName, (n, o) => {
2774
+ }), e.register("go_text", N.moduleName, (n, o) => {
2565
2775
  let a;
2566
2776
  Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
2567
- const u = D.deserialize(n), h = ne(this.wnd.document, new R({
2568
- href: e.location.href,
2777
+ const d = H.deserialize(n), h = ht(this.wnd.document, new U({
2778
+ href: t.location.href,
2569
2779
  type: "text/html",
2570
- text: u,
2571
- locations: a ? new b({
2780
+ text: d,
2781
+ locations: a ? new x({
2572
2782
  otherLocations: /* @__PURE__ */ new Map([
2573
2783
  ["cssSelector", a]
2574
2784
  ])
@@ -2579,54 +2789,54 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2579
2789
  return;
2580
2790
  }
2581
2791
  this.wnd.requestAnimationFrame(() => {
2582
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
2792
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2583
2793
  });
2584
- }), t.register("go_end", x.moduleName, (n, o) => {
2585
- const a = z(e) ? -1 : 1;
2794
+ }), e.register("go_end", N.moduleName, (n, o) => {
2795
+ const a = B(t) ? -1 : 1;
2586
2796
  this.wnd.requestAnimationFrame(() => {
2587
2797
  this.cachedScrollWidth = this.doc().scrollWidth;
2588
- const u = this.cachedScrollWidth * a;
2589
- if (this.doc().scrollLeft === u) return o(!1);
2590
- this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), v(this.wnd), o(!0);
2798
+ const d = this.cachedScrollWidth * a;
2799
+ if (this.doc().scrollLeft === d) return o(!1);
2800
+ this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), S(this.wnd), o(!0);
2591
2801
  });
2592
- }), t.register("go_start", x.moduleName, (n, o) => {
2802
+ }), e.register("go_start", N.moduleName, (n, o) => {
2593
2803
  this.wnd.requestAnimationFrame(() => {
2594
2804
  if (this.doc().scrollLeft === 0) return o(!1);
2595
- this.doc().scrollLeft = 0, this.reportProgress(), v(this.wnd), o(!0);
2805
+ this.doc().scrollLeft = 0, this.reportProgress(), S(this.wnd), o(!0);
2596
2806
  });
2597
- }), t.register("go_prev", x.moduleName, (n, o) => {
2807
+ }), e.register("go_prev", N.moduleName, (n, o) => {
2598
2808
  this.wnd.requestAnimationFrame(() => {
2599
2809
  this.cachedScrollWidth = this.doc().scrollWidth;
2600
- const a = e.scrollX - e.innerWidth, u = z(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = r(Math.max(a, u));
2601
- h && (this.reportProgress(), v(this.wnd)), o(h);
2810
+ 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);
2602
2812
  });
2603
- }), t.register("go_next", x.moduleName, (n, o) => {
2813
+ }), e.register("go_next", N.moduleName, (n, o) => {
2604
2814
  this.wnd.requestAnimationFrame(() => {
2605
2815
  this.cachedScrollWidth = this.doc().scrollWidth;
2606
- const a = e.scrollX + e.innerWidth, u = z(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = r(Math.min(a, u));
2607
- h && (this.reportProgress(), v(this.wnd)), o(h);
2816
+ 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);
2608
2818
  });
2609
- }), t.register("unfocus", x.moduleName, (n, o) => {
2610
- this.snappingCancelled = !0, v(this.wnd), o(!0);
2611
- }), t.register("shake", x.moduleName, (n, o) => {
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) => {
2612
2822
  this.shake(), o(!0);
2613
- }), t.register("focus", x.moduleName, (n, o) => {
2823
+ }), e.register("focus", N.moduleName, (n, o) => {
2614
2824
  this.wnd.requestAnimationFrame(() => {
2615
2825
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2616
2826
  });
2617
- }), t.register("first_visible_locator", x.moduleName, (n, o) => {
2618
- const a = Ne(e, !1);
2827
+ }), e.register("first_visible_locator", N.moduleName, (n, o) => {
2828
+ const a = Dt(t, !1);
2619
2829
  this.comms.send("first_visible_locator", a.serialize()), o(!0);
2620
- }), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
2621
- }), t.log("ColumnSnapper Mounted"), !0;
2830
+ }), 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
+ }), e.log("ColumnSnapper Mounted"), !0;
2622
2832
  }
2623
- unmount(e, t) {
2624
- return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(Ge)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2833
+ 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);
2625
2835
  }
2626
2836
  };
2627
- x.moduleName = "column_snapper";
2628
- let me = x;
2629
- const Ye = "readium-scroll-snapper-style", T = class T extends G {
2837
+ N.moduleName = "column_snapper";
2838
+ let wt = N;
2839
+ const ce = "readium-scroll-snapper-style", O = class O extends j {
2630
2840
  constructor() {
2631
2841
  super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
2632
2842
  if (this.comms.ready && !this.isResizing) {
@@ -2636,8 +2846,8 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2636
2846
  }
2637
2847
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2638
2848
  this.reportProgress();
2639
- const e = this.doc().scrollTop, t = e - this.lastScrollTop;
2640
- this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
2849
+ const t = this.doc().scrollTop, e = t - this.lastScrollTop;
2850
+ this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;
2641
2851
  }));
2642
2852
  }
2643
2853
  };
@@ -2647,16 +2857,16 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2647
2857
  }
2648
2858
  reportProgress() {
2649
2859
  if (!this.comms.ready) return;
2650
- const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, r = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
2860
+ const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
2651
2861
  this.comms.send("progress", {
2652
- start: r,
2862
+ start: s,
2653
2863
  end: n
2654
2864
  });
2655
2865
  }
2656
- mount(e, t) {
2657
- this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "scrolling");
2658
- const i = e.document.createElement("style");
2659
- return i.dataset.readium = "true", i.id = Ye, i.textContent = `
2866
+ mount(t, e) {
2867
+ 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
+ const i = t.document.createElement("style");
2869
+ return i.dataset.readium = "true", i.id = ce, i.textContent = `
2660
2870
  * {
2661
2871
  scrollbar-width: none; /* for Firefox */
2662
2872
  }
@@ -2664,79 +2874,79 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2664
2874
  body::-webkit-scrollbar {
2665
2875
  display: none; /* for Chrome, Safari, and Opera */
2666
2876
  }
2667
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2877
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2668
2878
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2669
2879
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2670
2880
  }, 50);
2671
- }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", T.moduleName, () => {
2672
- ht(this.wnd);
2673
- const r = this.doc().scrollTop;
2674
- r > 1 ? this.doc().scrollTop = r - 1 : this.doc().scrollTop = r + 1, this.doc().scrollTop = r;
2675
- }), t.register("go_progression", T.moduleName, (r, n) => {
2676
- const o = r;
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);
2883
+ const s = this.doc().scrollTop;
2884
+ 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) => {
2886
+ const o = s;
2677
2887
  if (o < 0 || o > 1) {
2678
- t.send("error", {
2888
+ e.send("error", {
2679
2889
  message: "go_progression must be given a position from 0.0 to 1.0"
2680
2890
  }), n(!1);
2681
2891
  return;
2682
2892
  }
2683
2893
  this.wnd.requestAnimationFrame(() => {
2684
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), v(this.wnd), n(!0);
2894
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), S(this.wnd), n(!0);
2685
2895
  });
2686
- }), t.register("go_id", T.moduleName, (r, n) => {
2687
- const o = e.document.getElementById(r);
2896
+ }), e.register("go_id", O.moduleName, (s, n) => {
2897
+ const o = t.document.getElementById(s);
2688
2898
  if (!o) {
2689
2899
  n(!1);
2690
2900
  return;
2691
2901
  }
2692
2902
  this.wnd.requestAnimationFrame(() => {
2693
- this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
2903
+ this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
2694
2904
  });
2695
- }), t.register("go_text", T.moduleName, (r, n) => {
2905
+ }), e.register("go_text", O.moduleName, (s, n) => {
2696
2906
  let o;
2697
- Array.isArray(r) && (r.length > 1 && (o = r[1]), r = r[0]);
2698
- const a = D.deserialize(r), u = ne(this.wnd.document, new R({
2699
- href: e.location.href,
2907
+ 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({
2909
+ href: t.location.href,
2700
2910
  type: "text/html",
2701
2911
  text: a,
2702
- locations: o ? new b({
2912
+ locations: o ? new x({
2703
2913
  otherLocations: /* @__PURE__ */ new Map([
2704
2914
  ["cssSelector", o]
2705
2915
  ])
2706
2916
  }) : void 0
2707
2917
  }));
2708
- if (!u) {
2918
+ if (!d) {
2709
2919
  n(!1);
2710
2920
  return;
2711
2921
  }
2712
2922
  this.wnd.requestAnimationFrame(() => {
2713
- this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
2923
+ this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
2714
2924
  });
2715
- }), t.register("go_start", T.moduleName, (r, n) => {
2925
+ }), e.register("go_start", O.moduleName, (s, n) => {
2716
2926
  if (this.doc().scrollTop === 0) return n(!1);
2717
2927
  this.doc().scrollTop = 0, this.reportProgress(), n(!0);
2718
- }), t.register("go_end", T.moduleName, (r, n) => {
2928
+ }), e.register("go_end", O.moduleName, (s, n) => {
2719
2929
  if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
2720
2930
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
2721
- }), t.register("unfocus", T.moduleName, (r, n) => {
2722
- v(this.wnd), n(!0);
2723
- }), t.register([
2931
+ }), e.register("unfocus", O.moduleName, (s, n) => {
2932
+ S(this.wnd), n(!0);
2933
+ }), e.register([
2724
2934
  "go_next",
2725
2935
  "go_prev"
2726
- ], T.moduleName, (r, n) => n(!1)), t.register("focus", T.moduleName, (r, n) => {
2936
+ ], O.moduleName, (s, n) => n(!1)), e.register("focus", O.moduleName, (s, n) => {
2727
2937
  this.reportProgress(), n(!0);
2728
- }), t.register("first_visible_locator", T.moduleName, (r, n) => {
2729
- const o = Ne(e, !0);
2938
+ }), e.register("first_visible_locator", O.moduleName, (s, n) => {
2939
+ const o = Dt(t, !0);
2730
2940
  this.comms.send("first_visible_locator", o.serialize()), n(!0);
2731
- }), t.log("ScrollSnapper Mounted"), !0;
2941
+ }), e.log("ScrollSnapper Mounted"), !0;
2732
2942
  }
2733
- unmount(e, t) {
2734
- return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(Ye)?.remove(), t.log("ScrollSnapper Unmounted"), !0;
2943
+ 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;
2735
2945
  }
2736
2946
  };
2737
- T.moduleName = "scroll_snapper";
2738
- let ge = T;
2739
- const w = class w extends G {
2947
+ O.moduleName = "scroll_snapper";
2948
+ let At = O;
2949
+ const P = class P extends j {
2740
2950
  constructor() {
2741
2951
  super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
2742
2952
  if (this.comms.ready && !this.isResizing) {
@@ -2746,8 +2956,8 @@ const w = class w extends G {
2746
2956
  }
2747
2957
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2748
2958
  this.reportProgress();
2749
- const e = this.doc().scrollTop, t = e - this.lastScrollTop;
2750
- this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
2959
+ const t = this.doc().scrollTop, e = t - this.lastScrollTop;
2960
+ this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;
2751
2961
  }));
2752
2962
  }
2753
2963
  };
@@ -2757,97 +2967,97 @@ const w = class w extends G {
2757
2967
  }
2758
2968
  reportProgress() {
2759
2969
  if (!this.comms.ready) return;
2760
- const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, r = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
2970
+ const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
2761
2971
  this.comms.send("progress", {
2762
- start: r,
2972
+ start: s,
2763
2973
  end: n
2764
2974
  });
2765
2975
  }
2766
- mount(e, t) {
2767
- return this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
2976
+ mount(t, e) {
2977
+ 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(() => {
2768
2978
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2769
2979
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2770
2980
  }, 50);
2771
- }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", w.moduleName, () => {
2772
- ht(this.wnd);
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);
2773
2983
  const i = this.doc().scrollTop;
2774
2984
  i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
2775
- }), t.register("go_progression", w.moduleName, (i, r) => {
2985
+ }), e.register("go_progression", P.moduleName, (i, s) => {
2776
2986
  const n = i;
2777
2987
  if (n < 0 || n > 1) {
2778
- t.send("error", {
2988
+ e.send("error", {
2779
2989
  message: "go_progression must be given a position from 0.0 to 1.0"
2780
- }), r(!1);
2990
+ }), s(!1);
2781
2991
  return;
2782
2992
  }
2783
2993
  this.wnd.requestAnimationFrame(() => {
2784
- this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd), r(!0);
2994
+ this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), S(this.wnd), s(!0);
2785
2995
  });
2786
- }), this.comms.register("go_id", w.moduleName, (i, r) => {
2787
- const n = e.document.getElementById(i);
2996
+ }), this.comms.register("go_id", P.moduleName, (i, s) => {
2997
+ const n = t.document.getElementById(i);
2788
2998
  if (!n) {
2789
- r(!1);
2999
+ s(!1);
2790
3000
  return;
2791
3001
  }
2792
3002
  this.wnd.requestAnimationFrame(() => {
2793
- this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
3003
+ this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), s(!0);
2794
3004
  });
2795
- }), t.register("go_text", w.moduleName, (i, r) => {
3005
+ }), e.register("go_text", P.moduleName, (i, s) => {
2796
3006
  let n;
2797
3007
  Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
2798
- const o = D.deserialize(i), a = ne(this.wnd.document, new R({
2799
- href: e.location.href,
3008
+ const o = H.deserialize(i), a = ht(this.wnd.document, new U({
3009
+ href: t.location.href,
2800
3010
  type: "text/html",
2801
3011
  text: o,
2802
- locations: n ? new b({
3012
+ locations: n ? new x({
2803
3013
  otherLocations: /* @__PURE__ */ new Map([
2804
3014
  ["cssSelector", n]
2805
3015
  ])
2806
3016
  }) : void 0
2807
3017
  }));
2808
3018
  if (!a) {
2809
- r(!1);
3019
+ s(!1);
2810
3020
  return;
2811
3021
  }
2812
3022
  this.wnd.requestAnimationFrame(() => {
2813
- this.doc().scrollTop = a.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
3023
+ this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), s(!0);
2814
3024
  });
2815
- }), t.register("go_start", w.moduleName, (i, r) => {
2816
- if (this.doc().scrollTop === 0) return r(!1);
2817
- this.doc().scrollTop = 0, this.reportProgress(), r(!0);
2818
- }), t.register("go_end", w.moduleName, (i, r) => {
2819
- if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return r(!1);
2820
- this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), r(!0);
2821
- }), t.register("unfocus", w.moduleName, (i, r) => {
2822
- v(this.wnd), r(!0);
2823
- }), t.register([
3025
+ }), e.register("go_start", P.moduleName, (i, s) => {
3026
+ if (this.doc().scrollTop === 0) return s(!1);
3027
+ this.doc().scrollTop = 0, this.reportProgress(), s(!0);
3028
+ }), e.register("go_end", P.moduleName, (i, s) => {
3029
+ if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
3030
+ 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);
3033
+ }), e.register([
2824
3034
  "go_next",
2825
3035
  "go_prev"
2826
- ], w.moduleName, (i, r) => r(!1)), t.register("focus", w.moduleName, (i, r) => {
2827
- this.reportProgress(), r(!0);
2828
- }), t.register("first_visible_locator", w.moduleName, (i, r) => {
2829
- const n = Ne(e, !0);
2830
- t.send("first_visible_locator", n.serialize()), r(!0);
2831
- }), t.log("WebPubSnapper Mounted"), !0;
3036
+ ], P.moduleName, (i, s) => s(!1)), e.register("focus", P.moduleName, (i, s) => {
3037
+ this.reportProgress(), s(!0);
3038
+ }), e.register("first_visible_locator", P.moduleName, (i, s) => {
3039
+ const n = Dt(t, !0);
3040
+ e.send("first_visible_locator", n.serialize()), s(!0);
3041
+ }), e.log("WebPubSnapper Mounted"), !0;
2832
3042
  }
2833
- unmount(e, t) {
2834
- return t.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), t.log("WebPubSnapper Unmounted"), !0;
3043
+ unmount(t, e) {
3044
+ return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), e.log("WebPubSnapper Unmounted"), !0;
2835
3045
  }
2836
3046
  };
2837
- w.moduleName = "webpub_snapper";
2838
- let ye = w;
2839
- const Oe = class Oe extends Y {
3047
+ P.moduleName = "webpub_snapper";
3048
+ let Et = P;
3049
+ const Mt = class Mt extends tt {
2840
3050
  constructor() {
2841
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);
2842
3052
  }
2843
- onPointUp(e) {
2844
- const t = this.wnd.getSelection();
2845
- if (t && t.toString()?.length > 0) {
2846
- const r = t.getRangeAt(0)?.getClientRects();
2847
- if (!r || r.length === 0)
3053
+ onPointUp(t) {
3054
+ const e = this.wnd.getSelection();
3055
+ if (e && e.toString()?.length > 0) {
3056
+ const s = e.getRangeAt(0)?.getClientRects();
3057
+ if (!s || s.length === 0)
2848
3058
  return;
2849
- const n = r[0], o = {
2850
- text: t.toString(),
3059
+ const n = s[0], o = {
3060
+ text: e.toString(),
2851
3061
  x: n.x,
2852
3062
  y: n.y,
2853
3063
  width: n.width,
@@ -2860,21 +3070,21 @@ const Oe = class Oe extends Y {
2860
3070
  this.pointerMoved = !1;
2861
3071
  return;
2862
3072
  }
2863
- if (!t?.isCollapsed || !e.isPrimary) return;
3073
+ if (!e?.isCollapsed || !t.isPrimary) return;
2864
3074
  const i = this.wnd.devicePixelRatio;
2865
- e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
2866
- defaultPrevented: e.defaultPrevented,
2867
- x: e.clientX * i,
2868
- y: e.clientY * i,
3075
+ t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {
3076
+ defaultPrevented: t.defaultPrevented,
3077
+ x: t.clientX * i,
3078
+ y: t.clientY * i,
2869
3079
  targetFrameSrc: this.wnd.location.href,
2870
- targetElement: e.target.outerHTML,
2871
- interactiveElement: ct(e.target)?.outerHTML,
2872
- cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
3080
+ targetElement: t.target.outerHTML,
3081
+ interactiveElement: xe(t.target)?.outerHTML,
3082
+ cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
2873
3083
  }), this.pointerMoved = !1;
2874
3084
  }
2875
- onPointMove(e) {
2876
- if (e.movementY !== void 0 && e.movementX !== void 0) {
2877
- (Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) && (this.pointerMoved = !0);
3085
+ onPointMove(t) {
3086
+ if (t.movementY !== void 0 && t.movementX !== void 0) {
3087
+ (Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);
2878
3088
  return;
2879
3089
  }
2880
3090
  this.pointerMoved = !0;
@@ -2882,57 +3092,57 @@ const Oe = class Oe extends Y {
2882
3092
  onPointDown() {
2883
3093
  this.pointerMoved = !1;
2884
3094
  }
2885
- onContext(e) {
2886
- this.onPointUp(e), this.pointerMoved = !1;
3095
+ onContext(t) {
3096
+ this.onPointUp(t), this.pointerMoved = !1;
2887
3097
  }
2888
- onClick(e) {
2889
- if (e.preventDefault(), !e.isTrusted) {
2890
- const t = new PointerEvent("pointerup", {
3098
+ onClick(t) {
3099
+ if (t.preventDefault(), !t.isTrusted) {
3100
+ const e = new PointerEvent("pointerup", {
2891
3101
  isPrimary: !0,
2892
3102
  pointerType: "mouse",
2893
3103
  // Not really a better choice than this
2894
- clientX: e.clientX,
2895
- clientY: e.clientY
3104
+ clientX: t.clientX,
3105
+ clientY: t.clientY
2896
3106
  });
2897
- Object.defineProperty(t, "target", { writable: !1, value: e.target }), Object.defineProperty(t, "defaultPrevented", { writable: !1, value: e.defaultPrevented }), this.onPointUp(t);
3107
+ Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
2898
3108
  }
2899
3109
  }
2900
- mount(e, t) {
2901
- return this.wnd = e, this.comms = t, e.document.addEventListener("pointerdown", this.onPointerDown), e.document.addEventListener("pointerup", this.onPointerUp), e.document.addEventListener("contextmenu", this.onContextMenu), e.document.addEventListener("pointermove", this.onPointerMove), e.document.addEventListener("click", this.onClicker), t.log("Peripherals Mounted"), !0;
3110
+ 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;
2902
3112
  }
2903
- unmount(e, t) {
2904
- return e.document.removeEventListener("pointerdown", this.onPointerDown), e.document.removeEventListener("pointerup", this.onPointerUp), e.document.removeEventListener("contextmenu", this.onContextMenu), e.document.removeEventListener("pointermove", this.onPointerMove), e.document.removeEventListener("click", this.onClicker), t.log("Peripherals Unmounted"), !0;
3113
+ 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;
2905
3115
  }
2906
3116
  };
2907
- Oe.moduleName = "peripherals";
2908
- let ve = Oe;
2909
- const _ = class _ extends Y {
3117
+ Mt.moduleName = "peripherals";
3118
+ let St = Mt;
3119
+ const J = class J extends tt {
2910
3120
  constructor() {
2911
3121
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
2912
3122
  }
2913
- wndOnErr(e) {
3123
+ wndOnErr(t) {
2914
3124
  this.comms?.send("error", {
2915
- message: e.message,
2916
- filename: e.filename,
2917
- lineno: e.lineno,
2918
- colno: e.colno
3125
+ message: t.message,
3126
+ filename: t.filename,
3127
+ lineno: t.lineno,
3128
+ colno: t.colno
2919
3129
  });
2920
3130
  }
2921
- unblock(e) {
2922
- for (e._readium_blockEvents = !1; e._readium_blockedEvents?.length > 0; ) {
2923
- const t = e._readium_blockedEvents.shift();
2924
- switch (t[0]) {
3131
+ unblock(t) {
3132
+ for (t._readium_blockEvents = !1; t._readium_blockedEvents?.length > 0; ) {
3133
+ const e = t._readium_blockedEvents.shift();
3134
+ switch (e[0]) {
2925
3135
  case 0:
2926
- Reflect.apply(t[1], t[2], t[3]);
3136
+ Reflect.apply(e[1], e[2], e[3]);
2927
3137
  break;
2928
3138
  case 1:
2929
- const i = t[1], r = t[2];
2930
- e.removeEventListener(i.type, e._readium_eventBlocker, !0);
3139
+ const i = e[1], s = e[2];
3140
+ t.removeEventListener(i.type, t._readium_eventBlocker, !0);
2931
3141
  const n = new Event(i.type, {
2932
3142
  bubbles: i.bubbles,
2933
3143
  cancelable: i.cancelable
2934
3144
  });
2935
- r ? r.dispatchEvent(n) : e.dispatchEvent(n);
3145
+ s ? s.dispatchEvent(n) : t.dispatchEvent(n);
2936
3146
  break;
2937
3147
  }
2938
3148
  }
@@ -2943,22 +3153,22 @@ const _ = class _ extends Y {
2943
3153
  onMediaPauseEvent() {
2944
3154
  this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);
2945
3155
  }
2946
- pauseAllMedia(e) {
2947
- const t = e.document.querySelectorAll("audio,video");
2948
- for (let i = 0; i < t.length; i++)
2949
- t[i].pause();
3156
+ pauseAllMedia(t) {
3157
+ const e = t.document.querySelectorAll("audio,video");
3158
+ for (let i = 0; i < e.length; i++)
3159
+ e[i].pause();
2950
3160
  }
2951
- mount(e, t) {
2952
- this.comms = t, e.addEventListener(
3161
+ mount(t, e) {
3162
+ this.comms = e, t.addEventListener(
2953
3163
  "error",
2954
3164
  this.wndOnErr,
2955
3165
  !1
2956
- ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
3166
+ ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
2957
3167
  value: {
2958
3168
  name: "readium-ts-toolkit",
2959
- version: "2.2.4",
2960
- hasFeature: (r, n = "") => {
2961
- switch (r) {
3169
+ version: "2.2.5",
3170
+ hasFeature: (s, n = "") => {
3171
+ switch (s) {
2962
3172
  case "dom-manipulation":
2963
3173
  return !0;
2964
3174
  case "layout-changes":
@@ -2979,70 +3189,70 @@ const _ = class _ extends Y {
2979
3189
  }
2980
3190
  },
2981
3191
  writable: !1
2982
- }), "getAnimations" in e.document && e.document.getAnimations().forEach((r) => {
2983
- r.cancel(), this.allAnimations.add(r);
2984
- }), t.register("activate", _.moduleName, (r, n) => {
3192
+ }), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
3193
+ s.cancel(), this.allAnimations.add(s);
3194
+ }), e.register("activate", J.moduleName, (s, n) => {
2985
3195
  this.allAnimations.forEach((o) => {
2986
3196
  o.cancel(), o.play();
2987
3197
  }), n(!0);
2988
- }), t.register("unfocus", _.moduleName, (r, n) => {
2989
- this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
3198
+ }), e.register("unfocus", J.moduleName, (s, n) => {
3199
+ this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
2990
3200
  });
2991
- const i = e.document.querySelectorAll("audio,video");
2992
- for (let r = 0; r < i.length; r++) {
2993
- const n = i[r];
3201
+ const i = t.document.querySelectorAll("audio,video");
3202
+ for (let s = 0; s < i.length; s++) {
3203
+ const n = i[s];
2994
3204
  n.addEventListener("play", this.onMediaPlayEvent, {
2995
3205
  passive: !0
2996
3206
  }), n.addEventListener("pause", this.onMediaPauseEvent, {
2997
3207
  passive: !0
2998
3208
  });
2999
3209
  }
3000
- return t.log("Setup Mounted"), !0;
3210
+ return e.log("Setup Mounted"), !0;
3001
3211
  }
3002
- unmount(e, t) {
3003
- return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;
3212
+ unmount(t, e) {
3213
+ 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;
3004
3214
  }
3005
3215
  };
3006
- _.moduleName = "setup";
3007
- let se = _;
3008
- const Ke = "readium-viewport", O = class O extends se {
3009
- onViewportWidthChanged(e) {
3010
- const t = e.target;
3011
- X(t, "--RS__viewportWidth", `${t.innerWidth}px`);
3012
- }
3013
- mount(e, t) {
3014
- if (!super.mount(e, t)) return !1;
3015
- const i = e.document.createElement("meta");
3016
- return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Ke), i.setAttribute(
3216
+ J.moduleName = "setup";
3217
+ let ct = J;
3218
+ const he = "readium-viewport", M = class M extends ct {
3219
+ onViewportWidthChanged(t) {
3220
+ const e = t.target;
3221
+ Q(e, "--RS__viewportWidth", `${e.innerWidth}px`);
3222
+ }
3223
+ mount(t, e) {
3224
+ if (!super.mount(t, e)) return !1;
3225
+ const i = t.document.createElement("meta");
3226
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", he), i.setAttribute(
3017
3227
  "content",
3018
3228
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
3019
- ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3020
- target: e
3021
- }), t.register("get_properties", O.moduleName, (r, n) => {
3022
- Me(e), n(!0);
3023
- }), t.register("update_properties", O.moduleName, (r, n) => {
3024
- r["--RS__viewportWidth"] = `${e.innerWidth}px`, at(e, r), n(!0);
3025
- }), t.register("set_property", O.moduleName, (r, n) => {
3026
- const o = r;
3027
- X(e, o[0], o[1]), n(!0);
3028
- }), t.register("remove_property", O.moduleName, (r, n) => {
3029
- oe(e, r), n(!0);
3030
- }), t.register("activate", O.moduleName, (r, n) => {
3031
- this.unblock(e), n(!0);
3032
- }), t.log("ReflowableSetup Mounted"), !0;
3033
- }
3034
- unmount(e, t) {
3035
- return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${Ke}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
3229
+ ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3230
+ target: t
3231
+ }), e.register("get_properties", M.moduleName, (s, n) => {
3232
+ zt(t), n(!0);
3233
+ }), e.register("update_properties", M.moduleName, (s, n) => {
3234
+ s["--RS__viewportWidth"] = `${t.innerWidth}px`, Ae(t, s), n(!0);
3235
+ }), e.register("set_property", M.moduleName, (s, n) => {
3236
+ const o = s;
3237
+ Q(t, o[0], o[1]), n(!0);
3238
+ }), e.register("remove_property", M.moduleName, (s, n) => {
3239
+ ut(t, s), n(!0);
3240
+ }), e.register("activate", M.moduleName, (s, n) => {
3241
+ this.unblock(t), n(!0);
3242
+ }), e.log("ReflowableSetup Mounted"), !0;
3243
+ }
3244
+ 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);
3036
3246
  }
3037
3247
  };
3038
- O.moduleName = "reflowable_setup";
3039
- let be = O;
3040
- const Ze = "readium-fixed-style", A = class A extends se {
3041
- mount(e, t) {
3042
- if (!super.mount(e, t)) return !1;
3043
- e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
3044
- const i = e.document.createElement("style");
3045
- return i.id = Ze, i.dataset.readium = "true", i.textContent = `
3248
+ M.moduleName = "reflowable_setup";
3249
+ let xt = M;
3250
+ const ue = "readium-fixed-style", z = class z extends ct {
3251
+ mount(t, e) {
3252
+ if (!super.mount(t, e)) return !1;
3253
+ t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
3254
+ const i = t.document.createElement("style");
3255
+ return i.id = ue, i.dataset.readium = "true", i.textContent = `
3046
3256
  html, body {
3047
3257
  text-size-adjust: none;
3048
3258
  -ms-text-size-adjust: none;
@@ -3054,14 +3264,14 @@ const Ze = "readium-fixed-style", A = class A extends se {
3054
3264
  min-height: 100%;
3055
3265
 
3056
3266
  /*cursor: var() TODO*/
3057
- }`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (r, n) => {
3058
- const o = r;
3059
- X(e, o[0], o[1]), n(!0);
3060
- }), t.register("remove_property", A.moduleName, (r, n) => {
3061
- oe(e, r), n(!0);
3062
- }), t.register("first_visible_locator", A.moduleName, (r, n) => n(!1)), t.register("unfocus", A.moduleName, (r, n) => {
3063
- v(e), n(!0);
3064
- }), t.register([
3267
+ }`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s, n) => {
3268
+ 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);
3274
+ }), e.register([
3065
3275
  "focus",
3066
3276
  "go_next",
3067
3277
  "go_prev",
@@ -3070,137 +3280,137 @@ const Ze = "readium-fixed-style", A = class A extends se {
3070
3280
  "go_start",
3071
3281
  "go_text",
3072
3282
  "go_progression"
3073
- ], A.moduleName, (r, n) => n(!0)), t.register("activate", A.moduleName, (r, n) => {
3074
- this.unblock(e), n(!0);
3075
- }), t.log("FixedSetup Mounted"), !0;
3283
+ ], z.moduleName, (s, n) => n(!0)), e.register("activate", z.moduleName, (s, n) => {
3284
+ this.unblock(t), n(!0);
3285
+ }), e.log("FixedSetup Mounted"), !0;
3076
3286
  }
3077
- unmount(e, t) {
3078
- return t.unregisterAll(A.moduleName), e.document.getElementById(Ze)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
3287
+ unmount(t, e) {
3288
+ return e.unregisterAll(z.moduleName), t.document.getElementById(ue)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
3079
3289
  }
3080
3290
  };
3081
- A.moduleName = "fixed_setup";
3082
- let Ee = A;
3083
- const L = class L extends Y {
3084
- wndOnErr(e) {
3291
+ z.moduleName = "fixed_setup";
3292
+ let Tt = z;
3293
+ const W = class W extends tt {
3294
+ wndOnErr(t) {
3085
3295
  this.comms?.send("error", {
3086
- message: e.message,
3087
- filename: e.filename,
3088
- lineno: e.lineno,
3089
- colno: e.colno
3296
+ message: t.message,
3297
+ filename: t.filename,
3298
+ lineno: t.lineno,
3299
+ colno: t.colno
3090
3300
  });
3091
3301
  }
3092
- mount(e, t) {
3093
- return this.comms = t, e.addEventListener(
3302
+ mount(t, e) {
3303
+ return this.comms = e, t.addEventListener(
3094
3304
  "error",
3095
3305
  this.wndOnErr,
3096
3306
  !1
3097
- ), t.register("get_properties", L.moduleName, (i, r) => {
3098
- Me(e), r(!0);
3099
- }), t.register("update_properties", L.moduleName, (i, r) => {
3100
- at(e, i), r(!0);
3101
- }), t.register("set_property", L.moduleName, (i, r) => {
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) => {
3102
3312
  const n = i;
3103
- X(e, n[0], n[1]), r(!0);
3104
- }), t.register("remove_property", L.moduleName, (i, r) => {
3105
- oe(e, i), r(!0);
3106
- }), t.register("activate", L.moduleName, (i, r) => {
3107
- r(!0);
3108
- }), t.log("WebPubSetup Mounted"), !0;
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) => {
3317
+ s(!0);
3318
+ }), e.log("WebPubSetup Mounted"), !0;
3109
3319
  }
3110
- unmount(e, t) {
3111
- return t.unregisterAll(L.moduleName), e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;
3320
+ unmount(t, e) {
3321
+ return e.unregisterAll(W.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
3112
3322
  }
3113
3323
  };
3114
- L.moduleName = "webpub_setup";
3115
- let xe = L;
3116
- const jt = [
3324
+ W.moduleName = "webpub_setup";
3325
+ let Ct = W;
3326
+ const ai = [
3117
3327
  "fixed_setup",
3118
3328
  "decorator",
3119
3329
  "peripherals"
3120
- ], _t = [
3330
+ ], li = [
3121
3331
  "reflowable_setup",
3122
3332
  "decorator",
3123
3333
  "peripherals",
3124
3334
  "column_snapper",
3125
3335
  "scroll_snapper"
3126
- ], Xt = [
3336
+ ], ci = [
3127
3337
  "webpub_setup",
3128
3338
  "webpub_snapper",
3129
3339
  "decorator",
3130
3340
  "peripherals"
3131
- ], Je = new Map([
3341
+ ], de = new Map([
3132
3342
  // All modules go here
3133
- Ee,
3134
- be,
3135
- xe,
3136
- ye,
3137
- ve,
3138
- fe,
3139
- me,
3140
- ge
3141
- ].map((s) => [s.moduleName, s]));
3142
- class Gt {
3343
+ Tt,
3344
+ xt,
3345
+ Ct,
3346
+ Et,
3347
+ St,
3348
+ yt,
3349
+ wt,
3350
+ At
3351
+ ].map((r) => [r.moduleName, r]));
3352
+ class hi {
3143
3353
  /**
3144
3354
  * @param wnd Window instance to operate on
3145
3355
  * @param initialModules List of initial modules to load
3146
3356
  */
3147
- constructor(e = window, t = []) {
3148
- this.loadedModules = [], this.wnd = e, this.comms = new ft(e);
3149
- const i = [...new Set(t)];
3357
+ constructor(t = window, e = []) {
3358
+ this.loadedModules = [], this.wnd = t, this.comms = new Oe(t);
3359
+ const i = [...new Set(e)];
3150
3360
  if (i.length) {
3151
- if (typeof e > "u")
3361
+ if (typeof t > "u")
3152
3362
  throw Error("Loader is not in a web browser");
3153
- e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((r) => {
3154
- const n = this.loadModule(r);
3363
+ t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
3364
+ const n = this.loadModule(s);
3155
3365
  if (n)
3156
3366
  return n.mount(this.wnd, this.comms), n;
3157
- }).filter((r) => r !== void 0);
3367
+ }).filter((s) => s !== void 0);
3158
3368
  }
3159
3369
  }
3160
- loadModule(e) {
3161
- const t = Je.get(e);
3162
- return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
3370
+ loadModule(t) {
3371
+ const e = de.get(t);
3372
+ return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
3163
3373
  }
3164
3374
  /**
3165
3375
  * Add a module by name
3166
3376
  * @param moduleName Module name
3167
3377
  * @returns Success
3168
3378
  */
3169
- addModule(e) {
3170
- const t = this.loadModule(e);
3171
- return !t || !t.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(t), !0);
3379
+ addModule(t) {
3380
+ const e = this.loadModule(t);
3381
+ return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);
3172
3382
  }
3173
3383
  /**
3174
3384
  * Remove a module by name
3175
3385
  * @param moduleName Module name
3176
3386
  * @returns Success
3177
3387
  */
3178
- removeModule(e) {
3179
- const t = Je.get(e);
3180
- if (t === void 0)
3181
- return this.comms.log(`Module "${e}" does not exist in the library`), !1;
3182
- const i = this.loadedModules.findIndex((r) => r instanceof t);
3388
+ removeModule(t) {
3389
+ const e = de.get(t);
3390
+ if (e === void 0)
3391
+ return this.comms.log(`Module "${t}" does not exist in the library`), !1;
3392
+ const i = this.loadedModules.findIndex((s) => s instanceof e);
3183
3393
  return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
3184
3394
  }
3185
3395
  /**
3186
3396
  * Unmount and remove all modules
3187
3397
  */
3188
3398
  destroy() {
3189
- this.comms.destroy(), this.loadedModules.forEach((e) => e.unmount(this.wnd, this.comms)), this.loadedModules = [];
3399
+ this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
3190
3400
  }
3191
3401
  }
3192
3402
  export {
3193
- k as COMMS_VERSION,
3194
- ft as Comms,
3195
- fe as Decorator,
3196
- jt as FXLModules,
3197
- Dt as Layout,
3198
- Gt as Loader,
3199
- Y as Module,
3200
- Je as ModuleLibrary,
3201
- ve as Peripherals,
3202
- _t as ReflowableModules,
3203
- Xt as WebPubModules,
3204
- zt as Width,
3205
- pt as mid
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
3206
3416
  };