diff --git a/.github/workflows/deflake.yml b/.github/workflows/deflake.yml new file mode 100644 index 0000000000..158dc6c96d --- /dev/null +++ b/.github/workflows/deflake.yml @@ -0,0 +1,106 @@ +# Workflow runs on main, on a release branch, and that were triggered as part of a merge group have +# already passed CI before being merged. Therefore if they fail, we should make sure that there +# wasn't a transient failure by rerunning the failed jobs once before investigating further. +name: Deflake + +on: + workflow_run: + types: [completed] + # Exclude workflows that have significant side effects, like publishing releases. It's OK to + # retry CodeQL analysis. + workflows: + - Check Expected Release Files + - Code-Scanning config CLI tests + - CodeQL action + - Manual Check - go + - "PR Check - All-platform bundle" + - "PR Check - Analysis kinds" + - "PR Check - Analyze: 'ref' and 'sha' from inputs" + - "PR Check - autobuild-action" + - "PR Check - Autobuild direct tracing (custom working directory)" + - "PR Check - Autobuild working directory" + - "PR Check - Build mode autobuild" + - "PR Check - Build mode manual" + - "PR Check - Build mode none" + - "PR Check - Build mode rollback" + - "PR Check - Bundle: Caching checks" + - "PR Check - Bundle: From nightly" + - "PR Check - Bundle: From toolcache" + - "PR Check - Bundle: Zstandard checks" + - "PR Check - C/C\\+\\+: autoinstalling dependencies (Linux)" + - "PR Check - C/C\\+\\+: autoinstalling dependencies is skipped (macOS)" + - "PR Check - C/C\\+\\+: disabling autoinstalling dependencies (Linux)" + - "PR Check - Clean up database cluster directory" + - "PR Check - CodeQL Bundle All" + - "PR Check - Config export" + - "PR Check - Config input" + - "PR Check - Custom source root" + - "PR Check - Debug artifact upload" + - "PR Check - Debug artifacts after failure" + - "PR Check - Diagnostic export" + - "PR Check - Export file baseline information" + - "PR Check - Extractor ram and threads options test" + - "PR Check - Go: Custom queries" + - "PR Check - Go: diagnostic when Go is changed after init step" + - "PR Check - Go: diagnostic when `file` is not installed" + - "PR Check - Go: tracing with autobuilder step" + - "PR Check - Go: tracing with custom build steps" + - "PR Check - Go: tracing with legacy workflow" + - "PR Check - Go: workaround for indirect tracing" + - "PR Check - Job run UUID added to SARIF" + - "PR Check - Language aliases" + - "PR Check - Local CodeQL bundle" + - "PR Check - Multi-language repository" + - "PR Check - Overlay database init fallback" + - "PR Check - Packaging: Action input" + - "PR Check - Packaging: Config and input" + - "PR Check - Packaging: Config and input passed to the CLI" + - "PR Check - Packaging: Config file" + - "PR Check - Packaging: Download using registries" + - "PR Check - Proxy test" + - "PR Check - Remote config file" + - "PR Check - Resolve environment" + - "PR Check - RuboCop multi-language" + - "PR Check - Ruby analysis" + - "PR Check - Rust analysis" + - "PR Check - Split workflow" + - "PR Check - Start proxy" + - "PR Check - Submit SARIF after failure" + - "PR Check - Swift analysis using a custom build command" + - "PR Check - Swift analysis using autobuild" + - "PR Check - Test different uses of `upload-sarif`" + - "PR Check - Test unsetting environment variables" + - "PR Check - Upload-sarif: ref and sha from inputs" + - "PR Check - Use a custom `checkout_path`" + - PR Checks + - Query filters tests + - Test that the workaround for python 3.12 on windows works + +jobs: + rerun-on-failure: + name: Rerun failed jobs + if: >- + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.run_attempt == 1 && + ( + github.event.workflow_run.head_branch == 'main' || + startsWith(github.event.workflow_run.head_branch, 'releases/') || + github.event.workflow_run.event == 'merge_group' + ) + runs-on: ubuntu-slim + permissions: + actions: write + steps: + - name: Rerun failed jobs in ${{ github.event.workflow_run.name }} + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RUN_ID: ${{ github.event.workflow_run.id }} + RUN_NAME: ${{ github.event.workflow_run.name }} + RUN_URL: ${{ github.event.workflow_run.html_url }} + run: | + echo "Rerunning failed jobs for workflow run ${RUN_ID}" + gh run rerun "${RUN_ID}" --failed + echo "### Reran failed jobs :recycle:" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "Workflow: [${RUN_NAME}](${RUN_URL})" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/update-bundle.yml b/.github/workflows/update-bundle.yml index acc8fc27eb..837079481a 100644 --- a/.github/workflows/update-bundle.yml +++ b/.github/workflows/update-bundle.yml @@ -63,13 +63,10 @@ jobs: with: tools: https://github.com/github/codeql-action/releases/download/${{ github.event.release.tag_name }}/codeql-bundle-linux64.tar.gz - - name: Update language aliases + - name: Update built-in languages + run: npx tsx pr-checks/update-builtin-languages.ts "$CODEQL_PATH" env: CODEQL_PATH: ${{ steps.setup-codeql.outputs.codeql-path }} - run: | - "$CODEQL_PATH" resolve languages --format=betterjson --extractor-include-aliases \ - | jq -S '.aliases // {}' \ - > src/known-language-aliases.json - name: Bump Action minor version if new CodeQL minor version series id: bump-action-version diff --git a/CHANGELOG.md b/CHANGELOG.md index 002fb3f2b1..d831f31be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,15 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th ## [UNRELEASED] +No user facing changes. + +## 4.35.2 - 15 Apr 2026 + - The undocumented TRAP cache cleanup feature that could be enabled using the `CODEQL_ACTION_CLEANUP_TRAP_CACHES` environment variable is deprecated and will be removed in May 2026. If you are affected by this, we recommend disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action. [#3795](https://github.com/github/codeql-action/pull/3795) - The Git version 2.36.0 requirement for improved incremental analysis now only applies to repositories that contain submodules. [#3789](https://github.com/github/codeql-action/pull/3789) - Python analysis on GHES no longer extracts the standard library, relying instead on models of the standard library. This should result in significantly faster extraction and analysis times, while the effect on alerts should be minimal. [#3794](https://github.com/github/codeql-action/pull/3794) - Fixed a bug in the validation of OIDC configurations for private registries that was added in CodeQL Action 4.33.0 / 3.33.0. [#3807](https://github.com/github/codeql-action/pull/3807) +- Update default CodeQL bundle version to [2.25.2](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.2). [#3823](https://github.com/github/codeql-action/pull/3823) ## 4.35.1 - 27 Mar 2026 diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index ca8b16fc1f..aa04634147 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -161559,7 +161813,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -162620,6 +162874,36 @@ var featureConfig = { } }; +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); diff --git a/lib/analyze-action.js b/lib/analyze-action.js index d6499da8e0..712b2b62bd 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto3 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -38029,7 +38029,7 @@ var require_frame2 = __commonJS({ } catch { crypto3 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53039,8 +53039,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57783,7 +57783,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57832,7 +57832,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -106728,7 +106982,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -107659,8 +107913,8 @@ var path6 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -108564,6 +108818,36 @@ ${jsonContents}` } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); @@ -108791,22 +109075,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -108827,12 +109107,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/tar.ts @@ -110739,15 +111013,9 @@ async function setupDiffInformedQueryRun(logger) { diffRanges, checkoutPath ); - if (packDir === void 0) { - logger.warning( - "Cannot create diff range extension pack for diff-informed queries; reverting to performing full analysis." - ); - } else { - logger.info( - `Successfully created diff range extension pack at ${packDir}.` - ); - } + logger.info( + `Successfully created diff range extension pack at ${packDir}.` + ); return packDir; } ); @@ -110772,9 +111040,6 @@ extensions: return header + data; } function writeDiffRangeDataExtensionPack(logger, ranges, checkoutPath) { - if (ranges === void 0) { - return void 0; - } if (ranges.length === 0) { ranges = [{ path: "", startLine: 0, endLine: 0 }]; } @@ -113379,7 +113644,11 @@ function doesGoExtractionOutputExist(config) { config, "go" /* go */ ); - const trapDirectory = import_path4.default.join(golangDbDirectory, "trap", "go" /* go */); + const trapDirectory = import_path4.default.join( + golangDbDirectory, + "trap", + "go" /* go */ + ); return fs19.existsSync(trapDirectory) && fs19.readdirSync(trapDirectory).some( (fileName) => [ ".trap", diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 5c93699627..a1b0a32553 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -103533,7 +103787,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -104151,8 +104405,8 @@ var path5 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -104999,6 +105253,36 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) { } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); diff --git a/lib/defaults.json b/lib/defaults.json index 33f577571a..cd7499eb29 100644 --- a/lib/defaults.json +++ b/lib/defaults.json @@ -1,6 +1,6 @@ { - "bundleVersion": "codeql-bundle-v2.25.1", - "cliVersion": "2.25.1", - "priorBundleVersion": "codeql-bundle-v2.24.3", - "priorCliVersion": "2.24.3" + "bundleVersion": "codeql-bundle-v2.25.2", + "cliVersion": "2.25.2", + "priorBundleVersion": "codeql-bundle-v2.25.1", + "priorCliVersion": "2.25.1" } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 67451b7021..59a13f6284 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -38029,7 +38029,7 @@ var require_frame2 = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53039,8 +53039,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57783,7 +57783,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57832,7 +57832,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -164669,7 +164923,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -165578,8 +165832,8 @@ var path6 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -166487,6 +166741,36 @@ ${jsonContents}` } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var fs7 = __toESM(require("fs")); var path7 = __toESM(require("path")); @@ -166636,22 +166920,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -166672,12 +166952,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/tar.ts diff --git a/lib/init-action.js b/lib/init-action.js index f1634c88b4..51f1eef91d 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto3 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -38029,7 +38029,7 @@ var require_frame2 = __commonJS({ } catch { crypto3 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53190,8 +53190,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57934,7 +57934,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57983,7 +57983,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61986,38 +61986,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -62031,7 +62031,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -62039,28 +62039,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -62068,26 +62068,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -62103,9 +62103,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -62116,88 +62116,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62205,19 +62205,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62226,146 +62226,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62382,9 +62434,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62404,14 +62454,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62419,97 +62474,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62532,410 +62583,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt2, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt2(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt2(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62944,13 +63174,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt2(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62959,131 +63189,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -63091,173 +63324,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100314,6 +100553,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100378,6 +100622,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100515,6 +100760,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100620,7 +100868,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100769,6 +101017,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString3(value) { return typeof value === "string" || value instanceof String; } @@ -100781,6 +101032,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -100809,22 +101063,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -100845,12 +101095,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/actions-util.ts @@ -104097,7 +104341,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -105209,8 +105453,8 @@ var path7 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -106249,20 +106493,48 @@ function getDiffRanges(fileDiff, logger) { return diffRanges; } -// src/languages.ts -var KnownLanguage = /* @__PURE__ */ ((KnownLanguage2) => { - KnownLanguage2["actions"] = "actions"; - KnownLanguage2["cpp"] = "cpp"; - KnownLanguage2["csharp"] = "csharp"; - KnownLanguage2["go"] = "go"; - KnownLanguage2["java"] = "java"; - KnownLanguage2["javascript"] = "javascript"; - KnownLanguage2["python"] = "python"; - KnownLanguage2["ruby"] = "ruby"; - KnownLanguage2["rust"] = "rust"; - KnownLanguage2["swift"] = "swift"; - return KnownLanguage2; -})(KnownLanguage || {}); +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var BuiltInLanguage = /* @__PURE__ */ ((BuiltInLanguage2) => { + BuiltInLanguage2["actions"] = "actions"; + BuiltInLanguage2["cpp"] = "cpp"; + BuiltInLanguage2["csharp"] = "csharp"; + BuiltInLanguage2["go"] = "go"; + BuiltInLanguage2["java"] = "java"; + BuiltInLanguage2["javascript"] = "javascript"; + BuiltInLanguage2["python"] = "python"; + BuiltInLanguage2["ruby"] = "ruby"; + BuiltInLanguage2["rust"] = "rust"; + BuiltInLanguage2["swift"] = "swift"; + return BuiltInLanguage2; +})(BuiltInLanguage || {}); +var builtInLanguageSet = new Set(builtin_default.languages); // src/overlay/diagnostics.ts async function addOverlayDisablementDiagnostics(config, codeql, overlayDisabledReason) { @@ -106525,7 +106797,7 @@ async function getSupportedLanguageMap(codeql, logger) { } const supportedLanguages = {}; for (const extractor of Object.keys(resolveResult.extractors)) { - if (resolveSupportedLanguagesUsingCli || KnownLanguage[extractor] !== void 0) { + if (resolveSupportedLanguagesUsingCli || BuiltInLanguage[extractor] !== void 0) { supportedLanguages[extractor] = extractor; } } diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 50c18e8ae6..02342c09bc 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -103541,7 +103795,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -104663,6 +104917,36 @@ var featureConfig = { } }; +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 847757a256..58431548c9 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -38029,7 +38029,7 @@ var require_frame2 = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53039,8 +53039,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57783,7 +57783,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57832,7 +57832,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -100648,22 +100902,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -100684,12 +100934,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/actions-util.ts @@ -103638,7 +103882,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -104002,8 +104246,8 @@ var path5 = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -105235,6 +105479,36 @@ function writeDiagnostic(config, language, diagnostic) { } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index 3c9dcf5e5f..00a390c1fc 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -158271,6 +158510,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -158335,6 +158579,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -158472,6 +158717,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -158577,7 +158825,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -158726,6 +158974,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -158738,6 +158989,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -161506,7 +161760,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } var persistedInputsKey = "persisted_inputs"; var restoreInputs = function() { @@ -161940,6 +162194,36 @@ var featureConfig = { } }; +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 0a64ac2147..2207e140e2 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -1586,8 +1586,8 @@ var require_util = __commonJS({ function isUSVString(val) { return hasIsWellFormed ? `${val}`.isWellFormed() : toUSVString(val) === `${val}`; } - function isTokenCharCode(c2) { - switch (c2) { + function isTokenCharCode(c) { + switch (c) { case 34: case 40: case 41: @@ -1607,7 +1607,7 @@ var require_util = __commonJS({ case 125: return false; default: - return c2 >= 33 && c2 <= 126; + return c >= 33 && c <= 126; } } function isValidHTTPToken(characters) { @@ -3179,7 +3179,7 @@ var require_constants2 = __commonJS({ exports2.HEADER_CHARS.push(i); } } - exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c2) => c2 !== 44); + exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c) => c !== 44); exports2.MAJOR = exports2.NUM_MAP; exports2.MINOR = exports2.MAJOR; var HEADER_STATE; @@ -4318,10 +4318,10 @@ var require_util2 = __commonJS({ } function isValidReasonPhrase(statusText) { for (let i = 0; i < statusText.length; ++i) { - const c2 = statusText.charCodeAt(i); - if (!(c2 === 9 || // HTAB - c2 >= 32 && c2 <= 126 || // SP / VCHAR - c2 >= 128 && c2 <= 255)) { + const c = statusText.charCodeAt(i); + if (!(c === 9 || // HTAB + c >= 32 && c <= 126 || // SP / VCHAR + c >= 128 && c <= 255)) { return false; } } @@ -8281,7 +8281,7 @@ var require_pool_base = __commonJS({ pool.emit("drain", origin, [pool, ...targets]); } if (pool[kClosedResolve] && queue.isEmpty()) { - Promise.all(pool[kClients].map((c2) => c2.close())).then(pool[kClosedResolve]); + Promise.all(pool[kClients].map((c) => c.close())).then(pool[kClosedResolve]); } }; this[kOnConnect] = (origin, targets) => { @@ -8330,7 +8330,7 @@ var require_pool_base = __commonJS({ } async [kClose]() { if (this[kQueue].isEmpty()) { - await Promise.all(this[kClients].map((c2) => c2.close())); + await Promise.all(this[kClients].map((c) => c.close())); } else { await new Promise((resolve2) => { this[kClosedResolve] = resolve2; @@ -8345,7 +8345,7 @@ var require_pool_base = __commonJS({ } item.handler.onError(err); } - await Promise.all(this[kClients].map((c2) => c2.destroy(err))); + await Promise.all(this[kClients].map((c) => c.destroy(err))); } [kDispatch](opts, handler2) { const dispatcher = this[kGetDispatcher](); @@ -15073,8 +15073,8 @@ var require_util4 = __commonJS({ return new TextDecoder(encoding).decode(sliced); } function BOMSniffing(ioQueue) { - const [a, b, c2] = ioQueue; - if (a === 239 && b === 187 && c2 === 191) { + const [a, b, c] = ioQueue; + if (a === 239 && b === 187 && c === 191) { return "UTF-8"; } else if (a === 254 && b === 255) { return "UTF-16BE"; @@ -19488,7 +19488,7 @@ var require_lib = __commonJS({ } }; exports2.HttpClient = HttpClient; - var lowercaseKeys2 = (obj) => Object.keys(obj).reduce((c2, k) => (c2[k.toLowerCase()] = obj[k], c2), {}); + var lowercaseKeys2 = (obj) => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); } }); @@ -20898,39 +20898,39 @@ var require_toolrunner = __commonJS({ let inQuotes = false; let escaped = false; let arg = ""; - function append(c2) { - if (escaped && c2 !== '"') { + function append(c) { + if (escaped && c !== '"') { arg += "\\"; } - arg += c2; + arg += c; escaped = false; } for (let i = 0; i < argString.length; i++) { - const c2 = argString.charAt(i); - if (c2 === '"') { + const c = argString.charAt(i); + if (c === '"') { if (!escaped) { inQuotes = !inQuotes; } else { - append(c2); + append(c); } continue; } - if (c2 === "\\" && escaped) { - append(c2); + if (c === "\\" && escaped) { + append(c); continue; } - if (c2 === "\\" && inQuotes) { + if (c === "\\" && inQuotes) { escaped = true; continue; } - if (c2 === " " && !inQuotes) { + if (c === " " && !inQuotes) { if (arg.length > 0) { args.push(arg); arg = ""; } continue; } - append(c2); + append(c); } if (arg.length > 0) { args.push(arg.trim()); @@ -22584,8 +22584,8 @@ var require_util9 = __commonJS({ function isUSVString(val) { return hasIsWellFormed ? `${val}`.isWellFormed() : toUSVString(val) === `${val}`; } - function isTokenCharCode(c2) { - switch (c2) { + function isTokenCharCode(c) { + switch (c) { case 34: case 40: case 41: @@ -22605,7 +22605,7 @@ var require_util9 = __commonJS({ case 125: return false; default: - return c2 >= 33 && c2 <= 126; + return c >= 33 && c <= 126; } } function isValidHTTPToken(characters) { @@ -24177,7 +24177,7 @@ var require_constants7 = __commonJS({ exports2.HEADER_CHARS.push(i); } } - exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c2) => c2 !== 44); + exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c) => c !== 44); exports2.MAJOR = exports2.NUM_MAP; exports2.MINOR = exports2.MAJOR; var HEADER_STATE; @@ -25316,10 +25316,10 @@ var require_util10 = __commonJS({ } function isValidReasonPhrase(statusText) { for (let i = 0; i < statusText.length; ++i) { - const c2 = statusText.charCodeAt(i); - if (!(c2 === 9 || // HTAB - c2 >= 32 && c2 <= 126 || // SP / VCHAR - c2 >= 128 && c2 <= 255)) { + const c = statusText.charCodeAt(i); + if (!(c === 9 || // HTAB + c >= 32 && c <= 126 || // SP / VCHAR + c >= 128 && c <= 255)) { return false; } } @@ -29279,7 +29279,7 @@ var require_pool_base2 = __commonJS({ pool.emit("drain", origin, [pool, ...targets]); } if (pool[kClosedResolve] && queue.isEmpty()) { - Promise.all(pool[kClients].map((c2) => c2.close())).then(pool[kClosedResolve]); + Promise.all(pool[kClients].map((c) => c.close())).then(pool[kClosedResolve]); } }; this[kOnConnect] = (origin, targets) => { @@ -29328,7 +29328,7 @@ var require_pool_base2 = __commonJS({ } async [kClose]() { if (this[kQueue].isEmpty()) { - await Promise.all(this[kClients].map((c2) => c2.close())); + await Promise.all(this[kClients].map((c) => c.close())); } else { await new Promise((resolve2) => { this[kClosedResolve] = resolve2; @@ -29343,7 +29343,7 @@ var require_pool_base2 = __commonJS({ } item.handler.onError(err); } - await Promise.all(this[kClients].map((c2) => c2.destroy(err))); + await Promise.all(this[kClients].map((c) => c.destroy(err))); } [kDispatch](opts, handler2) { const dispatcher = this[kGetDispatcher](); @@ -36071,8 +36071,8 @@ var require_util12 = __commonJS({ return new TextDecoder(encoding).decode(sliced); } function BOMSniffing(ioQueue) { - const [a, b, c2] = ioQueue; - if (a === 239 && b === 187 && c2 === 191) { + const [a, b, c] = ioQueue; + if (a === 239 && b === 187 && c === 191) { return "UTF-8"; } else if (a === 254 && b === 255) { return "UTF-16BE"; @@ -40160,8 +40160,8 @@ function encodeReserved(str2) { }).join(""); } function encodeUnreserved(str2) { - return encodeURIComponent(str2).replace(/[!'()*]/g, function(c2) { - return "%" + c2.charCodeAt(0).toString(16).toUpperCase(); + return encodeURIComponent(str2).replace(/[!'()*]/g, function(c) { + return "%" + c.charCodeAt(0).toString(16).toUpperCase(); }); } function encodeValue(operator, value, key) { @@ -44946,19 +44946,19 @@ var require_range = __commonJS({ this.loose = !!options.loose; this.includePrerelease = !!options.includePrerelease; this.raw = range.trim().replace(SPACE_CHARACTERS, " "); - this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c2) => c2.length); + this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length); if (!this.set.length) { throw new TypeError(`Invalid SemVer Range: ${this.raw}`); } if (this.set.length > 1) { const first = this.set[0]; - this.set = this.set.filter((c2) => !isNullSet(c2[0])); + this.set = this.set.filter((c) => !isNullSet(c[0])); if (this.set.length === 0) { this.set = [first]; } else if (this.set.length > 1) { - for (const c2 of this.set) { - if (c2.length === 1 && isAny(c2[0])) { - this.set = [c2]; + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c]; break; } } @@ -45079,8 +45079,8 @@ var require_range = __commonJS({ caretTrimReplace } = require_re(); var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants11(); - var isNullSet = (c2) => c2.value === "<0.0.0-0"; - var isAny = (c2) => c2.value === ""; + var isNullSet = (c) => c.value === "<0.0.0-0"; + var isAny = (c) => c.value === ""; var isSatisfiable = (comparators, options) => { let result = true; const remainingComparators = comparators.slice(); @@ -45108,7 +45108,7 @@ var require_range = __commonJS({ }; var isX = (id) => !id || id.toLowerCase() === "x" || id === "*"; var replaceTildes = (comp, options) => { - return comp.trim().split(/\s+/).map((c2) => replaceTilde(c2, options)).join(" "); + return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "); }; var replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]; @@ -45132,7 +45132,7 @@ var require_range = __commonJS({ }); }; var replaceCarets = (comp, options) => { - return comp.trim().split(/\s+/).map((c2) => replaceCaret(c2, options)).join(" "); + return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "); }; var replaceCaret = (comp, options) => { debug5("caret", comp, options); @@ -45180,7 +45180,7 @@ var require_range = __commonJS({ }; var replaceXRanges = (comp, options) => { debug5("replaceXRanges", comp, options); - return comp.split(/\s+/).map((c2) => replaceXRange(c2, options)).join(" "); + return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" "); }; var replaceXRange = (comp, options) => { comp = comp.trim(); @@ -45433,7 +45433,7 @@ var require_to_comparators = __commonJS({ "node_modules/semver/ranges/to-comparators.js"(exports2, module2) { "use strict"; var Range2 = require_range(); - var toComparators = (range, options) => new Range2(range, options).set.map((comp) => comp.map((c2) => c2.value).join(" ").trim().split(" ")); + var toComparators = (range, options) => new Range2(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")); module2.exports = toComparators; } }); @@ -45778,13 +45778,13 @@ var require_subset = __commonJS({ } const eqSet = /* @__PURE__ */ new Set(); let gt, lt; - for (const c2 of sub) { - if (c2.operator === ">" || c2.operator === ">=") { - gt = higherGT(gt, c2, options); - } else if (c2.operator === "<" || c2.operator === "<=") { - lt = lowerLT(lt, c2, options); + for (const c of sub) { + if (c.operator === ">" || c.operator === ">=") { + gt = higherGT(gt, c, options); + } else if (c.operator === "<" || c.operator === "<=") { + lt = lowerLT(lt, c, options); } else { - eqSet.add(c2.semver); + eqSet.add(c.semver); } } if (eqSet.size > 1) { @@ -45806,8 +45806,8 @@ var require_subset = __commonJS({ if (lt && !satisfies2(eq, String(lt), options)) { return null; } - for (const c2 of dom) { - if (!satisfies2(eq, String(c2), options)) { + for (const c of dom) { + if (!satisfies2(eq, String(c), options)) { return false; } } @@ -45820,40 +45820,40 @@ var require_subset = __commonJS({ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) { needDomLTPre = false; } - for (const c2 of dom) { - hasDomGT = hasDomGT || c2.operator === ">" || c2.operator === ">="; - hasDomLT = hasDomLT || c2.operator === "<" || c2.operator === "<="; + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">="; + hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<="; if (gt) { if (needDomGTPre) { - if (c2.semver.prerelease && c2.semver.prerelease.length && c2.semver.major === needDomGTPre.major && c2.semver.minor === needDomGTPre.minor && c2.semver.patch === needDomGTPre.patch) { + if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) { needDomGTPre = false; } } - if (c2.operator === ">" || c2.operator === ">=") { - higher = higherGT(gt, c2, options); - if (higher === c2 && higher !== gt) { + if (c.operator === ">" || c.operator === ">=") { + higher = higherGT(gt, c, options); + if (higher === c && higher !== gt) { return false; } - } else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c2), options)) { + } else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) { return false; } } if (lt) { if (needDomLTPre) { - if (c2.semver.prerelease && c2.semver.prerelease.length && c2.semver.major === needDomLTPre.major && c2.semver.minor === needDomLTPre.minor && c2.semver.patch === needDomLTPre.patch) { + if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) { needDomLTPre = false; } } - if (c2.operator === "<" || c2.operator === "<=") { - lower = lowerLT(lt, c2, options); - if (lower === c2 && lower !== lt) { + if (c.operator === "<" || c.operator === "<=") { + lower = lowerLT(lt, c, options); + if (lower === c && lower !== lt) { return false; } - } else if (lt.operator === "<=" && !satisfies2(lt.semver, String(c2), options)) { + } else if (lt.operator === "<=" && !satisfies2(lt.semver, String(c), options)) { return false; } } - if (!c2.operator && (lt || gt) && gtltComp !== 0) { + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false; } } @@ -48072,9 +48072,9 @@ var require_tool_cache = __commonJS({ core13.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { - const c2 = semver6.clean(versionSpec) || ""; - core13.debug(`isExplicit: ${c2}`); - const valid2 = semver6.valid(c2) != null; + const c = semver6.clean(versionSpec) || ""; + core13.debug(`isExplicit: ${c}`); + const valid2 = semver6.valid(c) != null; core13.debug(`explicit? ${valid2}`); return valid2; } @@ -49942,25 +49942,25 @@ var require_brace_expansion = __commonJS({ var pad = n.some(isPadded); N = []; for (var i = x; test(i, y); i += incr) { - var c2; + var c; if (isAlphaSequence) { - c2 = String.fromCharCode(i); - if (c2 === "\\") - c2 = ""; + c = String.fromCharCode(i); + if (c === "\\") + c = ""; } else { - c2 = String(i); + c = String(i); if (pad) { - var need = width - c2.length; + var need = width - c.length; if (need > 0) { var z = new Array(need + 1).join("0"); if (i < 0) - c2 = "-" + z + c2.slice(1); + c = "-" + z + c.slice(1); else - c2 = z + c2; + c = z + c; } } } - N.push(c2); + N.push(c); } } else { N = concatMap(n, function(el) { @@ -50008,8 +50008,8 @@ var require_minimatch = __commonJS({ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?"; var reSpecials = charSet("().*{}+?[]^$\\!"); function charSet(s) { - return s.split("").reduce(function(set2, c2) { - set2[c2] = true; + return s.split("").reduce(function(set2, c) { + set2[c] = true; return set2; }, {}); } @@ -50213,14 +50213,14 @@ var require_minimatch = __commonJS({ stateChar = false; } } - for (var i = 0, len = pattern.length, c2; i < len && (c2 = pattern.charAt(i)); i++) { - this.debug("%s %s %s %j", pattern, i, re, c2); - if (escaping && reSpecials[c2]) { - re += "\\" + c2; + for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) { + this.debug("%s %s %s %j", pattern, i, re, c); + if (escaping && reSpecials[c]) { + re += "\\" + c; escaping = false; continue; } - switch (c2) { + switch (c) { /* istanbul ignore next */ case "/": { return false; @@ -50236,17 +50236,17 @@ var require_minimatch = __commonJS({ case "+": case "@": case "!": - this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c2); + this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c); if (inClass) { this.debug(" in class"); - if (c2 === "!" && i === classStart + 1) c2 = "^"; - re += c2; + if (c === "!" && i === classStart + 1) c = "^"; + re += c; continue; } - if (c2 === "*" && stateChar === "*") continue; + if (c === "*" && stateChar === "*") continue; self2.debug("call clearStateChar %j", stateChar); clearStateChar(); - stateChar = c2; + stateChar = c; if (options.noext) clearStateChar(); continue; case "(": @@ -50296,17 +50296,17 @@ var require_minimatch = __commonJS({ case "[": clearStateChar(); if (inClass) { - re += "\\" + c2; + re += "\\" + c; continue; } inClass = true; classStart = i; reClassStart = re.length; - re += c2; + re += c; continue; case "]": if (i === classStart + 1 || !inClass) { - re += "\\" + c2; + re += "\\" + c; escaping = false; continue; } @@ -50322,16 +50322,16 @@ var require_minimatch = __commonJS({ } hasMagic = true; inClass = false; - re += c2; + re += c; continue; default: clearStateChar(); if (escaping) { escaping = false; - } else if (reSpecials[c2] && !(c2 === "^" && inClass)) { + } else if (reSpecials[c] && !(c === "^" && inClass)) { re += "\\"; } - re += c2; + re += c; } } if (inClass) { @@ -50929,25 +50929,25 @@ var require_internal_pattern = __commonJS({ static getLiteral(segment) { let literal = ""; for (let i = 0; i < segment.length; i++) { - const c2 = segment[i]; - if (c2 === "\\" && !IS_WINDOWS && i + 1 < segment.length) { + const c = segment[i]; + if (c === "\\" && !IS_WINDOWS && i + 1 < segment.length) { literal += segment[++i]; continue; - } else if (c2 === "*" || c2 === "?") { + } else if (c === "*" || c === "?") { return ""; - } else if (c2 === "[" && i + 1 < segment.length) { + } else if (c === "[" && i + 1 < segment.length) { let set2 = ""; let closed = -1; for (let i2 = i + 1; i2 < segment.length; i2++) { - const c22 = segment[i2]; - if (c22 === "\\" && !IS_WINDOWS && i2 + 1 < segment.length) { + const c2 = segment[i2]; + if (c2 === "\\" && !IS_WINDOWS && i2 + 1 < segment.length) { set2 += segment[++i2]; continue; - } else if (c22 === "]") { + } else if (c2 === "]") { closed = i2; break; } else { - set2 += c22; + set2 += c2; } } if (closed >= 0) { @@ -50961,7 +50961,7 @@ var require_internal_pattern = __commonJS({ } } } - literal += c2; + literal += c; } return literal; } @@ -52147,8 +52147,8 @@ var require_semver3 = __commonJS({ this.raw = range.trim().split(/\s+/).join(" "); this.set = this.raw.split("||").map(function(range2) { return this.parseRange(range2.trim()); - }, this).filter(function(c2) { - return c2.length; + }, this).filter(function(c) { + return c.length; }); if (!this.set.length) { throw new TypeError("Invalid SemVer Range: " + this.raw); @@ -52217,8 +52217,8 @@ var require_semver3 = __commonJS({ exports2.toComparators = toComparators; function toComparators(range, options) { return new Range2(range, options).set.map(function(comp) { - return comp.map(function(c2) { - return c2.value; + return comp.map(function(c) { + return c.value; }).join(" ").trim().split(" "); }); } @@ -52979,10 +52979,10 @@ function __rest(s, e) { return t; } function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c2 < 3 ? d(r) : c2 > 3 ? d(target, key, r) : d(target, key)) || r; - return c2 > 3 && r && Object.defineProperty(target, key, r), r; + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function(target, key) { @@ -55730,8 +55730,8 @@ var require_browser = __commonJS({ if (!this.useColors) { return; } - const c2 = "color: " + this.color; - args.splice(1, 0, c2, "color: inherit"); + const c = "color: " + this.color; + args.splice(1, 0, c, "color: inherit"); let index = 0; let lastC = 0; args[0].replace(/%[a-zA-Z%]/g, (match) => { @@ -55743,7 +55743,7 @@ var require_browser = __commonJS({ lastC = index; } }); - args.splice(lastC, 0, c2); + args.splice(lastC, 0, c); } exports2.log = console.debug || console.log || (() => { }); @@ -56027,8 +56027,8 @@ var require_node = __commonJS({ function formatArgs(args) { const { namespace: name, useColors: useColors2 } = this; if (useColors2) { - const c2 = this.color; - const colorCode = "\x1B[3" + (c2 < 8 ? c2 : "8;5;" + c2); + const c = this.color; + const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c); const prefix = ` ${colorCode};1m${name} \x1B[0m`; args[0] = prefix + args[0].split("\n").join("\n" + prefix); args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m"); @@ -62657,44 +62657,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = c2(t2, r2); + r2 = c(t2, r2); continue; } { @@ -62702,7 +62702,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -62710,55 +62710,55 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = c2(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -62767,16 +62767,16 @@ var require_fxp = __commonJS({ } return e2; } - function c2(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -62787,88 +62787,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62876,19 +62876,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62897,146 +62897,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -63053,9 +63105,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -63075,14 +63125,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -63090,97 +63145,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -63203,410 +63254,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c3 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c3 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c3) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c3) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -63615,13 +63845,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -63630,131 +63860,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c3 = i2; - "" !== c3 && (c3 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let c2 = n2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c3, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -63762,173 +63995,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -86456,7 +86695,7 @@ var require_poller3 = __commonJS({ onProgress(callback) { this.pollProgressCallbacks.push(callback); return () => { - this.pollProgressCallbacks = this.pollProgressCallbacks.filter((c2) => c2 !== callback); + this.pollProgressCallbacks = this.pollProgressCallbacks.filter((c) => c !== callback); }; } /** @@ -91557,8 +91796,8 @@ var require_AccountSASPermissions = __commonJS({ */ static parse(permissions) { const accountSASPermissions = new _AccountSASPermissions(); - for (const c2 of permissions) { - switch (c2) { + for (const c of permissions) { + switch (c) { case "r": accountSASPermissions.read = true; break; @@ -91599,7 +91838,7 @@ var require_AccountSASPermissions = __commonJS({ accountSASPermissions.permanentDelete = true; break; default: - throw new RangeError(`Invalid permission character: ${c2}`); + throw new RangeError(`Invalid permission character: ${c}`); } } return accountSASPermissions; @@ -91778,8 +92017,8 @@ var require_AccountSASResourceTypes = __commonJS({ */ static parse(resourceTypes) { const accountSASResourceTypes = new _AccountSASResourceTypes(); - for (const c2 of resourceTypes) { - switch (c2) { + for (const c of resourceTypes) { + switch (c) { case "s": accountSASResourceTypes.service = true; break; @@ -91790,7 +92029,7 @@ var require_AccountSASResourceTypes = __commonJS({ accountSASResourceTypes.object = true; break; default: - throw new RangeError(`Invalid resource type: ${c2}`); + throw new RangeError(`Invalid resource type: ${c}`); } } return accountSASResourceTypes; @@ -91846,8 +92085,8 @@ var require_AccountSASServices = __commonJS({ */ static parse(services) { const accountSASServices = new _AccountSASServices(); - for (const c2 of services) { - switch (c2) { + for (const c of services) { + switch (c) { case "b": accountSASServices.blob = true; break; @@ -91861,7 +92100,7 @@ var require_AccountSASServices = __commonJS({ accountSASServices.table = true; break; default: - throw new RangeError(`Invalid service character: ${c2}`); + throw new RangeError(`Invalid service character: ${c}`); } } return accountSASServices; @@ -95322,9 +95561,9 @@ var require_json_format_contract = __commonJS({ exports2.jsonWriteOptions = jsonWriteOptions; function mergeJsonOptions(a, b) { var _a, _b; - let c2 = Object.assign(Object.assign({}, a), b); - c2.typeRegistry = [...(_a = a === null || a === void 0 ? void 0 : a.typeRegistry) !== null && _a !== void 0 ? _a : [], ...(_b = b === null || b === void 0 ? void 0 : b.typeRegistry) !== null && _b !== void 0 ? _b : []]; - return c2; + let c = Object.assign(Object.assign({}, a), b); + c.typeRegistry = [...(_a = a === null || a === void 0 ? void 0 : a.typeRegistry) !== null && _a !== void 0 ? _a : [], ...(_b = b === null || b === void 0 ? void 0 : b.typeRegistry) !== null && _b !== void 0 ? _b : []]; + return c; } exports2.mergeJsonOptions = mergeJsonOptions; } @@ -97461,14 +97700,14 @@ var require_rpc_options = __commonJS({ function copy(a, into) { if (!a) return; - let c2 = into; + let c = into; for (let [k, v] of Object.entries(a)) { if (v instanceof Date) - c2[k] = new Date(v.getTime()); + c[k] = new Date(v.getTime()); else if (Array.isArray(v)) - c2[k] = v.concat(); + c[k] = v.concat(); else - c2[k] = v; + c[k] = v; } } } @@ -100501,9 +100740,9 @@ var require_util19 = __commonJS({ return this.data.charCodeAt(this.data.length - 1); }; util.ByteStringBuffer.prototype.copy = function() { - var c2 = util.createBuffer(this.data); - c2.read = this.read; - return c2; + var c = util.createBuffer(this.data); + c.read = this.read; + return c; }; util.ByteStringBuffer.prototype.compact = function() { if (this.read > 0) { @@ -100862,15 +101101,15 @@ var require_util19 = __commonJS({ } return new util.ByteBuffer(input); }; - util.fillString = function(c2, n) { + util.fillString = function(c, n) { var s = ""; while (n > 0) { if (n & 1) { - s += c2; + s += c; } n >>>= 1; if (n > 0) { - c2 += c2; + c += c; } } return s; @@ -100880,16 +101119,16 @@ var require_util19 = __commonJS({ var b = ""; var t = ""; var i = 0; - var c2 = 0; + var c = 0; for (; n > 0; --n, ++i) { b = s1.charCodeAt(i) ^ s2.charCodeAt(i); - if (c2 >= 10) { + if (c >= 10) { s3 += t; t = ""; - c2 = 0; + c = 0; } t += String.fromCharCode(b); - ++c2; + ++c; } s3 += t; return s3; @@ -101376,12 +101615,12 @@ var require_util19 = __commonJS({ return parts.join(""); }; util.formatNumber = function(number, decimals, dec_point, thousands_sep) { - var n = number, c2 = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; + var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; var d = dec_point === void 0 ? "," : dec_point; var t = thousands_sep === void 0 ? "." : thousands_sep, s = n < 0 ? "-" : ""; - var i = parseInt(n = Math.abs(+n || 0).toFixed(c2), 10) + ""; + var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + ""; var j = i.length > 3 ? i.length % 3 : 0; - return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c2 ? d + Math.abs(n - i).toFixed(c2).slice(2) : ""); + return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }; util.formatSize = function(size) { if (size >= 1073741824) { @@ -102318,8 +102557,8 @@ var require_cipherModes = __commonJS({ } m[0] = [0, 0, 0, 0]; for (i = half + 1; i < size; ++i) { - var c2 = m[i ^ half]; - m[i] = [mid[0] ^ c2[0], mid[1] ^ c2[1], mid[2] ^ c2[2], mid[3] ^ c2[3]]; + var c = m[i ^ half]; + m[i] = [mid[0] ^ c[0], mid[1] ^ c[1], mid[2] ^ c[2], mid[3] ^ c[3]]; } return m; }; @@ -102586,25 +102825,25 @@ var require_aes = __commonJS({ m3 = mix[3]; sub = sbox; } - var a, b, c2, d, a2, b2, c22; + var a, b, c, d, a2, b2, c2; a = input[0] ^ w[0]; b = input[decrypt ? 3 : 1] ^ w[1]; - c2 = input[2] ^ w[2]; + c = input[2] ^ w[2]; d = input[decrypt ? 1 : 3] ^ w[3]; var i = 3; for (var round = 1; round < Nr; ++round) { - a2 = m0[a >>> 24] ^ m1[b >>> 16 & 255] ^ m2[c2 >>> 8 & 255] ^ m3[d & 255] ^ w[++i]; - b2 = m0[b >>> 24] ^ m1[c2 >>> 16 & 255] ^ m2[d >>> 8 & 255] ^ m3[a & 255] ^ w[++i]; - c22 = m0[c2 >>> 24] ^ m1[d >>> 16 & 255] ^ m2[a >>> 8 & 255] ^ m3[b & 255] ^ w[++i]; - d = m0[d >>> 24] ^ m1[a >>> 16 & 255] ^ m2[b >>> 8 & 255] ^ m3[c2 & 255] ^ w[++i]; + a2 = m0[a >>> 24] ^ m1[b >>> 16 & 255] ^ m2[c >>> 8 & 255] ^ m3[d & 255] ^ w[++i]; + b2 = m0[b >>> 24] ^ m1[c >>> 16 & 255] ^ m2[d >>> 8 & 255] ^ m3[a & 255] ^ w[++i]; + c2 = m0[c >>> 24] ^ m1[d >>> 16 & 255] ^ m2[a >>> 8 & 255] ^ m3[b & 255] ^ w[++i]; + d = m0[d >>> 24] ^ m1[a >>> 16 & 255] ^ m2[b >>> 8 & 255] ^ m3[c & 255] ^ w[++i]; a = a2; b = b2; - c2 = c22; + c = c2; } - output[0] = sub[a >>> 24] << 24 ^ sub[b >>> 16 & 255] << 16 ^ sub[c2 >>> 8 & 255] << 8 ^ sub[d & 255] ^ w[++i]; - output[decrypt ? 3 : 1] = sub[b >>> 24] << 24 ^ sub[c2 >>> 16 & 255] << 16 ^ sub[d >>> 8 & 255] << 8 ^ sub[a & 255] ^ w[++i]; - output[2] = sub[c2 >>> 24] << 24 ^ sub[d >>> 16 & 255] << 16 ^ sub[a >>> 8 & 255] << 8 ^ sub[b & 255] ^ w[++i]; - output[decrypt ? 1 : 3] = sub[d >>> 24] << 24 ^ sub[a >>> 16 & 255] << 16 ^ sub[b >>> 8 & 255] << 8 ^ sub[c2 & 255] ^ w[++i]; + output[0] = sub[a >>> 24] << 24 ^ sub[b >>> 16 & 255] << 16 ^ sub[c >>> 8 & 255] << 8 ^ sub[d & 255] ^ w[++i]; + output[decrypt ? 3 : 1] = sub[b >>> 24] << 24 ^ sub[c >>> 16 & 255] << 16 ^ sub[d >>> 8 & 255] << 8 ^ sub[a & 255] ^ w[++i]; + output[2] = sub[c >>> 24] << 24 ^ sub[d >>> 16 & 255] << 16 ^ sub[a >>> 8 & 255] << 8 ^ sub[b & 255] ^ w[++i]; + output[decrypt ? 1 : 3] = sub[d >>> 24] << 24 ^ sub[a >>> 16 & 255] << 16 ^ sub[b >>> 8 & 255] << 8 ^ sub[c & 255] ^ w[++i]; } function _createCipher(options) { options = options || {}; @@ -103202,9 +103441,9 @@ var require_asn1 = __commonJS({ var mm = parseInt(utc.substr(8, 2), 10); var ss = 0; if (utc.length > 11) { - var c2 = utc.charAt(10); + var c = utc.charAt(10); var end = 10; - if (c2 !== "+" && c2 !== "-") { + if (c !== "+" && c !== "-") { ss = parseInt(utc.substr(10, 2), 10); end += 2; } @@ -103212,13 +103451,13 @@ var require_asn1 = __commonJS({ date.setUTCFullYear(year, MM, DD); date.setUTCHours(hh, mm, ss, 0); if (end) { - c2 = utc.charAt(end); - if (c2 === "+" || c2 === "-") { + c = utc.charAt(end); + if (c === "+" || c === "-") { var hhoffset = parseInt(utc.substr(end + 1, 2), 10); var mmoffset = parseInt(utc.substr(end + 4, 2), 10); var offset = hhoffset * 60 + mmoffset; offset *= 6e4; - if (c2 === "+") { + if (c === "+") { date.setTime(+date - offset); } else { date.setTime(+date + offset); @@ -103241,13 +103480,13 @@ var require_asn1 = __commonJS({ if (gentime.charAt(gentime.length - 1) === "Z") { isUTC = true; } - var end = gentime.length - 5, c2 = gentime.charAt(end); - if (c2 === "+" || c2 === "-") { + var end = gentime.length - 5, c = gentime.charAt(end); + if (c === "+" || c === "-") { var hhoffset = parseInt(gentime.substr(end + 1, 2), 10); var mmoffset = parseInt(gentime.substr(end + 4, 2), 10); offset = hhoffset * 60 + mmoffset; offset *= 6e4; - if (c2 === "+") { + if (c === "+") { offset *= -1; } isUTC = true; @@ -103926,53 +104165,53 @@ var require_md5 = __commonJS({ _initialized = true; } function _update(s, w, bytes) { - var t, a, b, c2, d, f, r, i; + var t, a, b, c, d, f, r, i; var len = bytes.length(); while (len >= 64) { a = s.h0; b = s.h1; - c2 = s.h2; + c = s.h2; d = s.h3; for (i = 0; i < 16; ++i) { w[i] = bytes.getInt32Le(); - f = d ^ b & (c2 ^ d); + f = d ^ b & (c ^ d); t = a + f + _k[i] + w[i]; r = _r[i]; a = d; - d = c2; - c2 = b; + d = c; + c = b; b += t << r | t >>> 32 - r; } for (; i < 32; ++i) { - f = c2 ^ d & (b ^ c2); + f = c ^ d & (b ^ c); t = a + f + _k[i] + w[_g[i]]; r = _r[i]; a = d; - d = c2; - c2 = b; + d = c; + c = b; b += t << r | t >>> 32 - r; } for (; i < 48; ++i) { - f = b ^ c2 ^ d; + f = b ^ c ^ d; t = a + f + _k[i] + w[_g[i]]; r = _r[i]; a = d; - d = c2; - c2 = b; + d = c; + c = b; b += t << r | t >>> 32 - r; } for (; i < 64; ++i) { - f = c2 ^ (b | ~d); + f = c ^ (b | ~d); t = a + f + _k[i] + w[_g[i]]; r = _r[i]; a = d; - d = c2; - c2 = b; + d = c; + c = b; b += t << r | t >>> 32 - r; } s.h0 = s.h0 + a | 0; s.h1 = s.h1 + b | 0; - s.h2 = s.h2 + c2 | 0; + s.h2 = s.h2 + c | 0; s.h3 = s.h3 + d | 0; len -= 64; } @@ -104381,7 +104620,7 @@ var require_pbkdf2 = __commonJS({ if (forge.util.isNodejs && !forge.options.usePureJavaScript) { crypto2 = require("crypto"); } - module2.exports = forge.pbkdf2 = pkcs5.pbkdf2 = function(p, s, c2, dkLen, md2, callback) { + module2.exports = forge.pbkdf2 = pkcs5.pbkdf2 = function(p, s, c, dkLen, md2, callback) { if (typeof md2 === "function") { callback = md2; md2 = null; @@ -104394,19 +104633,19 @@ var require_pbkdf2 = __commonJS({ s = Buffer.from(s, "binary"); if (!callback) { if (crypto2.pbkdf2Sync.length === 4) { - return crypto2.pbkdf2Sync(p, s, c2, dkLen).toString("binary"); + return crypto2.pbkdf2Sync(p, s, c, dkLen).toString("binary"); } - return crypto2.pbkdf2Sync(p, s, c2, dkLen, md2).toString("binary"); + return crypto2.pbkdf2Sync(p, s, c, dkLen, md2).toString("binary"); } if (crypto2.pbkdf2Sync.length === 4) { - return crypto2.pbkdf2(p, s, c2, dkLen, function(err2, key) { + return crypto2.pbkdf2(p, s, c, dkLen, function(err2, key) { if (err2) { return callback(err2); } callback(null, key.toString("binary")); }); } - return crypto2.pbkdf2(p, s, c2, dkLen, md2, function(err2, key) { + return crypto2.pbkdf2(p, s, c, dkLen, md2, function(err2, key) { if (err2) { return callback(err2); } @@ -104442,7 +104681,7 @@ var require_pbkdf2 = __commonJS({ prf.update(s); prf.update(forge.util.int32ToBytes(i)); xor = u_c1 = prf.digest().getBytes(); - for (var j = 2; j <= c2; ++j) { + for (var j = 2; j <= c; ++j) { prf.start(null, null); prf.update(u_c1); u_c = prf.digest().getBytes(); @@ -104466,7 +104705,7 @@ var require_pbkdf2 = __commonJS({ inner(); } function inner() { - if (j <= c2) { + if (j <= c) { prf.start(null, null); prf.update(u_c1); u_c = prf.digest().getBytes(); @@ -104666,7 +104905,7 @@ var require_sha2562 = __commonJS({ _initialized = true; } function _update(s, w, bytes) { - var t1, t2, s0, s1, ch, maj, i, a, b, c2, d, e, f, g, h; + var t1, t2, s0, s1, ch, maj, i, a, b, c, d, e, f, g, h; var len = bytes.length(); while (len >= 64) { for (i = 0; i < 16; ++i) { @@ -104681,7 +104920,7 @@ var require_sha2562 = __commonJS({ } a = s.h0; b = s.h1; - c2 = s.h2; + c = s.h2; d = s.h3; e = s.h4; f = s.h5; @@ -104691,21 +104930,21 @@ var require_sha2562 = __commonJS({ s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7); ch = g ^ e & (f ^ g); s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10); - maj = a & b | c2 & (a ^ b); + maj = a & b | c & (a ^ b); t1 = h + s1 + ch + _k[i] + w[i]; t2 = s0 + maj; h = g; g = f; f = e; e = d + t1 >>> 0; - d = c2; - c2 = b; + d = c; + c = b; b = a; a = t1 + t2 >>> 0; } s.h0 = s.h0 + a | 0; s.h1 = s.h1 + b | 0; - s.h2 = s.h2 + c2 | 0; + s.h2 = s.h2 + c | 0; s.h3 = s.h3 + d | 0; s.h4 = s.h4 + e | 0; s.h5 = s.h5 + f | 0; @@ -105534,10 +105773,10 @@ var require_jsbn = __commonJS({ var dbits; var canary = 244837814094590; var j_lm = (canary & 16777215) == 15715070; - function BigInteger(a, b, c2) { + function BigInteger(a, b, c) { this.data = []; if (a != null) - if ("number" == typeof a) this.fromNumber(a, b, c2); + if ("number" == typeof a) this.fromNumber(a, b, c); else if (b == null && "string" != typeof a) this.fromString(a, 256); else this.fromString(a, b); } @@ -105545,37 +105784,37 @@ var require_jsbn = __commonJS({ function nbi() { return new BigInteger(null); } - function am1(i, x, w, j, c2, n) { + function am1(i, x, w, j, c, n) { while (--n >= 0) { - var v = x * this.data[i++] + w.data[j] + c2; - c2 = Math.floor(v / 67108864); + var v = x * this.data[i++] + w.data[j] + c; + c = Math.floor(v / 67108864); w.data[j++] = v & 67108863; } - return c2; + return c; } - function am2(i, x, w, j, c2, n) { + function am2(i, x, w, j, c, n) { var xl = x & 32767, xh = x >> 15; while (--n >= 0) { var l = this.data[i] & 32767; var h = this.data[i++] >> 15; var m = xh * l + h * xl; - l = xl * l + ((m & 32767) << 15) + w.data[j] + (c2 & 1073741823); - c2 = (l >>> 30) + (m >>> 15) + xh * h + (c2 >>> 30); + l = xl * l + ((m & 32767) << 15) + w.data[j] + (c & 1073741823); + c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30); w.data[j++] = l & 1073741823; } - return c2; + return c; } - function am3(i, x, w, j, c2, n) { + function am3(i, x, w, j, c, n) { var xl = x & 16383, xh = x >> 14; while (--n >= 0) { var l = this.data[i] & 16383; var h = this.data[i++] >> 14; var m = xh * l + h * xl; - l = xl * l + ((m & 16383) << 14) + w.data[j] + c2; - c2 = (l >> 28) + (m >> 14) + xh * h; + l = xl * l + ((m & 16383) << 14) + w.data[j] + c; + c = (l >> 28) + (m >> 14) + xh * h; w.data[j++] = l & 268435455; } - return c2; + return c; } if (typeof navigator === "undefined") { BigInteger.prototype.am = am3; @@ -105611,8 +105850,8 @@ var require_jsbn = __commonJS({ return BI_RM.charAt(n); } function intAt(s, i) { - var c2 = BI_RC[s.charCodeAt(i)]; - return c2 == null ? -1 : c2; + var c = BI_RC[s.charCodeAt(i)]; + return c == null ? -1 : c; } function bnpCopyTo(r) { for (var i = this.t - 1; i >= 0; --i) r.data[i] = this.data[i]; @@ -105671,8 +105910,8 @@ var require_jsbn = __commonJS({ if (mi) BigInteger.ZERO.subTo(this, this); } function bnpClamp() { - var c2 = this.s & this.DM; - while (this.t > 0 && this.data[this.t - 1] == c2) --this.t; + var c = this.s & this.DM; + while (this.t > 0 && this.data[this.t - 1] == c) --this.t; } function bnToString(b) { if (this.s < 0) return "-" + this.negate().toString(b); @@ -105768,13 +106007,13 @@ var require_jsbn = __commonJS({ var bs = n % this.DB; var cbs = this.DB - bs; var bm = (1 << cbs) - 1; - var ds = Math.floor(n / this.DB), c2 = this.s << bs & this.DM, i; + var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i; for (i = this.t - 1; i >= 0; --i) { - r.data[i + ds + 1] = this.data[i] >> cbs | c2; - c2 = (this.data[i] & bm) << bs; + r.data[i + ds + 1] = this.data[i] >> cbs | c; + c = (this.data[i] & bm) << bs; } for (i = ds - 1; i >= 0; --i) r.data[i] = 0; - r.data[ds] = c2; + r.data[ds] = c; r.t = this.t + ds + 1; r.s = this.s; r.clamp(); @@ -105799,32 +106038,32 @@ var require_jsbn = __commonJS({ r.clamp(); } function bnpSubTo(a, r) { - var i = 0, c2 = 0, m = Math.min(a.t, this.t); + var i = 0, c = 0, m = Math.min(a.t, this.t); while (i < m) { - c2 += this.data[i] - a.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c += this.data[i] - a.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } if (a.t < this.t) { - c2 -= a.s; + c -= a.s; while (i < this.t) { - c2 += this.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c += this.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } - c2 += this.s; + c += this.s; } else { - c2 += this.s; + c += this.s; while (i < a.t) { - c2 -= a.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c -= a.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } - c2 -= a.s; + c -= a.s; } - r.s = c2 < 0 ? -1 : 0; - if (c2 < -1) r.data[i++] = this.DV + c2; - else if (c2 > 0) r.data[i++] = c2; + r.s = c < 0 ? -1 : 0; + if (c < -1) r.data[i++] = this.DV + c; + else if (c > 0) r.data[i++] = c; r.t = i; r.clamp(); } @@ -105843,8 +106082,8 @@ var require_jsbn = __commonJS({ var i = r.t = 2 * x.t; while (--i >= 0) r.data[i] = 0; for (i = 0; i < x.t - 1; ++i) { - var c2 = x.am(i, x.data[i], r, 2 * i, 0, 1); - if ((r.data[i + x.t] += x.am(i + 1, 2 * x.data[i], r, 2 * i + 1, c2, x.t - i - 1)) >= x.DV) { + var c = x.am(i, x.data[i], r, 2 * i, 0, 1); + if ((r.data[i + x.t] += x.am(i + 1, 2 * x.data[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) { r.data[i + x.t] -= x.DV; r.data[i + x.t + 1] = 1; } @@ -106110,11 +106349,11 @@ var require_jsbn = __commonJS({ } if (mi) BigInteger.ZERO.subTo(this, this); } - function bnpFromNumber(a, b, c2) { + function bnpFromNumber(a, b, c) { if ("number" == typeof b) { if (a < 2) this.fromInt(1); else { - this.fromNumber(a, c2); + this.fromNumber(a, c); if (!this.testBit(a - 1)) this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this); if (this.isEven()) this.dAddOffset(1, 0); @@ -106293,32 +106532,32 @@ var require_jsbn = __commonJS({ return this.changeBit(n, op_xor); } function bnpAddTo(a, r) { - var i = 0, c2 = 0, m = Math.min(a.t, this.t); + var i = 0, c = 0, m = Math.min(a.t, this.t); while (i < m) { - c2 += this.data[i] + a.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c += this.data[i] + a.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } if (a.t < this.t) { - c2 += a.s; + c += a.s; while (i < this.t) { - c2 += this.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c += this.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } - c2 += this.s; + c += this.s; } else { - c2 += this.s; + c += this.s; while (i < a.t) { - c2 += a.data[i]; - r.data[i++] = c2 & this.DM; - c2 >>= this.DB; + c += a.data[i]; + r.data[i++] = c & this.DM; + c >>= this.DB; } - c2 += a.s; + c += a.s; } - r.s = c2 < 0 ? -1 : 0; - if (c2 > 0) r.data[i++] = c2; - else if (c2 < -1) r.data[i++] = this.DV + c2; + r.s = c < 0 ? -1 : 0; + if (c > 0) r.data[i++] = c; + else if (c < -1) r.data[i++] = this.DV + c; r.t = i; r.clamp(); } @@ -106571,7 +106810,7 @@ var require_jsbn = __commonJS({ var ac = m.isEven(); if (this.isEven() && ac || m.signum() == 0) return BigInteger.ZERO; var u = m.clone(), v = this.clone(); - var a = nbv(1), b = nbv(0), c2 = nbv(0), d = nbv(1); + var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); while (u.signum() != 0) { while (u.isEven()) { u.rShiftTo(1, u); @@ -106587,21 +106826,21 @@ var require_jsbn = __commonJS({ while (v.isEven()) { v.rShiftTo(1, v); if (ac) { - if (!c2.isEven() || !d.isEven()) { - c2.addTo(this, c2); + if (!c.isEven() || !d.isEven()) { + c.addTo(this, c); d.subTo(m, d); } - c2.rShiftTo(1, c2); + c.rShiftTo(1, c); } else if (!d.isEven()) d.subTo(m, d); d.rShiftTo(1, d); } if (u.compareTo(v) >= 0) { u.subTo(v, u); - if (ac) a.subTo(c2, a); + if (ac) a.subTo(c, a); b.subTo(d, b); } else { v.subTo(u, v); - if (ac) c2.subTo(a, c2); + if (ac) c.subTo(a, c); d.subTo(b, d); } } @@ -106820,22 +107059,22 @@ var require_sha1 = __commonJS({ _initialized = true; } function _update(s, w, bytes) { - var t, a, b, c2, d, e, f, i; + var t, a, b, c, d, e, f, i; var len = bytes.length(); while (len >= 64) { a = s.h0; b = s.h1; - c2 = s.h2; + c = s.h2; d = s.h3; e = s.h4; for (i = 0; i < 16; ++i) { t = bytes.getInt32(); w[i] = t; - f = d ^ b & (c2 ^ d); + f = d ^ b & (c ^ d); t = (a << 5 | a >>> 27) + f + e + 1518500249 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } @@ -106843,11 +107082,11 @@ var require_sha1 = __commonJS({ t = w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]; t = t << 1 | t >>> 31; w[i] = t; - f = d ^ b & (c2 ^ d); + f = d ^ b & (c ^ d); t = (a << 5 | a >>> 27) + f + e + 1518500249 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } @@ -106855,11 +107094,11 @@ var require_sha1 = __commonJS({ t = w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]; t = t << 1 | t >>> 31; w[i] = t; - f = b ^ c2 ^ d; + f = b ^ c ^ d; t = (a << 5 | a >>> 27) + f + e + 1859775393 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } @@ -106867,11 +107106,11 @@ var require_sha1 = __commonJS({ t = w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]; t = t << 2 | t >>> 30; w[i] = t; - f = b ^ c2 ^ d; + f = b ^ c ^ d; t = (a << 5 | a >>> 27) + f + e + 1859775393 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } @@ -106879,11 +107118,11 @@ var require_sha1 = __commonJS({ t = w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]; t = t << 2 | t >>> 30; w[i] = t; - f = b & c2 | d & (b ^ c2); + f = b & c | d & (b ^ c); t = (a << 5 | a >>> 27) + f + e + 2400959708 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } @@ -106891,17 +107130,17 @@ var require_sha1 = __commonJS({ t = w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]; t = t << 2 | t >>> 30; w[i] = t; - f = b ^ c2 ^ d; + f = b ^ c ^ d; t = (a << 5 | a >>> 27) + f + e + 3395469782 + t; e = d; - d = c2; - c2 = (b << 30 | b >>> 2) >>> 0; + d = c; + c = (b << 30 | b >>> 2) >>> 0; b = a; a = t; } s.h0 = s.h0 + a | 0; s.h1 = s.h1 + b | 0; - s.h2 = s.h2 + c2 | 0; + s.h2 = s.h2 + c | 0; s.h3 = s.h3 + d | 0; s.h4 = s.h4 + e | 0; len -= 64; @@ -107047,14 +107286,14 @@ var require_pkcs1 = __commonJS({ var t = ""; var count = Math.ceil(maskLength / hash.digestLength); for (var i = 0; i < count; ++i) { - var c2 = String.fromCharCode( + var c = String.fromCharCode( i >> 24 & 255, i >> 16 & 255, i >> 8 & 255, i & 255 ); hash.start(); - hash.update(seed + c2); + hash.update(seed + c); t += hash.digest().getBytes(); } return t.substring(0, maskLength); @@ -108939,8 +109178,8 @@ var require_pbe = __commonJS({ } var I = S; I.putBuffer(P); - var c2 = Math.ceil(n / u); - for (var i = 1; i <= c2; i++) { + var c = Math.ceil(n / u); + for (var i = 1; i <= c; i++) { var buf = new forge.util.ByteBuffer(); buf.putBytes(D.bytes()); buf.putBytes(I.bytes()); @@ -109523,10 +109762,10 @@ var require_mgf1 = __commonJS({ var t = new forge.util.ByteBuffer(); var len = Math.ceil(maskLen / md2.digestLength); for (var i = 0; i < len; i++) { - var c2 = new forge.util.ByteBuffer(); - c2.putInt32(i); + var c = new forge.util.ByteBuffer(); + c.putInt32(i); md2.start(); - md2.update(seed + c2.getBytes()); + md2.update(seed + c.getBytes()); t.putBuffer(md2.digest()); } t.truncate(t.length() - maskLen); @@ -112780,10 +113019,10 @@ var require_tls = __commonJS({ hmac.update(b.getBytes()); return hmac.digest().getBytes(); }; - var deflate = function(c2, record, s) { + var deflate = function(c, record, s) { var rval = false; try { - var bytes = c2.deflate(record.fragment.getBytes()); + var bytes = c.deflate(record.fragment.getBytes()); record.fragment = forge.util.createBuffer(bytes); record.length = bytes.length; rval = true; @@ -112791,10 +113030,10 @@ var require_tls = __commonJS({ } return rval; }; - var inflate = function(c2, record, s) { + var inflate = function(c, record, s) { var rval = false; try { - var bytes = c2.inflate(record.fragment.getBytes()); + var bytes = c.inflate(record.fragment.getBytes()); record.fragment = forge.util.createBuffer(bytes); record.length = bytes.length; rval = true; @@ -112931,10 +113170,10 @@ var require_tls = __commonJS({ } return rval; }; - tls.handleUnexpected = function(c2, record) { - var ignore = !c2.open && c2.entity === tls.ConnectionEnd.client; + tls.handleUnexpected = function(c, record) { + var ignore = !c.open && c.entity === tls.ConnectionEnd.client; if (!ignore) { - c2.error(c2, { + c.error(c, { message: "Unexpected message. Received TLS record out of order.", send: true, alert: { @@ -112944,21 +113183,21 @@ var require_tls = __commonJS({ }); } }; - tls.handleHelloRequest = function(c2, record, length) { - if (!c2.handshaking && c2.handshakes > 0) { - tls.queue(c2, tls.createAlert(c2, { + tls.handleHelloRequest = function(c, record, length) { + if (!c.handshaking && c.handshakes > 0) { + tls.queue(c, tls.createAlert(c, { level: tls.Alert.Level.warning, description: tls.Alert.Description.no_renegotiation })); - tls.flush(c2); + tls.flush(c); } - c2.process(); + c.process(); }; - tls.parseHelloMessage = function(c2, record, length) { + tls.parseHelloMessage = function(c, record, length) { var msg = null; - var client = c2.entity === tls.ConnectionEnd.client; + var client = c.entity === tls.ConnectionEnd.client; if (length < 38) { - c2.error(c2, { + c.error(c, { message: client ? "Invalid ServerHello message. Message too short." : "Invalid ClientHello message. Message too short.", send: true, alert: { @@ -113004,7 +113243,7 @@ var require_tls = __commonJS({ if (snType !== 0) { break; } - c2.session.extensions.server_name.serverNameList.push( + c.session.extensions.server_name.serverNameList.push( readVector(snl, 2).getBytes() ); } @@ -113012,9 +113251,9 @@ var require_tls = __commonJS({ } } } - if (c2.session.version) { - if (msg.version.major !== c2.session.version.major || msg.version.minor !== c2.session.version.minor) { - return c2.error(c2, { + if (c.session.version) { + if (msg.version.major !== c.session.version.major || msg.version.minor !== c.session.version.minor) { + return c.error(c, { message: "TLS version change is disallowed during renegotiation.", send: true, alert: { @@ -113025,18 +113264,18 @@ var require_tls = __commonJS({ } } if (client) { - c2.session.cipherSuite = tls.getCipherSuite(msg.cipher_suite); + c.session.cipherSuite = tls.getCipherSuite(msg.cipher_suite); } else { var tmp = forge.util.createBuffer(msg.cipher_suites.bytes()); while (tmp.length() > 0) { - c2.session.cipherSuite = tls.getCipherSuite(tmp.getBytes(2)); - if (c2.session.cipherSuite !== null) { + c.session.cipherSuite = tls.getCipherSuite(tmp.getBytes(2)); + if (c.session.cipherSuite !== null) { break; } } } - if (c2.session.cipherSuite === null) { - return c2.error(c2, { + if (c.session.cipherSuite === null) { + return c.error(c, { message: "No cipher suites in common.", send: true, alert: { @@ -113047,20 +113286,20 @@ var require_tls = __commonJS({ }); } if (client) { - c2.session.compressionMethod = msg.compression_method; + c.session.compressionMethod = msg.compression_method; } else { - c2.session.compressionMethod = tls.CompressionMethod.none; + c.session.compressionMethod = tls.CompressionMethod.none; } } return msg; }; - tls.createSecurityParameters = function(c2, msg) { - var client = c2.entity === tls.ConnectionEnd.client; + tls.createSecurityParameters = function(c, msg) { + var client = c.entity === tls.ConnectionEnd.client; var msgRandom = msg.random.bytes(); - var cRandom = client ? c2.session.sp.client_random : msgRandom; + var cRandom = client ? c.session.sp.client_random : msgRandom; var sRandom = client ? msgRandom : tls.createRandom().getBytes(); - c2.session.sp = { - entity: c2.entity, + c.session.sp = { + entity: c.entity, prf_algorithm: tls.PRFAlgorithm.tls_prf_sha256, bulk_cipher_algorithm: null, cipher_type: null, @@ -113071,22 +113310,22 @@ var require_tls = __commonJS({ mac_algorithm: null, mac_length: null, mac_key_length: null, - compression_algorithm: c2.session.compressionMethod, + compression_algorithm: c.session.compressionMethod, pre_master_secret: null, master_secret: null, client_random: cRandom, server_random: sRandom }; }; - tls.handleServerHello = function(c2, record, length) { - var msg = tls.parseHelloMessage(c2, record, length); - if (c2.fail) { + tls.handleServerHello = function(c, record, length) { + var msg = tls.parseHelloMessage(c, record, length); + if (c.fail) { return; } - if (msg.version.minor <= c2.version.minor) { - c2.version.minor = msg.version.minor; + if (msg.version.minor <= c.version.minor) { + c.version.minor = msg.version.minor; } else { - return c2.error(c2, { + return c.error(c, { message: "Incompatible TLS version.", send: true, alert: { @@ -113095,29 +113334,29 @@ var require_tls = __commonJS({ } }); } - c2.session.version = c2.version; + c.session.version = c.version; var sessionId = msg.session_id.bytes(); - if (sessionId.length > 0 && sessionId === c2.session.id) { - c2.expect = SCC; - c2.session.resuming = true; - c2.session.sp.server_random = msg.random.bytes(); + if (sessionId.length > 0 && sessionId === c.session.id) { + c.expect = SCC; + c.session.resuming = true; + c.session.sp.server_random = msg.random.bytes(); } else { - c2.expect = SCE; - c2.session.resuming = false; - tls.createSecurityParameters(c2, msg); + c.expect = SCE; + c.session.resuming = false; + tls.createSecurityParameters(c, msg); } - c2.session.id = sessionId; - c2.process(); + c.session.id = sessionId; + c.process(); }; - tls.handleClientHello = function(c2, record, length) { - var msg = tls.parseHelloMessage(c2, record, length); - if (c2.fail) { + tls.handleClientHello = function(c, record, length) { + var msg = tls.parseHelloMessage(c, record, length); + if (c.fail) { return; } var sessionId = msg.session_id.bytes(); var session = null; - if (c2.sessionCache) { - session = c2.sessionCache.getSession(sessionId); + if (c.sessionCache) { + session = c.sessionCache.getSession(sessionId); if (session === null) { sessionId = ""; } else if (session.version.major !== msg.version.major || session.version.minor > msg.version.minor) { @@ -113128,12 +113367,12 @@ var require_tls = __commonJS({ if (sessionId.length === 0) { sessionId = forge.random.getBytes(32); } - c2.session.id = sessionId; - c2.session.clientHelloVersion = msg.version; - c2.session.sp = {}; + c.session.id = sessionId; + c.session.clientHelloVersion = msg.version; + c.session.sp = {}; if (session) { - c2.version = c2.session.version = session.version; - c2.session.sp = session.sp; + c.version = c.session.version = session.version; + c.session.sp = session.sp; } else { var version; for (var i = 1; i < tls.SupportedVersions.length; ++i) { @@ -113142,62 +113381,62 @@ var require_tls = __commonJS({ break; } } - c2.version = { major: version.major, minor: version.minor }; - c2.session.version = c2.version; + c.version = { major: version.major, minor: version.minor }; + c.session.version = c.version; } if (session !== null) { - c2.expect = CCC; - c2.session.resuming = true; - c2.session.sp.client_random = msg.random.bytes(); + c.expect = CCC; + c.session.resuming = true; + c.session.sp.client_random = msg.random.bytes(); } else { - c2.expect = c2.verifyClient !== false ? CCE : CKE; - c2.session.resuming = false; - tls.createSecurityParameters(c2, msg); + c.expect = c.verifyClient !== false ? CCE : CKE; + c.session.resuming = false; + tls.createSecurityParameters(c, msg); } - c2.open = true; - tls.queue(c2, tls.createRecord(c2, { + c.open = true; + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createServerHello(c2) + data: tls.createServerHello(c) })); - if (c2.session.resuming) { - tls.queue(c2, tls.createRecord(c2, { + if (c.session.resuming) { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.change_cipher_spec, data: tls.createChangeCipherSpec() })); - c2.state.pending = tls.createConnectionState(c2); - c2.state.current.write = c2.state.pending.write; - tls.queue(c2, tls.createRecord(c2, { + c.state.pending = tls.createConnectionState(c); + c.state.current.write = c.state.pending.write; + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createFinished(c2) + data: tls.createFinished(c) })); } else { - tls.queue(c2, tls.createRecord(c2, { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createCertificate(c2) + data: tls.createCertificate(c) })); - if (!c2.fail) { - tls.queue(c2, tls.createRecord(c2, { + if (!c.fail) { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createServerKeyExchange(c2) + data: tls.createServerKeyExchange(c) })); - if (c2.verifyClient !== false) { - tls.queue(c2, tls.createRecord(c2, { + if (c.verifyClient !== false) { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createCertificateRequest(c2) + data: tls.createCertificateRequest(c) })); } - tls.queue(c2, tls.createRecord(c2, { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createServerHelloDone(c2) + data: tls.createServerHelloDone(c) })); } } - tls.flush(c2); - c2.process(); + tls.flush(c); + c.process(); }; - tls.handleCertificate = function(c2, record, length) { + tls.handleCertificate = function(c, record, length) { if (length < 3) { - return c2.error(c2, { + return c.error(c, { message: "Invalid Certificate message. Message too short.", send: true, alert: { @@ -113220,7 +113459,7 @@ var require_tls = __commonJS({ certs.push(cert); } } catch (ex) { - return c2.error(c2, { + return c.error(c, { message: "Could not parse certificate list.", cause: ex, send: true, @@ -113230,9 +113469,9 @@ var require_tls = __commonJS({ } }); } - var client = c2.entity === tls.ConnectionEnd.client; - if ((client || c2.verifyClient === true) && certs.length === 0) { - c2.error(c2, { + var client = c.entity === tls.ConnectionEnd.client; + if ((client || c.verifyClient === true) && certs.length === 0) { + c.error(c, { message: client ? "No server certificate provided." : "No client certificate provided.", send: true, alert: { @@ -113241,22 +113480,22 @@ var require_tls = __commonJS({ } }); } else if (certs.length === 0) { - c2.expect = client ? SKE : CKE; + c.expect = client ? SKE : CKE; } else { if (client) { - c2.session.serverCertificate = certs[0]; + c.session.serverCertificate = certs[0]; } else { - c2.session.clientCertificate = certs[0]; + c.session.clientCertificate = certs[0]; } - if (tls.verifyCertificateChain(c2, certs)) { - c2.expect = client ? SKE : CKE; + if (tls.verifyCertificateChain(c, certs)) { + c.expect = client ? SKE : CKE; } } - c2.process(); + c.process(); }; - tls.handleServerKeyExchange = function(c2, record, length) { + tls.handleServerKeyExchange = function(c, record, length) { if (length > 0) { - return c2.error(c2, { + return c.error(c, { message: "Invalid key parameters. Only RSA is supported.", send: true, alert: { @@ -113265,12 +113504,12 @@ var require_tls = __commonJS({ } }); } - c2.expect = SCR; - c2.process(); + c.expect = SCR; + c.process(); }; - tls.handleClientKeyExchange = function(c2, record, length) { + tls.handleClientKeyExchange = function(c, record, length) { if (length < 48) { - return c2.error(c2, { + return c.error(c, { message: "Invalid key parameters. Only RSA is supported.", send: true, alert: { @@ -113284,12 +113523,12 @@ var require_tls = __commonJS({ enc_pre_master_secret: readVector(b, 2).getBytes() }; var privateKey = null; - if (c2.getPrivateKey) { + if (c.getPrivateKey) { try { - privateKey = c2.getPrivateKey(c2, c2.session.serverCertificate); + privateKey = c.getPrivateKey(c, c.session.serverCertificate); privateKey = forge.pki.privateKeyFromPem(privateKey); } catch (ex) { - c2.error(c2, { + c.error(c, { message: "Could not get private key.", cause: ex, send: true, @@ -113301,7 +113540,7 @@ var require_tls = __commonJS({ } } if (privateKey === null) { - return c2.error(c2, { + return c.error(c, { message: "No private key set.", send: true, alert: { @@ -113311,24 +113550,24 @@ var require_tls = __commonJS({ }); } try { - var sp = c2.session.sp; + var sp = c.session.sp; sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret); - var version = c2.session.clientHelloVersion; + var version = c.session.clientHelloVersion; if (version.major !== sp.pre_master_secret.charCodeAt(0) || version.minor !== sp.pre_master_secret.charCodeAt(1)) { throw new Error("TLS version rollback attack detected."); } } catch (ex) { sp.pre_master_secret = forge.random.getBytes(48); } - c2.expect = CCC; - if (c2.session.clientCertificate !== null) { - c2.expect = CCV; + c.expect = CCC; + if (c.session.clientCertificate !== null) { + c.expect = CCV; } - c2.process(); + c.process(); }; - tls.handleCertificateRequest = function(c2, record, length) { + tls.handleCertificateRequest = function(c, record, length) { if (length < 3) { - return c2.error(c2, { + return c.error(c, { message: "Invalid CertificateRequest. Message too short.", send: true, alert: { @@ -113342,13 +113581,13 @@ var require_tls = __commonJS({ certificate_types: readVector(b, 1), certificate_authorities: readVector(b, 2) }; - c2.session.certificateRequest = msg; - c2.expect = SHD; - c2.process(); + c.session.certificateRequest = msg; + c.expect = SHD; + c.process(); }; - tls.handleCertificateVerify = function(c2, record, length) { + tls.handleCertificateVerify = function(c, record, length) { if (length < 2) { - return c2.error(c2, { + return c.error(c, { message: "Invalid CertificateVerify. Message too short.", send: true, alert: { @@ -113365,18 +113604,18 @@ var require_tls = __commonJS({ signature: readVector(b, 2).getBytes() }; var verify = forge.util.createBuffer(); - verify.putBuffer(c2.session.md5.digest()); - verify.putBuffer(c2.session.sha1.digest()); + verify.putBuffer(c.session.md5.digest()); + verify.putBuffer(c.session.sha1.digest()); verify = verify.getBytes(); try { - var cert = c2.session.clientCertificate; + var cert = c.session.clientCertificate; if (!cert.publicKey.verify(verify, msg.signature, "NONE")) { throw new Error("CertificateVerify signature does not match."); } - c2.session.md5.update(msgBytes); - c2.session.sha1.update(msgBytes); + c.session.md5.update(msgBytes); + c.session.sha1.update(msgBytes); } catch (ex) { - return c2.error(c2, { + return c.error(c, { message: "Bad signature in CertificateVerify.", send: true, alert: { @@ -113385,12 +113624,12 @@ var require_tls = __commonJS({ } }); } - c2.expect = CCC; - c2.process(); + c.expect = CCC; + c.process(); }; - tls.handleServerHelloDone = function(c2, record, length) { + tls.handleServerHelloDone = function(c, record, length) { if (length > 0) { - return c2.error(c2, { + return c.error(c, { message: "Invalid ServerHelloDone message. Invalid length.", send: true, alert: { @@ -113399,7 +113638,7 @@ var require_tls = __commonJS({ } }); } - if (c2.serverCertificate === null) { + if (c.serverCertificate === null) { var error3 = { message: "No server certificate provided. Not enough security.", send: true, @@ -113409,7 +113648,7 @@ var require_tls = __commonJS({ } }; var depth = 0; - var ret = c2.verify(c2, error3.alert.description, depth, []); + var ret = c.verify(c, error3.alert.description, depth, []); if (ret !== true) { if (ret || ret === 0) { if (typeof ret === "object" && !forge.util.isArray(ret)) { @@ -113423,51 +113662,51 @@ var require_tls = __commonJS({ error3.alert.description = ret; } } - return c2.error(c2, error3); + return c.error(c, error3); } } - if (c2.session.certificateRequest !== null) { - record = tls.createRecord(c2, { + if (c.session.certificateRequest !== null) { + record = tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createCertificate(c2) + data: tls.createCertificate(c) }); - tls.queue(c2, record); + tls.queue(c, record); } - record = tls.createRecord(c2, { + record = tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createClientKeyExchange(c2) + data: tls.createClientKeyExchange(c) }); - tls.queue(c2, record); - c2.expect = SER; - var callback = function(c3, signature) { - if (c3.session.certificateRequest !== null && c3.session.clientCertificate !== null) { - tls.queue(c3, tls.createRecord(c3, { + tls.queue(c, record); + c.expect = SER; + var callback = function(c2, signature) { + if (c2.session.certificateRequest !== null && c2.session.clientCertificate !== null) { + tls.queue(c2, tls.createRecord(c2, { type: tls.ContentType.handshake, - data: tls.createCertificateVerify(c3, signature) + data: tls.createCertificateVerify(c2, signature) })); } - tls.queue(c3, tls.createRecord(c3, { + tls.queue(c2, tls.createRecord(c2, { type: tls.ContentType.change_cipher_spec, data: tls.createChangeCipherSpec() })); - c3.state.pending = tls.createConnectionState(c3); - c3.state.current.write = c3.state.pending.write; - tls.queue(c3, tls.createRecord(c3, { + c2.state.pending = tls.createConnectionState(c2); + c2.state.current.write = c2.state.pending.write; + tls.queue(c2, tls.createRecord(c2, { type: tls.ContentType.handshake, - data: tls.createFinished(c3) + data: tls.createFinished(c2) })); - c3.expect = SCC; - tls.flush(c3); - c3.process(); + c2.expect = SCC; + tls.flush(c2); + c2.process(); }; - if (c2.session.certificateRequest === null || c2.session.clientCertificate === null) { - return callback(c2, null); + if (c.session.certificateRequest === null || c.session.clientCertificate === null) { + return callback(c, null); } - tls.getClientSignature(c2, callback); + tls.getClientSignature(c, callback); }; - tls.handleChangeCipherSpec = function(c2, record) { + tls.handleChangeCipherSpec = function(c, record) { if (record.fragment.getByte() !== 1) { - return c2.error(c2, { + return c.error(c, { message: "Invalid ChangeCipherSpec message received.", send: true, alert: { @@ -113476,34 +113715,34 @@ var require_tls = __commonJS({ } }); } - var client = c2.entity === tls.ConnectionEnd.client; - if (c2.session.resuming && client || !c2.session.resuming && !client) { - c2.state.pending = tls.createConnectionState(c2); + var client = c.entity === tls.ConnectionEnd.client; + if (c.session.resuming && client || !c.session.resuming && !client) { + c.state.pending = tls.createConnectionState(c); } - c2.state.current.read = c2.state.pending.read; - if (!c2.session.resuming && client || c2.session.resuming && !client) { - c2.state.pending = null; + c.state.current.read = c.state.pending.read; + if (!c.session.resuming && client || c.session.resuming && !client) { + c.state.pending = null; } - c2.expect = client ? SFI : CFI; - c2.process(); + c.expect = client ? SFI : CFI; + c.process(); }; - tls.handleFinished = function(c2, record, length) { + tls.handleFinished = function(c, record, length) { var b = record.fragment; b.read -= 4; var msgBytes = b.bytes(); b.read += 4; var vd = record.fragment.getBytes(); b = forge.util.createBuffer(); - b.putBuffer(c2.session.md5.digest()); - b.putBuffer(c2.session.sha1.digest()); - var client = c2.entity === tls.ConnectionEnd.client; + b.putBuffer(c.session.md5.digest()); + b.putBuffer(c.session.sha1.digest()); + var client = c.entity === tls.ConnectionEnd.client; var label = client ? "server finished" : "client finished"; - var sp = c2.session.sp; + var sp = c.session.sp; var vdl = 12; var prf = prf_TLS1; b = prf(sp.master_secret, label, b.getBytes(), vdl); if (b.getBytes() !== vd) { - return c2.error(c2, { + return c.error(c, { message: "Invalid verify_data in Finished message.", send: true, alert: { @@ -113512,30 +113751,30 @@ var require_tls = __commonJS({ } }); } - c2.session.md5.update(msgBytes); - c2.session.sha1.update(msgBytes); - if (c2.session.resuming && client || !c2.session.resuming && !client) { - tls.queue(c2, tls.createRecord(c2, { + c.session.md5.update(msgBytes); + c.session.sha1.update(msgBytes); + if (c.session.resuming && client || !c.session.resuming && !client) { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.change_cipher_spec, data: tls.createChangeCipherSpec() })); - c2.state.current.write = c2.state.pending.write; - c2.state.pending = null; - tls.queue(c2, tls.createRecord(c2, { + c.state.current.write = c.state.pending.write; + c.state.pending = null; + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createFinished(c2) + data: tls.createFinished(c) })); } - c2.expect = client ? SAD : CAD; - c2.handshaking = false; - ++c2.handshakes; - c2.peerCertificate = client ? c2.session.serverCertificate : c2.session.clientCertificate; - tls.flush(c2); - c2.isConnected = true; - c2.connected(c2); - c2.process(); + c.expect = client ? SAD : CAD; + c.handshaking = false; + ++c.handshakes; + c.peerCertificate = client ? c.session.serverCertificate : c.session.clientCertificate; + tls.flush(c); + c.isConnected = true; + c.connected(c); + c.process(); }; - tls.handleAlert = function(c2, record) { + tls.handleAlert = function(c, record) { var b = record.fragment; var alert = { level: b.getByte(), @@ -113617,35 +113856,35 @@ var require_tls = __commonJS({ break; } if (alert.description === tls.Alert.Description.close_notify) { - return c2.close(); + return c.close(); } - c2.error(c2, { + c.error(c, { message: msg, send: false, // origin is the opposite end - origin: c2.entity === tls.ConnectionEnd.client ? "server" : "client", + origin: c.entity === tls.ConnectionEnd.client ? "server" : "client", alert }); - c2.process(); + c.process(); }; - tls.handleHandshake = function(c2, record) { + tls.handleHandshake = function(c, record) { var b = record.fragment; var type2 = b.getByte(); var length = b.getInt24(); if (length > b.length()) { - c2.fragmented = record; + c.fragmented = record; record.fragment = forge.util.createBuffer(); b.read -= 4; - return c2.process(); + return c.process(); } - c2.fragmented = null; + c.fragmented = null; b.read -= 4; var bytes = b.bytes(length + 4); b.read += 4; - if (type2 in hsTable[c2.entity][c2.expect]) { - if (c2.entity === tls.ConnectionEnd.server && !c2.open && !c2.fail) { - c2.handshaking = true; - c2.session = { + if (type2 in hsTable[c.entity][c.expect]) { + if (c.entity === tls.ConnectionEnd.server && !c.open && !c.fail) { + c.handshaking = true; + c.session = { version: null, extensions: { server_name: { @@ -113661,45 +113900,45 @@ var require_tls = __commonJS({ }; } if (type2 !== tls.HandshakeType.hello_request && type2 !== tls.HandshakeType.certificate_verify && type2 !== tls.HandshakeType.finished) { - c2.session.md5.update(bytes); - c2.session.sha1.update(bytes); + c.session.md5.update(bytes); + c.session.sha1.update(bytes); } - hsTable[c2.entity][c2.expect][type2](c2, record, length); + hsTable[c.entity][c.expect][type2](c, record, length); } else { - tls.handleUnexpected(c2, record); + tls.handleUnexpected(c, record); } }; - tls.handleApplicationData = function(c2, record) { - c2.data.putBuffer(record.fragment); - c2.dataReady(c2); - c2.process(); + tls.handleApplicationData = function(c, record) { + c.data.putBuffer(record.fragment); + c.dataReady(c); + c.process(); }; - tls.handleHeartbeat = function(c2, record) { + tls.handleHeartbeat = function(c, record) { var b = record.fragment; var type2 = b.getByte(); var length = b.getInt16(); var payload = b.getBytes(length); if (type2 === tls.HeartbeatMessageType.heartbeat_request) { - if (c2.handshaking || length > payload.length) { - return c2.process(); + if (c.handshaking || length > payload.length) { + return c.process(); } - tls.queue(c2, tls.createRecord(c2, { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.heartbeat, data: tls.createHeartbeat( tls.HeartbeatMessageType.heartbeat_response, payload ) })); - tls.flush(c2); + tls.flush(c); } else if (type2 === tls.HeartbeatMessageType.heartbeat_response) { - if (payload !== c2.expectedHeartbeatPayload) { - return c2.process(); + if (payload !== c.expectedHeartbeatPayload) { + return c.process(); } - if (c2.heartbeatReceived) { - c2.heartbeatReceived(c2, forge.util.createBuffer(payload)); + if (c.heartbeatReceived) { + c.heartbeatReceived(c, forge.util.createBuffer(payload)); } } - c2.process(); + c.process(); }; var SHE = 0; var SCE = 1; @@ -113815,10 +114054,10 @@ var require_tls = __commonJS({ /*CER*/ [__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __] ]; - tls.generateKeys = function(c2, sp) { + tls.generateKeys = function(c, sp) { var prf = prf_TLS1; var random = sp.client_random + sp.server_random; - if (!c2.session.resuming) { + if (!c.session.resuming) { sp.master_secret = prf( sp.pre_master_secret, "master secret", @@ -113829,7 +114068,7 @@ var require_tls = __commonJS({ } random = sp.server_random + sp.client_random; var length = 2 * sp.mac_key_length + 2 * sp.enc_key_length; - var tls10 = c2.version.major === tls.Versions.TLS_1_0.major && c2.version.minor === tls.Versions.TLS_1_0.minor; + var tls10 = c.version.major === tls.Versions.TLS_1_0.major && c.version.minor === tls.Versions.TLS_1_0.minor; if (tls10) { length += 2 * sp.fixed_iv_length; } @@ -113846,8 +114085,8 @@ var require_tls = __commonJS({ } return rval; }; - tls.createConnectionState = function(c2) { - var client = c2.entity === tls.ConnectionEnd.client; + tls.createConnectionState = function(c) { + var client = c.entity === tls.ConnectionEnd.client; var createMode = function() { var mode = { // two 32-bit numbers, first is most significant @@ -113878,9 +114117,9 @@ var require_tls = __commonJS({ read: createMode(), write: createMode() }; - state.read.update = function(c3, record) { + state.read.update = function(c2, record) { if (!state.read.cipherFunction(record, state.read)) { - c3.error(c3, { + c2.error(c2, { message: "Could not decrypt record or bad MAC.", send: true, alert: { @@ -113891,8 +114130,8 @@ var require_tls = __commonJS({ description: tls.Alert.Description.bad_record_mac } }); - } else if (!state.read.compressFunction(c3, record, state.read)) { - c3.error(c3, { + } else if (!state.read.compressFunction(c2, record, state.read)) { + c2.error(c2, { message: "Could not decompress record.", send: true, alert: { @@ -113901,11 +114140,11 @@ var require_tls = __commonJS({ } }); } - return !c3.fail; + return !c2.fail; }; - state.write.update = function(c3, record) { - if (!state.write.compressFunction(c3, record, state.write)) { - c3.error(c3, { + state.write.update = function(c2, record) { + if (!state.write.compressFunction(c2, record, state.write)) { + c2.error(c2, { message: "Could not compress record.", send: false, alert: { @@ -113914,7 +114153,7 @@ var require_tls = __commonJS({ } }); } else if (!state.write.cipherFunction(record, state.write)) { - c3.error(c3, { + c2.error(c2, { message: "Could not encrypt record.", send: false, alert: { @@ -113923,15 +114162,15 @@ var require_tls = __commonJS({ } }); } - return !c3.fail; + return !c2.fail; }; - if (c2.session) { - var sp = c2.session.sp; - c2.session.cipherSuite.initSecurityParameters(sp); - sp.keys = tls.generateKeys(c2, sp); + if (c.session) { + var sp = c.session.sp; + c.session.cipherSuite.initSecurityParameters(sp); + sp.keys = tls.generateKeys(c, sp); state.read.macKey = client ? sp.keys.server_write_MAC_key : sp.keys.client_write_MAC_key; state.write.macKey = client ? sp.keys.client_write_MAC_key : sp.keys.server_write_MAC_key; - c2.session.cipherSuite.initConnectionState(state, c2, sp); + c.session.cipherSuite.initConnectionState(state, c, sp); switch (sp.compression_algorithm) { case tls.CompressionMethod.none: break; @@ -113953,38 +114192,38 @@ var require_tls = __commonJS({ rval.putBytes(forge.random.getBytes(28)); return rval; }; - tls.createRecord = function(c2, options) { + tls.createRecord = function(c, options) { if (!options.data) { return null; } var record = { type: options.type, version: { - major: c2.version.major, - minor: c2.version.minor + major: c.version.major, + minor: c.version.minor }, length: options.data.length(), fragment: options.data }; return record; }; - tls.createAlert = function(c2, alert) { + tls.createAlert = function(c, alert) { var b = forge.util.createBuffer(); b.putByte(alert.level); b.putByte(alert.description); - return tls.createRecord(c2, { + return tls.createRecord(c, { type: tls.ContentType.alert, data: b }); }; - tls.createClientHello = function(c2) { - c2.session.clientHelloVersion = { - major: c2.version.major, - minor: c2.version.minor + tls.createClientHello = function(c) { + c.session.clientHelloVersion = { + major: c.version.major, + minor: c.version.minor }; var cipherSuites = forge.util.createBuffer(); - for (var i = 0; i < c2.cipherSuites.length; ++i) { - var cs = c2.cipherSuites[i]; + for (var i = 0; i < c.cipherSuites.length; ++i) { + var cs = c.cipherSuites[i]; cipherSuites.putByte(cs.id[0]); cipherSuites.putByte(cs.id[1]); } @@ -113993,13 +114232,13 @@ var require_tls = __commonJS({ compressionMethods.putByte(tls.CompressionMethod.none); var cMethods = compressionMethods.length(); var extensions = forge.util.createBuffer(); - if (c2.virtualHost) { + if (c.virtualHost) { var ext = forge.util.createBuffer(); ext.putByte(0); ext.putByte(0); var serverName = forge.util.createBuffer(); serverName.putByte(0); - writeVector(serverName, 2, forge.util.createBuffer(c2.virtualHost)); + writeVector(serverName, 2, forge.util.createBuffer(c.virtualHost)); var snList = forge.util.createBuffer(); writeVector(snList, 2, serverName); writeVector(ext, 2, snList); @@ -114009,7 +114248,7 @@ var require_tls = __commonJS({ if (extLength > 0) { extLength += 2; } - var sessionId = c2.session.id; + var sessionId = c.session.id; var length = sessionId.length + 1 + // session ID vector 2 + // version (major + minor) 4 + 28 + // random time and random bytes @@ -114019,9 +114258,9 @@ var require_tls = __commonJS({ var rval = forge.util.createBuffer(); rval.putByte(tls.HandshakeType.client_hello); rval.putInt24(length); - rval.putByte(c2.version.major); - rval.putByte(c2.version.minor); - rval.putBytes(c2.session.sp.client_random); + rval.putByte(c.version.major); + rval.putByte(c.version.minor); + rval.putBytes(c.session.sp.client_random); writeVector(rval, 1, forge.util.createBuffer(sessionId)); writeVector(rval, 2, cipherSuites); writeVector(rval, 1, compressionMethods); @@ -114030,8 +114269,8 @@ var require_tls = __commonJS({ } return rval; }; - tls.createServerHello = function(c2) { - var sessionId = c2.session.id; + tls.createServerHello = function(c) { + var sessionId = c.session.id; var length = sessionId.length + 1 + // session ID vector 2 + // version (major + minor) 4 + 28 + // random time and random bytes @@ -114040,26 +114279,26 @@ var require_tls = __commonJS({ var rval = forge.util.createBuffer(); rval.putByte(tls.HandshakeType.server_hello); rval.putInt24(length); - rval.putByte(c2.version.major); - rval.putByte(c2.version.minor); - rval.putBytes(c2.session.sp.server_random); + rval.putByte(c.version.major); + rval.putByte(c.version.minor); + rval.putBytes(c.session.sp.server_random); writeVector(rval, 1, forge.util.createBuffer(sessionId)); - rval.putByte(c2.session.cipherSuite.id[0]); - rval.putByte(c2.session.cipherSuite.id[1]); - rval.putByte(c2.session.compressionMethod); + rval.putByte(c.session.cipherSuite.id[0]); + rval.putByte(c.session.cipherSuite.id[1]); + rval.putByte(c.session.compressionMethod); return rval; }; - tls.createCertificate = function(c2) { - var client = c2.entity === tls.ConnectionEnd.client; + tls.createCertificate = function(c) { + var client = c.entity === tls.ConnectionEnd.client; var cert = null; - if (c2.getCertificate) { + if (c.getCertificate) { var hint; if (client) { - hint = c2.session.certificateRequest; + hint = c.session.certificateRequest; } else { - hint = c2.session.extensions.server_name.serverNameList; + hint = c.session.extensions.server_name.serverNameList; } - cert = c2.getCertificate(c2, hint); + cert = c.getCertificate(c, hint); } var certList = forge.util.createBuffer(); if (cert !== null) { @@ -114088,12 +114327,12 @@ var require_tls = __commonJS({ } cert = forge.pki.certificateFromAsn1(asn1); if (client) { - c2.session.clientCertificate = cert; + c.session.clientCertificate = cert; } else { - c2.session.serverCertificate = cert; + c.session.serverCertificate = cert; } } catch (ex) { - return c2.error(c2, { + return c.error(c, { message: "Could not send certificate list.", cause: ex, send: true, @@ -114111,14 +114350,14 @@ var require_tls = __commonJS({ writeVector(rval, 3, certList); return rval; }; - tls.createClientKeyExchange = function(c2) { + tls.createClientKeyExchange = function(c) { var b = forge.util.createBuffer(); - b.putByte(c2.session.clientHelloVersion.major); - b.putByte(c2.session.clientHelloVersion.minor); + b.putByte(c.session.clientHelloVersion.major); + b.putByte(c.session.clientHelloVersion.minor); b.putBytes(forge.random.getBytes(46)); - var sp = c2.session.sp; + var sp = c.session.sp; sp.pre_master_secret = b.getBytes(); - var key2 = c2.session.serverCertificate.publicKey; + var key2 = c.session.serverCertificate.publicKey; b = key2.encrypt(sp.pre_master_secret); var length = b.length + 2; var rval = forge.util.createBuffer(); @@ -114128,7 +114367,7 @@ var require_tls = __commonJS({ rval.putBytes(b); return rval; }; - tls.createServerKeyExchange = function(c2) { + tls.createServerKeyExchange = function(c) { var length = 0; var rval = forge.util.createBuffer(); if (length > 0) { @@ -114137,19 +114376,19 @@ var require_tls = __commonJS({ } return rval; }; - tls.getClientSignature = function(c2, callback) { + tls.getClientSignature = function(c, callback) { var b = forge.util.createBuffer(); - b.putBuffer(c2.session.md5.digest()); - b.putBuffer(c2.session.sha1.digest()); + b.putBuffer(c.session.md5.digest()); + b.putBuffer(c.session.sha1.digest()); b = b.getBytes(); - c2.getSignature = c2.getSignature || function(c3, b2, callback2) { + c.getSignature = c.getSignature || function(c2, b2, callback2) { var privateKey = null; - if (c3.getPrivateKey) { + if (c2.getPrivateKey) { try { - privateKey = c3.getPrivateKey(c3, c3.session.clientCertificate); + privateKey = c2.getPrivateKey(c2, c2.session.clientCertificate); privateKey = forge.pki.privateKeyFromPem(privateKey); } catch (ex) { - c3.error(c3, { + c2.error(c2, { message: "Could not get private key.", cause: ex, send: true, @@ -114161,7 +114400,7 @@ var require_tls = __commonJS({ } } if (privateKey === null) { - c3.error(c3, { + c2.error(c2, { message: "No private key set.", send: true, alert: { @@ -114172,11 +114411,11 @@ var require_tls = __commonJS({ } else { b2 = privateKey.sign(b2, null); } - callback2(c3, b2); + callback2(c2, b2); }; - c2.getSignature(c2, b, callback); + c.getSignature(c, b, callback); }; - tls.createCertificateVerify = function(c2, signature) { + tls.createCertificateVerify = function(c, signature) { var length = signature.length + 2; var rval = forge.util.createBuffer(); rval.putByte(tls.HandshakeType.certificate_verify); @@ -114185,12 +114424,12 @@ var require_tls = __commonJS({ rval.putBytes(signature); return rval; }; - tls.createCertificateRequest = function(c2) { + tls.createCertificateRequest = function(c) { var certTypes = forge.util.createBuffer(); certTypes.putByte(1); var cAs = forge.util.createBuffer(); - for (var key2 in c2.caStore.certs) { - var cert = c2.caStore.certs[key2]; + for (var key2 in c.caStore.certs) { + var cert = c.caStore.certs[key2]; var dn = forge.pki.distinguishedNameToAsn1(cert.subject); var byteBuffer = forge.asn1.toDer(dn); cAs.putInt16(byteBuffer.length()); @@ -114204,7 +114443,7 @@ var require_tls = __commonJS({ writeVector(rval, 2, cAs); return rval; }; - tls.createServerHelloDone = function(c2) { + tls.createServerHelloDone = function(c) { var rval = forge.util.createBuffer(); rval.putByte(tls.HandshakeType.server_hello_done); rval.putInt24(0); @@ -114215,12 +114454,12 @@ var require_tls = __commonJS({ rval.putByte(1); return rval; }; - tls.createFinished = function(c2) { + tls.createFinished = function(c) { var b = forge.util.createBuffer(); - b.putBuffer(c2.session.md5.digest()); - b.putBuffer(c2.session.sha1.digest()); - var client = c2.entity === tls.ConnectionEnd.client; - var sp = c2.session.sp; + b.putBuffer(c.session.md5.digest()); + b.putBuffer(c.session.sha1.digest()); + var client = c.entity === tls.ConnectionEnd.client; + var sp = c.session.sp; var vdl = 12; var prf = prf_TLS1; var label = client ? "client finished" : "server finished"; @@ -114244,7 +114483,7 @@ var require_tls = __commonJS({ rval.putBytes(forge.random.getBytes(paddingLength)); return rval; }; - tls.queue = function(c2, record) { + tls.queue = function(c, record) { if (!record) { return; } @@ -114255,8 +114494,8 @@ var require_tls = __commonJS({ } if (record.type === tls.ContentType.handshake) { var bytes = record.fragment.bytes(); - c2.session.md5.update(bytes); - c2.session.sha1.update(bytes); + c.session.md5.update(bytes); + c.session.sha1.update(bytes); bytes = null; } var records; @@ -114266,38 +114505,38 @@ var require_tls = __commonJS({ records = []; var data = record.fragment.bytes(); while (data.length > tls.MaxFragment) { - records.push(tls.createRecord(c2, { + records.push(tls.createRecord(c, { type: record.type, data: forge.util.createBuffer(data.slice(0, tls.MaxFragment)) })); data = data.slice(tls.MaxFragment); } if (data.length > 0) { - records.push(tls.createRecord(c2, { + records.push(tls.createRecord(c, { type: record.type, data: forge.util.createBuffer(data) })); } } - for (var i = 0; i < records.length && !c2.fail; ++i) { + for (var i = 0; i < records.length && !c.fail; ++i) { var rec = records[i]; - var s = c2.state.current.write; - if (s.update(c2, rec)) { - c2.records.push(rec); + var s = c.state.current.write; + if (s.update(c, rec)) { + c.records.push(rec); } } }; - tls.flush = function(c2) { - for (var i = 0; i < c2.records.length; ++i) { - var record = c2.records[i]; - c2.tlsData.putByte(record.type); - c2.tlsData.putByte(record.version.major); - c2.tlsData.putByte(record.version.minor); - c2.tlsData.putInt16(record.fragment.length()); - c2.tlsData.putBuffer(c2.records[i].fragment); + tls.flush = function(c) { + for (var i = 0; i < c.records.length; ++i) { + var record = c.records[i]; + c.tlsData.putByte(record.type); + c.tlsData.putByte(record.version.major); + c.tlsData.putByte(record.version.minor); + c.tlsData.putInt16(record.fragment.length()); + c.tlsData.putBuffer(c.records[i].fragment); } - c2.records = []; - return c2.tlsDataReady(c2); + c.records = []; + return c.tlsDataReady(c); }; var _certErrorToAlertDesc = function(error3) { switch (error3) { @@ -114339,15 +114578,15 @@ var require_tls = __commonJS({ return forge.pki.certificateError.bad_certificate; } }; - tls.verifyCertificateChain = function(c2, chain) { + tls.verifyCertificateChain = function(c, chain) { try { var options = {}; - for (var key2 in c2.verifyOptions) { - options[key2] = c2.verifyOptions[key2]; + for (var key2 in c.verifyOptions) { + options[key2] = c.verifyOptions[key2]; } options.verify = function(vfd, depth, chain2) { var desc = _certErrorToAlertDesc(vfd); - var ret = c2.verify(c2, vfd, depth, chain2); + var ret = c.verify(c, vfd, depth, chain2); if (ret !== true) { if (typeof ret === "object" && !forge.util.isArray(ret)) { var error3 = new Error("The application rejected the certificate."); @@ -114370,7 +114609,7 @@ var require_tls = __commonJS({ } return ret; }; - forge.pki.verifyCertificateChain(c2.caStore, chain, options); + forge.pki.verifyCertificateChain(c.caStore, chain, options); } catch (ex) { var err = ex; if (typeof err !== "object" || forge.util.isArray(err)) { @@ -114391,9 +114630,9 @@ var require_tls = __commonJS({ description: _certErrorToAlertDesc(err.error) }; } - c2.error(c2, err); + c.error(c, err); } - return !c2.fail; + return !c.fail; }; tls.createSessionCache = function(cache, capacity) { var rval = null; @@ -114463,7 +114702,7 @@ var require_tls = __commonJS({ } var entity = options.server || false ? tls.ConnectionEnd.server : tls.ConnectionEnd.client; var sessionCache = options.sessionCache ? tls.createSessionCache(options.sessionCache) : null; - var c2 = { + var c = { version: { major: tls.Version.major, minor: tls.Version.minor }, entity, sessionId: options.sessionId, @@ -114487,64 +114726,64 @@ var require_tls = __commonJS({ dataReady: options.dataReady, heartbeatReceived: options.heartbeatReceived, closed: options.closed, - error: function(c3, ex) { - ex.origin = ex.origin || (c3.entity === tls.ConnectionEnd.client ? "client" : "server"); + error: function(c2, ex) { + ex.origin = ex.origin || (c2.entity === tls.ConnectionEnd.client ? "client" : "server"); if (ex.send) { - tls.queue(c3, tls.createAlert(c3, ex.alert)); - tls.flush(c3); + tls.queue(c2, tls.createAlert(c2, ex.alert)); + tls.flush(c2); } var fatal = ex.fatal !== false; if (fatal) { - c3.fail = true; + c2.fail = true; } - options.error(c3, ex); + options.error(c2, ex); if (fatal) { - c3.close(false); + c2.close(false); } }, deflate: options.deflate || null, inflate: options.inflate || null }; - c2.reset = function(clearFail) { - c2.version = { major: tls.Version.major, minor: tls.Version.minor }; - c2.record = null; - c2.session = null; - c2.peerCertificate = null; - c2.state = { + c.reset = function(clearFail) { + c.version = { major: tls.Version.major, minor: tls.Version.minor }; + c.record = null; + c.session = null; + c.peerCertificate = null; + c.state = { pending: null, current: null }; - c2.expect = c2.entity === tls.ConnectionEnd.client ? SHE : CHE; - c2.fragmented = null; - c2.records = []; - c2.open = false; - c2.handshakes = 0; - c2.handshaking = false; - c2.isConnected = false; - c2.fail = !(clearFail || typeof clearFail === "undefined"); - c2.input.clear(); - c2.tlsData.clear(); - c2.data.clear(); - c2.state.current = tls.createConnectionState(c2); + c.expect = c.entity === tls.ConnectionEnd.client ? SHE : CHE; + c.fragmented = null; + c.records = []; + c.open = false; + c.handshakes = 0; + c.handshaking = false; + c.isConnected = false; + c.fail = !(clearFail || typeof clearFail === "undefined"); + c.input.clear(); + c.tlsData.clear(); + c.data.clear(); + c.state.current = tls.createConnectionState(c); }; - c2.reset(); - var _update = function(c3, record) { + c.reset(); + var _update = function(c2, record) { var aligned = record.type - tls.ContentType.change_cipher_spec; - var handlers = ctTable[c3.entity][c3.expect]; + var handlers = ctTable[c2.entity][c2.expect]; if (aligned in handlers) { - handlers[aligned](c3, record); + handlers[aligned](c2, record); } else { - tls.handleUnexpected(c3, record); + tls.handleUnexpected(c2, record); } }; - var _readRecordHeader = function(c3) { + var _readRecordHeader = function(c2) { var rval = 0; - var b = c3.input; + var b = c2.input; var len = b.length(); if (len < 5) { rval = 5 - len; } else { - c3.record = { + c2.record = { type: b.getByte(), version: { major: b.getByte(), @@ -114554,12 +114793,12 @@ var require_tls = __commonJS({ fragment: forge.util.createBuffer(), ready: false }; - var compatibleVersion = c3.record.version.major === c3.version.major; - if (compatibleVersion && c3.session && c3.session.version) { - compatibleVersion = c3.record.version.minor === c3.version.minor; + var compatibleVersion = c2.record.version.major === c2.version.major; + if (compatibleVersion && c2.session && c2.session.version) { + compatibleVersion = c2.record.version.minor === c2.version.minor; } if (!compatibleVersion) { - c3.error(c3, { + c2.error(c2, { message: "Incompatible TLS version.", send: true, alert: { @@ -114571,23 +114810,23 @@ var require_tls = __commonJS({ } return rval; }; - var _readRecord = function(c3) { + var _readRecord = function(c2) { var rval = 0; - var b = c3.input; + var b = c2.input; var len = b.length(); - if (len < c3.record.length) { - rval = c3.record.length - len; + if (len < c2.record.length) { + rval = c2.record.length - len; } else { - c3.record.fragment.putBytes(b.getBytes(c3.record.length)); + c2.record.fragment.putBytes(b.getBytes(c2.record.length)); b.compact(); - var s = c3.state.current.read; - if (s.update(c3, c3.record)) { - if (c3.fragmented !== null) { - if (c3.fragmented.type === c3.record.type) { - c3.fragmented.fragment.putBuffer(c3.record.fragment); - c3.record = c3.fragmented; + var s = c2.state.current.read; + if (s.update(c2, c2.record)) { + if (c2.fragmented !== null) { + if (c2.fragmented.type === c2.record.type) { + c2.fragmented.fragment.putBuffer(c2.record.fragment); + c2.record = c2.fragmented; } else { - c3.error(c3, { + c2.error(c2, { message: "Invalid fragmented record.", send: true, alert: { @@ -114597,44 +114836,44 @@ var require_tls = __commonJS({ }); } } - c3.record.ready = true; + c2.record.ready = true; } } return rval; }; - c2.handshake = function(sessionId) { - if (c2.entity !== tls.ConnectionEnd.client) { - c2.error(c2, { + c.handshake = function(sessionId) { + if (c.entity !== tls.ConnectionEnd.client) { + c.error(c, { message: "Cannot initiate handshake as a server.", fatal: false }); - } else if (c2.handshaking) { - c2.error(c2, { + } else if (c.handshaking) { + c.error(c, { message: "Handshake already in progress.", fatal: false }); } else { - if (c2.fail && !c2.open && c2.handshakes === 0) { - c2.fail = false; + if (c.fail && !c.open && c.handshakes === 0) { + c.fail = false; } - c2.handshaking = true; + c.handshaking = true; sessionId = sessionId || ""; var session = null; if (sessionId.length > 0) { - if (c2.sessionCache) { - session = c2.sessionCache.getSession(sessionId); + if (c.sessionCache) { + session = c.sessionCache.getSession(sessionId); } if (session === null) { sessionId = ""; } } - if (sessionId.length === 0 && c2.sessionCache) { - session = c2.sessionCache.getSession(); + if (sessionId.length === 0 && c.sessionCache) { + session = c.sessionCache.getSession(); if (session !== null) { sessionId = session.id; } } - c2.session = { + c.session = { id: sessionId, version: null, cipherSuite: null, @@ -114647,55 +114886,55 @@ var require_tls = __commonJS({ sha1: forge.md.sha1.create() }; if (session) { - c2.version = session.version; - c2.session.sp = session.sp; + c.version = session.version; + c.session.sp = session.sp; } - c2.session.sp.client_random = tls.createRandom().getBytes(); - c2.open = true; - tls.queue(c2, tls.createRecord(c2, { + c.session.sp.client_random = tls.createRandom().getBytes(); + c.open = true; + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.handshake, - data: tls.createClientHello(c2) + data: tls.createClientHello(c) })); - tls.flush(c2); + tls.flush(c); } }; - c2.process = function(data) { + c.process = function(data) { var rval = 0; if (data) { - c2.input.putBytes(data); + c.input.putBytes(data); } - if (!c2.fail) { - if (c2.record !== null && c2.record.ready && c2.record.fragment.isEmpty()) { - c2.record = null; + if (!c.fail) { + if (c.record !== null && c.record.ready && c.record.fragment.isEmpty()) { + c.record = null; } - if (c2.record === null) { - rval = _readRecordHeader(c2); + if (c.record === null) { + rval = _readRecordHeader(c); } - if (!c2.fail && c2.record !== null && !c2.record.ready) { - rval = _readRecord(c2); + if (!c.fail && c.record !== null && !c.record.ready) { + rval = _readRecord(c); } - if (!c2.fail && c2.record !== null && c2.record.ready) { - _update(c2, c2.record); + if (!c.fail && c.record !== null && c.record.ready) { + _update(c, c.record); } } return rval; }; - c2.prepare = function(data) { - tls.queue(c2, tls.createRecord(c2, { + c.prepare = function(data) { + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.application_data, data: forge.util.createBuffer(data) })); - return tls.flush(c2); + return tls.flush(c); }; - c2.prepareHeartbeatRequest = function(payload, payloadLength) { + c.prepareHeartbeatRequest = function(payload, payloadLength) { if (payload instanceof forge.util.ByteBuffer) { payload = payload.bytes(); } if (typeof payloadLength === "undefined") { payloadLength = payload.length; } - c2.expectedHeartbeatPayload = payload; - tls.queue(c2, tls.createRecord(c2, { + c.expectedHeartbeatPayload = payload; + tls.queue(c, tls.createRecord(c, { type: tls.ContentType.heartbeat, data: tls.createHeartbeat( tls.HeartbeatMessageType.heartbeat_request, @@ -114703,34 +114942,34 @@ var require_tls = __commonJS({ payloadLength ) })); - return tls.flush(c2); + return tls.flush(c); }; - c2.close = function(clearFail) { - if (!c2.fail && c2.sessionCache && c2.session) { + c.close = function(clearFail) { + if (!c.fail && c.sessionCache && c.session) { var session = { - id: c2.session.id, - version: c2.session.version, - sp: c2.session.sp + id: c.session.id, + version: c.session.version, + sp: c.session.sp }; session.sp.keys = null; - c2.sessionCache.setSession(session.id, session); - } - if (c2.open) { - c2.open = false; - c2.input.clear(); - if (c2.isConnected || c2.handshaking) { - c2.isConnected = c2.handshaking = false; - tls.queue(c2, tls.createAlert(c2, { + c.sessionCache.setSession(session.id, session); + } + if (c.open) { + c.open = false; + c.input.clear(); + if (c.isConnected || c.handshaking) { + c.isConnected = c.handshaking = false; + tls.queue(c, tls.createAlert(c, { level: tls.Alert.Level.warning, description: tls.Alert.Description.close_notify })); - tls.flush(c2); + tls.flush(c); } - c2.closed(c2); + c.closed(c); } - c2.reset(clearFail); + c.reset(clearFail); }; - return c2; + return c; }; module2.exports = forge.tls = forge.tls || {}; for (key in tls) { @@ -114785,8 +115024,8 @@ var require_aesCipherSuites = __commonJS({ }, initConnectionState }; - function initConnectionState(state, c2, sp) { - var client = c2.entity === forge.tls.ConnectionEnd.client; + function initConnectionState(state, c, sp) { + var client = c.entity === forge.tls.ConnectionEnd.client; state.read.cipherState = { init: false, cipher: forge.cipher.createDecipher("AES-CBC", client ? sp.keys.server_write_key : sp.keys.client_write_key), @@ -115874,20 +116113,20 @@ var require_ed25519 = __commonJS({ modL(r, x); } function add(p, q) { - var a = gf(), b = gf(), c2 = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf(); + var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf(); Z(a, p[1], p[0]); Z(t, q[1], q[0]); M(a, a, t); A(b, p[0], p[1]); A(t, q[0], q[1]); M(b, b, t); - M(c2, p[3], q[3]); - M(c2, c2, D2); + M(c, p[3], q[3]); + M(c, c, D2); M(d, p[2], q[2]); A(d, d, d); Z(e, b, a); - Z(f, d, c2); - A(g, d, c2); + Z(f, d, c); + A(g, d, c); A(h, b, a); M(p[0], e, f); M(p[1], h, g); @@ -115974,27 +116213,27 @@ var require_ed25519 = __commonJS({ o[15] &= 32767; } function pow2523(o, i) { - var c2 = gf(); + var c = gf(); var a; for (a = 0; a < 16; ++a) { - c2[a] = i[a]; + c[a] = i[a]; } for (a = 250; a >= 0; --a) { - S(c2, c2); + S(c, c); if (a !== 1) { - M(c2, c2, i); + M(c, c, i); } } for (a = 0; a < 16; ++a) { - o[a] = c2[a]; + o[a] = c[a]; } } function neq25519(a, b) { - var c2 = new NativeBuffer(32); + var c = new NativeBuffer(32); var d = new NativeBuffer(32); - pack25519(c2, a); + pack25519(c, a); pack25519(d, b); - return crypto_verify_32(c2, 0, d, 0); + return crypto_verify_32(c, 0, d, 0); } function crypto_verify_32(x, xi, y, yi) { return vn(x, xi, y, yi, 32); @@ -116040,34 +116279,34 @@ var require_ed25519 = __commonJS({ } } function inv25519(o, i) { - var c2 = gf(); + var c = gf(); var a; for (a = 0; a < 16; ++a) { - c2[a] = i[a]; + c[a] = i[a]; } for (a = 253; a >= 0; --a) { - S(c2, c2); + S(c, c); if (a !== 2 && a !== 4) { - M(c2, c2, i); + M(c, c, i); } } for (a = 0; a < 16; ++a) { - o[a] = c2[a]; + o[a] = c[a]; } } function car25519(o) { - var i, v, c2 = 1; + var i, v, c = 1; for (i = 0; i < 16; ++i) { - v = o[i] + c2 + 65535; - c2 = Math.floor(v / 65536); - o[i] = v - c2 * 65536; + v = o[i] + c + 65535; + c = Math.floor(v / 65536); + o[i] = v - c * 65536; } - o[0] += c2 - 1 + 37 * (c2 - 1); + o[0] += c - 1 + 37 * (c - 1); } function sel25519(p, q, b) { - var t, c2 = ~(b - 1); + var t, c = ~(b - 1); for (var i = 0; i < 16; ++i) { - t = c2 & (p[i] ^ q[i]); + t = c & (p[i] ^ q[i]); p[i] ^= t; q[i] ^= t; } @@ -116095,7 +116334,7 @@ var require_ed25519 = __commonJS({ M(o, a, a); } function M(o, a, b) { - var v, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; + var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; v = a[0]; t0 += v * b0; t1 += v * b1; @@ -116383,106 +116622,106 @@ var require_ed25519 = __commonJS({ t12 += 38 * t28; t13 += 38 * t29; t14 += 38 * t30; - c2 = 1; - v = t0 + c2 + 65535; - c2 = Math.floor(v / 65536); - t0 = v - c2 * 65536; - v = t1 + c2 + 65535; - c2 = Math.floor(v / 65536); - t1 = v - c2 * 65536; - v = t2 + c2 + 65535; - c2 = Math.floor(v / 65536); - t2 = v - c2 * 65536; - v = t3 + c2 + 65535; - c2 = Math.floor(v / 65536); - t3 = v - c2 * 65536; - v = t4 + c2 + 65535; - c2 = Math.floor(v / 65536); - t4 = v - c2 * 65536; - v = t5 + c2 + 65535; - c2 = Math.floor(v / 65536); - t5 = v - c2 * 65536; - v = t6 + c2 + 65535; - c2 = Math.floor(v / 65536); - t6 = v - c2 * 65536; - v = t7 + c2 + 65535; - c2 = Math.floor(v / 65536); - t7 = v - c2 * 65536; - v = t8 + c2 + 65535; - c2 = Math.floor(v / 65536); - t8 = v - c2 * 65536; - v = t9 + c2 + 65535; - c2 = Math.floor(v / 65536); - t9 = v - c2 * 65536; - v = t10 + c2 + 65535; - c2 = Math.floor(v / 65536); - t10 = v - c2 * 65536; - v = t11 + c2 + 65535; - c2 = Math.floor(v / 65536); - t11 = v - c2 * 65536; - v = t12 + c2 + 65535; - c2 = Math.floor(v / 65536); - t12 = v - c2 * 65536; - v = t13 + c2 + 65535; - c2 = Math.floor(v / 65536); - t13 = v - c2 * 65536; - v = t14 + c2 + 65535; - c2 = Math.floor(v / 65536); - t14 = v - c2 * 65536; - v = t15 + c2 + 65535; - c2 = Math.floor(v / 65536); - t15 = v - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - c2 = 1; - v = t0 + c2 + 65535; - c2 = Math.floor(v / 65536); - t0 = v - c2 * 65536; - v = t1 + c2 + 65535; - c2 = Math.floor(v / 65536); - t1 = v - c2 * 65536; - v = t2 + c2 + 65535; - c2 = Math.floor(v / 65536); - t2 = v - c2 * 65536; - v = t3 + c2 + 65535; - c2 = Math.floor(v / 65536); - t3 = v - c2 * 65536; - v = t4 + c2 + 65535; - c2 = Math.floor(v / 65536); - t4 = v - c2 * 65536; - v = t5 + c2 + 65535; - c2 = Math.floor(v / 65536); - t5 = v - c2 * 65536; - v = t6 + c2 + 65535; - c2 = Math.floor(v / 65536); - t6 = v - c2 * 65536; - v = t7 + c2 + 65535; - c2 = Math.floor(v / 65536); - t7 = v - c2 * 65536; - v = t8 + c2 + 65535; - c2 = Math.floor(v / 65536); - t8 = v - c2 * 65536; - v = t9 + c2 + 65535; - c2 = Math.floor(v / 65536); - t9 = v - c2 * 65536; - v = t10 + c2 + 65535; - c2 = Math.floor(v / 65536); - t10 = v - c2 * 65536; - v = t11 + c2 + 65535; - c2 = Math.floor(v / 65536); - t11 = v - c2 * 65536; - v = t12 + c2 + 65535; - c2 = Math.floor(v / 65536); - t12 = v - c2 * 65536; - v = t13 + c2 + 65535; - c2 = Math.floor(v / 65536); - t13 = v - c2 * 65536; - v = t14 + c2 + 65535; - c2 = Math.floor(v / 65536); - t14 = v - c2 * 65536; - v = t15 + c2 + 65535; - c2 = Math.floor(v / 65536); - t15 = v - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); o[0] = t0; o[1] = t1; o[2] = t2; @@ -116551,11 +116790,11 @@ var require_kem = __commonJS({ kdf.generate = function(x, length) { var key = new forge.util.ByteBuffer(); var k = Math.ceil(length / digestLength) + counterStart; - var c2 = new forge.util.ByteBuffer(); + var c = new forge.util.ByteBuffer(); for (var i = counterStart; i < k; ++i) { - c2.putInt32(i); + c.putInt32(i); md2.start(); - md2.update(x + c2.getBytes()); + md2.update(x + c.getBytes()); var hash = md2.digest(); key.putBytes(hash.getBytes(digestLength)); } @@ -118354,14 +118593,14 @@ var bool = new type("tag:yaml.org,2002:bool", { }, defaultStyle: "lowercase" }); -function isHexCode(c2) { - return 48 <= c2 && c2 <= 57 || 65 <= c2 && c2 <= 70 || 97 <= c2 && c2 <= 102; +function isHexCode(c) { + return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; } -function isOctCode(c2) { - return 48 <= c2 && c2 <= 55; +function isOctCode(c) { + return 48 <= c && c <= 55; } -function isDecCode(c2) { - return 48 <= c2 && c2 <= 57; +function isDecCode(c) { + return 48 <= c && c <= 57; } function resolveYamlInteger(data) { if (data === null) return false; @@ -118791,57 +119030,57 @@ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\ function _class(obj) { return Object.prototype.toString.call(obj); } -function is_EOL(c2) { - return c2 === 10 || c2 === 13; +function is_EOL(c) { + return c === 10 || c === 13; } -function is_WHITE_SPACE(c2) { - return c2 === 9 || c2 === 32; +function is_WHITE_SPACE(c) { + return c === 9 || c === 32; } -function is_WS_OR_EOL(c2) { - return c2 === 9 || c2 === 32 || c2 === 10 || c2 === 13; +function is_WS_OR_EOL(c) { + return c === 9 || c === 32 || c === 10 || c === 13; } -function is_FLOW_INDICATOR(c2) { - return c2 === 44 || c2 === 91 || c2 === 93 || c2 === 123 || c2 === 125; +function is_FLOW_INDICATOR(c) { + return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; } -function fromHexCode(c2) { +function fromHexCode(c) { var lc; - if (48 <= c2 && c2 <= 57) { - return c2 - 48; + if (48 <= c && c <= 57) { + return c - 48; } - lc = c2 | 32; + lc = c | 32; if (97 <= lc && lc <= 102) { return lc - 97 + 10; } return -1; } -function escapedHexLen(c2) { - if (c2 === 120) { +function escapedHexLen(c) { + if (c === 120) { return 2; } - if (c2 === 117) { + if (c === 117) { return 4; } - if (c2 === 85) { + if (c === 85) { return 8; } return 0; } -function fromDecimalCode(c2) { - if (48 <= c2 && c2 <= 57) { - return c2 - 48; +function fromDecimalCode(c) { + if (48 <= c && c <= 57) { + return c - 48; } return -1; } -function simpleEscapeSequence(c2) { - return c2 === 48 ? "\0" : c2 === 97 ? "\x07" : c2 === 98 ? "\b" : c2 === 116 ? " " : c2 === 9 ? " " : c2 === 110 ? "\n" : c2 === 118 ? "\v" : c2 === 102 ? "\f" : c2 === 114 ? "\r" : c2 === 101 ? "\x1B" : c2 === 32 ? " " : c2 === 34 ? '"' : c2 === 47 ? "/" : c2 === 92 ? "\\" : c2 === 78 ? "\x85" : c2 === 95 ? "\xA0" : c2 === 76 ? "\u2028" : c2 === 80 ? "\u2029" : ""; +function simpleEscapeSequence(c) { + return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; } -function charFromCodepoint(c2) { - if (c2 <= 65535) { - return String.fromCharCode(c2); +function charFromCodepoint(c) { + if (c <= 65535) { + return String.fromCharCode(c); } return String.fromCharCode( - (c2 - 65536 >> 10) + 55296, - (c2 - 65536 & 1023) + 56320 + (c - 65536 >> 10) + 55296, + (c - 65536 & 1023) + 56320 ); } function setProperty(object, key, value) { @@ -120083,31 +120322,31 @@ function testImplicitResolving(state, str2) { } return false; } -function isWhitespace(c2) { - return c2 === CHAR_SPACE || c2 === CHAR_TAB; +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; } -function isPrintable(c2) { - return 32 <= c2 && c2 <= 126 || 161 <= c2 && c2 <= 55295 && c2 !== 8232 && c2 !== 8233 || 57344 <= c2 && c2 <= 65533 && c2 !== CHAR_BOM || 65536 <= c2 && c2 <= 1114111; +function isPrintable(c) { + return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111; } -function isNsCharOrWhitespace(c2) { - return isPrintable(c2) && c2 !== CHAR_BOM && c2 !== CHAR_CARRIAGE_RETURN && c2 !== CHAR_LINE_FEED; +function isNsCharOrWhitespace(c) { + return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED; } -function isPlainSafe(c2, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c2); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c2); +function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); return ( // ns-plain-safe (inblock ? ( // c = flow-in cIsNsCharOrWhitespace - ) : cIsNsCharOrWhitespace && c2 !== CHAR_COMMA && c2 !== CHAR_LEFT_SQUARE_BRACKET && c2 !== CHAR_RIGHT_SQUARE_BRACKET && c2 !== CHAR_LEFT_CURLY_BRACKET && c2 !== CHAR_RIGHT_CURLY_BRACKET) && c2 !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c2 === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar + ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar ); } -function isPlainSafeFirst(c2) { - return isPrintable(c2) && c2 !== CHAR_BOM && !isWhitespace(c2) && c2 !== CHAR_MINUS && c2 !== CHAR_QUESTION && c2 !== CHAR_COLON && c2 !== CHAR_COMMA && c2 !== CHAR_LEFT_SQUARE_BRACKET && c2 !== CHAR_RIGHT_SQUARE_BRACKET && c2 !== CHAR_LEFT_CURLY_BRACKET && c2 !== CHAR_RIGHT_CURLY_BRACKET && c2 !== CHAR_SHARP && c2 !== CHAR_AMPERSAND && c2 !== CHAR_ASTERISK && c2 !== CHAR_EXCLAMATION && c2 !== CHAR_VERTICAL_LINE && c2 !== CHAR_EQUALS && c2 !== CHAR_GREATER_THAN && c2 !== CHAR_SINGLE_QUOTE && c2 !== CHAR_DOUBLE_QUOTE && c2 !== CHAR_PERCENT && c2 !== CHAR_COMMERCIAL_AT && c2 !== CHAR_GRAVE_ACCENT; +function isPlainSafeFirst(c) { + return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT; } -function isPlainSafeLast(c2) { - return !isWhitespace(c2) && c2 !== CHAR_COLON; +function isPlainSafeLast(c) { + return !isWhitespace(c) && c !== CHAR_COLON; } function codePointAt(string, pos) { var first = string.charCodeAt(pos), second; @@ -120726,7 +120965,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -120977,8 +121216,8 @@ var path = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/git-utils.ts var core6 = __toESM(require_core()); @@ -121626,6 +121865,47 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) { } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); +function isBuiltInLanguage(language) { + return builtInLanguageSet.has(language); +} +function parseBuiltInLanguage(language) { + language = language.trim().toLowerCase(); + language = builtin_default.aliases[language] ?? language; + if (isBuiltInLanguage(language)) { + return language; + } + return void 0; +} + // src/logging.ts var core7 = __toESM(require_core()); function getActionsLogger() { @@ -121688,56 +121968,6 @@ function isAuthToken(value, patterns = GITHUB_TOKEN_PATTERNS) { return void 0; } -// src/known-language-aliases.json -var known_language_aliases_exports = {}; -__export(known_language_aliases_exports, { - c: () => c, - "c#": () => c_, - "c++": () => c__, - "c-c++": () => c_c__, - "c-cpp": () => c_cpp, - default: () => known_language_aliases_default, - "java-kotlin": () => java_kotlin, - "javascript-typescript": () => javascript_typescript, - kotlin: () => kotlin, - typescript: () => typescript -}); -var c = "cpp"; -var c_c__ = "cpp"; -var c_cpp = "cpp"; -var c_ = "csharp"; -var c__ = "cpp"; -var java_kotlin = "java"; -var javascript_typescript = "javascript"; -var kotlin = "java"; -var typescript = "javascript"; -var known_language_aliases_default = { - c, - "c-c++": c_c__, - "c-cpp": c_cpp, - "c#": c_, - "c++": c__, - "java-kotlin": java_kotlin, - "javascript-typescript": javascript_typescript, - kotlin, - typescript -}; - -// src/languages.ts -var KnownLanguage = /* @__PURE__ */ ((KnownLanguage2) => { - KnownLanguage2["actions"] = "actions"; - KnownLanguage2["cpp"] = "cpp"; - KnownLanguage2["csharp"] = "csharp"; - KnownLanguage2["go"] = "go"; - KnownLanguage2["java"] = "java"; - KnownLanguage2["javascript"] = "javascript"; - KnownLanguage2["python"] = "python"; - KnownLanguage2["ruby"] = "ruby"; - KnownLanguage2["rust"] = "rust"; - KnownLanguage2["swift"] = "swift"; - return KnownLanguage2; -})(KnownLanguage || {}); - // src/start-proxy/types.ts function hasUsername(config) { return "username" in config; @@ -122158,7 +122388,7 @@ async function sendFailedStatusReport(logger, startedAt, language, unwrappedErro getActionsStatus(error3), startedAt, { - languages: language && [language] + languages: language === void 0 ? void 0 : [language] }, await checkDiskUsage(logger), logger, @@ -122171,19 +122401,6 @@ async function sendFailedStatusReport(logger, startedAt, language, unwrappedErro var UPDATEJOB_PROXY = "update-job-proxy"; var UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; var UPDATEJOB_PROXY_URL_PREFIX = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/"; -function parseLanguage(language) { - language = language.trim().toLowerCase(); - if (Object.hasOwn(KnownLanguage, language)) { - return language; - } - if (Object.hasOwn(known_language_aliases_exports, language)) { - language = known_language_aliases_exports[language]; - if (Object.hasOwn(KnownLanguage, language)) { - return language; - } - } - return void 0; -} function isPAT(value) { return isAuthToken(value, [ GITHUB_PAT_CLASSIC_PATTERN, @@ -122766,7 +122983,7 @@ async function run(startedAt) { logger ); const languageInput = getOptionalInput("language"); - language = languageInput ? parseLanguage(languageInput) : void 0; + language = languageInput ? parseBuiltInLanguage(languageInput) : void 0; const skipUnusedRegistries = await features.getValue( "start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */ ); @@ -122783,7 +123000,7 @@ async function run(startedAt) { } logger.info( `Credentials loaded for the following registries: - ${credentials.map((c2) => credentialToStr(c2)).join("\n")}` + ${credentials.map((c) => credentialToStr(c)).join("\n")}` ); if (core12.isDebug() || isInTestMode()) { try { @@ -122810,9 +123027,9 @@ async function run(startedAt) { await sendSuccessStatusReport( startedAt, { - languages: language && [language] + languages: language === void 0 ? void 0 : [language] }, - proxyConfig.all_credentials.map((c2) => c2.type), + proxyConfig.all_credentials.map((c) => c.type), logger ); } catch (unwrappedError) { diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 7fed483bfd..60cd5fe570 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -39334,7 +39334,7 @@ var require_frame2 = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53039,8 +53039,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57783,7 +57783,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57832,7 +57832,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -106434,7 +106688,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -107267,8 +107521,8 @@ var fs5 = __toESM(require("fs")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -107843,6 +108097,36 @@ ${jsonContents}` } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); @@ -107933,22 +108217,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -107969,12 +108249,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/tar.ts diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 955291ece6..00baeb3605 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -64040,38 +64040,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -64085,7 +64085,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -64093,28 +64093,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -64122,26 +64122,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -64157,9 +64157,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -64170,88 +64170,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -64259,19 +64259,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -64280,146 +64280,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -64436,9 +64488,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -64458,14 +64508,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -64473,97 +64528,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -64586,410 +64637,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -64998,13 +65228,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -65013,131 +65243,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -65145,173 +65378,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -158271,6 +158510,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -158335,6 +158579,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -158472,6 +158717,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -158577,7 +158825,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -158726,6 +158974,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -158738,6 +158989,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -161506,7 +161760,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } var persistedInputsKey = "persisted_inputs"; var restoreInputs = function() { @@ -162110,6 +162364,36 @@ var featureConfig = { } }; +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache6()); diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index ae2184461f..aeaf1e7c63 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -17031,7 +17031,7 @@ var require_frame = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -38029,7 +38029,7 @@ var require_frame2 = __commonJS({ } catch { crypto2 = { // not full compatibility, but minimum. - randomFillSync: function randomFillSync2(buffer2, _offset, _size) { + randomFillSync: function randomFillSync(buffer2, _offset, _size) { for (let i = 0; i < buffer2.length; ++i) { buffer2[i] = Math.random() * 255 | 0; } @@ -53039,8 +53039,8 @@ var require_uuidUtils = __commonJS({ "node_modules/@typespec/ts-http-runtime/dist/commonjs/util/uuidUtils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomUUID = randomUUID2; - function randomUUID2() { + exports2.randomUUID = randomUUID; + function randomUUID() { return crypto.randomUUID(); } } @@ -57783,7 +57783,7 @@ var require_commonjs4 = __commonJS({ exports2.getRandomIntegerInclusive = getRandomIntegerInclusive; exports2.isError = isError; exports2.isObject = isObject3; - exports2.randomUUID = randomUUID2; + exports2.randomUUID = randomUUID; exports2.uint8ArrayToString = uint8ArrayToString; exports2.stringToUint8Array = stringToUint8Array; var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); @@ -57832,7 +57832,7 @@ var require_commonjs4 = __commonJS({ function isObject3(input) { return tspRuntime.isObject(input); } - function randomUUID2() { + function randomUUID() { return tspRuntime.randomUUID(); } exports2.isBrowser = tspRuntime.isBrowser; @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { 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(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, 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: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } @@ -100163,6 +100402,11 @@ var require_follow_redirects = __commonJS({ } catch (error3) { useNativeURL = error3.code === "ERR_INVALID_URL"; } + var sensitiveHeaders = [ + "Authorization", + "Proxy-Authorization", + "Cookie" + ]; var preservedUrlFields = [ "auth", "host", @@ -100227,6 +100471,7 @@ var require_follow_redirects = __commonJS({ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause })); } }; + this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i"); this._performRequest(); } RedirectableRequest.prototype = Object.create(Writable.prototype); @@ -100364,6 +100609,9 @@ var require_follow_redirects = __commonJS({ if (!options.headers) { options.headers = {}; } + if (!isArray(options.sensitiveHeaders)) { + options.sensitiveHeaders = []; + } if (options.host) { if (!options.hostname) { options.hostname = options.host; @@ -100469,7 +100717,7 @@ var require_follow_redirects = __commonJS({ this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { - removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers); + removeMatchingHeaders(this._headerFilter, this._options.headers); } if (isFunction(beforeRedirect)) { var responseDetails = { @@ -100618,6 +100866,9 @@ var require_follow_redirects = __commonJS({ var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } + function isArray(value) { + return value instanceof Array; + } function isString2(value) { return typeof value === "string" || value instanceof String; } @@ -100630,6 +100881,9 @@ var require_follow_redirects = __commonJS({ function isURL(value) { return URL2 && value instanceof URL2; } + function escapeRegex(regex) { + return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + } module2.exports = wrap({ http, https: https2 }); module2.exports.wrap = wrap; } @@ -106462,7 +106716,7 @@ function getDiffRangesJsonFilePath() { return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.35.2"; + return "4.35.3"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -106943,8 +107197,8 @@ var path5 = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.25.1"; -var cliVersion = "2.25.1"; +var bundleVersion = "codeql-bundle-v2.25.2"; +var cliVersion = "2.25.2"; // src/overlay/index.ts var fs4 = __toESM(require("fs")); @@ -108039,6 +108293,36 @@ ${jsonContents}` } } +// src/languages/builtin.json +var builtin_default = { + languages: [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + aliases: { + c: "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + kotlin: "java", + typescript: "javascript" + } +}; + +// src/languages/index.ts +var builtInLanguageSet = new Set(builtin_default.languages); + // src/overlay/status.ts var actionsCache = __toESM(require_cache5()); @@ -108599,22 +108883,18 @@ function unsafeStringify(arr, offset = 0) { } // node_modules/uuid/dist-node/rng.js -var import_node_crypto = require("node:crypto"); -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; +var rnds8 = new Uint8Array(16); function rng() { - if (poolPtr > rnds8Pool.length - 16) { - (0, import_node_crypto.randomFillSync)(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); + return crypto.getRandomValues(rnds8); } -// node_modules/uuid/dist-node/native.js -var import_node_crypto2 = require("node:crypto"); -var native_default = { randomUUID: import_node_crypto2.randomUUID }; - // node_modules/uuid/dist-node/v4.js +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} function _v4(options, buf, offset) { options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); @@ -108635,12 +108915,6 @@ function _v4(options, buf, offset) { } return unsafeStringify(rnds); } -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - return _v4(options, buf, offset); -} var v4_default = v4; // src/tar.ts diff --git a/package-lock.json b/package-lock.json index 09b0328d03..26e4a13078 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codeql", - "version": "4.35.2", + "version": "4.35.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codeql", - "version": "4.35.2", + "version": "4.35.3", "license": "MIT", "workspaces": [ "pr-checks" @@ -25,7 +25,7 @@ "@octokit/plugin-retry": "^8.1.0", "archiver": "^7.0.1", "fast-deep-equal": "^3.1.3", - "follow-redirects": "^1.15.11", + "follow-redirects": "^1.16.0", "get-folder-size": "^5.0.0", "https-proxy-agent": "^7.0.6", "js-yaml": "^4.1.1", @@ -33,11 +33,11 @@ "long": "^5.3.2", "node-forge": "^1.4.0", "semver": "^7.7.4", - "uuid": "^13.0.0" + "uuid": "^14.0.0" }, "devDependencies": { "@ava/typescript": "6.0.0", - "@eslint/compat": "^2.0.4", + "@eslint/compat": "^2.0.5", "@microsoft/eslint-formatter-sarif": "^3.1.0", "@octokit/types": "^16.0.0", "@types/archiver": "^7.0.0", @@ -51,17 +51,17 @@ "ava": "^7.0.0", "esbuild": "^0.28.0", "eslint": "^9.39.2", - "eslint-import-resolver-typescript": "^3.8.7", + "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-github": "^6.0.0", "eslint-plugin-import-x": "^4.16.2", "eslint-plugin-jsdoc": "^62.9.0", "eslint-plugin-no-async-foreach": "^0.1.1", "glob": "^11.1.0", - "globals": "^17.4.0", + "globals": "^17.5.0", "nock": "^14.0.12", - "sinon": "^21.0.3", + "sinon": "^21.1.2", "typescript": "^6.0.2", - "typescript-eslint": "^8.58.0" + "typescript-eslint": "^8.58.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1333,13 +1333,13 @@ } }, "node_modules/@eslint/compat": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-2.0.4.tgz", - "integrity": "sha512-o598tCGstJv9Kk4XapwP+oDij9HD9Qr3V37ABzTfdzVvbFciV+sfg9zSW6olj6G/IXj7p89SwSzPnZ+JUEPIPg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-2.0.5.tgz", + "integrity": "sha512-IbHDbHJfkVNv6xjlET8AIVo/K1NQt7YT4Rp6ok/clyBGcpRx1l6gv0Rq3vBvYfPJIZt6ODf66Zq08FJNDpnzgg==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^1.2.0" + "@eslint/core": "^1.2.1" }, "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" @@ -1988,6 +1988,18 @@ "@tybys/wasm-util": "^0.10.0" } }, + "node_modules/@nodable/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/nodable" + } + ], + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -2020,15 +2032,6 @@ "node": ">= 8" } }, - "node_modules/@nolyfill/is-core-module": { - "version": "1.0.39", - "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", - "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", - "dev": true, - "engines": { - "node": ">=12.4.0" - } - }, "node_modules/@octokit/auth-token": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", @@ -2400,9 +2403,9 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "15.1.1", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.1.1.tgz", - "integrity": "sha512-cO5W33JgAPbOh07tvZjUOJ7oWhtaqGHiZw+11DPbyqh2kHTBc3eF/CjJDeQ4205RLQsX6rxCuYOroFQwl7JDRw==", + "version": "15.3.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.3.2.tgz", + "integrity": "sha512-mrn35Jl2pCpns+mE3HaZa1yPN5EYCRgiMI+135COjr2hr8Cls9DXqIZ57vZe2cz7y2XVSq92tcs6kGQcT1J8Rw==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -2410,9 +2413,9 @@ } }, "node_modules/@sinonjs/samsam": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-9.0.3.tgz", - "integrity": "sha512-ZgYY7Dc2RW+OUdnZ1DEHg00lhRt+9BjymPKHog4PRFzr1U3MbK57+djmscWyKxzO1qfunHqs4N45WWyKIFKpiQ==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-10.0.2.tgz", + "integrity": "sha512-8lVwD1Df1BmzoaOLhMcGGcz/Jyr5QY2KSB75/YK1QgKzoabTeLdIVyhXNZK9ojfSKSdirbXqdbsXXqP9/Ve8+A==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -2549,17 +2552,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.58.0.tgz", - "integrity": "sha512-RLkVSiNuUP1C2ROIWfqX+YcUfLaSnxGE/8M+Y57lopVwg9VTYYfhuz15Yf1IzCKgZj6/rIbYTmJCUSqr76r0Wg==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.58.2.tgz", + "integrity": "sha512-aC2qc5thQahutKjP+cl8cgN9DWe3ZUqVko30CMSZHnFEHyhOYoZSzkGtAI2mcwZ38xeImDucI4dnqsHiOYuuCw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.58.0", - "@typescript-eslint/type-utils": "8.58.0", - "@typescript-eslint/utils": "8.58.0", - "@typescript-eslint/visitor-keys": "8.58.0", + "@typescript-eslint/scope-manager": "8.58.2", + "@typescript-eslint/type-utils": "8.58.2", + "@typescript-eslint/utils": "8.58.2", + "@typescript-eslint/visitor-keys": "8.58.2", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -2572,7 +2575,7 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.58.0", + "@typescript-eslint/parser": "^8.58.2", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } @@ -2588,16 +2591,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.58.0.tgz", - "integrity": "sha512-rLoGZIf9afaRBYsPUMtvkDWykwXwUPL60HebR4JgTI8mxfFe2cQTu3AGitANp4b9B2QlVru6WzjgB2IzJKiCSA==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.58.2.tgz", + "integrity": "sha512-/Zb/xaIDfxeJnvishjGdcR4jmr7S+bda8PKNhRGdljDM+elXhlvN0FyPSsMnLmJUrVG9aPO6dof80wjMawsASg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.58.0", - "@typescript-eslint/types": "8.58.0", - "@typescript-eslint/typescript-estree": "8.58.0", - "@typescript-eslint/visitor-keys": "8.58.0", + "@typescript-eslint/scope-manager": "8.58.2", + "@typescript-eslint/types": "8.58.2", + "@typescript-eslint/typescript-estree": "8.58.2", + "@typescript-eslint/visitor-keys": "8.58.2", "debug": "^4.4.3" }, "engines": { @@ -2631,14 +2634,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.58.0.tgz", - "integrity": "sha512-8Q/wBPWLQP1j16NxoPNIKpDZFMaxl7yWIoqXWYeWO+Bbd2mjgvoF0dxP2jKZg5+x49rgKdf7Ck473M8PC3V9lg==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.58.2.tgz", + "integrity": "sha512-Cq6UfpZZk15+r87BkIh5rDpi38W4b+Sjnb8wQCPPDDweS/LRCFjCyViEbzHk5Ck3f2QDfgmlxqSa7S7clDtlfg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.58.0", - "@typescript-eslint/types": "^8.58.0", + "@typescript-eslint/tsconfig-utils": "^8.58.2", + "@typescript-eslint/types": "^8.58.2", "debug": "^4.4.3" }, "engines": { @@ -2671,14 +2674,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.58.0.tgz", - "integrity": "sha512-W1Lur1oF50FxSnNdGp3Vs6P+yBRSmZiw4IIjEeYxd8UQJwhUF0gDgDD/W/Tgmh73mxgEU3qX0Bzdl/NGuSPEpQ==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.58.2.tgz", + "integrity": "sha512-SgmyvDPexWETQek+qzZnrG6844IaO02UVyOLhI4wpo82dpZJY9+6YZCKAMFzXb7qhx37mFK1QcPQ18tud+vo6Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.58.0", - "@typescript-eslint/visitor-keys": "8.58.0" + "@typescript-eslint/types": "8.58.2", + "@typescript-eslint/visitor-keys": "8.58.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2689,9 +2692,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.58.0.tgz", - "integrity": "sha512-doNSZEVJsWEu4htiVC+PR6NpM+pa+a4ClH9INRWOWCUzMst/VA9c4gXq92F8GUD1rwhNvRLkgjfYtFXegXQF7A==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.58.2.tgz", + "integrity": "sha512-3SR+RukipDvkkKp/d0jP0dyzuls3DbGmwDpVEc5wqk5f38KFThakqAAO0XMirWAE+kT00oTauTbzMFGPoAzB0A==", "dev": true, "license": "MIT", "engines": { @@ -2706,15 +2709,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.58.0.tgz", - "integrity": "sha512-aGsCQImkDIqMyx1u4PrVlbi/krmDsQUs4zAcCV6M7yPcPev+RqVlndsJy9kJ8TLihW9TZ0kbDAzctpLn5o+lOg==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.58.2.tgz", + "integrity": "sha512-Z7EloNR/B389FvabdGeTo2XMs4W9TjtPiO9DAsmT0yom0bwlPyRjkJ1uCdW1DvrrrYP50AJZ9Xc3sByZA9+dcg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.58.0", - "@typescript-eslint/typescript-estree": "8.58.0", - "@typescript-eslint/utils": "8.58.0", + "@typescript-eslint/types": "8.58.2", + "@typescript-eslint/typescript-estree": "8.58.2", + "@typescript-eslint/utils": "8.58.2", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -2749,9 +2752,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.58.0.tgz", - "integrity": "sha512-O9CjxypDT89fbHxRfETNoAnHj/i6IpRK0CvbVN3qibxlLdo5p5hcLmUuCCrHMpxiWSwKyI8mCP7qRNYuOJ0Uww==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.58.2.tgz", + "integrity": "sha512-9TukXyATBQf/Jq9AMQXfvurk+G5R2MwfqQGDR2GzGz28HvY/lXNKGhkY+6IOubwcquikWk5cjlgPvD2uAA7htQ==", "dev": true, "license": "MIT", "engines": { @@ -2763,16 +2766,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.58.0.tgz", - "integrity": "sha512-7vv5UWbHqew/dvs+D3e1RvLv1v2eeZ9txRHPnEEBUgSNLx5ghdzjHa0sgLWYVKssH+lYmV0JaWdoubo0ncGYLA==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.58.2.tgz", + "integrity": "sha512-ELGuoofuhhoCvNbQjFFiobFcGgcDCEm0ThWdmO4Z0UzLqPXS3KFvnEZ+SHewwOYHjM09tkzOWXNTv9u6Gqtyuw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.58.0", - "@typescript-eslint/tsconfig-utils": "8.58.0", - "@typescript-eslint/types": "8.58.0", - "@typescript-eslint/visitor-keys": "8.58.0", + "@typescript-eslint/project-service": "8.58.2", + "@typescript-eslint/tsconfig-utils": "8.58.2", + "@typescript-eslint/types": "8.58.2", + "@typescript-eslint/visitor-keys": "8.58.2", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -2848,16 +2851,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.58.0.tgz", - "integrity": "sha512-RfeSqcFeHMHlAWzt4TBjWOAtoW9lnsAGiP3GbaX9uVgTYYrMbVnGONEfUCiSss+xMHFl+eHZiipmA8WkQ7FuNA==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.58.2.tgz", + "integrity": "sha512-QZfjHNEzPY8+l0+fIXMvuQ2sJlplB4zgDZvA+NmvZsZv3EQwOcc1DuIU1VJUTWZ/RKouBMhDyNaBMx4sWvrzRA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.58.0", - "@typescript-eslint/types": "8.58.0", - "@typescript-eslint/typescript-estree": "8.58.0" + "@typescript-eslint/scope-manager": "8.58.2", + "@typescript-eslint/types": "8.58.2", + "@typescript-eslint/typescript-estree": "8.58.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2872,13 +2875,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.58.0.tgz", - "integrity": "sha512-XJ9UD9+bbDo4a4epraTwG3TsNPeiB9aShrUneAVXy8q4LuwowN+qu89/6ByLMINqvIMeI9H9hOHQtg/ijrYXzQ==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.58.2.tgz", + "integrity": "sha512-f1WO2Lx8a9t8DARmcWAUPJbu0G20bJlj8L4z72K00TMeJAoyLr/tHhI/pzYBLrR4dXWkcxO1cWYZEOX8DKHTqA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.58.0", + "@typescript-eslint/types": "8.58.2", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -4477,9 +4480,9 @@ } }, "node_modules/diff": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.3.tgz", - "integrity": "sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz", + "integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -4540,19 +4543,6 @@ "version": "8.0.0", "license": "MIT" }, - "node_modules/enhanced-resolve": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", - "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/es-abstract": { "version": "1.24.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", @@ -4873,24 +4863,25 @@ } }, "node_modules/eslint-import-resolver-typescript": { - "version": "3.8.7", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.8.7.tgz", - "integrity": "sha512-U7k84gOzrfl09c33qrIbD3TkWTWu3nt3dK5sDajHSekfoLlYGusIwSdPlPzVeA6TFpi0Wpj+ZdBD8hX4hxPoww==", + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-4.4.4.tgz", + "integrity": "sha512-1iM2zeBvrYmUNTj2vSC/90JTHDth+dfOfiNKkxApWRsTJYNrc8rOdxxIf5vazX+BiAXTeOT0UvWpGI/7qIWQOw==", "dev": true, + "license": "ISC", "dependencies": { - "@nolyfill/is-core-module": "1.0.39", - "debug": "^4.3.7", - "enhanced-resolve": "^5.15.0", - "get-tsconfig": "^4.10.0", - "is-bun-module": "^1.0.2", - "stable-hash": "^0.0.4", - "tinyglobby": "^0.2.12" + "debug": "^4.4.1", + "eslint-import-context": "^0.1.8", + "get-tsconfig": "^4.10.1", + "is-bun-module": "^2.0.0", + "stable-hash-x": "^0.2.0", + "tinyglobby": "^0.2.14", + "unrs-resolver": "^1.7.11" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^16.17.0 || >=18.6.0" }, "funding": { - "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" + "url": "https://opencollective.com/eslint-import-resolver-typescript" }, "peerDependencies": { "eslint": "*", @@ -5700,9 +5691,9 @@ "license": "MIT" }, "node_modules/fast-xml-builder": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", - "integrity": "sha512-f2jhpN4Eccy0/Uz9csxh3Nu6q4ErKxf0XIsasomfOihuSUa3/xw6w8dnOtCDgEItQFJG8KyXPzQXzcODDrrbOg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.5.tgz", + "integrity": "sha512-4TJn/8FKLeslLAH3dnohXqE3QSoxkhvaMzepOIZytwJXZO69Bfz0HBdDHzOTOon6G59Zrk6VQ2bEiv1t61rfkA==", "funding": [ { "type": "github", @@ -5715,9 +5706,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "5.5.7", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.7.tgz", - "integrity": "sha512-LteOsISQ2GEiDHZch6L9hB0+MLoYVLToR7xotrzU0opCICBkxOPgHAy1HxAvtxfJNXDJpgAsQN30mkrfpO2Prg==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.1.tgz", + "integrity": "sha512-8Cc3f8GUGUULg34pBch/KGyPLglS+OFs05deyOlY7fL2MTagYPKrVQNmR1fLF/yJ9PH5ZSTd3YDF6pnmeZU+zA==", "funding": [ { "type": "github", @@ -5726,9 +5717,10 @@ ], "license": "MIT", "dependencies": { - "fast-xml-builder": "^1.1.4", - "path-expression-matcher": "^1.1.3", - "strnum": "^2.2.0" + "@nodable/entities": "^2.1.0", + "fast-xml-builder": "^1.1.5", + "path-expression-matcher": "^1.5.0", + "strnum": "^2.2.3" }, "bin": { "fxparser": "src/cli/cli.js" @@ -5841,9 +5833,9 @@ "license": "ISC" }, "node_modules/follow-redirects": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", - "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", "funding": [ { "type": "individual", @@ -6148,9 +6140,9 @@ } }, "node_modules/globals": { - "version": "17.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-17.4.0.tgz", - "integrity": "sha512-hjrNztw/VajQwOLsMNT1cbJiH2muO3OROCHnbehc8eY5JyD2gqz4AcMHPqgaOR59DjgUjYAYLeH699g/eWi2jw==", + "version": "17.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.5.0.tgz", + "integrity": "sha512-qoV+HK2yFl/366t2/Cb3+xxPUo5BuMynomoDmiaZBIdbs+0pYbjfZU+twLhGKp4uCZ/+NbtpVepH5bGCxRyy2g==", "dev": true, "license": "MIT", "engines": { @@ -6581,12 +6573,13 @@ } }, "node_modules/is-bun-module": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.1.0.tgz", - "integrity": "sha512-4mTAVPlrXpaN3jtF0lsnPCMGnq4+qZjVIKq0HCpfcqf8OC1SM5oATCIAPM5V5FN05qp2NNnFndphmdZS9CV3hA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-2.0.0.tgz", + "integrity": "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==", "dev": true, + "license": "MIT", "dependencies": { - "semver": "^7.6.3" + "semver": "^7.7.1" } }, "node_modules/is-callable": { @@ -7860,9 +7853,9 @@ } }, "node_modules/path-expression-matcher": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.1.3.tgz", - "integrity": "sha512-qdVgY8KXmVdJZRSS1JdEPOKPdTiEK/pi0RkcT2sw1RhXxohdujUlJFPuS1TSkevZ9vzd3ZlL7ULl1MHGTApKzQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz", + "integrity": "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ==", "funding": [ { "type": "github", @@ -8532,17 +8525,16 @@ } }, "node_modules/sinon": { - "version": "21.0.3", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-21.0.3.tgz", - "integrity": "sha512-0x8TQFr8EjADhSME01u1ZK31yv2+bd6Z5NrBCHVM+n4qL1wFqbxftmeyi3bwlr49FbbzRfrqSFOpyHCOh/YmYA==", + "version": "21.1.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-21.1.2.tgz", + "integrity": "sha512-FS6mN+/bx7e2ajpXkEmOcWB6xBzWiuNoAQT18/+a20SS4U7FSYl8Ms7N6VTUxN/1JAjkx7aXp+THMC8xdpp0gA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^3.0.1", - "@sinonjs/fake-timers": "^15.1.1", - "@sinonjs/samsam": "^9.0.3", - "diff": "^8.0.3", - "supports-color": "^7.2.0" + "@sinonjs/fake-timers": "^15.3.2", + "@sinonjs/samsam": "^10.0.2", + "diff": "^8.0.4" }, "funding": { "type": "opencollective", @@ -8626,13 +8618,6 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, - "node_modules/stable-hash": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", - "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", - "dev": true, - "license": "MIT" - }, "node_modules/stable-hash-x": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", @@ -8863,9 +8848,9 @@ } }, "node_modules/strnum": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.1.tgz", - "integrity": "sha512-BwRvNd5/QoAtyW1na1y1LsJGQNvRlkde6Q/ipqqEaivoMdV+B1OMOTVdwR+N/cwVUcIt9PYyHmV8HyexCZSupg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz", + "integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==", "funding": [ { "type": "github", @@ -8988,15 +8973,6 @@ "url": "https://opencollective.com/unts" } }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/tar": { "version": "7.5.11", "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.11.tgz", @@ -9825,16 +9801,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.58.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.58.0.tgz", - "integrity": "sha512-e2TQzKfaI85fO+F3QywtX+tCTsu/D3WW5LVU6nz8hTFKFZ8yBJ6mSYRpXqdR3mFjPWmO0eWsTa5f+UpAOe/FMA==", + "version": "8.58.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.58.2.tgz", + "integrity": "sha512-V8iSng9mRbdZjl54VJ9NKr6ZB+dW0J3TzRXRGcSbLIej9jV86ZRtlYeTKDR/QLxXykocJ5icNzbsl2+5TzIvcQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.58.0", - "@typescript-eslint/parser": "8.58.0", - "@typescript-eslint/typescript-estree": "8.58.0", - "@typescript-eslint/utils": "8.58.0" + "@typescript-eslint/eslint-plugin": "8.58.2", + "@typescript-eslint/parser": "8.58.2", + "@typescript-eslint/typescript-estree": "8.58.2", + "@typescript-eslint/utils": "8.58.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -9999,9 +9975,9 @@ "license": "MIT" }, "node_modules/uuid": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", - "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz", + "integrity": "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" diff --git a/package.json b/package.json index 7a26e4b317..25b90b7b82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeql", - "version": "4.35.2", + "version": "4.35.3", "private": true, "description": "CodeQL action", "scripts": { @@ -12,7 +12,7 @@ "ava": "npm run transpile && ava --verbose", "test": "npm run ava -- src/", "test-debug": "npm run test -- --timeout=20m", - "transpile": "tsc --build --verbose" + "transpile": "tsc --build --verbose tsconfig.json" }, "license": "MIT", "workspaces": [ @@ -32,7 +32,7 @@ "@octokit/plugin-retry": "^8.1.0", "archiver": "^7.0.1", "fast-deep-equal": "^3.1.3", - "follow-redirects": "^1.15.11", + "follow-redirects": "^1.16.0", "get-folder-size": "^5.0.0", "https-proxy-agent": "^7.0.6", "js-yaml": "^4.1.1", @@ -40,11 +40,11 @@ "long": "^5.3.2", "node-forge": "^1.4.0", "semver": "^7.7.4", - "uuid": "^13.0.0" + "uuid": "^14.0.0" }, "devDependencies": { "@ava/typescript": "6.0.0", - "@eslint/compat": "^2.0.4", + "@eslint/compat": "^2.0.5", "@microsoft/eslint-formatter-sarif": "^3.1.0", "@octokit/types": "^16.0.0", "@types/archiver": "^7.0.0", @@ -58,17 +58,17 @@ "ava": "^7.0.0", "esbuild": "^0.28.0", "eslint": "^9.39.2", - "eslint-import-resolver-typescript": "^3.8.7", + "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-github": "^6.0.0", "eslint-plugin-import-x": "^4.16.2", "eslint-plugin-jsdoc": "^62.9.0", "eslint-plugin-no-async-foreach": "^0.1.1", "glob": "^11.1.0", - "globals": "^17.4.0", + "globals": "^17.5.0", "nock": "^14.0.12", - "sinon": "^21.0.3", + "sinon": "^21.1.2", "typescript": "^6.0.2", - "typescript-eslint": "^8.58.0" + "typescript-eslint": "^8.58.2" }, "overrides": { "@actions/tool-cache": { diff --git a/pr-checks/config.ts b/pr-checks/config.ts index 253843f226..92c8beef0a 100644 --- a/pr-checks/config.ts +++ b/pr-checks/config.ts @@ -11,3 +11,13 @@ export const PR_CHECK_EXCLUDED_FILE = path.join(PR_CHECKS_DIR, "excluded.yml"); /** The path to the esbuild metadata file. */ export const BUNDLE_METADATA_FILE = path.join(PR_CHECKS_DIR, "..", "meta.json"); + +/** The `src` directory. */ +const SOURCE_ROOT = path.join(PR_CHECKS_DIR, "..", "src"); + +/** The path to the built-in languages file. */ +export const BUILTIN_LANGUAGES_FILE = path.join( + SOURCE_ROOT, + "languages", + "builtin.json", +); diff --git a/pr-checks/sync.ts b/pr-checks/sync.ts index 8a1842323c..e46fca2483 100755 --- a/pr-checks/sync.ts +++ b/pr-checks/sync.ts @@ -5,7 +5,7 @@ import * as path from "path"; import * as yaml from "yaml"; -import { KnownLanguage } from "../src/languages"; +import { BuiltInLanguage } from "../src/languages"; /** Known workflow input names. */ enum KnownInputName { @@ -91,8 +91,8 @@ interface LanguageSetup { steps: Step[]; } -/** Describes partial mappings from known languages to their specific setup information. */ -type LanguageSetups = Partial>; +/** Describes partial mappings from built-in languages to their specific setup information. */ +type LanguageSetups = Partial>; // The default set of CodeQL Bundle versions to use for the PR checks. const defaultTestVersions = [ @@ -125,7 +125,7 @@ const defaultLanguageVersions = { java: "17", python: "3.13", csharp: "9.x", -} as const satisfies Partial>; +} as const satisfies Partial>; /** A mapping from known input names to their specifications. */ const inputSpecs: WorkflowInputs = { @@ -364,7 +364,7 @@ function getSetupSteps(checkSpecification: JobSpecification): { const inputs: Array> = []; const steps: Step[] = []; - for (const language of Object.values(KnownLanguage).sort()) { + for (const language of Object.values(BuiltInLanguage).sort()) { const setupSpec = languageSetups[language]; if ( diff --git a/pr-checks/update-builtin-languages.ts b/pr-checks/update-builtin-languages.ts new file mode 100644 index 0000000000..a7be6ed36f --- /dev/null +++ b/pr-checks/update-builtin-languages.ts @@ -0,0 +1,131 @@ +#!/usr/bin/env npx tsx + +/* + * Updates src/languages/builtin.json by querying the CodeQL CLI for: + * - Languages that have default queries (via codeql-extractor.yml) + * - Language aliases (via `codeql resolve languages --format=betterjson --extractor-include-aliases`) + * + * Usage: + * npx tsx pr-checks/update-builtin-languages.ts [path-to-codeql] + * + * If no path is given, falls back to "codeql". + */ + +import { execFileSync } from "node:child_process"; +import * as fs from "node:fs"; +import * as path from "node:path"; + +import * as yaml from "yaml"; + +import { EnvVar } from "../src/environment"; + +import { BUILTIN_LANGUAGES_FILE } from "./config"; + +/** Resolve all known language extractor directories. */ +function resolveLanguages(codeqlPath: string): Record { + return JSON.parse( + execFileSync(codeqlPath, ["resolve", "languages", "--format=json"], { + encoding: "utf8", + env: { + ...process.env, + [EnvVar.EXPERIMENTAL_FEATURES]: "true", // include experimental languages + }, + }), + ) as Record; +} + +/** + * Return the sorted list of languages whose extractors ship default queries. + * + * @param extractorDirs - Map from language to list of extractor directories + */ +function findLanguagesWithDefaultQueries( + extractorDirs: Record, +): string[] { + const languages: string[] = []; + + for (const [language, dirs] of Object.entries(extractorDirs)) { + if (dirs.length !== 1) { + throw new Error( + `Expected exactly one extractor directory for language '${language}', but found ${dirs.length}: ${dirs.join( + ", ", + )}`, + ); + } + + const extractorYmlPath = path.join(dirs[0], "codeql-extractor.yml"); + + if (!fs.existsSync(extractorYmlPath)) { + throw new Error( + `Extractor YAML not found for language '${language}' at expected path: ${extractorYmlPath}`, + ); + } + + const extractorYml = yaml.parse(fs.readFileSync(extractorYmlPath, "utf8")); + const defaultQueries: unknown[] | undefined = extractorYml.default_queries; + + if (Array.isArray(defaultQueries) && defaultQueries.length > 0) { + console.log( + ` ✅ ${language}: included (default queries: ${JSON.stringify(defaultQueries)})`, + ); + languages.push(language); + } else { + console.log(` ❌ ${language}: excluded (no default queries)`); + } + } + + return languages.sort(); +} + +/** + * Resolve language aliases from the CodeQL CLI, keeping only those whose + * target is in the given set of included languages. + */ +function resolveAliases( + codeqlPath: string, + includedLanguages: Set, +): Record { + const betterjsonOutput = JSON.parse( + execFileSync( + codeqlPath, + [ + "resolve", + "languages", + "--format=betterjson", + "--extractor-include-aliases", + ], + { encoding: "utf8" }, + ), + ); + + return Object.fromEntries( + Object.entries((betterjsonOutput.aliases ?? {}) as Record) + .filter(([, target]) => includedLanguages.has(target)) + .sort(([a], [b]) => a.localeCompare(b)), + ); +} + +/** Write the built-in languages data to disk. */ +function writeBuiltinLanguages( + languages: string[], + aliases: Record, +): void { + const content = `${JSON.stringify({ languages, aliases }, null, 2)}\n`; + fs.mkdirSync(path.dirname(BUILTIN_LANGUAGES_FILE), { recursive: true }); + fs.writeFileSync(BUILTIN_LANGUAGES_FILE, content); + + console.log(`\nWrote ${BUILTIN_LANGUAGES_FILE}`); + console.log(` Languages: ${languages.join(", ")}`); + console.log(` Aliases: ${Object.keys(aliases).join(", ")}`); +} + +function main(): void { + const codeqlPath = process.argv[2] || "codeql"; + + const extractorDirs = resolveLanguages(codeqlPath); + const languages = findLanguagesWithDefaultQueries(extractorDirs); + const aliases = resolveAliases(codeqlPath, new Set(languages)); + writeBuiltinLanguages(languages, aliases); +} + +main(); diff --git a/src/analyze-action.ts b/src/analyze-action.ts index f146950d30..7f43961392 100644 --- a/src/analyze-action.ts +++ b/src/analyze-action.ts @@ -30,7 +30,7 @@ import { } from "./dependency-caching"; import { EnvVar } from "./environment"; import { initFeatures } from "./feature-flags"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getActionsLogger, Logger } from "./logging"; import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay/caching"; import { getRepositoryNwo } from "./repository"; @@ -135,9 +135,13 @@ function hasBadExpectErrorInput(): boolean { function doesGoExtractionOutputExist(config: Config): boolean { const golangDbDirectory = util.getCodeQLDatabasePath( config, - KnownLanguage.go, + BuiltInLanguage.go, + ); + const trapDirectory = path.join( + golangDbDirectory, + "trap", + BuiltInLanguage.go, ); - const trapDirectory = path.join(golangDbDirectory, "trap", KnownLanguage.go); return ( fs.existsSync(trapDirectory) && fs @@ -169,7 +173,7 @@ function doesGoExtractionOutputExist(config: Config): boolean { * whether any extraction output already exists for Go. */ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) { - if (!config.languages.includes(KnownLanguage.go)) { + if (!config.languages.includes(BuiltInLanguage.go)) { return; } if (config.buildMode) { @@ -182,7 +186,7 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) { logger.debug("Won't run Go autobuild since it has already been run."); return; } - if (dbIsFinalized(config, KnownLanguage.go, logger)) { + if (dbIsFinalized(config, BuiltInLanguage.go, logger)) { logger.debug( "Won't run Go autobuild since there is already a finalized database for Go.", ); @@ -205,7 +209,7 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) { logger.debug( "Running Go autobuild because extraction output (TRAP files) for Go code has not been found.", ); - await runAutobuild(config, KnownLanguage.go, logger); + await runAutobuild(config, BuiltInLanguage.go, logger); } async function run(startedAt: Date) { diff --git a/src/analyze.test.ts b/src/analyze.test.ts index 0749a0cc26..7523d239bf 100644 --- a/src/analyze.test.ts +++ b/src/analyze.test.ts @@ -14,7 +14,7 @@ import { } from "./analyze"; import { createStubCodeQL } from "./codeql"; import { Feature } from "./feature-flags"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getRunnerLogger } from "./logging"; import { setupTests, @@ -41,7 +41,7 @@ test.serial("status report fields", async (t) => { const threadsFlag = ""; sinon.stub(uploadLib, "validateSarifFileSchema"); - for (const language of Object.values(KnownLanguage)) { + for (const language of Object.values(BuiltInLanguage)) { const codeql = createStubCodeQL({ databaseRunQueries: async () => {}, databaseInterpretResults: async ( @@ -130,13 +130,13 @@ test.serial("status report fields", async (t) => { test("resolveQuerySuiteAlias", (t) => { // default query suite names should resolve to something language-specific ending in `.qls`. for (const suite of defaultSuites) { - const resolved = resolveQuerySuiteAlias(KnownLanguage.go, suite); + const resolved = resolveQuerySuiteAlias(BuiltInLanguage.go, suite); t.assert( path.extname(resolved) === ".qls", "Resolved default suite doesn't end in .qls", ); t.assert( - resolved.indexOf(KnownLanguage.go) >= 0, + resolved.indexOf(BuiltInLanguage.go) >= 0, "Resolved default suite doesn't contain language name", ); } @@ -145,12 +145,12 @@ test("resolveQuerySuiteAlias", (t) => { const names = ["foo", "bar", "codeql/go-queries@1.0"]; for (const name of names) { - t.deepEqual(resolveQuerySuiteAlias(KnownLanguage.go, name), name); + t.deepEqual(resolveQuerySuiteAlias(BuiltInLanguage.go, name), name); } }); test("addSarifExtension", (t) => { - for (const language of Object.values(KnownLanguage)) { + for (const language of Object.values(BuiltInLanguage)) { t.deepEqual(addSarifExtension(CodeScanning, language), `${language}.sarif`); t.deepEqual( addSarifExtension(CodeQuality, language), diff --git a/src/analyze.ts b/src/analyze.ts index f048a10d11..63830445d2 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -21,7 +21,7 @@ import { } from "./diff-informed-analysis-utils"; import { EnvVar } from "./environment"; import { FeatureEnablement, Feature } from "./feature-flags"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { Logger, withGroupAsync } from "./logging"; import { OverlayDatabaseMode } from "./overlay/overlay-database-mode"; import type * as sarif from "./sarif"; @@ -41,7 +41,7 @@ export class CodeQLAnalysisError extends Error { } } -type KnownLanguageKey = keyof typeof KnownLanguage; +type BuiltInLanguageKey = keyof typeof BuiltInLanguage; type RunQueriesDurationStatusReport = { /** @@ -50,12 +50,12 @@ type RunQueriesDurationStatusReport = { * The "builtin" designation is now outdated with the move to CLI config parsing: this is the time * taken to run _all_ the queries. */ - [L in KnownLanguageKey as `analyze_builtin_queries_${L}_duration_ms`]?: number; + [L in BuiltInLanguageKey as `analyze_builtin_queries_${L}_duration_ms`]?: number; }; type InterpretResultsDurationStatusReport = { /** Time taken in ms to interpret results for the language (or undefined if this language was not analyzed). */ - [L in KnownLanguageKey as `interpret_results_${L}_duration_ms`]?: number; + [L in BuiltInLanguageKey as `interpret_results_${L}_duration_ms`]?: number; }; export interface QueriesStatusReport @@ -115,12 +115,12 @@ export async function runExtraction( if (await shouldExtractLanguage(codeql, config, language)) { logger.startGroup(`Extracting ${language}`); - if (language === KnownLanguage.python) { + if (language === BuiltInLanguage.python) { await setupPythonExtractor(logger); } if (config.buildMode) { if ( - language === KnownLanguage.cpp && + language === BuiltInLanguage.cpp && config.buildMode === BuildMode.Autobuild ) { await setupCppAutobuild(codeql, logger); @@ -131,14 +131,14 @@ export async function runExtraction( // a stable path that caches can be restored into and that we can cache at the // end of the workflow (i.e. that does not get removed when the scratch directory is). if ( - language === KnownLanguage.java && + language === BuiltInLanguage.java && config.buildMode === BuildMode.None ) { process.env["CODEQL_EXTRACTOR_JAVA_OPTION_BUILDLESS_DEPENDENCY_DIR"] = getJavaTempDependencyDir(); } if ( - language === KnownLanguage.csharp && + language === BuiltInLanguage.csharp && config.buildMode === BuildMode.None && (await features.getValue(Feature.CsharpCacheBuildModeNone)) ) { @@ -251,16 +251,9 @@ export async function setupDiffInformedQueryRun( diffRanges, checkoutPath, ); - if (packDir === undefined) { - logger.warning( - "Cannot create diff range extension pack for diff-informed queries; " + - "reverting to performing full analysis.", - ); - } else { - logger.info( - `Successfully created diff range extension pack at ${packDir}.`, - ); - } + logger.info( + `Successfully created diff range extension pack at ${packDir}.`, + ); return packDir; }, ); @@ -314,18 +307,13 @@ extensions: * @param ranges The file line ranges, as returned by * `getPullRequestEditedDiffRanges`. * @param checkoutPath The path at which the repository was checked out. - * @returns The absolute path of the directory containing the extension pack, or - * `undefined` if no extension pack was created. + * @returns The absolute path of the directory containing the extension pack. */ function writeDiffRangeDataExtensionPack( logger: Logger, - ranges: DiffThunkRange[] | undefined, + ranges: DiffThunkRange[], checkoutPath: string, -): string | undefined { - if (ranges === undefined) { - return undefined; - } - +): string { if (ranges.length === 0) { // An empty diff range means that there are no added or modified lines in // the pull request. But the `restrictAlertsTo` extensible predicate @@ -698,7 +686,7 @@ export async function warnIfGoInstalledAfterInit( addDiagnostic( config, - KnownLanguage.go, + BuiltInLanguage.go, makeDiagnostic( "go/workflow/go-installed-after-codeql-init", "Go was installed after the `codeql-action/init` Action was run", diff --git a/src/autobuild.ts b/src/autobuild.ts index 46935bba67..fc4983f4ef 100644 --- a/src/autobuild.ts +++ b/src/autobuild.ts @@ -7,7 +7,7 @@ import * as configUtils from "./config-utils"; import { DocUrl } from "./doc-url"; import { EnvVar } from "./environment"; import { Feature, featureConfig, initFeatures } from "./feature-flags"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { Logger } from "./logging"; import { getRepositoryNwo } from "./repository"; import { asyncFilter, BuildMode } from "./util"; @@ -72,7 +72,7 @@ export async function determineAutobuildLanguages( * version of the CodeQL Action. */ const autobuildLanguagesWithoutGo = autobuildLanguages.filter( - (l) => l !== KnownLanguage.go, + (l) => l !== BuiltInLanguage.go, ); const languages: Language[] = []; @@ -84,7 +84,7 @@ export async function determineAutobuildLanguages( // If Go is requested, run the Go autobuilder last to ensure it doesn't // interfere with the other autobuilder. if (autobuildLanguages.length !== autobuildLanguagesWithoutGo.length) { - languages.push(KnownLanguage.go); + languages.push(BuiltInLanguage.go); } logger.debug(`Will autobuild ${languages.join(" and ")}.`); @@ -156,7 +156,7 @@ export async function runAutobuild( ) { logger.startGroup(`Attempting to automatically build ${language} code`); const codeQL = await getCodeQL(config.codeQLCmd); - if (language === KnownLanguage.cpp) { + if (language === BuiltInLanguage.cpp) { await setupCppAutobuild(codeQL, logger); } if (config.buildMode) { @@ -164,7 +164,7 @@ export async function runAutobuild( } else { await codeQL.runAutobuild(config, language); } - if (language === KnownLanguage.go) { + if (language === BuiltInLanguage.go) { core.exportVariable(EnvVar.DID_AUTOBUILD_GOLANG, "true"); } logger.endGroup(); diff --git a/src/codeql.test.ts b/src/codeql.test.ts index cfbddf4f78..eccad6895b 100644 --- a/src/codeql.test.ts +++ b/src/codeql.test.ts @@ -21,7 +21,7 @@ import { import type { Config } from "./config-utils"; import * as defaults from "./defaults.json"; import { DocUrl } from "./doc-url"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getRunnerLogger } from "./logging"; import { ToolsSource } from "./setup-codeql"; import { @@ -46,7 +46,7 @@ test.beforeEach(() => { initializeEnvironment("1.2.3"); stubConfig = createTestConfig({ - languages: [KnownLanguage.cpp], + languages: [BuiltInLanguage.cpp], }); }); @@ -115,7 +115,7 @@ async function stubCodeql(): Promise { sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.17.6")); sinon .stub(codeqlObject, "isTracedLanguage") - .withArgs(KnownLanguage.cpp) + .withArgs(BuiltInLanguage.cpp) .resolves(true); return codeqlObject; } @@ -956,7 +956,8 @@ test.serial("runTool summarizes autobuilder errors", async (t) => { sinon.stub(io, "which").resolves(""); await t.throwsAsync( - async () => await codeqlObject.runAutobuild(stubConfig, KnownLanguage.java), + async () => + await codeqlObject.runAutobuild(stubConfig, BuiltInLanguage.java), { instanceOf: util.ConfigurationError, message: @@ -982,7 +983,8 @@ test.serial("runTool truncates long autobuilder errors", async (t) => { sinon.stub(io, "which").resolves(""); await t.throwsAsync( - async () => await codeqlObject.runAutobuild(stubConfig, KnownLanguage.java), + async () => + await codeqlObject.runAutobuild(stubConfig, BuiltInLanguage.java), { instanceOf: util.ConfigurationError, message: diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index e6485528f2..25aa414334 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -18,7 +18,7 @@ import { Feature } from "./feature-flags"; import { RepositoryProperties } from "./feature-flags/properties"; import * as gitUtils from "./git-utils"; import { GitVersionInfo } from "./git-utils"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { getRunnerLogger } from "./logging"; import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay"; import { OverlayDisabledReason } from "./overlay/diagnostics"; @@ -215,7 +215,7 @@ test.serial("load code quality config", async (t) => { // And the config we expect it to result in const expectedConfig = createTestConfig({ analysisKinds: [AnalysisKind.CodeQuality], - languages: [KnownLanguage.actions], + languages: [BuiltInLanguage.actions], // This gets set because we only have `AnalysisKind.CodeQuality` computedConfig: { "disable-default-queries": true, @@ -268,7 +268,7 @@ test.serial( const expectedConfig = createTestConfig({ analysisKinds: [AnalysisKind.CodeQuality], - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], codeQLCmd: codeql.getPath(), computedConfig, dbLocation: path.resolve(tempDir, "codeql_databases"), @@ -518,7 +518,7 @@ test.serial("load non-empty input", async (t) => { // And the config we expect it to parse to const expectedConfig = createTestConfig({ - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], buildMode: BuildMode.None, originalUserInput: userConfig, computedConfig: userConfig, @@ -892,10 +892,10 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo"); betterResolveLanguages: (options) => Promise.resolve({ aliases: { - "c#": KnownLanguage.csharp, - c: KnownLanguage.cpp, - kotlin: KnownLanguage.java, - typescript: KnownLanguage.javascript, + "c#": BuiltInLanguage.csharp, + c: BuiltInLanguage.cpp, + kotlin: BuiltInLanguage.java, + typescript: BuiltInLanguage.javascript, }, extractors: { cpp: [stubExtractorEntry], @@ -944,12 +944,12 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo"); for (const { displayName, language, feature } of [ { displayName: "Java", - language: KnownLanguage.java, + language: BuiltInLanguage.java, feature: Feature.DisableJavaBuildlessEnabled, }, { displayName: "C#", - language: KnownLanguage.csharp, + language: BuiltInLanguage.csharp, feature: Feature.DisableCsharpBuildless, }, ]) { @@ -969,7 +969,7 @@ for (const { displayName, language, feature } of [ const messages: LoggedMessage[] = []; const buildMode = await configUtils.parseBuildModeInput( "none", - [KnownLanguage.python], + [BuiltInLanguage.python], createFeatures([feature]), getRecordingLogger(messages), ); @@ -1019,7 +1019,7 @@ const defaultOverlayDatabaseModeTestSetup: OverlayDatabaseModeTestSetup = { isPullRequest: false, isDefaultBranch: false, buildMode: BuildMode.None, - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], codeqlVersion: CODEQL_OVERLAY_MINIMUM_VERSION, gitRoot: "/some/git/root", gitVersion: new GitVersionInfo("2.39.0", "2.39.0"), @@ -1091,7 +1091,7 @@ const checkOverlayEnablementMacro = test.macro({ sinon .stub(codeql, "isTracedLanguage") .callsFake(async (lang: Language) => { - return [KnownLanguage.java].includes(lang as KnownLanguage); + return lang === BuiltInLanguage.java; }); // Mock git root detection @@ -1184,7 +1184,7 @@ test.serial( checkOverlayEnablementMacro, "Ignore feature flag when analyzing non-default branch", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], }, { @@ -1196,7 +1196,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch when feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], isDefaultBranch: true, }, @@ -1210,7 +1210,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch when feature enabled with custom analysis", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], codeScanningConfig: { packs: ["some-custom-pack@1.0.0"], @@ -1227,7 +1227,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch when code-scanning feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1244,7 +1244,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch if runner disk space is too low", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1264,7 +1264,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch if we can't determine runner disk space", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1281,7 +1281,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch if runner disk space is too low and skip resource checks flag is enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1303,7 +1303,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch if runner disk space is below v2 limit and v2 resource checks enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1324,7 +1324,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1346,7 +1346,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks not enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1366,7 +1366,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch if memory flag is too low", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1383,7 +1383,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch if memory flag is too low but CodeQL >= 2.24.3", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1402,7 +1402,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay-base database on default branch if memory flag is too low and skip resource checks flag is enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1421,7 +1421,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when cached status indicates previous failure", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript, @@ -1439,7 +1439,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when cached status indicates previous failure", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript, @@ -1457,7 +1457,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1476,7 +1476,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when code-scanning feature enabled with packs", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1495,7 +1495,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when code-scanning feature enabled with queries", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1514,7 +1514,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when code-scanning feature enabled with query-filters", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1533,7 +1533,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when only language-specific feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysisJavascript], isDefaultBranch: true, }, @@ -1546,7 +1546,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when only code-scanning feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysisCodeScanningJavascript], isDefaultBranch: true, }, @@ -1559,7 +1559,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay-base database on default branch when language-specific feature disabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis], isDefaultBranch: true, }, @@ -1572,7 +1572,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR when feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], isPullRequest: true, }, @@ -1586,7 +1586,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR when feature enabled with custom analysis", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], codeScanningConfig: { packs: ["some-custom-pack@1.0.0"], @@ -1603,7 +1603,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR when code-scanning feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1620,7 +1620,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR if runner disk space is too low", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1640,7 +1640,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR if runner disk space is too low and skip resource checks flag is enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1662,7 +1662,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR if we can't determine runner disk space", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1679,7 +1679,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR if memory flag is too low", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1696,7 +1696,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR if memory flag is too low but CodeQL >= 2.24.3", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1715,7 +1715,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay analysis on PR if memory flag is too low and skip resource checks flag is enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1734,7 +1734,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when code-scanning feature enabled with disable-default-queries", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1753,7 +1753,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when code-scanning feature enabled with packs", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1772,7 +1772,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when code-scanning feature enabled with queries", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1791,7 +1791,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when code-scanning feature enabled with query-filters", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [ Feature.OverlayAnalysis, Feature.OverlayAnalysisCodeScanningJavascript, @@ -1810,7 +1810,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when only language-specific feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysisJavascript], isPullRequest: true, }, @@ -1823,7 +1823,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when only code-scanning feature enabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysisCodeScanningJavascript], isPullRequest: true, }, @@ -1836,7 +1836,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis on PR when language-specific feature disabled", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis], isPullRequest: true, }, @@ -1874,7 +1874,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay PR analysis by feature flag", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], isPullRequest: true, }, @@ -1890,7 +1890,7 @@ test.serial( { overlayDatabaseEnvVar: "overlay", buildMode: BuildMode.Autobuild, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], }, { disabledReason: OverlayDisabledReason.IncompatibleBuildMode, @@ -1903,7 +1903,7 @@ test.serial( { overlayDatabaseEnvVar: "overlay", buildMode: undefined, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], }, { disabledReason: OverlayDisabledReason.IncompatibleBuildMode, @@ -1978,7 +1978,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay when disabled via repository property", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], isPullRequest: true, repositoryProperties: { @@ -1994,7 +1994,7 @@ test.serial( checkOverlayEnablementMacro, "Overlay not disabled when repository property is false", { - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript], isPullRequest: true, repositoryProperties: { @@ -2023,7 +2023,7 @@ test.serial( ); // Exercise language-specific overlay analysis features code paths -for (const language in KnownLanguage) { +for (const language in BuiltInLanguage) { test.serial( checkOverlayEnablementMacro, `Check default overlay analysis feature for ${language}`, @@ -2046,7 +2046,7 @@ test.serial( checkOverlayEnablementMacro, "No overlay analysis for language without per-language overlay feature flag", { - languages: [KnownLanguage.swift], + languages: [BuiltInLanguage.swift], features: [Feature.OverlayAnalysis], isPullRequest: true, }, diff --git a/src/config-utils.ts b/src/config-utils.ts index e8d2ef8e1d..0b07010070 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -48,7 +48,7 @@ import { hasSubmodules, isAnalyzingDefaultBranch, } from "./git-utils"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { Logger } from "./logging"; import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay"; import { @@ -274,10 +274,10 @@ async function getSupportedLanguageMap( for (const extractor of Object.keys(resolveResult.extractors)) { // If the CLI supports resolving languages with default queries, use these // as the set of supported languages. Otherwise, require the language to be - // a known language. + // a built-in language. if ( resolveSupportedLanguagesUsingCli || - KnownLanguage[extractor] !== undefined + BuiltInLanguage[extractor] !== undefined ) { supportedLanguages[extractor] = extractor; } @@ -947,7 +947,7 @@ async function validateOverlayDatabaseMode( await Promise.all( languages.map( async (l) => - l !== KnownLanguage.go && // Workaround to allow overlay analysis for Go with any build + l !== BuiltInLanguage.go && // Workaround to allow overlay analysis for Go with any build // mode, since it does not yet support BMN. The Go autobuilder and/or extractor will // ensure that overlay-base databases are only created for supported Go build setups, // and that we'll fall back to full databases in other cases. @@ -1036,13 +1036,13 @@ async function setCppTrapCachingEnvironmentVariables( config: Config, logger: Logger, ): Promise { - if (config.languages.includes(KnownLanguage.cpp)) { + if (config.languages.includes(BuiltInLanguage.cpp)) { const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING"; if (process.env[envVar]) { logger.info( `Environment variable ${envVar} already set, leaving it unchanged.`, ); - } else if (config.trapCaches[KnownLanguage.cpp]) { + } else if (config.trapCaches[BuiltInLanguage.cpp]) { logger.info("Enabling TRAP caching for C/C++."); core.exportVariable(envVar, "true"); } else { @@ -1539,7 +1539,7 @@ export async function parseBuildModeInput( } if ( - languages.includes(KnownLanguage.csharp) && + languages.includes(BuiltInLanguage.csharp) && (await features.getValue(Feature.DisableCsharpBuildless)) ) { logger.warning( @@ -1549,7 +1549,7 @@ export async function parseBuildModeInput( } if ( - languages.includes(KnownLanguage.java) && + languages.includes(BuiltInLanguage.java) && (await features.getValue(Feature.DisableJavaBuildlessEnabled)) ) { logger.warning( diff --git a/src/config/db-config.test.ts b/src/config/db-config.test.ts index d7ff48eed8..d0c11d268e 100644 --- a/src/config/db-config.test.ts +++ b/src/config/db-config.test.ts @@ -1,7 +1,7 @@ import test, { ExecutionContext } from "ava"; import { RepositoryProperties } from "../feature-flags/properties"; -import { KnownLanguage, Language } from "../languages"; +import { BuiltInLanguage, Language } from "../languages"; import { getRunnerLogger } from "../logging"; import { checkExpectedLogMessages, @@ -54,7 +54,7 @@ const invalidPackNameMacro = test.macro({ parsePacksErrorMacro.exec( t, name, - [KnownLanguage.cpp], + [BuiltInLanguage.cpp], new RegExp(`^"${name}" is not a valid pack$`), ), title: (_providedTitle: string | undefined, arg: string | undefined) => @@ -62,23 +62,23 @@ const invalidPackNameMacro = test.macro({ }); test("no packs", parsePacksMacro, "", [], undefined); -test("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [KnownLanguage.cpp], { - [KnownLanguage.cpp]: ["a/b", "c/d@1.2.3"], +test("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [BuiltInLanguage.cpp], { + [BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"], }); test( "two packs with spaces", parsePacksMacro, " a/b , c/d@1.2.3 ", - [KnownLanguage.cpp], + [BuiltInLanguage.cpp], { - [KnownLanguage.cpp]: ["a/b", "c/d@1.2.3"], + [BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"], }, ); test( "two packs with language", parsePacksErrorMacro, "a/b,c/d@1.2.3", - [KnownLanguage.cpp, KnownLanguage.java], + [BuiltInLanguage.cpp, BuiltInLanguage.java], new RegExp( "Cannot specify a 'packs' input in a multi-language analysis. " + "Use a codeql-config.yml file instead and specify packs by language.", @@ -106,9 +106,9 @@ test( // (globbing is not done) "c/d@1.2.3:+*)_(", ].join(","), - [KnownLanguage.cpp], + [BuiltInLanguage.cpp], { - [KnownLanguage.cpp]: [ + [BuiltInLanguage.cpp]: [ "c/d@1.0", "c/d@~1.0.0", "c/d@~1.0.0:a/b", @@ -215,7 +215,7 @@ test( "All empty", undefined, undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, { ...dbConfig.defaultAugmentationProperties, @@ -227,7 +227,7 @@ test( "With queries", undefined, " a, b , c, d", - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, { ...dbConfig.defaultAugmentationProperties, @@ -240,7 +240,7 @@ test( "With queries combining", undefined, " + a, b , c, d ", - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, { ...dbConfig.defaultAugmentationProperties, @@ -254,7 +254,7 @@ test( "With packs", " codeql/a , codeql/b , codeql/c , codeql/d ", undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, { ...dbConfig.defaultAugmentationProperties, @@ -267,7 +267,7 @@ test( "With packs combining", " + codeql/a, codeql/b, codeql/c, codeql/d", undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, { ...dbConfig.defaultAugmentationProperties, @@ -281,7 +281,7 @@ test( "With repo property queries", undefined, undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], { "github-codeql-extra-queries": "a, b, c, d", }, @@ -299,7 +299,7 @@ test( "With repo property queries combining", undefined, undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], { "github-codeql-extra-queries": "+ a, b, c, d", }, @@ -341,7 +341,7 @@ test( "Plus (+) with nothing else (queries)", undefined, " + ", - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, /The workflow property "queries" is invalid/, ); @@ -351,7 +351,7 @@ test( "Plus (+) with nothing else (packs)", " + ", undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, /The workflow property "packs" is invalid/, ); @@ -361,7 +361,7 @@ test( "Plus (+) with nothing else (repo property queries)", undefined, undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], { "github-codeql-extra-queries": " + ", }, @@ -373,7 +373,7 @@ test( "Packs input with multiple languages", " + a/b, c/d ", undefined, - [KnownLanguage.javascript, KnownLanguage.java], + [BuiltInLanguage.javascript, BuiltInLanguage.java], {}, /Cannot specify a 'packs' input in a multi-language analysis/, ); @@ -393,7 +393,7 @@ test( "Invalid packs", " a-pack-without-a-scope ", undefined, - [KnownLanguage.javascript], + [BuiltInLanguage.javascript], {}, /"a-pack-without-a-scope" is not a valid pack/, ); diff --git a/src/database-upload.test.ts b/src/database-upload.test.ts index c4ac59e76b..1cfbaecad6 100644 --- a/src/database-upload.test.ts +++ b/src/database-upload.test.ts @@ -12,7 +12,7 @@ import { createStubCodeQL } from "./codeql"; import { Config } from "./config-utils"; import { cleanupAndUploadDatabases } from "./database-upload"; import * as gitUtils from "./git-utils"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { RepositoryNwo } from "./repository"; import { checkExpectedLogMessages, @@ -45,7 +45,7 @@ const testApiDetails: GitHubApiDetails = { function getTestConfig(tmpDir: string): Config { return createTestConfig({ - languages: [KnownLanguage.javascript], + languages: [BuiltInLanguage.javascript], dbLocation: tmpDir, }); } diff --git a/src/defaults.json b/src/defaults.json index 33f577571a..cd7499eb29 100644 --- a/src/defaults.json +++ b/src/defaults.json @@ -1,6 +1,6 @@ { - "bundleVersion": "codeql-bundle-v2.25.1", - "cliVersion": "2.25.1", - "priorBundleVersion": "codeql-bundle-v2.24.3", - "priorCliVersion": "2.24.3" + "bundleVersion": "codeql-bundle-v2.25.2", + "cliVersion": "2.25.2", + "priorBundleVersion": "codeql-bundle-v2.25.1", + "priorCliVersion": "2.25.1" } diff --git a/src/dependency-caching.test.ts b/src/dependency-caching.test.ts index a2d75190d1..e611cd03eb 100644 --- a/src/dependency-caching.test.ts +++ b/src/dependency-caching.test.ts @@ -27,7 +27,7 @@ import { CacheStoreResult, } from "./dependency-caching"; import { Feature } from "./feature-flags"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { setupTests, createFeatures, @@ -179,7 +179,7 @@ test("checkHashPatterns - logs when no patterns match", async (t) => { const result = await checkHashPatterns( codeql, features, - KnownLanguage.csharp, + BuiltInLanguage.csharp, config, "download", getRecordingLogger(messages), @@ -208,7 +208,7 @@ test("checkHashPatterns - returns patterns when patterns match", async (t) => { const result = await checkHashPatterns( codeql, features, - KnownLanguage.csharp, + BuiltInLanguage.csharp, config, "upload", getRecordingLogger(messages), @@ -270,7 +270,7 @@ test.serial( const keyWithFeature = await cacheKey( codeql, createFeatures([Feature.CsharpNewCacheKey]), - KnownLanguage.csharp, + BuiltInLanguage.csharp, // Patterns don't matter here because we have stubbed `hashFiles` to always return a specific hash above. [], ); @@ -288,12 +288,12 @@ test.serial( const result = await downloadDependencyCaches( codeql, createFeatures([]), - [KnownLanguage.csharp], + [BuiltInLanguage.csharp], logger, ); const statusReport = result.statusReport; t.is(statusReport.length, 1); - t.is(statusReport[0].language, KnownLanguage.csharp); + t.is(statusReport[0].language, BuiltInLanguage.csharp); t.is(statusReport[0].hit_kind, CacheHitKind.Miss); t.deepEqual(result.restoredKeys, []); t.assert(restoreCacheStub.calledOnce); @@ -316,7 +316,7 @@ test.serial( const keyWithFeature = await cacheKey( codeql, features, - KnownLanguage.csharp, + BuiltInLanguage.csharp, // Patterns don't matter here because we have stubbed `hashFiles` to always return a specific hash above. [], ); @@ -334,14 +334,14 @@ test.serial( const result = await downloadDependencyCaches( codeql, features, - [KnownLanguage.csharp], + [BuiltInLanguage.csharp], logger, ); // Check that the status report for telemetry indicates that one cache was restored with an exact match. const statusReport = result.statusReport; t.is(statusReport.length, 1); - t.is(statusReport[0].language, KnownLanguage.csharp); + t.is(statusReport[0].language, BuiltInLanguage.csharp); t.is(statusReport[0].hit_kind, CacheHitKind.Exact); // Check that the restored key has been returned. @@ -380,7 +380,7 @@ test.serial( const keyWithFeature = await cacheKey( codeql, features, - KnownLanguage.csharp, + BuiltInLanguage.csharp, // Patterns don't matter here because we have stubbed `hashFiles` to always return a specific hash above. [], ); @@ -398,14 +398,14 @@ test.serial( const result = await downloadDependencyCaches( codeql, features, - [KnownLanguage.csharp], + [BuiltInLanguage.csharp], logger, ); // Check that the status report for telemetry indicates that one cache was restored with a partial match. const statusReport = result.statusReport; t.is(statusReport.length, 1); - t.is(statusReport[0].language, KnownLanguage.csharp); + t.is(statusReport[0].language, BuiltInLanguage.csharp); t.is(statusReport[0].hit_kind, CacheHitKind.Partial); // Check that the restored key has been returned. @@ -426,7 +426,7 @@ test("uploadDependencyCaches - skips upload for a language with no cache config" const logger = getRecordingLogger(messages); const features = createFeatures([]); const config = createTestConfig({ - languages: [KnownLanguage.actions], + languages: [BuiltInLanguage.actions], }); const result = await uploadDependencyCaches(codeql, features, config, logger); @@ -444,7 +444,7 @@ test.serial( const logger = getRecordingLogger(messages); const features = createFeatures([]); const config = createTestConfig({ - languages: [KnownLanguage.go], + languages: [BuiltInLanguage.go], }); const makePatternCheckStub = sinon.stub(internal, "makePatternCheck"); @@ -457,7 +457,7 @@ test.serial( logger, ); t.is(result.length, 1); - t.is(result[0].language, KnownLanguage.go); + t.is(result[0].language, BuiltInLanguage.go); t.is(result[0].result, CacheStoreResult.NoHash); }, ); @@ -483,12 +483,12 @@ test.serial( const primaryCacheKey = await cacheKey( codeql, features, - KnownLanguage.csharp, + BuiltInLanguage.csharp, CSHARP_BASE_PATTERNS, ); const config = createTestConfig({ - languages: [KnownLanguage.csharp], + languages: [BuiltInLanguage.csharp], dependencyCachingRestoredKeys: [primaryCacheKey], }); @@ -499,7 +499,7 @@ test.serial( logger, ); t.is(result.length, 1); - t.is(result[0].language, KnownLanguage.csharp); + t.is(result[0].language, BuiltInLanguage.csharp); t.is(result[0].result, CacheStoreResult.Duplicate); }, ); @@ -525,7 +525,7 @@ test.serial( sinon.stub(cachingUtils, "getTotalCacheSize").resolves(0); const config = createTestConfig({ - languages: [KnownLanguage.csharp], + languages: [BuiltInLanguage.csharp], }); const result = await uploadDependencyCaches( @@ -535,7 +535,7 @@ test.serial( logger, ); t.is(result.length, 1); - t.is(result[0].language, KnownLanguage.csharp); + t.is(result[0].language, BuiltInLanguage.csharp); t.is(result[0].result, CacheStoreResult.Empty); checkExpectedLogMessages(t, messages, [ @@ -566,7 +566,7 @@ test.serial( sinon.stub(actionsCache, "saveCache").resolves(); const config = createTestConfig({ - languages: [KnownLanguage.csharp], + languages: [BuiltInLanguage.csharp], }); const result = await uploadDependencyCaches( @@ -576,7 +576,7 @@ test.serial( logger, ); t.is(result.length, 1); - t.is(result[0].language, KnownLanguage.csharp); + t.is(result[0].language, BuiltInLanguage.csharp); t.is(result[0].result, CacheStoreResult.Stored); t.is(result[0].upload_size_bytes, 1024); @@ -608,7 +608,7 @@ test.serial( .throws(new actionsCache.ReserveCacheError("Already in use")); const config = createTestConfig({ - languages: [KnownLanguage.csharp], + languages: [BuiltInLanguage.csharp], }); await t.notThrowsAsync(async () => { @@ -619,7 +619,7 @@ test.serial( logger, ); t.is(result.length, 1); - t.is(result[0].language, KnownLanguage.csharp); + t.is(result[0].language, BuiltInLanguage.csharp); t.is(result[0].result, CacheStoreResult.Duplicate); checkExpectedLogMessages(t, messages, ["Not uploading cache for"]); @@ -647,7 +647,7 @@ test.serial("uploadDependencyCaches - throws other exceptions", async (t) => { sinon.stub(actionsCache, "saveCache").throws(); const config = createTestConfig({ - languages: [KnownLanguage.csharp], + languages: [BuiltInLanguage.csharp], }); await t.throwsAsync(async () => { @@ -659,7 +659,7 @@ test("getFeaturePrefix - returns empty string if no features are enabled", async const codeql = createStubCodeQL({}); const features = createFeatures([]); - for (const knownLanguage of Object.values(KnownLanguage)) { + for (const knownLanguage of Object.values(BuiltInLanguage)) { const result = await getFeaturePrefix(codeql, features, knownLanguage); t.deepEqual(result, "", `Expected no feature prefix for ${knownLanguage}`); } @@ -669,7 +669,11 @@ test("getFeaturePrefix - C# - returns prefix if CsharpNewCacheKey is enabled", a const codeql = createStubCodeQL({}); const features = createFeatures([Feature.CsharpNewCacheKey]); - const result = await getFeaturePrefix(codeql, features, KnownLanguage.csharp); + const result = await getFeaturePrefix( + codeql, + features, + BuiltInLanguage.csharp, + ); t.notDeepEqual(result, ""); t.assert(result.endsWith("-")); // Check the length of the prefix, which should correspond to `cacheKeyHashLength` + 1 for the trailing `-`. @@ -680,9 +684,9 @@ test("getFeaturePrefix - non-C# - returns '' if CsharpNewCacheKey is enabled", a const codeql = createStubCodeQL({}); const features = createFeatures([Feature.CsharpNewCacheKey]); - for (const knownLanguage of Object.values(KnownLanguage)) { + for (const knownLanguage of Object.values(BuiltInLanguage)) { // Skip C# since we expect a result for it, which is tested in the previous test. - if (knownLanguage === KnownLanguage.csharp) { + if (knownLanguage === BuiltInLanguage.csharp) { continue; } const result = await getFeaturePrefix(codeql, features, knownLanguage); @@ -694,7 +698,11 @@ test("getFeaturePrefix - C# - returns prefix if CsharpCacheBuildModeNone is enab const codeql = createStubCodeQL({}); const features = createFeatures([Feature.CsharpCacheBuildModeNone]); - const result = await getFeaturePrefix(codeql, features, KnownLanguage.csharp); + const result = await getFeaturePrefix( + codeql, + features, + BuiltInLanguage.csharp, + ); t.notDeepEqual(result, ""); t.assert(result.endsWith("-")); // Check the length of the prefix, which should correspond to `cacheKeyHashLength` + 1 for the trailing `-`. @@ -705,9 +713,9 @@ test("getFeaturePrefix - non-C# - returns '' if CsharpCacheBuildModeNone is enab const codeql = createStubCodeQL({}); const features = createFeatures([Feature.CsharpCacheBuildModeNone]); - for (const knownLanguage of Object.values(KnownLanguage)) { + for (const knownLanguage of Object.values(BuiltInLanguage)) { // Skip C# since we expect a result for it, which is tested in the previous test. - if (knownLanguage === KnownLanguage.csharp) { + if (knownLanguage === BuiltInLanguage.csharp) { continue; } const result = await getFeaturePrefix(codeql, features, knownLanguage); diff --git a/src/dependency-caching.ts b/src/dependency-caching.ts index dc9a140be4..f04d38f46c 100644 --- a/src/dependency-caching.ts +++ b/src/dependency-caching.ts @@ -11,7 +11,7 @@ import { CodeQL } from "./codeql"; import { Config } from "./config-utils"; import { EnvVar } from "./environment"; import { Feature, FeatureEnablement } from "./feature-flags"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { Logger } from "./logging"; import { getErrorMessage, getRequiredEnvParam } from "./util"; @@ -541,7 +541,7 @@ export async function getFeaturePrefix( } }; - if (language === KnownLanguage.csharp) { + if (language === BuiltInLanguage.csharp) { await addFeatureIfEnabled(Feature.CsharpNewCacheKey); await addFeatureIfEnabled(Feature.CsharpCacheBuildModeNone); } diff --git a/src/init-action.ts b/src/init-action.ts index ffebf49742..37a9df9c83 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -58,7 +58,7 @@ import { initConfig, runDatabaseInitCluster, } from "./init"; -import { JavaEnvVars, KnownLanguage } from "./languages"; +import { JavaEnvVars, BuiltInLanguage } from "./languages"; import { getActionsLogger, Logger, withGroupAsync } from "./logging"; import { downloadOverlayBaseDatabaseFromCache, @@ -330,7 +330,7 @@ async function run(startedAt: Date) { // requested rust - don't enable it via language autodetection. configUtils .getRawLanguagesNoAutodetect(getOptionalInput("languages")) - .includes(KnownLanguage.rust) + .includes(BuiltInLanguage.rust) ) { const experimental = "2.19.3"; const publicPreview = "2.22.1"; @@ -390,7 +390,7 @@ async function run(startedAt: Date) { }); if ( - config.languages.includes(KnownLanguage.swift) && + config.languages.includes(BuiltInLanguage.swift) && process.platform !== "darwin" ) { throw new ConfigurationError( @@ -509,7 +509,7 @@ async function run(startedAt: Date) { } if ( - config.languages.includes(KnownLanguage.go) && + config.languages.includes(BuiltInLanguage.go) && process.platform === "linux" ) { try { @@ -567,7 +567,7 @@ async function run(startedAt: Date) { if (e instanceof FileCmdNotFoundError) { addDiagnostic( config, - KnownLanguage.go, + BuiltInLanguage.go, makeDiagnostic( "go/workflow/file-program-unavailable", "The `file` program is required on Linux, but does not appear to be installed", @@ -661,7 +661,7 @@ async function run(startedAt: Date) { (await codeQlVersionAtLeast(codeql, CODEQL_VERSION_JAR_MINIMIZATION)) && config.dependencyCachingEnabled && config.buildMode === BuildMode.None && - config.languages.includes(KnownLanguage.java) + config.languages.includes(BuiltInLanguage.java) ) { core.exportVariable( EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS, diff --git a/src/init.test.ts b/src/init.test.ts index 1f1f0de8dd..f7add6a9a5 100644 --- a/src/init.test.ts +++ b/src/init.test.ts @@ -15,7 +15,7 @@ import { getFileCoverageInformationEnabled, logFileCoverageOnPrsDeprecationWarning, } from "./init"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { createFeatures, LoggedMessage, @@ -152,7 +152,7 @@ test("cleanupDatabaseClusterDirectory can disable warning with options", async ( }); type PackInfo = { - language: KnownLanguage; + language: BuiltInLanguage; packinfoContents: string | undefined; sourceOnlyPack?: boolean; qlpackFileName?: string; @@ -169,13 +169,13 @@ const testCheckPacksForOverlayCompatibility = test.macro({ expectedResult, }: { cliOverlayVersion: number | undefined; - languages: KnownLanguage[]; + languages: BuiltInLanguage[]; packs: Record; expectedResult: boolean; }, ) => { await withTmpDir(async (tmpDir) => { - const packDirsByLanguage = new Map(); + const packDirsByLanguage = new Map(); for (const [packName, packInfo] of Object.entries(packs)) { const packPath = path.join(tmpDir, packName); @@ -242,10 +242,10 @@ test( "returns false when CLI does not support overlay", { cliOverlayVersion: undefined, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, }, @@ -258,7 +258,7 @@ test( "returns true when there are no query packs", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: {}, expectedResult: true, }, @@ -269,10 +269,10 @@ test( "returns true when query pack has not been compiled", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: undefined, sourceOnlyPack: true, }, @@ -286,10 +286,10 @@ test( "returns true when query pack has expected overlay version", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, }, @@ -302,14 +302,14 @@ test( "returns true when query packs for all languages to analyze are compatible", { cliOverlayVersion: 2, - languages: [KnownLanguage.cpp, KnownLanguage.java], + languages: [BuiltInLanguage.cpp, BuiltInLanguage.java], packs: { "codeql/cpp-queries": { - language: KnownLanguage.cpp, + language: BuiltInLanguage.cpp, packinfoContents: '{"overlayVersion":2}', }, "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, }, @@ -322,14 +322,14 @@ test( "returns true when query pack for a language not analyzed is incompatible", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/cpp-queries": { - language: KnownLanguage.cpp, + language: BuiltInLanguage.cpp, packinfoContents: undefined, }, "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, }, @@ -342,14 +342,14 @@ test( "returns false when query pack for a language to analyze is incompatible", { cliOverlayVersion: 2, - languages: [KnownLanguage.cpp, KnownLanguage.java], + languages: [BuiltInLanguage.cpp, BuiltInLanguage.java], packs: { "codeql/cpp-queries": { - language: KnownLanguage.cpp, + language: BuiltInLanguage.cpp, packinfoContents: '{"overlayVersion":1}', }, "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, }, @@ -362,14 +362,14 @@ test( "returns false when query pack is missing .packinfo", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, "custom/queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: undefined, }, }, @@ -382,14 +382,14 @@ test( "returns false when query pack has different overlay version", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, "custom/queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":1}', }, }, @@ -402,14 +402,14 @@ test( "returns false when query pack is missing overlayVersion in .packinfo", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, "custom/queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: "{}", }, }, @@ -422,14 +422,14 @@ test( "returns false when .packinfo is not valid JSON", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', }, "custom/queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: "this_is_not_valid_json", }, }, @@ -442,10 +442,10 @@ test( "returns true when query pack uses codeql-pack.yml filename", { cliOverlayVersion: 2, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], packs: { "codeql/java-queries": { - language: KnownLanguage.java, + language: BuiltInLanguage.java, packinfoContents: '{"overlayVersion":2}', qlpackFileName: "codeql-pack.yml", }, diff --git a/src/init.ts b/src/init.ts index 8e3fa21a4a..8ed6f64005 100644 --- a/src/init.ts +++ b/src/init.ts @@ -26,7 +26,7 @@ import { RepositoryProperties, RepositoryPropertyName, } from "./feature-flags/properties"; -import { KnownLanguage, Language } from "./languages"; +import { BuiltInLanguage, Language } from "./languages"; import { Logger, withGroupAsync } from "./logging"; import { ToolsSource } from "./setup-codeql"; import { ZstdAvailability } from "./tar"; @@ -235,7 +235,7 @@ export async function checkInstallPython311( codeql: CodeQL, ) { if ( - languages.includes(KnownLanguage.python) && + languages.includes(BuiltInLanguage.python) && process.platform === "win32" && !(await codeql.getVersion()).features?.supportsPython312 ) { diff --git a/src/known-language-aliases.json b/src/known-language-aliases.json deleted file mode 100644 index 50726256fe..0000000000 --- a/src/known-language-aliases.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "c": "cpp", - "c-c++": "cpp", - "c-cpp": "cpp", - "c#": "csharp", - "c++": "cpp", - "java-kotlin": "java", - "javascript-typescript": "javascript", - "kotlin": "java", - "typescript": "javascript" -} diff --git a/src/languages.ts b/src/languages.ts deleted file mode 100644 index 0723b89eb4..0000000000 --- a/src/languages.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** A language to analyze with CodeQL. */ -export type Language = string; - -/** - * A language supported by CodeQL that is treated specially by the Action. - * - * This is not an exhaustive list of languages supported by CodeQL and new - * languages do not need to be added here. - */ -export enum KnownLanguage { - actions = "actions", - cpp = "cpp", - csharp = "csharp", - go = "go", - java = "java", - javascript = "javascript", - python = "python", - ruby = "ruby", - rust = "rust", - swift = "swift", -} - -/** Java-specific environment variable names that we may care about. */ -export enum JavaEnvVars { - JAVA_HOME = "JAVA_HOME", - JAVA_TOOL_OPTIONS = "JAVA_TOOL_OPTIONS", - JDK_JAVA_OPTIONS = "JDK_JAVA_OPTIONS", - _JAVA_OPTIONS = "_JAVA_OPTIONS", -} diff --git a/src/languages/builtin.json b/src/languages/builtin.json new file mode 100644 index 0000000000..2c3511816d --- /dev/null +++ b/src/languages/builtin.json @@ -0,0 +1,25 @@ +{ + "languages": [ + "actions", + "cpp", + "csharp", + "go", + "java", + "javascript", + "python", + "ruby", + "rust", + "swift" + ], + "aliases": { + "c": "cpp", + "c-c++": "cpp", + "c-cpp": "cpp", + "c#": "csharp", + "c++": "cpp", + "java-kotlin": "java", + "javascript-typescript": "javascript", + "kotlin": "java", + "typescript": "javascript" + } +} diff --git a/src/languages/index.test.ts b/src/languages/index.test.ts new file mode 100644 index 0000000000..4fe1675af7 --- /dev/null +++ b/src/languages/index.test.ts @@ -0,0 +1,46 @@ +import test from "ava"; + +import { setupTests } from "../testing-utils"; + +import knownLanguagesData from "./builtin.json"; + +import { isBuiltInLanguage, BuiltInLanguage, parseBuiltInLanguage } from "."; + +setupTests(test); + +test("parseBuiltInLanguage", (t) => { + // Exact matches + t.is(parseBuiltInLanguage("csharp"), BuiltInLanguage.csharp); + t.is(parseBuiltInLanguage("cpp"), BuiltInLanguage.cpp); + t.is(parseBuiltInLanguage("go"), BuiltInLanguage.go); + t.is(parseBuiltInLanguage("java"), BuiltInLanguage.java); + t.is(parseBuiltInLanguage("javascript"), BuiltInLanguage.javascript); + t.is(parseBuiltInLanguage("python"), BuiltInLanguage.python); + t.is(parseBuiltInLanguage("rust"), BuiltInLanguage.rust); + + // Aliases + t.is(parseBuiltInLanguage(" \t\nCsHaRp\t\t"), BuiltInLanguage.csharp); + t.is(parseBuiltInLanguage("c"), BuiltInLanguage.cpp); + t.is(parseBuiltInLanguage("c++"), BuiltInLanguage.cpp); + t.is(parseBuiltInLanguage("kotlin"), BuiltInLanguage.java); + t.is(parseBuiltInLanguage("typescript"), BuiltInLanguage.javascript); + + // spaces and case-insensitivity + t.is(parseBuiltInLanguage(" \t\nkOtLin\t\t"), BuiltInLanguage.java); + + // Not matches + t.is(parseBuiltInLanguage(BuiltInLanguage.python), BuiltInLanguage.python); + t.is(parseBuiltInLanguage("foo"), undefined); + t.is(parseBuiltInLanguage(" "), undefined); + t.is(parseBuiltInLanguage(""), undefined); +}); + +test("isBuiltInLanguage matches the curated built-in language set", (t) => { + t.true(isBuiltInLanguage(BuiltInLanguage.actions)); + t.true(isBuiltInLanguage(BuiltInLanguage.swift)); + t.false(isBuiltInLanguage("typescript")); +}); + +test("BuiltInLanguage enum matches builtin.json", (t) => { + t.deepEqual(Object.values(BuiltInLanguage), knownLanguagesData.languages); +}); diff --git a/src/languages/index.ts b/src/languages/index.ts new file mode 100644 index 0000000000..7ecbd06fd5 --- /dev/null +++ b/src/languages/index.ts @@ -0,0 +1,57 @@ +import knownLanguagesData from "./builtin.json"; + +/** A language to analyze with CodeQL. */ +export type Language = string; + +/** A language built into the `defaults.json` CodeQL distribution. */ +export enum BuiltInLanguage { + actions = "actions", + cpp = "cpp", + csharp = "csharp", + go = "go", + java = "java", + javascript = "javascript", + python = "python", + ruby = "ruby", + rust = "rust", + swift = "swift", +} + +/** Java-specific environment variable names that we may care about. */ +export enum JavaEnvVars { + JAVA_HOME = "JAVA_HOME", + JAVA_TOOL_OPTIONS = "JAVA_TOOL_OPTIONS", + JDK_JAVA_OPTIONS = "JDK_JAVA_OPTIONS", + _JAVA_OPTIONS = "_JAVA_OPTIONS", +} + +const builtInLanguageSet = new Set(knownLanguagesData.languages); + +export function isBuiltInLanguage( + language: string, +): language is BuiltInLanguage { + return builtInLanguageSet.has(language); +} + +/** + * Parse a language input corresponding to a built-in language into its canonical CodeQL language + * name. + * + * This uses the language aliases shipped with the Action and will not be able to resolve aliases + * added by third-party CodeQL language support or versions of the CodeQL CLI newer than the one + * mentioned in `defaults.json`. Therefore, this function should only be used when the CodeQL CLI is + * not available. + */ +export function parseBuiltInLanguage( + language: string, +): BuiltInLanguage | undefined { + language = language.trim().toLowerCase(); + language = + knownLanguagesData.aliases[ + language as keyof typeof knownLanguagesData.aliases + ] ?? language; + if (isBuiltInLanguage(language)) { + return language; + } + return undefined; +} diff --git a/src/overlay/caching.test.ts b/src/overlay/caching.test.ts index 735b8824d6..9c7abc6bd7 100644 --- a/src/overlay/caching.test.ts +++ b/src/overlay/caching.test.ts @@ -9,7 +9,7 @@ import * as actionsUtil from "../actions-util"; import * as apiClient from "../api-client"; import { ResolveDatabaseOutput } from "../codeql"; import * as gitUtils from "../git-utils"; -import { KnownLanguage } from "../languages"; +import { BuiltInLanguage } from "../languages"; import { getRunnerLogger } from "../logging"; import { createTestConfig, @@ -65,7 +65,7 @@ const testDownloadOverlayBaseDatabaseFromCache = test.macro({ const testCase = { ...defaultDownloadTestCase, ...partialTestCase }; const config = createTestConfig({ dbLocation, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], }); config.overlayDatabaseMode = testCase.overlayDatabaseMode; diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index 29c76643e3..a288acc5c0 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -6,7 +6,7 @@ import * as core from "@actions/core"; import * as actionsUtil from "./actions-util"; import { getGitHubVersion } from "./api-client"; import { Feature, FeatureEnablement, initFeatures } from "./feature-flags"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage, parseBuiltInLanguage } from "./languages"; import { getActionsLogger, Logger } from "./logging"; import { getRepositoryNwo } from "./repository"; import { @@ -14,7 +14,6 @@ import { getCredentials, getProxyBinaryPath, getSafeErrorMessage, - parseLanguage, ProxyInfo, sendFailedStatusReport, sendSuccessStatusReport, @@ -33,7 +32,7 @@ async function run(startedAt: Date) { const logger = getActionsLogger(); let features: FeatureEnablement | undefined; - let language: KnownLanguage | undefined; + let language: BuiltInLanguage | undefined; try { // Make inputs accessible in the `post` step. @@ -56,7 +55,7 @@ async function run(startedAt: Date) { // Get the language input. const languageInput = actionsUtil.getOptionalInput("language"); - language = languageInput ? parseLanguage(languageInput) : undefined; + language = languageInput ? parseBuiltInLanguage(languageInput) : undefined; // Query the FF for whether we should use the reduced registry mapping. const skipUnusedRegistries = await features.getValue( @@ -119,7 +118,7 @@ async function run(startedAt: Date) { await sendSuccessStatusReport( startedAt, { - languages: language && [language], + languages: language === undefined ? undefined : [language], }, proxyConfig.all_credentials.map((c) => c.type), logger, diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index e1d465abc9..4d8f4afeec 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -8,10 +8,9 @@ import sinon from "sinon"; import * as apiClient from "./api-client"; import * as defaults from "./defaults.json"; import { setUpFeatureFlagTests } from "./feature-flags/testing-util"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getRunnerLogger, Logger } from "./logging"; import * as startProxyExports from "./start-proxy"; -import { parseLanguage } from "./start-proxy"; import * as statusReport from "./status-report"; import { assertNotLogged, @@ -232,7 +231,7 @@ test("getCredentials filters by language when specified", async (t) => { getRunnerLogger(true), undefined, toEncodedJSON(mixedCredentials), - KnownLanguage.java, + BuiltInLanguage.java, ); t.is(credentials.length, 1); t.is(credentials[0].type, "maven_repository"); @@ -243,7 +242,7 @@ test("getCredentials returns all for a language when specified", async (t) => { getRunnerLogger(true), undefined, toEncodedJSON(mixedCredentials), - KnownLanguage.go, + BuiltInLanguage.go, ); t.is(credentials.length, 2); @@ -263,7 +262,7 @@ test("getCredentials returns all goproxy_servers for Go when specified", async ( getRunnerLogger(true), undefined, toEncodedJSON(multipleGoproxyServers), - KnownLanguage.go, + BuiltInLanguage.go, ); t.is(credentials.length, 3); @@ -292,7 +291,7 @@ test("getCredentials returns all maven_repositories for Java when specified", as getRunnerLogger(true), undefined, toEncodedJSON(multipleMavenRepositories), - KnownLanguage.java, + BuiltInLanguage.java, ); t.is(credentials.length, 2); @@ -480,7 +479,7 @@ test("getCredentials accepts OIDC configurations", (t) => { getRunnerLogger(true), undefined, toEncodedJSON(oidcConfigurations), - KnownLanguage.csharp, + BuiltInLanguage.csharp, ); t.is(credentials.length, 3); @@ -647,7 +646,7 @@ test("getCredentials returns all credentials for Actions when using LANGUAGE_TO_ getRunnerLogger(true), undefined, credentialsInput, - KnownLanguage.actions, + BuiltInLanguage.actions, false, ); t.is(credentials.length, mixedCredentials.length); @@ -660,39 +659,12 @@ test("getCredentials returns no credentials for Actions when using NEW_LANGUAGE_ getRunnerLogger(true), undefined, credentialsInput, - KnownLanguage.actions, + BuiltInLanguage.actions, true, ); t.deepEqual(credentials, []); }); -test("parseLanguage", async (t) => { - // Exact matches - t.deepEqual(parseLanguage("csharp"), KnownLanguage.csharp); - t.deepEqual(parseLanguage("cpp"), KnownLanguage.cpp); - t.deepEqual(parseLanguage("go"), KnownLanguage.go); - t.deepEqual(parseLanguage("java"), KnownLanguage.java); - t.deepEqual(parseLanguage("javascript"), KnownLanguage.javascript); - t.deepEqual(parseLanguage("python"), KnownLanguage.python); - t.deepEqual(parseLanguage("rust"), KnownLanguage.rust); - - // Aliases - t.deepEqual(parseLanguage("c"), KnownLanguage.cpp); - t.deepEqual(parseLanguage("c++"), KnownLanguage.cpp); - t.deepEqual(parseLanguage("c#"), KnownLanguage.csharp); - t.deepEqual(parseLanguage("kotlin"), KnownLanguage.java); - t.deepEqual(parseLanguage("typescript"), KnownLanguage.javascript); - - // spaces and case-insensitivity - t.deepEqual(parseLanguage(" \t\nCsHaRp\t\t"), KnownLanguage.csharp); - t.deepEqual(parseLanguage(" \t\nkOtLin\t\t"), KnownLanguage.java); - - // Not matches - t.deepEqual(parseLanguage("foo"), undefined); - t.deepEqual(parseLanguage(" "), undefined); - t.deepEqual(parseLanguage(""), undefined); -}); - function mockGetApiClient(endpoints: any) { return ( sinon diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 270681240b..8859eb16e2 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -18,8 +18,7 @@ import { FeatureEnablement, } from "./feature-flags"; import * as json from "./json"; -import * as knownLanguageAliases from "./known-language-aliases.json"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { Logger } from "./logging"; import { Address, @@ -157,7 +156,7 @@ export function getSafeErrorMessage(error: Error): string { export async function sendFailedStatusReport( logger: Logger, startedAt: Date, - language: KnownLanguage | undefined, + language: BuiltInLanguage | undefined, unwrappedError: unknown, ) { const error = util.wrapError(unwrappedError); @@ -173,7 +172,7 @@ export async function sendFailedStatusReport( getActionsStatus(error), startedAt, { - languages: language && [language], + languages: language === undefined ? undefined : [language], }, await util.checkDiskUsage(logger), logger, @@ -189,35 +188,6 @@ export const UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; const UPDATEJOB_PROXY_URL_PREFIX = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/"; -/** - * Parse the start-proxy language input into its canonical CodeQL language name. - * - * This uses the language aliases shipped with the Action and will not be able to resolve aliases - * added by versions of the CodeQL CLI newer than the one mentioned in `defaults.json`. However, - * this is sufficient for the start-proxy Action since we are already specifying proxy - * configurations on a per-language basis. - */ -export function parseLanguage(language: string): KnownLanguage | undefined { - // Normalize to lower case - language = language.trim().toLowerCase(); - - // See if it's an exact match - if (Object.hasOwn(KnownLanguage, language)) { - return language as KnownLanguage; - } - - // Check language aliases - if (Object.hasOwn(knownLanguageAliases, language)) { - language = - knownLanguageAliases[language as keyof typeof knownLanguageAliases]; - if (Object.hasOwn(KnownLanguage, language)) { - return language as KnownLanguage; - } - } - - return undefined; -} - function isPAT(value: string) { return artifactScanner.isAuthToken(value, [ artifactScanner.GITHUB_PAT_CLASSIC_PATTERN, @@ -225,7 +195,7 @@ function isPAT(value: string) { ]); } -type RegistryMapping = Partial>; +type RegistryMapping = Partial>; const LANGUAGE_TO_REGISTRY_TYPE: RegistryMapping = { java: ["maven_repository"], @@ -357,7 +327,7 @@ export function getCredentials( logger: Logger, registrySecrets: string | undefined, registriesCredentials: string | undefined, - language: KnownLanguage | undefined, + language: BuiltInLanguage | undefined, skipUnusedRegistries: boolean = false, ): Credential[] { const registryMapping = skipUnusedRegistries diff --git a/src/start-proxy/environment.test.ts b/src/start-proxy/environment.test.ts index 6722c53ab2..decd2fa6b3 100644 --- a/src/start-proxy/environment.test.ts +++ b/src/start-proxy/environment.test.ts @@ -7,7 +7,7 @@ import * as io from "@actions/io"; import test, { ExecutionContext } from "ava"; import sinon from "sinon"; -import { JavaEnvVars, KnownLanguage } from "../languages"; +import { JavaEnvVars, BuiltInLanguage } from "../languages"; import { checkExpectedLogMessages, getRecordingLogger, @@ -182,11 +182,11 @@ test.serial("checkProxyEnvVars - credentials are removed from URLs", (t) => { }); test.serial( - "checkProxyEnvironment - includes base checks for all known languages", + "checkProxyEnvironment - includes base checks for all built-in languages", async (t) => { stubToolrunner(); - for (const language of Object.values(KnownLanguage)) { + for (const language of Object.values(BuiltInLanguage)) { const messages: LoggedMessage[] = []; const logger = getRecordingLogger(messages); @@ -204,7 +204,7 @@ test.serial( stubToolrunner(); - await checkProxyEnvironment(logger, KnownLanguage.java); + await checkProxyEnvironment(logger, BuiltInLanguage.java); assertEnvVarLogMessages(t, Object.keys(ProxyEnvVars), messages, false); assertEnvVarLogMessages(t, JAVA_PROXY_ENV_VARS, messages, false); }, diff --git a/src/start-proxy/environment.ts b/src/start-proxy/environment.ts index 13eb121901..0a683cc07e 100644 --- a/src/start-proxy/environment.ts +++ b/src/start-proxy/environment.ts @@ -4,7 +4,7 @@ import * as path from "path"; import * as toolrunner from "@actions/exec/lib/toolrunner"; import * as io from "@actions/io"; -import { JavaEnvVars, KnownLanguage, Language } from "../languages"; +import { JavaEnvVars, BuiltInLanguage, Language } from "../languages"; import { Logger } from "../logging"; import { getErrorMessage, isDefined } from "../util"; @@ -196,7 +196,7 @@ export async function checkProxyEnvironment( // Check language-specific configurations. If we don't know the language, // then we perform all checks. - if (language === undefined || language === KnownLanguage.java) { + if (language === undefined || language === BuiltInLanguage.java) { checkJavaEnvVars(logger); await showJavaSettings(logger); diff --git a/src/status-report.test.ts b/src/status-report.test.ts index 35d608b7d3..8302e411fa 100644 --- a/src/status-report.test.ts +++ b/src/status-report.test.ts @@ -4,7 +4,7 @@ import * as sinon from "sinon"; import * as actionsUtil from "./actions-util"; import { Config } from "./config-utils"; import { EnvVar } from "./environment"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getRunnerLogger } from "./logging"; import { ToolsSource } from "./setup-codeql"; import { @@ -48,7 +48,7 @@ test.serial("createStatusReportBase", async (t) => { new Date("May 19, 2023 05:19:00"), createTestConfig({ buildMode: BuildMode.None, - languages: [KnownLanguage.java, KnownLanguage.swift], + languages: [BuiltInLanguage.java, BuiltInLanguage.swift], }), { numAvailableBytes: 100, numTotalBytes: 500 }, getRunnerLogger(false), @@ -345,7 +345,7 @@ test.serial( "returns a value", createTestConfig({ buildMode: BuildMode.None, - languages: [KnownLanguage.java, KnownLanguage.swift], + languages: [BuiltInLanguage.java, BuiltInLanguage.swift], }), { trap_cache_download_size_bytes: 1024, @@ -360,7 +360,7 @@ test.serial( "includes packs for a single language", createTestConfig({ buildMode: BuildMode.None, - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], computedConfig: { packs: ["foo", "bar"], }, @@ -377,7 +377,7 @@ test.serial( "includes packs for multiple languages", createTestConfig({ buildMode: BuildMode.None, - languages: [KnownLanguage.java, KnownLanguage.swift], + languages: [BuiltInLanguage.java, BuiltInLanguage.swift], computedConfig: { packs: { java: ["java-foo", "java-bar"], swift: ["swift-bar"] }, }, diff --git a/src/tracer-config.test.ts b/src/tracer-config.test.ts index cc49957086..58f844b8e7 100644 --- a/src/tracer-config.test.ts +++ b/src/tracer-config.test.ts @@ -6,7 +6,7 @@ import * as sinon from "sinon"; import { CodeQL, getCodeQLForTesting } from "./codeql"; import * as configUtils from "./config-utils"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { createTestConfig, makeVersionInfo, setupTests } from "./testing-utils"; import { ToolsFeature } from "./tools-features"; import { getCombinedTracerConfig } from "./tracer-config"; @@ -16,7 +16,7 @@ setupTests(test); function getTestConfig(tempDir: string): configUtils.Config { return createTestConfig({ - languages: [KnownLanguage.java], + languages: [BuiltInLanguage.java], tempDir, dbLocation: path.resolve(tempDir, "codeql_databases"), }); @@ -36,7 +36,7 @@ async function stubCodeql( ); sinon .stub(codeqlObject, "isTracedLanguage") - .withArgs(KnownLanguage.java) + .withArgs(BuiltInLanguage.java) .resolves(true); return codeqlObject; } @@ -45,7 +45,7 @@ test("getCombinedTracerConfig - return undefined when no languages are traced la await util.withTmpDir(async (tmpDir) => { const config = getTestConfig(tmpDir); // No traced languages - config.languages = [KnownLanguage.javascript, KnownLanguage.python]; + config.languages = [BuiltInLanguage.javascript, BuiltInLanguage.python]; t.deepEqual( await getCombinedTracerConfig(await stubCodeql(), config), undefined, diff --git a/src/trap-caching.test.ts b/src/trap-caching.test.ts index a6c7fc76cb..9805475796 100644 --- a/src/trap-caching.test.ts +++ b/src/trap-caching.test.ts @@ -15,7 +15,7 @@ import { import * as configUtils from "./config-utils"; import { Feature } from "./feature-flags"; import * as gitUtils from "./git-utils"; -import { KnownLanguage } from "./languages"; +import { BuiltInLanguage } from "./languages"; import { getRunnerLogger } from "./logging"; import { createFeatures, @@ -41,7 +41,7 @@ const stubCodeql = createStubCodeQL({ async betterResolveLanguages() { return { extractors: { - [KnownLanguage.javascript]: [ + [BuiltInLanguage.javascript]: [ { extractor_root: "some_root", extractor_options: { @@ -65,7 +65,7 @@ const stubCodeql = createStubCodeQL({ }, }, ], - [KnownLanguage.cpp]: [ + [BuiltInLanguage.cpp]: [ { extractor_root: "other_root", }, @@ -76,7 +76,7 @@ const stubCodeql = createStubCodeQL({ }); const testConfigWithoutTmpDir = createTestConfig({ - languages: [KnownLanguage.javascript, KnownLanguage.cpp], + languages: [BuiltInLanguage.javascript, BuiltInLanguage.cpp], trapCaches: { javascript: "/some/cache/dir", }, @@ -84,7 +84,7 @@ const testConfigWithoutTmpDir = createTestConfig({ function getTestConfigWithTempDir(tempDir: string): configUtils.Config { return createTestConfig({ - languages: [KnownLanguage.javascript, KnownLanguage.ruby], + languages: [BuiltInLanguage.javascript, BuiltInLanguage.ruby], tempDir, dbLocation: path.resolve(tempDir, "codeql_databases"), trapCaches: { @@ -100,7 +100,7 @@ test.serial("check flags for JS, analyzing default branch", async (t) => { sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true); const result = await getTrapCachingExtractorConfigArgsForLang( config, - KnownLanguage.javascript, + BuiltInLanguage.javascript, ); t.deepEqual(result, [ `-O=javascript.trap.cache.dir=${path.resolve(tmpDir, "jsCache")}`, @@ -131,10 +131,10 @@ test("get languages that support TRAP caching", async (t) => { const logger = getRecordingLogger(loggedMessages); const languagesSupportingCaching = await getLanguagesSupportingCaching( stubCodeql, - [KnownLanguage.javascript, KnownLanguage.cpp], + [BuiltInLanguage.javascript, BuiltInLanguage.cpp], logger, ); - t.deepEqual(languagesSupportingCaching, [KnownLanguage.javascript]); + t.deepEqual(languagesSupportingCaching, [BuiltInLanguage.javascript]); }); test.serial("upload cache key contains right fields", async (t) => { @@ -180,7 +180,7 @@ test.serial( ); await downloadTrapCaches( stubCodeql, - [KnownLanguage.javascript, KnownLanguage.cpp], + [BuiltInLanguage.javascript, BuiltInLanguage.cpp], logger, ); t.assert( diff --git a/tests/multi-language-repo/.github/codeql/codeql-config-packaging.yml b/tests/multi-language-repo/.github/codeql/codeql-config-packaging.yml index 66e0f95a6c..8d560bdcb6 100644 --- a/tests/multi-language-repo/.github/codeql/codeql-config-packaging.yml +++ b/tests/multi-language-repo/.github/codeql/codeql-config-packaging.yml @@ -8,5 +8,6 @@ packs: - codeql-testing/codeql-pack3:other-query.ql paths-ignore: - - tests - lib + - pr-checks + - tests diff --git a/tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml b/tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml index 1369a4060b..3442d3ee1b 100644 --- a/tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml +++ b/tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml @@ -2,5 +2,6 @@ name: Pack testing in the CodeQL Action disable-default-queries: true paths-ignore: - - tests - lib + - pr-checks + - tests diff --git a/tests/multi-language-repo/.github/codeql/codeql-config-packaging3.yml b/tests/multi-language-repo/.github/codeql/codeql-config-packaging3.yml index 084df41d50..2a75653212 100644 --- a/tests/multi-language-repo/.github/codeql/codeql-config-packaging3.yml +++ b/tests/multi-language-repo/.github/codeql/codeql-config-packaging3.yml @@ -6,5 +6,6 @@ packs: - codeql-testing/codeql-pack2 - codeql-testing/codeql-pack3:other-query.ql paths-ignore: - - tests - lib + - pr-checks + - tests