marked.esm.CbTws8Ir.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var we=Object.defineProperty;var me=(t,e,r)=>e in t?we(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var f=(t,e,r)=>me(t,typeof e!="symbol"?e+"":e,r);function H(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var T=H();function ae(t){T=t}var L={exec:()=>null};function g(t,e=""){let r=typeof t=="string"?t:t.source,s={replace:(n,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(b.caret,"$1"),r=r.replace(n,c),s},getRegex:()=>new RegExp(r,e)};return s}var b={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,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,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ 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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},ye=/^(?:[ \t]*(?:\n|$))+/,$e=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Se=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,v=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Re=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,G=/(?:[*+-]|\d{1,9}[.)])/,oe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ce=g(oe).replace(/bull/g,G).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}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Te=g(oe).replace(/bull/g,G).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}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),W=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ze=/^[^\n]+/,X=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ae=g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",X).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_e=g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,G).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",F=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pe=g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",F).replace("tag",D).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),he=g(W).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),Ie=g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",he).getRegex(),U={blockquote:Ie,code:$e,def:Ae,fences:Se,heading:Re,hr:v,html:Pe,lheading:ce,list:_e,newline:ye,paragraph:he,table:L,text:ze},re=g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),Le={...U,lheading:Te,table:re,paragraph:g(W).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex()},ve={...U,html:g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",F).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:L,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:g(W).replace("hr",v).replace("heading",` *#{1,6} *[^
  2. ]`).replace("lheading",ce).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Be=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ce=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pe=/^( {2,}|\\)\n(?!\s*$)/,qe=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,M=/[\p{P}\p{S}]/u,J=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ee=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,J).getRegex(),ge=/(?!~)[\p{P}\p{S}]/u,Ze=/(?!~)[\s\p{P}\p{S}]/u,De=/(?:[^\s\p{P}\p{S}]|~)/u,Me=/\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,ke=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Qe=g(ke,"u").replace(/punct/g,M).getRegex(),Ne=g(ke,"u").replace(/punct/g,ge).getRegex(),fe="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Oe=g(fe,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,J).replace(/punct/g,M).getRegex(),je=g(fe,"gu").replace(/notPunctSpace/g,De).replace(/punctSpace/g,Ze).replace(/punct/g,ge).getRegex(),He=g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,J).replace(/punct/g,M).getRegex(),Ge=g(/\\(punct)/,"gu").replace(/punct/g,M).getRegex(),We=g(/^<(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(),Xe=g(F).replace("(?:-->|$)","-->").getRegex(),Fe=g("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Xe).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/,Ue=g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=g(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",X).getRegex(),xe=g(/^!?\[(ref)\](?:\[\])?/).replace("ref",X).getRegex(),Je=g("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",xe).getRegex(),K={_backpedal:L,anyPunctuation:Ge,autolink:We,blockSkip:Me,br:pe,code:Ce,del:L,emStrongLDelim:Qe,emStrongRDelimAst:Oe,emStrongRDelimUnd:He,escape:Be,link:Ue,nolink:xe,punctuation:Ee,reflink:de,reflinkSearch:Je,tag:Fe,text:qe,url:L},Ke={...K,link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...K,emStrongRDelimAst:je,emStrongLDelim:Ne,url:g(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ve={...N,br:g(pe).replace("{2,}","*").getRegex(),text:g(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},B={normal:U,gfm:Le,pedantic:ve},_={normal:K,gfm:N,breaks:Ve,pedantic:Ke},Ye={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ne=t=>Ye[t];function m(t,e){if(e){if(b.escapeTest.test(t))return t.replace(b.escapeReplace,ne)}else if(b.escapeTestNoEncode.test(t))return t.replace(b.escapeReplaceNoEncode,ne);return t}function se(t){try{t=encodeURI(t).replace(b.percentDecode,"%")}catch{return null}return t}function le(t,e){var i;let r=t.replace(b.findPipe,(c,l,o)=>{let a=!1,p=l;for(;--p>=0&&o[p]==="\\";)a=!a;return a?"|":" |"}),s=r.split(b.splitPipe),n=0;if(s[0].trim()||s.shift(),s.length>0&&!((i=s.at(-1))!=null&&i.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(b.slashPipe,"|");return s}function P(t,e,r){let s=t.length;if(s===0)return"";let n=0;for(;n<s&&t.charAt(s-n-1)===e;)n++;return t.slice(0,s-n)}function et(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let s=0;s<t.length;s++)if(t[s]==="\\")s++;else if(t[s]===e[0])r++;else if(t[s]===e[1]&&(r--,r<0))return s;return r>0?-2:-1}function ie(t,e,r,s,n){let i=e.href,c=e.title||null,l=t[1].replace(n.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:r,href:i,title:c,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,o}function tt(t,e,r){let s=t.match(r.other.indentCodeCompensation);if(s===null)return e;let n=s[1];return e.split(`
  3. `).map(i=>{let c=i.match(r.other.beginningSpace);if(c===null)return i;let[l]=c;return l.length>=n.length?i.slice(n.length):i}).join(`
  4. `)}var E=class{constructor(t){f(this,"options");f(this,"rules");f(this,"lexer");this.options=t||T}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:P(r,`
  5. `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],s=tt(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let s=P(r,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(r=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:P(e[0],`
  6. `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=P(e[0],`
  7. `).split(`
  8. `),s="",n="",i=[];for(;r.length>0;){let c=!1,l=[],o;for(o=0;o<r.length;o++)if(this.rules.other.blockquoteStart.test(r[o]))l.push(r[o]),c=!0;else if(!c)l.push(r[o]);else break;r=r.slice(o);let a=l.join(`
  9. `),p=a.replace(this.rules.other.blockquoteSetextReplace,`
  10. $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
  11. ${a}`:a,n=n?`${n}
  12. ${p}`:p;let k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=k,r.length===0)break;let h=i.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){let x=h,u=x.raw+`
  13. `+r.join(`
  14. `),w=this.blockquote(u);i[i.length-1]=w,s=s.substring(0,s.length-x.raw.length)+w.raw,n=n.substring(0,n.length-x.text.length)+w.text;break}else if((h==null?void 0:h.type)==="list"){let x=h,u=x.raw+`
  15. `+r.join(`
  16. `),w=this.list(u);i[i.length-1]=w,s=s.substring(0,s.length-h.raw.length)+w.raw,n=n.substring(0,n.length-x.raw.length)+w.raw,r=u.substring(i.at(-1).raw.length).split(`
  17. `);continue}}return{type:"blockquote",raw:s,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),s=r.length>1,n={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");let i=this.rules.other.listItemRegex(r),c=!1;for(;t;){let o=!1,a="",p="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;a=e[0],t=t.substring(a.length);let k=e[2].split(`
  18. `,1)[0].replace(this.rules.other.listReplaceTabs,z=>" ".repeat(3*z.length)),h=t.split(`
  19. `,1)[0],x=!k.trim(),u=0;if(this.options.pedantic?(u=2,p=k.trimStart()):x?u=e[1].length+1:(u=e[2].search(this.rules.other.nonSpaceChar),u=u>4?1:u,p=k.slice(u),u+=e[1].length),x&&this.rules.other.blankLine.test(h)&&(a+=h+`
  20. `,t=t.substring(h.length+1),o=!0),!o){let z=this.rules.other.nextBulletRegex(u),Y=this.rules.other.hrRegex(u),ee=this.rules.other.fencesBeginRegex(u),te=this.rules.other.headingBeginRegex(u),be=this.rules.other.htmlBeginRegex(u);for(;t;){let Q=t.split(`
  21. `,1)[0],A;if(h=Q,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),ee.test(h)||te.test(h)||be.test(h)||z.test(h)||Y.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=u||!h.trim())p+=`
  22. `+A.slice(u);else{if(x||k.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ee.test(k)||te.test(k)||Y.test(k))break;p+=`
  23. `+h}!x&&!h.trim()&&(x=!0),a+=Q+`
  24. `,t=t.substring(Q.length+1),k=A.slice(u)}}n.loose||(c?n.loose=!0:this.rules.other.doubleBlankLine.test(a)&&(c=!0));let w=null,S;this.options.gfm&&(w=this.rules.other.listIsTask.exec(p),w&&(S=w[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),n.items.push({type:"list_item",raw:a,task:!!w,checked:S,loose:!1,text:p,tokens:[]}),n.raw+=a}let l=n.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let o=0;o<n.items.length;o++)if(this.lexer.state.top=!1,n.items[o].tokens=this.lexer.blockTokens(n.items[o].text,[]),!n.loose){let a=n.items[o].tokens.filter(k=>k.type==="space"),p=a.length>0&&a.some(k=>this.rules.other.anyLine.test(k.raw));n.loose=p}if(n.loose)for(let o=0;o<n.items.length;o++)n.items[o].loose=!0;return n}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let r=e[1].toLowerCase().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:r,raw:e[0],href:s,title:n}}}table(t){var c;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=le(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=(c=e[3])!=null&&c.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
  25. `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(let l of s)this.rules.other.tableAlignRight.test(l)?i.align.push("right"):this.rules.other.tableAlignCenter.test(l)?i.align.push("center"):this.rules.other.tableAlignLeft.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<r.length;l++)i.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:i.align[l]});for(let l of n)i.rows.push(le(l,i.header.length).map((o,a)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[a]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let r=e[1].charAt(e[1].length-1)===`
  26. `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);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(t){let e=this.rules.inline.link.exec(t);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let i=P(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{let i=et(e[2],"()");if(i===-2)return;if(i>-1){let c=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let s=e[2],n="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],n=i[3])}else n=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?s=s.slice(1):s=s.slice(1,-1)),ie(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[s.toLowerCase()];if(!n){let i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return ie(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!r||this.rules.inline.punctuation.exec(r))){let n=[...s[0]].length-1,i,c,l=n,o=0,a=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,e=e.slice(-1*t.length+n);(s=a.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(c=[...i].length,s[3]||s[4]){l+=c;continue}else if((s[5]||s[6])&&n%3&&!((n+c)%3)){o+=c;continue}if(l-=c,l>0)continue;c=Math.min(c,c+l+o);let p=[...s[0]][0].length,k=t.slice(0,n+s.index+p+c);if(Math.min(n,c)%2){let x=k.slice(1,-1);return{type:"em",raw:k,text:x,tokens:this.lexer.inlineTokens(x)}}let h=k.slice(2,-2);return{type:"strong",raw:k,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(r),n=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&n&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,s;return e[2]==="@"?(r=e[1],s="mailto:"+r):(r=e[1],s=r),{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(t){var r;let e;if(e=this.rules.inline.url.exec(t)){let s,n;if(e[2]==="@")s=e[0],n="mailto:"+s;else{let i;do i=e[0],e[0]=((r=this.rules.inline._backpedal.exec(e[0]))==null?void 0:r[0])??"";while(i!==e[0]);s=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},y=class O{constructor(e){f(this,"tokens");f(this,"options");f(this,"state");f(this,"tokenizer");f(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new E,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let r={other:b,block:B.normal,inline:_.normal};this.options.pedantic?(r.block=B.pedantic,r.inline=_.pedantic):this.options.gfm&&(r.block=B.gfm,this.options.breaks?r.inline=_.breaks:r.inline=_.gfm),this.tokenizer.rules=r}static get rules(){return{block:B,inline:_}}static lex(e,r){return new O(r).lex(e)}static lexInline(e,r){return new O(r).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,`
  27. `),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let s=this.inlineQueue[r];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],s=!1){var n,i,c;for(this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));e;){let l;if((i=(n=this.options.extensions)==null?void 0:n.block)!=null&&i.some(a=>(l=a.call({lexer:this},e,r))?(e=e.substring(l.raw.length),r.push(l),!0):!1))continue;if(l=this.tokenizer.space(e)){e=e.substring(l.raw.length);let a=r.at(-1);l.raw.length===1&&a!==void 0?a.raw+=`
  28. `:r.push(l);continue}if(l=this.tokenizer.code(e)){e=e.substring(l.raw.length);let a=r.at(-1);(a==null?void 0:a.type)==="paragraph"||(a==null?void 0:a.type)==="text"?(a.raw+=(a.raw.endsWith(`
  29. `)?"":`
  30. `)+l.raw,a.text+=`
  31. `+l.text,this.inlineQueue.at(-1).src=a.text):r.push(l);continue}if(l=this.tokenizer.fences(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.heading(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.hr(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.blockquote(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.list(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.html(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.def(e)){e=e.substring(l.raw.length);let a=r.at(-1);(a==null?void 0:a.type)==="paragraph"||(a==null?void 0:a.type)==="text"?(a.raw+=(a.raw.endsWith(`
  32. `)?"":`
  33. `)+l.raw,a.text+=`
  34. `+l.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title},r.push(l));continue}if(l=this.tokenizer.table(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.lheading(e)){e=e.substring(l.raw.length),r.push(l);continue}let o=e;if((c=this.options.extensions)!=null&&c.startBlock){let a=1/0,p=e.slice(1),k;this.options.extensions.startBlock.forEach(h=>{k=h.call({lexer:this},p),typeof k=="number"&&k>=0&&(a=Math.min(a,k))}),a<1/0&&a>=0&&(o=e.substring(0,a+1))}if(this.state.top&&(l=this.tokenizer.paragraph(o))){let a=r.at(-1);s&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=(a.raw.endsWith(`
  35. `)?"":`
  36. `)+l.raw,a.text+=`
  37. `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):r.push(l),s=o.length!==e.length,e=e.substring(l.raw.length);continue}if(l=this.tokenizer.text(e)){e=e.substring(l.raw.length);let a=r.at(-1);(a==null?void 0:a.type)==="text"?(a.raw+=(a.raw.endsWith(`
  38. `)?"":`
  39. `)+l.raw,a.text+=`
  40. `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):r.push(l);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){var l,o,a,p,k;let s=e,n=null;if(this.tokens.links){let h=Object.keys(this.tokens.links);if(h.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)h.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,n.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((o=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:o.call({lexer:this},s))??s;let i=!1,c="";for(;e;){i||(c=""),i=!1;let h;if((p=(a=this.options.extensions)==null?void 0:a.inline)!=null&&p.some(u=>(h=u.call({lexer:this},e,r))?(e=e.substring(h.raw.length),r.push(h),!0):!1))continue;if(h=this.tokenizer.escape(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.tag(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.link(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(h.raw.length);let u=r.at(-1);h.type==="text"&&(u==null?void 0:u.type)==="text"?(u.raw+=h.raw,u.text+=h.text):r.push(h);continue}if(h=this.tokenizer.emStrong(e,s,c)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.codespan(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.br(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.del(e)){e=e.substring(h.raw.length),r.push(h);continue}if(h=this.tokenizer.autolink(e)){e=e.substring(h.raw.length),r.push(h);continue}if(!this.state.inLink&&(h=this.tokenizer.url(e))){e=e.substring(h.raw.length),r.push(h);continue}let x=e;if((k=this.options.extensions)!=null&&k.startInline){let u=1/0,w=e.slice(1),S;this.options.extensions.startInline.forEach(z=>{S=z.call({lexer:this},w),typeof S=="number"&&S>=0&&(u=Math.min(u,S))}),u<1/0&&u>=0&&(x=e.substring(0,u+1))}if(h=this.tokenizer.inlineText(x)){e=e.substring(h.raw.length),h.raw.slice(-1)!=="_"&&(c=h.raw.slice(-1)),i=!0;let u=r.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=h.raw,u.text+=h.text):r.push(h);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return r}},Z=class{constructor(t){f(this,"options");f(this,"parser");this.options=t||T}space(t){return""}code({text:t,lang:e,escaped:r}){var i;let s=(i=(e||"").match(b.notSpaceStart))==null?void 0:i[0],n=t.replace(b.endingNewline,"")+`
  41. `;return s?'<pre><code class="language-'+m(s)+'">'+(r?n:m(n,!0))+`</code></pre>
  42. `:"<pre><code>"+(r?n:m(n,!0))+`</code></pre>
  43. `}blockquote({tokens:t}){return`<blockquote>
  44. ${this.parser.parse(t)}</blockquote>
  45. `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
  46. `}hr(t){return`<hr>
  47. `}list(t){let e=t.ordered,r=t.start,s="";for(let c=0;c<t.items.length;c++){let l=t.items[c];s+=this.listitem(l)}let n=e?"ol":"ul",i=e&&r!==1?' start="'+r+'"':"";return"<"+n+i+`>
  48. `+s+"</"+n+`>
  49. `}listitem(t){var r;let e="";if(t.task){let s=this.checkbox({checked:!!t.checked});t.loose?((r=t.tokens[0])==null?void 0:r.type)==="paragraph"?(t.tokens[0].text=s+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=s+" "+m(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:s+" ",text:s+" ",escaped:!0}):e+=s+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
  50. `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
  51. `}table(t){let e="",r="";for(let n=0;n<t.header.length;n++)r+=this.tablecell(t.header[n]);e+=this.tablerow({text:r});let s="";for(let n=0;n<t.rows.length;n++){let i=t.rows[n];r="";for(let c=0;c<i.length;c++)r+=this.tablecell(i[c]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
  52. <thead>
  53. `+e+`</thead>
  54. `+s+`</table>
  55. `}tablerow({text:t}){return`<tr>
  56. ${t}</tr>
  57. `}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
  58. `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${m(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let s=this.parser.parseInline(r),n=se(t);if(n===null)return s;t=n;let i='<a href="'+t+'"';return e&&(i+=' title="'+m(e)+'"'),i+=">"+s+"</a>",i}image({href:t,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));let n=se(t);if(n===null)return m(r);t=n;let i=`<img src="${t}" alt="${r}"`;return e&&(i+=` title="${m(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:m(t.text)}},V=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},$=class j{constructor(e){f(this,"options");f(this,"renderer");f(this,"textRenderer");this.options=e||T,this.options.renderer=this.options.renderer||new Z,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new V}static parse(e,r){return new j(r).parse(e)}static parseInline(e,r){return new j(r).parseInline(e)}parse(e,r=!0){var n,i;let s="";for(let c=0;c<e.length;c++){let l=e[c];if((i=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&i[l.type]){let a=l,p=this.options.extensions.renderers[a.type].call({parser:this},a);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=p||"";continue}}let o=l;switch(o.type){case"space":{s+=this.renderer.space(o);continue}case"hr":{s+=this.renderer.hr(o);continue}case"heading":{s+=this.renderer.heading(o);continue}case"code":{s+=this.renderer.code(o);continue}case"table":{s+=this.renderer.table(o);continue}case"blockquote":{s+=this.renderer.blockquote(o);continue}case"list":{s+=this.renderer.list(o);continue}case"html":{s+=this.renderer.html(o);continue}case"def":{s+=this.renderer.def(o);continue}case"paragraph":{s+=this.renderer.paragraph(o);continue}case"text":{let a=o,p=this.renderer.text(a);for(;c+1<e.length&&e[c+1].type==="text";)a=e[++c],p+=`
  59. `+this.renderer.text(a);r?s+=this.renderer.paragraph({type:"paragraph",raw:p,text:p,tokens:[{type:"text",raw:p,text:p,escaped:!0}]}):s+=p;continue}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,r=this.renderer){var n,i;let s="";for(let c=0;c<e.length;c++){let l=e[c];if((i=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&i[l.type]){let a=this.options.extensions.renderers[l.type].call({parser:this},l);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){s+=a||"";continue}}let o=l;switch(o.type){case"escape":{s+=r.text(o);break}case"html":{s+=r.html(o);break}case"link":{s+=r.link(o);break}case"image":{s+=r.image(o);break}case"strong":{s+=r.strong(o);break}case"em":{s+=r.em(o);break}case"codespan":{s+=r.codespan(o);break}case"br":{s+=r.br(o);break}case"del":{s+=r.del(o);break}case"text":{s+=r.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},C,I=(C=class{constructor(t){f(this,"options");f(this,"block");this.options=t||T}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?y.lex:y.lexInline}provideParser(){return this.block?$.parse:$.parseInline}},f(C,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),f(C,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),C),rt=class{constructor(...t){f(this,"defaults",H());f(this,"options",this.setOptions);f(this,"parse",this.parseMarkdown(!0));f(this,"parseInline",this.parseMarkdown(!1));f(this,"Parser",$);f(this,"Renderer",Z);f(this,"TextRenderer",V);f(this,"Lexer",y);f(this,"Tokenizer",E);f(this,"Hooks",I);this.use(...t)}walkTokens(t,e){var s,n;let r=[];for(let i of t)switch(r=r.concat(e.call(this,i)),i.type){case"table":{let c=i;for(let l of c.header)r=r.concat(this.walkTokens(l.tokens,e));for(let l of c.rows)for(let o of l)r=r.concat(this.walkTokens(o.tokens,e));break}case"list":{let c=i;r=r.concat(this.walkTokens(c.items,e));break}default:{let c=i;(n=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&n[c.type]?this.defaults.extensions.childTokens[c.type].forEach(l=>{let o=c[l].flat(1/0);r=r.concat(this.walkTokens(o,e))}):c.tokens&&(r=r.concat(this.walkTokens(c.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...c){let l=n.renderer.apply(this,c);return l===!1&&(l=i.apply(this,c)),l}: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 i=e[n.level];i?i.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),r.renderer){let n=this.defaults.renderer||new Z(this.defaults);for(let i in r.renderer){if(!(i in n))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let c=i,l=r.renderer[c],o=n[c];n[c]=(...a)=>{let p=l.apply(n,a);return p===!1&&(p=o.apply(n,a)),p||""}}s.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new E(this.defaults);for(let i in r.tokenizer){if(!(i in n))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let c=i,l=r.tokenizer[c],o=n[c];n[c]=(...a)=>{let p=l.apply(n,a);return p===!1&&(p=o.apply(n,a)),p}}s.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new I;for(let i in r.hooks){if(!(i in n))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let c=i,l=r.hooks[c],o=n[c];I.passThroughHooks.has(i)?n[c]=a=>{if(this.defaults.async&&I.passThroughHooksRespectAsync.has(i))return Promise.resolve(l.call(n,a)).then(k=>o.call(n,k));let p=l.call(n,a);return o.call(n,p)}:n[c]=(...a)=>{let p=l.apply(n,a);return p===!1&&(p=o.apply(n,a)),p}}s.hooks=n}if(r.walkTokens){let n=this.defaults.walkTokens,i=r.walkTokens;s.walkTokens=function(c){let l=[];return l.push(i.call(this,c)),n&&(l=l.concat(n.call(this,c))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return y.lex(t,e??this.defaults)}parser(t,e){return $.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let s={...r},n={...this.defaults,...s},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));n.hooks&&(n.hooks.options=n,n.hooks.block=t);let c=n.hooks?n.hooks.provideLexer():t?y.lex:y.lexInline,l=n.hooks?n.hooks.provideParser():t?$.parse:$.parseInline;if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(e):e).then(o=>c(o,n)).then(o=>n.hooks?n.hooks.processAllTokens(o):o).then(o=>n.walkTokens?Promise.all(this.walkTokens(o,n.walkTokens)).then(()=>o):o).then(o=>l(o,n)).then(o=>n.hooks?n.hooks.postprocess(o):o).catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let o=c(e,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let a=l(o,n);return n.hooks&&(a=n.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return r=>{if(r.message+=`
  60. Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+m(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},R=new rt;function d(t,e){return R.parse(t,e)}d.options=d.setOptions=function(t){return R.setOptions(t),d.defaults=R.defaults,ae(d.defaults),d};d.getDefaults=H;d.defaults=T;d.use=function(...t){return R.use(...t),d.defaults=R.defaults,ae(d.defaults),d};d.walkTokens=function(t,e){return R.walkTokens(t,e)};d.parseInline=R.parseInline;d.Parser=$;d.parser=$.parse;d.Renderer=Z;d.TextRenderer=V;d.Lexer=y;d.lexer=y.lex;d.Tokenizer=E;d.Hooks=I;d.parse=d;d.options;d.setOptions;d.use;d.walkTokens;d.parseInline;$.parse;y.lex;export{d};