import{m as t,u as e,e as n,f as r,d as s}from"./mdurl.Dwcmq5MZ.js";import{u as o,P as i,r as c}from"./uc.micro.CRGj88R_.js";import{d as l}from"./entities.zpoy7YfM.js";import{L as a}from"./linkify-it.xinbW_ni.js";import{p as h}from"./punycode.js.BkBFhtvi.js";function u(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)}const p=Object.prototype.hasOwnProperty;function f(t){return Array.prototype.slice.call(arguments,1).forEach(function(e){if(e){if("object"!=typeof e)throw new TypeError(e+"must be object");Object.keys(e).forEach(function(n){t[n]=e[n]})}}),t}function d(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function k(t){return!(t>=55296&&t<=57343)&&(!(t>=64976&&t<=65007)&&(!!(65535&~t&&65534!=(65535&t))&&(!(t>=0&&t<=8)&&(11!==t&&(!(t>=14&&t<=31)&&(!(t>=127&&t<=159)&&!(t>1114111)))))))}function m(t){if(t>65535){const e=55296+((t-=65536)>>10),n=56320+(1023&t);return String.fromCharCode(e,n)}return String.fromCharCode(t)}const g=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,b=new RegExp(g.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),_=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function C(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(b,function(t,e,n){return e||function(t,e){if(35===e.charCodeAt(0)&&_.test(e)){const n="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return k(n)?m(n):t}const n=l(t);return n!==t?n:t}(t,n)})}const y=/[&<>"]/,A=/[&<>"]/g,x={"&":"&","<":"<",">":">",'"':"""};function M(t){return x[t]}function v(t){return y.test(t)?t.replace(A,M):t}const S=/[.?*+^$[\]\\(){}|-]/g;function w(t){switch(t){case 9:case 32:return!0}return!1}function I(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9: // \t case 10: // \n case 11: // \v case 12: // \f case 13: // \r case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function L(t){return i.test(t)||c.test(t)}function z(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function T(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}const E={mdurl:t,ucmicro:o},O=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:d,assign:f,escapeHtml:v,escapeRE:function(t){return t.replace(S,"\\$&")},fromCodePoint:m,has:function(t,e){return p.call(t,e)},isMdAsciiPunct:z,isPunctChar:L,isSpace:w,isString:u,isValidEntityCode:k,isWhiteSpace:I,lib:E,normalizeReference:T,unescapeAll:C,unescapeMd:function(t){return t.indexOf("\\")<0?t:t.replace(g,"$1")}},Symbol.toStringTag,{value:"Module"}));const $=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:function(t,e,n){let r,s=e;const o={ok:!1,pos:0,str:""};if(60===t.charCodeAt(s)){for(s++;s32))return o;if(41===r){if(0===i)break;i--}s++}return e===s||0!==i||(o.str=C(t.slice(e,s)),o.pos=s,o.ok=!0),o},parseLinkLabel:function(t,e,n){let r,s,o,i;const c=t.posMax,l=t.pos;for(t.pos=e+1,r=1;t.pos=n)return i;let r=t.charCodeAt(o);if(34!==r&&39!==r&&40!==r)return i;e++,o++,40===r&&(r=41),i.marker=r}for(;o"+v(o.content)+""},j.code_block=function(t,e,n,r,s){const o=t[e];return""+v(t[e].content)+"\n"},j.fence=function(t,e,n,r,s){const o=t[e],i=o.info?C(o.info).trim():"";let c,l="",a="";if(i){const t=i.split(/(\s+)/g);l=t[0],a=t.slice(2).join("")}if(c=n.highlight&&n.highlight(o.content,l,a)||v(o.content),0===c.indexOf("${c}\n`}return`
${c}
\n`},j.image=function(t,e,n,r,s){const o=t[e];return o.attrs[o.attrIndex("alt")][1]=s.renderInlineAsText(o.children,n,r),s.renderToken(t,e,n)},j.hardbreak=function(t,e,n){return n.xhtmlOut?"
\n":"
\n"},j.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?"
\n":"
\n":"\n"},j.text=function(t,e){return v(t[e].content)},j.html_block=function(t,e){return t[e].content},j.html_inline=function(t,e){return t[e].content},q.prototype.renderAttrs=function(t){let e,n,r;if(!t.attrs)return"";for(r="",e=0,n=t.attrs.length;e\n":">",s},q.prototype.renderInline=function(t,e,n){let r="";const s=this.rules;for(let o=0,i=t.length;o=0&&(n=this.attrs[e][1]),n},R.prototype.attrJoin=function(t,e){const n=this.attrIndex(t);n<0?this.attrPush([t,e]):this.attrs[n][1]=this.attrs[n][1]+" "+e},Z.prototype.Token=R;const D=/\r\n?|\n/g,N=/\0/g;function B(t){return/^\s]/i.test(t)}function W(t){return/^<\/a\s*>/i.test(t)}const U=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,F=/\((c|tm|r)\)/i,G=/\((c|tm|r)\)/gi,H={c:"©",r:"®",tm:"™"};function J(t,e){return H[e.toLowerCase()]}function V(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];"text"!==r.type||e||(r.content=r.content.replace(G,J)),"link_open"===r.type&&"auto"===r.info&&e--,"link_close"===r.type&&"auto"===r.info&&e++}}function X(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];"text"!==r.type||e||U.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===r.type&&"auto"===r.info&&e--,"link_close"===r.type&&"auto"===r.info&&e++}}const K=/['"]/,Q=/['"]/g;function Y(t,e,n){return t.slice(0,e)+n+t.slice(e+1)}function tt(t,e){let n;const r=[];for(let s=0;s=0&&!(r[n].level<=i);n--);if(r.length=n+1,"text"!==o.type)continue;let c=o.content,l=0,a=c.length;t:for(;l=0)d=c.charCodeAt(h.index-1);else for(n=s-1;n>=0&&("softbreak"!==t[n].type&&"hardbreak"!==t[n].type);n--)if(t[n].content){d=t[n].content.charCodeAt(t[n].content.length-1);break}let k=32;if(l=48&&d<=57&&(p=u=!1),u&&p&&(u=m,p=g),u||p){if(p)for(n=r.length-1;n>=0;n--){let u=r[n];if(r[n].level=0;o--){const i=r[o];if("link_close"!==i.type){if("html_inline"===i.type&&(B(i.content)&&s>0&&s--,W(i.content)&&s++),!(s>0)&&"text"===i.type&&t.md.linkify.test(i.content)){const s=i.content;let c=t.md.linkify.match(s);const l=[];let a=i.level,h=0;c.length>0&&0===c[0].index&&o>0&&"text_special"===r[o-1].type&&(c=c.slice(1));for(let e=0;eh){const e=new t.Token("text","",0);e.content=s.slice(h,i),e.level=a,l.push(e)}const u=new t.Token("link_open","a",1);u.attrs=[["href",r]],u.level=a++,u.markup="linkify",u.info="auto",l.push(u);const p=new t.Token("text","",0);p.content=o,p.level=a,l.push(p);const f=new t.Token("link_close","a",-1);f.level=--a,f.markup="linkify",f.info="auto",l.push(f),h=c[e].lastIndex}if(h=0;e--)"inline"===t.tokens[e].type&&(F.test(t.tokens[e].content)&&V(t.tokens[e].children),U.test(t.tokens[e].content)&&X(t.tokens[e].children))}],["smartquotes",function(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&K.test(t.tokens[e].content)&&tt(t.tokens[e].children,t)}], // `text_join` finds `text_special` tokens (for escape sequences) // and joins them with the rest of the text ["text_join",function(t){let e,n;const r=t.tokens,s=r.length;for(let o=0;o0&&this.level++,this.tokens.push(r),r},rt.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},rt.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;te;)if(!w(this.src.charCodeAt(--t)))return t+1;return t},rt.prototype.skipChars=function(t,e){for(let n=this.src.length;tn;)if(e!==this.src.charCodeAt(--t))return t+1;return t},rt.prototype.getLines=function(t,e,n,r){if(t>=e)return"";const s=new Array(e-t);for(let o=0,i=t;in?new Array(t-n+1).join(" ")+this.src.slice(a,l):this.src.slice(a,l)}return s.join("")},rt.prototype.Token=R;function st(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function ot(t){const e=[],n=t.length;let r=0,s=t.charCodeAt(r),o=!1,i=0,c="";for(;r=r)return-1;let o=t.src.charCodeAt(s++);if(o<48||o>57)return-1;for(;;){if(s>=r)return-1;if(o=t.src.charCodeAt(s++),!(o>=48&&o<=57)){if(41===o||46===o)break;return-1}if(s-n>=10)return-1}return s`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",at="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",ht=new RegExp("^(?:"+lt+"|"+at+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|]*>|)"),ut=new RegExp("^(?:"+lt+"|"+at+")"),pt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(ut.source+"\\s*$"),/^$/,!1]];const ft=[ // First 2 params - rule name & source. Secondary array - list of rules, // which can be terminated by this one. ["table",function(t,e,n,r){if(e+2>n)return!1;let s=e+1;if(t.sCount[s]=4)return!1;let o=t.bMarks[s]+t.tShift[s];if(o>=t.eMarks[s])return!1;const i=t.src.charCodeAt(o++);if(124!==i&&45!==i&&58!==i)return!1;if(o>=t.eMarks[s])return!1;const c=t.src.charCodeAt(o++);if(124!==c&&45!==c&&58!==c&&!w(c))return!1;if(45===i&&w(c))return!1;for(;o=4)return!1;a=ot(l),a.length&&""===a[0]&&a.shift(),a.length&&""===a[a.length-1]&&a.pop();const u=a.length;if(0===u||u!==h.length)return!1;if(r)return!0;const p=t.parentType;t.parentType="table";const f=t.md.block.ruler.getRules("blockquote"),d=[e,0];t.push("table_open","table",1).map=d,t.push("thead_open","thead",1).map=[e,e+1],t.push("tr_open","tr",1).map=[e,e+1];for(let g=0;g=4)break;if(a=ot(l),a.length&&""===a[0]&&a.shift(),a.length&&""===a[a.length-1]&&a.pop(),m+=u-a.length,m>65536)break;if(s===e+2){t.push("tbody_open","tbody",1).map=k=[e+2,0]}t.push("tr_open","tr",1).map=[s,s+1];for(let e=0;e=4))break;r++,s=r}t.line=s;const o=t.push("code_block","code",0);return o.content=t.getLines(e,s,4+t.blkIndent,!1)+"\n",o.map=[e,t.line],!0}],["fence",function(t,e,n,r){let s=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(s+3>o)return!1;const i=t.src.charCodeAt(s);if(126!==i&&96!==i)return!1;let c=s;s=t.skipChars(s,i);let l=s-c;if(l<3)return!1;const a=t.src.slice(c,s),h=t.src.slice(s,o);if(96===i&&h.indexOf(String.fromCharCode(i))>=0)return!1;if(r)return!0;let u=e,p=!1;for(;(u++,!(u>=n))&&(s=c=t.bMarks[u]+t.tShift[u],o=t.eMarks[u],!(s=4||(s=t.skipChars(s,i),s-c=4)return!1;if(62!==t.src.charCodeAt(s))return!1;if(r)return!0;const c=[],l=[],a=[],h=[],u=t.md.block.ruler.getRules("blockquote"),p=t.parentType;t.parentType="blockquote";let f,d=!1;for(f=e;f=o)break;if(62===t.src.charCodeAt(s++)&&!e){let e,n,r=t.sCount[f]+1;32===t.src.charCodeAt(s)?(s++,r++,n=!1,e=!0):9===t.src.charCodeAt(s)?(e=!0,(t.bsCount[f]+r)%4==3?(s++,r++,n=!1):n=!0):e=!1;let i=r;for(c.push(t.bMarks[f]),t.bMarks[f]=s;s=o,l.push(t.bsCount[f]),t.bsCount[f]=t.sCount[f]+1+(e?1:0),a.push(t.sCount[f]),t.sCount[f]=i-r,h.push(t.tShift[f]),t.tShift[f]=s-t.bMarks[f];continue}if(d)break;let r=!1;for(let s=0,o=u.length;s";const g=[e,0];m.map=g,t.md.block.tokenize(t,e,f),t.push("blockquote_close","blockquote",-1).markup=">",t.lineMax=i,t.parentType=p,g[1]=t.line;for(let b=0;b=4)return!1;let o=t.bMarks[e]+t.tShift[e];const i=t.src.charCodeAt(o++);if(42!==i&&45!==i&&95!==i)return!1;let c=1;for(;o=4)return!1;if(t.listIndent>=0&&t.sCount[l]-t.listIndent>=4&&t.sCount[l]=t.blkIndent&&(f=!0),(p=ct(t,l))>=0){if(h=!0,i=t.bMarks[l]+t.tShift[l],u=Number(t.src.slice(i,p-1)),f&&1!==u)return!1}else{if(!((p=it(t,l))>=0))return!1;h=!1}if(f&&t.skipSpaces(p)>=t.eMarks[l])return!1;if(r)return!0;const d=t.src.charCodeAt(p-1),k=t.tokens.length;h?(c=t.push("ordered_list_open","ol",1),1!==u&&(c.attrs=[["start",u]])):c=t.push("bullet_list_open","ul",1);const m=[l,0];c.map=m,c.markup=String.fromCharCode(d);let g=!1;const b=t.md.block.ruler.getRules("list"),_=t.parentType;for(t.parentType="list";l=s?1:r-e,f>4&&(f=1);const k=e+f;c=t.push("list_item_open","li",1),c.markup=String.fromCharCode(d);const m=[l,0];c.map=m,h&&(c.info=t.src.slice(i,p-1));const _=t.tight,C=t.tShift[l],y=t.sCount[l],A=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=k,t.tight=!0,t.tShift[l]=u-t.bMarks[l],t.sCount[l]=r,u>=s&&t.isEmpty(l+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,l,n,!0),t.tight&&!g||(a=!1),g=t.line-l>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=A,t.tShift[l]=C,t.sCount[l]=y,t.tight=_,c=t.push("list_item_close","li",-1),c.markup=String.fromCharCode(d),l=t.line,m[1]=l,l>=n)break;if(t.sCount[l]=4)break;let x=!1;for(let s=0,o=b.length;s=4)return!1;if(91!==t.src.charCodeAt(s))return!1;function c(e){const n=t.lineMax;if(e>=n||t.isEmpty(e))return null;let r=!1;if(t.sCount[e]-t.blkIndent>3&&(r=!0),t.sCount[e]<0&&(r=!0),!r){const r=t.md.block.ruler.getRules("reference"),s=t.parentType;t.parentType="reference";let o=!1;for(let i=0,c=r.length;i=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(s))return!1;let i=t.src.slice(s,o),c=0;for(;c=4)return!1;let i=t.src.charCodeAt(s);if(35!==i||s>=o)return!1;let c=1;for(i=t.src.charCodeAt(++s);35===i&&s6||ss&&w(t.src.charCodeAt(l-1))&&(o=l),t.line=e+1;const a=t.push("heading_open","h"+String(c),1);a.markup="########".slice(0,c),a.map=[e,t.line];const h=t.push("inline","",0);return h.content=t.src.slice(s,o).trim(),h.map=[e,t.line],h.children=[],t.push("heading_close","h"+String(c),-1).markup="########".slice(0,c),!0},["paragraph","reference","blockquote"]],["lheading",function(t,e,n){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const s=t.parentType;t.parentType="paragraph";let o,i=0,c=e+1;for(;c3)continue;if(t.sCount[c]>=t.blkIndent){let e=t.bMarks[c]+t.tShift[c];const n=t.eMarks[c];if(e=n))){i=61===o?1:2;break}}if(t.sCount[c]<0)continue;let e=!1;for(let s=0,o=r.length;s3)continue;if(t.sCount[o]<0)continue;let e=!1;for(let s=0,i=r.length;s=n))&&!(t.sCount[i]=o){t.line=n;break}const e=t.line;let l=!1;for(let o=0;o=t.line)throw new Error("block rule didn't increment state.line");break}if(!l)throw new Error("none of the block rules matched");t.tight=!c,t.isEmpty(t.line-1)&&(c=!0),i=t.line,i0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],s={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(s),r},kt.prototype.scanDelims=function(t,e){const n=this.posMax,r=this.src.charCodeAt(t),s=t>0?this.src.charCodeAt(t-1):32;let o=t;for(;o?@[]^_`{|}~-".split("").forEach(function(t){bt[t.charCodeAt(0)]=1});const Ct={tokenize:function(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e)return!1;if(126!==r)return!1;const s=t.scanDelims(t.pos,!0);let o=s.length;const i=String.fromCharCode(r);if(o<2)return!1;let c;o%2&&(c=t.push("text","",0),c.content=i,o--);for(let l=0;l=0;n--){const r=e[n];if(95!==r.marker&&42!==r.marker)continue;if(-1===r.end)continue;const s=e[r.end],o=n>0&&e[n-1].end===r.end+1&&// check that first two markers match and adjacent e[n-1].marker===r.marker&&e[n-1].token===r.token-1&&// check that last two markers are adjacent (we can safely assume they match) e[r.end+1].token===s.token+1,i=String.fromCharCode(r.marker),c=t.tokens[r.token];c.type=o?"strong_open":"em_open",c.tag=o?"strong":"em",c.nesting=1,c.markup=o?i+i:i,c.content="";const l=t.tokens[s.token];l.type=o?"strong_close":"em_close",l.tag=o?"strong":"em",l.nesting=-1,l.markup=o?i+i:i,l.content="",o&&(t.tokens[e[n-1].token].content="",t.tokens[e[r.end+1].token].content="",n--)}}const At={tokenize:function(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e)return!1;if(95!==r&&42!==r)return!1;const s=t.scanDelims(t.pos,42===r);for(let o=0;o\x00-\x20]*)$/;const vt=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,St=/^&([a-z][a-z0-9]{1,31});/i;function wt(t){const e={},n=t.length;if(!n)return;let r=0,s=-2;const o=[];for(let i=0;ic;l-=o[l]+1){const e=t[l];if(e.marker===n.marker&&(e.open&&e.end<0)){let r=!1;if((e.close||n.open)&&(e.length+n.length)%3==0&&(e.length%3==0&&n.length%3==0||(r=!0)),!r){const r=l>0&&!t[l-1].open?o[l-1]+1:0;o[i]=i-l+r,o[l]=r,n.open=!1,e.end=i,e.close=!1,a=-1,s=-2;break}}}-1!==a&&(e[n.marker][(n.open?3:0)+(n.length||0)%3]=a)}}const It=[["text",function(t,e){let n=t.pos;for(;n0)return!1;const n=t.pos;if(n+3>t.posMax)return!1;if(58!==t.src.charCodeAt(n))return!1;if(47!==t.src.charCodeAt(n+1))return!1;if(47!==t.src.charCodeAt(n+2))return!1;const r=t.pending.match(gt);if(!r)return!1;const s=r[1],o=t.md.linkify.matchAtStart(t.src.slice(n-s.length));if(!o)return!1;let i=o.url;if(i.length<=s.length)return!1;let c=i.length;for(;c>0&&42===i.charCodeAt(c-1);)c--;c!==i.length&&(i=i.slice(0,c));const l=t.md.normalizeLink(i);if(!t.md.validateLink(l))return!1;if(!e){t.pending=t.pending.slice(0,-s.length);const e=t.push("link_open","a",1);e.attrs=[["href",l]],e.markup="linkify",e.info="auto";t.push("text","",0).content=t.md.normalizeLinkText(i);const n=t.push("link_close","a",-1);n.markup="linkify",n.info="auto"}return t.pos+=i.length-s.length,!0}],["newline",function(t,e){let n=t.pos;if(10!==t.src.charCodeAt(n))return!1;const r=t.pending.length-1,s=t.posMax;if(!e)if(r>=0&&32===t.pending.charCodeAt(r))if(r>=1&&32===t.pending.charCodeAt(r-1)){let e=r-1;for(;e>=1&&32===t.pending.charCodeAt(e-1);)e--;t.pending=t.pending.slice(0,e),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(n++;n=r)return!1;let s=t.src.charCodeAt(n);if(10===s){for(e||t.push("hardbreak","br",0),n++;n=55296&&s<=56319&&n+1=56320&&e<=57343&&(o+=t.src[n+1],n++)}const i="\\"+o;if(!e){const e=t.push("text_special","",0);s<256&&0!==bt[s]?e.content=o:e.content=i,e.markup=i,e.info="escape"}return t.pos=n+1,!0}],["backticks",function(t,e){let n=t.pos;if(96!==t.src.charCodeAt(n))return!1;const r=n;n++;const s=t.posMax;for(;n=u)return!1;if(l=d,s=t.md.helpers.parseLinkDestination(t.src,d,t.posMax),s.ok){for(i=t.md.normalizeLink(s.str),t.md.validateLink(i)?d=s.pos:i="",l=d;d=u||41!==t.src.charCodeAt(d))&&(a=!0),d++}if(a){if(void 0===t.env.references)return!1;if(d=0?r=t.src.slice(l,d++):d=f+1):d=f+1,r||(r=t.src.slice(p,f)),o=t.env.references[T(r)],!o)return t.pos=h,!1;i=o.href,c=o.title}if(!e){t.pos=p,t.posMax=f;const e=[["href",i]];t.push("link_open","a",1).attrs=e,c&&e.push(["title",c]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=d,t.posMax=u,!0}],["image",function(t,e){let n,r,s,o,i,c,l,a,h="";const u=t.pos,p=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;const f=t.pos+2,d=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(d<0)return!1;if(o=d+1,o=p)return!1;for(a=o,c=t.md.helpers.parseLinkDestination(t.src,o,t.posMax),c.ok&&(h=t.md.normalizeLink(c.str),t.md.validateLink(h)?o=c.pos:h=""),a=o;o=p||41!==t.src.charCodeAt(o))return t.pos=u,!1;o++}else{if(void 0===t.env.references)return!1;if(o=0?s=t.src.slice(a,o++):o=d+1):o=d+1,s||(s=t.src.slice(f,d)),i=t.env.references[T(s)],!i)return t.pos=u,!1;h=i.href,l=i.title}if(!e){r=t.src.slice(f,d);const e=[];t.md.inline.parse(r,t.md,t.env,e);const n=t.push("image","img",0),s=[["src",h],["alt",""]];n.attrs=s,n.children=e,n.content=r,l&&s.push(["title",l])}return t.pos=o,t.posMax=p,!0}],["autolink",function(t,e){let n=t.pos;if(60!==t.src.charCodeAt(n))return!1;const r=t.pos,s=t.posMax;for(;;){if(++n>=s)return!1;const e=t.src.charCodeAt(n);if(60===e)return!1;if(62===e)break}const o=t.src.slice(r+1,n);if(Mt.test(o)){const n=t.md.normalizeLink(o);if(!t.md.validateLink(n))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",n]],e.markup="autolink",e.info="auto";t.push("text","",0).content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="autolink",r.info="auto"}return t.pos+=o.length+2,!0}if(xt.test(o)){const n=t.md.normalizeLink("mailto:"+o);if(!t.md.validateLink(n))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",n]],e.markup="autolink",e.info="auto";t.push("text","",0).content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="autolink",r.info="auto"}return t.pos+=o.length+2,!0}return!1}],["html_inline",function(t,e){if(!t.md.options.html)return!1;const n=t.posMax,r=t.pos;if(60!==t.src.charCodeAt(r)||r+2>=n)return!1;const s=t.src.charCodeAt(r+1);if(33!==s&&63!==s&&47!==s&&!function(t){const e=32|t;return e>=97&&e<=122}(s))return!1;const o=t.src.slice(r).match(ht);if(!o)return!1;if(!e){const e=t.push("html_inline","",0);e.content=o[0],i=e.content,/^\s]/i.test(i)&&t.linkLevel++,function(t){return/^<\/a\s*>/i.test(t)}(e.content)&&t.linkLevel--}var i;return t.pos+=o[0].length,!0}],["entity",function(t,e){const n=t.pos,r=t.posMax;if(38!==t.src.charCodeAt(n))return!1;if(n+1>=r)return!1;if(35===t.src.charCodeAt(n+1)){const r=t.src.slice(n).match(vt);if(r){if(!e){const e="x"===r[1][0].toLowerCase()?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=t.push("text_special","",0);n.content=k(e)?m(e):m(65533),n.markup=r[0],n.info="entity"}return t.pos+=r[0].length,!0}}else{const r=t.src.slice(n).match(St);if(r){const n=l(r[0]);if(n!==r[0]){if(!e){const e=t.push("text_special","",0);e.content=n,e.markup=r[0],e.info="entity"}return t.pos+=r[0].length,!0}}}return!1}]],Lt=[["balance_pairs",function(t){const e=t.tokens_meta,n=t.tokens_meta.length;wt(t.delimiters);for(let r=0;r0&&r++,"text"===s[e].type&&e+1=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;i||t.pos++,o[e]=t.pos},zt.prototype.tokenize=function(t){const e=this.ruler.getRules(""),n=e.length,r=t.posMax,s=t.md.options.maxNesting;for(;t.pos=t.pos)throw new Error("inline rule didn't increment state.pos");break}if(i){if(t.pos>=r)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},zt.prototype.parse=function(t,e,n,r){const s=new this.State(t,e,n,r);this.tokenize(s);const o=this.ruler2.getRules(""),i=o.length;for(let c=0;c) xhtmlOut:!1, // Convert '\n' in paragraphs into
breaks:!1, // CSS language prefix for fenced blocks langPrefix:"language-", // autoconvert URL-like texts to links linkify:!1, // Enable some language-neutral replacements + quotes beautification typographer:!1, // Double + single quotes replacement pairs, when typographer enabled, // and smartquotes on. Could be either a String or an Array. // For example, you can use '«»„“' for Russian, '„“‚‘' for German, // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). quotes:"“”‘’", /* “”‘’ */ // Highlighter function. Should return escaped HTML, // or '' if the source string is not changed and should be escaped externaly. // If result starts with ) xhtmlOut:!1, // Convert '\n' in paragraphs into
breaks:!1, // CSS language prefix for fenced blocks langPrefix:"language-", // autoconvert URL-like texts to links linkify:!1, // Enable some language-neutral replacements + quotes beautification typographer:!1, // Double + single quotes replacement pairs, when typographer enabled, // and smartquotes on. Could be either a String or an Array. // For example, you can use '«»„“' for Russian, '„“‚‘' for German, // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). quotes:"“”‘’", /* “”‘’ */ // Highlighter function. Should return escaped HTML, // or '' if the source string is not changed and should be escaped externaly. // If result starts with ) xhtmlOut:!0, // Convert '\n' in paragraphs into
breaks:!1, // CSS language prefix for fenced blocks langPrefix:"language-", // autoconvert URL-like texts to links linkify:!1, // Enable some language-neutral replacements + quotes beautification typographer:!1, // Double + single quotes replacement pairs, when typographer enabled, // and smartquotes on. Could be either a String or an Array. // For example, you can use '«»„“' for Russian, '„“‚‘' for German, // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). quotes:"“”‘’", /* “”‘’ */ // Highlighter function. Should return escaped HTML, // or '' if the source string is not changed and should be escaped externaly. // If result starts with =0))try{s.hostname=h.toASCII(s.hostname)}catch(o){}return n(r(s))}function Pt(t){const n=e(t,!0);if(n.hostname&&(!n.protocol||jt.indexOf(n.protocol)>=0))try{n.hostname=h.toUnicode(n.hostname)}catch(o){}return s(r(n),s.defaultChars+"%")}function Rt(t,e){if(!(this instanceof Rt))return new Rt(t,e);e||u(t)||(e=t||{},t="default"),this.inline=new zt,this.block=new dt,this.core=new nt,this.renderer=new q,this.linkify=new a,this.validateLink=$t,this.normalizeLink=qt,this.normalizeLinkText=Pt,this.utils=O,this.helpers=f({},$),this.options={},this.configure(t),e&&this.set(e)}Rt.prototype.set=function(t){return f(this.options,t),this},Rt.prototype.configure=function(t){const e=this;if(u(t)){const e=t;if(!(t=Tt[e]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach(function(n){t.components[n].rules&&e[n].ruler.enableOnly(t.components[n].rules),t.components[n].rules2&&e[n].ruler2.enableOnly(t.components[n].rules2)}),this},Rt.prototype.enable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(e){n=n.concat(this[e].ruler.enable(t,!0))},this),n=n.concat(this.inline.ruler2.enable(t,!0));const r=t.filter(function(t){return n.indexOf(t)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this},Rt.prototype.disable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(e){n=n.concat(this[e].ruler.disable(t,!0))},this),n=n.concat(this.inline.ruler2.disable(t,!0));const r=t.filter(function(t){return n.indexOf(t)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this},Rt.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},Rt.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");const n=new this.core.State(t,this,e);return this.core.process(n),n.tokens},Rt.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)},Rt.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens},Rt.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};export{Rt as M};