UNPKG

@epubjs-react-native/core

Version:

A digital book reader in .opf .epub format for react native using epub.js library inside a webview.

1,648 lines (1,644 loc) 488 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _default = exports.default = ` !(function (t, e) { "object" == typeof exports && "object" == typeof module ? (module.exports = e(require("JSZip"))) : "function" == typeof define && define.amd ? define(["JSZip"], e) : "object" == typeof exports ? (exports.ePub = e(require("JSZip"))) : (t.ePub = e(t.JSZip)); })(window, function (t) { return (function (t) { var e = {}; function i(n) { if (e[n]) return e[n].exports; var r = (e[n] = { i: n, l: !1, exports: {} }); return t[n].call(r.exports, r, r.exports, i), (r.l = !0), r.exports; } return ( (i.m = t), (i.c = e), (i.d = function (t, e, n) { i.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); }), (i.r = function (t) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "__esModule", { value: !0 }); }), (i.t = function (t, e) { if ((1 & e && (t = i(t)), 8 & e)) return t; if (4 & e && "object" == typeof t && t && t.__esModule) return t; var n = Object.create(null); if ( (i.r(n), Object.defineProperty(n, "default", { enumerable: !0, value: t }), 2 & e && "string" != typeof t) ) for (var r in t) i.d( n, r, function (e) { return t[e]; }.bind(null, r), ); return n; }), (i.n = function (t) { var e = t && t.__esModule ? function () { return t.default; } : function () { return t; }; return i.d(e, "a", e), e; }), (i.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }), (i.p = "/dist/"), i((i.s = 77)) ); })([ function (t, e, i) { "use strict"; i.r(e), i.d(e, "requestAnimationFrame", function () { return r; }), i.d(e, "uuid", function () { return o; }), i.d(e, "documentHeight", function () { return a; }), i.d(e, "isElement", function () { return h; }), i.d(e, "isNumber", function () { return l; }), i.d(e, "isFloat", function () { return c; }), i.d(e, "prefixed", function () { return u; }), i.d(e, "defaults", function () { return d; }), i.d(e, "extend", function () { return f; }), i.d(e, "insert", function () { return p; }), i.d(e, "locationOf", function () { return g; }), i.d(e, "indexOfSorted", function () { return m; }), i.d(e, "bounds", function () { return v; }), i.d(e, "borders", function () { return y; }), i.d(e, "nodeBounds", function () { return b; }), i.d(e, "windowBounds", function () { return w; }), i.d(e, "indexOfNode", function () { return x; }), i.d(e, "indexOfTextNode", function () { return E; }), i.d(e, "indexOfElementNode", function () { return S; }), i.d(e, "isXml", function () { return N; }), i.d(e, "createBlob", function () { return _; }), i.d(e, "createBlobUrl", function () { return O; }), i.d(e, "revokeBlobUrl", function () { return T; }), i.d(e, "createBase64Url", function () { return C; }), i.d(e, "type", function () { return I; }), i.d(e, "parse", function () { return k; }), i.d(e, "qs", function () { return R; }), i.d(e, "qsa", function () { return A; }), i.d(e, "qsp", function () { return L; }), i.d(e, "sprint", function () { return j; }), i.d(e, "treeWalker", function () { return D; }), i.d(e, "walk", function () { return P; }), i.d(e, "blob2base64", function () { return M; }), i.d(e, "defer", function () { return z; }), i.d(e, "querySelectorByType", function () { return B; }), i.d(e, "findChildren", function () { return q; }), i.d(e, "parents", function () { return F; }), i.d(e, "filterChildren", function () { return U; }), i.d(e, "getParentByTagName", function () { return W; }), i.d(e, "RangeObject", function () { return H; }); var n = i(28); const r = "undefined" != typeof window && (window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame), s = "undefined" != typeof URL ? URL : "undefined" != typeof window ? window.URL || window.webkitURL || window.mozURL : void 0; function o() { var t = new Date().getTime(); return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( /[xy]/g, function (e) { var i = (t + 16 * Math.random()) % 16 | 0; return ( (t = Math.floor(t / 16)), ("x" == e ? i : (7 & i) | 8).toString(16) ); }, ); } function a() { return Math.max( document.documentElement.clientHeight, document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, ); } function h(t) { return !(!t || 1 != t.nodeType); } function l(t) { return !isNaN(parseFloat(t)) && isFinite(t); } function c(t) { let e = parseFloat(t); return ( !1 !== l(t) && (("string" == typeof t && t.indexOf(".") > -1) || Math.floor(e) !== e) ); } function u(t) { var e = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"], i = t.toLowerCase(), n = ["Webkit", "webkit", "Moz", "O", "ms"].length; if ("undefined" == typeof document || void 0 !== document.body.style[i]) return t; for (var r = 0; r < n; r++) if (void 0 !== document.body.style[e[r] + i]) return e[r] + i; return t; } function d(t) { for (var e = 1, i = arguments.length; e < i; e++) { var n = arguments[e]; for (var r in n) void 0 === t[r] && (t[r] = n[r]); } return t; } function f(t) { var e = [].slice.call(arguments, 1); return ( e.forEach(function (e) { e && Object.getOwnPropertyNames(e).forEach(function (i) { Object.defineProperty( t, i, Object.getOwnPropertyDescriptor(e, i), ); }); }), t ); } function p(t, e, i) { var n = g(t, e, i); return e.splice(n, 0, t), n; } function g(t, e, i, n, r) { var s, o = n || 0, a = r || e.length, h = parseInt(o + (a - o) / 2); return ( i || (i = function (t, e) { return t > e ? 1 : t < e ? -1 : t == e ? 0 : void 0; }), a - o <= 0 ? h : ((s = i(e[h], t)), a - o == 1 ? s >= 0 ? h : h + 1 : 0 === s ? h : -1 === s ? g(t, e, i, h, a) : g(t, e, i, o, h)) ); } function m(t, e, i, n, r) { var s, o = n || 0, a = r || e.length, h = parseInt(o + (a - o) / 2); return ( i || (i = function (t, e) { return t > e ? 1 : t < e ? -1 : t == e ? 0 : void 0; }), a - o <= 0 ? -1 : ((s = i(e[h], t)), a - o == 1 ? 0 === s ? h : -1 : 0 === s ? h : -1 === s ? m(t, e, i, h, a) : m(t, e, i, o, h)) ); } function v(t) { var e = window.getComputedStyle(t), i = 0, n = 0; return ( [ "width", "paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth", ].forEach(function (t) { i += parseFloat(e[t]) || 0; }), [ "height", "paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth", ].forEach(function (t) { n += parseFloat(e[t]) || 0; }), { height: n, width: i } ); } function y(t) { var e = window.getComputedStyle(t), i = 0, n = 0; return ( [ "paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth", ].forEach(function (t) { i += parseFloat(e[t]) || 0; }), [ "paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth", ].forEach(function (t) { n += parseFloat(e[t]) || 0; }), { height: n, width: i } ); } function b(t) { let e, i = t.ownerDocument; if (t.nodeType == Node.TEXT_NODE) { let n = i.createRange(); n.selectNodeContents(t), (e = n.getBoundingClientRect()); } else e = t.getBoundingClientRect(); return e; } function w() { var t = window.innerWidth, e = window.innerHeight; return { top: 0, left: 0, right: t, bottom: e, width: t, height: e }; } function x(t, e) { for ( var i, n = t.parentNode.childNodes, r = -1, s = 0; s < n.length && ((i = n[s]).nodeType === e && r++, i != t); s++ ); return r; } function E(t) { return x(t, 3); } function S(t) { return x(t, 1); } function N(t) { return ["xml", "opf", "ncx"].indexOf(t) > -1; } function _(t, e) { return new Blob([t], { type: e }); } function O(t, e) { var i = _(t, e); return s.createObjectURL(i); } function T(t) { return s.revokeObjectURL(t); } function C(t, e) { if ("string" == typeof t) return "data:" + e + ";base64," + btoa(t); } function I(t) { return Object.prototype.toString.call(t).slice(8, -1); } function k(t, e, i) { var r; return ( (r = "undefined" == typeof DOMParser || i ? n.DOMParser : DOMParser), 65279 === t.charCodeAt(0) && (t = t.slice(1)), new r().parseFromString(t, e) ); } function R(t, e) { var i; if (!t) throw new Error("No Element Provided"); return void 0 !== t.querySelector ? t.querySelector(e) : (i = t.getElementsByTagName(e)).length ? i[0] : void 0; } function A(t, e) { return void 0 !== t.querySelector ? t.querySelectorAll(e) : t.getElementsByTagName(e); } function L(t, e, i) { var n, r; if (void 0 !== t.querySelector) { for (var s in ((e += "["), i)) e += s + "~='" + i[s] + "'"; return (e += "]"), t.querySelector(e); } if ( ((n = t.getElementsByTagName(e)), (r = Array.prototype.slice.call(n, 0).filter(function (t) { for (var e in i) if (t.getAttribute(e) === i[e]) return !0; return !1; }))) ) return r[0]; } function j(t, e) { void 0 !== (t.ownerDocument || t).createTreeWalker ? D(t, e, NodeFilter.SHOW_TEXT) : P(t, function (t) { t && 3 === t.nodeType && e(t); }); } function D(t, e, i) { var n = document.createTreeWalker(t, i, null, !1); let r; for (; (r = n.nextNode()); ) e(r); } function P(t, e) { if (e(t)) return !0; if ((t = t.firstChild)) do { if (P(t, e)) return !0; t = t.nextSibling; } while (t); } function M(t) { return new Promise(function (e, i) { var n = new FileReader(); n.readAsDataURL(t), (n.onloadend = function () { e(n.result); }); }); } function z() { (this.resolve = null), (this.reject = null), (this.id = o()), (this.promise = new Promise((t, e) => { (this.resolve = t), (this.reject = e); })), Object.freeze(this); } function B(t, e, i) { var n; if ( (void 0 !== t.querySelector && (n = t.querySelector(\`\${e}[*|type="\${i}"]\`)), n && 0 !== n.length) ) return n; n = A(t, e); for (var r = 0; r < n.length; r++) if ( n[r].getAttributeNS("http://www.idpf.org/2007/ops", "type") === i || n[r].getAttribute("epub:type") === i ) return n[r]; } function q(t) { for (var e = [], i = t.childNodes, n = 0; n < i.length; n++) { let t = i[n]; 1 === t.nodeType && e.push(t); } return e; } function F(t) { for (var e = [t]; t; t = t.parentNode) e.unshift(t); return e; } function U(t, e, i) { for (var n = [], r = t.childNodes, s = 0; s < r.length; s++) { let t = r[s]; if (1 === t.nodeType && t.nodeName.toLowerCase() === e) { if (i) return t; n.push(t); } } if (!i) return n; } function W(t, e) { let i; if (null !== t && "" !== e) for (i = t.parentNode; 1 === i.nodeType; ) { if (i.tagName.toLowerCase() === e) return i; i = i.parentNode; } } class H { constructor() { (this.collapsed = !1), (this.commonAncestorContainer = void 0), (this.endContainer = void 0), (this.endOffset = void 0), (this.startContainer = void 0), (this.startOffset = void 0); } setStart(t, e) { (this.startContainer = t), (this.startOffset = e), this.endContainer ? (this.commonAncestorContainer = this._commonAncestorContainer()) : this.collapse(!0), this._checkCollapsed(); } setEnd(t, e) { (this.endContainer = t), (this.endOffset = e), this.startContainer ? ((this.collapsed = !1), (this.commonAncestorContainer = this._commonAncestorContainer())) : this.collapse(!1), this._checkCollapsed(); } collapse(t) { (this.collapsed = !0), t ? ((this.endContainer = this.startContainer), (this.endOffset = this.startOffset), (this.commonAncestorContainer = this.startContainer.parentNode)) : ((this.startContainer = this.endContainer), (this.startOffset = this.endOffset), (this.commonAncestorContainer = this.endOffset.parentNode)); } selectNode(t) { let e = t.parentNode, i = Array.prototype.indexOf.call(e.childNodes, t); this.setStart(e, i), this.setEnd(e, i + 1); } selectNodeContents(t) { t.childNodes[t.childNodes - 1]; let e = 3 === t.nodeType ? t.textContent.length : parent.childNodes.length; this.setStart(t, 0), this.setEnd(t, e); } _commonAncestorContainer(t, e) { var i = F(t || this.startContainer), n = F(e || this.endContainer); if (i[0] == n[0]) for (var r = 0; r < i.length; r++) if (i[r] != n[r]) return i[r - 1]; } _checkCollapsed() { this.startContainer === this.endContainer && this.startOffset === this.endOffset ? (this.collapsed = !0) : (this.collapsed = !1); } toString() {} } }, function (t, e, i) { "use strict"; i.d(e, "b", function () { return n; }), i.d(e, "a", function () { return r; }), i.d(e, "c", function () { return s; }); const n = "0.3", r = [ "keydown", "keyup", "keypressed", "mouseup", "mousedown", "mousemove", "click", "touchend", "touchstart", "touchmove", ], s = { BOOK: { OPEN_FAILED: "openFailed" }, CONTENTS: { EXPAND: "expand", RESIZE: "resize", SELECTED: "selected", SELECTED_RANGE: "selectedRange", LINK_CLICKED: "linkClicked", }, LOCATIONS: { CHANGED: "changed" }, MANAGERS: { RESIZE: "resize", RESIZED: "resized", ORIENTATION_CHANGE: "orientationchange", ADDED: "added", SCROLL: "scroll", SCROLLED: "scrolled", REMOVED: "removed", }, VIEWS: { AXIS: "axis", WRITING_MODE: "writingMode", LOAD_ERROR: "loaderror", RENDERED: "rendered", RESIZED: "resized", DISPLAYED: "displayed", SHOWN: "shown", HIDDEN: "hidden", MARK_CLICKED: "markClicked", }, RENDITION: { STARTED: "started", ATTACHED: "attached", DISPLAYED: "displayed", DISPLAY_ERROR: "displayerror", RENDERED: "rendered", REMOVED: "removed", RESIZED: "resized", ORIENTATION_CHANGE: "orientationchange", LOCATION_CHANGED: "locationChanged", RELOCATED: "relocated", MARK_CLICKED: "markClicked", SELECTED: "selected", LAYOUT: "layout", }, LAYOUT: { UPDATED: "updated" }, ANNOTATION: { ATTACH: "attach", DETACH: "detach" }, }; }, function (t, e, i) { "use strict"; var n = i(0); class r { constructor(t, e, i) { var s; if ( ((this.str = ""), (this.base = {}), (this.spinePos = 0), (this.range = !1), (this.path = {}), (this.start = null), (this.end = null), !(this instanceof r)) ) return new r(t, e, i); if ( ("string" == typeof e ? (this.base = this.parseComponent(e)) : "object" == typeof e && e.steps && (this.base = e), "string" === (s = this.checkType(t))) ) return (this.str = t), Object(n.extend)(this, this.parse(t)); if ("range" === s) return Object(n.extend)(this, this.fromRange(t, this.base, i)); if ("node" === s) return Object(n.extend)(this, this.fromNode(t, this.base, i)); if ("EpubCFI" === s && t.path) return t; if (t) throw new TypeError("not a valid argument for EpubCFI"); return this; } checkType(t) { return this.isCfiString(t) ? "string" : !t || "object" != typeof t || ("Range" !== Object(n.type)(t) && void 0 === t.startContainer) ? t && "object" == typeof t && void 0 !== t.nodeType ? "node" : !!(t && "object" == typeof t && t instanceof r) && "EpubCFI" : "range"; } parse(t) { var e, i, n, r = { spinePos: -1, range: !1, base: {}, path: {}, start: null, end: null, }; return "string" != typeof t ? { spinePos: -1 } : (0 === t.indexOf("epubcfi(") && ")" === t[t.length - 1] && (t = t.slice(8, t.length - 1)), (e = this.getChapterComponent(t)) ? ((r.base = this.parseComponent(e)), (i = this.getPathComponent(t)), (r.path = this.parseComponent(i)), (n = this.getRange(t)) && ((r.range = !0), (r.start = this.parseComponent(n[0])), (r.end = this.parseComponent(n[1]))), (r.spinePos = r.base.steps[1].index), r) : { spinePos: -1 }); } parseComponent(t) { var e, i = { steps: [], terminal: { offset: null, assertion: null } }, n = t.split(":"), r = n[0].split("/"); return ( n.length > 1 && ((e = n[1]), (i.terminal = this.parseTerminal(e))), "" === r[0] && r.shift(), (i.steps = r.map( function (t) { return this.parseStep(t); }.bind(this), )), i ); } parseStep(t) { var e, i, n, r, s; if ( ((r = t.match(/\\[(.*)\\]/)) && r[1] && (s = r[1]), (i = parseInt(t)), !isNaN(i)) ) return ( i % 2 == 0 ? ((e = "element"), (n = i / 2 - 1)) : ((e = "text"), (n = (i - 1) / 2)), { type: e, index: n, id: s || null } ); } parseTerminal(t) { var e, i, r = t.match(/\\[(.*)\\]/); return ( r && r[1] ? ((e = parseInt(t.split("[")[0])), (i = r[1])) : (e = parseInt(t)), Object(n.isNumber)(e) || (e = null), { offset: e, assertion: i } ); } getChapterComponent(t) { return t.split("!")[0]; } getPathComponent(t) { var e = t.split("!"); if (e[1]) { return e[1].split(",")[0]; } } getRange(t) { var e = t.split(","); return 3 === e.length && [e[1], e[2]]; } getCharecterOffsetComponent(t) { return t.split(":")[1] || ""; } joinSteps(t) { return t ? t .map(function (t) { var e = ""; return ( "element" === t.type && (e += 2 * (t.index + 1)), "text" === t.type && (e += 1 + 2 * t.index), t.id && (e += "[" + t.id + "]"), e ); }) .join("/") : ""; } segmentString(t) { var e = "/"; return ( (e += this.joinSteps(t.steps)), t.terminal && null != t.terminal.offset && (e += ":" + t.terminal.offset), t.terminal && null != t.terminal.assertion && (e += "[" + t.terminal.assertion + "]"), e ); } toString() { var t = "epubcfi("; return ( (t += this.segmentString(this.base)), (t += "!"), (t += this.segmentString(this.path)), this.range && this.start && ((t += ","), (t += this.segmentString(this.start))), this.range && this.end && ((t += ","), (t += this.segmentString(this.end))), (t += ")") ); } compare(t, e) { var i, n, s, o; if ( ("string" == typeof t && (t = new r(t)), "string" == typeof e && (e = new r(e)), t.spinePos > e.spinePos) ) return 1; if (t.spinePos < e.spinePos) return -1; t.range ? ((i = t.path.steps.concat(t.start.steps)), (s = t.start.terminal)) : ((i = t.path.steps), (s = t.path.terminal)), e.range ? ((n = e.path.steps.concat(e.start.steps)), (o = e.start.terminal)) : ((n = e.path.steps), (o = e.path.terminal)); for (var a = 0; a < i.length; a++) { if (!i[a]) return -1; if (!n[a]) return 1; if (i[a].index > n[a].index) return 1; if (i[a].index < n[a].index) return -1; } return i.length < n.length ? -1 : s.offset > o.offset ? 1 : s.offset < o.offset ? -1 : 0; } step(t) { var e = 3 === t.nodeType ? "text" : "element"; return { id: t.id, tagName: t.tagName, type: e, index: this.position(t), }; } filteredStep(t, e) { var i, n = this.filter(t, e); if (n) return ( (i = 3 === n.nodeType ? "text" : "element"), { id: n.id, tagName: n.tagName, type: i, index: this.filteredPosition(n, e), } ); } pathTo(t, e, i) { for ( var n, r = { steps: [], terminal: { offset: null, assertion: null } }, s = t; s && s.parentNode && 9 != s.parentNode.nodeType; ) (n = i ? this.filteredStep(s, i) : this.step(s)) && r.steps.unshift(n), (s = s.parentNode); return ( null != e && e >= 0 && ((r.terminal.offset = e), "text" != r.steps[r.steps.length - 1].type && r.steps.push({ type: "text", index: 0 })), r ); } equalStep(t, e) { return ( !(!t || !e) && t.index === e.index && t.id === e.id && t.type === e.type ); } fromRange(t, e, i) { var n = { range: !1, base: {}, path: {}, start: null, end: null }, r = t.startContainer, s = t.endContainer, o = t.startOffset, a = t.endOffset, h = !1; if ( (i && (h = null != r.ownerDocument.querySelector("." + i)), "string" == typeof e ? ((n.base = this.parseComponent(e)), (n.spinePos = n.base.steps[1].index)) : "object" == typeof e && (n.base = e), t.collapsed) ) h && (o = this.patchOffset(r, o, i)), (n.path = this.pathTo(r, o, i)); else { (n.range = !0), h && (o = this.patchOffset(r, o, i)), (n.start = this.pathTo(r, o, i)), h && (a = this.patchOffset(s, a, i)), (n.end = this.pathTo(s, a, i)), (n.path = { steps: [], terminal: null }); var l, c = n.start.steps.length; for ( l = 0; l < c && this.equalStep(n.start.steps[l], n.end.steps[l]); l++ ) l === c - 1 ? n.start.terminal === n.end.terminal && (n.path.steps.push(n.start.steps[l]), (n.range = !1)) : n.path.steps.push(n.start.steps[l]); (n.start.steps = n.start.steps.slice(n.path.steps.length)), (n.end.steps = n.end.steps.slice(n.path.steps.length)); } return n; } fromNode(t, e, i) { var n = { range: !1, base: {}, path: {}, start: null, end: null }; return ( "string" == typeof e ? ((n.base = this.parseComponent(e)), (n.spinePos = n.base.steps[1].index)) : "object" == typeof e && (n.base = e), (n.path = this.pathTo(t, null, i)), n ); } filter(t, e) { var i, n, r, s, o, a = !1; return ( 3 === t.nodeType ? ((a = !0), (r = t.parentNode), (i = t.parentNode.classList.contains(e))) : ((a = !1), (i = t.classList.contains(e))), i && a ? ((s = r.previousSibling), (o = r.nextSibling), s && 3 === s.nodeType ? (n = s) : o && 3 === o.nodeType && (n = o), n || t) : !(i && !a) && t ); } patchOffset(t, e, i) { if (3 != t.nodeType) throw new Error("Anchor must be a text node"); var n = t, r = e; for ( t.parentNode.classList.contains(i) && (n = t.parentNode); n.previousSibling; ) { if (1 === n.previousSibling.nodeType) { if (!n.previousSibling.classList.contains(i)) break; r += n.previousSibling.textContent.length; } else r += n.previousSibling.textContent.length; n = n.previousSibling; } return r; } normalizedMap(t, e, i) { var n, r, s, o = {}, a = -1, h = t.length; for (n = 0; n < h; n++) 1 === (r = t[n].nodeType) && t[n].classList.contains(i) && (r = 3), n > 0 && 3 === r && 3 === s ? (o[n] = a) : e === r && ((a += 1), (o[n] = a)), (s = r); return o; } position(t) { var e, i; return ( 1 === t.nodeType ? ((e = t.parentNode.children) || (e = Object(n.findChildren)(t.parentNode)), (i = Array.prototype.indexOf.call(e, t))) : (i = (e = this.textNodes(t.parentNode)).indexOf(t)), i ); } filteredPosition(t, e) { var i, n; return ( 1 === t.nodeType ? ((i = t.parentNode.children), (n = this.normalizedMap(i, 1, e))) : ((i = t.parentNode.childNodes), t.parentNode.classList.contains(e) && (i = (t = t.parentNode).parentNode.childNodes), (n = this.normalizedMap(i, 3, e))), n[Array.prototype.indexOf.call(i, t)] ); } stepsToXpath(t) { var e = [".", "*"]; return ( t.forEach(function (t) { var i = t.index + 1; t.id ? e.push("*[position()=" + i + " and @id='" + t.id + "']") : "text" === t.type ? e.push("text()[" + i + "]") : e.push("*[" + i + "]"); }), e.join("/") ); } stepsToQuerySelector(t) { var e = ["html"]; return ( t.forEach(function (t) { var i = t.index + 1; t.id ? e.push("#" + t.id) : "text" === t.type || e.push("*:nth-child(" + i + ")"); }), e.join(">") ); } textNodes(t, e) { return Array.prototype.slice.call(t.childNodes).filter(function (t) { return 3 === t.nodeType || !(!e || !t.classList.contains(e)); }); } walkToNode(t, e, i) { var r, s, o = e || document, a = o.documentElement, h = t.length; for ( s = 0; s < h && ("element" === (r = t[s]).type ? (a = r.id ? o.getElementById(r.id) : (a.children || Object(n.findChildren)(a))[r.index]) : "text" === r.type && (a = this.textNodes(a, i)[r.index]), a); s++ ); return a; } findNode(t, e, i) { var n, r, s = e || document; return ( i || void 0 === s.evaluate ? (n = i ? this.walkToNode(t, s, i) : this.walkToNode(t, s)) : ((r = this.stepsToXpath(t)), (n = s.evaluate( r, s, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null, ).singleNodeValue)), n ); } fixMiss(t, e, i, n) { var r, s, o = this.findNode(t.slice(0, -1), i, n), a = o.childNodes, h = this.normalizedMap(a, 3, n), l = t[t.length - 1].index; for (let t in h) { if (!h.hasOwnProperty(t)) return; if (h[t] === l) { if (!(e > (s = (r = a[t]).textContent.length))) { o = 1 === r.nodeType ? r.childNodes[0] : r; break; } e -= s; } } return { container: o, offset: e }; } toRange(t, e) { var i, r, s, o, a, h, l, c, u = t || document, d = !!e && null != u.querySelector("." + e); if ( ((i = void 0 !== u.createRange ? u.createRange() : new n.RangeObject()), this.range ? ((r = this.start), (h = this.path.steps.concat(r.steps)), (o = this.findNode(h, u, d ? e : null)), (s = this.end), (l = this.path.steps.concat(s.steps)), (a = this.findNode(l, u, d ? e : null))) : ((r = this.path), (h = this.path.steps), (o = this.findNode(this.path.steps, u, d ? e : null))), !o) ) return ( console.log("No startContainer found for", this.toString()), null ); try { null != r.terminal.offset ? i.setStart(o, r.terminal.offset) : i.setStart(o, 0); } catch (t) { (c = this.fixMiss(h, r.terminal.offset, u, d ? e : null)), i.setStart(c.container, c.offset); } if (a) try { null != s.terminal.offset ? i.setEnd(a, s.terminal.offset) : i.setEnd(a, 0); } catch (t) { (c = this.fixMiss(l, this.end.terminal.offset, u, d ? e : null)), i.setEnd(c.container, c.offset); } return i; } isCfiString(t) { return ( "string" == typeof t && 0 === t.indexOf("epubcfi(") && ")" === t[t.length - 1] ); } generateChapterComponent(t, e, i) { var n = "/" + 2 * (t + 1) + "/"; return (n += 2 * (parseInt(e) + 1)), i && (n += "[" + i + "]"), n; } collapse(t) { this.range && ((this.range = !1), t ? ((this.path.steps = this.path.steps.concat(this.start.steps)), (this.path.terminal = this.start.terminal)) : ((this.path.steps = this.path.steps.concat(this.end.steps)), (this.path.terminal = this.end.terminal))); } } e.a = r; }, function (t, e, i) { "use strict"; var n, r, s, o, a, h, l, c = i(78), u = i(92), d = Function.prototype.apply, f = Function.prototype.call, p = Object.create, g = Object.defineProperty, m = Object.defineProperties, v = Object.prototype.hasOwnProperty, y = { configurable: !0, enumerable: !1, writable: !0 }; (r = function (t, e) { var i, r; return ( u(e), (r = this), n.call( this, t, (i = function () { s.call(r, t, i), d.call(e, this, arguments); }), ), (i.__eeOnceListener__ = e), this ); }), (a = { on: (n = function (t, e) { var i; return ( u(e), v.call(this, "__ee__") ? (i = this.__ee__) : ((i = y.value = p(null)), g(this, "__ee__", y), (y.value = null)), i[t] ? "object" == typeof i[t] ? i[t].push(e) : (i[t] = [i[t], e]) : (i[t] = e), this ); }), once: r, off: (s = function (t, e) { var i, n, r, s; if ((u(e), !v.call(this, "__ee__"))) return this; if (!(i = this.__ee__)[t]) return this; if ("object" == typeof (n = i[t])) for (s = 0; (r = n[s]); ++s) (r !== e && r.__eeOnceListener__ !== e) || (2 === n.length ? (i[t] = n[s ? 0 : 1]) : n.splice(s, 1)); else (n !== e && n.__eeOnceListener__ !== e) || delete i[t]; return this; }), emit: (o = function (t) { var e, i, n, r, s; if (v.call(this, "__ee__") && (r = this.__ee__[t])) if ("object" == typeof r) { for ( i = arguments.length, s = new Array(i - 1), e = 1; e < i; ++e ) s[e - 1] = arguments[e]; for (r = r.slice(), e = 0; (n = r[e]); ++e) d.call(n, this, s); } else switch (arguments.length) { case 1: f.call(r, this); break; case 2: f.call(r, this, arguments[1]); break; case 3: f.call(r, this, arguments[1], arguments[2]); break; default: for ( i = arguments.length, s = new Array(i - 1), e = 1; e < i; ++e ) s[e - 1] = arguments[e]; d.call(r, this, s); } }), }), (h = { on: c(n), once: c(r), off: c(s), emit: c(o) }), (l = m({}, h)), (t.exports = e = function (t) { return null == t ? p(l) : m(Object(t), h); }), (e.methods = a); }, function (t, e, i) { "use strict"; var n = i(8), r = i.n(n); e.a = class { constructor(t) { var e; t.indexOf("://") > -1 && (t = new URL(t).pathname), (e = this.parse(t)), (this.path = t), this.isDirectory(t) ? (this.directory = t) : (this.directory = e.dir + "/"), (this.filename = e.base), (this.extension = e.ext.slice(1)); } parse(t) { return r.a.parse(t); } isAbsolute(t) { return r.a.isAbsolute(t || this.path); } isDirectory(t) { return "/" === t.charAt(t.length - 1); } join(t) { return r.a.join(this.directory, t); } resolve(t) { return r.a.resolve(this.directory, t); } relative(t) { return t && t.indexOf("://") > -1 ? t : r.a.relative(this.directory, t); } splitPath(t) { return this.splitPathRe.exec(t).slice(1); } toString() { return this.path; } }; }, function (t, e, i) { "use strict"; var n = i(4), r = i(8), s = i.n(r); e.a = class { constructor(t, e) { var i = t.indexOf("://") > -1, r = t; if ( ((this.Url = void 0), (this.href = t), (this.protocol = ""), (this.origin = ""), (this.hash = ""), (this.hash = ""), (this.search = ""), (this.base = e), !i && !1 !== e && "string" != typeof e && window && window.location && (this.base = window.location.href), i || this.base) ) try { this.base ? (this.Url = new URL(t, this.base)) : (this.Url = new URL(t)), (this.href = this.Url.href), (this.protocol = this.Url.protocol), (this.origin = this.Url.origin), (this.hash = this.Url.hash), (this.search = this.Url.search), (r = this.Url.pathname + (this.Url.search ? this.Url.search : "")); } catch (t) { (this.Url = void 0), this.base && (r = new n.a(this.base).resolve(r)); } (this.Path = new n.a(r)), (this.directory = this.Path.directory), (this.filename = this.Path.filename), (this.extension = this.Path.extension); } path() { return this.Path; } resolve(t) { var e; return t.indexOf("://") > -1 ? t : ((e = s.a.resolve(this.directory, t)), this.origin + e); } relative(t) { return s.a.relative(t, this.directory); } toString() { return this.href; } }; }, function (t, e, i) { "use strict"; e.a = class { constructor(t) { (this.context = t || this), (this.hooks = []); } register() { for (var t = 0; t < arguments.length; ++t) if ("function" == typeof arguments[t]) this.hooks.push(arguments[t]); else for (var e = 0; e < arguments[t].length; ++e) this.hooks.push(arguments[t][e]); } deregister(t) { let e; for (let i = 0; i < this.hooks.length; i++) if (((e = this.hooks[i]), e === t)) { this.hooks.splice(i, 1); break; } } trigger() { var t = arguments, e = this.context, i = []; return ( this.hooks.forEach(function (n) { try { var r = n.apply(e, t); } catch (t) { console.log(t); } r && "function" == typeof r.then && i.push(r); }), Promise.all(i) ); } list() { return this.hooks; } clear() { return (this.hooks = []); } }; }, function (t, e) { t.exports = function (t) { return "function" == typeof t; }; }, function (t, e, i) { "use strict"; if (!n) var n = { cwd: function () { return "/"; }, }; function r(t) { if ("string" != typeof t) throw new TypeError("Path must be a string. Received " + t); } function s(t, e) { for (var i, n = "", r = -1, s = 0, o = 0; o <= t.length; ++o) { if (o < t.length) i = t.charCodeAt(o); else { if (47 === i) break; i = 47; } if (47 === i) { if (r === o - 1 || 1 === s); else if (r !== o - 1 && 2 === s) { if ( n.length < 2 || 46 !== n.charCodeAt(n.length - 1) || 46 !== n.charCodeAt(n.length - 2) ) if (n.length > 2) { for ( var a = n.length - 1, h = a; h >= 0 && 47 !== n.charCodeAt(h); --h ); if (h !== a) { (n = -1 === h ? "" : n.slice(0, h)), (r = o), (s = 0); continue; } } else if (2 === n.length || 1 === n.length) { (n = ""), (r = o), (s = 0); continue; } e && (n.length > 0 ? (n += "/..") : (n = "..")); } else n.length > 0 ? (n += "/" + t.slice(r + 1, o)) : (n = t.slice(r + 1, o)); (r = o), (s = 0); } else 46 === i && -1 !== s ? ++s : (s = -1); } return n; } var o = { resolve: function () { for ( var t, e = "", i = !1, o = arguments.length - 1; o >= -1 && !i; o-- ) { var a; o >= 0 ? (a = arguments[o]) : (void 0 === t && (t = n.cwd()), (a = t)), r(a), 0 !== a.length && ((e = a + "/" + e), (i = 47 === a.charCodeAt(0))); } return ( (e = s(e, !i)), i ? (e.length > 0 ? "/" + e : "/") : e.length > 0 ? e : "." ); }, normalize: function (t) { if ((r(t), 0 === t.length)) return "."; var e = 47 === t.charCodeAt(0), i = 47 === t.charCodeAt(t.length - 1); return ( 0 !== (t = s(t, !e)).length || e || (t = "."), t.length > 0 && i && (t += "/"), e ? "/" + t : t ); }, isAbsolute: function (t) { return r(t), t.length > 0 && 47 === t.charCodeAt(0); }, join: function () { if (0 === arguments.length) return "."; for (var t, e = 0; e < arguments.length; ++e) { var i = arguments[e]; r(i), i.length > 0 && (void 0 === t ? (t = i) : (t += "/" + i)); } return void 0 === t ? "." : o.normalize(t); }, relative: function (t, e) { if ((r(t), r(e), t === e)) return ""; if ((t = o.resolve(t)) === (e = o.resolve(e))) return ""; for (var i = 1; i < t.length && 47 === t.charCodeAt(i); ++i); for ( var n = t.length, s = n - i, a = 1; a < e.length && 47 === e.charCodeAt(a); ++a ); for ( var h = e.length - a, l = s < h ? s : h, c = -1, u = 0; u <= l; ++u ) { if (u === l) { if (h > l) { if (47 === e.charCodeAt(a + u)) return e.slice(a + u + 1); if (0 === u) return e.slice(a + u); } else s > l && (47 === t.charCodeAt(i + u) ? (c = u) : 0 === u && (c = 0)); break; } var d = t.charCodeAt(i + u); if (d !== e.charCodeAt(a + u)) break; 47 === d && (c = u); } var f = ""; for (u = i + c + 1; u <= n; ++u) (u !== n && 47 !== t.charCodeAt(u)) || (0 === f.length ? (f += "..") : (f += "/..")); return f.length > 0 ? f + e.slice(a + c) : ((a += c), 47 === e.charCodeAt(a) && ++a, e.slice(a)); }, _makeLong: function (t) { return t; }, dirname: function (t) { if ((r(t), 0 === t.length)) return "."; for ( var e = t.charCodeAt(0), i = 47 === e, n = -1, s = !0, o = t.length - 1; o >= 1; --o ) if (47 === (e = t.charCodeAt(o))) { if (!s) { n = o; break; } } else s = !1; return -1 === n ? i ? "/" : "." : i && 1 === n ? "//"