UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

112 lines (99 loc) • 49 kB
/*! # License information ## Contribution License Agreement If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. `</legalese>` ## Marked Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/) Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Markdown Copyright © 2004, John Gruber http://daringfireball.net/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name “Markdown” 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 owner 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. */ var marked=(()=>{var M=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var Pe=(r,e,t)=>e in r?M(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Le=(r,e)=>{for(var t in e)M(r,t,{get:e[t],enumerable:!0})},Ee=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ae(e))!_e.call(r,n)&&n!==t&&M(r,n,{get:()=>e[n],enumerable:!(s=ze(e,n))||s.enumerable});return r};var Ie=r=>Ee(M({},"__esModule",{value:!0}),r);var b=(r,e,t)=>Pe(r,typeof e!="symbol"?e+"":e,t);var Dt={};Le(Dt,{Hooks:()=>E,Lexer:()=>$,Marked:()=>$e,Parser:()=>y,Renderer:()=>v,TextRenderer:()=>X,Tokenizer:()=>q,defaults:()=>A,getDefaults:()=>U,lexer:()=>Zt,marked:()=>x,options:()=>Et,parse:()=>qt,parseInline:()=>Bt,parser:()=>vt,setOptions:()=>It,use:()=>ye,walkTokens:()=>Ct});function U(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A=U();function ge(r){A=r}var _={exec:()=>null};function L(r){let e=[];return t=>{let s=Math.max(0,Math.min(3,t-1)),n=e[s];return n||(n=r(s),e[s]=n),n}}function f(r,e=""){let t=typeof r=="string"?r:r.source,s={replace:(n,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(w.caret,"$1"),t=t.replace(n,a),s},getRegex:()=>new RegExp(t,e)};return s}var Ce=((r="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+r)}catch(e){return!1}})(),w={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:L(r=>new RegExp(`^ {0,${r}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:L(r=>new RegExp(`^ {0,${r}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:L(r=>new RegExp(`^ {0,${r}}(?:\`\`\`|~~~)`)),headingBeginRegex:L(r=>new RegExp(`^ {0,${r}}#`)),htmlBeginRegex:L(r=>new RegExp(`^ {0,${r}}(?:</?(?:${D})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,"i")),blockquoteBeginRegex:L(r=>new RegExp(`^ {0,${r}}>`))},Be=/^(?:[ \t]*(?:\n|$))+/,qe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ve=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Z=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ze=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,V=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ke=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=f(ke).replace(/bull/g,V).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),De=f(ke).replace(/bull/g,V).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Y=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Oe=/^[^\n]+/,ee=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qe=f(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ee).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Me=f(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,V).getRegex(),D="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",te=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,je=f("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",te).replace("tag",D).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),de=r=>f(Y).replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",r).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),He=de(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Ne=de(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Ge=f(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ne).getRegex(),re={blockquote:Ge,code:qe,def:Qe,fences:ve,heading:Ze,hr:Z,html:je,lheading:fe,list:Me,newline:Be,paragraph:He,table:_,text:Oe},se=f("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),Ue={...re,lheading:De,table:se,paragraph:f(Y).replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",se).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex()},Xe={...re,html:f(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",te).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:_,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:f(Y).replace("hr",Z).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",fe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},We=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Fe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,xe=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Je=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,T=/[\p{P}\p{S}]/u,I=/[\s\p{P}\p{S}]/u,O=/[^\s\p{P}\p{S}]/u,Ke=f(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,I).getRegex(),Ve=/[\p{Pi}\p{Ps}"']/u,be=/(?!~)[\p{P}\p{S}]/u,Ye=/(?!~)[\s\p{P}\p{S}]/u,et=/(?:[^\s\p{P}\p{S}]|~)/u,tt=f(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ce?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),we=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,rt=f(we,"u").replace(/punct/g,T).getRegex(),nt=f(we,"u").replace(/punct/g,be).getRegex(),st=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,it=f(st,"u").replace(/openQuote/g,Ve).replace(/punct/g,T).getRegex(),me="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",lt=f(me,"gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,I).replace(/punct/g,T).getRegex(),at=f(me,"gu").replace(/notPunctSpace/g,et).replace(/punctSpace/g,Ye).replace(/punct/g,be).getRegex(),ot="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ct=f(ot,"gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,I).replace(/punct/g,T).getRegex(),ht=f("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,I).replace(/punct/g,T).getRegex(),pt="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",ut=f(pt,"gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,I).replace(/punct/g,T).getRegex(),gt=f(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,T).getRegex(),kt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ft=f(kt,"gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,I).replace(/punct/g,T).getRegex(),dt=f(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),xt=f(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),bt=f(te).replace("(?:-->|$)","-->").getRegex(),wt=f("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",bt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Se=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,N=f(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",Se).getRegex(),mt=f(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",N).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),St=f(/^!?\[(label)\]\[(ref)\]/).replace("label",N).replace("ref",ee).getRegex(),$t=f(/^!?\[(ref)\](?:\[\])?/).replace("ref",ee).getRegex(),ie=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,yt=f(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",Se).getRegex(),Rt=f("reflink|nolink(?!\\()","g").replace("reflink",f(/^!?\[(label)\]\[(ref)\]/).replace("label",yt).replace("ref",ie).getRegex()).replace("nolink",f(/^!?\[(ref)\](?:\[\])?/).replace("ref",ie).getRegex()).getRegex(),le=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ne={_backpedal:_,anyPunctuation:dt,autolink:xt,blockSkip:tt,br:xe,code:Fe,del:_,delLDelim:_,delRDelim:_,emStrongLDelim:rt,emStrongRDelimAst:lt,emStrongRDelimUnd:ht,escape:We,link:mt,nolink:$t,punctuation:Ke,reflink:St,reflinkSearch:Rt,tag:wt,text:Je,url:_},Tt={...ne,emStrongLDelim:it,emStrongRDelimAst:ct,emStrongRDelimUnd:ut,link:f(/^!?\[(label)\]\((.*?)\)/).replace("label",N).getRegex(),reflink:f(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",N).getRegex()},F={...ne,emStrongRDelimAst:at,emStrongLDelim:nt,delLDelim:gt,delRDelim:ft,url:f(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",le).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:f(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",le).getRegex()},zt={...F,br:f(xe).replace("{2,}","*").getRegex(),text:f(F.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},j={normal:re,gfm:Ue,pedantic:Xe},B={normal:ne,gfm:F,breaks:zt,pedantic:Tt},At={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ae=r=>At[r];function S(r,e){if(e){if(w.escapeTest.test(r))return r.replace(w.escapeReplace,ae)}else if(w.escapeTestNoEncode.test(r))return r.replace(w.escapeReplaceNoEncode,ae);return r}function oe(r){try{r=encodeURI(r).replace(w.percentDecode,"%")}catch(e){return null}return r}function ce(r,e){var l;let t=r.replace(w.findPipe,(a,o,i)=>{let h=!1,c=o;for(;--c>=0&&i[c]==="\\";)h=!h;return h?"|":" |"}),s=t.split(w.splitPipe),n=0;if(s[0].trim()||s.shift(),s.length>0&&!((l=s.at(-1))!=null&&l.trim())&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;n<s.length;n++)s[n]=s[n].trim().replace(w.slashPipe,"|");return s}function z(r,e,t){let s=r.length;if(s===0)return"";let n=0;for(;n<s;){let l=r.charAt(s-n-1);if(l===e&&!t)n++;else if(l!==e&&t)n++;else break}return r.slice(0,s-n)}function he(r){let e=r.split(` `),t=e.length-1;for(;t>=0&&w.blankLine.test(e[t]);)t--;return e.length-t<=2?r:e.slice(0,t+1).join(` `)}function G(r){return r.toLowerCase().toUpperCase().toLowerCase()}function _t(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<r.length;s++)if(r[s]==="\\")s++;else if(r[s]===e[0])t++;else if(r[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function Pt(r,e=0){let t=e,s="";for(let n of r)if(n===" "){let l=4-t%4;s+=" ".repeat(l),t+=l}else s+=n,t++;return s}function pe(r,e,t,s,n){let l=e.href,a=e.title||null,o=r[1].replace(n.other.outputLinkReplace,"$1"),i=r[0].charAt(0)==="!";s.state.inLink=!0;let h=s.state.linkEmitted,c=s.state.inRawBlock;s.state.linkEmitted=!1;let u=s.inlineTokens(o),g=s.state.linkEmitted;if(s.state.linkEmitted=h,s.state.inLink=!1,!i){if(g){s.state.inRawBlock=c;return}s.state.linkEmitted=!0}return{type:i?"image":"link",raw:t,href:l,title:a,text:o,tokens:u}}function Lt(r,e,t){let s=r.match(t.other.indentCodeCompensation);if(s===null)return e;let n=s[1];return e.split(` `).map(l=>{let a=l.match(t.other.beginningSpace);if(a===null)return l;let[o]=a;return l.slice(Math.min(o.length,n.length))}).join(` `)}function ue(r,e,t,s){if(!e.includes("<"))return!1;for(let n=0;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="`"){let o=s.inline.code.exec(e.slice(n));if(o){n+=o[0].length-1;continue}}if(e[n]!=="<")continue;let l=r.slice(t+n),a=s.inline.tag.exec(l)||s.inline.autolink.exec(l);if(a){if(a[0].length>e.length-n)return!0;n+=a[0].length-1}}return!1}var q=class{constructor(r){b(this,"options");b(this,"rules");b(this,"lexer");this.options=r||A}space(r){let e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(r){let e=this.rules.block.code.exec(r);if(e){let t=this.options.pedantic?e[0]:he(e[0]),s=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:s}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let t=e[0],s=Lt(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=z(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceTabChar.test(s))&&(t=s.trim())}return{type:"heading",raw:z(e[0],` `),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:z(e[0],` `)}}blockquote(r){let e=this.rules.block.blockquote.exec(r);if(e){let t=z(e[0],` `).split(` `),s="",n="",l=[];for(;t.length>0;){let a=!1,o=[],i;for(i=0;i<t.length;i++)if(this.rules.other.blockquoteStart.test(t[i]))o.push(t[i]),a=!0;else if(!a)o.push(t[i]);else break;t=t.slice(i);let h=o.join(` `),c=h.replace(this.rules.other.blockquoteSetextReplace,` $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s} ${h}`:h,n=n?`${n} ${c}`:c;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,l,!0),this.lexer.state.top=u,t.length===0)break;let g=l.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let p=g,d=t.join(` `),k=p.raw+` `+d.replace(this.rules.other.blockquoteSetextReplace2,""),m=this.blockquote(k);l[l.length-1]=m,s=`${s} ${d}`,n=n.substring(0,n.length-p.text.length)+m.text;break}else if((g==null?void 0:g.type)==="list"){let p=g,d=p.raw+` `+t.join(` `),k=this.list(d);l[l.length-1]=k,s=s.substring(0,s.length-g.raw.length)+k.raw,n=n.substring(0,n.length-p.raw.length)+k.raw,t=d.substring(l.at(-1).raw.length).split(` `);continue}}return{type:"blockquote",raw:s,tokens:l,text:n}}}list(r){let e=this.rules.block.list.exec(r);if(e){let t=e[1].trim(),s=t.length>1,n={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let l=this.rules.other.listItemRegex(t),a=!1;for(;r;){let i=!1,h="",c="";if(!(e=l.exec(r))||this.rules.block.hr.test(r))break;h=e[0],r=r.substring(h.length);let u=Pt(e[2].split(` `,1)[0],e[1].length),g=r.split(` `,1)[0],p=!u.trim(),d=0;if(this.options.pedantic?(d=2,c=u.trimStart()):p?d=e[1].length+1:(d=u.search(this.rules.other.nonSpaceChar),d=d>4?1:d,c=u.slice(d),d+=e[1].length),p&&this.rules.other.blankLine.test(g)&&(h+=g+` `,r=r.substring(g.length+1),i=!0),!i){let k=this.rules.other.nextBulletRegex(d),m=this.rules.other.hrRegex(d),R=this.rules.other.fencesBeginRegex(d),Q=this.rules.other.headingBeginRegex(d),Re=this.rules.other.htmlBeginRegex(d),Te=this.rules.other.blockquoteBeginRegex(d);for(;r;){let W=r.split(` `,1)[0],C;if(g=W,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),R.test(g)||Q.test(g)||Re.test(g)||Te.test(g)||k.test(g)||m.test(g))break;if(C.search(this.rules.other.nonSpaceChar)>=d||!g.trim())c+=` `+C.slice(d);else{if(p||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(u)||Q.test(u)||m.test(u))break;c+=` `+g}p=!g.trim(),h+=W+` `,r=r.substring(W.length+1),u=C.slice(d)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),n.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),n.raw+=h}let o=n.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let i of n.items)if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),!n.loose){let h=i.tokens.filter(u=>u.type==="space"),c=h.length>0&&h.some(u=>this.rules.other.anyLine.test(u.raw));n.loose=c}for(let i of n.items){let h=i.tokens[0];if(i.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){i.text=i.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(i.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};i.checked=u.checked,n.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=u.raw+i.tokens[0].raw,i.tokens[0].text=u.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(u)):i.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):i.tokens.unshift(u)}}else i.task&&(i.task=!1)}if(n.loose)for(let i of n.items){i.loose=!0;for(let h of i.tokens)h.type==="text"&&(h.type="paragraph")}return n}}html(r){let e=this.rules.block.html.exec(r);if(e){let t=he(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(r){let e=this.rules.block.def.exec(r);if(e){let t=G(e[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:z(e[0],` `),href:s,title:n}}}table(r){var a;let e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=ce(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=(a=e[3])!=null&&a.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(` `):[],l={type:"table",raw:z(e[0],` `),header:[],align:[],rows:[]};if(t.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?l.align.push("right"):this.rules.other.tableAlignCenter.test(o)?l.align.push("center"):this.rules.other.tableAlignLeft.test(o)?l.align.push("left"):l.align.push(null);for(let o=0;o<t.length;o++)l.header.push({text:t[o],tokens:this.lexer.inline(t[o]),header:!0,align:l.align[o]});for(let o of n)l.rows.push(ce(o,l.header.length).map((i,h)=>({text:i,tokens:this.lexer.inline(i),header:!1,align:l.align[h]})));return l}}lheading(r){let e=this.rules.block.lheading.exec(r);if(e){let t=e[1].trim();return{type:"heading",raw:z(e[0],` `),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(r){let e=this.rules.block.paragraph.exec(r);if(e){let t=e[1].charAt(e[1].length-1)===` `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(r){let e=this.rules.inline.link.exec(r);if(e){let t=e[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&ue(r,e[1],t,this.rules))return;let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let a=z(s.slice(0,-1),"\\");if((s.length-a.length)%2===0)return}else{let a=_t(e[2],"()");if(a===-2)return;if(a>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let n=e[2],l="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(n);a&&(n=a[1],l=a[3])}else l=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?n=n.slice(1):n=n.slice(1,-1)),pe(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let t;if((t=this.rules.inline.reflink.exec(r))||(t=this.rules.inline.nolink.exec(r))){let s=t[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&ue(r,t[1],s,this.rules))return;let n=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),l=e[G(n)];if(!l){let a=t[0].charAt(0);return{type:"text",raw:a,text:a}}return pe(t,l,t[0],this.lexer,this.rules)}}emStrong(r,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(r);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!t||this.rules.inline.punctuation.exec(t))){let n=[...s[0]].length-1,l,a,o=n,i=0,h=s[0][0],c=t===h,u=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*r.length+n);(s=u.exec(e))!==null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(a=[...l].length,s[3]||s[4]){o+=a;continue}else if(s[5]||s[6]){if(n%3&&!((n+a)%3)){i+=a;continue}if(c)break}if(o-=a,o>0)continue;a=Math.min(a,a+o+i);let g=[...s[0]][0].length,p=r.slice(0,n+s.index+g+a);if(Math.min(n,a)%2){let k=p.slice(1,-1);return{type:"em",raw:p,text:k,tokens:this.lexer.inlineTokens(k)}}let d=p.slice(2,-2);return{type:"strong",raw:p,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r,e,t=""){let s=this.rules.inline.delLDelim.exec(r);if(s&&(!s[1]||!t||this.rules.inline.punctuation.exec(t))){let n=[...s[0]].length-1,l,a,o=n,i=this.rules.inline.delRDelim;for(i.lastIndex=0,e=e.slice(-1*r.length+n);(s=i.exec(e))!==null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l||(a=[...l].length,a!==n))continue;if(s[3]||s[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let h=[...s[0]][0].length,c=r.slice(0,n+s.index+h+a),u=c.slice(n,-n);return{type:"del",raw:c,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,autolink:!0,tokens:[{type:"text",raw:t,text:t}]}}}url(r){var t,s;let e;if(e=this.rules.inline.url.exec(r)){let n,l;if(e[2]==="@")n=e[0],l="mailto:"+n;else{let a;do a=e[0],e[0]=(s=(t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])!=null?s:"";while(a!==e[0]);n=e[0],e[1]==="www."?l="http://"+e[0]:l=e[0]}return{type:"link",raw:e[0],text:n,href:l,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},$=class J{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||A,this.options.tokenizer=this.options.tokenizer||new q,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:w,block:j.normal,inline:B.normal};this.options.pedantic?(t.block=j.pedantic,t.inline=B.pedantic):this.options.gfm&&(t.block=j.gfm,this.options.breaks?t.inline=B.breaks:t.inline=B.gfm),this.tokenizer.rules=t}static get rules(){return{block:j,inline:B}}static lex(e,t){return new J(t).lex(e)}static lexInline(e,t){return new J(t).inlineTokens(e)}lex(e){e=e.replace(w.carriageReturn,` `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){var l,a,o;this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(w.tabCharGlobal," ").replace(w.spaceLine,""));let n=1/0;for(;e;){if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if((a=(l=this.options.extensions)==null?void 0:l.block)!=null&&a.some(c=>(i=c.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let c=t.at(-1);i.raw.length===1&&c!==void 0?c.raw+=` `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let c=t.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(` `)?"":` `)+i.raw,c.text+=` `+i.text,this.inlineQueue.at(-1).src=c.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let c=t.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(` `)?"":` `)+i.raw,c.text+=` `+i.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let h=e;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,u=e.slice(1),g;this.options.extensions.startBlock.forEach(p=>{g=p.call({lexer:this},u),typeof g=="number"&&g>=0&&(c=Math.min(c,g))}),c<1/0&&c>=0&&(h=e.substring(0,c+1))}if(this.state.top&&(i=this.tokenizer.paragraph(h))){let c=t.at(-1);s&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(` `)?"":` `)+i.raw,c.text+=` `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):t.push(i),s=h.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let c=t.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(` `)?"":` `)+i.raw,c.text+=` `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes("["))return!1;let t=this.tokenizer.rules.inline.link;for(let s of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(s[0])&&e.charAt(s.index-1)!=="!")return!0;for(let s of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let n=s[0],l=n.lastIndexOf("[");if(!(n.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,G(n.slice(l+1,-1))))&&!(l>1&&this.linkInText(n.slice(1,l-1))))return!0}return!1}inlineTokens(e,t=[]){var o,i,h,c,u,g;this.tokenizer.lexer=this;let s=e;if(this.tokens.links&&e.includes("[")){let p=this.tokenizer.rules.inline.reflinkSearch,d=k=>{let m=k.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,G(k.slice(m+1,-1))))return k;if(m>1&&k.charAt(0)!=="!"){let R=k.slice(1,m-1);if(this.linkInText(R))return"["+R.replace(p,d)+"]["+"a".repeat(k.length-m-2)+"]"}return"["+"a".repeat(k.length-2)+"]"};s=s.replace(p,d)}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,p=>"+".repeat(p.length)),s=s.replace(this.tokenizer.rules.inline.blockSkip,(p,d,k)=>{let m=k?k.length:0;return p.slice(0,m)+"["+"a".repeat(p.length-m-2)+"]"}),s=(h=(i=(o=this.options.hooks)==null?void 0:o.emStrongMask)==null?void 0:i.call({lexer:this},s))!=null?h:s;let n=!1,l="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}n||(l=""),n=!1;let p;if((u=(c=this.options.extensions)==null?void 0:c.inline)!=null&&u.some(k=>(p=k.call({lexer:this},e,t))?(e=e.substring(p.raw.length),t.push(p),!0):!1))continue;if(p=this.tokenizer.escape(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.tag(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.link(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(p.raw.length);let k=t.at(-1);p.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=p.raw,k.text+=p.text):t.push(p);continue}if(p=this.tokenizer.emStrong(e,s,l)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.codespan(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.br(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.del(e,s,l)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.autolink(e)){e=e.substring(p.raw.length),t.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(e))){e=e.substring(p.raw.length),t.push(p);continue}let d=e;if((g=this.options.extensions)!=null&&g.startInline){let k=1/0,m=e.slice(1),R;this.options.extensions.startInline.forEach(Q=>{R=Q.call({lexer:this},m),typeof R=="number"&&R>=0&&(k=Math.min(k,R))}),k<1/0&&k>=0&&(d=e.substring(0,k+1))}if(p=this.tokenizer.inlineText(d)){e=e.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(l=p.raw.slice(-1)),n=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=p.raw,k.text+=p.text):t.push(p);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},v=class{constructor(r){b(this,"options");b(this,"parser");this.options=r||A}space(r){return""}code({text:r,lang:e,escaped:t}){var l;let s=(l=(e||"").match(w.notSpaceStart))==null?void 0:l[0],n=r?r.replace(w.endingNewline,"")+` `:"";return s?'<pre><code class="language-'+S(s)+'">'+(t?n:S(n,!0))+`</code></pre> `:"<pre><code>"+(t?n:S(n,!0))+`</code></pre> `}blockquote({tokens:r}){return`<blockquote> ${this.parser.parse(r)}</blockquote> `}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:e}){return`<h${e}>${this.parser.parseInline(r)}</h${e}> `}hr(r){return`<hr> `}list(r){let e=r.ordered,t=r.start,s="";for(let a=0;a<r.items.length;a++){let o=r.items[a];s+=this.listitem(o)}let n=e?"ol":"ul",l=e&&t!==1?' start="'+t+'"':"";return"<"+n+l+`> `+s+"</"+n+`> `}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li> `}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p> `}table(r){let e="",t="";for(let n=0;n<r.header.length;n++)t+=this.tablecell(r.header[n]);e+=this.tablerow({text:t});let s="";for(let n=0;n<r.rows.length;n++){let l=r.rows[n];t="";for(let a=0;a<l.length;a++)t+=this.tablecell(l[a]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table> <thead> `+e+`</thead> `+s+`</table> `}tablerow({text:r}){return`<tr> ${r}</tr> `}tablecell(r){let e=this.parser.parseInline(r.tokens),t=r.header?"th":"td";return(r.align?`<${t} align="${r.align}">`:`<${t}>`)+e+`</${t}> `}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${S(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,text:t,tokens:s,autolink:n}){let l=n?S(t,!0):this.parser.parseInline(s),a=oe(r);if(a===null)return l;r=S(a,n);let o='<a href="'+r+'"';return e&&(o+=' title="'+S(e)+'"'),o+=">"+l+"</a>",o}image({href:r,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let n=oe(r);if(n===null)return S(t);r=n;let l=`<img src="${S(r)}" alt="${S(t)}"`;return e&&(l+=` title="${S(e)}"`),l+=">",l}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:S(r.text)}},X=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},y=class K{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||A,this.options.renderer=this.options.renderer||new v,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new X}static parse(e,t){return new K(t).parse(e)}static parseInline(e,t){return new K(t).parseInline(e)}parse(e){var s,n;this.renderer.parser=this;let t="";for(let l=0;l<e.length;l++){let a=e[l];if((n=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&n[a.type]){let i=a,h=this.options.extensions.renderers[i.type].call({parser:this},i);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(i.type)){t+=h||"";continue}}let o=a;switch(o.type){case"space":{t+=this.renderer.space(o);break}case"hr":{t+=this.renderer.hr(o);break}case"heading":{t+=this.renderer.heading(o);break}case"code":{t+=this.renderer.code(o);break}case"table":{t+=this.renderer.table(o);break}case"blockquote":{t+=this.renderer.blockquote(o);break}case"list":{t+=this.renderer.list(o);break}case"checkbox":{t+=this.renderer.checkbox(o);break}case"html":{t+=this.renderer.html(o);break}case"def":{t+=this.renderer.def(o);break}case"paragraph":{t+=this.renderer.paragraph(o);break}case"text":{t+=this.renderer.text(o);break}default:{let i='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return t}parseInline(e,t=this.renderer){var n,l;this.renderer.parser=this;let s="";for(let a=0;a<e.length;a++){let o=e[a];if((l=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&l[o.type]){let h=this.options.extensions.renderers[o.type].call({parser:this},o);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){s+=h||"";continue}}let i=o;switch(i.type){case"escape":{s+=t.text(i);break}case"html":{s+=t.html(i);break}case"link":{s+=t.link(i);break}case"image":{s+=t.image(i);break}case"checkbox":{s+=t.checkbox(i);break}case"strong":{s+=t.strong(i);break}case"em":{s+=t.em(i);break}case"codespan":{s+=t.codespan(i);break}case"br":{s+=t.br(i);break}case"del":{s+=t.del(i);break}case"text":{s+=t.text(i);break}default:{let h='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return s}},H,E=(H=class{constructor(r){b(this,"options");b(this,"block");this.options=r||A}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(r=this.block){return r?$.lex:$.lexInline}provideParser(r=this.block){return r?y.parse:y.parseInline}},b(H,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(H,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),H),$e=class{constructor(...r){b(this,"defaults",U());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",y);b(this,"Renderer",v);b(this,"TextRenderer",X);b(this,"Lexer",$);b(this,"Tokenizer",q);b(this,"Hooks",E);this.use(...r)}walkTokens(r,e){var s,n;let t=[];for(let l of r)switch(t=t.concat(e.call(this,l)),l.type){case"table":{let a=l;for(let o of a.header)t=t.concat(this.walkTokens(o.tokens,e));for(let o of a.rows)for(let i of o)t=t.concat(this.walkTokens(i.tokens,e));break}case"list":{let a=l;t=t.concat(this.walkTokens(a.items,e));break}default:{let a=l;(n=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&n[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{let i=a[o].flat(1/0);t=t.concat(this.walkTokens(i,e))}):a.tokens&&(t=t.concat(this.walkTokens(a.tokens,e)))}}return t}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let l=e.renderers[n.name];l?e.renderers[n.name]=function(...a){let o=n.renderer.apply(this,a);return o===!1&&(o=l.apply(this,a)),o}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let l=e[n.level];l?l.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),s.extensions=e),t.renderer){let n=this.defaults.renderer||new v(this.defaults);for(let l in t.renderer){if(!(l in n))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let a=l,o=t.renderer[a],i=n[a];n[a]=(...h)=>{let c=o.apply(n,h);return c===!1&&(c=i.apply(n,h)),c||""}}s.renderer=n}if(t.tokenizer){let n=this.defaults.tokenizer||new q(this.defaults);for(let l in t.tokenizer){if(!(l in n))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let a=l,o=t.tokenizer[a],i=n[a];n[a]=(...h)=>{let c=o.apply(n,h);return c===!1&&(c=i.apply(n,h)),c}}s.tokenizer=n}if(t.hooks){let n=this.defaults.hooks||new E;for(let l in t.hooks){if(!(l in n))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let a=l,o=t.hooks[a],i=n[a];E.passThroughHooks.has(l)?n[a]=h=>{if(this.defaults.async&&E.passThroughHooksRespectAsync.has(l))return(async()=>{let u=await o.call(n,h);return i.call(n,u)})();let c=o.call(n,h);return i.call(n,c)}:n[a]=(...h)=>{if(this.defaults.async)return(async()=>{let u=await o.apply(n,h);return u===!1&&(u=await i.apply(n,h)),u})();let c=o.apply(n,h);return c===!1&&(c=i.apply(n,h)),c}}s.hooks=n}if(t.walkTokens){let n=this.defaults.walkTokens,l=t.walkTokens;s.walkTokens=function(a){let o=[];return o.push(l.call(this,a)),n&&(o=o.concat(n.call(this,a))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return $.lex(r,e!=null?e:this.defaults)}parser(r,e){return y.parse(r,e!=null?e:this.defaults)}parseMarkdown(r){return(e,t)=>{let s={...t},n={...this.defaults,...s},l=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=r),n.async)return(async()=>{let a=n.hooks?await n.hooks.preprocess(e):e,o=await(n.hooks?await n.hooks.provideLexer(r):r?$.lex:$.lexInline)(a,n),i=n.hooks?await n.hooks.processAllTokens(o):o;n.walkTokens&&await Promise.all(this.walkTokens(i,n.walkTokens));let h=await(n.hooks?await n.hooks.provideParser(r):r?y.parse:y.parseInline)(i,n);return n.hooks?await n.hooks.postprocess(h):h})().catch(l);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer(r):r?$.lex:$.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let o=(n.hooks?n.hooks.provideParser(r):r?y.parse:y.parseInline)(a,n);return n.hooks&&(o=n.hooks.postprocess(o)),o}catch(a){return l(a)}}}onError(r,e){return t=>{if(t.message+=` Please report this to https://github.com/markedjs/marked.`,r){let s="<p>An error occurred:</p><pre>"+S(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},P=new $e;function x(r,e){return P.parse(r,e)}x.options=x.setOptions=function(r){return P.setOptions(r),x.defaults=P.defaults,ge(x.defaults),x};x.getDefaults=U;x.defaults=A;function ye(...r){return P.use(...r),x.defaults=P.defaults,ge(x.defaults),x}x.use=ye;x.walkTokens=function(r,e){return P.walkTokens(r,e)};x.parseInline=P.parseInline;x.Parser=y;x.parser=y.parse;x.Renderer=v;x.TextRenderer=X;x.Lexer=$;x.lexer=$.lex;x.Tokenizer=q;x.Hooks=E;x.parse=x;var Et=x.options,It=x.setOptions,Ct=x.walkTokens,Bt=x.parseInline,qt=x,vt=y.parse,Zt=$.lex;return Ie(Dt);})();