@readium/navigator-html-injectables 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,27 +1,24 @@
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 {
1
+ const _e = Math.pow(2, 32), me = () => Math.round(Math.random() * _e).toString(36), Ye = () => `${Math.round(performance.now())}-${me()}-${me()}`, F = 1;
2
+ class Ke {
3
3
  constructor(e) {
4
4
  this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
5
5
  }
6
6
  receive(e) {
7
- if (e.source === null)
8
- throw Error("Event source is null");
9
- if (typeof e.data != "object")
10
- return;
7
+ if (e.source === null) throw Error("Event source is null");
8
+ if (typeof e.data != "object") return;
11
9
  const t = e.data;
12
10
  if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
13
11
  if (t.key === "_ping") {
14
12
  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 = "";
13
+ if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== F) {
14
+ t._readium > F ? this.send("error", `received comms version ${t._readium} higher than ${F}`) : this.send("error", `received comms version ${t._readium} lower than ${F}`), this.destination = null, this.origin = "", this.channelId = "";
17
15
  return;
18
16
  }
19
17
  this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
20
18
  }
21
19
  return;
22
20
  } else if (this.channelId) {
23
- if (t._channel !== this.channelId || e.origin !== this.origin)
24
- return;
21
+ if (t._channel !== this.channelId || e.origin !== this.origin) return;
25
22
  } else
26
23
  return;
27
24
  this.handle(t);
@@ -41,8 +38,7 @@ class at {
41
38
  Array.isArray(e) || (e = [e]), e.forEach((r) => {
42
39
  const n = this.registrar.get(r);
43
40
  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}`);
41
+ if (n.find((l) => l.module === t)) throw new Error(`Trying to register another callback for combination of event ${r} and module ${t}`);
46
42
  n.push({
47
43
  cb: i,
48
44
  module: t
@@ -73,12 +69,11 @@ class at {
73
69
  this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
74
70
  }
75
71
  send(e, t, i = void 0, r = []) {
76
- if (!this.destination)
77
- throw Error("Attempted to send comms message before destination has been initialized");
72
+ if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
78
73
  const n = {
79
- _readium: k,
74
+ _readium: F,
80
75
  _channel: this.channelId,
81
- id: i ?? ot(),
76
+ id: i ?? Ye(),
82
77
  // scrict,
83
78
  key: e,
84
79
  data: t
@@ -89,13 +84,47 @@ class at {
89
84
  transfer: r
90
85
  });
91
86
  } catch (o) {
92
- if (r.length > 0)
93
- throw o;
87
+ if (r.length > 0) throw o;
94
88
  this.destination.postMessage(n, this.origin, r);
95
89
  }
96
90
  }
97
91
  }
98
- class ie {
92
+ const M = class z {
93
+ constructor(e) {
94
+ if (typeof e == "string") {
95
+ if (!z.VALID_MODES.has(e.toLowerCase()))
96
+ return;
97
+ this.value = e.toLowerCase();
98
+ } else {
99
+ const t = e.filter(
100
+ (i) => z.VALID_MODES.has(i.toLowerCase())
101
+ );
102
+ if (t.length === 0)
103
+ return;
104
+ this.value = Array.from(new Set(t));
105
+ }
106
+ }
107
+ /**
108
+ * Parses a [PrimaryAccessMode] from its RWPM JSON representation.
109
+ */
110
+ static deserialize(e) {
111
+ if (!e) return;
112
+ if (typeof e == "string")
113
+ return new z(e);
114
+ if (!Array.isArray(e)) return;
115
+ const t = e.filter((i) => i ? z.VALID_MODES.has(i.toLowerCase()) : !1);
116
+ if (t.length !== 0)
117
+ return new z(t);
118
+ }
119
+ /**
120
+ * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
121
+ */
122
+ serialize() {
123
+ return this.value;
124
+ }
125
+ };
126
+ M.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), M.AUDITORY = new M("auditory"), M.TACTILE = new M("tactile"), M.TEXTUAL = new M("textual"), M.VISUAL = new M("visual");
127
+ class oe {
99
128
  /**
100
129
  * Creates a [Encryption].
101
130
  */
@@ -107,7 +136,7 @@ class ie {
107
136
  */
108
137
  static deserialize(e) {
109
138
  if (e && e.algorithm)
110
- return new ie({
139
+ return new oe({
111
140
  algorithm: e.algorithm,
112
141
  compression: e.compression,
113
142
  originalLength: e.originalLength,
@@ -123,7 +152,7 @@ class ie {
123
152
  return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
124
153
  }
125
154
  }
126
- class w {
155
+ class S {
127
156
  constructor(e) {
128
157
  this.otherProperties = e;
129
158
  }
@@ -135,7 +164,7 @@ class w {
135
164
  */
136
165
  static deserialize(e) {
137
166
  if (e)
138
- return new w(e);
167
+ return new S(e);
139
168
  }
140
169
  /**
141
170
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -150,30 +179,30 @@ class w {
150
179
  const t = Object.assign({}, this.otherProperties);
151
180
  for (const i in e)
152
181
  t[i] = e[i];
153
- return new w(t);
182
+ return new S(t);
154
183
  }
155
184
  }
156
- Object.defineProperty(w.prototype, "encryption", {
185
+ Object.defineProperty(S.prototype, "encryption", {
157
186
  get: function() {
158
- return ie.deserialize(this.otherProperties.encrypted);
187
+ return oe.deserialize(this.otherProperties.encrypted);
159
188
  }
160
189
  });
161
- function lt(s) {
162
- return s && s instanceof Array ? s : void 0;
190
+ function Ze(s) {
191
+ return s && Array.isArray(s) ? s : void 0;
163
192
  }
164
- function We(s) {
165
- return s && typeof s == "string" ? [s] : lt(s);
193
+ function De(s) {
194
+ return s && typeof s == "string" ? [s] : Ze(s);
166
195
  }
167
- function ye(s) {
196
+ function ge(s) {
168
197
  return typeof s == "string" ? new Date(s) : void 0;
169
198
  }
170
- function j(s) {
199
+ function V(s) {
171
200
  return isNaN(s) ? void 0 : s;
172
201
  }
173
- function T(s) {
174
- return j(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
202
+ function w(s) {
203
+ return V(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
175
204
  }
176
- function ht(s) {
205
+ function Je(s) {
177
206
  const e = new Array();
178
207
  return s.forEach((t) => e.push(t)), e;
179
208
  }
@@ -188,22 +217,22 @@ class a {
188
217
  } else
189
218
  throw new Error("Invalid media type");
190
219
  const o = {};
191
- for (let d = 1; d < r.length; d++) {
192
- const f = r[d].split("=");
193
- if (f.length === 2) {
194
- const g = f[0].toLocaleLowerCase(), m = g === "charset" ? f[1].toUpperCase() : f[1];
195
- o[g] = m;
220
+ for (let p = 1; p < r.length; p++) {
221
+ const y = r[p].split("=");
222
+ if (y.length === 2) {
223
+ const d = y[0].toLocaleLowerCase(), f = d === "charset" ? y[1].toUpperCase() : y[1];
224
+ o[d] = f;
196
225
  }
197
226
  }
198
- const l = {}, c = Object.keys(o);
199
- c.sort((d, f) => d.localeCompare(f)), c.forEach((d) => l[d] = o[d]);
227
+ const l = {}, u = Object.keys(o);
228
+ u.sort((p, y) => p.localeCompare(y)), u.forEach((p) => l[p] = o[p]);
200
229
  let h = "";
201
- for (const d in l) {
202
- const f = l[d];
203
- h += `;${d}=${f}`;
230
+ for (const p in l) {
231
+ const y = l[p];
232
+ h += `;${p}=${y}`;
204
233
  }
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;
234
+ const c = `${t}/${i}${h}`, m = l.encoding;
235
+ this.string = c, this.type = t, this.subtype = i, this.parameters = l, this.encoding = m, this.name = e.name, this.fileExtension = e.fileExtension;
207
236
  }
208
237
  static parse(e) {
209
238
  return new a(e);
@@ -632,7 +661,7 @@ class a {
632
661
  });
633
662
  }
634
663
  }
635
- class ve {
664
+ class ye {
636
665
  constructor(e) {
637
666
  this.uri = e, this.parameters = this.getParameters(e);
638
667
  }
@@ -660,7 +689,7 @@ class ve {
660
689
  return this.uri.replace(/\{(\??)([^}]+)\}/g, (...r) => r[1] ? i(r[2]) : t(r[2]));
661
690
  }
662
691
  }
663
- class E {
692
+ class v {
664
693
  /**
665
694
  * Creates a [Locations].
666
695
  */
@@ -671,19 +700,18 @@ class E {
671
700
  * Parses a [Locations] from its RWPM JSON representation.
672
701
  */
673
702
  static deserialize(e) {
674
- if (!e)
675
- return;
676
- const t = j(e.progression), i = j(e.totalProgression), r = j(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
703
+ if (!e) return;
704
+ const t = V(e.progression), i = V(e.totalProgression), r = V(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
677
705
  "fragment",
678
706
  "fragments",
679
707
  "progression",
680
708
  "totalProgression",
681
709
  "position"
682
710
  ]);
683
- return Object.entries(e).forEach(([l, c]) => {
684
- o.has(l) || n.set(l, c);
685
- }), new E({
686
- fragments: We(e.fragments || e.fragment),
711
+ return Object.entries(e).forEach(([l, u]) => {
712
+ o.has(l) || n.set(l, u);
713
+ }), new v({
714
+ fragments: De(e.fragments || e.fragment),
687
715
  progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
688
716
  totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
689
717
  position: r !== void 0 && r > 0 ? r : void 0,
@@ -698,7 +726,7 @@ class E {
698
726
  return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
699
727
  }
700
728
  }
701
- class U {
729
+ class W {
702
730
  /**
703
731
  * Creates a [Text].
704
732
  */
@@ -710,7 +738,7 @@ class U {
710
738
  */
711
739
  static deserialize(e) {
712
740
  if (e)
713
- return new U({
741
+ return new W({
714
742
  after: e.after,
715
743
  before: e.before,
716
744
  highlight: e.highlight
@@ -724,24 +752,24 @@ class U {
724
752
  return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;
725
753
  }
726
754
  }
727
- class D {
755
+ class L {
728
756
  /**
729
757
  * Creates a [Locator].
730
758
  */
731
759
  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;
760
+ this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new v({}), this.text = e.text;
733
761
  }
734
762
  /**
735
763
  * Parses a [Link] from its RWPM JSON representation.
736
764
  */
737
765
  static deserialize(e) {
738
766
  if (e && e.href && e.type)
739
- return new D({
767
+ return new L({
740
768
  href: e.href,
741
769
  type: e.type,
742
770
  title: e.title,
743
- locations: E.deserialize(e.locations),
744
- text: U.deserialize(e.text)
771
+ locations: v.deserialize(e.locations),
772
+ text: W.deserialize(e.text)
745
773
  });
746
774
  }
747
775
  /**
@@ -755,16 +783,16 @@ class D {
755
783
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
756
784
  */
757
785
  copyWithLocations(e) {
758
- return new D({
786
+ return new L({
759
787
  href: this.href,
760
788
  type: this.type,
761
789
  title: this.title,
762
790
  text: this.text,
763
- locations: new E({ ...this.locations, ...e })
791
+ locations: new v({ ...this.locations, ...e })
764
792
  });
765
793
  }
766
794
  }
767
- class B {
795
+ class D {
768
796
  /**
769
797
  * Creates a [Link].
770
798
  */
@@ -776,21 +804,21 @@ class B {
776
804
  */
777
805
  static deserialize(e) {
778
806
  if (!(!e || typeof e.href != "string"))
779
- return new B({
807
+ return new D({
780
808
  href: e.href,
781
809
  templated: e.templated,
782
810
  type: e.type,
783
811
  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)
812
+ rels: e.rel ? Array.isArray(e.rel) ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
813
+ properties: S.deserialize(e.properties),
814
+ height: w(e.height),
815
+ width: w(e.width),
816
+ size: w(e.size),
817
+ duration: w(e.duration),
818
+ bitrate: w(e.bitrate),
819
+ languages: De(e.language),
820
+ alternates: j.deserialize(e.alternate),
821
+ children: j.deserialize(e.children)
794
822
  });
795
823
  }
796
824
  /**
@@ -798,7 +826,7 @@ class B {
798
826
  */
799
827
  serialize() {
800
828
  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;
829
+ return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = Je(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;
802
830
  }
803
831
  /** MediaType of the linked resource. */
804
832
  get mediaType() {
@@ -809,21 +837,20 @@ class B {
809
837
  */
810
838
  toURL(e) {
811
839
  const t = this.href.replace(/^(\/)/, "");
812
- if (t.length === 0)
813
- return;
840
+ if (t.length === 0) return;
814
841
  let i = e || "/";
815
842
  return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
816
843
  }
817
844
  /** List of URI template parameter keys, if the `Link` is templated. */
818
845
  get templateParameters() {
819
- return this.templated ? new ve(this.href).parameters : /* @__PURE__ */ new Set();
846
+ return this.templated ? new ye(this.href).parameters : /* @__PURE__ */ new Set();
820
847
  }
821
848
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
822
849
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
823
850
  */
824
851
  expandTemplate(e) {
825
- return new B({
826
- href: new ve(this.href).expand(e),
852
+ return new D({
853
+ href: new ye(this.href).expand(e),
827
854
  templated: !1
828
855
  });
829
856
  }
@@ -831,26 +858,25 @@ class B {
831
858
  * Makes a copy of this [Link] after merging in the given additional other [properties].
832
859
  */
833
860
  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;
861
+ const t = D.deserialize(this.serialize());
862
+ return t.properties = t.properties ? t.properties?.add(e) : new S(e), t;
837
863
  }
838
864
  /**
839
865
  * Creates a [Locator] from a reading order [Link].
840
866
  */
841
867
  get locator() {
842
868
  let e = this.href.split("#");
843
- return new D({
869
+ return new L({
844
870
  href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
845
871
  type: this.type ?? "",
846
872
  title: this.title,
847
- locations: new E({
873
+ locations: new v({
848
874
  fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
849
875
  })
850
876
  });
851
877
  }
852
878
  }
853
- class V {
879
+ class j {
854
880
  /**
855
881
  * Creates a [Links].
856
882
  */
@@ -861,9 +887,9 @@ class V {
861
887
  * Creates a list of [Link] from its RWPM JSON representation.
862
888
  */
863
889
  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)
890
+ if (e && Array.isArray(e))
891
+ return new j(
892
+ e.map((t) => D.deserialize(t)).filter((t) => t !== void 0)
867
893
  );
868
894
  }
869
895
  /**
@@ -944,7 +970,7 @@ class V {
944
970
  return this.items.filter((e) => e.type);
945
971
  }
946
972
  }
947
- w.prototype.getContains = function() {
973
+ S.prototype.getContains = function() {
948
974
  return new Set(this.otherProperties.contains || []);
949
975
  };
950
976
  class q {
@@ -958,13 +984,11 @@ class q {
958
984
  * Parses a [DomRangePoint] from its RWPM JSON representation.
959
985
  */
960
986
  static deserialize(e) {
961
- if (!(e && e.cssSelector))
962
- return;
963
- let t = T(e.textNodeIndex);
964
- if (t === void 0)
965
- return;
966
- let i = T(e.charOffset);
967
- return i === void 0 && (i = T(e.offset)), new q({
987
+ if (!(e && e.cssSelector)) return;
988
+ let t = w(e.textNodeIndex);
989
+ if (t === void 0) return;
990
+ let i = w(e.charOffset);
991
+ return i === void 0 && (i = w(e.offset)), new q({
968
992
  cssSelector: e.cssSelector,
969
993
  textNodeIndex: t,
970
994
  charOffset: i
@@ -981,7 +1005,7 @@ class q {
981
1005
  return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
982
1006
  }
983
1007
  }
984
- class se {
1008
+ class ae {
985
1009
  /**
986
1010
  * Creates a [DomRange].
987
1011
  */
@@ -992,11 +1016,10 @@ class se {
992
1016
  * Parses a [DomRange] from its RWPM JSON representation.
993
1017
  */
994
1018
  static deserialize(e) {
995
- if (!e)
996
- return;
1019
+ if (!e) return;
997
1020
  let t = q.deserialize(e.start);
998
1021
  if (t)
999
- return new se({
1022
+ return new ae({
1000
1023
  start: t,
1001
1024
  end: q.deserialize(e.end)
1002
1025
  });
@@ -1009,19 +1032,16 @@ class se {
1009
1032
  return this.end && (e.end = this.end.serialize()), e;
1010
1033
  }
1011
1034
  }
1012
- E.prototype.getCssSelector = function() {
1013
- var s;
1014
- return (s = this.otherLocations) == null ? void 0 : s.get("cssSelector");
1035
+ v.prototype.getCssSelector = function() {
1036
+ return this.otherLocations?.get("cssSelector");
1015
1037
  };
1016
- E.prototype.getPartialCfi = function() {
1017
- var s;
1018
- return (s = this.otherLocations) == null ? void 0 : s.get("partialCfi");
1038
+ v.prototype.getPartialCfi = function() {
1039
+ return this.otherLocations?.get("partialCfi");
1019
1040
  };
1020
- E.prototype.getDomRange = function() {
1021
- var s;
1022
- return se.deserialize((s = this.otherLocations) == null ? void 0 : s.get("domRange"));
1041
+ v.prototype.getDomRange = function() {
1042
+ return ae.deserialize(this.otherLocations?.get("domRange"));
1023
1043
  };
1024
- E.prototype.fragmentParameters = function() {
1044
+ v.prototype.fragmentParameters = function() {
1025
1045
  return new Map(
1026
1046
  this.fragments.map((s) => s.startsWith("#") ? s.slice(1) : s).join("&").split("&").filter((s) => !s.startsWith("#")).map((s) => s.split("=")).filter((s) => s.length === 2).map((s) => [
1027
1047
  s[0].trim().toLowerCase(),
@@ -1029,35 +1049,31 @@ E.prototype.fragmentParameters = function() {
1029
1049
  ])
1030
1050
  );
1031
1051
  };
1032
- E.prototype.htmlId = function() {
1033
- if (!this.fragments.length)
1034
- return;
1052
+ v.prototype.htmlId = function() {
1053
+ if (!this.fragments.length) return;
1035
1054
  let s = this.fragments.find((e) => e.length && !e.includes("="));
1036
1055
  if (!s) {
1037
1056
  const e = this.fragmentParameters();
1038
1057
  e.has("id") ? s = e.get("id") : e.has("name") && (s = e.get("name"));
1039
1058
  }
1040
- return s != null && s.startsWith("#") ? s.slice(1) : s;
1059
+ return s?.startsWith("#") ? s.slice(1) : s;
1041
1060
  };
1042
- E.prototype.page = function() {
1061
+ v.prototype.page = function() {
1043
1062
  const s = parseInt(this.fragmentParameters().get("page"));
1044
- if (!isNaN(s) && s >= 0)
1045
- return s;
1063
+ if (!isNaN(s) && s >= 0) return s;
1046
1064
  };
1047
- E.prototype.time = function() {
1065
+ v.prototype.time = function() {
1048
1066
  const s = parseInt(this.fragmentParameters().get("t"));
1049
- if (!isNaN(s))
1050
- return s;
1067
+ if (!isNaN(s)) return s;
1051
1068
  };
1052
- E.prototype.space = function() {
1069
+ v.prototype.space = function() {
1053
1070
  const s = this.fragmentParameters();
1054
- if (!s.has("xywh"))
1055
- return;
1071
+ if (!s.has("xywh")) return;
1056
1072
  const e = s.get("xywh").split(",").map((t) => parseInt(t));
1057
1073
  if (e.length === 4 && !e.some(isNaN))
1058
1074
  return e;
1059
1075
  };
1060
- class re {
1076
+ class le {
1061
1077
  /** Creates a [Price]. */
1062
1078
  constructor(e) {
1063
1079
  this.currency = e.currency, this.value = e.value;
@@ -1066,14 +1082,13 @@ class re {
1066
1082
  * Parses a [Price] from its RWPM JSON representation.
1067
1083
  */
1068
1084
  static deserialize(e) {
1069
- if (!e)
1070
- return;
1085
+ if (!e) return;
1071
1086
  let t = e.currency;
1072
1087
  if (!(t && typeof t == "string" && t.length > 0))
1073
1088
  return;
1074
- let i = T(e.value);
1089
+ let i = w(e.value);
1075
1090
  if (i !== void 0)
1076
- return new re({ currency: t, value: i });
1091
+ return new le({ currency: t, value: i });
1077
1092
  }
1078
1093
  /**
1079
1094
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1082,7 +1097,7 @@ class re {
1082
1097
  return { currency: this.currency, value: this.value };
1083
1098
  }
1084
1099
  }
1085
- class $ {
1100
+ class U {
1086
1101
  /** Creates a [Acquisition]. */
1087
1102
  constructor(e) {
1088
1103
  this.type = e.type, this.children = e.children;
@@ -1092,14 +1107,14 @@ class $ {
1092
1107
  */
1093
1108
  static deserialize(e) {
1094
1109
  if (e && e.type)
1095
- return new $({
1110
+ return new U({
1096
1111
  type: e.type,
1097
- children: $.deserializeArray(e.children)
1112
+ children: U.deserializeArray(e.children)
1098
1113
  });
1099
1114
  }
1100
1115
  static deserializeArray(e) {
1101
- if (e instanceof Array)
1102
- return e.map((t) => $.deserialize(t)).filter((t) => t !== void 0);
1116
+ if (Array.isArray(e))
1117
+ return e.map((t) => U.deserialize(t)).filter((t) => t !== void 0);
1103
1118
  }
1104
1119
  /**
1105
1120
  * Serializes a [Acquisition] to its RWPM JSON representation.
@@ -1109,7 +1124,7 @@ class $ {
1109
1124
  return this.children && (e.children = this.children.map((t) => t.serialize())), e;
1110
1125
  }
1111
1126
  }
1112
- class ne {
1127
+ class he {
1113
1128
  /** Creates a [Price]. */
1114
1129
  constructor(e) {
1115
1130
  this.total = e.total, this.position = e.position;
@@ -1119,9 +1134,9 @@ class ne {
1119
1134
  */
1120
1135
  static deserialize(e) {
1121
1136
  if (e)
1122
- return new ne({
1123
- total: T(e.total),
1124
- position: T(e.position)
1137
+ return new he({
1138
+ total: w(e.total),
1139
+ position: w(e.position)
1125
1140
  });
1126
1141
  }
1127
1142
  /**
@@ -1132,7 +1147,7 @@ class ne {
1132
1147
  return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
1133
1148
  }
1134
1149
  }
1135
- class oe {
1150
+ class ce {
1136
1151
  /** Creates a [Copies]. */
1137
1152
  constructor(e) {
1138
1153
  this.total = e.total, this.available = e.available;
@@ -1142,9 +1157,9 @@ class oe {
1142
1157
  */
1143
1158
  static deserialize(e) {
1144
1159
  if (e)
1145
- return new oe({
1146
- total: T(e.total),
1147
- available: T(e.available)
1160
+ return new ce({
1161
+ total: w(e.total),
1162
+ available: w(e.available)
1148
1163
  });
1149
1164
  }
1150
1165
  /**
@@ -1155,7 +1170,7 @@ class oe {
1155
1170
  return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
1156
1171
  }
1157
1172
  }
1158
- class ae {
1173
+ class ue {
1159
1174
  /** Creates a [Availability]. */
1160
1175
  constructor(e) {
1161
1176
  this.state = e.state, this.since = e.since, this.until = e.until;
@@ -1165,10 +1180,10 @@ class ae {
1165
1180
  */
1166
1181
  static deserialize(e) {
1167
1182
  if (e && e.state)
1168
- return new ae({
1183
+ return new ue({
1169
1184
  state: e.state,
1170
- since: ye(e.since),
1171
- until: ye(e.until)
1185
+ since: ge(e.since),
1186
+ until: ge(e.until)
1172
1187
  });
1173
1188
  }
1174
1189
  /**
@@ -1179,101 +1194,89 @@ class ae {
1179
1194
  return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
1180
1195
  }
1181
1196
  }
1182
- w.prototype.getNumberOfItems = function() {
1183
- return T(this.otherProperties.numberOfItems);
1197
+ S.prototype.getNumberOfItems = function() {
1198
+ return w(this.otherProperties.numberOfItems);
1184
1199
  };
1185
- w.prototype.getPrice = function() {
1186
- return re.deserialize(this.otherProperties.price);
1200
+ S.prototype.getPrice = function() {
1201
+ return le.deserialize(this.otherProperties.price);
1187
1202
  };
1188
- w.prototype.getIndirectAcquisitions = function() {
1203
+ S.prototype.getIndirectAcquisitions = function() {
1189
1204
  const s = this.otherProperties.indirectAcquisition;
1190
- if (s && s instanceof Array)
1191
- return s.map((e) => $.deserialize(e)).filter((e) => e !== void 0);
1205
+ if (s && Array.isArray(s))
1206
+ return s.map((e) => U.deserialize(e)).filter((e) => e !== void 0);
1192
1207
  };
1193
- w.prototype.getHolds = function() {
1194
- return ne.deserialize(this.otherProperties.holds);
1208
+ S.prototype.getHolds = function() {
1209
+ return he.deserialize(this.otherProperties.holds);
1195
1210
  };
1196
- w.prototype.getCopies = function() {
1197
- return oe.deserialize(this.otherProperties.copies);
1211
+ S.prototype.getCopies = function() {
1212
+ return ce.deserialize(this.otherProperties.copies);
1198
1213
  };
1199
- w.prototype.getAvailability = function() {
1200
- return ae.deserialize(this.otherProperties.availability);
1214
+ S.prototype.getAvailability = function() {
1215
+ return ue.deserialize(this.otherProperties.availability);
1201
1216
  };
1202
- w.prototype.getAuthenticate = function() {
1203
- return B.deserialize(this.otherProperties.authenticate);
1217
+ S.prototype.getAuthenticate = function() {
1218
+ return D.deserialize(this.otherProperties.authenticate);
1204
1219
  };
1205
- var R;
1206
- (function(s) {
1207
- s.NONE = "none", s.DESCENDANT = "descendant", s.CHILD = "child";
1208
- })(R || (R = {}));
1209
- var N;
1210
- (function(s) {
1211
- 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);
1216
- }
1217
- N.id, N.class, N.tag, N.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1218
- function ut(s) {
1220
+ const Qe = "CssSelectorGenerator";
1221
+ function ve(s = "unknown problem", ...e) {
1222
+ console.warn(`${Qe}: ${s}`, ...e);
1223
+ }
1224
+ function et(s) {
1219
1225
  return s instanceof RegExp;
1220
1226
  }
1221
- function dt(s) {
1227
+ function tt(s) {
1222
1228
  return s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1223
1229
  }
1224
- function pt(s) {
1230
+ function it(s) {
1225
1231
  const e = s.map((t) => {
1226
- if (ut(t))
1232
+ if (et(t))
1227
1233
  return (i) => t.test(i);
1228
1234
  if (typeof t == "function")
1229
1235
  return (i) => {
1230
1236
  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;
1237
+ return typeof r != "boolean" ? (ve("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : r;
1232
1238
  };
1233
1239
  if (typeof t == "string") {
1234
- const i = new RegExp("^" + dt(t) + "$");
1240
+ const i = new RegExp("^" + tt(t) + "$");
1235
1241
  return (r) => i.test(r);
1236
1242
  }
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;
1243
+ return ve("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
1238
1244
  });
1239
1245
  return (t) => e.some((i) => i(t));
1240
1246
  }
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([
1247
+ it([
1245
1248
  "class",
1246
1249
  "id",
1247
1250
  // Angular attributes
1248
1251
  "ng-*"
1249
1252
  ]);
1250
- class Y {
1253
+ class Z {
1251
1254
  }
1252
1255
  function Ee(s) {
1253
1256
  return s.split("").reverse().join("");
1254
1257
  }
1255
- function yt(s, e, t) {
1258
+ function st(s, e, t) {
1256
1259
  const i = Ee(e);
1257
1260
  return t.map((r) => {
1258
1261
  const n = Math.max(0, r.end - e.length - r.errors), o = Ee(s.slice(n, r.end));
1259
1262
  return {
1260
- start: Fe(o, i, r.errors).reduce((c, h) => r.end - h.end < c ? r.end - h.end : c, r.end),
1263
+ start: We(o, i, r.errors).reduce((u, h) => r.end - h.end < u ? r.end - h.end : u, r.end),
1261
1264
  end: r.end,
1262
1265
  errors: r.errors
1263
1266
  };
1264
1267
  });
1265
1268
  }
1266
- function Z(s) {
1269
+ function J(s) {
1267
1270
  return (s | -s) >> 31 & 1;
1268
1271
  }
1269
- function xe(s, e, t, i) {
1272
+ function be(s, e, t, i) {
1270
1273
  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;
1272
- 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;
1274
+ const o = i >>> 31, l = e[t] | o, u = l | n, h = (l & r) + r ^ r | l;
1275
+ let c = n | ~(h | r), m = r & h;
1276
+ const p = J(c & s.lastRowMask[t]) - J(m & s.lastRowMask[t]);
1277
+ return c <<= 1, m <<= 1, m |= o, c |= J(i) - o, r = m | ~(u | c), n = c & u, s.P[t] = r, s.M[t] = n, p;
1275
1278
  }
1276
- function Fe(s, e, t) {
1279
+ function We(s, e, t) {
1277
1280
  if (e.length === 0)
1278
1281
  return [];
1279
1282
  t = Math.min(t, e.length);
@@ -1283,64 +1286,64 @@ function Fe(s, e, t) {
1283
1286
  lastRowMask: new Uint32Array(n + 1)
1284
1287
  };
1285
1288
  o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % r;
1286
- const l = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
1287
- for (let d = 0; d < 256; d++)
1289
+ const l = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];
1290
+ for (let p = 0; p < 256; p++)
1288
1291
  h.push(l);
1289
- for (let d = 0; d < e.length; d += 1) {
1290
- const f = e.charCodeAt(d);
1291
- if (c.has(f))
1292
+ for (let p = 0; p < e.length; p += 1) {
1293
+ const y = e.charCodeAt(p);
1294
+ if (u.has(y))
1292
1295
  continue;
1293
- const g = new Uint32Array(n + 1);
1294
- c.set(f, g), f < h.length && (h[f] = g);
1295
- for (let m = 0; m <= n; m += 1) {
1296
- g[m] = 0;
1297
- for (let v = 0; v < r; v += 1) {
1298
- const x = m * r + v;
1299
- if (x >= e.length)
1296
+ const d = new Uint32Array(n + 1);
1297
+ u.set(y, d), y < h.length && (h[y] = d);
1298
+ for (let f = 0; f <= n; f += 1) {
1299
+ d[f] = 0;
1300
+ for (let g = 0; g < r; g += 1) {
1301
+ const E = f * r + g;
1302
+ if (E >= e.length)
1300
1303
  continue;
1301
- e.charCodeAt(x) === f && (g[m] |= 1 << v);
1304
+ e.charCodeAt(E) === y && (d[f] |= 1 << g);
1302
1305
  }
1303
1306
  }
1304
1307
  }
1305
- let u = Math.max(0, Math.ceil(t / r) - 1);
1306
- const p = new Uint32Array(n + 1);
1307
- for (let d = 0; d <= u; d += 1)
1308
- p[d] = (d + 1) * r;
1309
- p[n] = e.length;
1310
- for (let d = 0; d <= u; d += 1)
1311
- o.P[d] = -1, o.M[d] = 0;
1312
- for (let d = 0; d < s.length; d += 1) {
1313
- const f = s.charCodeAt(d);
1314
- let g;
1315
- f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = l));
1316
- let m = 0;
1317
- 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)) {
1320
- u += 1, o.P[u] = -1, o.M[u] = 0;
1321
- let v;
1322
- if (u === n) {
1323
- const x = e.length % r;
1324
- v = x === 0 ? r : x;
1308
+ let c = Math.max(0, Math.ceil(t / r) - 1);
1309
+ const m = new Uint32Array(n + 1);
1310
+ for (let p = 0; p <= c; p += 1)
1311
+ m[p] = (p + 1) * r;
1312
+ m[n] = e.length;
1313
+ for (let p = 0; p <= c; p += 1)
1314
+ o.P[p] = -1, o.M[p] = 0;
1315
+ for (let p = 0; p < s.length; p += 1) {
1316
+ const y = s.charCodeAt(p);
1317
+ let d;
1318
+ y < h.length ? d = h[y] : (d = u.get(y), typeof d > "u" && (d = l));
1319
+ let f = 0;
1320
+ for (let g = 0; g <= c; g += 1)
1321
+ f = be(o, d, g, f), m[g] += f;
1322
+ if (m[c] - f <= t && c < n && (d[c + 1] & 1 || f < 0)) {
1323
+ c += 1, o.P[c] = -1, o.M[c] = 0;
1324
+ let g;
1325
+ if (c === n) {
1326
+ const E = e.length % r;
1327
+ g = E === 0 ? r : E;
1325
1328
  } else
1326
- v = r;
1327
- p[u] = p[u - 1] + v - m + xe(o, g, u, m);
1329
+ g = r;
1330
+ m[c] = m[c - 1] + g - f + be(o, d, c, f);
1328
1331
  } else
1329
- for (; u > 0 && p[u] >= t + r; )
1330
- u -= 1;
1331
- u === n && p[u] <= t && (p[u] < t && i.splice(0, i.length), i.push({
1332
+ for (; c > 0 && m[c] >= t + r; )
1333
+ c -= 1;
1334
+ c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({
1332
1335
  start: -1,
1333
- end: d + 1,
1334
- errors: p[u]
1335
- }), t = p[u]);
1336
+ end: p + 1,
1337
+ errors: m[c]
1338
+ }), t = m[c]);
1336
1339
  }
1337
1340
  return i;
1338
1341
  }
1339
- function vt(s, e, t) {
1340
- const i = Fe(s, e, t);
1341
- return yt(s, e, i);
1342
+ function rt(s, e, t) {
1343
+ const i = We(s, e, t);
1344
+ return st(s, e, i);
1342
1345
  }
1343
- function Be(s, e, t) {
1346
+ function Fe(s, e, t) {
1344
1347
  let i = 0;
1345
1348
  const r = [];
1346
1349
  for (; i !== -1; )
@@ -1349,40 +1352,38 @@ function Be(s, e, t) {
1349
1352
  end: i + e.length,
1350
1353
  errors: 0
1351
1354
  }), i += 1);
1352
- return r.length > 0 ? r : vt(s, e, t);
1355
+ return r.length > 0 ? r : rt(s, e, t);
1353
1356
  }
1354
- function Se(s, e) {
1355
- return e.length === 0 || s.length === 0 ? 0 : 1 - Be(s, e, e.length)[0].errors / e.length;
1357
+ function xe(s, e) {
1358
+ return e.length === 0 || s.length === 0 ? 0 : 1 - Fe(s, e, e.length)[0].errors / e.length;
1356
1359
  }
1357
- function bt(s, e, t = {}) {
1360
+ function nt(s, e, t = {}) {
1358
1361
  if (e.length === 0)
1359
1362
  return null;
1360
- const i = Math.min(256, e.length / 2), r = Be(s, e, i);
1363
+ const i = Math.min(256, e.length / 2), r = Fe(s, e, i);
1361
1364
  if (r.length === 0)
1362
1365
  return null;
1363
1366
  const n = (l) => {
1364
- const d = 1 - l.errors / e.length, f = t.prefix ? Se(
1367
+ const p = 1 - l.errors / e.length, y = t.prefix ? xe(
1365
1368
  s.slice(
1366
1369
  Math.max(0, l.start - t.prefix.length),
1367
1370
  l.start
1368
1371
  ),
1369
1372
  t.prefix
1370
- ) : 1, g = t.suffix ? Se(
1373
+ ) : 1, d = t.suffix ? xe(
1371
1374
  s.slice(l.end, l.end + t.suffix.length),
1372
1375
  t.suffix
1373
1376
  ) : 1;
1374
- let m = 1;
1375
- typeof t.hint == "number" && (m = 1 - Math.abs(l.start - t.hint) / s.length);
1376
- const v = 50 * d + 20 * f + 20 * g + 2 * m, x = 50 + 20 + 20 + 2;
1377
- return v / x;
1377
+ let f = 1;
1378
+ return typeof t.hint == "number" && (f = 1 - Math.abs(l.start - t.hint) / s.length), (50 * p + 20 * y + 20 * d + 2 * f) / 92;
1378
1379
  }, o = r.map((l) => ({
1379
1380
  start: l.start,
1380
1381
  end: l.end,
1381
1382
  score: n(l)
1382
1383
  }));
1383
- return o.sort((l, c) => c.score - l.score), o[0];
1384
+ return o.sort((l, u) => u.score - l.score), o[0];
1384
1385
  }
1385
- function J(s, e, t) {
1386
+ function Q(s, e, t) {
1386
1387
  const i = t === 1 ? e : e - 1;
1387
1388
  if (s.charAt(i).trim() !== "")
1388
1389
  return e;
@@ -1404,8 +1405,8 @@ function Te(s, e) {
1404
1405
  let o = -1;
1405
1406
  const l = () => {
1406
1407
  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);
1408
+ const u = n.textContent, h = e === 1 ? 0 : u.length;
1409
+ o = Q(u, h, e);
1409
1410
  }
1410
1411
  };
1411
1412
  for (; n && o === -1 && n !== r; )
@@ -1414,7 +1415,7 @@ function Te(s, e) {
1414
1415
  return { node: n, offset: o };
1415
1416
  throw new RangeError("No text nodes with non-whitespace text found in range");
1416
1417
  }
1417
- function Et(s) {
1418
+ function ot(s) {
1418
1419
  if (!s.toString().trim().length)
1419
1420
  throw new RangeError("Range contains no non-whitespace text");
1420
1421
  if (s.startContainer.nodeType !== Node.TEXT_NODE)
@@ -1424,13 +1425,13 @@ function Et(s) {
1424
1425
  const e = s.cloneRange();
1425
1426
  let t = !1, i = !1;
1426
1427
  const r = {
1427
- start: J(
1428
+ start: Q(
1428
1429
  s.startContainer.textContent,
1429
1430
  s.startOffset,
1430
1431
  1
1431
1432
  /* Forwards */
1432
1433
  ),
1433
- end: J(
1434
+ end: Q(
1434
1435
  s.endContainer.textContent,
1435
1436
  s.endOffset,
1436
1437
  2
@@ -1458,11 +1459,10 @@ function Et(s) {
1458
1459
  return e;
1459
1460
  }
1460
1461
  function Ue(s) {
1461
- var e;
1462
1462
  switch (s.nodeType) {
1463
1463
  case Node.ELEMENT_NODE:
1464
1464
  case Node.TEXT_NODE:
1465
- return ((e = s.textContent) == null ? void 0 : e.length) ?? 0;
1465
+ return s.textContent?.length ?? 0;
1466
1466
  default:
1467
1467
  return 0;
1468
1468
  }
@@ -1473,7 +1473,7 @@ function we(s) {
1473
1473
  t += Ue(e), e = e.previousSibling;
1474
1474
  return t;
1475
1475
  }
1476
- function ke(s, ...e) {
1476
+ function Be(s, ...e) {
1477
1477
  let t = e.shift();
1478
1478
  const i = s.ownerDocument.createNodeIterator(
1479
1479
  s,
@@ -1527,7 +1527,7 @@ class A {
1527
1527
  */
1528
1528
  resolve(e = {}) {
1529
1529
  try {
1530
- return ke(this.element, this.offset)[0];
1530
+ return Be(this.element, this.offset)[0];
1531
1531
  } catch (t) {
1532
1532
  if (this.offset === 0 && e.direction !== void 0) {
1533
1533
  const i = document.createTreeWalker(
@@ -1586,7 +1586,7 @@ class A {
1586
1586
  }
1587
1587
  }
1588
1588
  }
1589
- class z {
1589
+ class O {
1590
1590
  constructor(e, t) {
1591
1591
  this.start = e, this.end = t;
1592
1592
  }
@@ -1596,7 +1596,7 @@ class z {
1596
1596
  * `end.element`.
1597
1597
  */
1598
1598
  relativeTo(e) {
1599
- return new z(
1599
+ return new O(
1600
1600
  this.start.relativeTo(e),
1601
1601
  this.end.relativeTo(e)
1602
1602
  );
@@ -1612,7 +1612,7 @@ class z {
1612
1612
  */
1613
1613
  toRange() {
1614
1614
  let e, t;
1615
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ke(
1615
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = Be(
1616
1616
  this.start.element,
1617
1617
  this.start.offset,
1618
1618
  this.end.offset
@@ -1634,14 +1634,14 @@ class z {
1634
1634
  e.startContainer,
1635
1635
  e.startOffset
1636
1636
  ), i = A.fromPoint(e.endContainer, e.endOffset);
1637
- return new z(t, i);
1637
+ return new O(t, i);
1638
1638
  }
1639
1639
  /**
1640
1640
  * Create a TextRange representing the `start`th to `end`th characters in
1641
1641
  * `root`
1642
1642
  */
1643
1643
  static fromOffsets(e, t, i) {
1644
- return new z(
1644
+ return new O(
1645
1645
  new A(e, t),
1646
1646
  new A(e, i)
1647
1647
  );
@@ -1651,23 +1651,23 @@ class z {
1651
1651
  * whitespace
1652
1652
  */
1653
1653
  static trimmedRange(e) {
1654
- return Et(z.fromRange(e).toRange());
1654
+ return ot(O.fromRange(e).toRange());
1655
1655
  }
1656
1656
  }
1657
- class _ {
1657
+ class X {
1658
1658
  constructor(e, t, i) {
1659
1659
  this.root = e, this.start = t, this.end = i;
1660
1660
  }
1661
1661
  static fromRange(e, t) {
1662
- const i = z.fromRange(t).relativeTo(e);
1663
- return new _(
1662
+ const i = O.fromRange(t).relativeTo(e);
1663
+ return new X(
1664
1664
  e,
1665
1665
  i.start.offset,
1666
1666
  i.end.offset
1667
1667
  );
1668
1668
  }
1669
1669
  static fromSelector(e, t) {
1670
- return new _(e, t.start, t.end);
1670
+ return new X(e, t.start, t.end);
1671
1671
  }
1672
1672
  toSelector() {
1673
1673
  return {
@@ -1677,10 +1677,10 @@ class _ {
1677
1677
  };
1678
1678
  }
1679
1679
  toRange() {
1680
- return z.fromOffsets(this.root, this.start, this.end).toRange();
1680
+ return O.fromOffsets(this.root, this.start, this.end).toRange();
1681
1681
  }
1682
1682
  }
1683
- class X {
1683
+ class G {
1684
1684
  /**
1685
1685
  * @param root - A root element from which to anchor.
1686
1686
  */
@@ -1693,15 +1693,15 @@ class X {
1693
1693
  * Will throw if `range` does not contain any text nodes.
1694
1694
  */
1695
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), {
1696
+ const i = e.textContent, r = O.fromRange(t).relativeTo(e), n = r.start.offset, o = r.end.offset, l = 32;
1697
+ return new G(e, i.slice(n, o), {
1698
1698
  prefix: i.slice(Math.max(0, n - l), n),
1699
1699
  suffix: i.slice(o, Math.min(i.length, o + l))
1700
1700
  });
1701
1701
  }
1702
1702
  static fromSelector(e, t) {
1703
1703
  const { prefix: i, suffix: r } = t;
1704
- return new X(e, t.exact, { prefix: i, suffix: r });
1704
+ return new G(e, t.exact, { prefix: i, suffix: r });
1705
1705
  }
1706
1706
  toSelector() {
1707
1707
  return {
@@ -1715,26 +1715,26 @@ class X {
1715
1715
  return this.toPositionAnchor(e).toRange();
1716
1716
  }
1717
1717
  toPositionAnchor(e = {}) {
1718
- const t = this.root.textContent, i = bt(t, this.exact, {
1718
+ const t = this.root.textContent, i = nt(t, this.exact, {
1719
1719
  ...this.context,
1720
1720
  hint: e.hint
1721
1721
  });
1722
1722
  if (!i)
1723
1723
  throw new Error("Quote not found");
1724
- return new _(this.root, i.start, i.end);
1724
+ return new X(this.root, i.start, i.end);
1725
1725
  }
1726
1726
  }
1727
- function xt(s) {
1727
+ function at(s) {
1728
1728
  const e = s.tagName.toUpperCase();
1729
1729
  return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
1730
1730
  }
1731
- function le(s, e) {
1731
+ function de(s, e) {
1732
1732
  try {
1733
1733
  const t = e.locations, i = e.text;
1734
1734
  if (i && i.highlight) {
1735
1735
  let r;
1736
1736
  t && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), r || (r = s.body);
1737
- const n = new X(r, i.highlight, {
1737
+ const n = new G(r, i.highlight, {
1738
1738
  prefix: i.before,
1739
1739
  suffix: i.after
1740
1740
  });
@@ -1753,7 +1753,7 @@ function le(s, e) {
1753
1753
  }
1754
1754
  if (r) {
1755
1755
  const n = s.createRange();
1756
- return r.childNodes.length === 0 || xt(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
1756
+ return r.childNodes.length === 0 || at(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
1757
1757
  }
1758
1758
  }
1759
1759
  } catch (t) {
@@ -1761,7 +1761,7 @@ function le(s, e) {
1761
1761
  }
1762
1762
  return null;
1763
1763
  }
1764
- function St(s, e) {
1764
+ function lt(s, e) {
1765
1765
  let t = s.getClientRects();
1766
1766
  t.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = s.commonAncestorContainer.getClientRects());
1767
1767
  const i = 1, r = [];
@@ -1774,14 +1774,13 @@ function St(s, e) {
1774
1774
  top: h.top,
1775
1775
  width: h.width
1776
1776
  });
1777
- const n = $e(
1777
+ const n = ke(
1778
1778
  r,
1779
- i,
1780
- e
1781
- ), o = wt(n, i), l = He(o), c = 2 * 2;
1779
+ i
1780
+ ), o = ct(n, i), l = $e(o), u = 4;
1782
1781
  for (let h = l.length - 1; h >= 0; h--) {
1783
- const u = l[h];
1784
- if (!(u.width * u.height > c))
1782
+ const c = l[h];
1783
+ if (!(c.width * c.height > u))
1785
1784
  if (l.length > 1)
1786
1785
  l.splice(h, 1);
1787
1786
  else
@@ -1789,25 +1788,24 @@ function St(s, e) {
1789
1788
  }
1790
1789
  return l;
1791
1790
  }
1792
- function $e(s, e, t) {
1791
+ function ke(s, e, t) {
1793
1792
  for (let i = 0; i < s.length; i++)
1794
1793
  for (let r = i + 1; r < s.length; r++) {
1795
1794
  const n = s[i], o = s[r];
1796
1795
  if (n === o)
1797
1796
  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(
1802
- d,
1803
- e,
1804
- t
1797
+ const l = C(n.top, o.top, e) && C(n.bottom, o.bottom, e), u = C(n.left, o.left, e) && C(n.right, o.right, e);
1798
+ if (l && !u && He(n, o, e)) {
1799
+ const m = s.filter((y) => y !== n && y !== o), p = ht(n, o);
1800
+ return m.push(p), ke(
1801
+ m,
1802
+ e
1805
1803
  );
1806
1804
  }
1807
1805
  }
1808
1806
  return s;
1809
1807
  }
1810
- function Tt(s, e) {
1808
+ function ht(s, e) {
1811
1809
  const t = Math.min(s.left, e.left), i = Math.max(s.right, e.right), r = Math.min(s.top, e.top), n = Math.max(s.bottom, e.bottom);
1812
1810
  return {
1813
1811
  bottom: n,
@@ -1818,7 +1816,7 @@ function Tt(s, e) {
1818
1816
  width: i - t
1819
1817
  };
1820
1818
  }
1821
- function wt(s, e) {
1819
+ function ct(s, e) {
1822
1820
  const t = new Set(s);
1823
1821
  for (const i of s) {
1824
1822
  if (!(i.width > 1 && i.height > 1)) {
@@ -1826,40 +1824,40 @@ function wt(s, e) {
1826
1824
  continue;
1827
1825
  }
1828
1826
  for (const n of s)
1829
- if (i !== n && t.has(n) && Ct(n, i, e)) {
1827
+ if (i !== n && t.has(n) && ut(n, i, e)) {
1830
1828
  t.delete(i);
1831
1829
  break;
1832
1830
  }
1833
1831
  }
1834
1832
  return Array.from(t);
1835
1833
  }
1836
- function Ct(s, e, t) {
1834
+ function ut(s, e, t) {
1837
1835
  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);
1838
1836
  }
1839
1837
  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));
1838
+ return (s.left < e || C(s.left, e, i)) && (s.right > e || C(s.right, e, i)) && (s.top < t || C(s.top, t, i)) && (s.bottom > t || C(s.bottom, t, i));
1841
1839
  }
1842
- function He(s) {
1840
+ function $e(s) {
1843
1841
  for (let e = 0; e < s.length; e++)
1844
1842
  for (let t = e + 1; t < s.length; t++) {
1845
1843
  const i = s[e], r = s[t];
1846
- if (i !== r && je(i, r, -1)) {
1844
+ if (i !== r && He(i, r, -1)) {
1847
1845
  let n = [], o;
1848
- const l = Ce(i, r);
1846
+ const l = Se(i, r);
1849
1847
  if (l.length === 1)
1850
1848
  n = l, o = i;
1851
1849
  else {
1852
- const h = Ce(r, i);
1850
+ const h = Se(r, i);
1853
1851
  l.length < h.length ? (n = l, o = i) : (n = h, o = r);
1854
1852
  }
1855
- const c = s.filter((h) => h !== o);
1856
- return Array.prototype.push.apply(c, n), He(c);
1853
+ const u = s.filter((h) => h !== o);
1854
+ return Array.prototype.push.apply(u, n), $e(u);
1857
1855
  }
1858
1856
  }
1859
1857
  return s;
1860
1858
  }
1861
- function Ce(s, e) {
1862
- const t = Pt(e, s);
1859
+ function Se(s, e) {
1860
+ const t = dt(e, s);
1863
1861
  if (t.height === 0 || t.width === 0)
1864
1862
  return [s];
1865
1863
  const i = [];
@@ -1909,7 +1907,7 @@ function Ce(s, e) {
1909
1907
  }
1910
1908
  return i;
1911
1909
  }
1912
- function Pt(s, e) {
1910
+ function dt(s, e) {
1913
1911
  const t = Math.max(s.left, e.left), i = Math.min(s.right, e.right), r = Math.max(s.top, e.top), n = Math.min(s.bottom, e.bottom);
1914
1912
  return {
1915
1913
  bottom: n,
@@ -1920,10 +1918,10 @@ function Pt(s, e) {
1920
1918
  width: Math.max(0, i - t)
1921
1919
  };
1922
1920
  }
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));
1921
+ function He(s, e, t) {
1922
+ return (s.left < e.right || t >= 0 && C(s.left, e.right, t)) && (e.left < s.right || t >= 0 && C(e.left, s.right, t)) && (s.top < e.bottom || t >= 0 && C(s.top, e.bottom, t)) && (e.top < s.bottom || t >= 0 && C(e.top, s.bottom, t));
1925
1923
  }
1926
- function M(s, e, t) {
1924
+ function C(s, e, t) {
1927
1925
  return Math.abs(s - e) <= t;
1928
1926
  }
1929
1927
  function Ve(s) {
@@ -1932,24 +1930,24 @@ function Ve(s) {
1932
1930
  Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
1933
1931
  return e;
1934
1932
  }
1935
- function Nt(s, e) {
1933
+ function pt(s, e) {
1936
1934
  const t = Ve(s);
1937
1935
  Object.keys(t).forEach((i) => {
1938
- e.hasOwnProperty(i) || he(s, i);
1936
+ e.hasOwnProperty(i) || pe(s, i);
1939
1937
  }), Object.entries(e).forEach(([i, r]) => {
1940
- t[i] !== r && G(s, i, r);
1938
+ t[i] !== r && _(s, i, r);
1941
1939
  });
1942
1940
  }
1943
- function Pe(s, e) {
1941
+ function Ce(s, e) {
1944
1942
  return s.document.documentElement.style.getPropertyValue(e);
1945
1943
  }
1946
- function G(s, e, t) {
1944
+ function _(s, e, t) {
1947
1945
  s.document.documentElement.style.setProperty(e, t);
1948
1946
  }
1949
- function he(s, e) {
1947
+ function pe(s, e) {
1950
1948
  s.document.documentElement.style.removeProperty(e);
1951
1949
  }
1952
- const Mt = (s) => {
1950
+ const ft = (s) => {
1953
1951
  if (s.startsWith("rgb")) {
1954
1952
  const e = s.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
1955
1953
  if (e)
@@ -1977,20 +1975,20 @@ const Mt = (s) => {
1977
1975
  };
1978
1976
  }
1979
1977
  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;
1978
+ }, mt = (s) => 0.2126 * s.r * s.a + 0.7152 * s.g * s.a + 0.0722 * s.b * s.a, gt = (s) => {
1979
+ const e = ft(s);
1980
+ return mt(e) < 128;
1983
1981
  };
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 {
1982
+ var yt = /* @__PURE__ */ ((s) => (s.Wrap = "wrap", s.Viewport = "viewport", s.Bounds = "bounds", s.Page = "page", s))(yt || {}), vt = /* @__PURE__ */ ((s) => (s.Boxes = "boxes", s.Bounds = "bounds", s))(vt || {});
1983
+ const Et = () => "Highlight" in window, Pe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
1984
+ class bt {
1987
1985
  /**
1988
1986
  * Creates a DecorationGroup object
1989
1987
  * @param id Unique HTML ID-adhering name of the group
1990
1988
  * @param name Human-readable name of the group
1991
1989
  */
1992
1990
  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());
1991
+ 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, Et() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
1994
1992
  }
1995
1993
  get activeable() {
1996
1994
  return this.activateable;
@@ -2003,14 +2001,13 @@ class zt {
2003
2001
  * @param decoration Decoration to add
2004
2002
  */
2005
2003
  add(e) {
2006
- var o, l, c, h;
2007
- const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
2004
+ const t = `${this.id}-${this.lastItemId++}`, i = de(this.wnd.document, e.locator);
2008
2005
  if (!i) {
2009
2006
  this.comms.log("Can't locate DOM range for decoration", e);
2010
2007
  return;
2011
2008
  }
2012
2009
  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)));
2010
+ r.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Pe.includes(r.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), r.querySelector(Pe.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (r.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));
2014
2011
  const n = {
2015
2012
  decoration: e,
2016
2013
  id: t,
@@ -2023,16 +2020,10 @@ class zt {
2023
2020
  * @param identifier ID of item to remove
2024
2021
  */
2025
2022
  remove(e) {
2026
- var r, n;
2027
- const t = this.items.findIndex((o) => o.decoration.id === e);
2028
- if (t < 0)
2029
- return;
2023
+ const t = this.items.findIndex((r) => r.decoration.id === e);
2024
+ if (t < 0) return;
2030
2025
  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))) {
2032
- const o = this.wnd.CSS.highlights.get(this.id);
2033
- o == null || o.delete(i.range);
2034
- }
2035
- (n = this.notTextFlag) == null || n.delete(i.id);
2026
+ this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
2036
2027
  }
2037
2028
  /**
2038
2029
  * Notifies that the given decoration was modified and needs to be updated.
@@ -2045,8 +2036,7 @@ class zt {
2045
2036
  * Removes all decorations from this group.
2046
2037
  */
2047
2038
  clear() {
2048
- var e;
2049
- this.clearContainer(), this.items.length = 0, (e = this.notTextFlag) == null || e.clear();
2039
+ this.clearContainer(), this.items.length = 0, this.notTextFlag?.clear();
2050
2040
  }
2051
2041
  /**
2052
2042
  * Recreates the decoration elements.
@@ -2056,12 +2046,11 @@ class zt {
2056
2046
  this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
2057
2047
  }
2058
2048
  experimentalLayout(e) {
2059
- var r, n;
2060
2049
  const [t, i] = this.requireContainer(!0);
2061
2050
  i.add(e.range), t.innerHTML = `
2062
2051
  ::highlight(${this.id}) {
2063
2052
  color: black;
2064
- background-color: ${((n = (r = e.decoration) == null ? void 0 : r.style) == null ? void 0 : n.tint) ?? "yellow"};
2053
+ background-color: ${e.decoration?.style?.tint ?? "yellow"};
2065
2054
  }`;
2066
2055
  }
2067
2056
  /**
@@ -2069,8 +2058,7 @@ class zt {
2069
2058
  * @param item
2070
2059
  */
2071
2060
  layout(e) {
2072
- var g, m, v, x, O;
2073
- if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(e.id)))
2061
+ if (this.experimentalHighlights && !this.notTextFlag?.has(e.id))
2074
2062
  return this.experimentalLayout(e);
2075
2063
  const t = this.wnd.document.createElement("div");
2076
2064
  t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
@@ -2078,50 +2066,47 @@ class zt {
2078
2066
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2079
2067
  "column-count"
2080
2068
  )
2081
- ), 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") {
2084
- 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")
2088
- 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") {
2090
- 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`;
2069
+ ), n = i / (r || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, u = o.scrollTop, h = (d, f, g) => {
2070
+ if (d.style.position = "absolute", e.decoration?.style?.width === "viewport") {
2071
+ d.style.width = `${i}px`, d.style.height = `${f.height}px`;
2072
+ let E = Math.floor(f.left / i) * i;
2073
+ d.style.left = `${E + l}px`, d.style.top = `${f.top + u}px`;
2074
+ } else if (e.decoration?.style?.width === "bounds")
2075
+ d.style.width = `${g.width}px`, d.style.height = `${f.height}px`, d.style.left = `${g.left + l}px`, d.style.top = `${f.top + u}px`;
2076
+ else if (e.decoration?.style?.width === "page") {
2077
+ d.style.width = `${n}px`, d.style.height = `${f.height}px`;
2078
+ let E = Math.floor(f.left / n) * n;
2079
+ d.style.left = `${E + l}px`, d.style.top = `${f.top + u}px`;
2093
2080
  } else
2094
- 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();
2096
- let p = this.wnd.document.createElement("template");
2097
- const d = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
2098
- p.innerHTML = `
2081
+ d.style.width = `${f.width}px`, d.style.height = `${f.height}px`, d.style.left = `${f.left + l}px`, d.style.top = `${f.top + u}px`;
2082
+ }, c = e.range.getBoundingClientRect();
2083
+ let m = this.wnd.document.createElement("template");
2084
+ const p = Ce(this.wnd, "--USER__appearance") === "readium-night-on" || gt(Ce(this.wnd, "--USER__backgroundColor"));
2085
+ m.innerHTML = `
2099
2086
  <div
2100
2087
  class="r2-highlight-0"
2101
2088
  style="${[
2102
- `background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
2089
+ `background-color: ${e.decoration?.style?.tint ?? "yellow"} !important`,
2103
2090
  //"opacity: 0.3 !important",
2104
- `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2091
+ `mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
2105
2092
  "opacity: 1 !important",
2106
2093
  "box-sizing: border-box !important"
2107
2094
  ].join("; ")}"
2108
2095
  >
2109
2096
  </div>
2110
2097
  `.trim();
2111
- const f = p.content.firstElementChild;
2112
- if (((O = (x = e.decoration) == null ? void 0 : x.style) == null ? void 0 : O.layout) === "bounds") {
2113
- const y = f.cloneNode(!0);
2114
- y.style.setProperty("pointer-events", "none"), h(y, u, u), t.append(y);
2098
+ const y = m.content.firstElementChild;
2099
+ if (e.decoration?.style?.layout === "bounds") {
2100
+ const d = y.cloneNode(!0);
2101
+ d.style.setProperty("pointer-events", "none"), h(d, c, c), t.append(d);
2115
2102
  } else {
2116
- let y = St(
2117
- e.range,
2118
- !0
2119
- // doNotMergeHorizontallyAlignedRects
2103
+ let d = lt(
2104
+ e.range
2120
2105
  );
2121
- y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
2122
- for (let b of y) {
2123
- const I = f.cloneNode(!0);
2124
- I.style.setProperty("pointer-events", "none"), h(I, b, u), t.append(I);
2106
+ d = d.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);
2107
+ for (let f of d) {
2108
+ const g = y.cloneNode(!0);
2109
+ g.style.setProperty("pointer-events", "none"), h(g, f, c), t.append(g);
2125
2110
  }
2126
2111
  }
2127
2112
  e.container = t, e.clickableElements = Array.from(
@@ -2130,11 +2115,7 @@ class zt {
2130
2115
  }
2131
2116
  renderLayout(e) {
2132
2117
  this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
2133
- if (e = e.filter((i) => {
2134
- var r;
2135
- return !this.experimentalHighlights || !!((r = this.notTextFlag) != null && r.has(i.id));
2136
- }), !e || e.length === 0)
2137
- return;
2118
+ if (e = e.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !e || e.length === 0) return;
2138
2119
  this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
2139
2120
  });
2140
2121
  }
@@ -2158,7 +2139,7 @@ class zt {
2158
2139
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2159
2140
  }
2160
2141
  }
2161
- const qe = class Q extends Y {
2142
+ const B = class B extends Z {
2162
2143
  constructor() {
2163
2144
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2164
2145
  }
@@ -2173,9 +2154,9 @@ const qe = class Q extends Y {
2173
2154
  }, 50);
2174
2155
  }
2175
2156
  mount(e, t) {
2176
- return this.wnd = e, t.register("decorate", Q.moduleName, (i, r) => {
2157
+ return this.wnd = e, t.register("decorate", B.moduleName, (i, r) => {
2177
2158
  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(
2159
+ n.decoration && n.decoration.locator && (n.decoration.locator = L.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new bt(
2179
2160
  e,
2180
2161
  t,
2181
2162
  `readium-decoration-${this.lastGroupId++}`,
@@ -2184,28 +2165,28 @@ const qe = class Q extends Y {
2184
2165
  const o = this.groups.get(n.group);
2185
2166
  switch (n.action) {
2186
2167
  case "add":
2187
- o == null || o.add(n.decoration);
2168
+ o?.add(n.decoration);
2188
2169
  break;
2189
2170
  case "remove":
2190
- o == null || o.remove(n.decoration.id);
2171
+ o?.remove(n.decoration.id);
2191
2172
  break;
2192
2173
  case "clear":
2193
- o == null || o.clear();
2174
+ o?.clear();
2194
2175
  break;
2195
2176
  case "update":
2196
- o == null || o.update(n.decoration);
2177
+ o?.update(n.decoration);
2197
2178
  break;
2198
2179
  }
2199
2180
  r(!0);
2200
2181
  }), 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;
2201
2182
  }
2202
2183
  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;
2184
+ return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(B.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
2204
2185
  }
2205
2186
  };
2206
- qe.moduleName = "decorator";
2207
- let Dt = qe;
2208
- const Me = "readium-snapper-style", _e = class ee extends Y {
2187
+ B.moduleName = "decorator";
2188
+ let ee = B;
2189
+ const Ae = "readium-snapper-style", k = class k extends Z {
2209
2190
  constructor() {
2210
2191
  super(...arguments), this.protected = !1;
2211
2192
  }
@@ -2218,60 +2199,59 @@ const Me = "readium-snapper-style", _e = class ee extends Y {
2218
2199
  }
2219
2200
  mount(e, t) {
2220
2201
  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) => {
2202
+ return i.dataset.readium = "true", i.id = Ae, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", k.moduleName, (r, n) => {
2222
2203
  this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2223
- }), t.register("unprotect", ee.moduleName, (r, n) => {
2204
+ }), t.register("unprotect", k.moduleName, (r, n) => {
2224
2205
  this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2225
2206
  }), t.log("Snapper Mounted"), !0;
2226
2207
  }
2227
2208
  unmount(e, t) {
2228
- var i;
2229
- return (i = e.document.getElementById(Me)) == null || i.remove(), t.log("Snapper Unmounted"), !0;
2209
+ return e.document.getElementById(Ae)?.remove(), t.log("Snapper Unmounted"), !0;
2230
2210
  }
2231
2211
  };
2232
- _e.moduleName = "snapper";
2233
- let Xe = _e;
2234
- function W(s) {
2212
+ k.moduleName = "snapper";
2213
+ let Y = k;
2214
+ function I(s) {
2235
2215
  return s.document.body.dir.toLowerCase() === "rtl";
2236
2216
  }
2237
- function Ge(s) {
2217
+ function je(s) {
2238
2218
  return parseInt(
2239
2219
  s.getComputedStyle(
2240
2220
  s.document.documentElement
2241
2221
  ).getPropertyValue("column-count")
2242
2222
  );
2243
2223
  }
2244
- function Ae(s) {
2224
+ function Me(s) {
2245
2225
  const e = getComputedStyle(s), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
2246
2226
  return s.clientHeight - t - i;
2247
2227
  }
2248
- function Oe(s) {
2249
- const e = Ge(s);
2228
+ function Ne(s) {
2229
+ const e = je(s);
2250
2230
  if (!e)
2251
2231
  return !1;
2252
2232
  const t = s.document.querySelectorAll("div[id^='readium-virtual-page']");
2253
2233
  for (const h of t)
2254
2234
  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;
2256
- if (c > 0)
2257
- for (let h = 0; h < c; h++) {
2258
- 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);
2235
+ const i = t.length, r = s.document.scrollingElement.scrollWidth, n = s.visualViewport.width, l = Math.round(r / n * e) % e, u = e === 1 || l === 0 ? 0 : e - l;
2236
+ if (u > 0)
2237
+ for (let h = 0; h < u; h++) {
2238
+ const c = s.document.createElement("div");
2239
+ c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = Me(s.document.documentElement) + "px"), c.innerHTML = "&#8203;", s.document.body.appendChild(c);
2260
2240
  }
2261
- return i !== c;
2241
+ return i !== u;
2262
2242
  }
2263
- function Wt(s) {
2243
+ function xt(s) {
2264
2244
  const e = s.document.createElement("style");
2265
2245
  e.appendChild(s.document.createTextNode("*{}")), s.document.body.appendChild(e), s.document.body.removeChild(e);
2266
2246
  }
2267
- function Ft(s) {
2247
+ function Tt(s) {
2268
2248
  return s < 0.5 ? 2 * s * s : -1 + (4 - 2 * s) * s;
2269
2249
  }
2270
- function S(s) {
2250
+ function T(s) {
2271
2251
  const e = s.getSelection();
2272
2252
  e && e.removeAllRanges();
2273
2253
  }
2274
- const Bt = [
2254
+ const wt = [
2275
2255
  "a",
2276
2256
  "audio",
2277
2257
  "button",
@@ -2285,36 +2265,35 @@ const Bt = [
2285
2265
  "textarea",
2286
2266
  "video"
2287
2267
  ];
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;
2268
+ function qe(s) {
2269
+ return wt.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && s.getAttribute("contenteditable")?.toLowerCase() !== "false" ? s : s.parentElement ? qe(s.parentElement) : null;
2291
2270
  }
2292
- function Ke(s, e) {
2293
- const t = Ze(s, s.document.body, e), i = s._readium_cssSelectorGenerator.getCssSelector(t, {
2271
+ function Xe(s, e) {
2272
+ const t = Ge(s, s.document.body, e), i = s._readium_cssSelectorGenerator.getCssSelector(t, {
2294
2273
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2295
2274
  });
2296
- return new D({
2275
+ return new L({
2297
2276
  href: "#",
2298
2277
  type: "application/xhtml+xml",
2299
- locations: new E({
2278
+ locations: new v({
2300
2279
  otherLocations: /* @__PURE__ */ new Map([
2301
2280
  ["cssSelector", i]
2302
2281
  ])
2303
2282
  }),
2304
- text: new U({
2283
+ text: new W({
2305
2284
  highlight: t.textContent || void 0
2306
2285
  })
2307
2286
  });
2308
2287
  }
2309
- function Ze(s, e, t) {
2288
+ function Ge(s, e, t) {
2310
2289
  for (var i = 0; i < e.children.length; i++) {
2311
2290
  const r = e.children[i];
2312
- if (!$t(r) && Ut(s, r, t))
2313
- return kt(s, r) ? r : Ze(s, r, t);
2291
+ if (!Pt(r) && St(s, r, t))
2292
+ return Ct(s, r) ? r : Ge(s, r, t);
2314
2293
  }
2315
2294
  return e;
2316
2295
  }
2317
- function Ut(s, e, t) {
2296
+ function St(s, e, t) {
2318
2297
  if (e === document.body || e === document.documentElement)
2319
2298
  return !0;
2320
2299
  if (!document || !document.documentElement || !document.body)
@@ -2322,11 +2301,11 @@ function Ut(s, e, t) {
2322
2301
  const i = e.getBoundingClientRect();
2323
2302
  return t ? i.bottom > 0 && i.top < s.innerHeight : i.right > 0 && i.left < s.innerWidth;
2324
2303
  }
2325
- function kt(s, e) {
2304
+ function Ct(s, e) {
2326
2305
  const t = e.getBoundingClientRect();
2327
2306
  return t.top >= 0 && t.left >= 0 && t.bottom <= s.innerHeight && t.right <= s.innerWidth;
2328
2307
  }
2329
- function $t(s) {
2308
+ function Pt(s) {
2330
2309
  const e = getComputedStyle(s);
2331
2310
  if (e) {
2332
2311
  const t = e.getPropertyValue("display");
@@ -2335,7 +2314,7 @@ function $t(s) {
2335
2314
  }
2336
2315
  return !1;
2337
2316
  }
2338
- const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2317
+ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
2339
2318
  constructor() {
2340
2319
  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
2320
  }
@@ -2346,7 +2325,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2346
2325
  return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
2347
2326
  }
2348
2327
  snapOffset(e) {
2349
- const t = e + (W(this.wnd) ? -1 : 1);
2328
+ const t = e + (I(this.wnd) ? -1 : 1);
2350
2329
  return t - t % this.wnd.innerWidth;
2351
2330
  }
2352
2331
  reportProgress() {
@@ -2357,10 +2336,9 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2357
2336
  });
2358
2337
  }
2359
2338
  shake() {
2360
- if (this.overscroll !== 0 || this.shakeTimeout !== 0)
2361
- return;
2339
+ if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
2362
2340
  const e = this.doc();
2363
- e.classList.add(W(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2341
+ e.classList.add(I(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2364
2342
  const t = this.scrollOffset();
2365
2343
  this.shakeTimeout = this.wnd.setTimeout(() => {
2366
2344
  e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
@@ -2368,35 +2346,33 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2368
2346
  }
2369
2347
  // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
2370
2348
  takeOverSnap() {
2371
- var t;
2372
2349
  this.snappingCancelled = !0, this.clearTouches();
2373
2350
  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;
2351
+ this.overscroll = e.style.transform?.length > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;
2375
2352
  }
2376
2353
  // Snaps the current offset to the page width.
2377
2354
  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 = (
2355
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, r = this.doc(), n = this.dragOffset(), o = je(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), u = I(this.wnd) ? -1 : 1, h = (
2379
2356
  // The hurdle to overcome in order to change pages
2380
- c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
2381
- ), u = this.snapOffset(l + h);
2382
- if (e && u !== this.scrollOffset()) {
2357
+ u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)
2358
+ ), c = this.snapOffset(l + h);
2359
+ if (e && c !== this.scrollOffset()) {
2383
2360
  this.snappingCancelled = !1;
2384
- const p = (m, v, x, O) => x > O ? v : m + (v - m) * Ft(x / O), d = (
2361
+ const m = (f, g, E, R) => E > R ? g : f + (g - f) * Tt(E / R), p = (
2385
2362
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2386
- Ht * o
2363
+ At * o
2387
2364
  );
2388
- let f;
2389
- const g = (m) => {
2390
- if (this.snappingCancelled)
2391
- return;
2392
- f || (f = m);
2393
- 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());
2365
+ let y;
2366
+ const d = (f) => {
2367
+ if (this.snappingCancelled) return;
2368
+ y || (y = f);
2369
+ const g = f - y, E = m(this.overscroll, 0, g, p), R = m(i, c, g, p);
2370
+ r.scrollLeft = R, this.overscroll !== 0 && (r.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < p ? this.wnd.requestAnimationFrame(d) : (this.clearTouches(), r.style.removeProperty("transform"), r.scrollLeft = c, t || this.reportProgress());
2395
2371
  };
2396
- this.wnd.requestAnimationFrame(g);
2372
+ this.wnd.requestAnimationFrame(d);
2397
2373
  } else
2398
2374
  r.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2399
- r.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
2375
+ r.scrollLeft = c, this.clearTouches(), t || this.reportProgress();
2400
2376
  });
2401
2377
  }
2402
2378
  dragOffset() {
@@ -2430,18 +2406,16 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2430
2406
  this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
2431
2407
  }
2432
2408
  onTouchMove(e) {
2433
- if (this.touchState === 0)
2434
- return;
2435
- this.touchState === 1 && (this.touchState = 2, S(this.wnd)), this.endingX = e.touches[0].clientX;
2409
+ if (this.touchState === 0) return;
2410
+ this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = e.touches[0].clientX;
2436
2411
  const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2437
2412
  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);
2438
2413
  }
2439
2414
  mount(e, t) {
2440
- if (this.wnd = e, this.comms = t, !super.mount(e, t))
2441
- return !1;
2415
+ if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;
2442
2416
  e.navigator.epubReadingSystem.layoutStyle = "paginated";
2443
2417
  const i = e.document.createElement("style");
2444
- i.dataset.readium = "true", i.id = Ie, i.textContent = `
2418
+ i.dataset.readium = "true", i.id = Oe, i.textContent = `
2445
2419
  @keyframes readium-bounce-l-animation {
2446
2420
  0%, 100% {transform: translate3d(0, 0, 0);}
2447
2421
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2477,14 +2451,14 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2477
2451
  }
2478
2452
  `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2479
2453
  e.requestAnimationFrame(() => {
2480
- e && Oe(e);
2454
+ e && Ne(e);
2481
2455
  }), this.onWidthChange();
2482
2456
  }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2483
2457
  for (const o of n)
2484
2458
  if (o.target === this.wnd.document.documentElement) {
2485
- 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);
2459
+ const l = o.oldValue, u = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = l?.match(h), m = u?.match(h);
2460
+ (!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {
2461
+ e && Ne(e);
2488
2462
  }), this.onWidthChange());
2489
2463
  } else
2490
2464
  e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
@@ -2493,7 +2467,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2493
2467
  const o = this.doc().scrollLeft;
2494
2468
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2495
2469
  };
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) => {
2470
+ return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", b.moduleName, (n, o) => {
2497
2471
  const l = n;
2498
2472
  if (l < 0 || l > 1) {
2499
2473
  t.send("error", {
@@ -2503,26 +2477,26 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2503
2477
  }
2504
2478
  this.wnd.requestAnimationFrame(() => {
2505
2479
  this.cachedScrollWidth = this.doc().scrollWidth;
2506
- const c = this.cachedScrollWidth, h = W(e) ? -1 : 1, u = c * l * h;
2507
- this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), S(this.wnd), o(!0);
2480
+ const u = this.cachedScrollWidth, h = I(e) ? -1 : 1, c = u * l * h;
2481
+ this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), T(this.wnd), o(!0);
2508
2482
  });
2509
- }), t.register("go_id", C.moduleName, (n, o) => {
2483
+ }), t.register("go_id", b.moduleName, (n, o) => {
2510
2484
  const l = e.document.getElementById(n);
2511
2485
  if (!l) {
2512
2486
  o(!1);
2513
2487
  return;
2514
2488
  }
2515
2489
  this.wnd.requestAnimationFrame(() => {
2516
- this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2490
+ this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2517
2491
  });
2518
- }), t.register("go_text", C.moduleName, (n, o) => {
2492
+ }), t.register("go_text", b.moduleName, (n, o) => {
2519
2493
  let l;
2520
2494
  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({
2495
+ const u = W.deserialize(n), h = de(this.wnd.document, new L({
2522
2496
  href: e.location.href,
2523
2497
  type: "text/html",
2524
- text: c,
2525
- locations: l ? new E({
2498
+ text: u,
2499
+ locations: l ? new v({
2526
2500
  otherLocations: /* @__PURE__ */ new Map([
2527
2501
  ["cssSelector", l]
2528
2502
  ])
@@ -2533,57 +2507,54 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class C extends Xe {
2533
2507
  return;
2534
2508
  }
2535
2509
  this.wnd.requestAnimationFrame(() => {
2536
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), S(this.wnd), o(!0);
2510
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2537
2511
  });
2538
- }), t.register("go_end", C.moduleName, (n, o) => {
2539
- const l = W(e) ? -1 : 1;
2512
+ }), t.register("go_end", b.moduleName, (n, o) => {
2513
+ const l = I(e) ? -1 : 1;
2540
2514
  this.wnd.requestAnimationFrame(() => {
2541
2515
  this.cachedScrollWidth = this.doc().scrollWidth;
2542
- const c = this.cachedScrollWidth * l;
2543
- if (this.doc().scrollLeft === c)
2544
- return o(!1);
2545
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), S(this.wnd), o(!0);
2516
+ const u = this.cachedScrollWidth * l;
2517
+ if (this.doc().scrollLeft === u) return o(!1);
2518
+ this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), T(this.wnd), o(!0);
2546
2519
  });
2547
- }), t.register("go_start", C.moduleName, (n, o) => {
2520
+ }), t.register("go_start", b.moduleName, (n, o) => {
2548
2521
  this.wnd.requestAnimationFrame(() => {
2549
- if (this.doc().scrollLeft === 0)
2550
- return o(!1);
2551
- this.doc().scrollLeft = 0, this.reportProgress(), S(this.wnd), o(!0);
2522
+ if (this.doc().scrollLeft === 0) return o(!1);
2523
+ this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
2552
2524
  });
2553
- }), t.register("go_prev", C.moduleName, (n, o) => {
2525
+ }), t.register("go_prev", b.moduleName, (n, o) => {
2554
2526
  this.wnd.requestAnimationFrame(() => {
2555
2527
  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));
2557
- h && (this.reportProgress(), S(this.wnd)), o(h);
2528
+ const l = e.scrollX - e.innerWidth, u = I(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = r(Math.max(l, u));
2529
+ h && (this.reportProgress(), T(this.wnd)), o(h);
2558
2530
  });
2559
- }), t.register("go_next", C.moduleName, (n, o) => {
2531
+ }), t.register("go_next", b.moduleName, (n, o) => {
2560
2532
  this.wnd.requestAnimationFrame(() => {
2561
2533
  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));
2563
- h && (this.reportProgress(), S(this.wnd)), o(h);
2534
+ const l = e.scrollX + e.innerWidth, u = I(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = r(Math.min(l, u));
2535
+ h && (this.reportProgress(), T(this.wnd)), o(h);
2564
2536
  });
2565
- }), t.register("unfocus", C.moduleName, (n, o) => {
2566
- this.snappingCancelled = !0, S(this.wnd), o(!0);
2567
- }), t.register("shake", C.moduleName, (n, o) => {
2537
+ }), t.register("unfocus", b.moduleName, (n, o) => {
2538
+ this.snappingCancelled = !0, T(this.wnd), o(!0);
2539
+ }), t.register("shake", b.moduleName, (n, o) => {
2568
2540
  this.shake(), o(!0);
2569
- }), t.register("focus", C.moduleName, (n, o) => {
2541
+ }), t.register("focus", b.moduleName, (n, o) => {
2570
2542
  this.wnd.requestAnimationFrame(() => {
2571
2543
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2572
2544
  });
2573
- }), t.register("first_visible_locator", C.moduleName, (n, o) => {
2574
- const l = Ke(e, !1);
2545
+ }), t.register("first_visible_locator", b.moduleName, (n, o) => {
2546
+ const l = Xe(e, !1);
2575
2547
  this.comms.send("first_visible_locator", l.serialize()), o(!0);
2576
2548
  }), 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
2549
  }), t.log("ColumnSnapper Mounted"), !0;
2578
2550
  }
2579
2551
  unmount(e, t) {
2580
- 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);
2552
+ return this.snappingCancelled = !0, t.unregisterAll(b.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(Oe)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2582
2553
  }
2583
2554
  };
2584
- Je.moduleName = "column_snapper";
2585
- let jt = Je;
2586
- const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
2555
+ b.moduleName = "column_snapper";
2556
+ let te = b;
2557
+ const Le = "readium-scroll-snapper-style", x = class x extends Y {
2587
2558
  constructor() {
2588
2559
  super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
2589
2560
  if (this.comms.ready && !this.isResizing) {
@@ -2603,8 +2574,7 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
2603
2574
  return this.wnd.document.scrollingElement;
2604
2575
  }
2605
2576
  reportProgress() {
2606
- if (!this.comms.ready)
2607
- return;
2577
+ if (!this.comms.ready) return;
2608
2578
  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));
2609
2579
  this.comms.send("progress", {
2610
2580
  start: r,
@@ -2626,11 +2596,11 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
2626
2596
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2627
2597
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2628
2598
  }, 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);
2599
+ }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", x.moduleName, () => {
2600
+ xt(this.wnd);
2631
2601
  const r = this.doc().scrollTop;
2632
2602
  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) => {
2603
+ }), t.register("go_progression", x.moduleName, (r, n) => {
2634
2604
  const o = r;
2635
2605
  if (o < 0 || o > 1) {
2636
2606
  t.send("error", {
@@ -2639,91 +2609,86 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
2639
2609
  return;
2640
2610
  }
2641
2611
  this.wnd.requestAnimationFrame(() => {
2642
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), S(this.wnd), n(!0);
2612
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), T(this.wnd), n(!0);
2643
2613
  });
2644
- }), t.register("go_id", P.moduleName, (r, n) => {
2614
+ }), t.register("go_id", x.moduleName, (r, n) => {
2645
2615
  const o = e.document.getElementById(r);
2646
2616
  if (!o) {
2647
2617
  n(!1);
2648
2618
  return;
2649
2619
  }
2650
2620
  this.wnd.requestAnimationFrame(() => {
2651
- this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
2621
+ this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
2652
2622
  });
2653
- }), t.register("go_text", P.moduleName, (r, n) => {
2623
+ }), t.register("go_text", x.moduleName, (r, n) => {
2654
2624
  let o;
2655
2625
  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({
2626
+ const l = W.deserialize(r), u = de(this.wnd.document, new L({
2657
2627
  href: e.location.href,
2658
2628
  type: "text/html",
2659
2629
  text: l,
2660
- locations: o ? new E({
2630
+ locations: o ? new v({
2661
2631
  otherLocations: /* @__PURE__ */ new Map([
2662
2632
  ["cssSelector", o]
2663
2633
  ])
2664
2634
  }) : void 0
2665
2635
  }));
2666
- if (!c) {
2636
+ if (!u) {
2667
2637
  n(!1);
2668
2638
  return;
2669
2639
  }
2670
2640
  this.wnd.requestAnimationFrame(() => {
2671
- this.doc().scrollTop = c.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
2641
+ this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
2672
2642
  });
2673
- }), t.register("go_start", P.moduleName, (r, n) => {
2674
- if (this.doc().scrollTop === 0)
2675
- return n(!1);
2643
+ }), t.register("go_start", x.moduleName, (r, n) => {
2644
+ if (this.doc().scrollTop === 0) return n(!1);
2676
2645
  this.doc().scrollTop = 0, this.reportProgress(), n(!0);
2677
- }), t.register("go_end", P.moduleName, (r, n) => {
2678
- if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight)
2679
- return n(!1);
2646
+ }), t.register("go_end", x.moduleName, (r, n) => {
2647
+ if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
2680
2648
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
2681
- }), t.register("unfocus", P.moduleName, (r, n) => {
2682
- S(this.wnd), n(!0);
2649
+ }), t.register("unfocus", x.moduleName, (r, n) => {
2650
+ T(this.wnd), n(!0);
2683
2651
  }), t.register([
2684
2652
  "go_next",
2685
2653
  "go_prev"
2686
- ], P.moduleName, (r, n) => n(!1)), t.register("focus", P.moduleName, (r, n) => {
2654
+ ], x.moduleName, (r, n) => n(!1)), t.register("focus", x.moduleName, (r, n) => {
2687
2655
  this.reportProgress(), n(!0);
2688
- }), t.register("first_visible_locator", P.moduleName, (r, n) => {
2689
- const o = Ke(e, !0);
2656
+ }), t.register("first_visible_locator", x.moduleName, (r, n) => {
2657
+ const o = Xe(e, !0);
2690
2658
  this.comms.send("first_visible_locator", o.serialize()), n(!0);
2691
2659
  }), t.log("ScrollSnapper Mounted"), !0;
2692
2660
  }
2693
2661
  unmount(e, t) {
2694
- 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;
2662
+ return t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(Le)?.remove(), t.log("ScrollSnapper Unmounted"), !0;
2696
2663
  }
2697
2664
  };
2698
- Qe.moduleName = "scroll_snapper";
2699
- let Vt = Qe;
2700
- class et extends Y {
2665
+ x.moduleName = "scroll_snapper";
2666
+ let ie = x;
2667
+ const fe = class fe extends Z {
2701
2668
  constructor() {
2702
2669
  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
2670
  }
2704
2671
  onPointUp(e) {
2705
- var r, n, o, l, c;
2706
2672
  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();
2709
- if (!h || h.length === 0)
2673
+ if (t && t.toString()?.length > 0) {
2674
+ const r = t.getRangeAt(0)?.getClientRects();
2675
+ if (!r || r.length === 0)
2710
2676
  return;
2711
- const u = h[0], p = {
2677
+ const n = r[0], o = {
2712
2678
  text: t.toString(),
2713
- x: u.x,
2714
- y: u.y,
2715
- width: u.width,
2716
- height: u.height,
2717
- targetFrameSrc: (l = (o = this.wnd) == null ? void 0 : o.location) == null ? void 0 : l.href
2679
+ x: n.x,
2680
+ y: n.y,
2681
+ width: n.width,
2682
+ height: n.height,
2683
+ targetFrameSrc: this.wnd?.location?.href
2718
2684
  };
2719
- this.comms.send("text_selected", p);
2685
+ this.comms.send("text_selected", o);
2720
2686
  }
2721
2687
  if (this.pointerMoved) {
2722
2688
  this.pointerMoved = !1;
2723
2689
  return;
2724
2690
  }
2725
- if (!(t != null && t.isCollapsed) || !e.isPrimary)
2726
- return;
2691
+ if (!t?.isCollapsed || !e.isPrimary) return;
2727
2692
  const i = this.wnd.devicePixelRatio;
2728
2693
  e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
2729
2694
  defaultPrevented: e.defaultPrevented,
@@ -2731,7 +2696,7 @@ class et extends Y {
2731
2696
  y: e.clientY * i,
2732
2697
  targetFrameSrc: this.wnd.location.href,
2733
2698
  targetElement: e.target.outerHTML,
2734
- interactiveElement: (c = Ye(e.target)) == null ? void 0 : c.outerHTML,
2699
+ interactiveElement: qe(e.target)?.outerHTML,
2735
2700
  cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
2736
2701
  }), this.pointerMoved = !1;
2737
2702
  }
@@ -2766,15 +2731,15 @@ class et extends Y {
2766
2731
  unmount(e, t) {
2767
2732
  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;
2768
2733
  }
2769
- }
2770
- et.moduleName = "peripherals";
2771
- const tt = class te extends Y {
2734
+ };
2735
+ fe.moduleName = "peripherals";
2736
+ let se = fe;
2737
+ const $ = class $ extends Z {
2772
2738
  constructor() {
2773
2739
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
2774
2740
  }
2775
2741
  wndOnErr(e) {
2776
- var t;
2777
- (t = this.comms) == null || t.send("error", {
2742
+ this.comms?.send("error", {
2778
2743
  message: e.message,
2779
2744
  filename: e.filename,
2780
2745
  lineno: e.lineno,
@@ -2782,32 +2747,29 @@ const tt = class te extends Y {
2782
2747
  });
2783
2748
  }
2784
2749
  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();
2788
- switch (i[0]) {
2750
+ for (e._readium_blockEvents = !1; e._readium_blockedEvents?.length > 0; ) {
2751
+ const t = e._readium_blockedEvents.shift();
2752
+ switch (t[0]) {
2789
2753
  case 0:
2790
- Reflect.apply(i[1], i[2], i[3]);
2754
+ Reflect.apply(t[1], t[2], t[3]);
2791
2755
  break;
2792
2756
  case 1:
2793
- const r = i[1], n = i[2];
2794
- e.removeEventListener(r.type, e._readium_eventBlocker, !0);
2795
- const o = new Event(r.type, {
2796
- bubbles: r.bubbles,
2797
- cancelable: r.cancelable
2757
+ const i = t[1], r = t[2];
2758
+ e.removeEventListener(i.type, e._readium_eventBlocker, !0);
2759
+ const n = new Event(i.type, {
2760
+ bubbles: i.bubbles,
2761
+ cancelable: i.cancelable
2798
2762
  });
2799
- n ? n.dispatchEvent(o) : e.dispatchEvent(o);
2763
+ r ? r.dispatchEvent(n) : e.dispatchEvent(n);
2800
2764
  break;
2801
2765
  }
2802
2766
  }
2803
2767
  }
2804
2768
  onMediaPlayEvent() {
2805
- var e;
2806
- this.mediaPlayingCount++, (e = this.comms) == null || e.send("media_play", this.mediaPlayingCount);
2769
+ this.mediaPlayingCount++, this.comms?.send("media_play", this.mediaPlayingCount);
2807
2770
  }
2808
2771
  onMediaPauseEvent() {
2809
- var e;
2810
- this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (e = this.comms) == null || e.send("media_pause", this.mediaPlayingCount);
2772
+ this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);
2811
2773
  }
2812
2774
  pauseAllMedia(e) {
2813
2775
  const t = e.document.querySelectorAll("audio,video");
@@ -2822,7 +2784,7 @@ const tt = class te extends Y {
2822
2784
  ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
2823
2785
  value: {
2824
2786
  name: "readium-ts-toolkit",
2825
- version: "2.0.0",
2787
+ version: "2.1.1",
2826
2788
  hasFeature: (r, n = "") => {
2827
2789
  switch (r) {
2828
2790
  case "dom-manipulation":
@@ -2847,11 +2809,11 @@ const tt = class te extends Y {
2847
2809
  writable: !1
2848
2810
  }), "getAnimations" in e.document && e.document.getAnimations().forEach((r) => {
2849
2811
  r.cancel(), this.allAnimations.add(r);
2850
- }), t.register("activate", te.moduleName, (r, n) => {
2812
+ }), t.register("activate", $.moduleName, (r, n) => {
2851
2813
  this.allAnimations.forEach((o) => {
2852
2814
  o.cancel(), o.play();
2853
2815
  }), n(!0);
2854
- }), t.register("unfocus", te.moduleName, (r, n) => {
2816
+ }), t.register("unfocus", $.moduleName, (r, n) => {
2855
2817
  this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
2856
2818
  });
2857
2819
  const i = e.document.querySelectorAll("audio,video");
@@ -2869,49 +2831,46 @@ const tt = class te extends Y {
2869
2831
  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;
2870
2832
  }
2871
2833
  };
2872
- tt.moduleName = "setup";
2873
- let it = tt;
2874
- const Re = "readium-viewport", st = class F extends it {
2834
+ $.moduleName = "setup";
2835
+ let K = $;
2836
+ const Ie = "readium-viewport", N = class N extends K {
2875
2837
  onViewportWidthChanged(e) {
2876
2838
  const t = e.target;
2877
- G(t, "--RS__viewportWidth", `${t.innerWidth}px`);
2839
+ _(t, "--RS__viewportWidth", `${t.innerWidth}px`);
2878
2840
  }
2879
2841
  mount(e, t) {
2880
- if (!super.mount(e, t))
2881
- return !1;
2842
+ if (!super.mount(e, t)) return !1;
2882
2843
  const i = e.document.createElement("meta");
2883
- return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Re), i.setAttribute(
2844
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Ie), i.setAttribute(
2884
2845
  "content",
2885
2846
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
2886
2847
  ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
2887
2848
  target: e
2888
- }), t.register("get_properties", F.moduleName, (r, n) => {
2849
+ }), t.register("get_properties", N.moduleName, (r, n) => {
2889
2850
  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) => {
2851
+ }), t.register("update_properties", N.moduleName, (r, n) => {
2852
+ r["--RS__viewportWidth"] = `${e.innerWidth}px`, pt(e, r), n(!0);
2853
+ }), t.register("set_property", N.moduleName, (r, n) => {
2893
2854
  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) => {
2855
+ _(e, o[0], o[1]), n(!0);
2856
+ }), t.register("remove_property", N.moduleName, (r, n) => {
2857
+ pe(e, r), n(!0);
2858
+ }), t.register("activate", N.moduleName, (r, n) => {
2898
2859
  this.unblock(e), n(!0);
2899
2860
  }), t.log("ReflowableSetup Mounted"), !0;
2900
2861
  }
2901
2862
  unmount(e, t) {
2902
- 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);
2863
+ return t.unregisterAll(N.moduleName), e.document.head.querySelector(`#${Ie}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
2904
2864
  }
2905
2865
  };
2906
- st.moduleName = "reflowable_setup";
2907
- let qt = st;
2908
- const ze = "readium-fixed-style", rt = class L extends it {
2866
+ N.moduleName = "reflowable_setup";
2867
+ let re = N;
2868
+ const Re = "readium-fixed-style", P = class P extends K {
2909
2869
  mount(e, t) {
2910
- if (!super.mount(e, t))
2911
- return !1;
2870
+ if (!super.mount(e, t)) return !1;
2912
2871
  e.navigator.epubReadingSystem.layoutStyle = "paginated";
2913
2872
  const i = e.document.createElement("style");
2914
- return i.id = ze, i.dataset.readium = "true", i.textContent = `
2873
+ return i.id = Re, i.dataset.readium = "true", i.textContent = `
2915
2874
  html, body {
2916
2875
  text-size-adjust: none;
2917
2876
  -ms-text-size-adjust: none;
@@ -2923,13 +2882,13 @@ const ze = "readium-fixed-style", rt = class L extends it {
2923
2882
  min-height: 100%;
2924
2883
 
2925
2884
  /*cursor: var() TODO*/
2926
- }`, e.document.head.appendChild(i), t.register("set_property", L.moduleName, (r, n) => {
2885
+ }`, e.document.head.appendChild(i), t.register("set_property", P.moduleName, (r, n) => {
2927
2886
  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);
2887
+ _(e, o[0], o[1]), n(!0);
2888
+ }), t.register("remove_property", P.moduleName, (r, n) => {
2889
+ pe(e, r), n(!0);
2890
+ }), t.register("first_visible_locator", P.moduleName, (r, n) => n(!1)), t.register("unfocus", P.moduleName, (r, n) => {
2891
+ T(e), n(!0);
2933
2892
  }), t.register([
2934
2893
  "focus",
2935
2894
  "go_next",
@@ -2939,43 +2898,42 @@ const ze = "readium-fixed-style", rt = class L extends it {
2939
2898
  "go_start",
2940
2899
  "go_text",
2941
2900
  "go_progression"
2942
- ], L.moduleName, (r, n) => n(!0)), t.register("activate", L.moduleName, (r, n) => {
2901
+ ], P.moduleName, (r, n) => n(!0)), t.register("activate", P.moduleName, (r, n) => {
2943
2902
  this.unblock(e), n(!0);
2944
2903
  }), t.log("FixedSetup Mounted"), !0;
2945
2904
  }
2946
2905
  unmount(e, t) {
2947
- var i;
2948
- return t.unregisterAll(L.moduleName), (i = e.document.getElementById(ze)) == null || i.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
2906
+ return t.unregisterAll(P.moduleName), e.document.getElementById(Re)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
2949
2907
  }
2950
2908
  };
2951
- rt.moduleName = "fixed_setup";
2952
- let _t = rt;
2953
- const Xt = [
2909
+ P.moduleName = "fixed_setup";
2910
+ let ne = P;
2911
+ const Nt = [
2954
2912
  "fixed_setup",
2955
2913
  "decorator",
2956
2914
  "peripherals"
2957
- ], Gt = [
2915
+ ], Ot = [
2958
2916
  "reflowable_setup",
2959
2917
  "decorator",
2960
2918
  "peripherals",
2961
2919
  "column_snapper",
2962
2920
  "scroll_snapper"
2963
- ], De = new Map([
2921
+ ], ze = new Map([
2964
2922
  // All modules go here
2965
- _t,
2966
- qt,
2967
- et,
2968
- Dt,
2969
- jt,
2970
- Vt
2923
+ ne,
2924
+ re,
2925
+ se,
2926
+ ee,
2927
+ te,
2928
+ ie
2971
2929
  ].map((s) => [s.moduleName, s]));
2972
- class Yt {
2930
+ class Lt {
2973
2931
  /**
2974
2932
  * @param wnd Window instance to operate on
2975
2933
  * @param initialModules List of initial modules to load
2976
2934
  */
2977
2935
  constructor(e = window, t = []) {
2978
- this.loadedModules = [], this.wnd = e, this.comms = new at(e);
2936
+ this.loadedModules = [], this.wnd = e, this.comms = new Ke(e);
2979
2937
  const i = [...new Set(t)];
2980
2938
  if (i.length) {
2981
2939
  if (typeof e > "u")
@@ -2988,7 +2946,7 @@ class Yt {
2988
2946
  }
2989
2947
  }
2990
2948
  loadModule(e) {
2991
- const t = De.get(e);
2949
+ const t = ze.get(e);
2992
2950
  return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
2993
2951
  }
2994
2952
  /**
@@ -3006,7 +2964,7 @@ class Yt {
3006
2964
  * @returns Success
3007
2965
  */
3008
2966
  removeModule(e) {
3009
- const t = De.get(e);
2967
+ const t = ze.get(e);
3010
2968
  if (t === void 0)
3011
2969
  return this.comms.log(`Module "${e}" does not exist in the library`), !1;
3012
2970
  const i = this.loadedModules.findIndex((r) => r instanceof t);
@@ -3020,16 +2978,16 @@ class Yt {
3020
2978
  }
3021
2979
  }
3022
2980
  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
2981
+ F as COMMS_VERSION,
2982
+ Ke as Comms,
2983
+ ee as Decorator,
2984
+ Nt as FXLModules,
2985
+ vt as Layout,
2986
+ Lt as Loader,
2987
+ Z as Module,
2988
+ ze as ModuleLibrary,
2989
+ se as Peripherals,
2990
+ Ot as ReflowableModules,
2991
+ yt as Width,
2992
+ Ye as mid
3035
2993
  };