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