{"ast":null,"code":"var __assign = this && this.__assign || function () {\n  __assign = Object.assign || function (t) {\n    for (var s, i = 1, n = arguments.length; i < n; i++) {\n      s = arguments[i];\n      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n    }\n    return t;\n  };\n  return __assign.apply(this, arguments);\n};\nimport { bodyRegExps, namedReferences } from './named-references.js';\nimport { numericUnicodeMap } from './numeric-unicode-map.js';\nimport { fromCodePoint, getCodePoint } from './surrogate-pairs.js';\nvar allNamedReferences = __assign(__assign({}, namedReferences), {\n  all: namedReferences.html5\n});\nvar encodeRegExps = {\n  specialChars: /[<>'\"&]/g,\n  nonAscii: /[<>'\"&\\u0080-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n  nonAsciiPrintable: /[<>'\"&\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n  nonAsciiPrintableOnly: /[\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n  extensive: /[\\x01-\\x0c\\x0e-\\x1f\\x21-\\x2c\\x2e-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7d\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g\n};\nvar defaultEncodeOptions = {\n  mode: 'specialChars',\n  level: 'all',\n  numeric: 'decimal'\n};\n/** Encodes all the necessary (specified by `level`) characters in the text */\nexport function encode(text, _a) {\n  var _b = _a === void 0 ? defaultEncodeOptions : _a,\n    _c = _b.mode,\n    mode = _c === void 0 ? 'specialChars' : _c,\n    _d = _b.numeric,\n    numeric = _d === void 0 ? 'decimal' : _d,\n    _e = _b.level,\n    level = _e === void 0 ? 'all' : _e;\n  if (!text) {\n    return '';\n  }\n  var encodeRegExp = encodeRegExps[mode];\n  var references = allNamedReferences[level].characters;\n  var isHex = numeric === 'hexadecimal';\n  return String.prototype.replace.call(text, encodeRegExp, function (input) {\n    var result = references[input];\n    if (!result) {\n      var code = input.length > 1 ? getCodePoint(input, 0) : input.charCodeAt(0);\n      result = (isHex ? '&#x' + code.toString(16) : '&#' + code) + ';';\n    }\n    return result;\n  });\n}\nvar defaultDecodeOptions = {\n  scope: 'body',\n  level: 'all'\n};\nvar strict = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+);/g;\nvar attribute = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g;\nvar baseDecodeRegExps = {\n  xml: {\n    strict: strict,\n    attribute: attribute,\n    body: bodyRegExps.xml\n  },\n  html4: {\n    strict: strict,\n    attribute: attribute,\n    body: bodyRegExps.html4\n  },\n  html5: {\n    strict: strict,\n    attribute: attribute,\n    body: bodyRegExps.html5\n  }\n};\nvar decodeRegExps = __assign(__assign({}, baseDecodeRegExps), {\n  all: baseDecodeRegExps.html5\n});\nvar fromCharCode = String.fromCharCode;\nvar outOfBoundsChar = fromCharCode(65533);\nvar defaultDecodeEntityOptions = {\n  level: 'all'\n};\nfunction getDecodedEntity(entity, references, isAttribute, isStrict) {\n  var decodeResult = entity;\n  var decodeEntityLastChar = entity[entity.length - 1];\n  if (isAttribute && decodeEntityLastChar === '=') {\n    decodeResult = entity;\n  } else if (isStrict && decodeEntityLastChar !== ';') {\n    decodeResult = entity;\n  } else {\n    var decodeResultByReference = references[entity];\n    if (decodeResultByReference) {\n      decodeResult = decodeResultByReference;\n    } else if (entity[0] === '&' && entity[1] === '#') {\n      var decodeSecondChar = entity[2];\n      var decodeCode = decodeSecondChar == 'x' || decodeSecondChar == 'X' ? parseInt(entity.substr(3), 16) : parseInt(entity.substr(2));\n      decodeResult = decodeCode >= 0x10ffff ? outOfBoundsChar : decodeCode > 65535 ? fromCodePoint(decodeCode) : fromCharCode(numericUnicodeMap[decodeCode] || decodeCode);\n    }\n  }\n  return decodeResult;\n}\n/** Decodes a single entity */\nexport function decodeEntity(entity, _a) {\n  var _b = _a === void 0 ? defaultDecodeEntityOptions : _a,\n    _c = _b.level,\n    level = _c === void 0 ? 'all' : _c;\n  if (!entity) {\n    return '';\n  }\n  return getDecodedEntity(entity, allNamedReferences[level].entities, false, false);\n}\n/** Decodes all entities in the text */\nexport function decode(text, _a) {\n  var _b = _a === void 0 ? defaultDecodeOptions : _a,\n    _c = _b.level,\n    level = _c === void 0 ? 'all' : _c,\n    _d = _b.scope,\n    scope = _d === void 0 ? level === 'xml' ? 'strict' : 'body' : _d;\n  if (!text) {\n    return '';\n  }\n  var decodeRegExp = decodeRegExps[level][scope];\n  var references = allNamedReferences[level].entities;\n  var isAttribute = scope === 'attribute';\n  var isStrict = scope === 'strict';\n  return text.replace(decodeRegExp, function (entity) {\n    return getDecodedEntity(entity, references, isAttribute, isStrict);\n  });\n}","map":{"version":3,"sources":["C:\\ldt\\LDT\\management\\node_modules\\html-entities\\src\\index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,SAAQ,WAAW,EAAE,eAAe,QAAO,uBAAuB;AAClE,SAAQ,iBAAiB,QAAO,0BAA0B;AAC1D,SAAQ,aAAa,EAAE,YAAY,QAAO,sBAAsB;AAEhE,IAAM,kBAAkB,GAAA,QAAA,CAAA,QAAA,CAAA,CAAA,CAAA,EACjB,eAAe,CAAA,EAAA;EAClB,GAAG,EAAE,eAAe,CAAC;AAAK,CAAA,CAC7B;AAqBD,IAAM,aAAa,GAA+B;EAC9C,YAAY,EAAE,UAAU;EACxB,QAAQ,EAAE,iFAAiF;EAC3F,iBAAiB,EAAE,0GAA0G;EAC7H,qBAAqB,EAAE,qGAAqG;EAC5H,SAAS,EAAE;CACd;AAED,IAAM,oBAAoB,GAAkB;EACxC,IAAI,EA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GAAG,KAAK,KAAK,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAA,EAAA;EAE3D,IAAI,CAAC,IAAI,EAAE;IACP,OAAO,EAAE;EACb;EAEA,IAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;EAChD,IAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,QAAQ;EACrD,IAAM,WAAW,GAAG,KAAK,KAAK,WAAW;EACzC,IAAM,QAAQ,GAAG,KAAK,KAAK,QAAQ;EAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,UAAC,MAAM,EAAA;IAAK,OAAA,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC;EAA3D,CAA2D,CAAC;AAC9G","sourcesContent":["import {bodyRegExps, namedReferences} from './named-references.js';\nimport {numericUnicodeMap} from './numeric-unicode-map.js';\nimport {fromCodePoint, getCodePoint} from './surrogate-pairs.js';\n\nconst allNamedReferences = {\n    ...namedReferences,\n    all: namedReferences.html5\n};\n\nexport type Level = 'xml' | 'html4' | 'html5' | 'all';\n\ninterface CommonOptions {\n    level?: Level;\n}\n\nexport type EncodeMode = 'specialChars' | 'nonAscii' | 'nonAsciiPrintable' | 'nonAsciiPrintableOnly' | 'extensive';\n\nexport interface EncodeOptions extends CommonOptions {\n    mode?: EncodeMode;\n    numeric?: 'decimal' | 'hexadecimal';\n}\n\nexport type DecodeScope = 'strict' | 'body' | 'attribute';\n\nexport interface DecodeOptions extends CommonOptions {\n    scope?: DecodeScope;\n}\n\nconst encodeRegExps: Record<EncodeMode, RegExp> = {\n    specialChars: /[<>'\"&]/g,\n    nonAscii: /[<>'\"&\\u0080-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n    nonAsciiPrintable: /[<>'\"&\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n    nonAsciiPrintableOnly: /[\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n    extensive: /[\\x01-\\x0c\\x0e-\\x1f\\x21-\\x2c\\x2e-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7d\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g\n};\n\nconst defaultEncodeOptions: EncodeOptions = {\n    mode: 'specialChars',\n    level: 'all',\n    numeric: 'decimal'\n};\n\n/** Encodes all the necessary (specified by `level`) characters in the text */\nexport function encode(\n    text: string | undefined | null,\n    {mode = 'specialChars', numeric = 'decimal', level = 'all'}: EncodeOptions = defaultEncodeOptions\n) {\n    if (!text) {\n        return '';\n    }\n\n    const encodeRegExp = encodeRegExps[mode];\n    const references = allNamedReferences[level].characters;\n    const isHex = numeric === 'hexadecimal';\n\n    return String.prototype.replace.call(text, encodeRegExp, (input) => {\n        let result = references[input];\n        if (!result) {\n            const code = input.length > 1 ? getCodePoint(input, 0)! : input.charCodeAt(0);\n            result = (isHex ? '&#x' + code.toString(16) : '&#' + code) + ';';\n        }\n        return result;\n    });\n}\n\nconst defaultDecodeOptions: DecodeOptions = {\n    scope: 'body',\n    level: 'all'\n};\n\nconst strict = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+);/g;\nconst attribute = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g;\n\nconst baseDecodeRegExps: Record<Exclude<Level, 'all'>, Record<DecodeScope, RegExp>> = {\n    xml: {\n        strict,\n        attribute,\n        body: bodyRegExps.xml\n    },\n    html4: {\n        strict,\n        attribute,\n        body: bodyRegExps.html4\n    },\n    html5: {\n        strict,\n        attribute,\n        body: bodyRegExps.html5\n    }\n};\n\nconst decodeRegExps: Record<Level, Record<DecodeScope, RegExp>> = {\n    ...baseDecodeRegExps,\n    all: baseDecodeRegExps.html5\n};\n\nconst fromCharCode = String.fromCharCode;\nconst outOfBoundsChar = fromCharCode(65533);\n\nconst defaultDecodeEntityOptions: CommonOptions = {\n    level: 'all'\n};\n\nfunction getDecodedEntity(\n    entity: string,\n    references: Record<string, string>,\n    isAttribute: boolean,\n    isStrict: boolean\n): string {\n    let decodeResult = entity;\n    const decodeEntityLastChar = entity[entity.length - 1];\n    if (isAttribute && decodeEntityLastChar === '=') {\n        decodeResult = entity;\n    } else if (isStrict && decodeEntityLastChar !== ';') {\n        decodeResult = entity;\n    } else {\n        const decodeResultByReference = references[entity];\n        if (decodeResultByReference) {\n            decodeResult = decodeResultByReference;\n        } else if (entity[0] === '&' && entity[1] === '#') {\n            const decodeSecondChar = entity[2];\n            const decodeCode =\n                decodeSecondChar == 'x' || decodeSecondChar == 'X'\n                    ? parseInt(entity.substr(3), 16)\n                    : parseInt(entity.substr(2));\n\n            decodeResult =\n                decodeCode >= 0x10ffff\n                    ? outOfBoundsChar\n                    : decodeCode > 65535\n                    ? fromCodePoint(decodeCode)\n                    : fromCharCode(numericUnicodeMap[decodeCode] || decodeCode);\n        }\n    }\n    return decodeResult;\n}\n\n/** Decodes a single entity */\nexport function decodeEntity(\n    entity: string | undefined | null,\n    {level = 'all'}: CommonOptions = defaultDecodeEntityOptions\n): string {\n    if (!entity) {\n        return '';\n    }\n    return getDecodedEntity(entity, allNamedReferences[level].entities, false, false);\n}\n\n/** Decodes all entities in the text */\nexport function decode(\n    text: string | undefined | null,\n    {level = 'all', scope = level === 'xml' ? 'strict' : 'body'}: DecodeOptions = defaultDecodeOptions\n) {\n    if (!text) {\n        return '';\n    }\n\n    const decodeRegExp = decodeRegExps[level][scope];\n    const references = allNamedReferences[level].entities;\n    const isAttribute = scope === 'attribute';\n    const isStrict = scope === 'strict';\n\n    return text.replace(decodeRegExp, (entity) => getDecodedEntity(entity, references, isAttribute, isStrict));\n}\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]}