UNPKG

lakutata

Version:

An IoC-based universal application framework.

1,654 lines (1,540 loc) 53.3 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const t = require("../../../vendor/Package.5.cjs"); var e = {}; var n = {}; (function(t) { "use strict"; const e = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; const n = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; const s = "[" + e + "][" + n + "]*"; const i = new RegExp("^" + s + "$"); const r = function(t, e) { const n = []; let s = e.exec(t); while (s) { const i = []; i.startIndex = e.lastIndex - s[0].length; const r = s.length; for (let t = 0; t < r; t++) { i.push(s[t]); } n.push(i); s = e.exec(t); } return n; }; const o = function(t) { const e = i.exec(t); return !(e === null || typeof e === "undefined"); }; t.isExist = function(t) { return typeof t !== "undefined"; }; t.isEmptyObject = function(t) { return Object.keys(t).length === 0; }; t.merge = function(t, e, n) { if (e) { const s = Object.keys(e); const i = s.length; for (let r = 0; r < i; r++) { if (n === "strict") { t[s[r]] = [ e[s[r]] ]; } else { t[s[r]] = e[s[r]]; } } } }; t.getValue = function(e) { if (t.isExist(e)) { return e; } else { return ""; } }; t.isName = o; t.getAllMatches = r; t.nameRegexp = s; })(n); const s = t.getDefaultExportFromCjs(n); "use strict"; const i = n; const r = { allowBooleanAttributes: false, unpairedTags: [] }; var o = e.validate = function(t, e) { e = Object.assign({}, r, e); const n = []; let s = false; let i = false; if (t[0] === "\ufeff") { t = t.substr(1); } for (let r = 0; r < t.length; r++) { if (t[r] === "<" && t[r + 1] === "?") { r += 2; r = l(t, r); if (r.err) return r; } else if (t[r] === "<") { let o = r; r++; if (t[r] === "!") { r = u(t, r); continue; } else { let f = false; if (t[r] === "/") { f = true; r++; } let c = ""; for (;r < t.length && t[r] !== ">" && t[r] !== " " && t[r] !== "\t" && t[r] !== "\n" && t[r] !== "\r"; r++) { c += t[r]; } c = c.trim(); if (c[c.length - 1] === "/") { c = c.substring(0, c.length - 1); r--; } if (!b(c)) { let e; if (c.trim().length === 0) { e = "Invalid space after '<'."; } else { e = "Tag '" + c + "' is an invalid name."; } return x("InvalidTag", e, E(t, r)); } const d = h(t, r); if (d === false) { return x("InvalidAttr", "Attributes for '" + c + "' have open quote.", E(t, r)); } let g = d.value; r = d.index; if (g[g.length - 1] === "/") { const n = r - g.length; g = g.substring(0, g.length - 1); const i = p(g, e); if (i === true) { s = true; } else { return x(i.err.code, i.err.msg, E(t, n + i.err.line)); } } else if (f) { if (!d.tagClosed) { return x("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", E(t, r)); } else if (g.trim().length > 0) { return x("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", E(t, o)); } else if (n.length === 0) { return x("InvalidTag", "Closing tag '" + c + "' has not been opened.", E(t, o)); } else { const e = n.pop(); if (c !== e.tagName) { let n = E(t, e.tagStartPos); return x("InvalidTag", "Expected closing tag '" + e.tagName + "' (opened in line " + n.line + ", col " + n.col + ") instead of closing tag '" + c + "'.", E(t, o)); } if (n.length == 0) { i = true; } } } else { const a = p(g, e); if (a !== true) { return x(a.err.code, a.err.msg, E(t, r - g.length + a.err.line)); } if (i === true) { return x("InvalidXml", "Multiple possible root nodes found.", E(t, r)); } else if (e.unpairedTags.indexOf(c) !== -1) {} else { n.push({ tagName: c, tagStartPos: o }); } s = true; } for (r++; r < t.length; r++) { if (t[r] === "<") { if (t[r + 1] === "!") { r++; r = u(t, r); continue; } else if (t[r + 1] === "?") { r = l(t, ++r); if (r.err) return r; } else { break; } } else if (t[r] === "&") { const e = m(t, r); if (e == -1) return x("InvalidChar", "char '&' is not expected.", E(t, r)); r = e; } else { if (i === true && !a(t[r])) { return x("InvalidXml", "Extra text at the end", E(t, r)); } } } if (t[r] === "<") { r--; } } } else { if (a(t[r])) { continue; } return x("InvalidChar", "char '" + t[r] + "' is not expected.", E(t, r)); } } if (!s) { return x("InvalidXml", "Start tag expected.", 1); } else if (n.length == 1) { return x("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", E(t, n[0].tagStartPos)); } else if (n.length > 0) { return x("InvalidXml", "Invalid '" + JSON.stringify(n.map((t => t.tagName)), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }); } return true; }; function a(t) { return t === " " || t === "\t" || t === "\n" || t === "\r"; } function l(t, e) { const n = e; for (;e < t.length; e++) { if (t[e] == "?" || t[e] == " ") { const s = t.substr(n, e - n); if (e > 5 && s === "xml") { return x("InvalidXml", "XML declaration allowed only at the start of the document.", E(t, e)); } else if (t[e] == "?" && t[e + 1] == ">") { e++; break; } else { continue; } } } return e; } function u(t, e) { if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") { for (e += 3; e < t.length; e++) { if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") { e += 2; break; } } } else if (t.length > e + 8 && t[e + 1] === "D" && t[e + 2] === "O" && t[e + 3] === "C" && t[e + 4] === "T" && t[e + 5] === "Y" && t[e + 6] === "P" && t[e + 7] === "E") { let n = 1; for (e += 8; e < t.length; e++) { if (t[e] === "<") { n++; } else if (t[e] === ">") { n--; if (n === 0) { break; } } } } else if (t.length > e + 9 && t[e + 1] === "[" && t[e + 2] === "C" && t[e + 3] === "D" && t[e + 4] === "A" && t[e + 5] === "T" && t[e + 6] === "A" && t[e + 7] === "[") { for (e += 8; e < t.length; e++) { if (t[e] === "]" && t[e + 1] === "]" && t[e + 2] === ">") { e += 2; break; } } } return e; } const f = '"'; const c = "'"; function h(t, e) { let n = ""; let s = ""; let i = false; for (;e < t.length; e++) { if (t[e] === f || t[e] === c) { if (s === "") { s = t[e]; } else if (s !== t[e]) {} else { s = ""; } } else if (t[e] === ">") { if (s === "") { i = true; break; } } n += t[e]; } if (s !== "") { return false; } return { value: n, index: e, tagClosed: i }; } const d = new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g"); function p(t, e) { const n = i.getAllMatches(t, d); const s = {}; for (let t = 0; t < n.length; t++) { if (n[t][1].length === 0) { return x("InvalidAttr", "Attribute '" + n[t][2] + "' has no space in starting.", v(n[t])); } else if (n[t][3] !== undefined && n[t][4] === undefined) { return x("InvalidAttr", "Attribute '" + n[t][2] + "' is without value.", v(n[t])); } else if (n[t][3] === undefined && !e.allowBooleanAttributes) { return x("InvalidAttr", "boolean attribute '" + n[t][2] + "' is not allowed.", v(n[t])); } const i = n[t][2]; if (!N(i)) { return x("InvalidAttr", "Attribute '" + i + "' is an invalid name.", v(n[t])); } if (!s.hasOwnProperty(i)) { s[i] = 1; } else { return x("InvalidAttr", "Attribute '" + i + "' is repeated.", v(n[t])); } } return true; } function g(t, e) { let n = /\d/; if (t[e] === "x") { e++; n = /[\da-fA-F]/; } for (;e < t.length; e++) { if (t[e] === ";") return e; if (!t[e].match(n)) break; } return -1; } function m(t, e) { e++; if (t[e] === ";") return -1; if (t[e] === "#") { e++; return g(t, e); } let n = 0; for (;e < t.length; e++, n++) { if (t[e].match(/\w/) && n < 20) continue; if (t[e] === ";") break; return -1; } return e; } function x(t, e, n) { return { err: { code: t, msg: e, line: n.line || n, col: n.col } }; } function N(t) { return i.isName(t); } function b(t) { return i.isName(t); } function E(t, e) { const n = t.substring(0, e).split(/\r?\n/); return { line: n.length, col: n[n.length - 1].length + 1 }; } function v(t) { return t.startIndex + t[1].length; } var y = {}; const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t, e) { return e; }, attributeValueProcessor: function(t, e) { return e; }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t, e, n) { return t; } }; const O = function(t) { return Object.assign({}, T, t); }; var P = y.buildOptions = O; var w = y.defaultOptions = T; "use strict"; class XmlNode { constructor(t) { this.tagname = t; this.child = []; this[":@"] = {}; } add(t, e) { if (t === "__proto__") t = "#__proto__"; this.child.push({ [t]: e }); } addChild(t) { if (t.tagname === "__proto__") t.tagname = "#__proto__"; if (t[":@"] && Object.keys(t[":@"]).length > 0) { this.child.push({ [t.tagname]: t.child, [":@"]: t[":@"] }); } else { this.child.push({ [t.tagname]: t.child }); } } } var A = XmlNode; const C = t.getDefaultExportFromCjs(A); const I = n; function j(t, e) { const n = {}; if (t[e + 3] === "O" && t[e + 4] === "C" && t[e + 5] === "T" && t[e + 6] === "Y" && t[e + 7] === "P" && t[e + 8] === "E") { e = e + 9; let s = 1; let i = false, r = false; let o = ""; for (;e < t.length; e++) { if (t[e] === "<" && !r) { if (i && D(t, e)) { e += 7; let s, i; [s, i, e] = S(t, e + 1); if (i.indexOf("&") === -1) n[_(s)] = { regx: RegExp(`&${s};`, "g"), val: i }; } else if (i && V(t, e)) e += 8; else if (i && k(t, e)) e += 8; else if (i && $(t, e)) e += 9; else if (F) r = true; else throw new Error("Invalid DOCTYPE"); s++; o = ""; } else if (t[e] === ">") { if (r) { if (t[e - 1] === "-" && t[e - 2] === "-") { r = false; s--; } } else { s--; } if (s === 0) { break; } } else if (t[e] === "[") { i = true; } else { o += t[e]; } } if (s !== 0) { throw new Error(`Unclosed DOCTYPE`); } } else { throw new Error(`Invalid Tag instead of DOCTYPE`); } return { entities: n, i: e }; } function S(t, e) { let n = ""; for (;e < t.length && (t[e] !== "'" && t[e] !== '"'); e++) { n += t[e]; } n = n.trim(); if (n.indexOf(" ") !== -1) throw new Error("External entites are not supported"); const s = t[e++]; let i = ""; for (;e < t.length && t[e] !== s; e++) { i += t[e]; } return [ n, i, e ]; } function F(t, e) { if (t[e + 1] === "!" && t[e + 2] === "-" && t[e + 3] === "-") return true; return false; } function D(t, e) { if (t[e + 1] === "!" && t[e + 2] === "E" && t[e + 3] === "N" && t[e + 4] === "T" && t[e + 5] === "I" && t[e + 6] === "T" && t[e + 7] === "Y") return true; return false; } function V(t, e) { if (t[e + 1] === "!" && t[e + 2] === "E" && t[e + 3] === "L" && t[e + 4] === "E" && t[e + 5] === "M" && t[e + 6] === "E" && t[e + 7] === "N" && t[e + 8] === "T") return true; return false; } function k(t, e) { if (t[e + 1] === "!" && t[e + 2] === "A" && t[e + 3] === "T" && t[e + 4] === "T" && t[e + 5] === "L" && t[e + 6] === "I" && t[e + 7] === "S" && t[e + 8] === "T") return true; return false; } function $(t, e) { if (t[e + 1] === "!" && t[e + 2] === "N" && t[e + 3] === "O" && t[e + 4] === "T" && t[e + 5] === "A" && t[e + 6] === "T" && t[e + 7] === "I" && t[e + 8] === "O" && t[e + 9] === "N") return true; return false; } function _(t) { if (I.isName(t)) return t; else throw new Error(`Invalid entity name ${t}`); } var L = j; const M = t.getDefaultExportFromCjs(L); const X = /^[-+]?0x[a-fA-F0-9]+$/; const B = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/; const G = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; function R(t, e = {}) { e = Object.assign({}, G, e); if (!t || typeof t !== "string") return t; let n = t.trim(); if (e.skipLike !== undefined && e.skipLike.test(n)) return t; else if (t === "0") return 0; else if (e.hex && X.test(n)) { return Z(n, 16); } else if (n.search(/[eE]/) !== -1) { const s = n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/); if (s) { if (e.leadingZeros) { n = (s[1] || "") + s[3]; } else { if (s[2] === "0" && s[3][0] === ".") {} else { return t; } } return e.eNotation ? Number(n) : t; } else { return t; } } else { const s = B.exec(n); if (s) { const i = s[1]; const r = s[2]; let o = U(s[3]); if (!e.leadingZeros && r.length > 0 && i && n[2] !== ".") return t; else if (!e.leadingZeros && r.length > 0 && !i && n[1] !== ".") return t; else if (e.leadingZeros && r === t) return 0; else { const s = Number(n); const a = "" + s; if (a.search(/[eE]/) !== -1) { if (e.eNotation) return s; else return t; } else if (n.indexOf(".") !== -1) { if (a === "0" && o === "") return s; else if (a === o) return s; else if (i && a === "-" + o) return s; else return t; } if (r) { return o === a || i + o === a ? s : t; } else { return n === a || n === i + a ? s : t; } } } else { return t; } } } function U(t) { if (t && t.indexOf(".") !== -1) { t = t.replace(/0+$/, ""); if (t === ".") t = "0"; else if (t[0] === ".") t = "0" + t; else if (t[t.length - 1] === ".") t = t.substr(0, t.length - 1); return t; } return t; } function Z(t, e) { if (parseInt) return parseInt(t, e); else if (Number.parseInt) return Number.parseInt(t, e); else if (window && window.parseInt) return window.parseInt(t, e); else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); } var Y = R; const q = t.getDefaultExportFromCjs(Y); function W(t) { if (typeof t === "function") { return t; } if (Array.isArray(t)) { return e => { for (const n of t) { if (typeof n === "string" && e === n) { return true; } if (n instanceof RegExp && n.test(e)) { return true; } } }; } return () => false; } var z = W; const J = t.getDefaultExportFromCjs(z); "use strict"; const H = n; const K = A; const Q = L; const tt = Y; const et = z; let nt = class OrderedObjParser { constructor(t) { this.options = t; this.currentNode = null; this.tagsNodeStack = []; this.docTypeEntities = {}; this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }; this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }; this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "¢" }, pound: { regex: /&(pound|#163);/g, val: "£" }, yen: { regex: /&(yen|#165);/g, val: "¥" }, euro: { regex: /&(euro|#8364);/g, val: "€" }, copyright: { regex: /&(copy|#169);/g, val: "©" }, reg: { regex: /&(reg|#174);/g, val: "®" }, inr: { regex: /&(inr|#8377);/g, val: "₹" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t, e) => String.fromCharCode(Number.parseInt(e, 10)) }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t, e) => String.fromCharCode(Number.parseInt(e, 16)) } }; this.addExternalEntities = st; this.parseXml = lt; this.parseTextData = it; this.resolveNameSpace = rt; this.buildAttributesMap = at; this.isItStopNode = ht; this.replaceEntitiesValue = ft; this.readStopNodeData = mt; this.saveTextToParentTag = ct; this.addChild = ut; this.ignoreAttributesFn = et(this.options.ignoreAttributes); } }; function st(t) { const e = Object.keys(t); for (let n = 0; n < e.length; n++) { const s = e[n]; this.lastEntities[s] = { regex: new RegExp("&" + s + ";", "g"), val: t[s] }; } } function it(t, e, n, s, i, r, o) { if (t !== undefined) { if (this.options.trimValues && !s) { t = t.trim(); } if (t.length > 0) { if (!o) t = this.replaceEntitiesValue(t); const s = this.options.tagValueProcessor(e, t, n, i, r); if (s === null || s === undefined) { return t; } else if (typeof s !== typeof t || s !== t) { return s; } else if (this.options.trimValues) { return xt(t, this.options.parseTagValue, this.options.numberParseOptions); } else { const e = t.trim(); if (e === t) { return xt(t, this.options.parseTagValue, this.options.numberParseOptions); } else { return t; } } } } } function rt(t) { if (this.options.removeNSPrefix) { const e = t.split(":"); const n = t.charAt(0) === "/" ? "/" : ""; if (e[0] === "xmlns") { return ""; } if (e.length === 2) { t = n + e[1]; } } return t; } const ot = new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm"); function at(t, e, n) { if (this.options.ignoreAttributes !== true && typeof t === "string") { const n = H.getAllMatches(t, ot); const s = n.length; const i = {}; for (let t = 0; t < s; t++) { const s = this.resolveNameSpace(n[t][1]); if (this.ignoreAttributesFn(s, e)) { continue; } let r = n[t][4]; let o = this.options.attributeNamePrefix + s; if (s.length) { if (this.options.transformAttributeName) { o = this.options.transformAttributeName(o); } if (o === "__proto__") o = "#__proto__"; if (r !== undefined) { if (this.options.trimValues) { r = r.trim(); } r = this.replaceEntitiesValue(r); const t = this.options.attributeValueProcessor(s, r, e); if (t === null || t === undefined) { i[o] = r; } else if (typeof t !== typeof r || t !== r) { i[o] = t; } else { i[o] = xt(r, this.options.parseAttributeValue, this.options.numberParseOptions); } } else if (this.options.allowBooleanAttributes) { i[o] = true; } } } if (!Object.keys(i).length) { return; } if (this.options.attributesGroupName) { const t = {}; t[this.options.attributesGroupName] = i; return t; } return i; } } const lt = function(t) { t = t.replace(/\r\n?/g, "\n"); const e = new K("!xml"); let n = e; let s = ""; let i = ""; for (let r = 0; r < t.length; r++) { const o = t[r]; if (o === "<") { if (t[r + 1] === "/") { const e = pt(t, ">", r, "Closing Tag is not closed."); let o = t.substring(r + 2, e).trim(); if (this.options.removeNSPrefix) { const t = o.indexOf(":"); if (t !== -1) { o = o.substr(t + 1); } } if (this.options.transformTagName) { o = this.options.transformTagName(o); } if (n) { s = this.saveTextToParentTag(s, n, i); } const a = i.substring(i.lastIndexOf(".") + 1); if (o && this.options.unpairedTags.indexOf(o) !== -1) { throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`); } let l = 0; if (a && this.options.unpairedTags.indexOf(a) !== -1) { l = i.lastIndexOf(".", i.lastIndexOf(".") - 1); this.tagsNodeStack.pop(); } else { l = i.lastIndexOf("."); } i = i.substring(0, l); n = this.tagsNodeStack.pop(); s = ""; r = e; } else if (t[r + 1] === "?") { let e = gt(t, r, false, "?>"); if (!e) throw new Error("Pi Tag is not closed."); s = this.saveTextToParentTag(s, n, i); if (this.options.ignoreDeclaration && e.tagName === "?xml" || this.options.ignorePiTags) {} else { const t = new K(e.tagName); t.add(this.options.textNodeName, ""); if (e.tagName !== e.tagExp && e.attrExpPresent) { t[":@"] = this.buildAttributesMap(e.tagExp, i, e.tagName); } this.addChild(n, t, i); } r = e.closeIndex + 1; } else if (t.substr(r + 1, 3) === "!--") { const e = pt(t, "--\x3e", r + 4, "Comment is not closed."); if (this.options.commentPropName) { const o = t.substring(r + 4, e - 2); s = this.saveTextToParentTag(s, n, i); n.add(this.options.commentPropName, [ { [this.options.textNodeName]: o } ]); } r = e; } else if (t.substr(r + 1, 2) === "!D") { const e = Q(t, r); this.docTypeEntities = e.entities; r = e.i; } else if (t.substr(r + 1, 2) === "![") { const e = pt(t, "]]>", r, "CDATA is not closed.") - 2; const o = t.substring(r + 9, e); s = this.saveTextToParentTag(s, n, i); let a = this.parseTextData(o, n.tagname, i, true, false, true, true); if (a == undefined) a = ""; if (this.options.cdataPropName) { n.add(this.options.cdataPropName, [ { [this.options.textNodeName]: o } ]); } else { n.add(this.options.textNodeName, a); } r = e + 2; } else { let o = gt(t, r, this.options.removeNSPrefix); let a = o.tagName; const l = o.rawTagName; let u = o.tagExp; let f = o.attrExpPresent; let c = o.closeIndex; if (this.options.transformTagName) { a = this.options.transformTagName(a); } if (n && s) { if (n.tagname !== "!xml") { s = this.saveTextToParentTag(s, n, i, false); } } const h = n; if (h && this.options.unpairedTags.indexOf(h.tagname) !== -1) { n = this.tagsNodeStack.pop(); i = i.substring(0, i.lastIndexOf(".")); } if (a !== e.tagname) { i += i ? "." + a : a; } if (this.isItStopNode(this.options.stopNodes, i, a)) { let e = ""; if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) { if (a[a.length - 1] === "/") { a = a.substr(0, a.length - 1); i = i.substr(0, i.length - 1); u = a; } else { u = u.substr(0, u.length - 1); } r = o.closeIndex; } else if (this.options.unpairedTags.indexOf(a) !== -1) { r = o.closeIndex; } else { const n = this.readStopNodeData(t, l, c + 1); if (!n) throw new Error(`Unexpected end of ${l}`); r = n.i; e = n.tagContent; } const s = new K(a); if (a !== u && f) { s[":@"] = this.buildAttributesMap(u, i, a); } if (e) { e = this.parseTextData(e, a, i, true, f, true, true); } i = i.substr(0, i.lastIndexOf(".")); s.add(this.options.textNodeName, e); this.addChild(n, s, i); } else { if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) { if (a[a.length - 1] === "/") { a = a.substr(0, a.length - 1); i = i.substr(0, i.length - 1); u = a; } else { u = u.substr(0, u.length - 1); } if (this.options.transformTagName) { a = this.options.transformTagName(a); } const t = new K(a); if (a !== u && f) { t[":@"] = this.buildAttributesMap(u, i, a); } this.addChild(n, t, i); i = i.substr(0, i.lastIndexOf(".")); } else { const t = new K(a); this.tagsNodeStack.push(n); if (a !== u && f) { t[":@"] = this.buildAttributesMap(u, i, a); } this.addChild(n, t, i); n = t; } s = ""; r = c; } } } else { s += t[r]; } } return e.child; }; function ut(t, e, n) { const s = this.options.updateTag(e.tagname, n, e[":@"]); if (s === false) {} else if (typeof s === "string") { e.tagname = s; t.addChild(e); } else { t.addChild(e); } } const ft = function(t) { if (this.options.processEntities) { for (let e in this.docTypeEntities) { const n = this.docTypeEntities[e]; t = t.replace(n.regx, n.val); } for (let e in this.lastEntities) { const n = this.lastEntities[e]; t = t.replace(n.regex, n.val); } if (this.options.htmlEntities) { for (let e in this.htmlEntities) { const n = this.htmlEntities[e]; t = t.replace(n.regex, n.val); } } t = t.replace(this.ampEntity.regex, this.ampEntity.val); } return t; }; function ct(t, e, n, s) { if (t) { if (s === undefined) s = e.child.length === 0; t = this.parseTextData(t, e.tagname, n, false, e[":@"] ? Object.keys(e[":@"]).length !== 0 : false, s); if (t !== undefined && t !== "") e.add(this.options.textNodeName, t); t = ""; } return t; } function ht(t, e, n) { const s = "*." + n; for (const n in t) { const i = t[n]; if (s === i || e === i) return true; } return false; } function dt(t, e, n = ">") { let s; let i = ""; for (let r = e; r < t.length; r++) { let e = t[r]; if (s) { if (e === s) s = ""; } else if (e === '"' || e === "'") { s = e; } else if (e === n[0]) { if (n[1]) { if (t[r + 1] === n[1]) { return { data: i, index: r }; } } else { return { data: i, index: r }; } } else if (e === "\t") { e = " "; } i += e; } } function pt(t, e, n, s) { const i = t.indexOf(e, n); if (i === -1) { throw new Error(s); } else { return i + e.length - 1; } } function gt(t, e, n, s = ">") { const i = dt(t, e + 1, s); if (!i) return; let r = i.data; const o = i.index; const a = r.search(/\s/); let l = r; let u = true; if (a !== -1) { l = r.substring(0, a); r = r.substring(a + 1).trimStart(); } const f = l; if (n) { const t = l.indexOf(":"); if (t !== -1) { l = l.substr(t + 1); u = l !== i.data.substr(t + 1); } } return { tagName: l, tagExp: r, closeIndex: o, attrExpPresent: u, rawTagName: f }; } function mt(t, e, n) { const s = n; let i = 1; for (;n < t.length; n++) { if (t[n] === "<") { if (t[n + 1] === "/") { const r = pt(t, ">", n, `${e} is not closed`); let o = t.substring(n + 2, r).trim(); if (o === e) { i--; if (i === 0) { return { tagContent: t.substring(s, n), i: r }; } } n = r; } else if (t[n + 1] === "?") { const e = pt(t, "?>", n + 1, "StopNode is not closed."); n = e; } else if (t.substr(n + 1, 3) === "!--") { const e = pt(t, "--\x3e", n + 3, "StopNode is not closed."); n = e; } else if (t.substr(n + 1, 2) === "![") { const e = pt(t, "]]>", n, "StopNode is not closed.") - 2; n = e; } else { const s = gt(t, n, ">"); if (s) { const t = s && s.tagName; if (t === e && s.tagExp[s.tagExp.length - 1] !== "/") { i++; } n = s.closeIndex; } } } } } function xt(t, e, n) { if (e && typeof t === "string") { const e = t.trim(); if (e === "true") return true; else if (e === "false") return false; else return tt(t, n); } else { if (H.isExist(t)) { return t; } else { return ""; } } } var Nt = nt; const bt = t.getDefaultExportFromCjs(Nt); var Et = {}; "use strict"; function vt(t, e) { return yt(t, e); } function yt(t, e, n) { let s; const i = {}; for (let r = 0; r < t.length; r++) { const o = t[r]; const a = Tt(o); let l = ""; if (n === undefined) l = a; else l = n + "." + a; if (a === e.textNodeName) { if (s === undefined) s = o[a]; else s += "" + o[a]; } else if (a === undefined) { continue; } else if (o[a]) { let t = yt(o[a], e, l); const n = Pt(t, e); if (o[":@"]) { Ot(t, o[":@"], l, e); } else if (Object.keys(t).length === 1 && t[e.textNodeName] !== undefined && !e.alwaysCreateTextNode) { t = t[e.textNodeName]; } else if (Object.keys(t).length === 0) { if (e.alwaysCreateTextNode) t[e.textNodeName] = ""; else t = ""; } if (i[a] !== undefined && i.hasOwnProperty(a)) { if (!Array.isArray(i[a])) { i[a] = [ i[a] ]; } i[a].push(t); } else { if (e.isArray(a, l, n)) { i[a] = [ t ]; } else { i[a] = t; } } } } if (typeof s === "string") { if (s.length > 0) i[e.textNodeName] = s; } else if (s !== undefined) i[e.textNodeName] = s; return i; } function Tt(t) { const e = Object.keys(t); for (let t = 0; t < e.length; t++) { const n = e[t]; if (n !== ":@") return n; } } function Ot(t, e, n, s) { if (e) { const i = Object.keys(e); const r = i.length; for (let o = 0; o < r; o++) { const r = i[o]; if (s.isArray(r, n + "." + r, true, true)) { t[r] = [ e[r] ]; } else { t[r] = e[r]; } } } } function Pt(t, e) { const {textNodeName: n} = e; const s = Object.keys(t).length; if (s === 0) { return true; } if (s === 1 && (t[n] || typeof t[n] === "boolean" || t[n] === 0)) { return true; } return false; } var wt = Et.prettify = vt; const {buildOptions: At} = y; const Ct = Nt; const {prettify: It} = Et; const jt = e; let St = class XMLParser { constructor(t) { this.externalEntities = {}; this.options = At(t); } parse(t, e) { if (typeof t === "string") {} else if (t.toString) { t = t.toString(); } else { throw new Error("XML data is accepted in String or Bytes[] form."); } if (e) { if (e === true) e = {}; const n = jt.validate(t, e); if (n !== true) { throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`); } } const n = new Ct(this.options); n.addExternalEntities(this.externalEntities); const s = n.parseXml(t); if (this.options.preserveOrder || s === undefined) return s; else return It(s, this.options); } addEntity(t, e) { if (e.indexOf("&") !== -1) { throw new Error("Entity value can't have '&'"); } else if (t.indexOf("&") !== -1 || t.indexOf(";") !== -1) { throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'"); } else if (e === "&") { throw new Error("An entity with value '&' is not permitted"); } else { this.externalEntities[t] = e; } } }; var Ft = St; const Dt = t.getDefaultExportFromCjs(Ft); const Vt = "\n"; function kt(t, e) { let n = ""; if (e.format && e.indentBy.length > 0) { n = Vt; } return $t(t, e, "", n); } function $t(t, e, n, s) { let i = ""; let r = false; for (let o = 0; o < t.length; o++) { const a = t[o]; const l = _t(a); if (l === undefined) continue; let u = ""; if (n.length === 0) u = l; else u = `${n}.${l}`; if (l === e.textNodeName) { let t = a[l]; if (!Mt(u, e)) { t = e.tagValueProcessor(l, t); t = Xt(t, e); } if (r) { i += s; } i += t; r = false; continue; } else if (l === e.cdataPropName) { if (r) { i += s; } i += `<![CDATA[${a[l][0][e.textNodeName]}]]>`; r = false; continue; } else if (l === e.commentPropName) { i += s + `\x3c!--${a[l][0][e.textNodeName]}--\x3e`; r = true; continue; } else if (l[0] === "?") { const t = Lt(a[":@"], e); const n = l === "?xml" ? "" : s; let o = a[l][0][e.textNodeName]; o = o.length !== 0 ? " " + o : ""; i += n + `<${l}${o}${t}?>`; r = true; continue; } let f = s; if (f !== "") { f += e.indentBy; } const c = Lt(a[":@"], e); const h = s + `<${l}${c}`; const d = $t(a[l], e, u, f); if (e.unpairedTags.indexOf(l) !== -1) { if (e.suppressUnpairedNode) i += h + ">"; else i += h + "/>"; } else if ((!d || d.length === 0) && e.suppressEmptyNode) { i += h + "/>"; } else if (d && d.endsWith(">")) { i += h + `>${d}${s}</${l}>`; } else { i += h + ">"; if (d && s !== "" && (d.includes("/>") || d.includes("</"))) { i += s + e.indentBy + d + s; } else { i += d; } i += `</${l}>`; } r = true; } return i; } function _t(t) { const e = Object.keys(t); for (let n = 0; n < e.length; n++) { const s = e[n]; if (!t.hasOwnProperty(s)) continue; if (s !== ":@") return s; } } function Lt(t, e) { let n = ""; if (t && !e.ignoreAttributes) { for (let s in t) { if (!t.hasOwnProperty(s)) continue; let i = e.attributeValueProcessor(s, t[s]); i = Xt(i, e); if (i === true && e.suppressBooleanAttributes) { n += ` ${s.substr(e.attributeNamePrefix.length)}`; } else { n += ` ${s.substr(e.attributeNamePrefix.length)}="${i}"`; } } } return n; } function Mt(t, e) { t = t.substr(0, t.length - e.textNodeName.length - 1); let n = t.substr(t.lastIndexOf(".") + 1); for (let s in e.stopNodes) { if (e.stopNodes[s] === t || e.stopNodes[s] === "*." + n) return true; } return false; } function Xt(t, e) { if (t && t.length > 0 && e.processEntities) { for (let n = 0; n < e.entities.length; n++) { const s = e.entities[n]; t = t.replace(s.regex, s.val); } } return t; } var Bt = kt; const Gt = t.getDefaultExportFromCjs(Bt); "use strict"; const Rt = Bt; const Ut = z; const Zt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t, e) { return e; }, attributeValueProcessor: function(t, e) { return e; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [ { regex: new RegExp("&", "g"), val: "&amp;" }, { regex: new RegExp(">", "g"), val: "&gt;" }, { regex: new RegExp("<", "g"), val: "&lt;" }, { regex: new RegExp("'", "g"), val: "&apos;" }, { regex: new RegExp('"', "g"), val: "&quot;" } ], processEntities: true, stopNodes: [], oneListGroup: false }; function Yt(t) { this.options = Object.assign({}, Zt, t); if (this.options.ignoreAttributes === true || this.options.attributesGroupName) { this.isAttribute = function() { return false; }; } else { this.ignoreAttributesFn = Ut(this.options.ignoreAttributes); this.attrPrefixLen = this.options.attributeNamePrefix.length; this.isAttribute = Jt; } this.processTextOrObjNode = qt; if (this.options.format) { this.indentate = zt; this.tagEndChar = ">\n"; this.newLine = "\n"; } else { this.indentate = function() { return ""; }; this.tagEndChar = ">"; this.newLine = ""; } } Yt.prototype.build = function(t) { if (this.options.preserveOrder) { return Rt(t, this.options); } else { if (Array.isArray(t) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) { t = { [this.options.arrayNodeName]: t }; } return this.j2x(t, 0, []).val; } }; Yt.prototype.j2x = function(t, e, n) { let s = ""; let i = ""; const r = n.join("."); for (let o in t) { if (!Object.prototype.hasOwnProperty.call(t, o)) continue; if (typeof t[o] === "undefined") { if (this.isAttribute(o)) { i += ""; } } else if (t[o] === null) { if (this.isAttribute(o)) { i += ""; } else if (o === this.options.cdataPropName) { i += ""; } else if (o[0] === "?") { i += this.indentate(e) + "<" + o + "?" + this.tagEndChar; } else { i += this.indentate(e) + "<" + o + "/" + this.tagEndChar; } } else if (t[o] instanceof Date) { i += this.buildTextValNode(t[o], o, "", e); } else if (typeof t[o] !== "object") { const n = this.isAttribute(o); if (n && !this.ignoreAttributesFn(n, r)) { s += this.buildAttrPairStr(n, "" + t[o]); } else if (!n) { if (o === this.options.textNodeName) { let e = this.options.tagValueProcessor(o, "" + t[o]); i += this.replaceEntitiesValue(e); } else { i += this.buildTextValNode(t[o], o, "", e); } } } else if (Array.isArray(t[o])) { const s = t[o].length; let r = ""; let a = ""; for (let l = 0; l < s; l++) { const s = t[o][l]; if (typeof s === "undefined") {} else if (s === null) { if (o[0] === "?") i += this.indentate(e) + "<" + o + "?" + this.tagEndChar; else i += this.indentate(e) + "<" + o + "/" + this.tagEndChar; } else if (typeof s === "object") { if (this.options.oneListGroup) { const t = this.j2x(s, e + 1, n.concat(o)); r += t.val; if (this.options.attributesGroupName && s.hasOwnProperty(this.options.attributesGroupName)) { a += t.attrStr; } } else { r += this.processTextOrObjNode(s, o, e, n); } } else { if (this.options.oneListGroup) { let t = this.options.tagValueProcessor(o, s); t = this.replaceEntitiesValue(t); r += t; } else { r += this.buildTextValNode(s, o, "", e); } } } if (this.options.oneListGroup) { r = this.buildObjectNode(r, o, a, e); } i += r; } else { if (this.options.attributesGroupName && o === this.options.attributesGroupName) { const e = Object.keys(t[o]); const n = e.length; for (let i = 0; i < n; i++) { s += this.buildAttrPairStr(e[i], "" + t[o][e[i]]); } } else { i += this.processTextOrObjNode(t[o], o, e, n); } } } return { attrStr: s, val: i }; }; Yt.prototype.buildAttrPairStr = function(t, e) { e = this.options.attributeValueProcessor(t, "" + e); e = this.replaceEntitiesValue(e); if (this.options.suppressBooleanAttributes && e === "true") { return " " + t; } else return " " + t + '="' + e + '"'; }; function qt(t, e, n, s) { const i = this.j2x(t, n + 1, s.concat(e)); if (t[this.options.textNodeName] !== undefined && Object.keys(t).length === 1) { return this.buildTextValNode(t[this.options.textNodeName], e, i.attrStr, n); } else { return this.buildObjectNode(i.val, e, i.attrStr, n);