@triabin/vue-book-reader
Version:
Forked from jinhuan138/vue-book-reader, add some features
1,197 lines • 61.4 kB
JavaScript
import { toRefs as jt, ref as U, watch as xr, onMounted as Nr, createElementBlock as x, openBlock as N, createElementVNode as F, withDirectives as Fr, createCommentVNode as j, vShow as jr, renderSlot as kt, defineComponent as kr, getCurrentInstance as Br, h as _r, Transition as Mr, reactive as Lr, normalizeStyle as Dr, normalizeClass as se, unref as K, createVNode as ae, toDisplayString as zr, mergeProps as Wr, withCtx as Kr } from "vue";
const Vr = (e, t) => e.map((r, n, o) => t(r, n, o) ? n : null).filter((r) => r != null), Ge = (e, t) => [-1, ...t, e.length].reduce(({ xs: r, a: n }, o) => ({ xs: (r == null ? void 0 : r.concat([e.slice(n + 1, o)])) ?? [], a: o }), {}).xs, Gr = (e, t) => e.slice(0, -1).concat([e[e.length - 1].concat(t[0])]).concat(t.slice(1)), mt = /\d/, ht = /^epubcfi\((.*)\)$/, ce = (e) => e.replace(/[\^[\](),;=]/g, "^$&"), Ue = (e) => ht.test(e) ? e : `epubcfi(${e})`, Ur = (e) => {
var t;
return ((t = e.match(ht)) == null ? void 0 : t[1]) ?? e;
}, Hr = (e) => (...t) => `epubcfi(${e(...t.map((r) => {
var n;
return ((n = r.match(ht)) == null ? void 0 : n[1]) ?? r;
}))})`, Yr = Hr((...e) => e.join("!")), qr = (e) => {
const t = [];
let r, n, o = "";
const i = (a) => (t.push(a), r = null, o = ""), s = (a) => (o += a, n = !1);
for (const a of Array.from(e.trim()).concat("")) {
if (a === "^" && !n) {
n = !0;
continue;
}
if (r === "!") i(["!"]);
else if (r === ",") i([","]);
else if (r === "/" || r === ":")
if (mt.test(a)) {
s(a);
continue;
} else i([r, parseInt(o)]);
else if (r === "~")
if (mt.test(a) || a === ".") {
s(a);
continue;
} else i(["~", parseFloat(o)]);
else if (r === "@") {
if (a === ":") {
i(["@", parseFloat(o)]), r = "@";
continue;
}
if (mt.test(a) || a === ".") {
s(a);
continue;
} else i(["@", parseFloat(o)]);
} else if (r === "[") {
a === ";" && !n ? (i(["[", o]), r = ";") : a === "," && !n ? (i(["[", o]), r = "[") : a === "]" && !n ? i(["[", o]) : s(a);
continue;
} else if (r != null && r.startsWith(";")) {
a === "=" && !n ? (r = `;${o}`, o = "") : a === ";" && !n ? (i([r, o]), r = ";") : a === "]" && !n ? i([r, o]) : s(a);
continue;
}
(a === "/" || a === ":" || a === "~" || a === "@" || a === "[" || a === "!" || a === ",") && (r = a);
}
return t;
}, He = (e, t) => Vr(e, ([r]) => r === t), Xr = (e) => {
const t = [];
let r;
for (const [n, o] of e) {
if (n === "/") t.push({ index: o });
else {
const i = t[t.length - 1];
if (n === ":") i.offset = o;
else if (n === "~") i.temporal = o;
else if (n === "@") i.spatial = (i.spatial ?? []).concat(o);
else if (n === ";s") i.side = o;
else if (n === "[")
if (r === "/" && o) i.id = o;
else {
i.text = (i.text ?? []).concat(o);
continue;
}
}
r = n;
}
return t;
}, le = (e) => Ge(e, He(e, "!")).map(Xr), ct = (e) => {
const t = qr(Ur(e)), r = He(t, ",");
if (!r.length) return le(t);
const [n, o, i] = Ge(t, r).map(le);
return { parent: n, start: o, end: i };
}, Zr = ({ index: e, id: t, offset: r, temporal: n, spatial: o, text: i, side: s }) => {
var u;
const a = s ? `;s=${s}` : "";
return `/${e}` + (t ? `[${ce(t)}${a}]` : "") + (r != null && e % 2 ? `:${r}` : "") + (n ? `~${n}` : "") + (o ? `@${o.join(":")}` : "") + (i || !t && s ? "[" + (((u = i == null ? void 0 : i.map(ce)) == null ? void 0 : u.join(",")) ?? "") + a + "]" : "");
}, Ye = (e) => e.parent ? [e.parent, e.start, e.end].map(Ye).join(",") : e.map((t) => t.map(Zr).join("")).join("!"), dt = (e) => Ue(Ye(e)), D = (e, t) => typeof e == "string" ? dt(D(ct(e), t)) : e.parent ? Gr(e.parent, e[t ? "end" : "start"]) : e, Jr = (e, t) => {
typeof e == "string" && (e = ct(e)), typeof t == "string" && (t = ct(t)), e = D(e), t = D(t, !0);
const r = e[e.length - 1], n = t[t.length - 1], o = [], i = [], s = [];
let a = !0;
const u = Math.max(r.length, n.length);
for (let l = 0; l < u; l++) {
const f = r[l], h = n[l];
a &&= (f == null ? void 0 : f.index) === (h == null ? void 0 : h.index) && !(f != null && f.offset) && !(h != null && h.offset), a ? o.push(f) : (f && i.push(f), h && s.push(h));
}
const c = e.slice(0, -1).concat([o]);
return dt({ parent: c, start: [i], end: [s] });
}, Bt = ({ nodeType: e }) => e === 3 || e === 4, ot = ({ nodeType: e }) => e === 1, qe = (e, t) => {
const r = Array.from(e.childNodes).filter((n) => Bt(n) || ot(n));
return t ? r.map((n) => {
const o = t(n);
return o === NodeFilter.FILTER_REJECT ? null : o === NodeFilter.FILTER_SKIP ? qe(n, t) : n;
}).flat().filter((n) => n) : r;
}, Gt = (e, t) => {
const r = qe(e, t).reduce((n, o) => {
let i = n[n.length - 1];
return i ? Bt(o) ? Array.isArray(i) ? i.push(o) : Bt(i) ? n[n.length - 1] = [i, o] : n.push(o) : ot(i) ? n.push(null, o) : n.push(o) : n.push(o), n;
}, []);
return ot(r[0]) && r.unshift("first"), ot(r[r.length - 1]) && r.push("last"), r.unshift("before"), r.push("after"), r;
}, _t = (e, t, r) => {
const { id: n } = t[t.length - 1];
if (n) {
const s = e.ownerDocument.getElementById(n);
if (s) return { node: s, offset: 0 };
}
for (const { index: s } of t) {
const a = e ? Gt(e, r)[s] : null;
if (a === "first") return { node: e.firstChild ?? e };
if (a === "last") return { node: e.lastChild ?? e };
if (a === "before") return { node: e, before: !0 };
if (a === "after") return { node: e, after: !0 };
e = a;
}
const { offset: o } = t[t.length - 1];
if (!Array.isArray(e)) return { node: e, offset: o };
let i = 0;
for (const s of e) {
const { length: a } = s.nodeValue;
if (i + a >= o) return { node: s, offset: o - i };
i += a;
}
}, lt = (e, t, r) => {
const { parentNode: n, id: o } = e, i = Gt(n, r), s = i.findIndex((c) => Array.isArray(c) ? c.some((l) => l === e) : c === e), a = i[s];
if (Array.isArray(a)) {
let c = 0;
for (const l of a)
if (l === e) {
c += t;
break;
} else c += l.nodeValue.length;
t = c;
}
const u = { id: o, index: s, offset: t };
return (n !== e.ownerDocument.documentElement ? lt(n, null, r).concat(u) : [u]).filter((c) => c.index !== -1);
}, Qr = (e, t) => {
const { startContainer: r, startOffset: n, endContainer: o, endOffset: i } = e, s = lt(r, n, t);
if (e.collapsed) return dt([s]);
const a = lt(o, i, t);
return Jr([s], [a]);
}, tn = (e, t, r) => {
const n = D(t), o = D(t, !0), i = e.documentElement, s = _t(i, n[0], r), a = _t(i, o[0], r), u = e.createRange();
return s.before ? u.setStartBefore(s.node) : s.after ? u.setStartAfter(s.node) : u.setStart(s.node, s.offset), a.before ? u.setEndBefore(a.node) : a.after ? u.setEndAfter(a.node) : u.setEnd(a.node, a.offset), u;
}, Sc = (e) => {
const t = [], { parentNode: r } = e[0], n = lt(r);
for (const [o, i] of Gt(r).entries()) {
const s = e[t.length];
i === s && t.push(dt([n.concat({ id: s.id, index: o })]));
}
return t;
}, Oc = (e, t) => _t(e.documentElement, D(t)).node, ue = {
fromIndex: (e) => Ue(`/6/${(e + 1) * 2}`),
toIndex: (e) => (e == null ? void 0 : e.at(-1).index) / 2 - 1
}, en = (e) => {
let t = 0;
const r = (n) => {
if (n.id = t++, n.subitems) for (const o of n.subitems) r(o);
};
for (const n of e) r(n);
return e;
}, Xe = (e) => e.map((t) => {
var r;
return (r = t.subitems) != null && r.length ? [t, Xe(t.subitems)].flat() : t;
}).flat();
class fe {
async init({ toc: t, ids: r, splitHref: n, getFragment: o }) {
en(t);
const i = Xe(t), s = /* @__PURE__ */ new Map();
for (const [u, c] of i.entries()) {
const [l, f] = await n(c == null ? void 0 : c.href) ?? [], h = { fragment: f, item: c };
s.has(l) ? s.get(l).items.push(h) : s.set(l, { prev: i[u - 1], items: [h] });
}
const a = /* @__PURE__ */ new Map();
for (const [u, c] of r.entries())
s.has(c) ? a.set(c, s.get(c)) : a.set(c, a.get(r[u - 1]));
this.ids = r, this.map = a, this.getFragment = o;
}
getProgress(t, r) {
var u;
if (!this.ids) return;
const n = this.ids[t], o = this.map.get(n);
if (!o) return null;
const { prev: i, items: s } = o;
if (!s) return i;
if (!r || s.length === 1 && !s[0].fragment) return s[0].item;
const a = r.startContainer.getRootNode();
for (const [c, { fragment: l }] of s.entries()) {
const f = this.getFragment(a, l);
if (f && r.comparePoint(f, 0) > 0)
return ((u = s[c - 1]) == null ? void 0 : u.item) ?? i;
}
return s[s.length - 1].item;
}
}
class rn {
constructor(t, r, n) {
this.sizes = t.map((o) => o.linear != "no" && o.size > 0 ? o.size : 0), this.sizePerLoc = r, this.sizePerTimeUnit = n, this.sizeTotal = this.sizes.reduce((o, i) => o + i, 0), this.sectionFractions = this.#e();
}
#e() {
const { sizeTotal: t } = this, r = [0];
let n = 0;
for (const o of this.sizes) r.push((n += o) / t);
return r;
}
// get progress given index of and fractions within a section
getProgress(t, r, n = 0) {
const { sizes: o, sizePerLoc: i, sizePerTimeUnit: s, sizeTotal: a } = this, u = o[t] ?? 0, l = o.slice(0, t).reduce((v, y) => v + y, 0) + r * u, f = l + n * u, h = a - l, d = (1 - r) * u;
return {
fraction: f / a,
section: {
current: t,
total: o.length
},
location: {
current: Math.floor(l / i),
next: Math.floor(f / i),
total: Math.ceil(a / i)
},
time: {
section: d / s,
total: h / s
}
};
}
// the inverse of `getProgress`
// get index of and fraction in section based on total fraction
getSection(t) {
if (t <= 0) return [0, 0];
if (t >= 1) return [this.sizes.length - 1, 1];
t = t + Number.EPSILON;
const { sizeTotal: r } = this;
let n = this.sectionFractions.findIndex((i) => i > t) - 1;
if (n < 0) return [0, 0];
for (; !this.sizes[n]; ) n++;
const o = (t - this.sectionFractions[n]) / (this.sizes[n] / r);
return [n, o];
}
}
const $ = (e) => document.createElementNS("http://www.w3.org/2000/svg", e);
class he {
#e = $("svg");
#t = /* @__PURE__ */ new Map();
#n = null;
constructor(t) {
this.#n = t, Object.assign(this.#e.style, {
position: "absolute",
top: "0",
left: "0",
width: "100%",
height: "100%",
pointerEvents: "none"
});
}
get element() {
return this.#e;
}
get #r() {
return /^((?!chrome|android).)*AppleWebKit/i.test(navigator.userAgent) && !window.chrome && window.getComputedStyle(this.#n.body).zoom || 1;
}
#o(t) {
var i;
const r = t.commonAncestorContainer, n = Array.from(((i = r.querySelectorAll) == null ? void 0 : i.call(r, "p")) || []);
if (n.length === 0) return [t];
const o = [];
return n.forEach((s) => {
const a = document.createRange();
t.intersectsNode(s) && (a.selectNodeContents(s), a.compareBoundaryPoints(Range.START_TO_START, t) < 0 && a.setStart(t.startContainer, t.startOffset), a.compareBoundaryPoints(Range.END_TO_END, t) > 0 && a.setEnd(t.endContainer, t.endOffset), o.push(a));
}), o;
}
add(t, r, n, o) {
this.#t.has(t) && this.remove(t), typeof r == "function" && (r = r(this.#e.getRootNode()));
const i = this.#r;
let s = [];
this.#o(r).forEach((u) => {
const c = Array.from(u.getClientRects()).map((l) => ({
left: l.left * i,
top: l.top * i,
right: l.right * i,
bottom: l.bottom * i,
width: l.width * i,
height: l.height * i
}));
s = s.concat(c);
});
const a = n(s, o);
this.#e.append(a), this.#t.set(t, { range: r, draw: n, options: o, element: a, rects: s });
}
remove(t) {
this.#t.has(t) && (this.#e.removeChild(this.#t.get(t).element), this.#t.delete(t));
}
redraw() {
for (const t of this.#t.values()) {
const { range: r, draw: n, options: o, element: i } = t;
this.#e.removeChild(i);
const s = this.#r;
let a = [];
this.#o(r).forEach((c) => {
const l = Array.from(c.getClientRects()).map((f) => ({
left: f.left * s,
top: f.top * s,
right: f.right * s,
bottom: f.bottom * s,
width: f.width * s,
height: f.height * s
}));
a = a.concat(l);
});
const u = n(a, o);
this.#e.append(u), t.element = u, t.rects = a;
}
}
hitTest({ x: t, y: r }) {
const n = Array.from(this.#t.entries());
for (let o = n.length - 1; o >= 0; o--) {
const [i, s] = n[o];
for (const { left: a, top: u, right: c, bottom: l } of s.rects)
if (u <= r && a <= t && l > r && c > t)
return [i, s.range];
}
return [];
}
static underline(t, r = {}) {
const { color: n = "red", width: o = 2, padding: i = 0, writingMode: s } = r, a = $("g");
if (a.setAttribute("fill", n), s === "vertical-rl" || s === "vertical-lr")
for (const { right: u, top: c, height: l } of t) {
const f = $("rect");
f.setAttribute("x", u - o / 2 + i), f.setAttribute("y", c), f.setAttribute("height", l), f.setAttribute("width", o), a.append(f);
}
else for (const { left: u, bottom: c, width: l } of t) {
const f = $("rect");
f.setAttribute("x", u), f.setAttribute("y", c - o / 2 + i), f.setAttribute("height", o), f.setAttribute("width", l), a.append(f);
}
return a;
}
static strikethrough(t, r = {}) {
const { color: n = "red", width: o = 2, writingMode: i } = r, s = $("g");
if (s.setAttribute("fill", n), i === "vertical-rl" || i === "vertical-lr")
for (const { right: a, left: u, top: c, height: l } of t) {
const f = $("rect");
f.setAttribute("x", (a + u) / 2), f.setAttribute("y", c), f.setAttribute("height", l), f.setAttribute("width", o), s.append(f);
}
else for (const { left: a, top: u, bottom: c, width: l } of t) {
const f = $("rect");
f.setAttribute("x", a), f.setAttribute("y", (u + c) / 2), f.setAttribute("height", o), f.setAttribute("width", l), s.append(f);
}
return s;
}
static squiggly(t, r = {}) {
const { color: n = "red", width: o = 2, padding: i = 0, writingMode: s } = r, a = $("g");
a.setAttribute("fill", "none"), a.setAttribute("stroke", n), a.setAttribute("stroke-width", o);
const u = o * 1.5;
if (s === "vertical-rl" || s === "vertical-lr")
for (const { right: c, top: l, height: f } of t) {
const h = $("path"), d = Math.round(f / u / 1.5), v = f / d, y = Array.from(
{ length: d },
(R, S) => `l${S % 2 ? -u : u} ${v}`
).join("");
h.setAttribute("d", `M${c - o / 2 + i} ${l}${y}`), a.append(h);
}
else for (const { left: c, bottom: l, width: f } of t) {
const h = $("path"), d = Math.round(f / u / 1.5), v = f / d, y = Array.from(
{ length: d },
(R, S) => `l${v} ${S % 2 ? u : -u}`
).join("");
h.setAttribute("d", `M${c} ${l + o / 2 + i}${y}`), a.append(h);
}
return a;
}
static highlight(t, r = {}) {
const { color: n = "red", padding: o = 0 } = r, i = $("g");
i.setAttribute("fill", n), i.style.opacity = "var(--overlayer-highlight-opacity, .3)", i.style.mixBlendMode = "var(--overlayer-highlight-blend-mode, normal)";
for (const { left: s, top: a, height: u, width: c } of t) {
const l = $("rect");
l.setAttribute("x", s - o), l.setAttribute("y", a - o), l.setAttribute("height", u + o * 2), l.setAttribute("width", c + o * 2), i.append(l);
}
return i;
}
static outline(t, r = {}) {
const { color: n = "red", width: o = 3, padding: i = 0, radius: s = 3 } = r, a = $("g");
a.setAttribute("fill", "none"), a.setAttribute("stroke", n), a.setAttribute("stroke-width", o);
for (const { left: u, top: c, height: l, width: f } of t) {
const h = $("rect");
h.setAttribute("x", u - i), h.setAttribute("y", c - i), h.setAttribute("height", l + i * 2), h.setAttribute("width", f + i * 2), h.setAttribute("rx", s), a.append(h);
}
return a;
}
// make an exact copy of an image in the overlay
// one can then apply filters to the entire element, without affecting them;
// it's a bit silly and probably better to just invert images twice
// (though the color will be off in that case if you do heu-rotate)
static copyImage([t], r = {}) {
const { src: n } = r, o = $("image"), { left: i, top: s, height: a, width: u } = t;
return o.setAttribute("href", n), o.setAttribute("x", i), o.setAttribute("y", s), o.setAttribute("height", a), o.setAttribute("width", u), o;
}
}
const nn = (e, t) => {
const r = [];
for (let n = t.currentNode; n; n = t.nextNode()) {
const o = e.comparePoint(n, 0);
if (o === 0) r.push(n);
else if (o > 0) break;
}
return r;
}, on = (e, t) => {
const r = [];
for (let n = t.nextNode(); n; n = t.nextNode())
r.push(n);
return r;
}, sn = NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_CDATA_SECTION, an = (e) => {
if (e.nodeType === 1) {
const t = e.tagName.toLowerCase();
return t === "script" || t === "style" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_SKIP;
}
return NodeFilter.FILTER_ACCEPT;
}, de = function* (e, t) {
const r = e.commonAncestorContainer ?? e.body ?? e, n = document.createTreeWalker(r, sn, { acceptNode: an }), i = (e.commonAncestorContainer ? nn : on)(e, n), s = i.map((u) => u.nodeValue ?? ""), a = (u, c, l, f) => {
const h = document.createRange();
return h.setStart(i[u], c), h.setEnd(i[l], f), h;
};
for (const u of t(s, a)) yield u;
}, V = "foliate-search:", cn = async (e) => {
const t = new Uint8Array(await e.slice(0, 4).arrayBuffer());
return t[0] === 80 && t[1] === 75 && t[2] === 3 && t[3] === 4;
}, ln = ({ name: e, type: t }) => t === "application/vnd.comicbook+zip" || e.endsWith(".cbz"), un = ({ name: e, type: t }) => t === "application/x-fictionbook+xml" || e.endsWith(".fb2"), fn = ({ name: e, type: t }) => t === "application/x-zip-compressed-fb2" || e.endsWith(".fb2.zip") || e.endsWith(".fbz"), hn = async (e) => {
const { configure: t, ZipReader: r, BlobReader: n, TextWriter: o, BlobWriter: i } = await import("./zip-Dk_eClhA.js");
t({ useWebWorkers: !1 });
const a = await new r(new n(e)).getEntries(), u = new Map(a.map((d) => [d.filename, d])), c = (d) => (v, ...y) => u.has(v) ? d(u.get(v), ...y) : null, l = c((d) => d.getData(new o())), f = c((d, v) => d.getData(new i(v)));
return { entries: a, loadText: l, loadBlob: f, getSize: (d) => {
var v;
return ((v = u.get(d)) == null ? void 0 : v.uncompressedSize) ?? 0;
} };
}, Ze = async (e) => e.isFile ? e : (await Promise.all(Array.from(
await new Promise((t, r) => e.createReader().readEntries((n) => t(n), (n) => r(n))),
Ze
))).flat(), dn = async (e) => {
const t = await Ze(e), r = await Promise.all(
t.map((l) => new Promise((f, h) => l.file(
(d) => f([d, l.fullPath]),
(d) => h(d)
)))
), n = new Map(r.map(([l, f]) => [f.replace(e.fullPath + "/", ""), l])), o = new TextDecoder(), i = (l) => l ? o.decode(l) : null, s = (l) => {
var f;
return ((f = n.get(l)) == null ? void 0 : f.arrayBuffer()) ?? null;
};
return { loadText: async (l) => i(await s(l)), loadBlob: (l) => n.get(l), getSize: (l) => {
var f;
return ((f = n.get(l)) == null ? void 0 : f.size) ?? 0;
} };
};
class vn extends Error {
}
class pn extends Error {
}
class gn extends Error {
}
const yn = async (e) => {
const t = await fetch(e);
if (!t.ok) throw new vn(
`${t.status} ${t.statusText}`,
{ cause: t }
);
return new File([await t.blob()], new URL(t.url).pathname);
}, mn = async (e) => {
typeof e == "string" && (e = await yn(e));
let t;
if (e.isDirectory) {
const r = await dn(e), { EPUB: n } = await import("./epub-Cp76KMm5.js");
t = await new n(r).init();
} else if (e.size) if (await cn(e)) {
const r = await hn(e);
if (ln(e)) {
const { makeComicBook: n } = await import("./comic-book-CwHQZGIL.js");
t = n(r, e);
} else if (fn(e)) {
const { makeFB2: n } = await import("./fb2-iMXnpBXU.js"), { entries: o } = r, i = o.find((a) => a.filename.endsWith(".fb2")), s = await r.loadBlob((i ?? o[0]).filename);
t = await n(s);
} else {
const { EPUB: n } = await import("./epub-Cp76KMm5.js");
t = await new n(r).init();
}
} else {
const { isMOBI: r, MOBI: n } = await import("./mobi-2ELj5U7Y.js");
if (await r(e)) {
const o = await import("./fflate-D9v8asEo.js");
t = await new n({ unzlib: o.unzlibSync }).open(e);
} else if (un(e)) {
const { makeFB2: o } = await import("./fb2-iMXnpBXU.js");
t = await o(e);
}
}
else throw new pn("File not found");
if (!t) throw new gn("File type not supported");
return t;
};
class Ut {
#e;
#t;
#n;
#r;
constructor(t, r, n = {}) {
this.#t = t, this.#n = r, this.#r = n, this.#r.hidden && this.hide(), this.#t.addEventListener("mousemove", ({ screenX: o, screenY: i }) => {
o === this.#r.x && i === this.#r.y || (this.#r.x = o, this.#r.y = i, this.show(), this.#e && clearTimeout(this.#e), r() && (this.#e = setTimeout(this.hide.bind(this), 1e3)));
}, !1);
}
cloneFor(t) {
return new Ut(t, this.#n, this.#r);
}
hide() {
this.#t.style.cursor = "none", this.#r.hidden = !0;
}
show() {
this.#t.style.removeProperty("cursor"), this.#r.hidden = !1;
}
}
class bn extends EventTarget {
#e = [];
#t = -1;
pushState(t) {
const r = this.#e[this.#t];
r === t || r != null && r.fraction && r.fraction === t.fraction || (this.#e[++this.#t] = t, this.#e.length = this.#t + 1, this.dispatchEvent(new Event("index-change")));
}
replaceState(t) {
const r = this.#t;
this.#e[r] = t;
}
back() {
const t = this.#t;
if (t <= 0) return;
const r = { state: this.#e[t - 1] };
this.#t = t - 1, this.dispatchEvent(new CustomEvent("popstate", { detail: r })), this.dispatchEvent(new Event("index-change"));
}
forward() {
const t = this.#t;
if (t >= this.#e.length - 1) return;
const r = { state: this.#e[t + 1] };
this.#t = t + 1, this.dispatchEvent(new CustomEvent("popstate", { detail: r })), this.dispatchEvent(new Event("index-change"));
}
get canGoBack() {
return this.#t > 0;
}
get canGoForward() {
return this.#t < this.#e.length - 1;
}
clear() {
this.#e = [], this.#t = -1;
}
}
const wn = (e) => {
var t, r;
if (!e) return {};
try {
const n = Intl.getCanonicalLocales(e)[0], o = new Intl.Locale(n), i = ["zh", "ja", "kr"].includes(o.language), s = (r = ((t = o.getTextInfo) == null ? void 0 : t.call(o)) ?? o.textInfo) == null ? void 0 : r.direction;
return { canonical: n, locale: o, isCJK: i, direction: s };
} catch (n) {
return console.warn(n), {};
}
};
class $n extends HTMLElement {
#e = this.attachShadow({ mode: "closed" });
#t;
#n;
#r;
#o = /* @__PURE__ */ new Map();
#a = new Ut(this, () => this.hasAttribute("autohide-cursor"));
isFixedLayout = !1;
lastLocation;
history = new bn();
constructor() {
super(), this.history.addEventListener("popstate", ({ detail: t }) => {
const r = this.resolveNavigation(t.state);
this.renderer.goTo(r);
});
}
async open(t) {
var r, n;
if ((typeof t == "string" || typeof t.arrayBuffer == "function" || t.isDirectory) && (t = await mn(t)), this.book = t, this.language = wn((r = t.metadata) == null ? void 0 : r.language), t.splitTOCHref && t.getTOCFragment) {
const o = t.sections.map((a) => a.id);
this.#t = new rn(t.sections, 1500, 1600);
const i = t.splitTOCHref.bind(t), s = t.getTOCFragment.bind(t);
this.#n = new fe(), await this.#n.init({
toc: t.toc ?? [],
ids: o,
splitHref: i,
getFragment: s
}), this.#r = new fe(), await this.#r.init({
toc: t.pageList ?? [],
ids: o,
splitHref: i,
getFragment: s
});
}
if (this.isFixedLayout = ((n = this.book.rendition) == null ? void 0 : n.layout) === "pre-paginated", this.isFixedLayout ? (await import("./fixed-layout-D6op8WRG.js"), this.renderer = document.createElement("foliate-fxl")) : (await import("./paginator-CRfybBXA.js"), this.renderer = document.createElement("foliate-paginator")), this.renderer.setAttribute("exportparts", "head,foot,filter,container"), this.renderer.addEventListener("load", (o) => this.#l(o.detail)), this.renderer.addEventListener("relocate", (o) => this.#c(o.detail)), this.renderer.addEventListener("create-overlayer", (o) => o.detail.attach(this.#f(o.detail))), this.renderer.open(t), this.#e.append(this.renderer), t.sections.some((o) => o.mediaOverlay)) {
const o = t.media.activeClass, i = t.media.playbackActiveClass;
this.mediaOverlay = t.getMediaOverlay();
let s;
this.mediaOverlay.addEventListener("highlight", (a) => {
const u = this.resolveNavigation(a.detail.text);
this.renderer.goTo(u).then(() => {
const { doc: c } = this.renderer.getContents().find((f) => f.index = u.index), l = u.anchor(c);
l.classList.add(o), i && l.ownerDocument.documentElement.classList.add(i), s = new WeakRef(l);
});
}), this.mediaOverlay.addEventListener("unhighlight", () => {
const a = s == null ? void 0 : s.deref();
a && (a.classList.remove(o), i && a.ownerDocument.documentElement.classList.remove(i));
});
}
}
close() {
var t, r;
(t = this.renderer) == null || t.destroy(), (r = this.renderer) == null || r.remove(), this.#t = null, this.#n = null, this.#r = null, this.#o = /* @__PURE__ */ new Map(), this.lastLocation = null, this.history.clear(), this.tts = null, this.mediaOverlay = null;
}
goToTextStart() {
var t, r;
return this.goTo(((r = (t = this.book.landmarks) == null ? void 0 : t.find((n) => n.type.includes("bodymatter") || n.type.includes("text"))) == null ? void 0 : r.href) ?? this.book.sections.findIndex((n) => n.linear !== "no"));
}
async init({ lastLocation: t, showTextStart: r }) {
const n = t ? this.resolveNavigation(t) : null;
n ? (await this.renderer.goTo(n), this.history.pushState(t)) : r ? await this.goToTextStart() : (this.history.pushState(0), await this.next());
}
#i(t, r, n) {
return this.dispatchEvent(new CustomEvent(t, { detail: r, cancelable: n }));
}
#c({ reason: t, range: r, index: n, fraction: o, size: i }) {
var l, f, h;
const s = ((l = this.#t) == null ? void 0 : l.getProgress(n, o, i)) ?? {}, a = (f = this.#n) == null ? void 0 : f.getProgress(n, r), u = (h = this.#r) == null ? void 0 : h.getProgress(n, r), c = this.getCFI(n, r);
this.lastLocation = { ...s, tocItem: a, pageItem: u, cfi: c, range: r }, (t === "snap" || t === "page" || t === "scroll") && this.history.replaceState(c), this.#i("relocate", this.lastLocation);
}
#l({ doc: t, index: r }) {
t.documentElement.lang ||= this.language.canonical ?? "", this.language.isCJK || (t.documentElement.dir ||= this.language.direction ?? ""), this.#u(t, r), this.#a.cloneFor(t.documentElement), this.#i("load", { doc: t, index: r });
}
#u(t, r) {
const { book: n } = this, o = n.sections[r];
t.addEventListener("click", (i) => {
var c, l;
const s = i.target.closest("a[href]");
if (!s) return;
i.preventDefault();
const a = s.getAttribute("href"), u = ((c = o == null ? void 0 : o.resolveHref) == null ? void 0 : c.call(o, a)) ?? a;
(l = n == null ? void 0 : n.isExternal) != null && l.call(n, u) ? Promise.resolve(this.#i("external-link", { a: s, href: u }, !0)).then((f) => f ? globalThis.open(u, "_blank") : null).catch((f) => console.error(f)) : Promise.resolve(this.#i("link", { a: s, href: u }, !0)).then((f) => f ? this.goTo(u) : null).catch((f) => console.error(f));
});
}
async addAnnotation(t, r) {
var u;
const { value: n } = t;
if (n.startsWith(V)) {
const c = n.replace(V, ""), { index: l, anchor: f } = await this.resolveNavigation(c), h = this.#s(l);
if (h) {
const { overlayer: d, doc: v } = h;
if (r) {
d.remove(n);
return;
}
const y = v ? f(v) : f;
d.add(n, y, he.outline);
}
return;
}
const { index: o, anchor: i } = await this.resolveNavigation(n), s = this.#s(o);
if (s) {
const { overlayer: c, doc: l } = s;
if (c.remove(n), !r) {
const f = l ? i(l) : i, h = (d, v) => c.add(n, f, d, v);
this.#i("draw-annotation", { draw: h, annotation: t, doc: l, range: f });
}
}
const a = ((u = this.#n.getProgress(o)) == null ? void 0 : u.label) ?? "";
return { index: o, label: a };
}
deleteAnnotation(t) {
return this.addAnnotation(t, !0);
}
#s(t) {
return this.renderer.getContents().find((r) => r.index === t && r.overlayer);
}
#f({ doc: t, index: r }) {
const n = new he(t);
t.addEventListener("click", (i) => {
const [s, a] = n.hitTest(i);
s && !s.startsWith(V) && this.#i("show-annotation", { value: s, index: r, range: a });
}, !1);
const o = this.#o.get(r);
if (o) for (const i of o) this.addAnnotation(i);
return this.#i("create-overlay", { index: r }), n;
}
async showAnnotation(t) {
const { value: r } = t, n = await this.goTo(r);
if (n) {
const { index: o, anchor: i } = n, { doc: s } = this.#s(o), a = i(s);
this.#i("show-annotation", { value: r, index: o, range: a });
}
}
getCFI(t, r) {
const n = this.book.sections[t].cfi ?? ue.fromIndex(t);
return r ? Yr(n, Qr(r)) : n;
}
resolveCFI(t) {
if (this.book.resolveCFI)
return this.book.resolveCFI(t);
{
const r = ct(t);
return { index: ue.toIndex((r.parent ?? r).shift()), anchor: (i) => tn(i, r) };
}
}
resolveNavigation(t) {
try {
if (typeof t == "number") return { index: t };
if (typeof t.fraction == "number") {
const [r, n] = this.#t.getSection(t.fraction);
return { index: r, anchor: n };
}
return ht.test(t) ? this.resolveCFI(t) : this.book.resolveHref(t);
} catch (r) {
console.error(r), console.error(`Could not resolve target ${t}`);
}
}
async goTo(t) {
const r = this.resolveNavigation(t);
try {
return await this.renderer.goTo(r), this.history.pushState(t), r;
} catch (n) {
console.error(n), console.error(`Could not go to ${t}`);
}
}
async goToFraction(t) {
const [r, n] = this.#t.getSection(t);
await this.renderer.goTo({ index: r, anchor: n }), this.history.pushState({ fraction: t });
}
async select(t) {
try {
const r = await this.resolveNavigation(t);
await this.renderer.goTo({ ...r, select: !0 }), this.history.pushState(t);
} catch (r) {
console.error(r), console.error(`Could not go to ${t}`);
}
}
deselect() {
for (const { doc: t } of this.renderer.getContents())
t.defaultView.getSelection().removeAllRanges();
}
getSectionFractions() {
var t;
return (((t = this.#t) == null ? void 0 : t.sectionFractions) ?? []).map((r) => r + Number.EPSILON);
}
getProgressOf(t, r) {
var i, s;
const n = (i = this.#n) == null ? void 0 : i.getProgress(t, r), o = (s = this.#r) == null ? void 0 : s.getProgress(t, r);
return { tocItem: n, pageItem: o };
}
async getTOCItemOf(t) {
try {
const { index: r, anchor: n } = await this.resolveNavigation(t), o = await this.book.sections[r].createDocument(), i = n(o), s = i instanceof Range, a = s ? i : o.createRange();
return s || a.selectNodeContents(i), this.#n.getProgress(r, a);
} catch (r) {
console.error(r), console.error(`Could not get ${t}`);
}
}
async prev(t) {
await this.renderer.prev(t);
}
async next(t) {
await this.renderer.next(t);
}
goLeft() {
return this.book.dir === "rtl" ? this.next() : this.prev();
}
goRight() {
return this.book.dir === "rtl" ? this.prev() : this.next();
}
async *#h(t, r, n) {
const o = await this.book.sections[n].createDocument();
for (const { range: i, excerpt: s } of t(o, r))
yield { cfi: this.getCFI(n, i), excerpt: s };
}
async *#d(t, r) {
const { sections: n } = this.book;
for (const [o, { createDocument: i }] of n.entries()) {
if (!i) continue;
const s = await i(), a = Array.from(t(s, r), ({ range: c, excerpt: l }) => ({ cfi: this.getCFI(o, c), excerpt: l }));
yield { progress: (o + 1) / n.length }, a.length && (yield { index: o, subitems: a });
}
}
async *search(t) {
var u;
this.clearSearch();
const { searchMatcher: r } = await import("./search-BIpxJuuh.js"), { query: n, index: o } = t, i = r(
de,
{ defaultLocale: this.language, ...t }
), s = o != null ? this.#h(i, n, o) : this.#d(i, n), a = [];
this.#o.set(o, a);
for await (const c of s)
if (c.subitems) {
const l = c.subitems.map(({ cfi: f }) => ({ value: V + f }));
this.#o.set(c.index, l);
for (const f of l) this.addAnnotation(f);
yield {
label: ((u = this.#n.getProgress(c.index)) == null ? void 0 : u.label) ?? "",
subitems: c.subitems
};
} else {
if (c.cfi) {
const l = { value: V + c.cfi };
a.push(l), this.addAnnotation(l);
}
yield c;
}
yield "done";
}
clearSearch() {
for (const t of this.#o.values())
for (const r of t) this.deleteAnnotation(r);
this.#o.clear();
}
async initTTS(t = "word") {
const r = this.renderer.getContents()[0].doc;
if (this.tts && this.tts.doc === r) return;
const { TTS: n } = await import("./tts-DTWRtlGz.js");
this.tts = new n(r, de, (o) => this.renderer.scrollToAnchor(o, !0), t);
}
startMediaOverlay() {
const { index: t } = this.renderer.getContents()[0];
return this.mediaOverlay.start(t);
}
}
customElements.define("foliate-view", $n);
var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, G = function(e) {
return e && e.Math === Math && e;
}, I = (
// eslint-disable-next-line es/no-global-this -- safe
G(typeof globalThis == "object" && globalThis) || G(typeof window == "object" && window) || // eslint-disable-next-line no-restricted-globals -- safe
G(typeof self == "object" && self) || G(typeof Z == "object" && Z) || G(typeof Z == "object" && Z) || // eslint-disable-next-line no-new-func -- fallback
/* @__PURE__ */ function() {
return this;
}() || Function("return this")()
), Ht = {}, A = function(e) {
try {
return !!e();
} catch {
return !0;
}
}, Tn = A, k = !Tn(function() {
return Object.defineProperty({}, 1, { get: function() {
return 7;
} })[1] !== 7;
}), En = A, Yt = !En(function() {
var e = (function() {
}).bind();
return typeof e != "function" || e.hasOwnProperty("prototype");
}), Sn = Yt, J = Function.prototype.call, z = Sn ? J.bind(J) : function() {
return J.apply(J, arguments);
}, Je = {}, Qe = {}.propertyIsEnumerable, tr = Object.getOwnPropertyDescriptor, On = tr && !Qe.call({ 1: 2 }, 1);
Je.f = On ? function(t) {
var r = tr(this, t);
return !!r && r.enumerable;
} : Qe;
var er = function(e, t) {
return {
enumerable: !(e & 1),
configurable: !(e & 2),
writable: !(e & 4),
value: t
};
}, rr = Yt, nr = Function.prototype, Mt = nr.call, In = rr && nr.bind.bind(Mt, Mt), T = rr ? In : function(e) {
return function() {
return Mt.apply(e, arguments);
};
}, or = T, Pn = or({}.toString), Cn = or("".slice), qt = function(e) {
return Cn(Pn(e), 8, -1);
}, An = T, Rn = A, xn = qt, bt = Object, Nn = An("".split), Fn = Rn(function() {
return !bt("z").propertyIsEnumerable(0);
}) ? function(e) {
return xn(e) === "String" ? Nn(e, "") : bt(e);
} : bt, Xt = function(e) {
return e == null;
}, jn = Xt, kn = TypeError, vt = function(e) {
if (jn(e)) throw new kn("Can't call method on " + e);
return e;
}, Bn = Fn, _n = vt, Zt = function(e) {
return Bn(_n(e));
}, wt = typeof document == "object" && document.all, P = typeof wt > "u" && wt !== void 0 ? function(e) {
return typeof e == "function" || e === wt;
} : function(e) {
return typeof e == "function";
}, Mn = P, pt = function(e) {
return typeof e == "object" ? e !== null : Mn(e);
}, $t = I, Ln = P, Dn = function(e) {
return Ln(e) ? e : void 0;
}, Jt = function(e, t) {
return arguments.length < 2 ? Dn($t[e]) : $t[e] && $t[e][t];
}, zn = T, ir = zn({}.isPrototypeOf), Wn = I, ve = Wn.navigator, pe = ve && ve.userAgent, Kn = pe ? String(pe) : "", sr = I, Tt = Kn, ge = sr.process, ye = sr.Deno, me = ge && ge.versions || ye && ye.version, be = me && me.v8, O, ut;
be && (O = be.split("."), ut = O[0] > 0 && O[0] < 4 ? 1 : +(O[0] + O[1]));
!ut && Tt && (O = Tt.match(/Edge\/(\d+)/), (!O || O[1] >= 74) && (O = Tt.match(/Chrome\/(\d+)/), O && (ut = +O[1])));
var Vn = ut, we = Vn, Gn = A, Un = I, Hn = Un.String, ar = !!Object.getOwnPropertySymbols && !Gn(function() {
var e = Symbol("symbol detection");
return !Hn(e) || !(Object(e) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
!Symbol.sham && we && we < 41;
}), Yn = ar, cr = Yn && !Symbol.sham && typeof Symbol.iterator == "symbol", qn = Jt, Xn = P, Zn = ir, Jn = cr, Qn = Object, lr = Jn ? function(e) {
return typeof e == "symbol";
} : function(e) {
var t = qn("Symbol");
return Xn(t) && Zn(t.prototype, Qn(e));
}, to = String, Qt = function(e) {
try {
return to(e);
} catch {
return "Object";
}
}, eo = P, ro = Qt, no = TypeError, H = function(e) {
if (eo(e)) return e;
throw new no(ro(e) + " is not a function");
}, oo = H, io = Xt, te = function(e, t) {
var r = e[t];
return io(r) ? void 0 : oo(r);
}, Et = z, St = P, Ot = pt, so = TypeError, ao = function(e, t) {
var r, n;
if (t === "string" && St(r = e.toString) && !Ot(n = Et(r, e)) || St(r = e.valueOf) && !Ot(n = Et(r, e)) || t !== "string" && St(r = e.toString) && !Ot(n = Et(r, e))) return n;
throw new so("Can't convert object to primitive value");
}, ur = { exports: {} }, $e = I, co = Object.defineProperty, ee = function(e, t) {
try {
co($e, e, { value: t, configurable: !0, writable: !0 });
} catch {
$e[e] = t;
}
return t;
}, lo = I, uo = ee, Te = "__core-js_shared__", Ee = ur.exports = lo[Te] || uo(Te, {});
(Ee.versions || (Ee.versions = [])).push({
version: "3.45.1",
mode: "global",
copyright: "© 2014-2025 Denis Pushkarev (zloirock.ru)",
license: "https://github.com/zloirock/core-js/blob/v3.45.1/LICENSE",
source: "https://github.com/zloirock/core-js"
});
var re = ur.exports, Se = re, fr = function(e, t) {
return Se[e] || (Se[e] = t || {});
}, fo = vt, ho = Object, vo = function(e) {
return ho(fo(e));
}, po = T, go = vo, yo = po({}.hasOwnProperty), B = Object.hasOwn || function(t, r) {
return yo(go(t), r);
}, mo = T, bo = 0, wo = Math.random(), $o = mo(1.1.toString), hr = function(e) {
return "Symbol(" + (e === void 0 ? "" : e) + ")_" + $o(++bo + wo, 36);
}, To = I, Eo = fr, Oe = B, So = hr, Oo = ar, Io = cr, L = To.Symbol, It = Eo("wks"), Po = Io ? L.for || L : L && L.withoutSetter || So, Y = function(e) {
return Oe(It, e) || (It[e] = Oo && Oe(L, e) ? L[e] : Po("Symbol." + e)), It[e];
}, Co = z, Ie = pt, Pe = lr, Ao = te, Ro = ao, xo = Y, No = TypeError, Fo = xo("toPrimitive"), jo = function(e, t) {
if (!Ie(e) || Pe(e)) return e;
var r = Ao(e, Fo), n;
if (r) {
if (t === void 0 && (t = "default"), n = Co(r, e, t), !Ie(n) || Pe(n)) return n;
throw new No("Can't convert object to primitive value");
}
return t === void 0 && (t = "number"), Ro(e, t);
}, ko = jo, Bo = lr, ne = function(e) {
var t = ko(e, "string");
return Bo(t) ? t : t + "";
}, _o = I, Ce = pt, Lt = _o.document, Mo = Ce(Lt) && Ce(Lt.createElement), Lo = function(e) {
return Mo ? Lt.createElement(e) : {};
}, Do = k, zo = A, Wo = Lo, dr = !Do && !zo(function() {
return Object.defineProperty(Wo("div"), "a", {
get: function() {
return 7;
}
}).a !== 7;
}), Ko = k, Vo = z, Go = Je, Uo = er, Ho = Zt, Yo = ne, qo = B, Xo = dr, Ae = Object.getOwnPropertyDescriptor;
Ht.f = Ko ? Ae : function(t, r) {
if (t = Ho(t), r = Yo(r), Xo) try {
return Ae(t, r);
} catch {
}
if (qo(t, r)) return Uo(!Vo(Go.f, t, r), t[r]);
};
var gt = {}, Zo = k, Jo = A, Qo = Zo && Jo(function() {
return Object.defineProperty(function() {
}, "prototype", {
value: 42,
writable: !1
}).prototype !== 42;
}), ti = pt, ei = String, ri = TypeError, q = function(e) {
if (ti(e)) return e;
throw new ri(ei(e) + " is not an object");
}, ni = k, oi = dr, ii = Qo, Q = q, Re = ne, si = TypeError, Pt = Object.defineProperty, ai = Object.getOwnPropertyDescriptor, Ct = "enumerable", At = "configurable", Rt = "writable";
gt.f = ni ? ii ? function(t, r, n) {
if (Q(t), r = Re(r), Q(n), typeof t == "function" && r === "prototype" && "value" in n && Rt in n && !n[Rt]) {
var o = ai(t, r);
o && o[Rt] && (t[r] = n.value, n = {
configurable: At in n ? n[At] : o[At],
enumerable: Ct in n ? n[Ct] : o[Ct],
writable: !1
});
}
return Pt(t, r, n);
} : Pt : function(t, r, n) {
if (Q(t), r = Re(r), Q(n), oi) try {
return Pt(t, r, n);
} catch {
}
if ("get" in n || "set" in n) throw new si("Accessors not supported");
return "value" in n && (t[r] = n.value), t;
};
var ci = k, li = gt, ui = er, vr = ci ? function(e, t, r) {
return li.f(e, t, ui(1, r));
} : function(e, t, r) {
return e[t] = r, e;
}, pr = { exports: {} }, Dt = k, fi = B, gr = Function.prototype, hi = Dt && Object.getOwnPropertyDescriptor, di = fi(gr, "name"), vi = di && (!Dt || Dt && hi(gr, "name").configurable), pi = {
CONFIGURABLE: vi
}, gi = T, yi = P, zt = re, mi = gi(Function.toString);
yi(zt.inspectSource) || (zt.inspectSource = function(e) {
return mi(e);
});
var bi = zt.inspectSource, wi = I, $i = P, xe = wi.WeakMap, Ti = $i(xe) && /native code/.test(String(xe)), Ei = fr, Si = hr, Ne = Ei("keys"), Oi = function(e) {
return Ne[e] || (Ne[e] = Si(e));
}, yr = {}, Ii = Ti, mr = I, Pi = vr, xt = B, Nt = re, Ci = Oi, Ai = yr, Fe = "Object already initialized", je = mr.TypeError, Ri = mr.WeakMap, Wt, ft, Kt, xi = function(e) {
return Kt(e) ? ft(e) : Wt(e, {});
};
if (Ii || Nt.state) {
var C = Nt.state || (Nt.state = new Ri());
C.get = C.get, C.has = C.has, C.set = C.set, Wt = function(e, t) {
if (C.has(e)) throw new je(Fe);
return t.facade = e, C.set(e, t), t;
}, ft = function(e) {
return C.get(e) || {};
}, Kt = function(e) {
return C.has(e);
};
} else {
var M = Ci("state");
Ai[M] = !0, Wt = function(e, t) {
if (xt(e, M)) throw new je(Fe);
return t.facade = e, Pi(e, M, t), t;
}, ft = function(e) {
return xt(e, M) ? e[M] : {};
}, Kt = function(e) {
return xt(e, M);
};
}
var Ni = {
get: ft,
enforce: xi
}, oe = T, Fi = A, ji = P, tt = B, Vt = k, ki = pi.CONFIGURABLE, Bi = bi, br = Ni, _i = br.enforce, Mi = br.get, ke = String, it = Object.defineProperty, Li = oe("".slice), Di = oe("".replace), zi = oe([].join), Wi = Vt && !Fi(function() {
return it(function() {
}, "length", { value: 8 }).length !== 8;
}), Ki = String(String).split("String"), Vi = pr.exports = function(e, t, r) {
Li(ke(t), 0, 7) === "Symbol(" && (t = "[" + Di(ke(t), /^Symbol\(([^)]*)\).*$/, "$1") + "]"), r && r.getter && (t = "get " + t), r && r.setter && (t = "set " + t), (!tt(e, "name") || ki && e.name !== t) && (Vt ? it(e, "name", { value: t, configurable: !0 }) : e.name = t), Wi && r && tt(r, "arity") && e.length !== r.arity && it(e, "length", { value: r.arity });
try {
r && tt(r, "constructor") && r.constructor ? Vt && it(e, "prototype", { writable: !1 }) : e.prototype && (e.prototype = void 0);
} catch {
}
var n = _i(e);
return tt(n, "source") || (n.source = zi(Ki, typeof t == "string" ? t : "")), e;
};
Function.prototype.toString = Vi(function() {
return ji(this) && Mi(this).source || Bi(this);
}, "toString");
var Gi = pr.exports, Ui = P, Hi = gt, Yi = Gi, qi = ee, Xi = function(e, t, r, n) {
n || (n = {});
var o = n.enumerable, i = n.name !== void 0 ? n.name : t;
if (Ui(r) && Yi(r, i, n), n.global)
o ? e[t] = r : qi(t, r);
else {
try {
n.unsafe ? e[t] && (o = !0) : delete e[t];
} catch {
}
o ? e[t] = r : Hi.f(e, t, {
value: r,
enumerable: !1,
configurable: !n.nonConfigurable,
writable: !n.nonWritable
});
}
return e;
}, wr = {}, Zi = Math.ceil, Ji = Math.floor, Qi = Math.trunc || function(t) {
var r = +t;
return (r > 0 ? Ji : Zi)(r);
}, ts = Qi, $r = function(e) {
var t = +e;
return t !== t || t === 0 ? 0 : ts(t);
}, es = $r, rs = Math.max, ns = Math.min, os = function(e, t) {
var r = es(e);
return r < 0 ? rs(r + t, 0) : ns(r, t);
}, is = $r, ss = Math.min, as = function(e) {
var t = is(e);
return t > 0 ? ss(t, 9007199254740991) : 0;
}, cs = as, Tr = function(e) {
return cs(e.length);
}, ls = Zt, us = os, fs = Tr, hs = function(e) {
return function(t, r, n) {
var o = ls(t), i = fs(o);
if (i === 0) return !e && -1;
var s = us(n, i), a;
if (e && r !== r) {
for (; i > s; )
if (a = o[s++], a !== a) return !0;
} else for (; i > s; s++)
if ((e || s in o) && o[s] === r) return e || s || 0;
return !e && -1;
};
}, ds = {
// `Array.prototype.indexOf` method
// https://tc39.es/ecma262/#sec-array.prototype.indexof
indexOf: hs(!1)
}, vs = T, Ft = B, ps = Zt, gs = ds.indexOf, ys = yr, Be = vs([].push), ms = function(e, t) {
var r = ps(e), n = 0, o = [], i;
for (i in r) !Ft(ys, i) && Ft(r, i) && Be(o, i);
for (; t.length > n; ) Ft(r, i = t[n++]) && (~gs(o, i) || Be(o, i));
return o;
}, bs = [
"constructor",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toLocaleString",
"toString",
"valueOf"
], ws = ms, $s = bs, Ts = $s.concat("length", "prototype");
wr.f = Object.getOwnPropertyNames || function(t) {
return ws(t, Ts);
};
var Er = {};
Er.f = Object.getOwnPropertySymbols;
var Es = Jt, Ss = T, Os = wr, Is = Er, Ps = q, Cs = Ss([].concat), As = Es("Reflect", "ownKeys") || function(t) {
var r = Os.f(Ps(t)), n = Is.f;
return n ? Cs(r, n(t)) : r;
}, _e = B, Rs = As, xs = Ht, Ns = gt, Fs = function(e, t, r) {
for (var n = Rs(t), o = Ns.f, i = xs.f, s = 0; s < n.length; s++) {
var a = n[s];
!_e(e, a) && !(r && _e(r, a)) && o(e, a, i(t, a));
}
}, js = A, ks = P, Bs = /#|\.prototype\./, X = function(e, t) {
var r = Ms[_s(e)];
return r === Ds ? !0 : r === Ls ? !1 : ks(t) ? js(t) : !!t;
}, _s = X.normalize = function(e) {
return String(e).replace(Bs, ".").toLowerCase();
}, Ms = X.data = {}, Ls = X.NATIVE = "N", Ds = X.POLYFILL = "P", zs = X, et = I, Ws = Ht.f, Ks = vr, Vs = Xi, Gs = ee, Us = Fs, Hs = zs, Sr = function(e, t) {
var r = e.target, n = e.global, o = e.stat, i, s, a, u, c, l;
if (n ? s = et : o ? s = et[r] || Gs(r, {}) : s = et[r] && et[r].prototype, s) for (a in t) {
if (c = t[a], e.dontCallGetSet ? (l = Ws(s, a), u = l && l.value) : u = s[a], i = Hs(n ? a : r + (o ? "." : "#") + a, e.forced), !i && u !== void 0) {
if (typeof c == typeof u) continue;
Us(c, u);
}
(e.sham || u && u.sham) && Ks(c, "sham", !0), Vs(s, a, c, e);
}
}, Ys = qt, qs = T, Xs = function(e) {
if (Ys(e) === "Function") return qs(e);
}, Me = Xs, Zs = H, Js = Yt, Qs = Me(Me.bind), ta = function(e, t) {
return Zs(e), t === void 0 ? e : Js ? Qs(e, t) : function() {
return e.apply(t, arguments);
};
}, Or = {}, ea = Y, ra = Or, na = ea("iterator"), oa = Array.prototype, ia = function(e) {
return e !== void 0 && (ra.Array === e || oa[na] === e);
}, sa = Y, aa = sa("toStringTag"), Ir = {};
Ir[aa] = "z";
var ca = String(Ir) === "[object z]", la = ca, ua = P, st = qt, fa = Y, ha = fa("toStringTag"), da = Object, va = st(/* @__PURE__ */ function() {
return arguments;
}()) === "Arguments", pa = function(e, t) {
try {
return e[t];
} catch {
}
}, ga = la ? st : function(e) {
var t, r, n;
return e === void 0 ? "Undefined" : e === null ? "Null" : typeof (r = pa(t = da(e), ha)) == "string" ? r : va ? st(t) : (n = st(t)) === "Object" && ua(t.callee) ? "Arguments" : n;
}, ya = ga, Le = te, ma = Xt, ba = Or, wa = Y, $a = wa("iterator"), Pr = function(e) {
if (!ma(e)) return Le(e, $a) || Le(e, "@@iterator") || ba[ya(e)];
}, Ta = z, Ea = H, Sa = q, Oa = Qt, Ia = Pr, Pa = TypeError, Ca = function(e, t) {
var r = arguments.length < 2 ? Ia(e) : t;
if (Ea(r)) return Sa(Ta(r, e));
throw new Pa(Oa(e) + " is not iterable");
}, Aa = z, De = q, Ra = te, xa = function(e, t, r) {
var n, o;
De(e);
try {
if (n = Ra(e, "return"), !n) {
if (t === "throw") throw r;
return r;
}
n = Aa(n, e);
} catch (i) {
o = !0, n = i;
}
if (t === "throw") throw r;
if (o) throw n;
return De(n), r;
}, Na = ta, Fa = z, ja = q, ka = Qt, Ba = ia, _a = Tr, ze = ir, Ma = Ca, La = Pr, We = xa, Da = TypeError, at = function(e, t) {
this.stopped = e, this.result = t;
}, Ke = at.prototype, Cr = function(e, t, r) {
var n = r && r.that, o = !!(r && r.AS_ENTRIES), i = !!(r && r.IS_RECORD), s = !!(r && r.IS_ITERATOR), a = !!(r && r.INTERRUPTED), u = Na(t, n), c, l, f, h, d, v, y, R = function(m) {
return c && We(c, "normal"), new at(!0, m);
}, S = function(m) {
return o ? (ja(m), a ? u(m[0], m[1], R) : u(m[0], m[1])) : a ? u(m, R) : u(m);
};
if (i)
c = e.iterator;
else if (s)
c = e;
else {
if (l = La(e), !l) throw new Da(ka(e) + " is not iterable");
if (Ba(l)) {
for (f = 0, h = _a(e); h > f; f++)
if (d = S(e[f]), d && ze(Ke,