@readium/navigator-html-injectables 2.4.4 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Loader.js +1 -0
- package/dist/comms/comms.js +1 -0
- package/dist/comms/mid.js +1 -0
- package/dist/helpers/animation.js +1 -0
- package/dist/helpers/css.js +1 -0
- package/dist/helpers/document.js +1 -0
- package/dist/helpers/dom.js +1 -0
- package/dist/helpers/locator.js +1 -0
- package/dist/helpers/rect.js +1 -0
- package/dist/helpers/sanitize.js +1 -0
- package/dist/index.js +1 -4174
- package/dist/keyboard/KeyCombinationManager.js +1 -0
- package/dist/keyboard/KeyboardCombinations.js +1 -0
- package/dist/modules/Decorator.js +24 -0
- package/dist/modules/Module.js +1 -0
- package/dist/modules/ModuleLibrary.js +1 -0
- package/dist/modules/Peripherals.js +1 -0
- package/dist/modules/setup/FixedSetup.js +13 -0
- package/dist/modules/setup/ReflowableSetup.js +1 -0
- package/dist/modules/setup/Setup.js +1 -0
- package/dist/modules/setup/WebPubSetup.js +1 -0
- package/dist/modules/snapper/CJKVerticalSnapper.js +12 -0
- package/dist/modules/snapper/ColumnSnapper.js +35 -0
- package/dist/modules/snapper/ScrollSnapper.js +9 -0
- package/dist/modules/snapper/Snapper.js +5 -0
- package/dist/modules/snapper/WebPubSnapper.js +1 -0
- package/dist/protection/BulkCopyProtector.js +1 -0
- package/dist/protection/PatternAnalyzer.js +1 -0
- package/dist/protection/PrintProtector.js +15 -0
- package/dist/protection/SelectionAnalyzer.js +1 -0
- package/dist/protection/config.js +1 -0
- package/dist/vendor/approx-string-match/index.js +1 -0
- package/dist/vendor/hypothesis/anchoring/match-quote.js +1 -0
- package/dist/vendor/hypothesis/anchoring/text-range.js +1 -0
- package/dist/vendor/hypothesis/anchoring/trim-range.js +1 -0
- package/dist/vendor/hypothesis/anchoring/types.js +1 -0
- package/package.json +9 -7
- package/src/comms/comms.ts +11 -1
- package/src/comms/keys.ts +8 -3
- package/src/helpers/css.ts +30 -1
- package/src/helpers/document.ts +123 -3
- package/src/helpers/locator.ts +5 -5
- package/src/helpers/rect.ts +88 -22
- package/src/helpers/sanitize.ts +77 -0
- package/src/index.ts +2 -1
- package/src/modules/Decorator.ts +924 -178
- package/src/modules/Peripherals.ts +3 -0
- package/src/modules/snapper/CJKVerticalSnapper.ts +34 -7
- package/src/modules/snapper/ColumnSnapper.ts +56 -7
- package/src/modules/snapper/ScrollSnapper.ts +30 -7
- package/src/modules/snapper/Snapper.ts +144 -0
- package/src/modules/snapper/WebPubSnapper.ts +31 -7
- package/types/src/comms/comms.d.ts +10 -1
- package/types/src/comms/keys.d.ts +2 -2
- package/types/src/helpers/css.d.ts +7 -1
- package/types/src/helpers/document.d.ts +69 -3
- package/types/src/helpers/rect.d.ts +2 -1
- package/types/src/helpers/sanitize.d.ts +13 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/modules/Decorator.d.ts +92 -17
- package/types/src/modules/Peripherals.d.ts +3 -0
- package/types/src/modules/snapper/CJKVerticalSnapper.d.ts +1 -0
- package/types/src/modules/snapper/ColumnSnapper.d.ts +14 -1
- package/types/src/modules/snapper/ScrollSnapper.d.ts +1 -0
- package/types/src/modules/snapper/Snapper.d.ts +58 -0
- package/types/src/modules/snapper/WebPubSnapper.d.ts +1 -0
- package/dist/ar-DyHX_uy2.js +0 -7
- package/dist/da-Dct0PS3E.js +0 -7
- package/dist/fr-C5HEel98.js +0 -7
- package/dist/index.umd.cjs +0 -95
- package/dist/it-DFOBoXGy.js +0 -7
- package/dist/pt_PT-Di3sVjze.js +0 -7
- package/dist/sv-BfzAFsVN.js +0 -7
- package/src/helpers/color.ts +0 -205
- package/types/src/helpers/color.d.ts +0 -26
package/dist/index.js
CHANGED
|
@@ -1,4174 +1 @@
|
|
|
1
|
-
|
|
2
|
-
class Be {
|
|
3
|
-
constructor(t) {
|
|
4
|
-
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
|
|
5
|
-
}
|
|
6
|
-
receive(t) {
|
|
7
|
-
if (t.source === null) throw Error("Event source is null");
|
|
8
|
-
if (typeof t.data != "object") return;
|
|
9
|
-
const e = t.data;
|
|
10
|
-
if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
|
|
11
|
-
if (e.key === "_ping") {
|
|
12
|
-
if (!this.destination) {
|
|
13
|
-
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== Z) {
|
|
14
|
-
e._readium > Z ? this.send("error", `received comms version ${e._readium} higher than ${Z}`) : this.send("error", `received comms version ${e._readium} lower than ${Z}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
} else if (this.channelId) {
|
|
21
|
-
if (e._channel !== this.channelId || t.origin !== this.origin) return;
|
|
22
|
-
} else
|
|
23
|
-
return;
|
|
24
|
-
this.handle(e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
handle(t) {
|
|
28
|
-
const e = this.registrar.get(t.key);
|
|
29
|
-
if (!e || e.length === 0) {
|
|
30
|
-
t.strict && this.send("_unhandled", t);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
e.forEach((i) => i.cb(t.data, (s) => {
|
|
34
|
-
this.send("_ack", s, t.id);
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
register(t, e, i) {
|
|
38
|
-
Array.isArray(t) || (t = [t]), t.forEach((s) => {
|
|
39
|
-
const r = this.registrar.get(s);
|
|
40
|
-
if (r && r.length >= 0) {
|
|
41
|
-
if (r.find((a) => a.module === e)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${e}`);
|
|
42
|
-
r.push({
|
|
43
|
-
cb: i,
|
|
44
|
-
module: e
|
|
45
|
-
}), this.registrar.set(s, r);
|
|
46
|
-
} else
|
|
47
|
-
this.registrar.set(s, [{
|
|
48
|
-
cb: i,
|
|
49
|
-
module: e
|
|
50
|
-
}]);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
unregister(t, e) {
|
|
54
|
-
Array.isArray(t) || (t = [t]), t.forEach((i) => {
|
|
55
|
-
const s = this.registrar.get(i);
|
|
56
|
-
!s || s.length === 0 || s.splice(s.findIndex((r) => r.module === e), 1);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
unregisterAll(t) {
|
|
60
|
-
this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((s) => s.module !== t)));
|
|
61
|
-
}
|
|
62
|
-
log(...t) {
|
|
63
|
-
this.destination ? this.send("log", t) : this.preLog.push(t);
|
|
64
|
-
}
|
|
65
|
-
get ready() {
|
|
66
|
-
return !!this.destination;
|
|
67
|
-
}
|
|
68
|
-
destroy() {
|
|
69
|
-
this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
|
|
70
|
-
}
|
|
71
|
-
send(t, e, i = void 0, s = []) {
|
|
72
|
-
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
|
-
const r = {
|
|
74
|
-
_readium: Z,
|
|
75
|
-
_channel: this.channelId,
|
|
76
|
-
id: i ?? Ue(),
|
|
77
|
-
// scrict,
|
|
78
|
-
key: t,
|
|
79
|
-
data: e
|
|
80
|
-
};
|
|
81
|
-
try {
|
|
82
|
-
this.destination.postMessage(r, {
|
|
83
|
-
targetOrigin: this.origin,
|
|
84
|
-
transfer: s
|
|
85
|
-
});
|
|
86
|
-
} catch (o) {
|
|
87
|
-
if (s.length > 0) throw o;
|
|
88
|
-
this.destination.postMessage(r, this.origin, s);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const y = class y {
|
|
93
|
-
constructor(t) {
|
|
94
|
-
this.uri = t;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Parses an [AccessibilityProfile] from its RWPM JSON representation.
|
|
98
|
-
*/
|
|
99
|
-
static deserialize(t) {
|
|
100
|
-
if (!(!t || typeof t != "string"))
|
|
101
|
-
return new y(t);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Serializes an [AccessibilityProfile] to its RWPM JSON representation.
|
|
105
|
-
*/
|
|
106
|
-
serialize() {
|
|
107
|
-
return this.uri;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns true if the profile is a WCAG Level A profile.
|
|
111
|
-
*/
|
|
112
|
-
get isWCAGLevelA() {
|
|
113
|
-
return this === y.EPUB_A11Y_10_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_21_A || this === y.EPUB_A11Y_11_WCAG_22_A;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Returns true if the profile is a WCAG Level AA profile.
|
|
117
|
-
*/
|
|
118
|
-
get isWCAGLevelAA() {
|
|
119
|
-
return this === y.EPUB_A11Y_10_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_21_AA || this === y.EPUB_A11Y_11_WCAG_22_AA;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns true if the profile is a WCAG Level AAA profile.
|
|
123
|
-
*/
|
|
124
|
-
get isWCAGLevelAAA() {
|
|
125
|
-
return this === y.EPUB_A11Y_10_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_21_AAA || this === y.EPUB_A11Y_11_WCAG_22_AAA;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
y.EPUB_A11Y_10_WCAG_20_A = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"), y.EPUB_A11Y_10_WCAG_20_AA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"), y.EPUB_A11Y_10_WCAG_20_AAA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"), y.EPUB_A11Y_11_WCAG_20_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"), y.EPUB_A11Y_11_WCAG_20_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"), y.EPUB_A11Y_11_WCAG_20_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"), y.EPUB_A11Y_11_WCAG_21_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"), y.EPUB_A11Y_11_WCAG_21_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"), y.EPUB_A11Y_11_WCAG_21_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"), y.EPUB_A11Y_11_WCAG_22_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"), y.EPUB_A11Y_11_WCAG_22_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"), y.EPUB_A11Y_11_WCAG_22_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");
|
|
129
|
-
let qt = y;
|
|
130
|
-
const w = class w {
|
|
131
|
-
constructor(t) {
|
|
132
|
-
this.value = t;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Parses an [AccessMode] from its RWPM JSON representation.
|
|
136
|
-
*/
|
|
137
|
-
static deserialize(t) {
|
|
138
|
-
if (!(!t || typeof t != "string"))
|
|
139
|
-
return new w(t);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Serializes an [AccessMode] to its RWPM JSON representation.
|
|
143
|
-
*/
|
|
144
|
-
serialize() {
|
|
145
|
-
return this.value;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
w.AUDITORY = new w("auditory"), w.CHART_ON_VISUAL = new w("chartOnVisual"), w.CHEM_ON_VISUAL = new w("chemOnVisual"), w.COLOR_DEPENDENT = new w("colorDependent"), w.DIAGRAM_ON_VISUAL = new w("diagramOnVisual"), w.MATH_ON_VISUAL = new w("mathOnVisual"), w.MUSIC_ON_VISUAL = new w("musicOnVisual"), w.TACTILE = new w("tactile"), w.TEXT_ON_VISUAL = new w("textOnVisual"), w.TEXTUAL = new w("textual"), w.VISUAL = new w("visual");
|
|
149
|
-
let Xt = w;
|
|
150
|
-
const x = class x {
|
|
151
|
-
constructor(t) {
|
|
152
|
-
if (typeof t == "string") {
|
|
153
|
-
if (!x.VALID_MODES.has(t.toLowerCase()))
|
|
154
|
-
return;
|
|
155
|
-
this.value = t.toLowerCase();
|
|
156
|
-
} else {
|
|
157
|
-
const e = t.filter(
|
|
158
|
-
(i) => x.VALID_MODES.has(i.toLowerCase())
|
|
159
|
-
);
|
|
160
|
-
if (e.length === 0)
|
|
161
|
-
return;
|
|
162
|
-
this.value = Array.from(new Set(e));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Parses a [PrimaryAccessMode] from its RWPM JSON representation.
|
|
167
|
-
*/
|
|
168
|
-
static deserialize(t) {
|
|
169
|
-
if (!t) return;
|
|
170
|
-
if (typeof t == "string")
|
|
171
|
-
return new x(t);
|
|
172
|
-
if (!Array.isArray(t)) return;
|
|
173
|
-
const e = t.filter((i) => i ? x.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
174
|
-
if (e.length !== 0)
|
|
175
|
-
return new x(e);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
179
|
-
*/
|
|
180
|
-
serialize() {
|
|
181
|
-
return this.value;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
x.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), x.AUDITORY = new x("auditory"), x.TACTILE = new x("tactile"), x.TEXTUAL = new x("textual"), x.VISUAL = new x("visual");
|
|
185
|
-
let Kt = x;
|
|
186
|
-
const h = class h {
|
|
187
|
-
constructor(t) {
|
|
188
|
-
this.value = t;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Parses a [Feature] from its RWPM JSON representation.
|
|
192
|
-
*/
|
|
193
|
-
static deserialize(t) {
|
|
194
|
-
if (!(!t || typeof t != "string"))
|
|
195
|
-
return new h(t);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Serializes a [Feature] to its RWPM JSON representation.
|
|
199
|
-
*/
|
|
200
|
-
serialize() {
|
|
201
|
-
return this.value;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
h.NONE = new h("none"), h.ANNOTATIONS = new h("annotations"), h.ARIA = new h("ARIA"), h.INDEX = new h("index"), h.PAGE_BREAK_MARKERS = new h("pageBreakMarkers"), h.PAGE_NAVIGATION = new h("pageNavigation"), h.PRINT_PAGE_NUMBERS = new h("printPageNumbers"), h.READING_ORDER = new h("readingOrder"), h.STRUCTURAL_NAVIGATION = new h("structuralNavigation"), h.TABLE_OF_CONTENTS = new h("tableOfContents"), h.TAGGED_PDF = new h("taggedPDF"), h.ALTERNATIVE_TEXT = new h("alternativeText"), h.AUDIO_DESCRIPTION = new h("audioDescription"), h.CAPTIONS = new h("captions"), h.CLOSED_CAPTIONS = new h("closedCaptions"), h.DESCRIBED_MATH = new h("describedMath"), h.LONG_DESCRIPTION = new h("longDescription"), h.OPEN_CAPTIONS = new h("openCaptions"), h.SIGN_LANGUAGE = new h("signLanguage"), h.TRANSCRIPT = new h("transcript"), h.DISPLAY_TRANSFORMABILITY = new h("displayTransformability"), h.SYNCHRONIZED_AUDIO_TEXT = new h("synchronizedAudioText"), h.TIMING_CONTROL = new h("timingControl"), h.UNLOCKED = new h("unlocked"), h.CHEM_ML = new h("ChemML"), h.LATEX = new h("latex"), h.LATEX_CHEMISTRY = new h("latex-chemistry"), h.MATH_ML = new h("MathML"), h.MATH_ML_CHEMISTRY = new h("MathML-chemistry"), h.TTS_MARKUP = new h("ttsMarkup"), h.HIGH_CONTRAST_AUDIO = new h("highContrastAudio"), h.HIGH_CONTRAST_DISPLAY = new h("highContrastDisplay"), h.LARGE_PRINT = new h("largePrint"), h.BRAILLE = new h("braille"), h.TACTILE_GRAPHIC = new h("tactileGraphic"), h.TACTILE_OBJECT = new h("tactileObject"), h.FULL_RUBY_ANNOTATIONS = new h("fullRubyAnnotations"), h.HORIZONTAL_WRITING = new h("horizontalWriting"), h.RUBY_ANNOTATIONS = new h("rubyAnnotations"), h.VERTICAL_WRITING = new h("verticalWriting"), h.WITH_ADDITIONAL_WORD_SEGMENTATION = new h("withAdditionalWordSegmentation"), h.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new h("withoutAdditionalWordSegmentation");
|
|
205
|
-
let Zt = h;
|
|
206
|
-
const S = class S {
|
|
207
|
-
constructor(t) {
|
|
208
|
-
this.value = t;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Parses a [Hazard] from its RWPM JSON representation.
|
|
212
|
-
*/
|
|
213
|
-
static deserialize(t) {
|
|
214
|
-
if (!(!t || typeof t != "string"))
|
|
215
|
-
return new S(t);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Serializes a [Hazard] to its RWPM JSON representation.
|
|
219
|
-
*/
|
|
220
|
-
serialize() {
|
|
221
|
-
return this.value;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
S.FLASHING = new S("flashing"), S.NO_FLASHING_HAZARD = new S("noFlashingHazard"), S.UNKNOWN_FLASHING_HAZARD = new S("unknownFlashingHazard"), S.MOTION_SIMULATION = new S("motionSimulation"), S.NO_MOTION_SIMULATION_HAZARD = new S("noMotionSimulationHazard"), S.UNKNOWN_MOTION_SIMULATION_HAZARD = new S("unknownMotionSimulationHazard"), S.SOUND = new S("sound"), S.NO_SOUND_HAZARD = new S("noSoundHazard"), S.UNKNOWN_SOUND_HAZARD = new S("unknownSoundHazard"), S.UNKNOWN = new S("unknown"), S.NONE = new S("none");
|
|
225
|
-
let Jt = S;
|
|
226
|
-
const E = class E {
|
|
227
|
-
constructor(t) {
|
|
228
|
-
this.value = t;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Parses an [Exemption] from its RWPM JSON representation.
|
|
232
|
-
*/
|
|
233
|
-
static deserialize(t) {
|
|
234
|
-
if (!(!t || typeof t != "string"))
|
|
235
|
-
return new E(t);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Serializes an [Exemption] to its RWPM JSON representation.
|
|
239
|
-
*/
|
|
240
|
-
serialize() {
|
|
241
|
-
return this.value;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
E.NONE = new E("none"), E.DOCUMENTED = new E("documented"), E.LEGAL = new E("legal"), E.TEMPORARY = new E("temporary"), E.TECHNICAL = new E("technical"), E.EAA_DISPROPORTIONATE_BURDEN = new E("eaa-disproportionate-burden"), E.EAA_FUNDAMENTAL_ALTERATION = new E("eaa-fundamental-alteration"), E.EAA_MICROENTERPRISE = new E("eaa-microenterprise"), E.EAA_TECHNICAL_IMPOSSIBILITY = new E("eaa-technical-impossibility"), E.EAA_TEMPORARY = new E("eaa-temporary");
|
|
245
|
-
let Qt = E;
|
|
246
|
-
const jt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], He = /* @__PURE__ */ JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`), _e = {
|
|
247
|
-
publication: He
|
|
248
|
-
}, te = {
|
|
249
|
-
fr: () => import("./fr-C5HEel98.js"),
|
|
250
|
-
ar: () => import("./ar-DyHX_uy2.js"),
|
|
251
|
-
da: () => import("./da-Dct0PS3E.js"),
|
|
252
|
-
// 'el': () => import('@edrlab/thorium-locales/publication-metadata/el.json'),
|
|
253
|
-
// 'et': () => import('@edrlab/thorium-locales/publication-metadata/et.json'),
|
|
254
|
-
it: () => import("./it-DFOBoXGy.js"),
|
|
255
|
-
pt_PT: () => import("./pt_PT-Di3sVjze.js"),
|
|
256
|
-
sv: () => import("./sv-BfzAFsVN.js")
|
|
257
|
-
// 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
|
|
258
|
-
// 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
|
|
259
|
-
}, ee = _e?.publication?.metadata?.accessibility?.["display-guide"] || {};
|
|
260
|
-
class Y {
|
|
261
|
-
constructor() {
|
|
262
|
-
this.currentLocaleCode = "en", this.locale = ee, this.loadedLocales = {}, this.loadedLocales.en = ee;
|
|
263
|
-
}
|
|
264
|
-
static getInstance() {
|
|
265
|
-
return Y.instance || (Y.instance = new Y()), Y.instance;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Loads a locale dynamically
|
|
269
|
-
* @param localeCode BCP 47 language code (e.g., 'en', 'fr')
|
|
270
|
-
* @returns Promise indicating if the locale was loaded successfully
|
|
271
|
-
*/
|
|
272
|
-
async loadLocale(t) {
|
|
273
|
-
if (!jt.includes(t))
|
|
274
|
-
return console.warn(`Locale '${t}' is not enabled`), !1;
|
|
275
|
-
if (t in this.loadedLocales)
|
|
276
|
-
return !0;
|
|
277
|
-
try {
|
|
278
|
-
if (!(t in te))
|
|
279
|
-
return console.warn(`Locale file not found for: ${t}`), !1;
|
|
280
|
-
const s = (await te[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
|
|
281
|
-
return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
|
|
282
|
-
} catch (e) {
|
|
283
|
-
return console.warn(`Failed to load locale ${t}:`, e), !1;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Registers a new locale or updates an existing one
|
|
288
|
-
* @param localeCode BCP 47 language code (e.g., 'en', 'fr-FR')
|
|
289
|
-
* @param localeData The locale data to register
|
|
290
|
-
*/
|
|
291
|
-
registerLocale(t, e) {
|
|
292
|
-
if (!t || typeof t != "string")
|
|
293
|
-
throw new Error("Locale code must be a non-empty string");
|
|
294
|
-
this.loadedLocales[t] = e;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Sets the current locale by language code, loading it dynamically if needed
|
|
298
|
-
* @param localeCode BCP 47 language code (e.g., 'en', 'fr')
|
|
299
|
-
* @returns Promise indicating if the locale was set successfully
|
|
300
|
-
*/
|
|
301
|
-
async setLocale(t) {
|
|
302
|
-
return t in this.loadedLocales || await this.loadLocale(t), t in this.loadedLocales ? (this.locale = this.loadedLocales[t], this.currentLocaleCode = t, !0) : (console.warn(`Locale '${t}' is not available`), !1);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Gets the current locale code (BCP 47)
|
|
306
|
-
*/
|
|
307
|
-
getCurrentLocale() {
|
|
308
|
-
return this.currentLocaleCode;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Gets a list of available locale codes
|
|
312
|
-
*/
|
|
313
|
-
getAvailableLocales() {
|
|
314
|
-
return jt;
|
|
315
|
-
}
|
|
316
|
-
getNestedValue(t, e) {
|
|
317
|
-
const i = e.split(".");
|
|
318
|
-
let s = t;
|
|
319
|
-
for (const r of i) {
|
|
320
|
-
if (s == null)
|
|
321
|
-
return;
|
|
322
|
-
s = s[r];
|
|
323
|
-
}
|
|
324
|
-
return s;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Gets a localized string by key
|
|
328
|
-
* @param key The key for the string to retrieve
|
|
329
|
-
* @returns The localized string as a [L10nString], or an empty string if not found
|
|
330
|
-
*/
|
|
331
|
-
getString(t) {
|
|
332
|
-
let e = this.getNestedValue(this.locale, t);
|
|
333
|
-
return e === void 0 && this.currentLocaleCode !== "en" && (e = this.getNestedValue(this.loadedLocales.en, t)), e !== void 0 ? typeof e == "string" ? { compact: e, descriptive: e } : e : (console.warn(`Missing localization for key: ${t}`), { compact: "", descriptive: "" });
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
Y.getInstance();
|
|
337
|
-
class kt {
|
|
338
|
-
/**
|
|
339
|
-
* Creates a [Encryption].
|
|
340
|
-
*/
|
|
341
|
-
constructor(t) {
|
|
342
|
-
this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Parses a [Encryption] from its RWPM JSON representation.
|
|
346
|
-
*/
|
|
347
|
-
static deserialize(t) {
|
|
348
|
-
if (t && t.algorithm)
|
|
349
|
-
return new kt({
|
|
350
|
-
algorithm: t.algorithm,
|
|
351
|
-
compression: t.compression,
|
|
352
|
-
originalLength: t.originalLength,
|
|
353
|
-
profile: t.profile,
|
|
354
|
-
scheme: t.scheme
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Serializes a [Encryption] to its RWPM JSON representation.
|
|
359
|
-
*/
|
|
360
|
-
serialize() {
|
|
361
|
-
const t = { algorithm: this.algorithm };
|
|
362
|
-
return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
class R {
|
|
366
|
-
constructor(t) {
|
|
367
|
-
this.otherProperties = t;
|
|
368
|
-
}
|
|
369
|
-
get page() {
|
|
370
|
-
return this.otherProperties.page;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Creates a [Properties] from its RWPM JSON representation.
|
|
374
|
-
*/
|
|
375
|
-
static deserialize(t) {
|
|
376
|
-
if (t)
|
|
377
|
-
return new R(t);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Serializes a [Properties] to its RWPM JSON representation.
|
|
381
|
-
*/
|
|
382
|
-
serialize() {
|
|
383
|
-
return this.otherProperties;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Makes a copy of this [Properties] after merging in the given additional other [properties].
|
|
387
|
-
*/
|
|
388
|
-
add(t) {
|
|
389
|
-
const e = Object.assign({}, this.otherProperties);
|
|
390
|
-
for (const i in t)
|
|
391
|
-
e[i] = t[i];
|
|
392
|
-
return new R(e);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
Object.defineProperty(R.prototype, "encryption", {
|
|
396
|
-
get: function() {
|
|
397
|
-
return kt.deserialize(this.otherProperties.encrypted);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
function Ve(n) {
|
|
401
|
-
return n && Array.isArray(n) ? n : void 0;
|
|
402
|
-
}
|
|
403
|
-
function Ce(n) {
|
|
404
|
-
return n && typeof n == "string" ? [n] : Ve(n);
|
|
405
|
-
}
|
|
406
|
-
function ie(n) {
|
|
407
|
-
return typeof n == "string" ? new Date(n) : void 0;
|
|
408
|
-
}
|
|
409
|
-
function ht(n) {
|
|
410
|
-
return isNaN(n) ? void 0 : n;
|
|
411
|
-
}
|
|
412
|
-
function O(n) {
|
|
413
|
-
return ht(n) !== void 0 && Math.sign(n) >= 0 ? n : void 0;
|
|
414
|
-
}
|
|
415
|
-
function Fe(n) {
|
|
416
|
-
const t = new Array();
|
|
417
|
-
return n.forEach((e) => t.push(e)), t;
|
|
418
|
-
}
|
|
419
|
-
class l {
|
|
420
|
-
/** Creates a MediaType object. */
|
|
421
|
-
constructor(t) {
|
|
422
|
-
let e, i, s = t.mediaType.replace(/\s/g, "").split(";");
|
|
423
|
-
const r = s[0].split("/");
|
|
424
|
-
if (r.length === 2) {
|
|
425
|
-
if (e = r[0].toLowerCase().trim(), i = r[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
|
|
426
|
-
throw new Error("Invalid media type");
|
|
427
|
-
} else
|
|
428
|
-
throw new Error("Invalid media type");
|
|
429
|
-
const o = {};
|
|
430
|
-
for (let p = 1; p < s.length; p++) {
|
|
431
|
-
const v = s[p].split("=");
|
|
432
|
-
if (v.length === 2) {
|
|
433
|
-
const g = v[0].toLocaleLowerCase(), m = g === "charset" ? v[1].toUpperCase() : v[1];
|
|
434
|
-
o[g] = m;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
const a = {}, c = Object.keys(o);
|
|
438
|
-
c.sort((p, v) => p.localeCompare(v)), c.forEach((p) => a[p] = o[p]);
|
|
439
|
-
let u = "";
|
|
440
|
-
for (const p in a) {
|
|
441
|
-
const v = a[p];
|
|
442
|
-
u += `;${p}=${v}`;
|
|
443
|
-
}
|
|
444
|
-
const d = `${e}/${i}${u}`, f = a.encoding;
|
|
445
|
-
this.string = d, this.type = e, this.subtype = i, this.parameters = a, this.encoding = f, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
446
|
-
}
|
|
447
|
-
static parse(t) {
|
|
448
|
-
return new l(t);
|
|
449
|
-
}
|
|
450
|
-
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
451
|
-
* Gives a hint on the underlying structure of this media type.
|
|
452
|
-
* See. https://tools.ietf.org/html/rfc6838#section-4.2.8
|
|
453
|
-
*/
|
|
454
|
-
get structuredSyntaxSuffix() {
|
|
455
|
-
const t = this.subtype.split("+");
|
|
456
|
-
return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
|
|
457
|
-
}
|
|
458
|
-
/** Parameter values might or might not be case-sensitive, depending on the semantics of
|
|
459
|
-
* the parameter name.
|
|
460
|
-
* https://tools.ietf.org/html/rfc2616#section-3.7
|
|
461
|
-
*
|
|
462
|
-
* The character set names may be up to 40 characters taken from the printable characters
|
|
463
|
-
* of US-ASCII. However, no distinction is made between use of upper and lower case
|
|
464
|
-
* letters.
|
|
465
|
-
* https://www.iana.org/assignments/character-sets/character-sets.xhtml
|
|
466
|
-
*/
|
|
467
|
-
get charset() {
|
|
468
|
-
return this.parameters.charset;
|
|
469
|
-
}
|
|
470
|
-
/** Returns whether the given `other` media type is included in this media type.
|
|
471
|
-
* For example, `text/html` contains `text/html;charset=utf-8`.
|
|
472
|
-
* - `other` must match the parameters in the `parameters` property, but extra parameters
|
|
473
|
-
* are ignored.
|
|
474
|
-
* - Order of parameters is ignored.
|
|
475
|
-
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
476
|
-
*/
|
|
477
|
-
contains(t) {
|
|
478
|
-
const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
|
|
479
|
-
if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
|
|
480
|
-
return !1;
|
|
481
|
-
const i = new Set(
|
|
482
|
-
Object.entries(this.parameters).map(([r, o]) => `${r}=${o}`)
|
|
483
|
-
), s = new Set(
|
|
484
|
-
Object.entries(e.parameters).map(([r, o]) => `${r}=${o}`)
|
|
485
|
-
);
|
|
486
|
-
for (const r of Array.from(i.values()))
|
|
487
|
-
if (!s.has(r))
|
|
488
|
-
return !1;
|
|
489
|
-
return !0;
|
|
490
|
-
}
|
|
491
|
-
/** Returns whether this media type and `other` are the same, ignoring parameters that
|
|
492
|
-
* are not in both media types.
|
|
493
|
-
* For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
|
|
494
|
-
* doesn't. This is basically like `contains`, but working in both direction.
|
|
495
|
-
*/
|
|
496
|
-
matches(t) {
|
|
497
|
-
const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
|
|
498
|
-
return this.contains(e) || e.contains(this);
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Returns whether this media type matches any of the [others] media types.
|
|
502
|
-
*/
|
|
503
|
-
matchesAny(...t) {
|
|
504
|
-
for (const e of t)
|
|
505
|
-
if (this.matches(e))
|
|
506
|
-
return !0;
|
|
507
|
-
return !1;
|
|
508
|
-
}
|
|
509
|
-
/** Checks the MediaType equals another one (comparing their string) */
|
|
510
|
-
equals(t) {
|
|
511
|
-
return this.string === t.string;
|
|
512
|
-
}
|
|
513
|
-
/** Returns whether this media type is structured as a ZIP archive. */
|
|
514
|
-
get isZIP() {
|
|
515
|
-
return this.matchesAny(
|
|
516
|
-
l.ZIP,
|
|
517
|
-
l.LCP_PROTECTED_AUDIOBOOK,
|
|
518
|
-
l.LCP_PROTECTED_PDF
|
|
519
|
-
) || this.structuredSyntaxSuffix === "+zip";
|
|
520
|
-
}
|
|
521
|
-
/** Returns whether this media type is structured as a JSON file. */
|
|
522
|
-
get isJSON() {
|
|
523
|
-
return this.matchesAny(l.JSON) || this.structuredSyntaxSuffix === "+json";
|
|
524
|
-
}
|
|
525
|
-
/** Returns whether this media type is of an OPDS feed. */
|
|
526
|
-
get isOPDS() {
|
|
527
|
-
return this.matchesAny(
|
|
528
|
-
l.OPDS1,
|
|
529
|
-
l.OPDS1_ENTRY,
|
|
530
|
-
l.OPDS2,
|
|
531
|
-
l.OPDS2_PUBLICATION,
|
|
532
|
-
l.OPDS_AUTHENTICATION
|
|
533
|
-
) || this.structuredSyntaxSuffix === "+json";
|
|
534
|
-
}
|
|
535
|
-
/** Returns whether this media type is of an HTML document. */
|
|
536
|
-
get isHTML() {
|
|
537
|
-
return this.matchesAny(l.HTML, l.XHTML);
|
|
538
|
-
}
|
|
539
|
-
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
|
|
540
|
-
get isBitmap() {
|
|
541
|
-
return this.matchesAny(
|
|
542
|
-
l.AVIF,
|
|
543
|
-
l.BMP,
|
|
544
|
-
l.GIF,
|
|
545
|
-
l.JPEG,
|
|
546
|
-
l.PNG,
|
|
547
|
-
l.TIFF,
|
|
548
|
-
l.WEBP
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
/** Returns whether this media type is of an audio clip. */
|
|
552
|
-
get isAudio() {
|
|
553
|
-
return this.type === "audio";
|
|
554
|
-
}
|
|
555
|
-
/** Returns whether this media type is of a video clip. */
|
|
556
|
-
get isVideo() {
|
|
557
|
-
return this.type === "video";
|
|
558
|
-
}
|
|
559
|
-
/** Returns whether this media type is of a Readium Web Publication Manifest. */
|
|
560
|
-
get isRWPM() {
|
|
561
|
-
return this.matchesAny(
|
|
562
|
-
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
563
|
-
l.DIVINA_MANIFEST,
|
|
564
|
-
l.READIUM_WEBPUB_MANIFEST
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
/** Returns whether this media type is of a publication file. */
|
|
568
|
-
get isPublication() {
|
|
569
|
-
return this.matchesAny(
|
|
570
|
-
l.READIUM_AUDIOBOOK,
|
|
571
|
-
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
572
|
-
l.CBZ,
|
|
573
|
-
l.DIVINA,
|
|
574
|
-
l.DIVINA_MANIFEST,
|
|
575
|
-
l.EPUB,
|
|
576
|
-
l.LCP_PROTECTED_AUDIOBOOK,
|
|
577
|
-
l.LCP_PROTECTED_PDF,
|
|
578
|
-
l.LPF,
|
|
579
|
-
l.PDF,
|
|
580
|
-
l.W3C_WPUB_MANIFEST,
|
|
581
|
-
l.READIUM_WEBPUB,
|
|
582
|
-
l.READIUM_WEBPUB_MANIFEST,
|
|
583
|
-
l.ZAB
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
// Known Media Types
|
|
587
|
-
static get AAC() {
|
|
588
|
-
return l.parse({ mediaType: "audio/aac", fileExtension: "aac" });
|
|
589
|
-
}
|
|
590
|
-
static get ACSM() {
|
|
591
|
-
return l.parse({
|
|
592
|
-
mediaType: "application/vnd.adobe.adept+xml",
|
|
593
|
-
name: "Adobe Content Server Message",
|
|
594
|
-
fileExtension: "acsm"
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
static get AIFF() {
|
|
598
|
-
return l.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });
|
|
599
|
-
}
|
|
600
|
-
static get AVI() {
|
|
601
|
-
return l.parse({
|
|
602
|
-
mediaType: "video/x-msvideo",
|
|
603
|
-
fileExtension: "avi"
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
static get AVIF() {
|
|
607
|
-
return l.parse({ mediaType: "image/avif", fileExtension: "avif" });
|
|
608
|
-
}
|
|
609
|
-
static get BINARY() {
|
|
610
|
-
return l.parse({ mediaType: "application/octet-stream" });
|
|
611
|
-
}
|
|
612
|
-
static get BMP() {
|
|
613
|
-
return l.parse({ mediaType: "image/bmp", fileExtension: "bmp" });
|
|
614
|
-
}
|
|
615
|
-
static get CBZ() {
|
|
616
|
-
return l.parse({
|
|
617
|
-
mediaType: "application/vnd.comicbook+zip",
|
|
618
|
-
name: "Comic Book Archive",
|
|
619
|
-
fileExtension: "cbz"
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
static get CSS() {
|
|
623
|
-
return l.parse({ mediaType: "text/css", fileExtension: "css" });
|
|
624
|
-
}
|
|
625
|
-
static get DIVINA() {
|
|
626
|
-
return l.parse({
|
|
627
|
-
mediaType: "application/divina+zip",
|
|
628
|
-
name: "Digital Visual Narratives",
|
|
629
|
-
fileExtension: "divina"
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
static get DIVINA_MANIFEST() {
|
|
633
|
-
return l.parse({
|
|
634
|
-
mediaType: "application/divina+json",
|
|
635
|
-
name: "Digital Visual Narratives",
|
|
636
|
-
fileExtension: "json"
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
static get EPUB() {
|
|
640
|
-
return l.parse({
|
|
641
|
-
mediaType: "application/epub+zip",
|
|
642
|
-
name: "EPUB",
|
|
643
|
-
fileExtension: "epub"
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
static get GIF() {
|
|
647
|
-
return l.parse({ mediaType: "image/gif", fileExtension: "gif" });
|
|
648
|
-
}
|
|
649
|
-
static get GZ() {
|
|
650
|
-
return l.parse({
|
|
651
|
-
mediaType: "application/gzip",
|
|
652
|
-
fileExtension: "gz"
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
static get HTML() {
|
|
656
|
-
return l.parse({ mediaType: "text/html", fileExtension: "html" });
|
|
657
|
-
}
|
|
658
|
-
static get JAVASCRIPT() {
|
|
659
|
-
return l.parse({
|
|
660
|
-
mediaType: "text/javascript",
|
|
661
|
-
fileExtension: "js"
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
static get JPEG() {
|
|
665
|
-
return l.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });
|
|
666
|
-
}
|
|
667
|
-
static get JSON() {
|
|
668
|
-
return l.parse({ mediaType: "application/json" });
|
|
669
|
-
}
|
|
670
|
-
static get LCP_LICENSE_DOCUMENT() {
|
|
671
|
-
return l.parse({
|
|
672
|
-
mediaType: "application/vnd.readium.lcp.license.v1.0+json",
|
|
673
|
-
name: "LCP License",
|
|
674
|
-
fileExtension: "lcpl"
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
static get LCP_PROTECTED_AUDIOBOOK() {
|
|
678
|
-
return l.parse({
|
|
679
|
-
mediaType: "application/audiobook+lcp",
|
|
680
|
-
name: "LCP Protected Audiobook",
|
|
681
|
-
fileExtension: "lcpa"
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
static get LCP_PROTECTED_PDF() {
|
|
685
|
-
return l.parse({
|
|
686
|
-
mediaType: "application/pdf+lcp",
|
|
687
|
-
name: "LCP Protected PDF",
|
|
688
|
-
fileExtension: "lcpdf"
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
static get LCP_STATUS_DOCUMENT() {
|
|
692
|
-
return l.parse({
|
|
693
|
-
mediaType: "application/vnd.readium.license.status.v1.0+json"
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
static get LPF() {
|
|
697
|
-
return l.parse({
|
|
698
|
-
mediaType: "application/lpf+zip",
|
|
699
|
-
fileExtension: "lpf"
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
static get MP3() {
|
|
703
|
-
return l.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });
|
|
704
|
-
}
|
|
705
|
-
static get MPEG() {
|
|
706
|
-
return l.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });
|
|
707
|
-
}
|
|
708
|
-
static get NCX() {
|
|
709
|
-
return l.parse({
|
|
710
|
-
mediaType: "application/x-dtbncx+xml",
|
|
711
|
-
fileExtension: "ncx"
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
static get OGG() {
|
|
715
|
-
return l.parse({ mediaType: "audio/ogg", fileExtension: "oga" });
|
|
716
|
-
}
|
|
717
|
-
static get OGV() {
|
|
718
|
-
return l.parse({ mediaType: "video/ogg", fileExtension: "ogv" });
|
|
719
|
-
}
|
|
720
|
-
static get OPDS1() {
|
|
721
|
-
return l.parse({
|
|
722
|
-
mediaType: "application/atom+xml;profile=opds-catalog"
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
static get OPDS1_ENTRY() {
|
|
726
|
-
return l.parse({
|
|
727
|
-
mediaType: "application/atom+xml;type=entry;profile=opds-catalog"
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
static get OPDS2() {
|
|
731
|
-
return l.parse({ mediaType: "application/opds+json" });
|
|
732
|
-
}
|
|
733
|
-
static get OPDS2_PUBLICATION() {
|
|
734
|
-
return l.parse({ mediaType: "application/opds-publication+json" });
|
|
735
|
-
}
|
|
736
|
-
static get OPDS_AUTHENTICATION() {
|
|
737
|
-
return l.parse({
|
|
738
|
-
mediaType: "application/opds-authentication+json"
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
static get OPUS() {
|
|
742
|
-
return l.parse({ mediaType: "audio/opus", fileExtension: "opus" });
|
|
743
|
-
}
|
|
744
|
-
static get OTF() {
|
|
745
|
-
return l.parse({ mediaType: "font/otf", fileExtension: "otf" });
|
|
746
|
-
}
|
|
747
|
-
static get PDF() {
|
|
748
|
-
return l.parse({
|
|
749
|
-
mediaType: "application/pdf",
|
|
750
|
-
name: "PDF",
|
|
751
|
-
fileExtension: "pdf"
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
static get PNG() {
|
|
755
|
-
return l.parse({ mediaType: "image/png", fileExtension: "png" });
|
|
756
|
-
}
|
|
757
|
-
static get READIUM_AUDIOBOOK() {
|
|
758
|
-
return l.parse({
|
|
759
|
-
mediaType: "application/audiobook+zip",
|
|
760
|
-
name: "Readium Audiobook",
|
|
761
|
-
fileExtension: "audiobook"
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
static get READIUM_AUDIOBOOK_MANIFEST() {
|
|
765
|
-
return l.parse({
|
|
766
|
-
mediaType: "application/audiobook+json",
|
|
767
|
-
name: "Readium Audiobook",
|
|
768
|
-
fileExtension: "json"
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
static get READIUM_CONTENT_DOCUMENT() {
|
|
772
|
-
return l.parse({
|
|
773
|
-
mediaType: "application/vnd.readium.content+json",
|
|
774
|
-
name: "Readium Content Document",
|
|
775
|
-
fileExtension: "json"
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {
|
|
779
|
-
return l.parse({
|
|
780
|
-
mediaType: "application/guided-navigation+json",
|
|
781
|
-
name: "Readium Guided Navigation Document",
|
|
782
|
-
fileExtension: "json"
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
static get READIUM_POSITION_LIST() {
|
|
786
|
-
return l.parse({
|
|
787
|
-
mediaType: "application/vnd.readium.position-list+json",
|
|
788
|
-
name: "Readium Position List",
|
|
789
|
-
fileExtension: "json"
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
static get READIUM_WEBPUB() {
|
|
793
|
-
return l.parse({
|
|
794
|
-
mediaType: "application/webpub+zip",
|
|
795
|
-
name: "Readium Web Publication",
|
|
796
|
-
fileExtension: "webpub"
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
static get READIUM_WEBPUB_MANIFEST() {
|
|
800
|
-
return l.parse({
|
|
801
|
-
mediaType: "application/webpub+json",
|
|
802
|
-
name: "Readium Web Publication",
|
|
803
|
-
fileExtension: "json"
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
static get SMIL() {
|
|
807
|
-
return l.parse({
|
|
808
|
-
mediaType: "application/smil+xml",
|
|
809
|
-
fileExtension: "smil"
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
static get SVG() {
|
|
813
|
-
return l.parse({
|
|
814
|
-
mediaType: "image/svg+xml",
|
|
815
|
-
fileExtension: "svg"
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
static get TEXT() {
|
|
819
|
-
return l.parse({ mediaType: "text/plain", fileExtension: "txt" });
|
|
820
|
-
}
|
|
821
|
-
static get TIFF() {
|
|
822
|
-
return l.parse({ mediaType: "image/tiff", fileExtension: "tiff" });
|
|
823
|
-
}
|
|
824
|
-
static get TTF() {
|
|
825
|
-
return l.parse({ mediaType: "font/ttf", fileExtension: "ttf" });
|
|
826
|
-
}
|
|
827
|
-
static get W3C_WPUB_MANIFEST() {
|
|
828
|
-
return l.parse({
|
|
829
|
-
mediaType: "application/x.readium.w3c.wpub+json",
|
|
830
|
-
name: "Web Publication",
|
|
831
|
-
fileExtension: "json"
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
static get WAV() {
|
|
835
|
-
return l.parse({ mediaType: "audio/wav", fileExtension: "wav" });
|
|
836
|
-
}
|
|
837
|
-
static get WEBM_AUDIO() {
|
|
838
|
-
return l.parse({ mediaType: "audio/webm", fileExtension: "webm" });
|
|
839
|
-
}
|
|
840
|
-
static get WEBM_VIDEO() {
|
|
841
|
-
return l.parse({ mediaType: "video/webm", fileExtension: "webm" });
|
|
842
|
-
}
|
|
843
|
-
static get WEBP() {
|
|
844
|
-
return l.parse({ mediaType: "image/webp", fileExtension: "webp" });
|
|
845
|
-
}
|
|
846
|
-
static get WOFF() {
|
|
847
|
-
return l.parse({ mediaType: "font/woff", fileExtension: "woff" });
|
|
848
|
-
}
|
|
849
|
-
static get WOFF2() {
|
|
850
|
-
return l.parse({ mediaType: "font/woff2", fileExtension: "woff2" });
|
|
851
|
-
}
|
|
852
|
-
static get XHTML() {
|
|
853
|
-
return l.parse({
|
|
854
|
-
mediaType: "application/xhtml+xml",
|
|
855
|
-
fileExtension: "xhtml"
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
static get XML() {
|
|
859
|
-
return l.parse({
|
|
860
|
-
mediaType: "application/xml",
|
|
861
|
-
fileExtension: "xml"
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
static get ZAB() {
|
|
865
|
-
return l.parse({
|
|
866
|
-
mediaType: "application/x.readium.zab+zip",
|
|
867
|
-
name: "Zipped Audio Book",
|
|
868
|
-
fileExtension: "zab"
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
static get ZIP() {
|
|
872
|
-
return l.parse({
|
|
873
|
-
mediaType: "application/zip",
|
|
874
|
-
fileExtension: "zip"
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
class se {
|
|
879
|
-
constructor(t) {
|
|
880
|
-
this.uri = t, this.parameters = this.getParameters(t);
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* List of URI template parameter keys, if the [Link] is templated.
|
|
884
|
-
*/
|
|
885
|
-
getParameters(t) {
|
|
886
|
-
const e = /\{\??([^}]+)\}/g, i = t.match(e);
|
|
887
|
-
return i ? new Set(
|
|
888
|
-
i.join(",").replace(e, "$1").split(",").map((s) => s.trim())
|
|
889
|
-
) : /* @__PURE__ */ new Set();
|
|
890
|
-
}
|
|
891
|
-
/** Expands the URI by replacing the template variables by the given parameters.
|
|
892
|
-
* Any extra parameter is appended as query parameters.
|
|
893
|
-
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
894
|
-
*/
|
|
895
|
-
expand(t) {
|
|
896
|
-
const e = (s) => s.split(",").map((r) => {
|
|
897
|
-
const o = t[r];
|
|
898
|
-
return o ? encodeURIComponent(o) : "";
|
|
899
|
-
}).join(","), i = (s) => "?" + s.split(",").map((r) => {
|
|
900
|
-
const o = r.split("=")[0], a = t[o];
|
|
901
|
-
return a ? `${o}=${encodeURIComponent(a)}` : "";
|
|
902
|
-
}).join("&");
|
|
903
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
class C {
|
|
907
|
-
/**
|
|
908
|
-
* Creates a [Locations].
|
|
909
|
-
*/
|
|
910
|
-
constructor(t) {
|
|
911
|
-
this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Parses a [Locations] from its RWPM JSON representation.
|
|
915
|
-
*/
|
|
916
|
-
static deserialize(t) {
|
|
917
|
-
if (!t) return;
|
|
918
|
-
const e = ht(t.progression), i = ht(t.totalProgression), s = ht(t.position), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
919
|
-
"fragment",
|
|
920
|
-
"fragments",
|
|
921
|
-
"progression",
|
|
922
|
-
"totalProgression",
|
|
923
|
-
"position"
|
|
924
|
-
]);
|
|
925
|
-
return Object.entries(t).forEach(([a, c]) => {
|
|
926
|
-
o.has(a) || r.set(a, c);
|
|
927
|
-
}), new C({
|
|
928
|
-
fragments: Ce(t.fragments || t.fragment),
|
|
929
|
-
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
930
|
-
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
931
|
-
position: s !== void 0 && s > 0 ? s : void 0,
|
|
932
|
-
otherLocations: r.size === 0 ? void 0 : r
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Serializes a [Locations] to its RWPM JSON representation.
|
|
937
|
-
*/
|
|
938
|
-
serialize() {
|
|
939
|
-
const t = {};
|
|
940
|
-
return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
class H {
|
|
944
|
-
/**
|
|
945
|
-
* Creates a [Text].
|
|
946
|
-
*/
|
|
947
|
-
constructor(t) {
|
|
948
|
-
this.after = t.after, this.before = t.before, this.highlight = t.highlight;
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* Parses a [Locations] from its RWPM JSON representation.
|
|
952
|
-
*/
|
|
953
|
-
static deserialize(t) {
|
|
954
|
-
if (t)
|
|
955
|
-
return new H({
|
|
956
|
-
after: t.after,
|
|
957
|
-
before: t.before,
|
|
958
|
-
highlight: t.highlight
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Serializes a [Locations] to its RWPM JSON representation.
|
|
963
|
-
*/
|
|
964
|
-
serialize() {
|
|
965
|
-
const t = {};
|
|
966
|
-
return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
class k {
|
|
970
|
-
/**
|
|
971
|
-
* Creates a [Locator].
|
|
972
|
-
*/
|
|
973
|
-
constructor(t) {
|
|
974
|
-
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new C({}), this.text = t.text;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Parses a [Link] from its RWPM JSON representation.
|
|
978
|
-
*/
|
|
979
|
-
static deserialize(t) {
|
|
980
|
-
if (t && t.href && t.type)
|
|
981
|
-
return new k({
|
|
982
|
-
href: t.href,
|
|
983
|
-
type: t.type,
|
|
984
|
-
title: t.title,
|
|
985
|
-
locations: C.deserialize(t.locations),
|
|
986
|
-
text: H.deserialize(t.text)
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Serializes a [Link] to its RWPM JSON representation.
|
|
991
|
-
*/
|
|
992
|
-
serialize() {
|
|
993
|
-
const t = { href: this.href, type: this.type };
|
|
994
|
-
return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
998
|
-
*/
|
|
999
|
-
copyWithLocations(t) {
|
|
1000
|
-
return new k({
|
|
1001
|
-
href: this.href,
|
|
1002
|
-
type: this.type,
|
|
1003
|
-
title: this.title,
|
|
1004
|
-
text: this.text,
|
|
1005
|
-
locations: new C({ ...this.locations, ...t })
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
class q {
|
|
1010
|
-
/**
|
|
1011
|
-
* Creates a [Link].
|
|
1012
|
-
*/
|
|
1013
|
-
constructor(t) {
|
|
1014
|
-
this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.size = t.size, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Parses a [Link] from its RWPM JSON representation.
|
|
1018
|
-
*/
|
|
1019
|
-
static deserialize(t) {
|
|
1020
|
-
if (!(!t || typeof t.href != "string"))
|
|
1021
|
-
return new q({
|
|
1022
|
-
href: t.href,
|
|
1023
|
-
templated: t.templated,
|
|
1024
|
-
type: t.type,
|
|
1025
|
-
title: t.title,
|
|
1026
|
-
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
1027
|
-
properties: R.deserialize(t.properties),
|
|
1028
|
-
height: O(t.height),
|
|
1029
|
-
width: O(t.width),
|
|
1030
|
-
size: O(t.size),
|
|
1031
|
-
duration: O(t.duration),
|
|
1032
|
-
bitrate: O(t.bitrate),
|
|
1033
|
-
languages: Ce(t.language),
|
|
1034
|
-
alternates: dt.deserialize(t.alternate),
|
|
1035
|
-
children: dt.deserialize(t.children)
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Serializes a [Link] to its RWPM JSON representation.
|
|
1040
|
-
*/
|
|
1041
|
-
serialize() {
|
|
1042
|
-
const t = { href: this.href };
|
|
1043
|
-
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = Fe(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
|
|
1044
|
-
}
|
|
1045
|
-
/** MediaType of the linked resource. */
|
|
1046
|
-
get mediaType() {
|
|
1047
|
-
return this.type !== void 0 ? l.parse({ mediaType: this.type }) : l.BINARY;
|
|
1048
|
-
}
|
|
1049
|
-
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
1050
|
-
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
1051
|
-
*/
|
|
1052
|
-
toURL(t) {
|
|
1053
|
-
const e = this.href.replace(/^(\/)/, "");
|
|
1054
|
-
if (e.length === 0) return;
|
|
1055
|
-
let i = t || "/";
|
|
1056
|
-
return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
|
|
1057
|
-
}
|
|
1058
|
-
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
1059
|
-
get templateParameters() {
|
|
1060
|
-
return this.templated ? new se(this.href).parameters : /* @__PURE__ */ new Set();
|
|
1061
|
-
}
|
|
1062
|
-
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
1063
|
-
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
1064
|
-
*/
|
|
1065
|
-
expandTemplate(t) {
|
|
1066
|
-
return new q({
|
|
1067
|
-
href: new se(this.href).expand(t),
|
|
1068
|
-
templated: !1
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
1073
|
-
*/
|
|
1074
|
-
addProperties(t) {
|
|
1075
|
-
const e = q.deserialize(this.serialize());
|
|
1076
|
-
return e.properties = e.properties ? e.properties?.add(t) : new R(t), e;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Creates a [Locator] from a reading order [Link].
|
|
1080
|
-
*/
|
|
1081
|
-
get locator() {
|
|
1082
|
-
let t = this.href.split("#");
|
|
1083
|
-
return new k({
|
|
1084
|
-
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
1085
|
-
type: this.type ?? "",
|
|
1086
|
-
title: this.title,
|
|
1087
|
-
locations: new C({
|
|
1088
|
-
fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
|
|
1089
|
-
})
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
class dt {
|
|
1094
|
-
/**
|
|
1095
|
-
* Creates a [Links].
|
|
1096
|
-
*/
|
|
1097
|
-
constructor(t) {
|
|
1098
|
-
this.items = t;
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Creates a list of [Link] from its RWPM JSON representation.
|
|
1102
|
-
*/
|
|
1103
|
-
static deserialize(t) {
|
|
1104
|
-
if (t && Array.isArray(t))
|
|
1105
|
-
return new dt(
|
|
1106
|
-
t.map((e) => q.deserialize(e)).filter((e) => e !== void 0)
|
|
1107
|
-
);
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Serializes an array of [Link] to its RWPM JSON representation.
|
|
1111
|
-
*/
|
|
1112
|
-
serialize() {
|
|
1113
|
-
return this.items.map((t) => t.serialize());
|
|
1114
|
-
}
|
|
1115
|
-
/** Finds the first link with the given relation. */
|
|
1116
|
-
findWithRel(t) {
|
|
1117
|
-
const e = (i) => i.rels && i.rels.has(t);
|
|
1118
|
-
return this.items.find(e);
|
|
1119
|
-
}
|
|
1120
|
-
/** Finds all the links with the given relation. */
|
|
1121
|
-
filterByRel(t) {
|
|
1122
|
-
const e = (i) => i.rels && i.rels.has(t);
|
|
1123
|
-
return this.items.filter(e);
|
|
1124
|
-
}
|
|
1125
|
-
/** Finds the first link matching the given HREF. */
|
|
1126
|
-
findWithHref(t) {
|
|
1127
|
-
const e = (i) => i.href === t;
|
|
1128
|
-
return this.items.find(e);
|
|
1129
|
-
}
|
|
1130
|
-
/** Finds the index of the first link matching the given HREF. */
|
|
1131
|
-
findIndexWithHref(t) {
|
|
1132
|
-
const e = (i) => i.href === t;
|
|
1133
|
-
return this.items.findIndex(e);
|
|
1134
|
-
}
|
|
1135
|
-
/** Finds the first link matching the given media type. */
|
|
1136
|
-
findWithMediaType(t) {
|
|
1137
|
-
const e = (i) => i.mediaType.matches(t);
|
|
1138
|
-
return this.items.find(e);
|
|
1139
|
-
}
|
|
1140
|
-
/** Finds all the links matching the given media type. */
|
|
1141
|
-
filterByMediaType(t) {
|
|
1142
|
-
const e = (i) => i.mediaType.matches(t);
|
|
1143
|
-
return this.items.filter(e);
|
|
1144
|
-
}
|
|
1145
|
-
/** Finds all the links matching any of the given media types. */
|
|
1146
|
-
filterByMediaTypes(t) {
|
|
1147
|
-
const e = (i) => {
|
|
1148
|
-
for (const s of t)
|
|
1149
|
-
if (i.mediaType.matches(s))
|
|
1150
|
-
return !0;
|
|
1151
|
-
return !1;
|
|
1152
|
-
};
|
|
1153
|
-
return this.items.filter(e);
|
|
1154
|
-
}
|
|
1155
|
-
/** Returns whether all the resources in the collection are audio clips. */
|
|
1156
|
-
everyIsAudio() {
|
|
1157
|
-
const t = (e) => e.mediaType.isAudio;
|
|
1158
|
-
return this.items.length > 0 && this.items.every(t);
|
|
1159
|
-
}
|
|
1160
|
-
/** Returns whether all the resources in the collection are bitmaps. */
|
|
1161
|
-
everyIsBitmap() {
|
|
1162
|
-
const t = (e) => e.mediaType.isBitmap;
|
|
1163
|
-
return this.items.length > 0 && this.items.every(t);
|
|
1164
|
-
}
|
|
1165
|
-
/** Returns whether all the resources in the collection are HTML documents. */
|
|
1166
|
-
everyIsHTML() {
|
|
1167
|
-
const t = (e) => e.mediaType.isHTML;
|
|
1168
|
-
return this.items.length > 0 && this.items.every(t);
|
|
1169
|
-
}
|
|
1170
|
-
/** Returns whether all the resources in the collection are video clips. */
|
|
1171
|
-
everyIsVideo() {
|
|
1172
|
-
const t = (e) => e.mediaType.isVideo;
|
|
1173
|
-
return this.items.length > 0 && this.items.every(t);
|
|
1174
|
-
}
|
|
1175
|
-
/** Returns whether all the resources in the collection are matching any of the given media types. */
|
|
1176
|
-
everyMatchesMediaType(t) {
|
|
1177
|
-
return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
|
|
1178
|
-
for (const i of t)
|
|
1179
|
-
return e.mediaType.matches(i);
|
|
1180
|
-
return !1;
|
|
1181
|
-
}) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
|
|
1182
|
-
}
|
|
1183
|
-
filterLinksHasType() {
|
|
1184
|
-
return this.items.filter((t) => t.type);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
R.prototype.getContains = function() {
|
|
1188
|
-
return new Set(this.otherProperties.contains || []);
|
|
1189
|
-
};
|
|
1190
|
-
class ut {
|
|
1191
|
-
/**
|
|
1192
|
-
* Creates a [DomRange].
|
|
1193
|
-
*/
|
|
1194
|
-
constructor(t) {
|
|
1195
|
-
this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Parses a [DomRangePoint] from its RWPM JSON representation.
|
|
1199
|
-
*/
|
|
1200
|
-
static deserialize(t) {
|
|
1201
|
-
if (!(t && t.cssSelector)) return;
|
|
1202
|
-
let e = O(t.textNodeIndex);
|
|
1203
|
-
if (e === void 0) return;
|
|
1204
|
-
let i = O(t.charOffset);
|
|
1205
|
-
return i === void 0 && (i = O(t.offset)), new ut({
|
|
1206
|
-
cssSelector: t.cssSelector,
|
|
1207
|
-
textNodeIndex: e,
|
|
1208
|
-
charOffset: i
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
/**
|
|
1212
|
-
* Serializes a [DomRangePoint] to its RWPM JSON representation.
|
|
1213
|
-
*/
|
|
1214
|
-
serialize() {
|
|
1215
|
-
const t = {
|
|
1216
|
-
cssSelector: this.cssSelector,
|
|
1217
|
-
textNodeIndex: this.textNodeIndex
|
|
1218
|
-
};
|
|
1219
|
-
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
class Wt {
|
|
1223
|
-
/**
|
|
1224
|
-
* Creates a [DomRange].
|
|
1225
|
-
*/
|
|
1226
|
-
constructor(t) {
|
|
1227
|
-
this.start = t.start, this.end = t.end;
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* Parses a [DomRange] from its RWPM JSON representation.
|
|
1231
|
-
*/
|
|
1232
|
-
static deserialize(t) {
|
|
1233
|
-
if (!t) return;
|
|
1234
|
-
let e = ut.deserialize(t.start);
|
|
1235
|
-
if (e)
|
|
1236
|
-
return new Wt({
|
|
1237
|
-
start: e,
|
|
1238
|
-
end: ut.deserialize(t.end)
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Serializes a [DomRange] to its RWPM JSON representation.
|
|
1243
|
-
*/
|
|
1244
|
-
serialize() {
|
|
1245
|
-
const t = { start: this.start.serialize() };
|
|
1246
|
-
return this.end && (t.end = this.end.serialize()), t;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
C.prototype.getCssSelector = function() {
|
|
1250
|
-
return this.otherLocations?.get("cssSelector");
|
|
1251
|
-
};
|
|
1252
|
-
C.prototype.getPartialCfi = function() {
|
|
1253
|
-
return this.otherLocations?.get("partialCfi");
|
|
1254
|
-
};
|
|
1255
|
-
C.prototype.getDomRange = function() {
|
|
1256
|
-
return Wt.deserialize(this.otherLocations?.get("domRange"));
|
|
1257
|
-
};
|
|
1258
|
-
C.prototype.fragmentParameters = function() {
|
|
1259
|
-
return new Map(
|
|
1260
|
-
this.fragments.map((n) => n.startsWith("#") ? n.slice(1) : n).join("&").split("&").filter((n) => !n.startsWith("#")).map((n) => n.split("=")).filter((n) => n.length === 2).map((n) => [
|
|
1261
|
-
n[0].trim().toLowerCase(),
|
|
1262
|
-
n[1].trim()
|
|
1263
|
-
])
|
|
1264
|
-
);
|
|
1265
|
-
};
|
|
1266
|
-
C.prototype.htmlId = function() {
|
|
1267
|
-
if (!this.fragments.length) return;
|
|
1268
|
-
let n = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1269
|
-
if (!n) {
|
|
1270
|
-
const t = this.fragmentParameters();
|
|
1271
|
-
t.has("id") ? n = t.get("id") : t.has("name") && (n = t.get("name"));
|
|
1272
|
-
}
|
|
1273
|
-
return n?.startsWith("#") ? n.slice(1) : n;
|
|
1274
|
-
};
|
|
1275
|
-
C.prototype.page = function() {
|
|
1276
|
-
const n = parseInt(this.fragmentParameters().get("page"));
|
|
1277
|
-
if (!isNaN(n) && n >= 0) return n;
|
|
1278
|
-
};
|
|
1279
|
-
C.prototype.time = function() {
|
|
1280
|
-
const n = parseInt(this.fragmentParameters().get("t"));
|
|
1281
|
-
if (!isNaN(n)) return n;
|
|
1282
|
-
};
|
|
1283
|
-
C.prototype.space = function() {
|
|
1284
|
-
const n = this.fragmentParameters();
|
|
1285
|
-
if (!n.has("xywh")) return;
|
|
1286
|
-
const t = n.get("xywh").split(",").map((e) => parseInt(e));
|
|
1287
|
-
if (t.length === 4 && !t.some(isNaN))
|
|
1288
|
-
return t;
|
|
1289
|
-
};
|
|
1290
|
-
class Ut {
|
|
1291
|
-
/** Creates a [Price]. */
|
|
1292
|
-
constructor(t) {
|
|
1293
|
-
this.currency = t.currency, this.value = t.value;
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* Parses a [Price] from its RWPM JSON representation.
|
|
1297
|
-
*/
|
|
1298
|
-
static deserialize(t) {
|
|
1299
|
-
if (!t) return;
|
|
1300
|
-
let e = t.currency;
|
|
1301
|
-
if (!(e && typeof e == "string" && e.length > 0))
|
|
1302
|
-
return;
|
|
1303
|
-
let i = O(t.value);
|
|
1304
|
-
if (i !== void 0)
|
|
1305
|
-
return new Ut({ currency: e, value: i });
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* Serializes a [Price] to its RWPM JSON representation.
|
|
1309
|
-
*/
|
|
1310
|
-
serialize() {
|
|
1311
|
-
return { currency: this.currency, value: this.value };
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
class Q {
|
|
1315
|
-
/** Creates a [Acquisition]. */
|
|
1316
|
-
constructor(t) {
|
|
1317
|
-
this.type = t.type, this.children = t.children;
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* Parses a [Acquisition] from its RWPM JSON representation.
|
|
1321
|
-
*/
|
|
1322
|
-
static deserialize(t) {
|
|
1323
|
-
if (t && t.type)
|
|
1324
|
-
return new Q({
|
|
1325
|
-
type: t.type,
|
|
1326
|
-
children: Q.deserializeArray(t.children)
|
|
1327
|
-
});
|
|
1328
|
-
}
|
|
1329
|
-
static deserializeArray(t) {
|
|
1330
|
-
if (Array.isArray(t))
|
|
1331
|
-
return t.map((e) => Q.deserialize(e)).filter((e) => e !== void 0);
|
|
1332
|
-
}
|
|
1333
|
-
/**
|
|
1334
|
-
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
1335
|
-
*/
|
|
1336
|
-
serialize() {
|
|
1337
|
-
const t = { type: this.type };
|
|
1338
|
-
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
class Bt {
|
|
1342
|
-
/** Creates a [Price]. */
|
|
1343
|
-
constructor(t) {
|
|
1344
|
-
this.total = t.total, this.position = t.position;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Parses a [Holds] from its RWPM JSON representation.
|
|
1348
|
-
*/
|
|
1349
|
-
static deserialize(t) {
|
|
1350
|
-
if (t)
|
|
1351
|
-
return new Bt({
|
|
1352
|
-
total: O(t.total),
|
|
1353
|
-
position: O(t.position)
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
/**
|
|
1357
|
-
* Serializes a [Holds] to its RWPM JSON representation.
|
|
1358
|
-
*/
|
|
1359
|
-
serialize() {
|
|
1360
|
-
const t = {};
|
|
1361
|
-
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
class Ht {
|
|
1365
|
-
/** Creates a [Copies]. */
|
|
1366
|
-
constructor(t) {
|
|
1367
|
-
this.total = t.total, this.available = t.available;
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Parses a [Copies] from its RWPM JSON representation.
|
|
1371
|
-
*/
|
|
1372
|
-
static deserialize(t) {
|
|
1373
|
-
if (t)
|
|
1374
|
-
return new Ht({
|
|
1375
|
-
total: O(t.total),
|
|
1376
|
-
available: O(t.available)
|
|
1377
|
-
});
|
|
1378
|
-
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Serializes a [Copies] to its RWPM JSON representation.
|
|
1381
|
-
*/
|
|
1382
|
-
serialize() {
|
|
1383
|
-
const t = {};
|
|
1384
|
-
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
class _t {
|
|
1388
|
-
/** Creates a [Availability]. */
|
|
1389
|
-
constructor(t) {
|
|
1390
|
-
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
1391
|
-
}
|
|
1392
|
-
/**
|
|
1393
|
-
* Parses a [Availability] from its RWPM JSON representation.
|
|
1394
|
-
*/
|
|
1395
|
-
static deserialize(t) {
|
|
1396
|
-
if (t && t.state)
|
|
1397
|
-
return new _t({
|
|
1398
|
-
state: t.state,
|
|
1399
|
-
since: ie(t.since),
|
|
1400
|
-
until: ie(t.until)
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
/**
|
|
1404
|
-
* Serializes a [Availability] to its RWPM JSON representation.
|
|
1405
|
-
*/
|
|
1406
|
-
serialize() {
|
|
1407
|
-
const t = { state: this.state };
|
|
1408
|
-
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
R.prototype.getNumberOfItems = function() {
|
|
1412
|
-
return O(this.otherProperties.numberOfItems);
|
|
1413
|
-
};
|
|
1414
|
-
R.prototype.getPrice = function() {
|
|
1415
|
-
return Ut.deserialize(this.otherProperties.price);
|
|
1416
|
-
};
|
|
1417
|
-
R.prototype.getIndirectAcquisitions = function() {
|
|
1418
|
-
const n = this.otherProperties.indirectAcquisition;
|
|
1419
|
-
if (n && Array.isArray(n))
|
|
1420
|
-
return n.map((t) => Q.deserialize(t)).filter((t) => t !== void 0);
|
|
1421
|
-
};
|
|
1422
|
-
R.prototype.getHolds = function() {
|
|
1423
|
-
return Bt.deserialize(this.otherProperties.holds);
|
|
1424
|
-
};
|
|
1425
|
-
R.prototype.getCopies = function() {
|
|
1426
|
-
return Ht.deserialize(this.otherProperties.copies);
|
|
1427
|
-
};
|
|
1428
|
-
R.prototype.getAvailability = function() {
|
|
1429
|
-
return _t.deserialize(this.otherProperties.availability);
|
|
1430
|
-
};
|
|
1431
|
-
R.prototype.getAuthenticate = function() {
|
|
1432
|
-
return q.deserialize(this.otherProperties.authenticate);
|
|
1433
|
-
};
|
|
1434
|
-
const Ge = "CssSelectorGenerator";
|
|
1435
|
-
function re(n = "unknown problem", ...t) {
|
|
1436
|
-
console.warn(`${Ge}: ${n}`, ...t);
|
|
1437
|
-
}
|
|
1438
|
-
function $e(n) {
|
|
1439
|
-
return n instanceof RegExp;
|
|
1440
|
-
}
|
|
1441
|
-
function Ye(n) {
|
|
1442
|
-
return n.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1443
|
-
}
|
|
1444
|
-
function qe(n) {
|
|
1445
|
-
const t = n.map((e) => {
|
|
1446
|
-
if ($e(e))
|
|
1447
|
-
return (i) => e.test(i);
|
|
1448
|
-
if (typeof e == "function")
|
|
1449
|
-
return (i) => {
|
|
1450
|
-
const s = e(i);
|
|
1451
|
-
return typeof s != "boolean" ? (re("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
1452
|
-
};
|
|
1453
|
-
if (typeof e == "string") {
|
|
1454
|
-
const i = new RegExp("^" + Ye(e) + "$");
|
|
1455
|
-
return (s) => i.test(s);
|
|
1456
|
-
}
|
|
1457
|
-
return re("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1458
|
-
});
|
|
1459
|
-
return (e) => t.some((i) => i(e));
|
|
1460
|
-
}
|
|
1461
|
-
qe([
|
|
1462
|
-
"class",
|
|
1463
|
-
"id",
|
|
1464
|
-
// Angular attributes
|
|
1465
|
-
"ng-*"
|
|
1466
|
-
]);
|
|
1467
|
-
class K {
|
|
1468
|
-
}
|
|
1469
|
-
function ne(n) {
|
|
1470
|
-
return n.split("").reverse().join("");
|
|
1471
|
-
}
|
|
1472
|
-
function Xe(n, t, e) {
|
|
1473
|
-
const i = ne(t);
|
|
1474
|
-
return e.map((s) => {
|
|
1475
|
-
const r = Math.max(0, s.end - t.length - s.errors), o = ne(n.slice(r, s.end));
|
|
1476
|
-
return {
|
|
1477
|
-
start: xe(o, i, s.errors).reduce((c, u) => s.end - u.end < c ? s.end - u.end : c, s.end),
|
|
1478
|
-
end: s.end,
|
|
1479
|
-
errors: s.errors
|
|
1480
|
-
};
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
function vt(n) {
|
|
1484
|
-
return (n | -n) >> 31 & 1;
|
|
1485
|
-
}
|
|
1486
|
-
function oe(n, t, e, i) {
|
|
1487
|
-
let s = n.P[e], r = n.M[e];
|
|
1488
|
-
const o = i >>> 31, a = t[e] | o, c = a | r, u = (a & s) + s ^ s | a;
|
|
1489
|
-
let d = r | ~(u | s), f = s & u;
|
|
1490
|
-
const p = vt(d & n.lastRowMask[e]) - vt(f & n.lastRowMask[e]);
|
|
1491
|
-
return d <<= 1, f <<= 1, f |= o, d |= vt(i) - o, s = f | ~(c | d), r = d & c, n.P[e] = s, n.M[e] = r, p;
|
|
1492
|
-
}
|
|
1493
|
-
function xe(n, t, e) {
|
|
1494
|
-
if (t.length === 0)
|
|
1495
|
-
return [];
|
|
1496
|
-
e = Math.min(e, t.length);
|
|
1497
|
-
const i = [], s = 32, r = Math.ceil(t.length / s) - 1, o = {
|
|
1498
|
-
P: new Uint32Array(r + 1),
|
|
1499
|
-
M: new Uint32Array(r + 1),
|
|
1500
|
-
lastRowMask: new Uint32Array(r + 1)
|
|
1501
|
-
};
|
|
1502
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[r] = 1 << (t.length - 1) % s;
|
|
1503
|
-
const a = new Uint32Array(r + 1), c = /* @__PURE__ */ new Map(), u = [];
|
|
1504
|
-
for (let p = 0; p < 256; p++)
|
|
1505
|
-
u.push(a);
|
|
1506
|
-
for (let p = 0; p < t.length; p += 1) {
|
|
1507
|
-
const v = t.charCodeAt(p);
|
|
1508
|
-
if (c.has(v))
|
|
1509
|
-
continue;
|
|
1510
|
-
const g = new Uint32Array(r + 1);
|
|
1511
|
-
c.set(v, g), v < u.length && (u[v] = g);
|
|
1512
|
-
for (let m = 0; m <= r; m += 1) {
|
|
1513
|
-
g[m] = 0;
|
|
1514
|
-
for (let b = 0; b < s; b += 1) {
|
|
1515
|
-
const D = m * s + b;
|
|
1516
|
-
if (D >= t.length)
|
|
1517
|
-
continue;
|
|
1518
|
-
t.charCodeAt(D) === v && (g[m] |= 1 << b);
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
let d = Math.max(0, Math.ceil(e / s) - 1);
|
|
1523
|
-
const f = new Uint32Array(r + 1);
|
|
1524
|
-
for (let p = 0; p <= d; p += 1)
|
|
1525
|
-
f[p] = (p + 1) * s;
|
|
1526
|
-
f[r] = t.length;
|
|
1527
|
-
for (let p = 0; p <= d; p += 1)
|
|
1528
|
-
o.P[p] = -1, o.M[p] = 0;
|
|
1529
|
-
for (let p = 0; p < n.length; p += 1) {
|
|
1530
|
-
const v = n.charCodeAt(p);
|
|
1531
|
-
let g;
|
|
1532
|
-
v < u.length ? g = u[v] : (g = c.get(v), typeof g > "u" && (g = a));
|
|
1533
|
-
let m = 0;
|
|
1534
|
-
for (let b = 0; b <= d; b += 1)
|
|
1535
|
-
m = oe(o, g, b, m), f[b] += m;
|
|
1536
|
-
if (f[d] - m <= e && d < r && (g[d + 1] & 1 || m < 0)) {
|
|
1537
|
-
d += 1, o.P[d] = -1, o.M[d] = 0;
|
|
1538
|
-
let b;
|
|
1539
|
-
if (d === r) {
|
|
1540
|
-
const D = t.length % s;
|
|
1541
|
-
b = D === 0 ? s : D;
|
|
1542
|
-
} else
|
|
1543
|
-
b = s;
|
|
1544
|
-
f[d] = f[d - 1] + b - m + oe(o, g, d, m);
|
|
1545
|
-
} else
|
|
1546
|
-
for (; d > 0 && f[d] >= e + s; )
|
|
1547
|
-
d -= 1;
|
|
1548
|
-
d === r && f[d] <= e && (f[d] < e && i.splice(0, i.length), i.push({
|
|
1549
|
-
start: -1,
|
|
1550
|
-
end: p + 1,
|
|
1551
|
-
errors: f[d]
|
|
1552
|
-
}), e = f[d]);
|
|
1553
|
-
}
|
|
1554
|
-
return i;
|
|
1555
|
-
}
|
|
1556
|
-
function Ke(n, t, e) {
|
|
1557
|
-
const i = xe(n, t, e);
|
|
1558
|
-
return Xe(n, t, i);
|
|
1559
|
-
}
|
|
1560
|
-
function Te(n, t, e) {
|
|
1561
|
-
let i = 0;
|
|
1562
|
-
const s = [];
|
|
1563
|
-
for (; i !== -1; )
|
|
1564
|
-
i = n.indexOf(t, i), i !== -1 && (s.push({
|
|
1565
|
-
start: i,
|
|
1566
|
-
end: i + t.length,
|
|
1567
|
-
errors: 0
|
|
1568
|
-
}), i += 1);
|
|
1569
|
-
return s.length > 0 ? s : Ke(n, t, e);
|
|
1570
|
-
}
|
|
1571
|
-
function ae(n, t) {
|
|
1572
|
-
return t.length === 0 || n.length === 0 ? 0 : 1 - Te(n, t, t.length)[0].errors / t.length;
|
|
1573
|
-
}
|
|
1574
|
-
function Ze(n, t, e = {}) {
|
|
1575
|
-
if (t.length === 0)
|
|
1576
|
-
return null;
|
|
1577
|
-
const i = Math.min(256, t.length / 2), s = Te(n, t, i);
|
|
1578
|
-
if (s.length === 0)
|
|
1579
|
-
return null;
|
|
1580
|
-
const r = (a) => {
|
|
1581
|
-
const p = 1 - a.errors / t.length, v = e.prefix ? ae(
|
|
1582
|
-
n.slice(
|
|
1583
|
-
Math.max(0, a.start - e.prefix.length),
|
|
1584
|
-
a.start
|
|
1585
|
-
),
|
|
1586
|
-
e.prefix
|
|
1587
|
-
) : 1, g = e.suffix ? ae(
|
|
1588
|
-
n.slice(a.end, a.end + e.suffix.length),
|
|
1589
|
-
e.suffix
|
|
1590
|
-
) : 1;
|
|
1591
|
-
let m = 1;
|
|
1592
|
-
return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) / n.length), (50 * p + 20 * v + 20 * g + 2 * m) / 92;
|
|
1593
|
-
}, o = s.map((a) => ({
|
|
1594
|
-
start: a.start,
|
|
1595
|
-
end: a.end,
|
|
1596
|
-
score: r(a)
|
|
1597
|
-
}));
|
|
1598
|
-
return o.sort((a, c) => c.score - a.score), o[0];
|
|
1599
|
-
}
|
|
1600
|
-
function At(n, t, e) {
|
|
1601
|
-
const i = e === 1 ? t : t - 1;
|
|
1602
|
-
if (n.charAt(i).trim() !== "")
|
|
1603
|
-
return t;
|
|
1604
|
-
let s, r;
|
|
1605
|
-
if (e === 2 ? (s = n.substring(0, t), r = s.trimEnd()) : (s = n.substring(t), r = s.trimStart()), !r.length)
|
|
1606
|
-
return -1;
|
|
1607
|
-
const o = s.length - r.length;
|
|
1608
|
-
return e === 2 ? t - o : t + o;
|
|
1609
|
-
}
|
|
1610
|
-
function le(n, t) {
|
|
1611
|
-
const e = n.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1612
|
-
n.commonAncestorContainer,
|
|
1613
|
-
NodeFilter.SHOW_TEXT
|
|
1614
|
-
), i = t === 1 ? n.startContainer : n.endContainer, s = t === 1 ? n.endContainer : n.startContainer;
|
|
1615
|
-
let r = e.nextNode();
|
|
1616
|
-
for (; r && r !== i; )
|
|
1617
|
-
r = e.nextNode();
|
|
1618
|
-
t === 2 && (r = e.previousNode());
|
|
1619
|
-
let o = -1;
|
|
1620
|
-
const a = () => {
|
|
1621
|
-
if (r = t === 1 ? e.nextNode() : e.previousNode(), r) {
|
|
1622
|
-
const c = r.textContent, u = t === 1 ? 0 : c.length;
|
|
1623
|
-
o = At(c, u, t);
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
|
-
for (; r && o === -1 && r !== s; )
|
|
1627
|
-
a();
|
|
1628
|
-
if (r && o >= 0)
|
|
1629
|
-
return { node: r, offset: o };
|
|
1630
|
-
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1631
|
-
}
|
|
1632
|
-
function Je(n) {
|
|
1633
|
-
if (!n.toString().trim().length)
|
|
1634
|
-
throw new RangeError("Range contains no non-whitespace text");
|
|
1635
|
-
if (n.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1636
|
-
throw new RangeError("Range startContainer is not a text node");
|
|
1637
|
-
if (n.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1638
|
-
throw new RangeError("Range endContainer is not a text node");
|
|
1639
|
-
const t = n.cloneRange();
|
|
1640
|
-
let e = !1, i = !1;
|
|
1641
|
-
const s = {
|
|
1642
|
-
start: At(
|
|
1643
|
-
n.startContainer.textContent,
|
|
1644
|
-
n.startOffset,
|
|
1645
|
-
1
|
|
1646
|
-
/* Forwards */
|
|
1647
|
-
),
|
|
1648
|
-
end: At(
|
|
1649
|
-
n.endContainer.textContent,
|
|
1650
|
-
n.endOffset,
|
|
1651
|
-
2
|
|
1652
|
-
/* Backwards */
|
|
1653
|
-
)
|
|
1654
|
-
};
|
|
1655
|
-
if (s.start >= 0 && (t.setStart(n.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(n.endContainer, s.end), i = !0), e && i)
|
|
1656
|
-
return t;
|
|
1657
|
-
if (!e) {
|
|
1658
|
-
const { node: r, offset: o } = le(
|
|
1659
|
-
t,
|
|
1660
|
-
1
|
|
1661
|
-
/* Forwards */
|
|
1662
|
-
);
|
|
1663
|
-
r && o >= 0 && t.setStart(r, o);
|
|
1664
|
-
}
|
|
1665
|
-
if (!i) {
|
|
1666
|
-
const { node: r, offset: o } = le(
|
|
1667
|
-
t,
|
|
1668
|
-
2
|
|
1669
|
-
/* Backwards */
|
|
1670
|
-
);
|
|
1671
|
-
r && o > 0 && t.setEnd(r, o);
|
|
1672
|
-
}
|
|
1673
|
-
return t;
|
|
1674
|
-
}
|
|
1675
|
-
function Pe(n) {
|
|
1676
|
-
switch (n.nodeType) {
|
|
1677
|
-
case Node.ELEMENT_NODE:
|
|
1678
|
-
case Node.TEXT_NODE:
|
|
1679
|
-
return n.textContent?.length ?? 0;
|
|
1680
|
-
default:
|
|
1681
|
-
return 0;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
function ce(n) {
|
|
1685
|
-
let t = n.previousSibling, e = 0;
|
|
1686
|
-
for (; t; )
|
|
1687
|
-
e += Pe(t), t = t.previousSibling;
|
|
1688
|
-
return e;
|
|
1689
|
-
}
|
|
1690
|
-
function Ne(n, ...t) {
|
|
1691
|
-
let e = t.shift();
|
|
1692
|
-
const i = n.ownerDocument.createNodeIterator(
|
|
1693
|
-
n,
|
|
1694
|
-
NodeFilter.SHOW_TEXT
|
|
1695
|
-
), s = [];
|
|
1696
|
-
let r = i.nextNode(), o, a = 0;
|
|
1697
|
-
for (; e !== void 0 && r; )
|
|
1698
|
-
o = r, a + o.data.length > e ? (s.push({ node: o, offset: e - a }), e = t.shift()) : (r = i.nextNode(), a += o.data.length);
|
|
1699
|
-
for (; e !== void 0 && o && a === e; )
|
|
1700
|
-
s.push({ node: o, offset: o.data.length }), e = t.shift();
|
|
1701
|
-
if (e !== void 0)
|
|
1702
|
-
throw new RangeError("Offset exceeds text length");
|
|
1703
|
-
return s;
|
|
1704
|
-
}
|
|
1705
|
-
class M {
|
|
1706
|
-
constructor(t, e) {
|
|
1707
|
-
if (e < 0)
|
|
1708
|
-
throw new Error("Offset is invalid");
|
|
1709
|
-
this.element = t, this.offset = e;
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Return a copy of this position with offset relative to a given ancestor
|
|
1713
|
-
* element.
|
|
1714
|
-
*
|
|
1715
|
-
* @param parent - Ancestor of `this.element`
|
|
1716
|
-
*/
|
|
1717
|
-
relativeTo(t) {
|
|
1718
|
-
if (!t.contains(this.element))
|
|
1719
|
-
throw new Error("Parent is not an ancestor of current element");
|
|
1720
|
-
let e = this.element, i = this.offset;
|
|
1721
|
-
for (; e !== t; )
|
|
1722
|
-
i += ce(e), e = e.parentElement;
|
|
1723
|
-
return new M(e, i);
|
|
1724
|
-
}
|
|
1725
|
-
/**
|
|
1726
|
-
* Resolve the position to a specific text node and offset within that node.
|
|
1727
|
-
*
|
|
1728
|
-
* Throws if `this.offset` exceeds the length of the element's text. In the
|
|
1729
|
-
* case where the element has no text and `this.offset` is 0, the `direction`
|
|
1730
|
-
* option determines what happens.
|
|
1731
|
-
*
|
|
1732
|
-
* Offsets at the boundary between two nodes are resolved to the start of the
|
|
1733
|
-
* node that begins at the boundary.
|
|
1734
|
-
*
|
|
1735
|
-
* @param options.direction - Specifies in which direction to search for the
|
|
1736
|
-
* nearest text node if `this.offset` is `0` and
|
|
1737
|
-
* `this.element` has no text. If not specified an
|
|
1738
|
-
* error is thrown.
|
|
1739
|
-
*
|
|
1740
|
-
* @throws {RangeError}
|
|
1741
|
-
*/
|
|
1742
|
-
resolve(t = {}) {
|
|
1743
|
-
try {
|
|
1744
|
-
return Ne(this.element, this.offset)[0];
|
|
1745
|
-
} catch (e) {
|
|
1746
|
-
if (this.offset === 0 && t.direction !== void 0) {
|
|
1747
|
-
const i = document.createTreeWalker(
|
|
1748
|
-
this.element.getRootNode(),
|
|
1749
|
-
NodeFilter.SHOW_TEXT
|
|
1750
|
-
);
|
|
1751
|
-
i.currentNode = this.element;
|
|
1752
|
-
const s = t.direction === 1, r = s ? i.nextNode() : i.previousNode();
|
|
1753
|
-
if (!r)
|
|
1754
|
-
throw e;
|
|
1755
|
-
return { node: r, offset: s ? 0 : r.data.length };
|
|
1756
|
-
} else
|
|
1757
|
-
throw e;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Construct a `TextPosition` that refers to the `offset`th character within
|
|
1762
|
-
* `node`.
|
|
1763
|
-
*/
|
|
1764
|
-
static fromCharOffset(t, e) {
|
|
1765
|
-
switch (t.nodeType) {
|
|
1766
|
-
case Node.TEXT_NODE:
|
|
1767
|
-
return M.fromPoint(t, e);
|
|
1768
|
-
case Node.ELEMENT_NODE:
|
|
1769
|
-
return new M(t, e);
|
|
1770
|
-
default:
|
|
1771
|
-
throw new Error("Node is not an element or text node");
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
/**
|
|
1775
|
-
* Construct a `TextPosition` representing the range start or end point (node, offset).
|
|
1776
|
-
*
|
|
1777
|
-
* @param node
|
|
1778
|
-
* @param offset - Offset within the node
|
|
1779
|
-
*/
|
|
1780
|
-
static fromPoint(t, e) {
|
|
1781
|
-
switch (t.nodeType) {
|
|
1782
|
-
case Node.TEXT_NODE: {
|
|
1783
|
-
if (e < 0 || e > t.data.length)
|
|
1784
|
-
throw new Error("Text node offset is out of range");
|
|
1785
|
-
if (!t.parentElement)
|
|
1786
|
-
throw new Error("Text node has no parent");
|
|
1787
|
-
const i = ce(t) + e;
|
|
1788
|
-
return new M(t.parentElement, i);
|
|
1789
|
-
}
|
|
1790
|
-
case Node.ELEMENT_NODE: {
|
|
1791
|
-
if (e < 0 || e > t.childNodes.length)
|
|
1792
|
-
throw new Error("Child node offset is out of range");
|
|
1793
|
-
let i = 0;
|
|
1794
|
-
for (let s = 0; s < e; s++)
|
|
1795
|
-
i += Pe(t.childNodes[s]);
|
|
1796
|
-
return new M(t, i);
|
|
1797
|
-
}
|
|
1798
|
-
default:
|
|
1799
|
-
throw new Error("Point is not in an element or text node");
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
class B {
|
|
1804
|
-
constructor(t, e) {
|
|
1805
|
-
this.start = t, this.end = e;
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Create a new TextRange whose `start` and `end` are computed relative to
|
|
1809
|
-
* `element`. `element` must be an ancestor of both `start.element` and
|
|
1810
|
-
* `end.element`.
|
|
1811
|
-
*/
|
|
1812
|
-
relativeTo(t) {
|
|
1813
|
-
return new B(
|
|
1814
|
-
this.start.relativeTo(t),
|
|
1815
|
-
this.end.relativeTo(t)
|
|
1816
|
-
);
|
|
1817
|
-
}
|
|
1818
|
-
/**
|
|
1819
|
-
* Resolve this TextRange to a (DOM) Range.
|
|
1820
|
-
*
|
|
1821
|
-
* The resulting DOM Range will always start and end in a `Text` node.
|
|
1822
|
-
* Hence `TextRange.fromRange(range).toRange()` can be used to "shrink" a
|
|
1823
|
-
* range to the text it contains.
|
|
1824
|
-
*
|
|
1825
|
-
* May throw if the `start` or `end` positions cannot be resolved to a range.
|
|
1826
|
-
*/
|
|
1827
|
-
toRange() {
|
|
1828
|
-
let t, e;
|
|
1829
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Ne(
|
|
1830
|
-
this.start.element,
|
|
1831
|
-
this.start.offset,
|
|
1832
|
-
this.end.offset
|
|
1833
|
-
) : (t = this.start.resolve({
|
|
1834
|
-
direction: 1
|
|
1835
|
-
/* FORWARDS */
|
|
1836
|
-
}), e = this.end.resolve({
|
|
1837
|
-
direction: 2
|
|
1838
|
-
/* BACKWARDS */
|
|
1839
|
-
}));
|
|
1840
|
-
const i = new Range();
|
|
1841
|
-
return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;
|
|
1842
|
-
}
|
|
1843
|
-
/**
|
|
1844
|
-
* Create a TextRange from a (DOM) Range
|
|
1845
|
-
*/
|
|
1846
|
-
static fromRange(t) {
|
|
1847
|
-
const e = M.fromPoint(
|
|
1848
|
-
t.startContainer,
|
|
1849
|
-
t.startOffset
|
|
1850
|
-
), i = M.fromPoint(t.endContainer, t.endOffset);
|
|
1851
|
-
return new B(e, i);
|
|
1852
|
-
}
|
|
1853
|
-
/**
|
|
1854
|
-
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1855
|
-
* `root`
|
|
1856
|
-
*/
|
|
1857
|
-
static fromOffsets(t, e, i) {
|
|
1858
|
-
return new B(
|
|
1859
|
-
new M(t, e),
|
|
1860
|
-
new M(t, i)
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
/**
|
|
1864
|
-
* Return a new Range representing `range` trimmed of any leading or trailing
|
|
1865
|
-
* whitespace
|
|
1866
|
-
*/
|
|
1867
|
-
static trimmedRange(t) {
|
|
1868
|
-
return Je(B.fromRange(t).toRange());
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
class pt {
|
|
1872
|
-
constructor(t, e, i) {
|
|
1873
|
-
this.root = t, this.start = e, this.end = i;
|
|
1874
|
-
}
|
|
1875
|
-
static fromRange(t, e) {
|
|
1876
|
-
const i = B.fromRange(e).relativeTo(t);
|
|
1877
|
-
return new pt(
|
|
1878
|
-
t,
|
|
1879
|
-
i.start.offset,
|
|
1880
|
-
i.end.offset
|
|
1881
|
-
);
|
|
1882
|
-
}
|
|
1883
|
-
static fromSelector(t, e) {
|
|
1884
|
-
return new pt(t, e.start, e.end);
|
|
1885
|
-
}
|
|
1886
|
-
toSelector() {
|
|
1887
|
-
return {
|
|
1888
|
-
type: "TextPositionSelector",
|
|
1889
|
-
start: this.start,
|
|
1890
|
-
end: this.end
|
|
1891
|
-
};
|
|
1892
|
-
}
|
|
1893
|
-
toRange() {
|
|
1894
|
-
return B.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
class mt {
|
|
1898
|
-
/**
|
|
1899
|
-
* @param root - A root element from which to anchor.
|
|
1900
|
-
*/
|
|
1901
|
-
constructor(t, e, i = {}) {
|
|
1902
|
-
this.root = t, this.exact = e, this.context = i;
|
|
1903
|
-
}
|
|
1904
|
-
/**
|
|
1905
|
-
* Create a `TextQuoteAnchor` from a range.
|
|
1906
|
-
*
|
|
1907
|
-
* Will throw if `range` does not contain any text nodes.
|
|
1908
|
-
*/
|
|
1909
|
-
static fromRange(t, e) {
|
|
1910
|
-
const i = t.textContent, s = B.fromRange(e).relativeTo(t), r = s.start.offset, o = s.end.offset, a = 32;
|
|
1911
|
-
return new mt(t, i.slice(r, o), {
|
|
1912
|
-
prefix: i.slice(Math.max(0, r - a), r),
|
|
1913
|
-
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1914
|
-
});
|
|
1915
|
-
}
|
|
1916
|
-
static fromSelector(t, e) {
|
|
1917
|
-
const { prefix: i, suffix: s } = e;
|
|
1918
|
-
return new mt(t, e.exact, { prefix: i, suffix: s });
|
|
1919
|
-
}
|
|
1920
|
-
toSelector() {
|
|
1921
|
-
return {
|
|
1922
|
-
type: "TextQuoteSelector",
|
|
1923
|
-
exact: this.exact,
|
|
1924
|
-
prefix: this.context.prefix,
|
|
1925
|
-
suffix: this.context.suffix
|
|
1926
|
-
};
|
|
1927
|
-
}
|
|
1928
|
-
toRange(t = {}) {
|
|
1929
|
-
return this.toPositionAnchor(t).toRange();
|
|
1930
|
-
}
|
|
1931
|
-
toPositionAnchor(t = {}) {
|
|
1932
|
-
const e = this.root.textContent, i = Ze(e, this.exact, {
|
|
1933
|
-
...this.context,
|
|
1934
|
-
hint: t.hint
|
|
1935
|
-
});
|
|
1936
|
-
if (!i)
|
|
1937
|
-
throw new Error("Quote not found");
|
|
1938
|
-
return new pt(this.root, i.start, i.end);
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
function Qe(n) {
|
|
1942
|
-
const t = n.tagName.toUpperCase();
|
|
1943
|
-
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1944
|
-
}
|
|
1945
|
-
function rt(n, t) {
|
|
1946
|
-
try {
|
|
1947
|
-
const e = t.locations, i = t.text;
|
|
1948
|
-
if (i && i.highlight) {
|
|
1949
|
-
let s;
|
|
1950
|
-
e && e.getCssSelector() && (s = n.querySelector(e.getCssSelector())), s || (s = n.body);
|
|
1951
|
-
const r = new mt(s, i.highlight, {
|
|
1952
|
-
prefix: i.before,
|
|
1953
|
-
suffix: i.after
|
|
1954
|
-
});
|
|
1955
|
-
try {
|
|
1956
|
-
return r.toRange();
|
|
1957
|
-
} catch {
|
|
1958
|
-
return console.warn("Quote not found:", r), null;
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
if (e) {
|
|
1962
|
-
let s = null;
|
|
1963
|
-
if (!s && e.getCssSelector() && (s = n.querySelector(e.getCssSelector())), !s && e.fragments) {
|
|
1964
|
-
for (const r of e.fragments)
|
|
1965
|
-
if (s = n.getElementById(r), s)
|
|
1966
|
-
break;
|
|
1967
|
-
}
|
|
1968
|
-
if (s) {
|
|
1969
|
-
const r = n.createRange();
|
|
1970
|
-
return s.childNodes.length === 0 || Qe(s) ? (r.selectNode(s), r) : (r.setStartBefore(s), r.setEndAfter(s), r);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
} catch (e) {
|
|
1974
|
-
console.error(e);
|
|
1975
|
-
}
|
|
1976
|
-
return null;
|
|
1977
|
-
}
|
|
1978
|
-
function je(n, t) {
|
|
1979
|
-
let e = n.getClientRects();
|
|
1980
|
-
e.length || n.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = n.commonAncestorContainer.getClientRects());
|
|
1981
|
-
const i = 1, s = [];
|
|
1982
|
-
for (const u of e)
|
|
1983
|
-
s.push({
|
|
1984
|
-
bottom: u.bottom,
|
|
1985
|
-
height: u.height,
|
|
1986
|
-
left: u.left,
|
|
1987
|
-
right: u.right,
|
|
1988
|
-
top: u.top,
|
|
1989
|
-
width: u.width
|
|
1990
|
-
});
|
|
1991
|
-
const r = Le(
|
|
1992
|
-
s,
|
|
1993
|
-
i
|
|
1994
|
-
), o = ei(r, i), a = Oe(o), c = 4;
|
|
1995
|
-
for (let u = a.length - 1; u >= 0; u--) {
|
|
1996
|
-
const d = a[u];
|
|
1997
|
-
if (!(d.width * d.height > c))
|
|
1998
|
-
if (a.length > 1)
|
|
1999
|
-
a.splice(u, 1);
|
|
2000
|
-
else
|
|
2001
|
-
break;
|
|
2002
|
-
}
|
|
2003
|
-
return a;
|
|
2004
|
-
}
|
|
2005
|
-
function Le(n, t, e) {
|
|
2006
|
-
for (let i = 0; i < n.length; i++)
|
|
2007
|
-
for (let s = i + 1; s < n.length; s++) {
|
|
2008
|
-
const r = n[i], o = n[s];
|
|
2009
|
-
if (r === o)
|
|
2010
|
-
continue;
|
|
2011
|
-
const a = I(r.top, o.top, t) && I(r.bottom, o.bottom, t), c = I(r.left, o.left, t) && I(r.right, o.right, t);
|
|
2012
|
-
if (a && !c && Re(r, o, t)) {
|
|
2013
|
-
const f = n.filter((v) => v !== r && v !== o), p = ti(r, o);
|
|
2014
|
-
return f.push(p), Le(
|
|
2015
|
-
f,
|
|
2016
|
-
t
|
|
2017
|
-
);
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
return n;
|
|
2021
|
-
}
|
|
2022
|
-
function ti(n, t) {
|
|
2023
|
-
const e = Math.min(n.left, t.left), i = Math.max(n.right, t.right), s = Math.min(n.top, t.top), r = Math.max(n.bottom, t.bottom);
|
|
2024
|
-
return {
|
|
2025
|
-
bottom: r,
|
|
2026
|
-
height: r - s,
|
|
2027
|
-
left: e,
|
|
2028
|
-
right: i,
|
|
2029
|
-
top: s,
|
|
2030
|
-
width: i - e
|
|
2031
|
-
};
|
|
2032
|
-
}
|
|
2033
|
-
function ei(n, t) {
|
|
2034
|
-
const e = new Set(n);
|
|
2035
|
-
for (const i of n) {
|
|
2036
|
-
if (!(i.width > 1 && i.height > 1)) {
|
|
2037
|
-
e.delete(i);
|
|
2038
|
-
continue;
|
|
2039
|
-
}
|
|
2040
|
-
for (const r of n)
|
|
2041
|
-
if (i !== r && e.has(r) && ii(r, i, t)) {
|
|
2042
|
-
e.delete(i);
|
|
2043
|
-
break;
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
return Array.from(e);
|
|
2047
|
-
}
|
|
2048
|
-
function ii(n, t, e) {
|
|
2049
|
-
return at(n, t.left, t.top, e) && at(n, t.right, t.top, e) && at(n, t.left, t.bottom, e) && at(n, t.right, t.bottom, e);
|
|
2050
|
-
}
|
|
2051
|
-
function at(n, t, e, i) {
|
|
2052
|
-
return (n.left < t || I(n.left, t, i)) && (n.right > t || I(n.right, t, i)) && (n.top < e || I(n.top, e, i)) && (n.bottom > e || I(n.bottom, e, i));
|
|
2053
|
-
}
|
|
2054
|
-
function Oe(n) {
|
|
2055
|
-
for (let t = 0; t < n.length; t++)
|
|
2056
|
-
for (let e = t + 1; e < n.length; e++) {
|
|
2057
|
-
const i = n[t], s = n[e];
|
|
2058
|
-
if (i !== s && Re(i, s, -1)) {
|
|
2059
|
-
let r = [], o;
|
|
2060
|
-
const a = he(i, s);
|
|
2061
|
-
if (a.length === 1)
|
|
2062
|
-
r = a, o = i;
|
|
2063
|
-
else {
|
|
2064
|
-
const u = he(s, i);
|
|
2065
|
-
a.length < u.length ? (r = a, o = i) : (r = u, o = s);
|
|
2066
|
-
}
|
|
2067
|
-
const c = n.filter((u) => u !== o);
|
|
2068
|
-
return Array.prototype.push.apply(c, r), Oe(c);
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
return n;
|
|
2072
|
-
}
|
|
2073
|
-
function he(n, t) {
|
|
2074
|
-
const e = si(t, n);
|
|
2075
|
-
if (e.height === 0 || e.width === 0)
|
|
2076
|
-
return [n];
|
|
2077
|
-
const i = [];
|
|
2078
|
-
{
|
|
2079
|
-
const s = {
|
|
2080
|
-
bottom: n.bottom,
|
|
2081
|
-
height: 0,
|
|
2082
|
-
left: n.left,
|
|
2083
|
-
right: e.left,
|
|
2084
|
-
top: n.top,
|
|
2085
|
-
width: 0
|
|
2086
|
-
};
|
|
2087
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2088
|
-
}
|
|
2089
|
-
{
|
|
2090
|
-
const s = {
|
|
2091
|
-
bottom: e.top,
|
|
2092
|
-
height: 0,
|
|
2093
|
-
left: e.left,
|
|
2094
|
-
right: e.right,
|
|
2095
|
-
top: n.top,
|
|
2096
|
-
width: 0
|
|
2097
|
-
};
|
|
2098
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2099
|
-
}
|
|
2100
|
-
{
|
|
2101
|
-
const s = {
|
|
2102
|
-
bottom: n.bottom,
|
|
2103
|
-
height: 0,
|
|
2104
|
-
left: e.left,
|
|
2105
|
-
right: e.right,
|
|
2106
|
-
top: e.bottom,
|
|
2107
|
-
width: 0
|
|
2108
|
-
};
|
|
2109
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2110
|
-
}
|
|
2111
|
-
{
|
|
2112
|
-
const s = {
|
|
2113
|
-
bottom: n.bottom,
|
|
2114
|
-
height: 0,
|
|
2115
|
-
left: e.right,
|
|
2116
|
-
right: n.right,
|
|
2117
|
-
top: n.top,
|
|
2118
|
-
width: 0
|
|
2119
|
-
};
|
|
2120
|
-
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2121
|
-
}
|
|
2122
|
-
return i;
|
|
2123
|
-
}
|
|
2124
|
-
function si(n, t) {
|
|
2125
|
-
const e = Math.max(n.left, t.left), i = Math.min(n.right, t.right), s = Math.max(n.top, t.top), r = Math.min(n.bottom, t.bottom);
|
|
2126
|
-
return {
|
|
2127
|
-
bottom: r,
|
|
2128
|
-
height: Math.max(0, r - s),
|
|
2129
|
-
left: e,
|
|
2130
|
-
right: i,
|
|
2131
|
-
top: s,
|
|
2132
|
-
width: Math.max(0, i - e)
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
function Re(n, t, e) {
|
|
2136
|
-
return (n.left < t.right || e >= 0 && I(n.left, t.right, e)) && (t.left < n.right || e >= 0 && I(t.left, n.right, e)) && (n.top < t.bottom || e >= 0 && I(n.top, t.bottom, e)) && (t.top < n.bottom || e >= 0 && I(t.top, n.bottom, e));
|
|
2137
|
-
}
|
|
2138
|
-
function I(n, t, e) {
|
|
2139
|
-
return Math.abs(n - t) <= e;
|
|
2140
|
-
}
|
|
2141
|
-
function Vt(n) {
|
|
2142
|
-
const t = {}, e = n.document.documentElement.style;
|
|
2143
|
-
for (const i in n.document.documentElement.style)
|
|
2144
|
-
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2145
|
-
return t;
|
|
2146
|
-
}
|
|
2147
|
-
function De(n, t) {
|
|
2148
|
-
const e = Vt(n);
|
|
2149
|
-
Object.keys(e).forEach((i) => {
|
|
2150
|
-
t.hasOwnProperty(i) || gt(n, i);
|
|
2151
|
-
}), Object.entries(t).forEach(([i, s]) => {
|
|
2152
|
-
e[i] !== s && st(n, i, s);
|
|
2153
|
-
});
|
|
2154
|
-
}
|
|
2155
|
-
function wt(n, t) {
|
|
2156
|
-
return n.document.documentElement.style.getPropertyValue(t);
|
|
2157
|
-
}
|
|
2158
|
-
function st(n, t, e) {
|
|
2159
|
-
n.document.documentElement.style.setProperty(t, e);
|
|
2160
|
-
}
|
|
2161
|
-
function gt(n, t) {
|
|
2162
|
-
n.document.documentElement.style.removeProperty(t);
|
|
2163
|
-
}
|
|
2164
|
-
let lt = null, St = null, J = 0;
|
|
2165
|
-
const $ = { r: 255, g: 255, b: 255, a: 1 }, G = /* @__PURE__ */ new Map(), ri = () => {
|
|
2166
|
-
if (!lt)
|
|
2167
|
-
if (typeof OffscreenCanvas < "u")
|
|
2168
|
-
lt = new OffscreenCanvas(5, 5), St = lt.getContext("2d", {
|
|
2169
|
-
willReadFrequently: !0,
|
|
2170
|
-
desynchronized: !0
|
|
2171
|
-
});
|
|
2172
|
-
else {
|
|
2173
|
-
const n = document.createElement("canvas");
|
|
2174
|
-
n.width = 5, n.height = 5, lt = n, St = n.getContext("2d", {
|
|
2175
|
-
willReadFrequently: !0,
|
|
2176
|
-
desynchronized: !0
|
|
2177
|
-
});
|
|
2178
|
-
}
|
|
2179
|
-
return St;
|
|
2180
|
-
}, ni = (n) => {
|
|
2181
|
-
if (!n) return !0;
|
|
2182
|
-
const t = n.trim().toLowerCase();
|
|
2183
|
-
return t.startsWith("var(") || [
|
|
2184
|
-
"transparent",
|
|
2185
|
-
"currentcolor",
|
|
2186
|
-
"inherit",
|
|
2187
|
-
"initial",
|
|
2188
|
-
"revert",
|
|
2189
|
-
"unset",
|
|
2190
|
-
"revert-layer"
|
|
2191
|
-
].includes(t) ? !0 : [
|
|
2192
|
-
"linear-gradient",
|
|
2193
|
-
"radial-gradient",
|
|
2194
|
-
"conic-gradient",
|
|
2195
|
-
"repeating-linear-gradient",
|
|
2196
|
-
"repeating-radial-gradient",
|
|
2197
|
-
"repeating-conic-gradient"
|
|
2198
|
-
].some((s) => t.includes(s));
|
|
2199
|
-
}, ct = (n, t) => {
|
|
2200
|
-
console.warn(
|
|
2201
|
-
`[Decorator] Could not parse color: "${n}". ${t} Falling back to ${JSON.stringify($)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
2202
|
-
);
|
|
2203
|
-
}, Ct = (n, t = null) => {
|
|
2204
|
-
const e = t ? `${n}|${t}` : n, i = G.get(e);
|
|
2205
|
-
if (i !== void 0)
|
|
2206
|
-
return i ?? $;
|
|
2207
|
-
if (ni(n))
|
|
2208
|
-
return ct(n, "Unsupported color format or special value."), G.set(e, null), $;
|
|
2209
|
-
const s = ri();
|
|
2210
|
-
if (!s)
|
|
2211
|
-
return ct(n, "Could not get canvas context."), G.set(e, null), $;
|
|
2212
|
-
try {
|
|
2213
|
-
J === 0 && s.clearRect(0, 0, 5, 5);
|
|
2214
|
-
const r = J % 5, o = Math.floor(J / 5);
|
|
2215
|
-
s.clearRect(r, o, 1, 1), t && (s.fillStyle = t, s.fillRect(r, o, 1, 1)), s.fillStyle = n, s.fillRect(r, o, 1, 1);
|
|
2216
|
-
const a = s.getImageData(r, o, 1, 1);
|
|
2217
|
-
J = (J + 1) % 25;
|
|
2218
|
-
const [c, u, d, f] = a.data;
|
|
2219
|
-
if (f === 0)
|
|
2220
|
-
return ct(n, "Fully transparent color."), G.set(e, null), $;
|
|
2221
|
-
const p = { r: c, g: u, b: d, a: f / 255 };
|
|
2222
|
-
return G.set(e, p), p;
|
|
2223
|
-
} catch (r) {
|
|
2224
|
-
return ct(n, `Error: ${r instanceof Error ? r.message : String(r)}`), G.set(e, null), $;
|
|
2225
|
-
}
|
|
2226
|
-
}, Et = (n) => {
|
|
2227
|
-
const t = n / 255;
|
|
2228
|
-
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2229
|
-
}, de = (n) => {
|
|
2230
|
-
const t = Et(n.r), e = Et(n.g), i = Et(n.b);
|
|
2231
|
-
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2232
|
-
}, ue = (n, t) => {
|
|
2233
|
-
const e = typeof n == "string" ? Ct(n) : n, i = typeof t == "string" ? Ct(t) : t, s = de(e), r = de(i), o = Math.max(s, r), a = Math.min(s, r);
|
|
2234
|
-
return (o + 0.05) / (a + 0.05);
|
|
2235
|
-
}, xt = (n, t = null) => {
|
|
2236
|
-
const e = Ct(n, t), i = ue(e, { r: 255, g: 255, b: 255, a: 1 }), s = ue(e, { r: 0, g: 0, b: 0, a: 1 });
|
|
2237
|
-
return i > s;
|
|
2238
|
-
}, oi = (n, t = null) => xt(n, t) ? "white" : "black", pe = "#FFFF00";
|
|
2239
|
-
var ai = /* @__PURE__ */ ((n) => (n.Wrap = "wrap", n.Viewport = "viewport", n.Bounds = "bounds", n.Page = "page", n))(ai || {}), li = /* @__PURE__ */ ((n) => (n.Boxes = "boxes", n.Bounds = "bounds", n))(li || {});
|
|
2240
|
-
const ci = () => "Highlight" in window, me = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2241
|
-
class hi {
|
|
2242
|
-
/**
|
|
2243
|
-
* Creates a DecorationGroup object
|
|
2244
|
-
* @param id Unique HTML ID-adhering name of the group
|
|
2245
|
-
* @param name Human-readable name of the group
|
|
2246
|
-
*/
|
|
2247
|
-
constructor(t, e, i, s) {
|
|
2248
|
-
this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, ci() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2249
|
-
}
|
|
2250
|
-
get activeable() {
|
|
2251
|
-
return this.activateable;
|
|
2252
|
-
}
|
|
2253
|
-
set activeable(t) {
|
|
2254
|
-
this.activateable = t;
|
|
2255
|
-
}
|
|
2256
|
-
/**
|
|
2257
|
-
* Adds a new decoration to the group.
|
|
2258
|
-
* @param decoration Decoration to add
|
|
2259
|
-
*/
|
|
2260
|
-
add(t) {
|
|
2261
|
-
const e = `${this.id}-${this.lastItemId++}`, i = rt(this.wnd.document, t.locator);
|
|
2262
|
-
if (!i) {
|
|
2263
|
-
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2264
|
-
return;
|
|
2265
|
-
}
|
|
2266
|
-
const s = i.commonAncestorContainer;
|
|
2267
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (me.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(me.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
|
|
2268
|
-
const r = {
|
|
2269
|
-
decoration: t,
|
|
2270
|
-
id: e,
|
|
2271
|
-
range: i
|
|
2272
|
-
};
|
|
2273
|
-
this.items.push(r), this.layout(r), this.renderLayout([r]);
|
|
2274
|
-
}
|
|
2275
|
-
/**
|
|
2276
|
-
* Removes the decoration with given ID from the group.
|
|
2277
|
-
* @param identifier ID of item to remove
|
|
2278
|
-
*/
|
|
2279
|
-
remove(t) {
|
|
2280
|
-
const e = this.items.findIndex((s) => s.decoration.id === t);
|
|
2281
|
-
if (e < 0) return;
|
|
2282
|
-
const i = this.items[e];
|
|
2283
|
-
this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
|
|
2284
|
-
}
|
|
2285
|
-
/**
|
|
2286
|
-
* Notifies that the given decoration was modified and needs to be updated.
|
|
2287
|
-
* @param decoration Decoration to update
|
|
2288
|
-
*/
|
|
2289
|
-
update(t) {
|
|
2290
|
-
this.remove(t.id), this.add(t);
|
|
2291
|
-
}
|
|
2292
|
-
/**
|
|
2293
|
-
* Removes all decorations from this group.
|
|
2294
|
-
*/
|
|
2295
|
-
clear() {
|
|
2296
|
-
this.clearContainer(), this.items.length = 0, this.notTextFlag?.clear();
|
|
2297
|
-
}
|
|
2298
|
-
/**
|
|
2299
|
-
* Recreates the decoration elements.
|
|
2300
|
-
* To be called after reflowing the resource, for example.
|
|
2301
|
-
*/
|
|
2302
|
-
requestLayout() {
|
|
2303
|
-
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);
|
|
2304
|
-
}
|
|
2305
|
-
experimentalLayout(t) {
|
|
2306
|
-
const [e, i] = this.requireContainer(!0);
|
|
2307
|
-
i.add(t.range);
|
|
2308
|
-
const s = wt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), r = t.decoration?.style?.tint ?? pe;
|
|
2309
|
-
e.innerHTML = `
|
|
2310
|
-
::highlight(${this.id}) {
|
|
2311
|
-
color: ${oi(r, s)};
|
|
2312
|
-
background-color: ${r};
|
|
2313
|
-
}`;
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* Layouts a single DecorationItem.
|
|
2317
|
-
* @param item
|
|
2318
|
-
*/
|
|
2319
|
-
layout(t) {
|
|
2320
|
-
if (this.experimentalHighlights && !this.notTextFlag?.has(t.id))
|
|
2321
|
-
return this.experimentalLayout(t);
|
|
2322
|
-
const e = this.wnd.document.createElement("div");
|
|
2323
|
-
e.setAttribute("id", t.id), e.dataset.highlightId = t.decoration.id, e.style.setProperty("pointer-events", "none");
|
|
2324
|
-
const i = this.wnd.innerWidth, s = parseInt(
|
|
2325
|
-
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2326
|
-
"column-count"
|
|
2327
|
-
)
|
|
2328
|
-
), r = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, u = (g, m, b) => {
|
|
2329
|
-
if (g.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2330
|
-
g.style.width = `${i}px`, g.style.height = `${m.height}px`;
|
|
2331
|
-
let D = Math.floor(m.left / i) * i;
|
|
2332
|
-
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2333
|
-
} else if (t.decoration?.style?.width === "bounds")
|
|
2334
|
-
g.style.width = `${b.width}px`, g.style.height = `${m.height}px`, g.style.left = `${b.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2335
|
-
else if (t.decoration?.style?.width === "page") {
|
|
2336
|
-
g.style.width = `${r}px`, g.style.height = `${m.height}px`;
|
|
2337
|
-
let D = Math.floor(m.left / r) * r;
|
|
2338
|
-
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2339
|
-
} else
|
|
2340
|
-
g.style.width = `${m.width}px`, g.style.height = `${m.height}px`, g.style.left = `${m.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2341
|
-
}, d = t.range.getBoundingClientRect();
|
|
2342
|
-
let f = this.wnd.document.createElement("template");
|
|
2343
|
-
const p = this.getCurrentDarkMode();
|
|
2344
|
-
f.innerHTML = `
|
|
2345
|
-
<div
|
|
2346
|
-
data-readium="true"
|
|
2347
|
-
class="readium-highlight"
|
|
2348
|
-
style="${[
|
|
2349
|
-
`background-color: ${t.decoration?.style?.tint ?? pe} !important`,
|
|
2350
|
-
//"opacity: 0.3 !important",
|
|
2351
|
-
`mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
|
|
2352
|
-
"opacity: 1 !important",
|
|
2353
|
-
"box-sizing: border-box !important"
|
|
2354
|
-
].join("; ")}"
|
|
2355
|
-
>
|
|
2356
|
-
</div>
|
|
2357
|
-
`.trim();
|
|
2358
|
-
const v = f.content.firstElementChild;
|
|
2359
|
-
if (t.decoration?.style?.layout === "bounds") {
|
|
2360
|
-
const g = v.cloneNode(!0);
|
|
2361
|
-
g.style.setProperty("pointer-events", "none"), u(g, d, d), e.append(g);
|
|
2362
|
-
} else {
|
|
2363
|
-
let g = je(
|
|
2364
|
-
t.range
|
|
2365
|
-
);
|
|
2366
|
-
g = g.sort((m, b) => m.top < b.top ? -1 : m.top > b.top ? 1 : 0);
|
|
2367
|
-
for (let m of g) {
|
|
2368
|
-
const b = v.cloneNode(!0);
|
|
2369
|
-
b.style.setProperty("pointer-events", "none"), u(b, m, d), e.append(b);
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
t.container = e, t.clickableElements = Array.from(
|
|
2373
|
-
e.querySelectorAll("[data-activable='1']")
|
|
2374
|
-
), t.clickableElements.length || (t.clickableElements = Array.from(e.children));
|
|
2375
|
-
}
|
|
2376
|
-
renderLayout(t) {
|
|
2377
|
-
this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
|
|
2378
|
-
if (t = t.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !t || t.length === 0) return;
|
|
2379
|
-
this.requireContainer().append(...t.map((i) => i.container).filter((i) => !!i));
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* Returns the group container element, after making sure it exists.
|
|
2384
|
-
* @returns Group's container
|
|
2385
|
-
*/
|
|
2386
|
-
requireContainer(t = !1) {
|
|
2387
|
-
if (t) {
|
|
2388
|
-
let e;
|
|
2389
|
-
this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));
|
|
2390
|
-
let i;
|
|
2391
|
-
return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];
|
|
2392
|
-
}
|
|
2393
|
-
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;
|
|
2394
|
-
}
|
|
2395
|
-
getCurrentDarkMode() {
|
|
2396
|
-
return wt(this.wnd, "--USER__appearance") === "readium-night-on" || xt(wt(this.wnd, "--USER__backgroundColor")) || xt(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
|
|
2397
|
-
}
|
|
2398
|
-
/**
|
|
2399
|
-
* Removes the group container.
|
|
2400
|
-
*/
|
|
2401
|
-
clearContainer() {
|
|
2402
|
-
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
const j = class j extends K {
|
|
2406
|
-
constructor() {
|
|
2407
|
-
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2408
|
-
}
|
|
2409
|
-
cleanup() {
|
|
2410
|
-
this.groups.forEach((t) => t.clear()), this.groups.clear();
|
|
2411
|
-
}
|
|
2412
|
-
updateHighlightStyles() {
|
|
2413
|
-
this.groups.forEach((t) => {
|
|
2414
|
-
t.requestLayout();
|
|
2415
|
-
});
|
|
2416
|
-
}
|
|
2417
|
-
extractCustomProperty(t, e) {
|
|
2418
|
-
if (!t) return null;
|
|
2419
|
-
const i = t.match(new RegExp(`${e}:\\s*([^;]+)`));
|
|
2420
|
-
return i ? i[1].trim() : null;
|
|
2421
|
-
}
|
|
2422
|
-
handleResize() {
|
|
2423
|
-
this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
|
|
2424
|
-
this.groups.forEach((t) => {
|
|
2425
|
-
t.experimentalHighlights || t.requestLayout();
|
|
2426
|
-
});
|
|
2427
|
-
}, 50);
|
|
2428
|
-
}
|
|
2429
|
-
mount(t, e) {
|
|
2430
|
-
return this.wnd = t, e.register("decorate", j.moduleName, (i, s) => {
|
|
2431
|
-
const r = i;
|
|
2432
|
-
r.decoration && r.decoration.locator && (r.decoration.locator = k.deserialize(r.decoration.locator)), this.groups.has(r.group) || this.groups.set(r.group, new hi(
|
|
2433
|
-
t,
|
|
2434
|
-
e,
|
|
2435
|
-
`readium-decoration-${this.lastGroupId++}`,
|
|
2436
|
-
r.group
|
|
2437
|
-
));
|
|
2438
|
-
const o = this.groups.get(r.group);
|
|
2439
|
-
switch (r.action) {
|
|
2440
|
-
case "add":
|
|
2441
|
-
o?.add(r.decoration);
|
|
2442
|
-
break;
|
|
2443
|
-
case "remove":
|
|
2444
|
-
o?.remove(r.decoration.id);
|
|
2445
|
-
break;
|
|
2446
|
-
case "clear":
|
|
2447
|
-
o?.clear();
|
|
2448
|
-
break;
|
|
2449
|
-
case "update":
|
|
2450
|
-
o?.update(r.decoration);
|
|
2451
|
-
break;
|
|
2452
|
-
}
|
|
2453
|
-
s(!0);
|
|
2454
|
-
}), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
|
|
2455
|
-
i.some((r) => {
|
|
2456
|
-
if (r.type === "attributes" && r.attributeName === "style") {
|
|
2457
|
-
const o = r.target, a = r.oldValue, c = o.getAttribute("style"), u = this.extractCustomProperty(a, "--USER__appearance"), d = this.extractCustomProperty(c, "--USER__appearance"), f = this.extractCustomProperty(a, "--USER__backgroundColor"), p = this.extractCustomProperty(c, "--USER__backgroundColor");
|
|
2458
|
-
return u !== d || f !== p;
|
|
2459
|
-
}
|
|
2460
|
-
return !1;
|
|
2461
|
-
}) && this.updateHighlightStyles();
|
|
2462
|
-
}), this.backgroundObserver.observe(t.document.documentElement, {
|
|
2463
|
-
attributes: !0,
|
|
2464
|
-
attributeFilter: ["style"],
|
|
2465
|
-
attributeOldValue: !0,
|
|
2466
|
-
subtree: !0
|
|
2467
|
-
}), e.log("Decorator Mounted"), !0;
|
|
2468
|
-
}
|
|
2469
|
-
unmount(t, e) {
|
|
2470
|
-
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(j.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2471
|
-
}
|
|
2472
|
-
};
|
|
2473
|
-
j.moduleName = "decorator";
|
|
2474
|
-
let Tt = j;
|
|
2475
|
-
const fe = "readium-snapper-style", tt = class tt extends K {
|
|
2476
|
-
constructor() {
|
|
2477
|
-
super(...arguments), this.protected = !1;
|
|
2478
|
-
}
|
|
2479
|
-
buildStyles() {
|
|
2480
|
-
return `
|
|
2481
|
-
html, body {
|
|
2482
|
-
touch-action: manipulation;
|
|
2483
|
-
user-select: ${this.protected ? "none" : "auto"};
|
|
2484
|
-
}`;
|
|
2485
|
-
}
|
|
2486
|
-
mount(t, e) {
|
|
2487
|
-
const i = t.document.createElement("style");
|
|
2488
|
-
return i.dataset.readium = "true", i.id = fe, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", tt.moduleName, (s, r) => {
|
|
2489
|
-
this.protected = !0, i.textContent = this.buildStyles(), r(!0);
|
|
2490
|
-
}), e.register("unprotect", tt.moduleName, (s, r) => {
|
|
2491
|
-
this.protected = !1, i.textContent = this.buildStyles(), r(!0);
|
|
2492
|
-
}), e.log("Snapper Mounted"), !0;
|
|
2493
|
-
}
|
|
2494
|
-
unmount(t, e) {
|
|
2495
|
-
return t.document.getElementById(fe)?.remove(), e.log("Snapper Unmounted"), !0;
|
|
2496
|
-
}
|
|
2497
|
-
};
|
|
2498
|
-
tt.moduleName = "snapper";
|
|
2499
|
-
let X = tt;
|
|
2500
|
-
function di(n) {
|
|
2501
|
-
return (n.document.documentElement.dir || n.document.body.dir).toLowerCase() === "rtl";
|
|
2502
|
-
}
|
|
2503
|
-
function ui(n) {
|
|
2504
|
-
return (n.getComputedStyle(n.document.documentElement).writingMode || n.getComputedStyle(n.document.body).writingMode) === "vertical-lr";
|
|
2505
|
-
}
|
|
2506
|
-
function Ie(n) {
|
|
2507
|
-
return parseInt(
|
|
2508
|
-
n.getComputedStyle(
|
|
2509
|
-
n.document.documentElement
|
|
2510
|
-
).getPropertyValue("column-count")
|
|
2511
|
-
);
|
|
2512
|
-
}
|
|
2513
|
-
function ge(n) {
|
|
2514
|
-
const t = getComputedStyle(n), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2515
|
-
return n.clientHeight - e - i;
|
|
2516
|
-
}
|
|
2517
|
-
function ye(n) {
|
|
2518
|
-
const t = Ie(n);
|
|
2519
|
-
if (!t)
|
|
2520
|
-
return !1;
|
|
2521
|
-
const e = n.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2522
|
-
for (const u of e)
|
|
2523
|
-
u.remove();
|
|
2524
|
-
const i = e.length, s = n.document.scrollingElement.scrollWidth, r = n.visualViewport.width, a = Math.round(s / r * t) % t, c = t === 1 || a === 0 ? 0 : t - a;
|
|
2525
|
-
if (c > 0)
|
|
2526
|
-
for (let u = 0; u < c; u++) {
|
|
2527
|
-
const d = n.document.createElement("div");
|
|
2528
|
-
d.setAttribute("id", `readium-virtual-page-${u}`), d.dataset.readium = "true", CSS.supports("break-before", "column") ? d.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (d.style.breakInside = "avoid-column"), d.style.height = ge(n.document.documentElement) + "px"), d.innerHTML = "​", n.document.body.appendChild(d);
|
|
2529
|
-
}
|
|
2530
|
-
return i !== c;
|
|
2531
|
-
}
|
|
2532
|
-
function Ft(n) {
|
|
2533
|
-
const t = n.document.createElement("style");
|
|
2534
|
-
t.appendChild(n.document.createTextNode("*{}")), n.document.body.appendChild(t), n.document.body.removeChild(t);
|
|
2535
|
-
}
|
|
2536
|
-
function pi(n) {
|
|
2537
|
-
return n < 0.5 ? 2 * n * n : -1 + (4 - 2 * n) * n;
|
|
2538
|
-
}
|
|
2539
|
-
function A(n) {
|
|
2540
|
-
const t = n.getSelection();
|
|
2541
|
-
t && t.removeAllRanges();
|
|
2542
|
-
}
|
|
2543
|
-
const mi = [
|
|
2544
|
-
"a",
|
|
2545
|
-
"area",
|
|
2546
|
-
"audio",
|
|
2547
|
-
"button",
|
|
2548
|
-
"canvas",
|
|
2549
|
-
"details",
|
|
2550
|
-
"input",
|
|
2551
|
-
"label",
|
|
2552
|
-
"option",
|
|
2553
|
-
"select",
|
|
2554
|
-
"submit",
|
|
2555
|
-
"textarea",
|
|
2556
|
-
"video"
|
|
2557
|
-
], fi = ["dialog", "radiogroup", "radio", "menu", "menuitem"];
|
|
2558
|
-
function Gt(n) {
|
|
2559
|
-
return gi(n) ? null : ze(n) ? n : n.parentElement ? Gt(n.parentElement) : null;
|
|
2560
|
-
}
|
|
2561
|
-
function gi(n) {
|
|
2562
|
-
return n ? n.closest("[inert]") !== null || n.hasAttribute("disabled") : !0;
|
|
2563
|
-
}
|
|
2564
|
-
function ze(n) {
|
|
2565
|
-
return n ? n.role && fi.includes(n.role) ? !0 : n.tagName.toLowerCase() === "iframe" ? !1 : n.tabIndex >= 0 ? !0 : mi.includes(n.nodeName.toLowerCase()) || n.hasAttribute("contenteditable") && n.getAttribute("contenteditable")?.toLowerCase() !== "false" : !1;
|
|
2566
|
-
}
|
|
2567
|
-
function yt(n, t) {
|
|
2568
|
-
const e = Me(n, n.document.body, t), i = n._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2569
|
-
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2570
|
-
});
|
|
2571
|
-
return new k({
|
|
2572
|
-
href: "#",
|
|
2573
|
-
type: "application/xhtml+xml",
|
|
2574
|
-
locations: new C({
|
|
2575
|
-
otherLocations: /* @__PURE__ */ new Map([
|
|
2576
|
-
["cssSelector", i]
|
|
2577
|
-
])
|
|
2578
|
-
}),
|
|
2579
|
-
text: new H({
|
|
2580
|
-
highlight: e.textContent || void 0
|
|
2581
|
-
})
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
function Me(n, t, e) {
|
|
2585
|
-
for (var i = 0; i < t.children.length; i++) {
|
|
2586
|
-
const s = t.children[i];
|
|
2587
|
-
if (!vi(s) && yi(n, s, e))
|
|
2588
|
-
return bi(n, s) ? s : Me(n, s, e);
|
|
2589
|
-
}
|
|
2590
|
-
return t;
|
|
2591
|
-
}
|
|
2592
|
-
function yi(n, t, e) {
|
|
2593
|
-
if (t === document.body || t === document.documentElement)
|
|
2594
|
-
return !0;
|
|
2595
|
-
if (!document || !document.documentElement || !document.body)
|
|
2596
|
-
return !1;
|
|
2597
|
-
const i = t.getBoundingClientRect();
|
|
2598
|
-
return e ? i.bottom > 0 && i.top < n.innerHeight : i.right > 0 && i.left < n.innerWidth;
|
|
2599
|
-
}
|
|
2600
|
-
function bi(n, t) {
|
|
2601
|
-
const e = t.getBoundingClientRect();
|
|
2602
|
-
return e.top >= 0 && e.left >= 0 && e.bottom <= n.innerHeight && e.right <= n.innerWidth;
|
|
2603
|
-
}
|
|
2604
|
-
function vi(n) {
|
|
2605
|
-
const t = getComputedStyle(n);
|
|
2606
|
-
if (t) {
|
|
2607
|
-
const e = t.getPropertyValue("display");
|
|
2608
|
-
if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
|
|
2609
|
-
return !0;
|
|
2610
|
-
}
|
|
2611
|
-
return !1;
|
|
2612
|
-
}
|
|
2613
|
-
const wi = {
|
|
2614
|
-
maxVelocity: 200,
|
|
2615
|
-
// Reasonable default for human-like scrolling (pixels/ms)
|
|
2616
|
-
minVariance: 0.01,
|
|
2617
|
-
// Default variance threshold
|
|
2618
|
-
historySize: 20,
|
|
2619
|
-
// Balanced history size for performance
|
|
2620
|
-
minDirectionChanges: 0.2,
|
|
2621
|
-
// Reasonable default for detecting patterns
|
|
2622
|
-
maxConsistentScrolls: 15
|
|
2623
|
-
// Balanced threshold for flagging
|
|
2624
|
-
}, $t = {
|
|
2625
|
-
maxVelocity: 200,
|
|
2626
|
-
// Extremely fast scrolling (pixels/ms)
|
|
2627
|
-
minVariance: 1e-5,
|
|
2628
|
-
// Near-perfect consistency
|
|
2629
|
-
historySize: 100,
|
|
2630
|
-
// Large history window
|
|
2631
|
-
minDirectionChanges: 0.1,
|
|
2632
|
-
// Only trigger on near-perfect patterns
|
|
2633
|
-
maxConsistentScrolls: 20
|
|
2634
|
-
// Need many consistent scrolls
|
|
2635
|
-
}, ke = {
|
|
2636
|
-
maxSelectionsPerSecond: 500,
|
|
2637
|
-
minVariance: 50,
|
|
2638
|
-
historySize: 20
|
|
2639
|
-
}, Si = {
|
|
2640
|
-
enabled: !0,
|
|
2641
|
-
maxSelectionPercent: 0.1,
|
|
2642
|
-
minThreshold: 100,
|
|
2643
|
-
absoluteMaxChars: 5e3,
|
|
2644
|
-
historySize: 20
|
|
2645
|
-
};
|
|
2646
|
-
class bt {
|
|
2647
|
-
constructor(t = {}) {
|
|
2648
|
-
this.history = [], this.consistentScrollCount = 0, this.options = { ...wi, ...t };
|
|
2649
|
-
}
|
|
2650
|
-
analyze(t, e, i) {
|
|
2651
|
-
if (i <= 0) return !1;
|
|
2652
|
-
const s = Math.abs(e) / i, r = Date.now();
|
|
2653
|
-
if (this.history.push({
|
|
2654
|
-
timestamp: r,
|
|
2655
|
-
direction: t,
|
|
2656
|
-
velocity: s,
|
|
2657
|
-
distance: Math.abs(e)
|
|
2658
|
-
}), this.history = this.history.filter((m) => r - m.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
|
|
2659
|
-
if (s > this.options.maxVelocity)
|
|
2660
|
-
return this.resetAfterDetection(), !0;
|
|
2661
|
-
const o = this.history.map((m) => m.velocity), a = this.history.map((m) => m.distance), c = o.reduce((m, b) => m + b, 0) / o.length, u = a.reduce((m, b) => m + b, 0) / a.length, d = o.reduce((m, b) => m + Math.pow(b - c, 2), 0) / o.length, f = a.reduce((m, b) => m + Math.pow(b - u, 2), 0) / a.length;
|
|
2662
|
-
if (d < this.options.minVariance && f < u * 0.1) {
|
|
2663
|
-
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2664
|
-
return this.resetAfterDetection(), !0;
|
|
2665
|
-
} else
|
|
2666
|
-
this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
|
|
2667
|
-
let p = 0, v = this.history[0].direction;
|
|
2668
|
-
for (let m = 1; m < this.history.length; m++)
|
|
2669
|
-
this.history[m].direction !== v && (p++, v = this.history[m].direction);
|
|
2670
|
-
return p / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
|
|
2671
|
-
}
|
|
2672
|
-
resetAfterDetection() {
|
|
2673
|
-
this.history = this.history.slice(-3), this.consistentScrollCount = 0;
|
|
2674
|
-
}
|
|
2675
|
-
clear() {
|
|
2676
|
-
this.history = [], this.consistentScrollCount = 0;
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
2680
|
-
constructor() {
|
|
2681
|
-
super(...arguments), this.isSnapProtectionEnabled = !1, this.patternAnalyzer = null, this.lastTurnTime = 0, this.rtl = !1, 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);
|
|
2682
|
-
}
|
|
2683
|
-
doc() {
|
|
2684
|
-
return this.wnd.document.scrollingElement;
|
|
2685
|
-
}
|
|
2686
|
-
scrollOffset() {
|
|
2687
|
-
const t = this.doc().scrollLeft;
|
|
2688
|
-
return t !== 0 ? t : this.alreadyScrollLeft;
|
|
2689
|
-
}
|
|
2690
|
-
snapOffset(t) {
|
|
2691
|
-
const e = t + (this.rtl ? -1 : 1);
|
|
2692
|
-
return e - e % this.wnd.innerWidth;
|
|
2693
|
-
}
|
|
2694
|
-
/**
|
|
2695
|
-
* Snap a non-negative normalized offset (distance from document start) to
|
|
2696
|
-
* the nearest page boundary. Works identically regardless of reading direction.
|
|
2697
|
-
*/
|
|
2698
|
-
snapNormOffset(t) {
|
|
2699
|
-
const e = t + 1;
|
|
2700
|
-
return e - e % this.wnd.innerWidth;
|
|
2701
|
-
}
|
|
2702
|
-
/**
|
|
2703
|
-
* Normalized scroll position: distance from document start, always in
|
|
2704
|
-
* [0, scrollWidth - innerWidth] regardless of reading direction.
|
|
2705
|
-
* scrollLeft may be negative depending on the browser — Math.abs() normalizes it.
|
|
2706
|
-
*/
|
|
2707
|
-
normScroll() {
|
|
2708
|
-
const t = this.doc().scrollLeft || this.alreadyScrollLeft;
|
|
2709
|
-
return this.rtl ? Math.abs(t) : Math.max(0, this.wnd.scrollX > 0 ? this.wnd.scrollX : t);
|
|
2710
|
-
}
|
|
2711
|
-
reportProgress() {
|
|
2712
|
-
const t = this.cachedScrollWidth, e = this.wnd.innerWidth, i = this.normScroll(), s = Math.max(1, t - e), r = Math.max(0, Math.min(1, i / s)), o = Math.max(0, Math.min(1, (i + e) / t));
|
|
2713
|
-
this.comms.send("progress", {
|
|
2714
|
-
start: r,
|
|
2715
|
-
end: o
|
|
2716
|
-
});
|
|
2717
|
-
}
|
|
2718
|
-
shake() {
|
|
2719
|
-
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2720
|
-
const t = this.doc(), e = this.normScroll() < 5, i = this.rtl ? e ? "readium-bounce-r" : "readium-bounce-l" : "readium-bounce-r";
|
|
2721
|
-
t.classList.add(i);
|
|
2722
|
-
const s = this.scrollOffset();
|
|
2723
|
-
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2724
|
-
t.classList.remove(i), this.shakeTimeout = 0, this.doc().scrollLeft = s;
|
|
2725
|
-
}, 150);
|
|
2726
|
-
}
|
|
2727
|
-
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
2728
|
-
takeOverSnap() {
|
|
2729
|
-
this.snappingCancelled = !0, this.clearTouches();
|
|
2730
|
-
const t = this.doc();
|
|
2731
|
-
this.overscroll = t.style.transform?.length > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;
|
|
2732
|
-
}
|
|
2733
|
-
// Snaps the current offset to the page width.
|
|
2734
|
-
snapCurrentOffset(t = !1, e = !1) {
|
|
2735
|
-
const i = this.doc(), s = Ie(this.wnd), r = this.cachedScrollWidth - this.wnd.innerWidth, o = Math.min(Math.max(0, this.normScroll()), r), a = this.dragOffset(), c = this.rtl ? -a : a, u = this.wnd.innerWidth / 3 * (c > 0 ? 2 : 1), d = Math.min(r, Math.max(0, this.snapNormOffset(o + u))), f = this.rtl ? -d : d, p = this.rtl ? -o : o, v = f > p ? "right" : "left";
|
|
2736
|
-
if (this.checkSuspiciousSnap(v, Math.abs(f - p)), t && f !== p) {
|
|
2737
|
-
this.snappingCancelled = !1;
|
|
2738
|
-
const g = (_, V, nt, ot) => nt > ot ? V : _ + (V - _) * pi(nt / ot), m = Ei * s;
|
|
2739
|
-
let b;
|
|
2740
|
-
const D = (_) => {
|
|
2741
|
-
if (this.snappingCancelled) return;
|
|
2742
|
-
b || (b = _);
|
|
2743
|
-
const V = _ - b, nt = g(this.overscroll, 0, V, m), ot = g(p, f, V, m);
|
|
2744
|
-
i.scrollLeft = ot, this.overscroll !== 0 && (i.style.transform = `translate3d(${-nt}px, 0px, 0px)`), V < m ? this.wnd.requestAnimationFrame(D) : (this.clearTouches(), i.style.removeProperty("transform"), i.scrollLeft = f, e || this.reportProgress());
|
|
2745
|
-
};
|
|
2746
|
-
this.wnd.requestAnimationFrame(D);
|
|
2747
|
-
} else
|
|
2748
|
-
i.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2749
|
-
i.scrollLeft = f, this.clearTouches(), e || this.reportProgress();
|
|
2750
|
-
});
|
|
2751
|
-
}
|
|
2752
|
-
dragOffset() {
|
|
2753
|
-
return (this.startingX ?? 0) - (this.endingX ?? 0);
|
|
2754
|
-
}
|
|
2755
|
-
clearTouches() {
|
|
2756
|
-
this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
|
|
2757
|
-
}
|
|
2758
|
-
onTouchStart(t) {
|
|
2759
|
-
switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {
|
|
2760
|
-
case 1:
|
|
2761
|
-
break;
|
|
2762
|
-
case 2:
|
|
2763
|
-
this.onTouchEnd(t);
|
|
2764
|
-
return;
|
|
2765
|
-
default: {
|
|
2766
|
-
this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);
|
|
2767
|
-
return;
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
|
|
2771
|
-
}
|
|
2772
|
-
onTouchEnd(t) {
|
|
2773
|
-
if (this.touchState === 2) {
|
|
2774
|
-
const e = this.dragOffset(), i = this.normScroll(), s = this.cachedScrollWidth - this.wnd.innerWidth, r = this.rtl ? -e : e;
|
|
2775
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), r > 5 && this.comms.send("no_more", void 0), r < -5 && this.comms.send("no_less", void 0)) : i < 5 && r < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : s - i < 5 && r > 5 && (this.alreadyScrollLeft = this.rtl ? -s : s, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
|
|
2776
|
-
}
|
|
2777
|
-
this.touchState = 0;
|
|
2778
|
-
}
|
|
2779
|
-
onWidthChange() {
|
|
2780
|
-
this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
|
|
2781
|
-
}
|
|
2782
|
-
onTouchMove(t) {
|
|
2783
|
-
if (this.touchState === 0) return;
|
|
2784
|
-
this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2785
|
-
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, s = this.rtl ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0, r = this.rtl ? 0 : this.cachedScrollWidth - this.wnd.innerWidth;
|
|
2786
|
-
i < s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i > r ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = i);
|
|
2787
|
-
}
|
|
2788
|
-
enableSnapProtection() {
|
|
2789
|
-
this.patternAnalyzer || (this.patternAnalyzer = new bt({
|
|
2790
|
-
maxVelocity: this.wnd.innerWidth,
|
|
2791
|
-
// page width
|
|
2792
|
-
minVariance: 0.1,
|
|
2793
|
-
// Allow for some variation in swipe speed
|
|
2794
|
-
historySize: 5,
|
|
2795
|
-
// Fewer samples needed for swipe detection
|
|
2796
|
-
maxConsistentScrolls: 3,
|
|
2797
|
-
// Lower threshold for consistent scrolling
|
|
2798
|
-
minDirectionChanges: 0.3
|
|
2799
|
-
// Require more direction changes
|
|
2800
|
-
}), this.isSnapProtectionEnabled = !0, this.comms?.log("Snap protection enabled"));
|
|
2801
|
-
}
|
|
2802
|
-
checkSuspiciousSnap(t, e) {
|
|
2803
|
-
if (!this.isSnapProtectionEnabled || !this.patternAnalyzer) return;
|
|
2804
|
-
const i = Date.now(), s = i - (this.lastTurnTime || i);
|
|
2805
|
-
this.lastTurnTime = i, this.patternAnalyzer.analyze(t, e, s) && this.comms?.send("content_protection", {
|
|
2806
|
-
type: "suspicious_snapping",
|
|
2807
|
-
timestamp: Date.now(),
|
|
2808
|
-
event: null
|
|
2809
|
-
});
|
|
2810
|
-
}
|
|
2811
|
-
mount(t, e) {
|
|
2812
|
-
if (this.wnd = t, this.comms = e, this.rtl = di(t), !super.mount(t, e)) return !1;
|
|
2813
|
-
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2814
|
-
const i = t.document.createElement("style");
|
|
2815
|
-
i.dataset.readium = "true", i.id = be, i.textContent = `
|
|
2816
|
-
@keyframes readium-bounce-l-animation {
|
|
2817
|
-
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2818
|
-
50% {transform: translate3d(-50px, 0, 0);}
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
@keyframes readium-bounce-r-animation {
|
|
2822
|
-
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2823
|
-
50% {transform: translate3d(50px, 0, 0);}
|
|
2824
|
-
}
|
|
2825
|
-
|
|
2826
|
-
.readium-bounce-l {
|
|
2827
|
-
animation: readium-bounce-l-animation 150ms ease-out 1;
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
.readium-bounce-r {
|
|
2831
|
-
animation: readium-bounce-r-animation 150ms ease-out 1;
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
html {
|
|
2835
|
-
overflow: hidden;
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
body {
|
|
2839
|
-
-ms-overflow-style: none; /* for Internet Explorer, Edge */
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
|
-
* {
|
|
2843
|
-
scrollbar-width: none; /* for Firefox */
|
|
2844
|
-
}
|
|
2845
|
-
|
|
2846
|
-
body::-webkit-scrollbar {
|
|
2847
|
-
display: none; /* for Chrome, Safari, and Opera */
|
|
2848
|
-
}
|
|
2849
|
-
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2850
|
-
t.requestAnimationFrame(() => {
|
|
2851
|
-
t && ye(t);
|
|
2852
|
-
}), this.onWidthChange();
|
|
2853
|
-
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((o) => {
|
|
2854
|
-
for (const a of o)
|
|
2855
|
-
if (a.target === this.wnd.document.documentElement) {
|
|
2856
|
-
const c = a.oldValue, u = a.target.getAttribute("style"), d = /transform\s*:\s*([^;]+)/, f = c?.match(d), p = u?.match(d);
|
|
2857
|
-
(!f && !p || f && !p || f && p && f[1] !== p[1]) && (t.requestAnimationFrame(() => {
|
|
2858
|
-
t && ye(t);
|
|
2859
|
-
}), this.onWidthChange());
|
|
2860
|
-
} else
|
|
2861
|
-
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2862
|
-
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] }), e.register("scroll_protection", T.moduleName, (o, a) => {
|
|
2863
|
-
this.enableSnapProtection(), a(!0);
|
|
2864
|
-
});
|
|
2865
|
-
const s = (o) => {
|
|
2866
|
-
const a = this.doc().scrollLeft;
|
|
2867
|
-
return this.doc().scrollLeft = this.snapOffset(o), a !== this.doc().scrollLeft;
|
|
2868
|
-
}, r = (o) => {
|
|
2869
|
-
const a = this.doc().scrollLeft, c = this.snapNormOffset(Math.max(0, Math.min(this.cachedScrollWidth - t.innerWidth, o)));
|
|
2870
|
-
return this.doc().scrollLeft = -c, a !== this.doc().scrollLeft;
|
|
2871
|
-
};
|
|
2872
|
-
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", T.moduleName, (o, a) => {
|
|
2873
|
-
const c = o;
|
|
2874
|
-
if (c < 0 || c > 1) {
|
|
2875
|
-
e.send("error", {
|
|
2876
|
-
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2877
|
-
}), a(!1);
|
|
2878
|
-
return;
|
|
2879
|
-
}
|
|
2880
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2881
|
-
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2882
|
-
const d = (this.cachedScrollWidth - t.innerWidth) * c;
|
|
2883
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(d) : this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), A(this.wnd), a(!0);
|
|
2884
|
-
});
|
|
2885
|
-
}), e.register("go_id", T.moduleName, (o, a) => {
|
|
2886
|
-
const c = t.document.getElementById(o);
|
|
2887
|
-
if (!c) {
|
|
2888
|
-
a(!1);
|
|
2889
|
-
return;
|
|
2890
|
-
}
|
|
2891
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2892
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2893
|
-
});
|
|
2894
|
-
}), e.register("go_text", T.moduleName, (o, a) => {
|
|
2895
|
-
let c;
|
|
2896
|
-
Array.isArray(o) && (o.length > 1 && (c = o[1]), o = o[0]);
|
|
2897
|
-
const u = H.deserialize(o), d = rt(this.wnd.document, new k({
|
|
2898
|
-
href: t.location.href,
|
|
2899
|
-
type: "text/html",
|
|
2900
|
-
text: u,
|
|
2901
|
-
locations: c ? new C({
|
|
2902
|
-
otherLocations: /* @__PURE__ */ new Map([
|
|
2903
|
-
["cssSelector", c]
|
|
2904
|
-
])
|
|
2905
|
-
}) : void 0
|
|
2906
|
-
}));
|
|
2907
|
-
if (!d) {
|
|
2908
|
-
a(!1);
|
|
2909
|
-
return;
|
|
2910
|
-
}
|
|
2911
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2912
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(d.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(d.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2913
|
-
});
|
|
2914
|
-
}), e.register("go_end", T.moduleName, (o, a) => {
|
|
2915
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2916
|
-
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2917
|
-
let c;
|
|
2918
|
-
if (this.rtl ? c = -this.snapNormOffset(this.cachedScrollWidth - t.innerWidth) : c = this.snapOffset(this.cachedScrollWidth), this.doc().scrollLeft === c) return a(!1);
|
|
2919
|
-
this.doc().scrollLeft = c, this.reportProgress(), A(this.wnd), a(!0);
|
|
2920
|
-
});
|
|
2921
|
-
}), e.register("go_start", T.moduleName, (o, a) => {
|
|
2922
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2923
|
-
if (this.doc().scrollLeft === 0) return a(!1);
|
|
2924
|
-
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), a(!0);
|
|
2925
|
-
});
|
|
2926
|
-
}), e.register("go_prev", T.moduleName, (o, a) => {
|
|
2927
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2928
|
-
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2929
|
-
let c;
|
|
2930
|
-
this.rtl ? c = r(this.normScroll() - t.innerWidth) : c = s(t.scrollX - t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), a(c);
|
|
2931
|
-
});
|
|
2932
|
-
}), e.register("go_next", T.moduleName, (o, a) => {
|
|
2933
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2934
|
-
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2935
|
-
let c;
|
|
2936
|
-
this.rtl ? c = r(this.normScroll() + t.innerWidth) : c = s(t.scrollX + t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), a(c);
|
|
2937
|
-
});
|
|
2938
|
-
}), e.register("unfocus", T.moduleName, (o, a) => {
|
|
2939
|
-
this.snappingCancelled = !0, A(this.wnd), a(!0);
|
|
2940
|
-
}), e.register("shake", T.moduleName, (o, a) => {
|
|
2941
|
-
this.shake(), a(!0);
|
|
2942
|
-
}), e.register("focus", T.moduleName, (o, a) => {
|
|
2943
|
-
this.wnd.requestAnimationFrame(() => {
|
|
2944
|
-
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), a(!0);
|
|
2945
|
-
});
|
|
2946
|
-
}), e.register("first_visible_locator", T.moduleName, (o, a) => {
|
|
2947
|
-
const c = yt(t, !1);
|
|
2948
|
-
this.comms.send("first_visible_locator", c.serialize()), a(!0);
|
|
2949
|
-
}), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
|
|
2950
|
-
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2951
|
-
}
|
|
2952
|
-
unmount(t, e) {
|
|
2953
|
-
return this.snappingCancelled = !0, e.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isSnapProtectionEnabled = !1), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), t.document.getElementById(be)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
|
|
2954
|
-
}
|
|
2955
|
-
};
|
|
2956
|
-
T.moduleName = "column_snapper";
|
|
2957
|
-
let Pt = T;
|
|
2958
|
-
const ve = "readium-scroll-snapper-style", P = class P extends X {
|
|
2959
|
-
constructor() {
|
|
2960
|
-
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
|
|
2961
|
-
if (this.comms.ready && !this.isResizing) {
|
|
2962
|
-
if (!this.initialScrollHandled) {
|
|
2963
|
-
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
2964
|
-
return;
|
|
2965
|
-
}
|
|
2966
|
-
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2967
|
-
this.reportProgress();
|
|
2968
|
-
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
2969
|
-
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
2970
|
-
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
2971
|
-
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
2972
|
-
i > 0 ? "down" : "up",
|
|
2973
|
-
Math.abs(i),
|
|
2974
|
-
r
|
|
2975
|
-
)) {
|
|
2976
|
-
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
2977
|
-
this.comms?.send("content_protection", {
|
|
2978
|
-
type: "suspicious_scrolling",
|
|
2979
|
-
timestamp: Date.now(),
|
|
2980
|
-
scrollDelta: i,
|
|
2981
|
-
scrollDirection: i > 0 ? "down" : "up",
|
|
2982
|
-
targetElement: a
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
this.lastScrollTime = s;
|
|
2986
|
-
}
|
|
2987
|
-
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
2988
|
-
}));
|
|
2989
|
-
}
|
|
2990
|
-
};
|
|
2991
|
-
}
|
|
2992
|
-
doc() {
|
|
2993
|
-
return this.wnd.document.scrollingElement;
|
|
2994
|
-
}
|
|
2995
|
-
reportProgress() {
|
|
2996
|
-
if (!this.comms.ready) return;
|
|
2997
|
-
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), r = Math.max(0, Math.min(1, (t + i) / e));
|
|
2998
|
-
this.comms.send("progress", {
|
|
2999
|
-
start: s,
|
|
3000
|
-
end: r
|
|
3001
|
-
});
|
|
3002
|
-
}
|
|
3003
|
-
enableScrollProtection() {
|
|
3004
|
-
this.patternAnalyzer || (this.patternAnalyzer = new bt($t), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3005
|
-
}
|
|
3006
|
-
mount(t, e) {
|
|
3007
|
-
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
3008
|
-
const i = t.document.createElement("style");
|
|
3009
|
-
return i.dataset.readium = "true", i.id = ve, i.textContent = `
|
|
3010
|
-
* {
|
|
3011
|
-
scrollbar-width: none; /* for Firefox */
|
|
3012
|
-
}
|
|
3013
|
-
|
|
3014
|
-
body::-webkit-scrollbar {
|
|
3015
|
-
display: none; /* for Chrome, Safari, and Opera */
|
|
3016
|
-
}
|
|
3017
|
-
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
3018
|
-
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3019
|
-
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3020
|
-
}, 50);
|
|
3021
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", P.moduleName, () => {
|
|
3022
|
-
Ft(this.wnd);
|
|
3023
|
-
const s = this.doc().scrollTop;
|
|
3024
|
-
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
3025
|
-
}), e.register("go_progression", P.moduleName, (s, r) => {
|
|
3026
|
-
const o = s;
|
|
3027
|
-
if (o < 0 || o > 1) {
|
|
3028
|
-
e.send("error", {
|
|
3029
|
-
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3030
|
-
}), r(!1);
|
|
3031
|
-
return;
|
|
3032
|
-
}
|
|
3033
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3034
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), r(!0);
|
|
3035
|
-
});
|
|
3036
|
-
}), e.register("go_id", P.moduleName, (s, r) => {
|
|
3037
|
-
const o = t.document.getElementById(s);
|
|
3038
|
-
if (!o) {
|
|
3039
|
-
r(!1);
|
|
3040
|
-
return;
|
|
3041
|
-
}
|
|
3042
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3043
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3044
|
-
});
|
|
3045
|
-
}), e.register("go_text", P.moduleName, (s, r) => {
|
|
3046
|
-
let o;
|
|
3047
|
-
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3048
|
-
const a = H.deserialize(s), c = rt(this.wnd.document, new k({
|
|
3049
|
-
href: t.location.href,
|
|
3050
|
-
type: "text/html",
|
|
3051
|
-
text: a,
|
|
3052
|
-
locations: o ? new C({
|
|
3053
|
-
otherLocations: /* @__PURE__ */ new Map([
|
|
3054
|
-
["cssSelector", o]
|
|
3055
|
-
])
|
|
3056
|
-
}) : void 0
|
|
3057
|
-
}));
|
|
3058
|
-
if (!c) {
|
|
3059
|
-
r(!1);
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3063
|
-
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3064
|
-
});
|
|
3065
|
-
}), e.register("go_start", P.moduleName, (s, r) => {
|
|
3066
|
-
if (this.doc().scrollTop === 0) return r(!1);
|
|
3067
|
-
this.doc().scrollTop = 0, this.reportProgress(), r(!0);
|
|
3068
|
-
}), e.register("go_end", P.moduleName, (s, r) => {
|
|
3069
|
-
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return r(!1);
|
|
3070
|
-
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), r(!0);
|
|
3071
|
-
}), e.register("unfocus", P.moduleName, (s, r) => {
|
|
3072
|
-
A(this.wnd), r(!0);
|
|
3073
|
-
}), e.register("scroll_protection", P.moduleName, (s, r) => {
|
|
3074
|
-
this.enableScrollProtection(), r(!0);
|
|
3075
|
-
}), e.register([
|
|
3076
|
-
"go_next",
|
|
3077
|
-
"go_prev"
|
|
3078
|
-
], P.moduleName, (s, r) => r(!1)), e.register("focus", P.moduleName, (s, r) => {
|
|
3079
|
-
this.reportProgress(), r(!0);
|
|
3080
|
-
}), e.register("first_visible_locator", P.moduleName, (s, r) => {
|
|
3081
|
-
const o = yt(t, !0);
|
|
3082
|
-
this.comms.send("first_visible_locator", o.serialize()), r(!0);
|
|
3083
|
-
}), e.log("ScrollSnapper Mounted"), !0;
|
|
3084
|
-
}
|
|
3085
|
-
unmount(t, e) {
|
|
3086
|
-
return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(ve)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
|
|
3087
|
-
}
|
|
3088
|
-
};
|
|
3089
|
-
P.moduleName = "scroll_snapper";
|
|
3090
|
-
let Nt = P;
|
|
3091
|
-
const N = class N extends X {
|
|
3092
|
-
constructor() {
|
|
3093
|
-
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
|
|
3094
|
-
if (this.comms.ready && !this.isResizing) {
|
|
3095
|
-
if (!this.initialScrollHandled) {
|
|
3096
|
-
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
3097
|
-
return;
|
|
3098
|
-
}
|
|
3099
|
-
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
3100
|
-
this.reportProgress();
|
|
3101
|
-
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
3102
|
-
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3103
|
-
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
3104
|
-
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3105
|
-
i > 0 ? "down" : "up",
|
|
3106
|
-
Math.abs(i),
|
|
3107
|
-
r
|
|
3108
|
-
)) {
|
|
3109
|
-
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3110
|
-
this.comms?.send("content_protection", {
|
|
3111
|
-
type: "suspicious_scrolling",
|
|
3112
|
-
timestamp: Date.now(),
|
|
3113
|
-
scrollDelta: i,
|
|
3114
|
-
scrollDirection: i > 0 ? "down" : "up",
|
|
3115
|
-
targetElement: a
|
|
3116
|
-
});
|
|
3117
|
-
}
|
|
3118
|
-
this.lastScrollTime = s;
|
|
3119
|
-
}
|
|
3120
|
-
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
3121
|
-
}));
|
|
3122
|
-
}
|
|
3123
|
-
};
|
|
3124
|
-
}
|
|
3125
|
-
doc() {
|
|
3126
|
-
return this.wnd.document.scrollingElement;
|
|
3127
|
-
}
|
|
3128
|
-
reportProgress() {
|
|
3129
|
-
if (!this.comms.ready) return;
|
|
3130
|
-
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), r = Math.max(0, Math.min(1, (t + i) / e));
|
|
3131
|
-
this.comms.send("progress", {
|
|
3132
|
-
start: s,
|
|
3133
|
-
end: r
|
|
3134
|
-
});
|
|
3135
|
-
}
|
|
3136
|
-
enableScrollProtection() {
|
|
3137
|
-
this.patternAnalyzer || (this.patternAnalyzer = new bt($t), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3138
|
-
}
|
|
3139
|
-
mount(t, e) {
|
|
3140
|
-
return this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
|
|
3141
|
-
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3142
|
-
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3143
|
-
}, 50);
|
|
3144
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
|
|
3145
|
-
Ft(this.wnd);
|
|
3146
|
-
const i = this.doc().scrollTop;
|
|
3147
|
-
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
3148
|
-
}), e.register("go_progression", N.moduleName, (i, s) => {
|
|
3149
|
-
const r = i;
|
|
3150
|
-
if (r < 0 || r > 1) {
|
|
3151
|
-
e.send("error", {
|
|
3152
|
-
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3153
|
-
}), s(!1);
|
|
3154
|
-
return;
|
|
3155
|
-
}
|
|
3156
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3157
|
-
this.doc().scrollTop = this.doc().offsetHeight * r, this.reportProgress(), A(this.wnd), s(!0);
|
|
3158
|
-
});
|
|
3159
|
-
}), e.register("go_id", N.moduleName, (i, s) => {
|
|
3160
|
-
const r = t.document.getElementById(i);
|
|
3161
|
-
if (!r) {
|
|
3162
|
-
s(!1);
|
|
3163
|
-
return;
|
|
3164
|
-
}
|
|
3165
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3166
|
-
this.doc().scrollTop = r.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3167
|
-
});
|
|
3168
|
-
}), e.register("go_text", N.moduleName, (i, s) => {
|
|
3169
|
-
let r;
|
|
3170
|
-
Array.isArray(i) && (i.length > 1 && (r = i[1]), i = i[0]);
|
|
3171
|
-
const o = H.deserialize(i), a = rt(this.wnd.document, new k({
|
|
3172
|
-
href: t.location.href,
|
|
3173
|
-
type: "text/html",
|
|
3174
|
-
text: o,
|
|
3175
|
-
locations: r ? new C({
|
|
3176
|
-
otherLocations: /* @__PURE__ */ new Map([
|
|
3177
|
-
["cssSelector", r]
|
|
3178
|
-
])
|
|
3179
|
-
}) : void 0
|
|
3180
|
-
}));
|
|
3181
|
-
if (!a) {
|
|
3182
|
-
s(!1);
|
|
3183
|
-
return;
|
|
3184
|
-
}
|
|
3185
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3186
|
-
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3187
|
-
});
|
|
3188
|
-
}), e.register("go_start", N.moduleName, (i, s) => {
|
|
3189
|
-
if (this.doc().scrollTop === 0) return s(!1);
|
|
3190
|
-
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
3191
|
-
}), e.register("go_end", N.moduleName, (i, s) => {
|
|
3192
|
-
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3193
|
-
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3194
|
-
}), e.register("unfocus", N.moduleName, (i, s) => {
|
|
3195
|
-
A(this.wnd), s(!0);
|
|
3196
|
-
}), e.register("scroll_protection", N.moduleName, (i, s) => {
|
|
3197
|
-
this.enableScrollProtection(), s(!0);
|
|
3198
|
-
}), e.register([
|
|
3199
|
-
"go_next",
|
|
3200
|
-
"go_prev"
|
|
3201
|
-
], N.moduleName, (i, s) => s(!1)), e.register("focus", N.moduleName, (i, s) => {
|
|
3202
|
-
this.reportProgress(), s(!0);
|
|
3203
|
-
}), e.register("first_visible_locator", N.moduleName, (i, s) => {
|
|
3204
|
-
const r = yt(t, !0);
|
|
3205
|
-
e.send("first_visible_locator", r.serialize()), s(!0);
|
|
3206
|
-
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3207
|
-
}
|
|
3208
|
-
unmount(t, e) {
|
|
3209
|
-
return e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("WebPubSnapper Unmounted"), !0;
|
|
3210
|
-
}
|
|
3211
|
-
};
|
|
3212
|
-
N.moduleName = "webpub_snapper";
|
|
3213
|
-
let Lt = N;
|
|
3214
|
-
class Ai {
|
|
3215
|
-
constructor(t, e) {
|
|
3216
|
-
this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
|
|
3217
|
-
}
|
|
3218
|
-
cleanupOldHistory(t) {
|
|
3219
|
-
this.copyHistory = this.copyHistory.filter(
|
|
3220
|
-
(i) => t - i.timestamp < 1e4
|
|
3221
|
-
), this.copyHistory.length > this.options.historySize && (this.copyHistory = this.copyHistory.slice(-this.options.historySize));
|
|
3222
|
-
}
|
|
3223
|
-
isSuspiciousPattern(t) {
|
|
3224
|
-
return this.copyHistory.length < 3 ? !1 : this.copyHistory.filter(
|
|
3225
|
-
(s) => t - s.timestamp < 2e3
|
|
3226
|
-
// Last 2 seconds
|
|
3227
|
-
).length >= 3 ? !0 : this.copyHistory.slice().sort((s, r) => s.timestamp - r.timestamp).every((s, r, o) => r === 0 ? !0 : s.length > o[r - 1].length * 1.5);
|
|
3228
|
-
}
|
|
3229
|
-
shouldAllowCopy(t) {
|
|
3230
|
-
if (!this.options.enabled) return !0;
|
|
3231
|
-
const e = this.window.getSelection();
|
|
3232
|
-
if (!e) return !0;
|
|
3233
|
-
const s = e.toString().length, r = this.window.document.body.innerText.length, o = Date.now();
|
|
3234
|
-
if (this.cleanupOldHistory(o), s < this.options.minThreshold)
|
|
3235
|
-
return this.copyHistory.push({
|
|
3236
|
-
timestamp: o,
|
|
3237
|
-
length: s,
|
|
3238
|
-
wasBlocked: !1
|
|
3239
|
-
}), !0;
|
|
3240
|
-
const c = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, u = Math.min(
|
|
3241
|
-
r * this.options.maxSelectionPercent,
|
|
3242
|
-
this.options.absoluteMaxChars
|
|
3243
|
-
), d = this.isSuspiciousPattern(o), f = s > u || c || d;
|
|
3244
|
-
return this.copyHistory.push({
|
|
3245
|
-
timestamp: o,
|
|
3246
|
-
length: s,
|
|
3247
|
-
wasBlocked: f
|
|
3248
|
-
}), f ? (t?.preventDefault(), !1) : (this.lastSelectionLength = s, this.lastSelectionTime = o, !0);
|
|
3249
|
-
}
|
|
3250
|
-
destroy() {
|
|
3251
|
-
this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
class Ci {
|
|
3255
|
-
constructor(t = ke) {
|
|
3256
|
-
this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3257
|
-
}
|
|
3258
|
-
analyze(t) {
|
|
3259
|
-
if (!t)
|
|
3260
|
-
return this.clear(), !1;
|
|
3261
|
-
const e = t.toString();
|
|
3262
|
-
if (e.length === 0)
|
|
3263
|
-
return this.clear(), !1;
|
|
3264
|
-
if (t.type !== "Range" || !t.rangeCount)
|
|
3265
|
-
return !1;
|
|
3266
|
-
const i = Date.now();
|
|
3267
|
-
if (e.length <= 50 || e === this.lastSelectedText)
|
|
3268
|
-
return !1;
|
|
3269
|
-
if (this.selectionStartTime === 0)
|
|
3270
|
-
return this.selectionStartTime = i, this.lastSelectedText = e, !1;
|
|
3271
|
-
if (i - this.selectionStartTime < 500)
|
|
3272
|
-
return !1;
|
|
3273
|
-
i - this.lastSelectionTime > 1e3 && (this.lastSelectionTime = i), this.selectionStartTime === 0 && (this.selectionStartTime = i), this.lastSelectedText = e;
|
|
3274
|
-
const r = this.analyzeSelectionPattern(t, i);
|
|
3275
|
-
return this.cleanup(i), r;
|
|
3276
|
-
}
|
|
3277
|
-
analyzeSelectionPattern(t, e) {
|
|
3278
|
-
if (!t.rangeCount) return !1;
|
|
3279
|
-
const i = t.getRangeAt(0), s = i.toString(), r = (e - this.selectionStartTime) / 1e3;
|
|
3280
|
-
if (s.length / Math.max(1, r) > this.options.maxSelectionsPerSecond) return !0;
|
|
3281
|
-
const a = i.startOffset, c = Math.abs(a - this.lastSelectionPosition);
|
|
3282
|
-
return this.selectionPatterns.push(c), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
|
|
3283
|
-
}
|
|
3284
|
-
calculateVariance(t) {
|
|
3285
|
-
if (t.length === 0) return 0;
|
|
3286
|
-
const e = t.reduce((i, s) => i + s, 0) / t.length;
|
|
3287
|
-
return t.reduce((i, s) => i + Math.pow(s - e, 2), 0) / t.length;
|
|
3288
|
-
}
|
|
3289
|
-
cleanup(t) {
|
|
3290
|
-
this.events = this.events.filter((e) => t - e.timestamp <= 1e3);
|
|
3291
|
-
}
|
|
3292
|
-
clear() {
|
|
3293
|
-
this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
class xi {
|
|
3297
|
-
/**
|
|
3298
|
-
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3299
|
-
*/
|
|
3300
|
-
match(t, e) {
|
|
3301
|
-
for (const i of e)
|
|
3302
|
-
if (this.matchesCombo(t, i))
|
|
3303
|
-
return !0;
|
|
3304
|
-
return !1;
|
|
3305
|
-
}
|
|
3306
|
-
matchesCombo(t, e) {
|
|
3307
|
-
return t.keyCode === e.keyCode && this.matchesModifier(t.ctrlKey, e.ctrl) && this.matchesModifier(t.shiftKey, e.shift) && this.matchesModifier(t.altKey, e.alt) && this.matchesModifier(t.metaKey, e.meta);
|
|
3308
|
-
}
|
|
3309
|
-
matchesModifier(t, e) {
|
|
3310
|
-
return e === void 0 ? !t : t === e;
|
|
3311
|
-
}
|
|
3312
|
-
/**
|
|
3313
|
-
* Creates an event handler that will call the provided handler when any of the key combinations match
|
|
3314
|
-
*/
|
|
3315
|
-
createKeyHandler(t, e) {
|
|
3316
|
-
return (i) => {
|
|
3317
|
-
this.match(i, t) && (i.preventDefault(), i.stopPropagation(), e(i));
|
|
3318
|
-
};
|
|
3319
|
-
}
|
|
3320
|
-
/**
|
|
3321
|
-
* Creates a standardized activity event for keyboard shortcuts
|
|
3322
|
-
*/
|
|
3323
|
-
createActivityEvent(t, e, i, s) {
|
|
3324
|
-
let r, o;
|
|
3325
|
-
if (s) {
|
|
3326
|
-
const a = s.getSelection(), c = a?.toString() || "", d = (c && a?.rangeCount ? a.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3327
|
-
d && c && (r = {
|
|
3328
|
-
text: c,
|
|
3329
|
-
x: d.x,
|
|
3330
|
-
y: d.y,
|
|
3331
|
-
width: d.width,
|
|
3332
|
-
height: d.height
|
|
3333
|
-
});
|
|
3334
|
-
const f = s.document.activeElement;
|
|
3335
|
-
f && f !== s.document.body && (o = Gt(f)?.outerHTML);
|
|
3336
|
-
}
|
|
3337
|
-
return {
|
|
3338
|
-
type: e,
|
|
3339
|
-
timestamp: Date.now(),
|
|
3340
|
-
key: t.key,
|
|
3341
|
-
code: t.code,
|
|
3342
|
-
keyCode: t.keyCode,
|
|
3343
|
-
ctrlKey: t.ctrlKey,
|
|
3344
|
-
altKey: t.altKey,
|
|
3345
|
-
shiftKey: t.shiftKey,
|
|
3346
|
-
metaKey: t.metaKey,
|
|
3347
|
-
targetFrameSrc: i,
|
|
3348
|
-
selectedText: r,
|
|
3349
|
-
interactiveElement: o
|
|
3350
|
-
};
|
|
3351
|
-
}
|
|
3352
|
-
/**
|
|
3353
|
-
* Creates handlers for keyboard shortcuts with centralized activity event dispatch
|
|
3354
|
-
*/
|
|
3355
|
-
createKeyboardHandlers(t, e, i, s) {
|
|
3356
|
-
const r = [];
|
|
3357
|
-
return e.forEach((o) => {
|
|
3358
|
-
r.push(...o.keyCombos.map((a) => ({
|
|
3359
|
-
...a,
|
|
3360
|
-
handler: (c) => {
|
|
3361
|
-
const u = o.type, d = this.createActivityEvent(c, u, t, s);
|
|
3362
|
-
i(d);
|
|
3363
|
-
}
|
|
3364
|
-
})));
|
|
3365
|
-
}), r;
|
|
3366
|
-
}
|
|
3367
|
-
/**
|
|
3368
|
-
* Creates a unified keyboard event handler that processes all shortcuts
|
|
3369
|
-
*/
|
|
3370
|
-
createUnifiedHandler(t, e, i, s) {
|
|
3371
|
-
const r = this.createKeyboardHandlers(t, e, i, s);
|
|
3372
|
-
return (o) => {
|
|
3373
|
-
if (o.isTrusted) {
|
|
3374
|
-
for (const a of r)
|
|
3375
|
-
if (this.match(o, [a])) {
|
|
3376
|
-
const c = a.suppressOnInteractiveElement;
|
|
3377
|
-
if (c) {
|
|
3378
|
-
const u = (s?.document ?? document).activeElement;
|
|
3379
|
-
if (Array.isArray(c) ? c.some((d) => u?.matches(d)) : ze(u)) return;
|
|
3380
|
-
}
|
|
3381
|
-
o.preventDefault(), o.stopPropagation(), a.handler(o);
|
|
3382
|
-
return;
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
};
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
const F = class F extends K {
|
|
3389
|
-
constructor() {
|
|
3390
|
-
super(...arguments), this.configApplied = !1, this.cleanupCallbacks = [], this.pointerMoved = !1, this.isContextMenuEnabled = !1, this.isDragAndDropEnabled = !1, this.isSelectionMonitoringEnabled = !1, this.isBulkCopyProtectionEnabled = !1, this.selectionAnalyzer = null, this.currentSelection = null, this.bulkCopyProtector = null, this.keyManager = new xi(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
|
|
3391
|
-
if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
|
|
3392
|
-
return !0;
|
|
3393
|
-
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
3394
|
-
t.preventDefault();
|
|
3395
|
-
const e = this.wnd.getSelection(), i = e?.toString() || "", r = (i ? e?.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3396
|
-
type: "bulk_copy",
|
|
3397
|
-
timestamp: Date.now(),
|
|
3398
|
-
clipboardTypes: t.clipboardData?.types ? [...t.clipboardData.types] : [],
|
|
3399
|
-
selectedText: r ? {
|
|
3400
|
-
text: i,
|
|
3401
|
-
x: r.x,
|
|
3402
|
-
y: r.y,
|
|
3403
|
-
width: r.width,
|
|
3404
|
-
height: r.height
|
|
3405
|
-
} : void 0,
|
|
3406
|
-
selectionLength: i.length,
|
|
3407
|
-
targetFrameSrc: this.wnd.location.href
|
|
3408
|
-
};
|
|
3409
|
-
return this.comms?.send("content_protection", o), !1;
|
|
3410
|
-
}
|
|
3411
|
-
return !0;
|
|
3412
|
-
}, this.handleSelection = (t) => {
|
|
3413
|
-
if (!this.isSelectionMonitoringEnabled || !this.wnd || !this.selectionAnalyzer)
|
|
3414
|
-
return;
|
|
3415
|
-
const e = this.wnd.getSelection();
|
|
3416
|
-
if (e) {
|
|
3417
|
-
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3418
|
-
const s = this.wnd.getSelection(), r = s?.toString() || "", a = (r && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], c = {
|
|
3419
|
-
type: "suspicious_selection",
|
|
3420
|
-
timestamp: Date.now(),
|
|
3421
|
-
selectionLength: r.length,
|
|
3422
|
-
selectedText: {
|
|
3423
|
-
text: r,
|
|
3424
|
-
x: a?.x ?? 0,
|
|
3425
|
-
y: a?.y ?? 0,
|
|
3426
|
-
width: a?.width ?? 0,
|
|
3427
|
-
height: a?.height ?? 0
|
|
3428
|
-
},
|
|
3429
|
-
eventType: t?.type || "selectionchange",
|
|
3430
|
-
targetFrameSrc: this.wnd.location.href
|
|
3431
|
-
};
|
|
3432
|
-
this.comms?.send("content_protection", c);
|
|
3433
|
-
}
|
|
3434
|
-
} else
|
|
3435
|
-
this.currentSelection = null;
|
|
3436
|
-
}, this.onDragOver = (t) => {
|
|
3437
|
-
this.isDragAndDropEnabled && (t.preventDefault(), t.stopPropagation());
|
|
3438
|
-
}, this.onDragStart = (t) => {
|
|
3439
|
-
if (this.isDragAndDropEnabled) {
|
|
3440
|
-
t.preventDefault();
|
|
3441
|
-
const e = {
|
|
3442
|
-
type: "drag_detected",
|
|
3443
|
-
timestamp: Date.now(),
|
|
3444
|
-
dataTransferTypes: t.dataTransfer?.types ? [...t.dataTransfer.types] : [],
|
|
3445
|
-
targetFrameSrc: this.wnd.location.href
|
|
3446
|
-
};
|
|
3447
|
-
return this.comms?.send("content_protection", e), !1;
|
|
3448
|
-
} else
|
|
3449
|
-
return !0;
|
|
3450
|
-
}, this.onDrop = (t) => {
|
|
3451
|
-
if (this.isDragAndDropEnabled) {
|
|
3452
|
-
t.preventDefault();
|
|
3453
|
-
const e = t.dataTransfer, i = {
|
|
3454
|
-
type: "drop_detected",
|
|
3455
|
-
timestamp: Date.now(),
|
|
3456
|
-
dataTransferTypes: e?.types ? [...e.types] : [],
|
|
3457
|
-
fileCount: e?.files?.length || 0,
|
|
3458
|
-
targetFrameSrc: this.wnd.location.href
|
|
3459
|
-
};
|
|
3460
|
-
return this.comms?.send("content_protection", i), !1;
|
|
3461
|
-
} else
|
|
3462
|
-
return !0;
|
|
3463
|
-
}, this.onContext = (t) => {
|
|
3464
|
-
if (this.isContextMenuEnabled) {
|
|
3465
|
-
t.preventDefault();
|
|
3466
|
-
const e = this.wnd.getSelection(), i = e?.toString() || "", r = (i && e?.rangeCount ? e.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3467
|
-
timestamp: Date.now(),
|
|
3468
|
-
clientX: t.clientX,
|
|
3469
|
-
clientY: t.clientY,
|
|
3470
|
-
...r && {
|
|
3471
|
-
selectedText: {
|
|
3472
|
-
text: i,
|
|
3473
|
-
x: r.x,
|
|
3474
|
-
y: r.y,
|
|
3475
|
-
width: r.width,
|
|
3476
|
-
height: r.height
|
|
3477
|
-
}
|
|
3478
|
-
},
|
|
3479
|
-
targetFrameSrc: this.wnd.location.href
|
|
3480
|
-
};
|
|
3481
|
-
this.comms?.send("context_menu", o);
|
|
3482
|
-
}
|
|
3483
|
-
}, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onClicker = this.onClick.bind(this);
|
|
3484
|
-
}
|
|
3485
|
-
addContextMenuPrevention() {
|
|
3486
|
-
this.isContextMenuEnabled || !this.wnd || (this.wnd.document.addEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !0);
|
|
3487
|
-
}
|
|
3488
|
-
removeContextMenuPrevention() {
|
|
3489
|
-
!this.isContextMenuEnabled || !this.wnd || (this.wnd.document.removeEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !1);
|
|
3490
|
-
}
|
|
3491
|
-
addDragAndDropPrevention() {
|
|
3492
|
-
this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("dragover", this.onDragOver), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
|
|
3493
|
-
}
|
|
3494
|
-
removeDragAndDropPrevention() {
|
|
3495
|
-
!this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("dragover", this.onDragOver), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
|
|
3496
|
-
}
|
|
3497
|
-
enableKeyboardPeripherals(t = []) {
|
|
3498
|
-
this.disableKeyboardPeripherals();
|
|
3499
|
-
const e = (i) => {
|
|
3500
|
-
this.comms?.send("keyboard_peripherals", i);
|
|
3501
|
-
};
|
|
3502
|
-
this.keyDownHandler = this.keyManager.createUnifiedHandler(this.wnd.location.href, t, e, this.wnd), this.wnd && this.wnd.document.addEventListener("keydown", this.keyDownHandler, {
|
|
3503
|
-
capture: !0
|
|
3504
|
-
});
|
|
3505
|
-
}
|
|
3506
|
-
disableKeyboardPeripherals() {
|
|
3507
|
-
this.wnd && this.keyDownHandler && (this.wnd.document.removeEventListener("keydown", this.keyDownHandler, {
|
|
3508
|
-
capture: !0
|
|
3509
|
-
}), this.keyDownHandler = null);
|
|
3510
|
-
}
|
|
3511
|
-
addBulkCopyProtection(t = {}) {
|
|
3512
|
-
if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
|
|
3513
|
-
const e = Si, i = t ? { ...e, ...t } : e;
|
|
3514
|
-
this.bulkCopyProtector = new Ai(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
|
|
3515
|
-
}
|
|
3516
|
-
removeBulkCopyProtection() {
|
|
3517
|
-
!this.isBulkCopyProtectionEnabled || !this.wnd || (this.wnd.document.removeEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.removeEventListener("cut", this.preventBulkCopy, !0), this.bulkCopyProtector?.destroy(), this.bulkCopyProtector = null, this.isBulkCopyProtectionEnabled = !1);
|
|
3518
|
-
}
|
|
3519
|
-
addSelectionMonitoring(t) {
|
|
3520
|
-
if (this.isSelectionMonitoringEnabled || !this.wnd) return;
|
|
3521
|
-
const e = t || ke;
|
|
3522
|
-
this.selectionAnalyzer = new Ci(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
|
|
3523
|
-
}
|
|
3524
|
-
removeSelectionMonitoring() {
|
|
3525
|
-
!this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
|
|
3526
|
-
}
|
|
3527
|
-
onPointUp(t) {
|
|
3528
|
-
const e = this.wnd.getSelection();
|
|
3529
|
-
if (e && e.toString()?.length > 0) {
|
|
3530
|
-
const s = e.getRangeAt(0)?.getClientRects();
|
|
3531
|
-
if (!s || s.length === 0)
|
|
3532
|
-
return;
|
|
3533
|
-
const r = s[0], o = {
|
|
3534
|
-
text: e.toString(),
|
|
3535
|
-
x: r.x,
|
|
3536
|
-
y: r.y,
|
|
3537
|
-
width: r.width,
|
|
3538
|
-
height: r.height,
|
|
3539
|
-
targetFrameSrc: this.wnd?.location?.href
|
|
3540
|
-
};
|
|
3541
|
-
this.comms.send("text_selected", o);
|
|
3542
|
-
}
|
|
3543
|
-
if (this.pointerMoved) {
|
|
3544
|
-
this.pointerMoved = !1;
|
|
3545
|
-
return;
|
|
3546
|
-
}
|
|
3547
|
-
if (!e?.isCollapsed || !t.isPrimary) return;
|
|
3548
|
-
const i = this.wnd.devicePixelRatio;
|
|
3549
|
-
t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {
|
|
3550
|
-
defaultPrevented: t.defaultPrevented,
|
|
3551
|
-
x: t.clientX * i,
|
|
3552
|
-
y: t.clientY * i,
|
|
3553
|
-
targetFrameSrc: this.wnd.location.href,
|
|
3554
|
-
targetElement: t.target.outerHTML,
|
|
3555
|
-
interactiveElement: Gt(t.target)?.outerHTML,
|
|
3556
|
-
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
3557
|
-
}), this.pointerMoved = !1;
|
|
3558
|
-
}
|
|
3559
|
-
onPointMove(t) {
|
|
3560
|
-
if (t.movementY !== void 0 && t.movementX !== void 0) {
|
|
3561
|
-
(Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);
|
|
3562
|
-
return;
|
|
3563
|
-
}
|
|
3564
|
-
this.pointerMoved = !0;
|
|
3565
|
-
}
|
|
3566
|
-
onPointDown() {
|
|
3567
|
-
this.pointerMoved = !1;
|
|
3568
|
-
}
|
|
3569
|
-
onClick(t) {
|
|
3570
|
-
if (t.preventDefault(), !t.isTrusted) {
|
|
3571
|
-
const e = new PointerEvent("pointerup", {
|
|
3572
|
-
isPrimary: !0,
|
|
3573
|
-
pointerType: "mouse",
|
|
3574
|
-
// Not really a better choice than this
|
|
3575
|
-
clientX: t.clientX,
|
|
3576
|
-
clientY: t.clientY
|
|
3577
|
-
});
|
|
3578
|
-
Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
|
|
3579
|
-
}
|
|
3580
|
-
}
|
|
3581
|
-
registerProtectionHandlers() {
|
|
3582
|
-
this.comms?.register("peripherals_protection", F.moduleName, (t, e) => {
|
|
3583
|
-
const i = t;
|
|
3584
|
-
if (!this.configApplied) {
|
|
3585
|
-
if (this.configApplied = !0, i.monitorSelection) {
|
|
3586
|
-
const s = typeof i.monitorSelection == "boolean" ? void 0 : i.monitorSelection;
|
|
3587
|
-
this.addSelectionMonitoring(s), this.comms?.log("Selection monitoring enabled");
|
|
3588
|
-
}
|
|
3589
|
-
typeof i.protectCopy == "object" ? (this.addBulkCopyProtection({
|
|
3590
|
-
enabled: !0,
|
|
3591
|
-
...i.protectCopy
|
|
3592
|
-
}), this.comms?.log("Copy protection enabled (limited)")) : i.protectCopy === !0 && (this.addBulkCopyProtection({
|
|
3593
|
-
enabled: !0,
|
|
3594
|
-
maxSelectionPercent: 0,
|
|
3595
|
-
minThreshold: 0,
|
|
3596
|
-
absoluteMaxChars: 0
|
|
3597
|
-
}), this.comms?.log("Copy protection enabled")), i.disableContextMenu && (this.addContextMenuPrevention(), this.comms?.log("Context menu protection enabled")), i.disableDragAndDrop && (this.addDragAndDropPrevention(), this.comms?.log("Drag and drop protection enabled"));
|
|
3598
|
-
}
|
|
3599
|
-
e(!0);
|
|
3600
|
-
}), this.comms?.register("unfocus", F.moduleName, (t, e) => {
|
|
3601
|
-
this.disableKeyboardPeripherals(), e(!0);
|
|
3602
|
-
}), this.comms?.register("keyboard_peripherals", F.moduleName, (t, e) => {
|
|
3603
|
-
const i = t;
|
|
3604
|
-
i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
|
|
3605
|
-
});
|
|
3606
|
-
}
|
|
3607
|
-
mount(t, e) {
|
|
3608
|
-
return this.wnd = t, this.comms = e, this.registerProtectionHandlers(), t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
|
|
3609
|
-
}
|
|
3610
|
-
unmount(t, e) {
|
|
3611
|
-
return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll(F.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
|
|
3612
|
-
}
|
|
3613
|
-
};
|
|
3614
|
-
F.moduleName = "peripherals";
|
|
3615
|
-
let Ot = F;
|
|
3616
|
-
const et = class et extends K {
|
|
3617
|
-
constructor() {
|
|
3618
|
-
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
3619
|
-
}
|
|
3620
|
-
wndOnErr(t) {
|
|
3621
|
-
this.comms?.send("error", {
|
|
3622
|
-
message: t.message,
|
|
3623
|
-
filename: t.filename,
|
|
3624
|
-
lineno: t.lineno,
|
|
3625
|
-
colno: t.colno
|
|
3626
|
-
});
|
|
3627
|
-
}
|
|
3628
|
-
unblock(t) {
|
|
3629
|
-
for (t._readium_blockEvents = !1; t._readium_blockedEvents?.length > 0; ) {
|
|
3630
|
-
const e = t._readium_blockedEvents.shift();
|
|
3631
|
-
switch (e[0]) {
|
|
3632
|
-
case 0:
|
|
3633
|
-
Reflect.apply(e[1], e[2], e[3]);
|
|
3634
|
-
break;
|
|
3635
|
-
case 1:
|
|
3636
|
-
const i = e[1], s = e[2];
|
|
3637
|
-
t.removeEventListener(i.type, t._readium_eventBlocker, !0);
|
|
3638
|
-
const r = new Event(i.type, {
|
|
3639
|
-
bubbles: i.bubbles,
|
|
3640
|
-
cancelable: i.cancelable
|
|
3641
|
-
});
|
|
3642
|
-
s ? s.dispatchEvent(r) : t.dispatchEvent(r);
|
|
3643
|
-
break;
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
}
|
|
3647
|
-
onMediaPlayEvent() {
|
|
3648
|
-
this.mediaPlayingCount++, this.comms?.send("media_play", this.mediaPlayingCount);
|
|
3649
|
-
}
|
|
3650
|
-
onMediaPauseEvent() {
|
|
3651
|
-
this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);
|
|
3652
|
-
}
|
|
3653
|
-
pauseAllMedia(t) {
|
|
3654
|
-
const e = t.document.querySelectorAll("audio,video");
|
|
3655
|
-
for (let i = 0; i < e.length; i++)
|
|
3656
|
-
e[i].pause();
|
|
3657
|
-
}
|
|
3658
|
-
mount(t, e) {
|
|
3659
|
-
this.comms = e, t.addEventListener(
|
|
3660
|
-
"error",
|
|
3661
|
-
this.wndOnErr,
|
|
3662
|
-
!1
|
|
3663
|
-
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3664
|
-
value: {
|
|
3665
|
-
name: "readium-ts-toolkit",
|
|
3666
|
-
version: "2.4.4",
|
|
3667
|
-
hasFeature: (s, r = "") => {
|
|
3668
|
-
switch (s) {
|
|
3669
|
-
case "dom-manipulation":
|
|
3670
|
-
return !0;
|
|
3671
|
-
case "layout-changes":
|
|
3672
|
-
return !0;
|
|
3673
|
-
case "touch-events":
|
|
3674
|
-
return !0;
|
|
3675
|
-
case "mouse-events":
|
|
3676
|
-
return !0;
|
|
3677
|
-
case "keyboard-events":
|
|
3678
|
-
return !0;
|
|
3679
|
-
case "spine-scripting":
|
|
3680
|
-
return !0;
|
|
3681
|
-
case "embedded-web-content":
|
|
3682
|
-
return !0;
|
|
3683
|
-
default:
|
|
3684
|
-
return !1;
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
},
|
|
3688
|
-
writable: !1
|
|
3689
|
-
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3690
|
-
s.cancel(), this.allAnimations.add(s);
|
|
3691
|
-
}), e.register("activate", et.moduleName, (s, r) => {
|
|
3692
|
-
this.allAnimations.forEach((o) => {
|
|
3693
|
-
o.cancel(), o.play();
|
|
3694
|
-
}), r(!0);
|
|
3695
|
-
}), e.register("unfocus", et.moduleName, (s, r) => {
|
|
3696
|
-
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), r(!0);
|
|
3697
|
-
});
|
|
3698
|
-
const i = t.document.querySelectorAll("audio,video");
|
|
3699
|
-
for (let s = 0; s < i.length; s++) {
|
|
3700
|
-
const r = i[s];
|
|
3701
|
-
r.addEventListener("play", this.onMediaPlayEvent, {
|
|
3702
|
-
passive: !0
|
|
3703
|
-
}), r.addEventListener("pause", this.onMediaPauseEvent, {
|
|
3704
|
-
passive: !0
|
|
3705
|
-
});
|
|
3706
|
-
}
|
|
3707
|
-
return e.log("Setup Mounted"), !0;
|
|
3708
|
-
}
|
|
3709
|
-
unmount(t, e) {
|
|
3710
|
-
return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
|
|
3711
|
-
}
|
|
3712
|
-
};
|
|
3713
|
-
et.moduleName = "setup";
|
|
3714
|
-
let ft = et;
|
|
3715
|
-
const we = "readium-viewport", W = class W extends ft {
|
|
3716
|
-
onViewportWidthChanged(t) {
|
|
3717
|
-
const e = t.target;
|
|
3718
|
-
st(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
3719
|
-
}
|
|
3720
|
-
mount(t, e) {
|
|
3721
|
-
if (!super.mount(t, e)) return !1;
|
|
3722
|
-
const i = t.document.createElement("meta");
|
|
3723
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", we), i.setAttribute(
|
|
3724
|
-
"content",
|
|
3725
|
-
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3726
|
-
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3727
|
-
target: t
|
|
3728
|
-
}), e.register("get_properties", W.moduleName, (s, r) => {
|
|
3729
|
-
Vt(t), r(!0);
|
|
3730
|
-
}), e.register("update_properties", W.moduleName, (s, r) => {
|
|
3731
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`, De(t, s), r(!0);
|
|
3732
|
-
}), e.register("set_property", W.moduleName, (s, r) => {
|
|
3733
|
-
const o = s;
|
|
3734
|
-
st(t, o[0], o[1]), r(!0);
|
|
3735
|
-
}), e.register("remove_property", W.moduleName, (s, r) => {
|
|
3736
|
-
gt(t, s), r(!0);
|
|
3737
|
-
}), e.register("activate", W.moduleName, (s, r) => {
|
|
3738
|
-
this.unblock(t), r(!0);
|
|
3739
|
-
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3740
|
-
}
|
|
3741
|
-
unmount(t, e) {
|
|
3742
|
-
return e.unregisterAll(W.moduleName), t.document.head.querySelector(`#${we}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
|
|
3743
|
-
}
|
|
3744
|
-
};
|
|
3745
|
-
W.moduleName = "reflowable_setup";
|
|
3746
|
-
let Rt = W;
|
|
3747
|
-
const Se = "readium-fixed-style", z = class z extends ft {
|
|
3748
|
-
mount(t, e) {
|
|
3749
|
-
if (!super.mount(t, e)) return !1;
|
|
3750
|
-
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
3751
|
-
const i = t.document.createElement("style");
|
|
3752
|
-
return i.id = Se, i.dataset.readium = "true", i.textContent = `
|
|
3753
|
-
html, body {
|
|
3754
|
-
text-size-adjust: none;
|
|
3755
|
-
-ms-text-size-adjust: none;
|
|
3756
|
-
-webkit-text-size-adjust: none;
|
|
3757
|
-
-moz-text-size-adjust: none;
|
|
3758
|
-
|
|
3759
|
-
/* Fight Safari pinches */
|
|
3760
|
-
touch-action: none !important;
|
|
3761
|
-
min-height: 100%;
|
|
3762
|
-
|
|
3763
|
-
/*cursor: var() TODO*/
|
|
3764
|
-
}`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s, r) => {
|
|
3765
|
-
const o = s;
|
|
3766
|
-
st(t, o[0], o[1]), r(!0);
|
|
3767
|
-
}), e.register("remove_property", z.moduleName, (s, r) => {
|
|
3768
|
-
gt(t, s), r(!0);
|
|
3769
|
-
}), e.register("first_visible_locator", z.moduleName, (s, r) => r(!1)), e.register("unfocus", z.moduleName, (s, r) => {
|
|
3770
|
-
A(t), r(!0);
|
|
3771
|
-
}), e.register([
|
|
3772
|
-
"focus",
|
|
3773
|
-
"go_next",
|
|
3774
|
-
"go_prev",
|
|
3775
|
-
"go_id",
|
|
3776
|
-
"go_end",
|
|
3777
|
-
"go_start",
|
|
3778
|
-
"go_text",
|
|
3779
|
-
"go_progression"
|
|
3780
|
-
], z.moduleName, (s, r) => r(!0)), e.register("activate", z.moduleName, (s, r) => {
|
|
3781
|
-
this.unblock(t), r(!0);
|
|
3782
|
-
}), e.log("FixedSetup Mounted"), !0;
|
|
3783
|
-
}
|
|
3784
|
-
unmount(t, e) {
|
|
3785
|
-
return e.unregisterAll(z.moduleName), t.document.getElementById(Se)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
3786
|
-
}
|
|
3787
|
-
};
|
|
3788
|
-
z.moduleName = "fixed_setup";
|
|
3789
|
-
let Dt = z;
|
|
3790
|
-
const U = class U extends K {
|
|
3791
|
-
wndOnErr(t) {
|
|
3792
|
-
this.comms?.send("error", {
|
|
3793
|
-
message: t.message,
|
|
3794
|
-
filename: t.filename,
|
|
3795
|
-
lineno: t.lineno,
|
|
3796
|
-
colno: t.colno
|
|
3797
|
-
});
|
|
3798
|
-
}
|
|
3799
|
-
mount(t, e) {
|
|
3800
|
-
return this.comms = e, t.addEventListener(
|
|
3801
|
-
"error",
|
|
3802
|
-
this.wndOnErr,
|
|
3803
|
-
!1
|
|
3804
|
-
), e.register("get_properties", U.moduleName, (i, s) => {
|
|
3805
|
-
Vt(t), s(!0);
|
|
3806
|
-
}), e.register("update_properties", U.moduleName, (i, s) => {
|
|
3807
|
-
De(t, i), s(!0);
|
|
3808
|
-
}), e.register("set_property", U.moduleName, (i, s) => {
|
|
3809
|
-
const r = i;
|
|
3810
|
-
st(t, r[0], r[1]), s(!0);
|
|
3811
|
-
}), e.register("remove_property", U.moduleName, (i, s) => {
|
|
3812
|
-
gt(t, i), s(!0);
|
|
3813
|
-
}), e.register("activate", U.moduleName, (i, s) => {
|
|
3814
|
-
s(!0);
|
|
3815
|
-
}), e.log("WebPubSetup Mounted"), !0;
|
|
3816
|
-
}
|
|
3817
|
-
unmount(t, e) {
|
|
3818
|
-
return e.unregisterAll(U.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
|
|
3819
|
-
}
|
|
3820
|
-
};
|
|
3821
|
-
U.moduleName = "webpub_setup";
|
|
3822
|
-
let It = U;
|
|
3823
|
-
const it = class it extends K {
|
|
3824
|
-
constructor() {
|
|
3825
|
-
super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
|
|
3826
|
-
}
|
|
3827
|
-
setupPrintProtection(t, e) {
|
|
3828
|
-
if (!e.disable) return;
|
|
3829
|
-
const i = t.document.createElement("style");
|
|
3830
|
-
i.textContent = `
|
|
3831
|
-
@media print {
|
|
3832
|
-
body * {
|
|
3833
|
-
display: none !important;
|
|
3834
|
-
}
|
|
3835
|
-
body::after {
|
|
3836
|
-
content: "${e.watermark || "Printing has been disabled"}";
|
|
3837
|
-
font-size: 200%;
|
|
3838
|
-
display: block;
|
|
3839
|
-
text-align: center;
|
|
3840
|
-
margin-top: 50vh;
|
|
3841
|
-
transform: translateY(-50%);
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
3844
|
-
`, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
|
|
3845
|
-
}
|
|
3846
|
-
registerPrintHandlers() {
|
|
3847
|
-
this.comms?.register("print_protection", it.moduleName, (t) => {
|
|
3848
|
-
const e = t;
|
|
3849
|
-
return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
|
|
3850
|
-
});
|
|
3851
|
-
}
|
|
3852
|
-
mount(t, e) {
|
|
3853
|
-
return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
|
|
3854
|
-
}
|
|
3855
|
-
unmount(t, e) {
|
|
3856
|
-
return this.beforePrintHandler && (t.removeEventListener("beforeprint", this.beforePrintHandler), this.beforePrintHandler = null), this.styleElement?.parentNode && (this.styleElement.parentNode.removeChild(this.styleElement), this.styleElement = null), this.comms?.unregisterAll(it.moduleName), this.configApplied = !1, !0;
|
|
3857
|
-
}
|
|
3858
|
-
};
|
|
3859
|
-
it.moduleName = "print_protection";
|
|
3860
|
-
let zt = it;
|
|
3861
|
-
const Ee = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
3862
|
-
constructor() {
|
|
3863
|
-
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.resizeDebounce = null, this.verticalLR = !1, this.handleScroll = (t) => {
|
|
3864
|
-
if (this.comms.ready && !this.isResizing) {
|
|
3865
|
-
if (!this.initialScrollHandled) {
|
|
3866
|
-
this.lastScrollLeft = Math.abs(this.doc().scrollLeft), this.initialScrollHandled = !0, this.reportProgress();
|
|
3867
|
-
return;
|
|
3868
|
-
}
|
|
3869
|
-
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
3870
|
-
this.reportProgress();
|
|
3871
|
-
const e = Math.abs(this.doc().scrollLeft), i = e - this.lastScrollLeft;
|
|
3872
|
-
if (this.lastScrollLeft = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3873
|
-
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
3874
|
-
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3875
|
-
// In vertical-rl, norm increases when scrolling forward (toward left/end),
|
|
3876
|
-
// so deltaX > 0 = going forward.
|
|
3877
|
-
i > 0 ? "down" : "up",
|
|
3878
|
-
Math.abs(i),
|
|
3879
|
-
r
|
|
3880
|
-
)) {
|
|
3881
|
-
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3882
|
-
this.comms?.send("content_protection", {
|
|
3883
|
-
type: "suspicious_scrolling",
|
|
3884
|
-
timestamp: Date.now(),
|
|
3885
|
-
scrollDelta: i,
|
|
3886
|
-
scrollDirection: i > 0 ? "left" : "right",
|
|
3887
|
-
targetElement: a
|
|
3888
|
-
});
|
|
3889
|
-
}
|
|
3890
|
-
this.lastScrollTime = s;
|
|
3891
|
-
}
|
|
3892
|
-
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
3893
|
-
}));
|
|
3894
|
-
}
|
|
3895
|
-
};
|
|
3896
|
-
}
|
|
3897
|
-
doc() {
|
|
3898
|
-
return this.wnd.document.scrollingElement;
|
|
3899
|
-
}
|
|
3900
|
-
/** Total horizontally scrollable distance (magnitude). */
|
|
3901
|
-
scrollable() {
|
|
3902
|
-
return Math.max(0, this.doc().scrollWidth - this.wnd.innerWidth);
|
|
3903
|
-
}
|
|
3904
|
-
reportProgress() {
|
|
3905
|
-
if (!this.comms.ready) return;
|
|
3906
|
-
const t = this.doc().scrollWidth, e = this.wnd.innerWidth, i = Math.max(1, t - e), s = Math.abs(this.doc().scrollLeft), r = Math.max(0, Math.min(1, s / i)), o = Math.max(0, Math.min(1, (s + e) / t));
|
|
3907
|
-
this.comms.send("progress", {
|
|
3908
|
-
start: r,
|
|
3909
|
-
end: o
|
|
3910
|
-
});
|
|
3911
|
-
}
|
|
3912
|
-
enableScrollProtection() {
|
|
3913
|
-
this.patternAnalyzer || (this.patternAnalyzer = new bt($t), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3914
|
-
}
|
|
3915
|
-
mount(t, e) {
|
|
3916
|
-
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.verticalLR = ui(t), this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
3917
|
-
const i = t.document.createElement("style");
|
|
3918
|
-
return i.dataset.readium = "true", i.id = Ee, i.textContent = `
|
|
3919
|
-
* {
|
|
3920
|
-
scrollbar-width: none;
|
|
3921
|
-
}
|
|
3922
|
-
body::-webkit-scrollbar {
|
|
3923
|
-
display: none;
|
|
3924
|
-
}
|
|
3925
|
-
html {
|
|
3926
|
-
overflow-x: auto !important;
|
|
3927
|
-
overflow-y: hidden !important;
|
|
3928
|
-
}
|
|
3929
|
-
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
3930
|
-
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3931
|
-
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3932
|
-
}, 50);
|
|
3933
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
|
|
3934
|
-
Ft(this.wnd);
|
|
3935
|
-
const s = this.doc().scrollLeft;
|
|
3936
|
-
this.verticalLR ? this.doc().scrollLeft = s > 1 ? s - 1 : s + 1 : this.doc().scrollLeft = s < -1 ? s + 1 : s - 1, this.doc().scrollLeft = s;
|
|
3937
|
-
}), e.register("go_progression", L.moduleName, (s, r) => {
|
|
3938
|
-
const o = s;
|
|
3939
|
-
if (o < 0 || o > 1) {
|
|
3940
|
-
e.send("error", {
|
|
3941
|
-
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3942
|
-
}), r(!1);
|
|
3943
|
-
return;
|
|
3944
|
-
}
|
|
3945
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3946
|
-
const a = this.scrollable() * o;
|
|
3947
|
-
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(), A(this.wnd), r(!0);
|
|
3948
|
-
});
|
|
3949
|
-
}), e.register("go_id", L.moduleName, (s, r) => {
|
|
3950
|
-
const o = t.document.getElementById(s);
|
|
3951
|
-
if (!o) {
|
|
3952
|
-
r(!1);
|
|
3953
|
-
return;
|
|
3954
|
-
}
|
|
3955
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3956
|
-
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3957
|
-
});
|
|
3958
|
-
}), e.register("go_text", L.moduleName, (s, r) => {
|
|
3959
|
-
let o;
|
|
3960
|
-
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3961
|
-
const a = H.deserialize(s), c = rt(this.wnd.document, new k({
|
|
3962
|
-
href: t.location.href,
|
|
3963
|
-
type: "text/html",
|
|
3964
|
-
text: a,
|
|
3965
|
-
locations: o ? new C({
|
|
3966
|
-
otherLocations: /* @__PURE__ */ new Map([["cssSelector", o]])
|
|
3967
|
-
}) : void 0
|
|
3968
|
-
}));
|
|
3969
|
-
if (!c) {
|
|
3970
|
-
r(!1);
|
|
3971
|
-
return;
|
|
3972
|
-
}
|
|
3973
|
-
this.wnd.requestAnimationFrame(() => {
|
|
3974
|
-
this.doc().scrollLeft += c.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3975
|
-
});
|
|
3976
|
-
}), e.register("go_start", L.moduleName, (s, r) => {
|
|
3977
|
-
if (this.doc().scrollLeft === 0) return r(!1);
|
|
3978
|
-
this.doc().scrollLeft = 0, this.reportProgress(), r(!0);
|
|
3979
|
-
}), e.register("go_end", L.moduleName, (s, r) => {
|
|
3980
|
-
if (Math.abs(this.doc().scrollLeft) === this.scrollable()) return r(!1);
|
|
3981
|
-
this.doc().scrollLeft = this.verticalLR ? this.scrollable() : -this.scrollable(), this.reportProgress(), r(!0);
|
|
3982
|
-
}), e.register([
|
|
3983
|
-
"go_next",
|
|
3984
|
-
"go_prev"
|
|
3985
|
-
], L.moduleName, (s, r) => r(!1)), e.register("unfocus", L.moduleName, (s, r) => {
|
|
3986
|
-
A(this.wnd), r(!0);
|
|
3987
|
-
}), e.register("scroll_protection", L.moduleName, (s, r) => {
|
|
3988
|
-
this.enableScrollProtection(), r(!0);
|
|
3989
|
-
}), e.register("focus", L.moduleName, (s, r) => {
|
|
3990
|
-
this.reportProgress(), r(!0);
|
|
3991
|
-
}), e.register("first_visible_locator", L.moduleName, (s, r) => {
|
|
3992
|
-
const o = yt(t, !0);
|
|
3993
|
-
this.comms.send("first_visible_locator", o.serialize()), r(!0);
|
|
3994
|
-
}), e.log("CJKVerticalSnapper Mounted"), !0;
|
|
3995
|
-
}
|
|
3996
|
-
unmount(t, e) {
|
|
3997
|
-
return e.unregisterAll(L.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(Ee)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("CJKVerticalSnapper Unmounted"), !0;
|
|
3998
|
-
}
|
|
3999
|
-
};
|
|
4000
|
-
L.moduleName = "cjk_vertical_snapper";
|
|
4001
|
-
let Mt = L;
|
|
4002
|
-
const Ti = [
|
|
4003
|
-
"fixed_setup",
|
|
4004
|
-
"decorator",
|
|
4005
|
-
"peripherals",
|
|
4006
|
-
"print_protection"
|
|
4007
|
-
], Pi = [
|
|
4008
|
-
"reflowable_setup",
|
|
4009
|
-
"decorator",
|
|
4010
|
-
"peripherals",
|
|
4011
|
-
"column_snapper",
|
|
4012
|
-
"scroll_snapper",
|
|
4013
|
-
"cjk_vertical_snapper",
|
|
4014
|
-
"print_protection"
|
|
4015
|
-
], Ni = [
|
|
4016
|
-
"webpub_setup",
|
|
4017
|
-
"webpub_snapper",
|
|
4018
|
-
"decorator",
|
|
4019
|
-
"peripherals",
|
|
4020
|
-
"print_protection"
|
|
4021
|
-
], Ae = new Map([
|
|
4022
|
-
// All modules go here
|
|
4023
|
-
Dt,
|
|
4024
|
-
Rt,
|
|
4025
|
-
It,
|
|
4026
|
-
Lt,
|
|
4027
|
-
Ot,
|
|
4028
|
-
Tt,
|
|
4029
|
-
Pt,
|
|
4030
|
-
Nt,
|
|
4031
|
-
Mt,
|
|
4032
|
-
zt
|
|
4033
|
-
].map((n) => [n.moduleName, n]));
|
|
4034
|
-
class Li {
|
|
4035
|
-
/**
|
|
4036
|
-
* @param wnd Window instance to operate on
|
|
4037
|
-
* @param initialModules List of initial modules to load
|
|
4038
|
-
*/
|
|
4039
|
-
constructor(t = window, e = []) {
|
|
4040
|
-
this.loadedModules = [], this.wnd = t, this.comms = new Be(t);
|
|
4041
|
-
const i = [...new Set(e)];
|
|
4042
|
-
if (i.length) {
|
|
4043
|
-
if (typeof t > "u")
|
|
4044
|
-
throw Error("Loader is not in a web browser");
|
|
4045
|
-
t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
|
|
4046
|
-
const r = this.loadModule(s);
|
|
4047
|
-
if (r)
|
|
4048
|
-
return r.mount(this.wnd, this.comms), r;
|
|
4049
|
-
}).filter((s) => s !== void 0);
|
|
4050
|
-
}
|
|
4051
|
-
}
|
|
4052
|
-
loadModule(t) {
|
|
4053
|
-
const e = Ae.get(t);
|
|
4054
|
-
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
4055
|
-
}
|
|
4056
|
-
/**
|
|
4057
|
-
* Add a module by name
|
|
4058
|
-
* @param moduleName Module name
|
|
4059
|
-
* @returns Success
|
|
4060
|
-
*/
|
|
4061
|
-
addModule(t) {
|
|
4062
|
-
const e = this.loadModule(t);
|
|
4063
|
-
return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);
|
|
4064
|
-
}
|
|
4065
|
-
/**
|
|
4066
|
-
* Remove a module by name
|
|
4067
|
-
* @param moduleName Module name
|
|
4068
|
-
* @returns Success
|
|
4069
|
-
*/
|
|
4070
|
-
removeModule(t) {
|
|
4071
|
-
const e = Ae.get(t);
|
|
4072
|
-
if (e === void 0)
|
|
4073
|
-
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
4074
|
-
const i = this.loadedModules.findIndex((s) => s instanceof e);
|
|
4075
|
-
return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
|
|
4076
|
-
}
|
|
4077
|
-
/**
|
|
4078
|
-
* Unmount and remove all modules
|
|
4079
|
-
*/
|
|
4080
|
-
destroy() {
|
|
4081
|
-
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
4082
|
-
}
|
|
4083
|
-
}
|
|
4084
|
-
const Oi = {
|
|
4085
|
-
type: "developer_tools",
|
|
4086
|
-
keyCombos: [
|
|
4087
|
-
{ keyCode: 73, meta: !0, alt: !0 },
|
|
4088
|
-
// Cmd+Option+I
|
|
4089
|
-
{ keyCode: 73, ctrl: !0, shift: !0 },
|
|
4090
|
-
// Ctrl+Shift+I
|
|
4091
|
-
{ keyCode: 74, meta: !0, alt: !0 },
|
|
4092
|
-
// Cmd+Option+J
|
|
4093
|
-
{ keyCode: 74, ctrl: !0, shift: !0 },
|
|
4094
|
-
// Ctrl+Shift+J
|
|
4095
|
-
{ keyCode: 85, meta: !0, alt: !0 },
|
|
4096
|
-
// Cmd+Option+U
|
|
4097
|
-
{ keyCode: 67, meta: !0, alt: !0 },
|
|
4098
|
-
// Cmd+Option+C
|
|
4099
|
-
{ keyCode: 67, meta: !0, shift: !0 },
|
|
4100
|
-
// Cmd+Shift+C
|
|
4101
|
-
{ keyCode: 67, ctrl: !0, shift: !0 },
|
|
4102
|
-
// Ctrl+Shift+C
|
|
4103
|
-
{ keyCode: 65, meta: !0, alt: !0 },
|
|
4104
|
-
// Cmd+Option+A
|
|
4105
|
-
{ keyCode: 84, meta: !0, shift: !0, alt: !0 },
|
|
4106
|
-
// Cmd+Shift+Option+T
|
|
4107
|
-
{ keyCode: 67, shift: !0, alt: !0 },
|
|
4108
|
-
// Shift+Option+C
|
|
4109
|
-
{ keyCode: 123 },
|
|
4110
|
-
// F12
|
|
4111
|
-
{ keyCode: 123, shift: !0 },
|
|
4112
|
-
// Shift+F12
|
|
4113
|
-
{ keyCode: 123, ctrl: !0, shift: !0 },
|
|
4114
|
-
// Ctrl+Shift+F12
|
|
4115
|
-
{ keyCode: 123, meta: !0, alt: !0 }
|
|
4116
|
-
// Cmd+Option+F12
|
|
4117
|
-
]
|
|
4118
|
-
}, Ri = {
|
|
4119
|
-
type: "select_all",
|
|
4120
|
-
keyCombos: [
|
|
4121
|
-
{ keyCode: 65, meta: !0 },
|
|
4122
|
-
// Cmd+A
|
|
4123
|
-
{ keyCode: 65, ctrl: !0 }
|
|
4124
|
-
// Ctrl+A
|
|
4125
|
-
]
|
|
4126
|
-
}, Di = {
|
|
4127
|
-
type: "print",
|
|
4128
|
-
keyCombos: [
|
|
4129
|
-
{ keyCode: 80, meta: !0 },
|
|
4130
|
-
// Cmd+P
|
|
4131
|
-
{ keyCode: 80, ctrl: !0 },
|
|
4132
|
-
// Ctrl+P
|
|
4133
|
-
{ keyCode: 80, meta: !0, shift: !0 },
|
|
4134
|
-
// Cmd+Shift+P
|
|
4135
|
-
{ keyCode: 80, ctrl: !0, shift: !0 },
|
|
4136
|
-
// Ctrl+Shift+P
|
|
4137
|
-
{ keyCode: 80, meta: !0, alt: !0 },
|
|
4138
|
-
// Cmd+Alt+P
|
|
4139
|
-
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
4140
|
-
// Ctrl+Alt+P
|
|
4141
|
-
]
|
|
4142
|
-
}, Ii = {
|
|
4143
|
-
type: "save",
|
|
4144
|
-
keyCombos: [
|
|
4145
|
-
{ keyCode: 83, meta: !0 },
|
|
4146
|
-
// Cmd+S
|
|
4147
|
-
{ keyCode: 83, ctrl: !0 }
|
|
4148
|
-
// Ctrl+S
|
|
4149
|
-
]
|
|
4150
|
-
};
|
|
4151
|
-
export {
|
|
4152
|
-
Ai as BulkCopyProtector,
|
|
4153
|
-
Z as COMMS_VERSION,
|
|
4154
|
-
Be as Comms,
|
|
4155
|
-
Oi as DEV_TOOLS,
|
|
4156
|
-
Tt as Decorator,
|
|
4157
|
-
Ti as FXLModules,
|
|
4158
|
-
xi as KeyCombinationManager,
|
|
4159
|
-
li as Layout,
|
|
4160
|
-
Li as Loader,
|
|
4161
|
-
K as Module,
|
|
4162
|
-
Ae as ModuleLibrary,
|
|
4163
|
-
Di as PRINT,
|
|
4164
|
-
bt as PatternAnalyzer,
|
|
4165
|
-
Ot as Peripherals,
|
|
4166
|
-
zt as PrintProtector,
|
|
4167
|
-
Pi as ReflowableModules,
|
|
4168
|
-
Ii as SAVE,
|
|
4169
|
-
Ri as SELECT_ALL,
|
|
4170
|
-
Ci as SelectionAnalyzer,
|
|
4171
|
-
Ni as WebPubModules,
|
|
4172
|
-
ai as Width,
|
|
4173
|
-
Ue as mid
|
|
4174
|
-
};
|
|
1
|
+
import{Loader as e}from"./Loader.js";import{COMMS_VERSION as m,Comms as p}from"./comms/comms.js";import{mid as f}from"./comms/mid.js";import{DecorationLayout as x,DecorationStyleType as i,DecorationWidth as n,Decorator as d}from"./modules/Decorator.js";import{Module as y}from"./modules/Module.js";import{FXLModules as M,ModuleLibrary as c,ReflowableModules as P,WebPubModules as S}from"./modules/ModuleLibrary.js";import{Peripherals as s}from"./modules/Peripherals.js";import{BulkCopyProtector as D}from"./protection/BulkCopyProtector.js";import{PatternAnalyzer as A}from"./protection/PatternAnalyzer.js";import{SelectionAnalyzer as T}from"./protection/SelectionAnalyzer.js";import{PrintProtector as V}from"./protection/PrintProtector.js";import{DEV_TOOLS as h,PRINT as z,SAVE as I,SELECT_ALL as N}from"./keyboard/KeyboardCombinations.js";import{KeyCombinationManager as g}from"./keyboard/KeyCombinationManager.js";export{D as BulkCopyProtector,m as COMMS_VERSION,p as Comms,h as DEV_TOOLS,x as DecorationLayout,i as DecorationStyleType,n as DecorationWidth,d as Decorator,M as FXLModules,g as KeyCombinationManager,e as Loader,y as Module,c as ModuleLibrary,z as PRINT,A as PatternAnalyzer,s as Peripherals,V as PrintProtector,P as ReflowableModules,I as SAVE,N as SELECT_ALL,T as SelectionAnalyzer,S as WebPubModules,f as mid};
|