@readium/navigator-html-injectables 2.0.0 → 2.1.0

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