1 |
- {"version":3,"file":"index.modern.js","sources":["../index.tsx"],"sourcesContent":["/* @jsx h */\n/**\n * markdown-to-jsx is a fork of\n * [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown)\n * from Khan Academy. Thank you Khan devs for making such an awesome\n * and extensible parsing infra... without it, half of the\n * optimizations here wouldn't be feasible. 🙏🏼\n */\nimport * as React from 'react'\n\n/**\n * Analogous to `node.type`. Please note that the values here may change at any time,\n * so do not hard code against the value directly.\n */\nexport const enum RuleType {\n blockQuote = '0',\n breakLine = '1',\n breakThematic = '2',\n codeBlock = '3',\n codeFenced = '4',\n codeInline = '5',\n footnote = '6',\n footnoteReference = '7',\n gfmTask = '8',\n heading = '9',\n headingSetext = '10',\n /** only available if not `disableHTMLParsing` */\n htmlBlock = '11',\n htmlComment = '12',\n /** only available if not `disableHTMLParsing` */\n htmlSelfClosing = '13',\n image = '14',\n link = '15',\n /** emits a `link` 'node', does not render directly */\n linkAngleBraceStyleDetector = '16',\n /** emits a `link` 'node', does not render directly */\n linkBareUrlDetector = '17',\n /** emits a `link` 'node', does not render directly */\n linkMailtoDetector = '18',\n newlineCoalescer = '19',\n orderedList = '20',\n paragraph = '21',\n ref = '22',\n refImage = '23',\n refLink = '24',\n table = '25',\n tableSeparator = '26',\n text = '27',\n textBolded = '28',\n textEmphasized = '29',\n textEscaped = '30',\n textMarked = '31',\n textStrikethroughed = '32',\n unorderedList = '33',\n}\n\nconst enum Priority {\n /**\n * anything that must scan the tree before everything else\n */\n MAX,\n /**\n * scans for block-level constructs\n */\n HIGH,\n /**\n * inline w/ more priority than other inline\n */\n MED,\n /**\n * inline elements\n */\n LOW,\n /**\n * bare text and stuff that is considered leftovers\n */\n MIN,\n}\n\n/** TODO: Drop for React 16? */\nconst ATTRIBUTE_TO_JSX_PROP_MAP = [\n 'allowFullScreen',\n 'allowTransparency',\n 'autoComplete',\n 'autoFocus',\n 'autoPlay',\n 'cellPadding',\n 'cellSpacing',\n 'charSet',\n 'className',\n 'classId',\n 'colSpan',\n 'contentEditable',\n 'contextMenu',\n 'crossOrigin',\n 'encType',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'frameBorder',\n 'hrefLang',\n 'inputMode',\n 'keyParams',\n 'keyType',\n 'marginHeight',\n 'marginWidth',\n 'maxLength',\n 'mediaGroup',\n 'minLength',\n 'noValidate',\n 'radioGroup',\n 'readOnly',\n 'rowSpan',\n 'spellCheck',\n 'srcDoc',\n 'srcLang',\n 'srcSet',\n 'tabIndex',\n 'useMap',\n].reduce(\n (obj, x) => {\n obj[x.toLowerCase()] = x\n return obj\n },\n { for: 'htmlFor' }\n)\n\nconst namedCodesToUnicode = {\n amp: '\\u0026',\n apos: '\\u0027',\n gt: '\\u003e',\n lt: '\\u003c',\n nbsp: '\\u00a0',\n quot: '\\u201c',\n} as const\n\nconst DO_NOT_PROCESS_HTML_ELEMENTS = ['style', 'script']\n\n/**\n * the attribute extractor regex looks for a valid attribute name,\n * followed by an equal sign (whitespace around the equal sign is allowed), followed\n * by one of the following:\n *\n * 1. a single quote-bounded string, e.g. 'foo'\n * 2. a double quote-bounded string, e.g. \"bar\"\n * 3. an interpolation, e.g. {something}\n *\n * JSX can be be interpolated into itself and is passed through the compiler using\n * the same options and setup as the current run.\n *\n * <Something children={<SomeOtherThing />} />\n * ==================\n * ↳ children: [<SomeOtherThing />]\n *\n * Otherwise, interpolations are handled as strings or simple booleans\n * unless HTML syntax is detected.\n *\n * <Something color={green} disabled={true} />\n * ===== ====\n * ↓ ↳ disabled: true\n * ↳ color: \"green\"\n *\n * Numbers are not parsed at this time due to complexities around int, float,\n * and the upcoming bigint functionality that would make handling it unwieldy.\n * Parse the string in your component as desired.\n *\n * <Something someBigNumber={123456789123456789} />\n * ==================\n * ↳ someBigNumber: \"123456789123456789\"\n */\nconst ATTR_EXTRACTOR_R =\n /([-A-Z0-9_:]+)(?:\\s*=\\s*(?:(?:\"((?:\\\\.|[^\"])*)\")|(?:'((?:\\\\.|[^'])*)')|(?:\\{((?:\\\\.|{[^}]*?}|[^}])*)\\})))?/gi\n\n/** TODO: Write explainers for each of these */\n\nconst AUTOLINK_MAILTO_CHECK_R = /mailto:/i\nconst BLOCK_END_R = /\\n{2,}$/\nconst BLOCKQUOTE_R = /^( *>[^\\n]+(\\n[^\\n]+)*\\n*)+\\n{2,}/\nconst BLOCKQUOTE_TRIM_LEFT_MULTILINE_R = /^ *> ?/gm\nconst BREAK_LINE_R = /^ {2,}\\n/\nconst BREAK_THEMATIC_R = /^(?:( *[-*_])){3,} *(?:\\n *)+\\n/\nconst CODE_BLOCK_FENCED_R =\n /^\\s*(`{3,}|~{3,}) *(\\S+)?([^\\n]*?)?\\n([\\s\\S]+?)\\s*\\1 *(?:\\n *)*\\n?/\nconst CODE_BLOCK_R = /^(?: {4}[^\\n]+\\n*)+(?:\\n *)+\\n?/\nconst CODE_INLINE_R = /^(`+)\\s*([\\s\\S]*?[^`])\\s*\\1(?!`)/\nconst CONSECUTIVE_NEWLINE_R = /^(?:\\n *)*\\n/\nconst CR_NEWLINE_R = /\\r\\n?/g\nconst FOOTNOTE_R = /^\\[\\^([^\\]]+)](:.*)\\n/\nconst FOOTNOTE_REFERENCE_R = /^\\[\\^([^\\]]+)]/\nconst FORMFEED_R = /\\f/g\nconst FRONT_MATTER_R = /^---[ \\t]*\\n(.|\\n)*\\n---[ \\t]*\\n/\nconst GFM_TASK_R = /^\\s*?\\[(x|\\s)\\]/\nconst HEADING_R = /^ *(#{1,6}) *([^\\n]+?)(?: +#*)?(?:\\n *)*(?:\\n|$)/\nconst HEADING_ATX_COMPLIANT_R =\n /^ *(#{1,6}) +([^\\n]+?)(?: +#*)?(?:\\n *)*(?:\\n|$)/\nconst HEADING_SETEXT_R = /^([^\\n]+)\\n *(=|-){3,} *(?:\\n *)+\\n/\n\n/**\n * Explanation:\n *\n * 1. Look for a starting tag, preceded by any amount of spaces\n * ^ *<\n *\n * 2. Capture the tag name (capture 1)\n * ([^ >/]+)\n *\n * 3. Ignore a space after the starting tag and capture the attribute portion of the tag (capture 2)\n * ?([^>]*)\\/{0}>\n *\n * 4. Ensure a matching closing tag is present in the rest of the input string\n * (?=[\\s\\S]*<\\/\\1>)\n *\n * 5. Capture everything until the matching closing tag -- this might include additional pairs\n * of the same tag type found in step 2 (capture 3)\n * ((?:[\\s\\S]*?(?:<\\1[^>]*>[\\s\\S]*?<\\/\\1>)*[\\s\\S]*?)*?)<\\/\\1>\n *\n * 6. Capture excess newlines afterward\n * \\n*\n */\nconst HTML_BLOCK_ELEMENT_R =\n /^ *(?!<[a-z][^ >/]* ?\\/>)<([a-z][^ >/]*) ?([^>]*)\\/{0}>\\n?(\\s*(?:<\\1[^>]*?>[\\s\\S]*?<\\/\\1>|(?!<\\1)[\\s\\S])*?)<\\/\\1>\\n*/i\n\nconst HTML_CHAR_CODE_R = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi\n\nconst HTML_COMMENT_R = /^<!--[\\s\\S]*?(?:-->)/\n\n/**\n * borrowed from React 15(https://github.com/facebook/react/blob/894d20744cba99383ffd847dbd5b6e0800355a5c/src/renderers/dom/shared/HTMLDOMPropertyConfig.js)\n */\nconst HTML_CUSTOM_ATTR_R = /^(data|aria|x)-[a-z_][a-z\\d_.-]*$/\n\nconst HTML_SELF_CLOSING_ELEMENT_R =\n /^ *<([a-z][a-z0-9:]*)(?:\\s+((?:<.*?>|[^>])*))?\\/?>(?!<\\/\\1>)(\\s*\\n)?/i\nconst INTERPOLATION_R = /^\\{.*\\}$/\nconst LINK_AUTOLINK_BARE_URL_R = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/\nconst LINK_AUTOLINK_MAILTO_R = /^<([^ >]+@[^ >]+)>/\nconst LINK_AUTOLINK_R = /^<([^ >]+:\\/[^ >]+)>/\nconst CAPTURE_LETTER_AFTER_HYPHEN = /-([a-z])?/gi\nconst NP_TABLE_R = /^(.*\\|?.*)\\n *(\\|? *[-:]+ *\\|[-| :]*)\\n((?:.*\\|.*\\n)*)\\n?/\nconst PARAGRAPH_R = /^[^\\n]+(?: \\n|\\n{2,})/\nconst REFERENCE_IMAGE_OR_LINK = /^\\[([^\\]]*)\\]:\\s+<?([^\\s>]+)>?\\s*(\"([^\"]*)\")?/\nconst REFERENCE_IMAGE_R = /^!\\[([^\\]]*)\\] ?\\[([^\\]]*)\\]/\nconst REFERENCE_LINK_R = /^\\[([^\\]]*)\\] ?\\[([^\\]]*)\\]/\nconst SQUARE_BRACKETS_R = /(\\[|\\])/g\nconst SHOULD_RENDER_AS_BLOCK_R = /(\\n|^[-*]\\s|^#|^ {2,}|^-{2,}|^>\\s)/\nconst TAB_R = /\\t/g\nconst TABLE_SEPARATOR_R = /^ *\\| */\nconst TABLE_TRIM_PIPES = /(^ *\\||\\| *$)/g\nconst TABLE_CELL_END_TRIM = / *$/\nconst TABLE_CENTER_ALIGN = /^ *:-+: *$/\nconst TABLE_LEFT_ALIGN = /^ *:-+ *$/\nconst TABLE_RIGHT_ALIGN = /^ *-+: *$/\n\nconst TEXT_BOLD_R =\n /^([*_])\\1((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~+.*?~+|.)*?)\\1\\1(?!\\1)/\nconst TEXT_EMPHASIZED_R =\n /^([*_])((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~+.*?~+|.)*?)\\1(?!\\1|\\w)/\nconst TEXT_MARKED_R = /^==((?:\\[.*?\\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)==/\nconst TEXT_STRIKETHROUGHED_R = /^~~((?:\\[.*?\\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)~~/\n\nconst TEXT_ESCAPED_R = /^\\\\([^0-9A-Za-z\\s])/\nconst TEXT_PLAIN_R =\n /^[\\s\\S]+?(?=[^0-9A-Z\\s\\u00c0-\\uffff&#;.()'\"]|\\d+\\.|\\n\\n| {2,}\\n|\\w+:\\S|$)/i\n\nconst TRIMstartING_NEWLINES = /^\\n+/\n\nconst HTML_LEFT_TRIM_AMOUNT_R = /^([ \\t]*)/\n\nconst UNESCAPE_URL_R = /\\\\([^\\\\])/g\n\ntype LIST_TYPE = 1 | 2\nconst ORDERED: LIST_TYPE = 1\nconst UNORDERED: LIST_TYPE = 2\n\nconst LIST_ITEM_END_R = / *\\n+$/\nconst LIST_LOOKBEHIND_R = /(?:^|\\n)( *)$/\n\n// recognize a `*` `-`, `+`, `1.`, `2.`... list bullet\nconst ORDERED_LIST_BULLET = '(?:\\\\d+\\\\.)'\nconst UNORDERED_LIST_BULLET = '(?:[*+-])'\n\nfunction generateListItemPrefix(type: LIST_TYPE) {\n return (\n '( *)(' +\n (type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET) +\n ') +'\n )\n}\n\n// recognize the start of a list item:\n// leading space plus a bullet plus a space (` * `)\nconst ORDERED_LIST_ITEM_PREFIX = generateListItemPrefix(ORDERED)\nconst UNORDERED_LIST_ITEM_PREFIX = generateListItemPrefix(UNORDERED)\n\nfunction generateListItemPrefixRegex(type: LIST_TYPE) {\n return new RegExp(\n '^' +\n (type === ORDERED ? ORDERED_LIST_ITEM_PREFIX : UNORDERED_LIST_ITEM_PREFIX)\n )\n}\n\nconst ORDERED_LIST_ITEM_PREFIX_R = generateListItemPrefixRegex(ORDERED)\nconst UNORDERED_LIST_ITEM_PREFIX_R = generateListItemPrefixRegex(UNORDERED)\n\nfunction generateListItemRegex(type: LIST_TYPE) {\n // recognize an individual list item:\n // * hi\n // this is part of the same item\n //\n // as is this, which is a new paragraph in the same item\n //\n // * but this is not part of the same item\n return new RegExp(\n '^' +\n (type === ORDERED\n ? ORDERED_LIST_ITEM_PREFIX\n : UNORDERED_LIST_ITEM_PREFIX) +\n '[^\\\\n]*(?:\\\\n' +\n '(?!\\\\1' +\n (type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET) +\n ' )[^\\\\n]*)*(\\\\n|$)',\n 'gm'\n )\n}\n\nconst ORDERED_LIST_ITEM_R = generateListItemRegex(ORDERED)\nconst UNORDERED_LIST_ITEM_R = generateListItemRegex(UNORDERED)\n\n// check whether a list item has paragraphs: if it does,\n// we leave the newlines at the end\nfunction generateListRegex(type: LIST_TYPE) {\n const bullet = type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET\n\n return new RegExp(\n '^( *)(' +\n bullet +\n ') ' +\n '[\\\\s\\\\S]+?(?:\\\\n{2,}(?! )' +\n '(?!\\\\1' +\n bullet +\n ' (?!' +\n bullet +\n ' ))\\\\n*' +\n // the \\\\s*$ here is so that we can parse the inside of nested\n // lists, where our content might end before we receive two `\\n`s\n '|\\\\s*\\\\n*$)'\n )\n}\n\nconst ORDERED_LIST_R = generateListRegex(ORDERED)\nconst UNORDERED_LIST_R = generateListRegex(UNORDERED)\n\nfunction generateListRule(\n h: any,\n type: LIST_TYPE\n): MarkdownToJSX.Rule<\n MarkdownToJSX.OrderedListNode | MarkdownToJSX.UnorderedListNode\n> {\n const ordered = type === ORDERED\n const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R\n const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R\n const LIST_ITEM_PREFIX_R = ordered\n ? ORDERED_LIST_ITEM_PREFIX_R\n : UNORDERED_LIST_ITEM_PREFIX_R\n\n return {\n match(source, state, prevCapture) {\n // We only want to break into a list if we are at the start of a\n // line. This is to avoid parsing \"hi * there\" with \"* there\"\n // becoming a part of a list.\n // You might wonder, \"but that's inline, so of course it wouldn't\n // start a list?\". You would be correct! Except that some of our\n // lists can be inline, because they might be inside another list,\n // in which case we can parse with inline scope, but need to allow\n // nested lists inside this inline scope.\n const isStartOfLine = LIST_LOOKBEHIND_R.exec(prevCapture)\n const isListBlock = state.list || (!state.inline && !state.simple)\n\n if (isStartOfLine && isListBlock) {\n source = isStartOfLine[1] + source\n\n return LIST_R.exec(source)\n } else {\n return null\n }\n },\n order: Priority.HIGH,\n parse(capture, parse, state) {\n const bullet = capture[2]\n const start = ordered ? +bullet : undefined\n const items = capture[0]\n // recognize the end of a paragraph block inside a list item:\n // two or more newlines at end end of the item\n .replace(BLOCK_END_R, '\\n')\n .match(LIST_ITEM_R)\n\n let lastItemWasAParagraph = false\n const itemContent = items.map(function (item, i) {\n // We need to see how far indented the item is:\n const space = LIST_ITEM_PREFIX_R.exec(item)[0].length\n\n // And then we construct a regex to \"unindent\" the subsequent\n // lines of the items by that amount:\n const spaceRegex = new RegExp('^ {1,' + space + '}', 'gm')\n\n // Before processing the item, we need a couple things\n const content = item\n // remove indents on trailing lines:\n .replace(spaceRegex, '')\n // remove the bullet:\n .replace(LIST_ITEM_PREFIX_R, '')\n\n // Handling \"loose\" lists, like:\n //\n // * this is wrapped in a paragraph\n //\n // * as is this\n //\n // * as is this\n const isLastItem = i === items.length - 1\n const containsBlocks = content.indexOf('\\n\\n') !== -1\n\n // Any element in a list is a block if it contains multiple\n // newlines. The last element in the list can also be a block\n // if the previous item in the list was a block (this is\n // because non-last items in the list can end with \\n\\n, but\n // the last item can't, so we just \"inherit\" this property\n // from our previous element).\n const thisItemIsAParagraph =\n containsBlocks || (isLastItem && lastItemWasAParagraph)\n lastItemWasAParagraph = thisItemIsAParagraph\n\n // backup our state for restoration afterwards. We're going to\n // want to set state.list to true, and state.inline depending\n // on our list's looseness.\n const oldStateInline = state.inline\n const oldStateList = state.list\n state.list = true\n\n // Parse inline if we're in a tight list, or block if we're in\n // a loose list.\n let adjustedContent\n if (thisItemIsAParagraph) {\n state.inline = false\n adjustedContent = content.replace(LIST_ITEM_END_R, '\\n\\n')\n } else {\n state.inline = true\n adjustedContent = content.replace(LIST_ITEM_END_R, '')\n }\n\n const result = parse(adjustedContent, state)\n\n // Restore our state before returning\n state.inline = oldStateInline\n state.list = oldStateList\n\n return result\n })\n\n return {\n items: itemContent,\n ordered: ordered,\n start: start,\n }\n },\n render(node, output, state) {\n const Tag = node.ordered ? 'ol' : 'ul'\n\n return (\n <Tag\n key={state.key}\n start={node.type === RuleType.orderedList ? node.start : undefined}\n >\n {node.items.map(function generateListItem(item, i) {\n return <li key={i}>{output(item, state)}</li>\n })}\n </Tag>\n )\n },\n }\n}\n\nconst LINK_R = /^\\[([^\\]]*)]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/\nconst IMAGE_R = /^!\\[([^\\]]*)]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/\n\nconst NON_PARAGRAPH_BLOCK_SYNTAXES = [\n BLOCKQUOTE_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n HEADING_R,\n HEADING_SETEXT_R,\n HEADING_ATX_COMPLIANT_R,\n HTML_COMMENT_R,\n NP_TABLE_R,\n ORDERED_LIST_ITEM_R,\n ORDERED_LIST_R,\n UNORDERED_LIST_ITEM_R,\n UNORDERED_LIST_R,\n]\n\nconst BLOCK_SYNTAXES = [\n ...NON_PARAGRAPH_BLOCK_SYNTAXES,\n PARAGRAPH_R,\n HTML_BLOCK_ELEMENT_R,\n HTML_SELF_CLOSING_ELEMENT_R,\n]\n\nfunction containsBlockSyntax(input: string) {\n return BLOCK_SYNTAXES.some(r => r.test(input))\n}\n\n/** Remove symmetrical leading and trailing quotes */\nfunction unquote(str: string) {\n const first = str[0]\n if (\n (first === '\"' || first === \"'\") &&\n str.length >= 2 &&\n str[str.length - 1] === first\n ) {\n return str.slice(1, -1)\n }\n return str\n}\n\n// based on https://stackoverflow.com/a/18123682/1141611\n// not complete, but probably good enough\nfunction slugify(str: string) {\n return str\n .replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, 'a')\n .replace(/[çÇ]/g, 'c')\n .replace(/[ðÐ]/g, 'd')\n .replace(/[ÈÉÊËéèêë]/g, 'e')\n .replace(/[ÏïÎîÍíÌì]/g, 'i')\n .replace(/[Ññ]/g, 'n')\n .replace(/[øØœŒÕõÔôÓóÒò]/g, 'o')\n .replace(/[ÜüÛûÚúÙù]/g, 'u')\n .replace(/[ŸÿÝý]/g, 'y')\n .replace(/[^a-z0-9- ]/gi, '')\n .replace(/ /gi, '-')\n .toLowerCase()\n}\n\nfunction parseTableAlignCapture(alignCapture: string) {\n if (TABLE_RIGHT_ALIGN.test(alignCapture)) {\n return 'right'\n } else if (TABLE_CENTER_ALIGN.test(alignCapture)) {\n return 'center'\n } else if (TABLE_LEFT_ALIGN.test(alignCapture)) {\n return 'left'\n }\n\n return null\n}\n\nfunction parseTableRow(\n source: string,\n parse: MarkdownToJSX.NestedParser,\n state: MarkdownToJSX.State\n): MarkdownToJSX.ParserResult[][] {\n const prevInTable = state.inTable\n state.inTable = true\n const tableRow = parse(source.trim(), state)\n state.inTable = prevInTable\n\n let cells = [[]]\n tableRow.forEach(function (node, i) {\n if (node.type === RuleType.tableSeparator) {\n // Filter out empty table separators at the start/end:\n if (i !== 0 && i !== tableRow.length - 1) {\n // Split the current row:\n cells.push([])\n }\n } else {\n if (\n node.type === RuleType.text &&\n (tableRow[i + 1] == null ||\n tableRow[i + 1].type === RuleType.tableSeparator)\n ) {\n node.text = node.text.replace(TABLE_CELL_END_TRIM, '')\n }\n cells[cells.length - 1].push(node)\n }\n })\n return cells\n}\n\nfunction parseTableAlign(source: string /*, parse, state*/) {\n const alignText = source.replace(TABLE_TRIM_PIPES, '').split('|')\n\n return alignText.map(parseTableAlignCapture)\n}\n\nfunction parseTableCells(\n source: string,\n parse: MarkdownToJSX.NestedParser,\n state: MarkdownToJSX.State\n) {\n const rowsText = source.trim().split('\\n')\n\n return rowsText.map(function (rowText) {\n return parseTableRow(rowText, parse, state)\n })\n}\n\nfunction parseTable(\n capture: RegExpMatchArray,\n parse: MarkdownToJSX.NestedParser,\n state: MarkdownToJSX.State\n) {\n state.inline = true\n const header = parseTableRow(capture[1], parse, state)\n const align = parseTableAlign(capture[2])\n const cells = parseTableCells(capture[3], parse, state)\n state.inline = false\n\n return {\n align: align,\n cells: cells,\n header: header,\n type: RuleType.table,\n }\n}\n\nfunction getTableStyle(node, colIndex) {\n return node.align[colIndex] == null\n ? {}\n : {\n textAlign: node.align[colIndex],\n }\n}\n\n/** TODO: remove for react 16 */\nfunction normalizeAttributeKey(key) {\n const hyphenIndex = key.indexOf('-')\n\n if (hyphenIndex !== -1 && key.match(HTML_CUSTOM_ATTR_R) === null) {\n key = key.replace(CAPTURE_LETTER_AFTER_HYPHEN, function (_, letter) {\n return letter.toUpperCase()\n })\n }\n\n return key\n}\n\nfunction attributeValueToJSXPropValue(\n key: keyof React.AllHTMLAttributes<Element>,\n value: string\n): any {\n if (key === 'style') {\n return value.split(/;\\s?/).reduce(function (styles, kvPair) {\n const key = kvPair.slice(0, kvPair.indexOf(':'))\n\n // snake-case to camelCase\n // also handles PascalCasing vendor prefixes\n const camelCasedKey = key.replace(/(-[a-z])/g, substr =>\n substr[1].toUpperCase()\n )\n\n // key.length + 1 to skip over the colon\n styles[camelCasedKey] = kvPair.slice(key.length + 1).trim()\n\n return styles\n }, {})\n } else if (key === 'href' || key === 'src') {\n return sanitizeUrl(value)\n } else if (value.match(INTERPOLATION_R)) {\n // return as a string and let the consumer decide what to do with it\n value = value.slice(1, value.length - 1)\n }\n\n if (value === 'true') {\n return true\n } else if (value === 'false') {\n return false\n }\n\n return value\n}\n\nfunction normalizeWhitespace(source: string): string {\n return source\n .replace(CR_NEWLINE_R, '\\n')\n .replace(FORMFEED_R, '')\n .replace(TAB_R, ' ')\n}\n\n/**\n * Creates a parser for a given set of rules, with the precedence\n * specified as a list of rules.\n *\n * @rules: an object containing\n * rule type -> {match, order, parse} objects\n * (lower order is higher precedence)\n * (Note: `order` is added to defaultRules after creation so that\n * the `order` of defaultRules in the source matches the `order`\n * of defaultRules in terms of `order` fields.)\n *\n * @returns The resulting parse function, with the following parameters:\n * @source: the input source string to be parsed\n * @state: an optional object to be threaded through parse\n * calls. Allows clients to add stateful operations to\n * parsing, such as keeping track of how many levels deep\n * some nesting is. For an example use-case, see passage-ref\n * parsing in src/widgets/passage/passage-markdown.jsx\n */\nfunction parserFor(\n rules: MarkdownToJSX.Rules\n): (\n source: string,\n state: MarkdownToJSX.State\n) => ReturnType<MarkdownToJSX.NestedParser> {\n // Sorts rules in order of increasing order, then\n // ascending rule name in case of ties.\n let ruleList = Object.keys(rules)\n\n if (process.env.NODE_ENV !== 'production') {\n ruleList.forEach(function (type) {\n let order = rules[type].order\n if (\n process.env.NODE_ENV !== 'production' &&\n (typeof order !== 'number' || !isFinite(order))\n ) {\n console.warn(\n 'markdown-to-jsx: Invalid order for rule `' + type + '`: ' + order\n )\n }\n })\n }\n\n ruleList.sort(function (typeA, typeB) {\n let orderA = rules[typeA].order\n let orderB = rules[typeB].order\n\n // Sort based on increasing order\n if (orderA !== orderB) {\n return orderA - orderB\n }\n\n return 1\n })\n\n function nestedParse(\n source: string,\n state: MarkdownToJSX.State\n ): MarkdownToJSX.ParserResult[] {\n let result = []\n\n // We store the previous capture so that match functions can\n // use some limited amount of lookbehind. Lists use this to\n // ensure they don't match arbitrary '- ' or '* ' in inline\n // text (see the list rule for more information).\n let prevCapture = ''\n while (source) {\n let i = 0\n while (i < ruleList.length) {\n const ruleType = ruleList[i]\n const rule = rules[ruleType]\n const capture = rule.match(source, state, prevCapture)\n\n if (capture) {\n const currCaptureString = capture[0]\n source = source.substring(currCaptureString.length)\n const parsed = rule.parse(capture, nestedParse, state)\n\n // We also let rules override the default type of\n // their parsed node if they would like to, so that\n // there can be a single output function for all links,\n // even if there are several rules to parse them.\n if (parsed.type == null) {\n parsed.type = ruleType as unknown as RuleType\n }\n\n result.push(parsed)\n\n prevCapture = currCaptureString\n break\n }\n\n i++\n }\n }\n\n return result\n }\n\n return function outerParse(source, state) {\n return nestedParse(normalizeWhitespace(source), state)\n }\n}\n\n// Creates a match function for an inline scoped or simple element from a regex\nfunction inlineRegex(regex: RegExp) {\n return function match(source, state: MarkdownToJSX.State) {\n if (state.inline) {\n return regex.exec(source)\n } else {\n return null\n }\n }\n}\n\n// basically any inline element except links\nfunction simpleInlineRegex(regex: RegExp) {\n return function match(source: string, state: MarkdownToJSX.State) {\n if (state.inline || state.simple) {\n return regex.exec(source)\n } else {\n return null\n }\n }\n}\n\n// Creates a match function for a block scoped element from a regex\nfunction blockRegex(regex: RegExp) {\n return function match(source: string, state: MarkdownToJSX.State) {\n if (state.inline || state.simple) {\n return null\n } else {\n return regex.exec(source)\n }\n }\n}\n\n// Creates a match function from a regex, ignoring block/inline scope\nfunction anyScopeRegex(regex: RegExp) {\n return function match(source: string /*, state*/) {\n return regex.exec(source)\n }\n}\n\nfunction matchParagraph(\n source: string,\n state: MarkdownToJSX.State,\n prevCapturedString?: string\n) {\n if (state.inline || state.simple) {\n return null\n }\n\n if (prevCapturedString && !prevCapturedString.endsWith('\\n')) {\n // don't match continuation of a line\n return null\n }\n\n let match = ''\n\n source.split('\\n').every(line => {\n // bail out on first sign of non-paragraph block\n if (NON_PARAGRAPH_BLOCK_SYNTAXES.some(regex => regex.test(line))) {\n return false\n }\n match += line + '\\n'\n return line.trim()\n })\n\n const captured = match.trimEnd()\n if (captured == '') {\n return null\n }\n\n return [match, captured]\n}\n\nfunction sanitizeUrl(url: string): string | undefined {\n try {\n const decoded = decodeURIComponent(url).replace(/[^A-Za-z0-9/:]/g, '')\n\n if (decoded.match(/^\\s*(javascript|vbscript|data(?!:image)):/i)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'Anchor URL contains an unsafe JavaScript/VBScript/data expression, it will not be rendered.',\n decoded\n )\n }\n\n return undefined\n }\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'Anchor URL could not be decoded due to malformed syntax or characters, it will not be rendered.',\n url\n )\n }\n\n // decodeURIComponent sometimes throws a URIError\n // See `decodeURIComponent('a%AFc');`\n // http://stackoverflow.com/questions/9064536/javascript-decodeuricomponent-malformed-uri-exception\n return null\n }\n\n return url\n}\n\nfunction unescapeUrl(rawUrlString: string): string {\n return rawUrlString.replace(UNESCAPE_URL_R, '$1')\n}\n\n/**\n * Everything inline, including links.\n */\nfunction parseInline(\n parse: MarkdownToJSX.NestedParser,\n children: string,\n state: MarkdownToJSX.State\n): MarkdownToJSX.ParserResult[] {\n const isCurrentlyInline = state.inline || false\n const isCurrentlySimple = state.simple || false\n state.inline = true\n state.simple = true\n const result = parse(children, state)\n state.inline = isCurrentlyInline\n state.simple = isCurrentlySimple\n return result\n}\n\n/**\n * Anything inline that isn't a link.\n */\nfunction parseSimpleInline(\n parse: MarkdownToJSX.NestedParser,\n children: string,\n state: MarkdownToJSX.State\n): MarkdownToJSX.ParserResult[] {\n const isCurrentlyInline = state.inline || false\n const isCurrentlySimple = state.simple || false\n state.inline = false\n state.simple = true\n const result = parse(children, state)\n state.inline = isCurrentlyInline\n state.simple = isCurrentlySimple\n return result\n}\n\nfunction parseBlock(\n parse,\n children,\n state: MarkdownToJSX.State\n): MarkdownToJSX.ParserResult[] {\n state.inline = false\n return parse(children, state)\n}\n\nconst parseCaptureInline: MarkdownToJSX.Parser<{\n children: MarkdownToJSX.ParserResult[]\n}> = (capture, parse, state: MarkdownToJSX.State) => {\n return {\n children: parseInline(parse, capture[1], state),\n }\n}\n\nfunction captureNothing() {\n return {}\n}\n\nfunction renderNothing() {\n return null\n}\n\nfunction reactFor(render) {\n return function patchedRender(\n ast: MarkdownToJSX.ParserResult | MarkdownToJSX.ParserResult[],\n state: MarkdownToJSX.State = {}\n ): React.ReactChild[] {\n if (Array.isArray(ast)) {\n const oldKey = state.key\n const result = []\n\n // map nestedOutput over the ast, except group any text\n // nodes together into a single string output.\n let lastWasString = false\n\n for (let i = 0; i < ast.length; i++) {\n state.key = i\n\n const nodeOut = patchedRender(ast[i], state)\n const isString = typeof nodeOut === 'string'\n\n if (isString && lastWasString) {\n result[result.length - 1] += nodeOut\n } else if (nodeOut !== null) {\n result.push(nodeOut)\n }\n\n lastWasString = isString\n }\n\n state.key = oldKey\n\n return result\n }\n\n return render(ast, patchedRender, state)\n }\n}\n\nfunction createRenderer(\n rules: MarkdownToJSX.Rules,\n userRender?: MarkdownToJSX.Options['renderRule']\n) {\n return function renderRule(\n ast: MarkdownToJSX.ParserResult,\n render: MarkdownToJSX.RuleOutput,\n state: MarkdownToJSX.State\n ): React.ReactChild {\n const renderer = rules[ast.type].render as MarkdownToJSX.Rule['render']\n\n return userRender\n ? userRender(() => renderer(ast, render, state), ast, render, state)\n : renderer(ast, render, state)\n }\n}\n\nfunction cx(...args) {\n return args.filter(Boolean).join(' ')\n}\n\nfunction get(src: Object, path: string, fb?: any) {\n let ptr = src\n const frags = path.split('.')\n\n while (frags.length) {\n ptr = ptr[frags[0]]\n\n if (ptr === undefined) break\n else frags.shift()\n }\n\n return ptr || fb\n}\n\nfunction getTag(tag: string, overrides: MarkdownToJSX.Overrides) {\n const override = get(overrides, tag)\n\n if (!override) return tag\n\n return typeof override === 'function' ||\n (typeof override === 'object' && 'render' in override)\n ? override\n : get(overrides, `${tag}.component`, tag)\n}\n\nexport function compiler(\n markdown: string,\n options: MarkdownToJSX.Options = {}\n) {\n options.overrides = options.overrides || {}\n options.slugify = options.slugify || slugify\n options.namedCodesToUnicode = options.namedCodesToUnicode\n ? { ...namedCodesToUnicode, ...options.namedCodesToUnicode }\n : namedCodesToUnicode\n\n const createElementFn = options.createElement || React.createElement\n\n // JSX custom pragma\n // eslint-disable-next-line no-unused-vars\n function h(\n // locally we always will render a known string tag\n tag: MarkdownToJSX.HTMLTags,\n props: Parameters<MarkdownToJSX.CreateElement>[1] & {\n className?: string\n id?: string\n },\n ...children\n ) {\n const overrideProps = get(options.overrides, `${tag}.props`, {})\n\n return createElementFn(\n getTag(tag, options.overrides),\n {\n ...props,\n ...overrideProps,\n className: cx(props?.className, overrideProps.className) || undefined,\n },\n ...children\n )\n }\n\n function compile(input: string): JSX.Element {\n input = input.replace(FRONT_MATTER_R, '')\n \n let inline = false\n\n if (options.forceInline) {\n inline = true\n } else if (!options.forceBlock) {\n /**\n * should not contain any block-level markdown like newlines, lists, headings,\n * thematic breaks, blockquotes, tables, etc\n */\n inline = SHOULD_RENDER_AS_BLOCK_R.test(input) === false\n }\n\n const arr = emitter(\n parser(\n inline\n ? input\n : `${input.trimEnd().replace(TRIMstartING_NEWLINES, '')}\\n\\n`,\n {\n inline,\n }\n )\n )\n\n while (\n typeof arr[arr.length - 1] === 'string' &&\n !arr[arr.length - 1].trim()\n ) {\n arr.pop()\n }\n\n if (options.wrapper === null) {\n return arr\n }\n\n const wrapper = options.wrapper || (inline ? 'span' : 'div')\n let jsx\n\n if (arr.length > 1 || options.forceWrapper) {\n jsx = arr\n } else if (arr.length === 1) {\n jsx = arr[0]\n\n // TODO: remove this for React 16\n if (typeof jsx === 'string') {\n return <span key=\"outer\">{jsx}</span>\n } else {\n return jsx\n }\n } else {\n // TODO: return null for React 16\n jsx = null\n }\n\n return React.createElement(wrapper, { key: 'outer' }, jsx)\n }\n\n function attrStringToMap(str: string): JSX.IntrinsicAttributes {\n const attributes = str.match(ATTR_EXTRACTOR_R)\n if (!attributes) {\n return null\n }\n\n return attributes.reduce(function (map, raw, index) {\n const delimiterIdx = raw.indexOf('=')\n\n if (delimiterIdx !== -1) {\n const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim()\n const value = unquote(raw.slice(delimiterIdx + 1).trim())\n\n const mappedKey = ATTRIBUTE_TO_JSX_PROP_MAP[key] || key\n const normalizedValue = (map[mappedKey] = attributeValueToJSXPropValue(\n key,\n value\n ))\n\n if (\n typeof normalizedValue === 'string' &&\n (HTML_BLOCK_ELEMENT_R.test(normalizedValue) ||\n HTML_SELF_CLOSING_ELEMENT_R.test(normalizedValue))\n ) {\n map[mappedKey] = React.cloneElement(compile(normalizedValue.trim()), {\n key: index,\n })\n }\n } else if (raw !== 'style') {\n map[ATTRIBUTE_TO_JSX_PROP_MAP[raw] || raw] = true\n }\n\n return map\n }, {})\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (typeof markdown !== 'string') {\n throw new Error(`markdown-to-jsx: the first argument must be\n a string`)\n }\n\n if (\n Object.prototype.toString.call(options.overrides) !== '[object Object]'\n ) {\n throw new Error(`markdown-to-jsx: options.overrides (second argument property) must be\n undefined or an object literal with shape:\n {\n htmltagname: {\n component: string|ReactComponent(optional),\n props: object(optional)\n }\n }`)\n }\n }\n\n const footnotes: { footnote: string; identifier: string }[] = []\n const refs: { [key: string]: { target: string; title: string } } = {}\n\n /**\n * each rule's react() output function goes through our custom\n * h() JSX pragma; this allows the override functionality to be\n * automatically applied\n */\n // @ts-ignore\n const rules: MarkdownToJSX.Rules = {\n [RuleType.blockQuote]: {\n match: blockRegex(BLOCKQUOTE_R),\n order: Priority.HIGH,\n parse(capture, parse, state) {\n return {\n children: parse(\n capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, ''),\n state\n ),\n }\n },\n render(node, output, state) {\n return (\n <blockquote key={state.key}>\n {output(node.children, state)}\n </blockquote>\n )\n },\n },\n\n [RuleType.breakLine]: {\n match: anyScopeRegex(BREAK_LINE_R),\n order: Priority.HIGH,\n parse: captureNothing,\n render(_, __, state) {\n return <br key={state.key} />\n },\n },\n\n [RuleType.breakThematic]: {\n match: blockRegex(BREAK_THEMATIC_R),\n order: Priority.HIGH,\n parse: captureNothing,\n render(_, __, state) {\n return <hr key={state.key} />\n },\n },\n\n [RuleType.codeBlock]: {\n match: blockRegex(CODE_BLOCK_R),\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n return {\n lang: undefined,\n text: capture[0].replace(/^ {4}/gm, '').replace(/\\n+$/, ''),\n }\n },\n\n render(node, output, state) {\n return (\n <pre key={state.key}>\n <code\n {...node.attrs}\n className={node.lang ? `lang-${node.lang}` : ''}\n >\n {node.text}\n </code>\n </pre>\n )\n },\n } as MarkdownToJSX.Rule<{\n attrs?: ReturnType<typeof attrStringToMap>\n lang?: string\n text: string\n }>,\n\n [RuleType.codeFenced]: {\n match: blockRegex(CODE_BLOCK_FENCED_R),\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n return {\n // if capture[3] it's additional metadata\n attrs: attrStringToMap(capture[3] || ''),\n lang: capture[2] || undefined,\n text: capture[4],\n type: RuleType.codeBlock,\n }\n },\n },\n\n [RuleType.codeInline]: {\n match: simpleInlineRegex(CODE_INLINE_R),\n order: Priority.LOW,\n parse(capture /*, parse, state*/) {\n return {\n text: capture[2],\n }\n },\n render(node, output, state) {\n return <code key={state.key}>{node.text}</code>\n },\n },\n\n /**\n * footnotes are emitted at the end of compilation in a special <footer> block\n */\n [RuleType.footnote]: {\n match: blockRegex(FOOTNOTE_R),\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n footnotes.push({\n footnote: capture[2],\n identifier: capture[1],\n })\n\n return {}\n },\n render: renderNothing,\n },\n\n [RuleType.footnoteReference]: {\n match: inlineRegex(FOOTNOTE_REFERENCE_R),\n order: Priority.HIGH,\n parse(capture /*, parse*/) {\n return {\n target: `#${options.slugify(capture[1])}`,\n text: capture[1],\n }\n },\n render(node, output, state) {\n return (\n <a key={state.key} href={sanitizeUrl(node.target)}>\n <sup key={state.key}>{node.text}</sup>\n </a>\n )\n },\n } as MarkdownToJSX.Rule<{ target: string; text: string }>,\n\n [RuleType.gfmTask]: {\n match: inlineRegex(GFM_TASK_R),\n order: Priority.HIGH,\n parse(capture /*, parse, state*/) {\n return {\n completed: capture[1].toLowerCase() === 'x',\n }\n },\n render(node, output, state) {\n return (\n <input\n checked={node.completed}\n key={state.key}\n readOnly\n type=\"checkbox\"\n />\n )\n },\n } as MarkdownToJSX.Rule<{ completed: boolean }>,\n\n [RuleType.heading]: {\n match: blockRegex(\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R\n ),\n order: Priority.HIGH,\n parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[2], state),\n id: options.slugify(capture[2]),\n level: capture[1].length as MarkdownToJSX.HeadingNode['level'],\n }\n },\n render(node, output, state) {\n return h(\n `h${node.level}`,\n { id: node.id, key: state.key },\n output(node.children, state)\n )\n },\n },\n\n [RuleType.headingSetext]: {\n match: blockRegex(HEADING_SETEXT_R),\n order: Priority.MAX,\n parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[1], state),\n level: capture[2] === '=' ? 1 : 2,\n type: RuleType.heading,\n }\n },\n },\n\n [RuleType.htmlBlock]: {\n /**\n * find the first matching end tag and process the interior\n */\n match: anyScopeRegex(HTML_BLOCK_ELEMENT_R),\n order: Priority.HIGH,\n parse(capture, parse, state) {\n const [, whitespace] = capture[3].match(HTML_LEFT_TRIM_AMOUNT_R)\n const trimmer = new RegExp(`^${whitespace}`, 'gm')\n const trimmed = capture[3].replace(trimmer, '')\n\n const parseFunc = containsBlockSyntax(trimmed)\n ? parseBlock\n : parseInline\n\n const tagName = capture[1].toLowerCase() as MarkdownToJSX.HTMLTags\n const noInnerParse =\n DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(tagName) !== -1\n\n const ast = {\n attrs: attrStringToMap(capture[2]),\n noInnerParse: noInnerParse,\n tag: noInnerParse ? tagName : capture[1],\n } as {\n attrs: ReturnType<typeof attrStringToMap>\n children?: ReturnType<MarkdownToJSX.NestedParser> | undefined\n noInnerParse: Boolean\n tag: MarkdownToJSX.HTMLTags\n text?: string | undefined\n }\n\n state.inAnchor = state.inAnchor || tagName === 'a'\n\n if (noInnerParse) {\n ast.text = capture[3]\n } else {\n ast.children = parseFunc(parse, trimmed, state)\n }\n\n /**\n * if another html block is detected within, parse as block,\n * otherwise parse as inline to pick up any further markdown\n */\n state.inAnchor = false\n\n return ast\n },\n render(node, output, state) {\n return (\n <node.tag key={state.key} {...node.attrs}>\n {node.text || output(node.children, state)}\n </node.tag>\n )\n },\n },\n\n [RuleType.htmlSelfClosing]: {\n /**\n * find the first matching end tag and process the interior\n */\n match: anyScopeRegex(HTML_SELF_CLOSING_ELEMENT_R),\n order: Priority.HIGH,\n parse(capture /*, parse, state*/) {\n return {\n attrs: attrStringToMap(capture[2] || ''),\n tag: capture[1],\n }\n },\n render(node, output, state) {\n return <node.tag {...node.attrs} key={state.key} />\n },\n },\n\n [RuleType.htmlComment]: {\n match: anyScopeRegex(HTML_COMMENT_R),\n order: Priority.HIGH,\n parse() {\n return {}\n },\n render: renderNothing,\n },\n\n [RuleType.image]: {\n match: simpleInlineRegex(IMAGE_R),\n order: Priority.HIGH,\n parse(capture /*, parse, state*/) {\n return {\n alt: capture[1],\n target: unescapeUrl(capture[2]),\n title: capture[3],\n }\n },\n render(node, output, state) {\n return (\n <img\n key={state.key}\n alt={node.alt || undefined}\n title={node.title || undefined}\n src={sanitizeUrl(node.target)}\n />\n )\n },\n } as MarkdownToJSX.Rule<{\n alt?: string\n target: string\n title?: string\n }>,\n\n [RuleType.link]: {\n match: inlineRegex(LINK_R),\n order: Priority.LOW,\n parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1], state),\n target: unescapeUrl(capture[2]),\n title: capture[3],\n }\n },\n render(node, output, state) {\n return (\n <a key={state.key} href={sanitizeUrl(node.target)} title={node.title}>\n {output(node.children, state)}\n </a>\n )\n },\n },\n\n // https://daringfireball.net/projects/markdown/syntax#autolink\n [RuleType.linkAngleBraceStyleDetector]: {\n match: inlineRegex(LINK_AUTOLINK_R),\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n return {\n children: [\n {\n text: capture[1],\n type: RuleType.text,\n },\n ],\n target: capture[1],\n type: RuleType.link,\n }\n },\n },\n\n [RuleType.linkBareUrlDetector]: {\n match: (source, state) => {\n if (state.inAnchor) {\n return null\n }\n return inlineRegex(LINK_AUTOLINK_BARE_URL_R)(source, state)\n },\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n return {\n children: [\n {\n text: capture[1],\n type: RuleType.text,\n },\n ],\n target: capture[1],\n title: undefined,\n type: RuleType.link,\n }\n },\n },\n\n [RuleType.linkMailtoDetector]: {\n match: inlineRegex(LINK_AUTOLINK_MAILTO_R),\n order: Priority.MAX,\n parse(capture /*, parse, state*/) {\n let address = capture[1]\n let target = capture[1]\n\n // Check for a `mailto:` already existing in the link:\n if (!AUTOLINK_MAILTO_CHECK_R.test(target)) {\n target = 'mailto:' + target\n }\n\n return {\n children: [\n {\n text: address.replace('mailto:', ''),\n type: RuleType.text,\n },\n ],\n target: target,\n type: RuleType.link,\n }\n },\n },\n\n [RuleType.orderedList]: generateListRule(\n h,\n ORDERED\n ) as MarkdownToJSX.Rule<MarkdownToJSX.OrderedListNode>,\n\n [RuleType.unorderedList]: generateListRule(\n h,\n UNORDERED\n ) as MarkdownToJSX.Rule<MarkdownToJSX.UnorderedListNode>,\n\n [RuleType.newlineCoalescer]: {\n match: blockRegex(CONSECUTIVE_NEWLINE_R),\n order: Priority.LOW,\n parse: captureNothing,\n render(/*node, output, state*/) {\n return '\\n'\n },\n },\n\n [RuleType.paragraph]: {\n match: matchParagraph,\n order: Priority.LOW,\n parse: parseCaptureInline,\n render(node, output, state) {\n return <p key={state.key}>{output(node.children, state)}</p>\n },\n } as MarkdownToJSX.Rule<ReturnType<typeof parseCaptureInline>>,\n\n [RuleType.ref]: {\n match: inlineRegex(REFERENCE_IMAGE_OR_LINK),\n order: Priority.MAX,\n parse(capture /*, parse*/) {\n refs[capture[1]] = {\n target: capture[2],\n title: capture[4],\n }\n\n return {}\n },\n render: renderNothing,\n },\n\n [RuleType.refImage]: {\n match: simpleInlineRegex(REFERENCE_IMAGE_R),\n order: Priority.MAX,\n parse(capture) {\n return {\n alt: capture[1] || undefined,\n ref: capture[2],\n }\n },\n render(node, output, state) {\n return (\n <img\n key={state.key}\n alt={node.alt}\n src={sanitizeUrl(refs[node.ref].target)}\n title={refs[node.ref].title}\n />\n )\n },\n } as MarkdownToJSX.Rule<{ alt?: string; ref: string }>,\n\n [RuleType.refLink]: {\n match: inlineRegex(REFERENCE_LINK_R),\n order: Priority.MAX,\n parse(capture, parse, state) {\n return {\n children: parse(capture[1], state),\n fallbackChildren: parse(\n capture[0].replace(SQUARE_BRACKETS_R, '\\\\$1'),\n state\n ),\n ref: capture[2],\n }\n },\n render(node, output, state) {\n return refs[node.ref] ? (\n <a\n key={state.key}\n href={sanitizeUrl(refs[node.ref].target)}\n title={refs[node.ref].title}\n >\n {output(node.children, state)}\n </a>\n ) : (\n <span key={state.key}>{output(node.fallbackChildren, state)}</span>\n )\n },\n },\n\n [RuleType.table]: {\n match: blockRegex(NP_TABLE_R),\n order: Priority.HIGH,\n parse: parseTable,\n render(node, output, state) {\n return (\n <table key={state.key}>\n <thead>\n <tr>\n {node.header.map(function generateHeaderCell(content, i) {\n return (\n <th key={i} style={getTableStyle(node, i)}>\n {output(content, state)}\n </th>\n )\n })}\n </tr>\n </thead>\n\n <tbody>\n {node.cells.map(function generateTableRow(row, i) {\n return (\n <tr key={i}>\n {row.map(function generateTableCell(content, c) {\n return (\n <td key={c} style={getTableStyle(node, c)}>\n {output(content, state)}\n </td>\n )\n })}\n </tr>\n )\n })}\n </tbody>\n </table>\n )\n },\n },\n\n [RuleType.tableSeparator]: {\n match: function (source, state) {\n if (!state.inTable) {\n return null\n }\n state.inline = true\n return TABLE_SEPARATOR_R.exec(source)\n },\n order: Priority.HIGH,\n parse: function () {\n return { type: RuleType.tableSeparator }\n },\n // These shouldn't be reached, but in case they are, be reasonable:\n render() {\n return ' | '\n },\n },\n\n [RuleType.text]: {\n // Here we look for anything followed by non-symbols,\n // double newlines, or double-space-newlines\n // We break on any symbol characters so that this grammar\n // is easy to extend without needing to modify this regex\n match: anyScopeRegex(TEXT_PLAIN_R),\n order: Priority.MIN,\n parse(capture /*, parse, state*/) {\n return {\n text: capture[0]\n // nbsp -> unicode equivalent for named chars\n .replace(HTML_CHAR_CODE_R, (full, inner) => {\n return options.namedCodesToUnicode[inner]\n ? options.namedCodesToUnicode[inner]\n : full\n }),\n }\n },\n render(node /*, output, state*/) {\n return node.text\n },\n },\n\n [RuleType.textBolded]: {\n match: simpleInlineRegex(TEXT_BOLD_R),\n order: Priority.MED,\n parse(capture, parse, state) {\n return {\n // capture[1] -> the syntax control character\n // capture[2] -> inner content\n children: parse(capture[2], state),\n }\n },\n render(node, output, state) {\n return <strong key={state.key}>{output(node.children, state)}</strong>\n },\n },\n\n [RuleType.textEmphasized]: {\n match: simpleInlineRegex(TEXT_EMPHASIZED_R),\n order: Priority.LOW,\n parse(capture, parse, state) {\n return {\n // capture[1] -> opening * or _\n // capture[2] -> inner content\n children: parse(capture[2], state),\n }\n },\n render(node, output, state) {\n return <em key={state.key}>{output(node.children, state)}</em>\n },\n },\n\n [RuleType.textEscaped]: {\n // We don't allow escaping numbers, letters, or spaces here so that\n // backslashes used in plain text still get rendered. But allowing\n // escaping anything else provides a very flexible escape mechanism,\n // regardless of how this grammar is extended.\n match: simpleInlineRegex(TEXT_ESCAPED_R),\n order: Priority.HIGH,\n parse(capture /*, parse, state*/) {\n return {\n text: capture[1],\n type: RuleType.text,\n }\n },\n },\n\n [RuleType.textMarked]: {\n match: simpleInlineRegex(TEXT_MARKED_R),\n order: Priority.LOW,\n parse: parseCaptureInline,\n render(node, output, state) {\n return <mark key={state.key}>{output(node.children, state)}</mark>\n },\n },\n\n [RuleType.textStrikethroughed]: {\n match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),\n order: Priority.LOW,\n parse: parseCaptureInline,\n render(node, output, state) {\n return <del key={state.key}>{output(node.children, state)}</del>\n },\n },\n }\n\n // Object.keys(rules).forEach(key => {\n // let { match: match, parse: parse } = rules[key]\n\n // rules[key].match = (...args) => {\n // const start = performance.now()\n // const result = match(...args)\n // const delta = performance.now() - start\n\n // if (delta > 5)\n // console.warn(\n // `Slow match for ${key}: ${delta.toFixed(3)}ms, input: ${args[0]}`\n // )\n\n // return result\n // }\n\n // rules[key].parse = (...args) => {\n // const start = performance.now()\n // const result = parse(...args)\n // const delta = performance.now() - start\n\n // if (delta > 5)\n // console.warn(`Slow parse for ${key}: ${delta.toFixed(3)}ms`)\n\n // console.log(`${key}:parse`, `${delta.toFixed(3)}ms`, args[0])\n\n // return result\n // }\n // })\n\n if (options.disableParsingRawHTML === true) {\n delete rules[RuleType.htmlBlock]\n delete rules[RuleType.htmlSelfClosing]\n }\n\n const parser = parserFor(rules)\n const emitter: Function = reactFor(createRenderer(rules, options.renderRule))\n\n const jsx = compile(markdown)\n\n if (footnotes.length) {\n return (\n <div>\n {jsx}\n <footer key=\"footer\">\n {footnotes.map(function createFootnote(def) {\n return (\n <div id={options.slugify(def.identifier)} key={def.identifier}>\n {def.identifier}\n {emitter(parser(def.footnote, { inline: true }))}\n </div>\n )\n })}\n </footer>\n </div>\n )\n }\n\n return jsx\n}\n\n/**\n * A simple HOC for easy React use. Feed the markdown content as a direct child\n * and the rest is taken care of automatically.\n */\nconst Markdown: React.FC<{\n [key: string]: any\n children: string\n options?: MarkdownToJSX.Options\n}> = ({ children, options, ...props }) => {\n if (process.env.NODE_ENV !== 'production' && typeof children !== 'string') {\n console.error(\n 'markdown-to-jsx: <Markdown> component only accepts a single string as a child, received:',\n children\n )\n }\n\n return React.cloneElement(\n compiler(children, options),\n props as JSX.IntrinsicAttributes\n )\n}\n\nexport namespace MarkdownToJSX {\n /**\n * RequireAtLeastOne<{ ... }> <- only requires at least one key\n */\n type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n > &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>\n }[Keys]\n\n export type CreateElement = typeof React.createElement\n\n export type HTMLTags = keyof JSX.IntrinsicElements\n\n export type State = {\n /** true if the current content is inside anchor link grammar */\n inAnchor?: boolean\n /** true if parsing in an inline context (subset of rules around formatting and links) */\n inline?: boolean\n /** true if in a table */\n inTable?: boolean\n /** use this for the `key` prop */\n key?: React.Key\n /** true if in a list */\n list?: boolean\n /** true if parsing in inline context w/o links */\n simple?: boolean\n }\n\n export interface BlockQuoteNode {\n children: MarkdownToJSX.ParserResult[]\n type: RuleType.blockQuote\n }\n\n export interface BreakLineNode {\n type: RuleType.breakLine\n }\n\n export interface BreakThematicNode {\n type: RuleType.breakThematic\n }\n\n export interface CodeBlockNode {\n type: RuleType.codeBlock\n attrs?: JSX.IntrinsicAttributes\n lang?: string\n text: string\n }\n\n export interface CodeFencedNode {\n type: RuleType.codeFenced\n }\n\n export interface CodeInlineNode {\n type: RuleType.codeInline\n text: string\n }\n\n export interface FootnoteNode {\n type: RuleType.footnote\n }\n\n export interface FootnoteReferenceNode {\n type: RuleType.footnoteReference\n target: string\n text: string\n }\n\n export interface GFMTaskNode {\n type: RuleType.gfmTask\n completed: boolean\n }\n\n export interface HeadingNode {\n type: RuleType.heading\n children: MarkdownToJSX.ParserResult[]\n id: string\n level: 1 | 2 | 3 | 4 | 5 | 6\n }\n\n export interface HeadingSetextNode {\n type: RuleType.headingSetext\n }\n\n export interface HTMLCommentNode {\n type: RuleType.htmlComment\n }\n\n export interface ImageNode {\n type: RuleType.image\n alt?: string\n target: string\n title?: string\n }\n\n export interface LinkNode {\n type: RuleType.link\n children: MarkdownToJSX.ParserResult[]\n target: string\n title?: string\n }\n\n export interface LinkAngleBraceNode {\n type: RuleType.linkAngleBraceStyleDetector\n }\n\n export interface LinkBareURLNode {\n type: RuleType.linkBareUrlDetector\n }\n\n export interface LinkMailtoNode {\n type: RuleType.linkMailtoDetector\n }\n\n export interface OrderedListNode {\n type: RuleType.orderedList\n items: MarkdownToJSX.ParserResult[][]\n ordered: true\n start?: number\n }\n\n export interface UnorderedListNode {\n type: RuleType.unorderedList\n items: MarkdownToJSX.ParserResult[][]\n ordered: false\n }\n\n export interface NewlineNode {\n type: RuleType.newlineCoalescer\n }\n\n export interface ParagraphNode {\n type: RuleType.paragraph\n children: MarkdownToJSX.ParserResult[]\n }\n\n export interface ReferenceNode {\n type: RuleType.ref\n }\n\n export interface ReferenceImageNode {\n type: RuleType.refImage\n alt?: string\n ref: string\n }\n\n export interface ReferenceLinkNode {\n type: RuleType.refLink\n children: MarkdownToJSX.ParserResult[]\n fallbackChildren: MarkdownToJSX.ParserResult[]\n ref: string\n }\n\n export interface TableNode {\n type: RuleType.table\n /**\n * alignment for each table column\n */\n align: ('left' | 'right' | 'center')[]\n cells: MarkdownToJSX.ParserResult[][][]\n header: MarkdownToJSX.ParserResult[][]\n }\n\n export interface TableSeparatorNode {\n type: RuleType.tableSeparator\n }\n\n export interface TextNode {\n type: RuleType.text\n text: string\n }\n\n export interface BoldTextNode {\n type: RuleType.textBolded\n children: MarkdownToJSX.ParserResult[]\n }\n\n export interface ItalicTextNode {\n type: RuleType.textEmphasized\n children: MarkdownToJSX.ParserResult[]\n }\n\n export interface EscapedTextNode {\n type: RuleType.textEscaped\n }\n\n export interface MarkedTextNode {\n type: RuleType.textMarked\n children: MarkdownToJSX.ParserResult[]\n }\n\n export interface StrikethroughTextNode {\n type: RuleType.textStrikethroughed\n children: MarkdownToJSX.ParserResult[]\n }\n\n export interface HTMLNode {\n type: RuleType.htmlBlock\n attrs: JSX.IntrinsicAttributes\n children?: ReturnType<MarkdownToJSX.NestedParser> | undefined\n noInnerParse: Boolean\n tag: MarkdownToJSX.HTMLTags\n text?: string | undefined\n }\n\n export interface HTMLSelfClosingNode {\n type: RuleType.htmlSelfClosing\n attrs: JSX.IntrinsicAttributes\n tag: string\n }\n\n export type ParserResult =\n | BlockQuoteNode\n | BreakLineNode\n | BreakThematicNode\n | CodeBlockNode\n | CodeFencedNode\n | CodeInlineNode\n | FootnoteNode\n | FootnoteReferenceNode\n | GFMTaskNode\n | HeadingNode\n | HeadingSetextNode\n | HTMLCommentNode\n | ImageNode\n | LinkNode\n | LinkAngleBraceNode\n | LinkBareURLNode\n | LinkMailtoNode\n | OrderedListNode\n | UnorderedListNode\n | NewlineNode\n | ParagraphNode\n | ReferenceNode\n | ReferenceImageNode\n | ReferenceLinkNode\n | TableNode\n | TableSeparatorNode\n | TextNode\n | BoldTextNode\n | ItalicTextNode\n | EscapedTextNode\n | MarkedTextNode\n | StrikethroughTextNode\n | HTMLNode\n | HTMLSelfClosingNode\n\n export type NestedParser = (\n input: string,\n state?: MarkdownToJSX.State\n ) => MarkdownToJSX.ParserResult[]\n\n export type Parser<ParserOutput> = (\n capture: RegExpMatchArray,\n nestedParse: NestedParser,\n state?: MarkdownToJSX.State\n ) => ParserOutput\n\n export type RuleOutput = (\n ast: MarkdownToJSX.ParserResult | MarkdownToJSX.ParserResult[],\n state: MarkdownToJSX.State\n ) => JSX.Element\n\n export type Rule<ParserOutput = MarkdownToJSX.ParserResult> = {\n match: (\n source: string,\n state: MarkdownToJSX.State,\n prevCapturedString?: string\n ) => RegExpMatchArray\n order: Priority\n parse: MarkdownToJSX.Parser<Omit<ParserOutput, 'type'>>\n render?: (\n node: ParserOutput,\n /**\n * Continue rendering AST nodes if applicable.\n */\n render: RuleOutput,\n state?: MarkdownToJSX.State\n ) => React.ReactChild\n }\n\n export type Rules = {\n [K in ParserResult['type']]: Rule<Extract<ParserResult, { type: K }>>\n }\n\n export type Override =\n | RequireAtLeastOne<{\n component: React.ElementType\n props: Object\n }>\n | React.ElementType\n\n export type Overrides = {\n [tag in HTMLTags]?: Override\n } & {\n [customComponent: string]: Override\n }\n\n export type Options = Partial<{\n /**\n * Ultimate control over the output of all rendered JSX.\n */\n createElement: (\n tag: Parameters<CreateElement>[0],\n props: JSX.IntrinsicAttributes,\n ...children: React.ReactChild[]\n ) => React.ReactChild\n\n /**\n * Disable the compiler's best-effort transcription of provided raw HTML\n * into JSX-equivalent. This is the functionality that prevents the need to\n * use `dangerouslySetInnerHTML` in React.\n */\n disableParsingRawHTML: boolean\n\n /**\n * Forces the compiler to have space between hash sign and the header text which\n * is explicitly stated in the most of the markdown specs.\n * https://github.github.com/gfm/#atx-heading\n * `The opening sequence of # characters must be followed by a space or by the end of line.`\n */\n enforceAtxHeadings: boolean\n\n /**\n * Forces the compiler to always output content with a block-level wrapper\n * (`<p>` or any block-level syntax your markdown already contains.)\n */\n forceBlock: boolean\n\n /**\n * Forces the compiler to always output content with an inline wrapper (`<span>`)\n */\n forceInline: boolean\n\n /**\n * Forces the compiler to wrap results, even if there is only a single\n * child or no children.\n */\n forceWrapper: boolean\n\n /**\n * Supply additional HTML entity: unicode replacement mappings.\n *\n * Pass only the inner part of the entity as the key,\n * e.g. `≤` -> `{ \"le\": \"\\u2264\" }`\n *\n * By default\n * the following entities are replaced with their unicode equivalents:\n *\n * ```\n * &\n * '\n * >\n * <\n * \n * "\n * ```\n */\n namedCodesToUnicode: {\n [key: string]: string\n }\n\n /**\n * Selectively control the output of particular HTML tags as they would be\n * emitted by the compiler.\n */\n overrides: Overrides\n\n /**\n * Allows for full control over rendering of particular rules.\n * For example, to implement a LaTeX renderer such as `react-katex`:\n *\n * ```\n * renderRule(next, node, renderChildren, state) {\n * if (node.type === RuleType.codeBlock && node.lang === 'latex') {\n * return (\n * <TeX as=\"div\" key={state.key}>\n * {String.raw`${node.text}`}\n * </TeX>\n * )\n * }\n *\n * return next();\n * }\n * ```\n *\n * Thar be dragons obviously, but you can do a lot with this\n * (have fun!) To see how things work internally, check the `render`\n * method in source for a particular rule.\n */\n renderRule: (\n /** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */\n next: () => React.ReactChild,\n /** the current AST node, use `RuleType` against `node.type` for identification */\n node: ParserResult,\n /** use as `renderChildren(node.children)` for block nodes */\n renderChildren: RuleOutput,\n /** contains `key` which should be supplied to the topmost JSX element */\n state: State\n ) => React.ReactChild\n\n /**\n * Override normalization of non-URI-safe characters for use in generating\n * HTML IDs for anchor linking purposes.\n */\n slugify: (source: string) => string\n\n /**\n * Declare the type of the wrapper to be used when there are multiple\n * children to render. Set to `null` to get an array of children back\n * without any wrapper, or use `React.Fragment` to get a React element\n * that won't show up in the DOM.\n */\n wrapper: React.ElementType | null\n }>\n}\n\nexport default Markdown\n"],"names":["RuleType","Priority","ATTRIBUTE_TO_JSX_PROP_MAP","reduce","obj","x","toLowerCase","for","namedCodesToUnicode","amp","apos","gt","lt","nbsp","quot","DO_NOT_PROCESS_HTML_ELEMENTS","ATTR_EXTRACTOR_R","AUTOLINK_MAILTO_CHECK_R","BLOCK_END_R","BLOCKQUOTE_R","BLOCKQUOTE_TRIM_LEFT_MULTILINE_R","BREAK_LINE_R","BREAK_THEMATIC_R","CODE_BLOCK_FENCED_R","CODE_BLOCK_R","CODE_INLINE_R","CONSECUTIVE_NEWLINE_R","CR_NEWLINE_R","FOOTNOTE_R","FOOTNOTE_REFERENCE_R","FORMFEED_R","FRONT_MATTER_R","GFM_TASK_R","HEADING_R","HEADING_ATX_COMPLIANT_R","HEADING_SETEXT_R","HTML_BLOCK_ELEMENT_R","HTML_CHAR_CODE_R","HTML_COMMENT_R","HTML_CUSTOM_ATTR_R","HTML_SELF_CLOSING_ELEMENT_R","INTERPOLATION_R","LINK_AUTOLINK_BARE_URL_R","LINK_AUTOLINK_MAILTO_R","LINK_AUTOLINK_R","CAPTURE_LETTER_AFTER_HYPHEN","NP_TABLE_R","REFERENCE_IMAGE_OR_LINK","REFERENCE_IMAGE_R","REFERENCE_LINK_R","SQUARE_BRACKETS_R","SHOULD_RENDER_AS_BLOCK_R","TAB_R","TABLE_SEPARATOR_R","TABLE_TRIM_PIPES","TABLE_CELL_END_TRIM","TABLE_CENTER_ALIGN","TABLE_LEFT_ALIGN","TABLE_RIGHT_ALIGN","TEXT_BOLD_R","TEXT_EMPHASIZED_R","TEXT_MARKED_R","TEXT_STRIKETHROUGHED_R","TEXT_ESCAPED_R","TEXT_PLAIN_R","TRIMstartING_NEWLINES","HTML_LEFT_TRIM_AMOUNT_R","UNESCAPE_URL_R","LIST_ITEM_END_R","LIST_LOOKBEHIND_R","ORDERED_LIST_BULLET","UNORDERED_LIST_BULLET","generateListItemPrefix","type","ORDERED_LIST_ITEM_PREFIX","UNORDERED_LIST_ITEM_PREFIX","generateListItemPrefixRegex","RegExp","ORDERED_LIST_ITEM_PREFIX_R","UNORDERED_LIST_ITEM_PREFIX_R","generateListItemRegex","ORDERED_LIST_ITEM_R","UNORDERED_LIST_ITEM_R","generateListRegex","bullet","ORDERED_LIST_R","UNORDERED_LIST_R","generateListRule","h","ordered","LIST_R","LIST_ITEM_R","LIST_ITEM_PREFIX_R","match","source","state","prevCapture","isStartOfLine","exec","list","inline","simple","order","parse","capture","start","undefined","items","replace","lastItemWasAParagraph","map","item","i","space","length","spaceRegex","content","isLastItem","thisItemIsAParagraph","indexOf","oldStateInline","oldStateList","adjustedContent","result","render","node","output","key","LINK_R","IMAGE_R","NON_PARAGRAPH_BLOCK_SYNTAXES","BLOCK_SYNTAXES","slugify","str","parseTableAlignCapture","alignCapture","test","parseTableRow","prevInTable","inTable","tableRow","trim","cells","forEach","push","text","parseTable","header","align","split","rowText","parseTableCells","getTableStyle","colIndex","textAlign","inlineRegex","regex","simpleInlineRegex","blockRegex","anyScopeRegex","matchParagraph","prevCapturedString","endsWith","every","line","some","captured","trimEnd","sanitizeUrl","url","decodeURIComponent","e","unescapeUrl","rawUrlString","parseInline","children","isCurrentlyInline","isCurrentlySimple","parseSimpleInline","parseBlock","parseCaptureInline","captureNothing","renderNothing","cx","args","filter","Boolean","join","get","src","path","fb","ptr","frags","shift","compiler","markdown","options","overrides","_extends","createElementFn","createElement","React","tag","props","overrideProps","override","getTag","className","compile","input","forceInline","forceBlock","arr","emitter","parser","pop","wrapper","jsx","forceWrapper","attrStringToMap","attributes","raw","index","delimiterIdx","_","letter","toUpperCase","normalizeAttributeKey","slice","value","first","unquote","mappedKey","normalizedValue","styles","kvPair","substr","attributeValueToJSXPropValue","cloneElement","footnotes","refs","rules","__","lang","attrs","footnote","identifier","target","href","completed","checked","readOnly","enforceAtxHeadings","id","level","whitespace","trimmer","trimmed","parseFunc","r","tagName","noInnerParse","ast","inAnchor","alt","title","address","ref","fallbackChildren","style","row","c","full","inner","disableParsingRawHTML","ruleList","Object","keys","nestedParse","ruleType","rule","currCaptureString","substring","parsed","sort","typeA","typeB","orderA","orderB","normalizeWhitespace","parserFor","userRender","renderer","createRenderer","renderRule","patchedRender","Array","isArray","oldKey","lastWasString","nodeOut","isString","def","_ref","_objectWithoutPropertiesLoose","_excluded"],"mappings":"2RAckB,IAAAA,EA0CPC,GA1CX,SAAkBD,GAChBA,iBACAA,gBACAA,oBACAA,gBACAA,iBACAA,iBACAA,eACAA,wBACAA,cACAA,cACAA,qBAEAA,iBACAA,mBAEAA,uBACAA,aACAA,YAEAA,mCAEAA,2BAEAA,0BACAA,wBACAA,mBACAA,iBACAA,WACAA,gBACAA,eACAA,aACAA,sBACAA,YACAA,kBACAA,sBACAA,mBACAA,kBACAA,2BACAA,oBACD,CAxCD,CAAkBA,IAAAA,OA0ClB,SAAWC,GAITA,iBAIAA,mBAIAA,iBAIAA,iBAIAA,gBACD,CArBD,CAAWA,IAAAA,OAwBX,MAAMC,EAA4B,CAChC,kBACA,oBACA,eACA,YACA,WACA,cACA,cACA,UACA,YACA,UACA,UACA,kBACA,cACA,cACA,UACA,aACA,cACA,aACA,iBACA,aACA,cACA,WACA,YACA,YACA,UACA,eACA,cACA,YACA,aACA,YACA,aACA,aACA,WACA,UACA,aACA,SACA,UACA,SACA,WACA,UACAC,OACA,CAACC,EAAKC,KACJD,EAAIC,EAAEC,eAAiBD,EAChBD,GAET,CAAEG,IAAK,YAGHC,EAAsB,CAC1BC,IAAK,IACLC,KAAM,IACNC,GAAI,IACJC,GAAI,IACJC,KAAM,IACNC,KAAM,KAGFC,EAA+B,CAAC,QAAS,UAkCzCC,EACJ,+GAIIC,EAA0B,WAC1BC,EAAc,UACdC,EAAe,oCACfC,EAAmC,WACnCC,EAAe,WACfC,EAAmB,kCACnBC,EACJ,qEACIC,EAAe,kCACfC,EAAgB,mCAChBC,EAAwB,eACxBC,EAAe,SACfC,EAAa,wBACbC,EAAuB,iBACvBC,EAAa,MACbC,EAAiB,mCACjBC,EAAa,kBACbC,EAAY,mDACZC,EACJ,mDACIC,EAAmB,sCAwBnBC,EACJ,wHAEIC,EAAmB,iDAEnBC,EAAiB,uBAKjBC,EAAqB,oCAErBC,EACJ,wEACIC,EAAkB,WAClBC,EAA2B,uCAC3BC,EAAyB,qBACzBC,EAAkB,uBAClBC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