vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
336 lines (335 loc) • 9.99 kB
JavaScript
import { DOMParser as v } from "../../../@xmldom/xmldom/lib/index.mjs";
const E = typeof window < "u" ? window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame : !1, w = 1, x = 3, g = typeof URL < "u" ? URL : typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : void 0;
function y() {
var e = (/* @__PURE__ */ new Date()).getTime(), t = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
var r = (e + Math.random() * 16) % 16 | 0;
return e = Math.floor(e / 16), (n == "x" ? r : r & 7 | 8).toString(16);
});
return t;
}
function R() {
return Math.max(
document.documentElement.clientHeight,
document.body.scrollHeight,
document.documentElement.scrollHeight,
document.body.offsetHeight,
document.documentElement.offsetHeight
);
}
function S(e) {
return !!(e && e.nodeType == 1);
}
function b(e) {
return !isNaN(parseFloat(e)) && isFinite(e);
}
function A(e) {
let t = parseFloat(e);
return b(e) === !1 ? !1 : typeof e == "string" && e.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
}
function B(e) {
var t = ["Webkit", "webkit", "Moz", "O", "ms"], n = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"], r = e.toLowerCase(), i = t.length;
if (typeof document > "u" || typeof document.body.style[r] < "u")
return e;
for (var o = 0; o < i; o++)
if (typeof document.body.style[n[o] + r] < "u")
return n[o] + r;
return e;
}
function q(e) {
for (var t = 1, n = arguments.length; t < n; t++) {
var r = arguments[t];
for (var i in r)
e[i] === void 0 && (e[i] = r[i]);
}
return e;
}
function L(e) {
var t = [].slice.call(arguments, 1);
return t.forEach(function(n) {
n && Object.getOwnPropertyNames(n).forEach(function(r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
});
}), e;
}
function P(e, t, n) {
var r = l(e, t, n);
return t.splice(r, 0, e), r;
}
function l(e, t, n, r, i) {
var o = r || 0, a = i || t.length, s = parseInt(o + (a - o) / 2), d;
return n || (n = function(f, u) {
if (f > u) return 1;
if (f < u) return -1;
if (f == u) return 0;
}), a - o <= 0 ? s : (d = n(t[s], e), a - o === 1 ? d >= 0 ? s : s + 1 : d === 0 ? s : d === -1 ? l(e, t, n, s, a) : l(e, t, n, o, s));
}
function h(e, t, n, r, i) {
var o = r || 0, a = i || t.length, s = parseInt(o + (a - o) / 2), d;
return n || (n = function(f, u) {
if (f > u) return 1;
if (f < u) return -1;
if (f == u) return 0;
}), a - o <= 0 ? -1 : (d = n(t[s], e), a - o === 1 ? d === 0 ? s : -1 : d === 0 ? s : d === -1 ? h(e, t, n, s, a) : h(e, t, n, o, s));
}
function k(e) {
var t = window.getComputedStyle(e), n = ["width", "paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth"], r = ["height", "paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth"], i = 0, o = 0;
return n.forEach(function(a) {
i += parseFloat(t[a]) || 0;
}), r.forEach(function(a) {
o += parseFloat(t[a]) || 0;
}), {
height: o,
width: i
};
}
function W(e) {
var t = window.getComputedStyle(e), n = ["paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth"], r = ["paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth"], i = 0, o = 0;
return n.forEach(function(a) {
i += parseFloat(t[a]) || 0;
}), r.forEach(function(a) {
o += parseFloat(t[a]) || 0;
}), {
height: o,
width: i
};
}
function U(e) {
let t, n = e.ownerDocument;
if (e.nodeType == Node.TEXT_NODE) {
let r = n.createRange();
r.selectNodeContents(e), t = r.getBoundingClientRect();
} else
t = e.getBoundingClientRect();
return t;
}
function D() {
var e = window.innerWidth, t = window.innerHeight;
return {
top: 0,
left: 0,
right: e,
bottom: t,
width: e,
height: t
};
}
function p(e, t) {
for (var n = e.parentNode, r = n.childNodes, i, o = -1, a = 0; a < r.length && (i = r[a], i.nodeType === t && o++, i != e); a++)
;
return o;
}
function F(e) {
return p(e, x);
}
function _(e) {
return p(e, w);
}
function M(e) {
return ["xml", "opf", "ncx"].indexOf(e) > -1;
}
function C(e, t) {
return new Blob([e], { type: t });
}
function j(e, t) {
var n, r = C(e, t);
return n = g.createObjectURL(r), n;
}
function H(e) {
return g.revokeObjectURL(e);
}
function z(e, t) {
var n, r;
if (typeof e == "string")
return n = btoa(e), r = "data:" + t + ";base64," + n, r;
}
function X(e) {
return Object.prototype.toString.call(e).slice(8, -1);
}
function I(e, t, n) {
var r, i;
return typeof DOMParser > "u" || n ? i = v : i = DOMParser, e.charCodeAt(0) === 65279 && (e = e.slice(1)), r = new i().parseFromString(e, t), r;
}
function $(e, t) {
var n;
if (!e)
throw new Error("No Element Provided");
if (typeof e.querySelector < "u")
return e.querySelector(t);
if (n = e.getElementsByTagName(t), n.length)
return n[0];
}
function O(e, t) {
return typeof e.querySelector < "u" ? e.querySelectorAll(t) : e.getElementsByTagName(t);
}
function G(e, t, n) {
var r, i;
if (typeof e.querySelector < "u") {
t += "[";
for (var o in n)
t += o + "~='" + n[o] + "'";
return t += "]", e.querySelector(t);
} else if (r = e.getElementsByTagName(t), i = Array.prototype.slice.call(r, 0).filter(function(a) {
for (var s in n)
if (a.getAttribute(s) === n[s])
return !0;
return !1;
}), i)
return i[0];
}
function J(e, t) {
var n = e.ownerDocument || e;
typeof n.createTreeWalker < "u" ? N(e, t, NodeFilter.SHOW_TEXT) : m(e, function(r) {
r && r.nodeType === 3 && t(r);
});
}
function N(e, t, n) {
var r = document.createTreeWalker(e, n, null, !1);
let i;
for (; i = r.nextNode(); )
t(i);
}
function m(e, t) {
if (t(e))
return !0;
if (e = e.firstChild, e)
do {
if (m(e, t))
return !0;
e = e.nextSibling;
} while (e);
}
function K(e) {
return new Promise(function(t, n) {
var r = new FileReader();
r.readAsDataURL(e), r.onloadend = function() {
t(r.result);
};
});
}
function Q() {
this.resolve = null, this.reject = null, this.id = y(), this.promise = new Promise((e, t) => {
this.resolve = e, this.reject = t;
}), Object.freeze(this);
}
function V(e, t, n) {
var r;
if (typeof e.querySelector < "u" && (r = e.querySelector(`${t}[*|type="${n}"]`)), !r || r.length === 0) {
r = O(e, t);
for (var i = 0; i < r.length; i++)
if (r[i].getAttributeNS("http://www.idpf.org/2007/ops", "type") === n || r[i].getAttribute("epub:type") === n)
return r[i];
} else
return r;
}
function Y(e) {
for (var t = [], n = e.childNodes, r = 0; r < n.length; r++) {
let i = n[r];
i.nodeType === 1 && t.push(i);
}
return t;
}
function c(e) {
for (var t = [e]; e; e = e.parentNode)
t.unshift(e);
return t;
}
function Z(e, t, n) {
for (var r = [], i = e.childNodes, o = 0; o < i.length; o++) {
let a = i[o];
if (a.nodeType === 1 && a.nodeName.toLowerCase() === t) {
if (n)
return a;
r.push(a);
}
}
if (!n)
return r;
}
function ee(e, t) {
let n;
if (!(e === null || t === ""))
for (n = e.parentNode; n.nodeType === 1; ) {
if (n.tagName.toLowerCase() === t)
return n;
n = n.parentNode;
}
}
class te {
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, n) {
this.startContainer = t, this.startOffset = n, this.endContainer ? this.commonAncestorContainer = this._commonAncestorContainer() : this.collapse(!0), this._checkCollapsed();
}
setEnd(t, n) {
this.endContainer = t, this.endOffset = n, 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 n = t.parentNode, r = Array.prototype.indexOf.call(n.childNodes, t);
this.setStart(n, r), this.setEnd(n, r + 1);
}
selectNodeContents(t) {
t.childNodes[t.childNodes - 1];
let n = t.nodeType === 3 ? t.textContent.length : parent.childNodes.length;
this.setStart(t, 0), this.setEnd(t, n);
}
_commonAncestorContainer(t, n) {
var r = c(t || this.startContainer), i = c(n || this.endContainer);
if (r[0] == i[0]) {
for (var o = 0; o < r.length; o++)
if (r[o] != i[o])
return r[o - 1];
}
}
_checkCollapsed() {
this.startContainer === this.endContainer && this.startOffset === this.endOffset ? this.collapsed = !0 : this.collapsed = !1;
}
toString() {
}
}
export {
te as RangeObject,
K as blob2base64,
W as borders,
k as bounds,
z as createBase64Url,
C as createBlob,
j as createBlobUrl,
q as defaults,
Q as defer,
R as documentHeight,
L as extend,
Z as filterChildren,
Y as findChildren,
ee as getParentByTagName,
_ as indexOfElementNode,
p as indexOfNode,
h as indexOfSorted,
F as indexOfTextNode,
P as insert,
S as isElement,
A as isFloat,
b as isNumber,
M as isXml,
l as locationOf,
U as nodeBounds,
c as parents,
I as parse,
B as prefixed,
$ as qs,
O as qsa,
G as qsp,
V as querySelectorByType,
E as requestAnimationFrame,
H as revokeBlobUrl,
J as sprint,
N as treeWalker,
X as type,
y as uuid,
m as walk,
D as windowBounds
};
//# sourceMappingURL=core.mjs.map