@readium/navigator-html-injectables 1.3.3 → 2.0.0-beta.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,5 +1,5 @@
1
- const Lt = Math.pow(2, 32), Me = () => Math.round(Math.random() * Lt).toString(36), It = () => `${Math.round(performance.now())}-${Me()}-${Me()}`, j = 1;
2
- class zt {
1
+ const nt = Math.pow(2, 32), ge = () => Math.round(Math.random() * nt).toString(36), ot = () => `${Math.round(performance.now())}-${ge()}-${ge()}`, k = 1;
2
+ class at {
3
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
  }
@@ -12,11 +12,11 @@ class zt {
12
12
  if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
13
13
  if (t.key === "_ping") {
14
14
  if (!this.destination) {
15
- if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== j) {
16
- t._readium > j ? this.send("error", `received comms version ${t._readium} higher than ${j}`) : this.send("error", `received comms version ${t._readium} lower than ${j}`), this.destination = null, this.origin = "", this.channelId = "";
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 = "";
17
17
  return;
18
18
  }
19
- this.send("_pong", void 0), this.preLog.forEach((r) => this.send("log", r)), this.preLog = [];
19
+ this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
20
20
  }
21
21
  return;
22
22
  } else if (this.channelId) {
@@ -33,35 +33,35 @@ class zt {
33
33
  e.strict && this.send("_unhandled", e);
34
34
  return;
35
35
  }
36
- t.forEach((r) => r.cb(e.data, (n) => {
37
- this.send("_ack", n, e.id);
36
+ t.forEach((i) => i.cb(e.data, (s) => {
37
+ this.send("_ack", s, e.id);
38
38
  }));
39
39
  }
40
- register(e, t, r) {
41
- Array.isArray(e) || (e = [e]), e.forEach((n) => {
42
- const s = this.registrar.get(n);
43
- if (s && s.length >= 0) {
44
- if (s.find((a) => a.module === t))
45
- throw new Error(`Trying to register another callback for combination of event ${n} and module ${t}`);
46
- s.push({
47
- cb: r,
40
+ register(e, t, i) {
41
+ Array.isArray(e) || (e = [e]), e.forEach((s) => {
42
+ const n = this.registrar.get(s);
43
+ if (n && n.length >= 0) {
44
+ if (n.find((a) => a.module === t))
45
+ throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);
46
+ n.push({
47
+ cb: i,
48
48
  module: t
49
- }), this.registrar.set(n, s);
49
+ }), this.registrar.set(s, n);
50
50
  } else
51
- this.registrar.set(n, [{
52
- cb: r,
51
+ this.registrar.set(s, [{
52
+ cb: i,
53
53
  module: t
54
54
  }]);
55
55
  });
56
56
  }
57
57
  unregister(e, t) {
58
- Array.isArray(e) || (e = [e]), e.forEach((r) => {
59
- const n = this.registrar.get(r);
60
- !n || n.length === 0 || n.splice(n.findIndex((s) => s.module === t), 1);
58
+ Array.isArray(e) || (e = [e]), e.forEach((i) => {
59
+ const s = this.registrar.get(i);
60
+ !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === t), 1);
61
61
  });
62
62
  }
63
63
  unregisterAll(e) {
64
- this.registrar.forEach((t, r) => this.registrar.set(r, t.filter((n) => n.module !== e)));
64
+ this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((s) => s.module !== e)));
65
65
  }
66
66
  log(...e) {
67
67
  this.destination ? this.send("log", e) : this.preLog.push(e);
@@ -72,30 +72,30 @@ class zt {
72
72
  destroy() {
73
73
  this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
74
74
  }
75
- send(e, t, r = void 0, n = []) {
75
+ send(e, t, i = void 0, s = []) {
76
76
  if (!this.destination)
77
77
  throw Error("Attempted to send comms message before destination has been initialized");
78
- const s = {
79
- _readium: j,
78
+ const n = {
79
+ _readium: k,
80
80
  _channel: this.channelId,
81
- id: r ?? It(),
81
+ id: i ?? ot(),
82
82
  // scrict,
83
83
  key: e,
84
84
  data: t
85
85
  };
86
86
  try {
87
- this.destination.postMessage(s, {
87
+ this.destination.postMessage(n, {
88
88
  targetOrigin: this.origin,
89
- transfer: n
89
+ transfer: s
90
90
  });
91
91
  } catch (o) {
92
- if (n.length > 0)
92
+ if (s.length > 0)
93
93
  throw o;
94
- this.destination.postMessage(s, this.origin, n);
94
+ this.destination.postMessage(n, this.origin, s);
95
95
  }
96
96
  }
97
97
  }
98
- class we {
98
+ class ie {
99
99
  /**
100
100
  * Creates a [Encryption].
101
101
  */
@@ -107,7 +107,7 @@ class we {
107
107
  */
108
108
  static deserialize(e) {
109
109
  if (e && e.algorithm)
110
- return new we({
110
+ return new ie({
111
111
  algorithm: e.algorithm,
112
112
  compression: e.compression,
113
113
  originalLength: e.originalLength,
@@ -123,7 +123,7 @@ class we {
123
123
  return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
124
124
  }
125
125
  }
126
- class b {
126
+ class E {
127
127
  constructor(e) {
128
128
  this.otherProperties = e;
129
129
  }
@@ -132,7 +132,7 @@ class b {
132
132
  */
133
133
  static deserialize(e) {
134
134
  if (e)
135
- return new b(e);
135
+ return new E(e);
136
136
  }
137
137
  /**
138
138
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -145,49 +145,49 @@ class b {
145
145
  */
146
146
  add(e) {
147
147
  const t = Object.assign({}, this.otherProperties);
148
- for (const r in e)
149
- t[r] = e[r];
150
- return new b(t);
148
+ for (const i in e)
149
+ t[i] = e[i];
150
+ return new E(t);
151
151
  }
152
152
  }
153
- Object.defineProperty(b.prototype, "encryption", {
153
+ Object.defineProperty(E.prototype, "encryption", {
154
154
  get: function() {
155
- return we.deserialize(this.otherProperties.encrypted);
155
+ return ie.deserialize(this.otherProperties.encrypted);
156
156
  }
157
157
  });
158
- b.prototype.getContains = function() {
158
+ E.prototype.getContains = function() {
159
159
  return new Set(this.otherProperties.contains || []);
160
160
  };
161
- b.prototype.getLayout = function() {
161
+ E.prototype.getLayout = function() {
162
162
  return this.otherProperties.layout;
163
163
  };
164
164
  class l {
165
165
  /** Creates a MediaType object. */
166
166
  constructor(e) {
167
- let t, r, n = e.mediaType.replace(/\s/g, "").split(";");
168
- const s = n[0].split("/");
169
- if (s.length === 2) {
170
- if (t = s[0].toLowerCase().trim(), r = s[1].toLowerCase().trim(), t.length === 0 || r.length === 0)
167
+ let t, i, s = e.mediaType.replace(/\s/g, "").split(";");
168
+ const n = s[0].split("/");
169
+ if (n.length === 2) {
170
+ if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
171
171
  throw new Error("Invalid media type");
172
172
  } else
173
173
  throw new Error("Invalid media type");
174
174
  const o = {};
175
- for (let d = 1; d < n.length; d++) {
176
- const f = n[d].split("=");
175
+ for (let u = 1; u < s.length; u++) {
176
+ const f = s[u].split("=");
177
177
  if (f.length === 2) {
178
- const v = f[0].toLocaleLowerCase(), g = v === "charset" ? f[1].toUpperCase() : f[1];
179
- o[v] = g;
178
+ const g = f[0].toLocaleLowerCase(), m = g === "charset" ? f[1].toUpperCase() : f[1];
179
+ o[g] = m;
180
180
  }
181
181
  }
182
182
  const a = {}, h = Object.keys(o);
183
- h.sort((d, f) => d.localeCompare(f)), h.forEach((d) => a[d] = o[d]);
183
+ h.sort((u, f) => u.localeCompare(f)), h.forEach((u) => a[u] = o[u]);
184
184
  let c = "";
185
- for (const d in a) {
186
- const f = a[d];
187
- c += `;${d}=${f}`;
185
+ for (const u in a) {
186
+ const f = a[u];
187
+ c += `;${u}=${f}`;
188
188
  }
189
- const u = `${t}/${r}${c}`, p = a.encoding;
190
- this.string = u, this.type = t, this.subtype = r, this.parameters = a, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
189
+ const d = `${t}/${i}${c}`, p = a.encoding;
190
+ this.string = d, this.type = t, this.subtype = i, this.parameters = a, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
191
191
  }
192
192
  static parse(e) {
193
193
  return new l(e);
@@ -223,13 +223,13 @@ class l {
223
223
  const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
224
224
  if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
225
225
  return !1;
226
- const r = new Set(
227
- Object.entries(this.parameters).map(([s, o]) => `${s}=${o}`)
228
- ), n = new Set(
229
- Object.entries(t.parameters).map(([s, o]) => `${s}=${o}`)
226
+ const i = new Set(
227
+ Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
228
+ ), s = new Set(
229
+ Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
230
230
  );
231
- for (const s of Array.from(r.values()))
232
- if (!n.has(s))
231
+ for (const n of Array.from(i.values()))
232
+ if (!s.has(n))
233
233
  return !1;
234
234
  return !0;
235
235
  }
@@ -616,7 +616,7 @@ class l {
616
616
  });
617
617
  }
618
618
  }
619
- class Re {
619
+ class ye {
620
620
  constructor(e) {
621
621
  this.uri = e, this.parameters = this.getParameters(e);
622
622
  }
@@ -624,9 +624,9 @@ class Re {
624
624
  * List of URI template parameter keys, if the [Link] is templated.
625
625
  */
626
626
  getParameters(e) {
627
- const t = /\{\??([^}]+)\}/g, r = e.match(t);
628
- return r ? new Set(
629
- r.join(",").replace(t, "$1").split(",").map((n) => n.trim())
627
+ const t = /\{\??([^}]+)\}/g, i = e.match(t);
628
+ return i ? new Set(
629
+ i.join(",").replace(t, "$1").split(",").map((s) => s.trim())
630
630
  ) : /* @__PURE__ */ new Set();
631
631
  }
632
632
  /** Expands the URI by replacing the template variables by the given parameters.
@@ -634,36 +634,36 @@ class Re {
634
634
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
635
635
  */
636
636
  expand(e) {
637
- const t = (n) => n.split(",").map((s) => {
638
- const o = e[s];
637
+ const t = (s) => s.split(",").map((n) => {
638
+ const o = e[n];
639
639
  return o ? encodeURIComponent(o) : "";
640
- }).join(","), r = (n) => "?" + n.split(",").map((s) => {
641
- const o = s.split("=")[0], a = e[o];
640
+ }).join(","), i = (s) => "?" + s.split(",").map((n) => {
641
+ const o = n.split("=")[0], a = e[o];
642
642
  return a ? `${o}=${encodeURIComponent(a)}` : "";
643
643
  }).join("&");
644
- return this.uri.replace(/\{(\??)([^}]+)\}/g, (...n) => n[1] ? r(n[2]) : t(n[2]));
644
+ return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));
645
645
  }
646
646
  }
647
- function Dt(i) {
648
- return i && i instanceof Array ? i : void 0;
647
+ function lt(r) {
648
+ return r && r instanceof Array ? r : void 0;
649
649
  }
650
- function it(i) {
651
- return i && typeof i == "string" ? [i] : Dt(i);
650
+ function We(r) {
651
+ return r && typeof r == "string" ? [r] : lt(r);
652
652
  }
653
- function Le(i) {
654
- return typeof i == "string" ? new Date(i) : void 0;
653
+ function ve(r) {
654
+ return typeof r == "string" ? new Date(r) : void 0;
655
655
  }
656
- function se(i) {
657
- return isNaN(i) ? void 0 : i;
656
+ function j(r) {
657
+ return isNaN(r) ? void 0 : r;
658
658
  }
659
- function O(i) {
660
- return se(i) !== void 0 && Math.sign(i) >= 0 ? i : void 0;
659
+ function C(r) {
660
+ return j(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
661
661
  }
662
- function Bt(i) {
662
+ function ht(r) {
663
663
  const e = new Array();
664
- return i.forEach((t) => e.push(t)), e;
664
+ return r.forEach((t) => e.push(t)), e;
665
665
  }
666
- class w {
666
+ class x {
667
667
  /**
668
668
  * Creates a [Locations].
669
669
  */
@@ -676,7 +676,7 @@ class w {
676
676
  static deserialize(e) {
677
677
  if (!e)
678
678
  return;
679
- const t = se(e.progression), r = se(e.totalProgression), n = se(e.position), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
679
+ const t = j(e.progression), i = j(e.totalProgression), s = j(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
680
680
  "fragment",
681
681
  "fragments",
682
682
  "progression",
@@ -684,13 +684,13 @@ class w {
684
684
  "position"
685
685
  ]);
686
686
  return Object.entries(e).forEach(([a, h]) => {
687
- o.has(a) || s.set(a, h);
688
- }), new w({
689
- fragments: it(e.fragments || e.fragment),
687
+ o.has(a) || n.set(a, h);
688
+ }), new x({
689
+ fragments: We(e.fragments || e.fragment),
690
690
  progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
691
- totalProgression: r !== void 0 && r >= 0 && r <= 1 ? r : void 0,
692
- position: n !== void 0 && n > 0 ? n : void 0,
693
- otherLocations: s.size === 0 ? void 0 : s
691
+ totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
692
+ position: s !== void 0 && s > 0 ? s : void 0,
693
+ otherLocations: n.size === 0 ? void 0 : n
694
694
  });
695
695
  }
696
696
  /**
@@ -698,10 +698,10 @@ class w {
698
698
  */
699
699
  serialize() {
700
700
  const e = {};
701
- 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, r) => e[r] = t), e;
701
+ 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;
702
702
  }
703
703
  }
704
- class _ {
704
+ class U {
705
705
  /**
706
706
  * Creates a [Text].
707
707
  */
@@ -713,7 +713,7 @@ class _ {
713
713
  */
714
714
  static deserialize(e) {
715
715
  if (e)
716
- return new _({
716
+ return new U({
717
717
  after: e.after,
718
718
  before: e.before,
719
719
  highlight: e.highlight
@@ -727,24 +727,24 @@ class _ {
727
727
  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;
728
728
  }
729
729
  }
730
- class B {
730
+ class D {
731
731
  /**
732
732
  * Creates a [Locator].
733
733
  */
734
734
  constructor(e) {
735
- this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new w({}), this.text = e.text;
735
+ this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new x({}), this.text = e.text;
736
736
  }
737
737
  /**
738
738
  * Parses a [Link] from its RWPM JSON representation.
739
739
  */
740
740
  static deserialize(e) {
741
741
  if (e && e.href && e.type)
742
- return new B({
742
+ return new D({
743
743
  href: e.href,
744
744
  type: e.type,
745
745
  title: e.title,
746
- locations: w.deserialize(e.locations),
747
- text: _.deserialize(e.text)
746
+ locations: x.deserialize(e.locations),
747
+ text: U.deserialize(e.text)
748
748
  });
749
749
  }
750
750
  /**
@@ -758,16 +758,16 @@ class B {
758
758
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
759
759
  */
760
760
  copyWithLocations(e) {
761
- return new B({
761
+ return new D({
762
762
  href: this.href,
763
763
  type: this.type,
764
764
  title: this.title,
765
765
  text: this.text,
766
- locations: new w({ ...this.locations, ...e })
766
+ locations: new x({ ...this.locations, ...e })
767
767
  });
768
768
  }
769
769
  }
770
- class V {
770
+ class B {
771
771
  /**
772
772
  * Creates a [Link].
773
773
  */
@@ -779,20 +779,20 @@ class V {
779
779
  */
780
780
  static deserialize(e) {
781
781
  if (e && e.href && typeof e.href == "string")
782
- return new V({
782
+ return new B({
783
783
  href: e.href,
784
784
  templated: e.templated,
785
785
  type: e.type,
786
786
  title: e.title,
787
787
  rels: e.rel ? e.rel instanceof Array ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
788
- properties: b.deserialize(e.properties),
789
- height: O(e.height),
790
- width: O(e.width),
791
- duration: O(e.duration),
792
- bitrate: O(e.bitrate),
793
- languages: it(e.language),
794
- alternates: ae.deserialize(e.alternate),
795
- children: ae.deserialize(e.children)
788
+ properties: E.deserialize(e.properties),
789
+ height: C(e.height),
790
+ width: C(e.width),
791
+ duration: C(e.duration),
792
+ bitrate: C(e.bitrate),
793
+ languages: We(e.language),
794
+ alternates: q.deserialize(e.alternate),
795
+ children: q.deserialize(e.children)
796
796
  });
797
797
  }
798
798
  /**
@@ -800,7 +800,7 @@ class V {
800
800
  */
801
801
  serialize() {
802
802
  const e = { href: this.href };
803
- 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 = Bt(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.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;
803
+ 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.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;
804
804
  }
805
805
  /** MediaType of the linked resource. */
806
806
  get mediaType() {
@@ -813,19 +813,19 @@ class V {
813
813
  const t = this.href.replace(/^(\/)/, "");
814
814
  if (t.length === 0)
815
815
  return;
816
- let r = e || "/";
817
- return r.startsWith("/") && (r = "file://" + r), new URL(t, r).href.replace(/^(file:\/\/)/, "");
816
+ let i = e || "/";
817
+ return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
818
818
  }
819
819
  /** List of URI template parameter keys, if the `Link` is templated. */
820
820
  get templateParameters() {
821
- return this.templated ? new Re(this.href).parameters : /* @__PURE__ */ new Set();
821
+ return this.templated ? new ye(this.href).parameters : /* @__PURE__ */ new Set();
822
822
  }
823
823
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
824
824
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
825
825
  */
826
826
  expandTemplate(e) {
827
- return new V({
828
- href: new Re(this.href).expand(e),
827
+ return new B({
828
+ href: new ye(this.href).expand(e),
829
829
  templated: !1
830
830
  });
831
831
  }
@@ -834,25 +834,25 @@ class V {
834
834
  */
835
835
  addProperties(e) {
836
836
  var t;
837
- const r = V.deserialize(this.serialize());
838
- return r.properties = r.properties ? (t = r.properties) == null ? void 0 : t.add(e) : new b(e), r;
837
+ const i = B.deserialize(this.serialize());
838
+ return i.properties = i.properties ? (t = i.properties) == null ? void 0 : t.add(e) : new E(e), i;
839
839
  }
840
840
  /**
841
841
  * Creates a [Locator] from a reading order [Link].
842
842
  */
843
843
  get locator() {
844
844
  let e = this.href.split("#");
845
- return new B({
845
+ return new D({
846
846
  href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
847
847
  type: this.type ?? "",
848
848
  title: this.title,
849
- locations: new w({
849
+ locations: new x({
850
850
  fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
851
851
  })
852
852
  });
853
853
  }
854
854
  }
855
- class ae {
855
+ class q {
856
856
  /**
857
857
  * Creates a [Links].
858
858
  */
@@ -864,8 +864,8 @@ class ae {
864
864
  */
865
865
  static deserialize(e) {
866
866
  if (e && e instanceof Array)
867
- return new ae(
868
- e.map((t) => V.deserialize(t)).filter((t) => t !== void 0)
867
+ return new q(
868
+ e.map((t) => B.deserialize(t)).filter((t) => t !== void 0)
869
869
  );
870
870
  }
871
871
  /**
@@ -876,39 +876,39 @@ class ae {
876
876
  }
877
877
  /** Finds the first link with the given relation. */
878
878
  findWithRel(e) {
879
- const t = (r) => r.rels && r.rels.has(e);
879
+ const t = (i) => i.rels && i.rels.has(e);
880
880
  return this.items.find(t);
881
881
  }
882
882
  /** Finds all the links with the given relation. */
883
883
  filterByRel(e) {
884
- const t = (r) => r.rels && r.rels.has(e);
884
+ const t = (i) => i.rels && i.rels.has(e);
885
885
  return this.items.filter(t);
886
886
  }
887
887
  /** Finds the first link matching the given HREF. */
888
888
  findWithHref(e) {
889
- const t = (r) => r.href === e;
889
+ const t = (i) => i.href === e;
890
890
  return this.items.find(t);
891
891
  }
892
892
  /** Finds the index of the first link matching the given HREF. */
893
893
  findIndexWithHref(e) {
894
- const t = (r) => r.href === e;
894
+ const t = (i) => i.href === e;
895
895
  return this.items.findIndex(t);
896
896
  }
897
897
  /** Finds the first link matching the given media type. */
898
898
  findWithMediaType(e) {
899
- const t = (r) => r.mediaType.matches(e);
899
+ const t = (i) => i.mediaType.matches(e);
900
900
  return this.items.find(t);
901
901
  }
902
902
  /** Finds all the links matching the given media type. */
903
903
  filterByMediaType(e) {
904
- const t = (r) => r.mediaType.matches(e);
904
+ const t = (i) => i.mediaType.matches(e);
905
905
  return this.items.filter(t);
906
906
  }
907
907
  /** Finds all the links matching any of the given media types. */
908
908
  filterByMediaTypes(e) {
909
- const t = (r) => {
910
- for (const n of e)
911
- if (r.mediaType.matches(n))
909
+ const t = (i) => {
910
+ for (const s of e)
911
+ if (i.mediaType.matches(s))
912
912
  return !0;
913
913
  return !1;
914
914
  };
@@ -937,8 +937,8 @@ class ae {
937
937
  /** Returns whether all the resources in the collection are matching any of the given media types. */
938
938
  everyMatchesMediaType(e) {
939
939
  return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {
940
- for (const r of e)
941
- return t.mediaType.matches(r);
940
+ for (const i of e)
941
+ return t.mediaType.matches(i);
942
942
  return !1;
943
943
  }) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));
944
944
  }
@@ -946,7 +946,7 @@ class ae {
946
946
  return this.items.filter((e) => e.type);
947
947
  }
948
948
  }
949
- class le {
949
+ class V {
950
950
  /**
951
951
  * Creates a [DomRange].
952
952
  */
@@ -959,14 +959,14 @@ class le {
959
959
  static deserialize(e) {
960
960
  if (!(e && e.cssSelector))
961
961
  return;
962
- let t = O(e.textNodeIndex);
962
+ let t = C(e.textNodeIndex);
963
963
  if (t === void 0)
964
964
  return;
965
- let r = O(e.charOffset);
966
- return r === void 0 && (r = O(e.offset)), new le({
965
+ let i = C(e.charOffset);
966
+ return i === void 0 && (i = C(e.offset)), new V({
967
967
  cssSelector: e.cssSelector,
968
968
  textNodeIndex: t,
969
- charOffset: r
969
+ charOffset: i
970
970
  });
971
971
  }
972
972
  /**
@@ -980,7 +980,7 @@ class le {
980
980
  return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
981
981
  }
982
982
  }
983
- class Te {
983
+ class re {
984
984
  /**
985
985
  * Creates a [DomRange].
986
986
  */
@@ -993,11 +993,11 @@ class Te {
993
993
  static deserialize(e) {
994
994
  if (!e)
995
995
  return;
996
- let t = le.deserialize(e.start);
996
+ let t = V.deserialize(e.start);
997
997
  if (t)
998
- return new Te({
998
+ return new re({
999
999
  start: t,
1000
- end: le.deserialize(e.end)
1000
+ end: V.deserialize(e.end)
1001
1001
  });
1002
1002
  }
1003
1003
  /**
@@ -1008,55 +1008,55 @@ class Te {
1008
1008
  return this.end && (e.end = this.end.serialize()), e;
1009
1009
  }
1010
1010
  }
1011
- w.prototype.getCssSelector = function() {
1012
- var i;
1013
- return (i = this.otherLocations) == null ? void 0 : i.get("cssSelector");
1011
+ x.prototype.getCssSelector = function() {
1012
+ var r;
1013
+ return (r = this.otherLocations) == null ? void 0 : r.get("cssSelector");
1014
1014
  };
1015
- w.prototype.getPartialCfi = function() {
1016
- var i;
1017
- return (i = this.otherLocations) == null ? void 0 : i.get("partialCfi");
1015
+ x.prototype.getPartialCfi = function() {
1016
+ var r;
1017
+ return (r = this.otherLocations) == null ? void 0 : r.get("partialCfi");
1018
1018
  };
1019
- w.prototype.getDomRange = function() {
1020
- var i;
1021
- return Te.deserialize((i = this.otherLocations) == null ? void 0 : i.get("domRange"));
1019
+ x.prototype.getDomRange = function() {
1020
+ var r;
1021
+ return re.deserialize((r = this.otherLocations) == null ? void 0 : r.get("domRange"));
1022
1022
  };
1023
- w.prototype.fragmentParameters = function() {
1023
+ x.prototype.fragmentParameters = function() {
1024
1024
  return new Map(
1025
- this.fragments.map((i) => i.startsWith("#") ? i.slice(1) : i).join("&").split("&").filter((i) => !i.startsWith("#")).map((i) => i.split("=")).filter((i) => i.length === 2).map((i) => [
1026
- i[0].trim().toLowerCase(),
1027
- i[1].trim()
1025
+ this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
1026
+ r[0].trim().toLowerCase(),
1027
+ r[1].trim()
1028
1028
  ])
1029
1029
  );
1030
1030
  };
1031
- w.prototype.htmlId = function() {
1031
+ x.prototype.htmlId = function() {
1032
1032
  if (!this.fragments.length)
1033
1033
  return;
1034
- let i = this.fragments.find((e) => e.length && !e.includes("="));
1035
- if (!i) {
1034
+ let r = this.fragments.find((e) => e.length && !e.includes("="));
1035
+ if (!r) {
1036
1036
  const e = this.fragmentParameters();
1037
- e.has("id") ? i = e.get("id") : e.has("name") && (i = e.get("name"));
1037
+ e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));
1038
1038
  }
1039
- return i != null && i.startsWith("#") ? i.slice(1) : i;
1039
+ return r != null && r.startsWith("#") ? r.slice(1) : r;
1040
1040
  };
1041
- w.prototype.page = function() {
1042
- const i = parseInt(this.fragmentParameters().get("page"));
1043
- if (!isNaN(i) && i >= 0)
1044
- return i;
1041
+ x.prototype.page = function() {
1042
+ const r = parseInt(this.fragmentParameters().get("page"));
1043
+ if (!isNaN(r) && r >= 0)
1044
+ return r;
1045
1045
  };
1046
- w.prototype.time = function() {
1047
- const i = parseInt(this.fragmentParameters().get("t"));
1048
- if (!isNaN(i))
1049
- return i;
1046
+ x.prototype.time = function() {
1047
+ const r = parseInt(this.fragmentParameters().get("t"));
1048
+ if (!isNaN(r))
1049
+ return r;
1050
1050
  };
1051
- w.prototype.space = function() {
1052
- const i = this.fragmentParameters();
1053
- if (!i.has("xywh"))
1051
+ x.prototype.space = function() {
1052
+ const r = this.fragmentParameters();
1053
+ if (!r.has("xywh"))
1054
1054
  return;
1055
- const e = i.get("xywh").split(",").map((t) => parseInt(t));
1055
+ const e = r.get("xywh").split(",").map((t) => parseInt(t));
1056
1056
  if (e.length === 4 && !e.some(isNaN))
1057
1057
  return e;
1058
1058
  };
1059
- class Se {
1059
+ class se {
1060
1060
  /** Creates a [Price]. */
1061
1061
  constructor(e) {
1062
1062
  this.currency = e.currency, this.value = e.value;
@@ -1070,9 +1070,9 @@ class Se {
1070
1070
  let t = e.currency;
1071
1071
  if (!(t && typeof t == "string" && t.length > 0))
1072
1072
  return;
1073
- let r = O(e.value);
1074
- if (r !== void 0)
1075
- return new Se({ currency: t, value: r });
1073
+ let i = C(e.value);
1074
+ if (i !== void 0)
1075
+ return new se({ currency: t, value: i });
1076
1076
  }
1077
1077
  /**
1078
1078
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1081,7 +1081,7 @@ class Se {
1081
1081
  return { currency: this.currency, value: this.value };
1082
1082
  }
1083
1083
  }
1084
- class G {
1084
+ class H {
1085
1085
  /** Creates a [Acquisition]. */
1086
1086
  constructor(e) {
1087
1087
  this.type = e.type, this.children = e.children;
@@ -1091,14 +1091,14 @@ class G {
1091
1091
  */
1092
1092
  static deserialize(e) {
1093
1093
  if (e && e.type)
1094
- return new G({
1094
+ return new H({
1095
1095
  type: e.type,
1096
- children: G.deserializeArray(e.children)
1096
+ children: H.deserializeArray(e.children)
1097
1097
  });
1098
1098
  }
1099
1099
  static deserializeArray(e) {
1100
1100
  if (e instanceof Array)
1101
- return e.map((t) => G.deserialize(t)).filter((t) => t !== void 0);
1101
+ return e.map((t) => H.deserialize(t)).filter((t) => t !== void 0);
1102
1102
  }
1103
1103
  /**
1104
1104
  * Serializes a [Acquisition] to its RWPM JSON representation.
@@ -1108,7 +1108,7 @@ class G {
1108
1108
  return this.children && (e.children = this.children.map((t) => t.serialize())), e;
1109
1109
  }
1110
1110
  }
1111
- class Ce {
1111
+ class ne {
1112
1112
  /** Creates a [Price]. */
1113
1113
  constructor(e) {
1114
1114
  this.total = e.total, this.position = e.position;
@@ -1118,9 +1118,9 @@ class Ce {
1118
1118
  */
1119
1119
  static deserialize(e) {
1120
1120
  if (e)
1121
- return new Ce({
1122
- total: O(e.total),
1123
- position: O(e.position)
1121
+ return new ne({
1122
+ total: C(e.total),
1123
+ position: C(e.position)
1124
1124
  });
1125
1125
  }
1126
1126
  /**
@@ -1131,7 +1131,7 @@ class Ce {
1131
1131
  return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
1132
1132
  }
1133
1133
  }
1134
- class Oe {
1134
+ class oe {
1135
1135
  /** Creates a [Copies]. */
1136
1136
  constructor(e) {
1137
1137
  this.total = e.total, this.available = e.available;
@@ -1141,9 +1141,9 @@ class Oe {
1141
1141
  */
1142
1142
  static deserialize(e) {
1143
1143
  if (e)
1144
- return new Oe({
1145
- total: O(e.total),
1146
- available: O(e.available)
1144
+ return new oe({
1145
+ total: C(e.total),
1146
+ available: C(e.available)
1147
1147
  });
1148
1148
  }
1149
1149
  /**
@@ -1154,7 +1154,7 @@ class Oe {
1154
1154
  return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
1155
1155
  }
1156
1156
  }
1157
- class Pe {
1157
+ class ae {
1158
1158
  /** Creates a [Availability]. */
1159
1159
  constructor(e) {
1160
1160
  this.state = e.state, this.since = e.since, this.until = e.until;
@@ -1164,10 +1164,10 @@ class Pe {
1164
1164
  */
1165
1165
  static deserialize(e) {
1166
1166
  if (e && e.state)
1167
- return new Pe({
1167
+ return new ae({
1168
1168
  state: e.state,
1169
- since: Le(e.since),
1170
- until: Le(e.until)
1169
+ since: ve(e.since),
1170
+ until: ve(e.until)
1171
1171
  });
1172
1172
  }
1173
1173
  /**
@@ -1178,334 +1178,334 @@ class Pe {
1178
1178
  return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
1179
1179
  }
1180
1180
  }
1181
- b.prototype.getNumberOfItems = function() {
1182
- return O(this.otherProperties.numberOfItems);
1181
+ E.prototype.getNumberOfItems = function() {
1182
+ return C(this.otherProperties.numberOfItems);
1183
1183
  };
1184
- b.prototype.getPrice = function() {
1185
- return Se.deserialize(this.otherProperties.price);
1184
+ E.prototype.getPrice = function() {
1185
+ return se.deserialize(this.otherProperties.price);
1186
1186
  };
1187
- b.prototype.getIndirectAcquisitions = function() {
1188
- const i = this.otherProperties.indirectAcquisition;
1189
- if (i && i instanceof Array)
1190
- return i.map((e) => G.deserialize(e)).filter((e) => e !== void 0);
1187
+ E.prototype.getIndirectAcquisitions = function() {
1188
+ const r = this.otherProperties.indirectAcquisition;
1189
+ if (r && r instanceof Array)
1190
+ return r.map((e) => H.deserialize(e)).filter((e) => e !== void 0);
1191
1191
  };
1192
- b.prototype.getHolds = function() {
1193
- return Ce.deserialize(this.otherProperties.holds);
1192
+ E.prototype.getHolds = function() {
1193
+ return ne.deserialize(this.otherProperties.holds);
1194
1194
  };
1195
- b.prototype.getCopies = function() {
1196
- return Oe.deserialize(this.otherProperties.copies);
1195
+ E.prototype.getCopies = function() {
1196
+ return oe.deserialize(this.otherProperties.copies);
1197
1197
  };
1198
- b.prototype.getAvailability = function() {
1199
- return Pe.deserialize(this.otherProperties.availability);
1198
+ E.prototype.getAvailability = function() {
1199
+ return ae.deserialize(this.otherProperties.availability);
1200
1200
  };
1201
- b.prototype.getAuthenticate = function() {
1202
- return V.deserialize(this.otherProperties.authenticate);
1201
+ E.prototype.getAuthenticate = function() {
1202
+ return B.deserialize(this.otherProperties.authenticate);
1203
1203
  };
1204
- b.prototype.getClipped = function() {
1204
+ E.prototype.getClipped = function() {
1205
1205
  return this.otherProperties.clipped;
1206
1206
  };
1207
- b.prototype.getFit = function() {
1207
+ E.prototype.getFit = function() {
1208
1208
  return this.otherProperties.fit;
1209
1209
  };
1210
- b.prototype.getOrientation = function() {
1210
+ E.prototype.getOrientation = function() {
1211
1211
  return this.otherProperties.orientation;
1212
1212
  };
1213
- b.prototype.getOverflow = function() {
1213
+ E.prototype.getOverflow = function() {
1214
1214
  return this.otherProperties.overflow;
1215
1215
  };
1216
- b.prototype.getPage = function() {
1216
+ E.prototype.getPage = function() {
1217
1217
  return this.otherProperties.page || void 0;
1218
1218
  };
1219
- b.prototype.getSpread = function() {
1219
+ E.prototype.getSpread = function() {
1220
1220
  return this.otherProperties.spread || void 0;
1221
1221
  };
1222
- var z;
1223
- (function(i) {
1224
- i.NONE = "none", i.DESCENDANT = "descendant", i.CHILD = "child";
1225
- })(z || (z = {}));
1226
- var A;
1227
- (function(i) {
1228
- i.id = "id", i.class = "class", i.tag = "tag", i.attribute = "attribute", i.nthchild = "nthchild", i.nthoftype = "nthoftype";
1229
- })(A || (A = {}));
1230
- const Wt = "CssSelectorGenerator";
1231
- function Ie(i = "unknown problem", ...e) {
1232
- console.warn(`${Wt}: ${i}`, ...e);
1233
- }
1234
- A.id, A.class, A.tag, A.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1235
- function Ft(i) {
1236
- return i instanceof RegExp;
1237
- }
1238
- function kt(i) {
1239
- return i.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1240
- }
1241
- function Ut(i) {
1242
- const e = i.map((t) => {
1243
- if (Ft(t))
1244
- return (r) => t.test(r);
1222
+ var R;
1223
+ (function(r) {
1224
+ r.NONE = "none", r.DESCENDANT = "descendant", r.CHILD = "child";
1225
+ })(R || (R = {}));
1226
+ var P;
1227
+ (function(r) {
1228
+ r.id = "id", r.class = "class", r.tag = "tag", r.attribute = "attribute", r.nthchild = "nthchild", r.nthoftype = "nthoftype";
1229
+ })(P || (P = {}));
1230
+ const ct = "CssSelectorGenerator";
1231
+ function Ee(r = "unknown problem", ...e) {
1232
+ console.warn(`${ct}: ${r}`, ...e);
1233
+ }
1234
+ P.id, P.class, P.tag, P.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1235
+ function dt(r) {
1236
+ return r instanceof RegExp;
1237
+ }
1238
+ function ut(r) {
1239
+ return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1240
+ }
1241
+ function pt(r) {
1242
+ const e = r.map((t) => {
1243
+ if (dt(t))
1244
+ return (i) => t.test(i);
1245
1245
  if (typeof t == "function")
1246
- return (r) => {
1247
- const n = t(r);
1248
- return typeof n != "boolean" ? (Ie("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : n;
1246
+ return (i) => {
1247
+ const s = t(i);
1248
+ return typeof s != "boolean" ? (Ee("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
1249
1249
  };
1250
1250
  if (typeof t == "string") {
1251
- const r = new RegExp("^" + kt(t) + "$");
1252
- return (n) => r.test(n);
1251
+ const i = new RegExp("^" + ut(t) + "$");
1252
+ return (s) => i.test(s);
1253
1253
  }
1254
- return Ie("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
1254
+ return Ee("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
1255
1255
  });
1256
- return (t) => e.some((r) => r(t));
1256
+ return (t) => e.some((i) => i(t));
1257
1257
  }
1258
- const Ht = "", $t = " > ", Vt = " ";
1259
- z.NONE + "", z.NONE, z.DESCENDANT + "", z.DESCENDANT, z.CHILD + "", z.CHILD;
1260
- A.nthoftype, A.tag, A.id, A.class, A.attribute, A.nthchild;
1261
- Ut([
1258
+ const ft = "", mt = " > ", gt = " ";
1259
+ R.NONE + "", R.NONE, R.DESCENDANT + "", R.DESCENDANT, R.CHILD + "", R.CHILD;
1260
+ P.nthoftype, P.tag, P.id, P.class, P.attribute, P.nthchild;
1261
+ pt([
1262
1262
  "class",
1263
1263
  "id",
1264
1264
  // Angular attributes
1265
1265
  "ng-*"
1266
1266
  ]);
1267
- class de {
1267
+ class Y {
1268
1268
  }
1269
- function ze(i) {
1270
- return i.split("").reverse().join("");
1269
+ function be(r) {
1270
+ return r.split("").reverse().join("");
1271
1271
  }
1272
- function qt(i, e, t) {
1273
- const r = ze(e);
1274
- return t.map((n) => {
1275
- const s = Math.max(0, n.end - e.length - n.errors), o = ze(i.slice(s, n.end));
1272
+ function yt(r, e, t) {
1273
+ const i = be(e);
1274
+ return t.map((s) => {
1275
+ const n = Math.max(0, s.end - e.length - s.errors), o = be(r.slice(n, s.end));
1276
1276
  return {
1277
- start: rt(o, r, n.errors).reduce((h, c) => n.end - c.end < h ? n.end - c.end : h, n.end),
1278
- end: n.end,
1279
- errors: n.errors
1277
+ start: Fe(o, i, s.errors).reduce((h, c) => s.end - c.end < h ? s.end - c.end : h, s.end),
1278
+ end: s.end,
1279
+ errors: s.errors
1280
1280
  };
1281
1281
  });
1282
1282
  }
1283
- function pe(i) {
1284
- return (i | -i) >> 31 & 1;
1283
+ function Z(r) {
1284
+ return (r | -r) >> 31 & 1;
1285
1285
  }
1286
- function De(i, e, t, r) {
1287
- let n = i.P[t], s = i.M[t];
1288
- const o = r >>> 31, a = e[t] | o, h = a | s, c = (a & n) + n ^ n | a;
1289
- let u = s | ~(c | n), p = n & c;
1290
- const d = pe(u & i.lastRowMask[t]) - pe(p & i.lastRowMask[t]);
1291
- return u <<= 1, p <<= 1, p |= o, u |= pe(r) - o, n = p | ~(h | u), s = u & h, i.P[t] = n, i.M[t] = s, d;
1286
+ function xe(r, e, t, i) {
1287
+ let s = r.P[t], n = r.M[t];
1288
+ const o = i >>> 31, a = e[t] | o, h = a | n, c = (a & s) + s ^ s | a;
1289
+ let d = n | ~(c | s), p = s & c;
1290
+ const u = Z(d & r.lastRowMask[t]) - Z(p & r.lastRowMask[t]);
1291
+ return d <<= 1, p <<= 1, p |= o, d |= Z(i) - o, s = p | ~(h | d), n = d & h, r.P[t] = s, r.M[t] = n, u;
1292
1292
  }
1293
- function rt(i, e, t) {
1293
+ function Fe(r, e, t) {
1294
1294
  if (e.length === 0)
1295
1295
  return [];
1296
1296
  t = Math.min(t, e.length);
1297
- const r = [], n = 32, s = Math.ceil(e.length / n) - 1, o = {
1298
- P: new Uint32Array(s + 1),
1299
- M: new Uint32Array(s + 1),
1300
- lastRowMask: new Uint32Array(s + 1)
1297
+ const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {
1298
+ P: new Uint32Array(n + 1),
1299
+ M: new Uint32Array(n + 1),
1300
+ lastRowMask: new Uint32Array(n + 1)
1301
1301
  };
1302
- o.lastRowMask.fill(1 << 31), o.lastRowMask[s] = 1 << (e.length - 1) % n;
1303
- const a = new Uint32Array(s + 1), h = /* @__PURE__ */ new Map(), c = [];
1304
- for (let d = 0; d < 256; d++)
1302
+ o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
1303
+ const a = new Uint32Array(n + 1), h = /* @__PURE__ */ new Map(), c = [];
1304
+ for (let u = 0; u < 256; u++)
1305
1305
  c.push(a);
1306
- for (let d = 0; d < e.length; d += 1) {
1307
- const f = e.charCodeAt(d);
1306
+ for (let u = 0; u < e.length; u += 1) {
1307
+ const f = e.charCodeAt(u);
1308
1308
  if (h.has(f))
1309
1309
  continue;
1310
- const v = new Uint32Array(s + 1);
1311
- h.set(f, v), f < c.length && (c[f] = v);
1312
- for (let g = 0; g <= s; g += 1) {
1313
- v[g] = 0;
1314
- for (let y = 0; y < n; y += 1) {
1315
- const x = g * n + y;
1316
- if (x >= e.length)
1310
+ const g = new Uint32Array(n + 1);
1311
+ h.set(f, g), f < c.length && (c[f] = g);
1312
+ for (let m = 0; m <= n; m += 1) {
1313
+ g[m] = 0;
1314
+ for (let v = 0; v < s; v += 1) {
1315
+ const S = m * s + v;
1316
+ if (S >= e.length)
1317
1317
  continue;
1318
- e.charCodeAt(x) === f && (v[g] |= 1 << y);
1318
+ e.charCodeAt(S) === f && (g[m] |= 1 << v);
1319
1319
  }
1320
1320
  }
1321
1321
  }
1322
- let u = Math.max(0, Math.ceil(t / n) - 1);
1323
- const p = new Uint32Array(s + 1);
1324
- for (let d = 0; d <= u; d += 1)
1325
- p[d] = (d + 1) * n;
1326
- p[s] = e.length;
1327
- for (let d = 0; d <= u; d += 1)
1328
- o.P[d] = -1, o.M[d] = 0;
1329
- for (let d = 0; d < i.length; d += 1) {
1330
- const f = i.charCodeAt(d);
1331
- let v;
1332
- f < c.length ? v = c[f] : (v = h.get(f), typeof v > "u" && (v = a));
1333
- let g = 0;
1334
- for (let y = 0; y <= u; y += 1)
1335
- g = De(o, v, y, g), p[y] += g;
1336
- if (p[u] - g <= t && u < s && (v[u + 1] & 1 || g < 0)) {
1337
- u += 1, o.P[u] = -1, o.M[u] = 0;
1338
- let y;
1339
- if (u === s) {
1340
- const x = e.length % n;
1341
- y = x === 0 ? n : x;
1322
+ let d = Math.max(0, Math.ceil(t / s) - 1);
1323
+ const p = new Uint32Array(n + 1);
1324
+ for (let u = 0; u <= d; u += 1)
1325
+ p[u] = (u + 1) * s;
1326
+ p[n] = e.length;
1327
+ for (let u = 0; u <= d; u += 1)
1328
+ o.P[u] = -1, o.M[u] = 0;
1329
+ for (let u = 0; u < r.length; u += 1) {
1330
+ const f = r.charCodeAt(u);
1331
+ let g;
1332
+ f < c.length ? g = c[f] : (g = h.get(f), typeof g > "u" && (g = a));
1333
+ let m = 0;
1334
+ for (let v = 0; v <= d; v += 1)
1335
+ m = xe(o, g, v, m), p[v] += m;
1336
+ if (p[d] - m <= t && d < n && (g[d + 1] & 1 || m < 0)) {
1337
+ d += 1, o.P[d] = -1, o.M[d] = 0;
1338
+ let v;
1339
+ if (d === n) {
1340
+ const S = e.length % s;
1341
+ v = S === 0 ? s : S;
1342
1342
  } else
1343
- y = n;
1344
- p[u] = p[u - 1] + y - g + De(o, v, u, g);
1343
+ v = s;
1344
+ p[d] = p[d - 1] + v - m + xe(o, g, d, m);
1345
1345
  } else
1346
- for (; u > 0 && p[u] >= t + n; )
1347
- u -= 1;
1348
- u === s && p[u] <= t && (p[u] < t && r.splice(0, r.length), r.push({
1346
+ for (; d > 0 && p[d] >= t + s; )
1347
+ d -= 1;
1348
+ d === n && p[d] <= t && (p[d] < t && i.splice(0, i.length), i.push({
1349
1349
  start: -1,
1350
- end: d + 1,
1351
- errors: p[u]
1352
- }), t = p[u]);
1350
+ end: u + 1,
1351
+ errors: p[d]
1352
+ }), t = p[d]);
1353
1353
  }
1354
- return r;
1354
+ return i;
1355
1355
  }
1356
- function _t(i, e, t) {
1357
- const r = rt(i, e, t);
1358
- return qt(i, e, r);
1359
- }
1360
- function nt(i, e, t) {
1361
- let r = 0;
1362
- const n = [];
1363
- for (; r !== -1; )
1364
- r = i.indexOf(e, r), r !== -1 && (n.push({
1365
- start: r,
1366
- end: r + e.length,
1356
+ function vt(r, e, t) {
1357
+ const i = Fe(r, e, t);
1358
+ return yt(r, e, i);
1359
+ }
1360
+ function Be(r, e, t) {
1361
+ let i = 0;
1362
+ const s = [];
1363
+ for (; i !== -1; )
1364
+ i = r.indexOf(e, i), i !== -1 && (s.push({
1365
+ start: i,
1366
+ end: i + e.length,
1367
1367
  errors: 0
1368
- }), r += 1);
1369
- return n.length > 0 ? n : _t(i, e, t);
1368
+ }), i += 1);
1369
+ return s.length > 0 ? s : vt(r, e, t);
1370
1370
  }
1371
- function Be(i, e) {
1372
- return e.length === 0 || i.length === 0 ? 0 : 1 - nt(i, e, e.length)[0].errors / e.length;
1371
+ function Se(r, e) {
1372
+ return e.length === 0 || r.length === 0 ? 0 : 1 - Be(r, e, e.length)[0].errors / e.length;
1373
1373
  }
1374
- function jt(i, e, t = {}) {
1374
+ function Et(r, e, t = {}) {
1375
1375
  if (e.length === 0)
1376
1376
  return null;
1377
- const r = Math.min(256, e.length / 2), n = nt(i, e, r);
1378
- if (n.length === 0)
1377
+ const i = Math.min(256, e.length / 2), s = Be(r, e, i);
1378
+ if (s.length === 0)
1379
1379
  return null;
1380
- const s = (a) => {
1381
- const d = 1 - a.errors / e.length, f = t.prefix ? Be(
1382
- i.slice(
1380
+ const n = (a) => {
1381
+ const u = 1 - a.errors / e.length, f = t.prefix ? Se(
1382
+ r.slice(
1383
1383
  Math.max(0, a.start - t.prefix.length),
1384
1384
  a.start
1385
1385
  ),
1386
1386
  t.prefix
1387
- ) : 1, v = t.suffix ? Be(
1388
- i.slice(a.end, a.end + t.suffix.length),
1387
+ ) : 1, g = t.suffix ? Se(
1388
+ r.slice(a.end, a.end + t.suffix.length),
1389
1389
  t.suffix
1390
1390
  ) : 1;
1391
- let g = 1;
1392
- typeof t.hint == "number" && (g = 1 - Math.abs(a.start - t.hint) / i.length);
1393
- const y = 50 * d + 20 * f + 20 * v + 2 * g, x = 50 + 20 + 20 + 2;
1394
- return y / x;
1395
- }, o = n.map((a) => ({
1391
+ let m = 1;
1392
+ typeof t.hint == "number" && (m = 1 - Math.abs(a.start - t.hint) / r.length);
1393
+ const v = 50 * u + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
1394
+ return v / S;
1395
+ }, o = s.map((a) => ({
1396
1396
  start: a.start,
1397
1397
  end: a.end,
1398
- score: s(a)
1398
+ score: n(a)
1399
1399
  }));
1400
1400
  return o.sort((a, h) => h.score - a.score), o[0];
1401
1401
  }
1402
- function ge(i, e, t) {
1403
- const r = t === 1 ? e : e - 1;
1404
- if (i.charAt(r).trim() !== "")
1402
+ function J(r, e, t) {
1403
+ const i = t === 1 ? e : e - 1;
1404
+ if (r.charAt(i).trim() !== "")
1405
1405
  return e;
1406
- let n, s;
1407
- if (t === 2 ? (n = i.substring(0, e), s = n.trimEnd()) : (n = i.substring(e), s = n.trimStart()), !s.length)
1406
+ let s, n;
1407
+ if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)
1408
1408
  return -1;
1409
- const o = n.length - s.length;
1409
+ const o = s.length - n.length;
1410
1410
  return t === 2 ? e - o : e + o;
1411
1411
  }
1412
- function We(i, e) {
1413
- const t = i.commonAncestorContainer.ownerDocument.createNodeIterator(
1414
- i.commonAncestorContainer,
1412
+ function Te(r, e) {
1413
+ const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1414
+ r.commonAncestorContainer,
1415
1415
  NodeFilter.SHOW_TEXT
1416
- ), r = e === 1 ? i.startContainer : i.endContainer, n = e === 1 ? i.endContainer : i.startContainer;
1417
- let s = t.nextNode();
1418
- for (; s && s !== r; )
1419
- s = t.nextNode();
1420
- e === 2 && (s = t.previousNode());
1416
+ ), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;
1417
+ let n = t.nextNode();
1418
+ for (; n && n !== i; )
1419
+ n = t.nextNode();
1420
+ e === 2 && (n = t.previousNode());
1421
1421
  let o = -1;
1422
1422
  const a = () => {
1423
- if (s = e === 1 ? t.nextNode() : t.previousNode(), s) {
1424
- const h = s.textContent, c = e === 1 ? 0 : h.length;
1425
- o = ge(h, c, e);
1423
+ if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
1424
+ const h = n.textContent, c = e === 1 ? 0 : h.length;
1425
+ o = J(h, c, e);
1426
1426
  }
1427
1427
  };
1428
- for (; s && o === -1 && s !== n; )
1428
+ for (; n && o === -1 && n !== s; )
1429
1429
  a();
1430
- if (s && o >= 0)
1431
- return { node: s, offset: o };
1430
+ if (n && o >= 0)
1431
+ return { node: n, offset: o };
1432
1432
  throw new RangeError("No text nodes with non-whitespace text found in range");
1433
1433
  }
1434
- function Xt(i) {
1435
- if (!i.toString().trim().length)
1434
+ function bt(r) {
1435
+ if (!r.toString().trim().length)
1436
1436
  throw new RangeError("Range contains no non-whitespace text");
1437
- if (i.startContainer.nodeType !== Node.TEXT_NODE)
1437
+ if (r.startContainer.nodeType !== Node.TEXT_NODE)
1438
1438
  throw new RangeError("Range startContainer is not a text node");
1439
- if (i.endContainer.nodeType !== Node.TEXT_NODE)
1439
+ if (r.endContainer.nodeType !== Node.TEXT_NODE)
1440
1440
  throw new RangeError("Range endContainer is not a text node");
1441
- const e = i.cloneRange();
1442
- let t = !1, r = !1;
1443
- const n = {
1444
- start: ge(
1445
- i.startContainer.textContent,
1446
- i.startOffset,
1441
+ const e = r.cloneRange();
1442
+ let t = !1, i = !1;
1443
+ const s = {
1444
+ start: J(
1445
+ r.startContainer.textContent,
1446
+ r.startOffset,
1447
1447
  1
1448
1448
  /* Forwards */
1449
1449
  ),
1450
- end: ge(
1451
- i.endContainer.textContent,
1452
- i.endOffset,
1450
+ end: J(
1451
+ r.endContainer.textContent,
1452
+ r.endOffset,
1453
1453
  2
1454
1454
  /* Backwards */
1455
1455
  )
1456
1456
  };
1457
- if (n.start >= 0 && (e.setStart(i.startContainer, n.start), t = !0), n.end > 0 && (e.setEnd(i.endContainer, n.end), r = !0), t && r)
1457
+ if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)
1458
1458
  return e;
1459
1459
  if (!t) {
1460
- const { node: s, offset: o } = We(
1460
+ const { node: n, offset: o } = Te(
1461
1461
  e,
1462
1462
  1
1463
1463
  /* Forwards */
1464
1464
  );
1465
- s && o >= 0 && e.setStart(s, o);
1465
+ n && o >= 0 && e.setStart(n, o);
1466
1466
  }
1467
- if (!r) {
1468
- const { node: s, offset: o } = We(
1467
+ if (!i) {
1468
+ const { node: n, offset: o } = Te(
1469
1469
  e,
1470
1470
  2
1471
1471
  /* Backwards */
1472
1472
  );
1473
- s && o > 0 && e.setEnd(s, o);
1473
+ n && o > 0 && e.setEnd(n, o);
1474
1474
  }
1475
1475
  return e;
1476
1476
  }
1477
- function st(i) {
1477
+ function Ue(r) {
1478
1478
  var e;
1479
- switch (i.nodeType) {
1479
+ switch (r.nodeType) {
1480
1480
  case Node.ELEMENT_NODE:
1481
1481
  case Node.TEXT_NODE:
1482
- return ((e = i.textContent) == null ? void 0 : e.length) ?? 0;
1482
+ return ((e = r.textContent) == null ? void 0 : e.length) ?? 0;
1483
1483
  default:
1484
1484
  return 0;
1485
1485
  }
1486
1486
  }
1487
- function Fe(i) {
1488
- let e = i.previousSibling, t = 0;
1487
+ function we(r) {
1488
+ let e = r.previousSibling, t = 0;
1489
1489
  for (; e; )
1490
- t += st(e), e = e.previousSibling;
1490
+ t += Ue(e), e = e.previousSibling;
1491
1491
  return t;
1492
1492
  }
1493
- function ot(i, ...e) {
1493
+ function ke(r, ...e) {
1494
1494
  let t = e.shift();
1495
- const r = i.ownerDocument.createNodeIterator(
1496
- i,
1495
+ const i = r.ownerDocument.createNodeIterator(
1496
+ r,
1497
1497
  NodeFilter.SHOW_TEXT
1498
- ), n = [];
1499
- let s = r.nextNode(), o, a = 0;
1500
- for (; t !== void 0 && s; )
1501
- o = s, a + o.data.length > t ? (n.push({ node: o, offset: t - a }), t = e.shift()) : (s = r.nextNode(), a += o.data.length);
1498
+ ), s = [];
1499
+ let n = i.nextNode(), o, a = 0;
1500
+ for (; t !== void 0 && n; )
1501
+ o = n, a + o.data.length > t ? (s.push({ node: o, offset: t - a }), t = e.shift()) : (n = i.nextNode(), a += o.data.length);
1502
1502
  for (; t !== void 0 && o && a === t; )
1503
- n.push({ node: o, offset: o.data.length }), t = e.shift();
1503
+ s.push({ node: o, offset: o.data.length }), t = e.shift();
1504
1504
  if (t !== void 0)
1505
1505
  throw new RangeError("Offset exceeds text length");
1506
- return n;
1506
+ return s;
1507
1507
  }
1508
- class L {
1508
+ class M {
1509
1509
  constructor(e, t) {
1510
1510
  if (t < 0)
1511
1511
  throw new Error("Offset is invalid");
@@ -1520,10 +1520,10 @@ class L {
1520
1520
  relativeTo(e) {
1521
1521
  if (!e.contains(this.element))
1522
1522
  throw new Error("Parent is not an ancestor of current element");
1523
- let t = this.element, r = this.offset;
1523
+ let t = this.element, i = this.offset;
1524
1524
  for (; t !== e; )
1525
- r += Fe(t), t = t.parentElement;
1526
- return new L(t, r);
1525
+ i += we(t), t = t.parentElement;
1526
+ return new M(t, i);
1527
1527
  }
1528
1528
  /**
1529
1529
  * Resolve the position to a specific text node and offset within that node.
@@ -1544,18 +1544,18 @@ class L {
1544
1544
  */
1545
1545
  resolve(e = {}) {
1546
1546
  try {
1547
- return ot(this.element, this.offset)[0];
1547
+ return ke(this.element, this.offset)[0];
1548
1548
  } catch (t) {
1549
1549
  if (this.offset === 0 && e.direction !== void 0) {
1550
- const r = document.createTreeWalker(
1550
+ const i = document.createTreeWalker(
1551
1551
  this.element.getRootNode(),
1552
1552
  NodeFilter.SHOW_TEXT
1553
1553
  );
1554
- r.currentNode = this.element;
1555
- const n = e.direction === 1, s = n ? r.nextNode() : r.previousNode();
1556
- if (!s)
1554
+ i.currentNode = this.element;
1555
+ const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();
1556
+ if (!n)
1557
1557
  throw t;
1558
- return { node: s, offset: n ? 0 : s.data.length };
1558
+ return { node: n, offset: s ? 0 : n.data.length };
1559
1559
  } else
1560
1560
  throw t;
1561
1561
  }
@@ -1567,9 +1567,9 @@ class L {
1567
1567
  static fromCharOffset(e, t) {
1568
1568
  switch (e.nodeType) {
1569
1569
  case Node.TEXT_NODE:
1570
- return L.fromPoint(e, t);
1570
+ return M.fromPoint(e, t);
1571
1571
  case Node.ELEMENT_NODE:
1572
- return new L(e, t);
1572
+ return new M(e, t);
1573
1573
  default:
1574
1574
  throw new Error("Node is not an element or text node");
1575
1575
  }
@@ -1587,23 +1587,23 @@ class L {
1587
1587
  throw new Error("Text node offset is out of range");
1588
1588
  if (!e.parentElement)
1589
1589
  throw new Error("Text node has no parent");
1590
- const r = Fe(e) + t;
1591
- return new L(e.parentElement, r);
1590
+ const i = we(e) + t;
1591
+ return new M(e.parentElement, i);
1592
1592
  }
1593
1593
  case Node.ELEMENT_NODE: {
1594
1594
  if (t < 0 || t > e.childNodes.length)
1595
1595
  throw new Error("Child node offset is out of range");
1596
- let r = 0;
1597
- for (let n = 0; n < t; n++)
1598
- r += st(e.childNodes[n]);
1599
- return new L(e, r);
1596
+ let i = 0;
1597
+ for (let s = 0; s < t; s++)
1598
+ i += Ue(e.childNodes[s]);
1599
+ return new M(e, i);
1600
1600
  }
1601
1601
  default:
1602
1602
  throw new Error("Point is not in an element or text node");
1603
1603
  }
1604
1604
  }
1605
1605
  }
1606
- class D {
1606
+ class z {
1607
1607
  constructor(e, t) {
1608
1608
  this.start = e, this.end = t;
1609
1609
  }
@@ -1613,7 +1613,7 @@ class D {
1613
1613
  * `end.element`.
1614
1614
  */
1615
1615
  relativeTo(e) {
1616
- return new D(
1616
+ return new z(
1617
1617
  this.start.relativeTo(e),
1618
1618
  this.end.relativeTo(e)
1619
1619
  );
@@ -1629,7 +1629,7 @@ class D {
1629
1629
  */
1630
1630
  toRange() {
1631
1631
  let e, t;
1632
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ot(
1632
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ke(
1633
1633
  this.start.element,
1634
1634
  this.start.offset,
1635
1635
  this.end.offset
@@ -1640,27 +1640,27 @@ class D {
1640
1640
  direction: 2
1641
1641
  /* BACKWARDS */
1642
1642
  }));
1643
- const r = new Range();
1644
- return r.setStart(e.node, e.offset), r.setEnd(t.node, t.offset), r;
1643
+ const i = new Range();
1644
+ return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
1645
1645
  }
1646
1646
  /**
1647
1647
  * Create a TextRange from a (DOM) Range
1648
1648
  */
1649
1649
  static fromRange(e) {
1650
- const t = L.fromPoint(
1650
+ const t = M.fromPoint(
1651
1651
  e.startContainer,
1652
1652
  e.startOffset
1653
- ), r = L.fromPoint(e.endContainer, e.endOffset);
1654
- return new D(t, r);
1653
+ ), i = M.fromPoint(e.endContainer, e.endOffset);
1654
+ return new z(t, i);
1655
1655
  }
1656
1656
  /**
1657
1657
  * Create a TextRange representing the `start`th to `end`th characters in
1658
1658
  * `root`
1659
1659
  */
1660
- static fromOffsets(e, t, r) {
1661
- return new D(
1662
- new L(e, t),
1663
- new L(e, r)
1660
+ static fromOffsets(e, t, i) {
1661
+ return new z(
1662
+ new M(e, t),
1663
+ new M(e, i)
1664
1664
  );
1665
1665
  }
1666
1666
  /**
@@ -1668,23 +1668,23 @@ class D {
1668
1668
  * whitespace
1669
1669
  */
1670
1670
  static trimmedRange(e) {
1671
- return Xt(D.fromRange(e).toRange());
1671
+ return bt(z.fromRange(e).toRange());
1672
1672
  }
1673
1673
  }
1674
- class he {
1675
- constructor(e, t, r) {
1676
- this.root = e, this.start = t, this.end = r;
1674
+ class _ {
1675
+ constructor(e, t, i) {
1676
+ this.root = e, this.start = t, this.end = i;
1677
1677
  }
1678
1678
  static fromRange(e, t) {
1679
- const r = D.fromRange(t).relativeTo(e);
1680
- return new he(
1679
+ const i = z.fromRange(t).relativeTo(e);
1680
+ return new _(
1681
1681
  e,
1682
- r.start.offset,
1683
- r.end.offset
1682
+ i.start.offset,
1683
+ i.end.offset
1684
1684
  );
1685
1685
  }
1686
1686
  static fromSelector(e, t) {
1687
- return new he(e, t.start, t.end);
1687
+ return new _(e, t.start, t.end);
1688
1688
  }
1689
1689
  toSelector() {
1690
1690
  return {
@@ -1694,15 +1694,15 @@ class he {
1694
1694
  };
1695
1695
  }
1696
1696
  toRange() {
1697
- return D.fromOffsets(this.root, this.start, this.end).toRange();
1697
+ return z.fromOffsets(this.root, this.start, this.end).toRange();
1698
1698
  }
1699
1699
  }
1700
- class ce {
1700
+ class X {
1701
1701
  /**
1702
1702
  * @param root - A root element from which to anchor.
1703
1703
  */
1704
- constructor(e, t, r = {}) {
1705
- this.root = e, this.exact = t, this.context = r;
1704
+ constructor(e, t, i = {}) {
1705
+ this.root = e, this.exact = t, this.context = i;
1706
1706
  }
1707
1707
  /**
1708
1708
  * Create a `TextQuoteAnchor` from a range.
@@ -1710,15 +1710,15 @@ class ce {
1710
1710
  * Will throw if `range` does not contain any text nodes.
1711
1711
  */
1712
1712
  static fromRange(e, t) {
1713
- const r = e.textContent, n = D.fromRange(t).relativeTo(e), s = n.start.offset, o = n.end.offset, a = 32;
1714
- return new ce(e, r.slice(s, o), {
1715
- prefix: r.slice(Math.max(0, s - a), s),
1716
- suffix: r.slice(o, Math.min(r.length, o + a))
1713
+ const i = e.textContent, s = z.fromRange(t).relativeTo(e), n = s.start.offset, o = s.end.offset, a = 32;
1714
+ return new X(e, i.slice(n, o), {
1715
+ prefix: i.slice(Math.max(0, n - a), n),
1716
+ suffix: i.slice(o, Math.min(i.length, o + a))
1717
1717
  });
1718
1718
  }
1719
1719
  static fromSelector(e, t) {
1720
- const { prefix: r, suffix: n } = t;
1721
- return new ce(e, t.exact, { prefix: r, suffix: n });
1720
+ const { prefix: i, suffix: s } = t;
1721
+ return new X(e, t.exact, { prefix: i, suffix: s });
1722
1722
  }
1723
1723
  toSelector() {
1724
1724
  return {
@@ -1732,45 +1732,45 @@ class ce {
1732
1732
  return this.toPositionAnchor(e).toRange();
1733
1733
  }
1734
1734
  toPositionAnchor(e = {}) {
1735
- const t = this.root.textContent, r = jt(t, this.exact, {
1735
+ const t = this.root.textContent, i = Et(t, this.exact, {
1736
1736
  ...this.context,
1737
1737
  hint: e.hint
1738
1738
  });
1739
- if (!r)
1739
+ if (!i)
1740
1740
  throw new Error("Quote not found");
1741
- return new he(this.root, r.start, r.end);
1741
+ return new _(this.root, i.start, i.end);
1742
1742
  }
1743
1743
  }
1744
- function Gt(i) {
1745
- const e = i.tagName.toUpperCase();
1744
+ function xt(r) {
1745
+ const e = r.tagName.toUpperCase();
1746
1746
  return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
1747
1747
  }
1748
- function Ae(i, e) {
1748
+ function le(r, e) {
1749
1749
  try {
1750
- const t = e.locations, r = e.text;
1751
- if (r && r.highlight) {
1752
- let n;
1753
- t && t.getCssSelector() && (n = i.querySelector(t.getCssSelector())), n || (n = i.body);
1754
- const s = new ce(n, r.highlight, {
1755
- prefix: r.before,
1756
- suffix: r.after
1750
+ const t = e.locations, i = e.text;
1751
+ if (i && i.highlight) {
1752
+ let s;
1753
+ t && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), s || (s = r.body);
1754
+ const n = new X(s, i.highlight, {
1755
+ prefix: i.before,
1756
+ suffix: i.after
1757
1757
  });
1758
1758
  try {
1759
- return s.toRange();
1759
+ return n.toRange();
1760
1760
  } catch {
1761
- return console.warn("Quote not found:", s), null;
1761
+ return console.warn("Quote not found:", n), null;
1762
1762
  }
1763
1763
  }
1764
1764
  if (t) {
1765
- let n = null;
1766
- if (!n && t.getCssSelector() && (n = i.querySelector(t.getCssSelector())), !n && t.fragments) {
1767
- for (const s of t.fragments)
1768
- if (n = i.getElementById(s), n)
1765
+ let s = null;
1766
+ if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {
1767
+ for (const n of t.fragments)
1768
+ if (s = r.getElementById(n), s)
1769
1769
  break;
1770
1770
  }
1771
- if (n) {
1772
- const s = i.createRange();
1773
- return n.childNodes.length === 0 || Gt(n) ? (s.selectNode(n), s) : (s.setStartBefore(n), s.setEndAfter(n), s);
1771
+ if (s) {
1772
+ const n = r.createRange();
1773
+ return s.childNodes.length === 0 || xt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1774
1774
  }
1775
1775
  }
1776
1776
  } catch (t) {
@@ -1778,12 +1778,12 @@ function Ae(i, e) {
1778
1778
  }
1779
1779
  return null;
1780
1780
  }
1781
- function Yt(i, e) {
1782
- let t = i.getClientRects();
1783
- t.length || i.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = i.commonAncestorContainer.getClientRects());
1784
- const r = 1, n = [];
1781
+ function St(r, e) {
1782
+ let t = r.getClientRects();
1783
+ t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
1784
+ const i = 1, s = [];
1785
1785
  for (const c of t)
1786
- n.push({
1786
+ s.push({
1787
1787
  bottom: c.bottom,
1788
1788
  height: c.height,
1789
1789
  left: c.left,
@@ -1791,14 +1791,14 @@ function Yt(i, e) {
1791
1791
  top: c.top,
1792
1792
  width: c.width
1793
1793
  });
1794
- const s = at(
1795
- n,
1796
- r,
1794
+ const n = He(
1795
+ s,
1796
+ i,
1797
1797
  e
1798
- ), o = Kt(s, r), a = lt(o), h = 2 * 2;
1798
+ ), o = wt(n, i), a = $e(o), h = 2 * 2;
1799
1799
  for (let c = a.length - 1; c >= 0; c--) {
1800
- const u = a[c];
1801
- if (!(u.width * u.height > h))
1800
+ const d = a[c];
1801
+ if (!(d.width * d.height > h))
1802
1802
  if (a.length > 1)
1803
1803
  a.splice(c, 1);
1804
1804
  else
@@ -1806,446 +1806,208 @@ function Yt(i, e) {
1806
1806
  }
1807
1807
  return a;
1808
1808
  }
1809
- function at(i, e, t) {
1810
- for (let r = 0; r < i.length; r++)
1811
- for (let n = r + 1; n < i.length; n++) {
1812
- const s = i[r], o = i[n];
1813
- if (s === o)
1809
+ function He(r, e, t) {
1810
+ for (let i = 0; i < r.length; i++)
1811
+ for (let s = i + 1; s < r.length; s++) {
1812
+ const n = r[i], o = r[s];
1813
+ if (n === o)
1814
1814
  continue;
1815
- const a = N(s.top, o.top, e) && N(s.bottom, o.bottom, e), h = N(s.left, o.left, e) && N(s.right, o.right, e);
1816
- if ((h && !t || a && !h) && ht(s, o, e)) {
1817
- const d = i.filter((v) => v !== s && v !== o), f = Jt(s, o);
1818
- return d.push(f), at(
1819
- d,
1815
+ const a = N(n.top, o.top, e) && N(n.bottom, o.bottom, e), h = N(n.left, o.left, e) && N(n.right, o.right, e);
1816
+ if ((h && !t || a && !h) && je(n, o, e)) {
1817
+ const u = r.filter((g) => g !== n && g !== o), f = Tt(n, o);
1818
+ return u.push(f), He(
1819
+ u,
1820
1820
  e,
1821
1821
  t
1822
1822
  );
1823
1823
  }
1824
1824
  }
1825
- return i;
1825
+ return r;
1826
1826
  }
1827
- function Jt(i, e) {
1828
- const t = Math.min(i.left, e.left), r = Math.max(i.right, e.right), n = Math.min(i.top, e.top), s = Math.max(i.bottom, e.bottom);
1827
+ function Tt(r, e) {
1828
+ const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);
1829
1829
  return {
1830
- bottom: s,
1831
- height: s - n,
1830
+ bottom: n,
1831
+ height: n - s,
1832
1832
  left: t,
1833
- right: r,
1834
- top: n,
1835
- width: r - t
1833
+ right: i,
1834
+ top: s,
1835
+ width: i - t
1836
1836
  };
1837
1837
  }
1838
- function Kt(i, e) {
1839
- const t = new Set(i);
1840
- for (const r of i) {
1841
- if (!(r.width > 1 && r.height > 1)) {
1842
- t.delete(r);
1838
+ function wt(r, e) {
1839
+ const t = new Set(r);
1840
+ for (const i of r) {
1841
+ if (!(i.width > 1 && i.height > 1)) {
1842
+ t.delete(i);
1843
1843
  continue;
1844
1844
  }
1845
- for (const s of i)
1846
- if (r !== s && t.has(s) && Zt(s, r, e)) {
1847
- t.delete(r);
1845
+ for (const n of r)
1846
+ if (i !== n && t.has(n) && Ct(n, i, e)) {
1847
+ t.delete(i);
1848
1848
  break;
1849
1849
  }
1850
1850
  }
1851
1851
  return Array.from(t);
1852
1852
  }
1853
- function Zt(i, e, t) {
1854
- return te(i, e.left, e.top, t) && te(i, e.right, e.top, t) && te(i, e.left, e.bottom, t) && te(i, e.right, e.bottom, t);
1853
+ function Ct(r, e, t) {
1854
+ return $(r, e.left, e.top, t) && $(r, e.right, e.top, t) && $(r, e.left, e.bottom, t) && $(r, e.right, e.bottom, t);
1855
1855
  }
1856
- function te(i, e, t, r) {
1857
- return (i.left < e || N(i.left, e, r)) && (i.right > e || N(i.right, e, r)) && (i.top < t || N(i.top, t, r)) && (i.bottom > t || N(i.bottom, t, r));
1856
+ function $(r, e, t, i) {
1857
+ return (r.left < e || N(r.left, e, i)) && (r.right > e || N(r.right, e, i)) && (r.top < t || N(r.top, t, i)) && (r.bottom > t || N(r.bottom, t, i));
1858
1858
  }
1859
- function lt(i) {
1860
- for (let e = 0; e < i.length; e++)
1861
- for (let t = e + 1; t < i.length; t++) {
1862
- const r = i[e], n = i[t];
1863
- if (r !== n && ht(r, n, -1)) {
1864
- let s = [], o;
1865
- const a = ke(r, n);
1859
+ function $e(r) {
1860
+ for (let e = 0; e < r.length; e++)
1861
+ for (let t = e + 1; t < r.length; t++) {
1862
+ const i = r[e], s = r[t];
1863
+ if (i !== s && je(i, s, -1)) {
1864
+ let n = [], o;
1865
+ const a = Ce(i, s);
1866
1866
  if (a.length === 1)
1867
- s = a, o = r;
1867
+ n = a, o = i;
1868
1868
  else {
1869
- const c = ke(n, r);
1870
- a.length < c.length ? (s = a, o = r) : (s = c, o = n);
1869
+ const c = Ce(s, i);
1870
+ a.length < c.length ? (n = a, o = i) : (n = c, o = s);
1871
1871
  }
1872
- const h = i.filter((c) => c !== o);
1873
- return Array.prototype.push.apply(h, s), lt(h);
1872
+ const h = r.filter((c) => c !== o);
1873
+ return Array.prototype.push.apply(h, n), $e(h);
1874
1874
  }
1875
1875
  }
1876
- return i;
1876
+ return r;
1877
1877
  }
1878
- function ke(i, e) {
1879
- const t = Qt(e, i);
1878
+ function Ce(r, e) {
1879
+ const t = Pt(e, r);
1880
1880
  if (t.height === 0 || t.width === 0)
1881
- return [i];
1882
- const r = [];
1881
+ return [r];
1882
+ const i = [];
1883
1883
  {
1884
- const n = {
1885
- bottom: i.bottom,
1884
+ const s = {
1885
+ bottom: r.bottom,
1886
1886
  height: 0,
1887
- left: i.left,
1887
+ left: r.left,
1888
1888
  right: t.left,
1889
- top: i.top,
1889
+ top: r.top,
1890
1890
  width: 0
1891
1891
  };
1892
- n.width = n.right - n.left, n.height = n.bottom - n.top, n.height !== 0 && n.width !== 0 && r.push(n);
1892
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1893
1893
  }
1894
1894
  {
1895
- const n = {
1895
+ const s = {
1896
1896
  bottom: t.top,
1897
1897
  height: 0,
1898
1898
  left: t.left,
1899
1899
  right: t.right,
1900
- top: i.top,
1900
+ top: r.top,
1901
1901
  width: 0
1902
1902
  };
1903
- n.width = n.right - n.left, n.height = n.bottom - n.top, n.height !== 0 && n.width !== 0 && r.push(n);
1903
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1904
1904
  }
1905
1905
  {
1906
- const n = {
1907
- bottom: i.bottom,
1906
+ const s = {
1907
+ bottom: r.bottom,
1908
1908
  height: 0,
1909
1909
  left: t.left,
1910
1910
  right: t.right,
1911
1911
  top: t.bottom,
1912
1912
  width: 0
1913
1913
  };
1914
- n.width = n.right - n.left, n.height = n.bottom - n.top, n.height !== 0 && n.width !== 0 && r.push(n);
1914
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1915
1915
  }
1916
1916
  {
1917
- const n = {
1918
- bottom: i.bottom,
1917
+ const s = {
1918
+ bottom: r.bottom,
1919
1919
  height: 0,
1920
1920
  left: t.right,
1921
- right: i.right,
1922
- top: i.top,
1921
+ right: r.right,
1922
+ top: r.top,
1923
1923
  width: 0
1924
1924
  };
1925
- n.width = n.right - n.left, n.height = n.bottom - n.top, n.height !== 0 && n.width !== 0 && r.push(n);
1925
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1926
1926
  }
1927
- return r;
1927
+ return i;
1928
1928
  }
1929
- function Qt(i, e) {
1930
- const t = Math.max(i.left, e.left), r = Math.min(i.right, e.right), n = Math.max(i.top, e.top), s = Math.min(i.bottom, e.bottom);
1929
+ function Pt(r, e) {
1930
+ const t = Math.max(r.left, e.left), i = Math.min(r.right, e.right), s = Math.max(r.top, e.top), n = Math.min(r.bottom, e.bottom);
1931
1931
  return {
1932
- bottom: s,
1933
- height: Math.max(0, s - n),
1932
+ bottom: n,
1933
+ height: Math.max(0, n - s),
1934
1934
  left: t,
1935
- right: r,
1936
- top: n,
1937
- width: Math.max(0, r - t)
1935
+ right: i,
1936
+ top: s,
1937
+ width: Math.max(0, i - t)
1938
1938
  };
1939
1939
  }
1940
- function ht(i, e, t) {
1941
- return (i.left < e.right || t >= 0 && N(i.left, e.right, t)) && (e.left < i.right || t >= 0 && N(e.left, i.right, t)) && (i.top < e.bottom || t >= 0 && N(i.top, e.bottom, t)) && (e.top < i.bottom || t >= 0 && N(e.top, i.bottom, t));
1940
+ function je(r, e, t) {
1941
+ return (r.left < e.right || t >= 0 && N(r.left, e.right, t)) && (e.left < r.right || t >= 0 && N(e.left, r.right, t)) && (r.top < e.bottom || t >= 0 && N(r.top, e.bottom, t)) && (e.top < r.bottom || t >= 0 && N(e.top, r.bottom, t));
1942
1942
  }
1943
- function N(i, e, t) {
1944
- return Math.abs(i - e) <= t;
1943
+ function N(r, e, t) {
1944
+ return Math.abs(r - e) <= t;
1945
1945
  }
1946
- var U = [], ei = function() {
1947
- return U.some(function(i) {
1948
- return i.activeTargets.length > 0;
1949
- });
1950
- }, ti = function() {
1951
- return U.some(function(i) {
1952
- return i.skippedTargets.length > 0;
1953
- });
1954
- }, Ue = "ResizeObserver loop completed with undelivered notifications.", ii = function() {
1955
- var i;
1956
- typeof ErrorEvent == "function" ? i = new ErrorEvent("error", {
1957
- message: Ue
1958
- }) : (i = document.createEvent("Event"), i.initEvent("error", !1, !1), i.message = Ue), window.dispatchEvent(i);
1959
- }, J;
1960
- (function(i) {
1961
- i.BORDER_BOX = "border-box", i.CONTENT_BOX = "content-box", i.DEVICE_PIXEL_CONTENT_BOX = "device-pixel-content-box";
1962
- })(J || (J = {}));
1963
- var H = function(i) {
1964
- return Object.freeze(i);
1965
- }, ri = function() {
1966
- function i(e, t) {
1967
- this.inlineSize = e, this.blockSize = t, H(this);
1968
- }
1969
- return i;
1970
- }(), ct = function() {
1971
- function i(e, t, r, n) {
1972
- return this.x = e, this.y = t, this.width = r, this.height = n, this.top = this.y, this.left = this.x, this.bottom = this.top + this.height, this.right = this.left + this.width, H(this);
1973
- }
1974
- return i.prototype.toJSON = function() {
1975
- var e = this, t = e.x, r = e.y, n = e.top, s = e.right, o = e.bottom, a = e.left, h = e.width, c = e.height;
1976
- return { x: t, y: r, top: n, right: s, bottom: o, left: a, width: h, height: c };
1977
- }, i.fromRect = function(e) {
1978
- return new i(e.x, e.y, e.width, e.height);
1979
- }, i;
1980
- }(), Ne = function(i) {
1981
- return i instanceof SVGElement && "getBBox" in i;
1982
- }, ut = function(i) {
1983
- if (Ne(i)) {
1984
- var e = i.getBBox(), t = e.width, r = e.height;
1985
- return !t && !r;
1986
- }
1987
- var n = i, s = n.offsetWidth, o = n.offsetHeight;
1988
- return !(s || o || i.getClientRects().length);
1989
- }, He = function(i) {
1990
- var e;
1991
- if (i instanceof Element)
1992
- return !0;
1993
- var t = (e = i == null ? void 0 : i.ownerDocument) === null || e === void 0 ? void 0 : e.defaultView;
1994
- return !!(t && i instanceof t.Element);
1995
- }, ni = function(i) {
1996
- switch (i.tagName) {
1997
- case "INPUT":
1998
- if (i.type !== "image")
1999
- break;
2000
- case "VIDEO":
2001
- case "AUDIO":
2002
- case "EMBED":
2003
- case "OBJECT":
2004
- case "CANVAS":
2005
- case "IFRAME":
2006
- case "IMG":
2007
- return !0;
2008
- }
2009
- return !1;
2010
- }, Y = typeof window < "u" ? window : {}, ie = /* @__PURE__ */ new WeakMap(), $e = /auto|scroll/, si = /^tb|vertical/, oi = /msie|trident/i.test(Y.navigator && Y.navigator.userAgent), R = function(i) {
2011
- return parseFloat(i || "0");
2012
- }, q = function(i, e, t) {
2013
- return i === void 0 && (i = 0), e === void 0 && (e = 0), t === void 0 && (t = !1), new ri((t ? e : i) || 0, (t ? i : e) || 0);
2014
- }, Ve = H({
2015
- devicePixelContentBoxSize: q(),
2016
- borderBoxSize: q(),
2017
- contentBoxSize: q(),
2018
- contentRect: new ct(0, 0, 0, 0)
2019
- }), dt = function(i, e) {
2020
- if (e === void 0 && (e = !1), ie.has(i) && !e)
2021
- return ie.get(i);
2022
- if (ut(i))
2023
- return ie.set(i, Ve), Ve;
2024
- var t = getComputedStyle(i), r = Ne(i) && i.ownerSVGElement && i.getBBox(), n = !oi && t.boxSizing === "border-box", s = si.test(t.writingMode || ""), o = !r && $e.test(t.overflowY || ""), a = !r && $e.test(t.overflowX || ""), h = r ? 0 : R(t.paddingTop), c = r ? 0 : R(t.paddingRight), u = r ? 0 : R(t.paddingBottom), p = r ? 0 : R(t.paddingLeft), d = r ? 0 : R(t.borderTopWidth), f = r ? 0 : R(t.borderRightWidth), v = r ? 0 : R(t.borderBottomWidth), g = r ? 0 : R(t.borderLeftWidth), y = p + c, x = h + u, S = g + f, m = d + v, E = a ? i.offsetHeight - m - i.clientHeight : 0, P = o ? i.offsetWidth - S - i.clientWidth : 0, K = n ? y + S : 0, Z = n ? x + m : 0, W = r ? r.width : R(t.width) - K - P, F = r ? r.height : R(t.height) - Z - E, Q = W + y + P + S, ee = F + x + E + m, $ = H({
2025
- devicePixelContentBoxSize: q(Math.round(W * devicePixelRatio), Math.round(F * devicePixelRatio), s),
2026
- borderBoxSize: q(Q, ee, s),
2027
- contentBoxSize: q(W, F, s),
2028
- contentRect: new ct(p, h, W, F)
2029
- });
2030
- return ie.set(i, $), $;
2031
- }, pt = function(i, e, t) {
2032
- var r = dt(i, t), n = r.borderBoxSize, s = r.contentBoxSize, o = r.devicePixelContentBoxSize;
2033
- switch (e) {
2034
- case J.DEVICE_PIXEL_CONTENT_BOX:
2035
- return o;
2036
- case J.BORDER_BOX:
2037
- return n;
2038
- default:
2039
- return s;
2040
- }
2041
- }, ai = function() {
2042
- function i(e) {
2043
- var t = dt(e);
2044
- this.target = e, this.contentRect = t.contentRect, this.borderBoxSize = H([t.borderBoxSize]), this.contentBoxSize = H([t.contentBoxSize]), this.devicePixelContentBoxSize = H([t.devicePixelContentBoxSize]);
2045
- }
2046
- return i;
2047
- }(), ft = function(i) {
2048
- if (ut(i))
2049
- return 1 / 0;
2050
- for (var e = 0, t = i.parentNode; t; )
2051
- e += 1, t = t.parentNode;
1946
+ function qe(r) {
1947
+ const e = {}, t = r.document.documentElement.style;
1948
+ for (const i in r.document.documentElement.style)
1949
+ Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
2052
1950
  return e;
2053
- }, li = function() {
2054
- var i = 1 / 0, e = [];
2055
- U.forEach(function(o) {
2056
- if (o.activeTargets.length !== 0) {
2057
- var a = [];
2058
- o.activeTargets.forEach(function(c) {
2059
- var u = new ai(c.target), p = ft(c.target);
2060
- a.push(u), c.lastReportedSize = pt(c.target, c.observedBox), p < i && (i = p);
2061
- }), e.push(function() {
2062
- o.callback.call(o.observer, a, o.observer);
2063
- }), o.activeTargets.splice(0, o.activeTargets.length);
2064
- }
2065
- });
2066
- for (var t = 0, r = e; t < r.length; t++) {
2067
- var n = r[t];
2068
- n();
2069
- }
2070
- return i;
2071
- }, qe = function(i) {
2072
- U.forEach(function(t) {
2073
- t.activeTargets.splice(0, t.activeTargets.length), t.skippedTargets.splice(0, t.skippedTargets.length), t.observationTargets.forEach(function(n) {
2074
- n.isActive() && (ft(n.target) > i ? t.activeTargets.push(n) : t.skippedTargets.push(n));
2075
- });
2076
- });
2077
- }, hi = function() {
2078
- var i = 0;
2079
- for (qe(i); ei(); )
2080
- i = li(), qe(i);
2081
- return ti() && ii(), i > 0;
2082
- }, fe, mt = [], ci = function() {
2083
- return mt.splice(0).forEach(function(i) {
2084
- return i();
2085
- });
2086
- }, ui = function(i) {
2087
- if (!fe) {
2088
- var e = 0, t = document.createTextNode(""), r = { characterData: !0 };
2089
- new MutationObserver(function() {
2090
- return ci();
2091
- }).observe(t, r), fe = function() {
2092
- t.textContent = "".concat(e ? e-- : e++);
2093
- };
2094
- }
2095
- mt.push(i), fe();
2096
- }, di = function(i) {
2097
- ui(function() {
2098
- requestAnimationFrame(i);
1951
+ }
1952
+ function Nt(r, e) {
1953
+ const t = qe(r);
1954
+ Object.keys(t).forEach((i) => {
1955
+ e.hasOwnProperty(i) || he(r, i);
1956
+ }), Object.entries(e).forEach(([i, s]) => {
1957
+ t[i] !== s && G(r, i, s);
2099
1958
  });
2100
- }, oe = 0, pi = function() {
2101
- return !!oe;
2102
- }, fi = 250, mi = { attributes: !0, characterData: !0, childList: !0, subtree: !0 }, _e = [
2103
- "resize",
2104
- "load",
2105
- "transitionend",
2106
- "animationend",
2107
- "animationstart",
2108
- "animationiteration",
2109
- "keyup",
2110
- "keydown",
2111
- "mouseup",
2112
- "mousedown",
2113
- "mouseover",
2114
- "mouseout",
2115
- "blur",
2116
- "focus"
2117
- ], je = function(i) {
2118
- return i === void 0 && (i = 0), Date.now() + i;
2119
- }, me = !1, gi = function() {
2120
- function i() {
2121
- var e = this;
2122
- this.stopped = !0, this.listener = function() {
2123
- return e.schedule();
2124
- };
2125
- }
2126
- return i.prototype.run = function(e) {
2127
- var t = this;
2128
- if (e === void 0 && (e = fi), !me) {
2129
- me = !0;
2130
- var r = je(e);
2131
- di(function() {
2132
- var n = !1;
2133
- try {
2134
- n = hi();
2135
- } finally {
2136
- if (me = !1, e = r - je(), !pi())
2137
- return;
2138
- n ? t.run(1e3) : e > 0 ? t.run(e) : t.start();
2139
- }
2140
- });
2141
- }
2142
- }, i.prototype.schedule = function() {
2143
- this.stop(), this.run();
2144
- }, i.prototype.observe = function() {
2145
- var e = this, t = function() {
2146
- return e.observer && e.observer.observe(document.body, mi);
2147
- };
2148
- document.body ? t() : Y.addEventListener("DOMContentLoaded", t);
2149
- }, i.prototype.start = function() {
2150
- var e = this;
2151
- this.stopped && (this.stopped = !1, this.observer = new MutationObserver(this.listener), this.observe(), _e.forEach(function(t) {
2152
- return Y.addEventListener(t, e.listener, !0);
2153
- }));
2154
- }, i.prototype.stop = function() {
2155
- var e = this;
2156
- this.stopped || (this.observer && this.observer.disconnect(), _e.forEach(function(t) {
2157
- return Y.removeEventListener(t, e.listener, !0);
2158
- }), this.stopped = !0);
2159
- }, i;
2160
- }(), ve = new gi(), Xe = function(i) {
2161
- !oe && i > 0 && ve.start(), oe += i, !oe && ve.stop();
2162
- }, vi = function(i) {
2163
- return !Ne(i) && !ni(i) && getComputedStyle(i).display === "inline";
2164
- }, yi = function() {
2165
- function i(e, t) {
2166
- this.target = e, this.observedBox = t || J.CONTENT_BOX, this.lastReportedSize = {
2167
- inlineSize: 0,
2168
- blockSize: 0
2169
- };
2170
- }
2171
- return i.prototype.isActive = function() {
2172
- var e = pt(this.target, this.observedBox, !0);
2173
- return vi(this.target) && (this.lastReportedSize = e), this.lastReportedSize.inlineSize !== e.inlineSize || this.lastReportedSize.blockSize !== e.blockSize;
2174
- }, i;
2175
- }(), bi = function() {
2176
- function i(e, t) {
2177
- this.activeTargets = [], this.skippedTargets = [], this.observationTargets = [], this.observer = e, this.callback = t;
1959
+ }
1960
+ function Pe(r, e) {
1961
+ return r.document.documentElement.style.getPropertyValue(e);
1962
+ }
1963
+ function G(r, e, t) {
1964
+ r.document.documentElement.style.setProperty(e, t);
1965
+ }
1966
+ function he(r, e) {
1967
+ r.document.documentElement.style.removeProperty(e);
1968
+ }
1969
+ const At = (r) => {
1970
+ if (r.startsWith("rgb")) {
1971
+ const e = r.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
1972
+ if (e)
1973
+ return {
1974
+ r: parseInt(e[1], 10),
1975
+ g: parseInt(e[2], 10),
1976
+ b: parseInt(e[3], 10),
1977
+ a: e[4] ? parseInt(e[4], 10) / 255 : 1
1978
+ };
1979
+ } else if (r.startsWith("#")) {
1980
+ const e = r.slice(1);
1981
+ if (e.length === 3 || e.length === 4)
1982
+ return {
1983
+ r: parseInt(e[0] + e[0], 16) / 255,
1984
+ g: parseInt(e[1] + e[1], 16) / 255,
1985
+ b: parseInt(e[2] + e[2], 16) / 255,
1986
+ a: e.length === 4 ? parseInt(e[3] + e[3], 16) / 255 : 1
1987
+ };
1988
+ if (e.length === 6 || e.length === 8)
1989
+ return {
1990
+ r: parseInt(e[0] + e[1], 16) / 255,
1991
+ g: parseInt(e[2] + e[3], 16) / 255,
1992
+ b: parseInt(e[4] + e[5], 16) / 255,
1993
+ a: e.length === 8 ? parseInt(e[6] + e[7], 16) / 255 : 1
1994
+ };
2178
1995
  }
2179
- return i;
2180
- }(), re = /* @__PURE__ */ new WeakMap(), Ge = function(i, e) {
2181
- for (var t = 0; t < i.length; t += 1)
2182
- if (i[t].target === e)
2183
- return t;
2184
- return -1;
2185
- }, ne = function() {
2186
- function i() {
2187
- }
2188
- return i.connect = function(e, t) {
2189
- var r = new bi(e, t);
2190
- re.set(e, r);
2191
- }, i.observe = function(e, t, r) {
2192
- var n = re.get(e), s = n.observationTargets.length === 0;
2193
- Ge(n.observationTargets, t) < 0 && (s && U.push(n), n.observationTargets.push(new yi(t, r && r.box)), Xe(1), ve.schedule());
2194
- }, i.unobserve = function(e, t) {
2195
- var r = re.get(e), n = Ge(r.observationTargets, t), s = r.observationTargets.length === 1;
2196
- n >= 0 && (s && U.splice(U.indexOf(r), 1), r.observationTargets.splice(n, 1), Xe(-1));
2197
- }, i.disconnect = function(e) {
2198
- var t = this, r = re.get(e);
2199
- r.observationTargets.slice().forEach(function(n) {
2200
- return t.unobserve(e, n.target);
2201
- }), r.activeTargets.splice(0, r.activeTargets.length);
2202
- }, i;
2203
- }(), gt = function() {
2204
- function i(e) {
2205
- if (arguments.length === 0)
2206
- throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
2207
- if (typeof e != "function")
2208
- throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
2209
- ne.connect(this, e);
2210
- }
2211
- return i.prototype.observe = function(e, t) {
2212
- if (arguments.length === 0)
2213
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
2214
- if (!He(e))
2215
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
2216
- ne.observe(this, e, t);
2217
- }, i.prototype.unobserve = function(e) {
2218
- if (arguments.length === 0)
2219
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
2220
- if (!He(e))
2221
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
2222
- ne.unobserve(this, e);
2223
- }, i.prototype.disconnect = function() {
2224
- ne.disconnect(this);
2225
- }, i.toString = function() {
2226
- return "function ResizeObserver () { [polyfill code] }";
2227
- }, i;
2228
- }();
2229
- function Ei(i, e) {
2230
- return i.document.documentElement.style.getPropertyValue(e);
2231
- }
2232
- function ye(i, e, t) {
2233
- i.document.documentElement.style.setProperty(e, t);
2234
- }
2235
- function vt(i, e) {
2236
- i.document.documentElement.style.removeProperty(e);
2237
- }
2238
- const xi = window.ResizeObserver || gt;
2239
- var wi = /* @__PURE__ */ ((i) => (i.Wrap = "wrap", i.Viewport = "viewport", i.Bounds = "bounds", i.Page = "page", i))(wi || {}), Ti = /* @__PURE__ */ ((i) => (i.Boxes = "boxes", i.Bounds = "bounds", i))(Ti || {});
2240
- const Si = "Highlight" in window, Ye = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2241
- class Ci {
1996
+ return { r: 0, g: 0, b: 0, a: 1 };
1997
+ }, Mt = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, Ot = (r) => {
1998
+ const e = At(r);
1999
+ return Mt(e) < 128;
2000
+ };
2001
+ var It = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(It || {}), Lt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Lt || {});
2002
+ const Rt = "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2003
+ class zt {
2242
2004
  /**
2243
2005
  * Creates a DecorationGroup object
2244
2006
  * @param id Unique HTML ID-adhering name of the group
2245
2007
  * @param name Human-readable name of the group
2246
2008
  */
2247
- constructor(e, t, r, n) {
2248
- this.wnd = e, this.comms = t, this.id = r, this.name = n, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Si && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2009
+ constructor(e, t, i, s) {
2010
+ this.wnd = e, this.comms = t, this.id = i, this.name = s, 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());
2249
2011
  }
2250
2012
  get activeable() {
2251
2013
  return this.activateable;
@@ -2259,35 +2021,35 @@ class Ci {
2259
2021
  */
2260
2022
  add(e) {
2261
2023
  var o, a, h, c;
2262
- const t = `${this.id}-${this.lastItemId++}`, r = Ae(this.wnd.document, e.locator);
2263
- if (!r) {
2024
+ const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
2025
+ if (!i) {
2264
2026
  this.comms.log("Can't locate DOM range for decoration", e);
2265
2027
  return;
2266
2028
  }
2267
- const n = r.commonAncestorContainer;
2268
- n.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ye.includes(n.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), n.querySelector(Ye.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((h = n.textContent) == null ? void 0 : h.trim()) || "").length === 0 && ((c = this.notTextFlag) == null || c.set(t, !0)));
2269
- const s = {
2029
+ const s = i.commonAncestorContainer;
2030
+ s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((h = s.textContent) == null ? void 0 : h.trim()) || "").length === 0 && ((c = this.notTextFlag) == null || c.set(t, !0)));
2031
+ const n = {
2270
2032
  decoration: e,
2271
2033
  id: t,
2272
- range: r
2034
+ range: i
2273
2035
  };
2274
- this.items.push(s), this.layout(s), this.renderLayout([s]);
2036
+ this.items.push(n), this.layout(n), this.renderLayout([n]);
2275
2037
  }
2276
2038
  /**
2277
2039
  * Removes the decoration with given ID from the group.
2278
2040
  * @param identifier ID of item to remove
2279
2041
  */
2280
2042
  remove(e) {
2281
- var n, s;
2043
+ var s, n;
2282
2044
  const t = this.items.findIndex((o) => o.decoration.id === e);
2283
2045
  if (t < 0)
2284
2046
  return;
2285
- const r = this.items[t];
2286
- if (this.items.splice(t, 1), r.clickableElements = void 0, r.container && (r.container.remove(), r.container = void 0), this.experimentalHighlights && !((n = this.notTextFlag) != null && n.has(r.id))) {
2047
+ const i = this.items[t];
2048
+ if (this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !((s = this.notTextFlag) != null && s.has(i.id))) {
2287
2049
  const o = this.wnd.CSS.highlights.get(this.id);
2288
- o == null || o.delete(r.range);
2050
+ o == null || o.delete(i.range);
2289
2051
  }
2290
- (s = this.notTextFlag) == null || s.delete(r.id);
2052
+ (n = this.notTextFlag) == null || n.delete(i.id);
2291
2053
  }
2292
2054
  /**
2293
2055
  * Notifies that the given decoration was modified and needs to be updated.
@@ -2311,12 +2073,12 @@ class Ci {
2311
2073
  this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
2312
2074
  }
2313
2075
  experimentalLayout(e) {
2314
- var n, s;
2315
- const [t, r] = this.requireContainer(!0);
2316
- r.add(e.range), t.innerHTML = `
2076
+ var s, n;
2077
+ const [t, i] = this.requireContainer(!0);
2078
+ i.add(e.range), t.innerHTML = `
2317
2079
  ::highlight(${this.id}) {
2318
2080
  color: black;
2319
- background-color: ${((s = (n = e.decoration) == null ? void 0 : n.style) == null ? void 0 : s.tint) ?? "yellow"};
2081
+ background-color: ${((n = (s = e.decoration) == null ? void 0 : s.style) == null ? void 0 : n.tint) ?? "yellow"};
2320
2082
  }`;
2321
2083
  }
2322
2084
  /**
@@ -2324,39 +2086,39 @@ class Ci {
2324
2086
  * @param item
2325
2087
  */
2326
2088
  layout(e) {
2327
- var v, g, y, x, S;
2328
- if (this.experimentalHighlights && !((v = this.notTextFlag) != null && v.has(e.id)))
2089
+ var g, m, v, S, O;
2090
+ if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(e.id)))
2329
2091
  return this.experimentalLayout(e);
2330
2092
  const t = this.wnd.document.createElement("div");
2331
2093
  t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
2332
- const r = this.wnd.innerWidth, n = parseInt(
2094
+ const i = this.wnd.innerWidth, s = parseInt(
2333
2095
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2334
2096
  "column-count"
2335
2097
  )
2336
- ), s = r / (n || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, h = o.scrollTop, c = (m, E, P) => {
2337
- var K, Z, W, F, Q, ee;
2338
- if (m.style.position = "absolute", ((Z = (K = e.decoration) == null ? void 0 : K.style) == null ? void 0 : Z.width) === "viewport") {
2339
- m.style.width = `${r}px`, m.style.height = `${E.height}px`;
2340
- let $ = Math.floor(E.left / r) * r;
2341
- m.style.left = `${$ + a}px`, m.style.top = `${E.top + h}px`;
2342
- } else if (((F = (W = e.decoration) == null ? void 0 : W.style) == null ? void 0 : F.width) === "bounds")
2343
- m.style.width = `${P.width}px`, m.style.height = `${E.height}px`, m.style.left = `${P.left + a}px`, m.style.top = `${E.top + h}px`;
2344
- else if (((ee = (Q = e.decoration) == null ? void 0 : Q.style) == null ? void 0 : ee.width) === "page") {
2345
- m.style.width = `${s}px`, m.style.height = `${E.height}px`;
2346
- let $ = Math.floor(E.left / s) * s;
2347
- m.style.left = `${$ + a}px`, m.style.top = `${E.top + h}px`;
2098
+ ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, h = o.scrollTop, c = (y, b, I) => {
2099
+ var ce, de, ue, pe, fe, me;
2100
+ if (y.style.position = "absolute", ((de = (ce = e.decoration) == null ? void 0 : ce.style) == null ? void 0 : de.width) === "viewport") {
2101
+ y.style.width = `${i}px`, y.style.height = `${b.height}px`;
2102
+ let K = Math.floor(b.left / i) * i;
2103
+ y.style.left = `${K + a}px`, y.style.top = `${b.top + h}px`;
2104
+ } else if (((pe = (ue = e.decoration) == null ? void 0 : ue.style) == null ? void 0 : pe.width) === "bounds")
2105
+ y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + a}px`, y.style.top = `${b.top + h}px`;
2106
+ else if (((me = (fe = e.decoration) == null ? void 0 : fe.style) == null ? void 0 : me.width) === "page") {
2107
+ y.style.width = `${n}px`, y.style.height = `${b.height}px`;
2108
+ let K = Math.floor(b.left / n) * n;
2109
+ y.style.left = `${K + a}px`, y.style.top = `${b.top + h}px`;
2348
2110
  } else
2349
- m.style.width = `${E.width}px`, m.style.height = `${E.height}px`, m.style.left = `${E.left + a}px`, m.style.top = `${E.top + h}px`;
2350
- }, u = e.range.getBoundingClientRect();
2111
+ y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + a}px`, y.style.top = `${b.top + h}px`;
2112
+ }, d = e.range.getBoundingClientRect();
2351
2113
  let p = this.wnd.document.createElement("template");
2352
- const d = Ei(this.wnd, "--USER__appearance") === "readium-night-on";
2114
+ const u = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
2353
2115
  p.innerHTML = `
2354
2116
  <div
2355
2117
  class="r2-highlight-0"
2356
2118
  style="${[
2357
- `background-color: ${((y = (g = e.decoration) == null ? void 0 : g.style) == null ? void 0 : y.tint) ?? "yellow"} !important`,
2119
+ `background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
2358
2120
  //"opacity: 0.3 !important",
2359
- `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2121
+ `mix-blend-mode: ${u ? "exclusion" : "multiply"} !important`,
2360
2122
  "opacity: 1 !important",
2361
2123
  "box-sizing: border-box !important"
2362
2124
  ].join("; ")}"
@@ -2364,19 +2126,19 @@ class Ci {
2364
2126
  </div>
2365
2127
  `.trim();
2366
2128
  const f = p.content.firstElementChild;
2367
- if (((S = (x = e.decoration) == null ? void 0 : x.style) == null ? void 0 : S.layout) === "bounds") {
2368
- const m = f.cloneNode(!0);
2369
- m.style.setProperty("pointer-events", "none"), c(m, u, u), t.append(m);
2129
+ if (((O = (S = e.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
2130
+ const y = f.cloneNode(!0);
2131
+ y.style.setProperty("pointer-events", "none"), c(y, d, d), t.append(y);
2370
2132
  } else {
2371
- let m = Yt(
2133
+ let y = St(
2372
2134
  e.range,
2373
2135
  !0
2374
2136
  // doNotMergeHorizontallyAlignedRects
2375
2137
  );
2376
- m = m.sort((E, P) => E.top < P.top ? -1 : E.top > P.top ? 1 : 0);
2377
- for (let E of m) {
2378
- const P = f.cloneNode(!0);
2379
- P.style.setProperty("pointer-events", "none"), c(P, E, u), t.append(P);
2138
+ y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
2139
+ for (let b of y) {
2140
+ const I = f.cloneNode(!0);
2141
+ I.style.setProperty("pointer-events", "none"), c(I, b, d), t.append(I);
2380
2142
  }
2381
2143
  }
2382
2144
  e.container = t, e.clickableElements = Array.from(
@@ -2385,12 +2147,12 @@ class Ci {
2385
2147
  }
2386
2148
  renderLayout(e) {
2387
2149
  this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
2388
- if (e = e.filter((r) => {
2389
- var n;
2390
- return !this.experimentalHighlights || !!((n = this.notTextFlag) != null && n.has(r.id));
2150
+ if (e = e.filter((i) => {
2151
+ var s;
2152
+ return !this.experimentalHighlights || !!((s = this.notTextFlag) != null && s.has(i.id));
2391
2153
  }), !e || e.length === 0)
2392
2154
  return;
2393
- this.requireContainer().append(...e.map((r) => r.container).filter((r) => !!r));
2155
+ this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
2394
2156
  });
2395
2157
  }
2396
2158
  /**
@@ -2401,8 +2163,8 @@ class Ci {
2401
2163
  if (e) {
2402
2164
  let t;
2403
2165
  this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));
2404
- let r;
2405
- return this.wnd.CSS.highlights.has(this.id) ? r = this.wnd.CSS.highlights.get(this.id) : (r = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, r)), [t, r];
2166
+ let i;
2167
+ return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];
2406
2168
  }
2407
2169
  return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
2408
2170
  }
@@ -2413,7 +2175,7 @@ class Ci {
2413
2175
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2414
2176
  }
2415
2177
  }
2416
- const yt = class be extends de {
2178
+ const Ve = class Q extends Y {
2417
2179
  constructor() {
2418
2180
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2419
2181
  }
@@ -2428,39 +2190,39 @@ const yt = class be extends de {
2428
2190
  }, 50);
2429
2191
  }
2430
2192
  mount(e, t) {
2431
- return this.wnd = e, t.register("decorate", be.moduleName, (r, n) => {
2432
- const s = r;
2433
- s.decoration && s.decoration.locator && (s.decoration.locator = B.deserialize(s.decoration.locator)), this.groups.has(s.group) || this.groups.set(s.group, new Ci(
2193
+ return this.wnd = e, t.register("decorate", Q.moduleName, (i, s) => {
2194
+ const n = i;
2195
+ 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(
2434
2196
  e,
2435
2197
  t,
2436
2198
  `readium-decoration-${this.lastGroupId++}`,
2437
- s.group
2199
+ n.group
2438
2200
  ));
2439
- const o = this.groups.get(s.group);
2440
- switch (s.action) {
2201
+ const o = this.groups.get(n.group);
2202
+ switch (n.action) {
2441
2203
  case "add":
2442
- o == null || o.add(s.decoration);
2204
+ o == null || o.add(n.decoration);
2443
2205
  break;
2444
2206
  case "remove":
2445
- o == null || o.remove(s.decoration.id);
2207
+ o == null || o.remove(n.decoration.id);
2446
2208
  break;
2447
2209
  case "clear":
2448
2210
  o == null || o.clear();
2449
2211
  break;
2450
2212
  case "update":
2451
- o == null || o.update(s.decoration);
2213
+ o == null || o.update(n.decoration);
2452
2214
  break;
2453
2215
  }
2454
- n(!0);
2455
- }), this.resizeObserver = new xi(() => 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;
2216
+ s(!0);
2217
+ }), 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;
2456
2218
  }
2457
2219
  unmount(e, t) {
2458
- return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(be.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
2220
+ 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;
2459
2221
  }
2460
2222
  };
2461
- yt.moduleName = "decorator";
2462
- let Oi = yt;
2463
- const Je = "readium-snapper-style", bt = class Ee extends de {
2223
+ Ve.moduleName = "decorator";
2224
+ let Dt = Ve;
2225
+ const Ae = "readium-snapper-style", _e = class ee extends Y {
2464
2226
  constructor() {
2465
2227
  super(...arguments), this.protected = !1;
2466
2228
  }
@@ -2472,48 +2234,53 @@ const Je = "readium-snapper-style", bt = class Ee extends de {
2472
2234
  }`;
2473
2235
  }
2474
2236
  mount(e, t) {
2475
- const r = e.document.createElement("style");
2476
- return r.dataset.readium = "true", r.id = Je, r.textContent = this.buildStyles(), e.document.head.appendChild(r), t.register("protect", Ee.moduleName, (n, s) => {
2477
- this.protected = !0, r.textContent = this.buildStyles(), s(!0);
2478
- }), t.register("unprotect", Ee.moduleName, (n, s) => {
2479
- this.protected = !1, r.textContent = this.buildStyles(), s(!0);
2237
+ const i = e.document.createElement("style");
2238
+ return i.dataset.readium = "true", i.id = Ae, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", ee.moduleName, (s, n) => {
2239
+ this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2240
+ }), t.register("unprotect", ee.moduleName, (s, n) => {
2241
+ this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2480
2242
  }), t.log("Snapper Mounted"), !0;
2481
2243
  }
2482
2244
  unmount(e, t) {
2483
- var r;
2484
- return (r = e.document.getElementById(Je)) == null || r.remove(), t.log("Snapper Unmounted"), !0;
2245
+ var i;
2246
+ return (i = e.document.getElementById(Ae)) == null || i.remove(), t.log("Snapper Unmounted"), !0;
2485
2247
  }
2486
2248
  };
2487
- bt.moduleName = "snapper";
2488
- let Et = bt;
2489
- function k(i) {
2490
- return i.document.body.dir.toLowerCase() === "rtl";
2249
+ _e.moduleName = "snapper";
2250
+ let Xe = _e;
2251
+ function W(r) {
2252
+ return r.document.body.dir.toLowerCase() === "rtl";
2491
2253
  }
2492
- function xt(i) {
2254
+ function Ge(r) {
2493
2255
  return parseInt(
2494
- i.getComputedStyle(
2495
- i.document.documentElement
2256
+ r.getComputedStyle(
2257
+ r.document.documentElement
2496
2258
  ).getPropertyValue("column-count")
2497
2259
  );
2498
2260
  }
2499
- function Pi(i) {
2500
- const e = "readium-virtual-page";
2501
- let t = i.document.getElementById(e);
2502
- if (xt(i) !== 2)
2503
- t && t.remove();
2504
- else {
2505
- const n = i.document.scrollingElement.scrollWidth / i.innerWidth;
2506
- Math.round(n * 2) / 2 % 1 > 0.1 && (t ? t.remove() : (t = i.document.createElement("div"), t.setAttribute("id", e), t.dataset.readium = "true", t.style.breakBefore = "column", t.innerHTML = "&#8203;", i.document.body.appendChild(t)));
2507
- }
2261
+ function Me(r) {
2262
+ const e = getComputedStyle(r), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
2263
+ return r.clientHeight - t - i;
2264
+ }
2265
+ function Oe(r) {
2266
+ const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2267
+ for (const a of e)
2268
+ a.remove();
2269
+ const t = Ge(r), i = r.document.scrollingElement.scrollWidth, s = Math.ceil(i / r.innerWidth) * t, n = Math.round(i / r.innerWidth * t), o = t === 1 ? 0 : s - n;
2270
+ if (o > 0)
2271
+ for (let a = 0; a < o; a++) {
2272
+ const h = r.document.createElement("div");
2273
+ h.setAttribute("id", `readium-virtual-page-${a}`), h.dataset.readium = "true", CSS.supports("break-before", "column") ? h.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (h.style.breakInside = "avoid-column"), h.style.height = Me(r.document.documentElement) + "px"), h.innerHTML = "&#8203;", r.document.body.appendChild(h);
2274
+ }
2508
2275
  }
2509
- function Ai(i) {
2510
- return i < 0.5 ? 2 * i * i : -1 + (4 - 2 * i) * i;
2276
+ function Wt(r) {
2277
+ return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2511
2278
  }
2512
- function T(i) {
2513
- const e = i.getSelection();
2279
+ function T(r) {
2280
+ const e = r.getSelection();
2514
2281
  e && e.removeAllRanges();
2515
2282
  }
2516
- const Ni = [
2283
+ const Ft = [
2517
2284
  "a",
2518
2285
  "audio",
2519
2286
  "button",
@@ -2527,49 +2294,49 @@ const Ni = [
2527
2294
  "textarea",
2528
2295
  "video"
2529
2296
  ];
2530
- function wt(i) {
2297
+ function Ye(r) {
2531
2298
  var e;
2532
- return Ni.indexOf(i.nodeName.toLowerCase()) !== -1 || i.hasAttribute("contenteditable") && ((e = i.getAttribute("contenteditable")) == null ? void 0 : e.toLowerCase()) !== "false" ? i : i.parentElement ? wt(i.parentElement) : null;
2299
+ return Ft.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && ((e = r.getAttribute("contenteditable")) == null ? void 0 : e.toLowerCase()) !== "false" ? r : r.parentElement ? Ye(r.parentElement) : null;
2533
2300
  }
2534
- function Tt(i, e) {
2535
- const t = St(i, i.document.body, e), r = i._readium_cssSelectorGenerator.getCssSelector(t, {
2301
+ function Ke(r, e) {
2302
+ const t = Ze(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {
2536
2303
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2537
2304
  });
2538
- return new B({
2305
+ return new D({
2539
2306
  href: "#",
2540
2307
  type: "application/xhtml+xml",
2541
- locations: new w({
2308
+ locations: new x({
2542
2309
  otherLocations: /* @__PURE__ */ new Map([
2543
- ["cssSelector", r]
2310
+ ["cssSelector", i]
2544
2311
  ])
2545
2312
  }),
2546
- text: new _({
2313
+ text: new U({
2547
2314
  highlight: t.textContent || void 0
2548
2315
  })
2549
2316
  });
2550
2317
  }
2551
- function St(i, e, t) {
2552
- for (var r = 0; r < e.children.length; r++) {
2553
- const n = e.children[r];
2554
- if (!Li(n) && Mi(i, n, t))
2555
- return Ri(i, n) ? n : St(i, n, t);
2318
+ function Ze(r, e, t) {
2319
+ for (var i = 0; i < e.children.length; i++) {
2320
+ const s = e.children[i];
2321
+ if (!kt(s) && Bt(r, s, t))
2322
+ return Ut(r, s) ? s : Ze(r, s, t);
2556
2323
  }
2557
2324
  return e;
2558
2325
  }
2559
- function Mi(i, e, t) {
2326
+ function Bt(r, e, t) {
2560
2327
  if (e === document.body || e === document.documentElement)
2561
2328
  return !0;
2562
2329
  if (!document || !document.documentElement || !document.body)
2563
2330
  return !1;
2564
- const r = e.getBoundingClientRect();
2565
- return t ? r.bottom > 0 && r.top < i.innerHeight : r.right > 0 && r.left < i.innerWidth;
2331
+ const i = e.getBoundingClientRect();
2332
+ return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2566
2333
  }
2567
- function Ri(i, e) {
2334
+ function Ut(r, e) {
2568
2335
  const t = e.getBoundingClientRect();
2569
- return t.top >= 0 && t.left >= 0 && t.bottom <= i.innerHeight && t.right <= i.innerWidth;
2336
+ return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;
2570
2337
  }
2571
- function Li(i) {
2572
- const e = getComputedStyle(i);
2338
+ function kt(r) {
2339
+ const e = getComputedStyle(r);
2573
2340
  if (e) {
2574
2341
  const t = e.getPropertyValue("display");
2575
2342
  if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
@@ -2577,7 +2344,7 @@ function Li(i) {
2577
2344
  }
2578
2345
  return !1;
2579
2346
  }
2580
- const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2347
+ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2581
2348
  constructor() {
2582
2349
  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);
2583
2350
  }
@@ -2588,7 +2355,7 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2588
2355
  return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
2589
2356
  }
2590
2357
  snapOffset(e) {
2591
- const t = e + (k(this.wnd) ? -1 : 1);
2358
+ const t = e + (W(this.wnd) ? -1 : 1);
2592
2359
  return t - t % this.wnd.innerWidth;
2593
2360
  }
2594
2361
  reportProgress() {
@@ -2598,7 +2365,7 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2598
2365
  if (this.overscroll !== 0 || this.shakeTimeout !== 0)
2599
2366
  return;
2600
2367
  const e = this.doc();
2601
- e.classList.add(k(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2368
+ e.classList.add(W(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2602
2369
  const t = this.scrollOffset();
2603
2370
  this.shakeTimeout = this.wnd.setTimeout(() => {
2604
2371
  e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
@@ -2613,28 +2380,28 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2613
2380
  }
2614
2381
  // Snaps the current offset to the page width.
2615
2382
  snapCurrentOffset(e = !1, t = !1) {
2616
- const r = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, n = this.doc(), s = this.dragOffset(), o = xt(this.wnd), a = Math.min(Math.max(0, r), this.cachedScrollWidth), h = k(this.wnd) ? -1 : 1, c = (
2383
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), h = W(this.wnd) ? -1 : 1, c = (
2617
2384
  // The hurdle to overcome in order to change pages
2618
- h * (this.wnd.innerWidth / 3) * (h * s > 0 ? 2 : 1)
2619
- ), u = this.snapOffset(a + c);
2620
- if (e && u !== this.scrollOffset()) {
2385
+ h * (this.wnd.innerWidth / 3) * (h * n > 0 ? 2 : 1)
2386
+ ), d = this.snapOffset(a + c);
2387
+ if (e && d !== this.scrollOffset()) {
2621
2388
  this.snappingCancelled = !1;
2622
- const p = (g, y, x, S) => x > S ? y : g + (y - g) * Ai(x / S), d = (
2389
+ const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O), u = (
2623
2390
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2624
- Ii * o
2391
+ Ht * o
2625
2392
  );
2626
2393
  let f;
2627
- const v = (g) => {
2394
+ const g = (m) => {
2628
2395
  if (this.snappingCancelled)
2629
2396
  return;
2630
- f || (f = g);
2631
- const y = g - f, x = p(this.overscroll, 0, y, d), S = p(r, u, y, d);
2632
- n.scrollLeft = S, this.overscroll !== 0 && (n.style.transform = `translate3d(${-x}px, 0px, 0px)`), y < d ? this.wnd.requestAnimationFrame(v) : (this.clearTouches(), n.style.removeProperty("transform"), n.scrollLeft = u, t || this.reportProgress());
2397
+ f || (f = m);
2398
+ const v = m - f, S = p(this.overscroll, 0, v, u), O = p(i, d, v, u);
2399
+ s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < u ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = d, t || this.reportProgress());
2633
2400
  };
2634
- this.wnd.requestAnimationFrame(v);
2401
+ this.wnd.requestAnimationFrame(g);
2635
2402
  } else
2636
- n.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2637
- n.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
2403
+ s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2404
+ s.scrollLeft = d, this.clearTouches(), t || this.reportProgress();
2638
2405
  });
2639
2406
  }
2640
2407
  dragOffset() {
@@ -2659,8 +2426,8 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2659
2426
  }
2660
2427
  onTouchEnd(e) {
2661
2428
  if (this.touchState === 2) {
2662
- const t = this.dragOffset(), r = this.scrollOffset();
2663
- this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : r < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - r - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
2429
+ const t = this.dragOffset(), i = this.scrollOffset();
2430
+ this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
2664
2431
  }
2665
2432
  this.touchState = 0;
2666
2433
  }
@@ -2671,15 +2438,15 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2671
2438
  if (this.touchState === 0)
2672
2439
  return;
2673
2440
  this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = e.touches[0].clientX;
2674
- const t = this.dragOffset(), r = this.alreadyScrollLeft + t;
2675
- r < 0 ? (this.overscroll = r, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : r + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = r, this.doc().style.transform = `translate3d(${-r}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
2441
+ const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2442
+ 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);
2676
2443
  }
2677
2444
  mount(e, t) {
2678
2445
  if (this.wnd = e, this.comms = t, !super.mount(e, t))
2679
2446
  return !1;
2680
2447
  e.navigator.epubReadingSystem.layoutStyle = "paginated";
2681
- const r = e.document.createElement("style");
2682
- r.dataset.readium = "true", r.id = Ke, r.textContent = `
2448
+ const i = e.document.createElement("style");
2449
+ i.dataset.readium = "true", i.id = Ie, i.textContent = `
2683
2450
  @keyframes readium-bounce-l-animation {
2684
2451
  0%, 100% {transform: translate3d(0, 0, 0);}
2685
2452
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2713,131 +2480,121 @@ const Ke = "readium-column-snapper-style", Ii = 200, Ct = class C extends Et {
2713
2480
  body::-webkit-scrollbar {
2714
2481
  display: none; /* for Chrome, Safari, and Opera */
2715
2482
  }
2716
- `, e.document.head.appendChild(r);
2717
- const n = e.ResizeObserver || gt;
2718
- this.resizeObserver = new n(() => e.requestAnimationFrame(() => {
2719
- e && Pi(e);
2720
- })), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver(() => {
2721
- this.wnd.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2722
- }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] });
2723
- const s = (o) => {
2724
- const a = this.doc().scrollLeft;
2725
- return this.doc().scrollLeft = this.snapOffset(o), a !== this.doc().scrollLeft;
2483
+ `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2484
+ e.requestAnimationFrame(() => {
2485
+ e && Oe(e);
2486
+ }), this.onWidthChange();
2487
+ }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2488
+ for (const o of n)
2489
+ if (o.target === this.wnd.document.documentElement) {
2490
+ const a = o.oldValue, h = o.target.getAttribute("style"), c = /transform\s*:\s*([^;]+)/, d = a == null ? void 0 : a.match(c), p = h == null ? void 0 : h.match(c);
2491
+ (!d && !p || d && !p || d && p && d[1] !== p[1]) && (e.requestAnimationFrame(() => {
2492
+ e && Oe(e);
2493
+ }), this.onWidthChange());
2494
+ } else
2495
+ e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2496
+ }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
2497
+ const s = (n) => {
2498
+ const o = this.doc().scrollLeft;
2499
+ return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2726
2500
  };
2727
- return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", C.moduleName, (o, a) => {
2728
- const h = o;
2729
- if (h < 0 || h > 1) {
2501
+ return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", w.moduleName, (n, o) => {
2502
+ const a = n;
2503
+ if (a < 0 || a > 1) {
2730
2504
  t.send("error", {
2731
2505
  message: "go_progression must be given a position from 0.0 to 1.0"
2732
- }), a(!1);
2506
+ }), o(!1);
2733
2507
  return;
2734
2508
  }
2735
2509
  this.wnd.requestAnimationFrame(() => {
2736
2510
  this.cachedScrollWidth = this.doc().scrollWidth;
2737
- const c = this.cachedScrollWidth, u = k(e) ? -1 : 1, p = c * h * u;
2738
- this.doc().scrollLeft = this.snapOffset(p), this.reportProgress(), T(this.wnd), a(!0);
2511
+ const h = this.cachedScrollWidth, c = W(e) ? -1 : 1, d = h * a * c;
2512
+ this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), T(this.wnd), o(!0);
2739
2513
  });
2740
- }), t.register("go_id", C.moduleName, (o, a) => {
2741
- const h = e.document.getElementById(o);
2742
- if (!h) {
2743
- a(!1);
2514
+ }), t.register("go_id", w.moduleName, (n, o) => {
2515
+ const a = e.document.getElementById(n);
2516
+ if (!a) {
2517
+ o(!1);
2744
2518
  return;
2745
2519
  }
2746
2520
  this.wnd.requestAnimationFrame(() => {
2747
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), a(!0);
2521
+ this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2748
2522
  });
2749
- }), t.register("go_text", C.moduleName, (o, a) => {
2750
- let h;
2751
- Array.isArray(o) && (o.length > 1 && (h = o[1]), o = o[0]);
2752
- const c = _.deserialize(o), u = Ae(this.wnd.document, new B({
2523
+ }), t.register("go_text", w.moduleName, (n, o) => {
2524
+ let a;
2525
+ Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
2526
+ const h = U.deserialize(n), c = le(this.wnd.document, new D({
2753
2527
  href: e.location.href,
2754
2528
  type: "text/html",
2755
- text: c,
2756
- locations: h ? new w({
2529
+ text: h,
2530
+ locations: a ? new x({
2757
2531
  otherLocations: /* @__PURE__ */ new Map([
2758
- ["cssSelector", h]
2532
+ ["cssSelector", a]
2759
2533
  ])
2760
2534
  }) : void 0
2761
2535
  }));
2762
- if (!u) {
2763
- a(!1);
2536
+ if (!c) {
2537
+ o(!1);
2764
2538
  return;
2765
2539
  }
2766
2540
  this.wnd.requestAnimationFrame(() => {
2767
- this.doc().scrollLeft = this.snapOffset(u.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), a(!0);
2541
+ this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2768
2542
  });
2769
- }), t.register("go_end", C.moduleName, (o, a) => {
2770
- const h = k(e) ? -1 : 1;
2543
+ }), t.register("go_end", w.moduleName, (n, o) => {
2544
+ const a = W(e) ? -1 : 1;
2771
2545
  this.wnd.requestAnimationFrame(() => {
2772
2546
  this.cachedScrollWidth = this.doc().scrollWidth;
2773
- const c = this.cachedScrollWidth * h;
2774
- if (this.doc().scrollLeft === c)
2775
- return a(!1);
2776
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), T(this.wnd), a(!0);
2547
+ const h = this.cachedScrollWidth * a;
2548
+ if (this.doc().scrollLeft === h)
2549
+ return o(!1);
2550
+ this.doc().scrollLeft = this.snapOffset(h), this.reportProgress(), T(this.wnd), o(!0);
2777
2551
  });
2778
- }), t.register("go_start", C.moduleName, (o, a) => {
2552
+ }), t.register("go_start", w.moduleName, (n, o) => {
2779
2553
  this.wnd.requestAnimationFrame(() => {
2780
2554
  if (this.doc().scrollLeft === 0)
2781
- return a(!1);
2782
- this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), a(!0);
2555
+ return o(!1);
2556
+ this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
2783
2557
  });
2784
- }), t.register("go_prev", C.moduleName, (o, a) => {
2558
+ }), t.register("go_prev", w.moduleName, (n, o) => {
2785
2559
  this.wnd.requestAnimationFrame(() => {
2786
- const h = e.scrollX - e.innerWidth, c = k(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, u = s(Math.max(h, c));
2787
- u && (this.reportProgress(), T(this.wnd)), a(u);
2560
+ this.cachedScrollWidth = this.doc().scrollWidth;
2561
+ const a = e.scrollX - e.innerWidth, h = W(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, c = s(Math.max(a, h));
2562
+ c && (this.reportProgress(), T(this.wnd)), o(c);
2788
2563
  });
2789
- }), t.register("go_next", C.moduleName, (o, a) => {
2564
+ }), t.register("go_next", w.moduleName, (n, o) => {
2790
2565
  this.wnd.requestAnimationFrame(() => {
2791
- const h = e.scrollX + e.innerWidth, c = k(e) ? 0 : this.cachedScrollWidth - e.innerWidth, u = s(Math.min(h, c));
2792
- u && (this.reportProgress(), T(this.wnd)), a(u);
2566
+ this.cachedScrollWidth = this.doc().scrollWidth;
2567
+ const a = e.scrollX + e.innerWidth, h = W(e) ? 0 : this.cachedScrollWidth - e.innerWidth, c = s(Math.min(a, h));
2568
+ c && (this.reportProgress(), T(this.wnd)), o(c);
2793
2569
  });
2794
- }), t.register("unfocus", C.moduleName, (o, a) => {
2795
- this.snappingCancelled = !0, T(this.wnd), a(!0);
2796
- }), t.register("shake", C.moduleName, (o, a) => {
2797
- this.shake(), a(!0);
2798
- }), t.register("focus", C.moduleName, (o, a) => {
2570
+ }), t.register("unfocus", w.moduleName, (n, o) => {
2571
+ this.snappingCancelled = !0, T(this.wnd), o(!0);
2572
+ }), t.register("shake", w.moduleName, (n, o) => {
2573
+ this.shake(), o(!0);
2574
+ }), t.register("focus", w.moduleName, (n, o) => {
2799
2575
  this.wnd.requestAnimationFrame(() => {
2800
- this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), a(!0);
2576
+ this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2801
2577
  });
2802
- }), t.register("first_visible_locator", C.moduleName, (o, a) => {
2803
- const h = Tt(e, !1);
2804
- this.comms.send("first_visible_locator", h.serialize()), a(!0);
2578
+ }), t.register("first_visible_locator", w.moduleName, (n, o) => {
2579
+ const a = Ke(e, !1);
2580
+ this.comms.send("first_visible_locator", a.serialize()), o(!0);
2805
2581
  }), 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", () => {
2806
2582
  }), t.log("ColumnSnapper Mounted"), !0;
2807
2583
  }
2808
2584
  unmount(e, t) {
2809
- var r;
2810
- 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), (r = e.document.getElementById(Ke)) == null || r.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2585
+ var i;
2586
+ return this.snappingCancelled = !0, t.unregisterAll(w.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);
2811
2587
  }
2812
2588
  };
2813
- Ct.moduleName = "column_snapper";
2814
- let zi = Ct;
2815
- const ue = {
2816
- top: "js-iframe-reader-top-anchor",
2817
- bottom: "js-iframe-reader-bottom-anchor"
2818
- };
2819
- class Di extends HTMLElement {
2820
- connectedCallback() {
2821
- this.setAttribute("aria-hidden", "true"), this.style.setProperty("display", "block", "important"), this.style.setProperty("padding", "0", "important"), this.style.setProperty("margin", "0", "important"), this.style.setProperty("visibility", "hidden", "important");
2822
- }
2823
- }
2824
- function Bi(i) {
2825
- const e = i.getElementsByTagName("body")[0], t = document.createElement("anchor-observer"), r = document.createElement("anchor-observer");
2826
- t.dataset.readium = "true", r.dataset.readium = "true", t == null || t.setAttribute("id", ue.top), t == null || t.style.setProperty("height", "115px", "important"), r == null || r.setAttribute("id", ue.bottom), r == null || r.style.setProperty("height", "80px", "important"), e == null || e.insertBefore(t, e.firstChild), e == null || e.appendChild(r);
2827
- }
2828
- function Wi(i) {
2829
- var n, s;
2830
- const e = i.getElementsByTagName("body")[0], t = e == null ? void 0 : e.querySelector(`#${ue.top}`), r = e == null ? void 0 : e.querySelector(`#${ue.bottom}`);
2831
- t && ((n = t.parentElement) == null || n.removeChild(t)), r && ((s = r.parentElement) == null || s.removeChild(r));
2832
- }
2833
- const Ze = "readium-scroll-snapper-style", Ot = class M extends Et {
2589
+ Je.moduleName = "column_snapper";
2590
+ let $t = Je;
2591
+ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
2834
2592
  constructor() {
2835
- super(...arguments), this.createAnchorElements = () => {
2836
- Bi(this.doc());
2837
- }, this.removeAnchorElements = () => {
2838
- Wi(this.doc());
2839
- }, this.createCustomElement = () => {
2840
- customElements.get("anchor-observer") || customElements.define("anchor-observer", Di);
2593
+ super(...arguments), this.isScrolling = !1, this.handleScroll = () => {
2594
+ this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2595
+ const e = this.doc().scrollTop / this.doc().offsetHeight;
2596
+ this.reportProgress({ progress: e, reference: this.wnd.innerHeight / this.doc().scrollHeight }), this.isScrolling = !1;
2597
+ }));
2841
2598
  };
2842
2599
  }
2843
2600
  doc() {
@@ -2848,8 +2605,8 @@ const Ze = "readium-scroll-snapper-style", Ot = class M extends Et {
2848
2605
  }
2849
2606
  mount(e, t) {
2850
2607
  this.wnd = e, this.comms = t, e.navigator.epubReadingSystem.layoutStyle = "scrolling";
2851
- const r = e.document.createElement("style");
2852
- return r.dataset.readium = "true", r.id = Ze, r.textContent = `
2608
+ const i = e.document.createElement("style");
2609
+ return i.dataset.readium = "true", i.id = Le, i.textContent = `
2853
2610
  * {
2854
2611
  scrollbar-width: none; /* for Firefox */
2855
2612
  }
@@ -2857,95 +2614,99 @@ const Ze = "readium-scroll-snapper-style", Ot = class M extends Et {
2857
2614
  body::-webkit-scrollbar {
2858
2615
  display: none; /* for Chrome, Safari, and Opera */
2859
2616
  }
2860
- `, e.document.head.appendChild(r), t.register("go_progression", M.moduleName, (n, s) => {
2861
- const o = n;
2617
+ `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2618
+ this.comms.ready && this.handleScroll();
2619
+ }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, {
2620
+ passive: !0
2621
+ }), t.register("go_progression", A.moduleName, (s, n) => {
2622
+ const o = s;
2862
2623
  if (o < 0 || o > 1) {
2863
2624
  t.send("error", {
2864
2625
  message: "go_progression must be given a position from 0.0 to 1.0"
2865
- }), s(!1);
2626
+ }), n(!1);
2866
2627
  return;
2867
2628
  }
2868
2629
  this.wnd.requestAnimationFrame(() => {
2869
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), s(!0);
2630
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2870
2631
  });
2871
- }), t.register("go_id", M.moduleName, (n, s) => {
2872
- const o = e.document.getElementById(n);
2632
+ }), t.register("go_id", A.moduleName, (s, n) => {
2633
+ const o = e.document.getElementById(s);
2873
2634
  if (!o) {
2874
- s(!1);
2635
+ n(!1);
2875
2636
  return;
2876
2637
  }
2877
2638
  this.wnd.requestAnimationFrame(() => {
2878
2639
  this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
2879
2640
  const a = this.doc().scrollTop / this.doc().offsetHeight;
2880
- this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), s(!0);
2641
+ this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2881
2642
  });
2882
- }), t.register("go_text", M.moduleName, (n, s) => {
2643
+ }), t.register("go_text", A.moduleName, (s, n) => {
2883
2644
  let o;
2884
- Array.isArray(n) && (n.length > 1 && (o = n[1]), n = n[0]);
2885
- const a = _.deserialize(n), h = Ae(this.wnd.document, new B({
2645
+ Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
2646
+ const a = U.deserialize(s), h = le(this.wnd.document, new D({
2886
2647
  href: e.location.href,
2887
2648
  type: "text/html",
2888
2649
  text: a,
2889
- locations: o ? new w({
2650
+ locations: o ? new x({
2890
2651
  otherLocations: /* @__PURE__ */ new Map([
2891
2652
  ["cssSelector", o]
2892
2653
  ])
2893
2654
  }) : void 0
2894
2655
  }));
2895
2656
  if (!h) {
2896
- s(!1);
2657
+ n(!1);
2897
2658
  return;
2898
2659
  }
2899
2660
  this.wnd.requestAnimationFrame(() => {
2900
2661
  this.doc().scrollTop = h.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
2901
2662
  const c = this.doc().scrollTop / this.doc().offsetHeight;
2902
- this.reportProgress({ progress: c, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), s(!0);
2663
+ this.reportProgress({ progress: c, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2903
2664
  });
2904
- }), t.register("go_start", M.moduleName, (n, s) => {
2665
+ }), t.register("go_start", A.moduleName, (s, n) => {
2905
2666
  if (this.doc().scrollTop === 0)
2906
- return s(!1);
2907
- this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), s(!0);
2908
- }), t.register("go_end", M.moduleName, (n, s) => {
2667
+ return n(!1);
2668
+ this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
2669
+ }), t.register("go_end", A.moduleName, (s, n) => {
2909
2670
  if (this.doc().scrollTop === 0)
2910
- return s(!1);
2911
- this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), s(!0);
2912
- }), t.register("unfocus", M.moduleName, (n, s) => {
2913
- T(this.wnd), s(!0);
2671
+ return n(!1);
2672
+ this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
2673
+ }), t.register("unfocus", A.moduleName, (s, n) => {
2674
+ T(this.wnd), n(!0);
2914
2675
  }), t.register([
2915
2676
  "go_next",
2916
2677
  "go_prev"
2917
- ], M.moduleName, (n, s) => s(!1)), t.register("focus", M.moduleName, (n, s) => {
2678
+ ], A.moduleName, (s, n) => n(!1)), t.register("focus", A.moduleName, (s, n) => {
2918
2679
  const o = this.doc().scrollTop / this.doc().offsetHeight;
2919
- this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), s(!0);
2920
- }), t.register("first_visible_locator", M.moduleName, (n, s) => {
2921
- const o = Tt(e, !0);
2922
- this.comms.send("first_visible_locator", o.serialize()), s(!0);
2923
- }), t.log("ScrollSnapper Mounted"), this.createCustomElement(), this.createAnchorElements(), !0;
2680
+ this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
2681
+ }), t.register("first_visible_locator", A.moduleName, (s, n) => {
2682
+ const o = Ke(e, !0);
2683
+ this.comms.send("first_visible_locator", o.serialize()), n(!0);
2684
+ }), t.log("ScrollSnapper Mounted"), !0;
2924
2685
  }
2925
2686
  unmount(e, t) {
2926
- var r;
2927
- return t.unregisterAll(M.moduleName), this.removeAnchorElements(), (r = e.document.getElementById(Ze)) == null || r.remove(), t.log("ScrollSnapper Unmounted"), !0;
2687
+ var i;
2688
+ return t.unregisterAll(A.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), (i = e.document.getElementById(Le)) == null || i.remove(), t.log("ScrollSnapper Unmounted"), !0;
2928
2689
  }
2929
2690
  };
2930
- Ot.moduleName = "scroll_snapper";
2931
- let Fi = Ot;
2932
- class Pt extends de {
2691
+ Qe.moduleName = "scroll_snapper";
2692
+ let jt = Qe;
2693
+ class et extends Y {
2933
2694
  constructor() {
2934
2695
  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);
2935
2696
  }
2936
2697
  onPointUp(e) {
2937
- var n, s, o, a, h;
2698
+ var s, n, o, a, h;
2938
2699
  const t = this.wnd.getSelection();
2939
- if (t && ((n = t.toString()) == null ? void 0 : n.length) > 0) {
2940
- const c = (s = t.getRangeAt(0)) == null ? void 0 : s.getClientRects();
2700
+ if (t && ((s = t.toString()) == null ? void 0 : s.length) > 0) {
2701
+ const c = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
2941
2702
  if (!c || c.length === 0)
2942
2703
  return;
2943
- const u = c[0], p = {
2704
+ const d = c[0], p = {
2944
2705
  text: t.toString(),
2945
- x: u.x,
2946
- y: u.y,
2947
- width: u.width,
2948
- height: u.height,
2706
+ x: d.x,
2707
+ y: d.y,
2708
+ width: d.width,
2709
+ height: d.height,
2949
2710
  targetFrameSrc: (a = (o = this.wnd) == null ? void 0 : o.location) == null ? void 0 : a.href
2950
2711
  };
2951
2712
  this.comms.send("text_selected", p);
@@ -2956,14 +2717,14 @@ class Pt extends de {
2956
2717
  }
2957
2718
  if (!(t != null && t.isCollapsed) || !e.isPrimary)
2958
2719
  return;
2959
- const r = this.wnd.devicePixelRatio;
2720
+ const i = this.wnd.devicePixelRatio;
2960
2721
  e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
2961
2722
  defaultPrevented: e.defaultPrevented,
2962
- x: e.clientX * r,
2963
- y: e.clientY * r,
2723
+ x: e.clientX * i,
2724
+ y: e.clientY * i,
2964
2725
  targetFrameSrc: this.wnd.location.href,
2965
2726
  targetElement: e.target.outerHTML,
2966
- interactiveElement: (h = wt(e.target)) == null ? void 0 : h.outerHTML,
2727
+ interactiveElement: (h = Ye(e.target)) == null ? void 0 : h.outerHTML,
2967
2728
  cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
2968
2729
  }), this.pointerMoved = !1;
2969
2730
  }
@@ -2999,8 +2760,8 @@ class Pt extends de {
2999
2760
  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;
3000
2761
  }
3001
2762
  }
3002
- Pt.moduleName = "peripherals";
3003
- const At = class xe extends de {
2763
+ et.moduleName = "peripherals";
2764
+ const tt = class te extends Y {
3004
2765
  constructor() {
3005
2766
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
3006
2767
  }
@@ -3016,19 +2777,19 @@ const At = class xe extends de {
3016
2777
  unblock(e) {
3017
2778
  var t;
3018
2779
  for (e._readium_blockEvents = !1; ((t = e._readium_blockedEvents) == null ? void 0 : t.length) > 0; ) {
3019
- const r = e._readium_blockedEvents.shift();
3020
- switch (r[0]) {
2780
+ const i = e._readium_blockedEvents.shift();
2781
+ switch (i[0]) {
3021
2782
  case 0:
3022
- Reflect.apply(r[1], r[2], r[3]);
2783
+ Reflect.apply(i[1], i[2], i[3]);
3023
2784
  break;
3024
2785
  case 1:
3025
- const n = r[1], s = r[2];
3026
- e.removeEventListener(n.type, e._readium_eventBlocker, !0);
3027
- const o = new Event(n.type, {
3028
- bubbles: n.bubbles,
3029
- cancelable: n.cancelable
2786
+ const s = i[1], n = i[2];
2787
+ e.removeEventListener(s.type, e._readium_eventBlocker, !0);
2788
+ const o = new Event(s.type, {
2789
+ bubbles: s.bubbles,
2790
+ cancelable: s.cancelable
3030
2791
  });
3031
- s ? s.dispatchEvent(o) : e.dispatchEvent(o);
2792
+ n ? n.dispatchEvent(o) : e.dispatchEvent(o);
3032
2793
  break;
3033
2794
  }
3034
2795
  }
@@ -3043,8 +2804,8 @@ const At = class xe extends de {
3043
2804
  }
3044
2805
  pauseAllMedia(e) {
3045
2806
  const t = e.document.querySelectorAll("audio,video");
3046
- for (let r = 0; r < t.length; r++)
3047
- t[r].pause();
2807
+ for (let i = 0; i < t.length; i++)
2808
+ t[i].pause();
3048
2809
  }
3049
2810
  mount(e, t) {
3050
2811
  this.comms = t, e.addEventListener(
@@ -3054,9 +2815,9 @@ const At = class xe extends de {
3054
2815
  ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
3055
2816
  value: {
3056
2817
  name: "readium-ts-toolkit",
3057
- version: "1.3.3",
3058
- hasFeature: (n, s = "") => {
3059
- switch (n) {
2818
+ version: "2.0.0-beta.1",
2819
+ hasFeature: (s, n = "") => {
2820
+ switch (s) {
3060
2821
  case "dom-manipulation":
3061
2822
  return !0;
3062
2823
  case "layout-changes":
@@ -3077,69 +2838,73 @@ const At = class xe extends de {
3077
2838
  }
3078
2839
  },
3079
2840
  writable: !1
3080
- }), "getAnimations" in e.document && e.document.getAnimations().forEach((n) => {
3081
- n.cancel(), this.allAnimations.add(n);
3082
- }), t.register("activate", xe.moduleName, (n, s) => {
2841
+ }), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {
2842
+ s.cancel(), this.allAnimations.add(s);
2843
+ }), t.register("activate", te.moduleName, (s, n) => {
3083
2844
  this.allAnimations.forEach((o) => {
3084
2845
  o.cancel(), o.play();
3085
- }), s(!0);
3086
- }), t.register("unfocus", xe.moduleName, (n, s) => {
3087
- this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), s(!0);
2846
+ }), n(!0);
2847
+ }), t.register("unfocus", te.moduleName, (s, n) => {
2848
+ this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
3088
2849
  });
3089
- const r = e.document.querySelectorAll("audio,video");
3090
- for (let n = 0; n < r.length; n++) {
3091
- const s = r[n];
3092
- s.addEventListener("play", this.onMediaPlayEvent, {
2850
+ const i = e.document.querySelectorAll("audio,video");
2851
+ for (let s = 0; s < i.length; s++) {
2852
+ const n = i[s];
2853
+ n.addEventListener("play", this.onMediaPlayEvent, {
3093
2854
  passive: !0
3094
- }), s.addEventListener("pause", this.onMediaPauseEvent, {
2855
+ }), n.addEventListener("pause", this.onMediaPauseEvent, {
3095
2856
  passive: !0
3096
2857
  });
3097
2858
  }
3098
2859
  return t.log("Setup Mounted"), !0;
3099
2860
  }
3100
2861
  unmount(e, t) {
3101
- return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((r) => r.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;
2862
+ 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;
3102
2863
  }
3103
2864
  };
3104
- At.moduleName = "setup";
3105
- let Nt = At;
3106
- const Qe = "readium-viewport", Mt = class X extends Nt {
2865
+ tt.moduleName = "setup";
2866
+ let it = tt;
2867
+ const Re = "readium-viewport", rt = class F extends it {
3107
2868
  onViewportWidthChanged(e) {
3108
2869
  const t = e.target;
3109
- ye(t, "--RS__viewportWidth", `${t.innerWidth}px`);
2870
+ G(t, "--RS__viewportWidth", `${t.innerWidth}px`);
3110
2871
  }
3111
2872
  mount(e, t) {
3112
2873
  if (!super.mount(e, t))
3113
2874
  return !1;
3114
- const r = e.document.createElement("meta");
3115
- return r.dataset.readium = "true", r.setAttribute("name", "viewport"), r.setAttribute("id", Qe), r.setAttribute(
2875
+ const i = e.document.createElement("meta");
2876
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Re), i.setAttribute(
3116
2877
  "content",
3117
2878
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
3118
- ), e.document.head.appendChild(r), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
2879
+ ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3119
2880
  target: e
3120
- }), t.register("set_property", X.moduleName, (n, s) => {
3121
- const o = n;
3122
- ye(e, o[0], o[1]), s(!0);
3123
- }), t.register("remove_property", X.moduleName, (n, s) => {
3124
- vt(e, n), s(!0);
3125
- }), t.register("activate", X.moduleName, (n, s) => {
3126
- this.unblock(e), s(!0);
2881
+ }), t.register("get_properties", F.moduleName, (s, n) => {
2882
+ qe(e), n(!0);
2883
+ }), t.register("update_properties", F.moduleName, (s, n) => {
2884
+ s["--RS__viewportWidth"] = `${e.innerWidth}px`, Nt(e, s), n(!0);
2885
+ }), t.register("set_property", F.moduleName, (s, n) => {
2886
+ const o = s;
2887
+ G(e, o[0], o[1]), n(!0);
2888
+ }), t.register("remove_property", F.moduleName, (s, n) => {
2889
+ he(e, s), n(!0);
2890
+ }), t.register("activate", F.moduleName, (s, n) => {
2891
+ this.unblock(e), n(!0);
3127
2892
  }), t.log("ReflowableSetup Mounted"), !0;
3128
2893
  }
3129
2894
  unmount(e, t) {
3130
- var r;
3131
- return t.unregisterAll(X.moduleName), (r = e.document.head.querySelector(`#${Qe}`)) == null || r.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
2895
+ var i;
2896
+ 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);
3132
2897
  }
3133
2898
  };
3134
- Mt.moduleName = "reflowable_setup";
3135
- let ki = Mt;
3136
- const et = "readium-fixed-style", Rt = class I extends Nt {
2899
+ rt.moduleName = "reflowable_setup";
2900
+ let qt = rt;
2901
+ const ze = "readium-fixed-style", st = class L extends it {
3137
2902
  mount(e, t) {
3138
2903
  if (!super.mount(e, t))
3139
2904
  return !1;
3140
2905
  e.navigator.epubReadingSystem.layoutStyle = "paginated";
3141
- const r = e.document.createElement("style");
3142
- return r.id = et, r.dataset.readium = "true", r.textContent = `
2906
+ const i = e.document.createElement("style");
2907
+ return i.id = ze, i.dataset.readium = "true", i.textContent = `
3143
2908
  html, body {
3144
2909
  text-size-adjust: none;
3145
2910
  -ms-text-size-adjust: none;
@@ -3151,13 +2916,13 @@ const et = "readium-fixed-style", Rt = class I extends Nt {
3151
2916
  min-height: 100%;
3152
2917
 
3153
2918
  /*cursor: var() TODO*/
3154
- }`, e.document.head.appendChild(r), t.register("set_property", I.moduleName, (n, s) => {
3155
- const o = n;
3156
- ye(e, o[0], o[1]), s(!0);
3157
- }), t.register("remove_property", I.moduleName, (n, s) => {
3158
- vt(e, n), s(!0);
3159
- }), t.register("first_visible_locator", I.moduleName, (n, s) => s(!1)), t.register("unfocus", I.moduleName, (n, s) => {
3160
- T(e), s(!0);
2919
+ }`, e.document.head.appendChild(i), t.register("set_property", L.moduleName, (s, n) => {
2920
+ const o = s;
2921
+ G(e, o[0], o[1]), n(!0);
2922
+ }), t.register("remove_property", L.moduleName, (s, n) => {
2923
+ he(e, s), n(!0);
2924
+ }), t.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), t.register("unfocus", L.moduleName, (s, n) => {
2925
+ T(e), n(!0);
3161
2926
  }), t.register([
3162
2927
  "focus",
3163
2928
  "go_next",
@@ -3167,56 +2932,56 @@ const et = "readium-fixed-style", Rt = class I extends Nt {
3167
2932
  "go_start",
3168
2933
  "go_text",
3169
2934
  "go_progression"
3170
- ], I.moduleName, (n, s) => s(!0)), t.register("activate", I.moduleName, (n, s) => {
3171
- this.unblock(e), s(!0);
2935
+ ], L.moduleName, (s, n) => n(!0)), t.register("activate", L.moduleName, (s, n) => {
2936
+ this.unblock(e), n(!0);
3172
2937
  }), t.log("FixedSetup Mounted"), !0;
3173
2938
  }
3174
2939
  unmount(e, t) {
3175
- var r;
3176
- return t.unregisterAll(I.moduleName), (r = e.document.getElementById(et)) == null || r.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
2940
+ var i;
2941
+ return t.unregisterAll(L.moduleName), (i = e.document.getElementById(ze)) == null || i.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
3177
2942
  }
3178
2943
  };
3179
- Rt.moduleName = "fixed_setup";
3180
- let Ui = Rt;
3181
- const Hi = [
2944
+ st.moduleName = "fixed_setup";
2945
+ let Vt = st;
2946
+ const _t = [
3182
2947
  "fixed_setup",
3183
2948
  "decorator",
3184
2949
  "peripherals"
3185
- ], $i = [
2950
+ ], Xt = [
3186
2951
  "reflowable_setup",
3187
2952
  "decorator",
3188
2953
  "peripherals",
3189
2954
  "column_snapper",
3190
2955
  "scroll_snapper"
3191
- ], tt = new Map([
2956
+ ], De = new Map([
3192
2957
  // All modules go here
3193
- Ui,
3194
- ki,
3195
- Pt,
3196
- Oi,
3197
- zi,
3198
- Fi
3199
- ].map((i) => [i.moduleName, i]));
3200
- class Vi {
2958
+ Vt,
2959
+ qt,
2960
+ et,
2961
+ Dt,
2962
+ $t,
2963
+ jt
2964
+ ].map((r) => [r.moduleName, r]));
2965
+ class Gt {
3201
2966
  /**
3202
2967
  * @param wnd Window instance to operate on
3203
2968
  * @param initialModules List of initial modules to load
3204
2969
  */
3205
2970
  constructor(e = window, t = []) {
3206
- this.loadedModules = [], this.wnd = e, this.comms = new zt(e);
3207
- const r = [...new Set(t)];
3208
- if (r.length) {
2971
+ this.loadedModules = [], this.wnd = e, this.comms = new at(e);
2972
+ const i = [...new Set(t)];
2973
+ if (i.length) {
3209
2974
  if (typeof e > "u")
3210
2975
  throw Error("Loader is not in a web browser");
3211
- e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = r.map((n) => {
3212
- const s = this.loadModule(n);
3213
- if (s)
3214
- return s.mount(this.wnd, this.comms), s;
3215
- }).filter((n) => n !== void 0);
2976
+ e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
2977
+ const n = this.loadModule(s);
2978
+ if (n)
2979
+ return n.mount(this.wnd, this.comms), n;
2980
+ }).filter((s) => s !== void 0);
3216
2981
  }
3217
2982
  }
3218
2983
  loadModule(e) {
3219
- const t = tt.get(e);
2984
+ const t = De.get(e);
3220
2985
  return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
3221
2986
  }
3222
2987
  /**
@@ -3234,11 +2999,11 @@ class Vi {
3234
2999
  * @returns Success
3235
3000
  */
3236
3001
  removeModule(e) {
3237
- const t = tt.get(e);
3002
+ const t = De.get(e);
3238
3003
  if (t === void 0)
3239
3004
  return this.comms.log(`Module "${e}" does not exist in the library`), !1;
3240
- const r = this.loadedModules.findIndex((n) => n instanceof t);
3241
- return r < 0 ? !1 : (this.loadedModules[r].unmount(this.wnd, this.comms), this.loadedModules.splice(r, 1), !0);
3005
+ const i = this.loadedModules.findIndex((s) => s instanceof t);
3006
+ return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
3242
3007
  }
3243
3008
  /**
3244
3009
  * Unmount and remove all modules
@@ -3248,16 +3013,16 @@ class Vi {
3248
3013
  }
3249
3014
  }
3250
3015
  export {
3251
- j as COMMS_VERSION,
3252
- zt as Comms,
3253
- Oi as Decorator,
3254
- Hi as FXLModules,
3255
- Ti as Layout,
3256
- Vi as Loader,
3257
- de as Module,
3258
- tt as ModuleLibrary,
3259
- Pt as Peripherals,
3260
- $i as ReflowableModules,
3261
- wi as Width,
3262
- It as mid
3016
+ k as COMMS_VERSION,
3017
+ at as Comms,
3018
+ Dt as Decorator,
3019
+ _t as FXLModules,
3020
+ Lt as Layout,
3021
+ Gt as Loader,
3022
+ Y as Module,
3023
+ De as ModuleLibrary,
3024
+ et as Peripherals,
3025
+ Xt as ReflowableModules,
3026
+ It as Width,
3027
+ ot as mid
3263
3028
  };