@readium/navigator-html-injectables 1.3.2 → 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 +853 -1032
- package/dist/index.umd.cjs +8 -8
- package/package.json +7 -8
- package/src/comms/keys.ts +2 -0
- package/src/helpers/color.ts +114 -0
- package/src/helpers/css.ts +37 -0
- package/src/helpers/document.ts +42 -21
- package/src/helpers/dom.ts +30 -3
- package/src/modules/Decorator.ts +3 -5
- package/src/modules/Peripherals.ts +1 -1
- package/src/modules/setup/ReflowableSetup.ts +12 -1
- package/src/modules/snapper/ColumnSnapper.ts +35 -9
- package/src/modules/snapper/ScrollSnapper.ts +24 -17
- package/types/src/comms/keys.d.ts +1 -1
- package/types/src/helpers/color.d.ts +16 -0
- package/types/src/helpers/css.d.ts +6 -0
- package/types/src/helpers/document.d.ts +11 -2
- package/types/src/modules/snapper/ScrollSnapper.d.ts +3 -3
- package/src/helpers/scrollSnapperHelper.ts +0 -43
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
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 Nt {
|
|
|
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 !==
|
|
16
|
-
t._readium >
|
|
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((
|
|
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 Nt {
|
|
|
33
33
|
e.strict && this.send("_unhandled", e);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
t.forEach((
|
|
36
|
+
t.forEach((i) => i.cb(e.data, (s) => {
|
|
37
37
|
this.send("_ack", s, e.id);
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
register(e, t,
|
|
40
|
+
register(e, t, i) {
|
|
41
41
|
Array.isArray(e) || (e = [e]), e.forEach((s) => {
|
|
42
42
|
const n = this.registrar.get(s);
|
|
43
43
|
if (n && n.length >= 0) {
|
|
44
44
|
if (n.find((a) => a.module === t))
|
|
45
45
|
throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);
|
|
46
46
|
n.push({
|
|
47
|
-
cb:
|
|
47
|
+
cb: i,
|
|
48
48
|
module: t
|
|
49
49
|
}), this.registrar.set(s, n);
|
|
50
50
|
} else
|
|
51
51
|
this.registrar.set(s, [{
|
|
52
|
-
cb:
|
|
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((
|
|
59
|
-
const s = this.registrar.get(
|
|
58
|
+
Array.isArray(e) || (e = [e]), e.forEach((i) => {
|
|
59
|
+
const s = this.registrar.get(i);
|
|
60
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,
|
|
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,13 +72,13 @@ class Nt {
|
|
|
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,
|
|
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
78
|
const n = {
|
|
79
|
-
_readium:
|
|
79
|
+
_readium: k,
|
|
80
80
|
_channel: this.channelId,
|
|
81
|
-
id:
|
|
81
|
+
id: i ?? ot(),
|
|
82
82
|
// scrict,
|
|
83
83
|
key: e,
|
|
84
84
|
data: t
|
|
@@ -95,7 +95,7 @@ class Nt {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
class
|
|
98
|
+
class ie {
|
|
99
99
|
/**
|
|
100
100
|
* Creates a [Encryption].
|
|
101
101
|
*/
|
|
@@ -107,7 +107,7 @@ class Ee {
|
|
|
107
107
|
*/
|
|
108
108
|
static deserialize(e) {
|
|
109
109
|
if (e && e.algorithm)
|
|
110
|
-
return new
|
|
110
|
+
return new ie({
|
|
111
111
|
algorithm: e.algorithm,
|
|
112
112
|
compression: e.compression,
|
|
113
113
|
originalLength: e.originalLength,
|
|
@@ -123,7 +123,7 @@ class Ee {
|
|
|
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
|
|
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
|
|
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
|
|
149
|
-
t[
|
|
150
|
-
return new
|
|
148
|
+
for (const i in e)
|
|
149
|
+
t[i] = e[i];
|
|
150
|
+
return new E(t);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
Object.defineProperty(
|
|
153
|
+
Object.defineProperty(E.prototype, "encryption", {
|
|
154
154
|
get: function() {
|
|
155
|
-
return
|
|
155
|
+
return ie.deserialize(this.otherProperties.encrypted);
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
E.prototype.getContains = function() {
|
|
159
159
|
return new Set(this.otherProperties.contains || []);
|
|
160
160
|
};
|
|
161
|
-
|
|
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,
|
|
167
|
+
let t, i, s = e.mediaType.replace(/\s/g, "").split(";");
|
|
168
168
|
const n = s[0].split("/");
|
|
169
169
|
if (n.length === 2) {
|
|
170
|
-
if (t = n[0].toLowerCase().trim(),
|
|
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
|
|
176
|
-
const f = s[
|
|
175
|
+
for (let u = 1; u < s.length; u++) {
|
|
176
|
+
const f = s[u].split("=");
|
|
177
177
|
if (f.length === 2) {
|
|
178
|
-
const
|
|
179
|
-
o[
|
|
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((
|
|
183
|
+
h.sort((u, f) => u.localeCompare(f)), h.forEach((u) => a[u] = o[u]);
|
|
184
184
|
let c = "";
|
|
185
|
-
for (const
|
|
186
|
-
const f = a[
|
|
187
|
-
c += `;${
|
|
185
|
+
for (const u in a) {
|
|
186
|
+
const f = a[u];
|
|
187
|
+
c += `;${u}=${f}`;
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
this.string =
|
|
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,12 +223,12 @@ 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
|
|
226
|
+
const i = new Set(
|
|
227
227
|
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
228
228
|
), s = new Set(
|
|
229
229
|
Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
|
|
230
230
|
);
|
|
231
|
-
for (const n of Array.from(
|
|
231
|
+
for (const n of Array.from(i.values()))
|
|
232
232
|
if (!s.has(n))
|
|
233
233
|
return !1;
|
|
234
234
|
return !0;
|
|
@@ -616,7 +616,7 @@ class l {
|
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
class
|
|
619
|
+
class ye {
|
|
620
620
|
constructor(e) {
|
|
621
621
|
this.uri = e, this.parameters = this.getParameters(e);
|
|
622
622
|
}
|
|
@@ -624,9 +624,9 @@ class Me {
|
|
|
624
624
|
* List of URI template parameter keys, if the [Link] is templated.
|
|
625
625
|
*/
|
|
626
626
|
getParameters(e) {
|
|
627
|
-
const t = /\{\??([^}]+)\}/g,
|
|
628
|
-
return
|
|
629
|
-
|
|
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.
|
|
@@ -637,33 +637,33 @@ class Me {
|
|
|
637
637
|
const t = (s) => s.split(",").map((n) => {
|
|
638
638
|
const o = e[n];
|
|
639
639
|
return o ? encodeURIComponent(o) : "";
|
|
640
|
-
}).join(","),
|
|
640
|
+
}).join(","), i = (s) => "?" + s.split(",").map((n) => {
|
|
641
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, (...s) => s[1] ?
|
|
644
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
function
|
|
648
|
-
return
|
|
647
|
+
function lt(r) {
|
|
648
|
+
return r && r instanceof Array ? r : void 0;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
return
|
|
650
|
+
function We(r) {
|
|
651
|
+
return r && typeof r == "string" ? [r] : lt(r);
|
|
652
652
|
}
|
|
653
|
-
function
|
|
654
|
-
return typeof
|
|
653
|
+
function ve(r) {
|
|
654
|
+
return typeof r == "string" ? new Date(r) : void 0;
|
|
655
655
|
}
|
|
656
|
-
function
|
|
657
|
-
return isNaN(
|
|
656
|
+
function j(r) {
|
|
657
|
+
return isNaN(r) ? void 0 : r;
|
|
658
658
|
}
|
|
659
|
-
function
|
|
660
|
-
return
|
|
659
|
+
function C(r) {
|
|
660
|
+
return j(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function ht(r) {
|
|
663
663
|
const e = new Array();
|
|
664
|
-
return
|
|
664
|
+
return r.forEach((t) => e.push(t)), e;
|
|
665
665
|
}
|
|
666
|
-
class
|
|
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 =
|
|
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",
|
|
@@ -685,10 +685,10 @@ class w {
|
|
|
685
685
|
]);
|
|
686
686
|
return Object.entries(e).forEach(([a, h]) => {
|
|
687
687
|
o.has(a) || n.set(a, h);
|
|
688
|
-
}), new
|
|
689
|
-
fragments:
|
|
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:
|
|
691
|
+
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
692
692
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
693
693
|
otherLocations: n.size === 0 ? void 0 : n
|
|
694
694
|
});
|
|
@@ -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,
|
|
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 q {
|
|
|
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 q {
|
|
|
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
|
|
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
|
|
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
|
|
742
|
+
return new D({
|
|
743
743
|
href: e.href,
|
|
744
744
|
type: e.type,
|
|
745
745
|
title: e.title,
|
|
746
|
-
locations:
|
|
747
|
-
text:
|
|
746
|
+
locations: x.deserialize(e.locations),
|
|
747
|
+
text: U.deserialize(e.text)
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
@@ -758,16 +758,16 @@ class I {
|
|
|
758
758
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
759
759
|
*/
|
|
760
760
|
copyWithLocations(e) {
|
|
761
|
-
return new
|
|
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
|
|
766
|
+
locations: new x({ ...this.locations, ...e })
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
class
|
|
770
|
+
class B {
|
|
771
771
|
/**
|
|
772
772
|
* Creates a [Link].
|
|
773
773
|
*/
|
|
@@ -779,20 +779,20 @@ class H {
|
|
|
779
779
|
*/
|
|
780
780
|
static deserialize(e) {
|
|
781
781
|
if (e && e.href && typeof e.href == "string")
|
|
782
|
-
return new
|
|
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:
|
|
789
|
-
height:
|
|
790
|
-
width:
|
|
791
|
-
duration:
|
|
792
|
-
bitrate:
|
|
793
|
-
languages:
|
|
794
|
-
alternates:
|
|
795
|
-
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 H {
|
|
|
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 =
|
|
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 H {
|
|
|
813
813
|
const t = this.href.replace(/^(\/)/, "");
|
|
814
814
|
if (t.length === 0)
|
|
815
815
|
return;
|
|
816
|
-
let
|
|
817
|
-
return
|
|
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
|
|
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
|
|
828
|
-
href: new
|
|
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 H {
|
|
|
834
834
|
*/
|
|
835
835
|
addProperties(e) {
|
|
836
836
|
var t;
|
|
837
|
-
const
|
|
838
|
-
return
|
|
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
|
|
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
|
|
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
|
|
855
|
+
class q {
|
|
856
856
|
/**
|
|
857
857
|
* Creates a [Links].
|
|
858
858
|
*/
|
|
@@ -864,8 +864,8 @@ class ne {
|
|
|
864
864
|
*/
|
|
865
865
|
static deserialize(e) {
|
|
866
866
|
if (e && e instanceof Array)
|
|
867
|
-
return new
|
|
868
|
-
e.map((t) =>
|
|
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 ne {
|
|
|
876
876
|
}
|
|
877
877
|
/** Finds the first link with the given relation. */
|
|
878
878
|
findWithRel(e) {
|
|
879
|
-
const t = (
|
|
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 = (
|
|
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 = (
|
|
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 = (
|
|
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 = (
|
|
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 = (
|
|
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 = (
|
|
909
|
+
const t = (i) => {
|
|
910
910
|
for (const s of e)
|
|
911
|
-
if (
|
|
911
|
+
if (i.mediaType.matches(s))
|
|
912
912
|
return !0;
|
|
913
913
|
return !1;
|
|
914
914
|
};
|
|
@@ -937,8 +937,8 @@ class ne {
|
|
|
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
|
|
941
|
-
return t.mediaType.matches(
|
|
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 ne {
|
|
|
946
946
|
return this.items.filter((e) => e.type);
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
class
|
|
949
|
+
class V {
|
|
950
950
|
/**
|
|
951
951
|
* Creates a [DomRange].
|
|
952
952
|
*/
|
|
@@ -959,14 +959,14 @@ class oe {
|
|
|
959
959
|
static deserialize(e) {
|
|
960
960
|
if (!(e && e.cssSelector))
|
|
961
961
|
return;
|
|
962
|
-
let t =
|
|
962
|
+
let t = C(e.textNodeIndex);
|
|
963
963
|
if (t === void 0)
|
|
964
964
|
return;
|
|
965
|
-
let
|
|
966
|
-
return
|
|
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:
|
|
969
|
+
charOffset: i
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
@@ -980,7 +980,7 @@ class oe {
|
|
|
980
980
|
return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
class
|
|
983
|
+
class re {
|
|
984
984
|
/**
|
|
985
985
|
* Creates a [DomRange].
|
|
986
986
|
*/
|
|
@@ -993,11 +993,11 @@ class xe {
|
|
|
993
993
|
static deserialize(e) {
|
|
994
994
|
if (!e)
|
|
995
995
|
return;
|
|
996
|
-
let t =
|
|
996
|
+
let t = V.deserialize(e.start);
|
|
997
997
|
if (t)
|
|
998
|
-
return new
|
|
998
|
+
return new re({
|
|
999
999
|
start: t,
|
|
1000
|
-
end:
|
|
1000
|
+
end: V.deserialize(e.end)
|
|
1001
1001
|
});
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
@@ -1008,55 +1008,55 @@ class xe {
|
|
|
1008
1008
|
return this.end && (e.end = this.end.serialize()), e;
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
|
-
|
|
1012
|
-
var
|
|
1013
|
-
return (
|
|
1011
|
+
x.prototype.getCssSelector = function() {
|
|
1012
|
+
var r;
|
|
1013
|
+
return (r = this.otherLocations) == null ? void 0 : r.get("cssSelector");
|
|
1014
1014
|
};
|
|
1015
|
-
|
|
1016
|
-
var
|
|
1017
|
-
return (
|
|
1015
|
+
x.prototype.getPartialCfi = function() {
|
|
1016
|
+
var r;
|
|
1017
|
+
return (r = this.otherLocations) == null ? void 0 : r.get("partialCfi");
|
|
1018
1018
|
};
|
|
1019
|
-
|
|
1020
|
-
var
|
|
1021
|
-
return
|
|
1019
|
+
x.prototype.getDomRange = function() {
|
|
1020
|
+
var r;
|
|
1021
|
+
return re.deserialize((r = this.otherLocations) == null ? void 0 : r.get("domRange"));
|
|
1022
1022
|
};
|
|
1023
|
-
|
|
1023
|
+
x.prototype.fragmentParameters = function() {
|
|
1024
1024
|
return new Map(
|
|
1025
|
-
this.fragments.map((
|
|
1026
|
-
|
|
1027
|
-
|
|
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
|
-
|
|
1031
|
+
x.prototype.htmlId = function() {
|
|
1032
1032
|
if (!this.fragments.length)
|
|
1033
1033
|
return;
|
|
1034
|
-
let
|
|
1035
|
-
if (!
|
|
1034
|
+
let r = this.fragments.find((e) => e.length && !e.includes("="));
|
|
1035
|
+
if (!r) {
|
|
1036
1036
|
const e = this.fragmentParameters();
|
|
1037
|
-
e.has("id") ?
|
|
1037
|
+
e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));
|
|
1038
1038
|
}
|
|
1039
|
-
return
|
|
1039
|
+
return r != null && r.startsWith("#") ? r.slice(1) : r;
|
|
1040
1040
|
};
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
if (!isNaN(
|
|
1044
|
-
return
|
|
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
|
-
|
|
1047
|
-
const
|
|
1048
|
-
if (!isNaN(
|
|
1049
|
-
return
|
|
1046
|
+
x.prototype.time = function() {
|
|
1047
|
+
const r = parseInt(this.fragmentParameters().get("t"));
|
|
1048
|
+
if (!isNaN(r))
|
|
1049
|
+
return r;
|
|
1050
1050
|
};
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
if (!
|
|
1051
|
+
x.prototype.space = function() {
|
|
1052
|
+
const r = this.fragmentParameters();
|
|
1053
|
+
if (!r.has("xywh"))
|
|
1054
1054
|
return;
|
|
1055
|
-
const e =
|
|
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
|
|
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 we {
|
|
|
1070
1070
|
let t = e.currency;
|
|
1071
1071
|
if (!(t && typeof t == "string" && t.length > 0))
|
|
1072
1072
|
return;
|
|
1073
|
-
let
|
|
1074
|
-
if (
|
|
1075
|
-
return new
|
|
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 we {
|
|
|
1081
1081
|
return { currency: this.currency, value: this.value };
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
|
-
class
|
|
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 j {
|
|
|
1091
1091
|
*/
|
|
1092
1092
|
static deserialize(e) {
|
|
1093
1093
|
if (e && e.type)
|
|
1094
|
-
return new
|
|
1094
|
+
return new H({
|
|
1095
1095
|
type: e.type,
|
|
1096
|
-
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) =>
|
|
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 j {
|
|
|
1108
1108
|
return this.children && (e.children = this.children.map((t) => t.serialize())), e;
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
class
|
|
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 Te {
|
|
|
1118
1118
|
*/
|
|
1119
1119
|
static deserialize(e) {
|
|
1120
1120
|
if (e)
|
|
1121
|
-
return new
|
|
1122
|
-
total:
|
|
1123
|
-
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 Te {
|
|
|
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
|
|
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 Se {
|
|
|
1141
1141
|
*/
|
|
1142
1142
|
static deserialize(e) {
|
|
1143
1143
|
if (e)
|
|
1144
|
-
return new
|
|
1145
|
-
total:
|
|
1146
|
-
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 Se {
|
|
|
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
|
|
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 Ce {
|
|
|
1164
1164
|
*/
|
|
1165
1165
|
static deserialize(e) {
|
|
1166
1166
|
if (e && e.state)
|
|
1167
|
-
return new
|
|
1167
|
+
return new ae({
|
|
1168
1168
|
state: e.state,
|
|
1169
|
-
since:
|
|
1170
|
-
until:
|
|
1169
|
+
since: ve(e.since),
|
|
1170
|
+
until: ve(e.until)
|
|
1171
1171
|
});
|
|
1172
1172
|
}
|
|
1173
1173
|
/**
|
|
@@ -1178,175 +1178,220 @@ class Ce {
|
|
|
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
|
-
|
|
1182
|
-
return
|
|
1181
|
+
E.prototype.getNumberOfItems = function() {
|
|
1182
|
+
return C(this.otherProperties.numberOfItems);
|
|
1183
1183
|
};
|
|
1184
|
-
|
|
1185
|
-
return
|
|
1184
|
+
E.prototype.getPrice = function() {
|
|
1185
|
+
return se.deserialize(this.otherProperties.price);
|
|
1186
1186
|
};
|
|
1187
|
-
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1190
|
-
return
|
|
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
|
-
|
|
1193
|
-
return
|
|
1192
|
+
E.prototype.getHolds = function() {
|
|
1193
|
+
return ne.deserialize(this.otherProperties.holds);
|
|
1194
1194
|
};
|
|
1195
|
-
|
|
1196
|
-
return
|
|
1195
|
+
E.prototype.getCopies = function() {
|
|
1196
|
+
return oe.deserialize(this.otherProperties.copies);
|
|
1197
1197
|
};
|
|
1198
|
-
|
|
1199
|
-
return
|
|
1198
|
+
E.prototype.getAvailability = function() {
|
|
1199
|
+
return ae.deserialize(this.otherProperties.availability);
|
|
1200
1200
|
};
|
|
1201
|
-
|
|
1202
|
-
return
|
|
1201
|
+
E.prototype.getAuthenticate = function() {
|
|
1202
|
+
return B.deserialize(this.otherProperties.authenticate);
|
|
1203
1203
|
};
|
|
1204
|
-
|
|
1204
|
+
E.prototype.getClipped = function() {
|
|
1205
1205
|
return this.otherProperties.clipped;
|
|
1206
1206
|
};
|
|
1207
|
-
|
|
1207
|
+
E.prototype.getFit = function() {
|
|
1208
1208
|
return this.otherProperties.fit;
|
|
1209
1209
|
};
|
|
1210
|
-
|
|
1210
|
+
E.prototype.getOrientation = function() {
|
|
1211
1211
|
return this.otherProperties.orientation;
|
|
1212
1212
|
};
|
|
1213
|
-
|
|
1213
|
+
E.prototype.getOverflow = function() {
|
|
1214
1214
|
return this.otherProperties.overflow;
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1216
|
+
E.prototype.getPage = function() {
|
|
1217
1217
|
return this.otherProperties.page || void 0;
|
|
1218
1218
|
};
|
|
1219
|
-
|
|
1219
|
+
E.prototype.getSpread = function() {
|
|
1220
1220
|
return this.otherProperties.spread || void 0;
|
|
1221
1221
|
};
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
function
|
|
1228
|
-
|
|
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
|
+
if (typeof t == "function")
|
|
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
|
+
};
|
|
1250
|
+
if (typeof t == "string") {
|
|
1251
|
+
const i = new RegExp("^" + ut(t) + "$");
|
|
1252
|
+
return (s) => i.test(s);
|
|
1253
|
+
}
|
|
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
|
+
});
|
|
1256
|
+
return (t) => e.some((i) => i(t));
|
|
1257
|
+
}
|
|
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
|
+
"class",
|
|
1263
|
+
"id",
|
|
1264
|
+
// Angular attributes
|
|
1265
|
+
"ng-*"
|
|
1266
|
+
]);
|
|
1267
|
+
class Y {
|
|
1268
|
+
}
|
|
1269
|
+
function be(r) {
|
|
1270
|
+
return r.split("").reverse().join("");
|
|
1271
|
+
}
|
|
1272
|
+
function yt(r, e, t) {
|
|
1273
|
+
const i = be(e);
|
|
1229
1274
|
return t.map((s) => {
|
|
1230
|
-
const n = Math.max(0, s.end - e.length - s.errors), o =
|
|
1275
|
+
const n = Math.max(0, s.end - e.length - s.errors), o = be(r.slice(n, s.end));
|
|
1231
1276
|
return {
|
|
1232
|
-
start:
|
|
1277
|
+
start: Fe(o, i, s.errors).reduce((h, c) => s.end - c.end < h ? s.end - c.end : h, s.end),
|
|
1233
1278
|
end: s.end,
|
|
1234
1279
|
errors: s.errors
|
|
1235
1280
|
};
|
|
1236
1281
|
});
|
|
1237
1282
|
}
|
|
1238
|
-
function
|
|
1239
|
-
return (
|
|
1283
|
+
function Z(r) {
|
|
1284
|
+
return (r | -r) >> 31 & 1;
|
|
1240
1285
|
}
|
|
1241
|
-
function
|
|
1242
|
-
let s =
|
|
1243
|
-
const o =
|
|
1244
|
-
let
|
|
1245
|
-
const
|
|
1246
|
-
return
|
|
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;
|
|
1247
1292
|
}
|
|
1248
|
-
function
|
|
1293
|
+
function Fe(r, e, t) {
|
|
1249
1294
|
if (e.length === 0)
|
|
1250
1295
|
return [];
|
|
1251
1296
|
t = Math.min(t, e.length);
|
|
1252
|
-
const
|
|
1297
|
+
const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {
|
|
1253
1298
|
P: new Uint32Array(n + 1),
|
|
1254
1299
|
M: new Uint32Array(n + 1),
|
|
1255
1300
|
lastRowMask: new Uint32Array(n + 1)
|
|
1256
1301
|
};
|
|
1257
1302
|
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
|
|
1258
1303
|
const a = new Uint32Array(n + 1), h = /* @__PURE__ */ new Map(), c = [];
|
|
1259
|
-
for (let
|
|
1304
|
+
for (let u = 0; u < 256; u++)
|
|
1260
1305
|
c.push(a);
|
|
1261
|
-
for (let
|
|
1262
|
-
const f = e.charCodeAt(
|
|
1306
|
+
for (let u = 0; u < e.length; u += 1) {
|
|
1307
|
+
const f = e.charCodeAt(u);
|
|
1263
1308
|
if (h.has(f))
|
|
1264
1309
|
continue;
|
|
1265
|
-
const
|
|
1266
|
-
h.set(f,
|
|
1267
|
-
for (let
|
|
1268
|
-
|
|
1269
|
-
for (let
|
|
1270
|
-
const
|
|
1271
|
-
if (
|
|
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)
|
|
1272
1317
|
continue;
|
|
1273
|
-
e.charCodeAt(
|
|
1318
|
+
e.charCodeAt(S) === f && (g[m] |= 1 << v);
|
|
1274
1319
|
}
|
|
1275
1320
|
}
|
|
1276
1321
|
}
|
|
1277
|
-
let
|
|
1322
|
+
let d = Math.max(0, Math.ceil(t / s) - 1);
|
|
1278
1323
|
const p = new Uint32Array(n + 1);
|
|
1279
|
-
for (let
|
|
1280
|
-
p[
|
|
1324
|
+
for (let u = 0; u <= d; u += 1)
|
|
1325
|
+
p[u] = (u + 1) * s;
|
|
1281
1326
|
p[n] = e.length;
|
|
1282
|
-
for (let
|
|
1283
|
-
o.P[
|
|
1284
|
-
for (let
|
|
1285
|
-
const f =
|
|
1286
|
-
let
|
|
1287
|
-
f < c.length ?
|
|
1288
|
-
let
|
|
1289
|
-
for (let
|
|
1290
|
-
|
|
1291
|
-
if (p[
|
|
1292
|
-
|
|
1293
|
-
let
|
|
1294
|
-
if (
|
|
1295
|
-
const
|
|
1296
|
-
|
|
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;
|
|
1297
1342
|
} else
|
|
1298
|
-
|
|
1299
|
-
p[
|
|
1343
|
+
v = s;
|
|
1344
|
+
p[d] = p[d - 1] + v - m + xe(o, g, d, m);
|
|
1300
1345
|
} else
|
|
1301
|
-
for (;
|
|
1302
|
-
|
|
1303
|
-
|
|
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({
|
|
1304
1349
|
start: -1,
|
|
1305
|
-
end:
|
|
1306
|
-
errors: p[
|
|
1307
|
-
}), t = p[
|
|
1350
|
+
end: u + 1,
|
|
1351
|
+
errors: p[d]
|
|
1352
|
+
}), t = p[d]);
|
|
1308
1353
|
}
|
|
1309
|
-
return
|
|
1354
|
+
return i;
|
|
1310
1355
|
}
|
|
1311
|
-
function
|
|
1312
|
-
const
|
|
1313
|
-
return
|
|
1356
|
+
function vt(r, e, t) {
|
|
1357
|
+
const i = Fe(r, e, t);
|
|
1358
|
+
return yt(r, e, i);
|
|
1314
1359
|
}
|
|
1315
|
-
function
|
|
1316
|
-
let
|
|
1360
|
+
function Be(r, e, t) {
|
|
1361
|
+
let i = 0;
|
|
1317
1362
|
const s = [];
|
|
1318
|
-
for (;
|
|
1319
|
-
|
|
1320
|
-
start:
|
|
1321
|
-
end:
|
|
1363
|
+
for (; i !== -1; )
|
|
1364
|
+
i = r.indexOf(e, i), i !== -1 && (s.push({
|
|
1365
|
+
start: i,
|
|
1366
|
+
end: i + e.length,
|
|
1322
1367
|
errors: 0
|
|
1323
|
-
}),
|
|
1324
|
-
return s.length > 0 ? s :
|
|
1368
|
+
}), i += 1);
|
|
1369
|
+
return s.length > 0 ? s : vt(r, e, t);
|
|
1325
1370
|
}
|
|
1326
|
-
function
|
|
1327
|
-
return e.length === 0 ||
|
|
1371
|
+
function Se(r, e) {
|
|
1372
|
+
return e.length === 0 || r.length === 0 ? 0 : 1 - Be(r, e, e.length)[0].errors / e.length;
|
|
1328
1373
|
}
|
|
1329
|
-
function
|
|
1374
|
+
function Et(r, e, t = {}) {
|
|
1330
1375
|
if (e.length === 0)
|
|
1331
1376
|
return null;
|
|
1332
|
-
const
|
|
1377
|
+
const i = Math.min(256, e.length / 2), s = Be(r, e, i);
|
|
1333
1378
|
if (s.length === 0)
|
|
1334
1379
|
return null;
|
|
1335
1380
|
const n = (a) => {
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1381
|
+
const u = 1 - a.errors / e.length, f = t.prefix ? Se(
|
|
1382
|
+
r.slice(
|
|
1338
1383
|
Math.max(0, a.start - t.prefix.length),
|
|
1339
1384
|
a.start
|
|
1340
1385
|
),
|
|
1341
1386
|
t.prefix
|
|
1342
|
-
) : 1,
|
|
1343
|
-
|
|
1387
|
+
) : 1, g = t.suffix ? Se(
|
|
1388
|
+
r.slice(a.end, a.end + t.suffix.length),
|
|
1344
1389
|
t.suffix
|
|
1345
1390
|
) : 1;
|
|
1346
|
-
let
|
|
1347
|
-
typeof t.hint == "number" && (
|
|
1348
|
-
const
|
|
1349
|
-
return
|
|
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;
|
|
1350
1395
|
}, o = s.map((a) => ({
|
|
1351
1396
|
start: a.start,
|
|
1352
1397
|
end: a.end,
|
|
@@ -1354,30 +1399,30 @@ function Bt(i, e, t = {}) {
|
|
|
1354
1399
|
}));
|
|
1355
1400
|
return o.sort((a, h) => h.score - a.score), o[0];
|
|
1356
1401
|
}
|
|
1357
|
-
function
|
|
1358
|
-
const
|
|
1359
|
-
if (
|
|
1402
|
+
function J(r, e, t) {
|
|
1403
|
+
const i = t === 1 ? e : e - 1;
|
|
1404
|
+
if (r.charAt(i).trim() !== "")
|
|
1360
1405
|
return e;
|
|
1361
1406
|
let s, n;
|
|
1362
|
-
if (t === 2 ? (s =
|
|
1407
|
+
if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)
|
|
1363
1408
|
return -1;
|
|
1364
1409
|
const o = s.length - n.length;
|
|
1365
1410
|
return t === 2 ? e - o : e + o;
|
|
1366
1411
|
}
|
|
1367
|
-
function
|
|
1368
|
-
const t =
|
|
1369
|
-
|
|
1412
|
+
function Te(r, e) {
|
|
1413
|
+
const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1414
|
+
r.commonAncestorContainer,
|
|
1370
1415
|
NodeFilter.SHOW_TEXT
|
|
1371
|
-
),
|
|
1416
|
+
), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;
|
|
1372
1417
|
let n = t.nextNode();
|
|
1373
|
-
for (; n && n !==
|
|
1418
|
+
for (; n && n !== i; )
|
|
1374
1419
|
n = t.nextNode();
|
|
1375
1420
|
e === 2 && (n = t.previousNode());
|
|
1376
1421
|
let o = -1;
|
|
1377
1422
|
const a = () => {
|
|
1378
1423
|
if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
|
|
1379
1424
|
const h = n.textContent, c = e === 1 ? 0 : h.length;
|
|
1380
|
-
o =
|
|
1425
|
+
o = J(h, c, e);
|
|
1381
1426
|
}
|
|
1382
1427
|
};
|
|
1383
1428
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1386,41 +1431,41 @@ function Ie(i, e) {
|
|
|
1386
1431
|
return { node: n, offset: o };
|
|
1387
1432
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1388
1433
|
}
|
|
1389
|
-
function
|
|
1390
|
-
if (!
|
|
1434
|
+
function bt(r) {
|
|
1435
|
+
if (!r.toString().trim().length)
|
|
1391
1436
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1392
|
-
if (
|
|
1437
|
+
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1393
1438
|
throw new RangeError("Range startContainer is not a text node");
|
|
1394
|
-
if (
|
|
1439
|
+
if (r.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1395
1440
|
throw new RangeError("Range endContainer is not a text node");
|
|
1396
|
-
const e =
|
|
1397
|
-
let t = !1,
|
|
1441
|
+
const e = r.cloneRange();
|
|
1442
|
+
let t = !1, i = !1;
|
|
1398
1443
|
const s = {
|
|
1399
|
-
start:
|
|
1400
|
-
|
|
1401
|
-
|
|
1444
|
+
start: J(
|
|
1445
|
+
r.startContainer.textContent,
|
|
1446
|
+
r.startOffset,
|
|
1402
1447
|
1
|
|
1403
1448
|
/* Forwards */
|
|
1404
1449
|
),
|
|
1405
|
-
end:
|
|
1406
|
-
|
|
1407
|
-
|
|
1450
|
+
end: J(
|
|
1451
|
+
r.endContainer.textContent,
|
|
1452
|
+
r.endOffset,
|
|
1408
1453
|
2
|
|
1409
1454
|
/* Backwards */
|
|
1410
1455
|
)
|
|
1411
1456
|
};
|
|
1412
|
-
if (s.start >= 0 && (e.setStart(
|
|
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)
|
|
1413
1458
|
return e;
|
|
1414
1459
|
if (!t) {
|
|
1415
|
-
const { node: n, offset: o } =
|
|
1460
|
+
const { node: n, offset: o } = Te(
|
|
1416
1461
|
e,
|
|
1417
1462
|
1
|
|
1418
1463
|
/* Forwards */
|
|
1419
1464
|
);
|
|
1420
1465
|
n && o >= 0 && e.setStart(n, o);
|
|
1421
1466
|
}
|
|
1422
|
-
if (!
|
|
1423
|
-
const { node: n, offset: o } =
|
|
1467
|
+
if (!i) {
|
|
1468
|
+
const { node: n, offset: o } = Te(
|
|
1424
1469
|
e,
|
|
1425
1470
|
2
|
|
1426
1471
|
/* Backwards */
|
|
@@ -1429,38 +1474,38 @@ function Wt(i) {
|
|
|
1429
1474
|
}
|
|
1430
1475
|
return e;
|
|
1431
1476
|
}
|
|
1432
|
-
function
|
|
1477
|
+
function Ue(r) {
|
|
1433
1478
|
var e;
|
|
1434
|
-
switch (
|
|
1479
|
+
switch (r.nodeType) {
|
|
1435
1480
|
case Node.ELEMENT_NODE:
|
|
1436
1481
|
case Node.TEXT_NODE:
|
|
1437
|
-
return ((e =
|
|
1482
|
+
return ((e = r.textContent) == null ? void 0 : e.length) ?? 0;
|
|
1438
1483
|
default:
|
|
1439
1484
|
return 0;
|
|
1440
1485
|
}
|
|
1441
1486
|
}
|
|
1442
|
-
function
|
|
1443
|
-
let e =
|
|
1487
|
+
function we(r) {
|
|
1488
|
+
let e = r.previousSibling, t = 0;
|
|
1444
1489
|
for (; e; )
|
|
1445
|
-
t +=
|
|
1490
|
+
t += Ue(e), e = e.previousSibling;
|
|
1446
1491
|
return t;
|
|
1447
1492
|
}
|
|
1448
|
-
function
|
|
1493
|
+
function ke(r, ...e) {
|
|
1449
1494
|
let t = e.shift();
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1495
|
+
const i = r.ownerDocument.createNodeIterator(
|
|
1496
|
+
r,
|
|
1452
1497
|
NodeFilter.SHOW_TEXT
|
|
1453
1498
|
), s = [];
|
|
1454
|
-
let n =
|
|
1499
|
+
let n = i.nextNode(), o, a = 0;
|
|
1455
1500
|
for (; t !== void 0 && n; )
|
|
1456
|
-
o = n, a + o.data.length > t ? (s.push({ node: o, offset: t - a }), t = e.shift()) : (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);
|
|
1457
1502
|
for (; t !== void 0 && o && a === t; )
|
|
1458
1503
|
s.push({ node: o, offset: o.data.length }), t = e.shift();
|
|
1459
1504
|
if (t !== void 0)
|
|
1460
1505
|
throw new RangeError("Offset exceeds text length");
|
|
1461
1506
|
return s;
|
|
1462
1507
|
}
|
|
1463
|
-
class
|
|
1508
|
+
class M {
|
|
1464
1509
|
constructor(e, t) {
|
|
1465
1510
|
if (t < 0)
|
|
1466
1511
|
throw new Error("Offset is invalid");
|
|
@@ -1475,10 +1520,10 @@ class N {
|
|
|
1475
1520
|
relativeTo(e) {
|
|
1476
1521
|
if (!e.contains(this.element))
|
|
1477
1522
|
throw new Error("Parent is not an ancestor of current element");
|
|
1478
|
-
let t = this.element,
|
|
1523
|
+
let t = this.element, i = this.offset;
|
|
1479
1524
|
for (; t !== e; )
|
|
1480
|
-
|
|
1481
|
-
return new
|
|
1525
|
+
i += we(t), t = t.parentElement;
|
|
1526
|
+
return new M(t, i);
|
|
1482
1527
|
}
|
|
1483
1528
|
/**
|
|
1484
1529
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1499,15 +1544,15 @@ class N {
|
|
|
1499
1544
|
*/
|
|
1500
1545
|
resolve(e = {}) {
|
|
1501
1546
|
try {
|
|
1502
|
-
return
|
|
1547
|
+
return ke(this.element, this.offset)[0];
|
|
1503
1548
|
} catch (t) {
|
|
1504
1549
|
if (this.offset === 0 && e.direction !== void 0) {
|
|
1505
|
-
const
|
|
1550
|
+
const i = document.createTreeWalker(
|
|
1506
1551
|
this.element.getRootNode(),
|
|
1507
1552
|
NodeFilter.SHOW_TEXT
|
|
1508
1553
|
);
|
|
1509
|
-
|
|
1510
|
-
const s = e.direction === 1, n = s ?
|
|
1554
|
+
i.currentNode = this.element;
|
|
1555
|
+
const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();
|
|
1511
1556
|
if (!n)
|
|
1512
1557
|
throw t;
|
|
1513
1558
|
return { node: n, offset: s ? 0 : n.data.length };
|
|
@@ -1522,9 +1567,9 @@ class N {
|
|
|
1522
1567
|
static fromCharOffset(e, t) {
|
|
1523
1568
|
switch (e.nodeType) {
|
|
1524
1569
|
case Node.TEXT_NODE:
|
|
1525
|
-
return
|
|
1570
|
+
return M.fromPoint(e, t);
|
|
1526
1571
|
case Node.ELEMENT_NODE:
|
|
1527
|
-
return new
|
|
1572
|
+
return new M(e, t);
|
|
1528
1573
|
default:
|
|
1529
1574
|
throw new Error("Node is not an element or text node");
|
|
1530
1575
|
}
|
|
@@ -1542,16 +1587,16 @@ class N {
|
|
|
1542
1587
|
throw new Error("Text node offset is out of range");
|
|
1543
1588
|
if (!e.parentElement)
|
|
1544
1589
|
throw new Error("Text node has no parent");
|
|
1545
|
-
const
|
|
1546
|
-
return new
|
|
1590
|
+
const i = we(e) + t;
|
|
1591
|
+
return new M(e.parentElement, i);
|
|
1547
1592
|
}
|
|
1548
1593
|
case Node.ELEMENT_NODE: {
|
|
1549
1594
|
if (t < 0 || t > e.childNodes.length)
|
|
1550
1595
|
throw new Error("Child node offset is out of range");
|
|
1551
|
-
let
|
|
1596
|
+
let i = 0;
|
|
1552
1597
|
for (let s = 0; s < t; s++)
|
|
1553
|
-
|
|
1554
|
-
return new
|
|
1598
|
+
i += Ue(e.childNodes[s]);
|
|
1599
|
+
return new M(e, i);
|
|
1555
1600
|
}
|
|
1556
1601
|
default:
|
|
1557
1602
|
throw new Error("Point is not in an element or text node");
|
|
@@ -1584,7 +1629,7 @@ class z {
|
|
|
1584
1629
|
*/
|
|
1585
1630
|
toRange() {
|
|
1586
1631
|
let e, t;
|
|
1587
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] =
|
|
1632
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ke(
|
|
1588
1633
|
this.start.element,
|
|
1589
1634
|
this.start.offset,
|
|
1590
1635
|
this.end.offset
|
|
@@ -1595,27 +1640,27 @@ class z {
|
|
|
1595
1640
|
direction: 2
|
|
1596
1641
|
/* BACKWARDS */
|
|
1597
1642
|
}));
|
|
1598
|
-
const
|
|
1599
|
-
return
|
|
1643
|
+
const i = new Range();
|
|
1644
|
+
return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
|
|
1600
1645
|
}
|
|
1601
1646
|
/**
|
|
1602
1647
|
* Create a TextRange from a (DOM) Range
|
|
1603
1648
|
*/
|
|
1604
1649
|
static fromRange(e) {
|
|
1605
|
-
const t =
|
|
1650
|
+
const t = M.fromPoint(
|
|
1606
1651
|
e.startContainer,
|
|
1607
1652
|
e.startOffset
|
|
1608
|
-
),
|
|
1609
|
-
return new z(t,
|
|
1653
|
+
), i = M.fromPoint(e.endContainer, e.endOffset);
|
|
1654
|
+
return new z(t, i);
|
|
1610
1655
|
}
|
|
1611
1656
|
/**
|
|
1612
1657
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1613
1658
|
* `root`
|
|
1614
1659
|
*/
|
|
1615
|
-
static fromOffsets(e, t,
|
|
1660
|
+
static fromOffsets(e, t, i) {
|
|
1616
1661
|
return new z(
|
|
1617
|
-
new
|
|
1618
|
-
new
|
|
1662
|
+
new M(e, t),
|
|
1663
|
+
new M(e, i)
|
|
1619
1664
|
);
|
|
1620
1665
|
}
|
|
1621
1666
|
/**
|
|
@@ -1623,23 +1668,23 @@ class z {
|
|
|
1623
1668
|
* whitespace
|
|
1624
1669
|
*/
|
|
1625
1670
|
static trimmedRange(e) {
|
|
1626
|
-
return
|
|
1671
|
+
return bt(z.fromRange(e).toRange());
|
|
1627
1672
|
}
|
|
1628
1673
|
}
|
|
1629
|
-
class
|
|
1630
|
-
constructor(e, t,
|
|
1631
|
-
this.root = e, this.start = t, this.end =
|
|
1674
|
+
class _ {
|
|
1675
|
+
constructor(e, t, i) {
|
|
1676
|
+
this.root = e, this.start = t, this.end = i;
|
|
1632
1677
|
}
|
|
1633
1678
|
static fromRange(e, t) {
|
|
1634
|
-
const
|
|
1635
|
-
return new
|
|
1679
|
+
const i = z.fromRange(t).relativeTo(e);
|
|
1680
|
+
return new _(
|
|
1636
1681
|
e,
|
|
1637
|
-
|
|
1638
|
-
|
|
1682
|
+
i.start.offset,
|
|
1683
|
+
i.end.offset
|
|
1639
1684
|
);
|
|
1640
1685
|
}
|
|
1641
1686
|
static fromSelector(e, t) {
|
|
1642
|
-
return new
|
|
1687
|
+
return new _(e, t.start, t.end);
|
|
1643
1688
|
}
|
|
1644
1689
|
toSelector() {
|
|
1645
1690
|
return {
|
|
@@ -1652,12 +1697,12 @@ class ae {
|
|
|
1652
1697
|
return z.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1653
1698
|
}
|
|
1654
1699
|
}
|
|
1655
|
-
class
|
|
1700
|
+
class X {
|
|
1656
1701
|
/**
|
|
1657
1702
|
* @param root - A root element from which to anchor.
|
|
1658
1703
|
*/
|
|
1659
|
-
constructor(e, t,
|
|
1660
|
-
this.root = e, this.exact = t, this.context =
|
|
1704
|
+
constructor(e, t, i = {}) {
|
|
1705
|
+
this.root = e, this.exact = t, this.context = i;
|
|
1661
1706
|
}
|
|
1662
1707
|
/**
|
|
1663
1708
|
* Create a `TextQuoteAnchor` from a range.
|
|
@@ -1665,15 +1710,15 @@ class le {
|
|
|
1665
1710
|
* Will throw if `range` does not contain any text nodes.
|
|
1666
1711
|
*/
|
|
1667
1712
|
static fromRange(e, t) {
|
|
1668
|
-
const
|
|
1669
|
-
return new
|
|
1670
|
-
prefix:
|
|
1671
|
-
suffix:
|
|
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))
|
|
1672
1717
|
});
|
|
1673
1718
|
}
|
|
1674
1719
|
static fromSelector(e, t) {
|
|
1675
|
-
const { prefix:
|
|
1676
|
-
return new
|
|
1720
|
+
const { prefix: i, suffix: s } = t;
|
|
1721
|
+
return new X(e, t.exact, { prefix: i, suffix: s });
|
|
1677
1722
|
}
|
|
1678
1723
|
toSelector() {
|
|
1679
1724
|
return {
|
|
@@ -1687,28 +1732,28 @@ class le {
|
|
|
1687
1732
|
return this.toPositionAnchor(e).toRange();
|
|
1688
1733
|
}
|
|
1689
1734
|
toPositionAnchor(e = {}) {
|
|
1690
|
-
const t = this.root.textContent,
|
|
1735
|
+
const t = this.root.textContent, i = Et(t, this.exact, {
|
|
1691
1736
|
...this.context,
|
|
1692
1737
|
hint: e.hint
|
|
1693
1738
|
});
|
|
1694
|
-
if (!
|
|
1739
|
+
if (!i)
|
|
1695
1740
|
throw new Error("Quote not found");
|
|
1696
|
-
return new
|
|
1741
|
+
return new _(this.root, i.start, i.end);
|
|
1697
1742
|
}
|
|
1698
1743
|
}
|
|
1699
|
-
function
|
|
1700
|
-
const e =
|
|
1744
|
+
function xt(r) {
|
|
1745
|
+
const e = r.tagName.toUpperCase();
|
|
1701
1746
|
return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
|
|
1702
1747
|
}
|
|
1703
|
-
function
|
|
1748
|
+
function le(r, e) {
|
|
1704
1749
|
try {
|
|
1705
|
-
const t = e.locations,
|
|
1706
|
-
if (
|
|
1750
|
+
const t = e.locations, i = e.text;
|
|
1751
|
+
if (i && i.highlight) {
|
|
1707
1752
|
let s;
|
|
1708
|
-
t && t.getCssSelector() && (s =
|
|
1709
|
-
const n = new
|
|
1710
|
-
prefix:
|
|
1711
|
-
suffix:
|
|
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
|
|
1712
1757
|
});
|
|
1713
1758
|
try {
|
|
1714
1759
|
return n.toRange();
|
|
@@ -1718,14 +1763,14 @@ function Oe(i, e) {
|
|
|
1718
1763
|
}
|
|
1719
1764
|
if (t) {
|
|
1720
1765
|
let s = null;
|
|
1721
|
-
if (!s && t.getCssSelector() && (s =
|
|
1766
|
+
if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {
|
|
1722
1767
|
for (const n of t.fragments)
|
|
1723
|
-
if (s =
|
|
1768
|
+
if (s = r.getElementById(n), s)
|
|
1724
1769
|
break;
|
|
1725
1770
|
}
|
|
1726
1771
|
if (s) {
|
|
1727
|
-
const n =
|
|
1728
|
-
return s.childNodes.length === 0 ||
|
|
1772
|
+
const n = r.createRange();
|
|
1773
|
+
return s.childNodes.length === 0 || xt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1729
1774
|
}
|
|
1730
1775
|
}
|
|
1731
1776
|
} catch (t) {
|
|
@@ -1733,10 +1778,10 @@ function Oe(i, e) {
|
|
|
1733
1778
|
}
|
|
1734
1779
|
return null;
|
|
1735
1780
|
}
|
|
1736
|
-
function
|
|
1737
|
-
let t =
|
|
1738
|
-
t.length ||
|
|
1739
|
-
const
|
|
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 = [];
|
|
1740
1785
|
for (const c of t)
|
|
1741
1786
|
s.push({
|
|
1742
1787
|
bottom: c.bottom,
|
|
@@ -1746,14 +1791,14 @@ function kt(i, e) {
|
|
|
1746
1791
|
top: c.top,
|
|
1747
1792
|
width: c.width
|
|
1748
1793
|
});
|
|
1749
|
-
const n =
|
|
1794
|
+
const n = He(
|
|
1750
1795
|
s,
|
|
1751
|
-
|
|
1796
|
+
i,
|
|
1752
1797
|
e
|
|
1753
|
-
), o =
|
|
1798
|
+
), o = wt(n, i), a = $e(o), h = 2 * 2;
|
|
1754
1799
|
for (let c = a.length - 1; c >= 0; c--) {
|
|
1755
|
-
const
|
|
1756
|
-
if (!(
|
|
1800
|
+
const d = a[c];
|
|
1801
|
+
if (!(d.width * d.height > h))
|
|
1757
1802
|
if (a.length > 1)
|
|
1758
1803
|
a.splice(c, 1);
|
|
1759
1804
|
else
|
|
@@ -1761,90 +1806,90 @@ function kt(i, e) {
|
|
|
1761
1806
|
}
|
|
1762
1807
|
return a;
|
|
1763
1808
|
}
|
|
1764
|
-
function
|
|
1765
|
-
for (let
|
|
1766
|
-
for (let s =
|
|
1767
|
-
const n = i
|
|
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];
|
|
1768
1813
|
if (n === o)
|
|
1769
1814
|
continue;
|
|
1770
|
-
const a =
|
|
1771
|
-
if ((h && !t || a && !h) &&
|
|
1772
|
-
const
|
|
1773
|
-
return
|
|
1774
|
-
|
|
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,
|
|
1775
1820
|
e,
|
|
1776
1821
|
t
|
|
1777
1822
|
);
|
|
1778
1823
|
}
|
|
1779
1824
|
}
|
|
1780
|
-
return
|
|
1825
|
+
return r;
|
|
1781
1826
|
}
|
|
1782
|
-
function
|
|
1783
|
-
const t = Math.min(
|
|
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);
|
|
1784
1829
|
return {
|
|
1785
1830
|
bottom: n,
|
|
1786
1831
|
height: n - s,
|
|
1787
1832
|
left: t,
|
|
1788
|
-
right:
|
|
1833
|
+
right: i,
|
|
1789
1834
|
top: s,
|
|
1790
|
-
width:
|
|
1835
|
+
width: i - t
|
|
1791
1836
|
};
|
|
1792
1837
|
}
|
|
1793
|
-
function
|
|
1794
|
-
const t = new Set(
|
|
1795
|
-
for (const
|
|
1796
|
-
if (!(
|
|
1797
|
-
t.delete(
|
|
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);
|
|
1798
1843
|
continue;
|
|
1799
1844
|
}
|
|
1800
|
-
for (const n of
|
|
1801
|
-
if (
|
|
1802
|
-
t.delete(
|
|
1845
|
+
for (const n of r)
|
|
1846
|
+
if (i !== n && t.has(n) && Ct(n, i, e)) {
|
|
1847
|
+
t.delete(i);
|
|
1803
1848
|
break;
|
|
1804
1849
|
}
|
|
1805
1850
|
}
|
|
1806
1851
|
return Array.from(t);
|
|
1807
1852
|
}
|
|
1808
|
-
function
|
|
1809
|
-
return
|
|
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);
|
|
1810
1855
|
}
|
|
1811
|
-
function
|
|
1812
|
-
return (
|
|
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));
|
|
1813
1858
|
}
|
|
1814
|
-
function
|
|
1815
|
-
for (let e = 0; e <
|
|
1816
|
-
for (let t = e + 1; t <
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
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)) {
|
|
1819
1864
|
let n = [], o;
|
|
1820
|
-
const a =
|
|
1865
|
+
const a = Ce(i, s);
|
|
1821
1866
|
if (a.length === 1)
|
|
1822
|
-
n = a, o =
|
|
1867
|
+
n = a, o = i;
|
|
1823
1868
|
else {
|
|
1824
|
-
const c =
|
|
1825
|
-
a.length < c.length ? (n = a, o =
|
|
1869
|
+
const c = Ce(s, i);
|
|
1870
|
+
a.length < c.length ? (n = a, o = i) : (n = c, o = s);
|
|
1826
1871
|
}
|
|
1827
|
-
const h =
|
|
1828
|
-
return Array.prototype.push.apply(h, n),
|
|
1872
|
+
const h = r.filter((c) => c !== o);
|
|
1873
|
+
return Array.prototype.push.apply(h, n), $e(h);
|
|
1829
1874
|
}
|
|
1830
1875
|
}
|
|
1831
|
-
return
|
|
1876
|
+
return r;
|
|
1832
1877
|
}
|
|
1833
|
-
function
|
|
1834
|
-
const t =
|
|
1878
|
+
function Ce(r, e) {
|
|
1879
|
+
const t = Pt(e, r);
|
|
1835
1880
|
if (t.height === 0 || t.width === 0)
|
|
1836
|
-
return [
|
|
1837
|
-
const
|
|
1881
|
+
return [r];
|
|
1882
|
+
const i = [];
|
|
1838
1883
|
{
|
|
1839
1884
|
const s = {
|
|
1840
|
-
bottom:
|
|
1885
|
+
bottom: r.bottom,
|
|
1841
1886
|
height: 0,
|
|
1842
|
-
left:
|
|
1887
|
+
left: r.left,
|
|
1843
1888
|
right: t.left,
|
|
1844
|
-
top:
|
|
1889
|
+
top: r.top,
|
|
1845
1890
|
width: 0
|
|
1846
1891
|
};
|
|
1847
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 &&
|
|
1892
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1848
1893
|
}
|
|
1849
1894
|
{
|
|
1850
1895
|
const s = {
|
|
@@ -1852,355 +1897,117 @@ function Be(i, e) {
|
|
|
1852
1897
|
height: 0,
|
|
1853
1898
|
left: t.left,
|
|
1854
1899
|
right: t.right,
|
|
1855
|
-
top:
|
|
1900
|
+
top: r.top,
|
|
1856
1901
|
width: 0
|
|
1857
1902
|
};
|
|
1858
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 &&
|
|
1903
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1859
1904
|
}
|
|
1860
1905
|
{
|
|
1861
1906
|
const s = {
|
|
1862
|
-
bottom:
|
|
1907
|
+
bottom: r.bottom,
|
|
1863
1908
|
height: 0,
|
|
1864
1909
|
left: t.left,
|
|
1865
1910
|
right: t.right,
|
|
1866
1911
|
top: t.bottom,
|
|
1867
1912
|
width: 0
|
|
1868
1913
|
};
|
|
1869
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 &&
|
|
1914
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1870
1915
|
}
|
|
1871
1916
|
{
|
|
1872
1917
|
const s = {
|
|
1873
|
-
bottom:
|
|
1918
|
+
bottom: r.bottom,
|
|
1874
1919
|
height: 0,
|
|
1875
1920
|
left: t.right,
|
|
1876
|
-
right:
|
|
1877
|
-
top:
|
|
1921
|
+
right: r.right,
|
|
1922
|
+
top: r.top,
|
|
1878
1923
|
width: 0
|
|
1879
1924
|
};
|
|
1880
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 &&
|
|
1925
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1881
1926
|
}
|
|
1882
|
-
return
|
|
1927
|
+
return i;
|
|
1883
1928
|
}
|
|
1884
|
-
function
|
|
1885
|
-
const t = Math.max(
|
|
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);
|
|
1886
1931
|
return {
|
|
1887
1932
|
bottom: n,
|
|
1888
1933
|
height: Math.max(0, n - s),
|
|
1889
1934
|
left: t,
|
|
1890
|
-
right:
|
|
1935
|
+
right: i,
|
|
1891
1936
|
top: s,
|
|
1892
|
-
width: Math.max(0,
|
|
1937
|
+
width: Math.max(0, i - t)
|
|
1893
1938
|
};
|
|
1894
1939
|
}
|
|
1895
|
-
function
|
|
1896
|
-
return (
|
|
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));
|
|
1897
1942
|
}
|
|
1898
|
-
function
|
|
1899
|
-
return Math.abs(
|
|
1943
|
+
function N(r, e, t) {
|
|
1944
|
+
return Math.abs(r - e) <= t;
|
|
1900
1945
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
}, Vt = function() {
|
|
1906
|
-
return F.some(function(i) {
|
|
1907
|
-
return i.skippedTargets.length > 0;
|
|
1908
|
-
});
|
|
1909
|
-
}, We = "ResizeObserver loop completed with undelivered notifications.", jt = function() {
|
|
1910
|
-
var i;
|
|
1911
|
-
typeof ErrorEvent == "function" ? i = new ErrorEvent("error", {
|
|
1912
|
-
message: We
|
|
1913
|
-
}) : (i = document.createEvent("Event"), i.initEvent("error", !1, !1), i.message = We), window.dispatchEvent(i);
|
|
1914
|
-
}, G;
|
|
1915
|
-
(function(i) {
|
|
1916
|
-
i.BORDER_BOX = "border-box", i.CONTENT_BOX = "content-box", i.DEVICE_PIXEL_CONTENT_BOX = "device-pixel-content-box";
|
|
1917
|
-
})(G || (G = {}));
|
|
1918
|
-
var k = function(i) {
|
|
1919
|
-
return Object.freeze(i);
|
|
1920
|
-
}, Xt = function() {
|
|
1921
|
-
function i(e, t) {
|
|
1922
|
-
this.inlineSize = e, this.blockSize = t, k(this);
|
|
1923
|
-
}
|
|
1924
|
-
return i;
|
|
1925
|
-
}(), at = function() {
|
|
1926
|
-
function i(e, t, r, s) {
|
|
1927
|
-
return this.x = e, this.y = t, this.width = r, this.height = s, this.top = this.y, this.left = this.x, this.bottom = this.top + this.height, this.right = this.left + this.width, k(this);
|
|
1928
|
-
}
|
|
1929
|
-
return i.prototype.toJSON = function() {
|
|
1930
|
-
var e = this, t = e.x, r = e.y, s = e.top, n = e.right, o = e.bottom, a = e.left, h = e.width, c = e.height;
|
|
1931
|
-
return { x: t, y: r, top: s, right: n, bottom: o, left: a, width: h, height: c };
|
|
1932
|
-
}, i.fromRect = function(e) {
|
|
1933
|
-
return new i(e.x, e.y, e.width, e.height);
|
|
1934
|
-
}, i;
|
|
1935
|
-
}(), Pe = function(i) {
|
|
1936
|
-
return i instanceof SVGElement && "getBBox" in i;
|
|
1937
|
-
}, lt = function(i) {
|
|
1938
|
-
if (Pe(i)) {
|
|
1939
|
-
var e = i.getBBox(), t = e.width, r = e.height;
|
|
1940
|
-
return !t && !r;
|
|
1941
|
-
}
|
|
1942
|
-
var s = i, n = s.offsetWidth, o = s.offsetHeight;
|
|
1943
|
-
return !(n || o || i.getClientRects().length);
|
|
1944
|
-
}, Fe = function(i) {
|
|
1945
|
-
var e;
|
|
1946
|
-
if (i instanceof Element)
|
|
1947
|
-
return !0;
|
|
1948
|
-
var t = (e = i == null ? void 0 : i.ownerDocument) === null || e === void 0 ? void 0 : e.defaultView;
|
|
1949
|
-
return !!(t && i instanceof t.Element);
|
|
1950
|
-
}, Gt = function(i) {
|
|
1951
|
-
switch (i.tagName) {
|
|
1952
|
-
case "INPUT":
|
|
1953
|
-
if (i.type !== "image")
|
|
1954
|
-
break;
|
|
1955
|
-
case "VIDEO":
|
|
1956
|
-
case "AUDIO":
|
|
1957
|
-
case "EMBED":
|
|
1958
|
-
case "OBJECT":
|
|
1959
|
-
case "CANVAS":
|
|
1960
|
-
case "IFRAME":
|
|
1961
|
-
case "IMG":
|
|
1962
|
-
return !0;
|
|
1963
|
-
}
|
|
1964
|
-
return !1;
|
|
1965
|
-
}, X = typeof window < "u" ? window : {}, ee = /* @__PURE__ */ new WeakMap(), ke = /auto|scroll/, Yt = /^tb|vertical/, Zt = /msie|trident/i.test(X.navigator && X.navigator.userAgent), R = function(i) {
|
|
1966
|
-
return parseFloat(i || "0");
|
|
1967
|
-
}, $ = function(i, e, t) {
|
|
1968
|
-
return i === void 0 && (i = 0), e === void 0 && (e = 0), t === void 0 && (t = !1), new Xt((t ? e : i) || 0, (t ? i : e) || 0);
|
|
1969
|
-
}, Ue = k({
|
|
1970
|
-
devicePixelContentBoxSize: $(),
|
|
1971
|
-
borderBoxSize: $(),
|
|
1972
|
-
contentBoxSize: $(),
|
|
1973
|
-
contentRect: new at(0, 0, 0, 0)
|
|
1974
|
-
}), ht = function(i, e) {
|
|
1975
|
-
if (e === void 0 && (e = !1), ee.has(i) && !e)
|
|
1976
|
-
return ee.get(i);
|
|
1977
|
-
if (lt(i))
|
|
1978
|
-
return ee.set(i, Ue), Ue;
|
|
1979
|
-
var t = getComputedStyle(i), r = Pe(i) && i.ownerSVGElement && i.getBBox(), s = !Zt && t.boxSizing === "border-box", n = Yt.test(t.writingMode || ""), o = !r && ke.test(t.overflowY || ""), a = !r && ke.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, Y = s ? y + S : 0, Z = s ? x + m : 0, D = r ? r.width : R(t.width) - Y - P, B = r ? r.height : R(t.height) - Z - E, J = D + y + P + S, K = B + x + E + m, U = k({
|
|
1980
|
-
devicePixelContentBoxSize: $(Math.round(D * devicePixelRatio), Math.round(B * devicePixelRatio), n),
|
|
1981
|
-
borderBoxSize: $(J, K, n),
|
|
1982
|
-
contentBoxSize: $(D, B, n),
|
|
1983
|
-
contentRect: new at(p, h, D, B)
|
|
1984
|
-
});
|
|
1985
|
-
return ee.set(i, U), U;
|
|
1986
|
-
}, ct = function(i, e, t) {
|
|
1987
|
-
var r = ht(i, t), s = r.borderBoxSize, n = r.contentBoxSize, o = r.devicePixelContentBoxSize;
|
|
1988
|
-
switch (e) {
|
|
1989
|
-
case G.DEVICE_PIXEL_CONTENT_BOX:
|
|
1990
|
-
return o;
|
|
1991
|
-
case G.BORDER_BOX:
|
|
1992
|
-
return s;
|
|
1993
|
-
default:
|
|
1994
|
-
return n;
|
|
1995
|
-
}
|
|
1996
|
-
}, Jt = function() {
|
|
1997
|
-
function i(e) {
|
|
1998
|
-
var t = ht(e);
|
|
1999
|
-
this.target = e, this.contentRect = t.contentRect, this.borderBoxSize = k([t.borderBoxSize]), this.contentBoxSize = k([t.contentBoxSize]), this.devicePixelContentBoxSize = k([t.devicePixelContentBoxSize]);
|
|
2000
|
-
}
|
|
2001
|
-
return i;
|
|
2002
|
-
}(), ut = function(i) {
|
|
2003
|
-
if (lt(i))
|
|
2004
|
-
return 1 / 0;
|
|
2005
|
-
for (var e = 0, t = i.parentNode; t; )
|
|
2006
|
-
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]));
|
|
2007
1950
|
return e;
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
a.push(u), c.lastReportedSize = ct(c.target, c.observedBox), p < i && (i = p);
|
|
2016
|
-
}), e.push(function() {
|
|
2017
|
-
o.callback.call(o.observer, a, o.observer);
|
|
2018
|
-
}), o.activeTargets.splice(0, o.activeTargets.length);
|
|
2019
|
-
}
|
|
2020
|
-
});
|
|
2021
|
-
for (var t = 0, r = e; t < r.length; t++) {
|
|
2022
|
-
var s = r[t];
|
|
2023
|
-
s();
|
|
2024
|
-
}
|
|
2025
|
-
return i;
|
|
2026
|
-
}, He = function(i) {
|
|
2027
|
-
F.forEach(function(t) {
|
|
2028
|
-
t.activeTargets.splice(0, t.activeTargets.length), t.skippedTargets.splice(0, t.skippedTargets.length), t.observationTargets.forEach(function(s) {
|
|
2029
|
-
s.isActive() && (ut(s.target) > i ? t.activeTargets.push(s) : t.skippedTargets.push(s));
|
|
2030
|
-
});
|
|
2031
|
-
});
|
|
2032
|
-
}, Qt = function() {
|
|
2033
|
-
var i = 0;
|
|
2034
|
-
for (He(i); _t(); )
|
|
2035
|
-
i = Kt(), He(i);
|
|
2036
|
-
return Vt() && jt(), i > 0;
|
|
2037
|
-
}, de, dt = [], ei = function() {
|
|
2038
|
-
return dt.splice(0).forEach(function(i) {
|
|
2039
|
-
return i();
|
|
2040
|
-
});
|
|
2041
|
-
}, ti = function(i) {
|
|
2042
|
-
if (!de) {
|
|
2043
|
-
var e = 0, t = document.createTextNode(""), r = { characterData: !0 };
|
|
2044
|
-
new MutationObserver(function() {
|
|
2045
|
-
return ei();
|
|
2046
|
-
}).observe(t, r), de = function() {
|
|
2047
|
-
t.textContent = "".concat(e ? e-- : e++);
|
|
2048
|
-
};
|
|
2049
|
-
}
|
|
2050
|
-
dt.push(i), de();
|
|
2051
|
-
}, ii = function(i) {
|
|
2052
|
-
ti(function() {
|
|
2053
|
-
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);
|
|
2054
1958
|
});
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
"
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
],
|
|
2073
|
-
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
return
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
if (pe = !1, e = r - qe(), !ri())
|
|
2092
|
-
return;
|
|
2093
|
-
s ? t.run(1e3) : e > 0 ? t.run(e) : t.start();
|
|
2094
|
-
}
|
|
2095
|
-
});
|
|
2096
|
-
}
|
|
2097
|
-
}, i.prototype.schedule = function() {
|
|
2098
|
-
this.stop(), this.run();
|
|
2099
|
-
}, i.prototype.observe = function() {
|
|
2100
|
-
var e = this, t = function() {
|
|
2101
|
-
return e.observer && e.observer.observe(document.body, ni);
|
|
2102
|
-
};
|
|
2103
|
-
document.body ? t() : X.addEventListener("DOMContentLoaded", t);
|
|
2104
|
-
}, i.prototype.start = function() {
|
|
2105
|
-
var e = this;
|
|
2106
|
-
this.stopped && (this.stopped = !1, this.observer = new MutationObserver(this.listener), this.observe(), $e.forEach(function(t) {
|
|
2107
|
-
return X.addEventListener(t, e.listener, !0);
|
|
2108
|
-
}));
|
|
2109
|
-
}, i.prototype.stop = function() {
|
|
2110
|
-
var e = this;
|
|
2111
|
-
this.stopped || (this.observer && this.observer.disconnect(), $e.forEach(function(t) {
|
|
2112
|
-
return X.removeEventListener(t, e.listener, !0);
|
|
2113
|
-
}), this.stopped = !0);
|
|
2114
|
-
}, i;
|
|
2115
|
-
}(), me = new oi(), _e = function(i) {
|
|
2116
|
-
!se && i > 0 && me.start(), se += i, !se && me.stop();
|
|
2117
|
-
}, ai = function(i) {
|
|
2118
|
-
return !Pe(i) && !Gt(i) && getComputedStyle(i).display === "inline";
|
|
2119
|
-
}, li = function() {
|
|
2120
|
-
function i(e, t) {
|
|
2121
|
-
this.target = e, this.observedBox = t || G.CONTENT_BOX, this.lastReportedSize = {
|
|
2122
|
-
inlineSize: 0,
|
|
2123
|
-
blockSize: 0
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
return i.prototype.isActive = function() {
|
|
2127
|
-
var e = ct(this.target, this.observedBox, !0);
|
|
2128
|
-
return ai(this.target) && (this.lastReportedSize = e), this.lastReportedSize.inlineSize !== e.inlineSize || this.lastReportedSize.blockSize !== e.blockSize;
|
|
2129
|
-
}, i;
|
|
2130
|
-
}(), hi = function() {
|
|
2131
|
-
function i(e, t) {
|
|
2132
|
-
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
|
+
};
|
|
2133
1995
|
}
|
|
2134
|
-
return
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2143
|
-
return i.connect = function(e, t) {
|
|
2144
|
-
var r = new hi(e, t);
|
|
2145
|
-
te.set(e, r);
|
|
2146
|
-
}, i.observe = function(e, t, r) {
|
|
2147
|
-
var s = te.get(e), n = s.observationTargets.length === 0;
|
|
2148
|
-
Ve(s.observationTargets, t) < 0 && (n && F.push(s), s.observationTargets.push(new li(t, r && r.box)), _e(1), me.schedule());
|
|
2149
|
-
}, i.unobserve = function(e, t) {
|
|
2150
|
-
var r = te.get(e), s = Ve(r.observationTargets, t), n = r.observationTargets.length === 1;
|
|
2151
|
-
s >= 0 && (n && F.splice(F.indexOf(r), 1), r.observationTargets.splice(s, 1), _e(-1));
|
|
2152
|
-
}, i.disconnect = function(e) {
|
|
2153
|
-
var t = this, r = te.get(e);
|
|
2154
|
-
r.observationTargets.slice().forEach(function(s) {
|
|
2155
|
-
return t.unobserve(e, s.target);
|
|
2156
|
-
}), r.activeTargets.splice(0, r.activeTargets.length);
|
|
2157
|
-
}, i;
|
|
2158
|
-
}(), pt = function() {
|
|
2159
|
-
function i(e) {
|
|
2160
|
-
if (arguments.length === 0)
|
|
2161
|
-
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
2162
|
-
if (typeof e != "function")
|
|
2163
|
-
throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
|
|
2164
|
-
ie.connect(this, e);
|
|
2165
|
-
}
|
|
2166
|
-
return i.prototype.observe = function(e, t) {
|
|
2167
|
-
if (arguments.length === 0)
|
|
2168
|
-
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
2169
|
-
if (!Fe(e))
|
|
2170
|
-
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
|
|
2171
|
-
ie.observe(this, e, t);
|
|
2172
|
-
}, i.prototype.unobserve = function(e) {
|
|
2173
|
-
if (arguments.length === 0)
|
|
2174
|
-
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
2175
|
-
if (!Fe(e))
|
|
2176
|
-
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
|
|
2177
|
-
ie.unobserve(this, e);
|
|
2178
|
-
}, i.prototype.disconnect = function() {
|
|
2179
|
-
ie.disconnect(this);
|
|
2180
|
-
}, i.toString = function() {
|
|
2181
|
-
return "function ResizeObserver () { [polyfill code] }";
|
|
2182
|
-
}, i;
|
|
2183
|
-
}();
|
|
2184
|
-
function ci(i, e) {
|
|
2185
|
-
return i.document.documentElement.style.getPropertyValue(e);
|
|
2186
|
-
}
|
|
2187
|
-
function ge(i, e, t) {
|
|
2188
|
-
i.document.documentElement.style.setProperty(e, t);
|
|
2189
|
-
}
|
|
2190
|
-
function ft(i, e) {
|
|
2191
|
-
i.document.documentElement.style.removeProperty(e);
|
|
2192
|
-
}
|
|
2193
|
-
const ui = window.ResizeObserver || pt;
|
|
2194
|
-
var di = /* @__PURE__ */ ((i) => (i.Wrap = "wrap", i.Viewport = "viewport", i.Bounds = "bounds", i.Page = "page", i))(di || {}), pi = /* @__PURE__ */ ((i) => (i.Boxes = "boxes", i.Bounds = "bounds", i))(pi || {});
|
|
2195
|
-
const fi = "Highlight" in window, je = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2196
|
-
class mi {
|
|
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 {
|
|
2197
2004
|
/**
|
|
2198
2005
|
* Creates a DecorationGroup object
|
|
2199
2006
|
* @param id Unique HTML ID-adhering name of the group
|
|
2200
2007
|
* @param name Human-readable name of the group
|
|
2201
2008
|
*/
|
|
2202
|
-
constructor(e, t,
|
|
2203
|
-
this.wnd = e, this.comms = t, this.id =
|
|
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());
|
|
2204
2011
|
}
|
|
2205
2012
|
get activeable() {
|
|
2206
2013
|
return this.activateable;
|
|
@@ -2214,17 +2021,17 @@ class mi {
|
|
|
2214
2021
|
*/
|
|
2215
2022
|
add(e) {
|
|
2216
2023
|
var o, a, h, c;
|
|
2217
|
-
const t = `${this.id}-${this.lastItemId++}`,
|
|
2218
|
-
if (!
|
|
2024
|
+
const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
|
|
2025
|
+
if (!i) {
|
|
2219
2026
|
this.comms.log("Can't locate DOM range for decoration", e);
|
|
2220
2027
|
return;
|
|
2221
2028
|
}
|
|
2222
|
-
const s =
|
|
2223
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (
|
|
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)));
|
|
2224
2031
|
const n = {
|
|
2225
2032
|
decoration: e,
|
|
2226
2033
|
id: t,
|
|
2227
|
-
range:
|
|
2034
|
+
range: i
|
|
2228
2035
|
};
|
|
2229
2036
|
this.items.push(n), this.layout(n), this.renderLayout([n]);
|
|
2230
2037
|
}
|
|
@@ -2237,12 +2044,12 @@ class mi {
|
|
|
2237
2044
|
const t = this.items.findIndex((o) => o.decoration.id === e);
|
|
2238
2045
|
if (t < 0)
|
|
2239
2046
|
return;
|
|
2240
|
-
const
|
|
2241
|
-
if (this.items.splice(t, 1),
|
|
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))) {
|
|
2242
2049
|
const o = this.wnd.CSS.highlights.get(this.id);
|
|
2243
|
-
o == null || o.delete(
|
|
2050
|
+
o == null || o.delete(i.range);
|
|
2244
2051
|
}
|
|
2245
|
-
(n = this.notTextFlag) == null || n.delete(
|
|
2052
|
+
(n = this.notTextFlag) == null || n.delete(i.id);
|
|
2246
2053
|
}
|
|
2247
2054
|
/**
|
|
2248
2055
|
* Notifies that the given decoration was modified and needs to be updated.
|
|
@@ -2267,8 +2074,8 @@ class mi {
|
|
|
2267
2074
|
}
|
|
2268
2075
|
experimentalLayout(e) {
|
|
2269
2076
|
var s, n;
|
|
2270
|
-
const [t,
|
|
2271
|
-
|
|
2077
|
+
const [t, i] = this.requireContainer(!0);
|
|
2078
|
+
i.add(e.range), t.innerHTML = `
|
|
2272
2079
|
::highlight(${this.id}) {
|
|
2273
2080
|
color: black;
|
|
2274
2081
|
background-color: ${((n = (s = e.decoration) == null ? void 0 : s.style) == null ? void 0 : n.tint) ?? "yellow"};
|
|
@@ -2279,39 +2086,39 @@ class mi {
|
|
|
2279
2086
|
* @param item
|
|
2280
2087
|
*/
|
|
2281
2088
|
layout(e) {
|
|
2282
|
-
var
|
|
2283
|
-
if (this.experimentalHighlights && !((
|
|
2089
|
+
var g, m, v, S, O;
|
|
2090
|
+
if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(e.id)))
|
|
2284
2091
|
return this.experimentalLayout(e);
|
|
2285
2092
|
const t = this.wnd.document.createElement("div");
|
|
2286
2093
|
t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
|
|
2287
|
-
const
|
|
2094
|
+
const i = this.wnd.innerWidth, s = parseInt(
|
|
2288
2095
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2289
2096
|
"column-count"
|
|
2290
2097
|
)
|
|
2291
|
-
), n =
|
|
2292
|
-
var
|
|
2293
|
-
if (
|
|
2294
|
-
|
|
2295
|
-
let
|
|
2296
|
-
|
|
2297
|
-
} else if (((
|
|
2298
|
-
|
|
2299
|
-
else if (((
|
|
2300
|
-
|
|
2301
|
-
let
|
|
2302
|
-
|
|
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`;
|
|
2303
2110
|
} else
|
|
2304
|
-
|
|
2305
|
-
},
|
|
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();
|
|
2306
2113
|
let p = this.wnd.document.createElement("template");
|
|
2307
|
-
const
|
|
2114
|
+
const u = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
|
|
2308
2115
|
p.innerHTML = `
|
|
2309
2116
|
<div
|
|
2310
2117
|
class="r2-highlight-0"
|
|
2311
2118
|
style="${[
|
|
2312
|
-
`background-color: ${((
|
|
2119
|
+
`background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
|
|
2313
2120
|
//"opacity: 0.3 !important",
|
|
2314
|
-
`mix-blend-mode: ${
|
|
2121
|
+
`mix-blend-mode: ${u ? "exclusion" : "multiply"} !important`,
|
|
2315
2122
|
"opacity: 1 !important",
|
|
2316
2123
|
"box-sizing: border-box !important"
|
|
2317
2124
|
].join("; ")}"
|
|
@@ -2319,19 +2126,19 @@ class mi {
|
|
|
2319
2126
|
</div>
|
|
2320
2127
|
`.trim();
|
|
2321
2128
|
const f = p.content.firstElementChild;
|
|
2322
|
-
if (((
|
|
2323
|
-
const
|
|
2324
|
-
|
|
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);
|
|
2325
2132
|
} else {
|
|
2326
|
-
let
|
|
2133
|
+
let y = St(
|
|
2327
2134
|
e.range,
|
|
2328
2135
|
!0
|
|
2329
2136
|
// doNotMergeHorizontallyAlignedRects
|
|
2330
2137
|
);
|
|
2331
|
-
|
|
2332
|
-
for (let
|
|
2333
|
-
const
|
|
2334
|
-
|
|
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);
|
|
2335
2142
|
}
|
|
2336
2143
|
}
|
|
2337
2144
|
e.container = t, e.clickableElements = Array.from(
|
|
@@ -2340,12 +2147,12 @@ class mi {
|
|
|
2340
2147
|
}
|
|
2341
2148
|
renderLayout(e) {
|
|
2342
2149
|
this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
|
|
2343
|
-
if (e = e.filter((
|
|
2150
|
+
if (e = e.filter((i) => {
|
|
2344
2151
|
var s;
|
|
2345
|
-
return !this.experimentalHighlights || !!((s = this.notTextFlag) != null && s.has(
|
|
2152
|
+
return !this.experimentalHighlights || !!((s = this.notTextFlag) != null && s.has(i.id));
|
|
2346
2153
|
}), !e || e.length === 0)
|
|
2347
2154
|
return;
|
|
2348
|
-
this.requireContainer().append(...e.map((
|
|
2155
|
+
this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
|
|
2349
2156
|
});
|
|
2350
2157
|
}
|
|
2351
2158
|
/**
|
|
@@ -2356,8 +2163,8 @@ class mi {
|
|
|
2356
2163
|
if (e) {
|
|
2357
2164
|
let t;
|
|
2358
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));
|
|
2359
|
-
let
|
|
2360
|
-
return this.wnd.CSS.highlights.has(this.id) ?
|
|
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];
|
|
2361
2168
|
}
|
|
2362
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;
|
|
2363
2170
|
}
|
|
@@ -2368,7 +2175,7 @@ class mi {
|
|
|
2368
2175
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2369
2176
|
}
|
|
2370
2177
|
}
|
|
2371
|
-
const
|
|
2178
|
+
const Ve = class Q extends Y {
|
|
2372
2179
|
constructor() {
|
|
2373
2180
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2374
2181
|
}
|
|
@@ -2383,9 +2190,9 @@ const mt = class ve extends ce {
|
|
|
2383
2190
|
}, 50);
|
|
2384
2191
|
}
|
|
2385
2192
|
mount(e, t) {
|
|
2386
|
-
return this.wnd = e, t.register("decorate",
|
|
2387
|
-
const n =
|
|
2388
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
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(
|
|
2389
2196
|
e,
|
|
2390
2197
|
t,
|
|
2391
2198
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2407,15 +2214,15 @@ const mt = class ve extends ce {
|
|
|
2407
2214
|
break;
|
|
2408
2215
|
}
|
|
2409
2216
|
s(!0);
|
|
2410
|
-
}), this.resizeObserver = new
|
|
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;
|
|
2411
2218
|
}
|
|
2412
2219
|
unmount(e, t) {
|
|
2413
|
-
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(
|
|
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;
|
|
2414
2221
|
}
|
|
2415
2222
|
};
|
|
2416
|
-
|
|
2417
|
-
let
|
|
2418
|
-
const
|
|
2223
|
+
Ve.moduleName = "decorator";
|
|
2224
|
+
let Dt = Ve;
|
|
2225
|
+
const Ae = "readium-snapper-style", _e = class ee extends Y {
|
|
2419
2226
|
constructor() {
|
|
2420
2227
|
super(...arguments), this.protected = !1;
|
|
2421
2228
|
}
|
|
@@ -2427,48 +2234,53 @@ const Xe = "readium-snapper-style", gt = class ye extends ce {
|
|
|
2427
2234
|
}`;
|
|
2428
2235
|
}
|
|
2429
2236
|
mount(e, t) {
|
|
2430
|
-
const
|
|
2431
|
-
return
|
|
2432
|
-
this.protected = !0,
|
|
2433
|
-
}), t.register("unprotect",
|
|
2434
|
-
this.protected = !1,
|
|
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);
|
|
2435
2242
|
}), t.log("Snapper Mounted"), !0;
|
|
2436
2243
|
}
|
|
2437
2244
|
unmount(e, t) {
|
|
2438
|
-
var
|
|
2439
|
-
return (
|
|
2245
|
+
var i;
|
|
2246
|
+
return (i = e.document.getElementById(Ae)) == null || i.remove(), t.log("Snapper Unmounted"), !0;
|
|
2440
2247
|
}
|
|
2441
2248
|
};
|
|
2442
|
-
|
|
2443
|
-
let
|
|
2444
|
-
function W(
|
|
2445
|
-
return
|
|
2249
|
+
_e.moduleName = "snapper";
|
|
2250
|
+
let Xe = _e;
|
|
2251
|
+
function W(r) {
|
|
2252
|
+
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2446
2253
|
}
|
|
2447
|
-
function
|
|
2254
|
+
function Ge(r) {
|
|
2448
2255
|
return parseInt(
|
|
2449
|
-
|
|
2450
|
-
|
|
2256
|
+
r.getComputedStyle(
|
|
2257
|
+
r.document.documentElement
|
|
2451
2258
|
).getPropertyValue("column-count")
|
|
2452
2259
|
);
|
|
2453
2260
|
}
|
|
2454
|
-
function
|
|
2455
|
-
const e = "
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
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 = "​", r.document.body.appendChild(h);
|
|
2274
|
+
}
|
|
2463
2275
|
}
|
|
2464
|
-
function
|
|
2465
|
-
return
|
|
2276
|
+
function Wt(r) {
|
|
2277
|
+
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2466
2278
|
}
|
|
2467
|
-
function T(
|
|
2468
|
-
const e =
|
|
2279
|
+
function T(r) {
|
|
2280
|
+
const e = r.getSelection();
|
|
2469
2281
|
e && e.removeAllRanges();
|
|
2470
2282
|
}
|
|
2471
|
-
const
|
|
2283
|
+
const Ft = [
|
|
2472
2284
|
"a",
|
|
2473
2285
|
"audio",
|
|
2474
2286
|
"button",
|
|
@@ -2482,46 +2294,57 @@ const bi = [
|
|
|
2482
2294
|
"textarea",
|
|
2483
2295
|
"video"
|
|
2484
2296
|
];
|
|
2485
|
-
function
|
|
2297
|
+
function Ye(r) {
|
|
2486
2298
|
var e;
|
|
2487
|
-
return
|
|
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;
|
|
2488
2300
|
}
|
|
2489
|
-
function
|
|
2490
|
-
const t =
|
|
2491
|
-
|
|
2301
|
+
function Ke(r, e) {
|
|
2302
|
+
const t = Ze(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {
|
|
2303
|
+
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2304
|
+
});
|
|
2305
|
+
return new D({
|
|
2492
2306
|
href: "#",
|
|
2493
2307
|
type: "application/xhtml+xml",
|
|
2494
|
-
locations: new
|
|
2308
|
+
locations: new x({
|
|
2495
2309
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2496
|
-
["cssSelector", i
|
|
2310
|
+
["cssSelector", i]
|
|
2497
2311
|
])
|
|
2498
2312
|
}),
|
|
2499
|
-
text: new
|
|
2313
|
+
text: new U({
|
|
2500
2314
|
highlight: t.textContent || void 0
|
|
2501
2315
|
})
|
|
2502
2316
|
});
|
|
2503
2317
|
}
|
|
2504
|
-
function
|
|
2505
|
-
for (var
|
|
2506
|
-
const s = e.children[
|
|
2507
|
-
if (!
|
|
2508
|
-
return
|
|
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);
|
|
2509
2323
|
}
|
|
2510
2324
|
return e;
|
|
2511
2325
|
}
|
|
2512
|
-
function
|
|
2326
|
+
function Bt(r, e, t) {
|
|
2513
2327
|
if (e === document.body || e === document.documentElement)
|
|
2514
2328
|
return !0;
|
|
2515
2329
|
if (!document || !document.documentElement || !document.body)
|
|
2516
2330
|
return !1;
|
|
2517
|
-
const
|
|
2518
|
-
return t ?
|
|
2519
|
-
}
|
|
2520
|
-
function
|
|
2521
|
-
const
|
|
2522
|
-
return
|
|
2331
|
+
const i = e.getBoundingClientRect();
|
|
2332
|
+
return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2333
|
+
}
|
|
2334
|
+
function Ut(r, e) {
|
|
2335
|
+
const t = e.getBoundingClientRect();
|
|
2336
|
+
return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;
|
|
2337
|
+
}
|
|
2338
|
+
function kt(r) {
|
|
2339
|
+
const e = getComputedStyle(r);
|
|
2340
|
+
if (e) {
|
|
2341
|
+
const t = e.getPropertyValue("display");
|
|
2342
|
+
if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
|
|
2343
|
+
return !0;
|
|
2344
|
+
}
|
|
2345
|
+
return !1;
|
|
2523
2346
|
}
|
|
2524
|
-
const
|
|
2347
|
+
const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
2525
2348
|
constructor() {
|
|
2526
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);
|
|
2527
2350
|
}
|
|
@@ -2557,28 +2380,28 @@ const Ge = "readium-column-snapper-style", wi = 200, wt = class C extends vt {
|
|
|
2557
2380
|
}
|
|
2558
2381
|
// Snaps the current offset to the page width.
|
|
2559
2382
|
snapCurrentOffset(e = !1, t = !1) {
|
|
2560
|
-
const
|
|
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 = (
|
|
2561
2384
|
// The hurdle to overcome in order to change pages
|
|
2562
2385
|
h * (this.wnd.innerWidth / 3) * (h * n > 0 ? 2 : 1)
|
|
2563
|
-
),
|
|
2564
|
-
if (e &&
|
|
2386
|
+
), d = this.snapOffset(a + c);
|
|
2387
|
+
if (e && d !== this.scrollOffset()) {
|
|
2565
2388
|
this.snappingCancelled = !1;
|
|
2566
|
-
const p = (
|
|
2389
|
+
const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O), u = (
|
|
2567
2390
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2568
|
-
|
|
2391
|
+
Ht * o
|
|
2569
2392
|
);
|
|
2570
2393
|
let f;
|
|
2571
|
-
const
|
|
2394
|
+
const g = (m) => {
|
|
2572
2395
|
if (this.snappingCancelled)
|
|
2573
2396
|
return;
|
|
2574
|
-
f || (f =
|
|
2575
|
-
const
|
|
2576
|
-
s.scrollLeft =
|
|
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());
|
|
2577
2400
|
};
|
|
2578
|
-
this.wnd.requestAnimationFrame(
|
|
2401
|
+
this.wnd.requestAnimationFrame(g);
|
|
2579
2402
|
} else
|
|
2580
2403
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2581
|
-
s.scrollLeft =
|
|
2404
|
+
s.scrollLeft = d, this.clearTouches(), t || this.reportProgress();
|
|
2582
2405
|
});
|
|
2583
2406
|
}
|
|
2584
2407
|
dragOffset() {
|
|
@@ -2603,8 +2426,8 @@ const Ge = "readium-column-snapper-style", wi = 200, wt = class C extends vt {
|
|
|
2603
2426
|
}
|
|
2604
2427
|
onTouchEnd(e) {
|
|
2605
2428
|
if (this.touchState === 2) {
|
|
2606
|
-
const t = this.dragOffset(),
|
|
2607
|
-
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)) :
|
|
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);
|
|
2608
2431
|
}
|
|
2609
2432
|
this.touchState = 0;
|
|
2610
2433
|
}
|
|
@@ -2615,15 +2438,15 @@ const Ge = "readium-column-snapper-style", wi = 200, wt = class C extends vt {
|
|
|
2615
2438
|
if (this.touchState === 0)
|
|
2616
2439
|
return;
|
|
2617
2440
|
this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = e.touches[0].clientX;
|
|
2618
|
-
const t = this.dragOffset(),
|
|
2619
|
-
|
|
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);
|
|
2620
2443
|
}
|
|
2621
2444
|
mount(e, t) {
|
|
2622
2445
|
if (this.wnd = e, this.comms = t, !super.mount(e, t))
|
|
2623
2446
|
return !1;
|
|
2624
2447
|
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2448
|
+
const i = e.document.createElement("style");
|
|
2449
|
+
i.dataset.readium = "true", i.id = Ie, i.textContent = `
|
|
2627
2450
|
@keyframes readium-bounce-l-animation {
|
|
2628
2451
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2629
2452
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2657,131 +2480,121 @@ const Ge = "readium-column-snapper-style", wi = 200, wt = class C extends vt {
|
|
|
2657
2480
|
body::-webkit-scrollbar {
|
|
2658
2481
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2659
2482
|
}
|
|
2660
|
-
`, e.document.head.appendChild(
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
})
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
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;
|
|
2670
2500
|
};
|
|
2671
|
-
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression",
|
|
2672
|
-
const
|
|
2673
|
-
if (
|
|
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) {
|
|
2674
2504
|
t.send("error", {
|
|
2675
2505
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2676
|
-
}),
|
|
2506
|
+
}), o(!1);
|
|
2677
2507
|
return;
|
|
2678
2508
|
}
|
|
2679
2509
|
this.wnd.requestAnimationFrame(() => {
|
|
2680
2510
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2681
|
-
const
|
|
2682
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
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);
|
|
2683
2513
|
});
|
|
2684
|
-
}), t.register("go_id",
|
|
2685
|
-
const
|
|
2686
|
-
if (!
|
|
2687
|
-
|
|
2514
|
+
}), t.register("go_id", w.moduleName, (n, o) => {
|
|
2515
|
+
const a = e.document.getElementById(n);
|
|
2516
|
+
if (!a) {
|
|
2517
|
+
o(!1);
|
|
2688
2518
|
return;
|
|
2689
2519
|
}
|
|
2690
2520
|
this.wnd.requestAnimationFrame(() => {
|
|
2691
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2521
|
+
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
|
|
2692
2522
|
});
|
|
2693
|
-
}), t.register("go_text",
|
|
2694
|
-
let
|
|
2695
|
-
Array.isArray(
|
|
2696
|
-
const
|
|
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({
|
|
2697
2527
|
href: e.location.href,
|
|
2698
2528
|
type: "text/html",
|
|
2699
|
-
text:
|
|
2700
|
-
locations:
|
|
2529
|
+
text: h,
|
|
2530
|
+
locations: a ? new x({
|
|
2701
2531
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2702
|
-
["cssSelector",
|
|
2532
|
+
["cssSelector", a]
|
|
2703
2533
|
])
|
|
2704
2534
|
}) : void 0
|
|
2705
2535
|
}));
|
|
2706
|
-
if (!
|
|
2707
|
-
|
|
2536
|
+
if (!c) {
|
|
2537
|
+
o(!1);
|
|
2708
2538
|
return;
|
|
2709
2539
|
}
|
|
2710
2540
|
this.wnd.requestAnimationFrame(() => {
|
|
2711
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2541
|
+
this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
|
|
2712
2542
|
});
|
|
2713
|
-
}), t.register("go_end",
|
|
2714
|
-
const
|
|
2543
|
+
}), t.register("go_end", w.moduleName, (n, o) => {
|
|
2544
|
+
const a = W(e) ? -1 : 1;
|
|
2715
2545
|
this.wnd.requestAnimationFrame(() => {
|
|
2716
2546
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2717
|
-
const
|
|
2718
|
-
if (this.doc().scrollLeft ===
|
|
2719
|
-
return
|
|
2720
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
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);
|
|
2721
2551
|
});
|
|
2722
|
-
}), t.register("go_start",
|
|
2552
|
+
}), t.register("go_start", w.moduleName, (n, o) => {
|
|
2723
2553
|
this.wnd.requestAnimationFrame(() => {
|
|
2724
2554
|
if (this.doc().scrollLeft === 0)
|
|
2725
|
-
return
|
|
2726
|
-
this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd),
|
|
2555
|
+
return o(!1);
|
|
2556
|
+
this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
|
|
2727
2557
|
});
|
|
2728
|
-
}), t.register("go_prev",
|
|
2558
|
+
}), t.register("go_prev", w.moduleName, (n, o) => {
|
|
2729
2559
|
this.wnd.requestAnimationFrame(() => {
|
|
2730
|
-
|
|
2731
|
-
|
|
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);
|
|
2732
2563
|
});
|
|
2733
|
-
}), t.register("go_next",
|
|
2564
|
+
}), t.register("go_next", w.moduleName, (n, o) => {
|
|
2734
2565
|
this.wnd.requestAnimationFrame(() => {
|
|
2735
|
-
|
|
2736
|
-
|
|
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);
|
|
2737
2569
|
});
|
|
2738
|
-
}), t.register("unfocus",
|
|
2739
|
-
this.snappingCancelled = !0, T(this.wnd),
|
|
2740
|
-
}), t.register("shake",
|
|
2741
|
-
this.shake(),
|
|
2742
|
-
}), t.register("focus",
|
|
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) => {
|
|
2743
2575
|
this.wnd.requestAnimationFrame(() => {
|
|
2744
|
-
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(),
|
|
2576
|
+
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2745
2577
|
});
|
|
2746
|
-
}), t.register("first_visible_locator",
|
|
2747
|
-
const
|
|
2748
|
-
this.comms.send("first_visible_locator",
|
|
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);
|
|
2749
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", () => {
|
|
2750
2582
|
}), t.log("ColumnSnapper Mounted"), !0;
|
|
2751
2583
|
}
|
|
2752
2584
|
unmount(e, t) {
|
|
2753
|
-
var
|
|
2754
|
-
return this.snappingCancelled = !0, t.unregisterAll(
|
|
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);
|
|
2755
2587
|
}
|
|
2756
2588
|
};
|
|
2757
|
-
|
|
2758
|
-
let
|
|
2759
|
-
const
|
|
2760
|
-
top: "js-iframe-reader-top-anchor",
|
|
2761
|
-
bottom: "js-iframe-reader-bottom-anchor"
|
|
2762
|
-
};
|
|
2763
|
-
class Si extends HTMLElement {
|
|
2764
|
-
connectedCallback() {
|
|
2765
|
-
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");
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
function Ci(i) {
|
|
2769
|
-
const e = i.getElementsByTagName("body")[0], t = document.createElement("anchor-observer"), r = document.createElement("anchor-observer");
|
|
2770
|
-
t.dataset.readium = "true", r.dataset.readium = "true", t == null || t.setAttribute("id", he.top), t == null || t.style.setProperty("height", "115px", "important"), r == null || r.setAttribute("id", he.bottom), r == null || r.style.setProperty("height", "80px", "important"), e == null || e.insertBefore(t, e.firstChild), e == null || e.appendChild(r);
|
|
2771
|
-
}
|
|
2772
|
-
function Oi(i) {
|
|
2773
|
-
var s, n;
|
|
2774
|
-
const e = i.getElementsByTagName("body")[0], t = e == null ? void 0 : e.querySelector(`#${he.top}`), r = e == null ? void 0 : e.querySelector(`#${he.bottom}`);
|
|
2775
|
-
t && ((s = t.parentElement) == null || s.removeChild(t)), r && ((n = r.parentElement) == null || n.removeChild(r));
|
|
2776
|
-
}
|
|
2777
|
-
const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
2589
|
+
Je.moduleName = "column_snapper";
|
|
2590
|
+
let $t = Je;
|
|
2591
|
+
const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
|
|
2778
2592
|
constructor() {
|
|
2779
|
-
super(...arguments), this.
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
customElements.get("anchor-observer") || customElements.define("anchor-observer", Si);
|
|
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
|
+
}));
|
|
2785
2598
|
};
|
|
2786
2599
|
}
|
|
2787
2600
|
doc() {
|
|
@@ -2792,8 +2605,8 @@ const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
|
2792
2605
|
}
|
|
2793
2606
|
mount(e, t) {
|
|
2794
2607
|
this.wnd = e, this.comms = t, e.navigator.epubReadingSystem.layoutStyle = "scrolling";
|
|
2795
|
-
const
|
|
2796
|
-
return
|
|
2608
|
+
const i = e.document.createElement("style");
|
|
2609
|
+
return i.dataset.readium = "true", i.id = Le, i.textContent = `
|
|
2797
2610
|
* {
|
|
2798
2611
|
scrollbar-width: none; /* for Firefox */
|
|
2799
2612
|
}
|
|
@@ -2801,7 +2614,11 @@ const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
|
2801
2614
|
body::-webkit-scrollbar {
|
|
2802
2615
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2803
2616
|
}
|
|
2804
|
-
`, e.document.head.appendChild(
|
|
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) => {
|
|
2805
2622
|
const o = s;
|
|
2806
2623
|
if (o < 0 || o > 1) {
|
|
2807
2624
|
t.send("error", {
|
|
@@ -2812,7 +2629,7 @@ const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
|
2812
2629
|
this.wnd.requestAnimationFrame(() => {
|
|
2813
2630
|
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
|
|
2814
2631
|
});
|
|
2815
|
-
}), t.register("go_id",
|
|
2632
|
+
}), t.register("go_id", A.moduleName, (s, n) => {
|
|
2816
2633
|
const o = e.document.getElementById(s);
|
|
2817
2634
|
if (!o) {
|
|
2818
2635
|
n(!1);
|
|
@@ -2823,14 +2640,14 @@ const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
|
2823
2640
|
const a = this.doc().scrollTop / this.doc().offsetHeight;
|
|
2824
2641
|
this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
|
|
2825
2642
|
});
|
|
2826
|
-
}), t.register("go_text",
|
|
2643
|
+
}), t.register("go_text", A.moduleName, (s, n) => {
|
|
2827
2644
|
let o;
|
|
2828
2645
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
2829
|
-
const a =
|
|
2646
|
+
const a = U.deserialize(s), h = le(this.wnd.document, new D({
|
|
2830
2647
|
href: e.location.href,
|
|
2831
2648
|
type: "text/html",
|
|
2832
2649
|
text: a,
|
|
2833
|
-
locations: o ? new
|
|
2650
|
+
locations: o ? new x({
|
|
2834
2651
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2835
2652
|
["cssSelector", o]
|
|
2836
2653
|
])
|
|
@@ -2845,35 +2662,35 @@ const Ye = "readium-scroll-snapper-style", Tt = class M extends vt {
|
|
|
2845
2662
|
const c = this.doc().scrollTop / this.doc().offsetHeight;
|
|
2846
2663
|
this.reportProgress({ progress: c, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
|
|
2847
2664
|
});
|
|
2848
|
-
}), t.register("go_start",
|
|
2665
|
+
}), t.register("go_start", A.moduleName, (s, n) => {
|
|
2849
2666
|
if (this.doc().scrollTop === 0)
|
|
2850
2667
|
return n(!1);
|
|
2851
2668
|
this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
|
|
2852
|
-
}), t.register("go_end",
|
|
2669
|
+
}), t.register("go_end", A.moduleName, (s, n) => {
|
|
2853
2670
|
if (this.doc().scrollTop === 0)
|
|
2854
2671
|
return n(!1);
|
|
2855
2672
|
this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
|
|
2856
|
-
}), t.register("unfocus",
|
|
2673
|
+
}), t.register("unfocus", A.moduleName, (s, n) => {
|
|
2857
2674
|
T(this.wnd), n(!0);
|
|
2858
2675
|
}), t.register([
|
|
2859
2676
|
"go_next",
|
|
2860
2677
|
"go_prev"
|
|
2861
|
-
],
|
|
2678
|
+
], A.moduleName, (s, n) => n(!1)), t.register("focus", A.moduleName, (s, n) => {
|
|
2862
2679
|
const o = this.doc().scrollTop / this.doc().offsetHeight;
|
|
2863
2680
|
this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
|
|
2864
|
-
}), t.register("first_visible_locator",
|
|
2865
|
-
const o =
|
|
2681
|
+
}), t.register("first_visible_locator", A.moduleName, (s, n) => {
|
|
2682
|
+
const o = Ke(e, !0);
|
|
2866
2683
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2867
|
-
}), t.log("ScrollSnapper Mounted"),
|
|
2684
|
+
}), t.log("ScrollSnapper Mounted"), !0;
|
|
2868
2685
|
}
|
|
2869
2686
|
unmount(e, t) {
|
|
2870
|
-
var
|
|
2871
|
-
return t.unregisterAll(
|
|
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;
|
|
2872
2689
|
}
|
|
2873
2690
|
};
|
|
2874
|
-
|
|
2875
|
-
let
|
|
2876
|
-
class
|
|
2691
|
+
Qe.moduleName = "scroll_snapper";
|
|
2692
|
+
let jt = Qe;
|
|
2693
|
+
class et extends Y {
|
|
2877
2694
|
constructor() {
|
|
2878
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);
|
|
2879
2696
|
}
|
|
@@ -2884,12 +2701,12 @@ class St extends ce {
|
|
|
2884
2701
|
const c = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
|
|
2885
2702
|
if (!c || c.length === 0)
|
|
2886
2703
|
return;
|
|
2887
|
-
const
|
|
2704
|
+
const d = c[0], p = {
|
|
2888
2705
|
text: t.toString(),
|
|
2889
|
-
x:
|
|
2890
|
-
y:
|
|
2891
|
-
width:
|
|
2892
|
-
height:
|
|
2706
|
+
x: d.x,
|
|
2707
|
+
y: d.y,
|
|
2708
|
+
width: d.width,
|
|
2709
|
+
height: d.height,
|
|
2893
2710
|
targetFrameSrc: (a = (o = this.wnd) == null ? void 0 : o.location) == null ? void 0 : a.href
|
|
2894
2711
|
};
|
|
2895
2712
|
this.comms.send("text_selected", p);
|
|
@@ -2900,14 +2717,14 @@ class St extends ce {
|
|
|
2900
2717
|
}
|
|
2901
2718
|
if (!(t != null && t.isCollapsed) || !e.isPrimary)
|
|
2902
2719
|
return;
|
|
2903
|
-
const
|
|
2720
|
+
const i = this.wnd.devicePixelRatio;
|
|
2904
2721
|
e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
|
|
2905
2722
|
defaultPrevented: e.defaultPrevented,
|
|
2906
|
-
x: e.clientX *
|
|
2907
|
-
y: e.clientY *
|
|
2723
|
+
x: e.clientX * i,
|
|
2724
|
+
y: e.clientY * i,
|
|
2908
2725
|
targetFrameSrc: this.wnd.location.href,
|
|
2909
2726
|
targetElement: e.target.outerHTML,
|
|
2910
|
-
interactiveElement: (h =
|
|
2727
|
+
interactiveElement: (h = Ye(e.target)) == null ? void 0 : h.outerHTML,
|
|
2911
2728
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
|
|
2912
2729
|
}), this.pointerMoved = !1;
|
|
2913
2730
|
}
|
|
@@ -2943,8 +2760,8 @@ class St extends ce {
|
|
|
2943
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;
|
|
2944
2761
|
}
|
|
2945
2762
|
}
|
|
2946
|
-
|
|
2947
|
-
const
|
|
2763
|
+
et.moduleName = "peripherals";
|
|
2764
|
+
const tt = class te extends Y {
|
|
2948
2765
|
constructor() {
|
|
2949
2766
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
2950
2767
|
}
|
|
@@ -2960,13 +2777,13 @@ const Ct = class be extends ce {
|
|
|
2960
2777
|
unblock(e) {
|
|
2961
2778
|
var t;
|
|
2962
2779
|
for (e._readium_blockEvents = !1; ((t = e._readium_blockedEvents) == null ? void 0 : t.length) > 0; ) {
|
|
2963
|
-
const
|
|
2964
|
-
switch (
|
|
2780
|
+
const i = e._readium_blockedEvents.shift();
|
|
2781
|
+
switch (i[0]) {
|
|
2965
2782
|
case 0:
|
|
2966
|
-
Reflect.apply(
|
|
2783
|
+
Reflect.apply(i[1], i[2], i[3]);
|
|
2967
2784
|
break;
|
|
2968
2785
|
case 1:
|
|
2969
|
-
const s =
|
|
2786
|
+
const s = i[1], n = i[2];
|
|
2970
2787
|
e.removeEventListener(s.type, e._readium_eventBlocker, !0);
|
|
2971
2788
|
const o = new Event(s.type, {
|
|
2972
2789
|
bubbles: s.bubbles,
|
|
@@ -2987,8 +2804,8 @@ const Ct = class be extends ce {
|
|
|
2987
2804
|
}
|
|
2988
2805
|
pauseAllMedia(e) {
|
|
2989
2806
|
const t = e.document.querySelectorAll("audio,video");
|
|
2990
|
-
for (let
|
|
2991
|
-
t[
|
|
2807
|
+
for (let i = 0; i < t.length; i++)
|
|
2808
|
+
t[i].pause();
|
|
2992
2809
|
}
|
|
2993
2810
|
mount(e, t) {
|
|
2994
2811
|
this.comms = t, e.addEventListener(
|
|
@@ -2998,7 +2815,7 @@ const Ct = class be extends ce {
|
|
|
2998
2815
|
), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
|
|
2999
2816
|
value: {
|
|
3000
2817
|
name: "readium-ts-toolkit",
|
|
3001
|
-
version: "
|
|
2818
|
+
version: "2.0.0-beta.1",
|
|
3002
2819
|
hasFeature: (s, n = "") => {
|
|
3003
2820
|
switch (s) {
|
|
3004
2821
|
case "dom-manipulation":
|
|
@@ -3023,16 +2840,16 @@ const Ct = class be extends ce {
|
|
|
3023
2840
|
writable: !1
|
|
3024
2841
|
}), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {
|
|
3025
2842
|
s.cancel(), this.allAnimations.add(s);
|
|
3026
|
-
}), t.register("activate",
|
|
2843
|
+
}), t.register("activate", te.moduleName, (s, n) => {
|
|
3027
2844
|
this.allAnimations.forEach((o) => {
|
|
3028
2845
|
o.cancel(), o.play();
|
|
3029
2846
|
}), n(!0);
|
|
3030
|
-
}), t.register("unfocus",
|
|
2847
|
+
}), t.register("unfocus", te.moduleName, (s, n) => {
|
|
3031
2848
|
this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
3032
2849
|
});
|
|
3033
|
-
const
|
|
3034
|
-
for (let s = 0; s <
|
|
3035
|
-
const n =
|
|
2850
|
+
const i = e.document.querySelectorAll("audio,video");
|
|
2851
|
+
for (let s = 0; s < i.length; s++) {
|
|
2852
|
+
const n = i[s];
|
|
3036
2853
|
n.addEventListener("play", this.onMediaPlayEvent, {
|
|
3037
2854
|
passive: !0
|
|
3038
2855
|
}), n.addEventListener("pause", this.onMediaPauseEvent, {
|
|
@@ -3042,48 +2859,52 @@ const Ct = class be extends ce {
|
|
|
3042
2859
|
return t.log("Setup Mounted"), !0;
|
|
3043
2860
|
}
|
|
3044
2861
|
unmount(e, t) {
|
|
3045
|
-
return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((
|
|
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;
|
|
3046
2863
|
}
|
|
3047
2864
|
};
|
|
3048
|
-
|
|
3049
|
-
let
|
|
3050
|
-
const
|
|
2865
|
+
tt.moduleName = "setup";
|
|
2866
|
+
let it = tt;
|
|
2867
|
+
const Re = "readium-viewport", rt = class F extends it {
|
|
3051
2868
|
onViewportWidthChanged(e) {
|
|
3052
2869
|
const t = e.target;
|
|
3053
|
-
|
|
2870
|
+
G(t, "--RS__viewportWidth", `${t.innerWidth}px`);
|
|
3054
2871
|
}
|
|
3055
2872
|
mount(e, t) {
|
|
3056
2873
|
if (!super.mount(e, t))
|
|
3057
2874
|
return !1;
|
|
3058
|
-
const
|
|
3059
|
-
return
|
|
2875
|
+
const i = e.document.createElement("meta");
|
|
2876
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Re), i.setAttribute(
|
|
3060
2877
|
"content",
|
|
3061
2878
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3062
|
-
), e.document.head.appendChild(
|
|
2879
|
+
), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3063
2880
|
target: e
|
|
3064
|
-
}), t.register("
|
|
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) => {
|
|
3065
2886
|
const o = s;
|
|
3066
|
-
|
|
3067
|
-
}), t.register("remove_property",
|
|
3068
|
-
|
|
3069
|
-
}), t.register("activate",
|
|
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) => {
|
|
3070
2891
|
this.unblock(e), n(!0);
|
|
3071
2892
|
}), t.log("ReflowableSetup Mounted"), !0;
|
|
3072
2893
|
}
|
|
3073
2894
|
unmount(e, t) {
|
|
3074
|
-
var
|
|
3075
|
-
return t.unregisterAll(
|
|
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);
|
|
3076
2897
|
}
|
|
3077
2898
|
};
|
|
3078
|
-
|
|
3079
|
-
let
|
|
3080
|
-
const
|
|
2899
|
+
rt.moduleName = "reflowable_setup";
|
|
2900
|
+
let qt = rt;
|
|
2901
|
+
const ze = "readium-fixed-style", st = class L extends it {
|
|
3081
2902
|
mount(e, t) {
|
|
3082
2903
|
if (!super.mount(e, t))
|
|
3083
2904
|
return !1;
|
|
3084
2905
|
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
3085
|
-
const
|
|
3086
|
-
return
|
|
2906
|
+
const i = e.document.createElement("style");
|
|
2907
|
+
return i.id = ze, i.dataset.readium = "true", i.textContent = `
|
|
3087
2908
|
html, body {
|
|
3088
2909
|
text-size-adjust: none;
|
|
3089
2910
|
-ms-text-size-adjust: none;
|
|
@@ -3095,11 +2916,11 @@ const Je = "readium-fixed-style", At = class L extends Ot {
|
|
|
3095
2916
|
min-height: 100%;
|
|
3096
2917
|
|
|
3097
2918
|
/*cursor: var() TODO*/
|
|
3098
|
-
}`, e.document.head.appendChild(
|
|
2919
|
+
}`, e.document.head.appendChild(i), t.register("set_property", L.moduleName, (s, n) => {
|
|
3099
2920
|
const o = s;
|
|
3100
|
-
|
|
2921
|
+
G(e, o[0], o[1]), n(!0);
|
|
3101
2922
|
}), t.register("remove_property", L.moduleName, (s, n) => {
|
|
3102
|
-
|
|
2923
|
+
he(e, s), n(!0);
|
|
3103
2924
|
}), t.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), t.register("unfocus", L.moduleName, (s, n) => {
|
|
3104
2925
|
T(e), n(!0);
|
|
3105
2926
|
}), t.register([
|
|
@@ -3116,43 +2937,43 @@ const Je = "readium-fixed-style", At = class L extends Ot {
|
|
|
3116
2937
|
}), t.log("FixedSetup Mounted"), !0;
|
|
3117
2938
|
}
|
|
3118
2939
|
unmount(e, t) {
|
|
3119
|
-
var
|
|
3120
|
-
return t.unregisterAll(L.moduleName), (
|
|
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);
|
|
3121
2942
|
}
|
|
3122
2943
|
};
|
|
3123
|
-
|
|
3124
|
-
let
|
|
3125
|
-
const
|
|
2944
|
+
st.moduleName = "fixed_setup";
|
|
2945
|
+
let Vt = st;
|
|
2946
|
+
const _t = [
|
|
3126
2947
|
"fixed_setup",
|
|
3127
2948
|
"decorator",
|
|
3128
2949
|
"peripherals"
|
|
3129
|
-
],
|
|
2950
|
+
], Xt = [
|
|
3130
2951
|
"reflowable_setup",
|
|
3131
2952
|
"decorator",
|
|
3132
2953
|
"peripherals",
|
|
3133
2954
|
"column_snapper",
|
|
3134
2955
|
"scroll_snapper"
|
|
3135
|
-
],
|
|
2956
|
+
], De = new Map([
|
|
3136
2957
|
// All modules go here
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
].map((
|
|
3144
|
-
class
|
|
2958
|
+
Vt,
|
|
2959
|
+
qt,
|
|
2960
|
+
et,
|
|
2961
|
+
Dt,
|
|
2962
|
+
$t,
|
|
2963
|
+
jt
|
|
2964
|
+
].map((r) => [r.moduleName, r]));
|
|
2965
|
+
class Gt {
|
|
3145
2966
|
/**
|
|
3146
2967
|
* @param wnd Window instance to operate on
|
|
3147
2968
|
* @param initialModules List of initial modules to load
|
|
3148
2969
|
*/
|
|
3149
2970
|
constructor(e = window, t = []) {
|
|
3150
|
-
this.loadedModules = [], this.wnd = e, this.comms = new
|
|
3151
|
-
const
|
|
3152
|
-
if (
|
|
2971
|
+
this.loadedModules = [], this.wnd = e, this.comms = new at(e);
|
|
2972
|
+
const i = [...new Set(t)];
|
|
2973
|
+
if (i.length) {
|
|
3153
2974
|
if (typeof e > "u")
|
|
3154
2975
|
throw Error("Loader is not in a web browser");
|
|
3155
|
-
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules =
|
|
2976
|
+
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
|
|
3156
2977
|
const n = this.loadModule(s);
|
|
3157
2978
|
if (n)
|
|
3158
2979
|
return n.mount(this.wnd, this.comms), n;
|
|
@@ -3160,7 +2981,7 @@ class Li {
|
|
|
3160
2981
|
}
|
|
3161
2982
|
}
|
|
3162
2983
|
loadModule(e) {
|
|
3163
|
-
const t =
|
|
2984
|
+
const t = De.get(e);
|
|
3164
2985
|
return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
|
|
3165
2986
|
}
|
|
3166
2987
|
/**
|
|
@@ -3178,11 +2999,11 @@ class Li {
|
|
|
3178
2999
|
* @returns Success
|
|
3179
3000
|
*/
|
|
3180
3001
|
removeModule(e) {
|
|
3181
|
-
const t =
|
|
3002
|
+
const t = De.get(e);
|
|
3182
3003
|
if (t === void 0)
|
|
3183
3004
|
return this.comms.log(`Module "${e}" does not exist in the library`), !1;
|
|
3184
|
-
const
|
|
3185
|
-
return
|
|
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);
|
|
3186
3007
|
}
|
|
3187
3008
|
/**
|
|
3188
3009
|
* Unmount and remove all modules
|
|
@@ -3192,16 +3013,16 @@ class Li {
|
|
|
3192
3013
|
}
|
|
3193
3014
|
}
|
|
3194
3015
|
export {
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
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
|
|
3207
3028
|
};
|