From bbd8e24a2d9628c397a79d2408bd573843d334a2 Mon Sep 17 00:00:00 2001 From: David Anson Date: Wed, 21 Oct 2026 07:05:33 +0000 Subject: [PATCH] Update dependency: markdownlint-cli2 to 0.24.0. --- dist/index.mjs | 9633 +++++++++++++++++++++++++++++++++++++++------ package-lock.json | 121 +- package.json | 2 +- 3 files changed, 8420 insertions(+), 1336 deletions(-) diff --git a/dist/index.mjs b/dist/index.mjs index 4d1895b..f3f973a 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -40217,8 +40217,6 @@ var __webpack_unused_export__; -/* eslint-disable unicorn/comment-content */ - const micromark = __nccwpck_require__(1670); const { newlineRe, nextLinesRe } = __nccwpck_require__(3408); @@ -40229,14 +40227,14 @@ module.exports.gi = nextLinesRe; /** @typedef {import("../lib/exports.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ /** @typedef {import("../lib/exports.mjs").MicromarkToken} MicromarkToken */ // eslint-disable-next-line jsdoc/valid-types -/** @typedef {import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} */ +/** @typedef {typeof import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} _ambient_ */ // eslint-disable-next-line jsdoc/valid-types -/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */ +/** @typedef {typeof import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} _ambient_2_ */ // Regular expression for matching common front matter (YAML and TOML) -// @ts-ignore +// Potential for regular expression denial of service is mitigated at point-of-use via "re2js" package module.exports.Q9 = - // eslint-disable-next-line unicorn/prefer-unicode-code-point-escapes + // eslint-disable-next-line redos/no-vulnerable, unicorn/prefer-unicode-code-point-escapes /((^---[^\S\r\n\u2028\u2029]*$[\s\S]+?^---\s*)|(^\+\+\+[^\S\r\n\u2028\u2029]*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{[^\S\r\n\u2028\u2029]*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m; // Regular expression for matching the start of inline disable/enable comments @@ -40259,6 +40257,17 @@ module.exports.qA = allPunctuation; // All punctuation characters without question mark (normal and full-width) module.exports.f4 = allPunctuation.replace(/[??]/gu, ""); +/** + * Returns true iff the input is a Boolean. + * + * @param {Object} obj Object of unknown type. + * @returns {boolean} True iff obj is a Boolean. + */ +function isBoolean(obj) { + return typeof obj === "boolean"; +} +module.exports.Lm = isBoolean; + /** * Returns true iff the input is a Number. * @@ -40394,7 +40403,7 @@ const safeCommentCharacter = "."; const startsWithPipeRe = /^ *\|/; const notCrLfRe = /[^\r\n]/g; const notSpaceCrLfRe = /[^ \r\n]/g; -const trailingSpaceRe = / +[\r\n]/g; +const trailingSpaceRe = /(?<=^|[^ ]) +[\r\n]/g; // eslint-disable-next-line unicorn/no-unsafe-string-replacement const replaceTrailingSpace = (/** @type {string} */ s) => s.replace(notCrLfRe, safeCommentCharacter); module.exports.X6 = function clearHtmlCommentText(/** @type {string} */ text) { @@ -40932,7 +40941,7 @@ const { flatTokensSymbol, htmlFlowSymbol, newlineRe } = __nccwpck_require__(3408 /** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */ /** @typedef {import("../lib/exports.mjs").MicromarkToken} Token */ // eslint-disable-next-line jsdoc/valid-types -/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */ +/** @typedef {typeof import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} _ambient_ */ /** * Determines if a Micromark token is within an htmlFlow type. @@ -41055,10 +41064,9 @@ function filterByTypes(tokens, types, htmlFlow) { const flatTokens = // @ts-ignore tokens[flatTokensSymbol]; - if (flatTokens) { - return flatTokens.filter(predicate); - } - return filterByPredicate(tokens, predicate); + return flatTokens ? + flatTokens.filter(predicate) : + filterByPredicate(tokens, predicate); } /** @@ -41129,10 +41137,7 @@ function getHeadingStyle(heading) { const atxHeadingSequenceLength = heading.children.filter( (child) => child.type === "atxHeadingSequence" ).length; - if (atxHeadingSequenceLength === 1) { - return "atx"; - } - return "atx_closed"; + return (atxHeadingSequenceLength === 1) ? "atx" : "atx_closed"; } /** @@ -41146,7 +41151,8 @@ function getHeadingText(heading) { .flatMap((descendant) => descendant.children.filter((child) => child.type !== "htmlText")) .map((data) => data.text) .join("") - .replace(newlineRe, " "); + .replace(newlineRe, " ") + .trim(); } /** @@ -41295,6 +41301,7 @@ module.exports.nextLinesRe = /[\r\n][\s\S]*$/; * @returns {any} Exported module content. */ function requireMarkdownItCjs() { + // eslint-disable-next-line n/global-require return __nccwpck_require__(9917); } @@ -41402,6 +41409,13 @@ function freezeToken(token) { if (token.map) { Object.freeze(token.map); } + if (token.meta) { + // eslint-disable-next-line guard-for-in + for (const meta in token.meta) { + Object.freeze(meta); + } + Object.freeze(token.meta); + } Object.freeze(token); } @@ -41424,7 +41438,7 @@ function annotateAndFreezeTokens(tokens, lines) { } else if (token.type === "tr_close") { trMap = null; } - if (!token.map && trMap) { + if (trMap && !token.map) { token.map = [ ...trMap ]; } // Update token metadata @@ -44121,7 +44135,7 @@ function linkifyit(options = {}) { // EXTERNAL MODULE: ./node_modules/punycode.js/punycode.js var punycode = __nccwpck_require__(8629); ;// CONCATENATED MODULE: ./node_modules/markdown-it/dist/markdown-it.mjs -/*! markdown-it 15.0.1 https://github.com/markdown-it/markdown-it @license MIT */ +/*! markdown-it 15.0.3 https://github.com/markdown-it/markdown-it @license MIT */ @@ -44525,7 +44539,7 @@ var helpers_exports = /* @__PURE__ */ __exportAll({ parseLinkTitle: () => parseLinkTitle }); //#endregion -//#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js +//#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) { @@ -44535,7 +44549,7 @@ function _typeof(o) { }, _typeof(o); } //#endregion -//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js +//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js function toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; @@ -44547,13 +44561,13 @@ function toPrimitive(t, r) { return ("string" === r ? String : Number)(t); } //#endregion -//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js +//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js function toPropertyKey(t) { var i = toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } //#endregion -//#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js +//#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, @@ -45305,6 +45319,14 @@ function replace(state) { var QUOTE_TEST_RE = /['"]/; var QUOTE_RE = /['"]/g; var APOSTROPHE = "’"; +var MAX_OPENERS = 1e3; +function truncateStack(stack, heads, length) { + while (stack.length > length) { + const item = stack.pop(); + if (item.isSingleQuote) heads.single = item.prevSameQuoteIdx; + else heads.double = item.prevSameQuoteIdx; + } +} function addReplacement(replacements, tokenIdx, pos, ch) { if (!replacements[tokenIdx]) replacements[tokenIdx] = []; replacements[tokenIdx].push({ @@ -45326,12 +45348,16 @@ function applyReplacements(str, replacements) { function process_inlines(tokens, state) { let j; const stack = []; + const heads = { + single: -1, + double: -1 + }; const replacements = {}; for (let i = 0; i < tokens.length; i++) { const token = tokens[i]; const thisLevel = tokens[i].level; for (j = stack.length - 1; j >= 0; j--) if (stack[j].level <= thisLevel) break; - stack.length = j + 1; + truncateStack(stack, heads, j + 1); if (token.type !== "text") continue; const text = token.content; let pos = 0; @@ -45383,11 +45409,10 @@ function process_inlines(tokens, state) { if (isSingle) addReplacement(replacements, i, t.index, APOSTROPHE); continue; } - if (canClose) for (j = stack.length - 1; j >= 0; j--) { - let item = stack[j]; - if (stack[j].level < thisLevel) break; - if (item.single === isSingle && stack[j].level === thisLevel) { - item = stack[j]; + if (canClose) { + j = isSingle ? heads.single : heads.double; + if (j >= 0 && stack[j].level === thisLevel) { + const item = stack[j]; let openQuote; let closeQuote; if (isSingle) { @@ -45398,18 +45423,23 @@ function process_inlines(tokens, state) { closeQuote = state.md.options.quotes[1]; } addReplacement(replacements, i, t.index, closeQuote); - addReplacement(replacements, item.token, item.pos, openQuote); - stack.length = j; + addReplacement(replacements, item.tokenIdx, item.contentPos, openQuote); + truncateStack(stack, heads, j); continue OUTER; } } - if (canOpen) stack.push({ - token: i, - pos: t.index, - single: isSingle, - level: thisLevel - }); - else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE); + if (canOpen) { + if (stack.length >= MAX_OPENERS) return; + stack.push({ + tokenIdx: i, + contentPos: t.index, + isSingleQuote: isSingle, + level: thisLevel, + prevSameQuoteIdx: isSingle ? heads.single : heads.double + }); + if (isSingle) heads.single = stack.length - 1; + else heads.double = stack.length - 1; + } else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE); } } Object.keys(replacements).forEach(function(tokenIdx) { @@ -45519,12 +45549,14 @@ var StateBlock = class { const s = this.src; for (let start = 0, pos = 0, indent = 0, offset = 0, len = s.length, indent_found = false; pos < len; pos++) { const ch = s.charCodeAt(pos); - if (!indent_found) if (isSpace(ch)) { - indent++; - if (ch === 9) offset += 4 - offset % 4; - else offset++; - continue; - } else indent_found = true; + if (!indent_found) { + if (isSpace(ch)) { + indent++; + if (ch === 9) offset += 4 - offset % 4; + else offset++; + continue; + } else indent_found = true; + } if (ch === 10 || pos === len - 1) { if (ch !== 10) pos++; this.bMarks.push(start); @@ -45591,9 +45623,10 @@ var StateBlock = class { else last = this.eMarks[line]; while (first < last && lineIndent < indent) { const ch = this.src.charCodeAt(first); - if (isSpace(ch)) if (ch === 9) lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4; - else lineIndent++; - else if (first - lineStart < this.tShift[line]) lineIndent++; + if (isSpace(ch)) { + if (ch === 9) lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4; + else lineIndent++; + } else if (first - lineStart < this.tShift[line]) lineIndent++; else break; first++; } @@ -45620,13 +45653,15 @@ function escapedSplit(str) { let lastPos = 0; let current = ""; while (pos < max) { - if (ch === 124) if (!isEscaped) { - result.push(current + str.substring(lastPos, pos)); - current = ""; - lastPos = pos + 1; - } else { - current += str.substring(lastPos, pos - 1); - lastPos = pos; + if (ch === 124) { + if (!isEscaped) { + result.push(current + str.substring(lastPos, pos)); + current = ""; + lastPos = pos + 1; + } else { + current += str.substring(lastPos, pos - 1); + lastPos = pos; + } } isEscaped = ch === 92; pos++; @@ -45658,8 +45693,10 @@ function table(state, startLine, endLine, silent) { const aligns = []; for (let i = 0; i < columns.length; i++) { const t = columns[i].trim(); - if (!t) if (i === 0 || i === columns.length - 1) continue; - else return false; + if (!t) { + if (i === 0 || i === columns.length - 1) continue; + else return false; + } if (!/^:?-+:?$/.test(t)) return false; if (t.charCodeAt(t.length - 1) === 58) aligns.push(t.charCodeAt(0) === 58 ? "center" : "right"); else if (t.charCodeAt(0) === 58) aligns.push("left"); @@ -45852,9 +45889,10 @@ function blockquote(state, startLine, endLine, silent) { state.bMarks[nextLine] = pos; while (pos < max) { const ch = state.src.charCodeAt(pos); - if (isSpace(ch)) if (ch === 9) offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4; - else offset++; - else break; + if (isSpace(ch)) { + if (ch === 9) offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4; + else offset++; + } else break; pos++; } lastLineEmpty = pos >= max; @@ -46087,129 +46125,141 @@ function list(state, startLine, endLine, silent) { } //#endregion //#region src/rules_block/reference.ts +var MAX_LABEL_LENGTH = 999; +function countCodePoints(str) { + let length = str.length; + for (let i = 0; i < str.length - 1; i++) { + const high = str.charCodeAt(i); + if (high < 55296 || high > 56319) continue; + const low = str.charCodeAt(i + 1); + if (low >= 56320 && low <= 57343) { + length--; + i++; + } + } + return length; +} +function lineEnd(state, line) { + return Math.min(state.eMarks[line] + 1, state.src.length); +} +function getNextLinePos(state, nextLine) { + const endLine = state.lineMax; + if (nextLine >= endLine || state.isEmpty(nextLine)) return -1; + let isContinuation = false; + if (state.sCount[nextLine] - state.blkIndent > 3) isContinuation = true; + if (state.sCount[nextLine] < 0) isContinuation = true; + if (!isContinuation) { + const terminatorRules = state.md.block.ruler.getRules("reference"); + const oldParentType = state.parentType; + state.parentType = "reference"; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + state.parentType = oldParentType; + if (terminate) return -1; + } + return state.bMarks[nextLine] + state.tShift[nextLine]; +} function reference(state, startLine, _endLine, silent) { + const src = state.src; let pos = state.bMarks[startLine] + state.tShift[startLine]; - let max = state.eMarks[startLine]; let nextLine = startLine + 1; if (state.sCount[startLine] - state.blkIndent >= 4) return false; - if (state.src.charCodeAt(pos) !== 91) return false; - function getNextLine(nextLine) { - const endLine = state.lineMax; - if (nextLine >= endLine || state.isEmpty(nextLine)) return null; - let isContinuation = false; - if (state.sCount[nextLine] - state.blkIndent > 3) isContinuation = true; - if (state.sCount[nextLine] < 0) isContinuation = true; - if (!isContinuation) { - const terminatorRules = state.md.block.ruler.getRules("reference"); - const oldParentType = state.parentType; - state.parentType = "reference"; - let terminate = false; - for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { - terminate = true; - break; - } - state.parentType = oldParentType; - if (terminate) return null; - } - const pos = state.bMarks[nextLine] + state.tShift[nextLine]; - const max = state.eMarks[nextLine]; - return state.src.slice(pos, max + 1); - } - let str = state.src.slice(pos, max + 1); - max = str.length; + if (src.charCodeAt(pos) !== 91) return false; + let max = lineEnd(state, startLine); + let rawLabel = ""; let labelEnd = -1; - for (pos = 1; pos < max; pos++) { - const ch = str.charCodeAt(pos); + let segmentStart = ++pos; + while (pos < max) { + if (rawLabel.length + pos - segmentStart > MAX_LABEL_LENGTH * 2) return false; + let ch = src.charCodeAt(pos); if (ch === 91) return false; - else if (ch === 93) { + if (ch === 93) { labelEnd = pos; break; - } else if (ch === 10) { - const lineContent = getNextLine(nextLine); - if (lineContent !== null) { - str += lineContent; - max = str.length; - nextLine++; - } - } else if (ch === 92) { - pos++; - if (pos < max && str.charCodeAt(pos) === 10) { - const lineContent = getNextLine(nextLine); - if (lineContent !== null) { - str += lineContent; - max = str.length; - nextLine++; - } - } } + if (ch === 92) ch = src.charCodeAt(++pos); + if (ch === 10 && pos < max) { + const nextPos = getNextLinePos(state, nextLine); + if (nextPos < 0) return false; + rawLabel += src.slice(segmentStart, max); + pos = segmentStart = nextPos; + max = lineEnd(state, nextLine++); + continue; + } + pos++; } - if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58) return false; - for (pos = labelEnd + 2; pos < max; pos++) { - const ch = str.charCodeAt(pos); + if (labelEnd < 0 || src.charCodeAt(labelEnd + 1) !== 58) return false; + rawLabel += src.slice(segmentStart, labelEnd); + if (rawLabel.length > MAX_LABEL_LENGTH && countCodePoints(rawLabel) > MAX_LABEL_LENGTH) return false; + pos = labelEnd + 2; + while (pos < max) { + const ch = src.charCodeAt(pos); if (ch === 10) { - const lineContent = getNextLine(nextLine); - if (lineContent !== null) { - str += lineContent; - max = str.length; - nextLine++; - } - } else if (isSpace(ch)) {} else break; + const nextPos = getNextLinePos(state, nextLine); + if (nextPos < 0) break; + pos = nextPos; + max = lineEnd(state, nextLine++); + } else if (isSpace(ch)) pos++; + else break; } - const destRes = state.md.helpers.parseLinkDestination(str, pos, max); + const destRes = state.md.helpers.parseLinkDestination(src, pos, max); if (!destRes.ok) return false; const href = state.md.normalizeLink(destRes.str); if (!state.md.validateLink(href)) return false; pos = destRes.pos; const destEndPos = pos; + const destEndMax = max; const destEndLineNo = nextLine; - const start = pos; - for (; pos < max; pos++) { - const ch = str.charCodeAt(pos); + while (pos < max) { + const ch = src.charCodeAt(pos); if (ch === 10) { - const lineContent = getNextLine(nextLine); - if (lineContent !== null) { - str += lineContent; - max = str.length; - nextLine++; - } - } else if (isSpace(ch)) {} else break; + const nextPos = getNextLinePos(state, nextLine); + if (nextPos < 0) break; + pos = nextPos; + max = lineEnd(state, nextLine++); + } else if (isSpace(ch)) pos++; + else break; } - let titleRes = state.md.helpers.parseLinkTitle(str, pos, max); + const titleStart = pos; + let titleRes = state.md.helpers.parseLinkTitle(src, pos, max); while (titleRes.can_continue) { - const lineContent = getNextLine(nextLine); - if (lineContent === null) break; - str += lineContent; - pos = max; - max = str.length; - nextLine++; - titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes); + const nextPos = getNextLinePos(state, nextLine); + if (nextPos < 0) break; + pos = nextPos; + max = lineEnd(state, nextLine++); + titleRes = state.md.helpers.parseLinkTitle(src, pos, max, titleRes); } let title; - if (pos < max && start !== pos && titleRes.ok) { + if (titleStart !== destEndPos && titleRes.ok) { title = titleRes.str; pos = titleRes.pos; } else { title = ""; pos = destEndPos; + max = destEndMax; nextLine = destEndLineNo; } while (pos < max) { - if (!isSpace(str.charCodeAt(pos))) break; + if (!isSpace(src.charCodeAt(pos))) break; pos++; } - if (pos < max && str.charCodeAt(pos) !== 10) { + if (pos < max && src.charCodeAt(pos) !== 10) { if (title) { title = ""; pos = destEndPos; + max = destEndMax; nextLine = destEndLineNo; while (pos < max) { - if (!isSpace(str.charCodeAt(pos))) break; + if (!isSpace(src.charCodeAt(pos))) break; pos++; } } } - if (pos < max && str.charCodeAt(pos) !== 10) return false; - const label = normalizeReference(str.slice(1, labelEnd)); + if (pos < max && src.charCodeAt(pos) !== 10) return false; + const label = normalizeReference(rawLabel); if (!label) return false; /* istanbul ignore if */ if (silent) return true; @@ -46297,7 +46347,7 @@ var html_blocks_default = [ //#region src/common/html_re.ts var open_tag = `<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`; var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>"; -var HTML_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag}||<[?][\\s\\S]*?[?]>|]*>|)`); +new RegExp(`^(?:${open_tag}|${close_tag}||<[?][\\s\\S]*?[?]>|]*>|)`); var HTML_OPEN_CLOSE_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag})`); //#endregion //#region src/rules_block/html_block.ts @@ -46623,6 +46673,7 @@ var StateInline = class { _defineProperty(this, "cache", {}); _defineProperty(this, "backticks", {}); _defineProperty(this, "backticksScanned", false); + _defineProperty(this, "skipHtmlSpecial", false); _defineProperty(this, "linkLevel", 0); _defineProperty(this, "delimiters", []); _defineProperty(this, "_prev_delimiters", []); @@ -46789,16 +46840,19 @@ function newline(state, silent) { if (state.src.charCodeAt(pos) !== 10) return false; const pmax = state.pending.length - 1; const max = state.posMax; - if (!silent) if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) { - let ws = pmax - 1; - while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--; - state.pending = state.pending.slice(0, ws); - state.push("hardbreak", "br", 0); - } else { - state.pending = state.pending.slice(0, -1); - state.push("softbreak", "br", 0); + if (!silent) { + if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) { + if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) { + let ws = pmax - 1; + while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--; + state.pending = state.pending.slice(0, ws); + state.push("hardbreak", "br", 0); + } else { + state.pending = state.pending.slice(0, -1); + state.push("softbreak", "br", 0); + } + } else state.push("softbreak", "br", 0); } - else state.push("softbreak", "br", 0); pos++; while (pos < max && isSpace(state.src.charCodeAt(pos))) pos++; state.pos = pos; @@ -47287,22 +47341,53 @@ function isLetter(ch) { const lc = ch | 32; return lc >= 97 && lc <= 122; } +function scanSpecial(state, pos) { + const src = state.src; + let start; + let terminator; + if (src.startsWith(""; + } else if (src.startsWith(""; + } else if (src.charCodeAt(pos + 1) === 63) { + start = pos + 2; + terminator = "?>"; + } else if (isLetter(src.charCodeAt(pos + 2))) { + start = pos + 3; + terminator = ">"; + } else return -1; + if (state.skipHtmlSpecial) return -1; + const end = src.indexOf(terminator, start); + if (end < 0) { + state.skipHtmlSpecial = true; + return -1; + } + return end + terminator.length; +} function html_inline(state, silent) { if (!state.md.options.html) return false; const max = state.posMax; const pos = state.pos; if (state.src.charCodeAt(pos) !== 60 || pos + 2 >= max) return false; + let end; const ch = state.src.charCodeAt(pos + 1); - if (ch !== 33 && ch !== 63 && ch !== 47 && !isLetter(ch)) return false; - const match = state.src.slice(pos).match(HTML_TAG_RE); - if (!match) return false; + if (ch === 33 || ch === 63) end = scanSpecial(state, pos); + else if (ch === 47 || isLetter(ch)) { + const match = state.src.slice(pos).match(HTML_OPEN_CLOSE_TAG_RE); + end = match ? pos + match[0].length : -1; + } else return false; + if (end < 0) return false; if (!silent) { const token = state.push("html_inline", "", 0); - token.content = match[0]; + token.content = state.src.slice(pos, end); if (isLinkOpen(token.content)) state.linkLevel++; if (isLinkClose(token.content)) state.linkLevel--; } - state.pos += match[0].length; + state.pos = end; return true; } //#endregion @@ -53764,6 +53849,6476 @@ const node_imports_node_os = { EOL: external_node_os_namespaceObject.EOL, homedi const node_imports_node_path = { dirname: external_node_path_namespaceObject.dirname, resolve: external_node_path_namespaceObject.resolve }; +;// CONCATENATED MODULE: ./node_modules/re2js/build/index.js +/*! +* re2js +* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching +* +* @version v2.8.6 +* @author Oleksii Vasyliev +* @homepage https://github.com/le0pard/re2js#readme +* @repository github:le0pard/re2js +* @license MIT +*/ +//#region src/RE2Flags.js +var RE2Flags = class RE2Flags { + static FOLD_CASE = 1; + static LITERAL = 2; + static CLASS_NL = 4; + static DOT_NL = 8; + static ONE_LINE = 16; + static NON_GREEDY = 32; + static PERL_X = 64; + static UNICODE_GROUPS = 128; + static WAS_DOLLAR = 256; + static LOOKBEHIND = 512; + static MATCH_NL = RE2Flags.CLASS_NL | RE2Flags.DOT_NL; + static PERL = RE2Flags.CLASS_NL | RE2Flags.ONE_LINE | RE2Flags.PERL_X | RE2Flags.UNICODE_GROUPS; + static POSIX = 0; + static UNANCHORED = 0; + static ANCHOR_START = 1; + static ANCHOR_BOTH = 2; +}; +//#endregion +//#region src/PublicFlags.js +/** +* Public flags for RE2JS and RE2Set compilation. +*/ +const PublicFlags = { + CASE_INSENSITIVE: 1, + DOTALL: 2, + MULTILINE: 4, + DISABLE_UNICODE_GROUPS: 8, + LONGEST_MATCH: 16, + LOOKBEHINDS: 512 +}; +//#endregion +//#region src/Codepoint.js +/** +* Various constants and helper for unicode codepoints. +*/ +const ASCII_SIZE = 128; +const ASCII_TO_UPPER = new Int32Array(ASCII_SIZE); +const ASCII_TO_LOWER = new Int32Array(ASCII_SIZE); +const MAX_BMP = 65535; +for (let i = 0; i < ASCII_SIZE; i++) { + if (i >= 97 && i <= 122) ASCII_TO_UPPER[i] = i - 32; + else ASCII_TO_UPPER[i] = i; + if (i >= 65 && i <= 90) ASCII_TO_LOWER[i] = i + 32; + else ASCII_TO_LOWER[i] = i; +} +var Codepoint = class { + static CODES = /* @__PURE__ */ new Map([ + ["\x07", 7], + ["\b", 8], + [" ", 9], + ["\n", 10], + ["\v", 11], + ["\f", 12], + ["\r", 13], + [" ", 32], + ["\"", 34], + ["$", 36], + ["&", 38], + ["'", 39], + ["(", 40], + [")", 41], + ["*", 42], + ["+", 43], + ["-", 45], + [".", 46], + ["0", 48], + ["1", 49], + ["2", 50], + ["3", 51], + ["4", 52], + ["5", 53], + ["6", 54], + ["7", 55], + ["8", 56], + ["9", 57], + [":", 58], + ["<", 60], + [">", 62], + ["?", 63], + ["A", 65], + ["B", 66], + ["C", 67], + ["F", 70], + ["P", 80], + ["Q", 81], + ["U", 85], + ["Z", 90], + ["[", 91], + ["\\", 92], + ["]", 93], + ["^", 94], + ["_", 95], + ["`", 96], + ["a", 97], + ["b", 98], + ["f", 102], + ["i", 105], + ["m", 109], + ["n", 110], + ["r", 114], + ["s", 115], + ["t", 116], + ["v", 118], + ["x", 120], + ["z", 122], + ["{", 123], + ["|", 124], + ["}", 125] + ]); + static toUpperCase(codepoint) { + if (codepoint < ASCII_SIZE) return ASCII_TO_UPPER[codepoint]; + const s = String.fromCodePoint(codepoint).toUpperCase(); + const expectedLen = s.codePointAt(0) > MAX_BMP ? 2 : 1; + if (s.length > expectedLen) return codepoint; + const sOrigin = String.fromCodePoint(s.codePointAt(0)).toLowerCase(); + const originExpectedLen = sOrigin.codePointAt(0) > MAX_BMP ? 2 : 1; + if (sOrigin.length > originExpectedLen || sOrigin.codePointAt(0) !== codepoint) return codepoint; + return s.codePointAt(0); + } + static toLowerCase(codepoint) { + if (codepoint < ASCII_SIZE) return ASCII_TO_LOWER[codepoint]; + const s = String.fromCodePoint(codepoint).toLowerCase(); + const expectedLen = s.codePointAt(0) > MAX_BMP ? 2 : 1; + if (s.length > expectedLen) return codepoint; + const sOrigin = String.fromCodePoint(s.codePointAt(0)).toUpperCase(); + const originExpectedLen = sOrigin.codePointAt(0) > MAX_BMP ? 2 : 1; + if (sOrigin.length > originExpectedLen || sOrigin.codePointAt(0) !== codepoint) return codepoint; + return s.codePointAt(0); + } +}; +//#endregion +//#region src/UnicodeRangeTable.js +var UnicodeRangeTable = class { + /** + * @param {Uint32Array | number[]} data + * @param {boolean} isStride1 + */ + constructor(data, isStride1 = false) { + this.data = data; + this.isStride1 = isStride1; + this.SIZE = isStride1 ? 2 : 3; + } + getLo(index) { + return this.data[index * this.SIZE]; + } + getHi(index) { + return this.data[index * this.SIZE + 1]; + } + getStride(index) { + return this.isStride1 ? 1 : this.data[index * this.SIZE + 2]; + } + get length() { + return this.data.length / this.SIZE; + } +}; +//#endregion +//#region src/UnicodeTables.js +const B64_MAP = /* @__PURE__ */ new Uint8Array(256); +for (let i = 0, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; i < 64; i++) B64_MAP[b.charCodeAt(i)] = i; +const decodeVLQ = (str) => { + const res = []; + let value = 0, shift = 0; + for (let i = 0; i < str.length; i++) { + let digit = B64_MAP[str.charCodeAt(i)]; + value |= (digit & 31) << shift; + if ((digit & 32) === 0) { + res.push(value); + value = 0; + shift = 0; + } else shift += 5; + } + return res; +}; +const decodeRanges = (str, isStride1) => { + const res = decodeVLQ(str); + const numRanges = isStride1 ? res.length / 2 : res.length / 3; + const out = new Uint32Array(numRanges * 3); + let current = 0, resIdx = 0; + for (let i = 0; i < numRanges; i++) { + current += res[resIdx++]; + out[i * 3] = current; + current += res[resIdx++]; + out[i * 3 + 1] = current; + out[i * 3 + 2] = isStride1 ? 1 : res[resIdx++]; + } + return out; +}; +const decodeOrbit = (str) => { + const res = decodeVLQ(str); + const map = /* @__PURE__ */ new Map(); + let currentKey = 0; + for (let i = 0; i < res.length; i += 2) { + currentKey += res[i]; + const zz = res[i + 1]; + const delta = zz >>> 1 ^ -(zz & 1); + map.set(currentKey, currentKey + delta); + } + return map; +}; +var LazyMap = class { + constructor(initializer) { + this.initializer = initializer; + this.cache = /* @__PURE__ */ new Map(); + } + has(key) { + return key in this.initializer; + } + get(key) { + if (this.cache.has(key)) return this.cache.get(key); + const fn = this.initializer[key]; + const val = fn ? fn() : null; + this.cache.set(key, val); + return val; + } +}; +var UnicodeTables = class { + static _CASE_ORBIT = null; + static get CASE_ORBIT() { + if (!this._CASE_ORBIT) this._CASE_ORBIT = decodeOrbit("rCgCIgCY+rQI4QiCuuBLgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCCgCBgCBgCBgCBgCBgCBgCB+7OB-BB-BB-BB-BB-BBskQB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BC-BB-BB-BB-BB-BB-BB-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BBF-6DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBrCHBxDUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIlkzVBxHvw-FB", false)), + Cc: () => new UnicodeRangeTable(decodeRanges("AfgDgB", true)), + Cf: () => new UnicodeRangeTable(decodeRanges("tFzqBzqBBEBXhGhGyBhMhMBxCxCs5D9-B9-BBDBbEByBEBCJBw03B6H6HBBBimEQQj7IPBhjiBDBwmFHBn0rYffB+CB", false)), + Cn: () => new UnicodeRangeTable(decodeRanges("4bBBHDBICCVuMuMnBBBzBBBE4B4BBGBcDBHKBvI9B9BBmDmDBMB8BBByBBBQddBCCMEBjBEBuHJJBDDBXXICCBBBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGG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BcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMB3iBJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBJ76DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBjGUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-BB---BBB---BBB", false)), + Co: () => new UnicodeRangeTable(decodeRanges("gg4B-nGh4hc9--BD9--B", true)), + Cs: () => new UnicodeRangeTable(decodeRanges("gg2B--B", true)), + L: () => new UnicodeRangeTable(decodeRanges("hCZBHZBwBLLFGGBVBCeBCpOBFLBPEBICCiEEBCBBDDBCHHCCBCCCBSBCyCBCqEBJlFBClBBDHHBnBBoCaBFDBuBqBBkBBBCiDB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able(decodeRanges("hBCBCFBCDBLBBEBBbCBCccCkBkBGEELBBEEE-VJJzOFBqBBB0BCCDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCmBmBBCBoCrCrCBDBFBBwDFBsFlTlTBHB4EuTuTtBBBvCCBoCBB+ECBCCBmBKB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBM9Z9ZBWBJTBCMBCLBfBBPBB6TDBeBB+hBNBwCBBgBJB0MVBgCDBhBBB8XDBCBBxDwEwEBtBBCfBDLBkNCBFJBDLBRNNjD7C7CjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HzqUzqUBxGxGBIBXiBBCNBCFFCBB2ECBCFBCDBLBBEBBbCBCccCCCBFB7MCB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDByO-J-JjBlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB", false)), + Pc: () => new UnicodeRangeTable(decodeRanges("-Cg-Hg-HBUU-u3BBBZCBwHAB", false)), + Pd: () => new UnicodeRangeTable(decodeRanges("tB9qB9qB0BiyDiyDmgBqgCqgCBEBiwDDDgBBBFdd-NUUwDxszBxszBBmBmBLqFqFhzD-J-J", false)), + Pe: () => new UnicodeRangeTable(decodeRanges("pB0B0BgB+1D+1DC-6B-6BqtC4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECtBGCtNICEGCDBB-ozB6G6GeOCESSCCCrF0B0BgBGD", false)), + Pf: () => new UnicodeRangeTable(decodeRanges("7F+6H+6HEddpuDCCFDDQEE", false)), + Pi: () => new UnicodeRangeTable(decodeRanges("rFt7Ht7HDBBDaapuDCCFDDQEE", false)), + Po: () => new UnicodeRangeTable(decodeRanges("hBCBCCBDECBLLBEEBcclCGGPBBI-V-VJzOzOBEBqB3B3BDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCxDxDrCEBFBBwDFBsFlTlTBHBmY9D9DBBBoCBB+ECBCCBmBFBCDB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBMjajaBJJBGBJIBDDBDCBEKBCCCBIB7kDDBCBBxDwEwEBFFBBBDDDBHBCBBCDDBLLBDBCJBDDBCCCBLBDCBtNCB6B+F+FjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HlxUlxUBFBDXXVBBDDBECBCDBICBHCCB2E2EBBBCCBDECBLLBEEBcclBDDB7M7MBBB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDB0ZlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB", false)), + Ps: () => new UnicodeRangeTable(decodeRanges("oBzBzBgB-1D-1DC-6B-6B-rCEEnB4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECaTTCECtNICEGCDipzBipzB4GeeCMCESSCCCrFzBzBgBEEDAB", false)), + S: () => new UnicodeRangeTable(decodeRanges("kBHHRCBgBCCcCCkBEBCBBDCCBCBDEEfgBgBrODBNNBGGBCCCBPB2DPPBxDxDsErIrIBBB3DCBDDDBvGvGLUUB4H4HIBBpEqLqLBHHB2H2H-DjEjEBGBlEwGwGqBmGmGiGCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WuLuLlL+E+EBgBBiLJBKIBhiBCCBBBMCBOCBOCBOBBmCOOoBCBOCBUhBB-BBBCDBCBBLCCBBBGFBCECFMMBFFBDBGDBC7B7BBFFB2LBFcBD+HBXKByCtCBXnTBtBwBBDeBLyMBX+BBFfBD1LBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBB8CBB0HBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BB6RWBKBBoDBB+EDBLDB+RCBiHPPB+9T+9TpEgBBuLPBhCBB3BHBtBDBjDCCBBBD7E7EHRRBBBgBCCcCCiEGBCGBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSmWmWBiKiKBGBnjC2kC2kCBbBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQQBgDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBrbaagBaagBaagBaagBaa9B-PB4BDBzBHBCNBCBBp2BwNwNttCEE+DiOiOBvIvIBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB", false)), + Sc: () => new UnicodeRangeTable(decodeRanges("kB+D+DBCBqnB8D8DzPBBzPBBI2H2HoImSmS8sClmClmCBgBB37hBkuVkuVtD7E7E8GBBEBB3-HDB-4wBxtCxtC", false)), + Sk: () => new UnicodeRangeTable(decodeRanges("+CCCoCHHFEEqQDBNNBGGBCCCBPB2DPPBjoBjoB15FCCBBBMCBOCBOCBOBB9kEBBkzdWBKBBoDBBxePPBniUniUBPB8bCCjF4g9B4g9BBDB", false)), + Sm: () => new UnicodeRangeTable(decodeRanges("rBRRBBB+BCCuBFFmBgBgB-XwQwQBBB8xGOOoBCBOCBsEoBoBBDBHlClCBDBGBBFGDIgBgBBDDCgBgBBqIBhBBB7CffBXBpBFB2OKK3BHBwDxKxKBDBDeBLPBhIiEBX+BBFfBDhIBxBUBDFB9+zB5Z5ZCCBlFRRBBB+BCCkEHHBCBitDBBhrwBx+Bx+BagBgBagBgBagBgBagBgBat5Ft5FB-uC-uCBHB", false)), + So: () => new UnicodeRangeTable(decodeRanges("mFDDFCCyerIrIBgEgEBvGvGLUUB4H4HkQ2L2LjEFBClElEwGqBqBoMCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WzWzW+EhBBiLJBKIBksBBBCDBCBBLCCBHHBEBCECFMMBPPCBBC7B7BBKKBDBDDBCBBCBBCGBCeBDBBCCCBdBtIHBFTBDGBDwCBCdBanBBHnCBXKByCtCBX2FBCIBC1BBJuDBC3HBtBrBBhC-HBhQvBBWBBHmBBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBBxKBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BBibDBLBBC+R+RBBBqqUPBuLPBhCBB3BHBuBCBlPEEFBBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSpgBpgBBGBnjC2kC2kCBGBFQBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQPBhDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBqlB-PB4BDBzBHBCNBCBBp2B96C96CiEyWyWBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E6HBG4WBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBB-B3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB", false)), + Z: () => new UnicodeRangeTable(decodeRanges("gBgEgEgvFgsCgsCBJBeBBGwBwBh9DAB", false)), + Zl: () => new UnicodeRangeTable(decodeRanges("ohIA", true)), + Zp: () => new UnicodeRangeTable(decodeRanges("phIA", true)), + Zs: () => new UnicodeRangeT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ECCBEEDJBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB", false)), + Emoji_Component: () => new UnicodeRangeTable(decodeRanges("jBHHGJB0+H2G2Gsp3B3+8B3+8BBYB8PEBxtBDBtzhY-CB", false)), + Emoji_Modifier: () => new UnicodeRangeTable(decodeRanges("7-8DE", true)), + Emoji_Modifier_Base: () => new UnicodeRangeTable(decodeRanges("9wJ8G8GRDB4jzD9B9BBBBDDDBBB2DBBDKBWSBEFFBBBCCBICCZqGqGBFFWFFBvFvFBBBEEB0CRRBBBKMMgSDDJHBHKKBIBDCB5B+B+BBCCBCCSCBCMBmHCBrBIB", false)), + Emoji_Presentation: () => new UnicodeRangeTable(decodeRanges("64IBBuGDBEDDqQBBWBBzBLBsBUUOJJBSSBGGBJJGWWIBBCFFDIIFBBdkBkBCFFBBBC+B+BBBBZPP8aBB0BFFvlxDrGrG-FDDBIBsCZBCZZVDDBDBCCBWBBvFgBBNIBClCBCVBNqBBFEBNQBEEEBlCBCCCB5FBD+BBODBCXBTbbBOO3C0CBxBlCBHEEBBBDDBEDBMBBIIBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB", false)), + Extended_Pictographic: () => new UnicodeRangeTable(decodeRanges("pFFFu8HNN5GXX7CFBQBBwLBBNnFnFaKBFCBoGoHoHBLLK7B7BBCBCEBKGDBDDFDDCBBDIEBJJBBBGCCGLBMBBDCCBCCTDDBTTBEBCCCBEEBGGDBBFBBMBBGBBDGGBECBVVBGGBEBCDBDFFDDDBEBCDDCCCHEEHLLBQQDFFCFFBBBCMMBxBxBBBBKeP1LBBwOCBUBB0BFF7mBNN6SCCrrvDoBoBBCBlDLBQBBQPPBmBmBBIBxDBBNBBPDDBIBU3BBcOBLVVDIBCDBKWBH7FBDvDBDBBCCBDyCBDCBCDBG9HBC+BBMFBCXBIBBDHBNDDBCBDFFBOOBDDJBBKGGBBBNCBJCBDCCFHHEHHB0CBxBlCBGHBDQBECCBEBDMB7GlBBNDB5BHBLFBpBHBfBBNDBDNBKmBBNuBBCJBC4FB5CHBPxEBhI9fB", false)), + Hex_Digit: () => new UnicodeRangeTable(decodeRanges("wBJIFbFq1-BJIFbF", true)), + Lowercase: () => new UnicodeRangeTable(decodeRanges("hDZBwBLLFlBlBBWBCHBC2BCBQCBuBCDECBBBDCCDEEBFFDEEBBBDDDCCCDCCBCCDEECDDBDDBBBHGDCOCBSCBDDCEEC4BCBFBDDDBCCFICBjCBDiBBIBBfEBhDsBsBCEEDDBTccBhBBCBBECBCWCBDBCGDB0B0BBuBBCgBCK0BCDMCBgDCxBoBBo6CqBBCDB5XFBjkCIBC2D2DB+FBiC0ECBHBCgDCBHBJFBLHBJHBJFBLHBJHBJNBDHBJHBJHBJEBCBBHEEBBBCBBJDBDBBJHBLCBCBB6DOORMBuDEEBEEcKFDBBJDBFiBiBBOBFsasaBYBn6BvBBCEEBGCFCCBCCBGBEiDCBIICFFNlBBCGG0oesBCUaCBBBmEMCBBBC8BCBIBCCCDICFCCDCCBBBCSCGGGCMCFCCDOCWDBCCCBBB2ZqBBCNBHvCBh6TGBNEBqhBZBumBnBBpEjBB8EKBCOBCGBCBBkODDBBBCpBBCIBmoByBB+DVB75CfBhsVfB8BYBnqZZBbGBCRBbZBbDBCCCBFBCKBbZBbZBbZBbZBbZBbZBbZBbZBbbBdYBCFBbYBCFBbYBCFBbYBCFBbYBCFBC15B15BBIBCTBHFBmI9BB1lChBB", false)), + Math: () => new UnicodeRangeTable(decodeRanges("rBRRBBBgBeeCuBuBFmBmBgB5W5WBBBDbbBDDBBBwQCBuwGccBBBMEEOPPBCBWEBMEBiCMBFEEBFFBDBTFFDJBCDDBEBHEEBDDBCCBBBCFBENBClClCBWBCFBCBBFBBFfBCHHBPPBqIBJDBVBB7CffBZBCZZMGB+NBBNJBFFBFBBDBBEEBPCCDFBMHBGBB6BCCeDBKCBxK-BBhI-PBxBUBDFB9+zB4Z4ZBEBCjFjFRCBeCCeCCkEHHBCBitDBBhrwBwoBwoBBzCBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBBhwFDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB-uCIB", false)), + Quotation_Mark: () => new UnicodeRangeTable(decodeRanges("iBFFkEQQ96HHBaBBowDqOqOBCBOCBixzBDB+FFF7CBB", false)), + Terminal_Punctuation: () => new UnicodeRangeTable(decodeRanges("hBLLCMMBEE-ZJJiQ6B6BpCPPCCB1FsBsBBJBCsHsHB3B3BBEBCHBgBmImIB1nB1nBBtFtFFFB4JBB2YHBmY9D9DBBBoCBB+ECBEoBoBBCBDBB7JBBjLDBjFBBLBBCCBeCB8FEB-BBBldYYBKKBBBwlDCBzJOOFLLCBBEBBtNBB8ndBBuICBkHEB-LBB3CBBgD4E4EBBB0ECBgERRB6H6HnxUDDB6B6BBBBCDBqFLLCMMBEEiCDD7hBxBxBnkBoGoG3JBB5EFBlCFB6CDB5dEBtBDB+FGBxDDBgECBiEBBHRRB5C5CBDBtDrJrJB2D2DBBBNBBnLDBEOBqDBB6HCBmQCC8HBB4CBBFBB-MCBuBmUmUBrCrCBspBspBBDB6vRBBmEiCiCBBBLqRqRBoJoJBnwTnwTovHDB", false)), + Uppercase: () => new UnicodeRangeTable(decodeRanges("hCZBmDWBCGBiB2BCDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIJDCMCDQCDDDCCBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBDDBBBEWCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBpCDBNDBNDBNEBMDBnIFFECBDCBDEEBDBHGCBCBDDBLBBGbbBOBUzZzZBYBx5BvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoqZZBbZBbZBbCCBGDBDDBCBCHBbZBbBBCDBDHBCGBcBBCDBCEBCEEBFBcZBbZBbZBbZBbZBbZBfYBiBYBiBYBiBYBiBYBiB2pE2pEBgBBvgCZBHZBHZB", false)), + White_Space: () => new UnicodeRangeTable(decodeRanges("JEBTlDlDbgvFgvFgsCKBeBBGwBwBh9DAB", false)) + }); + static get Upper() { + return this.CATEGORIES.get("Lu"); + } + static SCRIPTS = new LazyMap({ + Adlam: () => new UnicodeRangeTable(decodeRanges("go6DrCFJFB", true)), + Ahom: () => new UnicodeRangeTable(decodeRanges("g4lCaDOFW", true)), + Anatolian_Hieroglyphs: () => new UnicodeRangeTable(decodeRanges("ggxCmS", true)), + Arabic: () => new UnicodeRangeTable(decodeRanges("gwBEBCFBCNBCCBCfBCJBMZBCrDBChBBxCvBBxHhBBGqCBCcBxy8BtPBDvEBhBPBxDEBCmEBk7DeBkCFBJIBiBFBh43BDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB", false)), + Armenian: () => new UnicodeRangeTable(decodeRanges("xpBlBDxBDCks9BE", true)), + Avestan: () => new UnicodeRangeTable(decodeRanges("g4iC1BEG", true)), + Balinese: () => new UnicodeRangeTable(decodeRanges("g4GsCCxB", true)), + Bamum: () => new UnicodeRangeTable(decodeRanges("g1pB3CpowB4R", true)), + Bassa_Vah: () => new UnicodeRangeTable(decodeRanges("w26CdDF", true)), + Batak: () => new UnicodeRangeTable(decodeRanges("g+GzBJD", true)), + Bengali: () => new UnicodeRangeTable(decodeRanges("gsCDBCHBDBBDVBCGBCEEBCBDIBDBBDDBJFFBCCBDBDYB", false)), + Beria_Erfe: () => new UnicodeRangeTable(decodeRanges("g17CYDY", true)), + Bhaiksuki: () => new UnicodeRangeTable(decodeRanges("ggnCICsBCNLc", true)), + Bopomofo: () => new UnicodeRangeTable(decodeRanges("qXB6wLqBxDf", true)), + Brahmi: () => new UnicodeRangeTable(decodeRanges("ggkCtCFjBKA", true)), + Braille: () => new UnicodeRangeTable(decodeRanges("ggK-H", true)), + Buginese: () => new UnicodeRangeTable(decodeRanges("gwGbDB", true)), + Buhid: () => new UnicodeRangeTable(decodeRanges("g6FT", true)), + Canadian_Aboriginal: () => new UnicodeRangeTable(decodeRanges("ggF-TxRlC7tgCP", true)), + Carian: () => new UnicodeRangeTable(decodeRanges("g1gCwB", true)), + Caucasian_Albanian: () => new UnicodeRangeTable(decodeRanges("wphCzBMA", true)), + Chakma: () => new UnicodeRangeTable(decodeRanges("gokC0BCR", true)), + Cham: () => new UnicodeRangeTable(decodeRanges("gwqB2BKNDJDD", true)), + Cherokee: () => new UnicodeRangeTable(decodeRanges("g9E1CDFz7lBvC", true)), + Chorasmian: () => new UnicodeRangeTable(decodeRanges("w9jCb", true)), + Common: () => new UnicodeRangeTable(decodeRanges("AgCBbFBbuBBCOBCEBYgBgBiOmBBGEBDTB1DKKHCC+THHPEEhB9E9ElQiEiEB6mB6mB2MDBjJwvBwvBBBBoCBBsGBBCumBumBOIIBCBCFBCCBDmYmYBKBD2CBCKBEKBCOBShBB-BlBBCCBDFBCaBCQBqBCBF5UBXKBW-cBhIzTBDpEBhQ9CBzMUBCCCBXBQHBFDB8CBBE7C7CB0E0EBOBhBlBBKxBxBB+BBgBwCBwB5C5CBmFBhuG-BBhoWhBBnDCBmFJB1HhFhFsMPPBzuUzuUBxGxGBIBXiBBCSBCDB0ECCBeBbFBbKBLuBuBBhChCBFBCGBLEBjICBFsBBEIBxCMB0BsBBlHaBltuBDB96D8HBEzNBHWBQQBgDzDB9B1HBLmBBD9BBEQBJBBIdBF8BB2GTBNTBN2CBKYBoE0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBByjFjCBtC8BBjWrBBFjDBNOBDOBCOBCkBBLtFB5BZBCBBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBCmDBnghYffB+CB", false)), + Coptic: () => new UnicodeRangeTable(decodeRanges("ifNxkKzDGG", true)), + Cuneiform: () => new UnicodeRangeTable(decodeRanges("ggoC5cnDuDCEMjG", true)), + Cypriot: () => new UnicodeRangeTable(decodeRanges("ggiCFBDCCBqBBCBBEDD", false)), + Cypro_Minoan: () => new UnicodeRangeTable(decodeRanges("w8rCiD", true)), + Cyrillic: () => new UnicodeRangeTable(decodeRanges("ggBkEBDoFBx6FKBhFtCtCojEfBhie-CBv8VBBhw4B9BBiBAB", false)), + Deseret: () => new UnicodeRangeTable(decodeRanges("gghCvC", true)), + Devanagari: () => new UnicodeRangeTable(decodeRanges("goCwCFODZh7nBfhwcJ", true)), + Dives_Akuru: () => new UnicodeRangeTable(decodeRanges("gomCGBDDDBGBCBBCdBCBBDLBKJB", false)), + Dogra: () => new UnicodeRangeTable(decodeRanges("ggmC7B", true)), + Duployan: () => new UnicodeRangeTable(decodeRanges("ggvDqDGMEIIJDD", true)), + Egyptian_Hieroglyphs: () => new UnicodeRangeTable(decodeRanges("ggsC1iBL68D", true)), + Elbasan: () => new UnicodeRangeTable(decodeRanges("gohCnB", true)), + Elymaic: () => new UnicodeRangeTable(decodeRanges("g-jCW", true)), + Ethiopic: () => new UnicodeRangeTable(decodeRanges("gwEoCBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBDfBEZBnvGWBKGBCGBCGBCGBCGBCGBCGBCGBjpfFBDFBDFBKGBCGBylvCGBCDBCBBCOB", false)), + Garay: () => new UnicodeRangeTable(decodeRanges("gqjClBEcJB", true)), + Georgian: () => new UnicodeRangeTable(decodeRanges("glElBBCGGDqBBCDBx8CqBBDCBhiElBBCGG", false)), + Glagolitic: () => new UnicodeRangeTable(decodeRanges("ggL-Ch9sDGCQDGCBCE", true)), + Gothic: () => new UnicodeRangeTable(decodeRanges("w5gCa", true)), + Grantha: () => new UnicodeRangeTable(decodeRanges("g4kCDBCHBDBBDVBCGBCBBCEBDIBDBBDCBDHHGGBDGBEEB", false)), + Greek: () => new UnicodeRangeTable(decodeRanges("wbDBCCBDDBCFFCCCBBBCCCBSBC+BBPPBnpGEBzBEBFEB1ChKhKBUBDFBDlBBDFBDHBCGCBdBD0BBCOBCNBDFBCSBDCBCIBoJ-xiB-xiB7uVuCBSgj0Bgj0BBkCB", false)), + Gujarati: () => new UnicodeRangeTable(decodeRanges("h0CCBCIBCCBCVBCGBCBBCEBDJBCCBCCBDQQBCBDLBIGB", false)), + Gunjala_Gondi: () => new UnicodeRangeTable(decodeRanges("grnCFCBCkBCBCFIJ", true)), + Gurmukhi: () => new UnicodeRangeTable(decodeRanges("hwCCBCFBFBBDVBCGBCBBCBBCBBDCCBDBFBBDCBEIIBCBCIIBPB", false)), + Gurung_Khema: () => new UnicodeRangeTable(decodeRanges("go4C5B", true)), + Han: () => new UnicodeRangeTable(decodeRanges("g0LZBC4CBN1GBwBCCaIBPDBle-tGBhC-vUBhoWtLBDpDBpodBBNGBqgkB-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB", false)), + Hangul: () => new UnicodeRangeTable(decodeRanges("goE-HvxHBiI9CyDeiCei3dckUj9KNWFwBl9JeEFDFDFDC", true)), + Hanifi_Rohingya: () => new UnicodeRangeTable(decodeRanges("gojCnBJJ", true)), + Hanunoo: () => new UnicodeRangeTable(decodeRanges("g5FU", true)), + Hatran: () => new UnicodeRangeTable(decodeRanges("gniCSCBGE", true)), + Hebrew: () => new UnicodeRangeTable(decodeRanges("xsB2BBJaBFFBpp9BZBCEBCCCBCCBCCBIB", false)), + Hiragana: () => new UnicodeRangeTable(decodeRanges("hiM1CBHCBi7-C+IBTeeBBBulQAB", false)), + Imperial_Aramaic: () => new UnicodeRangeTable(decodeRanges("giiCVCI", true)), + Inherited: () => new UnicodeRangeTable(decodeRanges("gYvDB2IBBlOKBbhXhXBCB8qEtBBDLBlPCBCMBCGBFHHEBBnG-BBtQBBjGgBB65DDBsDBBmrzBPBRNBwejHjH7iEl+uBl+uBBsBBDWBhRCBSHBDGBfDBz6rYvHB", false)), + Inscriptional_Pahlavi: () => new UnicodeRangeTable(decodeRanges("g7iCSGH", true)), + Inscriptional_Parthian: () => new UnicodeRangeTable(decodeRanges("g6iCVDH", true)), + Javanese: () => new UnicodeRangeTable(decodeRanges("gsqBtCDJFB", true)), + Kaithi: () => new UnicodeRangeTable(decodeRanges("gkkCiCLA", true)), + Kannada: () => new UnicodeRangeTable(decodeRanges("gkDMCCCWCJCEDICCCDIBGCCDDJCC", true)), + Katakana: () => new UnicodeRangeTable(decodeRanges("hlM5CBDCBxHPBxGuBBC3CBvgzBJBCsBBzisBDBCGBCBBCgJgJBBBzBPPBCB", false)), + Kawi: () => new UnicodeRangeTable(decodeRanges("g4nCQCoBEc", true)), + Kayah_Li: () => new UnicodeRangeTable(decodeRanges("goqBtBCA", true)), + Kharoshthi: () => new UnicodeRangeTable(decodeRanges("gwiCDCBGHCCCcDCFJII", true)), + Khitan_Small_Script: () => new UnicodeRangeTable(decodeRanges("k-7C84G84GB0OBqBAB", false)), + Khmer: () => new UnicodeRangeTable(decodeRanges("g8F9CDJHJnPf", true)), + Khojki: () => new UnicodeRangeTable(decodeRanges("gwkCRCuB", true)), + Khudawadi: () => new UnicodeRangeTable(decodeRanges("w1kC6BGJ", true)), + Kirat_Rai: () => new UnicodeRangeTable(decodeRanges("gq7C5B", true)), + Lao: () => new UnicodeRangeTable(decodeRanges("h0DBBCCCBDBCXBCCCBVBDEBCCCBFBCJBDDB", false)), + Latin: () => new UnicodeRangeTable(decodeRanges("hCZBHZBwBQQGWBCeBCgOBoBEB8wGlBBHwBBGDBGMBClCBiC-HByLOORMBuEBBHccSoBB42CfBj1elDBExCBVOBxZqBBCIBCDB38TGB7gBZBHZBmhCFBCpBBCIBm61BeBHFB", false)), + Lepcha: () => new UnicodeRangeTable(decodeRanges("ggH3BEOEC", true)), + Limbu: () => new UnicodeRangeTable(decodeRanges("goGeBCLBFLBFEEBKB", false)), + Linear_A: () => new UnicodeRangeTable(decodeRanges("gwhC2JKVLH", true)), + Linear_B: () => new UnicodeRangeTable(decodeRanges("gggCLCZCSCBCODNjB6D", true)), + Lisu: () => new UnicodeRangeTable(decodeRanges("wmpBvBx1eA", true)), + Lycian: () => new UnicodeRangeTable(decodeRanges("g0gCc", true)), + Lydian: () => new UnicodeRangeTable(decodeRanges("gpiCZGA", true)), + Mahajani: () => new UnicodeRangeTable(decodeRanges("wqkCmB", true)), + Makasar: () => new UnicodeRangeTable(decodeRanges("g3nCY", true)), + Malayalam: () => new UnicodeRangeTable(decodeRanges("goDMCCCyBCCCFFPDZ", true)), + Mandaic: () => new UnicodeRangeTable(decodeRanges("giCbDA", true)), + Manichaean: () => new UnicodeRangeTable(decodeRanges("g2iCmBFL", true)), + Marchen: () => new UnicodeRangeTable(decodeRanges("wjnCfDVCN", true)), + Masaram_Gondi: () => new UnicodeRangeTable(decodeRanges("gonCGBCBBCrBBECCBCCBHBJJB", false)), + Medefaidrin: () => new UnicodeRangeTable(decodeRanges("gy7C6C", true)), + Meetei_Mayek: () => new UnicodeRangeTable(decodeRanges("g3qBWqGtBDJ", true)), + Mende_Kikakui: () => new UnicodeRangeTable(decodeRanges("gg6DkGDP", true)), + Meroitic_Cursive: () => new UnicodeRangeTable(decodeRanges("gtiCXFTDtB", true)), + Meroitic_Hieroglyphs: () => new UnicodeRangeTable(decodeRanges("gsiCf", true)), + Miao: () => new UnicodeRangeTable(decodeRanges("g47CqCF4BIQ", true)), + Modi: () => new UnicodeRangeTable(decodeRanges("gwlCkCMJ", true)), + Mongolian: () => new UnicodeRangeTable(decodeRanges("ggGBBDCCBSBH4CBIqBB2t-BMB", false)), + Mro: () => new UnicodeRangeTable(decodeRanges("gy6CeCJFB", true)), + Multani: () => new UnicodeRangeTable(decodeRanges("g0kCGBCCCBCBCOBCKB", false)), + Myanmar: () => new UnicodeRangeTable(decodeRanges("ggE-EhqmBeiDfxibT", true)), + Nabataean: () => new UnicodeRangeTable(decodeRanges("gkiCeJI", true)), + Nag_Mundari: () => new UnicodeRangeTable(decodeRanges("wm5DpB", true)), + Nandinagari: () => new UnicodeRangeTable(decodeRanges("gtmCHDtBDK", true)), + New_Tai_Lue: () => new UnicodeRangeTable(decodeRanges("gsGrBFZHKEB", true)), + Newa: () => new UnicodeRangeTable(decodeRanges("gglC7CCE", true)), + Nko: () => new UnicodeRangeTable(decodeRanges("g+B6BDC", true)), + Nushu: () => new UnicodeRangeTable(decodeRanges("h-7CvsQvsQBqMB", false)), + Nyiakeng_Puachue_Hmong: () => new UnicodeRangeTable(decodeRanges("go4DsBENDJFB", true)), + Ogham: () => new UnicodeRangeTable(decodeRanges("g0Fc", true)), + Ol_Chiki: () => new UnicodeRangeTable(decodeRanges("wiHvB", true)), + Ol_Onal: () => new UnicodeRangeTable(decodeRanges("wu5DqBFA", true)), + Old_Hungarian: () => new UnicodeRangeTable(decodeRanges("gkjCyBOyBIF", true)), + Old_Italic: () => new UnicodeRangeTable(decodeRanges("g4gCjBKC", true)), + Old_North_Arabian: () => new UnicodeRangeTable(decodeRanges("g0iCf", true)), + Old_Permic: () => new UnicodeRangeTable(decodeRanges("w6gCqB", true)), + Old_Persian: () => new UnicodeRangeTable(decodeRanges("g9gCjBFN", true)), + Old_Sogdian: () => new UnicodeRangeTable(decodeRanges("g4jCnB", true)), + Old_South_Arabian: () => new UnicodeRangeTable(decodeRanges("gziCf", true)), + Old_Turkic: () => new UnicodeRangeTable(decodeRanges("ggjCoC", true)), + Old_Uyghur: () => new UnicodeRangeTable(decodeRanges("w7jCZ", true)), + Oriya: () => new UnicodeRangeTable(decodeRanges("h4CCCHDBDVCGCBCEDIDBDCICFBCEDR", true)), + Osage: () => new UnicodeRangeTable(decodeRanges("wlhCjBFjB", true)), + Osmanya: () => new UnicodeRangeTable(decodeRanges("gkhCdDJ", true)), + Pahawh_Hmong: () => new UnicodeRangeTable(decodeRanges("g46ClCLJCGCUGS", true)), + Palmyrene: () => new UnicodeRangeTable(decodeRanges("gjiCf", true)), + Pau_Cin_Hau: () => new UnicodeRangeTable(decodeRanges("g2mC4B", true)), + Phags_Pa: () => new UnicodeRangeTable(decodeRanges("giqB3B", true)), + Phoenician: () => new UnicodeRangeTable(decodeRanges("goiCbEA", true)), + Psalter_Pahlavi: () => new UnicodeRangeTable(decodeRanges("g8iCRIDNG", true)), + Rejang: () => new UnicodeRangeTable(decodeRanges("wpqBjBMA", true)), + Runic: () => new UnicodeRangeTable(decodeRanges("g1FqCEK", true)), + Samaritan: () => new UnicodeRangeTable(decodeRanges("ggCtBDO", true)), + Saurashtra: () => new UnicodeRangeTable(decodeRanges("gkqBlCJL", true)), + Sharada: () => new UnicodeRangeTable(decodeRanges("gskC-ChsCH", true)), + Shavian: () => new UnicodeRangeTable(decodeRanges("wihCvB", true)), + Siddham: () => new UnicodeRangeTable(decodeRanges("gslC1BDlB", true)), + Sidetic: () => new UnicodeRangeTable(decodeRanges("gqiCZ", true)), + SignWriting: () => new UnicodeRangeTable(decodeRanges("gg2DrUQECO", true)), + Sinhala: () => new UnicodeRangeTable(decodeRanges("hsDCBCRBEXBCIBCDDBFBEFFBEBCCCBGBHJBDCBt-gCTB", false)), + Sogdian: () => new UnicodeRangeTable(decodeRanges("w5jCpB", true)), + Sora_Sompeng: () => new UnicodeRangeTable(decodeRanges("wmkCYIJ", true)), + Soyombo: () => new UnicodeRangeTable(decodeRanges("wymCyC", true)), + Sundanese: () => new UnicodeRangeTable(decodeRanges("g8G-BhIH", true)), + Sunuwar: () => new UnicodeRangeTable(decodeRanges("g+mChBPJ", true)), + Syloti_Nagri: () => new UnicodeRangeTable(decodeRanges("ggqBsB", true)), + Syriac: () => new UnicodeRangeTable(decodeRanges("g4BNC7BDCxIK", true)), + Tagalog: () => new UnicodeRangeTable(decodeRanges("g4FVKA", true)), + Tagbanwa: () => new UnicodeRangeTable(decodeRanges("g7FMCCCB", true)), + Tai_Le: () => new UnicodeRangeTable(decodeRanges("wqGdDE", true)), + Tai_Tham: () => new UnicodeRangeTable(decodeRanges("gxG+BCcDKHJHN", true)), + Tai_Viet: () => new UnicodeRangeTable(decodeRanges("g0qBiCZE", true)), + Tai_Yo: () => new UnicodeRangeTable(decodeRanges("g25DeCVJB", true)), + Takri: () => new UnicodeRangeTable(decodeRanges("g0lC5BHJ", true)), + Tamil: () => new UnicodeRangeTable(decodeRanges("i8CBBCFBECBCDBEBBCCCBEEBEEBBBELBFEBECBCDBDHHPUBm+kCxBBOAB", false)), + Tangsa: () => new UnicodeRangeTable(decodeRanges("wz6CuCCJ", true)), + Tangut: () => new UnicodeRangeTable(decodeRanges("g-7CgBgBB+3GBhQeBiDyDB", false)), + Telugu: () => new UnicodeRangeTable(decodeRanges("ggDMCCCWCPDICCCDIBCCCBDDDJII", true)), + Thaana: () => new UnicodeRangeTable(decodeRanges("g8BxB", true)), + Thai: () => new UnicodeRangeTable(decodeRanges("hwD5BGb", true)), + Tibetan: () => new UnicodeRangeTable(decodeRanges("g4DnCCjBFmBCjBCOCGFB", true)), + Tifinagh: () => new UnicodeRangeTable(decodeRanges("wpL3BIBPA", true)), + Tirhuta: () => new UnicodeRangeTable(decodeRanges("gklCnCJJ", true)), + Todhri: () => new UnicodeRangeTable(decodeRanges("guhCzB", true)), + Tolong_Siki: () => new UnicodeRangeTable(decodeRanges("wtnCrBFJ", true)), + Toto: () => new UnicodeRangeTable(decodeRanges("w04De", true)), + Tulu_Tigalari: () => new UnicodeRangeTable(decodeRanges("g8kCJBCDDClBBCJBCDDCDBCJBCBBJBB", false)), + Ugaritic: () => new UnicodeRangeTable(decodeRanges("g8gCdCA", true)), + Unknown: () => new UnicodeRangeTable(decodeRanges("4bBBHDBICCVuMuMnB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GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-FB", false)), + Vai: () => new UnicodeRangeTable(decodeRanges("gopBrJ", true)), + Vithkuqi: () => new UnicodeRangeTable(decodeRanges("wrhCKCOCGCBCKCOCGCB", true)), + Wancho: () => new UnicodeRangeTable(decodeRanges("g24D5BGA", true)), + Warang_Citi: () => new UnicodeRangeTable(decodeRanges("glmCyCNA", true)), + Yezidi: () => new UnicodeRangeTable(decodeRanges("g0jCpBCCDB", true)), + Yi: () => new UnicodeRangeTable(decodeRanges("ggoBskBE2B", true)), + Zanabazar_Square: () => new UnicodeRangeTable(decodeRanges("gwmCnC", true)) + }); + static FOLD_CATEGORIES = new LazyMap({ + L: () => new UnicodeRangeTable(decodeRanges("laA", true)), + LC: () => new UnicodeRangeTable(decodeRanges("laA", true)), + Ll: () => new UnicodeRangeTable(decodeRanges("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGC3HrBrBCEEJHHCCBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHxC9zC9zCBuBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB", false)), + Lt: () => new UnicodeRangeTable(decodeRanges("kOCCBCCBCClBCCtsHHBJHBJHBMQQwBAB", false)), + Lu: () => new UnicodeRangeTable(decodeRanges("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpL2B2Bs1CvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB", false)), + M: () => new UnicodeRangeTable(decodeRanges("5cgBgBlgHAB", false)), + Mn: () => new UnicodeRangeTable(decodeRanges("5cgBgBlgHAB", false)), + Emoji: () => new UnicodeRangeTable(decodeRanges("8mJA", true)), + Extended_Pictographic: () => new UnicodeRangeTable(decodeRanges("8mJA", true)), + Lowercase: () => new UnicodeRangeTable(decodeRanges("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHuBPBUzZzZBYBx5BvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB", false)), + Math: () => new UnicodeRangeTable(decodeRanges("ycGDCHHFMMDDDCHHFAB", false)), + Uppercase: () => new UnicodeRangeTable(decodeRanges("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpLiBiBBOBFsasaBYBn6BvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB", false)) + }); + static FOLD_SCRIPT = new LazyMap({ + Common: () => new UnicodeRangeTable(decodeRanges("8cgBgB", false)), + Greek: () => new UnicodeRangeTable(decodeRanges("1FwUwU", false)), + Inherited: () => new UnicodeRangeTable(decodeRanges("5cgBgBlgHAB", false)) + }); +}; +//#endregion +//#region src/Unicode.js +/** +* Utilities for dealing with Unicode better than JS does. +*/ +var Unicode = class Unicode { + static MAX_RUNE = 1114111; + static MAX_ASCII = 127; + static MAX_LATIN1 = 255; + static MAX_BMP = 65535; + static MIN_FOLD = 65; + static MAX_FOLD = 125251; + static MIN_HIGH_SURROGATE = 55296; + static MAX_HIGH_SURROGATE = 56319; + static MIN_LOW_SURROGATE = 56320; + static MAX_LOW_SURROGATE = 57343; + static MIN_SUPPLEMENTARY_CODE_POINT = 65536; + static is32(ranges, r) { + let lo = 0; + let hi = ranges.length; + while (lo < hi) { + const m = lo + Math.floor((hi - lo) / 2); + const rlo = ranges.getLo(m); + const rhi = ranges.getHi(m); + if (rlo <= r && r <= rhi) { + const stride = ranges.getStride(m); + return (r - rlo) % stride === 0; + } + if (r < rlo) hi = m; + else lo = m + 1; + } + return false; + } + static is(ranges, r) { + if (r <= Unicode.MAX_LATIN1) { + for (let i = 0; i < ranges.length; i++) { + if (r > ranges.getHi(i)) continue; + const rlo = ranges.getLo(i); + if (r < rlo) return false; + const stride = ranges.getStride(i); + return (r - rlo) % stride === 0; + } + return false; + } + return ranges.length > 0 && r >= ranges.getLo(0) && Unicode.is32(ranges, r); + } + static isUpper(r) { + if (r <= Unicode.MAX_LATIN1) { + const s = String.fromCodePoint(r); + return s.toUpperCase() === s && s.toLowerCase() !== s; + } + return Unicode.is(UnicodeTables.Upper, r); + } + static isPrint(r) { + if (r <= Unicode.MAX_LATIN1) return r >= 32 && r < Unicode.MAX_ASCII || r >= 161 && r !== 173; + return Unicode.is(UnicodeTables.Print, r); + } + static simpleFold(r) { + if (UnicodeTables.CASE_ORBIT.has(r)) return UnicodeTables.CASE_ORBIT.get(r); + const l = Codepoint.toLowerCase(r); + if (l !== r) return l; + return Codepoint.toUpperCase(r); + } + static equalsIgnoreCase(r1, r2) { + if (r1 === r2) return true; + if (r1 < 0 || r2 < 0) return false; + if (r1 <= Unicode.MAX_ASCII && r2 <= Unicode.MAX_ASCII) { + if (65 <= r1 && r1 <= 90) r1 |= 32; + if (65 <= r2 && r2 <= 90) r2 |= 32; + return r1 === r2; + } + for (let r = Unicode.simpleFold(r1); r !== r1; r = Unicode.simpleFold(r)) if (r === r2) return true; + return false; + } +}; +//#endregion +//#region src/Utils.js +/** +* Size of the precomputed single-byte lookup table. +* Covers standard ASCII and Latin-1 characters for fast-path execution. +*/ +const FAST_PATH_TABLE_SIZE = 256; +/** +* Precomputed lookup table for Word Boundary (\b, \B) assertions. +* * By precomputing the boolean results for standard ASCII word ranges +* ('a'-'z', 'A'-'Z', '0'-'9', '_'), we completely eliminate 4 logical +* branches from the NFA's hot execution loop. This prevents costly +* CPU branch mispredictions when scanning large strings. +*/ +const WORD_RUNE_TABLE = new Uint8Array(FAST_PATH_TABLE_SIZE); +for (let i = 0; i < FAST_PATH_TABLE_SIZE; i++) WORD_RUNE_TABLE[i] = 97 <= i && i <= 122 || 65 <= i && i <= 90 || 48 <= i && i <= 57 || i === 95 ? 1 : 0; +let cachedNativeEncoder = null; +let cachedNativeDecoder = null; +/** +* Various constants and helper utilities. +*/ +var Utils = class Utils { + static METACHARACTERS = "\\.+*?()|[]{}^$"; + static EMPTY_BEGIN_LINE = 1; + static EMPTY_END_LINE = 2; + static EMPTY_BEGIN_TEXT = 4; + static EMPTY_END_TEXT = 8; + static EMPTY_WORD_BOUNDARY = 16; + static EMPTY_NO_WORD_BOUNDARY = 32; + static EMPTY_ALL = -1; + static emptyInts() { + return []; + } + static isByteArray(input) { + return Array.isArray(input) || input instanceof Uint8Array; + } + static isalnum(c) { + return Codepoint.CODES.get("0") <= c && c <= Codepoint.CODES.get("9") || Codepoint.CODES.get("a") <= c && c <= Codepoint.CODES.get("z") || Codepoint.CODES.get("A") <= c && c <= Codepoint.CODES.get("Z"); + } + static unhex(c) { + if (Codepoint.CODES.get("0") <= c && c <= Codepoint.CODES.get("9")) return c - Codepoint.CODES.get("0"); + if (Codepoint.CODES.get("a") <= c && c <= Codepoint.CODES.get("f")) return c - Codepoint.CODES.get("a") + 10; + if (Codepoint.CODES.get("A") <= c && c <= Codepoint.CODES.get("F")) return c - Codepoint.CODES.get("A") + 10; + return -1; + } + static escapeRune(rune) { + let out = ""; + if (Unicode.isPrint(rune)) { + if (Utils.METACHARACTERS.indexOf(String.fromCodePoint(rune)) >= 0) out += "\\"; + out += String.fromCodePoint(rune); + } else switch (rune) { + case Codepoint.CODES.get("\""): + out += "\\\""; + break; + case Codepoint.CODES.get("\\"): + out += "\\\\"; + break; + case Codepoint.CODES.get(" "): + out += "\\t"; + break; + case Codepoint.CODES.get("\n"): + out += "\\n"; + break; + case Codepoint.CODES.get("\r"): + out += "\\r"; + break; + case Codepoint.CODES.get("\b"): + out += "\\b"; + break; + case Codepoint.CODES.get("\f"): + out += "\\f"; + break; + default: { + let s = rune.toString(16); + if (rune < 256) { + out += "\\x"; + if (s.length === 1) out += "0"; + out += s; + } else out += `\\x{${s}}`; + break; + } + } + return out; + } + static stringToRunes(str) { + const string = String(str); + const runes = []; + let i = 0; + while (i < string.length) { + const cp = string.codePointAt(i); + runes.push(cp); + i += cp > Unicode.MAX_BMP ? 2 : 1; + } + return runes; + } + static runeToString(r) { + return String.fromCodePoint(r); + } + static isWordRune(r) { + return r < FAST_PATH_TABLE_SIZE ? WORD_RUNE_TABLE[r] === 1 : false; + } + static emptyOpContext(r1, r2) { + let op = 0; + if (r1 < 0) op |= Utils.EMPTY_BEGIN_TEXT | Utils.EMPTY_BEGIN_LINE; + if (r1 === 10) op |= Utils.EMPTY_BEGIN_LINE; + if (r2 < 0) op |= Utils.EMPTY_END_TEXT | Utils.EMPTY_END_LINE; + if (r2 === 10) op |= Utils.EMPTY_END_LINE; + if (Utils.isWordRune(r1) !== Utils.isWordRune(r2)) op |= Utils.EMPTY_WORD_BOUNDARY; + else op |= Utils.EMPTY_NO_WORD_BOUNDARY; + return op; + } + /** + * Returns a string that quotes all regular expression metacharacters inside the argument text; + * the returned string is a regular expression matching the literal text. For example, + * {@code quoteMeta("[foo]").equals("\\[foo\\]")}. + * @param {string} str + * @returns {string} + */ + static quoteMeta(str) { + return str.split("").map((s) => { + if (Utils.METACHARACTERS.indexOf(s) >= 0) return `\\${s}`; + return s; + }).join(""); + } + static charCount(codePoint) { + return codePoint > Unicode.MAX_BMP ? 2 : 1; + } + /** + * High-speed conversion from TypedArrays to standard JS Arrays. + * Bypasses the expensive Symbol.iterator overhead of Array.from() + */ + static toArray(typedArray) { + const len = typedArray.length; + const res = new Array(len); + for (let i = 0; i < len; i++) res[i] = typedArray[i]; + return res; + } + static stringToUtf8ByteArray(str) { + if (globalThis.TextEncoder) { + if (!cachedNativeEncoder) cachedNativeEncoder = new TextEncoder(); + return cachedNativeEncoder.encode(str); + } else { + let out = [], p = 0; + for (let i = 0; i < str.length; i++) { + let c = str.charCodeAt(i); + if (c < 128) out[p++] = c; + else if (c < 2048) { + out[p++] = c >> 6 | 192; + out[p++] = c & 63 | 128; + } else if ((c & 64512) === Unicode.MIN_HIGH_SURROGATE && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) === Unicode.MIN_LOW_SURROGATE) { + c = Unicode.MIN_SUPPLEMENTARY_CODE_POINT + ((c & 1023) << 10) + (str.charCodeAt(++i) & 1023); + out[p++] = c >> 18 | 240; + out[p++] = c >> 12 & 63 | 128; + out[p++] = c >> 6 & 63 | 128; + out[p++] = c & 63 | 128; + } else { + out[p++] = c >> 12 | 224; + out[p++] = c >> 6 & 63 | 128; + out[p++] = c & 63 | 128; + } + } + return out; + } + } + static utf8ByteArrayToString(bytes) { + if (globalThis.TextDecoder) { + if (!cachedNativeDecoder) cachedNativeDecoder = new TextDecoder("utf-8"); + const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes); + return cachedNativeDecoder.decode(view); + } else { + let out = [], pos = 0, c = 0; + while (pos < bytes.length) { + let c1 = bytes[pos++]; + if (c1 < 128) out[c++] = String.fromCharCode(c1); + else if (c1 > 191 && c1 < 224) { + let c2 = bytes[pos++]; + out[c++] = String.fromCharCode((c1 & 31) << 6 | c2 & 63); + } else if (c1 > 239 && c1 < 365) { + let c2 = bytes[pos++]; + let c3 = bytes[pos++]; + let c4 = bytes[pos++]; + let u = ((c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63) - Unicode.MIN_SUPPLEMENTARY_CODE_POINT; + out[c++] = String.fromCharCode(Unicode.MIN_HIGH_SURROGATE + (u >> 10)); + out[c++] = String.fromCharCode(Unicode.MIN_LOW_SURROGATE + (u & 1023)); + } else { + let c2 = bytes[pos++]; + let c3 = bytes[pos++]; + out[c++] = String.fromCharCode((c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63); + } + } + return out.join(""); + } + } +}; +//#endregion +//#region src/helpers.js +const createEnum = (values = [], initNum = 0) => { + const enumObject = Object.create(null); + for (let i = 0; i < values.length; i++) { + const val = values[i]; + const keyVal = initNum + i; + enumObject[val] = keyVal; + enumObject[keyVal] = val; + } + return Object.freeze(enumObject); +}; +//#endregion +//#region src/MatcherInput.js +/** +* Abstract the representations of input text supplied to Matcher. +*/ +var MatcherInputBase = class MatcherInputBase { + static Encoding = createEnum(["UTF_16", "UTF_8"]); + getEncoding() { + throw Error("not implemented"); + } + /** @returns {string} */ + asCharSequence() { + throw Error("not implemented"); + } + /** @returns {Uint8Array|number[]} */ + asBytes() { + throw Error("not implemented"); + } + /** @returns {number} */ + length() { + throw Error("not implemented"); + } + /** + * + * @returns {boolean} + */ + isUTF8Encoding() { + return this.getEncoding() === MatcherInputBase.Encoding.UTF_8; + } + /** + * + * @returns {boolean} + */ + isUTF16Encoding() { + return this.getEncoding() === MatcherInputBase.Encoding.UTF_16; + } +}; +var Utf8MatcherInput = class extends MatcherInputBase { + /** @param {Uint8Array|number[]|null} bytes */ + constructor(bytes = null) { + super(); + this.bytes = bytes; + } + getEncoding() { + return MatcherInputBase.Encoding.UTF_8; + } + /** + * + * @returns {string} + */ + asCharSequence() { + return Utils.utf8ByteArrayToString(this.bytes); + } + /** + * + * @returns {Uint8Array|number[]|null} + */ + asBytes() { + return this.bytes; + } + /** + * + * @returns {number} + */ + length() { + return this.bytes.length; + } +}; +var Utf16MatcherInput = class extends MatcherInputBase { + /** @param {string|null} charSequence */ + constructor(charSequence = null) { + super(); + this.charSequence = charSequence; + } + getEncoding() { + return MatcherInputBase.Encoding.UTF_16; + } + /** + * + * @returns {string} + */ + asCharSequence() { + return this.charSequence; + } + /** + * + * @returns {number[]} + */ + asBytes() { + return Utils.stringToUtf8ByteArray(this.charSequence.toString()); + } + /** + * + * @returns {number} + */ + length() { + return this.charSequence.length; + } +}; +var MatcherInput = class { + /** + * Return the MatcherInput for UTF_16 encoding. + * @returns {Utf16MatcherInput} + */ + static utf16(charSequence) { + return new Utf16MatcherInput(charSequence); + } + /** + * Return the MatcherInput for UTF_8 encoding. + * @returns {Utf8MatcherInput} + */ + static utf8(input) { + if (Utils.isByteArray(input)) return new Utf8MatcherInput(input); + return new Utf8MatcherInput(Utils.stringToUtf8ByteArray(input)); + } +}; +//#endregion +//#region src/MachineInput.js +/** +* MachineInput abstracts different representations of the input text supplied to the Machine. It +* provides one-character lookahead. +*/ +var MachineInputBase = class { + static EOF() { + return -8; + } + constructor() { + this.end = 0; + } + canCheckPrefix() { + return true; + } + endPos() { + return this.end; + } + hasString() { + return false; + } + hasAnyString() { + return false; + } + prefixLength() { + return 0; + } +}; +var MachineUTF8Input = class extends MachineInputBase { + constructor(bytes, start = 0, end = bytes.length) { + super(); + this.bytes = bytes; + this.start = start; + this.end = end; + } + hasString(prefilter, pos) { + const target = prefilter.bytes; + if (target.length === 0) return true; + const idx = this.indexOf(this.bytes, target, this.start + pos); + return idx !== -1 && idx <= this.end - target.length; + } + hasAnyString(prefilter, pos) { + if (!prefilter.ac8) return false; + return prefilter.ac8.searchUTF8(this.bytes, this.start + pos, this.end); + } + step(pos) { + pos += this.start; + if (pos >= this.end) return MachineInputBase.EOF(); + const c = this.bytes[pos] & 255; + if (c < 128) return c << 3 | 1; + else if (c >= 194 && c <= 223 && pos + 1 < this.end) { + const c1 = this.bytes[pos + 1] & 255; + if ((c1 & 192) !== 128) return c << 3 | 1; + return ((c & 31) << 6 | c1 & 63) << 3 | 2; + } else if (c >= 224 && c <= 239 && pos + 2 < this.end) { + const c1 = this.bytes[pos + 1] & 255; + if ((c1 & 192) !== 128) return c << 3 | 1; + const c2 = this.bytes[pos + 2] & 255; + if ((c2 & 192) !== 128) return c << 3 | 1; + return ((c & 15) << 12 | (c1 & 63) << 6 | c2 & 63) << 3 | 3; + } else if (c >= 240 && c <= 244 && pos + 3 < this.end) { + const c1 = this.bytes[pos + 1] & 255; + if ((c1 & 192) !== 128) return c << 3 | 1; + const c2 = this.bytes[pos + 2] & 255; + if ((c2 & 192) !== 128) return c << 3 | 1; + const c3 = this.bytes[pos + 3] & 255; + if ((c3 & 192) !== 128) return c << 3 | 1; + return ((c & 7) << 18 | (c1 & 63) << 12 | (c2 & 63) << 6 | c3 & 63) << 3 | 4; + } else return c << 3 | 1; + } + index(re2, pos) { + pos += this.start; + const i = this.indexOf(this.bytes, re2.prefixUTF8, pos); + return i < 0 ? i : i - pos; + } + context(pos) { + pos += this.start; + let r1 = -1; + if (pos > this.start && pos <= this.end) { + let start = pos - 1; + r1 = this.bytes[start--]; + if (r1 >= 128) { + let lim = pos - 4; + if (lim < this.start) lim = this.start; + while (start >= lim && (this.bytes[start] & 192) === 128) start--; + if (start < this.start) start = this.start; + r1 = this.step(start - this.start) >> 3; + } + } + const r2 = pos < this.end ? this.step(pos - this.start) >> 3 : -1; + return Utils.emptyOpContext(r1, r2); + } + indexOf(source, target, fromIndex = 0) { + let targetLength = target.length; + if (targetLength === 0) return fromIndex <= this.end ? fromIndex : -1; + const firstByte = target[0]; + let limit = this.end - targetLength; + const hasNativeIndexOf = typeof source.indexOf === "function"; + let i = fromIndex; + while (i <= limit) { + if (hasNativeIndexOf) { + i = source.indexOf(firstByte, i); + if (i === -1 || i > limit) return -1; + } else { + while (i <= limit && source[i] !== firstByte) i++; + if (i > limit) return -1; + } + let match = true; + for (let j = 1; j < targetLength; j++) if (source[i + j] !== target[j]) { + match = false; + break; + } + if (match) return i; + i++; + } + return -1; + } + prefixLength(re2) { + return re2.prefixUTF8.length; + } +}; +var MachineUTF16Input = class extends MachineInputBase { + constructor(charSequence, start = 0, end = charSequence.length) { + super(); + this.charSequence = charSequence; + this.start = start; + this.end = end; + } + hasString(prefilter, pos) { + const idx = this.charSequence.indexOf(prefilter.str, this.start + pos); + return idx !== -1 && idx <= this.end - prefilter.str.length; + } + hasAnyString(prefilter, pos) { + if (!prefilter.ac16) return false; + return prefilter.ac16.searchUTF16(this.charSequence, this.start + pos, this.end); + } + step(pos) { + pos += this.start; + if (pos >= this.end) return MachineInputBase.EOF(); + const c1 = this.charSequence.charCodeAt(pos); + if (c1 < Unicode.MIN_HIGH_SURROGATE || c1 > Unicode.MAX_HIGH_SURROGATE || pos + 1 >= this.end) return c1 << 3 | 1; + const c2 = this.charSequence.charCodeAt(pos + 1); + if (c2 >= Unicode.MIN_LOW_SURROGATE && c2 <= Unicode.MAX_LOW_SURROGATE) return (c1 - Unicode.MIN_HIGH_SURROGATE) * 1024 + (c2 - Unicode.MIN_LOW_SURROGATE) + Unicode.MIN_SUPPLEMENTARY_CODE_POINT << 3 | 2; + return c1 << 3 | 1; + } + index(re2, pos) { + pos += this.start; + const i = this.charSequence.indexOf(re2.prefix, pos); + if (i < 0 || i > this.end - re2.prefix.length) return -1; + return i - pos; + } + context(pos) { + pos += this.start; + const r1 = pos > this.start && pos <= this.end ? this.charSequence.charCodeAt(pos - 1) : -1; + const r2 = pos < this.end ? this.charSequence.charCodeAt(pos) : -1; + return Utils.emptyOpContext(r1, r2); + } + prefixLength(re2) { + return re2.prefix.length; + } +}; +var MachineInput = class { + static fromUTF8(bytes, start = 0, end = bytes.length) { + return new MachineUTF8Input(bytes, start, end); + } + static fromUTF16(charSequence, start = 0, end = charSequence.length) { + return new MachineUTF16Input(charSequence, start, end); + } +}; +//#endregion +//#region src/exceptions.js +var RE2JSException = class extends Error { + /** @param {string} message */ + constructor(message) { + super(message); + this.name = "RE2JSException"; + } +}; +/** +* An exception thrown by the parser if the pattern was invalid. +*/ +var RE2JSSyntaxException = class extends RE2JSException { + /** + * @param {string} error + * @param {string|null} [input=null] + */ + constructor(error, input = null) { + let message = `error parsing regexp: ${error}`; + if (input) message += `: \`${input}\``; + super(message); + this.name = "RE2JSSyntaxException"; + this.message = message; + /** @type {string} */ + this.error = error; + /** @type {string|null} */ + this.input = input; + } + /** + * Retrieves the description of the error. + * @returns {string} + */ + getDescription() { + return this.error; + } + /** + * Retrieves the erroneous regular-expression pattern. + * @returns {string|null} + */ + getPattern() { + return this.input; + } +}; +/** +* An exception thrown by the compiler +*/ +var RE2JSCompileException = class extends RE2JSException { + /** @param {string} message */ + constructor(message) { + super(message); + this.name = "RE2JSCompileException"; + } +}; +/** +* An exception thrown by using groups +*/ +var RE2JSGroupException = class extends RE2JSException { + /** @param {string} message */ + constructor(message) { + super(message); + this.name = "RE2JSGroupException"; + } +}; +/** +* An exception thrown by flags +*/ +var RE2JSFlagsException = class extends RE2JSException { + /** @param {string} message */ + constructor(message) { + super(message); + this.name = "RE2JSFlagsException"; + } +}; +/** +* An exception thrown for internal engine errors, such as corrupted bytecodes. +*/ +var RE2JSInternalException = class extends RE2JSException { + /** @param {string} message */ + constructor(message) { + super(message); + this.name = "RE2JSInternalException"; + } +}; +//#endregion +//#region src/Matcher.js +/** +* A stateful iterator that interprets a regex {@code RE2JS} on a specific input. +* +* Conceptually, a Matcher consists of four parts: +*
    +*
  1. A compiled regular expression {@code RE2JS}, set at construction and fixed for the lifetime +* of the matcher.
  2. +* +*
  3. The remainder of the input string, set at construction or {@link #reset()} and advanced by +* each match operation such as {@link #find}, {@link #matches} or {@link #lookingAt}.
  4. +* +*
  5. The current match information, accessible via {@link #start}, {@link #end}, and +* {@link #group}, and updated by each match operation.
  6. +* +*
  7. The append position, used and advanced by {@link #appendReplacement} and {@link #appendTail} +* if performing a search and replace from the input to an external {@code StringBuffer}. +* +*
+* +* +* @author rsc@google.com (Russ Cox) +*/ +var Matcher = class Matcher { + /** + * V8 and WebKit have historical hard limits on the number of arguments + * that can be passed to a function. We cap replacer arguments to prevent + * Call Stack Overflow (DoS) vulnerabilities on massive ASTs. + */ + static MAX_REPLACER_ARGS = 65535; + /** + * Quotes '\' and '$' in {@code s}, so that the returned string could be used in + * {@link #appendReplacement} as a literal replacement of {@code s}. + * + * @param {string} str the string to be quoted + * @param {boolean} [javaMode=false] whether the replacement will be used in javaMode + * @returns {string} the quoted string + */ + static quoteReplacement(str, javaMode = false) { + if (javaMode) { + if (str.indexOf("\\") < 0 && str.indexOf("$") < 0) return str; + return str.split("").map((s) => { + const c = s.codePointAt(0); + if (c === Codepoint.CODES.get("\\") || c === Codepoint.CODES.get("$")) return `\\${s}`; + return s; + }).join(""); + } + if (str.indexOf("$") < 0) return str; + return str.split("").map((s) => { + if (s.codePointAt(0) === Codepoint.CODES.get("$")) return "$$"; + return s; + }).join(""); + } + /** + * + * @param {import('./index.js').RE2JS} pattern + * @param {string|number[]|Uint8Array|MatcherInputBase} input + */ + constructor(pattern, input) { + if (pattern === null) throw new Error("pattern is null"); + /** + * The pattern being matched. + * @type {import('./index.js').RE2JS} + */ + this.patternInput = pattern; + const re2 = this.patternInput.re2(); + /** @type {number} */ + this.patternGroupCount = re2.numberOfCapturingGroups(); + /** @type {number[]} */ + this.groups = []; + /** @type {Record} */ + this.namedGroups = re2.namedGroups; + /** @type {number} */ + this.numberOfInstructions = re2.numberOfInstructions(); + if (input instanceof MatcherInputBase) this.resetMatcherInput(input); + else if (Utils.isByteArray(input)) this.resetMatcherInput(MatcherInput.utf8(input)); + else this.resetMatcherInput(MatcherInput.utf16(input)); + } + /** + * Returns the {@code RE2JS} associated with this {@code Matcher}. + * @returns {import('./index.js').RE2JS} + */ + pattern() { + return this.patternInput; + } + /** + * Resets the {@code Matcher}, rewinding input and discarding any match information. + * + * @returns {Matcher} the {@code Matcher} itself, for chained method calls + */ + reset() { + /** @type {number} */ + this.matcherInputLength = this.matcherInput.length(); + /** @type {number} */ + this.appendPos = 0; + this.hasMatch = false; + this.hasGroups = false; + this.anchorFlag = 0; + return this; + } + /** + * Resets the {@code Matcher} and changes the input. + * @param {string|number[]|Uint8Array|MatcherInputBase} input + * @returns {Matcher} the {@code Matcher} itself, for chained method calls + */ + resetMatcherInput(input) { + if (input === null) throw new Error("input is null"); + if (!(input instanceof MatcherInputBase)) if (Utils.isByteArray(input)) input = MatcherInput.utf8(input); + else input = MatcherInput.utf16(input); + this.matcherInput = input; + this.reset(); + return this; + } + /** + * Returns the start of the named group of the most recent match, or -1 if the group was not + * matched. + * @param {string|number} [group=0] + * @returns {number} + */ + start(group = 0) { + if (typeof group === "string") { + const groupInt = this.namedGroups[group]; + if (!Number.isFinite(groupInt)) throw new RE2JSGroupException(`group '${group}' not found`); + group = groupInt; + } + this.loadGroup(group); + return this.groups[2 * group]; + } + /** + * Returns the end of the named group of the most recent match, or -1 if the group was not + * matched. + * @param {string|number} [group=0] + * @returns {number} + */ + end(group = 0) { + if (typeof group === "string") { + const groupInt = this.namedGroups[group]; + if (!Number.isFinite(groupInt)) throw new RE2JSGroupException(`group '${group}' not found`); + group = groupInt; + } + this.loadGroup(group); + return this.groups[2 * group + 1]; + } + /** + * Returns the program size of this pattern. + * + *

+ * Similar to the C++ implementation, the program size is a very approximate measure of a regexp's + * "cost". Larger numbers are more expensive than smaller numbers. + *

+ * + * @returns {number} the program size of this pattern + */ + programSize() { + return this.numberOfInstructions; + } + /** + * Returns the named group of the most recent match, or {@code null} if the group was not matched. + * @param {string|number} [group=0] + * @returns {string|null} + */ + group(group = 0) { + if (typeof group === "string") { + const groupInt = this.namedGroups[group]; + if (!Number.isFinite(groupInt)) throw new RE2JSGroupException(`group '${group}' not found`); + group = groupInt; + } + const start = this.start(group); + const end = this.end(group); + if (start < 0 && end < 0) return null; + return this.substring(start, end); + } + /** + * Returns a dictionary map of all named capturing groups and their matched values. + * If a group was not matched, its value will be `null`. + * @returns {Record} + */ + getNamedGroups() { + if (!this.hasMatch) throw new RE2JSGroupException("perhaps no match attempted"); + const result = Object.create(null); + for (const name of Object.keys(this.namedGroups)) result[name] = this.group(name); + return result; + } + /** + * Returns the number of subgroups in this pattern. + * + * @returns {number} the number of subgroups; the overall match (group 0) does not count + */ + groupCount() { + return this.patternGroupCount; + } + /** + * Helper: finds subgroup information if needed for group. + * @param {number} group + * @private + */ + loadGroup(group) { + if (group < 0 || group > this.patternGroupCount) throw new RE2JSGroupException(`Group index out of bounds: ${group}`); + if (!this.hasMatch) throw new RE2JSGroupException("perhaps no match attempted"); + if (group === 0 || this.hasGroups) return; + const end = this.matcherInputLength; + const res = this.patternInput.re2().matchMachineInput(this.matcherInput, this.groups[0], end, this.anchorFlag, 1 + this.patternGroupCount); + if (!res[0]) throw new RE2JSGroupException("inconsistency in matching group data"); + this.groups = res[1]; + this.hasGroups = true; + } + /** + * Matches the entire input against the pattern (anchored start and end). If there is a match, + * {@code matches} sets the match state to describe it. + * + * @returns {boolean} true if the entire input matches the pattern + */ + matches() { + return this.genMatch(0, RE2Flags.ANCHOR_BOTH); + } + /** + * Matches the beginning of input against the pattern (anchored start). If there is a match, + * {@code lookingAt} sets the match state to describe it. + * + * @returns {boolean} true if the beginning of the input matches the pattern + */ + lookingAt() { + return this.genMatch(0, RE2Flags.ANCHOR_START); + } + /** + * Matches the input against the pattern (unanchored), starting at a specified position. If there + * is a match, {@code find} sets the match state to describe it. + * + * @param {number|null} [start=null] the input position where the search begins + * @returns {boolean} if it finds a match + * @throws IndexOutOfBoundsException if start is not a valid input position + */ + find(start = null) { + if (start !== null) { + if (start < 0 || start > this.matcherInputLength) throw new RE2JSGroupException(`start index out of bounds: ${start}`); + this.reset(); + return this.genMatch(start, 0); + } + start = 0; + if (this.hasMatch) { + start = this.groups[1]; + if (this.groups[0] === this.groups[1]) { + const r = (this.matcherInput.isUTF16Encoding() ? MachineInput.fromUTF16(this.matcherInput.asCharSequence(), 0, this.matcherInputLength) : MachineInput.fromUTF8(this.matcherInput.asBytes(), 0, this.matcherInputLength)).step(start); + if (r < 0) start++; + else start += r & 7; + } + } + return this.genMatch(start, RE2Flags.UNANCHORED); + } + /** + * Helper: does match starting at start, with RE2 anchor flag. + * @param {number} startByte + * @param {number} anchor + * @returns {boolean} + * @private + */ + genMatch(startByte, anchor) { + const res = this.patternInput.re2().matchMachineInput(this.matcherInput, startByte, this.matcherInputLength, anchor, 1); + if (!res[0]) { + this.hasMatch = false; + return false; + } + this.groups = res[1]; + this.hasMatch = true; + this.hasGroups = this.patternGroupCount === 0; + this.anchorFlag = anchor; + return true; + } + /** + * Helper: return substring for [start, end). + * @param {number} start + * @param {number} end + * @returns {string} + */ + substring(start, end) { + if (this.matcherInput.isUTF8Encoding()) return Utils.utf8ByteArrayToString(this.matcherInput.asBytes().slice(start, end)); + return this.matcherInput.asCharSequence().substring(start, end).toString(); + } + /** + * Helper for Pattern: return input length. + * @returns {number} + */ + inputLength() { + return this.matcherInputLength; + } + /** + * Appends to result two strings: the text from the append position up to the beginning of the + * most recent match, and then the replacement with submatch groups substituted for references of + * the form {@code $n}, where {@code n} is the group number in decimal. It advances the append + * position to where the most recent match ended. + * + * To embed a literal {@code $}, use \$ (actually {@code "\\$"} with string escapes). The escape + * is only necessary when {@code $} is followed by a digit, but it is always allowed. Only + * {@code $} and {@code \} need escaping, but any character can be escaped. + * + * The group number {@code n} in {@code $n} is always at least one digit and expands to use more + * digits as long as the resulting number is a valid group number for this pattern. To cut it off + * earlier, escape the first digit that should not be used. + * + * @param {string} replacement the replacement string + * @param {boolean} [javaMode=false] activate java mode (different behaviour for capture groups and special characters) + * @returns {string} + * @throws IllegalStateException if there was no most recent match + * @throws IndexOutOfBoundsException if replacement refers to an invalid group + * @private + */ + appendReplacement(replacement, javaMode = false) { + let res = ""; + const s = this.start(); + const e = this.end(); + if (this.appendPos < s) res += this.substring(this.appendPos, s); + this.appendPos = e; + res += javaMode ? this.appendReplacementInternalJava(replacement) : this.appendReplacementInternalJs(replacement); + return res; + } + /** + * @param {string} replacement - the replacement string + * @returns {string} + * @private + */ + appendReplacementInternalJava(replacement) { + let res = ""; + let last = 0; + const m = replacement.length; + let i = 0; + while (i < m) { + const cCode = replacement.codePointAt(i); + if (cCode === Codepoint.CODES.get("\\")) { + if (last < i) res += replacement.substring(last, i); + i++; + if (i >= m) throw new RE2JSGroupException("character to be escaped is missing"); + last = i; + i++; + continue; + } + if (cCode === Codepoint.CODES.get("$")) { + if (last < i) res += replacement.substring(last, i); + if (i + 1 >= m) throw new RE2JSGroupException("Illegal group reference: group index is missing"); + const nextCode = replacement.codePointAt(i + 1); + if (Codepoint.CODES.get("0") <= nextCode && nextCode <= Codepoint.CODES.get("9")) { + let n = nextCode - Codepoint.CODES.get("0"); + let j = i + 2; + for (; j < m; j++) { + const digit = replacement.codePointAt(j); + if (digit < Codepoint.CODES.get("0") || digit > Codepoint.CODES.get("9") || n * 10 + digit - Codepoint.CODES.get("0") > this.patternGroupCount) break; + n = n * 10 + digit - Codepoint.CODES.get("0"); + } + if (n > this.patternGroupCount) throw new RE2JSGroupException(`n > number of groups: ${n}`); + const group = this.group(n); + if (group !== null) res += group; + i = j; + last = i; + } else if (nextCode === Codepoint.CODES.get("{")) { + let j = i + 2; + while (j < m && replacement.codePointAt(j) !== Codepoint.CODES.get("}")) j++; + if (j >= m) throw new RE2JSGroupException("named capture group is missing trailing '}'"); + const groupName = replacement.substring(i + 2, j); + const groupVal = this.group(groupName); + if (groupVal !== null) res += groupVal; + i = j + 1; + last = i; + } else throw new RE2JSGroupException("Illegal group reference"); + continue; + } + i++; + } + if (last < m) res += replacement.substring(last, m); + return res; + } + /** + * @param {string} replacement - the replacement string + * @returns {string} + * @private + */ + appendReplacementInternalJs(replacement) { + let res = ""; + let last = 0; + const m = replacement.length; + for (let i = 0; i < m - 1; i++) if (replacement.codePointAt(i) === Codepoint.CODES.get("$")) { + let c = replacement.codePointAt(i + 1); + if (Codepoint.CODES.get("$") === c) { + if (last < i) res += replacement.substring(last, i); + res += "$"; + i++; + last = i + 1; + continue; + } else if (Codepoint.CODES.get("&") === c) { + if (last < i) res += replacement.substring(last, i); + const group = this.group(0); + if (group !== null) res += group; + else res += "$&"; + i++; + last = i + 1; + continue; + } else if (Codepoint.CODES.get("`") === c) { + if (last < i) res += replacement.substring(last, i); + res += this.substring(0, this.start(0)); + i++; + last = i + 1; + continue; + } else if (Codepoint.CODES.get("'") === c) { + if (last < i) res += replacement.substring(last, i); + res += this.substring(this.end(0), this.matcherInputLength); + i++; + last = i + 1; + continue; + } else if (Codepoint.CODES.get("1") <= c && c <= Codepoint.CODES.get("9")) { + let n = c - Codepoint.CODES.get("0"); + if (last < i) res += replacement.substring(last, i); + for (i += 2; i < m; i++) { + c = replacement.codePointAt(i); + if (c < Codepoint.CODES.get("0") || c > Codepoint.CODES.get("9") || n * 10 + c - Codepoint.CODES.get("0") > this.patternGroupCount) break; + n = n * 10 + c - Codepoint.CODES.get("0"); + } + if (n > this.patternGroupCount) { + res += `$${n}`; + last = i; + i--; + continue; + } + const group = this.group(n); + if (group !== null) res += group; + last = i; + i--; + continue; + } else if (c === Codepoint.CODES.get("<")) { + if (last < i) res += replacement.substring(last, i); + i++; + let j = i + 1; + while (j < replacement.length && replacement.codePointAt(j) !== Codepoint.CODES.get(">") && replacement.codePointAt(j) !== Codepoint.CODES.get(" ")) j++; + if (j === replacement.length || replacement.codePointAt(j) !== Codepoint.CODES.get(">")) { + res += replacement.substring(i - 1, j + 1); + last = j + 1; + i = j; + continue; + } + const groupName = replacement.substring(i + 1, j); + if (Object.prototype.hasOwnProperty.call(this.namedGroups, groupName)) { + const groupVal = this.group(groupName); + if (groupVal !== null) res += groupVal; + } else res += `$<${groupName}>`; + last = j + 1; + i = j; + continue; + } + } + if (last < m) res += replacement.substring(last, m); + return res; + } + /** + * Return the substring of the input from the append position to the end of the + * input. + * @returns {string} + */ + appendTail() { + return this.substring(this.appendPos, this.matcherInputLength); + } + /** + * Returns the input with all matches replaced by {@code replacement}, interpreted as for + * {@code appendReplacement}. + * + * @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function + * @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters) + * @returns {string} the input string with the matches replaced + * @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true + */ + replaceAll(replacement, javaMode = false) { + return this.replace(replacement, true, javaMode); + } + /** + * Returns the input with the first match replaced by {@code replacement}, interpreted as for + * {@code appendReplacement}. + * + * @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function + * @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters) + * @returns {string} the input string with the first match replaced + * @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true + */ + replaceFirst(replacement, javaMode = false) { + return this.replace(replacement, false, javaMode); + } + /** + * Helper: replaceAll/replaceFirst hybrid. + * @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function + * @param {boolean} [all=true] - replace all matches + * @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters) + * @returns {string} + * @private + */ + replace(replacement, all = true, javaMode = false) { + let res = ""; + this.reset(); + const isFunc = typeof replacement === "function"; + const hasNamedGroups = Object.keys(this.namedGroups).length > 0; + let originalInput = null; + if (isFunc) { + if (this.groupCount() >= Matcher.MAX_REPLACER_ARGS) throw new RE2JSGroupException("Too many capture groups to safely invoke replacer function"); + originalInput = this.matcherInput.isUTF8Encoding() ? this.matcherInput.asBytes() : this.matcherInput.asCharSequence(); + } + while (this.find()) { + res += isFunc ? this.appendReplacementFunc(replacement, hasNamedGroups, originalInput) : this.appendReplacement(replacement, javaMode); + if (!all) break; + } + res += this.appendTail(); + return res; + } + /** + * Evaluates a replacer function for the current match and appends the result, + * along with any un-matched preceding text, advancing the append position. + * @param {Function} replacer - the replacer function + * @param {boolean} hasNamedGroups - cached flag if pattern has named groups + * @param {string|Uint8Array|number[]} originalInput - the cached original input reference + * @returns {string} the evaluated string to append + * @private + */ + appendReplacementFunc(replacer, hasNamedGroups, originalInput) { + let res = ""; + const s = this.start(); + const e = this.end(); + if (this.appendPos < s) res += this.substring(this.appendPos, s); + this.appendPos = e; + const args = this.buildReplacerArgs(s, hasNamedGroups, originalInput); + res += String(replacer(...args)); + return res; + } + /** + * Builds the argument array for the replacer function matching the standard + * JS String.prototype.replace(regex, replacer) signature. + * @param {number} matchStart - the start index of the match + * @param {boolean} hasNamedGroups - cached flag if pattern has named groups + * @param {string|Uint8Array|number[]} originalInput - the cached original input reference + * @returns {Array} array of arguments + * @private + */ + buildReplacerArgs(matchStart, hasNamedGroups, originalInput) { + const args = [this.group(0)]; + const numGroups = this.groupCount(); + for (let i = 1; i <= numGroups; i++) { + const start = this.start(i); + if (start < 0) args.push(void 0); + else args.push(this.substring(start, this.end(i))); + } + args.push(matchStart); + args.push(originalInput); + if (hasNamedGroups) { + const parsedGroups = this.getNamedGroups(); + for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0; + args.push(parsedGroups); + } + return args; + } +}; +//#endregion +//#region src/Inst.js +/** +* A single instruction in the regular expression virtual machine. +* +* @see http://swtch.com/~rsc/regexp/regexp2.html +*/ +var Inst = class Inst { + static ALT = 1; + static ALT_MATCH = 2; + static CAPTURE = 3; + static EMPTY_WIDTH = 4; + static FAIL = 5; + static MATCH = 6; + static NOP = 7; + static RUNE = 8; + static RUNE1 = 9; + static RUNE_ANY = 10; + static RUNE_ANY_NOT_NL = 11; + static LB_WRITE = 12; + static LB_CHECK = 13; + static isRuneOp(op) { + return Inst.RUNE <= op && op <= Inst.RUNE_ANY_NOT_NL; + } + static escapeRunes(runes) { + let out = "\""; + for (let rune of runes) out += Utils.escapeRune(rune); + out += "\""; + return out; + } + constructor(op) { + this.op = op; + this.out = 0; + this.arg = 0; + this.runes = []; + /** @type {Uint32Array | number[] | null} */ + this.next = null; + } + matchRune(r) { + if (this.runes.length === 1) { + const r0 = this.runes[0]; + if ((this.arg & RE2Flags.FOLD_CASE) !== 0) return Unicode.equalsIgnoreCase(r0, r); + return r === r0; + } + const len = this.runes.length; + if (len === 0) return false; + if (len === 2 || len === 4 || len === 6 || len === 8) { + for (let j = 0; j < len; j += 2) { + if (r < this.runes[j]) return false; + if (r <= this.runes[j + 1]) return true; + } + return false; + } + let base = 0; + let n = len >> 1; + while (n > 1) { + const half = n >> 1; + base += this.runes[base + half << 1] <= r ? half : 0; + n -= half; + } + base += this.runes[base << 1] <= r ? 1 : 0; + const m = base - 1; + return m >= 0 && r <= this.runes[m << 1 | 1]; + } + matchRunePos(r) { + if (this.runes.length === 1) { + const r0 = this.runes[0]; + if ((this.arg & RE2Flags.FOLD_CASE) !== 0) return Unicode.equalsIgnoreCase(r0, r) ? 0 : -1; + return r === r0 ? 0 : -1; + } + const len = this.runes.length; + if (len === 0) return -1; + if (len === 2 || len === 4 || len === 6 || len === 8) { + for (let j = 0; j < len; j += 2) { + if (r < this.runes[j]) return -1; + if (r <= this.runes[j + 1]) return Math.floor(j / 2); + } + return -1; + } + let base = 0; + let n = len >> 1; + while (n > 1) { + const half = n >> 1; + base += this.runes[base + half << 1] <= r ? half : 0; + n -= half; + } + base += this.runes[base << 1] <= r ? 1 : 0; + const m = base - 1; + return m >= 0 && r <= this.runes[m << 1 | 1] ? m : -1; + } + /** + * + * @returns {string} + */ + toString() { + switch (this.op) { + case Inst.ALT: return `alt -> ${this.out}, ${this.arg}`; + case Inst.ALT_MATCH: return `altmatch -> ${this.out}, ${this.arg}`; + case Inst.CAPTURE: return `cap ${this.arg} -> ${this.out}`; + case Inst.EMPTY_WIDTH: return `empty ${this.arg} -> ${this.out}`; + case Inst.MATCH: return `match${this.arg !== 0 ? ` ${this.arg}` : ""}`; + case Inst.FAIL: return "fail"; + case Inst.NOP: return `nop -> ${this.out}`; + case Inst.LB_WRITE: return `lbwrite ${this.arg} -> ${this.out}`; + case Inst.LB_CHECK: return `lbcheck ${this.arg} -> ${this.out}`; + case Inst.RUNE: + if (this.runes === null) return "rune "; + return [ + "rune ", + Inst.escapeRunes(this.runes), + (this.arg & RE2Flags.FOLD_CASE) !== 0 ? "/i" : "", + " -> ", + this.out + ].join(""); + case Inst.RUNE1: return `rune1 ${Inst.escapeRunes(this.runes)} -> ${this.out}`; + case Inst.RUNE_ANY: return `any -> ${this.out}`; + case Inst.RUNE_ANY_NOT_NL: return `anynotnl -> ${this.out}`; + default: throw new Error("unhandled case in Inst.toString"); + } + } +}; +//#endregion +//#region src/Machine.js +var Queue = class { + constructor(numInst) { + this.sparse = new Int32Array(numInst); + this.densePcs = new Int32Array(numInst); + this.denseCaps = null; + this.size = 0; + this.ncap = 0; + } + init(ncap) { + this.ncap = ncap; + const needed = this.densePcs.length * ncap; + if (!this.denseCaps || this.denseCaps.length < needed) this.denseCaps = new Int32Array(needed); + } + contains(pc) { + const j = this.sparse[pc]; + return j < this.size && this.densePcs[j] === pc; + } + isEmpty() { + return this.size === 0; + } + add(pc) { + const j = this.size++; + this.sparse[pc] = j; + this.densePcs[j] = pc; + return j; + } + clear() { + this.size = 0; + } + toString() { + let out = "{"; + for (let i = 0; i < this.size; i++) { + if (i !== 0) out += ", "; + out += this.densePcs[i]; + } + out += "}"; + return out; + } +}; +var Machine = class Machine { + static fromRE2(re2) { + const m = new Machine(); + m.prog = re2.prog; + m.re2 = re2; + m.q0 = new Queue(m.prog.numInst()); + m.q1 = new Queue(m.prog.numInst()); + m.matched = false; + m.matchcap = new Int32Array(m.prog.numCap < 2 ? 2 : m.prog.numCap); + m.ncap = 0; + return m; + } + static fromMachine(machine) { + return Machine.fromRE2(machine.re2); + } + constructor() { + this.prog = null; + this.re2 = null; + this.q0 = null; + this.q1 = null; + this.matched = false; + this.matchcap = null; + this.ncap = 0; + this.lbTable = null; + } + init(ncap) { + this.ncap = ncap; + if (ncap > this.matchcap.length) this.matchcap = new Int32Array(ncap).fill(-1); + else this.matchcap.fill(-1); + this.q0.init(ncap); + this.q1.init(ncap); + if (this.prog.numLb > 0) { + if (!this.lbTable || this.lbTable.length < this.prog.numLb + 1) this.lbTable = new Int32Array(this.prog.numLb + 1); + this.lbTable.fill(-1); + } + } + submatches() { + if (this.ncap === 0) return Utils.emptyInts(); + return Utils.toArray(this.matchcap.subarray(0, this.ncap)); + } + match(input, pos, anchor) { + const startCond = this.re2.cond; + if (startCond === Utils.EMPTY_ALL) return false; + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return false; + this.matched = false; + this.matchcap.fill(-1); + let currentPos = this.prog.numLb > 0 ? 0 : pos; + let matchStartPos = pos; + let runq = this.q0; + let nextq = this.q1; + let r = input.step(currentPos); + let rune = r >> 3; + let width = r & 7; + let rune1 = -1; + let width1 = 0; + if (r !== MachineInputBase.EOF()) { + r = input.step(currentPos + width); + rune1 = r >> 3; + width1 = r & 7; + } + let flag; + if (currentPos === 0) flag = Utils.emptyOpContext(-1, rune); + else flag = input.context(currentPos); + while (true) { + if (runq.isEmpty()) { + if ((startCond & Utils.EMPTY_BEGIN_TEXT) !== 0 && currentPos !== 0) break; + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && currentPos !== 0) break; + if (this.matched) break; + if (this.prog.numLb === 0 && !(this.re2.prefix.length === 0) && rune1 !== this.re2.prefixRune && input.canCheckPrefix()) { + const advance = input.index(this.re2, currentPos); + if (advance < 0) break; + currentPos += advance; + r = input.step(currentPos); + rune = r >> 3; + width = r & 7; + r = input.step(currentPos + width); + rune1 = r >> 3; + width1 = r & 7; + flag = input.context(currentPos); + } + } + if (currentPos === 0 && this.prog.numLb > 0) for (let i = 0; i < this.prog.lbStarts.length; i++) this.add(runq, this.prog.lbStarts[i], currentPos, this.matchcap, 0, flag); + if (!this.matched && (currentPos === 0 || anchor === RE2Flags.UNANCHORED)) { + if (currentPos >= matchStartPos) { + if (this.ncap > 0) this.matchcap[0] = currentPos; + this.add(runq, this.prog.start, currentPos, this.matchcap, 0, flag); + } + } + const nextPos = currentPos + width; + flag = input.context(nextPos); + this.step(runq, nextq, currentPos, nextPos, rune, flag, anchor, currentPos === input.endPos()); + if (width === 0) break; + if (this.ncap === 0 && this.matched) break; + currentPos += width; + rune = rune1; + width = width1; + if (rune !== -1) { + r = input.step(currentPos + width); + rune1 = r >> 3; + width1 = r & 7; + } + const tmpq = runq; + runq = nextq; + nextq = tmpq; + } + nextq.clear(); + return this.matched; + } + matchSet(input, pos, anchor) { + const startCond = this.re2.cond; + if (startCond === Utils.EMPTY_ALL) return []; + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return []; + let currentPos = this.prog.numLb > 0 ? 0 : pos; + let matchStartPos = pos; + let runq = this.q0; + let nextq = this.q1; + let r = input.step(currentPos); + let rune = r >> 3; + let width = r & 7; + let rune1 = -1; + let width1 = 0; + if (r !== MachineInputBase.EOF()) { + r = input.step(currentPos + width); + rune1 = r >> 3; + width1 = r & 7; + } + let flag = currentPos === 0 ? Utils.emptyOpContext(-1, rune) : input.context(currentPos); + const matches = /* @__PURE__ */ new Set(); + while (true) { + if (runq.isEmpty()) { + if ((startCond & Utils.EMPTY_BEGIN_TEXT) !== 0 && currentPos !== 0) break; + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && currentPos !== 0) break; + } + if (currentPos === 0 && this.prog.numLb > 0) for (let i = 0; i < this.prog.lbStarts.length; i++) this.add(runq, this.prog.lbStarts[i], currentPos, this.matchcap, 0, flag); + if (currentPos === 0 || anchor === RE2Flags.UNANCHORED) { + if (currentPos >= matchStartPos) this.add(runq, this.prog.start, currentPos, this.matchcap, 0, flag); + } + const nextPos = currentPos + width; + flag = input.context(nextPos); + for (let j = 0; j < runq.size; j++) { + const pc = runq.densePcs[j]; + const i = this.prog.inst[pc]; + const capOffset = j * this.ncap; + let add = false; + switch (i.op) { + case Inst.MATCH: + if (anchor === RE2Flags.ANCHOR_BOTH && currentPos !== input.endPos()) break; + matches.add(i.arg); + break; + case Inst.RUNE: + add = i.matchRune(rune); + break; + case Inst.RUNE1: + add = rune === i.runes[0]; + break; + case Inst.RUNE_ANY: + add = true; + break; + case Inst.RUNE_ANY_NOT_NL: + add = rune !== 10; + break; + default: continue; + } + if (add) this.add(nextq, i.out, nextPos, runq.denseCaps, capOffset, flag); + } + runq.clear(); + if (width === 0) break; + currentPos += width; + rune = rune1; + width = width1; + if (rune !== -1) { + r = input.step(currentPos + width); + rune1 = r >> 3; + width1 = r & 7; + } + const tmpq = runq; + runq = nextq; + nextq = tmpq; + } + nextq.clear(); + return Array.from(matches).sort((a, b) => a - b); + } + step(runq, nextq, pos, nextPos, c, nextCond, anchor, atEnd) { + const longest = this.re2.longest; + for (let j = 0; j < runq.size; j++) { + const pc = runq.densePcs[j]; + const capOffset = j * this.ncap; + if (longest && this.matched && this.ncap > 0 && this.matchcap[0] < runq.denseCaps[capOffset]) continue; + const i = this.prog.inst[pc]; + let add = false; + switch (i.op) { + case Inst.MATCH: + if (anchor === RE2Flags.ANCHOR_BOTH && !atEnd) break; + if (this.ncap > 0 && (!longest || !this.matched || this.matchcap[1] < pos)) { + runq.denseCaps[capOffset + 1] = pos; + for (let k = 0; k < this.ncap; k++) this.matchcap[k] = runq.denseCaps[capOffset + k]; + } + if (!longest) runq.size = 0; + this.matched = true; + break; + case Inst.RUNE: + add = i.matchRune(c); + break; + case Inst.RUNE1: + add = c === i.runes[0]; + break; + case Inst.RUNE_ANY: + add = true; + break; + case Inst.RUNE_ANY_NOT_NL: + add = c !== 10; + break; + default: continue; + } + if (add) this.add(nextq, i.out, nextPos, runq.denseCaps, capOffset, nextCond); + } + runq.clear(); + } + add(q, pc, pos, capArray, capOffset, cond) { + while (true) { + if (pc === 0) return; + if (q.contains(pc)) return; + const d = q.add(pc); + const inst = this.prog.inst[pc]; + switch (inst.op) { + case Inst.FAIL: return; + case Inst.ALT: + case Inst.ALT_MATCH: + this.add(q, inst.out, pos, capArray, capOffset, cond); + pc = inst.arg; + continue; + case Inst.EMPTY_WIDTH: + if ((inst.arg & ~cond) === 0) { + pc = inst.out; + continue; + } + return; + case Inst.NOP: + pc = inst.out; + continue; + case Inst.CAPTURE: if (inst.arg < this.ncap) { + const opos = capArray[capOffset + inst.arg]; + capArray[capOffset + inst.arg] = pos; + this.add(q, inst.out, pos, capArray, capOffset, cond); + capArray[capOffset + inst.arg] = opos; + return; + } else { + pc = inst.out; + continue; + } + case Inst.LB_WRITE: + this.lbTable[Math.abs(inst.arg)] = pos; + pc = inst.out; + continue; + case Inst.LB_CHECK: + if (inst.arg > 0) { + if (this.lbTable[inst.arg] === pos) { + pc = inst.out; + continue; + } + } else if (this.lbTable[-inst.arg] !== pos) { + pc = inst.out; + continue; + } + return; + case Inst.MATCH: + case Inst.RUNE: + case Inst.RUNE1: + case Inst.RUNE_ANY: + case Inst.RUNE_ANY_NOT_NL: + if (this.ncap > 0) { + const destOffset = d * this.ncap; + for (let c = 0; c < this.ncap; c++) q.denseCaps[destOffset + c] = capArray[capOffset + c]; + } + return; + default: throw new RE2JSInternalException("unhandled"); + } + } + } +}; +//#endregion +//#region src/DFA.js +const hashPCs = (pcs) => { + let h = -2128831035; + for (let i = 0; i < pcs.length; i++) { + h ^= pcs[i]; + h = Math.imul(h, 16777619); + } + return h; +}; +const arraysEqual = (a, b) => { + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false; + return true; +}; +var DFAState = class { + constructor(nfaStates, isMatch, matchIDs = []) { + this.nfaStates = nfaStates; + this.isMatch = isMatch; + this.matchIDs = matchIDs; + this.nextLatin1 = new Array(Unicode.MAX_LATIN1 + 1).fill(null); + this.nextLatin1Anchored = new Array(Unicode.MAX_LATIN1 + 1).fill(null); + this.transKeys = []; + this.transVals = []; + this.lastSeen = 0; + } +}; +var DFA = class DFA { + static MAX_CACHE_CLEARS = 5; + static STATE_MEMORY_ESTIMATE = 838; + constructor(prog, maxMem = 8388608) { + this.prog = prog; + this.stateCache = /* @__PURE__ */ new Map(); + this.stateCount = 0; + this.startState = null; + this.stateLimit = Math.max(1, Math.floor(maxMem / DFA.STATE_MEMORY_ESTIMATE)); + this.cacheClears = 0; + this.failed = false; + this.clock = 0; + } + computeClosure(pcs) { + const closure = /* @__PURE__ */ new Set(); + const stack = [...pcs]; + let isMatch = false; + const matchIDs = []; + while (stack.length > 0) { + const pc = stack.pop(); + if (closure.has(pc)) continue; + closure.add(pc); + const inst = this.prog.getInst(pc); + switch (inst.op) { + case Inst.MATCH: + isMatch = true; + if (!matchIDs.includes(inst.arg)) matchIDs.push(inst.arg); + break; + case Inst.ALT: + case Inst.ALT_MATCH: + stack.push(inst.out); + stack.push(inst.arg); + break; + case Inst.NOP: + case Inst.CAPTURE: + stack.push(inst.out); + break; + case Inst.EMPTY_WIDTH: + case Inst.LB_WRITE: + case Inst.LB_CHECK: return null; + } + } + const sortedPCs = Int32Array.from(closure).sort(); + matchIDs.sort((a, b) => a - b); + return { + pcs: sortedPCs, + isMatch, + matchIDs + }; + } + getState(pcs) { + const closureResult = this.computeClosure(pcs); + if (!closureResult) return null; + const sortedPCs = closureResult.pcs; + const hash = hashPCs(sortedPCs); + let bucket = this.stateCache.get(hash); + if (bucket) for (let i = 0; i < bucket.length; i++) { + const state = bucket[i]; + if (arraysEqual(state.nfaStates, sortedPCs)) { + state.lastSeen = ++this.clock; + return state; + } + } + else { + bucket = []; + this.stateCache.set(hash, bucket); + } + if (this.failed) return null; + if (this.stateCount >= this.stateLimit) { + this.cacheClears++; + if (this.cacheClears >= DFA.MAX_CACHE_CLEARS) { + this.failed = true; + this.stateCache.clear(); + this.stateCount = 0; + this.startState = null; + return null; + } + this.evictCache(); + bucket = this.stateCache.get(hash); + if (!bucket) { + bucket = []; + this.stateCache.set(hash, bucket); + } + } + const state = new DFAState(sortedPCs, closureResult.isMatch, closureResult.matchIDs); + state.lastSeen = ++this.clock; + bucket.push(state); + this.stateCount++; + return state; + } + evictCache() { + const allStates = []; + for (const bucket of this.stateCache.values()) for (let i = 0; i < bucket.length; i++) allStates.push(bucket[i]); + allStates.sort((a, b) => a.lastSeen - b.lastSeen); + const keepCount = Math.max(1, Math.floor(this.stateLimit / 2)); + const startIndex = allStates.length - keepCount; + const survivorsArray = allStates.slice(startIndex); + const survivors = new Set(survivorsArray); + this.stateCache.clear(); + this.stateCount = 0; + for (let i = 0; i < survivorsArray.length; i++) { + const state = survivorsArray[i]; + state.nextLatin1.fill(null); + state.nextLatin1Anchored.fill(null); + state.transKeys.length = 0; + state.transVals.length = 0; + const hash = hashPCs(state.nfaStates); + let bucket = this.stateCache.get(hash); + if (!bucket) { + bucket = []; + this.stateCache.set(hash, bucket); + } + bucket.push(state); + this.stateCount++; + } + if (this.startState && !survivors.has(this.startState)) this.startState = null; + } + step(state, charCode, anchor) { + if (charCode <= Unicode.MAX_LATIN1) if (anchor === RE2Flags.UNANCHORED) { + const next = state.nextLatin1[charCode]; + if (next !== null) return next; + } else { + const next = state.nextLatin1Anchored[charCode]; + if (next !== null) return next; + } + else { + const key = charCode + (anchor === RE2Flags.UNANCHORED ? 0 : Unicode.MAX_RUNE + 1); + const keys = state.transKeys; + const len = keys.length; + for (let i = 0; i < len; i++) if (keys[i] === key) return state.transVals[i]; + } + const nextPCs = []; + for (let i = 0; i < state.nfaStates.length; i++) { + const pc = state.nfaStates[i]; + const inst = this.prog.getInst(pc); + if (Inst.isRuneOp(inst.op) && inst.matchRune(charCode)) nextPCs.push(inst.out); + } + if (anchor === RE2Flags.UNANCHORED) nextPCs.push(this.prog.start); + const nextState = this.getState(nextPCs); + if (charCode <= Unicode.MAX_LATIN1) if (anchor === RE2Flags.UNANCHORED) state.nextLatin1[charCode] = nextState; + else state.nextLatin1Anchored[charCode] = nextState; + else { + const key = charCode + (anchor === RE2Flags.UNANCHORED ? 0 : Unicode.MAX_RUNE + 1); + state.transKeys.push(key); + state.transVals.push(nextState); + } + return nextState; + } + match(input, pos, anchor) { + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return false; + if (!this.startState) { + this.startState = this.getState([this.prog.start]); + if (!this.startState) return null; + } + let endPos = input.endPos(); + let currentState = this.startState; + if (currentState.isMatch) if (anchor === RE2Flags.ANCHOR_BOTH) { + if (pos === endPos) return true; + } else return true; + let i = pos; + while (i < endPos) { + const r = input.step(i); + const rune = r >> 3; + const width = r & 7; + if (width === 0) break; + currentState = anchor === RE2Flags.UNANCHORED && rune <= Unicode.MAX_LATIN1 && currentState.nextLatin1[rune] || this.step(currentState, rune, anchor); + if (currentState === null) return null; + currentState.lastSeen = ++this.clock; + if (currentState.isMatch) if (anchor === RE2Flags.ANCHOR_BOTH) { + if (i + width === endPos) return true; + } else return true; + if (currentState.nfaStates.length === 0) { + if (anchor !== RE2Flags.UNANCHORED) return false; + } + i += width; + } + return false; + } + matchSet(input, pos, anchor) { + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return []; + if (!this.startState) { + this.startState = this.getState([this.prog.start]); + if (!this.startState) return null; + } + let endPos = input.endPos(); + let currentState = this.startState; + const matches = /* @__PURE__ */ new Set(); + const checkMatch = (state, currentPos) => { + if (state.isMatch) if (anchor === RE2Flags.ANCHOR_BOTH) { + if (currentPos === endPos) state.matchIDs.forEach((id) => matches.add(id)); + } else state.matchIDs.forEach((id) => matches.add(id)); + }; + checkMatch(currentState, pos); + let i = pos; + while (i < endPos) { + const r = input.step(i); + const rune = r >> 3; + const width = r & 7; + if (width === 0) break; + currentState = anchor === RE2Flags.UNANCHORED && rune <= Unicode.MAX_LATIN1 && currentState.nextLatin1[rune] || this.step(currentState, rune, anchor); + if (currentState === null) return null; + currentState.lastSeen = ++this.clock; + i += width; + checkMatch(currentState, i); + if (currentState.nfaStates.length === 0) { + if (anchor !== RE2Flags.UNANCHORED) break; + } + } + return Array.from(matches).sort((a, b) => a - b); + } +}; +//#endregion +//#region src/Backtracker.js +const VISITED_BITS = 32; +const MAX_BACKTRACK_PROG = 500; +const INITIAL_JOB_CAPACITY = 256; +const MAX_BACKTRACK_VECTOR = 256 * 1024; +var BitState = class { + constructor() { + this.end = 0; + this.cap = /* @__PURE__ */ new Int32Array(0); + this.matchcap = /* @__PURE__ */ new Int32Array(0); + this.ncap = 0; + this.jobPc = new Int32Array(INITIAL_JOB_CAPACITY); + this.jobArg = new Uint8Array(INITIAL_JOB_CAPACITY); + this.jobPos = new Int32Array(INITIAL_JOB_CAPACITY); + this.jobLen = 0; + this.visited = /* @__PURE__ */ new Uint32Array(0); + } + reset(prog, end, ncap) { + this.end = end; + this.jobLen = 0; + this.ncap = ncap; + const visitedSize = prog.numInst() * (end + 1) + VISITED_BITS - 1 >>> 5; + if (this.visited.length < visitedSize) this.visited = new Uint32Array(visitedSize); + else this.visited.fill(0, 0, visitedSize); + if (this.cap.length < ncap) this.cap = new Int32Array(ncap).fill(-1); + else this.cap.fill(-1, 0, ncap); + if (this.matchcap.length < ncap) this.matchcap = new Int32Array(ncap).fill(-1); + else this.matchcap.fill(-1, 0, ncap); + } + shouldVisit(pc, pos) { + const n = pc * (this.end + 1) + pos; + const idx = n >>> 5; + const mask = 1 << (n & 31); + if ((this.visited[idx] & mask) !== 0) return false; + this.visited[idx] |= mask; + return true; + } + push(re2, pc, pos, arg) { + if (re2.prog.getInst(pc).op !== Inst.FAIL && (arg || this.shouldVisit(pc, pos))) { + if (this.jobLen >= this.jobPc.length) { + const newSize = this.jobPc.length * 2; + const newPc = new Int32Array(newSize); + newPc.set(this.jobPc); + this.jobPc = newPc; + const newArg = new Uint8Array(newSize); + newArg.set(this.jobArg); + this.jobArg = newArg; + const newPos = new Int32Array(newSize); + newPos.set(this.jobPos); + this.jobPos = newPos; + } + this.jobPc[this.jobLen] = pc; + this.jobArg[this.jobLen] = arg ? 1 : 0; + this.jobPos[this.jobLen] = pos; + this.jobLen++; + } + } + tryBacktrack(re2, input, pc, pos, anchor) { + const longest = re2.longest; + this.push(re2, pc, pos, false); + while (this.jobLen > 0) { + this.jobLen--; + let currentPc = this.jobPc[this.jobLen]; + let arg = this.jobArg[this.jobLen] === 1; + let currentPos = this.jobPos[this.jobLen]; + let skipShouldVisit = true; + while (true) { + if (!skipShouldVisit) { + if (!this.shouldVisit(currentPc, currentPos)) break; + } + skipShouldVisit = false; + const inst = re2.prog.getInst(currentPc); + switch (inst.op) { + case Inst.FAIL: throw new RE2JSInternalException("unexpected InstFail"); + case Inst.ALT: if (arg) { + arg = false; + currentPc = inst.arg; + continue; + } else { + this.push(re2, currentPc, currentPos, true); + currentPc = inst.out; + continue; + } + case Inst.ALT_MATCH: { + const outInst = re2.prog.getInst(inst.out); + if (Inst.isRuneOp(outInst.op)) { + this.push(re2, inst.arg, currentPos, false); + currentPc = inst.arg; + currentPos = this.end; + continue; + } + this.push(re2, inst.out, this.end, false); + currentPc = inst.out; + continue; + } + case Inst.RUNE: { + const r = input.step(currentPos); + if (r === MachineInputBase.EOF()) break; + if (!inst.matchRune(r >> 3)) break; + currentPos += r & 7; + currentPc = inst.out; + continue; + } + case Inst.RUNE1: { + const r = input.step(currentPos); + if (r === MachineInputBase.EOF()) break; + if (r >> 3 !== inst.runes[0]) break; + currentPos += r & 7; + currentPc = inst.out; + continue; + } + case Inst.RUNE_ANY_NOT_NL: { + const r = input.step(currentPos); + if (r === MachineInputBase.EOF()) break; + if (r >> 3 === 10) break; + currentPos += r & 7; + currentPc = inst.out; + continue; + } + case Inst.RUNE_ANY: { + const r = input.step(currentPos); + if (r === MachineInputBase.EOF()) break; + currentPos += r & 7; + currentPc = inst.out; + continue; + } + case Inst.CAPTURE: if (arg) { + this.cap[inst.arg] = currentPos; + break; + } else { + if (inst.arg < this.ncap) { + this.push(re2, currentPc, this.cap[inst.arg], true); + this.cap[inst.arg] = currentPos; + } + currentPc = inst.out; + continue; + } + case Inst.EMPTY_WIDTH: { + const flag = input.context(currentPos); + if ((inst.arg & ~flag) !== 0) break; + currentPc = inst.out; + continue; + } + case Inst.NOP: + currentPc = inst.out; + continue; + case Inst.MATCH: { + if (anchor === RE2Flags.ANCHOR_BOTH && currentPos !== this.end) break; + if (this.ncap === 0) return true; + if (this.ncap > 1) this.cap[1] = currentPos; + const old = this.matchcap[1]; + if (old === -1 || longest && currentPos > 0 && currentPos > old) this.matchcap.set(this.cap); + if (!longest) return true; + if (currentPos === this.end) return true; + break; + } + case Inst.LB_WRITE: + case Inst.LB_CHECK: throw new RE2JSInternalException("Backtracker cannot evaluate Lookbehind instructions"); + default: throw new RE2JSInternalException("bad inst"); + } + break; + } + } + return longest && this.matchcap.length > 1 && this.matchcap[1] >= 0; + } +}; +const bitStatePool = []; +var Backtracker = class Backtracker { + static shouldBacktrack(prog) { + return prog.numInst() <= MAX_BACKTRACK_PROG; + } + static maxBitStateLen(prog) { + if (!Backtracker.shouldBacktrack(prog)) return 0; + return Math.floor(MAX_BACKTRACK_VECTOR / prog.numInst()); + } + static execute(re2, input, pos, anchor, ncap) { + const startCond = re2.cond; + if (startCond === Utils.EMPTY_ALL) return null; + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return null; + if ((startCond & Utils.EMPTY_BEGIN_TEXT) !== 0 && pos !== 0) return null; + const b = bitStatePool.length > 0 ? bitStatePool.pop() : new BitState(); + const end = input.endPos(); + b.reset(re2.prog, end, ncap); + let matched = false; + if ((startCond & Utils.EMPTY_BEGIN_TEXT) !== 0 || anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) { + if (b.ncap > 0) b.cap[0] = pos; + if (b.tryBacktrack(re2, input, re2.prog.start, pos, anchor)) matched = true; + } else { + let width = -1; + for (; pos <= end && width !== 0; pos += width) { + if (re2.prefix.length > 0) { + const advance = input.index(re2, pos); + if (advance < 0) break; + pos += advance; + } + if (b.ncap > 0) b.cap[0] = pos; + if (b.tryBacktrack(re2, input, re2.prog.start, pos, anchor)) { + matched = true; + break; + } + const r = input.step(pos); + width = r === MachineInputBase.EOF() ? 0 : r & 7; + } + } + if (!matched) { + bitStatePool.push(b); + return null; + } + const result = ncap === 0 ? [] : Utils.toArray(b.matchcap.subarray(0, ncap)); + bitStatePool.push(b); + return result; + } +}; +//#endregion +//#region src/OnePass.js +var QueueOnePass = class { + constructor(size) { + this.sparse = new Uint32Array(size); + this.dense = new Uint32Array(size); + this.size = 0; + this.nextIndex = 0; + } + empty() { + return this.nextIndex >= this.size; + } + next() { + return this.dense[this.nextIndex++]; + } + clear() { + this.size = 0; + this.nextIndex = 0; + } + contains(u) { + return u < this.sparse.length && this.sparse[u] < this.size && this.dense[this.sparse[u]] === u; + } + insert(u) { + if (!this.contains(u)) this.insertNew(u); + } + insertNew(u) { + if (u >= this.sparse.length) return; + this.sparse[u] = this.size; + this.dense[this.size] = u; + this.size++; + } +}; +const mergeRuneSets = (leftRunes, rightRunes, leftPC, rightPC) => { + const leftLen = leftRunes.length; + const rightLen = rightRunes.length; + let lx = 0, rx = 0; + const merged = []; + const next = []; + let ok = true; + let ix = -1; + const extend = (isLeft) => { + const newArray = isLeft ? leftRunes : rightRunes; + const low = isLeft ? lx : rx; + const pc = isLeft ? leftPC : rightPC; + if (ix > 0 && newArray[low] <= merged[ix]) return false; + merged.push(newArray[low], newArray[low + 1]); + if (isLeft) lx += 2; + else rx += 2; + ix += 2; + next.push(pc); + return true; + }; + while (lx < leftLen || rx < rightLen) { + if (rx >= rightLen) ok = extend(true); + else if (lx >= leftLen) ok = extend(false); + else if (rightRunes[rx] < leftRunes[lx]) ok = extend(false); + else ok = extend(true); + if (!ok) return null; + } + return { + merged, + next + }; +}; +var OnePassProg = class { + constructor(prog) { + this.start = prog.start; + this.numCap = prog.numCap; + this.inst = new Array(prog.inst.length); + for (let i = 0; i < prog.inst.length; i++) { + const orig = prog.inst[i]; + const inst = new Inst(orig.op); + inst.out = orig.out; + inst.arg = orig.arg; + inst.runes = orig.runes ? orig.runes.slice() : []; + inst.next = null; + this.inst[i] = inst; + } + } +}; +const onePassCopy = (prog) => { + const p = new OnePassProg(prog); + for (let pc = 0; pc < p.inst.length; pc++) { + const inst = p.inst[pc]; + if (inst.op !== Inst.ALT && inst.op !== Inst.ALT_MATCH) continue; + let pAOther = "out"; + let pAAlt = "arg"; + let instAlt = p.inst[inst[pAAlt]]; + if (instAlt.op !== Inst.ALT && instAlt.op !== Inst.ALT_MATCH) { + pAOther = "arg"; + pAAlt = "out"; + instAlt = p.inst[inst[pAAlt]]; + if (instAlt.op !== Inst.ALT && instAlt.op !== Inst.ALT_MATCH) continue; + } + const instOther = p.inst[inst[pAOther]]; + if (instOther.op === Inst.ALT || instOther.op === Inst.ALT_MATCH) continue; + let pBAlt = "out"; + let pBOther = "arg"; + let patch = false; + if (instAlt.out === pc) patch = true; + else if (instAlt.arg === pc) { + patch = true; + pBAlt = "arg"; + pBOther = "out"; + } + if (patch) instAlt[pBAlt] = inst[pAOther]; + if (inst[pAOther] === instAlt[pBAlt]) inst[pAAlt] = instAlt[pBOther]; + } + return p; +}; +const makeOnePass = (p) => { + if (p.inst.length >= 1e3) return null; + const instQueue = new QueueOnePass(p.inst.length); + const visitQueue = new QueueOnePass(p.inst.length); + const onePassRunes = new Array(p.inst.length); + const m = new Array(p.inst.length).fill(false); + const check = (pc) => { + let ok = true; + const inst = p.inst[pc]; + if (visitQueue.contains(pc)) return true; + visitQueue.insert(pc); + switch (inst.op) { + case Inst.ALT: + case Inst.ALT_MATCH: { + ok = check(inst.out) && check(inst.arg); + let matchOut = m[inst.out]; + let matchArg = m[inst.arg]; + if (matchOut && matchArg) return false; + if (matchArg) { + const tempOut = inst.out; + inst.out = inst.arg; + inst.arg = tempOut; + const tempMatch = matchOut; + matchOut = matchArg; + matchArg = tempMatch; + } + if (matchOut) { + m[pc] = true; + inst.op = Inst.ALT_MATCH; + } + const leftRunes = onePassRunes[inst.out] || []; + const rightRunes = onePassRunes[inst.arg] || []; + const mergeRes = mergeRuneSets(leftRunes, rightRunes, inst.out, inst.arg); + if (!mergeRes) return false; + onePassRunes[pc] = mergeRes.merged; + inst.next = new Uint32Array(mergeRes.next); + break; + } + case Inst.CAPTURE: + case Inst.EMPTY_WIDTH: + case Inst.NOP: + ok = check(inst.out); + m[pc] = m[inst.out]; + onePassRunes[pc] = onePassRunes[inst.out] ? onePassRunes[inst.out].slice() : []; + inst.next = new Uint32Array(Math.floor(onePassRunes[pc].length / 2) + 1).fill(inst.out); + break; + case Inst.MATCH: + case Inst.FAIL: + m[pc] = inst.op === Inst.MATCH; + break; + case Inst.RUNE: { + m[pc] = false; + if (inst.next && inst.next.length > 0) break; + instQueue.insert(inst.out); + if (!inst.runes || inst.runes.length === 0) { + onePassRunes[pc] = []; + inst.next = new Uint32Array([inst.out]); + break; + } + let runes = []; + if (inst.runes.length === 1 && (inst.arg & RE2Flags.FOLD_CASE) !== 0) { + const r0 = inst.runes[0]; + runes.push(r0, r0); + for (let r1 = Unicode.simpleFold(r0); r1 !== r0; r1 = Unicode.simpleFold(r1)) runes.push(r1, r1); + runes.sort((a, b) => a - b); + } else for (let j = 0; j < inst.runes.length; j++) runes.push(inst.runes[j]); + onePassRunes[pc] = runes; + inst.next = new Uint32Array(Math.floor(runes.length / 2) + 1).fill(inst.out); + inst.op = Inst.RUNE; + break; + } + case Inst.RUNE1: { + m[pc] = false; + if (inst.next && inst.next.length > 0) break; + instQueue.insert(inst.out); + let runes = []; + if ((inst.arg & RE2Flags.FOLD_CASE) !== 0) { + const r0 = inst.runes[0]; + runes.push(r0, r0); + for (let r1 = Unicode.simpleFold(r0); r1 !== r0; r1 = Unicode.simpleFold(r1)) runes.push(r1, r1); + runes.sort((a, b) => a - b); + } else runes.push(inst.runes[0], inst.runes[0]); + onePassRunes[pc] = runes; + inst.next = new Uint32Array(Math.floor(runes.length / 2) + 1).fill(inst.out); + inst.op = Inst.RUNE; + break; + } + case Inst.RUNE_ANY: + m[pc] = false; + if (inst.next && inst.next.length > 0) break; + instQueue.insert(inst.out); + onePassRunes[pc] = [0, Unicode.MAX_RUNE]; + inst.next = new Uint32Array([inst.out]); + break; + case Inst.RUNE_ANY_NOT_NL: + m[pc] = false; + if (inst.next && inst.next.length > 0) break; + instQueue.insert(inst.out); + onePassRunes[pc] = [ + 0, + 9, + 11, + Unicode.MAX_RUNE + ]; + inst.next = new Uint32Array(Math.floor(onePassRunes[pc].length / 2) + 1).fill(inst.out); + break; + } + return ok; + }; + instQueue.clear(); + instQueue.insert(p.start); + while (!instQueue.empty()) { + visitQueue.clear(); + if (!check(instQueue.next())) return null; + } + for (let i = 0; i < p.inst.length; i++) if (onePassRunes[i]) p.inst[i].runes = onePassRunes[i]; + return p; +}; +const cleanupOnePass = (p, original) => { + for (let ix = 0; ix < original.inst.length; ix++) { + const instOriginal = original.inst[ix]; + switch (instOriginal.op) { + case Inst.ALT: + case Inst.ALT_MATCH: + case Inst.RUNE: break; + case Inst.CAPTURE: + case Inst.EMPTY_WIDTH: + case Inst.NOP: + case Inst.MATCH: + case Inst.FAIL: + p.inst[ix].next = null; + break; + case Inst.RUNE1: + case Inst.RUNE_ANY: + case Inst.RUNE_ANY_NOT_NL: + p.inst[ix].next = null; + p.inst[ix].op = instOriginal.op; + p.inst[ix].runes = instOriginal.runes ? instOriginal.runes.slice() : []; + break; + } + } +}; +var OnePass = class OnePass { + static compile(prog) { + if (prog.start === 0) return null; + if (prog.numLb > 0) return null; + const startInst = prog.inst[prog.start]; + if (startInst.op !== Inst.EMPTY_WIDTH || (startInst.arg & Utils.EMPTY_BEGIN_TEXT) === 0) return null; + let hasAlt = false; + for (let i = 0; i < prog.inst.length; i++) if (prog.inst[i].op === Inst.ALT || prog.inst[i].op === Inst.ALT_MATCH) { + hasAlt = true; + break; + } + for (let i = 0; i < prog.inst.length; i++) { + const inst = prog.inst[i]; + const opOut = prog.inst[inst.out].op; + switch (inst.op) { + case Inst.ALT: + case Inst.ALT_MATCH: + if (opOut === Inst.MATCH || prog.inst[inst.arg].op === Inst.MATCH) return null; + break; + case Inst.EMPTY_WIDTH: + if (opOut === Inst.MATCH) { + if ((inst.arg & Utils.EMPTY_END_TEXT) === Utils.EMPTY_END_TEXT) continue; + return null; + } + break; + default: + if (opOut === Inst.MATCH && hasAlt) return null; + break; + } + } + let p = onePassCopy(prog); + p = makeOnePass(p); + if (p !== null) cleanupOnePass(p, prog); + return p; + } + static next(inst, r) { + const nextIdx = inst.matchRunePos(r); + if (nextIdx >= 0) return inst.next[nextIdx]; + if (inst.op === Inst.ALT_MATCH) return inst.out; + return 0; + } + static execute(re2, input, pos, anchor, ncap) { + const onepass = re2.onepass; + if (!onepass) return null; + const matchcap = new Int32Array(ncap).fill(-1); + let matched = false; + let r = input.step(pos); + let rune = r >> 3; + let width = r & 7; + let r1 = MachineInputBase.EOF(); + let rune1 = -1; + let width1 = 0; + if (r !== MachineInputBase.EOF()) { + r1 = input.step(pos + width); + if (r1 !== MachineInputBase.EOF()) { + rune1 = r1 >> 3; + width1 = r1 & 7; + } + } + let flag = pos === 0 ? Utils.emptyOpContext(-1, rune) : input.context(pos); + let pc = onepass.start; + let inst; + while (true) { + inst = onepass.inst[pc]; + pc = inst.out; + switch (inst.op) { + case Inst.MATCH: + if (anchor === RE2Flags.ANCHOR_BOTH && pos !== input.endPos()) return null; + matched = true; + if (matchcap.length > 0) { + matchcap[0] = 0; + matchcap[1] = pos; + } + return ncap === 0 ? [] : Utils.toArray(matchcap); + case Inst.RUNE: + if (!inst.matchRune(rune)) return null; + break; + case Inst.RUNE1: + if (rune !== inst.runes[0]) return null; + break; + case Inst.RUNE_ANY: break; + case Inst.RUNE_ANY_NOT_NL: + if (rune === 10) return null; + break; + case Inst.ALT: + case Inst.ALT_MATCH: + pc = OnePass.next(inst, rune); + continue; + case Inst.FAIL: return null; + case Inst.NOP: continue; + case Inst.EMPTY_WIDTH: + if ((inst.arg & ~flag) !== 0) return null; + continue; + case Inst.CAPTURE: + if (inst.arg < matchcap.length) matchcap[inst.arg] = pos; + continue; + default: throw new RE2JSInternalException("bad inst"); + } + if (width === 0) break; + flag = Utils.emptyOpContext(rune, rune1); + pos += width; + rune = rune1; + width = width1; + if (rune !== -1) { + r1 = input.step(pos + width); + if (r1 !== MachineInputBase.EOF()) { + rune1 = r1 >> 3; + width1 = r1 & 7; + } else { + rune1 = -1; + width1 = 0; + } + } + } + if (!matched) return null; + return ncap === 0 ? [] : Utils.toArray(matchcap); + } +}; +//#endregion +//#region src/Regexp.js +/** +* Regular expression abstract syntax tree. Produced by parser, used by compiler. NB, this +* corresponds to {@code syntax.regexp} in the Go implementation; Go's {@code regexp} is called +* {@code RE2} in Java. +*/ +var Regexp = class Regexp { + static Op = createEnum([ + "NO_MATCH", + "EMPTY_MATCH", + "LITERAL", + "CHAR_CLASS", + "ANY_CHAR_NOT_NL", + "ANY_CHAR", + "BEGIN_LINE", + "END_LINE", + "BEGIN_TEXT", + "END_TEXT", + "WORD_BOUNDARY", + "NO_WORD_BOUNDARY", + "CAPTURE", + "STAR", + "PLUS", + "QUEST", + "REPEAT", + "CONCAT", + "ALTERNATE", + "PLB", + "NLB", + "LEFT_PAREN", + "VERTICAL_BAR" + ]); + static isPseudoOp(op) { + return op >= Regexp.Op.LEFT_PAREN; + } + static emptySubs() { + return []; + } + static quoteIfHyphen(rune) { + if (rune === Codepoint.CODES.get("-")) return "\\"; + return ""; + } + static fromRegexp(re) { + const regex = new Regexp(re.op); + regex.flags = re.flags; + regex.subs = re.subs; + regex.runes = re.runes; + regex.cap = re.cap; + regex.min = re.min; + regex.max = re.max; + regex.name = re.name; + regex.namedGroups = re.namedGroups; + regex.lb = re.lb; + return regex; + } + constructor(op) { + this.op = op; + this.flags = 0; + this.subs = Regexp.emptySubs(); + this.runes = []; + this.min = 0; + this.max = 0; + this.cap = 0; + this.name = null; + this.namedGroups = Object.create(null); + this.lb = 0; + } + reinit() { + this.flags = 0; + this.subs = Regexp.emptySubs(); + this.runes = []; + this.cap = 0; + this.min = 0; + this.max = 0; + this.name = null; + this.namedGroups = Object.create(null); + this.lb = 0; + } + toString() { + return this.appendTo(); + } + appendTo() { + let out = ""; + switch (this.op) { + case Regexp.Op.NO_MATCH: + out += "[^\\x00-\\x{10FFFF}]"; + break; + case Regexp.Op.EMPTY_MATCH: + out += "(?:)"; + break; + case Regexp.Op.STAR: + case Regexp.Op.PLUS: + case Regexp.Op.QUEST: + case Regexp.Op.REPEAT: { + const sub = this.subs[0]; + if (sub.op > Regexp.Op.CAPTURE || sub.op === Regexp.Op.LITERAL && sub.runes.length > 1) out += `(?:${sub.appendTo()})`; + else out += sub.appendTo(); + switch (this.op) { + case Regexp.Op.STAR: + out += "*"; + break; + case Regexp.Op.PLUS: + out += "+"; + break; + case Regexp.Op.QUEST: + out += "?"; + break; + case Regexp.Op.REPEAT: + out += `{${this.min}`; + if (this.min !== this.max) { + out += ","; + if (this.max >= 0) out += this.max; + } + out += "}"; + break; + } + if ((this.flags & RE2Flags.NON_GREEDY) !== 0) out += "?"; + break; + } + case Regexp.Op.CONCAT: + for (let sub of this.subs) if (sub.op === Regexp.Op.ALTERNATE) out += `(?:${sub.appendTo()})`; + else out += sub.appendTo(); + break; + case Regexp.Op.ALTERNATE: { + let sep = ""; + for (let sub of this.subs) { + out += sep; + sep = "|"; + out += sub.appendTo(); + } + break; + } + case Regexp.Op.LITERAL: + if ((this.flags & RE2Flags.FOLD_CASE) !== 0) out += "(?i:"; + for (let rune of this.runes) out += Utils.escapeRune(rune); + if ((this.flags & RE2Flags.FOLD_CASE) !== 0) out += ")"; + break; + case Regexp.Op.ANY_CHAR_NOT_NL: + out += "(?-s:.)"; + break; + case Regexp.Op.ANY_CHAR: + out += "(?s:.)"; + break; + case Regexp.Op.PLB: + out += `(?<=${this.subs[0].appendTo()})`; + break; + case Regexp.Op.NLB: + out += `(?`; + if (this.subs[0].op !== Regexp.Op.EMPTY_MATCH) out += this.subs[0].appendTo(); + out += ")"; + break; + case Regexp.Op.BEGIN_TEXT: + out += "\\A"; + break; + case Regexp.Op.END_TEXT: + if ((this.flags & RE2Flags.WAS_DOLLAR) !== 0) out += "(?-m:$)"; + else out += "\\z"; + break; + case Regexp.Op.BEGIN_LINE: + out += "^"; + break; + case Regexp.Op.END_LINE: + out += "$"; + break; + case Regexp.Op.WORD_BOUNDARY: + out += "\\b"; + break; + case Regexp.Op.NO_WORD_BOUNDARY: + out += "\\B"; + break; + case Regexp.Op.CHAR_CLASS: + if (this.runes.length % 2 !== 0) { + out += "[invalid char class]"; + break; + } + out += "["; + if (this.runes.length === 0) out += "^\\x00-\\x{10FFFF}"; + else if (this.runes[0] === 0 && this.runes[this.runes.length - 1] === Unicode.MAX_RUNE) { + out += "^"; + for (let i = 1; i < this.runes.length - 1; i += 2) { + const lo = this.runes[i] + 1; + const hi = this.runes[i + 1] - 1; + out += Regexp.quoteIfHyphen(lo); + out += Utils.escapeRune(lo); + if (lo !== hi) { + out += "-"; + out += Regexp.quoteIfHyphen(hi); + out += Utils.escapeRune(hi); + } + } + } else for (let i = 0; i < this.runes.length; i += 2) { + const lo = this.runes[i]; + const hi = this.runes[i + 1]; + out += Regexp.quoteIfHyphen(lo); + out += Utils.escapeRune(lo); + if (lo !== hi) { + out += "-"; + out += Regexp.quoteIfHyphen(hi); + out += Utils.escapeRune(hi); + } + } + out += "]"; + break; + default: + out += this.op; + break; + } + return out; + } + maxCap() { + let m = 0; + if (this.op === Regexp.Op.CAPTURE) m = this.cap; + if (this.subs !== null) for (let sub of this.subs) { + const n = sub.maxCap(); + if (m < n) m = n; + } + return m; + } + equals(that) { + if (!(that !== null && that instanceof Regexp)) return false; + if (this.op !== that.op) return false; + switch (this.op) { + case Regexp.Op.END_TEXT: + if ((this.flags & RE2Flags.WAS_DOLLAR) !== (that.flags & RE2Flags.WAS_DOLLAR)) return false; + break; + case Regexp.Op.LITERAL: + case Regexp.Op.CHAR_CLASS: + if (this.runes === null && that.runes === null) break; + if (this.runes === null || that.runes === null) return false; + if (this.runes.length !== that.runes.length) return false; + for (let i = 0; i < this.runes.length; i++) if (this.runes[i] !== that.runes[i]) return false; + break; + case Regexp.Op.ALTERNATE: + case Regexp.Op.CONCAT: + if (this.subs.length !== that.subs.length) return false; + for (let i = 0; i < this.subs.length; ++i) if (!this.subs[i].equals(that.subs[i])) return false; + break; + case Regexp.Op.STAR: + case Regexp.Op.PLUS: + case Regexp.Op.QUEST: + if ((this.flags & RE2Flags.NON_GREEDY) !== (that.flags & RE2Flags.NON_GREEDY) || !this.subs[0].equals(that.subs[0])) return false; + break; + case Regexp.Op.REPEAT: + if ((this.flags & RE2Flags.NON_GREEDY) !== (that.flags & RE2Flags.NON_GREEDY) || this.min !== that.min || this.max !== that.max || !this.subs[0].equals(that.subs[0])) return false; + break; + case Regexp.Op.CAPTURE: + if (this.cap !== that.cap || (this.name === null ? that.name !== null : this.name !== that.name) || !this.subs[0].equals(that.subs[0])) return false; + break; + case Regexp.Op.PLB: + case Regexp.Op.NLB: + if (this.lb !== that.lb || !this.subs[0].equals(that.subs[0])) return false; + break; + } + return true; + } +}; +//#endregion +//#region src/Prefilter.js +var AhoCorasick = class { + constructor(wordArrays) { + this.next = [Object.create(null)]; + this.fail = [0]; + this.match = [false]; + for (const word of wordArrays) { + let node = 0; + for (let i = 0; i < word.length; i++) { + const val = word[i]; + if (!(val in this.next[node])) { + this.next.push(Object.create(null)); + this.fail.push(0); + this.match.push(false); + this.next[node][val] = this.next.length - 1; + } + node = this.next[node][val]; + } + this.match[node] = true; + } + const queue = []; + for (const val in this.next[0]) if (Object.prototype.hasOwnProperty.call(this.next[0], val)) { + const child = this.next[0][val]; + this.fail[child] = 0; + queue.push(child); + } + while (queue.length > 0) { + const curr = queue.shift(); + for (const val in this.next[curr]) if (Object.prototype.hasOwnProperty.call(this.next[curr], val)) { + const child = this.next[curr][val]; + let failNode = this.fail[curr]; + while (failNode !== 0 && !(val in this.next[failNode])) failNode = this.fail[failNode]; + if (val in this.next[failNode]) this.fail[child] = this.next[failNode][val]; + else this.fail[child] = 0; + this.match[child] = this.match[child] || this.match[this.fail[child]]; + queue.push(child); + } + } + } + searchUTF16(charSeq, start, end) { + let node = 0; + for (let i = start; i < end; i++) { + const val = charSeq.charCodeAt(i); + while (node !== 0 && !(val in this.next[node])) node = this.fail[node]; + if (val in this.next[node]) node = this.next[node][val]; + if (this.match[node]) return true; + } + return false; + } + searchUTF8(bytes, start, end) { + let node = 0; + for (let i = start; i < end; i++) { + const val = bytes[i]; + while (node !== 0 && !(val in this.next[node])) node = this.fail[node]; + if (val in this.next[node]) node = this.next[node][val]; + if (this.match[node]) return true; + } + return false; + } +}; +var Prefilter = class Prefilter { + static Type = { + NONE: 0, + EXACT: 1, + AND: 2, + OR: 3 + }; + constructor(type) { + this.type = type; + this.subs = []; + this.str = ""; + this.bytes = null; + this.ac16 = null; + this.ac8 = null; + } + eval(input, pos) { + switch (this.type) { + case Prefilter.Type.NONE: return true; + case Prefilter.Type.EXACT: return input.hasString(this, pos); + case Prefilter.Type.AND: + for (let i = 0; i < this.subs.length; i++) if (!this.subs[i].eval(input, pos)) return false; + return true; + case Prefilter.Type.OR: + if (this.ac16 && this.ac8) return input.hasAnyString(this, pos); + for (let i = 0; i < this.subs.length; i++) if (this.subs[i].eval(input, pos)) return true; + return false; + default: return true; + } + } +}; +var PrefilterTree = class PrefilterTree { + static build(re) { + const pf = PrefilterTree.fromRegexp(re); + return PrefilterTree.simplify(pf); + } + static fromRegexp(re) { + if (!re) return new Prefilter(Prefilter.Type.NONE); + switch (re.op) { + case Regexp.Op.PLB: + case Regexp.Op.NLB: + case Regexp.Op.NO_MATCH: + case Regexp.Op.EMPTY_MATCH: + case Regexp.Op.BEGIN_LINE: + case Regexp.Op.END_LINE: + case Regexp.Op.BEGIN_TEXT: + case Regexp.Op.END_TEXT: + case Regexp.Op.WORD_BOUNDARY: + case Regexp.Op.NO_WORD_BOUNDARY: + case Regexp.Op.CHAR_CLASS: + case Regexp.Op.ANY_CHAR_NOT_NL: + case Regexp.Op.ANY_CHAR: return new Prefilter(Prefilter.Type.NONE); + case Regexp.Op.LITERAL: { + if (re.runes.length === 0 || (re.flags & RE2Flags.FOLD_CASE) !== 0) return new Prefilter(Prefilter.Type.NONE); + const pf = new Prefilter(Prefilter.Type.EXACT); + let str = ""; + for (let i = 0; i < re.runes.length; i++) str += String.fromCodePoint(re.runes[i]); + pf.str = str; + pf.bytes = Utils.stringToUtf8ByteArray(pf.str); + return pf; + } + case Regexp.Op.CAPTURE: + case Regexp.Op.PLUS: return PrefilterTree.fromRegexp(re.subs[0]); + case Regexp.Op.REPEAT: + if (re.min >= 1) return PrefilterTree.fromRegexp(re.subs[0]); + return new Prefilter(Prefilter.Type.NONE); + case Regexp.Op.CONCAT: { + const pf = new Prefilter(Prefilter.Type.AND); + for (const sub of re.subs) pf.subs.push(PrefilterTree.fromRegexp(sub)); + return pf; + } + case Regexp.Op.ALTERNATE: { + const pf = new Prefilter(Prefilter.Type.OR); + for (const sub of re.subs) pf.subs.push(PrefilterTree.fromRegexp(sub)); + return pf; + } + default: return new Prefilter(Prefilter.Type.NONE); + } + } + static simplify(pf) { + if (pf.type === Prefilter.Type.EXACT || pf.type === Prefilter.Type.NONE) return pf; + if (pf.type === Prefilter.Type.AND) { + const newSubs = []; + for (const sub of pf.subs) { + const s = PrefilterTree.simplify(sub); + if (s.type !== Prefilter.Type.NONE) if (s.type === Prefilter.Type.AND) for (let j = 0; j < s.subs.length; j++) newSubs.push(s.subs[j]); + else newSubs.push(s); + } + if (newSubs.length === 0) return new Prefilter(Prefilter.Type.NONE); + if (newSubs.length === 1) return newSubs[0]; + pf.subs = newSubs; + return pf; + } + if (pf.type === Prefilter.Type.OR) { + const newSubs = []; + for (const sub of pf.subs) { + const s = PrefilterTree.simplify(sub); + if (s.type === Prefilter.Type.NONE) return new Prefilter(Prefilter.Type.NONE); + if (s.type === Prefilter.Type.OR) for (let j = 0; j < s.subs.length; j++) newSubs.push(s.subs[j]); + else newSubs.push(s); + } + if (newSubs.length === 0) return new Prefilter(Prefilter.Type.NONE); + if (newSubs.length === 1) return newSubs[0]; + const seen = /* @__PURE__ */ new Set(); + const uniqueSubs = []; + for (const sub of newSubs) if (sub.type === Prefilter.Type.EXACT) { + if (!seen.has(sub.str)) { + seen.add(sub.str); + uniqueSubs.push(sub); + } + } else uniqueSubs.push(sub); + pf.subs = uniqueSubs; + let allExact = true; + for (const sub of uniqueSubs) if (sub.type !== Prefilter.Type.EXACT) { + allExact = false; + break; + } + if (allExact && uniqueSubs.length > 1) { + pf.ac16 = new AhoCorasick(uniqueSubs.map((s) => { + const arr = []; + for (let i = 0; i < s.str.length; i++) arr.push(s.str.charCodeAt(i)); + return arr; + })); + pf.ac8 = new AhoCorasick(uniqueSubs.map((s) => s.bytes)); + } + return pf; + } + return pf; + } +}; +//#endregion +//#region src/Prog.js +/** +* A list of instruction pointers waiting to be patched. +* Tracks both `head` and `tail` to allow O(1) appending during compilation. +* * Values are encoded integers, not standard memory pointers: +* - Program instruction index: `l >> 1` +* - Patch `.out` field if: `(l & 1) === 0` +* - Patch `.arg` field if: `(l & 1) === 1` +* - `0` denotes an empty list. +* * @see https://swtch.com/~rsc/regexp/regexp1.html +*/ +var PatchList = class { + /** + * @param {number} head - Encoded pointer to the start of the patch list. + * @param {number} tail - Encoded pointer to the end of the patch list. + */ + constructor(head = 0, tail = 0) { + this.head = head; + this.tail = tail; + } +}; +/** +* A Prog is a compiled regular expression program. +*/ +var Prog = class { + constructor() { + this.inst = []; + this.start = 0; + this.numCap = 2; + this.lbStarts = []; + this.numLb = 0; + } + getInst(pc) { + return this.inst[pc]; + } + numInst() { + return this.inst.length; + } + addInst(op) { + this.inst.push(new Inst(op)); + } + skipNop(pc) { + let i = this.inst[pc]; + while (i.op === Inst.NOP || i.op === Inst.CAPTURE) { + i = this.inst[pc]; + pc = i.out; + } + return i; + } + prefix() { + let prefix = ""; + let i = this.skipNop(this.start); + if (!Inst.isRuneOp(i.op) || i.runes.length !== 1) return [i.op === Inst.MATCH, prefix]; + while (Inst.isRuneOp(i.op) && i.runes.length === 1 && (i.arg & RE2Flags.FOLD_CASE) === 0) { + prefix += String.fromCodePoint(i.runes[0]); + i = this.skipNop(i.out); + } + return [i.op === Inst.MATCH, prefix]; + } + startCond() { + let flag = 0; + let pc = this.start; + loop: for (;;) { + const i = this.inst[pc]; + switch (i.op) { + case Inst.EMPTY_WIDTH: + flag |= i.arg; + break; + case Inst.FAIL: return -1; + case Inst.CAPTURE: + case Inst.NOP: break; + default: break loop; + } + pc = i.out; + } + return flag; + } + patch(l, val) { + let head = l.head; + while (head !== 0) { + const i = this.inst[head >> 1]; + if ((head & 1) === 0) { + head = i.out; + i.out = val; + } else { + head = i.arg; + i.arg = val; + } + } + } + append(l1, l2) { + if (l1.head === 0) return l2; + if (l2.head === 0) return l1; + const i = this.inst[l1.tail >> 1]; + if ((l1.tail & 1) === 0) i.out = l2.head; + else i.arg = l2.head; + return new PatchList(l1.head, l2.tail); + } + /** + * + * @returns {string} + */ + toString() { + let out = ""; + for (let pc = 0; pc < this.inst.length; pc++) { + const len = out.length; + out += pc; + if (pc === this.start) out += "*"; + out += " ".substring(out.length - len); + out += this.inst[pc]; + out += "\n"; + } + return out; + } +}; +//#endregion +//#region src/Compiler.js +/** +* A fragment of a compiled regular expression program. +* +* @see http://swtch.com/~rsc/regexp/regexp1.html +* @class +*/ +var Frag = class { + constructor(i = 0, out = new PatchList(), nullable = false) { + this.i = i; + this.out = out; + this.nullable = nullable; + } +}; +/** +* Compiler from {@code Regexp} (RE2 abstract syntax) to {@code RE2} (compiled regular expression). +* +* The only entry point is {@link #compileRegexp}. +*/ +var Compiler = class Compiler { + static ANY_RUNE_NOT_NL() { + return [ + 0, + Codepoint.CODES.get("\n") - 1, + Codepoint.CODES.get("\n") + 1, + Unicode.MAX_RUNE + ]; + } + static ANY_RUNE() { + return [0, Unicode.MAX_RUNE]; + } + static compileRegexp(re) { + const c = new Compiler(); + const f = c.compile(re); + c.prog.patch(f.out, c.newInst(Inst.MATCH).i); + c.prog.start = f.i; + return c.prog; + } + static compileSet(regexps) { + const c = new Compiler(); + if (regexps.length === 0) { + c.prog.start = c.newInst(Inst.FAIL).i; + return c.prog; + } + let starts = []; + for (let i = 0; i < regexps.length; i++) { + const f = c.compile(regexps[i]); + const m = c.newInst(Inst.MATCH); + c.prog.getInst(m.i).arg = i; + c.prog.patch(f.out, m.i); + starts.push(f.i); + } + let start = starts[0]; + for (let i = 1; i < starts.length; i++) { + const f = c.newInst(Inst.ALT); + const inst = c.prog.getInst(f.i); + inst.out = start; + inst.arg = starts[i]; + start = f.i; + } + c.prog.start = start; + return c.prog; + } + constructor() { + this.prog = new Prog(); + this.newInst(Inst.FAIL); + } + newInst(op) { + this.prog.addInst(op); + return new Frag(this.prog.numInst() - 1, new PatchList(), true); + } + nop() { + const f = this.newInst(Inst.NOP); + f.out = new PatchList(f.i << 1, f.i << 1); + return f; + } + fail() { + return new Frag(); + } + cap(arg) { + const f = this.newInst(Inst.CAPTURE); + f.out = new PatchList(f.i << 1, f.i << 1); + this.prog.getInst(f.i).arg = arg; + if (this.prog.numCap < arg + 1) this.prog.numCap = arg + 1; + return f; + } + cat(f1, f2) { + if (f1.i === 0 || f2.i === 0) return this.fail(); + this.prog.patch(f1.out, f2.i); + return new Frag(f1.i, f2.out, f1.nullable && f2.nullable); + } + alt(f1, f2) { + if (f1.i === 0) return f2; + if (f2.i === 0) return f1; + const f = this.newInst(Inst.ALT); + const i = this.prog.getInst(f.i); + i.out = f1.i; + i.arg = f2.i; + f.out = this.prog.append(f1.out, f2.out); + f.nullable = f1.nullable || f2.nullable; + return f; + } + loop(f1, nongreedy) { + const f = this.newInst(Inst.ALT); + const i = this.prog.getInst(f.i); + if (nongreedy) { + i.arg = f1.i; + f.out = new PatchList(f.i << 1, f.i << 1); + } else { + i.out = f1.i; + f.out = new PatchList(f.i << 1 | 1, f.i << 1 | 1); + } + this.prog.patch(f1.out, f.i); + return f; + } + quest(f1, nongreedy) { + const f = this.newInst(Inst.ALT); + const i = this.prog.getInst(f.i); + if (nongreedy) { + i.arg = f1.i; + f.out = new PatchList(f.i << 1, f.i << 1); + } else { + i.out = f1.i; + f.out = new PatchList(f.i << 1 | 1, f.i << 1 | 1); + } + f.out = this.prog.append(f.out, f1.out); + return f; + } + star(f1, nongreedy) { + if (f1.nullable) return this.quest(this.plus(f1, nongreedy), nongreedy); + return this.loop(f1, nongreedy); + } + plus(f1, nongreedy) { + return new Frag(f1.i, this.loop(f1, nongreedy).out, f1.nullable); + } + empty(op) { + const f = this.newInst(Inst.EMPTY_WIDTH); + this.prog.getInst(f.i).arg = op; + f.out = new PatchList(f.i << 1, f.i << 1); + return f; + } + rune(runes, flags) { + const f = this.newInst(Inst.RUNE); + f.nullable = false; + const i = this.prog.getInst(f.i); + i.runes = runes; + flags &= RE2Flags.FOLD_CASE; + if (runes.length !== 1 || Unicode.simpleFold(runes[0]) === runes[0]) flags &= ~RE2Flags.FOLD_CASE; + i.arg = flags; + f.out = new PatchList(f.i << 1, f.i << 1); + if ((flags & RE2Flags.FOLD_CASE) === 0 && runes.length === 1 || runes.length === 2 && runes[0] === runes[1]) i.op = Inst.RUNE1; + else if (runes.length === 2 && runes[0] === 0 && runes[1] === Unicode.MAX_RUNE) i.op = Inst.RUNE_ANY; + else if (runes.length === 4 && runes[0] === 0 && runes[1] === Codepoint.CODES.get("\n") - 1 && runes[2] === Codepoint.CODES.get("\n") + 1 && runes[3] === Unicode.MAX_RUNE) i.op = Inst.RUNE_ANY_NOT_NL; + return f; + } + lookBehind(a, lb) { + const id = this.newInst(Inst.LB_WRITE); + this.prog.getInst(id.i).arg = lb; + const any = this.rune(Compiler.ANY_RUNE(), 0); + const dotStar = this.star(any, true); + const lbAutomaton = this.cat(dotStar, a); + this.prog.patch(lbAutomaton.out, id.i); + const checkId = this.newInst(Inst.LB_CHECK); + this.prog.getInst(checkId.i).arg = lb; + this.prog.lbStarts.push(lbAutomaton.i); + if (Math.abs(lb) > this.prog.numLb) this.prog.numLb = Math.abs(lb); + checkId.out = new PatchList(checkId.i << 1, checkId.i << 1); + return checkId; + } + compile(re) { + switch (re.op) { + case Regexp.Op.NO_MATCH: return this.fail(); + case Regexp.Op.EMPTY_MATCH: return this.nop(); + case Regexp.Op.LITERAL: if (re.runes.length === 0) return this.nop(); + else { + let f = null; + for (let r of re.runes) { + const f1 = this.rune([r], re.flags); + f = f === null ? f1 : this.cat(f, f1); + } + return f; + } + case Regexp.Op.CHAR_CLASS: return this.rune(re.runes, re.flags); + case Regexp.Op.ANY_CHAR_NOT_NL: return this.rune(Compiler.ANY_RUNE_NOT_NL(), 0); + case Regexp.Op.ANY_CHAR: return this.rune(Compiler.ANY_RUNE(), 0); + case Regexp.Op.BEGIN_LINE: return this.empty(Utils.EMPTY_BEGIN_LINE); + case Regexp.Op.END_LINE: return this.empty(Utils.EMPTY_END_LINE); + case Regexp.Op.BEGIN_TEXT: return this.empty(Utils.EMPTY_BEGIN_TEXT); + case Regexp.Op.END_TEXT: return this.empty(Utils.EMPTY_END_TEXT); + case Regexp.Op.WORD_BOUNDARY: return this.empty(Utils.EMPTY_WORD_BOUNDARY); + case Regexp.Op.NO_WORD_BOUNDARY: return this.empty(Utils.EMPTY_NO_WORD_BOUNDARY); + case Regexp.Op.PLB: + case Regexp.Op.NLB: return this.lookBehind(this.compile(re.subs[0]), re.lb); + case Regexp.Op.CAPTURE: { + const bra = this.cap(re.cap << 1); + const sub = this.compile(re.subs[0]); + const ket = this.cap(re.cap << 1 | 1); + return this.cat(this.cat(bra, sub), ket); + } + case Regexp.Op.STAR: return this.star(this.compile(re.subs[0]), (re.flags & RE2Flags.NON_GREEDY) !== 0); + case Regexp.Op.PLUS: return this.plus(this.compile(re.subs[0]), (re.flags & RE2Flags.NON_GREEDY) !== 0); + case Regexp.Op.QUEST: return this.quest(this.compile(re.subs[0]), (re.flags & RE2Flags.NON_GREEDY) !== 0); + case Regexp.Op.CONCAT: if (re.subs.length === 0) return this.nop(); + else { + let f = null; + for (let sub of re.subs) { + const f1 = this.compile(sub); + f = f === null ? f1 : this.cat(f, f1); + } + return f; + } + case Regexp.Op.ALTERNATE: if (re.subs.length === 0) return this.nop(); + else { + let f = null; + for (let sub of re.subs) { + const f1 = this.compile(sub); + f = f === null ? f1 : this.alt(f, f1); + } + return f; + } + default: throw new RE2JSCompileException("regexp: unhandled case in compile"); + } + } +}; +//#endregion +//#region src/Simplify.js +var Simplify = class Simplify { + static simplify(re) { + if (re === null) return null; + switch (re.op) { + case Regexp.Op.PLB: + case Regexp.Op.NLB: + case Regexp.Op.CAPTURE: { + const sub = Simplify.simplify(re.subs[0]); + if (sub !== re.subs[0]) { + const nre = Regexp.fromRegexp(re); + nre.runes = []; + nre.subs = [sub]; + return nre; + } + return re; + } + case Regexp.Op.CONCAT: + case Regexp.Op.ALTERNATE: { + const newSubs = []; + let changed = false; + for (let i = 0; i < re.subs.length; i++) { + const sub = re.subs[i]; + const nsub = Simplify.simplify(sub); + if (nsub !== sub) changed = true; + if (re.op === Regexp.Op.CONCAT) { + if (nsub.op === Regexp.Op.NO_MATCH) return new Regexp(Regexp.Op.NO_MATCH); + if (nsub.op === Regexp.Op.EMPTY_MATCH) { + changed = true; + continue; + } + if (nsub.op === Regexp.Op.CONCAT) { + changed = true; + for (let j = 0; j < nsub.subs.length; j++) newSubs.push(nsub.subs[j]); + continue; + } + } else if (re.op === Regexp.Op.ALTERNATE) { + if (nsub.op === Regexp.Op.NO_MATCH) { + changed = true; + continue; + } + if (nsub.op === Regexp.Op.ALTERNATE) { + changed = true; + for (let j = 0; j < nsub.subs.length; j++) newSubs.push(nsub.subs[j]); + continue; + } + } + newSubs.push(nsub); + } + if (changed) { + if (newSubs.length === 0) return new Regexp(re.op === Regexp.Op.CONCAT ? Regexp.Op.EMPTY_MATCH : Regexp.Op.NO_MATCH); + if (newSubs.length === 1) return newSubs[0]; + const nre = Regexp.fromRegexp(re); + nre.runes = []; + nre.subs = newSubs; + return nre; + } + return re; + } + case Regexp.Op.CHAR_CLASS: + if (re.runes === null) return re; + if (re.runes.length === 0) return new Regexp(Regexp.Op.NO_MATCH); + if (re.runes.length === 2 && re.runes[0] === 0 && re.runes[1] === Unicode.MAX_RUNE) return new Regexp(Regexp.Op.ANY_CHAR); + if (re.runes.length === 4 && re.runes[0] === 0 && re.runes[1] === Codepoint.CODES.get("\n") - 1 && re.runes[2] === Codepoint.CODES.get("\n") + 1 && re.runes[3] === Unicode.MAX_RUNE) return new Regexp(Regexp.Op.ANY_CHAR_NOT_NL); + return re; + case Regexp.Op.STAR: + case Regexp.Op.PLUS: + case Regexp.Op.QUEST: { + const sub = Simplify.simplify(re.subs[0]); + return Simplify.simplify1(re.op, re.flags, sub, re); + } + case Regexp.Op.REPEAT: { + if (re.min === 0 && re.max === 0) return new Regexp(Regexp.Op.EMPTY_MATCH); + const sub = Simplify.simplify(re.subs[0]); + if (re.max === -1) { + if (re.min === 0) return Simplify.simplify1(Regexp.Op.STAR, re.flags, sub, null); + if (re.min === 1) return Simplify.simplify1(Regexp.Op.PLUS, re.flags, sub, null); + const nre = new Regexp(Regexp.Op.CONCAT); + const subs = []; + for (let i = 0; i < re.min - 1; i++) subs.push(sub); + subs.push(Simplify.simplify1(Regexp.Op.PLUS, re.flags, sub, null)); + nre.subs = subs.slice(0); + return Simplify.simplify(nre); + } + if (re.min === 1 && re.max === 1) return sub; + let prefixSubs = null; + if (re.min > 0) { + prefixSubs = []; + for (let i = 0; i < re.min; i++) prefixSubs.push(sub); + } + if (re.max > re.min) { + let suffix = Simplify.simplify1(Regexp.Op.QUEST, re.flags, sub, null); + for (let i = re.min + 1; i < re.max; i++) { + const nre2 = new Regexp(Regexp.Op.CONCAT); + nre2.subs = [sub, suffix]; + suffix = Simplify.simplify1(Regexp.Op.QUEST, re.flags, nre2, null); + } + if (prefixSubs === null) return suffix; + prefixSubs.push(suffix); + } + if (prefixSubs !== null) { + const prefix = new Regexp(Regexp.Op.CONCAT); + prefix.subs = prefixSubs.slice(0); + return Simplify.simplify(prefix); + } + return new Regexp(Regexp.Op.NO_MATCH); + } + } + return re; + } + static simplify1(op, flags, sub, re) { + if (sub.op === Regexp.Op.EMPTY_MATCH) return sub; + if (sub.op === Regexp.Op.NO_MATCH) { + if (op === Regexp.Op.PLUS) return sub; + return new Regexp(Regexp.Op.EMPTY_MATCH); + } + if (op === sub.op && (flags & RE2Flags.NON_GREEDY) === (sub.flags & RE2Flags.NON_GREEDY)) return sub; + if (re !== null && re.op === op && (re.flags & RE2Flags.NON_GREEDY) === (flags & RE2Flags.NON_GREEDY) && sub === re.subs[0]) return re; + const nre = new Regexp(op); + nre.flags = flags; + nre.subs = [sub]; + return nre; + } +}; +//#endregion +//#region src/CharGroup.js +var CharGroup = class { + constructor(sign, cls) { + this.sign = sign; + this.cls = cls; + } +}; +const code1 = [48, 57]; +const code2 = [ + 9, + 10, + 12, + 13, + 32, + 32 +]; +const code3 = [ + 48, + 57, + 65, + 90, + 95, + 95, + 97, + 122 +]; +const PERL_GROUPS = /* @__PURE__ */ new Map([ + ["\\d", new CharGroup(1, code1)], + ["\\D", new CharGroup(-1, code1)], + ["\\s", new CharGroup(1, code2)], + ["\\S", new CharGroup(-1, code2)], + ["\\w", new CharGroup(1, code3)], + ["\\W", new CharGroup(-1, code3)] +]); +const code4 = [ + 48, + 57, + 65, + 90, + 97, + 122 +]; +const code5 = [ + 65, + 90, + 97, + 122 +]; +const code6 = [0, 127]; +const code7 = [ + 9, + 9, + 32, + 32 +]; +const code8 = [ + 0, + 31, + 127, + 127 +]; +const code9 = [48, 57]; +const code10 = [33, 126]; +const code11 = [97, 122]; +const code12 = [32, 126]; +const code13 = [ + 33, + 47, + 58, + 64, + 91, + 96, + 123, + 126 +]; +const code14 = [ + 9, + 13, + 32, + 32 +]; +const code15 = [65, 90]; +const code16 = [ + 48, + 57, + 65, + 90, + 95, + 95, + 97, + 122 +]; +const code17 = [ + 48, + 57, + 65, + 70, + 97, + 102 +]; +const POSIX_GROUPS = /* @__PURE__ */ new Map([ + ["[:alnum:]", new CharGroup(1, code4)], + ["[:^alnum:]", new CharGroup(-1, code4)], + ["[:alpha:]", new CharGroup(1, code5)], + ["[:^alpha:]", new CharGroup(-1, code5)], + ["[:ascii:]", new CharGroup(1, code6)], + ["[:^ascii:]", new CharGroup(-1, code6)], + ["[:blank:]", new CharGroup(1, code7)], + ["[:^blank:]", new CharGroup(-1, code7)], + ["[:cntrl:]", new CharGroup(1, code8)], + ["[:^cntrl:]", new CharGroup(-1, code8)], + ["[:digit:]", new CharGroup(1, code9)], + ["[:^digit:]", new CharGroup(-1, code9)], + ["[:graph:]", new CharGroup(1, code10)], + ["[:^graph:]", new CharGroup(-1, code10)], + ["[:lower:]", new CharGroup(1, code11)], + ["[:^lower:]", new CharGroup(-1, code11)], + ["[:print:]", new CharGroup(1, code12)], + ["[:^print:]", new CharGroup(-1, code12)], + ["[:punct:]", new CharGroup(1, code13)], + ["[:^punct:]", new CharGroup(-1, code13)], + ["[:space:]", new CharGroup(1, code14)], + ["[:^space:]", new CharGroup(-1, code14)], + ["[:upper:]", new CharGroup(1, code15)], + ["[:^upper:]", new CharGroup(-1, code15)], + ["[:word:]", new CharGroup(1, code16)], + ["[:^word:]", new CharGroup(-1, code16)], + ["[:xdigit:]", new CharGroup(1, code17)], + ["[:^xdigit:]", new CharGroup(-1, code17)] +]); +//#endregion +//#region src/CharClass.js +/** +* A "builder"-style helper class for manipulating character classes represented as an array of +* pairs of runes [lo, hi], each denoting an inclusive interval. +* +* All methods mutate the internal state and return {@code this}, allowing operations to be chained. +*/ +var CharClass = class CharClass { + static charClassToString(r, len) { + let result = "["; + for (let i = 0; i < len; i += 2) { + if (i > 0) result += " "; + const lo = r[i]; + const hi = r[i + 1]; + if (lo === hi) result += `0x${lo.toString(16)}`; + else result += `0x${lo.toString(16)}-0x${hi.toString(16)}`; + } + result += "]"; + return result; + } + static cmp(array, i, pivotFrom, pivotTo) { + const cmp = array[i] - pivotFrom; + return cmp !== 0 ? cmp : pivotTo - array[i + 1]; + } + static qsortIntPair(array, left, right) { + const pivotIndex = ((left + right) / 2 | 0) & -2; + const pivotFrom = array[pivotIndex]; + const pivotTo = array[pivotIndex + 1]; + let i = left; + let j = right; + while (i <= j) { + while (i < right && CharClass.cmp(array, i, pivotFrom, pivotTo) < 0) i += 2; + while (j > left && CharClass.cmp(array, j, pivotFrom, pivotTo) > 0) j -= 2; + if (i <= j) { + if (i !== j) { + let temp = array[i]; + array[i] = array[j]; + array[j] = temp; + temp = array[i + 1]; + array[i + 1] = array[j + 1]; + array[j + 1] = temp; + } + i += 2; + j -= 2; + } + } + if (left < j) CharClass.qsortIntPair(array, left, j); + if (i < right) CharClass.qsortIntPair(array, i, right); + } + constructor(r = Utils.emptyInts()) { + this.r = r; + this.len = r.length; + } + toArray() { + if (this.len === this.r.length) return this.r; + else return this.r.slice(0, this.len); + } + cleanClass() { + if (this.len < 4) return this; + CharClass.qsortIntPair(this.r, 0, this.len - 2); + let w = 2; + for (let i = 2; i < this.len; i += 2) { + const lo = this.r[i]; + const hi = this.r[i + 1]; + if (lo <= this.r[w - 1] + 1) { + if (hi > this.r[w - 1]) this.r[w - 1] = hi; + continue; + } + this.r[w] = lo; + this.r[w + 1] = hi; + w += 2; + } + this.len = w; + return this; + } + appendLiteral(x, flags) { + return (flags & RE2Flags.FOLD_CASE) !== 0 ? this.appendFoldedRange(x, x) : this.appendRange(x, x); + } + appendRange(lo, hi) { + if (this.len > 0) { + for (let i = 2; i <= 4; i += 2) if (this.len >= i) { + const rlo = this.r[this.len - i]; + const rhi = this.r[this.len - i + 1]; + if (lo <= rhi + 1 && rlo <= hi + 1) { + if (lo < rlo) this.r[this.len - i] = lo; + if (hi > rhi) this.r[this.len - i + 1] = hi; + return this; + } + } + } + this.r[this.len++] = lo; + this.r[this.len++] = hi; + return this; + } + appendFoldedRange(lo, hi) { + if (lo <= Unicode.MIN_FOLD && hi >= Unicode.MAX_FOLD) return this.appendRange(lo, hi); + if (hi < Unicode.MIN_FOLD || lo > Unicode.MAX_FOLD) return this.appendRange(lo, hi); + if (lo < Unicode.MIN_FOLD) { + this.appendRange(lo, Unicode.MIN_FOLD - 1); + lo = Unicode.MIN_FOLD; + } + if (hi > Unicode.MAX_FOLD) { + this.appendRange(Unicode.MAX_FOLD + 1, hi); + hi = Unicode.MAX_FOLD; + } + for (let c = lo; c <= hi; c++) { + this.appendRange(c, c); + for (let f = Unicode.simpleFold(c); f !== c; f = Unicode.simpleFold(f)) this.appendRange(f, f); + } + return this; + } + appendClass(x) { + for (let i = 0; i < x.length; i += 2) this.appendRange(x[i], x[i + 1]); + return this; + } + appendFoldedClass(x) { + for (let i = 0; i < x.length; i += 2) this.appendFoldedRange(x[i], x[i + 1]); + return this; + } + appendNegatedClass(x) { + let nextLo = 0; + for (let i = 0; i < x.length; i += 2) { + const lo = x[i]; + const hi = x[i + 1]; + if (nextLo <= lo - 1) this.appendRange(nextLo, lo - 1); + nextLo = hi + 1; + } + if (nextLo <= Unicode.MAX_RUNE) this.appendRange(nextLo, Unicode.MAX_RUNE); + return this; + } + appendTable(table) { + for (let i = 0; i < table.length; ++i) { + const lo = table.getLo(i); + const hi = table.getHi(i); + const stride = table.getStride(i); + if (stride === 1) { + this.appendRange(lo, hi); + continue; + } + for (let c = lo; c <= hi; c += stride) this.appendRange(c, c); + } + return this; + } + appendNegatedTable(table) { + let nextLo = 0; + for (let i = 0; i < table.length; ++i) { + const lo = table.getLo(i); + const hi = table.getHi(i); + const stride = table.getStride(i); + if (stride === 1) { + if (nextLo <= lo - 1) this.appendRange(nextLo, lo - 1); + nextLo = hi + 1; + continue; + } + for (let c = lo; c <= hi; c += stride) { + if (nextLo <= c - 1) this.appendRange(nextLo, c - 1); + nextLo = c + 1; + } + } + if (nextLo <= Unicode.MAX_RUNE) this.appendRange(nextLo, Unicode.MAX_RUNE); + return this; + } + appendTableWithSign(table, sign) { + return sign < 0 ? this.appendNegatedTable(table) : this.appendTable(table); + } + negateClass() { + let nextLo = 0; + let w = 0; + for (let i = 0; i < this.len; i += 2) { + const lo = this.r[i]; + const hi = this.r[i + 1]; + if (nextLo <= lo - 1) { + this.r[w] = nextLo; + this.r[w + 1] = lo - 1; + w += 2; + } + nextLo = hi + 1; + } + this.len = w; + if (nextLo <= Unicode.MAX_RUNE) { + this.r[this.len++] = nextLo; + this.r[this.len++] = Unicode.MAX_RUNE; + } + return this; + } + appendClassWithSign(x, sign) { + return sign < 0 ? this.appendNegatedClass(x) : this.appendClass(x); + } + appendGroup(g, foldCase) { + let cls = g.cls; + if (foldCase) cls = new CharClass().appendFoldedClass(cls).cleanClass().toArray(); + return this.appendClassWithSign(cls, g.sign); + } + toString() { + return CharClass.charClassToString(this.r, this.len); + } +}; +//#endregion +//#region src/Parser.js +var StringIterator = class { + constructor(str) { + this.str = str; + this.position = 0; + } + pos() { + return this.position; + } + rewindTo(pos) { + this.position = pos; + } + more() { + return this.position < this.str.length; + } + peek() { + return this.str.codePointAt(this.position); + } + skip(n) { + this.position += n; + } + skipString(s) { + this.position += s.length; + } + pop() { + const r = this.str.codePointAt(this.position); + this.position += Utils.charCount(r); + return r; + } + lookingAt(s) { + return this.str.startsWith(s, this.position); + } + rest() { + return this.str.substring(this.position); + } + from(beforePos) { + return this.str.substring(beforePos, this.position); + } + toString() { + return this.rest(); + } +}; +/** +* A parser of regular expression patterns. +* +* The only public entry point is {@link #parse(String pattern, int flags)}. +*/ +var Parser = class Parser { + static ERR_INTERNAL_ERROR = "regexp/syntax: internal error"; + static ERR_INVALID_CHAR_RANGE = "invalid character class range"; + static ERR_INVALID_ESCAPE = "invalid escape sequence"; + static ERR_INVALID_NAMED_CAPTURE = "invalid named capture"; + static ERR_INVALID_PERL_OP = "invalid or unsupported Perl syntax"; + static ERR_INVALID_REPEAT_OP = "invalid nested repetition operator"; + static ERR_INVALID_REPEAT_SIZE = "invalid repeat count"; + static ERR_MISSING_BRACKET = "missing closing ]"; + static ERR_MISSING_PAREN = "missing closing )"; + static ERR_MISSING_REPEAT_ARGUMENT = "missing argument to repetition operator"; + static ERR_TRAILING_BACKSLASH = "trailing backslash at end of expression"; + static ERR_DUPLICATE_NAMED_CAPTURE = "duplicate capture group name"; + static ERR_UNEXPECTED_PAREN = "unexpected )"; + static ERR_NESTING_DEPTH = "expression nests too deeply"; + static ERR_LARGE = "expression too large"; + static ERR_INVALID_CAPTURE_IN_LOOKBEHIND = "invalid capture in lookbehind"; + static MAX_HEIGHT = 1e3; + static MAX_SIZE = 3355443; + static MAX_RUNES = 33554432; + static ANY_TABLE = new UnicodeRangeTable(new Uint32Array([ + 0, + Unicode.MAX_RUNE, + 1 + ])); + static ASCII_TABLE = new UnicodeRangeTable(new Uint32Array([ + 0, + 127, + 1 + ])); + static ASCII_FOLD_TABLE = new UnicodeRangeTable(new Uint32Array([ + 0, + 127, + 1, + 383, + 383, + 1, + 8490, + 8490, + 1 + ])); + static unicodeTable(name) { + if (name === "Any") return { + tab: Parser.ANY_TABLE, + fold: Parser.ANY_TABLE, + sign: 1 + }; + if (name === "Ascii") return { + tab: Parser.ASCII_TABLE, + fold: Parser.ASCII_FOLD_TABLE, + sign: 1 + }; + if (name === "Assigned") return { + tab: UnicodeTables.CATEGORIES.get("Cn"), + fold: UnicodeTables.CATEGORIES.get("Cn"), + sign: -1 + }; + if (name === "Lc") return { + tab: UnicodeTables.CATEGORIES.get("LC"), + fold: UnicodeTables.FOLD_CATEGORIES.get("LC"), + sign: 1 + }; + if (UnicodeTables.CATEGORIES.has(name)) return { + tab: UnicodeTables.CATEGORIES.get(name), + fold: UnicodeTables.FOLD_CATEGORIES.get(name), + sign: 1 + }; + if (UnicodeTables.SCRIPTS.has(name)) return { + tab: UnicodeTables.SCRIPTS.get(name), + fold: UnicodeTables.FOLD_SCRIPT.get(name), + sign: 1 + }; + return null; + } + static minFoldRune(r) { + if (r < Unicode.MIN_FOLD || r > Unicode.MAX_FOLD) return r; + let min = r; + const r0 = r; + for (r = Unicode.simpleFold(r); r !== r0; r = Unicode.simpleFold(r)) if (min > r) min = r; + return min; + } + static leadingRegexp(re) { + if (re.op === Regexp.Op.EMPTY_MATCH) return null; + if (re.op === Regexp.Op.CONCAT && re.subs.length > 0) { + const sub = re.subs[0]; + if (sub.op === Regexp.Op.EMPTY_MATCH) return null; + return sub; + } + return re; + } + static literalRegexp(s, flags) { + const re = new Regexp(Regexp.Op.LITERAL); + re.flags = flags; + re.runes = Utils.stringToRunes(s); + return re; + } + /** + * Parse regular expression pattern {@code pattern} with mode flags {@code flags}. + * @param {string} pattern + * @param {number} flags + */ + static parse(pattern, flags) { + return new Parser(pattern, flags).parseInternal(); + } + static parseRepeat(t) { + const start = t.pos(); + if (!t.more() || !t.lookingAt("{")) return -1; + t.skip(1); + const min = Parser.parseInt(t); + if (min === -1) return -1; + if (!t.more()) return -1; + let max; + if (!t.lookingAt(",")) max = min; + else { + t.skip(1); + if (!t.more()) return -1; + if (t.lookingAt("}")) max = -1; + else if ((max = Parser.parseInt(t)) === -1) return -1; + } + if (!t.more() || !t.lookingAt("}")) return -1; + t.skip(1); + if (min < 0 || min > 1e3 || max === -2 || max > 1e3 || max >= 0 && min > max) throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_SIZE, t.from(start)); + return min << 16 | max & Unicode.MAX_BMP; + } + static isValidCaptureName(name) { + if (name.length === 0) return false; + for (let i = 0; i < name.length; i++) { + const c = name.codePointAt(i); + if (c !== Codepoint.CODES.get("_") && !Utils.isalnum(c)) return false; + } + return true; + } + static parseInt(t) { + const start = t.pos(); + while (t.more() && t.peek() >= Codepoint.CODES.get("0") && t.peek() <= Codepoint.CODES.get("9")) t.skip(1); + const n = t.from(start); + if (n.length === 0 || n.length > 1 && n.codePointAt(0) === Codepoint.CODES.get("0")) return -1; + if (n.length > 8) return -2; + return parseInt(n, 10); + } + static isCharClass(re) { + return re.op === Regexp.Op.LITERAL && re.runes.length === 1 || re.op === Regexp.Op.CHAR_CLASS || re.op === Regexp.Op.ANY_CHAR_NOT_NL || re.op === Regexp.Op.ANY_CHAR; + } + static matchRune(re, r) { + switch (re.op) { + case Regexp.Op.LITERAL: return re.runes.length === 1 && re.runes[0] === r; + case Regexp.Op.CHAR_CLASS: + for (let i = 0; i < re.runes.length; i += 2) if (re.runes[i] <= r && r <= re.runes[i + 1]) return true; + return false; + case Regexp.Op.ANY_CHAR_NOT_NL: return r !== Codepoint.CODES.get("\n"); + case Regexp.Op.ANY_CHAR: return true; + } + return false; + } + static mergeCharClass(dst, src) { + switch (dst.op) { + case Regexp.Op.ANY_CHAR: break; + case Regexp.Op.ANY_CHAR_NOT_NL: + if (Parser.matchRune(src, Codepoint.CODES.get("\n"))) dst.op = Regexp.Op.ANY_CHAR; + break; + case Regexp.Op.CHAR_CLASS: + if (src.op === Regexp.Op.LITERAL) dst.runes = new CharClass(dst.runes).appendLiteral(src.runes[0], src.flags).toArray(); + else dst.runes = new CharClass(dst.runes).appendClass(src.runes).toArray(); + break; + case Regexp.Op.LITERAL: + if (src.runes[0] === dst.runes[0] && src.flags === dst.flags) break; + dst.op = Regexp.Op.CHAR_CLASS; + dst.runes = new CharClass().appendLiteral(dst.runes[0], dst.flags).appendLiteral(src.runes[0], src.flags).toArray(); + break; + } + } + static parseEscape(t) { + const startPos = t.pos(); + t.skip(1); + if (!t.more()) throw new RE2JSSyntaxException(Parser.ERR_TRAILING_BACKSLASH); + let c = t.pop(); + bigswitch: switch (c) { + case Codepoint.CODES.get("1"): + case Codepoint.CODES.get("2"): + case Codepoint.CODES.get("3"): + case Codepoint.CODES.get("4"): + case Codepoint.CODES.get("5"): + case Codepoint.CODES.get("6"): + case Codepoint.CODES.get("7"): if (!t.more() || t.peek() < Codepoint.CODES.get("0") || t.peek() > Codepoint.CODES.get("7")) break; + case Codepoint.CODES.get("0"): { + let r = c - Codepoint.CODES.get("0"); + for (let i = 1; i < 3; i++) { + if (!t.more() || t.peek() < Codepoint.CODES.get("0") || t.peek() > Codepoint.CODES.get("7")) break; + r = r * 8 + t.peek() - Codepoint.CODES.get("0"); + t.skip(1); + } + return r; + } + case Codepoint.CODES.get("x"): { + if (!t.more()) break; + c = t.pop(); + if (c === Codepoint.CODES.get("{")) { + let nhex = 0; + let r = 0; + while (true) { + if (!t.more()) break bigswitch; + c = t.pop(); + if (c === Codepoint.CODES.get("}")) break; + const v = Utils.unhex(c); + if (v < 0) break bigswitch; + r = r * 16 + v; + if (r > Unicode.MAX_RUNE) break bigswitch; + nhex++; + } + if (nhex === 0) break bigswitch; + return r; + } + const x = Utils.unhex(c); + if (!t.more()) break; + c = t.pop(); + const y = Utils.unhex(c); + if (x < 0 || y < 0) break; + return x * 16 + y; + } + case Codepoint.CODES.get("a"): return Codepoint.CODES.get("\x07"); + case Codepoint.CODES.get("f"): return Codepoint.CODES.get("\f"); + case Codepoint.CODES.get("n"): return Codepoint.CODES.get("\n"); + case Codepoint.CODES.get("r"): return Codepoint.CODES.get("\r"); + case Codepoint.CODES.get("t"): return Codepoint.CODES.get(" "); + case Codepoint.CODES.get("v"): return Codepoint.CODES.get("\v"); + default: + if (c <= Unicode.MAX_ASCII && !Utils.isalnum(c)) return c; + break; + } + throw new RE2JSSyntaxException(Parser.ERR_INVALID_ESCAPE, t.from(startPos)); + } + static parseClassChar(t, wholeClassPos) { + if (!t.more()) throw new RE2JSSyntaxException(Parser.ERR_MISSING_BRACKET, t.from(wholeClassPos)); + if (t.lookingAt("\\")) return Parser.parseEscape(t); + return t.pop(); + } + static concatRunes(x, y) { + for (let i = 0; i < y.length; i++) x.push(y[i]); + return x; + } + static hasCapture(re) { + if (re === null) return false; + if (re.op === Regexp.Op.CAPTURE) return true; + if (re.subs) { + for (let sub of re.subs) if (Parser.hasCapture(sub)) return true; + } + return false; + } + constructor(wholeRegexp, flags = 0) { + this.wholeRegexp = wholeRegexp; + this.flags = flags; + this.numCap = 0; + this.namedGroups = Object.create(null); + this.stack = []; + this.free = null; + this.numRegexp = 0; + this.numRunes = 0; + this.repeats = 0; + this.height = null; + this.size = null; + this.nlb = 0; + } + newRegexp(op) { + let re = this.free; + if (re !== null && re.subs !== null && re.subs.length > 0) { + this.free = re.subs[0]; + re.reinit(); + re.op = op; + } else { + re = new Regexp(op); + this.numRegexp += 1; + } + return re; + } + reuse(re) { + if (this.height !== null && this.height.has(re)) this.height.delete(re); + if (re.subs !== null && re.subs.length > 0) re.subs[0] = this.free; + this.free = re; + } + checkLimits(re) { + if (this.numRunes > Parser.MAX_RUNES) throw new RE2JSSyntaxException(Parser.ERR_LARGE); + this.checkSize(re); + this.checkHeight(re); + } + checkSize(re) { + if (this.size === null) { + if (this.repeats === 0) this.repeats = 1; + if (re.op === Regexp.Op.REPEAT) { + let n = re.max; + if (n === -1) n = re.min; + if (n <= 0) n = 1; + if (n > Math.floor(Parser.MAX_SIZE / this.repeats)) this.repeats = Parser.MAX_SIZE; + else this.repeats *= n; + } + if (this.numRegexp < Math.floor(Parser.MAX_SIZE / this.repeats)) return; + this.size = /* @__PURE__ */ new Map(); + for (let reEx of this.stack) this.checkSize(reEx); + } + if (this.calcSize(re, true) > Parser.MAX_SIZE) throw new RE2JSSyntaxException(Parser.ERR_LARGE); + } + calcSize(re, force = false) { + if (!force && this.size !== null) { + if (this.size.has(re)) return this.size.get(re); + } + let size = 0; + switch (re.op) { + case Regexp.Op.LITERAL: + size = re.runes.length; + break; + case Regexp.Op.PLB: + case Regexp.Op.NLB: + case Regexp.Op.CAPTURE: + case Regexp.Op.STAR: + size = 2 + this.calcSize(re.subs[0]); + break; + case Regexp.Op.PLUS: + case Regexp.Op.QUEST: + size = 1 + this.calcSize(re.subs[0]); + break; + case Regexp.Op.CONCAT: + for (let sub of re.subs) size = size + this.calcSize(sub); + break; + case Regexp.Op.ALTERNATE: + for (let sub of re.subs) size = size + this.calcSize(sub); + if (re.subs.length > 1) size = size + re.subs.length - 1; + break; + case Regexp.Op.REPEAT: { + let sub = this.calcSize(re.subs[0]); + if (re.max === -1) { + if (re.min === 0) size = 2 + sub; + else size = 1 + re.min * sub; + break; + } + size = re.max * sub + (re.max - re.min); + break; + } + } + size = Math.max(1, size); + if (this.size === null) this.size = /* @__PURE__ */ new Map(); + this.size.set(re, size); + return size; + } + checkHeight(re) { + if (this.numRegexp < Parser.MAX_HEIGHT) return; + if (this.height === null) { + this.height = /* @__PURE__ */ new Map(); + for (let reEx of this.stack) this.checkHeight(reEx); + } + if (this.calcHeight(re, true) > Parser.MAX_HEIGHT) throw new RE2JSSyntaxException(Parser.ERR_NESTING_DEPTH); + } + calcHeight(re, force = false) { + if (!force && this.height !== null) { + if (this.height.has(re)) return this.height.get(re); + } + let h = 1; + for (let sub of re.subs) { + const hsub = this.calcHeight(sub); + if (h < 1 + hsub) h = 1 + hsub; + } + if (this.height === null) this.height = /* @__PURE__ */ new Map(); + this.height.set(re, h); + return h; + } + pop() { + return this.stack.pop(); + } + popToPseudo() { + const n = this.stack.length; + let i = n; + while (i > 0 && !Regexp.isPseudoOp(this.stack[i - 1].op)) i--; + const r = this.stack.slice(i, n); + this.stack = this.stack.slice(0, i); + return r; + } + push(re) { + this.numRunes += re.runes.length; + if (re.op === Regexp.Op.CHAR_CLASS && re.runes.length === 2 && re.runes[0] === re.runes[1]) { + if (this.maybeConcat(re.runes[0], this.flags & ~RE2Flags.FOLD_CASE)) return null; + re.op = Regexp.Op.LITERAL; + re.runes = [re.runes[0]]; + re.flags = this.flags & ~RE2Flags.FOLD_CASE; + } else if (re.op === Regexp.Op.CHAR_CLASS && re.runes.length === 4 && re.runes[0] === re.runes[1] && re.runes[2] === re.runes[3] && Unicode.simpleFold(re.runes[0]) === re.runes[2] && Unicode.simpleFold(re.runes[2]) === re.runes[0] || re.op === Regexp.Op.CHAR_CLASS && re.runes.length === 2 && re.runes[0] + 1 === re.runes[1] && Unicode.simpleFold(re.runes[0]) === re.runes[1] && Unicode.simpleFold(re.runes[1]) === re.runes[0]) { + if (this.maybeConcat(re.runes[0], this.flags | RE2Flags.FOLD_CASE)) return null; + re.op = Regexp.Op.LITERAL; + re.runes = [re.runes[0]]; + re.flags = this.flags | RE2Flags.FOLD_CASE; + } else this.maybeConcat(-1, 0); + this.stack.push(re); + this.checkLimits(re); + return re; + } + maybeConcat(r, flags) { + const n = this.stack.length; + if (n < 2) return false; + const re1 = this.stack[n - 1]; + const re2 = this.stack[n - 2]; + if (re1.op !== Regexp.Op.LITERAL || re2.op !== Regexp.Op.LITERAL || (re1.flags & RE2Flags.FOLD_CASE) !== (re2.flags & RE2Flags.FOLD_CASE)) return false; + re2.runes = Parser.concatRunes(re2.runes, re1.runes); + if (r >= 0) { + re1.runes = [r]; + re1.flags = flags; + return true; + } + this.pop(); + this.reuse(re1); + return false; + } + newLiteral(r, flags) { + const re = this.newRegexp(Regexp.Op.LITERAL); + re.flags = flags; + if ((flags & RE2Flags.FOLD_CASE) !== 0) r = Parser.minFoldRune(r); + re.runes = [r]; + return re; + } + literal(r) { + this.push(this.newLiteral(r, this.flags)); + } + op(op) { + const re = this.newRegexp(op); + re.flags = this.flags; + return this.push(re); + } + repeat(op, min, max, beforePos, t, lastRepeatPos) { + let flags = this.flags; + if ((flags & RE2Flags.PERL_X) !== 0) { + if (t.more() && t.lookingAt("?")) { + t.skip(1); + flags ^= RE2Flags.NON_GREEDY; + } + if (lastRepeatPos !== -1) throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_OP, t.from(lastRepeatPos)); + } + const n = this.stack.length; + if (n === 0) throw new RE2JSSyntaxException(Parser.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos)); + const sub = this.stack[n - 1]; + if (Regexp.isPseudoOp(sub.op)) throw new RE2JSSyntaxException(Parser.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos)); + const re = this.newRegexp(op); + re.min = min; + re.max = max; + re.flags = flags; + re.subs = [sub]; + this.stack[n - 1] = re; + this.checkLimits(re); + if (op === Regexp.Op.REPEAT && (min >= 2 || max >= 2) && !this.repeatIsValid(re, 1e3)) throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_SIZE, t.from(beforePos)); + } + repeatIsValid(re, n) { + if (re.op === Regexp.Op.REPEAT) { + let m = re.max; + if (m === 0) return true; + if (m < 0) m = re.min; + if (m > n) return false; + if (m > 0) n = Math.trunc(n / m); + } + for (let sub of re.subs) if (!this.repeatIsValid(sub, n)) return false; + return true; + } + concat() { + this.maybeConcat(-1, 0); + const subs = this.popToPseudo(); + if (subs.length === 0) return this.push(this.newRegexp(Regexp.Op.EMPTY_MATCH)); + return this.push(this.collapse(subs, Regexp.Op.CONCAT)); + } + alternate() { + const subs = this.popToPseudo(); + if (subs.length > 0) this.cleanAlt(subs[subs.length - 1]); + if (subs.length === 0) return this.push(this.newRegexp(Regexp.Op.NO_MATCH)); + return this.push(this.collapse(subs, Regexp.Op.ALTERNATE)); + } + cleanAlt(re) { + if (re.op === Regexp.Op.CHAR_CLASS) { + re.runes = new CharClass(re.runes).cleanClass().toArray(); + if (re.runes.length === 2 && re.runes[0] === 0 && re.runes[1] === Unicode.MAX_RUNE) { + re.runes = []; + re.op = Regexp.Op.ANY_CHAR; + } else if (re.runes.length === 4 && re.runes[0] === 0 && re.runes[1] === Codepoint.CODES.get("\n") - 1 && re.runes[2] === Codepoint.CODES.get("\n") + 1 && re.runes[3] === Unicode.MAX_RUNE) { + re.runes = []; + re.op = Regexp.Op.ANY_CHAR_NOT_NL; + } + } + } + collapse(subs, op) { + if (subs.length === 1) return subs[0]; + let len = 0; + for (let sub of subs) len += sub.op === op ? sub.subs.length : 1; + let newsubs = new Array(len).fill(null); + let i = 0; + for (let sub of subs) if (sub.op === op) { + for (let j = 0; j < sub.subs.length; j++) newsubs[i++] = sub.subs[j]; + this.reuse(sub); + } else newsubs[i++] = sub; + let re = this.newRegexp(op); + re.subs = newsubs; + if (op === Regexp.Op.ALTERNATE) { + re.subs = this.factor(re.subs); + if (re.subs.length === 1) { + const old = re; + re = re.subs[0]; + this.reuse(old); + } + } + return re; + } + factor(array) { + if (array.length < 2) return array; + let s = 0; + let lensub = array.length; + let lenout = 0; + let str = null; + let strlen = 0; + let strflags = 0; + let start = 0; + for (let i = 0; i <= lensub; i++) { + let istr = null; + let istrlen = 0; + let iflags = 0; + if (i < lensub) { + let re = array[s + i]; + if (re.op === Regexp.Op.CONCAT && re.subs.length > 0) re = re.subs[0]; + if (re.op === Regexp.Op.LITERAL) { + istr = re.runes; + istrlen = re.runes.length; + iflags = re.flags & RE2Flags.FOLD_CASE; + } + if (iflags === strflags) { + let same = 0; + while (same < strlen && same < istrlen && str[same] === istr[same]) same++; + if (same > 0) { + strlen = same; + continue; + } + } + } + if (i === start) {} else if (i === start + 1) array[lenout++] = array[s + start]; + else { + const prefix = this.newRegexp(Regexp.Op.LITERAL); + prefix.flags = strflags; + prefix.runes = str.slice(0, strlen); + for (let j = start; j < i; j++) { + array[s + j] = this.removeLeadingString(array[s + j], strlen); + this.checkLimits(array[s + j]); + } + const suffix = this.collapse(array.slice(s + start, s + i), Regexp.Op.ALTERNATE); + const re = this.newRegexp(Regexp.Op.CONCAT); + re.subs = [prefix, suffix]; + array[lenout++] = re; + } + start = i; + str = istr; + strlen = istrlen; + strflags = iflags; + } + lensub = lenout; + s = 0; + start = 0; + lenout = 0; + let first = null; + for (let i = 0; i <= lensub; i++) { + let ifirst = null; + if (i < lensub) { + ifirst = Parser.leadingRegexp(array[s + i]); + if (first !== null && first.equals(ifirst) && (Parser.isCharClass(first) || first.op === Regexp.Op.REPEAT && first.min === first.max && Parser.isCharClass(first.subs[0]))) continue; + } + if (i === start) {} else if (i === start + 1) array[lenout++] = array[s + start]; + else { + const prefix = first; + for (let j = start; j < i; j++) { + const reuse = j !== start; + array[s + j] = this.removeLeadingRegexp(array[s + j], reuse); + this.checkLimits(array[s + j]); + } + const suffix = this.collapse(array.slice(s + start, s + i), Regexp.Op.ALTERNATE); + const re = this.newRegexp(Regexp.Op.CONCAT); + re.subs = [prefix, suffix]; + array[lenout++] = re; + } + start = i; + first = ifirst; + } + lensub = lenout; + s = 0; + start = 0; + lenout = 0; + for (let i = 0; i <= lensub; i++) { + if (i < lensub && Parser.isCharClass(array[s + i])) continue; + if (i === start) {} else if (i === start + 1) array[lenout++] = array[s + start]; + else { + let max = start; + for (let j = start + 1; j < i; j++) { + const subMax = array[s + max]; + const subJ = array[s + j]; + if (subMax.op < subJ.op || subMax.op === subJ.op && (subMax.runes !== null ? subMax.runes.length : 0) < (subJ.runes !== null ? subJ.runes.length : 0)) max = j; + } + const tmp = array[s + start]; + array[s + start] = array[s + max]; + array[s + max] = tmp; + for (let j = start + 1; j < i; j++) { + Parser.mergeCharClass(array[s + start], array[s + j]); + this.reuse(array[s + j]); + } + this.cleanAlt(array[s + start]); + array[lenout++] = array[s + start]; + } + if (i < lensub) array[lenout++] = array[s + i]; + start = i + 1; + } + lensub = lenout; + s = 0; + start = 0; + lenout = 0; + for (let i = 0; i < lensub; ++i) { + if (i + 1 < lensub && array[s + i].op === Regexp.Op.EMPTY_MATCH && array[s + i + 1].op === Regexp.Op.EMPTY_MATCH) continue; + array[lenout++] = array[s + i]; + } + lensub = lenout; + s = 0; + return array.slice(s, lensub); + } + removeLeadingString(re, n) { + if (re.op === Regexp.Op.CONCAT && re.subs.length > 0) { + const sub = this.removeLeadingString(re.subs[0], n); + re.subs[0] = sub; + if (sub.op === Regexp.Op.EMPTY_MATCH) { + this.reuse(sub); + switch (re.subs.length) { + case 0: + case 1: + re.op = Regexp.Op.EMPTY_MATCH; + re.subs = Regexp.emptySubs(); + break; + case 2: { + const old = re; + re = re.subs[1]; + this.reuse(old); + break; + } + default: + re.subs = re.subs.slice(1, re.subs.length); + break; + } + } + return re; + } + if (re.op === Regexp.Op.LITERAL) { + re.runes = re.runes.slice(n, re.runes.length); + if (re.runes.length === 0) re.op = Regexp.Op.EMPTY_MATCH; + } + return re; + } + removeLeadingRegexp(re, reuse) { + if (re.op === Regexp.Op.CONCAT && re.subs.length > 0) { + if (reuse) this.reuse(re.subs[0]); + re.subs = re.subs.slice(1, re.subs.length); + switch (re.subs.length) { + case 0: + re.op = Regexp.Op.EMPTY_MATCH; + re.subs = Regexp.emptySubs(); + break; + case 1: { + const old = re; + re = re.subs[0]; + this.reuse(old); + break; + } + } + return re; + } + if (reuse) this.reuse(re); + return this.newRegexp(Regexp.Op.EMPTY_MATCH); + } + parseInternal() { + if ((this.flags & RE2Flags.LITERAL) !== 0) return Parser.literalRegexp(this.wholeRegexp, this.flags); + let lastRepeatPos = -1; + let min = -1; + let max = -1; + const t = new StringIterator(this.wholeRegexp); + while (t.more()) { + let repeatPos = -1; + bigswitch: switch (t.peek()) { + case Codepoint.CODES.get("("): + if ((this.flags & RE2Flags.LOOKBEHIND) !== 0) { + if (t.lookingAt("(?<=")) { + this.parsePosLookBehind(); + t.skip(4); + break; + } + if (t.lookingAt("(?> 16; + max = (minMax & Unicode.MAX_BMP) << 16 >> 16; + this.repeat(Regexp.Op.REPEAT, min, max, repeatPos, t, lastRepeatPos); + break; + } + case Codepoint.CODES.get("\\"): { + const savedPos = t.pos(); + t.skip(1); + if ((this.flags & RE2Flags.PERL_X) !== 0 && t.more()) switch (t.pop()) { + case Codepoint.CODES.get("A"): + this.op(Regexp.Op.BEGIN_TEXT); + break bigswitch; + case Codepoint.CODES.get("b"): + this.op(Regexp.Op.WORD_BOUNDARY); + break bigswitch; + case Codepoint.CODES.get("B"): + this.op(Regexp.Op.NO_WORD_BOUNDARY); + break bigswitch; + case Codepoint.CODES.get("C"): throw new RE2JSSyntaxException(Parser.ERR_INVALID_ESCAPE, "\\C"); + case Codepoint.CODES.get("Q"): { + let lit = t.rest(); + const i = lit.indexOf("\\E"); + if (i >= 0) { + lit = lit.substring(0, i); + t.skipString(lit); + t.skipString("\\E"); + } else t.skipString(lit); + let j = 0; + while (j < lit.length) { + const codepoint = lit.codePointAt(j); + this.literal(codepoint); + j += Utils.charCount(codepoint); + } + break bigswitch; + } + case Codepoint.CODES.get("z"): + this.op(Regexp.Op.END_TEXT); + break bigswitch; + default: + t.rewindTo(savedPos); + break; + } + else t.rewindTo(savedPos); + const re = this.newRegexp(Regexp.Op.CHAR_CLASS); + re.flags = this.flags; + if (t.lookingAt("\\p") || t.lookingAt("\\P")) { + const cc = new CharClass(); + if (this.parseUnicodeClass(t, cc)) { + re.runes = cc.toArray(); + this.push(re); + break bigswitch; + } + } + const cc = new CharClass(); + if (this.parsePerlClassEscape(t, cc)) { + re.runes = cc.toArray(); + this.push(re); + break bigswitch; + } + t.rewindTo(savedPos); + this.reuse(re); + this.literal(Parser.parseEscape(t)); + break; + } + default: + this.literal(t.pop()); + break; + } + lastRepeatPos = repeatPos; + } + this.concat(); + if (this.swapVerticalBar()) this.pop(); + this.alternate(); + if (this.stack.length !== 1) throw new RE2JSSyntaxException(Parser.ERR_MISSING_PAREN, this.wholeRegexp); + this.stack[0].namedGroups = this.namedGroups; + return this.stack[0]; + } + parsePerlFlags(t) { + const startPos = t.pos(); + const s = t.rest(); + if (s.startsWith("(?P<") || s.startsWith("(?<")) { + const begin = s.charAt(2) === "P" ? 4 : 3; + const end = s.indexOf(">"); + if (end < 0) throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s); + const name = s.substring(begin, end); + t.skipString(name); + t.skip(begin + 1); + if (!Parser.isValidCaptureName(name)) throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s.substring(0, end + 1)); + const re = this.op(Regexp.Op.LEFT_PAREN); + re.cap = ++this.numCap; + if (this.namedGroups[name]) throw new RE2JSSyntaxException(Parser.ERR_DUPLICATE_NAMED_CAPTURE, name); + this.namedGroups[name] = this.numCap; + re.name = name; + return; + } + t.skip(2); + let flags = this.flags; + let sign = 1; + let sawFlag = false; + loop: while (t.more()) { + const c = t.pop(); + switch (c) { + case Codepoint.CODES.get("i"): + flags |= RE2Flags.FOLD_CASE; + sawFlag = true; + break; + case Codepoint.CODES.get("m"): + flags &= ~RE2Flags.ONE_LINE; + sawFlag = true; + break; + case Codepoint.CODES.get("s"): + flags |= RE2Flags.DOT_NL; + sawFlag = true; + break; + case Codepoint.CODES.get("U"): + flags |= RE2Flags.NON_GREEDY; + sawFlag = true; + break; + case Codepoint.CODES.get("-"): + if (sign < 0) break loop; + sign = -1; + flags = ~flags; + sawFlag = false; + break; + case Codepoint.CODES.get(":"): + case Codepoint.CODES.get(")"): + if (sign < 0) { + if (!sawFlag) break loop; + flags = ~flags; + } + if (c === Codepoint.CODES.get(":")) this.op(Regexp.Op.LEFT_PAREN); + this.flags = flags; + return; + default: break loop; + } + } + throw new RE2JSSyntaxException(Parser.ERR_INVALID_PERL_OP, t.from(startPos)); + } + parsePosLookBehind() { + const re = this.newRegexp(Regexp.Op.LEFT_PAREN); + re.flags = this.flags; + re.lb = ++this.nlb; + return this.push(re); + } + parseNegLookBehind() { + const re = this.newRegexp(Regexp.Op.LEFT_PAREN); + re.flags = this.flags; + re.lb = -++this.nlb; + return this.push(re); + } + parseVerticalBar() { + this.concat(); + if (!this.swapVerticalBar()) this.op(Regexp.Op.VERTICAL_BAR); + } + swapVerticalBar() { + const n = this.stack.length; + if (n >= 3 && this.stack[n - 2].op === Regexp.Op.VERTICAL_BAR && Parser.isCharClass(this.stack[n - 1]) && Parser.isCharClass(this.stack[n - 3])) { + let re1 = this.stack[n - 1]; + let re3 = this.stack[n - 3]; + if (re1.op > re3.op) { + const tmp = re3; + re3 = re1; + re1 = tmp; + this.stack[n - 3] = re3; + } + Parser.mergeCharClass(re3, re1); + this.reuse(re1); + this.pop(); + return true; + } + if (n >= 2) { + const re1 = this.stack[n - 1]; + const re2 = this.stack[n - 2]; + if (re2.op === Regexp.Op.VERTICAL_BAR) { + if (n >= 3) this.cleanAlt(this.stack[n - 3]); + this.stack[n - 2] = re1; + this.stack[n - 1] = re2; + return true; + } + } + return false; + } + parseRightParen() { + this.concat(); + if (this.swapVerticalBar()) this.pop(); + this.alternate(); + if (this.stack.length < 2) throw new RE2JSSyntaxException(Parser.ERR_UNEXPECTED_PAREN, this.wholeRegexp); + const re1 = this.pop(); + const re2 = this.pop(); + if (re2.op !== Regexp.Op.LEFT_PAREN) throw new RE2JSSyntaxException(Parser.ERR_UNEXPECTED_PAREN, this.wholeRegexp); + this.flags = re2.flags; + if (re2.lb !== 0) { + if (Parser.hasCapture(re1)) throw new RE2JSSyntaxException(Parser.ERR_INVALID_CAPTURE_IN_LOOKBEHIND, this.wholeRegexp); + if (re2.lb > 0) re2.op = Regexp.Op.PLB; + else re2.op = Regexp.Op.NLB; + re2.subs = [re1]; + this.push(re2); + return; + } + if (re2.cap === 0) this.push(re1); + else { + re2.op = Regexp.Op.CAPTURE; + re2.subs = [re1]; + this.push(re2); + } + } + parsePerlClassEscape(t, cc) { + const beforePos = t.pos(); + if ((this.flags & RE2Flags.PERL_X) === 0 || !t.more() || t.pop() !== Codepoint.CODES.get("\\") || !t.more()) return false; + t.pop(); + const p = t.from(beforePos); + const g = PERL_GROUPS.has(p) ? PERL_GROUPS.get(p) : null; + if (g === null) return false; + cc.appendGroup(g, (this.flags & RE2Flags.FOLD_CASE) !== 0); + return true; + } + parseNamedClass(t, cc) { + const cls = t.rest(); + const i = cls.indexOf(":]"); + if (i < 0) return false; + const name = cls.substring(0, i + 2); + t.skipString(name); + const g = POSIX_GROUPS.has(name) ? POSIX_GROUPS.get(name) : null; + if (g === null) throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, name); + cc.appendGroup(g, (this.flags & RE2Flags.FOLD_CASE) !== 0); + return true; + } + parseUnicodeClass(t, cc) { + const startPos = t.pos(); + if ((this.flags & RE2Flags.UNICODE_GROUPS) === 0 || !t.lookingAt("\\p") && !t.lookingAt("\\P")) return false; + t.skip(1); + let sign = 1; + let c = t.pop(); + if (c === Codepoint.CODES.get("P")) sign = -1; + if (!t.more()) { + t.rewindTo(startPos); + throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest()); + } + c = t.pop(); + let name; + if (c !== Codepoint.CODES.get("{")) name = Utils.runeToString(c); + else { + const rest = t.rest(); + const end = rest.indexOf("}"); + if (end < 0) { + t.rewindTo(startPos); + throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest()); + } + name = rest.substring(0, end); + t.skipString(name); + t.skip(1); + } + if (!(name.length === 0) && name.codePointAt(0) === Codepoint.CODES.get("^")) { + sign = 0 - sign; + name = name.substring(1); + } + const pair = Parser.unicodeTable(name); + if (pair === null) throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.from(startPos)); + if (pair.sign < 0) sign = 0 - sign; + const tab = pair.tab; + const fold = pair.fold; + if ((this.flags & RE2Flags.FOLD_CASE) === 0 || fold === null) cc.appendTableWithSign(tab, sign); + else { + const tmp = new CharClass().appendTable(tab).appendTable(fold).cleanClass().toArray(); + cc.appendClassWithSign(tmp, sign); + } + return true; + } + parseClass(t) { + const startPos = t.pos(); + t.skip(1); + const re = this.newRegexp(Regexp.Op.CHAR_CLASS); + re.flags = this.flags; + const cc = new CharClass(); + let sign = 1; + if (t.more() && t.lookingAt("^")) { + sign = -1; + t.skip(1); + if ((this.flags & RE2Flags.CLASS_NL) === 0) cc.appendRange(Codepoint.CODES.get("\n"), Codepoint.CODES.get("\n")); + } + let first = true; + while (!t.more() || t.peek() !== Codepoint.CODES.get("]") || first) { + if (t.more() && t.lookingAt("-") && (this.flags & RE2Flags.PERL_X) === 0 && !first) { + const s = t.rest(); + if (s === "-" || !s.startsWith("-]")) { + t.rewindTo(startPos); + throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest()); + } + } + first = false; + const beforePos = t.pos(); + if (t.lookingAt("[:")) { + if (this.parseNamedClass(t, cc)) continue; + t.rewindTo(beforePos); + } + if (this.parseUnicodeClass(t, cc)) continue; + if (this.parsePerlClassEscape(t, cc)) continue; + t.rewindTo(beforePos); + const lo = Parser.parseClassChar(t, startPos); + let hi = lo; + if (t.more() && t.lookingAt("-")) { + t.skip(1); + if (t.more() && t.lookingAt("]")) t.skip(-1); + else { + hi = Parser.parseClassChar(t, startPos); + if (hi < lo) throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.from(beforePos)); + } + } + if ((this.flags & RE2Flags.FOLD_CASE) === 0) cc.appendRange(lo, hi); + else cc.appendFoldedRange(lo, hi); + } + t.skip(1); + cc.cleanClass(); + if (sign < 0) cc.negateClass(); + re.runes = cc.toArray(); + this.push(re); + } +}; +//#endregion +//#region src/RE2.js +/** +* An RE2 class instance is a compiled representation of an RE2 regular expression, independent of +* the public Java-like Pattern/Matcher API. +* +* This class also contains various implementation helpers for RE2 regular expressions. +* +* Use the {@link #quoteMeta(String)} utility function to quote all regular expression +* metacharacters in an arbitrary string. +* +*/ +var RE2 = class RE2 { + static initTest(expr) { + const re2 = RE2.compile(expr); + const res = new RE2(re2.expr, re2.prog, re2.numSubexp, re2.longest); + res.cond = re2.cond; + res.prefix = re2.prefix; + res.prefixUTF8 = re2.prefixUTF8; + res.prefixComplete = re2.prefixComplete; + res.prefixRune = re2.prefixRune; + res.prefilter = re2.prefilter; + return res; + } + /** + * Parses a regular expression and returns, if successful, an {@code RE2} instance that can be + * used to match against text. + * + * When matching against text, the regexp returns a match that begins as early as possible in the + * input (leftmost), and among those it chooses the one that a backtracking search would have + * found first. This so-called leftmost-first matching is the same semantics that Perl, Python, + * and other implementations use, although this package implements it without the expense of + * backtracking. For POSIX leftmost-longest matching, see {@link #compilePOSIX}. + */ + static compile(expr) { + return RE2.compileImpl(expr, RE2Flags.PERL, false); + } + /** + * {@code compilePOSIX} is like {@link #compile} but restricts the regular expression to POSIX ERE + * (egrep) syntax and changes the match semantics to leftmost-longest. + * + * That is, when matching against text, the regexp returns a match that begins as early as + * possible in the input (leftmost), and among those it chooses a match that is as long as + * possible. This so-called leftmost-longest matching is the same semantics that early regular + * expression implementations used and that POSIX specifies. + * + * However, there can be multiple leftmost-longest matches, with different submatch choices, and + * here this package diverges from POSIX. Among the possible leftmost-longest matches, this + * package chooses the one that a backtracking search would have found first, while POSIX + * specifies that the match be chosen to maximize the length of the first subexpression, then the + * second, and so on from left to right. The POSIX rule is computationally prohibitive and not + * even well-defined. See http://swtch.com/~rsc/regexp/regexp2.html#posix + */ + static compilePOSIX(expr) { + return RE2.compileImpl(expr, RE2Flags.POSIX, true); + } + static compileImpl(expr, mode, longest) { + let re = Parser.parse(expr, mode); + const maxCap = re.maxCap(); + re = Simplify.simplify(re); + const prefilter = PrefilterTree.build(re); + const prog = Compiler.compileRegexp(re); + const re2 = new RE2(expr, prog, maxCap, longest); + re2.prefilter = prefilter.type === Prefilter.Type.NONE ? null : prefilter; + const [prefixCompl, prefixStr] = prog.prefix(); + re2.prefixComplete = prefixCompl; + re2.prefix = prefixStr; + re2.prefixUTF8 = Utils.stringToUtf8ByteArray(re2.prefix); + if (re2.prefix.length > 0) re2.prefixRune = re2.prefix.codePointAt(0); + re2.namedGroups = re.namedGroups; + return re2; + } + /** + * Returns true iff textual regular expression {@code pattern} matches string {@code s}. + * + * More complicated queries need to use {@link #compile} and the full {@code RE2} interface. + */ + static match(pattern, s) { + return RE2.compile(pattern).match(s); + } + constructor(expr, prog, numSubexp = 0, longest = 0) { + this.expr = expr; + this.prog = prog; + this.numSubexp = numSubexp; + this.longest = longest; + this.cond = prog.startCond(); + this.prefix = null; + this.prefixUTF8 = null; + this.prefixComplete = false; + this.prefixRune = 0; + this.machinePool = []; + this.dfa = new DFA(this.prog); + this.onepass = OnePass.compile(this.prog); + this.prefilter = null; + } + matchPrefixComplete(input, pos, anchor, ncap) { + if ((anchor === RE2Flags.ANCHOR_START || anchor === RE2Flags.ANCHOR_BOTH) && pos !== 0) return null; + let matchStart = -1; + let matchEnd = -1; + const pLen = input.prefixLength(this); + if (anchor === RE2Flags.UNANCHORED) { + const idx = input.index(this, pos); + if (idx < 0) return null; + matchStart = pos + idx; + matchEnd = matchStart + pLen; + } else if (anchor === RE2Flags.ANCHOR_BOTH) { + if (input.endPos() !== pLen) return null; + if (input.index(this, 0) !== 0) return null; + matchStart = 0; + matchEnd = pLen; + } else if (anchor === RE2Flags.ANCHOR_START) { + if (input.index(this, 0) !== 0) return null; + matchStart = 0; + matchEnd = pLen; + } + if (matchStart < 0) return null; + if (ncap > 0) { + const matchcap = new Int32Array(ncap).fill(-1); + matchcap[0] = matchStart; + matchcap[1] = matchEnd; + return Array.from(matchcap); + } + return []; + } + executeEngine(input, pos, anchor, ncap) { + if (this.prefixComplete && (ncap === 0 || this.numSubexp === 0)) return this.matchPrefixComplete(input, pos, anchor, ncap); + if (this.prefilter !== null && anchor === RE2Flags.UNANCHORED) { + if (!this.prefilter.eval(input, pos)) return null; + } + if (this.onepass !== null) return OnePass.execute(this, input, pos, anchor, ncap); + if (ncap > 0) { + if (this.prog.numLb === 0 && input.endPos() <= Backtracker.maxBitStateLen(this.prog)) return Backtracker.execute(this, input, pos, anchor, ncap); + return this.doExecuteNFA(input, pos, anchor, ncap); + } + if (this.prog.numLb === 0) { + const dfaResult = this.dfa.match(input, pos, anchor); + if (dfaResult !== null) return dfaResult ? [] : null; + if (input.endPos() <= Backtracker.maxBitStateLen(this.prog)) return Backtracker.execute(this, input, pos, anchor, ncap); + } + return this.doExecuteNFA(input, pos, anchor, ncap); + } + /** + * Returns the number of parenthesized subexpressions in this regular expression. + */ + numberOfCapturingGroups() { + return this.numSubexp; + } + /** + * Returns the number of instructions in this compiled regular expression program. + */ + numberOfInstructions() { + return this.prog.numInst(); + } + get() { + return this.machinePool.length > 0 ? this.machinePool.pop() : null; + } + reset() { + this.machinePool.length = 0; + } + put(m) { + this.machinePool.push(m); + } + toString() { + return this.expr; + } + doExecuteNFA(input, pos, anchor, ncap) { + let m = this.get(); + if (!m) m = Machine.fromRE2(this); + m.init(ncap); + const cap = m.match(input, pos, anchor) ? m.submatches() : null; + this.put(m); + return cap; + } + match(s) { + return this.executeEngine(MachineInput.fromUTF16(s), 0, RE2Flags.UNANCHORED, 0) !== null; + } + /** + * Matches the regular expression against input starting at position start and ending at position + * end, with the given anchoring. Records the submatch boundaries in group, which is [start, end) + * pairs of byte offsets. The number of boundaries needed is inferred from the size of the group + * array. It is most efficient not to ask for submatch boundaries. + * + * @param input the input byte array + * @param start the beginning position in the input + * @param end the end position in the input + * @param anchor the anchoring flag (UNANCHORED, ANCHOR_START, ANCHOR_BOTH) + * @param group the array to fill with submatch positions + * @param ngroup the number of array pairs to fill in + * @returns true if a match was found + */ + matchWithGroup(input, start, end, anchor, ngroup) { + if (!(input instanceof MatcherInputBase)) if (Utils.isByteArray(input)) input = MatcherInput.utf8(input); + else input = MatcherInput.utf16(input); + return this.matchMachineInput(input, start, end, anchor, ngroup); + } + matchMachineInput(input, start, end, anchor, ngroup) { + if (start > end) return [false, null]; + const machineInput = input.isUTF16Encoding() ? MachineInput.fromUTF16(input.asCharSequence(), 0, end) : MachineInput.fromUTF8(input.asBytes(), 0, end); + const groupMatch = this.executeEngine(machineInput, start, anchor, 2 * ngroup); + if (groupMatch === null) return [false, null]; + return [true, groupMatch]; + } + /** + * Returns true iff this regexp matches the UTF-8 byte array {@code b}. + */ + matchUTF8(b) { + return this.executeEngine(MachineInput.fromUTF8(b), 0, RE2Flags.UNANCHORED, 0) !== null; + } + /** + * Returns a copy of {@code src} in which all matches for this regexp have been replaced by + * {@code repl}. No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the + * replacement string. + */ + replaceAll(src, repl) { + return this.replaceAllFunc(src, () => repl, 2 * src.length + 1); + } + /** + * Returns a copy of {@code src} in which only the first match for this regexp has been replaced + * by {@code repl}. No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the + * replacement string. + */ + replaceFirst(src, repl) { + return this.replaceAllFunc(src, () => repl, 1); + } + /** + * Returns a copy of {@code src} in which at most {@code maxReplaces} matches for this regexp have + * been replaced by the return value of of function {@code repl} (whose first argument is the + * matched string). No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the + * replacement string. + */ + replaceAllFunc(src, replFunc, maxReplaces) { + let lastMatchEnd = 0; + let searchPos = 0; + let out = ""; + const input = MachineInput.fromUTF16(src); + let numReplaces = 0; + while (searchPos <= src.length) { + const a = this.executeEngine(input, searchPos, RE2Flags.UNANCHORED, 2); + if (a === null || a.length === 0) break; + out += src.substring(lastMatchEnd, a[0]); + if (a[1] > lastMatchEnd || a[0] === 0) { + out += replFunc(src.substring(a[0], a[1])); + numReplaces++; + } + lastMatchEnd = a[1]; + const width = input.step(searchPos) & 7; + if (searchPos + width > a[1]) searchPos += width; + else if (searchPos + 1 > a[1]) searchPos++; + else searchPos = a[1]; + if (numReplaces >= maxReplaces) break; + } + out += src.substring(lastMatchEnd); + return out; + } + pad(a) { + if (a === null) return null; + let n = (1 + this.numSubexp) * 2; + if (a.length < n) { + let a2 = new Array(n).fill(-1); + for (let i = 0; i < a.length; i++) a2[i] = a[i]; + a = a2; + } + return a; + } + allMatches(input, n, deliverFun = (v) => v) { + let result = []; + const end = input.endPos(); + if (n < 0) n = end + 1; + let pos = 0; + let i = 0; + let prevMatchEnd = -1; + while (i < n && pos <= end) { + const matches = this.executeEngine(input, pos, RE2Flags.UNANCHORED, this.prog.numCap); + if (matches === null || matches.length === 0) break; + let accept = true; + if (matches[1] === pos) { + if (matches[0] === prevMatchEnd) accept = false; + const r = input.step(pos); + if (r < 0) pos = end + 1; + else pos += r & 7; + } else pos = matches[1]; + prevMatchEnd = matches[1]; + if (accept) { + result.push(deliverFun(this.pad(matches))); + i++; + } + } + return result; + } + /** + * Returns an array holding the text of the leftmost match in {@code b} of this regular + * expression. + * + * A return value of null indicates no match. + */ + findUTF8(b) { + const a = this.executeEngine(MachineInput.fromUTF8(b), 0, RE2Flags.UNANCHORED, 2); + if (a === null) return null; + return b.slice(a[0], a[1]); + } + /** + * Returns a two-element array of integers defining the location of the leftmost match in + * {@code b} of this regular expression. The match itself is at {@code b[loc[0]...loc[1]]}. + * + * A return value of null indicates no match. + */ + findUTF8Index(b) { + const a = this.executeEngine(MachineInput.fromUTF8(b), 0, RE2Flags.UNANCHORED, 2); + if (a === null) return null; + return a.slice(0, 2); + } + /** + * Returns a string holding the text of the leftmost match in {@code s} of this regular + * expression. + * + * If there is no match, the return value is an empty string, but it will also be empty if the + * regular expression successfully matches an empty string. Use {@link #findIndex} or + * {@link #findSubmatch} if it is necessary to distinguish these cases. + */ + find(s) { + const a = this.executeEngine(MachineInput.fromUTF16(s), 0, RE2Flags.UNANCHORED, 2); + if (a === null) return ""; + return s.substring(a[0], a[1]); + } + /** + * Returns a two-element array of integers defining the location of the leftmost match in + * {@code s} of this regular expression. The match itself is at + * {@code s.substring(loc[0], loc[1])}. + * + * A return value of null indicates no match. + */ + findIndex(s) { + return this.executeEngine(MachineInput.fromUTF16(s), 0, RE2Flags.UNANCHORED, 2); + } + /** + * Returns an array of arrays the text of the leftmost match of the regular expression in + * {@code b} and the matches, if any, of its subexpressions, as defined by the Submatch description above. + * + * A return value of null indicates no match. + */ + findUTF8Submatch(b) { + const a = this.executeEngine(MachineInput.fromUTF8(b), 0, RE2Flags.UNANCHORED, this.prog.numCap); + if (a === null) return null; + const ret = new Array(1 + this.numSubexp).fill(null); + for (let i = 0; i < ret.length; i++) if (2 * i < a.length && a[2 * i] >= 0) ret[i] = b.slice(a[2 * i], a[2 * i + 1]); + return ret; + } + /** + * Returns an array holding the index pairs identifying the leftmost match of this regular + * expression in {@code b} and the matches, if any, of its subexpressions, as defined by the the + * Submatch and Index descriptions above. + * + * A return value of null indicates no match. + */ + findUTF8SubmatchIndex(b) { + return this.pad(this.executeEngine(MachineInput.fromUTF8(b), 0, RE2Flags.UNANCHORED, this.prog.numCap)); + } + /** + * Returns an array of strings holding the text of the leftmost match of the regular expression in + * {@code s} and the matches, if any, of its subexpressions, as defined by the Submatch description above. + * + * A return value of null indicates no match. + */ + findSubmatch(s) { + const a = this.executeEngine(MachineInput.fromUTF16(s), 0, RE2Flags.UNANCHORED, this.prog.numCap); + if (a === null) return null; + const ret = new Array(1 + this.numSubexp).fill(null); + for (let i = 0; i < ret.length; i++) if (2 * i < a.length && a[2 * i] >= 0) ret[i] = s.substring(a[2 * i], a[2 * i + 1]); + return ret; + } + /** + * Returns an array holding the index pairs identifying the leftmost match of this regular + * expression in {@code s} and the matches, if any, of its subexpressions, as defined by the Submatch description above. + * + * A return value of null indicates no match. + */ + findSubmatchIndex(s) { + return this.pad(this.executeEngine(MachineInput.fromUTF16(s), 0, RE2Flags.UNANCHORED, this.prog.numCap)); + } + /** + * {@code findAllUTF8()} is the All version of {@link #findUTF8}; it returns a + * list of up to {@code n} successive matches of the expression, as defined by the All description above. + * + * A return value of null indicates no match. + * + * TODO(adonovan): think about defining a byte slice view class, like a read-only Go slice backed + * by |b|. + */ + findAllUTF8(b, n) { + const result = this.allMatches(MachineInput.fromUTF8(b), n, (match) => b.slice(match[0], match[1])); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllUTF8Index} is the All version of {@link #findUTF8Index}; it + * returns a list of up to {@code n} successive matches of the expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllUTF8Index(b, n) { + const result = this.allMatches(MachineInput.fromUTF8(b), n, (match) => match.slice(0, 2)); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAll} is the All version of {@link #find}; it returns a list of up + * to {@code n} successive matches of the expression, as defined by the All + * description above. + * + * A return value of null indicates no match. + */ + findAll(s, n) { + const result = this.allMatches(MachineInput.fromUTF16(s), n, (match) => s.substring(match[0], match[1])); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllIndex} is the All version of {@link #findIndex}; it returns a + * list of up to {@code n} successive matches of the expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllIndex(s, n) { + const result = this.allMatches(MachineInput.fromUTF16(s), n, (match) => match.slice(0, 2)); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllUTF8Submatch} is the All version of {@link #findUTF8Submatch}; + * it returns a list of up to {@code n} successive matches of the expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllUTF8Submatch(b, n) { + const result = this.allMatches(MachineInput.fromUTF8(b), n, (match) => { + let slice = new Array(match.length / 2 | 0).fill(null); + for (let j = 0; j < slice.length; j++) if (match[2 * j] >= 0) slice[j] = b.slice(match[2 * j], match[2 * j + 1]); + return slice; + }); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllUTF8SubmatchIndex} is the All version of + * {@link #findUTF8SubmatchIndex}; it returns a list of up to {@code n} successive matches of the + * expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllUTF8SubmatchIndex(b, n) { + const result = this.allMatches(MachineInput.fromUTF8(b), n); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllSubmatch} is the All version of {@link #findSubmatch}; it + * returns a list of up to {@code n} successive matches of the expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllSubmatch(s, n) { + const result = this.allMatches(MachineInput.fromUTF16(s), n, (match) => { + let slice = new Array(match.length / 2 | 0).fill(null); + for (let j = 0; j < slice.length; j++) if (match[2 * j] >= 0) slice[j] = s.substring(match[2 * j], match[2 * j + 1]); + return slice; + }); + if (result.length === 0) return null; + return result; + } + /** + * {@code findAllSubmatchIndex} is the All version of + * {@link #findSubmatchIndex}; it returns a list of up to {@code n} successive matches of the + * expression, as defined by the All description above. + * + * A return value of null indicates no match. + */ + findAllSubmatchIndex(s, n) { + const result = this.allMatches(MachineInput.fromUTF16(s), n); + if (result.length === 0) return null; + return result; + } +}; +//#endregion +//#region src/Set.js +var RE2Set = class RE2Set { + /** @type {number} */ + static UNANCHORED = RE2Flags.UNANCHORED; + /** @type {number} */ + static ANCHOR_START = RE2Flags.ANCHOR_START; + /** @type {number} */ + static ANCHOR_BOTH = RE2Flags.ANCHOR_BOTH; + /** + * Constructs a new RE2Set with the specified anchor mode and flags. + * @param {number} [anchor=RE2Set.UNANCHORED] - The anchoring mode (e.g., RE2Set.UNANCHORED). + * @param {number} [flags=0] - The public flags to apply to all patterns in the set. + * @param {number} [maxMem=8388608] - The maximum memory in bytes to use for the DFA (default 8MB). + */ + constructor(anchor = RE2Set.UNANCHORED, flags = 0, maxMem = 8388608) { + this.anchor = anchor; + this.jsFlags = flags; + this.maxMem = maxMem; + let re2Flags = RE2Flags.PERL; + if ((flags & PublicFlags.DISABLE_UNICODE_GROUPS) !== 0) re2Flags &= ~RE2Flags.UNICODE_GROUPS; + if ((flags & PublicFlags.LOOKBEHINDS) !== 0) re2Flags |= RE2Flags.LOOKBEHIND; + this.re2Flags = re2Flags; + this.regexps = []; + this.prog = null; + this.dfa = null; + this.dummyRe2 = null; + } + /** + * Adds a new regular expression pattern to the set. + * Patterns cannot be added after the set has been compiled. + * @param {string} pattern - The regular expression pattern to add. + * @returns {number} The integer index assigned to the added pattern. + * @throws {RE2JSCompileException} If patterns are added after compilation. + */ + add(pattern) { + if (this.prog) throw new RE2JSCompileException("Cannot add patterns after compile"); + let fregex = pattern; + if ((this.jsFlags & PublicFlags.CASE_INSENSITIVE) !== 0) fregex = `(?i)${fregex}`; + if ((this.jsFlags & PublicFlags.DOTALL) !== 0) fregex = `(?s)${fregex}`; + if ((this.jsFlags & PublicFlags.MULTILINE) !== 0) fregex = `(?m)${fregex}`; + const re = Parser.parse(fregex, this.re2Flags); + this.regexps.push(Simplify.simplify(re)); + return this.regexps.length - 1; + } + /** + * Compiles the added patterns into a single state machine. + * This is automatically called on the first match if not called explicitly. + * @returns {void} + */ + compile() { + if (this.prog) return; + this.prog = Compiler.compileSet(this.regexps); + this.dfa = new DFA(this.prog, this.maxMem); + this.dummyRe2 = { + prog: this.prog, + cond: this.prog.startCond(), + prefix: "", + prefixRune: 0, + longest: false + }; + } + /** + * Matches the input against the compiled set of regular expressions. + * @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to match against. + * @returns {number[]} An array of indices representing the patterns that successfully matched the input. + */ + match(input) { + if (!this.prog) this.compile(); + const machineInput = Utils.isByteArray(input) ? MachineInput.fromUTF8(input) : MachineInput.fromUTF16(input); + let internalAnchor = RE2Flags.UNANCHORED; + if (this.anchor === RE2Set.ANCHOR_START) internalAnchor = RE2Flags.ANCHOR_START; + else if (this.anchor === RE2Set.ANCHOR_BOTH) internalAnchor = RE2Flags.ANCHOR_BOTH; + const dfaResult = this.dfa.matchSet(machineInput, 0, internalAnchor); + if (dfaResult !== null) return dfaResult; + const machine = Machine.fromRE2(this.dummyRe2); + machine.init(0); + return machine.matchSet(machineInput, 0, internalAnchor); + } +}; +//#endregion +//#region src/TranslateRegExpString.js +/** +* Transform JS regex string to RE2 regex string +*/ +var TranslateRegExpString = class TranslateRegExpString { + static isHexadecimal(ch) { + return "0" <= ch && ch <= "9" || "A" <= ch && ch <= "F" || "a" <= ch && ch <= "f"; + } + static translate(data) { + let prefixFlags = ""; + if (data instanceof RegExp) { + if (data.ignoreCase) prefixFlags += "i"; + if (data.multiline) prefixFlags += "m"; + if (data.dotAll) prefixFlags += "s"; + data = data.source; + } + if (typeof data !== "string") return data; + let result = ""; + let changed = false; + let size = data.length; + if (size === 0) { + result = "(?:)"; + changed = true; + } + let inCharClass = false; + let i = 0; + while (i < size) { + let ch = data[i]; + if (ch === "\\") { + if (i + 1 < size) { + ch = data[i + 1]; + switch (ch) { + case "\\": + result += "\\\\"; + i += 2; + continue; + case "c": + if (i + 2 < size) { + let code = data[i + 2].charCodeAt(0); + if (code >= 65 && code <= 90 || code >= 97 && code <= 122) { + let val = code % 32; + result += "\\x"; + result += (val >> 4).toString(16).toUpperCase(); + result += (val & 15).toString(16).toUpperCase(); + i += 3; + changed = true; + continue; + } + } + result += "c"; + i += 2; + changed = true; + continue; + case "u": + if (i + 2 < size) { + if (data[i + 2] === "{") { + let j = i + 3; + let hasHex = false; + let closed = false; + while (j < size) { + const hexChar = data[j]; + if (hexChar === "}") { + closed = true; + break; + } + if (!TranslateRegExpString.isHexadecimal(hexChar)) break; + hasHex = true; + j++; + } + if (closed && hasHex) { + result += "\\x"; + i += 2; + changed = true; + continue; + } + } else if (i + 5 < size) { + let isHex4 = true; + for (let j = 0; j < 4; j++) if (!TranslateRegExpString.isHexadecimal(data[i + 2 + j])) { + isHex4 = false; + break; + } + if (isHex4) { + result += "\\x{" + data.substring(i + 2, i + 6) + "}"; + i += 6; + changed = true; + continue; + } + } + } + result += "u"; + i += 2; + changed = true; + continue; + case "x": { + let isValidHex = false; + if (i + 2 < size && data[i + 2] === "{") { + let j = i + 3; + let hasHex = false; + let closed = false; + while (j < size) { + const hexChar = data[j]; + if (hexChar === "}") { + closed = true; + break; + } + if (!TranslateRegExpString.isHexadecimal(hexChar)) break; + hasHex = true; + j++; + } + if (closed && hasHex) isValidHex = true; + } else if (i + 3 < size && TranslateRegExpString.isHexadecimal(data[i + 2]) && TranslateRegExpString.isHexadecimal(data[i + 3])) isValidHex = true; + if (isValidHex) { + result += "\\x"; + i += 2; + } else { + result += "x"; + i += 2; + changed = true; + } + continue; + } + case "n": + case "r": + case "t": + case "a": + case "f": + case "v": + case "d": + case "D": + case "s": + case "S": + case "w": + case "W": + case "b": + case "B": + case "p": + case "P": + case "A": + case "z": + case "Q": + case "E": + case "0": + case "1": + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + result += "\\" + ch; + i += 2; + continue; + default: { + let cp = data.codePointAt(i + 1); + if (cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122) { + let symSize = Utils.charCount(cp); + result += data.substring(i + 1, i + 1 + symSize); + i += symSize + 1; + changed = true; + } else { + result += "\\"; + let symSize = Utils.charCount(cp); + result += data.substring(i + 1, i + 1 + symSize); + i += symSize + 1; + } + continue; + } + } + } + } else if (ch === "/") { + result += "\\/"; + i += 1; + changed = true; + continue; + } else if (ch === "[") inCharClass = true; + else if (ch === "]") inCharClass = false; + else if (!inCharClass && ch === "(" && i + 2 < size && data[i + 1] === "?" && data[i + 2] === "<") { + if (i + 3 < size && !"=!>)".includes(data[i + 3])) { + result += "(?P<"; + i += 3; + changed = true; + continue; + } + } + let cp = data.codePointAt(i); + let symSize = Utils.charCount(cp); + result += data.substring(i, i + symSize); + i += symSize; + } + const finalResult = changed ? result : data; + if (prefixFlags.length > 0) return `(?${prefixFlags})${finalResult}`; + return finalResult; + } +}; +//#endregion +//#region src/index.js +/** +* A compiled representation of an RE2 regular expression +* +* The matching functions take {@code String} arguments instead of the more general Java +* {@code CharSequence} since the latter doesn't provide UTF-16 decoding. +* +* +* @author rsc@google.com (Russ Cox) +* @class +*/ +var RE2JS = class RE2JS { + /** + * Flag: case insensitive matching. + */ + static CASE_INSENSITIVE = PublicFlags.CASE_INSENSITIVE; + /** + * Flag: dot ({@code .}) matches all characters, including newline. + */ + static DOTALL = PublicFlags.DOTALL; + /** + * Flag: multiline matching: {@code ^} and {@code $} match at beginning and end of line, not just + * beginning and end of input. + */ + static MULTILINE = PublicFlags.MULTILINE; + /** + * Flag: Unicode groups (e.g. {@code \p\ Greek\} ) will be syntax errors. + */ + static DISABLE_UNICODE_GROUPS = PublicFlags.DISABLE_UNICODE_GROUPS; + /** + * Flag: matches longest possible string. + */ + static LONGEST_MATCH = PublicFlags.LONGEST_MATCH; + /** + * Flag: enable linear-time captureless lookbehinds. + */ + static LOOKBEHINDS = PublicFlags.LOOKBEHINDS; + /** + * Returns a literal pattern string for the specified string. + * + * This method produces a string that can be used to create a RE2JS that would + * match the string s as if it were a literal pattern. + * + * Metacharacters or escape sequences in the input sequence will be given no special meaning. + * + * @param {string} str The string to be literalized + * @returns {string} A literal string replacement + */ + static quote(str) { + return Utils.quoteMeta(str); + } + /** + * Quotes '\' and '$' in {@code str}, so that the returned string could be used in + * replacement methods as a literal replacement of {@code str}. + * + * This is a convenience delegation to {@link Matcher.quoteReplacement}. + * + * @param {string} str the string to be quoted + * @param {boolean} [javaMode=false] whether the replacement will be used in javaMode + * @returns {string} the quoted string + */ + static quoteReplacement(str, javaMode = false) { + return Matcher.quoteReplacement(str, javaMode); + } + /** + * Translates a given regular expression string to ensure compatibility with RE2JS. + * + * This function preprocesses the input regex string by applying necessary transformations, + * such as escaping special characters (e.g., `/`), converting named capture groups to + * RE2JS-compatible syntax, and handling Unicode sequences properly. It ensures that the + * resulting regex is safe and properly formatted before compilation. + * + * @param {string|RegExp} expr - The regular expression string to be translated. + * @returns {string} - The transformed regular expression string, ready for compilation. + */ + static translateRegExp(expr) { + return TranslateRegExpString.translate(expr); + } + /** + * Helper: create new RE2JS with given regex and flags. Flregex is the regex with flags applied. + * @param {string} regex + * @param {number} [flags=0] + * @returns {RE2JS} + */ + static compile(regex, flags = 0) { + let fregex = regex; + if ((flags & RE2JS.CASE_INSENSITIVE) !== 0) fregex = `(?i)${fregex}`; + if ((flags & RE2JS.DOTALL) !== 0) fregex = `(?s)${fregex}`; + if ((flags & RE2JS.MULTILINE) !== 0) fregex = `(?m)${fregex}`; + if ((flags & ~(RE2JS.MULTILINE | RE2JS.DOTALL | RE2JS.CASE_INSENSITIVE | RE2JS.DISABLE_UNICODE_GROUPS | RE2JS.LONGEST_MATCH | RE2JS.LOOKBEHINDS)) !== 0) throw new RE2JSFlagsException("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH, LOOKBEHINDS"); + let re2Flags = RE2Flags.PERL; + if ((flags & RE2JS.DISABLE_UNICODE_GROUPS) !== 0) re2Flags &= ~RE2Flags.UNICODE_GROUPS; + if ((flags & RE2JS.LOOKBEHINDS) !== 0) re2Flags |= RE2Flags.LOOKBEHIND; + const p = new RE2JS(regex, flags); + p.re2Input = RE2.compileImpl(fregex, re2Flags, (flags & RE2JS.LONGEST_MATCH) !== 0); + return p; + } + /** + * Matches a string against a regular expression. + * + * @param {string} regex the regular expression + * @param {string|number[]|Uint8Array} input the input + * @returns {boolean} true if the regular expression matches the entire input + * @throws RE2JSSyntaxException if the regular expression is malformed + */ + static matches(regex, input) { + return RE2JS.compile(regex).testExact(input); + } + /** + * This is visible for testing. + * @private + */ + static initTest(pattern, flags, re2) { + if (pattern == null) throw new Error("pattern is null"); + if (re2 == null) throw new Error("re2 is null"); + const p = new RE2JS(pattern, flags); + p.re2Input = re2; + return p; + } + /** + * + * @param {string} pattern + * @param {number} flags + */ + constructor(pattern, flags) { + this.patternInput = pattern; + this.flagsInput = flags; + /** @type {import('./RE2.js').RE2} */ + this.re2Input = null; + } + /** + * Releases memory used by internal caches associated with this pattern. Does not change the + * observable behaviour. Useful for tests that detect memory leaks via allocation tracking. + */ + reset() { + this.re2Input.reset(); + } + /** + * Returns the flags used in the constructor. + * @returns {number} + */ + flags() { + return this.flagsInput; + } + /** + * Returns the pattern used in the constructor. + * @returns {string} + */ + pattern() { + return this.patternInput; + } + re2() { + return this.re2Input; + } + /** + * Matches a string against a regular expression. + * + * @param {string|number[]|Uint8Array} input the input + * @returns {boolean} true if the regular expression matches the entire input + */ + matches(input) { + return this.testExact(input); + } + /** + * Creates a new {@code Matcher} matching the pattern against the input. + * + * @param {string|number[]|Uint8Array|MatcherInputBase} input the input string + * @returns {Matcher} + */ + matcher(input) { + if (Utils.isByteArray(input)) input = MatcherInput.utf8(input); + return new Matcher(this, input); + } + /** + * Tests whether the regular expression matches any part of the input string. + * Performance Note: This method is highly optimized. Because it only returns + * a boolean and does not extract capture groups, it bypasses the `Matcher` overhead + * and guarantees execution on the high-speed DFA engine whenever possible. + * + * @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against. + * @returns {boolean} `true` if the pattern is found anywhere in the input, `false` otherwise. + */ + test(input) { + if (Utils.isByteArray(input)) return this.re2Input.matchUTF8(input); + return this.re2Input.match(input); + } + /** + * Tests whether the regular expression matches the ENTIRE input string. + * * **Performance Note:** This operates identically to `.matches()`, but is significantly + * faster because it does not request capture group data. By requesting 0 capture groups, + * it securely routes execution through the DFA fast-path. + * + * @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against. + * @returns {boolean} `true` if the exact input string fully matches the pattern, `false` otherwise. + */ + testExact(input) { + const machineInput = Utils.isByteArray(input) ? MachineInput.fromUTF8(input) : MachineInput.fromUTF16(input); + return this.re2Input.executeEngine(machineInput, 0, RE2Flags.ANCHOR_BOTH, 0) !== null; + } + /** + * Executes a search for a match in a specified string. + * Returns a result array, or null if no match is found. + * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`, + * including `.index`, `.input`, and `.groups` properties. + * + * @param {string|number[]|Uint8Array} input the input string or byte array + * @returns {Array|null} the match array with index, input, and groups properties, or null + */ + exec(input) { + const m = this.matcher(input); + if (!m.find()) return null; + const result = [m.group(0)]; + for (let i = 1; i <= m.groupCount(); i++) { + const val = m.group(i); + result.push(val === null ? void 0 : val); + } + result.index = m.start(0); + result.input = input; + const namedGroups = this.namedGroups(); + if (Object.keys(namedGroups).length > 0) { + const parsedGroups = m.getNamedGroups(); + for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0; + result.groups = parsedGroups; + } else result.groups = void 0; + return result; + } + /** + * Splits input around instances of the regular expression. It returns an array giving the strings + * that occur before, between, and after instances of the regular expression. + * + * If {@code limit <= 0}, there is no limit on the size of the returned array. If + * {@code limit == 0}, empty strings that would occur at the end of the array are omitted. If + * {@code limit > 0}, at most limit strings are returned. The final string contains the remainder + * of the input, possibly including additional matches of the pattern. + * + * @param {string} input the input string to be split + * @param {number} [limit=0] the limit + * @returns {string[]} the split strings + */ + split(input, limit = 0) { + const m = this.matcher(input); + const result = []; + let emptiesSkipped = 0; + let last = 0; + while (m.find()) { + if (last === 0 && m.end() === 0) { + last = m.end(); + continue; + } + if (limit > 0 && result.length === limit - 1) break; + if (last === m.start()) { + if (limit === 0) { + emptiesSkipped += 1; + last = m.end(); + continue; + } + } else while (emptiesSkipped > 0) { + result.push(""); + emptiesSkipped -= 1; + } + result.push(m.substring(last, m.start())); + last = m.end(); + } + if (limit === 0 && last !== m.inputLength()) { + while (emptiesSkipped > 0) { + result.push(""); + emptiesSkipped -= 1; + } + result.push(m.substring(last, m.inputLength())); + } + if (limit !== 0 || result.length === 0 && !(last === m.inputLength() && last > 0)) result.push(m.substring(last, m.inputLength())); + return result; + } + /** + * Returns an iterator of all results matching a string against the regular expression, + * including capturing groups. + * + * @param {string|number[]|Uint8Array} input the input string or byte array + * @returns {IterableIterator} + */ + *matchAll(input) { + const m = this.matcher(input); + while (m.find()) { + const result = [m.group(0)]; + for (let i = 1; i <= m.groupCount(); i++) { + const groupVal = m.group(i); + result.push(groupVal === null ? void 0 : groupVal); + } + result.index = m.start(0); + result.input = input; + const namedGroups = this.namedGroups(); + if (Object.keys(namedGroups).length > 0) { + const parsedGroups = m.getNamedGroups(); + for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0; + result.groups = parsedGroups; + } else result.groups = void 0; + yield result; + } + } + /** + * + * @returns {string} + */ + toString() { + return this.patternInput; + } + /** + * Returns the program size of this pattern. + * + *

+ * Similar to the C++ implementation, the program size is a very approximate measure of a regexp's + * "cost". Larger numbers are more expensive than smaller numbers. + *

+ * + * @returns {number} the program size of this pattern + */ + programSize() { + return this.re2Input.numberOfInstructions(); + } + /** + * Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire + * pattern and is excluded from this count. + * + * @returns {number} the number of capturing groups in this pattern + */ + groupCount() { + return this.re2Input.numberOfCapturingGroups(); + } + /** + * Return a map of the capturing groups in this matcher's pattern, where key is the name and value + * is the index of the group in the pattern. + * @returns {Record} + */ + namedGroups() { + return this.re2Input.namedGroups; + } + /** + * + * @param {*} other + * @returns {boolean} + */ + equals(other) { + if (this === other) return true; + if (other === null || this.constructor !== other.constructor) return false; + return this.flagsInput === other.flagsInput && this.patternInput === other.patternInput; + } +}; +/** +* Creates an RE2JS regex directly from a template literal. +* @overload +* @param {TemplateStringsArray} stringsOrFlags - The raw string segments of the template literal. +* @param {...any} values - The interpolated values. +* @returns {RE2JS} +*/ +/** +* Creates a template literal tag function with specific RE2JS flags. +* @overload +* @param {number} stringsOrFlags - The RE2JS flags to apply (e.g., RE2JS.CASE_INSENSITIVE). +* @returns {(strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS} +*/ +/** +* Implementation signature +* @param {TemplateStringsArray | number} stringsOrFlags +* @param {...any} values +* @returns {RE2JS | ((strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS)} +*/ +const re = (stringsOrFlags, ...values) => { + if (Array.isArray(stringsOrFlags) && "raw" in stringsOrFlags) { + const pattern = String.raw(stringsOrFlags, ...values); + return RE2JS.compile(pattern); + } + const flags = typeof stringsOrFlags === "number" ? stringsOrFlags : 0; + return (strings, ...tagValues) => { + const pattern = String.raw(strings, ...tagValues); + return RE2JS.compile(pattern, flags); + }; +}; +//#endregion + + // EXTERNAL MODULE: ./node_modules/markdownlint/helpers/helpers.cjs var helpers_helpers = __nccwpck_require__(3810); // EXTERNAL MODULE: ./node_modules/markdownlint/helpers/micromark-helpers.cjs @@ -53865,7 +60420,7 @@ const fixableRuleNames = (/* unused pure expression or super */ null && ([ "MD054", "MD058", "MD060" ])); const homepage = "https://github.com/DavidAnson/markdownlint"; -const version = "0.41.1"; +const version = "0.42.0"; // EXTERNAL MODULE: ./node_modules/markdownlint/lib/defer-require.cjs var defer_require = __nccwpck_require__(9489); @@ -54121,9 +60676,9 @@ const unorderedParentTypes = "tags": [ "bullet", "ul", "indentation" ], "parser": "micromark", "function": function MD007(params, onError) { - const indent = Number(params.config.indent || 2); + const indent = Number(params.config.indent ?? 2); const startIndented = !!params.config.start_indented; - const startIndent = Number(params.config.start_indent || indent); + const startIndent = Number(params.config.start_indent ?? indent); const unorderedListNesting = new Map(); let lastBlockQuotePrefix = null; const tokens = filterByTypesCached(unorderedListTypes); @@ -54200,10 +60755,9 @@ const unorderedParentTypes = "tags": [ "whitespace" ], "parser": "micromark", "function": function MD009(params, onError) { - let brSpaces = params.config.br_spaces; - brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces); + const brSpaces = Number(params.config.br_spaces ?? 2); const codeBlocks = params.config.code_blocks; - const includeCode = (codeBlocks === undefined) ? false : !!codeBlocks; + const includeCode = (codeBlocks !== undefined) && !!codeBlocks; const listItemEmptyLines = !!params.config.list_item_empty_lines; const strict = !!params.config.strict; const codeBlockLineNumbers = new Set(); @@ -54301,7 +60855,7 @@ const tabRe = /\t+/g; "parser": "micromark", "function": function MD010(params, onError) { const codeBlocks = params.config.code_blocks; - const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks; + const includeCode = (codeBlocks === undefined) || !!codeBlocks; const ignoreCodeLanguages = new Set( (params.config.ignore_code_languages || []) .map((/** @type {void} */ language) => String(language).toLowerCase()) @@ -54371,9 +60925,10 @@ const tabRe = /\t+/g; -/** @typedef {import("micromark-extension-math")} */ -const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g; +/** @typedef {typeof import("micromark-extension-math")} _ambient_ */ + +const reversedLinkRe = re`(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\]`; /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md011 = ({ @@ -54383,22 +60938,24 @@ const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g; "parser": "micromark", "function": function MD011(params, onError) { const ignoreBlockLineNumbers = new Set(); - for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "mathFlow" ])) { + for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow", "mathFlow" ])) { (0,micromark_helpers.addRangeToSet)(ignoreBlockLineNumbers, ignoreBlock.startLine, ignoreBlock.endLine); } const ignoreTexts = filterByTypesCached([ "codeText", "mathText" ]); for (const [ lineIndex, line ] of params.lines.entries()) { const lineNumber = lineIndex + 1; if (!ignoreBlockLineNumbers.has(lineNumber)) { - let match = null; - while ((match = reversedLinkRe.exec(line)) !== null) { + for (const match of reversedLinkRe.matchAll(line)) { const [ reversedLink, preChar, linkText, linkDestination ] = match; + const matchIndex = match.index ?? 0; + const matchLength = match[0].length; if ( + (line[matchIndex + matchLength] !== "(") && !linkText.endsWith("\\") && !linkDestination.endsWith("\\") ) { - const column = match.index + preChar.length + 1; - const length = match[0].length - preChar.length; + const column = matchIndex + preChar.length + 1; + const length = matchLength - preChar.length; /** @type {import("../helpers/helpers.cjs").FileRange} */ const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 }; if (!ignoreTexts.some((ignoreText) => (0,helpers_helpers/* hasOverlap */.UM)(ignoreText, range))) { @@ -54436,7 +60993,7 @@ const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g; "tags": [ "whitespace", "blank_lines" ], "parser": "micromark", "function": function MD012(params, onError) { - const maximum = Number(params.config.maximum || 1); + const maximum = Number(params.config.maximum ?? 1); const { lines } = params; const codeBlockLineNumbers = new Set(); for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) { @@ -54471,11 +61028,15 @@ const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g; + +/** @typedef {typeof import("micromark-extension-gfm-autolink-literal")} _ambient_ */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_2_ */ + // Regular expression for a line that is not wrappable const notWrappableRe = /^(?:[#>\s]*\s)?\S*$/; -/** @typedef {import("micromark-extension-gfm-autolink-literal")} */ -/** @typedef {import("micromark-extension-gfm-table")} */ +// Regular expression for the last run of non-whitespace +const lastRunRe = re`\S*$`; /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md013 = ({ @@ -54484,17 +61045,17 @@ const notWrappableRe = /^(?:[#>\s]*\s)?\S*$/; "tags": [ "line_length" ], "parser": "micromark", "function": function MD013(params, onError) { - const lineLength = Number(params.config.line_length || 80); - const headingLineLength = Number(params.config.heading_line_length || lineLength); - const codeLineLength = Number(params.config.code_block_line_length || lineLength); + const lineLength = Number(params.config.line_length ?? 80); + const headingLineLength = Number(params.config.heading_line_length ?? lineLength); + const codeLineLength = Number(params.config.code_block_line_length ?? lineLength); const strict = !!params.config.strict; const stern = !!params.config.stern; const codeBlocks = params.config.code_blocks; - const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks; + const includeCodeBlocks = (codeBlocks === undefined) || !!codeBlocks; const tables = params.config.tables; - const includeTables = (tables === undefined) ? true : !!tables; + const includeTables = (tables === undefined) || !!tables; const headings = params.config.headings; - const includeHeadings = (headings === undefined) ? true : !!headings; + const includeHeadings = (headings === undefined) || !!headings; const headingLineNumbers = new Set(); for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) { (0,micromark_helpers.addRangeToSet)(headingLineNumbers, heading.startLine, heading.endLine); @@ -54533,7 +61094,7 @@ const notWrappableRe = /^(?:[#>\s]*\s)?\S*$/; const maxLength = inCode ? codeLineLength : (isHeading ? headingLineLength : lineLength); // If not strict/stern, the last run of non-whitespace is allowed to go // beyond the limit as long as it begins within the limit - const text = (strict || stern) ? line : line.replace(/\S*$/u, "#"); + const text = (strict || stern) ? line : lastRunRe.matcher(line).replaceFirst("#"); if ((maxLength > 0) && (includeCodeBlocks || !inCode) && (includeTables || !inTable) && @@ -54622,7 +61183,7 @@ const dollarCommandRe = /^(\s*)(\$\s+)/; "function": function MD018(params, onError) { const { lines } = params; const ignoreBlockLineNumbers = new Set(); - for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow" ])) { + for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow", "mathFlow" ])) { (0,micromark_helpers.addRangeToSet)(ignoreBlockLineNumbers, ignoreBlock.startLine, ignoreBlock.endLine); } for (const [ lineIndex, line ] of lines.entries()) { @@ -54747,7 +61308,7 @@ function validateHeadingSpaces(onError, heading, delta) { "function": function MD020(params, onError) { const { lines } = params; const ignoreBlockLineNumbers = new Set(); - for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow" ])) { + for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow", "mathFlow" ])) { (0,micromark_helpers.addRangeToSet)(ignoreBlockLineNumbers, ignoreBlock.startLine, ignoreBlock.endLine); } for (const [ lineIndex, line ] of lines.entries()) { @@ -54817,13 +61378,13 @@ const getLinesFunction = (/** @type {any} */ linesParam) => { if (Array.isArray(linesParam)) { // eslint-disable-next-line unicorn/no-unreadable-new-expression const linesArray = new Array(6).fill(defaultLines); - for (const [ index, value ] of [ ...linesParam.entries() ].slice(0, 6)) { + for (const [ index, value ] of linesParam.slice(0, 6).entries()) { linesArray[index] = value; } return (/** @type {MicromarkToken} */ heading) => linesArray[(0,micromark_helpers.getHeadingLevel)(heading) - 1]; } // Coerce linesParam to a number - const lines = (linesParam === undefined) ? defaultLines : Number(linesParam); + const lines = Number(linesParam ?? defaultLines); return () => lines; }; @@ -54831,10 +61392,9 @@ const getLine = (/** @type {readonly string[]} */ lines, /** @type {number} */ i if ((index >= 0) && (index < lines.length)) { return lines[index]; } - if (includeFrontMatter && (frontMatterLines.length > 0) && (index < 0) && (index >= -frontMatterLines.length)) { - return frontMatterLines[frontMatterLines.length + index]; - } - return ""; + return (includeFrontMatter && (frontMatterLines.length > 0) && (index < 0) && (index >= -frontMatterLines.length)) ? + frontMatterLines[frontMatterLines.length + index] : + ""; }; /** @type {import("markdownlint").Rule} */ @@ -55007,7 +61567,7 @@ const getLine = (/** @type {readonly string[]} */ lines, /** @type {number} */ i "tags": [ "headings" ], "parser": "micromark", "function": function MD025(params, onError) { - const level = Number(params.config.level || 1); + const level = Number(params.config.level ?? 1); const { tokens } = params.parsers.micromark; const matchingHeadings = filterByTypesCached([ "atxHeading", "setextHeading" ]) .filter((heading) => (level === (0,micromark_helpers.getHeadingLevel)(heading)) && !(0,micromark_helpers.isDocfxTab)(heading)); @@ -55105,7 +61665,7 @@ const listTypes = [ "listOrdered", "listUnordered" ]; "parser": "micromark", "function": function MD027(params, onError) { const listItems = params.config.list_items; - const includeListItems = (listItems === undefined) ? true : !!listItems; + const includeListItems = (listItems === undefined) || !!listItems; const { tokens } = params.parsers.micromark; for (const token of filterByTypesCached([ "linePrefix" ])) { const parent = token.parent; @@ -55158,8 +61718,7 @@ const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]); const errorLineNumbers = []; const siblings = token.parent?.children || params.parsers.micromark.tokens; for (let i = siblings.indexOf(token) + 1; i < siblings.length; i++) { - const sibling = siblings[i]; - const { startLine, type } = sibling; + const { startLine, type } = siblings[i]; if (type === "lineEndingBlank") { // Possible blank between blockquotes errorLineNumbers.push(startLine); @@ -55201,8 +61760,7 @@ const listStyles = Object.keys(listStyleExamples); * @returns {{startColumn: number, endColumn: number, text: string, number: number}} List item value column and text. */ function getOrderedListItemValue(listItemPrefix) { - const listItemValue = (0,micromark_helpers.getDescendantsByType)(listItemPrefix, [ "listItemValue" ])[0]; - const { startColumn, endColumn, text } = listItemValue; + const { startColumn, endColumn, text } = (0,micromark_helpers.getDescendantsByType)(listItemPrefix, [ "listItemValue" ])[0]; return { startColumn, endColumn, @@ -55291,10 +61849,10 @@ function getOrderedListItemValue(listItemPrefix) { "tags": [ "ol", "ul", "whitespace" ], "parser": "micromark", "function": function MD030(params, onError) { - const ulSingle = Number(params.config.ul_single || 1); - const olSingle = Number(params.config.ol_single || 1); - const ulMulti = Number(params.config.ul_multi || 1); - const olMulti = Number(params.config.ol_multi || 1); + const ulSingle = Number(params.config.ul_single ?? 1); + const olSingle = Number(params.config.ol_single ?? 1); + const ulMulti = Number(params.config.ul_multi ?? 1); + const olMulti = Number(params.config.ol_multi ?? 1); for (const list of filterByTypesCached([ "listOrdered", "listUnordered" ])) { const ordered = (list.type === "listOrdered"); const listItemPrefixes = @@ -55385,7 +61943,7 @@ function addError(onError, lines, lineNumber, top) { "parser": "micromark", "function": function MD031(params, onError) { const listItems = params.config.list_items; - const includeListItems = (listItems === undefined) ? true : !!listItems; + const includeListItems = (listItems === undefined) || !!listItems; const { lines } = params; for (const codeBlock of filterByTypesCached([ "codeFenced" ])) { if (includeListItems || !((0,micromark_helpers.getParentOfType)(codeBlock, [ "listOrdered", "listUnordered" ]))) { @@ -55488,7 +62046,7 @@ const isList = (/** @type {MicromarkToken} */ token) => ( -/** @typedef {import("micromark-extension-gfm-table")} */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */ // eslint-disable-next-line jsdoc/reject-any-type const toLowerCaseStringArray = (/** @type {any} */ arr) => Array.isArray(arr) ? arr.map((elm) => String(elm).toLowerCase()) : []; @@ -55536,7 +62094,7 @@ const toLowerCaseStringArray = (/** @type {any} */ arr) => Array.isArray(arr) ? /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ -/** @typedef {import("micromark-extension-gfm-autolink-literal")} */ +/** @typedef {typeof import("micromark-extension-gfm-autolink-literal")} _ambient_ */ /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md034 = ({ @@ -55881,6 +62439,10 @@ const isParagraphChildMeaningful = (/** @type {MicromarkToken} */ token) => !( + +const startRe = re`^[^\S\r\n]+`; +const endRe = re`[^\S\r\n]+$`; + /** * Adds an error for a label space issue. * @@ -55890,7 +62452,7 @@ const isParagraphChildMeaningful = (/** @type {MicromarkToken} */ token) => !( * @param {boolean} isStart True iff error is at the start of the link. */ function addLabelSpaceError(onError, label, labelText, isStart) { - const match = labelText.text.match(isStart ? /^[^\S\r\n]+/ : /[^\S\r\n]+$/); + const match = (isStart ? startRe : endRe).exec(labelText.text); const range = match ? [ (isStart ? (labelText.startColumn) : (labelText.endColumn - match[0].length)), @@ -56004,7 +62566,7 @@ function getHtmlFlowTagName(token) { "parser": "micromark", "function": function MD041(params, onError) { const allowPreamble = !!params.config.allow_preamble; - const level = Number(params.config.level || 1); + const level = Number(params.config.level ?? 1); const { tokens } = params.parsers.micromark; if ( !(0,helpers_helpers/* frontMatterHasTitle */.Fl)( @@ -56110,6 +62672,29 @@ function getHtmlFlowTagName(token) { +const headingsItemsRe = /^(?:[*+?]|\^+|[#%]{1,6}\s+\S.*)$/u; +const prefixedHeadingPartsRe = /^([#%]{1,6})\s+(\S.*)$/u; +const loopHeadingRe = /^\^+$/u; +const canMatchNothingHeadingsRe = /^(?:\*|\^+)$/u; +const maximumLoopsAllowed = 1000; + +const headingIsExpected = (/** @type {string} */ actual, /** @type {string} */ expected, /** @type {boolean} */ matchCase) => { + if (expected.startsWith("%")) { + // Regular expression comparison + const [ , actualLevel, actualText ] = prefixedHeadingPartsRe.exec(actual) || []; + const [ , expectedLevel, expectedText ] = prefixedHeadingPartsRe.exec(expected) || []; + return ( + (actualLevel.length === expectedLevel.length) && + // eslint-disable-next-line unicorn/no-unreadable-new-expression + (new RegExp(expectedText, `${matchCase ? "" : "i"}u`)).test(actualText) + ); + } + // Text comparison + const actualLower = matchCase ? actual : actual.toLowerCase(); + const expectedLower = matchCase ? expected : expected.toLowerCase(); + return actualLower === expectedLower; +}; + /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md043 = ({ "names": [ "MD043", "required-headings" ], @@ -56117,62 +62702,93 @@ function getHtmlFlowTagName(token) { "tags": [ "headings" ], "parser": "micromark", "function": function MD043(params, onError) { - const requiredHeadings = params.config.headings; - if (!Array.isArray(requiredHeadings)) { - // Nothing to check; avoid doing any work + /** @type {string[] | null | undefined} */ + const headings = params.config.headings; + if (!headings) { return; } - const matchCase = params.config.match_case || false; + const requiredHeadings = headings.map((heading) => headingsItemsRe.test(heading) ? heading : "[Invalid syntax]"); + const matchCase = Boolean(params.config.match_case); let i = 0; - let matchAny = false; + let remainingLoopsAllowed = maximumLoopsAllowed; + let allowAnyMatchFallback = false; let hasError = false; - let anyHeadings = false; - const getExpected = () => String(requiredHeadings[i++] || "[None]"); - const handleCase = (/** @type {string} */ str) => (matchCase ? str : str.toLowerCase()); + const getExpected = (/** @type {boolean} */ skipLoopHeadings) => { + let expected = null; + do { + expected = requiredHeadings[i++] || "[No heading]"; + // eslint-disable-next-line no-unmodified-loop-condition + } while (skipLoopHeadings && loopHeadingRe.test(expected)); + return expected; + }; for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) { - if (!hasError) { - const headingText = (0,micromark_helpers.getHeadingText)(heading); - const headingLevel = (0,micromark_helpers.getHeadingLevel)(heading); - anyHeadings = true; - const actual = `${"".padEnd(headingLevel, "#")} ${headingText}`; - const expected = getExpected(); - if (expected === "*") { - const nextExpected = getExpected(); - if (handleCase(nextExpected) !== handleCase(actual)) { - matchAny = true; - i--; - } - } else if (expected === "+") { - matchAny = true; - } else if (expected === "?") { - // Allow current, match next - } else if (handleCase(expected) === handleCase(actual)) { - matchAny = false; - } else if (matchAny) { - i--; + const headingText = (0,micromark_helpers.getHeadingText)(heading); + const headingLevel = (0,micromark_helpers.getHeadingLevel)(heading); + const actual = `${"".padEnd(headingLevel, "#")} ${headingText}`; + let expected = getExpected(false); + if (expected.startsWith("^")) { + // Handle loop + const current = i; + const nextExpected = getExpected(true); + if (headingIsExpected(actual, nextExpected, matchCase)) { + // No need to loop (again) + expected = nextExpected; } else { - (0,helpers_helpers/* addErrorDetailIf */.qC)( - onError, - heading.startLine, - expected, - actual - ); - hasError = true; + // Try to loop to previous matching marker + remainingLoopsAllowed--; + let j = current - 2; + for (; j >= 0; j--) { + if (requiredHeadings[j] === expected) { + // Perform loop + i = j + 1; + expected = getExpected(false); + break; + } + } + if (j < 0) { + // No matching loop marker + expected = nextExpected; + } } } + if (remainingLoopsAllowed < 0) { + // Too many loops performed + (0,helpers_helpers/* addError */.CN)(onError, heading.startLine, "Too many loops", `Limit: ${maximumLoopsAllowed}`); + hasError = true; + break; + } else if (expected === "*") { + // Handle "zero or more of anything" + const nextExpected = getExpected(true); + if (!headingIsExpected(actual, nextExpected, matchCase)) { + allowAnyMatchFallback = true; + i--; + } + } else if (expected === "+") { + // Handle "one or more of anything" + allowAnyMatchFallback = true; + } else if (expected === "?") { + // Handle "exactly one of anything" + // Nothing to do + } else if (headingIsExpected(actual, expected, matchCase)) { + // Handle successful match + allowAnyMatchFallback = false; + } else if (allowAnyMatchFallback) { + // Handle "anything" match by restoring index + i--; + } else { + // Report heading mismatch + (0,helpers_helpers/* addErrorDetailIf */.qC)(onError, heading.startLine, expected, actual); + hasError = true; + break; + } } - const extraHeadings = requiredHeadings.length - i; + const remainingRequiredHeadings = requiredHeadings.slice(i).filter((heading) => !canMatchNothingHeadingsRe.test(heading)); if ( !hasError && - ((extraHeadings > 1) || - ((extraHeadings === 1) && (requiredHeadings[i] !== "*"))) && - (anyHeadings || !requiredHeadings.every((heading) => heading === "*")) + (remainingRequiredHeadings.length > 0) ) { - (0,helpers_helpers/* addErrorContext */.Xr)( - onError, - params.lines.length, - requiredHeadings[i] - ); + // Report unmatched heading(s) + (0,helpers_helpers/* addErrorDetailIf */.qC)(onError, params.lines.length, remainingRequiredHeadings[0], "[End of file]"); } } }); @@ -56352,7 +62968,7 @@ function markdownLineEndingOrSpace(code) { * @returns {boolean} * Whether it matches. */ -function micromark_util_character_markdownSpace(code) { +function markdownSpace(code) { return code === -2 || code === -1 || code === 32; } @@ -56472,7 +63088,7 @@ function factorySpace(effects, ok, type, max) { /** @type {State} */ function start(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.enter(type); return prefix(code); } @@ -56481,7 +63097,7 @@ function factorySpace(effects, ok, type, max) { /** @type {State} */ function prefix(code) { - if (micromark_util_character_markdownSpace(code) && size++ < limit) { + if (markdownSpace(code) && size++ < limit) { effects.consume(code); return prefix; } @@ -56580,7 +63196,7 @@ function factoryWhitespace(effects, ok) { seen = true; return start; } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code); } return ok(code); @@ -56637,7 +63253,7 @@ function factoryAttributes(effects, ok, nok, attributesType, attributesMarkerTyp type = attributeClassType; return shortcutStart(code); } - if (disallowEol && micromark_util_character_markdownSpace(code)) { + if (disallowEol && markdownSpace(code)) { return factorySpace(effects, between, "whitespace")(code); } if (!disallowEol && markdownLineEndingOrSpace(code)) { @@ -56698,7 +63314,7 @@ function factoryAttributes(effects, ok, nok, attributesType, attributesMarkerTyp function name(code) { if (code === null || markdownLineEnding(code) || unicodeWhitespace(code) || unicodePunctuation(code) && code !== 45 && code !== 46 && code !== 58 && code !== 95) { effects.exit(attributeNameType); - if (disallowEol && micromark_util_character_markdownSpace(code)) { + if (disallowEol && markdownSpace(code)) { return factorySpace(effects, nameAfter, "whitespace")(code); } if (!disallowEol && markdownLineEndingOrSpace(code)) { @@ -56737,7 +63353,7 @@ function factoryAttributes(effects, ok, nok, attributesType, attributesMarkerTyp marker = code; return valueQuotedStart; } - if (disallowEol && micromark_util_character_markdownSpace(code)) { + if (disallowEol && markdownSpace(code)) { return factorySpace(effects, valueBefore, "whitespace")(code); } if (!disallowEol && markdownLineEndingOrSpace(code)) { @@ -58327,7 +64943,7 @@ function tokenizeBlankLine(effects, ok, nok) { * @type {State} */ function start(code) { - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code); + return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code); } /** @@ -58905,15 +65521,27 @@ class EditMap { * @type {Array} */ this.map = []; + + /** + * Changes by index, so `add` does not scan `map` (quadratic on + * table-heavy documents). + * + * @type {Map} + */ + this.index = new Map(); } /** * Create an edit: a remove and/or add at a certain place. * * @param {number} index + * Index at which to apply the edit. * @param {number} remove + * Count of items to remove at the index. * @param {Array} add + * Items to add at the index. * @returns {undefined} + * Nothing. */ add(index, remove, add) { addImplementation(this, index, remove, add); @@ -58936,7 +65564,9 @@ class EditMap { * Done, change the events. * * @param {Array} events + * List of events to apply the edits to. * @returns {undefined} + * Nothing. */ consume(events) { this.map.sort(function (a, b) { @@ -58988,6 +65618,7 @@ class EditMap { // Truncate everything. this.map.length = 0; + this.index.clear(); } } @@ -58995,35 +65626,40 @@ class EditMap { * Create an edit. * * @param {EditMap} editMap + * Edit map to apply to. * @param {number} at + * Index at which to apply the edit. * @param {number} remove + * Count of items to remove at the index. * @param {Array} add + * Items to add at the index. * @returns {undefined} + * Nothing. */ function addImplementation(editMap, at, remove, add) { - let index = 0; - /* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */ if (remove === 0 && add.length === 0) { return; } - while (index < editMap.map.length) { - if (editMap.map[index][0] === at) { - editMap.map[index][1] += remove; + const existing = editMap.index.get(at); + if (existing) { + existing[1] += remove; - // To do: before not used by tables, use when moving to micromark. - // if (before) { - // add.push(...editMap.map[index][2]) - // editMap.map[index][2] = add - // } else { - editMap.map[index][2].push(...add); - // } + // To do: before not used by tables, use when moving to micromark. + // if (before) { + // add.push(...existing[2]) + // existing[2] = add + // } else { + existing[2].push(...add); + // } - return; - } - index += 1; + return; } - editMap.map.push([at, remove, add]); + + /** @type {Change} */ + const change = [at, remove, add]; + editMap.map.push(change); + editMap.index.set(at, change); } // /** @@ -59162,6 +65798,8 @@ function gfmTable() { } /** + * Tokenizer for GFM tables. + * * @this {TokenizeContext} * @type {Tokenizer} */ @@ -59192,10 +65830,16 @@ function tokenizeTable(effects, ok, nok) { function start(code) { let index = self.events.length - 1; while (index > -1) { - const type = self.events[index][1].type; + const { + type + } = self.events[index][1]; if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix` - type === "linePrefix") index--;else break; + type === "linePrefix") { + index--; + } else { + break; + } } const tail = index > -1 ? self.events[index][1].type : null; const next = tail === 'tableHead' || tail === 'tableRow' ? bodyRowStart : headRowBefore; @@ -59294,7 +65938,7 @@ function tokenizeTable(effects, ok, nok) { // Note: in `markdown-rs`, we need to reset, in `micromark-js` we don‘t. return nok(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { // To do: check if this is fine. // effects.attempt(State::Next(StateName::GfmTableHeadRowBreak), State::Nok) // State::Retry(space_or_tab(tokenizer)) @@ -59384,7 +66028,7 @@ function tokenizeTable(effects, ok, nok) { effects.enter('tableDelimiterRow'); // Track if we’ve seen a `:` or `|`. seen = false; - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code); } return headDelimiterBefore(code); @@ -59433,7 +66077,7 @@ function tokenizeTable(effects, ok, nok) { * @type {State} */ function headDelimiterCellBefore(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code); } return headDelimiterValueBefore(code); @@ -59536,7 +66180,7 @@ function tokenizeTable(effects, ok, nok) { * @type {State} */ function headDelimiterRightAlignmentAfter(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code); } return headDelimiterCellAfter(code); @@ -59637,7 +66281,7 @@ function tokenizeTable(effects, ok, nok) { effects.exit('tableRow'); return ok(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, bodyRowBreak, "whitespace")(code); } @@ -59815,12 +66459,19 @@ function resolveTable(events, context) { * Generate a cell. * * @param {EditMap} map + * Edit map to apply to. * @param {Readonly} context + * Tokenize context. * @param {Readonly} range + * Range of the cell within events. * @param {RowKind} rowKind + * Type of row. * @param {number | undefined} rowEnd + * Index of the end of the row, if known. * @param {Token | undefined} previousCell + * Previous cell token, if any. * @returns {Token | undefined} + * Current cell token after flushing, if any. */ // eslint-disable-next-line max-params function flushCell(map, context, range, rowKind, rowEnd, previousCell) { @@ -59915,10 +66566,17 @@ function flushCell(map, context, range, rowKind, rowEnd, previousCell) { * Generate table end (and table body end). * * @param {Readonly} map + * Edit map to apply to. * @param {Readonly} context + * Tokenize context. * @param {number} index + * Index within the events where the table end should be inserted. * @param {Token} table + * Table token. * @param {Token | undefined} tableBody + * Table body token, if any. + * @returns {undefined} + * Nothing. */ // eslint-disable-next-line max-params function flushTableEnd(map, context, index, table, tableBody) { @@ -59935,9 +66593,14 @@ function flushTableEnd(map, context, index, table, tableBody) { } /** + * Get the point (start or end) for a given event in the list of events. + * * @param {Readonly>} events + * List of events. * @param {number} index + * Index of the event to get the point for. * @returns {Readonly} + * Start point for enter and end point for exit. */ function getPoint(events, index) { const event = events[index]; @@ -60858,6 +67521,232 @@ function initializeContent(effects) { return data; } } +;// CONCATENATED MODULE: ./node_modules/micromark-util-edit-map/index.js +/** + * @import {Event} from 'micromark-util-types' + */ + +/** + * @typedef {[number, number, Array]} Change + * @typedef {[number, number, number]} Jump + */ + +/** + * Tracks a bunch of edits. + * + * Port of `edit_map.rs` from `markdown-rs`: + * . + * + * Deal with several changes in events, batching them together. + * + * Preferably, changes should be kept to a minimum. + * Sometimes, it’s needed to change the list of events, because parsing can be + * messy, and it helps to expose a cleaner interface of events to the compiler + * and other users. + * It can also help to merge many adjacent similar events. + * And, in other cases, it’s needed to parse subcontent: pass some events + * through another tokenizer and inject the result. + */ +class micromark_util_edit_map_EditMap { + /** + * Create a new edit map. + * + * @returns + * New instance. + */ + constructor() { + /** + * Changes by index, so `add` does not need to scan `map` (which is + * quadratic for documents with many edits at different places). + * + * @type {Map} + */ + this.index = new Map(); + + /** + * Record of changes. + * + * @type {Array} + */ + this.map = []; + } + + /** + * Create an edit: a remove and/or add at a certain place. + * + * @param {number} index + * Index at which to apply the edit. + * @param {number} remove + * Count of items to remove at the index. + * @param {Array} add + * Items to add at the index. + * @returns {undefined} + * Nothing. + */ + add(index, remove, add) { + micromark_util_edit_map_addImplementation(this, index, remove, add, false); + } + + /** + * Create an edit: but insert `add` before existing additions, instead of + * after them. + * + * @param {number} index + * Index at which to apply the edit. + * @param {number} remove + * Count of items to remove at the index. + * @param {Array} add + * Items to add at the index. + * @returns {undefined} + * Nothing. + */ + addBefore(index, remove, add) { + micromark_util_edit_map_addImplementation(this, index, remove, add, true); + } + + /** + * Done, change the events. + * + * @param {Array} events + * List of events to apply the edits to. + * @returns {undefined} + * Nothing. + */ + consume(events) { + this.map.sort(function (a, b) { + return a[0] - b[0]; + }); + if (this.map.length === 0) { + return; + } + + // To do: if links are added in events, like they are in `markdown-rs`, + // this is needed. + // // Calculate jumps: where items in the current list move to. + // /** @type {Array} */ + // const jumps = [] + // let index = 0 + // let addAcc = 0 + // let removeAcc = 0 + // while (index < this.map.length) { + // const [at, remove, add] = this.map[index] + // removeAcc += remove + // addAcc += add.length + // jumps.push([at, removeAcc, addAcc]) + // index += 1 + // } + // + // shiftLinks(events, jumps) + + let index = this.map.length; + /** @type {Array>} */ + const vecs = []; + while (index > 0) { + index -= 1; + vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]); + + // Truncate rest. + events.length = this.map[index][0]; + } + vecs.push(events.slice()); + events.length = 0; + let slice = vecs.pop(); + while (slice) { + for (const element of slice) { + events.push(element); + } + slice = vecs.pop(); + } + + // Truncate everything. + this.map.length = 0; + this.index.clear(); + } +} + +/** + * Create an edit. + * + * @param {EditMap} editMap + * Edit map to apply to. + * @param {number} at + * Index at which to apply the edit. + * @param {number} remove + * Count of items to remove at the index. + * @param {Array} add + * Items to add at the index. + * @param {boolean} before + * Insert `add` before existing additions at `at`, instead of after them. + * @returns {undefined} + * Nothing. + */ +function micromark_util_edit_map_addImplementation(editMap, at, remove, add, before) { + if (remove === 0 && add.length === 0) { + return; + } + const existing = editMap.index.get(at); + if (existing) { + existing[1] += remove; + if (before) { + add.push(...existing[2]); + existing[2] = add; + } else { + existing[2].push(...add); + } + return; + } + + /** @type {Change} */ + const change = [at, remove, add]; + editMap.map.push(change); + editMap.index.set(at, change); +} + +// /** +// * Shift `previous` and `next` links according to `jumps`. +// * +// * This fixes links in case there are events removed or added between them. +// * +// * @param {Array} events +// * @param {Array} jumps +// */ +// function shiftLinks(events, jumps) { +// let jumpIndex = 0 +// let index = 0 +// let add = 0 +// let rm = 0 + +// while (index < events.length) { +// const rmCurr = rm + +// while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) { +// add = jumps[jumpIndex][2] +// rm = jumps[jumpIndex][1] +// jumpIndex += 1 +// } + +// // Ignore items that will be removed. +// if (rm > rmCurr) { +// index += rm - rmCurr +// } else { +// // ? +// // if let Some(link) = &events[index].link { +// // if let Some(next) = link.next { +// // events[next].link.as_mut().unwrap().previous = Some(index + add - rm); +// // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next { +// // add = jumps[jumpIndex].2; +// // rm = jumps[jumpIndex].1; +// // jumpIndex += 1; +// // } +// // events[index].link.as_mut().unwrap().next = Some(next + add - rm); +// // index = next; +// // continue; +// // } +// // } +// index += 1 +// } +// } +// } ;// CONCATENATED MODULE: ./node_modules/micromark/lib/initialize/document.js /** * @import { @@ -60969,12 +67858,12 @@ function initializeDocument(effects) { }; index++; } - + const editMap = new micromark_util_edit_map_EditMap(); // Inject the exits earlier (they’re still also at the end). - splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); - + editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); // Discard the duplicate exits. - self.events.length = index; + editMap.add(indexBeforeExits, index - indexBeforeExits, []); + editMap.consume(self.events); return checkNewContainers(code); } return start(code); @@ -61017,7 +67906,9 @@ function initializeDocument(effects) { /** @type {State} */ function thereIsANewContainer(code) { - if (childFlow) closeFlow(); + if (childFlow) { + closeFlow(); + } exitContainers(continued); return documentContinued(code); } @@ -61047,7 +67938,9 @@ function initializeDocument(effects) { /** @type {State} */ function flowStart(code) { if (code === null) { - if (childFlow) closeFlow(); + if (childFlow) { + closeFlow(); + } exitContainers(0); effects.consume(code); return; @@ -61091,9 +67984,13 @@ function initializeDocument(effects) { */ function writeToChild(token, endOfFile) { const stream = self.sliceStream(token); - if (endOfFile) stream.push(null); + if (endOfFile) { + stream.push(null); + } token.previous = childToken; - if (childToken) childToken.next = token; + if (childToken) { + childToken.next = token; + } childToken = token; childFlow.defineSkip(token.start); childFlow.write(stream); @@ -61176,12 +68073,12 @@ function initializeDocument(effects) { }; index++; } - + const editMap = new micromark_util_edit_map_EditMap(); // Inject the exits earlier (they’re still also at the end). - splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); - + editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); // Discard the duplicate exits. - self.events.length = index; + editMap.add(indexBeforeExits, index - indexBeforeExits, []); + editMap.consume(self.events); } } @@ -61937,6 +68834,7 @@ function initializeFlow(effects) { * } from 'micromark-util-types' */ + const resolver = { resolveAll: createResolver() }; @@ -62070,6 +68968,7 @@ function createResolver(extraResolver) { * @type {Resolver} */ function resolveAllLineSuffixes(events, context) { + const editMap = new micromark_util_edit_map_EditMap(); let eventIndex = 0; // Skip first. while (++eventIndex <= events.length) { @@ -62089,7 +68988,9 @@ function resolveAllLineSuffixes(events, context) { size++; bufferIndex--; } - if (bufferIndex) break; + if (bufferIndex) { + break; + } bufferIndex = -1; } // Number @@ -62129,13 +69030,13 @@ function resolveAllLineSuffixes(events, context) { if (data.start.offset === data.end.offset) { Object.assign(data, token); } else { - events.splice(eventIndex, 0, ['enter', token, context], ['exit', token, context]); - eventIndex += 2; + editMap.add(eventIndex, 0, [['enter', token, context], ['exit', token, context]]); } } eventIndex++; } } + editMap.consume(events); return events; } ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/thematic-break.js @@ -62238,7 +69139,7 @@ function tokenizeThematicBreak(effects, ok, nok) { return sequence; } effects.exit("thematicBreakSequence"); - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code); + return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code); } } ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/list.js @@ -62353,7 +69254,7 @@ function tokenizeListStart(effects, ok, nok) { /** @type {State} */ function otherPrefix(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.enter("listItemPrefixWhitespace"); effects.consume(code); effects.exit("listItemPrefixWhitespace"); @@ -62390,7 +69291,7 @@ function tokenizeListContinuation(effects, ok, nok) { /** @type {State} */ function notBlank(code) { - if (self.containerState.furtherBlankLines || !micromark_util_character_markdownSpace(code)) { + if (self.containerState.furtherBlankLines || !markdownSpace(code)) { self.containerState.furtherBlankLines = undefined; self.containerState.initialBlankLine = undefined; return notInCurrentItem(code); @@ -62452,7 +69353,7 @@ function tokenizeListItemPrefixWhitespace(effects, ok, nok) { /** @type {State} */ function afterPrefix(code) { const tail = self.events[self.events.length - 1]; - return !micromark_util_character_markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code); + return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code); } } ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/block-quote.js @@ -62526,7 +69427,7 @@ function tokenizeBlockQuoteStart(effects, ok, nok) { * @type {State} */ function after(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.enter("blockQuotePrefixWhitespace"); effects.consume(code); effects.exit("blockQuotePrefixWhitespace"); @@ -62569,7 +69470,7 @@ function tokenizeBlockQuoteContinuation(effects, ok, nok) { * @type {State} */ function contStart(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { // Always populated by defaults. return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code); @@ -62932,7 +69833,7 @@ function micromark_factory_label_factoryLabel(effects, ok, nok, type, markerType return atBreak(code); } effects.consume(code); - if (!seen) seen = !micromark_util_character_markdownSpace(code); + if (!seen) seen = !markdownSpace(code); return code === 92 ? labelEscape : labelInside; } @@ -63269,7 +70170,7 @@ function tokenizeDefinition(effects, ok, nok) { * @type {State} */ function after(code) { - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code); + return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code); } /** @@ -63352,7 +70253,7 @@ function tokenizeTitleBefore(effects, ok, nok) { * @type {State} */ function titleAfter(code) { - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code); + return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code); } /** @@ -63399,7 +70300,6 @@ const furtherStart = { * @type {Tokenizer} */ function tokenizeCodeIndented(effects, ok, nok) { - const self = this; return start; /** @@ -63420,24 +70320,7 @@ function tokenizeCodeIndented(effects, ok, nok) { // To do: manually check if interrupting like `markdown-rs`. effects.enter("codeIndented"); - // To do: use an improved `space_or_tab` function like `markdown-rs`, - // so that we can drop the next state. - return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code); - } - - /** - * At start, after 1 or 4 spaces. - * - * ```markdown - * > | aaa - * ^ - * ``` - * - * @type {State} - */ - function afterPrefix(code) { - const tail = self.events[self.events.length - 1]; - return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code); + return factorySpaceMinMax(effects, atBreak, nok, "linePrefix", 4, 4)(code); } /** @@ -63526,25 +70409,25 @@ function tokenizeFurtherStart(effects, ok, nok) { // To do: the code here in `micromark-js` is a bit different from // `markdown-rs` because there it can attempt spaces. // We can’t yet. - // - // To do: use an improved `space_or_tab` function like `markdown-rs`, - // so that we can drop the next state. - return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code); + return factorySpaceMinMax(effects, ok, onNotEnoughPrefix, "linePrefix", 4, 4)(code); } /** - * At start, after 1 or 4 spaces. + * After not enough of a prefix. + * + * A following line ending is another (potentially blank) line to try, + * anything else means this isn’t a continuation. * * ```markdown * > | aaa - * ^ + * + * | bbb * ``` * * @type {State} */ - function afterPrefix(code) { - const tail = self.events[self.events.length - 1]; - return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code); + function onNotEnoughPrefix(code) { + return markdownLineEnding(code) ? furtherStart(code) : nok(code); } } ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/heading-atx.js @@ -63573,10 +70456,6 @@ const headingAtx = { function resolveHeadingAtx(events, context) { let contentEnd = events.length - 2; let contentStart = 3; - /** @type {Token} */ - let content; - /** @type {Token} */ - let text; // Prefix whitespace, part of the opening. if (events[contentStart][1].type === "whitespace") { @@ -63591,12 +70470,12 @@ function resolveHeadingAtx(events, context) { contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; } if (contentEnd > contentStart) { - content = { + const content = { type: "atxHeadingText", start: events[contentStart][1].start, end: events[contentEnd][1].end }; - text = { + const text = { type: "chunkText", start: events[contentStart][1].start, end: events[contentEnd][1].end, @@ -63693,7 +70572,7 @@ function tokenizeHeadingAtx(effects, ok, nok) { // tokenizer.interrupt = false return ok(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { return factorySpace(effects, atBreak, "whitespace")(code); } @@ -63757,6 +70636,7 @@ function tokenizeHeadingAtx(effects, ok, nok) { + /** @type {Construct} */ const setextUnderline = { name: 'setextUnderline', @@ -63766,7 +70646,7 @@ const setextUnderline = { /** @type {Resolver} */ function resolveToSetextUnderline(events, context) { - // To do: resolve like `markdown-rs`. + const editMap = new micromark_util_edit_map_EditMap(); let index = events.length; /** @type {number | undefined} */ let content; @@ -63791,7 +70671,7 @@ function resolveToSetextUnderline(events, context) { else { if (events[index][1].type === "content") { // Remove the content end (if needed we’ll add it later) - events.splice(index, 1); + editMap.add(index, 1, []); } if (!definition && events[index][1].type === "definition") { definition = index; @@ -63814,8 +70694,8 @@ function resolveToSetextUnderline(events, context) { // If we have definitions in the content, we’ll keep on having content, // but we need move it. if (definition) { - events.splice(text, 0, ['enter', heading, context]); - events.splice(definition + 1, 0, ['exit', events[content][1], context]); + editMap.add(text, 0, [['enter', heading, context]]); + editMap.add(definition + 1, 0, [['exit', events[content][1], context]]); events[content][1].end = { ...events[definition][1].end }; @@ -63824,7 +70704,8 @@ function resolveToSetextUnderline(events, context) { } // Add the heading exit at the end. - events.push(['exit', heading, context]); + editMap.add(events.length, 0, [['exit', heading, context]]); + editMap.consume(events); return events; } @@ -63907,7 +70788,7 @@ function tokenizeSetextUnderline(effects, ok, nok) { return inside; } effects.exit("setextHeadingLineSequence"); - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code); + return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code); } /** @@ -64024,6 +70905,68 @@ const htmlBlockNames = [ */ const htmlRawNames = ['pre', 'script', 'style', 'textarea'] +;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +/** + * @import { + * Construct, + * State, + * TokenizeContext, + * Tokenizer + * } from 'micromark-util-types' + */ + + +/** @type {Construct} */ +const partial_non_lazy_continuation_nonLazyContinuation = { + partial: true, + tokenize: partial_non_lazy_continuation_tokenizeNonLazyContinuation +}; + +/** + * @this {TokenizeContext} + * Context. + * @type {Tokenizer} + */ +function partial_non_lazy_continuation_tokenizeNonLazyContinuation(effects, ok, nok) { + const self = this; + return start; + + /** + * At eol, before continuation. + * + * ```markdown + * > | * ```js + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + if (code === null) { + return nok(code); + } + effects.enter("lineEnding"); + effects.consume(code); + effects.exit("lineEnding"); + return after; + } + + /** + * A continuation. + * + * ```markdown + * | * ```js + * > | b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code); + } +} ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/html-flow.js /** * @import { @@ -64040,6 +70983,7 @@ const htmlRawNames = ['pre', 'script', 'style', 'textarea'] + /** @type {Construct} */ const htmlFlow = { concrete: true, @@ -64053,10 +70997,6 @@ const blankLineBefore = { partial: true, tokenize: tokenizeBlankLineBefore }; -const nonLazyContinuationStart = { - partial: true, - tokenize: tokenizeNonLazyContinuationStart -}; /** @type {Resolver} */ function resolveToHtmlFlow(events) { @@ -64353,7 +71293,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { * @type {State} */ function completeClosingTagAfter(code) { - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return completeClosingTagAfter; } @@ -64394,7 +71334,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { effects.consume(code); return completeAttributeName; } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return completeAttributeNameBefore; } @@ -64442,7 +71382,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { effects.consume(code); return completeAttributeValueBefore; } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return completeAttributeNameAfter; } @@ -64471,7 +71411,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { markerB = code; return completeAttributeValueQuoted; } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return completeAttributeValueBefore; } @@ -64533,7 +71473,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { * @type {State} */ function completeAttributeValueQuotedAfter(code) { - if (code === 47 || code === 62 || micromark_util_character_markdownSpace(code)) { + if (code === 47 || code === 62 || markdownSpace(code)) { return completeAttributeNameBefore(code); } return nok(code); @@ -64573,7 +71513,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { // tokenizer.concrete = true return continuation(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return completeAfter; } @@ -64635,7 +71575,7 @@ function tokenizeHtmlFlow(effects, ok, nok) { * @type {State} */ function continuationStart(code) { - return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code); + return effects.check(partial_non_lazy_continuation_nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code); } /** @@ -64829,52 +71769,6 @@ function tokenizeHtmlFlow(effects, ok, nok) { } } -/** - * @this {TokenizeContext} - * Context. - * @type {Tokenizer} - */ -function tokenizeNonLazyContinuationStart(effects, ok, nok) { - const self = this; - return start; - - /** - * At eol, before continuation. - * - * ```markdown - * > | * ```js - * ^ - * | b - * ``` - * - * @type {State} - */ - function start(code) { - if (markdownLineEnding(code)) { - effects.enter("lineEnding"); - effects.consume(code); - effects.exit("lineEnding"); - return after; - } - return nok(code); - } - - /** - * A continuation. - * - * ```markdown - * | * ```js - * > | b - * ^ - * ``` - * - * @type {State} - */ - function after(code) { - return self.parser.lazy[self.now().line] ? nok(code) : ok(code); - } -} - /** * @this {TokenizeContext} * Context. @@ -64914,11 +71808,7 @@ function tokenizeBlankLineBefore(effects, ok, nok) { -/** @type {Construct} */ -const code_fenced_nonLazyContinuation = { - partial: true, - tokenize: code_fenced_tokenizeNonLazyContinuation -}; + /** @type {Construct} */ const codeFenced = { @@ -65006,7 +71896,7 @@ function tokenizeCodeFenced(effects, ok, nok) { return nok(code); } effects.exit("codeFencedFenceSequence"); - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code); + return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code); } /** @@ -65024,7 +71914,7 @@ function tokenizeCodeFenced(effects, ok, nok) { function infoBefore(code) { if (code === null || markdownLineEnding(code)) { effects.exit("codeFencedFence"); - return self.interrupt ? ok(code) : effects.check(code_fenced_nonLazyContinuation, atNonLazyBreak, after)(code); + return self.interrupt ? ok(code) : effects.check(partial_non_lazy_continuation_nonLazyContinuation, atNonLazyBreak, after)(code); } effects.enter("codeFencedFenceInfo"); effects.enter("chunkString", { @@ -65051,7 +71941,7 @@ function tokenizeCodeFenced(effects, ok, nok) { effects.exit("codeFencedFenceInfo"); return infoBefore(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.exit("chunkString"); effects.exit("codeFencedFenceInfo"); return factorySpace(effects, metaBefore, "whitespace")(code); @@ -65160,7 +72050,7 @@ function tokenizeCodeFenced(effects, ok, nok) { * @type {State} */ function contentStart(code) { - return initialPrefix > 0 && micromark_util_character_markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code); + return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code); } /** @@ -65177,7 +72067,7 @@ function tokenizeCodeFenced(effects, ok, nok) { */ function beforeContentChunk(code) { if (code === null || markdownLineEnding(code)) { - return effects.check(code_fenced_nonLazyContinuation, atNonLazyBreak, after)(code); + return effects.check(partial_non_lazy_continuation_nonLazyContinuation, atNonLazyBreak, after)(code); } effects.enter("codeFlowValue"); return contentChunk(code); @@ -65259,7 +72149,7 @@ function tokenizeCodeFenced(effects, ok, nok) { // To do: `enter` here or in next state? effects.enter("codeFencedFence"); - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code); + return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code); } /** @@ -65302,7 +72192,7 @@ function tokenizeCodeFenced(effects, ok, nok) { } if (size >= sizeOpen) { effects.exit("codeFencedFenceSequence"); - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code); + return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code); } return nok(code); } @@ -65328,40 +72218,6 @@ function tokenizeCodeFenced(effects, ok, nok) { } } } - -/** - * @this {TokenizeContext} - * Context. - * @type {Tokenizer} - */ -function code_fenced_tokenizeNonLazyContinuation(effects, ok, nok) { - const self = this; - return start; - - /** - * - * - * @type {State} - */ - function start(code) { - if (code === null) { - return nok(code); - } - effects.enter("lineEnding"); - effects.consume(code); - effects.exit("lineEnding"); - return lineStart; - } - - /** - * - * - * @type {State} - */ - function lineStart(code) { - return self.parser.lazy[self.now().line] ? nok(code) : ok(code); - } -} ;// CONCATENATED MODULE: ./node_modules/character-entities/index.js /** * Map of named character references. @@ -67869,8 +74725,6 @@ function resolveAllLabelEnd(events) { function resolveToLabelEnd(events, context) { let index = events.length; let offset = 0; - /** @type {Token} */ - let token; /** @type {number | undefined} */ let open; /** @type {number | undefined} */ @@ -67880,7 +74734,7 @@ function resolveToLabelEnd(events, context) { // Find an opening. while (index--) { - token = events[index][1]; + const token = events[index][1]; if (open) { // If we see another link, or inactive link label, we’ve been here before. if (token.type === "link" || token.type === "labelLink" && token._inactive) { @@ -67963,18 +74817,18 @@ function resolveToLabelEnd(events, context) { */ function tokenizeLabelEnd(effects, ok, nok) { const self = this; - let index = self.events.length; + const labelStarts = self._labelStarts; /** @type {Token} */ let labelStart; /** @type {boolean} */ let defined; - - // Find an opening. - while (index--) { - if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) { - labelStart = self.events[index][1]; - break; + if (labelStarts) { + // Discard ones that failed to close, + // they’re not needed anymore. + while (labelStarts.length > 0 && labelStarts[labelStarts.length - 1]._balanced) { + labelStarts.pop(); } + labelStart = labelStarts[labelStarts.length - 1]; } return start; @@ -68093,6 +74947,9 @@ function tokenizeLabelEnd(effects, ok, nok) { */ function labelEndOk(code) { // Note: `markdown-rs` does a bunch of stuff here. + // This label start is now used up: discard it so it’s never found again. + + labelStarts.pop(); return ok(code); } @@ -68366,6 +75223,7 @@ function tokenizeReferenceCollapsed(effects, ok, nok) { * @import { * Construct, * State, + * Token, * TokenizeContext, * Tokenizer * } from 'micromark-util-types' @@ -68387,6 +75245,8 @@ const labelStartImage = { */ function tokenizeLabelStartImage(effects, ok, nok) { const self = this; + /** @type {Token} */ + let labelImage; return start; /** @@ -68422,7 +75282,7 @@ function tokenizeLabelStartImage(effects, ok, nok) { effects.enter("labelMarker"); effects.consume(code); effects.exit("labelMarker"); - effects.exit("labelImage"); + labelImage = effects.exit("labelImage"); return after; } return nok(code); @@ -68460,8 +75320,13 @@ function tokenizeLabelStartImage(effects, ok, nok) { // `micromark-extension-gfm-footnote`, but the `label-start-link` // behavior isn’t. // Hidden footnotes hook. - /* c8 ignore next 3 */ - return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code); + /* c8 ignore next 6 */ + if (code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs) { + return nok(code); + } + self._labelStarts = self._labelStarts || []; + self._labelStarts.push(labelImage); + return ok(code); } } ;// CONCATENATED MODULE: ./node_modules/micromark-util-classify-character/index.js @@ -68525,22 +75390,8 @@ const attention = { // eslint-disable-next-line complexity function resolveAllAttention(events, context) { let index = -1; - /** @type {number} */ - let open; - /** @type {Token} */ - let group; - /** @type {Token} */ - let text; - /** @type {Token} */ - let openingSequence; - /** @type {Token} */ - let closingSequence; - /** @type {number} */ - let use; /** @type {Array} */ let nextEvents; - /** @type {number} */ - let offset; // Walk through all events. // @@ -68549,7 +75400,7 @@ function resolveAllAttention(events, context) { while (++index < events.length) { // Find a token that can close. if (events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close) { - open = index; + let open = index; // Now walk back to find an opener. while (open--) { @@ -68566,7 +75417,7 @@ function resolveAllAttention(events, context) { } // Number of markers to use from the sequence. - use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1; + const use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1; const start = { ...events[open][1].end }; @@ -68575,21 +75426,21 @@ function resolveAllAttention(events, context) { }; movePoint(start, -use); movePoint(end, use); - openingSequence = { + const openingSequence = { type: use > 1 ? "strongSequence" : "emphasisSequence", start, end: { ...events[open][1].end } }; - closingSequence = { + const closingSequence = { type: use > 1 ? "strongSequence" : "emphasisSequence", start: { ...events[index][1].start }, end }; - text = { + const text = { type: use > 1 ? "strongText" : "emphasisText", start: { ...events[open][1].end @@ -68598,7 +75449,7 @@ function resolveAllAttention(events, context) { ...events[index][1].start } }; - group = { + const group = { type: use > 1 ? "strong" : "emphasis", start: { ...openingSequence.start @@ -68631,12 +75482,13 @@ function resolveAllAttention(events, context) { // Closing. nextEvents = push(nextEvents, [['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context]]); + /** @type {number} */ + let offset = 0; + // If there are more markers in the closing, add them after. if (events[index][1].end.offset - events[index][1].start.offset) { offset = 2; nextEvents = push(nextEvents, [['enter', events[index][1], context], ['exit', events[index][1], context]]); - } else { - offset = 0; } splice(events, open - 1, index - open + 3, nextEvents); index = open + nextEvents.length - offset - 2; @@ -68708,8 +75560,11 @@ function tokenizeAttention(effects, ok) { // Always populated by defaults. - const open = !after || after === 2 && before || attentionMarkers.includes(code); - const close = !before || before === 2 && after || attentionMarkers.includes(previous); + // Note: `*` and `_` are in `attentionMarkers` through core. + // They are excluded here as the loosening is meant for markers registered + // by *other* constructs (such as GFM strikethrough’s `~`). + const open = !after || after === 2 && before || attentionMarkers.includes(code) && code !== 42 && code !== 95; + const close = !before || before === 2 && after || attentionMarkers.includes(previous) && previous !== 42 && previous !== 95; token._open = Boolean(marker === 42 ? open : open && (before || !close)); token._close = Boolean(marker === 42 ? close : close && (after || !open)); return ok(code); @@ -69361,7 +76216,7 @@ function tokenizeHtmlText(effects, ok, nok) { returnState = tagCloseBetween; return lineEndingBefore(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return tagCloseBetween; } @@ -69415,7 +76270,7 @@ function tokenizeHtmlText(effects, ok, nok) { returnState = tagOpenBetween; return lineEndingBefore(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return tagOpenBetween; } @@ -69461,7 +76316,7 @@ function tokenizeHtmlText(effects, ok, nok) { returnState = tagOpenAttributeNameAfter; return lineEndingBefore(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return tagOpenAttributeNameAfter; } @@ -69492,7 +76347,7 @@ function tokenizeHtmlText(effects, ok, nok) { returnState = tagOpenAttributeValueBefore; return lineEndingBefore(code); } - if (micromark_util_character_markdownSpace(code)) { + if (markdownSpace(code)) { effects.consume(code); return tagOpenAttributeValueBefore; } @@ -69625,7 +76480,7 @@ function tokenizeHtmlText(effects, ok, nok) { function lineEndingAfter(code) { // Always populated by defaults. - return micromark_util_character_markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code); + return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code); } /** @@ -69652,6 +76507,7 @@ function tokenizeHtmlText(effects, ok, nok) { * @import { * Construct, * State, + * Token, * TokenizeContext, * Tokenizer * } from 'micromark-util-types' @@ -69673,6 +76529,8 @@ const labelStartLink = { */ function tokenizeLabelStartLink(effects, ok, nok) { const self = this; + /** @type {Token} */ + let labelLink; return start; /** @@ -69690,7 +76548,7 @@ function tokenizeLabelStartLink(effects, ok, nok) { effects.enter("labelMarker"); effects.consume(code); effects.exit("labelMarker"); - effects.exit("labelLink"); + labelLink = effects.exit("labelLink"); return after; } @@ -69699,8 +76557,13 @@ function tokenizeLabelStartLink(effects, ok, nok) { // To do: this isn’t needed in `micromark-extension-gfm-footnote`, // remove. // Hidden footnotes hook. - /* c8 ignore next 3 */ - return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code); + /* c8 ignore next 6 */ + if (code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs) { + return nok(code); + } + self._labelStarts = self._labelStarts || []; + self._labelStarts.push(labelLink); + return ok(code); } } ;// CONCATENATED MODULE: ./node_modules/micromark-core-commonmark/lib/hard-break-escape.js @@ -70280,14 +77143,12 @@ function createTokenizer(parser, initialize, from) { * Nothing. */ function main() { - /** @type {number} */ - let chunkIndex; while (point._index < chunks.length) { const chunk = chunks[point._index]; // If we’re in a buffer chunk, loop through it. if (typeof chunk === 'string') { - chunkIndex = point._index; + const chunkIndex = point._index; if (point._bufferIndex < 0) { point._bufferIndex = 0; } @@ -70650,38 +77511,42 @@ function serializeChunks(chunks, expandTabs) { let value; if (typeof chunk === 'string') { value = chunk; - } else switch (chunk) { - case -5: - { - value = "\r"; - break; - } - case -4: - { - value = "\n"; - break; - } - case -3: - { - value = "\r" + "\n"; - break; - } - case -2: - { - value = expandTabs ? " " : "\t"; - break; - } - case -1: - { - if (!expandTabs && atTab) continue; - value = " "; - break; - } - default: - { - // Currently only replacement character. - value = String.fromCharCode(chunk); - } + } else { + switch (chunk) { + case -5: + { + value = "\r"; + break; + } + case -4: + { + value = "\n"; + break; + } + case -3: + { + value = "\r" + "\n"; + break; + } + case -2: + { + value = expandTabs ? " " : "\t"; + break; + } + case -1: + { + if (!expandTabs && atTab) { + continue; + } + value = " "; + break; + } + default: + { + // Currently only replacement character. + value = String.fromCharCode(chunk); + } + } } atTab = chunk === -2; result.push(value); @@ -70781,20 +77646,11 @@ function preprocess() { /** @type {Preprocessor} */ // eslint-disable-next-line complexity function preprocessor(value, encoding, end) { + value = buffer + (typeof value === 'string' ? value.toString() : new TextDecoder(encoding || undefined).decode(value)); + /** @type {Array} */ const chunks = []; - /** @type {RegExpMatchArray | null} */ - let match; - /** @type {number} */ - let next; - /** @type {number} */ - let startPosition; - /** @type {number} */ - let endPosition; - /** @type {Code} */ - let code; - value = buffer + (typeof value === 'string' ? value.toString() : new TextDecoder(encoding || undefined).decode(value)); - startPosition = 0; + let startPosition = 0; buffer = ''; if (start) { // To do: `markdown-rs` actually parses BOMs (byte order mark). @@ -70805,9 +77661,9 @@ function preprocess() { } while (startPosition < value.length) { search.lastIndex = startPosition; - match = search.exec(value); - endPosition = match && match.index !== undefined ? match.index : value.length; - code = value.charCodeAt(endPosition); + const match = search.exec(value); + const endPosition = match && match.index !== undefined ? match.index : value.length; + const code = value.charCodeAt(endPosition); if (!match) { buffer = value.slice(startPosition); break; @@ -70833,9 +77689,11 @@ function preprocess() { } case 9: { - next = Math.ceil(column / 4) * 4; + const next = Math.ceil(column / 4) * 4; chunks.push(-2); - while (column++ < next) chunks.push(-1); + while (column++ < next) { + chunks.push(-1); + } break; } case 10: @@ -70854,8 +77712,12 @@ function preprocess() { startPosition = endPosition + 1; } if (end) { - if (atCarriageReturn) chunks.push(-5); - if (buffer) chunks.push(buffer); + if (atCarriageReturn) { + chunks.push(-5); + } + if (buffer) { + chunks.push(buffer); + } chunks.push(null); } return chunks; @@ -70904,7 +77766,7 @@ var shared = __nccwpck_require__(3408); /** @typedef {import("micromark-util-types").Token} Token */ /** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */ /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ -/** @typedef {import("./micromark-types.d.mts")} */ +/** @typedef {typeof import("./micromark-types.d.mts")} _ambient_ */ /** * Gets a modified micromark-extension-directive without support for inline directives. @@ -71249,10 +78111,10 @@ const ignoredChildTypes = new Set( } const codeBlocks = params.config.code_blocks; const includeCodeBlocks = - (codeBlocks === undefined) ? true : !!codeBlocks; + (codeBlocks === undefined) || !!codeBlocks; const htmlElements = params.config.html_elements; const includeHtmlElements = - (htmlElements === undefined) ? true : !!htmlElements; + (htmlElements === undefined) || !!htmlElements; const scannedTypes = new Set([ "data" ]); if (includeCodeBlocks) { scannedTypes.add("codeFlowValue"); @@ -71493,9 +78355,7 @@ function fencedCodeBlockStyleFor(markup) { let expectedStyle = style; const codeFenceds = filterByTypesCached([ "codeFenced" ]); for (const codeFenced of codeFenceds) { - const codeFencedFenceSequence = - (0,micromark_helpers.getDescendantsByType)(codeFenced, [ "codeFencedFence", "codeFencedFenceSequence" ])[0]; - const { startLine, text } = codeFencedFenceSequence; + const { startLine, text } = (0,micromark_helpers.getDescendantsByType)(codeFenced, [ "codeFencedFence", "codeFencedFenceSequence" ])[0]; if (expectedStyle === "consistent") { expectedStyle = fencedCodeBlockStyleFor(text); } @@ -71636,7 +78496,7 @@ const impl = // Regular expression for identifying HTML anchor names const idRe = (0,helpers_helpers/* getHtmlAttributeRe */.Xi)("id"); const nameRe = (0,helpers_helpers/* getHtmlAttributeRe */.Xi)("name"); -const anchorRe = /\{(#[a-z\d]+(?:[-_][a-z\d]+)*)\}/gu; +const anchorRe = /\{(#[a-z\d]+(?:[-_]+[a-z\d]+)*)\}/gu; const lineFragmentRe = /^#(?:L\d+(?:C\d+)?-L\d+(?:C\d+)?|L\d+)$/; // Sets for filtering heading tokens during conversion @@ -71646,8 +78506,7 @@ const tokensInclude = new Set( ); /** - * Converts a Markdown heading into an HTML fragment according to the rules - * used by GitHub. + * Converts a Markdown heading into an HTML fragment according to the rules used by GitHub. * * @param {import("markdownlint").MicromarkToken} headingText Heading text token. * @returns {string} Fragment string for heading. @@ -72036,8 +78895,9 @@ const autolinkAble = (/** @type {string} */ destination) => { + /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ -/** @typedef {import("micromark-extension-gfm-table")} */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */ const whitespaceTypes = new Set([ "linePrefix", "whitespace" ]); const ignoreWhitespace = (/** @type {MicromarkToken[]} */ tokens) => tokens.filter( @@ -72060,8 +78920,17 @@ const makeRange = (/** @type {number} */ start, /** @type {number} */ end) => [ ((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only")); let expectedTrailingPipe = ((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only")); + let currentTable = null; const rows = filterByTypesCached([ "tableDelimiterRow", "tableRow" ]); for (const row of rows) { + if (style === "per_table") { + // Reset style for each new table + const rowTable = (0,micromark_helpers.getParentOfType)(row, [ "table" ]); + if (rowTable !== currentTable) { + expectedStyle = "consistent"; + currentTable = rowTable; + } + } // The following uses of first/lastOrNothing lack fallback handling // because it seems not to be possible (i.e., 0% coverage) const firstCell = firstOrNothing(row.children); @@ -72113,7 +78982,7 @@ const makeRange = (/** @type {number} */ start, /** @type {number} */ end) => [ const md056_makeRange = (/** @type {number} */ start, /** @type {number} */ end) => [ start, end - start + 1 ]; -/** @typedef {import("micromark-extension-gfm-table")} */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */ /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md056 = ({ @@ -72163,7 +79032,7 @@ const md056_makeRange = (/** @type {number} */ start, /** @type {number} */ end) -/** @typedef {import("micromark-extension-gfm-table")} */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */ /** @type {import("markdownlint").Rule} */ /* harmony default export */ const md058 = ({ @@ -72535,21 +79404,20 @@ function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) { Logic: - Segment graphemes to match how terminals render clusters. - Width rules: - 1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design. + 1. Skip non-printing clusters (Default_Ignorable, Control, pure nonspacing/enclosing Mark, lone Surrogates). Tabs are ignored by design. 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width. 3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width. 4. Hangul jamo collapse each standard modern Hangul L+V or L+V+T syllable piece to width 2. Unmatched repeated leading/vowel/trailing jamo stay additive because that matches how the terminals we target render them. - 5. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark). + 5. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing spacing marks and Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark). */ const segmenter = new Intl.Segmenter(); -// Whole-cluster zero-width -const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v; - -// Pick the base scalar if the cluster starts with Prepend/Format/Marks -const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v; +// Matches a visible (printing) character. Used to find the base scalar of a cluster (skipping leading Prepend/Format/Marks) and to detect whole-cluster zero-width. +// Intentionally a single negated class without a quantifier: a repeated pattern like `^(?:…|…)+$` backtracks exponentially on overlapping properties, and even `^[…]+$` overflows V8's backtrack stack (RangeError) on clusters with millions of marks. +const visibleCharacterRegex = /[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v; +const spacingMarkRegex = /\p{Spacing_Mark}/v; // RGI emoji sequences const rgiEmojiRegex = /^\p{RGI_Emoji}$/v; @@ -72577,12 +79445,10 @@ function isDoubleWidthNonRgiEmojiSequence(segment) { return false; } +// Returns the cluster starting at its first visible character, or `undefined` if the whole cluster is zero-width. function baseVisible(segment) { - return segment.replace(leadingNonPrintingRegex, ''); -} - -function isZeroWidthCluster(segment) { - return zeroWidthClusterRegex.test(segment); + const index = segment.search(visibleCharacterRegex); + return index === -1 ? undefined : segment.slice(index); } function isHangulLeadingJamo(codePoint) { @@ -72610,7 +79476,7 @@ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) { const codePoints = []; for (const character of visibleSegment) { - if (zeroWidthClusterRegex.test(character)) { + if (!visibleCharacterRegex.test(character)) { continue; } @@ -72655,7 +79521,7 @@ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) { return width; } -function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) { +function trailingWidth(visibleSegment, eastAsianWidthOptions) { let extra = 0; let first = true; @@ -72665,7 +79531,10 @@ function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) { continue; } - if (character >= '\uFF00' && character <= '\uFFEF') { + if ( + spacingMarkRegex.test(character) + || (character >= '\uFF00' && character <= '\uFFEF') + ) { extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions); } } @@ -72704,7 +79573,8 @@ function stringWidth(input, options = {}) { for (const {segment} of segmenter.segment(string)) { // Zero-width / non-printing clusters - if (isZeroWidthCluster(segment)) { + const visibleSegment = baseVisible(segment); + if (visibleSegment === undefined) { continue; } @@ -72714,7 +79584,6 @@ function stringWidth(input, options = {}) { continue; } - const visibleSegment = baseVisible(segment); const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions); if (hangulWidth !== undefined) { width += hangulWidth; @@ -72725,8 +79594,8 @@ function stringWidth(input, options = {}) { const codePoint = visibleSegment.codePointAt(0); width += eastAsianWidth(codePoint, eastAsianWidthOptions); - // Add width for trailing Halfwidth and Fullwidth Forms (e.g., ゙, ゚, ー) - width += trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions); + // Add width for trailing spacing marks and Halfwidth/Fullwidth Forms (e.g., ゙, ゚, ー) + width += trailingWidth(visibleSegment, eastAsianWidthOptions); } return width; @@ -72739,21 +79608,35 @@ function stringWidth(input, options = {}) { -/** @typedef {import("micromark-extension-gfm-table")} */ +/** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */ /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ /** @typedef {import("markdownlint").RuleOnErrorInfo} RuleOnErrorInfo */ /** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ +// Regular expression to match text that could represent an unordered list item prefix +const unorderedListPrefix = /^[>\s]*[-+*]$/; + /** * Adds a RuleOnErrorInfo object to a list of RuleOnErrorInfo objects. * * @param {RuleOnErrorInfo[]} errors List of errors. + * @param {readonly string[]} lines File/string lines. * @param {number} lineNumber Line number. * @param {number} column Column number. * @param {string} detail Detail message. * @param {RuleOnErrorFixInfo} [fixInfo] Fix information. + * @returns {void} */ -function md060_addError(errors, lineNumber, column, detail, fixInfo) { +function md060_addError(errors, lines, lineNumber, column, detail, fixInfo) { + if ( + fixInfo && + (fixInfo.insertText === " ") && + fixInfo.editColumn && + unorderedListPrefix.test(lines[lineNumber - 1].slice(0, fixInfo.editColumn - 1)) + ) { + // Do not apply edits that would change a table cell into an unordered list item + fixInfo = undefined; + } errors.push({ lineNumber, detail, @@ -72805,7 +79688,7 @@ function checkStyleAligned(lines, rows, detail) { const rowDividerColumns = getTableDividerColumns(lines, row); for (const dividerColumn of rowDividerColumns) { if ((remainingHeaderDividerColumns.size > 0) && !remainingHeaderDividerColumns.delete(dividerColumn.effective)) { - md060_addError(errorInfos, row.startLine, dividerColumn.actual, detail); + md060_addError(errorInfos, lines, row.startLine, dividerColumn.actual, detail); } } } @@ -72863,6 +79746,7 @@ function checkStyleAligned(lines, rows, detail) { if (previous.text.length !== 1) { md060_addError( errorsIfCompact, + lines, startLine, startColumn, "Table pipe has extra space to the left for style \"compact\"", @@ -72871,6 +79755,7 @@ function checkStyleAligned(lines, rows, detail) { } md060_addError( errorsIfTight, + lines, startLine, startColumn, "Table pipe has space to the left for style \"tight\"", @@ -72879,6 +79764,7 @@ function checkStyleAligned(lines, rows, detail) { } else { md060_addError( errorsIfCompact, + lines, startLine, startColumn, "Table pipe is missing space to the left for style \"compact\"", @@ -72893,6 +79779,7 @@ function checkStyleAligned(lines, rows, detail) { if (next.text.length !== 1) { md060_addError( errorsIfCompact, + lines, startLine, startColumn, "Table pipe has extra space to the right for style \"compact\"", @@ -72901,6 +79788,7 @@ function checkStyleAligned(lines, rows, detail) { } md060_addError( errorsIfTight, + lines, startLine, startColumn, "Table pipe has space to the right for style \"tight\"", @@ -72910,6 +79798,7 @@ function checkStyleAligned(lines, rows, detail) { } else { md060_addError( errorsIfCompact, + lines, startLine, startColumn, "Table pipe is missing space to the right for style \"compact\"", @@ -72926,7 +79815,7 @@ function checkStyleAligned(lines, rows, detail) { let errorInfos = errorsIfAligned; if ( styleCompactAllowed && - ((errorsIfCompact.length < errorInfos.length) || !styleAlignedAllowed) + (!styleAlignedAllowed || (errorsIfCompact.length < errorInfos.length)) ) { errorInfos = errorsIfCompact; } @@ -73130,6 +80019,7 @@ function parse_configuration_parseConfiguration(name, content, parsers) { + /** * Validate the list of rules for structure and reuse. * @@ -73195,7 +80085,7 @@ function validateRuleList(ruleList, synchronous) { ) { result = newError("asynchronous", rule.asynchronous); } - if (!result && rule.asynchronous && synchronous) { + if (!result && synchronous && rule.asynchronous) { result = new Error( "Custom rule " + rule.names.join("/") + " at index " + customIndex + " is asynchronous and can not be used in a synchronous context." @@ -73236,14 +80126,15 @@ function validateRuleList(ruleList, synchronous) { * Remove front matter (if present at beginning of content). * * @param {string} content Markdown content. - * @param {RegExp | null} frontMatter Regular expression to match front matter. + * @param {RE2JS | null} frontMatterRe2 Regular expression to match front matter. * @returns {RemoveFrontMatterResult} Trimmed content and front matter lines. */ -function removeFrontMatter(content, frontMatter) { +function removeFrontMatter(content, frontMatterRe2) { /** @type {string[]} */ let frontMatterLines = []; - if (frontMatter) { - const frontMatterMatch = content.match(frontMatter); + if (frontMatterRe2) { + const frontMatterMatch = frontMatterRe2.exec(content); + // @ts-ignore if (frontMatterMatch && !frontMatterMatch.index) { const contentMatched = frontMatterMatch[0]; content = content.slice(contentMatched.length); @@ -73318,7 +80209,7 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) { let ruleDefaultEnable = true; /** @type {"error" | "warning"} */ let ruleDefaultSeverity = "error"; - // eslint-disable-next-line unicorn/no-unused-array-method-return + // eslint-disable-next-line unicorn/no-unused-builtin-method-return Object.entries(config).every(([ key, value ]) => { if (key.toUpperCase() === "DEFAULT") { ruleDefaultEnable = !!value; @@ -73355,7 +80246,7 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) { if (value instanceof Object) { /** @type {{ enabled?: boolean, severity?: "error" | "warning" }} */ const valueObject = value; - enabled = (valueObject.enabled === undefined) ? true : !!valueObject.enabled; + enabled = (valueObject.enabled === undefined) || !!valueObject.enabled; severity = (valueObject.severity === "warning") ? "warning" : "error"; effectiveValue = Object.fromEntries( Object.entries(value).filter( @@ -73396,7 +80287,6 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) { * * @param {Rule[]} ruleList List of rules. * @param {string[]} lines List of content lines. - * @param {string[]} frontMatterLines List of front matter lines. * @param {boolean} noInlineConfig Whether to allow inline configuration. * @param {Configuration} config Configuration object. * @param {ConfigurationParser[] | undefined} configParsers Configuration parsers. @@ -73406,7 +80296,6 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) { function getEnabledRulesPerLineNumber( ruleList, lines, - frontMatterLines, noInlineConfig, config, configParsers, @@ -73416,7 +80305,7 @@ function getEnabledRulesPerLineNumber( let enabledRules = new Map(); /** @type {Map} */ let capturedRules = enabledRules; - const enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length); + const enabledRulesPerLineNumber = new Array(1); // Helper functions // eslint-disable-next-line jsdoc/require-jsdoc function handleInlineConfig(/** @type {string[]} */ input, /** @type {(act: string, par: string, ind: number) => void} */ forEachMatch, /** @type {(() => void)|undefined} */ forEachLine = undefined) { @@ -73492,8 +80381,7 @@ function getEnabledRulesPerLineNumber( const disableLine = (action === "DISABLE-LINE"); const disableNextLine = (action === "DISABLE-NEXT-LINE"); if (disableLine || disableNextLine) { - const nextLineNumber = - frontMatterLines.length + lineNumber + (disableNextLine ? 1 : 0); + const nextLineNumber = lineNumber + (disableNextLine ? 1 : 0); enabledRulesPerLineNumber[nextLineNumber] = applyEnableDisable( action, @@ -73535,7 +80423,7 @@ function getEnabledRulesPerLineNumber( * @param {MarkdownItFactory} markdownItFactory Function to create a markdown-it parser. * @param {Configuration} config Configuration object. * @param {ConfigurationParser[] | undefined} configParsers Configuration parsers. - * @param {RegExp | null} frontMatter Regular expression for front matter. + * @param {RE2JS | null} frontMatterRe2 Regular expression for front matter. * @param {boolean} handleRuleFailures Whether to handle exceptions in rules. * @param {boolean} noInlineConfig Whether to allow inline configuration. * @param {boolean} synchronous Whether to execute synchronously. @@ -73550,7 +80438,7 @@ function lintContent( markdownItFactory, config, configParsers, - frontMatter, + frontMatterRe2, handleRuleFailures, noInlineConfig, synchronous, @@ -73560,17 +80448,16 @@ function lintContent( const callbackError = (/** @type {any} */ error) => callback(error instanceof Error ? error : new Error(error)); // Remove UTF-8 byte order marker (if present) // eslint-disable-next-line unicorn/prefer-unicode-code-point-escapes - content = content.replace(/^\uFEFF/, ""); + const fullContent = content.replace(/^\uFEFF/, ""); + const fullContentLines = fullContent.split(helpers_helpers/* newLineRe */.Or); + const fullContentNormalized = fullContentLines.join("\n"); // Remove front matter - const removeFrontMatterResult = removeFrontMatter(content, frontMatter); - const { frontMatterLines } = removeFrontMatterResult; - content = removeFrontMatterResult.content; + const { "content": markdownContentNormalized, frontMatterLines } = removeFrontMatter(fullContentNormalized, frontMatterRe2); // Get enabled rules per line (with HTML comments present) const { effectiveConfig, enabledRulesPerLineNumber, enabledRuleList, rulesSeverity } = getEnabledRulesPerLineNumber( ruleList, - content.split(helpers_helpers/* newLineRe */.Or), - frontMatterLines, + fullContentLines, noInlineConfig, config, configParsers, @@ -73585,13 +80472,12 @@ function lintContent( const customRulesPresent = (ruleList.length !== lib_rules.length); // Parse content into parser tokens const micromarkTokens = needMicromarkTokens ? - micromark_parse_parse(content, { "freezeTokens": customRulesPresent }) : + micromark_parse_parse(markdownContentNormalized, { "freezeTokens": customRulesPresent }) : []; // Hide the content of HTML comments from rules - const preClearedContent = content; - content = helpers_helpers/* clearHtmlCommentText */.X6(content); + const markdownContentNormalizedSanitized = helpers_helpers/* clearHtmlCommentText */.X6(markdownContentNormalized); // Parse content into lines and get markdown-it tokens - const lines = content.split(helpers_helpers/* newLineRe */.Or); + const lines = markdownContentNormalizedSanitized.split(helpers_helpers/* newLineRe */.Or); // Function to run after fetching markdown-it tokens (when needed) const lintContentInternal = (/** @type {MarkdownItToken[]} */ markdownitTokens) => { // Create (frozen) parameters for rules @@ -73658,37 +80544,45 @@ function lintContent( } // eslint-disable-next-line jsdoc/require-jsdoc function onError(/** @type {RuleOnErrorInfo} */ errorInfo) { - if (!errorInfo || - !helpers_helpers/* isNumber */.Et(errorInfo.lineNumber) || + if (!errorInfo) { + throwError("onErrorInfo"); + } + if ((errorInfo.frontMatter !== undefined) && + !helpers_helpers/* isBoolean */.Lm(errorInfo.frontMatter)) { + throwError("frontMatter"); + } + const useFrontMatter = Boolean(errorInfo.frontMatter); + const contentLines = useFrontMatter ? frontMatterLines : lines; + const lineOffset = useFrontMatter ? 0 : frontMatterLines.length; + if (!helpers_helpers/* isNumber */.Et(errorInfo.lineNumber) || (errorInfo.lineNumber < 1) || - (errorInfo.lineNumber > lines.length)) { + (errorInfo.lineNumber > contentLines.length)) { throwError("lineNumber"); } - const lineNumber = errorInfo.lineNumber + frontMatterLines.length; + const lineNumber = errorInfo.lineNumber + lineOffset; if (!enabledRulesPerLineNumber[lineNumber].get(ruleName)) { return; } - if (errorInfo.detail && + if ((errorInfo.detail !== undefined) && !helpers_helpers/* isString */.Kg(errorInfo.detail)) { throwError("detail"); } - if (errorInfo.context && + if ((errorInfo.context !== undefined) && !helpers_helpers/* isString */.Kg(errorInfo.context)) { throwError("context"); } - if (errorInfo.information && + if ((errorInfo.information !== undefined) && !helpers_helpers/* isUrl */.gU(errorInfo.information)) { throwError("information"); } - if (errorInfo.range && + if ((errorInfo.range !== undefined) && (!Array.isArray(errorInfo.range) || (errorInfo.range.length !== 2) || !helpers_helpers/* isNumber */.Et(errorInfo.range[0]) || (errorInfo.range[0] < 1) || !helpers_helpers/* isNumber */.Et(errorInfo.range[1]) || (errorInfo.range[1] < 1) || - ((errorInfo.range[0] + errorInfo.range[1] - 1) > - lines[errorInfo.lineNumber - 1].length))) { + ((errorInfo.range[0] + errorInfo.range[1] - 1) > contentLines[errorInfo.lineNumber - 1].length))) { throwError("range"); } const fixInfo = errorInfo.fixInfo; @@ -73700,18 +80594,16 @@ function lintContent( if (fixInfo.lineNumber !== undefined) { if ((!helpers_helpers/* isNumber */.Et(fixInfo.lineNumber) || (fixInfo.lineNumber < 1) || - (fixInfo.lineNumber > lines.length))) { + (fixInfo.lineNumber > contentLines.length))) { throwError("fixInfo.lineNumber"); } - cleanFixInfo.lineNumber = - fixInfo.lineNumber + frontMatterLines.length; + cleanFixInfo.lineNumber = fixInfo.lineNumber + lineOffset; } const effectiveLineNumber = fixInfo.lineNumber || errorInfo.lineNumber; if (fixInfo.editColumn !== undefined) { if ((!helpers_helpers/* isNumber */.Et(fixInfo.editColumn) || (fixInfo.editColumn < 1) || - (fixInfo.editColumn > - lines[effectiveLineNumber - 1].length + 1))) { + (fixInfo.editColumn > contentLines[effectiveLineNumber - 1].length + 1))) { throwError("fixInfo.editColumn"); } cleanFixInfo.editColumn = fixInfo.editColumn; @@ -73719,8 +80611,7 @@ function lintContent( if (fixInfo.deleteCount !== undefined) { if ((!helpers_helpers/* isNumber */.Et(fixInfo.deleteCount) || (fixInfo.deleteCount < -1) || - (fixInfo.deleteCount > - lines[effectiveLineNumber - 1].length))) { + (((fixInfo.editColumn ?? 1) + fixInfo.deleteCount - 1) > contentLines[effectiveLineNumber - 1].length))) { throwError("fixInfo.deleteCount"); } cleanFixInfo.deleteCount = fixInfo.deleteCount; @@ -73807,7 +80698,7 @@ function lintContent( if (!needMarkdownItTokens || synchronous) { // Need/able to call into markdown-it and lintContentInternal synchronously const markdownItTokens = needMarkdownItTokens ? - (0,defer_require.requireMarkdownItCjs)().getMarkdownItTokens(markdownItFactory(), preClearedContent, lines) : + (0,defer_require.requireMarkdownItCjs)().getMarkdownItTokens(markdownItFactory(), markdownContentNormalized, lines) : []; lintContentInternal(markdownItTokens); } else { @@ -73818,7 +80709,7 @@ function lintContent( // eslint-disable-next-line no-promise-executor-return new Promise((resolve) => resolve(markdownItFactory())) ]).then(([ markdownitCjs, markdownIt ]) => { - const markdownItTokens = markdownitCjs.getMarkdownItTokens(markdownIt, preClearedContent, lines); + const markdownItTokens = markdownitCjs.getMarkdownItTokens(markdownIt, markdownContentNormalized, lines); lintContentInternal(markdownItTokens); }).catch(callbackError); } @@ -73833,7 +80724,7 @@ function lintContent( * @param {MarkdownItFactory} markdownItFactory Function to create a markdown-it parser. * @param {Configuration} config Configuration object. * @param {ConfigurationParser[] | undefined} configParsers Configuration parsers. - * @param {RegExp | null} frontMatter Regular expression for front matter. + * @param {RE2JS | null} frontMatterRe2 Regular expression for front matter. * @param {boolean} handleRuleFailures Whether to handle exceptions in rules. * @param {boolean} noInlineConfig Whether to allow inline configuration. * @param {FsLike} fs File system implementation. @@ -73848,7 +80739,7 @@ function lintFile( markdownItFactory, config, configParsers, - frontMatter, + frontMatterRe2, handleRuleFailures, noInlineConfig, fs, @@ -73856,23 +80747,22 @@ function lintFile( callback) { // eslint-disable-next-line jsdoc/require-jsdoc function lintContentWrapper(/** @type {Error | null} */ err, /** @type {string} */ content) { - if (err) { - return callback(err); - } - return lintContent( - ruleList, - aliasToRuleNames, - file, - content, - markdownItFactory, - config, - configParsers, - frontMatter, - handleRuleFailures, - noInlineConfig, - synchronous, - callback - ); + return err ? + callback(err) : + lintContent( + ruleList, + aliasToRuleNames, + file, + content, + markdownItFactory, + config, + configParsers, + frontMatterRe2, + handleRuleFailures, + noInlineConfig, + synchronous, + callback + ); } // Make a/synchronous call to read file if (synchronous) { @@ -73926,9 +80816,8 @@ function lintInput(options, synchronous, callback) { const stringsKeys = Object.keys(strings); const config = options.config || { "default": true }; const configParsers = options.configParsers || undefined; - const frontMatter = (options.frontMatter === undefined) ? - helpers_helpers/* frontMatterRe */.Q9 : - options.frontMatter; + const frontMatterRe = (options.frontMatter === undefined) ? helpers_helpers/* frontMatterRe */.Q9 : options.frontMatter; + const frontMatterRe2 = frontMatterRe && RE2JS.compile(RE2JS.translateRegExp(frontMatterRe)); const handleRuleFailures = !!options.handleRuleFailures; const noInlineConfig = !!options.noInlineConfig; const markdownItFactory = @@ -73971,7 +80860,7 @@ function lintInput(options, synchronous, callback) { markdownItFactory, config, configParsers, - frontMatter, + frontMatterRe2, handleRuleFailures, noInlineConfig, fs, @@ -73989,7 +80878,7 @@ function lintInput(options, synchronous, callback) { markdownItFactory, config, configParsers, - frontMatter, + frontMatterRe2, handleRuleFailures, noInlineConfig, synchronous, @@ -74148,8 +81037,8 @@ function resolveConfigExtendsSync(configFile, referenceId, fs) { */ function extendConfig(config, file, parsers, fs, callback) { const configExtends = config.extends; - if (configExtends) { - return resolveConfigExtends( + return configExtends ? + resolveConfigExtends( file, helpers_helpers/* expandTildePath */.ww(configExtends, node_imports_node_os), fs, @@ -74171,9 +81060,8 @@ function extendConfig(config, file, parsers, fs, callback) { return callback(null, result); } ) - ); - } - return callback(null, config); + ) : + callback(null, config); } /** @@ -74233,13 +81121,11 @@ function readConfigAsync(file, parsers, fs, callback) { // Try to parse file // @ts-ignore const { config, message } = parse_configuration_parseConfiguration(file, content, parsers); - if (!config) { + return config ? // @ts-ignore - return callback(new Error(message)); - } - // Extend configuration - // @ts-ignore - return extendConfig(config, file, parsers, fsLike, callback); + extendConfig(config, file, parsers, fsLike, callback) : + // @ts-ignore + callback(new Error(message)); }); } @@ -74530,6 +81416,7 @@ function getVersion() { * Fix information for RuleOnError callback. * * @typedef {Object} RuleOnErrorInfo + * @property {boolean} [frontMatter] True if applies to front matter. * @property {number} lineNumber Line number (1-based). * @property {string} [detail] Detail about the error. * @property {string} [context] Context for the error. @@ -74570,12 +81457,7 @@ function getVersion() { * @returns {MarkdownItBaseToken[]} Tokens. */ -/** - * Instance of the markdown-it parser. - * - * @typedef MarkdownIt - * @property {MarkdownItParse} parse Method to parse input. - */ +/** @typedef {import("markdown-it").MarkdownIt} MarkdownIt */ /** * Gets an instance of the markdown-it parser. Any plugins should already have been loaded. @@ -74609,7 +81491,7 @@ function getVersion() { /** * Lint results. * - * @typedef {Object.} LintResults + * @typedef {{[k: string]: LintError[]}} LintResults */ /** @@ -74783,7 +81665,7 @@ const appendToArray = (destination, source) => { // @ts-check const packageName = "markdownlint-cli2"; -const packageVersion = "0.23.3"; +const packageVersion = "0.24.0"; const libraryName = "markdownlint"; @@ -74898,6 +81780,228 @@ const jsoncParse = (text) => { /* harmony default export */ const jsonc_parse = (jsoncParse); +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +function getLineColFromPtr(string, ptr) { + let lines = string.slice(0, ptr).split(/\r?\n/); + return [lines.length, lines.pop().length + 1]; +} +function makeCodeBlock(string, line, column) { + let lines = string.split(/\r?\n/); + let codeblock = ''; + let numberLen = (Math.log10(line + 1) | 0) + 1; + for (let i = line - 1; i <= line + 1; i++) { + let l = lines[i - 1]; + if (!l) + continue; + codeblock += i.toString().padEnd(numberLen, ' '); + codeblock += ': '; + codeblock += l; + codeblock += '\n'; + if (i === line) { + codeblock += ' '.repeat(numberLen + column + 2); + codeblock += '^\n'; + } + } + return codeblock; +} +class TomlError extends Error { + line; + column; + codeblock; + constructor(message, options) { + const [line, column] = getLineColFromPtr(options.toml, options.ptr); + const codeblock = makeCodeBlock(options.toml, line, column); + super(`Invalid TOML document: ${message}\n\n${codeblock}`, options); + this.line = line; + this.column = column; + this.codeblock = codeblock; + } + /** @internal */ + static x(message, ctx, ptr) { + throw new TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p }); + } +} + +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/primitive.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** @internal */ +function parseString(ctx) { + let startPtr = ctx.p; + let c = ctx.s.charCodeAt(ctx.p++); + let first = c; + let isLiteral = c === 0x27; /* ' */ + let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1); + if (isMultiline) { + // Trim initial newline + if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 0xa /* \n */) + ctx.p++; + else if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */) + ctx.p += 2; + } + // For the record: it is not worth it to use a fast-path for literal strings using `indexOf`. + // Doing a char-by-char iteration ends up dispatching less instructions, for the same wall-clock runtime. + let parsed = ''; + let sliceStart = ctx.p; + // states: + // 0 - decoding + // 1 - decoding escape + // 2 - whitespace escape (no newline encountered yet, must fail on non-whitespace) + // 3 - whitespace escape (newline encountered, allowed to transition back to normal decode) + let state = 0; + for (; ctx.p < ctx.s.length; ctx.p++) { + c = ctx.s.charCodeAt(ctx.p); + // Deal with newlines first, since that simplifies control character checking and handling across all states + if (isMultiline && (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))) { + state = state && 3; + } + // Control characters are banned in TOML, so we throw an error if we encounter them + else if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) { + TomlError.x('control characters are not allowed in strings', ctx); + } + // The string might terminate while we're parsing through a newline escape. + // It must have encountered a newline; otherwise, it'll simply fail in another branch. + else if ((!state || state === 3) && c === first && (!isMultiline || (ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first))) { + if (isMultiline) { + // If the string ends with 4-5 quotes, then the first 1-2 are part of the string + if (ctx.s.charCodeAt(ctx.p + 3) === first) + ctx.p++; + if (ctx.s.charCodeAt(ctx.p + 3) === first) + ctx.p++; + } + // If we're in a newline escape still, then there's nothing to add. + if (!state) { + // Avoid a useless concat operation if the string can be used as-is. + let s = ctx.s.slice(sliceStart, ctx.p); + parsed = parsed ? parsed + s : s; + } + ctx.p += isMultiline ? 3 : 1; + return parsed; + } + // Baseline state; keep moving forward unless an escape sequence starts + else if (!state) { + if (!isLiteral && c === 0x5c /* \ */) { + parsed += ctx.s.slice(sliceStart, (sliceStart = ctx.p)); + state = 1; + } + } + else if (state === 1) { + if (c === 0x78 /* x */ || c === 0x75 /* u */ || c === 0x55 /* U */) { // Unicode escape + let errPtr = ctx.p++ - 1; + let value = 0; + let len = c === 0x78 /* x */ ? 2 : c === 0x75 /* u */ ? 4 : 8; + for (let j = 0; j < len; j++, ctx.p++) { + let hex = ctx.s.charCodeAt(ctx.p); + let digit = + /* 0-9 */ hex >= 0x30 && hex <= 0x39 ? hex - 0x30 : + /* A-F */ hex >= 0x41 && hex <= 0x46 ? hex - 0x41 + 10 : + /* a-f */ hex >= 0x61 && hex <= 0x66 ? hex - 0x61 + 10 : -1; + if (digit < 0) + TomlError.x('invalid non-hex character in unicode escape', ctx); + value = (value << 4) | digit; + } + // Because JS does bitwise on signed 32bit integers, all 0xfzzzzzzz values are actually seen as negative + if (value < 0 || value > 0x10ffff || (value >= 0xd800 && value <= 0xdfff)) { + TomlError.x('invalid unicode escape', ctx, errPtr); + } + parsed += String.fromCodePoint(value); + sliceStart = ctx.p--; + state = 0; + } + // Newline escape sequence. We only need to care about spaces and tabs; newlines are dealt with earlier + else if (isMultiline && (c === 0x20 || c === 0x9 /* \t */)) { + state = 2; + } + // Basic escape sequence + else { + if (c === 0x62 /* b */) + parsed += '\b'; + else if (c === 0x74 /* t */) + parsed += '\t'; + else if (c === 0x6e /* n */) + parsed += '\n'; + else if (c === 0x66 /* f */) + parsed += '\f'; + else if (c === 0x72 /* r */) + parsed += '\r'; + else if (c === 0x65 /* e */) + parsed += '\x1b'; + else if (c === 0x22 /* " */) + parsed += '"'; + else if (c === 0x5c /* \ */) + parsed += '\\'; + else + TomlError.x('unrecognised escape sequence', ctx); + sliceStart = ctx.p + 1; + state = 0; + } + } + // Newline escape continuation: keep moving forward until the first non-whitespace char + else if (c !== 0x20 && c !== 0x9 /* \t */) { + if (state === 2) + TomlError.x('invalid escape: only line-ending whitespace may be escaped', ctx, sliceStart); + // State cannot be zero, or we'd have branched earlier already. + // If it's a backslash, immediately transition to the escape state so it can be processed. + state = !isLiteral && c === 0x5c /* \ */ ? 1 : 0; + sliceStart = ctx.p; + } + } + TomlError.x('unfinished string', ctx, startPtr); +} + ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/date.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -74926,39 +82030,68 @@ const jsoncParse = (text) => { * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i; +let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i; class TomlDate extends Date { #hasDate = false; #hasTime = false; #offset = null; - constructor(date) { + constructor(date, fasttype, unsafeDelim) { let hasDate = true; let hasTime = true; let offset = 'Z'; + let c; if (typeof date === 'string') { - let match = date.match(DATE_TIME_RE); - if (match) { - if (!match[1]) { - hasDate = false; - date = `0000-01-01T${date}`; + if (fasttype) + prep: { + // Date-time + if (fasttype < 3) { + if (+date.slice(11, 13) > 23) { + date = ''; + break prep; + } + // Local + if (fasttype === 2) { + offset = null; + date += 'Z'; + } + // Offset; keep track of offset if not Z + else if ((c = date.charCodeAt(date.length - 1)) !== 0x5a /* Z */ && c !== 0x7a /* z */) { + offset = date.slice(date.length - 6); + } + if (unsafeDelim) + date = date.slice(0, 10) + 'T' + date.slice(11); + } + // Time + else if (fasttype === 4) { + date = +date.slice(0, 2) > 23 ? '' : `0000-01-01T${date}Z`; + } + hasDate = fasttype !== 4; + hasTime = fasttype !== 3; } - hasTime = !!match[2]; - // Make sure to use T instead of a space. Breaks in case of extreme values otherwise. - hasTime && date[10] === ' ' && (date = date.replace(' ', 'T')); - // Do not allow rollover hours. - if (match[2] && +match[2] > 23) { - date = ''; + else { + let match = date.match(DATE_TIME_RE); + if (match) { + if (!match[1]) { + hasDate = false; + date = `0000-01-01T${date}`; + } + hasTime = !!match[2]; + // Make sure to use T instead of a space. Breaks in case of extreme values otherwise. + hasTime && date[10] === ' ' && (date = date.replace(' ', 'T')); + // Do not allow rollover hours. + if (match[2] && +match[2] > 23) { + date = ''; + } + else { + offset = match[3] || null; + if (!offset && hasTime) + date += 'Z'; + } } else { - offset = match[3] || null; - date = date.toUpperCase(); - if (!offset && hasTime) - date += 'Z'; + date = ''; } } - else { - date = ''; - } } super(date); if (!isNaN(this.getTime())) { @@ -74994,7 +82127,7 @@ class TomlDate extends Date { if (this.#offset === null) return iso.slice(0, -1); // Offset DateTime - if (this.#offset === 'Z') + if (this.#offset === 'Z' || this.#offset === 'z') return iso; // This part is quite annoying: JS strips the original timezone from the ISO string representation // Instead of using a "modified" date and "Z", we restore the representation "as authored" @@ -75027,402 +82160,6 @@ class TomlDate extends Date { } } -;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js -/*! - * Copyright (c) Squirrel Chat et al., All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -function getLineColFromPtr(string, ptr) { - let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g); - return [lines.length, lines.pop().length + 1]; -} -function makeCodeBlock(string, line, column) { - let lines = string.split(/\r\n|\n|\r/g); - let codeblock = ''; - let numberLen = (Math.log10(line + 1) | 0) + 1; - for (let i = line - 1; i <= line + 1; i++) { - let l = lines[i - 1]; - if (!l) - continue; - codeblock += i.toString().padEnd(numberLen, ' '); - codeblock += ': '; - codeblock += l; - codeblock += '\n'; - if (i === line) { - codeblock += ' '.repeat(numberLen + column + 2); - codeblock += '^\n'; - } - } - return codeblock; -} -class TomlError extends Error { - line; - column; - codeblock; - constructor(message, options) { - const [line, column] = getLineColFromPtr(options.toml, options.ptr); - const codeblock = makeCodeBlock(options.toml, line, column); - super(`Invalid TOML document: ${message}\n\n${codeblock}`, options); - this.line = line; - this.column = column; - this.codeblock = codeblock; - } -} - -;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js -/*! - * Copyright (c) Squirrel Chat et al., All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** @internal */ -function indexOfNewline(str, start = 0) { - let idx = str.indexOf('\n', start); - if (str.charCodeAt(idx - 1) === 0xd /* \r */) - idx--; - return idx; -} -/** @internal */ -function skipComment(ctx) { - for (; ctx.p < ctx.s.length; ctx.p++) { - let c = ctx.s.charCodeAt(ctx.p); - if (c === 0xa /* \n */) - break; - if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */) { - ctx.p++; - break; - } - if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) { - throw new TomlError('control characters are not allowed in comments', { - toml: ctx.s, - ptr: ctx.p, - }); - } - } -} -/** @internal */ -function skipVoid(ctx, banNewLines, banComments) { - let c; - while (1) { - while ((c = ctx.s.charCodeAt(ctx.p)) === 0x20 || - c === 0x9 /* \t */ || - (!banNewLines && - (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */)))) - ctx.p++; - if (banComments || c !== 0x23 /* # */) - break; - skipComment(ctx); - } -} -/** @internal */ -function skipUntil(ctx, sep, end) { - let ptr = ctx.p; - if (!end) { - ptr = indexOfNewline(ctx.s, ptr); - ctx.p = ptr < 0 ? ctx.s.length : ptr; - return; - } - for (; ctx.p < ctx.s.length; ctx.p++) { - let c = ctx.s.charCodeAt(ctx.p); - if (c === 0x23 /* # */) { - skipComment(ctx); - } - else if (c === end || c === sep) { - return; - } - } - throw new TomlError('cannot find end of structure', { - toml: ctx.s, - ptr, - }); -} - -;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/primitive.js -/*! - * Copyright (c) Squirrel Chat et al., All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - - -// let CTRL_REGEX = /[\x00-\x08\x0f-\x1f\x7f]/ -let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/; -let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/; -let LEADING_ZERO = /^[+-]?0[0-9_]/; -/** @internal */ -function parseString(ctx) { - let start = ctx.p; - let c = ctx.s.charCodeAt(ctx.p++); - let first = c; - let isLiteral = c === 0x27; /* ' */ - let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1); - if (isMultiline) { - // Trim initial newline - if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 0xa /* \n */) - ctx.p++; - else if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */) - ctx.p += 2; - } - /* - The fast path does not seem to bring significant performance gains, so it's commented out. - Kept for reference and/or future fafoing. - - Without: spec 5.08 µs/iter 3.88 ipc (99.44% cache) 23.90 branch misses 28.61k cycles 111.01k instructions - 5MB 115.73 ms/iter 2.51 ipc (98.36% cache) 3.12M branch misses 619.30M cycles 1.56G instructions - - With: spec 5.09 µs/iter 3.90 ipc (99.46% cache) 24.42 branch misses 28.57k cycles 111.49k instructions - 5MB 113.89 ms/iter 2.47 ipc (98.38% cache) 3.12M branch misses 611.94M cycles 1.51G instructions - - if (c === "'") { - // Literal strings fast path - no transform needs to occur; just grab the str and that's it - let endPtr = str.indexOf(isMultiline ? "'''" : "'", ptr) - if (endPtr < 0) { - throw new TomlError("unfinished string literal", { toml: str, ptr }) - } - - if (isMultiline) { - // If the string ends with 4-5 quotes, then the first 1-2 are part of the string - if (str[endPtr + 3] === "'") endPtr++ - if (str[endPtr + 3] === "'") endPtr++ - } - - let string = str.slice(ptr, endPtr) - if (CTRL_REGEX.test(string)) { - let match = string.match(CTRL_REGEX)! - throw new TomlError('control characters are not allowed in strings', { toml: str, ptr: ptr + (match.index ?? 0) }) - } - return [string, endPtr + (isMultiline ? 3 : 1)] - } - */ - let parsed = ''; - let sliceStart = ctx.p; - // states: - // 0 - decoding - // 1 - decoding escape - // 2 - whitespace escape (no newline encountered yet, must fail on non-whitespace) - // 3 - whitespace escape (newline encountered, allowed to transition back to normal decode) - let state = 0; - for (; ctx.p < ctx.s.length; ctx.p++) { - c = ctx.s.charCodeAt(ctx.p); - // Deal with newlines first, since that simplifies control character checking and handling across all states - if (isMultiline && (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))) { - state = state && 3; - } - // Control characters are banned in TOML, so we throw an error if we encounter them - else if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) { - throw new TomlError('control characters are not allowed in strings', { - toml: ctx.s, - ptr: ctx.p, - }); - } - // The string might terminate while we're parsing through a newline escape. - // It must have encountered a newline; otherwise, it'll simply fail in another branch. - else if ((!state || state === 3) && c === first && (!isMultiline || (ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first))) { - if (isMultiline) { - // If the string ends with 4-5 quotes, then the first 1-2 are part of the string - if (ctx.s.charCodeAt(ctx.p + 3) === first) - ctx.p++; - if (ctx.s.charCodeAt(ctx.p + 3) === first) - ctx.p++; - } - // If we're in a newline escape still, then there's nothing to add. - if (!state) - parsed += ctx.s.slice(sliceStart, ctx.p); - ctx.p += isMultiline ? 3 : 1; - return parsed; - } - else if (!state) { - if (!isLiteral && c === 0x5c /* \ */) { - parsed += ctx.s.slice(sliceStart, (sliceStart = ctx.p)); - state = 1; - } - } - else if (state === 1) { - if (c === 0x78 /* x */ || c === 0x75 /* u */ || c === 0x55 /* U */) { // Unicode escape - let value = 0; - let len = c === 0x78 /* x */ ? 2 : c === 0x75 /* u */ ? 4 : 8; - for (let j = 0; j < len; j++, ctx.p++) { - let hex = ctx.s.charCodeAt(ctx.p + 1); - let digit = - /* 0-9 */ hex >= 0x30 && hex <= 0x39 ? hex - 0x30 : - /* A-F */ hex >= 0x41 && hex <= 0x46 ? hex - 0x41 + 10 : - /* a-f */ hex >= 0x61 && hex <= 0x66 ? hex - 0x61 + 10 : -1; - if (digit < 0) - throw new TomlError('invalid non-hex character in unicode escape', { toml: ctx.s, ptr: ctx.p + 1 }); - value = (value << 4) | digit; - } - // Because JS does bitwise on signed 32bit integers, all 0xfzzzzzzz values are actually seen as negative - if (value < 0 || value > 0x10ffff || (value >= 0xd800 && value <= 0xdfff)) { - throw new TomlError('invalid unicode escape', { toml: ctx.s, ptr: ctx.p }); - } - parsed += String.fromCodePoint(value); - sliceStart = ctx.p + 1; - state = 0; - } - else if (c === 0x20 || c === 0x9 /* \t */) { // If it was a newline, it'd have been handled earlier - state = 2; - } - else { - if (c === 0x62 /* b */) - parsed += '\b'; - else if (c === 0x74 /* t */) - parsed += '\t'; - else if (c === 0x6e /* n */) - parsed += '\n'; - else if (c === 0x66 /* f */) - parsed += '\f'; - else if (c === 0x72 /* r */) - parsed += '\r'; - else if (c === 0x65 /* e */) - parsed += '\x1b'; - else if (c === 0x22 /* " */) - parsed += '"'; - else if (c === 0x5c /* \ */) - parsed += '\\'; - else - throw new TomlError('unrecognized escape sequence', { toml: ctx.s, ptr: ctx.p }); - sliceStart = ctx.p + 1; - state = 0; - } - } - else if (c !== 0x20 && c !== 0x9 /* \t */) { - if (state === 2) { - throw new TomlError('invalid escape: only line-ending whitespace may be escaped', { - toml: ctx.s, - ptr: sliceStart, - }); - } - // State cannot be zero, or we'd have branched earlier already. - // If it's a backslash, immediately transition to the escape state so it can be processed. - state = !isLiteral && c === 0x5c /* \ */ ? 1 : 0; - sliceStart = ctx.p; - } - } - throw new TomlError('unfinished string', { toml: ctx.s, ptr: start }); -} -function sliceAndTrimEndOf(ctx, start, end) { - let value = ctx.s.slice(start, end); - let commentIdx = value.indexOf('#'); - if (commentIdx > 0) { - // The call to skipComment allows to "validate" the comment - // (absence of control characters) - skipComment({ s: value, p: commentIdx, d: 0 }); - value = value.slice(0, commentIdx); - } - return value.trimEnd(); -} -/** @internal */ -function parseValue(ctx, integersAsBigInt, end) { - let ptr = ctx.p; - let err = { toml: ctx.s, ptr }; - skipUntil(ctx, 0x2c /* , */, end); - let value = sliceAndTrimEndOf(ctx, ptr, ctx.p); - if (!value) - throw new TomlError('incomplete declaration: value expected', err); - if (value === '-inf') - return -Infinity; - if (value === 'inf' || value === '+inf') - return Infinity; - if (value === 'nan' || value === '+nan' || value === '-nan') - return NaN; - // Avoid FP representation of -0 - if (value === '-0') - return integersAsBigInt ? 0n : 0; - // Numbers - let isInt = INT_REGEX.test(value); - if (isInt || FLOAT_REGEX.test(value)) { - if (LEADING_ZERO.test(value)) { - throw new TomlError('leading zeroes are not allowed', err); - } - value = value.replace(/_/g, ''); - let numeric = +value; - if (isNaN(numeric)) { - throw new TomlError('invalid number', err); - } - if (isInt) { - if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) { - throw new TomlError('integer value cannot be represented losslessly', err); - } - if (isInt || integersAsBigInt === true) - numeric = BigInt(value); - } - return numeric; - } - const date = new TomlDate(value); - if (!date.isValid()) - throw new TomlError('invalid value', err); - return date; -} - ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/extract.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -75454,21 +82191,30 @@ function parseValue(ctx, integersAsBigInt, end) { + +function isDigit(char, base = 10) { + return base === 16 + ? (char > 0x2f && char < 0x3a) || (char > 0x40 && char < 0x47) || (char > 0x60 && char < 0x67) + : (char > 0x2f && char < 0x30 + base); +} +function isEndOfValue(char, delim) { + // Whitespace -- we're permissive on `\r` for performance; it'll be dealt with later anyway + return char === 0x20 || char === 0x9 /* \t */ || char === 0xa /* \n */ || char === 0xd /* \r */ || + // Structure end or next value delimiter + (delim && (char === delim || char === 0x2c /* , */)) || + // Comment + char === 0x23; /* # */ +} /** @internal */ -function extractValue(ctx, end, integersAsBigInt) { - let ptr = ctx.p; - let c = ctx.s.charCodeAt(ptr); +function extractValue(ctx, end) { + let errPtr = ctx.p; + let c = ctx.s.charCodeAt(ctx.p); // Structs if (c === 0x5b /* [ */ || c === 0x7b /* { */) { - if (!ctx.d--) { - throw new TomlError('document contains excessively nested structures. aborting.', { - toml: ctx.s, - ptr, - }); - } + ctx.d-- || TomlError.x('document contains excessively nested structures. aborting.', ctx); let value = c === 0x5b /* [ */ - ? parseArray(ctx, integersAsBigInt) - : parseInlineTable(ctx, integersAsBigInt); + ? parseArray(ctx) + : parseInlineTable(ctx); ctx.d++; return value; } @@ -75480,18 +82226,292 @@ function extractValue(ctx, end, integersAsBigInt) { // We can fast-path because the first character is enough to know the only possible value if (c === 0x74 /* t */) { // Only possible valid value is `true` if (ctx.s.charCodeAt(++ctx.p) !== 0x72 || ctx.s.charCodeAt(++ctx.p) !== 0x75 || ctx.s.charCodeAt(++ctx.p) !== 0x65) - throw new TomlError('invalid value', { toml: ctx.s, ptr }); - ctx.p++; - return true; + TomlError.x('invalid value', ctx, errPtr); + return ctx.p++, true; } if (c === 0x66 /* f */) { // Only possible valid value is `false` if (ctx.s.charCodeAt(++ctx.p) !== 0x61 || ctx.s.charCodeAt(++ctx.p) !== 0x6c || ctx.s.charCodeAt(++ctx.p) !== 0x73 || ctx.s.charCodeAt(++ctx.p) !== 0x65) - throw new TomlError('invalid value', { toml: ctx.s, ptr }); - ctx.p++; - return false; + TomlError.x('invalid value', ctx, errPtr); + return ctx.p++, false; + } + if (c === 0x2b /* + */ || c === 0x2d /* - */) { + return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 0x2c - c, end); + } + // Rough heuristic, but `parseDate` falls back to number parsing if it's a false positive. + // e.g.: `a = 1\n-------------- = 1` would match this heuristic, but gracefully fallback to numbers. + if (ctx.s.charCodeAt(ctx.p + 4) === 0x2d /* - */ && ctx.s.charCodeAt(ctx.p + 7) === 0x2d /* - */) { + return parseDate(ctx, c, end); + } + // Same logic as above; `parseTime` falls back to number parsing if it's a false positive. + if (ctx.s.charCodeAt(ctx.p + 2) === 0x3a /* : */) { + return parseTime(ctx, c, end); + } + return parseNumber(ctx, ctx.p, c, 0, end); +} +// State: +// 0: init +// 1: integer +// 2: fractional dot +// 3: fractional +// 4: exponent letter +// 5: exponent +// 6: exponent sign +// 7: exponent with sign +// >9: underscore; see below +// -> 12: was integer +// -> 14: was fractional +// -> 16: was exponent +// states 2-5, 14, 16 are ONLY permitted iif base === 10 +function parseNumber(ctx, startPtr, startChr, sign, endChr) { + let c = startChr; + let state = 0; + let hasUnderscores = false; + // (+/-)inf + if (c === 0x69 /* i */) { + if (ctx.s.charCodeAt(++ctx.p) !== 0x6e || ctx.s.charCodeAt(++ctx.p) !== 0x66) + TomlError.x('invalid value', ctx, startPtr); + return ctx.p++, (sign || 1) / 0; + } + // (+/-)nan + if (c === 0x6e /* n */) { + if (ctx.s.charCodeAt(++ctx.p) !== 0x61 || ctx.s.charCodeAt(++ctx.p) !== 0x6e) + TomlError.x('invalid value', ctx, startPtr); + return ctx.p++, NaN; + } + // Leading zero + // Only allowed cases: `0`, `0.(...)`, `0e(...)`, `0x(...)`, `0b(...)`, `0o(...)` + // FWIW, `0e(...)` is a stupid case, but it's not banned per-se so we have to parse it + if (c === 0x30 /* 0 */) { + if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr)) + return ctx.bi === true ? 0n : 0; // note: conveniently deals with `-0` + if (!sign) { + if (c === 0x78 /* x */) + return parseIntegerBaseN(ctx, startPtr, 16, endChr); + else if (c === 0x62 /* b */) + return parseIntegerBaseN(ctx, startPtr, 2, endChr); + else if (c === 0x6f /* o */) + return parseIntegerBaseN(ctx, startPtr, 8, endChr); + } + if (c === 0x2e /* . */) + state = 2; + else if (c === 0x65 /* e */ || c === 0x45 /* E */) + state = 4; + else + TomlError.x('illegal leading zero', ctx, startPtr); + } + // If the 1st char is not a digit by now, then it's not a valid TOML value at all + else if (!isDigit(c)) + TomlError.x('invalid value', ctx, startPtr); + while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) { + if (!state) + state = 1; // Detects single-digit numbers we can use a fast parse path for + // The way the states are numbered is not random: underscores are always permitted in odd-numbered states and + // never permitted in even-numbered ones. + if (c === 0x5f /* _ */) { + if (!(state & 1)) + TomlError.x('illegal underscore', ctx); + state += 11; // 11 is a marker that makes the state even and greater than 9; see the numbering + rationale above + hasUnderscores = true; + } + // Transition to fractional part. + else if (state === 1 && c === 0x2e /* . */) + state = 2; + // Transition to exponent part. + else if ((state === 1 || state === 3) && (c === 0x65 /* e */ || c === 0x45 /* E */)) + state = 4; + // + and - are permitted in state 4 only (handled before entering the function for state 0) + else if (state === 4 && (c === 0x2b /* + */ || c === 0x2d /* - */)) { + state = 6; + } + // All special cases have been handled; only digits are allowed here + else if (!isDigit(c)) + TomlError.x(`illegal character in numeric literal`, ctx); + // Clear state flags + else if (state > 9) + state -= 11; + else if (!(state & 1)) + state++; + } + // Single-char number; we can fast-path these very easily. + if (!state) { + let val = (startChr - 0x30 /* 0 */) * (sign || 1); + return ctx.bi === true ? BigInt(val) : val; + } + // Even-numbered states absolutely require a digit next; not even end of value is permitted + if (!(state & 1)) + TomlError.x('unfinished numeric value', ctx, startPtr); + let str = ctx.s.slice(startPtr, ctx.p); + if (hasUnderscores) + str = str.replaceAll('_', ''); // perf: replaceAll 1.25x faster than replace with a regex + return state > 1 + ? parseFloat(str) + : parseInteger(ctx, str, 10, startPtr); +} +function parseIntegerBaseN(ctx, startPtr, base, endChr) { + let c, underscore = 1; + while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) { + if (c === 0x5f /* _ */) { + if (underscore & 1) + TomlError.x('illegal underscore', ctx); + underscore = 3; + } + // We only need to check if the number is a valid digit, nothing else is permitted + else if (!isDigit(c, base)) + TomlError.x(`illegal character in numeric literal`, ctx); + // Clear underscore flag + else if (underscore & 1) + underscore--; + } + // Trailing underscore is not allowed + if (underscore & 1) + TomlError.x('unfinished numeric value', ctx); + let str = ctx.s.slice(startPtr + 2, ctx.p); + if (underscore) + str = str.replaceAll('_', ''); // perf: replaceAll 1.25x faster than replace with a regex + return parseInteger(ctx, str, base, startPtr); +} +function parseInteger(ctx, str, base, startPtr) { + if (ctx.bi !== true) + int: { + let val = parseInt(str, base); + if (!Number.isSafeInteger(val)) { + if (ctx.bi) + break int; + TomlError.x('integer value cannot be represented losslessly', ctx, startPtr); + } + return val; + } + return base === 10 ? BigInt(str) : BigInt((base === 2 ? '0b' : base === 8 ? '0o' : '0x') + str); +} +function parseDate(ctx, c, endChr) { + let startPtr = ctx.p++, unsafeSeparator; + if (!isDigit(c) || + !isDigit(ctx.s.charCodeAt(ctx.p++)) || + !isDigit(ctx.s.charCodeAt(ctx.p++)) || + !isDigit(ctx.s.charCodeAt(ctx.p++))) { + return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr); + } + ctx.p += 5; + if (!isDigit(ctx.s.charCodeAt(ctx.p++))) + TomlError.x('invalid date-time: date part is malformed', ctx, startPtr); + if (ctx.p >= ctx.s.length || (((c = ctx.s.charCodeAt(ctx.p)) !== 0x20 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 0x54 /* T */ && c !== 0x74 /* t */)) { + let t = ctx.s.slice(startPtr, ctx.p); + return readDate(ctx, t, 3, false, startPtr); + } + if (ctx.s.charCodeAt(ctx.p += 3) !== 0x3a /* : */) + TomlError.x('invalid date-time: time part is malformed', ctx, startPtr); + if (ctx.s.charCodeAt(ctx.p += 3) === 0x3a /* : */) + ctx.p += 3; + if (ctx.s.charCodeAt(ctx.p) === 0x2e /* . */) + while (isDigit(ctx.s.charCodeAt(++ctx.p))) + ; + if (c = ctx.s.charCodeAt(ctx.p)) { + if (c === 0x5a /* Z */ || c === 0x7a /* z */) { + let t = ctx.s.slice(startPtr, ++ctx.p); + return readDate(ctx, t, 1, unsafeSeparator, startPtr, '[+00:00]'); + } + if (c === 0x2b /* + */ || c === 0x2d /* - */) { + // Temporal's ZonedDateTime is weird asf when it comes to dealing with traditional offsets... + // It's 1.2x faster to allocate a new string to pass to ZDT than use Instant.toZonedDateTimeISO + let t = ctx.s.slice(startPtr, ctx.p += 6); + return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && ('[' + ctx.s.slice(ctx.p - 6, ctx.p) + ']')); + } + } + let t = ctx.s.slice(startPtr, ctx.p); + return readDate(ctx, t, 2, unsafeSeparator, startPtr); +} +function parseTime(ctx, c, endChr) { + let start = ctx.p; + if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) { + return parseNumber(ctx, --ctx.p, c, 0, endChr); + } + if (ctx.s.charCodeAt(ctx.p += 4) === 0x3a /* : */) + ctx.p += 3; + if (ctx.s.charCodeAt(ctx.p) === 0x2e /* . */) + while (isDigit(ctx.s.charCodeAt(++ctx.p))) + ; + let t = ctx.s.slice(start, ctx.p); + return readDate(ctx, t, 4, false, start); +} +function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) { + if (ctx.ld) { + let date = new TomlDate(str, type, unsafeDelim); + if (!date.isValid()) + TomlError.x('invalid date', ctx, errPtr); + return date; + } + try { + if (temporalSuffix) + str += temporalSuffix; + switch (type) { + case 1: return Temporal.ZonedDateTime.from(str); + case 2: return Temporal.PlainDateTime.from(str); + case 3: return Temporal.PlainDate.from(str); + case 4: return Temporal.PlainTime.from(str); + } + } + catch (e) { + TomlError.x(e instanceof Error ? e.message : '' + e, ctx, errPtr); + } +} + +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** @internal */ +function skipComment(ctx) { + for (; ctx.p < ctx.s.length; ctx.p++) { + let c = ctx.s.charCodeAt(ctx.p); + if (c === 0xa /* \n */) + break; + if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */) { + ctx.p++; + break; + } + if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) { + TomlError.x('control characters are not allowed in comments', ctx); + } + } +} +/** @internal */ +function skipVoid(ctx, banNewLines, banComments) { + let c; + while (ctx.p < ctx.s.length) { + while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 0x20 || + c === 0x9 /* \t */ || + (!banNewLines && + (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))))) + ctx.p++; + if (banComments || c !== 0x23 /* # */) + break; + skipComment(ctx); } - // Legacy logic for numbers and dates. Slow and needs to be rewritten. - return parseValue(ctx, integersAsBigInt, end); } ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/struct.js @@ -75526,83 +82546,67 @@ function extractValue(ctx, end, integersAsBigInt) { -let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/; /** @internal */ -function parseKey(ctx, end = '=') { - let start = ctx.p; - let dot = start - 1; +function parseKey(ctx, end = 0x3d /* = */) { + // States: + // 0: before first char + // 1: parsing bare key + // 2: after key component + let startPtr; + let state = 0; let parsed = []; - let endPtr = ctx.s.indexOf(end, start); - if (endPtr < 0) { - throw new TomlError('incomplete key-value: cannot find end of key', { - toml: ctx.s, - ptr: start, - }); - } + let sliceStart; + let c = ctx.s.charCodeAt(startPtr = ctx.p); do { - let c = ctx.s.charCodeAt(ctx.p = ++dot); - // If it's whitespace, ignore - if (c !== 0x20 && c !== 0x9 /* \t */) { - // If it's a string - if (c === 0x22 /* " */ || c === 0x27 /* ' */) { - if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) { - throw new TomlError('multiline strings are not allowed in keys', { - toml: ctx.s, - ptr: ctx.p, - }); - } - let part = parseString(ctx); - dot = ctx.s.indexOf('.', ctx.p); - let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot); - let newLine = indexOfNewline(strEnd); - if (newLine > -1) { - throw new TomlError('newlines are not allowed in keys', { - toml: ctx.s, - ptr: newLine, - }); - } - if (strEnd.trimStart()) { - throw new TomlError('found extra tokens after the string part', { - toml: ctx.s, - ptr: ctx.p, - }); - } - if (endPtr < ctx.p) { - endPtr = ctx.s.indexOf(end, ctx.p); - if (endPtr < 0) { - throw new TomlError('incomplete key-value: cannot find end of key', { - toml: ctx.s, - ptr: start, - }); - } - } - parsed.push(part); - } - else { - // Normal raw key part consumption and validation - dot = ctx.s.indexOf('.', ctx.p); - let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot); - if (!KEY_PART_RE.test(part)) { - throw new TomlError('only letter, numbers, dashes and underscores are allowed in keys', { - toml: ctx.s, - ptr: ctx.p, - }); - } - parsed.push(part.trimEnd()); + // End of key + if (c === end) { + if (!state) + TomlError.x('unexpected end of key', ctx); + if (state === 1) + parsed.push(ctx.s.slice(sliceStart, ctx.p)); + return ctx.p++, parsed; + } + // Dotted key separator + else if (c === 0x2e /* . */) { + if (!state) + TomlError.x('illegal empty bare key', ctx); + if (state === 1) + parsed.push(ctx.s.slice(sliceStart, ctx.p)); + state = 0; + } + // Quoted key + else if (!state && (c === 0x22 /* " */ || c === 0x27 /* ' */)) { + if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) + TomlError.x('illegal quoted key: multiline strings are not allowed', ctx); + parsed.push(parseString(ctx)); + state = 2; + ctx.p--; + } + // Whitespace; no-op in state 0 and 2, end of bare key in state 1 + else if (c === 0x20 || c === 0x9 /* \t */) { + if (state === 1) { + parsed.push(ctx.s.slice(sliceStart, ctx.p)); + state = 2; } } - // Until there's no more dot - } while (dot + 1 && dot < endPtr); - ctx.p = endPtr + 1; - skipVoid(ctx, true, true); - return parsed; + // If state is post-key, no character is allowed; otherwise ensure it's a bare-key component + else if (state === 2 || (c < 0x30 && c !== 0x2d /* - */) || (c > 0x39 && c < 0x41) || (c > 0x5a && c < 0x61 && c !== 0x5f /* _ */) || c > 0x7a) { + TomlError.x('illegal character in key', ctx); + } + // Illegal character + else if (!state) { + state = 1; + sliceStart = ctx.p; + } + } while (c = ctx.s.charCodeAt(++ctx.p)); + TomlError.x('incomplete key-value: cannot find end of key', ctx, startPtr); } /** @internal */ -function parseInlineTable(ctx, integersAsBigInt) { - let res = {}; +function parseInlineTable(ctx) { + let startPtr = ctx.p++; + let res = Object.create(null); let seen = new Set(); let c; - ctx.p++; while (ctx.p < ctx.s.length) { skipVoid(ctx); if ((c = ctx.s.charCodeAt(ctx.p)) === 0x7d /* } */) { @@ -75612,67 +82616,60 @@ function parseInlineTable(ctx, integersAsBigInt) { let k; let t = res; let hasOwn = false; - let p = ctx.p; + let errPtr = ctx.p; let key = parseKey(ctx); for (let i = 0; i < key.length; i++) { if (i) - t = hasOwn ? t[k] : (t[k] = {}); + t = hasOwn ? t[k] : (t[k] = Object.create(null)); k = key[i]; if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== 'object' || seen.has(t[k]))) { - throw new TomlError('trying to redefine an already defined value', { - toml: ctx.s, - ptr: p, - }); + TomlError.x('trying to redefine an already defined value', ctx, errPtr); } - if (!hasOwn && k === '__proto__') { + let unsafe = k === '__proto__'; + if (ctx.uk && (unsafe || k === 'constructor')) { + t = ctx.uk !== 1 && TomlError.x('document contains an unsafe property', ctx, errPtr); + break; + } + if (!hasOwn && unsafe) { Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true }); } } if (hasOwn) { - throw new TomlError('trying to redefine an already defined value', { - toml: ctx.s, - ptr: ctx.p, - }); + TomlError.x('trying to redefine an already defined value', ctx, errPtr); } - let value = extractValue(ctx, 0x7d /* } */, integersAsBigInt); - seen.add(t[k] = value); + skipVoid(ctx, true, true); + let value = extractValue(ctx, 0x7d /* } */); + if (t && typeof (t[k] = value) === 'object') + seen.add(value); skipVoid(ctx); if ((c = ctx.s.charCodeAt(ctx.p++)) === 0x7d /* } */) { return res; } - if (c !== 0x2c /* , */) { - throw new TomlError('expected comma or end of structure', { toml: ctx.s, ptr: ctx.p - 1 }); - } + if (c !== 0x2c /* , */) + TomlError.x('expected comma or end of structure', ctx, ctx.p - 1); } - throw new TomlError('unfinished table encountered', { - toml: ctx.s, - ptr: ctx.p, - }); + TomlError.x('unfinished table', ctx, startPtr); } /** @internal */ -function parseArray(ctx, integersAsBigInt) { +function parseArray(ctx) { + let startPtr = ctx.p++; let res = []; let c; - ctx.p++; while (ctx.p < ctx.s.length) { skipVoid(ctx); if ((c = ctx.s.charCodeAt(ctx.p)) === 0x5d /* ] */) { ctx.p++; return res; } - res.push(extractValue(ctx, 0x5d /* ] */, integersAsBigInt)); + res.push(extractValue(ctx, 0x5d /* ] */)); skipVoid(ctx); if ((c = ctx.s.charCodeAt(ctx.p++)) === 0x5d /* ] */) { return res; } - if (c !== 0x2c /* , */) { - throw new TomlError('expected comma or end of structure', { toml: ctx.s, ptr: ctx.p - 1 }); - } + if (c !== 0x2c /* , */) + TomlError.x('expected comma or end of structure', ctx, ctx.p - 1); } - throw new TomlError('unfinished array encountered', { - toml: ctx.s, - ptr: ctx.p, - }); + TomlError.x('unfinished array', ctx, startPtr); } ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/parse.js @@ -75707,7 +82704,7 @@ function parseArray(ctx, integersAsBigInt) { -function peekTable(key, table, meta, type) { +function peekTable(ctx, key, table, meta, type) { let t = table; let m = meta; let k; @@ -75715,7 +82712,7 @@ function peekTable(key, table, meta, type) { let state; for (let i = 0; i < key.length; i++) { if (i) { - t = hasOwn ? t[k] : (t[k] = {}); + t = hasOwn ? t[k] : (t[k] = Object.create(null)); m = (state = m[k]).c; if (type === 0 /* Type.DOTTED */ && (state.t === 1 /* Type.EXPLICIT */ || state.t === 2 /* Type.ARRAY */)) { return null; @@ -75731,7 +82728,10 @@ function peekTable(key, table, meta, type) { return null; } if (!hasOwn) { - if (k === '__proto__') { + let unsafe = k === '__proto__'; + if (ctx.uk && (unsafe || k === 'constructor')) + return false; + if (unsafe) { Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true }); Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true }); } @@ -75740,7 +82740,7 @@ function peekTable(key, table, meta, type) { ? 3 /* Type.ARRAY_DOTTED */ : type, d: false, i: 0, - c: {}, + c: Object.create(null), }; } } @@ -75754,8 +82754,8 @@ function peekTable(key, table, meta, type) { state.d = true; t[k] = []; } - t[k].push(t = {}); - state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: {} }); + t[k].push(t = Object.create(null)); + state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: Object.create(null) }); } if (state.d) { // Redefining a table! @@ -75763,63 +82763,75 @@ function peekTable(key, table, meta, type) { } state.d = true; if (type === 1 /* Type.EXPLICIT */) { - t = hasOwn ? t[k] : (t[k] = {}); + t = hasOwn ? t[k] : (t[k] = Object.create(null)); } else if (type === 0 /* Type.DOTTED */ && hasOwn) { return null; } return [k, t, state.c]; } -function parse_parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) { - let ctx = { s: toml, p: 0, d: maxDepth }; - let res = {}; - let meta = {}; +function validateTablePeek(ctx, peek, ptr) { + if (peek === null || ctx.uk === 2) + TomlError.x(peek === null + ? 'trying to redefine an already defined table or value' + : 'document contains an unsafe property', ctx, ptr); +} +function parse_parse(toml, options = {}) { + let ctx = { + s: toml, + p: 0, + d: options.maxDepth ?? 1000, + bi: options.integersAsBigInt ?? false, + ld: options.useLegacyDate ?? true, + uk: options.unsafeKeyBehaviour === 'throw' ? 2 : options.unsafeKeyBehaviour === 'drop' ? 1 : 0, + }; + let res = Object.create(null); + let meta = Object.create(null); let tmp; + let skipping = false; let tbl = res; let m = meta; + // BOM is allowed, skip. + // JS is UTF-16, so we have to check for the UTF-16 BOM instead of the UTF-8 BOM sequence! + if (toml.charCodeAt(0) === 0xfeff) + ctx.p++; skipVoid(ctx); while (ctx.p < toml.length) { if (toml.charCodeAt(ctx.p) === 0x5b /* [ */) { let isTableArray = toml.charCodeAt(++ctx.p) === 0x5b; /* [ */ tmp = ctx.p += +isTableArray; - let k = parseKey(ctx, ']'); + skipping = false; + let k = parseKey(ctx, 0x5d /* ] */); if (isTableArray) { - if (toml.charCodeAt(ctx.p - 1) !== 0x5d /* ] */) { - throw new TomlError('expected end of table declaration', { - toml: toml, - ptr: ctx.p - 1, - }); + if (toml.charCodeAt(ctx.p) !== 0x5d /* ] */) { + TomlError.x('expected end of table array declaration', ctx); } ctx.p++; } - let p = peekTable(k, res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */); + let p = peekTable(ctx, k, res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */); if (!p) { - throw new TomlError('trying to redefine an already defined table or value', { - toml: toml, - ptr: tmp, - }); + validateTablePeek(ctx, p, tmp); + skipping = true; + } + else { + m = p[2]; + tbl = p[1]; } - m = p[2]; - tbl = p[1]; } else { tmp = ctx.p; let k = parseKey(ctx); - let p = peekTable(k, tbl, m, 0 /* Type.DOTTED */); - if (!p) { - throw new TomlError('trying to redefine an already defined table or value', { - toml: toml, - ptr: tmp, - }); - } - p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt); + let p = peekTable(ctx, k, tbl, m, 0 /* Type.DOTTED */); + if (!p && !skipping) + validateTablePeek(ctx, p, tmp); + skipVoid(ctx, true, true); + let v = extractValue(ctx, void 0); + if (p && !skipping) + p[1][p[0]] = v; } skipVoid(ctx, true); - if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 0xa /* \n */ && tmp !== 0xd /* \r */) { - throw new TomlError('each key-value declaration must be followed by an end-of-line', { - toml: toml, - ptr: ctx.p, - }); + if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 0xa /* \n */ && (tmp !== 0xd /* \r */ || toml.charCodeAt(ctx.p + 1) !== 0xa /* \n */)) { + TomlError.x('each key-value declaration must be followed by an end-of-line', ctx); } skipVoid(ctx); } @@ -75855,22 +82867,29 @@ function parse_parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) { * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ let BARE_KEY = /^[a-z0-9-_]+$/i; +let HAS_WELLFORMED = !!(''.isWellFormed); function extendedTypeOf(obj) { let type = typeof obj; if (type === 'object') { if (Array.isArray(obj)) return 'array'; - if (typeof obj?.getUTCDate === 'function' && obj instanceof Date) + if (typeof obj.getUTCDate === 'function' && obj instanceof Date) return 'date'; - if (globalThis.Temporal && - // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks - typeof obj?.since === 'function' && - (obj instanceof Temporal.Instant || - obj instanceof Temporal.PlainDate || - obj instanceof Temporal.PlainDateTime || - obj instanceof Temporal.PlainTime || - obj instanceof Temporal.ZonedDateTime)) { - return 'temporal'; + if (globalThis.Temporal) { + if (obj.until) { + if (obj instanceof Temporal.ZonedDateTime) + return 'temporal/tz+uc'; + if (obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainDate) + return 'temporal/uc'; + if (obj instanceof Temporal.PlainTime || obj instanceof Temporal.Instant) + return 'temporal'; + if (obj instanceof Temporal.PlainYearMonth) + return 'temporal/x'; + } + else if ((obj.toPlainDate && obj instanceof Temporal.PlainMonthDay) || + (obj.negated && obj instanceof Temporal.Duration)) { + return 'temporal/x'; + } } } return type; @@ -75882,16 +82901,20 @@ function isArrayOfTables(obj) { } return obj.length != 0; } +function formatWellFormedStringUnchecked(s) { + return JSON.stringify(s).replaceAll('\x7f', '\\u007f'); +} function formatString(s) { - return JSON.stringify(s).replace(/\x7f/g, '\\u007f'); + return formatWellFormedStringUnchecked(HAS_WELLFORMED ? s.toWellFormed() : s); } -function stringifyTemporal(temporal) { - return temporal.toString({ - calendarName: 'never', - timeZoneName: 'never', - }); +function formatKey(s) { + if (BARE_KEY.test(s)) + return s; + if (HAS_WELLFORMED && !s.isWellFormed()) + throw new RangeError('key contains illegal lone surrogates'); + return formatWellFormedStringUnchecked(s); } -function stringifyValue(val, type, depth, numberAsFloat) { +function stringifyValue(val, type, depth, numberAsFloat, strictTemporal) { if (depth === 0) { throw new Error('Could not stringify the object: maximum object depth exceeded'); } @@ -75908,6 +82931,7 @@ function stringifyValue(val, type, depth, numberAsFloat) { return val.toFixed(1); case 'bigint': case 'boolean': + case 'temporal': return val.toString(); case 'string': return formatString(val); @@ -75916,14 +82940,42 @@ function stringifyValue(val, type, depth, numberAsFloat) { throw new TypeError('cannot serialize invalid date'); return val.toISOString(); case 'object': - return stringifyInlineTable(val, depth, numberAsFloat); + return stringifyInlineTable(val, depth, numberAsFloat, strictTemporal); case 'array': - return stringifyArray(val, depth, numberAsFloat); - case 'temporal': - return stringifyTemporal(val); + return stringifyArray(val, depth, numberAsFloat, strictTemporal); + // @ts-expect-error -- intentional fallthrough case + case 'temporal/tz+uc': + if (strictTemporal) { + let tz = val.timeZoneId; + let tzc = tz.charCodeAt(0); + if ( + // Classic offset + tzc !== 0x2b /* + */ && tzc !== 0x2d /* - */ && + ( + // Fast pre-check pass; see below for the actually accepted values + (tzc !== 0x55 /* U */ && tzc !== 0x47 /* G */ && tzc !== 0x5a /* Z */ && tzc !== 0x45 /* E */) || + ( + // UTC and its aliases; Temporal implementations don't all canonicalise unfortunately + tz !== 'UTC' && tz !== 'UCT' && tz !== 'Universal' && tz !== 'Zulu' && + // GMT is a TZ but it's for all intents and purposes equivalent to UTC. Safe to downgrade. + !tz.startsWith('GMT') && tz !== 'Greenwich' && + // Etc/* are all safe to downgrade to offset (either UTC, GMT, or offset) + !tz.startsWith('Etc/')))) { + throw new TypeError('Temporal objects with an IANA timezone are not allowed in Temporal strict mode'); + } + } + case 'temporal/uc': + if (strictTemporal && val.calendarId !== 'iso8601') + throw new TypeError('Temporal objects with a non-default calendar are not allowed in Temporal strict mode'); + return val.toString({ + calendarName: 'never', + timeZoneName: 'never', + }); + case 'temporal/x': + throw new TypeError('Unsupported ' + val[Symbol.toStringTag]); } } -function stringifyInlineTable(obj, depth, numberAsFloat) { +function stringifyInlineTable(obj, depth, numberAsFloat, strictTemporal) { let keys = Object.keys(obj); if (keys.length === 0) return '{}'; @@ -75932,13 +82984,11 @@ function stringifyInlineTable(obj, depth, numberAsFloat) { let k = keys[i]; if (i) res += ', '; - res += BARE_KEY.test(k) ? k : formatString(k); - res += ' = '; - res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat); + res += formatKey(k) + ' = ' + stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat, strictTemporal); } return res + ' }'; } -function stringifyArray(array, depth, numberAsFloat) { +function stringifyArray(array, depth, numberAsFloat, strictTemporal) { if (array.length === 0) return '[]'; let res = '[ '; @@ -75948,22 +82998,22 @@ function stringifyArray(array, depth, numberAsFloat) { if (array[i] === null || array[i] === void 0) { throw new TypeError('arrays cannot contain null or undefined values'); } - res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat); + res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat, strictTemporal); } return res + ' ]'; } -function stringifyArrayTable(array, key, depth, numberAsFloat) { +function stringifyArrayTable(array, key, depth, numberAsFloat, strictTemporal) { if (depth === 0) { throw new Error('Could not stringify the object: maximum object depth exceeded'); } let res = ''; for (let i = 0; i < array.length; i++) { res += `${res && '\n'}[[${key}]]\n`; - res += stringifyTable(0, array[i], key, depth, numberAsFloat); + res += stringifyTable(0, array[i], key, depth, numberAsFloat, strictTemporal); } return res; } -function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) { +function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat, strictTemporal) { if (depth === 0) { throw new Error('Could not stringify the object: maximum object depth exceeded'); } @@ -75977,18 +83027,18 @@ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) { if (type === 'symbol' || type === 'function') { throw new TypeError(`cannot serialize values of type '${type}'`); } - let key = BARE_KEY.test(k) ? k : formatString(k); + let key = formatKey(k); if (type === 'array' && isArrayOfTables(obj[k])) { - tables += (tables && '\n') + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat); + tables += (tables && '\n') + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat, strictTemporal); } else if (type === 'object') { let tblKey = prefix ? `${prefix}.${key}` : key; - tables += (tables && '\n') + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat); + tables += (tables && '\n') + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat, strictTemporal); } else { preamble += key; preamble += ' = '; - preamble += stringifyValue(obj[k], type, depth, numberAsFloat); + preamble += stringifyValue(obj[k], type, depth, numberAsFloat, strictTemporal); preamble += '\n'; } } @@ -75999,11 +83049,11 @@ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) { ? `${preamble}\n${tables}` : preamble || tables; } -function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) { +function stringify(obj, { maxDepth = 1000, numbersAsFloat = false, strictTemporal = false } = {}) { if (extendedTypeOf(obj) !== 'object') { throw new TypeError('stringify can only be called with an object'); } - let str = stringifyTable(0, obj, '', maxDepth, numbersAsFloat); + let str = stringifyTable(0, obj, '', maxDepth, numbersAsFloat, strictTemporal); if (str[str.length - 1] !== '\n') return str + '\n'; return str; @@ -76041,8 +83091,9 @@ function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) { -/* harmony default export */ const dist = ({ parse: parse_parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError }); +/** @deprecated use `import * as ... from 'smol-toml'` instead */ +/* harmony default export */ const dist = ({ parse: parse_parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError }); ;// CONCATENATED MODULE: ./node_modules/markdownlint-cli2/parsers/toml-parse.mjs // @ts-check @@ -76058,7 +83109,7 @@ const tomlParse = (text) => parse_parse(text); /* harmony default export */ const toml_parse = (tomlParse); ;// CONCATENATED MODULE: ./node_modules/markdownlint-cli2/node_modules/js-yaml/dist/js-yaml.mjs -/*! js-yaml 5.4.1 https://github.com/nodeca/js-yaml @license MIT */ +/*! js-yaml 5.4.3 https://github.com/nodeca/js-yaml @license MIT */ //#region src/tag.ts /** * Returned by a scalar resolver when the source does not match its tag. @@ -78193,7 +85244,7 @@ function readBlockScalar(state, parentIndent, props) { state.position = linePosition + column; throwError(state, "tab characters must not be used in indentation"); } - if (column < maxLeadingIndent) { + if (column >= parentIndent && column < maxLeadingIndent) { state.position = linePosition + column; throwError(state, "bad indentation of a mapping entry"); } @@ -78403,13 +85454,16 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) { ch = state.input.charCodeAt(++state.position); if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping"); if (!mappingOpened) { - restoreState(state, beforeKey); - addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK); + state.events.splice(beforeKey.eventsLength, 0, { + type: EVENT_ID.MAPPING, + start: beforeKey.position, + anchorStart: props.anchorStart, + anchorEnd: props.anchorEnd, + tagStart: props.tagStart, + tagEnd: props.tagEnd, + style: COLLECTION_STYLE.BLOCK + }); mappingOpened = true; - parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true); - ch = state.input.charCodeAt(state.position); - while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position); - state.position++; } detected = true; atExplicitKey = false; @@ -78920,6 +85974,7 @@ function doubleQuoteWhitespaceOnly(layout) { function applyForceQuotesOption(layout) { if (!layout.presenterOptions.forceQuotes) return; if (layout.isKey || layout.style !== SCALAR_STYLE.PLAIN) return; + if (layout.node.tag !== layout.presenterOptions.schema.defaultScalarTag.tagName) return; layout.style = layout.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout); } function tryLongOrMultilineAsBlock(layout) { @@ -79922,11 +86977,9 @@ const processArgv = (/** @type {string[]} */ argv) => { // Escape RegExp special characters recognized by fast-glob // https://github.com/mrmlnc/fast-glob#advanced-syntax const specialCharacters = /\\(?![$()*+?[\]^])/gu; - if (glob.startsWith("\\:")) { - return `\\:${glob.slice(2).replace(specialCharacters, "/")}`; - } - return (glob.startsWith("#") ? `!${glob.slice(1)}` : glob). - replace(specialCharacters, "/"); + return (glob.startsWith("\\:")) + ? `\\:${glob.slice(2).replace(specialCharacters, "/")}` + : (glob.startsWith("#") ? `!${glob.slice(1)}` : glob).replace(specialCharacters, "/"); } ); if ((globPatterns.length === 1) && (globPatterns[0] === ".")) { @@ -80393,6 +87446,7 @@ const createDirInfos = async ( const overrides = dirInfo.markdownlintOptions?.overrides || []; for (const override of overrides) { const { filter, config, combine } = override; + // eslint-disable-next-line unicorn/prefer-continue if (filter && config && (filter.length > 0) && ((combine === "merge") || (combine === "replace"))) { const filteredFiles = filterByGlobs(dirInfo.dir, dirInfo.files, filter); if (filteredFiles.length > 0) { @@ -80505,11 +87559,10 @@ const lintFiles = ( const filesToFix = []; options.files = filesToFix; const subTasks = []; - const errorFiles = Object.keys(results). - filter((result) => filteredFiles.includes(result)); + const errorFiles = Object.keys(results).filter((result) => filteredFiles.includes(result)); for (const fileName of errorFiles) { - const errorInfos = results[fileName]. - filter((errorInfo) => errorInfo.fixInfo); + const errorInfos = results[fileName].filter((errorInfo) => errorInfo.fixInfo); + // eslint-disable-next-line unicorn/prefer-continue if (errorInfos.length > 0) { issuesToFix += errorInfos.length; filesToFix.push(fileName); diff --git a/package-lock.json b/package-lock.json index 4974078..e81933a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@actions/core": "3.0.1", - "markdownlint-cli2": "0.23.3" + "markdownlint-cli2": "0.24.0" }, "devDependencies": { "@eslint/js": "10.0.1", @@ -1805,9 +1805,9 @@ } }, "node_modules/markdown-it": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.1.tgz", - "integrity": "sha512-9/7gE95FNPkfUWrjJIoHZza2iLmuJlPD0UNMxPi7bxUrbCR525YZY0r+zyfes0dZI5ZZ/uNIXUJca0pJvtw41g==", + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.3.tgz", + "integrity": "sha512-+Az7Ojz3iRGu8KYMvJ6xVhvrxP3eE+vEtJX75Ow88XBpcQNV/0lGX5ZynIIBftREo4DC2jsveAMDaeltmm8QvQ==", "funding": [ { "type": "github", @@ -1820,9 +1820,9 @@ ], "license": "MIT", "dependencies": { - "argparse": "^3.0.0", - "entities": "^8.0.0", - "linkify-it": "^6.0.0", + "argparse": "^3.0.3", + "entities": "^8.1.0", + "linkify-it": "^6.1.0", "mdurl": "^2.1.0", "punycode.js": "^2.3.1", "uc.micro": "^3.0.0" @@ -1832,20 +1832,21 @@ } }, "node_modules/markdownlint": { - "version": "0.41.1", - "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.41.1.tgz", - "integrity": "sha512-qHKeU2E1bdyNAT077go2FVTNXvYcktN5IHtF6XyeD1l0PClxzSp2tUApAV14ORI8DGX4H9bNKZEzelZp4qn8IA==", + "version": "0.42.0", + "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.42.0.tgz", + "integrity": "sha512-kzsCV/rPWRFn3jUhcB919YF4Qgeh0g9tcogoXFadGSo6Zxj6662YOqWXv0jDn8nv5KCCxDfMKJZv6N4HkNkvTg==", "license": "MIT", "dependencies": { - "micromark": "4.0.2", - "micromark-core-commonmark": "2.0.3", + "micromark": "4.0.3", + "micromark-core-commonmark": "2.0.4", "micromark-extension-directive": "4.0.0", "micromark-extension-gfm-autolink-literal": "2.1.0", "micromark-extension-gfm-footnote": "2.1.0", - "micromark-extension-gfm-table": "2.1.1", + "micromark-extension-gfm-table": "2.1.2", "micromark-extension-math": "3.1.0", - "micromark-util-types": "2.0.2", - "string-width": "8.2.1" + "micromark-util-types": "2.0.3", + "re2js": "2.8.6", + "string-width": "8.3.0" }, "engines": { "node": ">=22" @@ -1855,20 +1856,20 @@ } }, "node_modules/markdownlint-cli2": { - "version": "0.23.3", - "resolved": "https://registry.npmjs.org/markdownlint-cli2/-/markdownlint-cli2-0.23.3.tgz", - "integrity": "sha512-xAr5o/TGpC3v6lE6cKIW4b5eOFRrRX5u7Vtjae9ix3RALv8nNOd94XMkD/1OXXBtpMcJ4uQGbpSo3hv5UqS4uQ==", + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/markdownlint-cli2/-/markdownlint-cli2-0.24.0.tgz", + "integrity": "sha512-c5hU2MDoTlS230MLzdNlkIyxImXq5acxGKz4nYz4aDhH/2BgFtpsA7iK9/OoTHMgZ4FuR0wedTQA31K6Lp9I/Q==", "license": "MIT", "dependencies": { "globby": "16.2.4", - "js-yaml": "5.4.1", + "js-yaml": "5.4.3", "jsonc-parser": "3.3.1", "jsonpointer": "5.0.1", - "markdown-it": "15.0.1", - "markdownlint": "0.41.1", + "markdown-it": "15.0.3", + "markdownlint": "0.42.0", "markdownlint-cli2-formatter-default": "0.0.6", "micromatch": "4.0.8", - "smol-toml": "1.8.0" + "smol-toml": "1.9.1" }, "bin": { "markdownlint-cli2": "markdownlint-cli2-bin.mjs" @@ -1899,9 +1900,9 @@ "license": "Python-2.0" }, "node_modules/markdownlint-cli2/node_modules/js-yaml": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.1.tgz", - "integrity": "sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.3.tgz", + "integrity": "sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==", "funding": [ { "type": "github", @@ -1943,9 +1944,9 @@ } }, "node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", + "integrity": "sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==", "funding": [ { "type": "GitHub Sponsors", @@ -1968,6 +1969,7 @@ "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", @@ -1978,9 +1980,9 @@ } }, "node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.4.tgz", + "integrity": "sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w==", "funding": [ { "type": "GitHub Sponsors", @@ -1997,18 +1999,19 @@ "devlop": "^1.0.0", "micromark-factory-destination": "^2.0.0", "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", + "micromark-factory-space": "^2.1.0", "micromark-factory-title": "^2.0.0", "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-classify-character": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", "micromark-util-html-tag-name": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "micromark-util-types": "^2.0.3" } }, "node_modules/micromark-extension-directive": { @@ -2067,9 +2070,9 @@ } }, "node_modules/micromark-extension-gfm-table": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", - "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.2.tgz", + "integrity": "sha512-pRzm4kDTu0MjlmBkxmS9yYhw60nncfcEwu9NNdPFSQEFXS95ZKyIIyTSHu/o3ReBUrLKYEq+7YaXCRn/bPB4MA==", "license": "MIT", "dependencies": { "devlop": "^1.0.0", @@ -2308,6 +2311,25 @@ "micromark-util-symbol": "^2.0.0" } }, + "node_modules/micromark-util-edit-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-edit-map/-/micromark-util-edit-map-1.0.0.tgz", + "integrity": "sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, "node_modules/micromark-util-encode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", @@ -2438,9 +2460,9 @@ "license": "MIT" }, "node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.3.tgz", + "integrity": "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==", "funding": [ { "type": "GitHub Sponsors", @@ -2754,6 +2776,15 @@ "url": "https://github.com/sindresorhus/quote-js-string?sponsor=1" } }, + "node_modules/re2js": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/re2js/-/re2js-2.8.6.tgz", + "integrity": "sha512-xLgQil4kIUCrAzVk9fRSkxkFNwmygLFjVxXrLc65aE1F0+Zsb8rxumFBy4XKyvgMCTL6kilDq3EZ0piE2dP/Dg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/regjsparser": { "version": "0.13.4", "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.4.tgz", @@ -2872,9 +2903,9 @@ } }, "node_modules/smol-toml": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.8.0.tgz", - "integrity": "sha512-kCZr2V3ch9i00x8zXRhjUNVcjG9ijES5dDudkXvUVCT5QlJNQWElSJdZqyPemffHoLNUYwOcou0Fy+ojN0uHSQ==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz", + "integrity": "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ==", "license": "BSD-3-Clause", "engines": { "node": ">= 18" @@ -2919,9 +2950,9 @@ "license": "CC0-1.0" }, "node_modules/string-width": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.2.1.tgz", - "integrity": "sha512-IIaP0g3iy9Cyy18w3M9YcaDudujEAVHKt3a3QJg1+sr/oX96TbaGUubG0hJyCjCBThFH+tFpcIyoUHUn1ogaLA==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", "license": "MIT", "dependencies": { "get-east-asian-width": "^1.5.0", diff --git a/package.json b/package.json index 5938ec1..fe20fa2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@actions/core": "3.0.1", - "markdownlint-cli2": "0.23.3" + "markdownlint-cli2": "0.24.0" }, "devDependencies": { "@eslint/js": "10.0.1",