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,EAEhEK,EAAQ,OAASJ,EAAQ,SAC3BA,EAAUI,EAEd,CAEA,OAAOF,IACJ,CAACH,EAAQ,uBAAyBG,EAAM,OAASF,EAAQ,QACxDE,EACAF,CACN,CC9DO,SAASM,EAAYC,EAAM,CAChC,MAAO,MAAQA,EAAK,SAAS,EAAE,EAAE,YAAY,EAAI,GACnD,CCWO,SAASC,EAAkBC,EAAOC,EAAS,CAChD,OAAOC,EAAKF,EAAO,OAAO,OAAO,CAAC,OAAQG,CAAW,EAAGF,CAAO,CAAC,CAClE,CAYO,SAASG,EAAuBJ,EAAOC,EAAS,CACrD,OAAOC,EAAKF,EAAO,OAAO,OAAO,CAAC,OAAQK,CAAW,EAAGJ,CAAO,CAAC,CAClE","names":["defaultSubsetRegex","surrogatePairsRegex","controlCharactersRegex","regexEscapeRegex","subsetToRegexCache","core","value","options","charactersToExpressionCached","basic","surrogate","pair","index","all","character","subset","cached","charactersToExpression","groups","hexadecimalRegex","toHexadecimal","code","next","omit","value","decimalRegex","toDecimal","code","next","omit","value","characterEntitiesLegacy","characterEntitiesHtml4","dangerous","own","characters","key","characterEntitiesHtml4","notAlphanumericRegex","toNamed","code","next","omit","attribute","character","name","value","characterEntitiesLegacy","dangerous","formatSmart","code","next","options","numeric","toHexadecimal","named","toNamed","decimal","toDecimal","formatBasic","code","stringifyEntities","value","options","core","formatSmart","stringifyEntitiesLight","formatBasic"],"sources":["../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/core.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-hexadecimal.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-decimal.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-named.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/constant/dangerous.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/format-smart.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/format-basic.js","../esm/npm/stringify-entities@4.0.4/node_modules/stringify-entities/lib/index.js"],"sourcesContent":["/**\n * @typedef CoreOptions\n * @property {ReadonlyArray\u003cstring\u003e} [subset=[]]\n *   Whether to only escape the given subset of characters.\n * @property {boolean} [escapeOnly=false]\n *   Whether to only escape possibly dangerous characters.\n *   Those characters are `\"`, `\u0026`, `'`, `\u003c`, `\u003e`, and `` ` ``.\n *\n * @typedef FormatOptions\n * @property {(code: number, next: number, options: CoreWithFormatOptions) =\u003e string} format\n *   Format strategy.\n *\n * @typedef {CoreOptions \u0026 FormatOptions \u0026 import('./util/format-smart.js').FormatSmartOptions} CoreWithFormatOptions\n */\n\nconst defaultSubsetRegex = /[\"\u0026'\u003c\u003e`]/g\nconst surrogatePairsRegex = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g\nconst controlCharactersRegex =\n  // eslint-disable-next-line no-control-regex, unicorn/no-hex-escape\n  /[\\x01-\\t\\v\\f\\x0E-\\x1F\\x7F\\x81\\x8D\\x8F\\x90\\x9D\\xA0-\\uFFFF]/g\nconst regexEscapeRegex = /[|\\\\{}()[\\]^$+*?.]/g\n\n/** @type {WeakMap\u003cReadonlyArray\u003cstring\u003e, RegExp\u003e} */\nconst subsetToRegexCache = new WeakMap()\n\n/**\n * Encode certain characters in `value`.\n *\n * @param {string} value\n * @param {CoreWithFormatOptions} options\n * @returns {string}\n */\nexport function core(value, options) {\n  value = value.replace(\n    options.subset\n      ? charactersToExpressionCached(options.subset)\n      : defaultSubsetRegex,\n    basic\n  )\n\n  if (options.subset || options.escapeOnly) {\n    return value\n  }\n\n  return (\n    value\n      // Surrogate pairs.\n      .replace(surrogatePairsRegex, surrogate)\n      // BMP control characters (C0 except for LF, CR, SP; DEL; and some more\n      // non-ASCII ones).\n      .replace(controlCharactersRegex, basic)\n  )\n\n  /**\n   * @param {string} pair\n   * @param {number} index\n   * @param {string} all\n   */\n  function surrogate(pair, index, all) {\n    return options.format(\n      (pair.charCodeAt(0) - 0xd800) * 0x400 +\n        pair.charCodeAt(1) -\n        0xdc00 +\n        0x10000,\n      all.charCodeAt(index + 2),\n      options\n    )\n  }\n\n  /**\n   * @param {string} character\n   * @param {number} index\n   * @param {string} all\n   */\n  function basic(character, index, all) {\n    return options.format(\n      character.charCodeAt(0),\n      all.charCodeAt(index + 1),\n      options\n    )\n  }\n}\n\n/**\n * A wrapper function that caches the result of `charactersToExpression` with a WeakMap.\n * This can improve performance when tooling calls `charactersToExpression` repeatedly\n * with the same subset.\n *\n * @param {ReadonlyArray\u003cstring\u003e} subset\n * @returns {RegExp}\n */\nfunction charactersToExpressionCached(subset) {\n  let cached = subsetToRegexCache.get(subset)\n\n  if (!cached) {\n    cached = charactersToExpression(subset)\n    subsetToRegexCache.set(subset, cached)\n  }\n\n  return cached\n}\n\n/**\n * @param {ReadonlyArray\u003cstring\u003e} subset\n * @returns {RegExp}\n */\nfunction charactersToExpression(subset) {\n  /** @type {Array\u003cstring\u003e} */\n  const groups = []\n  let index = -1\n\n  while (++index \u003c subset.length) {\n    groups.push(subset[index].replace(regexEscapeRegex, '\\\\$\u0026'))\n  }\n\n  return new RegExp('(?:' + groups.join('|') + ')', 'g')\n}\n","const hexadecimalRegex = /[\\dA-Fa-f]/\n\n/**\n * Configurable ways to encode characters as hexadecimal references.\n *\n * @param {number} code\n * @param {number} next\n * @param {boolean|undefined} omit\n * @returns {string}\n */\nexport function toHexadecimal(code, next, omit) {\n  const value = '\u0026#x' + code.toString(16).toUpperCase()\n  return omit \u0026\u0026 next \u0026\u0026 !hexadecimalRegex.test(String.fromCharCode(next))\n    ? value\n    : value + ';'\n}\n","const decimalRegex = /\\d/\n\n/**\n * Configurable ways to encode characters as decimal references.\n *\n * @param {number} code\n * @param {number} next\n * @param {boolean|undefined} omit\n * @returns {string}\n */\nexport function toDecimal(code, next, omit) {\n  const value = '\u0026#' + String(code)\n  return omit \u0026\u0026 next \u0026\u0026 !decimalRegex.test(String.fromCharCode(next))\n    ? value\n    : value + ';'\n}\n","import {characterEntitiesLegacy} from 'character-entities-legacy'\nimport {characterEntitiesHtml4} from 'character-entities-html4'\nimport {dangerous} from '../constant/dangerous.js'\n\nconst own = {}.hasOwnProperty\n\n/**\n * `characterEntitiesHtml4` but inverted.\n *\n * @type {Record\u003cstring, string\u003e}\n */\nconst characters = {}\n\n/** @type {string} */\nlet key\n\nfor (key in characterEntitiesHtml4) {\n  if (own.call(characterEntitiesHtml4, key)) {\n    characters[characterEntitiesHtml4[key]] = key\n  }\n}\n\nconst notAlphanumericRegex = /[^\\dA-Za-z]/\n\n/**\n * Configurable ways to encode characters as named references.\n *\n * @param {number} code\n * @param {number} next\n * @param {boolean|undefined} omit\n * @param {boolean|undefined} attribute\n * @returns {string}\n */\nexport function toNamed(code, next, omit, attribute) {\n  const character = String.fromCharCode(code)\n\n  if (own.call(characters, character)) {\n    const name = characters[character]\n    const value = '\u0026' + name\n\n    if (\n      omit \u0026\u0026\n      characterEntitiesLegacy.includes(name) \u0026\u0026\n      !dangerous.includes(name) \u0026\u0026\n      (!attribute ||\n        (next \u0026\u0026\n          next !== 61 /* `=` */ \u0026\u0026\n          notAlphanumericRegex.test(String.fromCharCode(next))))\n    ) {\n      return value\n    }\n\n    return value + ';'\n  }\n\n  return ''\n}\n","/**\n * List of legacy (that don’t need a trailing `;`) named references which could,\n * depending on what follows them, turn into a different meaning\n *\n * @type {Array\u003cstring\u003e}\n */\nexport const dangerous = [\n  'cent',\n  'copy',\n  'divide',\n  'gt',\n  'lt',\n  'not',\n  'para',\n  'times'\n]\n","/**\n * @typedef FormatSmartOptions\n * @property {boolean} [useNamedReferences=false]\n *   Prefer named character references (`\u0026amp;`) where possible.\n * @property {boolean} [useShortestReferences=false]\n *   Prefer the shortest possible reference, if that results in less bytes.\n *   **Note**: `useNamedReferences` can be omitted when using `useShortestReferences`.\n * @property {boolean} [omitOptionalSemicolons=false]\n *   Whether to omit semicolons when possible.\n *   **Note**: This creates what HTML calls “parse errors” but is otherwise still valid HTML — don’t use this except when building a minifier.\n *   Omitting semicolons is possible for certain named and numeric references in some cases.\n * @property {boolean} [attribute=false]\n *   Create character references which don’t fail in attributes.\n *   **Note**: `attribute` only applies when operating dangerously with\n *   `omitOptionalSemicolons: true`.\n */\n\nimport {toHexadecimal} from './to-hexadecimal.js'\nimport {toDecimal} from './to-decimal.js'\nimport {toNamed} from './to-named.js'\n\n/**\n * Configurable ways to encode a character yielding pretty or small results.\n *\n * @param {number} code\n * @param {number} next\n * @param {FormatSmartOptions} options\n * @returns {string}\n */\nexport function formatSmart(code, next, options) {\n  let numeric = toHexadecimal(code, next, options.omitOptionalSemicolons)\n  /** @type {string|undefined} */\n  let named\n\n  if (options.useNamedReferences || options.useShortestReferences) {\n    named = toNamed(\n      code,\n      next,\n      options.omitOptionalSemicolons,\n      options.attribute\n    )\n  }\n\n  // Use the shortest numeric reference when requested.\n  // A simple algorithm would use decimal for all code points under 100, as\n  // those are shorter than hexadecimal:\n  //\n  // * `\u0026#99;` vs `\u0026#x63;` (decimal shorter)\n  // * `\u0026#100;` vs `\u0026#x64;` (equal)\n  //\n  // However, because we take `next` into consideration when `omit` is used,\n  // And it would be possible that decimals are shorter on bigger values as\n  // well if `next` is hexadecimal but not decimal, we instead compare both.\n  if (\n    (options.useShortestReferences || !named) \u0026\u0026\n    options.useShortestReferences\n  ) {\n    const decimal = toDecimal(code, next, options.omitOptionalSemicolons)\n\n    if (decimal.length \u003c numeric.length) {\n      numeric = decimal\n    }\n  }\n\n  return named \u0026\u0026\n    (!options.useShortestReferences || named.length \u003c numeric.length)\n    ? named\n    : numeric\n}\n","/**\n * The smallest way to encode a character.\n *\n * @param {number} code\n * @returns {string}\n */\nexport function formatBasic(code) {\n  return '\u0026#x' + code.toString(16).toUpperCase() + ';'\n}\n","/**\n * @typedef {import('./core.js').CoreOptions \u0026 import('./util/format-smart.js').FormatSmartOptions} Options\n * @typedef {import('./core.js').CoreOptions} LightOptions\n */\n\nimport {core} from './core.js'\nimport {formatSmart} from './util/format-smart.js'\nimport {formatBasic} from './util/format-basic.js'\n\n/**\n * Encode special characters in `value`.\n *\n * @param {string} value\n *   Value to encode.\n * @param {Options} [options]\n *   Configuration.\n * @returns {string}\n *   Encoded value.\n */\nexport function stringifyEntities(value, options) {\n  return core(value, Object.assign({format: formatSmart}, options))\n}\n\n/**\n * Encode special characters in `value` as hexadecimals.\n *\n * @param {string} value\n *   Value to encode.\n * @param {LightOptions} [options]\n *   Configuration.\n * @returns {string}\n *   Encoded value.\n */\nexport function stringifyEntitiesLight(value, options) {\n  return core(value, Object.assign({format: formatBasic}, options))\n}\n"],"version":3}
