@prose-reader/cfi 1.214.0 → 1.215.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +127 -126
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,78 +28,78 @@ function ie(e) {
|
|
|
28
28
|
function se(e) {
|
|
29
29
|
const t = [];
|
|
30
30
|
let n = null, i = !1, r = "";
|
|
31
|
-
const
|
|
31
|
+
const s = (c) => {
|
|
32
32
|
t.push(c), n = null, r = "";
|
|
33
33
|
}, l = (c) => {
|
|
34
34
|
r += c, i = !1;
|
|
35
35
|
}, f = ie(e).trim(), a = Array.from(f).concat("");
|
|
36
36
|
for (let c = 0; c < a.length; c++) {
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
n === "/" || n === ":" ?
|
|
37
|
+
const o = a[c];
|
|
38
|
+
if (!o) {
|
|
39
|
+
n === "/" || n === ":" ? s([n, parseInt(r, 10)]) : n === "~" ? s(["~", parseFloat(r)]) : n === "@" ? s(["@", parseFloat(r)]) : n === "[" ? s(["[", r]) : (n === ";" || n != null && n.startsWith(";")) && s([n, r]);
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
42
|
+
if (o === "^" && !i) {
|
|
43
43
|
i = !0;
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
if (n === "!")
|
|
47
|
-
|
|
47
|
+
s(["!", 0]);
|
|
48
48
|
else if (n === ",")
|
|
49
|
-
|
|
49
|
+
s([",", 0]);
|
|
50
50
|
else if (n === "/" || n === ":") {
|
|
51
|
-
if (/^\d$/.test(
|
|
52
|
-
l(
|
|
51
|
+
if (/^\d$/.test(o)) {
|
|
52
|
+
l(o);
|
|
53
53
|
continue;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
s([n, parseInt(r, 10)]);
|
|
56
56
|
} else if (n === "~") {
|
|
57
|
-
if (/^\d$/.test(
|
|
58
|
-
l(
|
|
57
|
+
if (/^\d$/.test(o) || o === ".") {
|
|
58
|
+
l(o);
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
s(["~", parseFloat(r)]);
|
|
62
62
|
} else if (n === "@") {
|
|
63
|
-
if (
|
|
64
|
-
|
|
63
|
+
if (o === ":") {
|
|
64
|
+
s(["@", parseFloat(r)]), n = "@";
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
-
if (/^\d$/.test(
|
|
68
|
-
l(
|
|
67
|
+
if (/^\d$/.test(o) || o === ".") {
|
|
68
|
+
l(o);
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
s(["@", parseFloat(r)]);
|
|
72
72
|
} else if (n === "[")
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
else if (
|
|
76
|
-
|
|
73
|
+
if (o === ";" && !i)
|
|
74
|
+
s(["[", r]), n = ";";
|
|
75
|
+
else if (o === "]" && !i)
|
|
76
|
+
s(["[", r]);
|
|
77
77
|
else {
|
|
78
|
-
l(
|
|
78
|
+
l(o);
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
else if (n === ";")
|
|
82
|
-
if (
|
|
82
|
+
if (o === "=" && !i)
|
|
83
83
|
n = `;${r}`, r = "";
|
|
84
|
-
else if (
|
|
85
|
-
|
|
86
|
-
else if (
|
|
87
|
-
|
|
84
|
+
else if (o === ";" && !i)
|
|
85
|
+
s([n, r]), n = ";";
|
|
86
|
+
else if (o === "]" && !i)
|
|
87
|
+
s([n, r]);
|
|
88
88
|
else {
|
|
89
|
-
l(
|
|
89
|
+
l(o);
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
92
|
else if (n != null && n.startsWith(";"))
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
else if (
|
|
96
|
-
|
|
93
|
+
if (o === ";" && !i)
|
|
94
|
+
s([n, r]), n = ";";
|
|
95
|
+
else if (o === "]" && !i)
|
|
96
|
+
s([n, r]);
|
|
97
97
|
else {
|
|
98
|
-
l(
|
|
98
|
+
l(o);
|
|
99
99
|
continue;
|
|
100
100
|
}
|
|
101
|
-
else n === null &&
|
|
102
|
-
(
|
|
101
|
+
else n === null && o === ";" && (n = ";");
|
|
102
|
+
(o === "/" || o === ":" || o === "~" || o === "@" || o === "[" || o === "!" || o === ",") && (n = o);
|
|
103
103
|
}
|
|
104
104
|
return t;
|
|
105
105
|
}
|
|
@@ -117,32 +117,32 @@ function oe(e) {
|
|
|
117
117
|
var r;
|
|
118
118
|
const t = [], n = {};
|
|
119
119
|
let i = -1;
|
|
120
|
-
for (let
|
|
121
|
-
const l = e[
|
|
120
|
+
for (let s = 0; s < e.length; s++) {
|
|
121
|
+
const l = e[s];
|
|
122
122
|
if (!l) continue;
|
|
123
123
|
const [f, a] = l;
|
|
124
124
|
f === "/" ? (i++, t[i] = { index: a }, n[i] = []) : i >= 0 && ((r = n[i]) == null || r.push(l));
|
|
125
125
|
}
|
|
126
|
-
for (let
|
|
127
|
-
const l = t[
|
|
126
|
+
for (let s = 0; s < t.length; s++) {
|
|
127
|
+
const l = t[s];
|
|
128
128
|
if (!l) continue;
|
|
129
|
-
const f = n[
|
|
129
|
+
const f = n[s] || [];
|
|
130
130
|
for (let a = 0; a < f.length; a++) {
|
|
131
131
|
const c = f[a];
|
|
132
132
|
if (!c) continue;
|
|
133
|
-
const [
|
|
134
|
-
if (
|
|
133
|
+
const [o, d] = c;
|
|
134
|
+
if (o === ":")
|
|
135
135
|
l.offset = d;
|
|
136
|
-
else if (
|
|
136
|
+
else if (o === "~")
|
|
137
137
|
l.temporal = d;
|
|
138
|
-
else if (
|
|
138
|
+
else if (o === "@")
|
|
139
139
|
l.spatial = (l.spatial || []).concat(d);
|
|
140
|
-
else if (
|
|
140
|
+
else if (o === ";s")
|
|
141
141
|
l.side = d;
|
|
142
|
-
else if (
|
|
143
|
-
const u =
|
|
142
|
+
else if (o.startsWith(";") && o !== ";s") {
|
|
143
|
+
const u = o.substring(1);
|
|
144
144
|
l.extensions || (l.extensions = {}), l.extensions[u] = d;
|
|
145
|
-
} else if (
|
|
145
|
+
} else if (o === "[") {
|
|
146
146
|
const u = typeof d == "string" && !d.includes(" ") && d.length < 50;
|
|
147
147
|
if (a === 0 && u && !l.id)
|
|
148
148
|
l.id = d;
|
|
@@ -168,14 +168,14 @@ function O(e) {
|
|
|
168
168
|
const n = H(t, ",");
|
|
169
169
|
if (n.length === 0)
|
|
170
170
|
return T(t);
|
|
171
|
-
const [i, r,
|
|
171
|
+
const [i, r, s] = U(t, n);
|
|
172
172
|
return {
|
|
173
173
|
parent: T(i || []),
|
|
174
174
|
start: T(r || []),
|
|
175
|
-
end: T(
|
|
175
|
+
end: T(s || [])
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function M(e) {
|
|
179
179
|
return e !== null && typeof e == "object" && "parent" in e && "start" in e && "end" in e;
|
|
180
180
|
}
|
|
181
181
|
function he(e, t, n = {}) {
|
|
@@ -183,7 +183,7 @@ function he(e, t, n = {}) {
|
|
|
183
183
|
if (typeof e != "string")
|
|
184
184
|
return D(e, t, n);
|
|
185
185
|
const i = O(e);
|
|
186
|
-
return n.asRange &&
|
|
186
|
+
return n.asRange && M(i) ? G(i, t) : D(i, t, n);
|
|
187
187
|
} catch (i) {
|
|
188
188
|
if (n.throwOnError)
|
|
189
189
|
throw i;
|
|
@@ -192,38 +192,39 @@ function he(e, t, n = {}) {
|
|
|
192
192
|
}
|
|
193
193
|
function D(e, t, n = { asRange: !1 }) {
|
|
194
194
|
const { asRange: i = !1 } = n;
|
|
195
|
-
if (
|
|
195
|
+
if (M(e)) {
|
|
196
196
|
if (i)
|
|
197
197
|
return G(e, t);
|
|
198
|
-
const
|
|
199
|
-
return y(
|
|
198
|
+
const s = e.start.at(-1) || [];
|
|
199
|
+
return y(s, t, n);
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
const r = e.at(-1);
|
|
202
|
+
if (r)
|
|
203
|
+
return y(r, t, n);
|
|
203
204
|
throw new Error("Invalid CFI structure");
|
|
204
205
|
}
|
|
205
206
|
function G(e, t) {
|
|
206
207
|
const n = e.parent[0] || [], i = e.start[0] || [], r = e.end[0] || [];
|
|
207
|
-
let
|
|
208
|
+
let s = t.documentElement;
|
|
208
209
|
if (n.length > 0) {
|
|
209
210
|
const d = y(n, t);
|
|
210
|
-
p(d.node) && (
|
|
211
|
+
p(d.node) && (s = d.node);
|
|
211
212
|
}
|
|
212
|
-
if (!
|
|
213
|
+
if (!s)
|
|
213
214
|
throw new Error("Failed to resolve parent node in CFI range");
|
|
214
215
|
const l = y(i, t), f = y(r, t);
|
|
215
216
|
if (!p(l.node) || !p(f.node))
|
|
216
217
|
throw new Error("Failed to resolve start or end node in CFI range");
|
|
217
|
-
const a = l.node, c = f.node,
|
|
218
|
-
return
|
|
218
|
+
const a = l.node, c = f.node, o = t.createRange();
|
|
219
|
+
return o.setStart(
|
|
219
220
|
a,
|
|
220
221
|
(Array.isArray(l.offset) ? l.offset[0] : l.offset) ?? 0
|
|
221
|
-
),
|
|
222
|
+
), o.setEnd(
|
|
222
223
|
c,
|
|
223
224
|
(Array.isArray(f.offset) ? f.offset[0] : f.offset) ?? 0
|
|
224
225
|
), {
|
|
225
226
|
...l,
|
|
226
|
-
node:
|
|
227
|
+
node: o,
|
|
227
228
|
isRange: !0
|
|
228
229
|
};
|
|
229
230
|
}
|
|
@@ -242,7 +243,7 @@ function S(e) {
|
|
|
242
243
|
return e.index % 2 !== 0;
|
|
243
244
|
}
|
|
244
245
|
function xe(e) {
|
|
245
|
-
const n = (
|
|
246
|
+
const n = (M(e) ? e.end : e).at(-1), i = n == null ? void 0 : n.at(-1);
|
|
246
247
|
return i == null ? void 0 : i.extensions;
|
|
247
248
|
}
|
|
248
249
|
function J(e) {
|
|
@@ -279,8 +280,8 @@ function W(e, t, n) {
|
|
|
279
280
|
}
|
|
280
281
|
function X(e, t, n, i) {
|
|
281
282
|
let r = e;
|
|
282
|
-
for (let
|
|
283
|
-
const l = t[
|
|
283
|
+
for (let s = n; s < t.length; s++) {
|
|
284
|
+
const l = t[s];
|
|
284
285
|
if (!r || !l) break;
|
|
285
286
|
if (S(l)) {
|
|
286
287
|
const f = l.index - 1;
|
|
@@ -316,30 +317,30 @@ function y(e, t, n = {}) {
|
|
|
316
317
|
throw new Error("Document is not available");
|
|
317
318
|
return E(null);
|
|
318
319
|
}
|
|
319
|
-
const { node:
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
323
|
-
const d =
|
|
324
|
-
if (d >= 0 && d <
|
|
325
|
-
const u =
|
|
326
|
-
return E(u,
|
|
320
|
+
const { node: s, remainingPathIndex: l } = fe(t, e);
|
|
321
|
+
if (s && l >= e.length) {
|
|
322
|
+
const o = e.at(-1);
|
|
323
|
+
if (o && S(o)) {
|
|
324
|
+
const d = o.index - 1;
|
|
325
|
+
if (d >= 0 && d < s.childNodes.length) {
|
|
326
|
+
const u = s.childNodes[d];
|
|
327
|
+
return E(u, o);
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
if (r) {
|
|
330
|
-
const d = W(t,
|
|
331
|
-
return v(d,
|
|
331
|
+
const d = W(t, s, o == null ? void 0 : o.offset);
|
|
332
|
+
return v(d, o);
|
|
332
333
|
}
|
|
333
|
-
return E(
|
|
334
|
+
return E(s, o);
|
|
334
335
|
}
|
|
335
|
-
let f =
|
|
336
|
-
const a =
|
|
336
|
+
let f = s || t.documentElement;
|
|
337
|
+
const a = s ? l : 0;
|
|
337
338
|
if (r && e.length > 0) {
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
if (
|
|
339
|
+
const o = e[e.length - 1];
|
|
340
|
+
if (o && !S(o)) {
|
|
341
|
+
if (o.index === 0 && f) {
|
|
341
342
|
const u = t.createRange();
|
|
342
|
-
return u.setStart(f, 0), u.setEnd(f, 0), v(u,
|
|
343
|
+
return u.setStart(f, 0), u.setEnd(f, 0), v(u, o);
|
|
343
344
|
}
|
|
344
345
|
const d = X(
|
|
345
346
|
f,
|
|
@@ -351,9 +352,9 @@ function y(e, t, n = {}) {
|
|
|
351
352
|
const u = Array.from(d.childNodes).filter(
|
|
352
353
|
(x) => x.nodeType === Node.ELEMENT_NODE
|
|
353
354
|
);
|
|
354
|
-
if (Math.floor(
|
|
355
|
+
if (Math.floor(o.index / 2) - 1 === u.length) {
|
|
355
356
|
const x = t.createRange();
|
|
356
|
-
return x.selectNodeContents(d), x.collapse(!1), v(x,
|
|
357
|
+
return x.selectNodeContents(d), x.collapse(!1), v(x, o);
|
|
357
358
|
}
|
|
358
359
|
}
|
|
359
360
|
}
|
|
@@ -365,8 +366,8 @@ function y(e, t, n = {}) {
|
|
|
365
366
|
}
|
|
366
367
|
const c = e.at(-1);
|
|
367
368
|
if (r) {
|
|
368
|
-
const
|
|
369
|
-
return v(
|
|
369
|
+
const o = W(t, f, c == null ? void 0 : c.offset);
|
|
370
|
+
return v(o, c);
|
|
370
371
|
}
|
|
371
372
|
return E(f, c);
|
|
372
373
|
}
|
|
@@ -385,7 +386,7 @@ function K(e, t, n = {}) {
|
|
|
385
386
|
return null;
|
|
386
387
|
const i = e.textContent, r = n.textAssertionLength || 10;
|
|
387
388
|
if (t !== void 0 && t <= i.length) {
|
|
388
|
-
const
|
|
389
|
+
const s = Math.floor(r / 2), l = Math.max(0, t - s), f = Math.min(i.length, t + s);
|
|
389
390
|
return i.substring(l, f);
|
|
390
391
|
}
|
|
391
392
|
return i.substring(0, Math.min(i.length, r));
|
|
@@ -394,7 +395,7 @@ function ce(e) {
|
|
|
394
395
|
const [t, n] = e, i = Math.max(0, Math.min(100, t)), r = Math.max(0, Math.min(100, n));
|
|
395
396
|
return `@${i}:${r}`;
|
|
396
397
|
}
|
|
397
|
-
function
|
|
398
|
+
function P(e, t, n) {
|
|
398
399
|
let i = e;
|
|
399
400
|
return t !== void 0 && (i += `~${t}`), n !== void 0 && (i += ce(n)), i;
|
|
400
401
|
}
|
|
@@ -406,9 +407,9 @@ function Q(e, t, n) {
|
|
|
406
407
|
}
|
|
407
408
|
return i;
|
|
408
409
|
}
|
|
409
|
-
function
|
|
410
|
+
function j(e, t, n = {}, i) {
|
|
410
411
|
var a;
|
|
411
|
-
let r = "",
|
|
412
|
+
let r = "", s = e, l = null;
|
|
412
413
|
if ((e == null ? void 0 : e.nodeType) === Node.TEXT_NODE) {
|
|
413
414
|
l = e;
|
|
414
415
|
const c = e.parentNode;
|
|
@@ -419,27 +420,27 @@ function M(e, t, n = {}, i) {
|
|
|
419
420
|
throw new Error("Node not found in parent's children");
|
|
420
421
|
if (r = `/${d + 1}`, w(c) && c.id) {
|
|
421
422
|
const u = c.id, h = Array.from(((a = c.parentNode) == null ? void 0 : a.childNodes) || []);
|
|
422
|
-
r = `/${h.slice(0, h.indexOf(c) + 1).filter((I) => I.nodeType === Node.ELEMENT_NODE).length * 2}[${g(u)}]${r}`,
|
|
423
|
+
r = `/${h.slice(0, h.indexOf(c) + 1).filter((I) => I.nodeType === Node.ELEMENT_NODE).length * 2}[${g(u)}]${r}`, s = c.parentNode;
|
|
423
424
|
} else
|
|
424
|
-
|
|
425
|
+
s = c;
|
|
425
426
|
}
|
|
426
427
|
let f = null;
|
|
427
|
-
for (l && n.includeTextAssertions && (f = K(l, t, n));
|
|
428
|
-
if (!(l &&
|
|
429
|
-
const c =
|
|
428
|
+
for (l && n.includeTextAssertions && (f = K(l, t, n)); s != null && s.parentNode; ) {
|
|
429
|
+
if (!(l && s === l.parentNode && r.includes(`[${w(s) ? s.id : ""}]`))) {
|
|
430
|
+
const c = s.parentNode, o = Array.from(c.childNodes), d = o.indexOf(s);
|
|
430
431
|
if (d === -1)
|
|
431
432
|
throw new Error("Node not found in parent's children");
|
|
432
|
-
const u =
|
|
433
|
+
const u = o.slice(0, d + 1).filter(($) => $.nodeType === Node.ELEMENT_NODE);
|
|
433
434
|
let h;
|
|
434
|
-
|
|
435
|
+
s.nodeType, Node.ELEMENT_NODE, h = u.length;
|
|
435
436
|
const x = h * 2;
|
|
436
|
-
w(
|
|
437
|
+
w(s) && s.id ? r = `/${x}[${g(s.id)}]${r}` : r = `/${x}${r}`;
|
|
437
438
|
}
|
|
438
|
-
if (
|
|
439
|
+
if (s.parentNode.nodeName.toLowerCase() === "html")
|
|
439
440
|
break;
|
|
440
|
-
|
|
441
|
+
s = s.parentNode;
|
|
441
442
|
}
|
|
442
|
-
return t !== void 0 && (r += `:${t}`), r =
|
|
443
|
+
return t !== void 0 && (r += `:${t}`), r = P(
|
|
443
444
|
r,
|
|
444
445
|
i == null ? void 0 : i.temporal,
|
|
445
446
|
(i == null ? void 0 : i.spatial) || n.spatialOffset
|
|
@@ -448,27 +449,27 @@ function M(e, t, n = {}, i) {
|
|
|
448
449
|
function z(e, t, n, i = {}, r) {
|
|
449
450
|
if (e === t) {
|
|
450
451
|
let a = n !== void 0 ? `:${n}` : "";
|
|
451
|
-
return a =
|
|
452
|
+
return a = P(a, r == null ? void 0 : r.temporal, r == null ? void 0 : r.spatial), a;
|
|
452
453
|
}
|
|
453
|
-
const
|
|
454
|
+
const s = [];
|
|
454
455
|
let l = t;
|
|
455
456
|
for (; l && l !== e; ) {
|
|
456
457
|
const a = l.parentNode;
|
|
457
458
|
if (!a) break;
|
|
458
459
|
const c = a.childNodes;
|
|
459
|
-
let
|
|
460
|
+
let o = -1;
|
|
460
461
|
for (let u = 0; u < c.length; u++)
|
|
461
462
|
if (c[u] === l) {
|
|
462
|
-
|
|
463
|
+
o = u;
|
|
463
464
|
break;
|
|
464
465
|
}
|
|
465
|
-
if (
|
|
466
|
+
if (o === -1)
|
|
466
467
|
throw new Error("Node not found in parent's children");
|
|
467
|
-
const d =
|
|
468
|
-
w(l) && l.id ?
|
|
468
|
+
const d = o + 1;
|
|
469
|
+
w(l) && l.id ? s.unshift(`/${d}[${g(l.id)}]`) : s.unshift(`/${d}`), l = a;
|
|
469
470
|
}
|
|
470
|
-
let f =
|
|
471
|
-
if (n !== void 0 && (f += `:${n}`), f =
|
|
471
|
+
let f = s.join("");
|
|
472
|
+
if (n !== void 0 && (f += `:${n}`), f = P(f, r == null ? void 0 : r.temporal, r == null ? void 0 : r.spatial), i.includeTextAssertions && t.nodeType === Node.TEXT_NODE) {
|
|
472
473
|
const a = K(t, n, i);
|
|
473
474
|
f = Q(
|
|
474
475
|
f,
|
|
@@ -492,17 +493,17 @@ function N(e, t) {
|
|
|
492
493
|
}
|
|
493
494
|
return e.endsWith("!") ? e : `${e}[;${n}]`;
|
|
494
495
|
}
|
|
495
|
-
function de(e, t, n, i, r = {},
|
|
496
|
+
function de(e, t, n, i, r = {}, s, l) {
|
|
496
497
|
const f = ee(e, n);
|
|
497
498
|
if (!f)
|
|
498
499
|
throw new Error("No common ancestor found");
|
|
499
|
-
const a =
|
|
500
|
+
const a = j(f, void 0, r), c = z(
|
|
500
501
|
f,
|
|
501
502
|
e,
|
|
502
503
|
t,
|
|
503
504
|
r,
|
|
504
|
-
|
|
505
|
-
),
|
|
505
|
+
s
|
|
506
|
+
), o = z(
|
|
506
507
|
f,
|
|
507
508
|
n,
|
|
508
509
|
i,
|
|
@@ -510,10 +511,10 @@ function de(e, t, n, i, r = {}, o, l) {
|
|
|
510
511
|
l
|
|
511
512
|
);
|
|
512
513
|
if (r.extensions && Object.keys(r.extensions).length > 0) {
|
|
513
|
-
const d = N(a, r.extensions), u = N(c, r.extensions), h = N(
|
|
514
|
+
const d = N(a, r.extensions), u = N(c, r.extensions), h = N(o, r.extensions);
|
|
514
515
|
return `${d},${u},${h}`;
|
|
515
516
|
}
|
|
516
|
-
return `${a},${c},${
|
|
517
|
+
return `${a},${c},${o}`;
|
|
517
518
|
}
|
|
518
519
|
const Y = (e, t, n = {}, i) => {
|
|
519
520
|
const r = "";
|
|
@@ -522,7 +523,7 @@ const Y = (e, t, n = {}, i) => {
|
|
|
522
523
|
};
|
|
523
524
|
function ge(e, t = {}) {
|
|
524
525
|
if (p(e))
|
|
525
|
-
return `epubcfi(${
|
|
526
|
+
return `epubcfi(${j(e, void 0, t)})`;
|
|
526
527
|
let n = "";
|
|
527
528
|
if (!("start" in e))
|
|
528
529
|
return e.spineIndex !== void 0 && (n = Y(
|
|
@@ -530,7 +531,7 @@ function ge(e, t = {}) {
|
|
|
530
531
|
e.spineId,
|
|
531
532
|
t,
|
|
532
533
|
!e.node
|
|
533
|
-
), !e.node) ? `epubcfi(${n})` : (n +=
|
|
534
|
+
), !e.node) ? `epubcfi(${n})` : (n += j(
|
|
534
535
|
e.node ?? null,
|
|
535
536
|
e.offset,
|
|
536
537
|
t,
|
|
@@ -559,14 +560,14 @@ function V(e) {
|
|
|
559
560
|
return e.offset !== void 0 ? 1 : e.index !== void 0 ? 2 : e.temporal !== void 0 || e.spatial !== void 0 ? 3 : 4;
|
|
560
561
|
}
|
|
561
562
|
function q(e, t) {
|
|
562
|
-
var r,
|
|
563
|
+
var r, s, l, f;
|
|
563
564
|
const n = typeof e == "string" ? O(e) : e, i = typeof t == "string" ? O(t) : t;
|
|
564
565
|
if ("parent" in n || "parent" in i)
|
|
565
566
|
return q(m(n), m(i)) || q(m(n, !0), m(i, !0));
|
|
566
567
|
for (let a = 0; a < Math.max(n.length, i.length); a++) {
|
|
567
|
-
const c = n[a] || [],
|
|
568
|
+
const c = n[a] || [], o = i[a] || [], d = Math.max(c.length, o.length) - 1;
|
|
568
569
|
for (let u = 0; u <= d; u++) {
|
|
569
|
-
const h = c[u], x =
|
|
570
|
+
const h = c[u], x = o[u];
|
|
570
571
|
if (!h) return -1;
|
|
571
572
|
if (!x) return 1;
|
|
572
573
|
const $ = V(h), I = V(x);
|
|
@@ -585,7 +586,7 @@ function q(e, t) {
|
|
|
585
586
|
if (A && !C) return 1;
|
|
586
587
|
if (!A && C) return -1;
|
|
587
588
|
if (A && C) {
|
|
588
|
-
const F = ((r = h.spatial) == null ? void 0 : r[1]) ?? 0, B = ((
|
|
589
|
+
const F = ((r = h.spatial) == null ? void 0 : r[1]) ?? 0, B = ((s = x.spatial) == null ? void 0 : s[1]) ?? 0;
|
|
589
590
|
if (F > B) return 1;
|
|
590
591
|
if (F < B) return -1;
|
|
591
592
|
const _ = ((l = h.spatial) == null ? void 0 : l[0]) ?? 0, L = ((f = x.spatial) == null ? void 0 : f[0]) ?? 0;
|
|
@@ -627,7 +628,7 @@ function Ne(e) {
|
|
|
627
628
|
export {
|
|
628
629
|
q as compare,
|
|
629
630
|
ge as generate,
|
|
630
|
-
|
|
631
|
+
M as isParsedCfiRange,
|
|
631
632
|
O as parse,
|
|
632
633
|
he as resolve,
|
|
633
634
|
xe as resolveExtensions,
|