@prose-reader/archive-reader 1.346.0 → 1.348.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.
@@ -97,7 +97,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
97
97
  data: t,
98
98
  basePath: t?.uri.substring(0, t.uri.lastIndexOf("/")) || ""
99
99
  };
100
- }, k = (e) => e === void 0 || e.trim().length === 0 ? [] : e.trim().split(/\s+/).filter((e) => e.length > 0), ee = (e) => {
100
+ }, k = (e) => e === void 0 || e.trim().length === 0 ? [] : e.trim().split(/\s+/).filter((e) => e.length > 0), A = (e) => {
101
101
  let t = k(e);
102
102
  if (t.length === 0) return {};
103
103
  let n;
@@ -109,16 +109,16 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
109
109
  ...t.includes("page-spread-left") ? { pageSpreadLeft: !0 } : {},
110
110
  ...t.includes("page-spread-right") ? { pageSpreadRight: !0 } : {}
111
111
  };
112
- }, A = (e) => e.includes(":") ? e.slice(e.lastIndexOf(":") + 1) : e, te = (e, t) => A(e).toLowerCase() === t.toLowerCase(), j = (e) => e.type === "element", M = (e, t) => {
113
- for (let n of e.children) if (j(n) && te(n.name, t)) return n;
114
- }, N = (e, t) => {
112
+ }, j = (e) => e.includes(":") ? e.slice(e.lastIndexOf(":") + 1) : e, M = (e, t) => j(e).toLowerCase() === t.toLowerCase(), ee = (e) => e.type === "element", N = (e, t) => {
113
+ for (let n of e.children) if (ee(n) && M(n.name, t)) return n;
114
+ }, P = (e, t) => {
115
115
  let n = [];
116
- for (let r of e.children) j(r) && te(r.name, t) && n.push(r);
116
+ for (let r of e.children) ee(r) && M(r.name, t) && n.push(r);
117
117
  return n;
118
- }, ne = (e, t) => {
118
+ }, te = (e, t) => {
119
119
  let n = [];
120
120
  return e.eachChild((e) => {
121
- if (A(e.name).toLowerCase() !== "identifier") return;
121
+ if (j(e.name).toLowerCase() !== "identifier") return;
122
122
  let r = e.val.trim();
123
123
  if (r.length === 0) return;
124
124
  let i = (e.attr["opf:scheme"] ?? e.attr["opf:Scheme"] ?? e.attr.scheme)?.trim(), a = e.attr.id?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0;
@@ -129,10 +129,10 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
129
129
  ...o !== void 0 && o === t ? { unique: !0 } : {}
130
130
  });
131
131
  }), n;
132
- }, re = (e) => {
132
+ }, ne = (e) => {
133
133
  let t = [];
134
134
  return e.eachChild((e) => {
135
- if (A(e.name).toLowerCase() !== "title") return;
135
+ if (j(e.name).toLowerCase() !== "title") return;
136
136
  let n = e.val.trim();
137
137
  if (n.length === 0) return;
138
138
  let r = e.attr.id?.trim();
@@ -141,46 +141,46 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
141
141
  ...r !== void 0 && r.length > 0 ? { id: r } : {}
142
142
  });
143
143
  }), t;
144
- }, P = (e, t) => {
144
+ }, F = (e, t) => {
145
145
  let n;
146
146
  return e.eachChild((e) => {
147
- if (n !== void 0 || A(e.name).toLowerCase() !== t.toLowerCase()) return;
147
+ if (n !== void 0 || j(e.name).toLowerCase() !== t.toLowerCase()) return;
148
148
  let r = e.val.trim();
149
149
  r.length > 0 && (n = r);
150
150
  }), n;
151
- }, F = (e, t) => {
151
+ }, I = (e, t) => {
152
152
  let n = [];
153
153
  return e.eachChild((e) => {
154
- if (A(e.name).toLowerCase() !== t.toLowerCase()) return;
154
+ if (j(e.name).toLowerCase() !== t.toLowerCase()) return;
155
155
  let r = e.val.trim();
156
156
  r.length > 0 && n.push(r);
157
157
  }), n;
158
- }, ie = (e) => {
158
+ }, re = (e) => {
159
159
  let t;
160
160
  return e.eachChild((e) => {
161
- if (t !== void 0 || A(e.name).toLowerCase() !== "meta" || e.attr.name?.toLowerCase() !== "cover") return;
161
+ if (t !== void 0 || j(e.name).toLowerCase() !== "meta" || e.attr.name?.toLowerCase() !== "cover") return;
162
162
  let n = e.attr.content?.trim();
163
163
  n !== void 0 && n.length > 0 && (t = n);
164
164
  }), t;
165
- }, ae = ({ manifestItems: e, metadataEl: t }) => {
165
+ }, ie = ({ manifestItems: e, metadataEl: t }) => {
166
166
  let n = (e) => e.mediaType?.toLowerCase().includes("image/") === !0, r = e.find((e) => n(e) ? k(e.properties).includes("cover-image") : !1);
167
167
  if (r !== void 0) return r.href;
168
168
  if (t !== void 0) {
169
- let r = ie(t);
169
+ let r = re(t);
170
170
  if (r !== void 0) {
171
171
  let t = e.find((e) => e.id === r && n(e));
172
172
  if (t !== void 0) return t.href;
173
173
  }
174
174
  }
175
175
  return e.find((e) => e.id.toLowerCase().includes("cover") && n(e))?.href;
176
- }, I = (e, t) => {
176
+ }, L = (e, t) => {
177
177
  let n = e.attr[t]?.trim();
178
178
  return n !== void 0 && n.length > 0 ? n : void 0;
179
- }, oe = (e) => {
179
+ }, ae = (e) => {
180
180
  let t = [];
181
181
  return e.eachChild((e) => {
182
- if (A(e.name).toLowerCase() !== "meta") return;
183
- let n = I(e, "property"), r = I(e, "refines"), i = I(e, "scheme"), a = I(e, "id"), o = I(e, "name"), s = I(e, "content"), c = e.val.trim(), l = c.length > 0 ? c : void 0, u = {
182
+ if (j(e.name).toLowerCase() !== "meta") return;
183
+ let n = L(e, "property"), r = L(e, "refines"), i = L(e, "scheme"), a = L(e, "id"), o = L(e, "name"), s = L(e, "content"), c = e.val.trim(), l = c.length > 0 ? c : void 0, u = {
184
184
  ...n === void 0 ? {} : { property: n },
185
185
  ...r === void 0 ? {} : { refines: r },
186
186
  ...i === void 0 ? {} : { scheme: i },
@@ -191,14 +191,14 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
191
191
  };
192
192
  Object.keys(u).length !== 0 && t.push(u);
193
193
  }), t;
194
- }, se = (e, t) => e.replace(/^#/, "") === t, ce = (e, t) => {
194
+ }, oe = (e, t) => e.replace(/^#/, "") === t, se = (e, t) => {
195
195
  let n = [];
196
196
  return e.eachChild((e) => {
197
- let r = A(e.name).toLowerCase();
197
+ let r = j(e.name).toLowerCase();
198
198
  if (r !== "creator" && r !== "contributor") return;
199
199
  let i = e.val.trim();
200
200
  if (i.length === 0) return;
201
- let a = I(e, "id"), o = (e) => a === void 0 ? [] : t.flatMap((t) => t.refines !== void 0 && se(t.refines, a) && t.property === e && t.value !== void 0 ? [t.value] : []), s = I(e, "opf:role") ?? I(e, "role"), c = [...s === void 0 ? [] : [s], ...o("role")], l = I(e, "opf:file-as") ?? I(e, "file-as") ?? o("file-as")[0];
201
+ let a = L(e, "id"), o = (e) => a === void 0 ? [] : t.flatMap((t) => t.refines !== void 0 && oe(t.refines, a) && t.property === e && t.value !== void 0 ? [t.value] : []), s = L(e, "opf:role") ?? L(e, "role"), c = [...s === void 0 ? [] : [s], ...o("role")], l = L(e, "opf:file-as") ?? L(e, "file-as") ?? o("file-as")[0];
202
202
  n.push({
203
203
  name: i,
204
204
  source: r,
@@ -207,14 +207,14 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
207
207
  ...l === void 0 ? {} : { fileAs: l }
208
208
  });
209
209
  }), n;
210
- }, L = (e, t) => {
211
- let n = N(e, "meta").find((e) => e.attr.property === t)?.val;
210
+ }, R = (e, t) => {
211
+ let n = P(e, "meta").find((e) => e.attr.property === t)?.val;
212
212
  if (!(n === void 0 || n.trim().length === 0)) return n;
213
- }, le = (e) => {
214
- let t = M(e, "guide");
213
+ }, ce = (e) => {
214
+ let t = N(e, "guide");
215
215
  if (t === void 0) return [];
216
216
  let n = [];
217
- for (let e of N(t, "reference")) {
217
+ for (let e of P(t, "reference")) {
218
218
  let t = e.attr.href?.trim();
219
219
  t === void 0 || t.length === 0 || n.push({
220
220
  href: t,
@@ -223,7 +223,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
223
223
  });
224
224
  }
225
225
  return n;
226
- }, ue = (e) => {
226
+ }, le = (e) => {
227
227
  let t = e.attr.id, n = e.attr.href;
228
228
  if (t === void 0 || t.length === 0 || n === void 0 || n.length === 0) return;
229
229
  let r = e.attr["media-type"], i = e.attr.properties?.trim();
@@ -233,24 +233,24 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
233
233
  ...r !== void 0 && r.length > 0 ? { mediaType: r } : {},
234
234
  ...i !== void 0 && i.length > 0 ? { properties: i } : {}
235
235
  };
236
- }, de = (e) => {
236
+ }, ue = (e) => {
237
237
  let t = [], n = /* @__PURE__ */ new Map();
238
- for (let r of N(e, "item")) {
239
- let e = ue(r);
238
+ for (let r of P(e, "item")) {
239
+ let e = le(r);
240
240
  e !== void 0 && (t.push(e), n.set(e.id, e));
241
241
  }
242
242
  return {
243
243
  items: t,
244
244
  byId: n
245
245
  };
246
- }, fe = (e, t) => {
246
+ }, de = (e, t) => {
247
247
  let n = [];
248
- for (let r of N(t, "itemref")) {
248
+ for (let r of P(t, "itemref")) {
249
249
  let t = r.attr.idref;
250
250
  if (t === void 0 || t.trim().length === 0) continue;
251
251
  let i = e.get(t);
252
252
  if (i === void 0) continue;
253
- let a = ee(r.attr.properties);
253
+ let a = A(r.attr.properties);
254
254
  n.push({
255
255
  idref: t,
256
256
  id: i.id,
@@ -264,18 +264,18 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
264
264
  });
265
265
  }
266
266
  return n;
267
- }, pe = (e) => {
268
- let t = new h(e), n = M(t, "manifest"), r = M(t, "spine"), i = M(t, "metadata"), a = t.attr["unique-identifier"]?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0, s = [], c = [];
267
+ }, fe = (e) => {
268
+ let t = new h(e), n = N(t, "manifest"), r = N(t, "spine"), i = N(t, "metadata"), a = t.attr["unique-identifier"]?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0, s = [], c = [];
269
269
  if (n !== void 0) {
270
- let { items: e, byId: t } = de(n);
271
- s = e, r !== void 0 && (c = fe(t, r));
270
+ let { items: e, byId: t } = ue(n);
271
+ s = e, r !== void 0 && (c = de(t, r));
272
272
  }
273
273
  let l = r?.attr["page-progression-direction"], u = l !== void 0 && l.trim().length > 0 ? l : void 0, d = r?.attr.toc, f = d !== void 0 && d.trim().length > 0 ? d.trim() : void 0, p = [], m, g, _, v, y = [], b = [], x = [], S = [], C, w, T, E = [], D = [];
274
- i !== void 0 && (p = re(i), m = P(i, "publisher"), g = P(i, "description"), _ = P(i, "rights"), v = P(i, "date"), y = F(i, "creator"), x = F(i, "language"), S = F(i, "subject"), C = L(i, "rendition:layout"), w = L(i, "rendition:flow"), T = L(i, "rendition:spread"), E = oe(i), b = ce(i, E), D.push(...ne(i, o)));
275
- let O = ae({
274
+ i !== void 0 && (p = ne(i), m = F(i, "publisher"), g = F(i, "description"), _ = F(i, "rights"), v = F(i, "date"), y = I(i, "creator"), x = I(i, "language"), S = I(i, "subject"), C = R(i, "rendition:layout"), w = R(i, "rendition:flow"), T = R(i, "rendition:spread"), E = ae(i), b = se(i, E), D.push(...te(i, o)));
275
+ let O = ie({
276
276
  manifestItems: s,
277
277
  metadataEl: i
278
- }), k = le(t);
278
+ }), k = ce(t);
279
279
  return {
280
280
  kind: "opf",
281
281
  manifestItems: s,
@@ -302,25 +302,25 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
302
302
  };
303
303
  //#endregion
304
304
  //#region src/metadata/opf/readArchiveOpf.ts
305
- async function R(e) {
305
+ async function z(e) {
306
306
  let { data: t, basePath: n } = O(e) || {};
307
307
  if (!(!t || t.dir)) return {
308
- opf: pe(await D(t)),
308
+ opf: fe(await D(t)),
309
309
  basePath: n
310
310
  };
311
311
  }
312
312
  //#endregion
313
313
  //#region src/metadata/apple/parse.ts
314
- var z = "com.apple.ibooks.display-options.xml", me = (e) => e.childrenNamed("option").map((e) => ({
314
+ var B = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("option").map((e) => ({
315
315
  name: e.attr?.name,
316
316
  value: e.val
317
- })), B = (e) => {
317
+ })), me = (e) => {
318
318
  let t = new h(e);
319
319
  if (t.name?.toLowerCase() !== "display_options") return { kind: "apple" };
320
320
  let n = t.childNamed("platform");
321
321
  return {
322
322
  kind: "apple",
323
- displayOptions: { ...n === void 0 ? {} : { platform: { options: me(n) } } }
323
+ displayOptions: { ...n === void 0 ? {} : { platform: { options: pe(n) } } }
324
324
  };
325
325
  }, V = "ComicInfo.xml", he = /* @__PURE__ */ "AgeRating.AlternateCount.AlternateNumber.AlternateSeries.BlackAndWhite.Characters.Colorist.CommunityRating.Count.CoverArtist.Day.Editor.Format.Genre.GTIN.Imprint.Inker.LanguageISO.Letterer.Locations.MainCharacterOrTeam.Manga.Month.Notes.Number.PageCount.Penciller.Publisher.Review.ScanInformation.Series.SeriesGroup.StoryArc.StoryArcNumber.Summary.Tags.Teams.Title.Translator.Volume.Web.Writer.Year".split("."), ge = /* @__PURE__ */ new Set(["Pages", "ComicInfo"]), _e = (e) => e.children.some((e) => e.type === "element"), ve = (e) => {
326
326
  let t = e.val.trim();
@@ -389,7 +389,7 @@ var z = "com.apple.ibooks.display-options.xml", me = (e) => e.childrenNamed("opt
389
389
  pageSpreadRight: e.pageSpreadRight,
390
390
  progressionWeight: a > 0 ? (i?.size ?? 0) / a : 1 / t.spineRows.length
391
391
  }));
392
- }, De = V.toLowerCase(), Oe = z.toLowerCase(), ke = (e) => {
392
+ }, De = V.toLowerCase(), Oe = B.toLowerCase(), ke = (e) => {
393
393
  let t = e.basename.toLowerCase();
394
394
  return t === De || t === Oe || e.uri.endsWith("com.kobobooks.display-options.xml") || t.endsWith(".db");
395
395
  }, Ae = (e) => {
@@ -405,13 +405,13 @@ var z = "com.apple.ibooks.display-options.xml", me = (e) => e.childrenNamed("opt
405
405
  });
406
406
  });
407
407
  }, U = async (e, { opf: t } = {}) => {
408
- let n = t ?? await R(e).catch(() => void 0);
408
+ let n = t ?? await z(e).catch(() => void 0);
409
409
  return n ? Ee(e, n) : Ae(e);
410
410
  }, je = (e, t) => {
411
411
  let n = C(e, t);
412
412
  if (n !== void 0) return f(n.encodingFormat ?? "") || o(n.basename);
413
- }, Me = async (e, { opf: t, readingOrder: n } = {}) => {
414
- let r = t ?? await R(e).catch(() => void 0);
413
+ }, W = async (e, { opf: t, readingOrder: n } = {}) => {
414
+ let r = t ?? await z(e).catch(() => void 0);
415
415
  if (r !== void 0 && r.opf.coverHref !== void 0) {
416
416
  let t = we(r.opf.coverHref, r.basePath);
417
417
  return H({
@@ -426,10 +426,10 @@ var z = "com.apple.ibooks.display-options.xml", me = (e) => e.childrenNamed("opt
426
426
  mediaType: i.mediaType,
427
427
  confidence: "assumed"
428
428
  });
429
- }, Ne = (e) => {
429
+ }, Me = (e) => {
430
430
  let t = e.descendantWithPath("head")?.childrenNamed("meta").find((e) => e.attr.name === "viewport");
431
431
  return !!(t && t.attr.name === "viewport");
432
- }, Pe = async (e, n) => {
432
+ }, Ne = async (e, n) => {
433
433
  if (n.length === 0) return !1;
434
434
  for (let r of n) {
435
435
  if (!d({
@@ -439,93 +439,73 @@ var z = "com.apple.ibooks.display-options.xml", me = (e) => e.childrenNamed("opt
439
439
  let n = C(e, r.uri);
440
440
  if (!n || !x(n)) return !1;
441
441
  try {
442
- if (!Ne(new h(await D(n)))) return !1;
442
+ if (!Me(new h(await D(n)))) return !1;
443
443
  } catch (e) {
444
444
  return t.error(`layout scan: unable to inspect ${r.uri}`, e), !1;
445
445
  }
446
446
  }
447
447
  return !0;
448
- }, Fe = z.toLowerCase();
449
- async function Ie(e) {
450
- let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Fe);
451
- if (t) return B(await D(t));
448
+ }, Pe = B.toLowerCase();
449
+ async function Fe(e) {
450
+ let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Pe);
451
+ if (t) return me(await D(t));
452
452
  }
453
453
  //#endregion
454
- //#region src/metadata/apple/resolve.ts
455
- var Le = { displayOptions: "apple.options" }, Re = (e) => {
456
- let t = e.displayOptions?.platform?.options, n = t?.find((e) => e.name === "fixed-layout")?.value.trim().toLowerCase(), r = n === "true" || n !== "false" && void 0, i = H({
457
- fixedLayout: r,
458
- options: t !== void 0 && t.length > 0 ? t.map(({ name: e, value: t }) => H({
459
- name: e,
460
- value: t
461
- })) : void 0
462
- });
463
- return H({
464
- renditionLayout: r === !0 ? "pre-paginated" : void 0,
465
- apple: Object.keys(i).length > 0 ? i : void 0
466
- });
467
- }, ze = V.toLowerCase(), W = (e) => e.records.find((e) => x(e) && e.basename.toLowerCase() === ze), Be = [
454
+ //#region src/metadata/comicInfo/getArchiveHasComicInfo.ts
455
+ var Ie = V.toLowerCase(), Le = (e) => e.records.find((e) => x(e) && e.basename.toLowerCase() === Ie), Re = [
468
456
  "Unknown",
469
457
  "No",
470
458
  "Yes",
471
459
  "YesAndRightToLeft"
472
- ], Ve = (e) => {
473
- for (let t of Be) if (t === e) return !0;
460
+ ], ze = (e) => {
461
+ for (let t of Re) if (t === e) return !0;
474
462
  return !1;
475
463
  };
476
464
  //#endregion
477
465
  //#region src/metadata/comicInfo/readArchiveComicInfo.ts
478
- async function He(e) {
479
- let t = W(e);
466
+ async function Be(e) {
467
+ let t = Le(e);
480
468
  if (t) return ye(await D(t));
481
469
  }
482
470
  //#endregion
483
- //#region src/metadata/comicInfo/resolve.ts
484
- var Ue = {
485
- AgeRating: "comic.ageRating",
486
- AlternateCount: "comic.alternateSeries",
487
- AlternateNumber: "comic.alternateSeries",
488
- AlternateSeries: "comic.alternateSeries",
489
- BlackAndWhite: "comic.blackAndWhite",
490
- Characters: "comic.characters",
491
- Colorist: "contributors",
492
- CommunityRating: "comic.communityRating",
493
- Count: "belongsTo.series",
494
- CoverArtist: "contributors",
495
- Day: "publication.edition.date",
496
- Editor: "contributors",
497
- Format: "comic.format",
498
- Genre: "subjects",
499
- GTIN: "identifiers",
500
- Imprint: "publication.edition.imprint",
501
- Inker: "contributors",
502
- LanguageISO: "languages",
503
- Letterer: "contributors",
504
- Locations: "comic.locations",
505
- MainCharacterOrTeam: "comic.mainCharacterOrTeam",
506
- Manga: "readingDirection",
507
- Month: "publication.edition.date",
508
- Notes: "comic.notes",
509
- Number: "belongsTo.series",
510
- PageCount: "numberOfPages",
511
- Penciller: "contributors",
512
- Publisher: "publication.edition.publisher",
513
- Review: "comic.review",
514
- ScanInformation: "comic.scanInformation",
515
- Series: "belongsTo.series",
516
- SeriesGroup: "belongsTo.collection",
517
- StoryArc: "comic.storyArcs",
518
- StoryArcNumber: "comic.storyArcs",
519
- Summary: "description",
520
- Tags: "subjects",
521
- Teams: "comic.teams",
522
- Title: "titles",
523
- Translator: "contributors",
524
- Volume: "comic.volume",
525
- Web: "comic.web",
526
- Writer: "contributors",
527
- Year: "publication.edition.date"
528
- }, We = (e) => {
471
+ //#region src/metadata/kobo/readArchiveKobo.ts
472
+ async function Ve(e) {
473
+ let n = e.records.filter((e) => x(e) && e.uri.endsWith("com.kobobooks.display-options.xml"));
474
+ if (n.length === 0) return;
475
+ let r;
476
+ for (let e of n) {
477
+ let n = await D(e);
478
+ try {
479
+ let { renditionLayout: e } = Se(n);
480
+ e && (r = e);
481
+ } catch (n) {
482
+ t.error(`Unable to parse ${be} (${e.uri})`, n);
483
+ }
484
+ }
485
+ return {
486
+ kind: "kobo",
487
+ ...r === void 0 ? {} : { renditionLayout: r }
488
+ };
489
+ }
490
+ //#endregion
491
+ //#region src/metadata/opf/getSpineItemFilesFromArchive.ts
492
+ var He = async ({ archive: e, archiveOpf: t }) => {
493
+ if (!t) return [];
494
+ let { opf: n, basePath: r } = t, { spineRows: i } = n;
495
+ return e.records.filter((e) => i.find((t) => r ? `${r}/${t.href}` === e.uri : `${t.href}` === e.uri));
496
+ }, Ue = (e) => e.toLowerCase().endsWith(".opf"), We = (e) => e.records.some((e) => !e.dir && (Ue(e.basename) || Ue(e.uri))), Ge = (e) => {
497
+ let t = e.displayOptions?.platform?.options, n = t?.find((e) => e.name === "fixed-layout")?.value.trim().toLowerCase(), r = n === "true" || n !== "false" && void 0, i = H({
498
+ fixedLayout: r,
499
+ options: t !== void 0 && t.length > 0 ? t.map(({ name: e, value: t }) => H({
500
+ name: e,
501
+ value: t
502
+ })) : void 0
503
+ });
504
+ return H({
505
+ renditionLayout: r === !0 ? "pre-paginated" : void 0,
506
+ apple: Object.keys(i).length > 0 ? i : void 0
507
+ });
508
+ }, Ke = (e) => {
529
509
  switch (e.Manga) {
530
510
  case "YesAndRightToLeft": return "rtl";
531
511
  case "Yes":
@@ -546,25 +526,25 @@ var Ue = {
546
526
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
547
527
  let n = Number.parseFloat(t);
548
528
  return Number.isFinite(n) ? n : void 0;
549
- }, Ge = (e) => {
529
+ }, qe = (e) => {
550
530
  let t = G(e)?.toLowerCase();
551
531
  if (t === "yes") return !0;
552
532
  if (t === "no") return !1;
553
- }, Ke = (e) => {
533
+ }, Je = (e) => {
554
534
  switch (e.Manga) {
555
535
  case "Yes":
556
536
  case "YesAndRightToLeft": return !0;
557
537
  case "No": return !1;
558
538
  default: return;
559
539
  }
560
- }, qe = (e) => {
540
+ }, Ye = (e) => {
561
541
  let t = q(e.Year), n = q(e.Month), r = q(e.Day);
562
542
  if (!(t === void 0 && n === void 0 && r === void 0)) return {
563
543
  ...t === void 0 ? {} : { year: t },
564
544
  ...n === void 0 ? {} : { month: n },
565
545
  ...r === void 0 ? {} : { day: r }
566
546
  };
567
- }, Je = [
547
+ }, Xe = [
568
548
  ["Writer", "author"],
569
549
  ["Penciller", "penciler"],
570
550
  ["Inker", "inker"],
@@ -573,9 +553,9 @@ var Ue = {
573
553
  ["CoverArtist", "coverArtist"],
574
554
  ["Editor", "editor"],
575
555
  ["Translator", "translator"]
576
- ], Ye = (e) => {
556
+ ], Ze = (e) => {
577
557
  let t = /* @__PURE__ */ new Map();
578
- for (let [n, r] of Je) for (let i of K(e[n])) {
558
+ for (let [n, r] of Xe) for (let i of K(e[n])) {
579
559
  let e = t.get(i);
580
560
  e ? e.roles.includes(r) || e.roles.push(r) : t.set(i, {
581
561
  name: i,
@@ -583,21 +563,21 @@ var Ue = {
583
563
  });
584
564
  }
585
565
  return [...t.values()];
586
- }, Xe = (e) => {
566
+ }, Qe = (e) => {
587
567
  let t = H({
588
568
  name: G(e.Series),
589
569
  position: J(e.Number),
590
570
  total: q(e.Count)
591
571
  });
592
572
  return Object.keys(t).length > 0 ? t : void 0;
593
- }, Ze = (e) => {
573
+ }, $e = (e) => {
594
574
  let t = G(e.AlternateSeries);
595
575
  if (t !== void 0) return H({
596
576
  name: t,
597
577
  position: J(e.AlternateNumber),
598
578
  total: q(e.AlternateCount)
599
579
  });
600
- }, Qe = (e) => {
580
+ }, et = (e) => {
601
581
  let t = K(e.StoryArc);
602
582
  if (t.length === 0) return [];
603
583
  let n = K(e.StoryArcNumber);
@@ -605,20 +585,20 @@ var Ue = {
605
585
  name: e,
606
586
  position: J(n[t])
607
587
  }));
608
- }, Y = (e) => e.length > 0 ? e : void 0, $e = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), et = (e) => {
588
+ }, Y = (e) => e.length > 0 ? e : void 0, tt = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), nt = (e) => {
609
589
  try {
610
590
  let t = new URL(e);
611
591
  return (t.protocol === "http:" || t.protocol === "https:") && t.hostname.length > 0;
612
592
  } catch {
613
593
  return !1;
614
594
  }
615
- }, tt = (e) => e.filter((e, t, n) => et(e) && n.indexOf(e) === t).map((e) => ({
595
+ }, rt = (e) => e.filter((e, t, n) => nt(e) && n.indexOf(e) === t).map((e) => ({
616
596
  value: e,
617
597
  scheme: "URL"
618
- })), nt = (e, t) => {
598
+ })), it = (e, t) => {
619
599
  let n = H({
620
- manga: Ke(e),
621
- blackAndWhite: Ge(e.BlackAndWhite),
600
+ manga: Je(e),
601
+ blackAndWhite: qe(e.BlackAndWhite),
622
602
  volume: q(e.Volume),
623
603
  format: G(e.Format),
624
604
  ageRating: G(e.AgeRating),
@@ -631,22 +611,22 @@ var Ue = {
631
611
  characters: Y(K(e.Characters)),
632
612
  teams: Y(K(e.Teams)),
633
613
  locations: Y(K(e.Locations)),
634
- storyArcs: Y(Qe(e)),
635
- alternateSeries: Ze(e)
614
+ storyArcs: Y(et(e)),
615
+ alternateSeries: $e(e)
636
616
  });
637
617
  return Object.keys(n).length > 0 ? n : void 0;
638
- }, rt = (e) => {
639
- let t = Xe(e), n = Y(K(e.SeriesGroup).map((e) => ({ name: e })));
618
+ }, at = (e) => {
619
+ let t = Qe(e), n = Y(K(e.SeriesGroup).map((e) => ({ name: e })));
640
620
  if (!(t === void 0 && n === void 0)) return H({
641
621
  series: t === void 0 ? void 0 : [t],
642
622
  collection: n
643
623
  });
644
- }, it = (e) => {
645
- let t = e.GTIN, n = G(t), r = $e(e), i = [...n === void 0 ? [] : [{
624
+ }, ot = (e) => {
625
+ let t = e.GTIN, n = G(t), r = tt(e), i = [...n === void 0 ? [] : [{
646
626
  value: n,
647
627
  scheme: "GTIN"
648
- }], ...tt(r)], a = G(e.LanguageISO), o = [...K(e.Genre), ...K(e.Tags)], s = H({
649
- date: qe(e),
628
+ }], ...rt(r)], a = G(e.LanguageISO), o = [...K(e.Genre), ...K(e.Tags)], s = H({
629
+ date: Ye(e),
650
630
  publisher: G(e.Publisher),
651
631
  imprint: G(e.Imprint)
652
632
  }), c = G(e.Title);
@@ -656,59 +636,32 @@ var Ue = {
656
636
  publication: s.date !== void 0 || s.publisher !== void 0 || s.imprint !== void 0 ? { edition: s } : void 0,
657
637
  languages: a === void 0 ? void 0 : [a],
658
638
  subjects: Y(o),
659
- contributors: Y(Ye(e)),
660
- readingDirection: We(e),
639
+ contributors: Y(Ze(e)),
640
+ readingDirection: Ke(e),
661
641
  numberOfPages: q(e.PageCount),
662
642
  identifiers: Y(i),
663
- belongsTo: rt(e),
664
- comic: nt(e, r)
643
+ belongsTo: at(e),
644
+ comicInfo: it(e, r)
665
645
  });
666
- };
667
- //#endregion
668
- //#region src/metadata/kobo/readArchiveKobo.ts
669
- async function at(e) {
670
- let n = e.records.filter((e) => x(e) && e.uri.endsWith("com.kobobooks.display-options.xml"));
671
- if (n.length === 0) return;
672
- let r;
673
- for (let e of n) {
674
- let n = await D(e);
675
- try {
676
- let { renditionLayout: e } = Se(n);
677
- e && (r = e);
678
- } catch (n) {
679
- t.error(`Unable to parse ${be} (${e.uri})`, n);
680
- }
681
- }
682
- return {
683
- kind: "kobo",
684
- ...r === void 0 ? {} : { renditionLayout: r }
685
- };
686
- }
687
- //#endregion
688
- //#region src/metadata/kobo/resolve.ts
689
- var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
646
+ }, st = (e) => H({
690
647
  renditionLayout: e.renditionLayout,
691
648
  kobo: e.renditionLayout === void 0 ? void 0 : { fixedLayout: e.renditionLayout === "pre-paginated" }
692
- }), ct = async ({ archive: e, archiveOpf: t }) => {
693
- if (!t) return [];
694
- let { opf: n, basePath: r } = t, { spineRows: i } = n;
695
- return e.records.filter((e) => i.find((t) => r ? `${r}/${t.href}` === e.uri : `${t.href}` === e.uri));
696
- }, lt = (e) => e.toLowerCase().endsWith(".opf"), ut = (e) => e.records.some((e) => !e.dir && (lt(e.basename) || lt(e.uri))), dt = /* @__PURE__ */ new Set([
649
+ }), ct = /* @__PURE__ */ new Set([
697
650
  8,
698
651
  12,
699
652
  13,
700
653
  14
701
- ]), ft = (e) => {
654
+ ]), lt = (e) => {
702
655
  if (e == null) return;
703
656
  let t = String(e).replace(/\D/g, "");
704
- if (!(t.length === 0 || !dt.has(t.length))) return t;
705
- }, pt = /(?:97[89])?\d{9}[\dXx]/, mt = (e) => {
657
+ if (!(t.length === 0 || !ct.has(t.length))) return t;
658
+ }, ut = /(?:97[89])?\d{9}[\dXx]/, dt = (e) => {
706
659
  if (e == null) return;
707
660
  let t = String(e).trim().replace(/^urn:isbn:/i, "").replace(/^isbn[:\s-]*/i, ""), n = t.replace(/[^0-9Xx]/g, "");
708
661
  if (n.length === 10 || n.length === 13) return n.toUpperCase();
709
- let r = t.match(pt);
662
+ let r = t.match(ut);
710
663
  if (r) return r[0].toUpperCase();
711
- }, ht = (e) => {
664
+ }, ft = (e) => {
712
665
  if (e === void 0) return;
713
666
  let t = e.trim().match(/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?/);
714
667
  if (t === null) return;
@@ -718,36 +671,15 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
718
671
  ...r === void 0 ? {} : { month: Number.parseInt(r, 10) },
719
672
  ...i === void 0 ? {} : { day: Number.parseInt(i, 10) }
720
673
  };
721
- }, gt = {
722
- manifestItems: "readingOrder",
723
- spineRows: "readingOrder",
724
- spineTocIdref: "toc",
725
- identifiers: "identifiers",
726
- titles: "titles",
727
- creators: "contributors",
728
- contributors: "contributors",
729
- publisher: "publication.edition.publisher",
730
- description: "description",
731
- rights: "rights",
732
- languages: "languages",
733
- subjects: "subjects",
734
- date: "publication.edition.date",
735
- coverHref: "cover",
736
- renditionLayoutMeta: "renditionLayout",
737
- renditionFlowMeta: "renditionFlow",
738
- renditionSpreadMeta: "renditionSpread",
739
- pageProgressionDirection: "readingDirection",
740
- guide: "guide",
741
- metas: "properties"
742
- }, _t = (e) => {
674
+ }, pt = (e) => {
743
675
  let t = e.trim();
744
676
  if (/^https?:\/\//i.test(t)) try {
745
677
  let e = new URL(t);
746
678
  if ((e.protocol === "http:" || e.protocol === "https:") && e.hostname.length > 0) return "URL";
747
679
  } catch {}
748
- let n = mt(t);
749
- return n !== void 0 && (n.length === 10 || /^97[89]/.test(n)) ? "ISBN" : ft(t) === void 0 ? "Unknown" : "GTIN";
750
- }, vt = (e) => {
680
+ let n = dt(t);
681
+ return n !== void 0 && (n.length === 10 || /^97[89]/.test(n)) ? "ISBN" : lt(t) === void 0 ? "Unknown" : "GTIN";
682
+ }, mt = (e) => {
751
683
  switch (e.trim().toLowerCase()) {
752
684
  case "isbn": return "ISBN";
753
685
  case "gtin": return "GTIN";
@@ -759,7 +691,7 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
759
691
  case "unknown": return "Unknown";
760
692
  default: return e.trim();
761
693
  }
762
- }, yt = {
694
+ }, ht = {
763
695
  art: "artist",
764
696
  aut: "author",
765
697
  clr: "colorist",
@@ -768,14 +700,14 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
768
700
  ill: "illustrator",
769
701
  nrt: "narrator",
770
702
  trl: "translator"
771
- }, bt = (e) => e.contributors.map((e) => {
772
- let t = e.roles.map((e) => yt[e.trim().toLowerCase()] ?? e);
703
+ }, gt = (e) => e.map((e) => {
704
+ let t = e.roles.map((e) => ht[e.trim().toLowerCase()] ?? e);
773
705
  return H({
774
706
  name: e.name,
775
707
  roles: t.length > 0 ? t : [e.source === "creator" ? "author" : "contributor"],
776
708
  sortAs: e.fileAs
777
709
  });
778
- }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, xt = {
710
+ }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, _t = {
779
711
  "02": "ISBN",
780
712
  "03": "GTIN",
781
713
  "04": "UPC",
@@ -791,18 +723,18 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
791
723
  26: "DOI",
792
724
  34: "GTIN",
793
725
  35: "ARK"
794
- }, St = (e) => {
726
+ }, vt = (e) => {
795
727
  let t = e?.value?.trim();
796
- if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? xt[t] ?? t : t;
797
- }, Ct = (e, t) => {
728
+ if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? _t[t] ?? t : t;
729
+ }, yt = (e, t) => {
798
730
  let n = e.id;
799
- if (n !== void 0) return St(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
800
- }, wt = (e) => {
731
+ if (n !== void 0) return vt(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
732
+ }, bt = (e) => {
801
733
  let t = e?.trim();
802
734
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
803
735
  let n = Number.parseFloat(t);
804
736
  return Number.isFinite(n) ? n : void 0;
805
- }, Tt = (e) => {
737
+ }, xt = (e) => {
806
738
  let t = e?.trim();
807
739
  if (t === void 0 || !/^\d+$/.test(t)) return;
808
740
  let n = Number.parseInt(t, 10);
@@ -810,30 +742,30 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
810
742
  }, Z = (e) => {
811
743
  let t = e?.trim();
812
744
  return t !== void 0 && t.length > 0 ? t : void 0;
813
- }, Q = (e, t, n) => t === void 0 ? void 0 : e.find((e) => X(e, t) && e.property === n && e.value !== void 0)?.value, Et = (e) => e.titles.map((t) => H({
814
- value: t.value,
815
- type: Z(Q(e.metas, t.id, "title-type"))?.toLowerCase(),
816
- displaySeq: Tt(Q(e.metas, t.id, "display-seq")),
817
- sortAs: Z(Q(e.metas, t.id, "file-as"))
818
- })), Dt = (e, t) => {
745
+ }, Q = (e, t, n) => t === void 0 ? void 0 : e.find((e) => X(e, t) && e.property === n && e.value !== void 0)?.value, St = (e, t) => e.map((e) => H({
746
+ value: e.value,
747
+ type: Z(Q(t, e.id, "title-type"))?.toLowerCase(),
748
+ displaySeq: xt(Q(t, e.id, "display-seq")),
749
+ sortAs: Z(Q(t, e.id, "file-as"))
750
+ })), Ct = (e, t) => {
819
751
  if (t === void 0) return;
820
752
  let n = e.flatMap((n) => {
821
753
  if (!X(n, t) || n.property !== "dcterms:identifier") return [];
822
754
  let r = Z(n.value);
823
755
  return r === void 0 ? [] : [{
824
756
  value: r,
825
- scheme: vt(St(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? _t(r))
757
+ scheme: mt(vt(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? pt(r))
826
758
  }];
827
759
  });
828
760
  return n.length > 0 ? n : void 0;
829
- }, Ot = (e) => {
761
+ }, wt = (e) => {
830
762
  let t = [], n = [];
831
763
  for (let r of e) {
832
764
  if (r.property !== "belongs-to-collection" || r.value === void 0) continue;
833
765
  let i = r.id, a = (t) => Q(e, i, t), o = a("collection-type")?.trim().toLowerCase(), s = H({
834
766
  name: r.value,
835
- identifiers: Dt(e, i),
836
- position: wt(a("group-position"))
767
+ identifiers: Ct(e, i),
768
+ position: bt(a("group-position"))
837
769
  });
838
770
  o === "series" ? t.push(s) : n.push(s);
839
771
  }
@@ -841,49 +773,49 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
841
773
  let n = e.find((e) => e.name?.toLowerCase() === "calibre:series" && e.content !== void 0)?.content;
842
774
  n !== void 0 && t.push(H({
843
775
  name: n,
844
- position: wt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
776
+ position: bt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
845
777
  }));
846
778
  }
847
779
  return {
848
780
  series: t,
849
781
  collection: n
850
782
  };
851
- }, kt = (e) => {
783
+ }, Tt = (e) => {
852
784
  let t = e?.trim();
853
785
  if (t === "scrolled-continuous" || t === "scrolled-doc" || t === "paginated" || t === "auto") return t;
854
- }, At = (e) => {
786
+ }, Et = (e) => {
855
787
  let t = e?.trim();
856
788
  if (t === "none" || t === "landscape" || t === "portrait" || t === "both" || t === "auto") return t;
857
- }, jt = (e) => {
858
- let t = e.pageProgressionDirection?.trim().toLowerCase(), n = t === "ltr" || t === "rtl" ? t : void 0, r = e.renditionLayoutMeta?.trim().toLowerCase(), i = r === "reflowable" || r === "pre-paginated" ? r : void 0, a = bt(e), o = Et(e), { series: s, collection: c } = Ot(e.metas), l = s.length > 0 || c.length > 0 ? H({
859
- series: s.length > 0 ? s : void 0,
860
- collection: c.length > 0 ? c : void 0
861
- }) : void 0, u = H({
862
- date: ht(e.date),
863
- publisher: e.publisher
789
+ }, Dt = (e) => {
790
+ let { titles: t, contributors: n, publisher: r, description: i, rights: a, languages: o, subjects: s, date: c, renditionLayoutMeta: l, renditionFlowMeta: u, renditionSpreadMeta: d, pageProgressionDirection: f, identifiers: p, metas: m, kind: h, creators: g, manifestItems: _, spineRows: v, spineTocIdref: y, coverHref: b, guide: x, ...S } = e, C = f?.trim().toLowerCase(), w = C === "ltr" || C === "rtl" ? C : void 0, T = l?.trim().toLowerCase(), E = T === "reflowable" || T === "pre-paginated" ? T : void 0, D = gt(n), O = St(t, m), { series: k, collection: A } = wt(m), j = k.length > 0 || A.length > 0 ? H({
791
+ series: k.length > 0 ? k : void 0,
792
+ collection: A.length > 0 ? A : void 0
793
+ }) : void 0, M = H({
794
+ date: ft(c),
795
+ publisher: r
864
796
  });
865
797
  return H({
866
- titles: o.length > 0 ? o : void 0,
867
- description: e.description,
868
- publication: u.date !== void 0 || u.publisher !== void 0 ? { edition: u } : void 0,
869
- rights: e.rights,
870
- languages: e.languages.length > 0 ? [...e.languages] : void 0,
871
- subjects: e.subjects.length > 0 ? [...e.subjects] : void 0,
872
- contributors: a.length > 0 ? a : void 0,
873
- readingDirection: n,
874
- renditionLayout: i,
875
- renditionFlow: kt(e.renditionFlowMeta),
876
- renditionSpread: At(e.renditionSpreadMeta),
877
- identifiers: e.identifiers.length > 0 ? e.identifiers.map((t) => H({
878
- value: t.value,
879
- scheme: vt(t.scheme ?? Ct(t, e.metas) ?? _t(t.value)),
880
- unique: t.unique
798
+ titles: O.length > 0 ? O : void 0,
799
+ description: i,
800
+ publication: M.date !== void 0 || M.publisher !== void 0 ? { edition: M } : void 0,
801
+ rights: a,
802
+ languages: o.length > 0 ? [...o] : void 0,
803
+ subjects: s.length > 0 ? [...s] : void 0,
804
+ contributors: D.length > 0 ? D : void 0,
805
+ readingDirection: w,
806
+ renditionLayout: E,
807
+ renditionFlow: Tt(u),
808
+ renditionSpread: Et(d),
809
+ identifiers: p.length > 0 ? p.map((e) => H({
810
+ value: e.value,
811
+ scheme: mt(e.scheme ?? yt(e, m) ?? pt(e.value)),
812
+ unique: e.unique
881
813
  })) : void 0,
882
- belongsTo: l,
883
- properties: e.metas.length > 0 ? [...e.metas] : void 0
814
+ belongsTo: j,
815
+ properties: m.length > 0 ? [...m] : void 0
884
816
  });
885
- }, Mt = (e) => e.kind === "comicInfo" ? it(e) : e.kind === "kobo" ? st(e) : e.kind === "apple" ? Re(e) : jt(e), Nt = (e) => {
886
- let t = e.opf === void 0 ? void 0 : jt(e.opf), n = e.comicInfo === void 0 ? void 0 : it(e.comicInfo), r = e.apple === void 0 ? void 0 : Re(e.apple), i = e.kobo === void 0 ? void 0 : st(e.kobo), a = [...t?.identifiers ?? [], ...n?.identifiers ?? []], o = H({
817
+ }, Ot = (e) => e.kind === "comicInfo" ? ot(e) : e.kind === "kobo" ? st(e) : e.kind === "apple" ? Ge(e) : Dt(e), kt = (e) => {
818
+ let t = e.opf === void 0 ? void 0 : Dt(e.opf), n = e.comicInfo === void 0 ? void 0 : ot(e.comicInfo), r = e.apple === void 0 ? void 0 : Ge(e.apple), i = e.kobo === void 0 ? void 0 : st(e.kobo), a = [...t?.identifiers ?? [], ...n?.identifiers ?? []], o = H({
887
819
  date: t?.publication?.edition?.date ?? n?.publication?.edition?.date,
888
820
  publisher: t?.publication?.edition?.publisher ?? n?.publication?.edition?.publisher,
889
821
  imprint: t?.publication?.edition?.imprint ?? n?.publication?.edition?.imprint
@@ -904,11 +836,11 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
904
836
  identifiers: a.length > 0 ? a : void 0,
905
837
  belongsTo: t?.belongsTo ?? n?.belongsTo,
906
838
  properties: t?.properties,
907
- comic: n?.comic,
839
+ comicInfo: n?.comicInfo,
908
840
  apple: r?.apple,
909
841
  kobo: i?.kobo
910
842
  });
911
- }, Pt = (e) => {
843
+ }, At = (e) => {
912
844
  let t = [...e.records].sort((e, t) => p(e.uri, t.uri)), n = (e, t, r, i, a) => {
913
845
  let o = e.find((e) => e.title === t), [s, ...c] = r;
914
846
  return o ? s ? [...e.filter((e) => e !== o), {
@@ -937,71 +869,71 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
937
869
  let a = encodeURI(t.uri).replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\/$/, ""), o = t.uri.replace(/\/$/, "");
938
870
  return n(e, r, i, a, o);
939
871
  }, []);
940
- }, Ft = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? Ft(e) : "").join("").trim() : "", It = (e) => k(e.properties).includes("nav"), Lt = (e, { basePath: t }) => {
872
+ }, jt = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? jt(e) : "").join("").trim() : "", Mt = (e) => k(e.properties).includes("nav"), Nt = (e, { basePath: t }) => {
941
873
  let n = {
942
874
  contents: [],
943
875
  path: "",
944
876
  containerHref: "",
945
877
  title: ""
946
878
  }, r = e.childNamed("span") || e.childNamed("a");
947
- n.title = (r?.attr.title || r?.val.trim() || Ft(r)) ?? "";
879
+ n.title = (r?.attr.title || r?.val.trim() || jt(r)) ?? "";
948
880
  let i = r?.name;
949
881
  i !== "a" && (r = e.descendantWithPath(`${i}.a`), r && (i = r.name.toLowerCase())), i === "a" && r?.attr.href && (n.path = m(t, r.attr.href), n.containerHref = n.path);
950
882
  let a = e.childNamed("ol");
951
883
  if (a) {
952
884
  let e = a.childrenNamed("li");
953
- e && e.length > 0 && (n.contents = e.map((e) => Lt(e, { basePath: t })));
885
+ e && e.length > 0 && (n.contents = e.map((e) => Nt(e, { basePath: t })));
954
886
  }
955
887
  return n;
956
- }, Rt = (e, { basePath: t }) => {
888
+ }, Pt = (e, { basePath: t }) => {
957
889
  let n = [], r;
958
890
  return e.descendantWithPath("body.nav.ol") ? r = e.descendantWithPath("body.nav.ol")?.children : e.descendantWithPath("body.section.nav.ol") && (r = e.descendantWithPath("body.section.nav.ol")?.children), r && r.length > 0 && r.filter((e) => e instanceof g && e.name === "li").forEach((e) => {
959
- n.push(Lt(e, { basePath: t }));
891
+ n.push(Nt(e, { basePath: t }));
960
892
  }), n;
961
- }, zt = async (e, t) => {
962
- let n = e.manifestItems.find(It);
893
+ }, Ft = async (e, t) => {
894
+ let n = e.manifestItems.find(Mt);
963
895
  if (n?.href) {
964
896
  let e = t.records.find((e) => e.uri.endsWith(n.href));
965
- if (e && !e.dir) return Rt(new h(await D(e)), { basePath: c(e.uri) });
897
+ if (e && !e.dir) return Pt(new h(await D(e)), { basePath: c(e.uri) });
966
898
  }
967
- }, Bt = (e, { basePath: t, prefix: n }) => {
899
+ }, It = (e, { basePath: t, prefix: n }) => {
968
900
  let r = m(t, e?.childNamed(`${n}content`)?.attr.src || ""), i = {
969
901
  title: e?.descendantWithPath(`${n}navLabel.${n}text`)?.val || "",
970
902
  path: r,
971
903
  containerHref: r,
972
904
  contents: []
973
905
  }, a = e.childrenNamed(`${n}navPoint`);
974
- return a && a.length > 0 && (i.contents = a.map((e) => Bt(e, {
906
+ return a && a.length > 0 && (i.contents = a.map((e) => It(e, {
975
907
  basePath: t,
976
908
  prefix: n
977
909
  }))), i;
978
- }, Vt = (e, { basePath: t }) => {
910
+ }, Lt = (e, { basePath: t }) => {
979
911
  let n = [], r = e.name, i = "";
980
912
  return r.indexOf(":") !== -1 && (i = `${r.split(":")[0]}:`), e.childNamed(`${i}navMap`)?.childrenNamed(`${i}navPoint`).forEach((e) => {
981
- n.push(Bt(e, {
913
+ n.push(It(e, {
982
914
  basePath: t,
983
915
  prefix: i
984
916
  }));
985
917
  }), n;
986
- }, Ht = async ({ opf: e, opfBasePath: t, archive: n }) => {
918
+ }, Rt = async ({ opf: e, opfBasePath: t, archive: n }) => {
987
919
  let r = e.spineTocIdref;
988
920
  if (r) {
989
921
  let i = e.manifestItems.find((e) => e.id === r);
990
922
  if (i) {
991
923
  let e = `${t}${t === "" ? "" : "/"}${i.href}`, r = n.records.find((t) => t.uri.endsWith(e));
992
- if (r && !r.dir) return Vt(new h(await D(r)), { basePath: c(r.uri) });
924
+ if (r && !r.dir) return Lt(new h(await D(r)), { basePath: c(r.uri) });
993
925
  }
994
926
  }
995
- }, Ut = async (e, { opf: t } = {}) => {
996
- let n = t ?? await R(e);
997
- if (n) return await zt(n.opf, e) || await Ht({
927
+ }, zt = async (e, { opf: t } = {}) => {
928
+ let n = t ?? await z(e);
929
+ if (n) return await Ft(n.opf, e) || await Rt({
998
930
  opf: n.opf,
999
931
  opfBasePath: n.basePath,
1000
932
  archive: e
1001
933
  }) || [];
1002
- let r = Pt(e);
934
+ let r = At(e);
1003
935
  return r.length === 0 ? void 0 : r;
1004
- }, Wt = [
936
+ }, Bt = [
1005
937
  "metadata",
1006
938
  "readingOrder",
1007
939
  "toc"
@@ -1017,39 +949,39 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
1017
949
  failed: !0
1018
950
  };
1019
951
  }
1020
- }, Gt = (e) => {
952
+ }, Vt = (e) => {
1021
953
  let t = (e) => e?.startsWith("audio/") === !0 || e?.startsWith("video/") === !0, n = e.filter((e) => e.renditionLayout === "pre-paginated" && !t(e.mediaType)).length;
1022
954
  return n > 0 ? n : void 0;
1023
- }, Kt = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
955
+ }, Ht = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
1024
956
  let a = [];
1025
- return t !== void 0 && t.value === void 0 && (t.failed || ut(e)) && a.push("opf"), n?.failed && a.push("comicInfo"), r?.failed && a.push("apple"), i?.failed && a.push("kobo"), a;
1026
- }, qt = 3, Jt = async (e, t = {}) => {
1027
- let n = new Set(t.include ?? Wt), r = n.has("metadata"), i = n.has("sources"), a = n.has("readingOrder"), o = n.has("toc"), s = t.layoutScan === !0 && (r || a), c = r || i || a || o ? await $(() => R(e), "opf") : void 0, l = c?.value, u = r || i || s, d = u ? await $(() => He(e), "comicInfo") : void 0, f = d?.value, p = u ? await $(() => Ie(e), "apple") : void 0, m = p?.value, h = u ? await $(() => at(e), "kobo") : void 0, g = h?.value, _ = r || s ? Nt({
957
+ return t !== void 0 && t.value === void 0 && (t.failed || We(e)) && a.push("opf"), n?.failed && a.push("comicInfo"), r?.failed && a.push("apple"), i?.failed && a.push("kobo"), a;
958
+ }, Ut = 3, Wt = async (e, t = {}) => {
959
+ let n = new Set(t.include ?? Bt), r = n.has("metadata"), i = n.has("sources"), a = n.has("readingOrder"), o = n.has("toc"), s = t.layoutScan === !0 && (r || a), c = r || i || a || o ? await $(() => z(e), "opf") : void 0, l = c?.value, u = r || i || s, d = u ? await $(() => Be(e), "comicInfo") : void 0, f = d?.value, p = u ? await $(() => Fe(e), "apple") : void 0, m = p?.value, h = u ? await $(() => Ve(e), "kobo") : void 0, g = h?.value, _ = r || s ? kt({
1028
960
  opf: l?.opf,
1029
961
  comicInfo: f,
1030
962
  apple: m,
1031
963
  kobo: g
1032
964
  }) : void 0, v = a || s ? await U(e, { opf: l }) : void 0;
1033
- if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await Pe(e, v) && (_ = {
965
+ if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await Ne(e, v) && (_ = {
1034
966
  ..._,
1035
967
  renditionLayout: "pre-paginated"
1036
968
  }, v = v.map((e) => ({
1037
969
  ...e,
1038
970
  renditionLayout: "pre-paginated"
1039
971
  }))), r && _ !== void 0) {
1040
- let t = v ?? await U(e, { opf: l }), n = await Me(e, {
972
+ let t = v ?? await U(e, { opf: l }), n = await W(e, {
1041
973
  opf: l,
1042
974
  readingOrder: t
1043
- }), r = _.numberOfPages ?? Gt(t);
975
+ }), r = _.numberOfPages ?? Vt(t);
1044
976
  _ = H({
1045
977
  ..._,
1046
978
  cover: n,
1047
979
  numberOfPages: r
1048
980
  });
1049
981
  }
1050
- let y = o ? (await $(() => Ut(e, { opf: l }), "toc")).value : void 0, b = {
1051
- version: qt,
1052
- unreadableSources: Kt({
982
+ let y = o ? (await $(() => zt(e, { opf: l }), "toc")).value : void 0, b = {
983
+ version: Ut,
984
+ unreadableSources: Ht({
1053
985
  archive: e,
1054
986
  opf: c,
1055
987
  comicInfo: d,
@@ -1063,8 +995,8 @@ var ot = { renditionLayout: "renditionLayout" }, st = (e) => H({
1063
995
  apple: m,
1064
996
  kobo: g
1065
997
  })), b;
1066
- }, Yt = (e) => e?.titles?.[0]?.value;
998
+ }, Gt = (e) => e?.titles?.[0]?.value;
1067
999
  //#endregion
1068
- export { z as APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME, V as COMIC_INFO_FILENAME, he as COMIC_INFO_KNOWN_FIELDS, Be as COMIC_INFO_MANGA_VALUES, be as KOBO_DISPLAY_OPTIONS_FILENAME, Le as appleMetadataHomes, i as arrayBufferFileAccessors, r as blobFileAccessors, Ue as comicInfoMetadataHomes, e as createArchive, v as createArchiveFromArrayBufferList, n as createArchiveFromEntries, y as createArchiveFromText, b as createArchiveFromUrls, C as getArchiveFileRecordByUri, W as getArchiveHasComicInfo, E as getArchiveImageRecords, O as getArchiveOpfInfo, ct as getSpineItemFilesFromArchive, ut as isArchiveEpub, Ve as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, ot as koboMetadataHomes, Yt as mainTitle, ft as normalizeGtin, mt as normalizeIsbn, gt as opfMetadataHomes, B as parseAppleDisplayOptionsXml, ye as parseComicInfo, Se as parseKoboXml, pe as parseOpf, ht as parseW3cDtfDate, Ie as readArchiveApple, He as readArchiveComicInfo, at as readArchiveKobo, R as readArchiveOpf, D as readRecordAsText, Pe as readingOrderDocumentsAllHaveViewport, Jt as resolveArchive, Me as resolveArchiveCover, Mt as resolveArchiveMetadata, U as resolveArchiveReadingOrder, Ut as resolveArchiveToc, Nt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1000
+ export { B as APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME, V as COMIC_INFO_FILENAME, he as COMIC_INFO_KNOWN_FIELDS, Re as COMIC_INFO_MANGA_VALUES, be as KOBO_DISPLAY_OPTIONS_FILENAME, i as arrayBufferFileAccessors, r as blobFileAccessors, e as createArchive, v as createArchiveFromArrayBufferList, n as createArchiveFromEntries, y as createArchiveFromText, b as createArchiveFromUrls, C as getArchiveFileRecordByUri, Le as getArchiveHasComicInfo, E as getArchiveImageRecords, O as getArchiveOpfInfo, He as getSpineItemFilesFromArchive, We as isArchiveEpub, ze as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, Gt as mainTitle, lt as normalizeGtin, dt as normalizeIsbn, me as parseAppleDisplayOptionsXml, ye as parseComicInfo, Se as parseKoboXml, fe as parseOpf, ft as parseW3cDtfDate, Fe as readArchiveApple, Be as readArchiveComicInfo, Ve as readArchiveKobo, z as readArchiveOpf, D as readRecordAsText, Ne as readingOrderDocumentsAllHaveViewport, Wt as resolveArchive, W as resolveArchiveCover, Ot as resolveArchiveMetadata, U as resolveArchiveReadingOrder, zt as resolveArchiveToc, kt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1069
1001
 
1070
1002
  //# sourceMappingURL=index.js.map