@prose-reader/koreader 25.0.0 → 25.1.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.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { generate as e, getEpubCfiSpineItemref as t, isIndirectionOnly as n, parse as r, resolve as i } from "@prose-reader/cfi";
2
+ import { md5HexDigest as a } from "@prose-reader/shared";
2
3
  //#region src/crengine/elements.ts
3
- var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.article.aside.audio.author.autoboxing.blockquote.body.book-name.book-title.canvas.caption.center.city.col.colgroup.coverpage.custom-info.date.dd.details.dialog.dir.div.dl.docfragment.document-info.dt.email.empty-line.epigraph.fictionbook.fieldset.figcaption.figure.floatbox.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.header.hgroup.history.home-page.hr.html.id.iframe.isbn.keygen.keywords.lang.legend.li.listing.main.map.menu.multicol.nav.nickname.noframes.noscript.ol.optgroup.output.p.part.plaintext.poem.pre.program-used.publish-info.publisher.search.section.select.sequence.source.src-lang.src-ocr.src-title-info.src-url.stanza.subtitle.summary.table.tabularbox.tbody.td.text-author.textarea.tfoot.th.thead.title-info.tr.track.ul.v.version.video.xmp.year".split(".")), o = /* @__PURE__ */ new Set([
4
+ var o = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.article.aside.audio.author.autoboxing.blockquote.body.book-name.book-title.canvas.caption.center.city.col.colgroup.coverpage.custom-info.date.dd.details.dialog.dir.div.dl.docfragment.document-info.dt.email.empty-line.epigraph.fictionbook.fieldset.figcaption.figure.floatbox.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.header.hgroup.history.home-page.hr.html.id.iframe.isbn.keygen.keywords.lang.legend.li.listing.main.map.menu.multicol.nav.nickname.noframes.noscript.ol.optgroup.output.p.part.plaintext.poem.pre.program-used.publish-info.publisher.search.section.select.sequence.source.src-lang.src-ocr.src-title-info.src-url.stanza.subtitle.summary.table.tabularbox.tbody.td.text-author.textarea.tfoot.th.thead.title-info.tr.track.ul.v.version.video.xmp.year".split(".")), s = /* @__PURE__ */ new Set([
4
5
  "button",
5
6
  "input",
6
7
  "marquee"
7
- ]), s = /* @__PURE__ */ new Set([
8
+ ]), c = /* @__PURE__ */ new Set([
8
9
  "area",
9
10
  "base",
10
11
  "basefont",
@@ -25,14 +26,14 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
25
26
  "stylesheet",
26
27
  "template",
27
28
  "title"
28
- ]), c = /* @__PURE__ */ new Set(/* @__PURE__ */ "annotation.applet.area.audio.author.base.basefont.bgsound.clonenode.col.colgroup.coverpage.description.docfragment.document-info.embed.empty-line.epigraph.fictionbook.head.html.image.img.input.keygen.link.meta.object.param.part.poem.pseudoelem.publish-info.source.src-title-info.stanza.svg.table.tbody.tfoot.thead.title-info.tr.track".split(".")), l = /* @__PURE__ */ new Set([
29
+ ]), l = /* @__PURE__ */ new Set(/* @__PURE__ */ "annotation.applet.area.audio.author.base.basefont.bgsound.clonenode.col.colgroup.coverpage.description.docfragment.document-info.embed.empty-line.epigraph.fictionbook.head.html.image.img.input.keygen.link.meta.object.param.part.poem.pseudoelem.publish-info.source.src-title-info.stanza.svg.table.tbody.tfoot.thead.title-info.tr.track".split(".")), u = /* @__PURE__ */ new Set([
29
30
  "listing",
30
31
  "plaintext",
31
32
  "pre",
32
33
  "style",
33
34
  "textarea",
34
35
  "xmp"
35
- ]), u = /* @__PURE__ */ new Set([
36
+ ]), ee = /* @__PURE__ */ new Set([
36
37
  "desc",
37
38
  "metadata",
38
39
  "style",
@@ -48,7 +49,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
48
49
  "mtext",
49
50
  "mspace",
50
51
  "ms"
51
- ]), p = /* @__PURE__ */ new Set(["script", "style"]), ee = {
52
+ ]), p = /* @__PURE__ */ new Set(["script", "style"]), te = {
52
53
  table: /* @__PURE__ */ new Set([
53
54
  "caption",
54
55
  "col",
@@ -62,12 +63,12 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
62
63
  tfoot: /* @__PURE__ */ new Set(["tr"]),
63
64
  thead: /* @__PURE__ */ new Set(["tr"]),
64
65
  tr: /* @__PURE__ */ new Set(["td", "th"])
65
- }, te = (e) => {
66
- let t = ee[e.localName.toLowerCase()];
66
+ }, ne = (e) => {
67
+ let t = te[e.localName.toLowerCase()];
67
68
  if (!t) return !1;
68
69
  for (let n = e.firstElementChild; n; n = n.nextElementSibling) if (!t.has(n.localName.toLowerCase())) return !0;
69
70
  return !1;
70
- }, ne = /* @__PURE__ */ new Set(["pre", "textarea"]), m = 1, h = (e) => e.nodeType === m, g = (e, t) => t ? e.localName : e.localName.toLowerCase(), re = /* @__PURE__ */ new Set([
71
+ }, m = /* @__PURE__ */ new Set(["pre", "textarea"]), h = 1, g = (e) => e.nodeType === h, _ = (e, t) => t ? e.localName : e.localName.toLowerCase(), v = /* @__PURE__ */ new Set([
71
72
  "col",
72
73
  "colgroup",
73
74
  "tbody",
@@ -76,17 +77,17 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
76
77
  "th",
77
78
  "thead",
78
79
  "tr"
79
- ]), ie = (e) => s.has(e) ? "none" : a.has(e) ? "block" : o.has(e) ? "inlineBlock" : e === "ruby" ? "ruby" : "inline", _ = (e) => {
80
+ ]), y = (e) => c.has(e) ? "none" : o.has(e) ? "block" : s.has(e) ? "inlineBlock" : e === "ruby" ? "ruby" : "inline", b = (e) => {
80
81
  let t = e.localName.toLowerCase();
81
- return e.hasAttribute("hidden") && !re.has(t) ? "none" : ie(t);
82
- }, v = (e) => {
82
+ return e.hasAttribute("hidden") && !v.has(t) ? "none" : y(t);
83
+ }, x = (e) => {
83
84
  let t = e.localName.toLowerCase(), n = !1, r = !1, i = t === "math";
84
- for (let t = e.parentNode; t && h(t); t = t.parentNode) {
85
+ for (let t = e.parentNode; t && g(t); t = t.parentNode) {
85
86
  let e = t.localName.toLowerCase();
86
- l.has(e) && (n = !0), e === "svg" && (r = !0), e === "math" && (i = !0);
87
+ u.has(e) && (n = !0), e === "svg" && (r = !0), e === "math" && (i = !0);
87
88
  }
88
89
  if (r) {
89
- let e = u.has(t);
90
+ let e = ee.has(t);
90
91
  return {
91
92
  display: "inline",
92
93
  block: !1,
@@ -110,54 +111,54 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
110
111
  opaque: !1,
111
112
  insideSvg: !1
112
113
  };
113
- let a = _(e);
114
+ let a = b(e);
114
115
  return {
115
116
  display: a,
116
117
  block: a === "block" || a === "inlineBlock",
117
- allowsText: !c.has(t),
118
- pre: n || l.has(t),
119
- stripsLeadingNewline: ne.has(t),
118
+ allowsText: !l.has(t),
119
+ pre: n || u.has(t),
120
+ stripsLeadingNewline: m.has(t),
120
121
  trimsText: !1,
121
122
  restructured: a === "ruby",
122
123
  opaque: p.has(t),
123
124
  insideSvg: t === "svg"
124
125
  };
125
- }, y = 8192, b = 9, x = 10, S = 13, C = 32, w = (e) => e === C || e === S || e === x || e === b, T = (e) => {
126
+ }, re = 8192, S = 9, C = 10, w = 13, T = 32, E = (e) => e === T || e === w || e === C || e === S, D = (e) => {
126
127
  for (let t = 0; t < e.length; t++) {
127
128
  let n = e.charCodeAt(t);
128
- if (n !== C && n !== S && n !== x && n !== b) return !1;
129
+ if (n !== T && n !== w && n !== C && n !== S) return !1;
129
130
  }
130
131
  return !0;
131
- }, E = (e) => e > 65535 ? 2 : 1, D = (e, t, n) => {
132
+ }, O = (e) => e > 65535 ? 2 : 1, k = (e, t, n) => {
132
133
  let r = 0;
133
134
  if (!t.pre) {
134
135
  let i = 0, a = 0, o = e.length;
135
- if (t.trim) for (; o > 0 && w(e.charCodeAt(o - 1));) o--;
136
+ if (t.trim) for (; o > 0 && E(e.charCodeAt(o - 1));) o--;
136
137
  for (; r < e.length;) {
137
- let s = e.codePointAt(r) ?? 0, c = E(s), l = 1;
138
- if (w(s) ? (l = +(i === 0), i++, t.trim && (a === 0 || r >= o) && (l = 0)) : i = 0, a += l, !n(r, c, l)) return;
138
+ let s = e.codePointAt(r) ?? 0, c = O(s), l = 1;
139
+ if (E(s) ? (l = +(i === 0), i++, t.trim && (a === 0 || r >= o) && (l = 0)) : i = 0, a += l, !n(r, c, l)) return;
139
140
  r += c;
140
141
  }
141
142
  return;
142
143
  }
143
144
  let i = 0, a = 0, o = t.stripsLeadingNewline;
144
145
  for (; r < e.length;) {
145
- let t = e.codePointAt(r) ?? 0, s = E(t), c = 1, l = !1;
146
- if (t === S) {
146
+ let t = e.codePointAt(r) ?? 0, s = O(t), c = 1, l = !1;
147
+ if (t === w) {
147
148
  let t = r + s < e.length ? e.codePointAt(r + s) : void 0;
148
- (r === 0 || i !== x) && t !== x ? (l = !0, i = x) : c = 0;
149
- } else t === x ? (l = !0, i = x) : t === b ? (c = 8 - (a & 7), a += c, i = b) : (a++, i = t);
149
+ (r === 0 || i !== C) && t !== C ? (l = !0, i = C) : c = 0;
150
+ } else t === C ? (l = !0, i = C) : t === S ? (c = 8 - (a & 7), a += c, i = S) : (a++, i = t);
150
151
  if (l && (a = 1), c > 0 && o && (o = !1, l && (c = 0)), !n(r, s, c)) return;
151
152
  r += s;
152
153
  }
153
- }, ae = (e, t, n) => {
154
+ }, ie = (e, t, n) => {
154
155
  let r = 0;
155
- return D(e, n, (e, n, i) => e + n > t ? !1 : (r += i, !0)), r;
156
- }, oe = (e, t, n) => {
156
+ return k(e, n, (e, n, i) => e + n > t ? !1 : (r += i, !0)), r;
157
+ }, ae = (e, t, n) => {
157
158
  if (t < 0) return;
158
159
  let r = 0, i;
159
- return D(e, n, (e, n, a) => a === 0 ? !0 : r === t || r + a > t ? (i = e, !1) : (r += a, !0)), i === void 0 ? r === t ? e.length : void 0 : i;
160
- }, O = (e) => {
160
+ return k(e, n, (e, n, a) => a === 0 ? !0 : r === t || r + a > t ? (i = e, !1) : (r += a, !0)), i === void 0 ? r === t ? e.length : void 0 : i;
161
+ }, oe = (e) => {
161
162
  if (e.length < 8192) return [{
162
163
  start: 0,
163
164
  end: e.length
@@ -165,7 +166,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
165
166
  let t = [], n = 0;
166
167
  for (; n < e.length;) {
167
168
  let r = n, i = 0;
168
- for (; r < e.length && i < 8192;) r += E(e.codePointAt(r) ?? 0), i++;
169
+ for (; r < e.length && i < 8192;) r += O(e.codePointAt(r) ?? 0), i++;
169
170
  if (i < 8192) {
170
171
  t.push({
171
172
  start: n,
@@ -176,13 +177,13 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
176
177
  let a = r;
177
178
  for (let t = r - 1; t >= n; t--) {
178
179
  let n = e.charCodeAt(t);
179
- if (n === C) {
180
+ if (n === T) {
180
181
  a = t + 1;
181
182
  break;
182
183
  }
183
- if (n === S || n === x) {
184
+ if (n === w || n === C) {
184
185
  let i = t + 1 < r ? e.charCodeAt(t + 1) : 0;
185
- if (n === S && i !== x || n === x && i !== S) {
186
+ if (n === w && i !== C || n === C && i !== w) {
186
187
  a = t + 1;
187
188
  break;
188
189
  }
@@ -194,12 +195,12 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
194
195
  }), n = a;
195
196
  }
196
197
  return t;
197
- }, k = 3, A = 4, j = (e) => e.nodeType === k || e.nodeType === A, se = (e, t) => {
198
+ }, se = 3, ce = 4, A = (e) => e.nodeType === se || e.nodeType === ce, le = (e, t) => {
198
199
  let n = [], r = 0;
199
200
  if (t.opaque) return n;
200
201
  for (let i = e.firstChild; i; i = i.nextSibling, r++) {
201
- if (h(i)) {
202
- let e = t.insideSvg ? "inline" : _(i), a = e === "block" ? "block" : e === "none" ? "invisible" : "inline";
202
+ if (g(i)) {
203
+ let e = t.insideSvg ? "inline" : b(i), a = e === "block" ? "block" : e === "none" ? "invisible" : "inline";
203
204
  n.push({
204
205
  node: i,
205
206
  childIndex: r,
@@ -209,8 +210,8 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
209
210
  });
210
211
  continue;
211
212
  }
212
- if (!j(i) || !t.allowsText) continue;
213
- let e = T(i.data);
213
+ if (!A(i) || !t.allowsText) continue;
214
+ let e = D(i.data);
214
215
  e && (t.block && !t.pre && n.length === 0 || t.trimsText) || n.push({
215
216
  node: i,
216
217
  childIndex: r,
@@ -220,19 +221,19 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
220
221
  });
221
222
  }
222
223
  return n;
223
- }, M = (e) => e.role === "inline" || e.role === "text", N = (e) => e !== void 0 && e.role === "text" && e.whitespace, ce = (e, t) => {
224
+ }, j = (e) => e.role === "inline" || e.role === "text", M = (e) => e !== void 0 && e.role === "text" && e.whitespace, ue = (e, t) => {
224
225
  let n = () => e.map((e) => ({
225
226
  kind: "node",
226
227
  child: e
227
228
  }));
228
229
  if (t.display === "block" || t.display === "inlineBlock") {
229
- let r = e.some((e) => e.role === "block"), i = e.some(M);
230
+ let r = e.some((e) => e.role === "block"), i = e.some(j);
230
231
  if (!r || !i) return n();
231
232
  let a = [], o = 0;
232
233
  for (; o < e.length;) {
233
234
  let n = e[o];
234
235
  if (!n) break;
235
- if (!M(n)) {
236
+ if (!j(n)) {
236
237
  a.push({
237
238
  kind: "node",
238
239
  child: n
@@ -242,14 +243,14 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
242
243
  let r = o;
243
244
  for (; r < e.length;) {
244
245
  let t = e[r];
245
- if (!t || !M(t)) break;
246
+ if (!t || !j(t)) break;
246
247
  r++;
247
248
  }
248
249
  let i = e.slice(o, r);
249
250
  if (!t.pre) {
250
251
  let e = 0;
251
- for (; e < i.length && N(i[e]);) e++;
252
- i = i.slice(e), i.length > 0 && N(i[i.length - 1]) && (i = i.slice(0, -1));
252
+ for (; e < i.length && M(i[e]);) e++;
253
+ i = i.slice(e), i.length > 0 && M(i[i.length - 1]) && (i = i.slice(0, -1));
253
254
  }
254
255
  i.length > 0 && a.push({
255
256
  kind: "box",
@@ -266,20 +267,20 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
266
267
  return e.forEach((t, n) => {
267
268
  if (t.role !== "block") return;
268
269
  let r = e[n - 1], a = e[n + 1];
269
- r && N(r) && i.add(r), a && N(a) && i.add(a);
270
+ r && M(r) && i.add(r), a && M(a) && i.add(a);
270
271
  }), e.filter((e) => !i.has(e)).map((e) => ({
271
272
  kind: "node",
272
273
  child: e
273
274
  }));
274
275
  }
275
276
  return n();
276
- }, P = (e, t) => ce(se(e, t), t), F = (e, t, n) => {
277
- if (h(e.node)) return n({
277
+ }, N = (e, t) => ue(le(e, t), t), P = (e, t, n) => {
278
+ if (g(e.node)) return n({
278
279
  kind: "element",
279
280
  node: e.node,
280
281
  childIndex: e.childIndex
281
282
  });
282
- let r = O(e.node.data);
283
+ let r = oe(e.node.data);
283
284
  for (let i = 0; i < r.length; i++) {
284
285
  let a = r[i];
285
286
  if (a && !n({
@@ -298,29 +299,29 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
298
299
  })) return !1;
299
300
  }
300
301
  return !0;
301
- }, I = (e, t, n = v(e)) => {
302
- for (let r of P(e, n)) {
302
+ }, F = (e, t, n = x(e)) => {
303
+ for (let r of N(e, n)) {
303
304
  let e = r.kind === "box" ? r.children : [r.child];
304
- for (let r of e) if (!F(r, n, t)) return;
305
+ for (let r of e) if (!P(r, n, t)) return;
305
306
  }
306
- }, L = (e, t = v(e)) => {
307
+ }, I = (e, t = x(e)) => {
307
308
  let n = [];
308
- for (let r of P(e, t)) {
309
+ for (let r of N(e, t)) {
309
310
  if (r.kind === "box") {
310
311
  let e = r.children[0], i = r.children[r.children.length - 1];
311
- e && i && F(e, t, (e) => (n.push({
312
+ e && i && P(e, t, (e) => (n.push({
312
313
  child: e,
313
314
  lastChildIndex: i.childIndex
314
315
  }), !1));
315
316
  continue;
316
317
  }
317
- F(r.child, t, (e) => (n.push({
318
+ P(r.child, t, (e) => (n.push({
318
319
  child: e,
319
320
  lastChildIndex: e.childIndex
320
321
  }), !0));
321
322
  }
322
323
  return n;
323
- }, R = (e) => e.body ?? void 0, z = (e) => {
324
+ }, L = (e) => e.body ?? void 0, R = (e) => {
324
325
  let t = `/body/DocFragment[${e.spineItemIndex + 1}]/body`;
325
326
  for (let n of e.steps) if (n.kind === "nodeIndex") t += `/${n.index}`;
326
327
  else {
@@ -328,30 +329,30 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
328
329
  t += n.index === void 0 ? `/${e}` : `/${e}[${n.index}]`;
329
330
  }
330
331
  return e.point === void 0 ? t : `${t}.${e.point}`;
331
- }, B = 9, V = (e) => e.nodeType === B, H = (e, t, n) => {
332
- let r = g(t, n), i, a = 0;
333
- if (I(e, (e) => e.kind !== "element" || g(e.node, n) !== r || (a++, e.node === t && (i = a), i === void 0 || a === 1)), i !== void 0) return {
332
+ }, z = 9, B = (e) => e.nodeType === z, V = (e, t, n) => {
333
+ let r = _(t, n), i, a = 0;
334
+ if (F(e, (e) => e.kind !== "element" || _(e.node, n) !== r || (a++, e.node === t && (i = a), i === void 0 || a === 1)), i !== void 0) return {
334
335
  kind: "element",
335
336
  name: r,
336
337
  index: a > 1 ? i : void 0
337
338
  };
338
- }, U = (e, t) => {
339
+ }, H = (e, t) => {
339
340
  let n = [], r = e;
340
341
  for (; r !== t;) {
341
- if (!r || !h(r)) return;
342
+ if (!r || !g(r)) return;
342
343
  n.push(r), r = r.parentNode;
343
344
  }
344
345
  n.reverse();
345
346
  let i = [], a = t, o = !1;
346
347
  for (let e of n) {
347
- let t = H(a, e, o);
348
+ let t = V(a, e, o);
348
349
  if (!t) return;
349
350
  i.push(t), e.localName.toLowerCase() === "svg" && (o = !0), a = e;
350
351
  }
351
352
  return i;
352
- }, W = (e, t, n) => {
353
+ }, U = (e, t, n) => {
353
354
  let r, i = 0, a = 0;
354
- if (I(e, (e) => {
355
+ if (F(e, (e) => {
355
356
  if (e.kind !== "text") return !0;
356
357
  if (a++, r === void 0 && e.node === t) {
357
358
  let t = e.pieceIndex === e.pieceCount - 1;
@@ -363,42 +364,42 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
363
364
  index: i,
364
365
  count: a
365
366
  };
366
- }, le = (e, t) => {
367
- let n = v(e), r = 0;
368
- for (let { child: i, lastChildIndex: a } of L(e, n)) {
367
+ }, de = (e, t) => {
368
+ let n = x(e), r = 0;
369
+ for (let { child: i, lastChildIndex: a } of I(e, n)) {
369
370
  if (i.childIndex >= t || t <= a) break;
370
371
  r++;
371
372
  }
372
- return (n.restructured || te(e)) && r > 0 ? void 0 : r;
373
- }, G = (e, t) => {
373
+ return (n.restructured || ne(e)) && r > 0 ? void 0 : r;
374
+ }, W = (e, t) => {
374
375
  if (!Number.isInteger(t) || t < 0) return;
375
- let { node: n, offset: r } = e, i = V(n) ? n : n.ownerDocument;
376
+ let { node: n, offset: r } = e, i = B(n) ? n : n.ownerDocument;
376
377
  if (!i) return;
377
- let a = R(i), o = (e, n) => e === void 0 ? void 0 : z({
378
+ let a = L(i), o = (e, n) => e === void 0 ? void 0 : R({
378
379
  spineItemIndex: t,
379
380
  steps: e,
380
381
  point: n,
381
382
  containsBoxingElements: !1
382
383
  });
383
- if (!a) return V(n) || n === i.documentElement ? o([], void 0) : void 0;
384
- if (V(n)) return;
385
- if (j(n)) {
384
+ if (!a) return B(n) || n === i.documentElement ? o([], void 0) : void 0;
385
+ if (B(n)) return;
386
+ if (A(n)) {
386
387
  let e = n.parentNode, t = r ?? 0;
387
- if (!e || !h(e) || t < 0 || t > n.data.length) return;
388
- let i = W(e, n, t);
388
+ if (!e || !g(e) || t < 0 || t > n.data.length) return;
389
+ let i = U(e, n, t);
389
390
  if (!i) return;
390
- let { piece: s } = i, c = U(e, a);
391
+ let { piece: s } = i, c = H(e, a);
391
392
  return c ? (c.push({
392
393
  kind: "text",
393
394
  index: i.count > 1 ? i.index : void 0
394
- }), o(c, ae(n.data.slice(s.start, s.end), t - s.start, s.mode))) : void 0;
395
+ }), o(c, ie(n.data.slice(s.start, s.end), t - s.start, s.mode))) : void 0;
395
396
  }
396
- if (!h(n)) return;
397
- if (r === void 0) return o(U(n, a), void 0);
397
+ if (!g(n)) return;
398
+ if (r === void 0) return o(H(n, a), void 0);
398
399
  if (r < 0 || r > n.childNodes.length) return;
399
- let s = le(n, r);
400
- return s === void 0 ? void 0 : o(U(n, a), s);
401
- }, K = [
400
+ let s = de(n, r);
401
+ return s === void 0 ? void 0 : o(H(n, a), s);
402
+ }, G = [
402
403
  "autoBoxing",
403
404
  "tabularBox",
404
405
  "rubyBox",
@@ -406,16 +407,16 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
406
407
  "floatBox",
407
408
  "inlineBox",
408
409
  "pseudoElem"
409
- ], ue = new Set(K.map((e) => e.toLowerCase())), q = (e) => e >= 48 && e <= 57, de = /^[A-Za-z_][A-Za-z0-9_:-]*$/, J = (e) => e === void 0 || e === "/" || e === ".", Y = (e, t) => {
410
+ ], fe = new Set(G.map((e) => e.toLowerCase())), K = (e) => e >= 48 && e <= 57, pe = /^[A-Za-z_][A-Za-z0-9_:-]*$/, q = (e) => e === void 0 || e === "/" || e === ".", J = (e, t) => {
410
411
  let n = t;
411
- for (; n < e.length && q(e.charCodeAt(n));) n++;
412
+ for (; n < e.length && K(e.charCodeAt(n));) n++;
412
413
  return n;
413
- }, fe = (e) => {
414
+ }, me = (e) => {
414
415
  let t = [], n = 0;
415
416
  for (; n < e.length;) {
416
417
  let r = e[n];
417
418
  if (r === ".") {
418
- let r = n + 1, i = Y(e, r);
419
+ let r = n + 1, i = J(e, r);
419
420
  return i === r || i !== e.length ? void 0 : {
420
421
  steps: t,
421
422
  point: Number(e.slice(r, i))
@@ -423,9 +424,9 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
423
424
  }
424
425
  if (r !== "/") return;
425
426
  let i = n + 1;
426
- if (q(e.charCodeAt(i))) {
427
- let r = Y(e, i);
428
- if (!J(e[r])) return;
427
+ if (K(e.charCodeAt(i))) {
428
+ let r = J(e, i);
429
+ if (!q(e[r])) return;
429
430
  let a = Number(e.slice(i, r));
430
431
  if (a < 1) return;
431
432
  t.push({
@@ -442,15 +443,15 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
442
443
  let t = e.indexOf("]", a + 1);
443
444
  if (t === -1) return;
444
445
  let n = e.slice(a + 1, t);
445
- if (n.length === 0 || Y(n, 0) !== n.length || (s = Number(n), s < 1)) return;
446
+ if (n.length === 0 || J(n, 0) !== n.length || (s = Number(n), s < 1)) return;
446
447
  c = t + 1;
447
448
  }
448
- if (!J(e[c])) return;
449
+ if (!q(e[c])) return;
449
450
  if (o === "text()") t.push({
450
451
  kind: "text",
451
452
  index: s
452
453
  });
453
- else if (de.test(o)) t.push({
454
+ else if (pe.test(o)) t.push({
454
455
  kind: "element",
455
456
  name: o,
456
457
  index: s
@@ -462,11 +463,11 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
462
463
  steps: t,
463
464
  point: void 0
464
465
  };
465
- }, X = (e, t) => e?.kind === "element" && e.name.toLowerCase() === t, Z = (e) => {
466
- let t = fe(e);
466
+ }, Y = (e, t) => e?.kind === "element" && e.name.toLowerCase() === t, X = (e) => {
467
+ let t = me(e);
467
468
  if (!t) return;
468
469
  let [n, r, i, ...a] = t.steps;
469
- if (!X(n, "body") || (n.index ?? 1) !== 1 || !X(r, "docfragment")) return;
470
+ if (!Y(n, "body") || (n.index ?? 1) !== 1 || !Y(r, "docfragment")) return;
470
471
  let o = (r.index ?? 1) - 1;
471
472
  if (i === void 0) return {
472
473
  spineItemIndex: o,
@@ -474,16 +475,16 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
474
475
  point: void 0,
475
476
  containsBoxingElements: !1
476
477
  };
477
- if (X(i, "body") && (i.index ?? 1) === 1) return {
478
+ if (Y(i, "body") && (i.index ?? 1) === 1) return {
478
479
  spineItemIndex: o,
479
480
  steps: a,
480
481
  point: t.point,
481
- containsBoxingElements: a.some((e) => e.kind === "element" && ue.has(e.name.toLowerCase()))
482
+ containsBoxingElements: a.some((e) => e.kind === "element" && fe.has(e.name.toLowerCase()))
482
483
  };
483
- }, pe = (e, t) => {
484
+ }, he = (e, t) => {
484
485
  let n = t.index ?? 1, r = t.kind === "element" ? t.name.toLowerCase() : void 0, i = 0, a;
485
- return I(e, (e) => t.kind === "nodeIndex" || (t.kind === "text" ? e.kind === "text" : e.kind === "element" && e.node.localName.toLowerCase() === r) ? (i++, i !== n || (a = e, !1)) : !0), a;
486
- }, me = (e, t, n) => {
486
+ return F(e, (e) => t.kind === "nodeIndex" || (t.kind === "text" ? e.kind === "text" : e.kind === "element" && e.node.localName.toLowerCase() === r) ? (i++, i !== n || (a = e, !1)) : !0), a;
487
+ }, Z = (e, t, n) => {
487
488
  let r = t[n]?.child;
488
489
  return r ? r.kind === "text" && r.pieceIndex > 0 ? {
489
490
  node: r.node,
@@ -496,9 +497,9 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
496
497
  offset: e.childNodes.length
497
498
  };
498
499
  }, Q = (e, t) => {
499
- let n = typeof e == "string" ? Z(e) : e;
500
+ let n = typeof e == "string" ? X(e) : e;
500
501
  if (!n || n.containsBoxingElements) return;
501
- let r = R(t);
502
+ let r = L(t);
502
503
  if (!r) return n.steps.length === 0 ? { node: t.documentElement } : void 0;
503
504
  let i = {
504
505
  kind: "parent",
@@ -506,7 +507,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
506
507
  };
507
508
  for (let e of n.steps) {
508
509
  if (i.kind === "text") return;
509
- let t = pe(i.node, e);
510
+ let t = he(i.node, e);
510
511
  if (!t) return;
511
512
  i = t.kind === "element" ? {
512
513
  kind: "parent",
@@ -518,7 +519,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
518
519
  node: i.node,
519
520
  offset: i.start
520
521
  };
521
- let e = oe(i.node.data.slice(i.start, i.end), n.point, i.mode);
522
+ let e = ae(i.node.data.slice(i.start, i.end), n.point, i.mode);
522
523
  return e === void 0 ? void 0 : {
523
524
  node: i.node,
524
525
  offset: i.start + e
@@ -526,24 +527,24 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
526
527
  }
527
528
  let a = i.node;
528
529
  if (n.point === void 0) return { node: a };
529
- let o = L(a);
530
- if (!(n.point > o.length)) return me(a, o, n.point);
530
+ let o = I(a);
531
+ if (!(n.point > o.length)) return Z(a, o, n.point);
531
532
  }, $ = (e) => {
532
533
  let { node: t, offset: n } = e;
533
- if (!h(t) || n === void 0) return e;
534
+ if (!g(t) || n === void 0) return e;
534
535
  let r = t.childNodes[n];
535
- if (r) return j(r) ? {
536
+ if (r) return A(r) ? {
536
537
  node: r,
537
538
  offset: 0
538
539
  } : { node: r };
539
540
  let i = t.lastChild;
540
- return i && j(i) ? {
541
+ return i && A(i) ? {
541
542
  node: i,
542
543
  offset: i.data.length
543
544
  } : { node: t };
544
- }, he = (t, n) => {
545
+ }, ge = (t, n) => {
545
546
  try {
546
- let r = typeof t == "string" ? Z(t) : t;
547
+ let r = typeof t == "string" ? X(t) : t;
547
548
  if (!r) return;
548
549
  let i = n(r.spineItemIndex);
549
550
  if (!i) return;
@@ -552,21 +553,21 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
552
553
  let { node: o, offset: s } = $(a);
553
554
  return e({
554
555
  node: o,
555
- offset: j(o) ? s : void 0,
556
+ offset: A(o) ? s : void 0,
556
557
  spineIndex: r.spineItemIndex,
557
558
  spineId: i.id
558
559
  });
559
560
  } catch {
560
561
  return;
561
562
  }
562
- }, ge = (e) => Array.isArray(e) ? e[0] : e, _e = (e, a) => {
563
+ }, _e = (e) => Array.isArray(e) ? e[0] : e, ve = (e, a) => {
563
564
  try {
564
565
  let o = t(e);
565
566
  if (!o) return;
566
567
  let { spineIndex: s } = o;
567
568
  if (!Number.isInteger(s) || s < 0) return;
568
569
  let c = r(e);
569
- if (n(c)) return z({
570
+ if (n(c)) return R({
570
571
  spineItemIndex: s,
571
572
  steps: [],
572
573
  point: void 0,
@@ -575,18 +576,34 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
575
576
  let l = a(s);
576
577
  if (!l) return;
577
578
  let u = i(c, l.document);
578
- return u.node ? G(u.isRange ? {
579
+ return u.node ? W(u.isRange ? {
579
580
  node: u.node.startContainer,
580
581
  offset: u.node.startOffset
581
582
  } : {
582
583
  node: u.node,
583
- offset: j(u.node) ? ge(u.offset) ?? 0 : void 0
584
+ offset: A(u.node) ? _e(u.offset) ?? 0 : void 0
584
585
  }, s) : void 0;
585
586
  } catch {
586
587
  return;
587
588
  }
588
- };
589
+ }, ye = 1024, be = [
590
+ 0,
591
+ 1024,
592
+ 4096,
593
+ 16384,
594
+ 65536,
595
+ 262144,
596
+ 1048576,
597
+ 4194304,
598
+ 16777216,
599
+ 67108864,
600
+ 268435456,
601
+ 1073741824
602
+ ], xe = async (e) => {
603
+ let t = await Promise.all(be.filter((t) => t < e.size).map(async (t) => new Uint8Array(await e.slice(t, t + ye).arrayBuffer())));
604
+ return a(t);
605
+ }, Se = (e) => a([new TextEncoder().encode(e)]);
589
606
  //#endregion
590
- export { y as CRENGINE_TEXT_SPLIT_SIZE, K as XPOINTER_BOXING_ELEMENT_NAMES, _e as cfiToXPointer, G as generateXPointer, Z as parseXPointer, Q as resolveXPointer, z as serializeXPointer, $ as toCfiPosition, he as xPointerToCfi };
607
+ export { re as CRENGINE_TEXT_SPLIT_SIZE, G as XPOINTER_BOXING_ELEMENT_NAMES, ve as cfiToXPointer, W as generateXPointer, xe as getKoreaderFileDigest, Se as getKoreaderFileNameDigest, X as parseXPointer, Q as resolveXPointer, R as serializeXPointer, $ as toCfiPosition, ge as xPointerToCfi };
591
608
 
592
609
  //# sourceMappingURL=index.js.map