vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
1,017 lines (1,016 loc) • 32.2 kB
JavaScript
import { __exports as x } from "../../../../_virtual/dom.mjs";
import "./conventions.mjs";
import { __exports as Me } from "../../../../_virtual/conventions.mjs";
var he = Me, d = he.find, V = he.NAMESPACE;
function Ue(e) {
return e !== "";
}
function Pe(e) {
return e ? e.split(/[\t\n\f\r ]+/).filter(Ue) : [];
}
function Be(e, t) {
return e.hasOwnProperty(t) || (e[t] = !0), e;
}
function ae(e) {
if (!e) return [];
var t = Pe(e);
return Object.keys(t.reduce(Be, {}));
}
function Ve(e) {
return function(t) {
return e && e.indexOf(t) !== -1;
};
}
function j(e, t) {
for (var n in e)
Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
}
function m(e, t) {
var n = e.prototype;
if (!(n instanceof t)) {
let r = function() {
};
r.prototype = t.prototype, r = new r(), j(n, r), e.prototype = n = r;
}
n.constructor != e && (typeof e != "function" && console.error("unknown Class:" + e), n.constructor = e);
}
var N = {}, E = N.ELEMENT_NODE = 1, U = N.ATTRIBUTE_NODE = 2, G = N.TEXT_NODE = 3, me = N.CDATA_SECTION_NODE = 4, Ne = N.ENTITY_REFERENCE_NODE = 5, ke = N.ENTITY_NODE = 6, Ee = N.PROCESSING_INSTRUCTION_NODE = 7, ve = N.COMMENT_NODE = 8, de = N.DOCUMENT_NODE = 9, Te = N.DOCUMENT_TYPE_NODE = 10, D = N.DOCUMENT_FRAGMENT_NODE = 11, je = N.NOTATION_NODE = 12, c = {}, f = {};
c.INDEX_SIZE_ERR = (f[1] = "Index size error", 1);
c.DOMSTRING_SIZE_ERR = (f[2] = "DOMString size error", 2);
var h = c.HIERARCHY_REQUEST_ERR = (f[3] = "Hierarchy request error", 3);
c.WRONG_DOCUMENT_ERR = (f[4] = "Wrong document", 4);
c.INVALID_CHARACTER_ERR = (f[5] = "Invalid character", 5);
c.NO_DATA_ALLOWED_ERR = (f[6] = "No data allowed", 6);
c.NO_MODIFICATION_ALLOWED_ERR = (f[7] = "No modification allowed", 7);
var ye = c.NOT_FOUND_ERR = (f[8] = "Not found", 8);
c.NOT_SUPPORTED_ERR = (f[9] = "Not supported", 9);
var ue = c.INUSE_ATTRIBUTE_ERR = (f[10] = "Attribute in use", 10);
c.INVALID_STATE_ERR = (f[11] = "Invalid state", 11);
c.SYNTAX_ERR = (f[12] = "Syntax error", 12);
c.INVALID_MODIFICATION_ERR = (f[13] = "Invalid modification", 13);
c.NAMESPACE_ERR = (f[14] = "Invalid namespace", 14);
c.INVALID_ACCESS_ERR = (f[15] = "Invalid access", 15);
function s(e, t) {
if (t instanceof Error)
var n = t;
else
n = this, Error.call(this, f[e]), this.message = f[e], Error.captureStackTrace && Error.captureStackTrace(this, s);
return n.code = e, t && (this.message = this.message + ": " + t), n;
}
s.prototype = Error.prototype;
j(c, s);
function _() {
}
_.prototype = {
/**
* The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
* @standard level1
*/
length: 0,
/**
* Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
* @standard level1
* @param index unsigned long
* Index into the collection.
* @return Node
* The node at the indexth position in the NodeList, or null if that is not a valid index.
*/
item: function(e) {
return e >= 0 && e < this.length ? this[e] : null;
},
toString: function(e, t) {
for (var n = [], r = 0; r < this.length; r++)
M(this[r], n, e, t);
return n.join("");
},
/**
* @private
* @param {function (Node):boolean} predicate
* @returns {Node[]}
*/
filter: function(e) {
return Array.prototype.filter.call(this, e);
},
/**
* @private
* @param {Node} item
* @returns {number}
*/
indexOf: function(e) {
return Array.prototype.indexOf.call(this, e);
}
};
function P(e, t) {
this._node = e, this._refresh = t, J(this);
}
function J(e) {
var t = e._node._inc || e._node.ownerDocument._inc;
if (e._inc !== t) {
var n = e._refresh(e._node);
if (be(e, "length", n.length), !e.$$length || n.length < e.$$length)
for (var r = n.length; r in e; r++)
Object.prototype.hasOwnProperty.call(e, r) && delete e[r];
j(n, e), e._inc = t;
}
}
P.prototype.item = function(e) {
return J(this), this[e] || null;
};
m(P, _);
function X() {
}
function ge(e, t) {
for (var n = e.length; n--; )
if (e[n] === t)
return n;
}
function se(e, t, n, r) {
if (r ? t[ge(t, r)] = n : t[t.length++] = n, e) {
n.ownerElement = e;
var i = e.ownerDocument;
i && (r && Oe(i, e, r), Le(i, e, n));
}
}
function fe(e, t, n) {
var r = ge(t, n);
if (r >= 0) {
for (var i = t.length - 1; r < i; )
t[r] = t[++r];
if (t.length = i, e) {
var o = e.ownerDocument;
o && (Oe(o, e, n), n.ownerElement = null);
}
} else
throw new s(ye, new Error(e.tagName + "@" + n));
}
X.prototype = {
length: 0,
item: _.prototype.item,
getNamedItem: function(e) {
for (var t = this.length; t--; ) {
var n = this[t];
if (n.nodeName == e)
return n;
}
},
setNamedItem: function(e) {
var t = e.ownerElement;
if (t && t != this._ownerElement)
throw new s(ue);
var n = this.getNamedItem(e.nodeName);
return se(this._ownerElement, this, e, n), n;
},
/* returns Node */
setNamedItemNS: function(e) {
var t = e.ownerElement, n;
if (t && t != this._ownerElement)
throw new s(ue);
return n = this.getNamedItemNS(e.namespaceURI, e.localName), se(this._ownerElement, this, e, n), n;
},
/* returns Node */
removeNamedItem: function(e) {
var t = this.getNamedItem(e);
return fe(this._ownerElement, this, t), t;
},
// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
//for level2
removeNamedItemNS: function(e, t) {
var n = this.getNamedItemNS(e, t);
return fe(this._ownerElement, this, n), n;
},
getNamedItemNS: function(e, t) {
for (var n = this.length; n--; ) {
var r = this[n];
if (r.localName == t && r.namespaceURI == e)
return r;
}
return null;
}
};
function _e() {
}
_e.prototype = {
/**
* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
* The different implementations fairly diverged in what kind of features were reported.
* The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
*
* @deprecated It is deprecated and modern browsers return true in all cases.
*
* @param {string} feature
* @param {string} [version]
* @returns {boolean} always true
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
*/
hasFeature: function(e, t) {
return !0;
},
/**
* Creates an XML Document object of the specified type with its document element.
*
* __It behaves slightly different from the description in the living standard__:
* - There is no interface/class `XMLDocument`, it returns a `Document` instance.
* - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
* - this implementation is not validating names or qualified names
* (when parsing XML strings, the SAX parser takes care of that)
*
* @param {string|null} namespaceURI
* @param {string} qualifiedName
* @param {DocumentType=null} doctype
* @returns {Document}
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
*
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
*/
createDocument: function(e, t, n) {
var r = new L();
if (r.implementation = this, r.childNodes = new _(), r.doctype = n || null, n && r.appendChild(n), t) {
var i = r.createElementNS(e, t);
r.appendChild(i);
}
return r;
},
/**
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
*
* __This behavior is slightly different from the in the specs__:
* - this implementation is not validating names or qualified names
* (when parsing XML strings, the SAX parser takes care of that)
*
* @param {string} qualifiedName
* @param {string} [publicId]
* @param {string} [systemId]
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
*
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
*/
createDocumentType: function(e, t, n) {
var r = new W();
return r.name = e, r.nodeName = e, r.publicId = t || "", r.systemId = n || "", r;
}
};
function a() {
}
a.prototype = {
firstChild: null,
lastChild: null,
previousSibling: null,
nextSibling: null,
attributes: null,
parentNode: null,
childNodes: null,
ownerDocument: null,
nodeValue: null,
namespaceURI: null,
prefix: null,
localName: null,
// Modified in DOM Level 2:
insertBefore: function(e, t) {
return $(this, e, t);
},
replaceChild: function(e, t) {
$(this, e, t, Ie), t && this.removeChild(t);
},
removeChild: function(e) {
return Se(this, e);
},
appendChild: function(e) {
return this.insertBefore(e, null);
},
hasChildNodes: function() {
return this.firstChild != null;
},
cloneNode: function(e) {
return Z(this.ownerDocument || this, this, e);
},
// Modified in DOM Level 2:
normalize: function() {
for (var e = this.firstChild; e; ) {
var t = e.nextSibling;
t && t.nodeType == G && e.nodeType == G ? (this.removeChild(t), e.appendData(t.data)) : (e.normalize(), e = t);
}
},
// Introduced in DOM Level 2:
isSupported: function(e, t) {
return this.ownerDocument.implementation.hasFeature(e, t);
},
// Introduced in DOM Level 2:
hasAttributes: function() {
return this.attributes.length > 0;
},
/**
* Look up the prefix associated to the given namespace URI, starting from this node.
* **The default namespace declarations are ignored by this method.**
* See Namespace Prefix Lookup for details on the algorithm used by this method.
*
* _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
*
* @param {string | null} namespaceURI
* @returns {string | null}
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
* @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
* @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
* @see https://github.com/xmldom/xmldom/issues/322
*/
lookupPrefix: function(e) {
for (var t = this; t; ) {
var n = t._nsMap;
if (n) {
for (var r in n)
if (Object.prototype.hasOwnProperty.call(n, r) && n[r] === e)
return r;
}
t = t.nodeType == U ? t.ownerDocument : t.parentNode;
}
return null;
},
// Introduced in DOM Level 3:
lookupNamespaceURI: function(e) {
for (var t = this; t; ) {
var n = t._nsMap;
if (n && e in n && Object.prototype.hasOwnProperty.call(n, e))
return n[e];
t = t.nodeType == U ? t.ownerDocument : t.parentNode;
}
return null;
},
// Introduced in DOM Level 3:
isDefaultNamespace: function(e) {
var t = this.lookupPrefix(e);
return t == null;
}
};
function De(e) {
return e == "<" && "<" || e == ">" && ">" || e == "&" && "&" || e == '"' && """ || "&#" + e.charCodeAt() + ";";
}
j(N, a);
j(N, a.prototype);
function k(e, t) {
if (t(e))
return !0;
if (e = e.firstChild)
do
if (k(e, t))
return !0;
while (e = e.nextSibling);
}
function L() {
this.ownerDocument = this;
}
function Le(e, t, n) {
e && e._inc++;
var r = n.namespaceURI;
r === V.XMLNS && (t._nsMap[n.prefix ? n.localName : ""] = n.value);
}
function Oe(e, t, n, r) {
e && e._inc++;
var i = n.namespaceURI;
i === V.XMLNS && delete t._nsMap[n.prefix ? n.localName : ""];
}
function K(e, t, n) {
if (e && e._inc) {
e._inc++;
var r = t.childNodes;
if (n)
r[r.length++] = n;
else {
for (var i = t.firstChild, o = 0; i; )
r[o++] = i, i = i.nextSibling;
r.length = o, delete r[r.length];
}
}
}
function Se(e, t) {
var n = t.previousSibling, r = t.nextSibling;
return n ? n.nextSibling = r : e.firstChild = r, r ? r.previousSibling = n : e.lastChild = n, t.parentNode = null, t.previousSibling = null, t.nextSibling = null, K(e.ownerDocument, e), t;
}
function Ye(e) {
return e && (e.nodeType === a.DOCUMENT_NODE || e.nodeType === a.DOCUMENT_FRAGMENT_NODE || e.nodeType === a.ELEMENT_NODE);
}
function Ge(e) {
return e && (T(e) || H(e) || O(e) || e.nodeType === a.DOCUMENT_FRAGMENT_NODE || e.nodeType === a.COMMENT_NODE || e.nodeType === a.PROCESSING_INSTRUCTION_NODE);
}
function O(e) {
return e && e.nodeType === a.DOCUMENT_TYPE_NODE;
}
function T(e) {
return e && e.nodeType === a.ELEMENT_NODE;
}
function H(e) {
return e && e.nodeType === a.TEXT_NODE;
}
function le(e, t) {
var n = e.childNodes || [];
if (d(n, T) || O(t))
return !1;
var r = d(n, O);
return !(t && r && n.indexOf(r) > n.indexOf(t));
}
function ce(e, t) {
var n = e.childNodes || [];
function r(o) {
return T(o) && o !== t;
}
if (d(n, r))
return !1;
var i = d(n, O);
return !(t && i && n.indexOf(i) > n.indexOf(t));
}
function Xe(e, t, n) {
if (!Ye(e))
throw new s(h, "Unexpected parent node type " + e.nodeType);
if (n && n.parentNode !== e)
throw new s(ye, "child not in parent");
if (
// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
!Ge(t) || // 5. If either `node` is a Text node and `parent` is a document,
// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
// or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
O(t) && e.nodeType !== a.DOCUMENT_NODE
)
throw new s(
h,
"Unexpected node type " + t.nodeType + " for parent node type " + e.nodeType
);
}
function $e(e, t, n) {
var r = e.childNodes || [], i = t.childNodes || [];
if (t.nodeType === a.DOCUMENT_FRAGMENT_NODE) {
var o = i.filter(T);
if (o.length > 1 || d(i, H))
throw new s(h, "More than one element or text in fragment");
if (o.length === 1 && !le(e, n))
throw new s(h, "Element in fragment can not be inserted before doctype");
}
if (T(t) && !le(e, n))
throw new s(h, "Only one element can be added and only after doctype");
if (O(t)) {
if (d(r, O))
throw new s(h, "Only one doctype is allowed");
var u = d(r, T);
if (n && r.indexOf(u) < r.indexOf(n))
throw new s(h, "Doctype can only be inserted before an element");
if (!n && u)
throw new s(h, "Doctype can not be appended since element is present");
}
}
function Ie(e, t, n) {
var r = e.childNodes || [], i = t.childNodes || [];
if (t.nodeType === a.DOCUMENT_FRAGMENT_NODE) {
var o = i.filter(T);
if (o.length > 1 || d(i, H))
throw new s(h, "More than one element or text in fragment");
if (o.length === 1 && !ce(e, n))
throw new s(h, "Element in fragment can not be inserted before doctype");
}
if (T(t) && !ce(e, n))
throw new s(h, "Only one element can be added and only after doctype");
if (O(t)) {
if (d(r, function(y) {
return O(y) && y !== n;
}))
throw new s(h, "Only one doctype is allowed");
var u = d(r, T);
if (n && r.indexOf(u) < r.indexOf(n))
throw new s(h, "Doctype can only be inserted before an element");
}
}
function $(e, t, n, r) {
Xe(e, t, n), e.nodeType === a.DOCUMENT_NODE && (r || $e)(e, t, n);
var i = t.parentNode;
if (i && i.removeChild(t), t.nodeType === D) {
var o = t.firstChild;
if (o == null)
return t;
var u = t.lastChild;
} else
o = u = t;
var p = n ? n.previousSibling : e.lastChild;
o.previousSibling = p, u.nextSibling = n, p ? p.nextSibling = o : e.firstChild = o, n == null ? e.lastChild = u : n.previousSibling = u;
do
o.parentNode = e;
while (o !== u && (o = o.nextSibling));
return K(e.ownerDocument || e, e), t.nodeType == D && (t.firstChild = t.lastChild = null), t;
}
function ze(e, t) {
return t.parentNode && t.parentNode.removeChild(t), t.parentNode = e, t.previousSibling = e.lastChild, t.nextSibling = null, t.previousSibling ? t.previousSibling.nextSibling = t : e.firstChild = t, e.lastChild = t, K(e.ownerDocument, e, t), t;
}
L.prototype = {
//implementation : null,
nodeName: "#document",
nodeType: de,
/**
* The DocumentType node of the document.
*
* @readonly
* @type DocumentType
*/
doctype: null,
documentElement: null,
_inc: 1,
insertBefore: function(e, t) {
if (e.nodeType == D) {
for (var n = e.firstChild; n; ) {
var r = n.nextSibling;
this.insertBefore(n, t), n = r;
}
return e;
}
return $(this, e, t), e.ownerDocument = this, this.documentElement === null && e.nodeType === E && (this.documentElement = e), e;
},
removeChild: function(e) {
return this.documentElement == e && (this.documentElement = null), Se(this, e);
},
replaceChild: function(e, t) {
$(this, e, t, Ie), e.ownerDocument = this, t && this.removeChild(t), T(e) && (this.documentElement = e);
},
// Introduced in DOM Level 2:
importNode: function(e, t) {
return xe(this, e, t);
},
// Introduced in DOM Level 2:
getElementById: function(e) {
var t = null;
return k(this.documentElement, function(n) {
if (n.nodeType == E && n.getAttribute("id") == e)
return t = n, !0;
}), t;
},
/**
* The `getElementsByClassName` method of `Document` interface returns an array-like object
* of all child elements which have **all** of the given class name(s).
*
* Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
*
*
* Warning: This is a live LiveNodeList.
* Changes in the DOM will reflect in the array as the changes occur.
* If an element selected by this array no longer qualifies for the selector,
* it will automatically be removed. Be aware of this for iteration purposes.
*
* @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
*/
getElementsByClassName: function(e) {
var t = ae(e);
return new P(this, function(n) {
var r = [];
return t.length > 0 && k(n.documentElement, function(i) {
if (i !== n && i.nodeType === E) {
var o = i.getAttribute("class");
if (o) {
var u = e === o;
if (!u) {
var p = ae(o);
u = t.every(Ve(p));
}
u && r.push(i);
}
}
}), r;
});
},
//document factory method:
createElement: function(e) {
var t = new C();
t.ownerDocument = this, t.nodeName = e, t.tagName = e, t.localName = e, t.childNodes = new _();
var n = t.attributes = new X();
return n._ownerElement = t, t;
},
createDocumentFragment: function() {
var e = new F();
return e.ownerDocument = this, e.childNodes = new _(), e;
},
createTextNode: function(e) {
var t = new q();
return t.ownerDocument = this, t.appendData(e), t;
},
createComment: function(e) {
var t = new ee();
return t.ownerDocument = this, t.appendData(e), t;
},
createCDATASection: function(e) {
var t = new te();
return t.ownerDocument = this, t.appendData(e), t;
},
createProcessingInstruction: function(e, t) {
var n = new re();
return n.ownerDocument = this, n.tagName = n.nodeName = n.target = e, n.nodeValue = n.data = t, n;
},
createAttribute: function(e) {
var t = new z();
return t.ownerDocument = this, t.name = e, t.nodeName = e, t.localName = e, t.specified = !0, t;
},
createEntityReference: function(e) {
var t = new ne();
return t.ownerDocument = this, t.nodeName = e, t;
},
// Introduced in DOM Level 2:
createElementNS: function(e, t) {
var n = new C(), r = t.split(":"), i = n.attributes = new X();
return n.childNodes = new _(), n.ownerDocument = this, n.nodeName = t, n.tagName = t, n.namespaceURI = e, r.length == 2 ? (n.prefix = r[0], n.localName = r[1]) : n.localName = t, i._ownerElement = n, n;
},
// Introduced in DOM Level 2:
createAttributeNS: function(e, t) {
var n = new z(), r = t.split(":");
return n.ownerDocument = this, n.nodeName = t, n.name = t, n.namespaceURI = e, n.specified = !0, r.length == 2 ? (n.prefix = r[0], n.localName = r[1]) : n.localName = t, n;
}
};
m(L, a);
function C() {
this._nsMap = {};
}
C.prototype = {
nodeType: E,
hasAttribute: function(e) {
return this.getAttributeNode(e) != null;
},
getAttribute: function(e) {
var t = this.getAttributeNode(e);
return t && t.value || "";
},
getAttributeNode: function(e) {
return this.attributes.getNamedItem(e);
},
setAttribute: function(e, t) {
var n = this.ownerDocument.createAttribute(e);
n.value = n.nodeValue = "" + t, this.setAttributeNode(n);
},
removeAttribute: function(e) {
var t = this.getAttributeNode(e);
t && this.removeAttributeNode(t);
},
//four real opeartion method
appendChild: function(e) {
return e.nodeType === D ? this.insertBefore(e, null) : ze(this, e);
},
setAttributeNode: function(e) {
return this.attributes.setNamedItem(e);
},
setAttributeNodeNS: function(e) {
return this.attributes.setNamedItemNS(e);
},
removeAttributeNode: function(e) {
return this.attributes.removeNamedItem(e.nodeName);
},
//get real attribute name,and remove it by removeAttributeNode
removeAttributeNS: function(e, t) {
var n = this.getAttributeNodeNS(e, t);
n && this.removeAttributeNode(n);
},
hasAttributeNS: function(e, t) {
return this.getAttributeNodeNS(e, t) != null;
},
getAttributeNS: function(e, t) {
var n = this.getAttributeNodeNS(e, t);
return n && n.value || "";
},
setAttributeNS: function(e, t, n) {
var r = this.ownerDocument.createAttributeNS(e, t);
r.value = r.nodeValue = "" + n, this.setAttributeNode(r);
},
getAttributeNodeNS: function(e, t) {
return this.attributes.getNamedItemNS(e, t);
},
getElementsByTagName: function(e) {
return new P(this, function(t) {
var n = [];
return k(t, function(r) {
r !== t && r.nodeType == E && (e === "*" || r.tagName == e) && n.push(r);
}), n;
});
},
getElementsByTagNameNS: function(e, t) {
return new P(this, function(n) {
var r = [];
return k(n, function(i) {
i !== n && i.nodeType === E && (e === "*" || i.namespaceURI === e) && (t === "*" || i.localName == t) && r.push(i);
}), r;
});
}
};
L.prototype.getElementsByTagName = C.prototype.getElementsByTagName;
L.prototype.getElementsByTagNameNS = C.prototype.getElementsByTagNameNS;
m(C, a);
function z() {
}
z.prototype.nodeType = U;
m(z, a);
function Y() {
}
Y.prototype = {
data: "",
substringData: function(e, t) {
return this.data.substring(e, e + t);
},
appendData: function(e) {
e = this.data + e, this.nodeValue = this.data = e, this.length = e.length;
},
insertData: function(e, t) {
this.replaceData(e, 0, t);
},
appendChild: function(e) {
throw new Error(f[h]);
},
deleteData: function(e, t) {
this.replaceData(e, t, "");
},
replaceData: function(e, t, n) {
var r = this.data.substring(0, e), i = this.data.substring(e + t);
n = r + n + i, this.nodeValue = this.data = n, this.length = n.length;
}
};
m(Y, a);
function q() {
}
q.prototype = {
nodeName: "#text",
nodeType: G,
splitText: function(e) {
var t = this.data, n = t.substring(e);
t = t.substring(0, e), this.data = this.nodeValue = t, this.length = t.length;
var r = this.ownerDocument.createTextNode(n);
return this.parentNode && this.parentNode.insertBefore(r, this.nextSibling), r;
}
};
m(q, Y);
function ee() {
}
ee.prototype = {
nodeName: "#comment",
nodeType: ve
};
m(ee, Y);
function te() {
}
te.prototype = {
nodeName: "#cdata-section",
nodeType: me
};
m(te, Y);
function W() {
}
W.prototype.nodeType = Te;
m(W, a);
function we() {
}
we.prototype.nodeType = je;
m(we, a);
function Re() {
}
Re.prototype.nodeType = ke;
m(Re, a);
function ne() {
}
ne.prototype.nodeType = Ne;
m(ne, a);
function F() {
}
F.prototype.nodeName = "#document-fragment";
F.prototype.nodeType = D;
m(F, a);
function re() {
}
re.prototype.nodeType = Ee;
m(re, a);
function Ae() {
}
Ae.prototype.serializeToString = function(e, t, n) {
return Ce.call(e, t, n);
};
a.prototype.toString = Ce;
function Ce(e, t) {
var n = [], r = this.nodeType == 9 && this.documentElement || this, i = r.prefix, o = r.namespaceURI;
if (o && i == null) {
var i = r.lookupPrefix(o);
if (i == null)
var u = [
{ namespace: o, prefix: null }
//{namespace:uri,prefix:''}
];
}
return M(this, n, e, t, u), n.join("");
}
function pe(e, t, n) {
var r = e.prefix || "", i = e.namespaceURI;
if (!i || r === "xml" && i === V.XML || i === V.XMLNS)
return !1;
for (var o = n.length; o--; ) {
var u = n[o];
if (u.prefix === r)
return u.namespace !== i;
}
return !0;
}
function Q(e, t, n) {
e.push(" ", t, '="', n.replace(/[<&"]/g, De), '"');
}
function M(e, t, n, r, i) {
if (i || (i = []), r)
if (e = r(e), e) {
if (typeof e == "string") {
t.push(e);
return;
}
} else
return;
switch (e.nodeType) {
case E:
var o = e.attributes, u = o.length, l = e.firstChild, p = e.tagName;
n = V.isHTML(e.namespaceURI) || n;
var y = p;
if (!n && !e.prefix && e.namespaceURI) {
for (var S, g = 0; g < o.length; g++)
if (o.item(g).name === "xmlns") {
S = o.item(g).value;
break;
}
if (!S)
for (var I = i.length - 1; I >= 0; I--) {
var w = i[I];
if (w.prefix === "" && w.namespace === e.namespaceURI) {
S = w.namespace;
break;
}
}
if (S !== e.namespaceURI)
for (var I = i.length - 1; I >= 0; I--) {
var w = i[I];
if (w.namespace === e.namespaceURI) {
w.prefix && (y = w.prefix + ":" + p);
break;
}
}
}
t.push("<", y);
for (var R = 0; R < u; R++) {
var v = o.item(R);
v.prefix == "xmlns" ? i.push({ prefix: v.localName, namespace: v.value }) : v.nodeName == "xmlns" && i.push({ prefix: "", namespace: v.value });
}
for (var R = 0; R < u; R++) {
var v = o.item(R);
if (pe(v, n, i)) {
var A = v.prefix || "", B = v.namespaceURI;
Q(t, A ? "xmlns:" + A : "xmlns", B), i.push({ prefix: A, namespace: B });
}
M(v, t, n, r, i);
}
if (p === y && pe(e, n, i)) {
var A = e.prefix || "", B = e.namespaceURI;
Q(t, A ? "xmlns:" + A : "xmlns", B), i.push({ prefix: A, namespace: B });
}
if (l || n && !/^(?:meta|link|img|br|hr|input)$/i.test(p)) {
if (t.push(">"), n && /^script$/i.test(p))
for (; l; )
l.data ? t.push(l.data) : M(l, t, n, r, i.slice()), l = l.nextSibling;
else
for (; l; )
M(l, t, n, r, i.slice()), l = l.nextSibling;
t.push("</", y, ">");
} else
t.push("/>");
return;
case de:
case D:
for (var l = e.firstChild; l; )
M(l, t, n, r, i.slice()), l = l.nextSibling;
return;
case U:
return Q(t, e.name, e.value);
case G:
return t.push(
e.data.replace(/[<&]/g, De).replace(/]]>/g, "]]>")
);
case me:
return t.push("<![CDATA[", e.data, "]]>");
case ve:
return t.push("<!--", e.data, "-->");
case Te:
var ie = e.publicId, b = e.systemId;
if (t.push("<!DOCTYPE ", e.name), ie)
t.push(" PUBLIC ", ie), b && b != "." && t.push(" ", b), t.push(">");
else if (b && b != ".")
t.push(" SYSTEM ", b, ">");
else {
var oe = e.internalSubset;
oe && t.push(" [", oe, "]"), t.push(">");
}
return;
case Ee:
return t.push("<?", e.target, " ", e.data, "?>");
case Ne:
return t.push("&", e.nodeName, ";");
default:
t.push("??", e.nodeName);
}
}
function xe(e, t, n) {
var r;
switch (t.nodeType) {
case E:
r = t.cloneNode(!1), r.ownerDocument = e;
case D:
break;
case U:
n = !0;
break;
}
if (r || (r = t.cloneNode(!1)), r.ownerDocument = e, r.parentNode = null, n)
for (var i = t.firstChild; i; )
r.appendChild(xe(e, i, n)), i = i.nextSibling;
return r;
}
function Z(e, t, n) {
var r = new t.constructor();
for (var i in t)
if (Object.prototype.hasOwnProperty.call(t, i)) {
var o = t[i];
typeof o != "object" && o != r[i] && (r[i] = o);
}
switch (t.childNodes && (r.childNodes = new _()), r.ownerDocument = e, r.nodeType) {
case E:
var u = t.attributes, p = r.attributes = new X(), y = u.length;
p._ownerElement = r;
for (var S = 0; S < y; S++)
r.setAttributeNode(Z(e, u.item(S), !0));
break;
case U:
n = !0;
}
if (n)
for (var g = t.firstChild; g; )
r.appendChild(Z(e, g, n)), g = g.nextSibling;
return r;
}
function be(e, t, n) {
e[t] = n;
}
try {
if (Object.defineProperty) {
let e = function(t) {
switch (t.nodeType) {
case E:
case D:
var n = [];
for (t = t.firstChild; t; )
t.nodeType !== 7 && t.nodeType !== 8 && n.push(e(t)), t = t.nextSibling;
return n.join("");
default:
return t.nodeValue;
}
};
Object.defineProperty(P.prototype, "length", {
get: function() {
return J(this), this.$$length;
}
}), Object.defineProperty(a.prototype, "textContent", {
get: function() {
return e(this);
},
set: function(t) {
switch (this.nodeType) {
case E:
case D:
for (; this.firstChild; )
this.removeChild(this.firstChild);
(t || String(t)) && this.appendChild(this.ownerDocument.createTextNode(t));
break;
default:
this.data = t, this.value = t, this.nodeValue = t;
}
}
}), be = function(t, n, r) {
t["$$" + n] = r;
};
}
} catch {
}
x.DocumentType = W;
x.DOMException = s;
x.DOMImplementation = _e;
x.Element = C;
x.Node = a;
x.NodeList = _;
x.XMLSerializer = Ae;
export {
x as default
};
//# sourceMappingURL=dom.mjs.map