-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconvert.js
5 lines (5 loc) · 50.8 KB
/
convert.js
1
2
3
4
5
var F1=Object.create;var{defineProperty:B0,getPrototypeOf:z1,getOwnPropertyNames:M1}=Object;var B1=Object.prototype.hasOwnProperty;var A0=($,J,Q)=>{Q=$!=null?F1(z1($)):{};const Z=J||!$||!$.__esModule?B0(Q,"default",{value:$,enumerable:!0}):Q;for(let q of M1($))if(!B1.call(Z,q))B0(Z,q,{get:()=>$[q],enumerable:!0});return Z};var u=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var D0=u((V$,S0)=>{var j1=function($){var J,Q=$.match(A1);if(Q&&Q[1])J=Q[1].toLowerCase();var Z,q,Y;switch(J){case j0:if(Z=$0($),!H0.test($)){if(q=Z.querySelector(w0),q)q.parentNode.removeChild(q)}if(!P0.test($)){if(q=Z.querySelector(i),q)q.parentNode.removeChild(q)}return Z.querySelectorAll(j0);case w0:case i:if(Z=l($),Y=Z.querySelectorAll(J),P0.test($)&&H0.test($))return Y[0].parentNode.childNodes;return Y;default:if(J0)return J0($);return q=l($,i).querySelector(i),q.childNodes}},j0="html",w0="head",i="body",A1=/<([a-zA-Z]+[0-9]?)/,H0=/<head[^]*>/i,P0=/<body[^]*>/i,l=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},$0=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},R0=typeof window==="object"&&window.DOMParser;if(typeof R0==="function")I0=new R0,L0="text/html",$0=function($,J){if(J)$="<"+J+">"+$+"</"+J+">";return I0.parseFromString($,L0)},l=$0;var I0,L0;if(typeof document==="object"&&document.implementation)_=document.implementation.createHTMLDocument(),l=function($,J){if(J){var Q=_.documentElement.querySelector(J);return Q.innerHTML=$,_}return _.documentElement.innerHTML=$,_};var _,e=typeof document==="object"?document.createElement("template"):{},J0;if(e.content)J0=function($){return e.innerHTML=$,e.content.childNodes};S0.exports=j1});var Q0=u((C0)=>{var w1=function($){return $.type===I.Tag||$.type===I.Script||$.type===I.Style};Object.defineProperty(C0,"__esModule",{value:!0});C0.Doctype=C0.CDATA=C0.Tag=C0.Style=C0.Script=C0.Comment=C0.Directive=C0.Text=C0.Root=C0.isTag=C0.ElementType=void 0;var I;(function($){$.Root="root",$.Text="text",$.Directive="directive",$.Comment="comment",$.Script="script",$.Style="style",$.Tag="tag",$.CDATA="cdata",$.Doctype="doctype"})(I=C0.ElementType||(C0.ElementType={}));C0.isTag=w1;C0.Root=I.Root;C0.Text=I.Text;C0.Directive=I.Directive;C0.Comment=I.Comment;C0.Script=I.Script;C0.Style=I.Style;C0.Tag=I.Tag;C0.CDATA=I.CDATA;C0.Doctype=I.Doctype});var X0=u((z)=>{var u0=function($){return(0,R.isTag)($)},_0=function($){return $.type===R.ElementType.CDATA},h0=function($){return $.type===R.ElementType.Text},x0=function($){return $.type===R.ElementType.Comment},m0=function($){return $.type===R.ElementType.Directive},p0=function($){return $.type===R.ElementType.Root},E1=function($){return Object.prototype.hasOwnProperty.call($,"children")},Y0=function($,J){if(J===void 0)J=!1;var Q;if(h0($))Q=new f0($.data);else if(x0($))Q=new y0($.data);else if(u0($)){var Z=J?Z0($.children):[],q=new T0($.name,h({},$.attribs),Z);if(Z.forEach(function(V){return V.parent=q}),$.namespace!=null)q.namespace=$.namespace;if($["x-attribsNamespace"])q["x-attribsNamespace"]=h({},$["x-attribsNamespace"]);if($["x-attribsPrefix"])q["x-attribsPrefix"]=h({},$["x-attribsPrefix"]);Q=q}else if(_0($)){var Z=J?Z0($.children):[],Y=new b0(Z);Z.forEach(function(W){return W.parent=Y}),Q=Y}else if(p0($)){var Z=J?Z0($.children):[],X=new g0(Z);if(Z.forEach(function(W){return W.parent=X}),$["x-mode"])X["x-mode"]=$["x-mode"];Q=X}else if(m0($)){var K=new v0($.name,$.data);if($["x-name"]!=null)K["x-name"]=$["x-name"],K["x-publicId"]=$["x-publicId"],K["x-systemId"]=$["x-systemId"];Q=K}else throw new Error("Not implemented yet: ".concat($.type));if(Q.startIndex=$.startIndex,Q.endIndex=$.endIndex,$.sourceCodeLocation!=null)Q.sourceCodeLocation=$.sourceCodeLocation;return Q},Z0=function($){var J=$.map(function(Z){return Y0(Z,!0)});for(var Q=1;Q<J.length;Q++)J[Q].prev=J[Q-1],J[Q-1].next=J[Q];return J},f=z&&z.__extends||function(){var $=function(J,Q){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Z,q){Z.__proto__=q}||function(Z,q){for(var Y in q)if(Object.prototype.hasOwnProperty.call(q,Y))Z[Y]=q[Y]},$(J,Q)};return function(J,Q){if(typeof Q!=="function"&&Q!==null)throw new TypeError("Class extends value "+String(Q)+" is not a constructor or null");$(J,Q);function Z(){this.constructor=J}J.prototype=Q===null?Object.create(Q):(Z.prototype=Q.prototype,new Z)}}(),h=z&&z.__assign||function(){return h=Object.assign||function($){for(var J,Q=1,Z=arguments.length;Q<Z;Q++){J=arguments[Q];for(var q in J)if(Object.prototype.hasOwnProperty.call(J,q))$[q]=J[q]}return $},h.apply(this,arguments)};Object.defineProperty(z,"__esModule",{value:!0});z.cloneNode=z.hasChildren=z.isDocument=z.isDirective=z.isComment=z.isText=z.isCDATA=z.isTag=z.Element=z.Document=z.CDATA=z.NodeWithChildren=z.ProcessingInstruction=z.Comment=z.Text=z.DataNode=z.Node=void 0;var R=Q0(),q0=function(){function $(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty($.prototype,"parentNode",{get:function(){return this.parent},set:function(J){this.parent=J},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"previousSibling",{get:function(){return this.prev},set:function(J){this.prev=J},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"nextSibling",{get:function(){return this.next},set:function(J){this.next=J},enumerable:!1,configurable:!0}),$.prototype.cloneNode=function(J){if(J===void 0)J=!1;return Y0(this,J)},$}();z.Node=q0;var a=function($){f(J,$);function J(Q){var Z=$.call(this)||this;return Z.data=Q,Z}return Object.defineProperty(J.prototype,"nodeValue",{get:function(){return this.data},set:function(Q){this.data=Q},enumerable:!1,configurable:!0}),J}(q0);z.DataNode=a;var f0=function($){f(J,$);function J(){var Q=$!==null&&$.apply(this,arguments)||this;return Q.type=R.ElementType.Text,Q}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),J}(a);z.Text=f0;var y0=function($){f(J,$);function J(){var Q=$!==null&&$.apply(this,arguments)||this;return Q.type=R.ElementType.Comment,Q}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),J}(a);z.Comment=y0;var v0=function($){f(J,$);function J(Q,Z){var q=$.call(this,Z)||this;return q.name=Q,q.type=R.ElementType.Directive,q}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),J}(a);z.ProcessingInstruction=v0;var c=function($){f(J,$);function J(Q){var Z=$.call(this)||this;return Z.children=Q,Z}return Object.defineProperty(J.prototype,"firstChild",{get:function(){var Q;return(Q=this.children[0])!==null&&Q!==void 0?Q:null},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"childNodes",{get:function(){return this.children},set:function(Q){this.children=Q},enumerable:!1,configurable:!0}),J}(q0);z.NodeWithChildren=c;var b0=function($){f(J,$);function J(){var Q=$!==null&&$.apply(this,arguments)||this;return Q.type=R.ElementType.CDATA,Q}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),J}(c);z.CDATA=b0;var g0=function($){f(J,$);function J(){var Q=$!==null&&$.apply(this,arguments)||this;return Q.type=R.ElementType.Root,Q}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),J}(c);z.Document=g0;var T0=function($){f(J,$);function J(Q,Z,q,Y){if(q===void 0)q=[];if(Y===void 0)Y=Q==="script"?R.ElementType.Script:Q==="style"?R.ElementType.Style:R.ElementType.Tag;var X=$.call(this,q)||this;return X.name=Q,X.attribs=Z,X.type=Y,X}return Object.defineProperty(J.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"tagName",{get:function(){return this.name},set:function(Q){this.name=Q},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"attributes",{get:function(){var Q=this;return Object.keys(this.attribs).map(function(Z){var q,Y;return{name:Z,value:Q.attribs[Z],namespace:(q=Q["x-attribsNamespace"])===null||q===void 0?void 0:q[Z],prefix:(Y=Q["x-attribsPrefix"])===null||Y===void 0?void 0:Y[Z]}})},enumerable:!1,configurable:!0}),J}(c);z.Element=T0;z.isTag=u0;z.isCDATA=_0;z.isText=h0;z.isComment=x0;z.isDirective=m0;z.isDocument=p0;z.hasChildren=E1;z.cloneNode=Y0});var i0=u((S)=>{var f1=S&&S.__createBinding||(Object.create?function($,J,Q,Z){if(Z===void 0)Z=Q;var q=Object.getOwnPropertyDescriptor(J,Q);if(!q||("get"in q?!J.__esModule:q.writable||q.configurable))q={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Z,q)}:function($,J,Q,Z){if(Z===void 0)Z=Q;$[Z]=J[Q]}),y1=S&&S.__exportStar||function($,J){for(var Q in $)if(Q!=="default"&&!Object.prototype.hasOwnProperty.call(J,Q))f1(J,$,Q)};Object.defineProperty(S,"__esModule",{value:!0});S.DomHandler=void 0;var K0=Q0(),y=X0();y1(X0(),S);var k0={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},d0=function(){function $(J,Q,Z){if(this.dom=[],this.root=new y.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof Q==="function")Z=Q,Q=k0;if(typeof J==="object")Q=J,J=void 0;this.callback=J!==null&&J!==void 0?J:null,this.options=Q!==null&&Q!==void 0?Q:k0,this.elementCB=Z!==null&&Z!==void 0?Z:null}return $.prototype.onparserinit=function(J){this.parser=J},$.prototype.onreset=function(){this.dom=[],this.root=new y.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},$.prototype.onend=function(){if(this.done)return;this.done=!0,this.parser=null,this.handleCallback(null)},$.prototype.onerror=function(J){this.handleCallback(J)},$.prototype.onclosetag=function(){this.lastNode=null;var J=this.tagStack.pop();if(this.options.withEndIndices)J.endIndex=this.parser.endIndex;if(this.elementCB)this.elementCB(J)},$.prototype.onopentag=function(J,Q){var Z=this.options.xmlMode?K0.ElementType.Tag:void 0,q=new y.Element(J,Q,void 0,Z);this.addNode(q),this.tagStack.push(q)},$.prototype.ontext=function(J){var Q=this.lastNode;if(Q&&Q.type===K0.ElementType.Text){if(Q.data+=J,this.options.withEndIndices)Q.endIndex=this.parser.endIndex}else{var Z=new y.Text(J);this.addNode(Z),this.lastNode=Z}},$.prototype.oncomment=function(J){if(this.lastNode&&this.lastNode.type===K0.ElementType.Comment){this.lastNode.data+=J;return}var Q=new y.Comment(J);this.addNode(Q),this.lastNode=Q},$.prototype.oncommentend=function(){this.lastNode=null},$.prototype.oncdatastart=function(){var J=new y.Text(""),Q=new y.CDATA([J]);this.addNode(Q),J.parent=Q,this.lastNode=J},$.prototype.oncdataend=function(){this.lastNode=null},$.prototype.onprocessinginstruction=function(J,Q){var Z=new y.ProcessingInstruction(J,Q);this.addNode(Z)},$.prototype.handleCallback=function(J){if(typeof this.callback==="function")this.callback(J,this.dom);else if(J)throw J},$.prototype.addNode=function(J){var Q=this.tagStack[this.tagStack.length-1],Z=Q.children[Q.children.length-1];if(this.options.withStartIndices)J.startIndex=this.parser.startIndex;if(this.options.withEndIndices)J.endIndex=this.parser.endIndex;if(Q.children.push(J),Z)J.prev=Z,Z.next=J;J.parent=Q,this.lastNode=null},$}();S.DomHandler=d0;S.default=d0});var l0=u((v1)=>{v1.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"]});var r0=u((p1)=>{var x1=function($){return s0[$]},o0=function($){var J={},Q;for(var Z=0,q=$.length;Z<q;Z++)Q=$[Z],J[Q.name]=Q.value;return J},m1=function($){$=$.toLowerCase();var J=x1($);if(J)return J;return $},n0=function($,J,Q){J=J||null;var Z=[],q;for(var Y=0,X=$.length;Y<X;Y++){var K=$[Y],V;switch(K.nodeType){case 1:q=m1(K.nodeName),V=new u1(q,o0(K.attributes)),V.children=n0(q==="template"?K.content.childNodes:K.childNodes,V);break;case 3:V=new h1(K.nodeValue);break;case 8:V=new T1(K.nodeValue);break;default:continue}var W=Z[Y-1]||null;if(W)W.next=V;V.parent=J,V.prev=W,V.next=null,Z.push(V)}if(Q){if(V=new _1(Q.substring(0,Q.indexOf(" ")).toLowerCase(),Q),V.next=Z[0]||null,V.parent=J,Z.unshift(V),Z[1])Z[1].prev=Z[0]}return Z},o=i0(),g1=l0(),a0=g1.CASE_SENSITIVE_TAG_NAMES,T1=o.Comment,u1=o.Element,_1=o.ProcessingInstruction,h1=o.Text,s0={},V0;for(s=0,c0=a0.length;s<c0;s++)V0=a0[s],s0[V0.toLowerCase()]=V0;var s,c0;p1.formatAttributes=o0;p1.formatDOM=n0});var t0=A0(D0(),1),e0=A0(r0(),1),i1=e0.default.formatDOM,l1=/<(![a-zA-Z\s]+)>/;function W0($){if(typeof $!=="string")throw new TypeError("First argument must be a string");if($==="")return[];var J=$.match(l1),Q;if(J&&J[1])Q=J[1];return i1(t0.default($),null,Q)}var U0=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},q1=function($){g=$},L=function($,J){if(J){if(Y1.test($))return $.replace(a1,$1)}else if(X1.test($))return $.replace(c1,$1);return $},n1=function($){return $.replace(o1,(J,Q)=>{if(Q=Q.toLowerCase(),Q==="colon")return":";if(Q.charAt(0)==="#")return Q.charAt(1)==="x"?String.fromCharCode(parseInt(Q.substring(2),16)):String.fromCharCode(+Q.substring(1));return""})},j=function($,J){$=typeof $==="string"?$:$.source,J=J||"";const Q={replace:(Z,q)=>{return q=typeof q==="object"&&("source"in q)?q.source:q,q=q.replace(r1,"$1"),$=$.replace(Z,q),Q},getRegex:()=>{return new RegExp($,J)}};return Q},J1=function($){try{$=encodeURI($).replace(/%25/g,"%")}catch(J){return null}return $},Q1=function($,J){const Q=$.replace(/\|/g,(Y,X,K)=>{let V=!1,W=X;while(--W>=0&&K[W]==="\\")V=!V;if(V)return"|";else return" |"}),Z=Q.split(/ \|/);let q=0;if(!Z[0].trim())Z.shift();if(Z.length>0&&!Z[Z.length-1].trim())Z.pop();if(J)if(Z.length>J)Z.splice(J);else while(Z.length<J)Z.push("");for(;q<Z.length;q++)Z[q]=Z[q].trim().replace(/\\\|/g,"|");return Z},G0=function($,J,Q){const Z=$.length;if(Z===0)return"";let q=0;while(q<Z){const Y=$.charAt(Z-q-1);if(Y===J&&!Q)q++;else if(Y!==J&&Q)q++;else break}return $.slice(0,Z-q)},t1=function($,J){if($.indexOf(J[1])===-1)return-1;let Q=0;for(let Z=0;Z<$.length;Z++)if($[Z]==="\\")Z++;else if($[Z]===J[0])Q++;else if($[Z]===J[1]){if(Q--,Q<0)return Z}return-1},Z1=function($,J,Q,Z){const q=J.href,Y=J.title?L(J.title):null,X=$[1].replace(/\\([\[\]])/g,"$1");if($[0].charAt(0)!=="!"){Z.state.inLink=!0;const K={type:"link",raw:Q,href:q,title:Y,text:X,tokens:Z.inlineTokens(X)};return Z.state.inLink=!1,K}return{type:"image",raw:Q,href:q,title:Y,text:L(X)}},e1=function($,J){const Q=$.match(/^(\s+)(?:```)/);if(Q===null)return J;const Z=Q[1];return J.split("\n").map((q)=>{const Y=q.match(/^\s+/);if(Y===null)return q;const[X]=Y;if(X.length>=Z.length)return q.slice(Z.length);return q}).join("\n")},A=function($,J){return b.parse($,J)},g=U0(),Y1=/[&<>"']/,a1=new RegExp(Y1.source,"g"),X1=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,c1=new RegExp(X1.source,"g"),s1={"&":"&","<":"<",">":">",'"':""","'":"'"},$1=($)=>s1[$],o1=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,r1=/(^|[^\[])\^/g,n={exec:()=>null};class m{options;rules;lexer;constructor($){this.options=$||g}space($){const J=this.rules.block.newline.exec($);if(J&&J[0].length>0)return{type:"space",raw:J[0]}}code($){const J=this.rules.block.code.exec($);if(J){const Q=J[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:!this.options.pedantic?G0(Q,"\n"):Q}}}fences($){const J=this.rules.block.fences.exec($);if(J){const Q=J[0],Z=e1(Q,J[3]||"");return{type:"code",raw:Q,lang:J[2]?J[2].trim().replace(this.rules.inline._escapes,"$1"):J[2],text:Z}}}heading($){const J=this.rules.block.heading.exec($);if(J){let Q=J[2].trim();if(/#$/.test(Q)){const Z=G0(Q,"#");if(this.options.pedantic)Q=Z.trim();else if(!Z||/ $/.test(Z))Q=Z.trim()}return{type:"heading",raw:J[0],depth:J[1].length,text:Q,tokens:this.lexer.inline(Q)}}}hr($){const J=this.rules.block.hr.exec($);if(J)return{type:"hr",raw:J[0]}}blockquote($){const J=this.rules.block.blockquote.exec($);if(J){const Q=J[0].replace(/^ *>[ \t]?/gm,""),Z=this.lexer.state.top;this.lexer.state.top=!0;const q=this.lexer.blockTokens(Q);return this.lexer.state.top=Z,{type:"blockquote",raw:J[0],tokens:q,text:Q}}}list($){let J=this.rules.block.list.exec($);if(J){let Q=J[1].trim();const Z=Q.length>1,q={type:"list",raw:"",ordered:Z,start:Z?+Q.slice(0,-1):"",loose:!1,items:[]};if(Q=Z?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic)Q=Z?Q:"[*+-]";const Y=new RegExp(`^( {0,3}${Q})((?:[\t ][^\\n]*)?(?:\\n|\$))`);let X="",K="",V=!1;while($){let W=!1;if(!(J=Y.exec($)))break;if(this.rules.block.hr.test($))break;X=J[0],$=$.substring(X.length);let F=J[2].split("\n",1)[0].replace(/^\t+/,(w)=>" ".repeat(3*w.length)),U=$.split("\n",1)[0],M=0;if(this.options.pedantic)M=2,K=F.trimStart();else M=J[2].search(/[^ ]/),M=M>4?1:M,K=F.slice(M),M+=J[1].length;let B=!1;if(!F&&/^ *$/.test(U))X+=U+"\n",$=$.substring(U.length+1),W=!0;if(!W){const w=new RegExp(`^ {0,${Math.min(3,M-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|\$))`),C=new RegExp(`^ {0,${Math.min(3,M-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|\$)`),v=new RegExp(`^ {0,${Math.min(3,M-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,M-1)}}#`);while($){const t=$.split("\n",1)[0];if(U=t,this.options.pedantic)U=U.replace(/^ {1,4}(?=( {4})*[^ ])/g," ");if(v.test(U))break;if(E.test(U))break;if(w.test(U))break;if(C.test($))break;if(U.search(/[^ ]/)>=M||!U.trim())K+="\n"+U.slice(M);else{if(B)break;if(F.search(/[^ ]/)>=4)break;if(v.test(F))break;if(E.test(F))break;if(C.test(F))break;K+="\n"+U}if(!B&&!U.trim())B=!0;X+=t+"\n",$=$.substring(t.length+1),F=U.slice(M)}}if(!q.loose){if(V)q.loose=!0;else if(/\n *\n *$/.test(X))V=!0}let P=null,H;if(this.options.gfm){if(P=/^\[[ xX]\] /.exec(K),P)H=P[0]!=="[ ] ",K=K.replace(/^\[[ xX]\] +/,"")}q.items.push({type:"list_item",raw:X,task:!!P,checked:H,loose:!1,text:K,tokens:[]}),q.raw+=X}q.items[q.items.length-1].raw=X.trimEnd(),q.items[q.items.length-1].text=K.trimEnd(),q.raw=q.raw.trimEnd();for(let W=0;W<q.items.length;W++)if(this.lexer.state.top=!1,q.items[W].tokens=this.lexer.blockTokens(q.items[W].text,[]),!q.loose){const F=q.items[W].tokens.filter((M)=>M.type==="space"),U=F.length>0&&F.some((M)=>/\n.*\n/.test(M.raw));q.loose=U}if(q.loose)for(let W=0;W<q.items.length;W++)q.items[W].loose=!0;return q}}html($){const J=this.rules.block.html.exec($);if(J)return{type:"html",block:!0,raw:J[0],pre:J[1]==="pre"||J[1]==="script"||J[1]==="style",text:J[0]}}def($){const J=this.rules.block.def.exec($);if(J){const Q=J[1].toLowerCase().replace(/\s+/g," "),Z=J[2]?J[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",q=J[3]?J[3].substring(1,J[3].length-1).replace(this.rules.inline._escapes,"$1"):J[3];return{type:"def",tag:Q,raw:J[0],href:Z,title:q}}}table($){const J=this.rules.block.table.exec($);if(J){if(!/[:|]/.test(J[2]))return;const Q={type:"table",raw:J[0],header:Q1(J[1]).map((Z)=>{return{text:Z,tokens:[]}}),align:J[2].replace(/^\||\| *$/g,"").split("|"),rows:J[3]&&J[3].trim()?J[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(Q.header.length===Q.align.length){let Z=Q.align.length,q,Y,X,K;for(q=0;q<Z;q++){const V=Q.align[q];if(V)if(/^ *-+: *$/.test(V))Q.align[q]="right";else if(/^ *:-+: *$/.test(V))Q.align[q]="center";else if(/^ *:-+ *$/.test(V))Q.align[q]="left";else Q.align[q]=null}Z=Q.rows.length;for(q=0;q<Z;q++)Q.rows[q]=Q1(Q.rows[q],Q.header.length).map((V)=>{return{text:V,tokens:[]}});Z=Q.header.length;for(Y=0;Y<Z;Y++)Q.header[Y].tokens=this.lexer.inline(Q.header[Y].text);Z=Q.rows.length;for(Y=0;Y<Z;Y++){K=Q.rows[Y];for(X=0;X<K.length;X++)K[X].tokens=this.lexer.inline(K[X].text)}return Q}}}lheading($){const J=this.rules.block.lheading.exec($);if(J)return{type:"heading",raw:J[0],depth:J[2].charAt(0)==="="?1:2,text:J[1],tokens:this.lexer.inline(J[1])}}paragraph($){const J=this.rules.block.paragraph.exec($);if(J){const Q=J[1].charAt(J[1].length-1)==="\n"?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:Q,tokens:this.lexer.inline(Q)}}}text($){const J=this.rules.block.text.exec($);if(J)return{type:"text",raw:J[0],text:J[0],tokens:this.lexer.inline(J[0])}}escape($){const J=this.rules.inline.escape.exec($);if(J)return{type:"escape",raw:J[0],text:L(J[1])}}tag($){const J=this.rules.inline.tag.exec($);if(J){if(!this.lexer.state.inLink&&/^<a /i.test(J[0]))this.lexer.state.inLink=!0;else if(this.lexer.state.inLink&&/^<\/a>/i.test(J[0]))this.lexer.state.inLink=!1;if(!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(J[0]))this.lexer.state.inRawBlock=!0;else if(this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(J[0]))this.lexer.state.inRawBlock=!1;return{type:"html",raw:J[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:J[0]}}}link($){const J=this.rules.inline.link.exec($);if(J){const Q=J[2].trim();if(!this.options.pedantic&&/^</.test(Q)){if(!/>$/.test(Q))return;const Y=G0(Q.slice(0,-1),"\\");if((Q.length-Y.length)%2===0)return}else{const Y=t1(J[2],"()");if(Y>-1){const K=(J[0].indexOf("!")===0?5:4)+J[1].length+Y;J[2]=J[2].substring(0,Y),J[0]=J[0].substring(0,K).trim(),J[3]=""}}let Z=J[2],q="";if(this.options.pedantic){const Y=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Z);if(Y)Z=Y[1],q=Y[3]}else q=J[3]?J[3].slice(1,-1):"";if(Z=Z.trim(),/^</.test(Z))if(this.options.pedantic&&!/>$/.test(Q))Z=Z.slice(1);else Z=Z.slice(1,-1);return Z1(J,{href:Z?Z.replace(this.rules.inline._escapes,"$1"):Z,title:q?q.replace(this.rules.inline._escapes,"$1"):q},J[0],this.lexer)}}reflink($,J){let Q;if((Q=this.rules.inline.reflink.exec($))||(Q=this.rules.inline.nolink.exec($))){let Z=(Q[2]||Q[1]).replace(/\s+/g," ");if(Z=J[Z.toLowerCase()],!Z){const q=Q[0].charAt(0);return{type:"text",raw:q,text:q}}return Z1(Q,Z,Q[0],this.lexer)}}emStrong($,J,Q=""){let Z=this.rules.inline.emStrong.lDelim.exec($);if(!Z)return;if(Z[3]&&Q.match(/[\p{L}\p{N}]/u))return;if(!(Z[1]||Z[2])||!Q||this.rules.inline.punctuation.exec(Q)){const Y=[...Z[0]].length-1;let X,K,V=Y,W=0;const F=Z[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;F.lastIndex=0,J=J.slice(-1*$.length+Z[0].length-1);while((Z=F.exec(J))!=null){if(X=Z[1]||Z[2]||Z[3]||Z[4]||Z[5]||Z[6],!X)continue;if(K=[...X].length,Z[3]||Z[4]){V+=K;continue}else if(Z[5]||Z[6]){if(Y%3&&!((Y+K)%3)){W+=K;continue}}if(V-=K,V>0)continue;K=Math.min(K,K+V+W);const U=[...$].slice(0,Y+Z.index+K+1).join("");if(Math.min(Y,K)%2){const B=U.slice(1,-1);return{type:"em",raw:U,text:B,tokens:this.lexer.inlineTokens(B)}}const M=U.slice(2,-2);return{type:"strong",raw:U,text:M,tokens:this.lexer.inlineTokens(M)}}}}codespan($){const J=this.rules.inline.code.exec($);if(J){let Q=J[2].replace(/\n/g," ");const Z=/[^ ]/.test(Q),q=/^ /.test(Q)&&/ $/.test(Q);if(Z&&q)Q=Q.substring(1,Q.length-1);return Q=L(Q,!0),{type:"codespan",raw:J[0],text:Q}}}br($){const J=this.rules.inline.br.exec($);if(J)return{type:"br",raw:J[0]}}del($){const J=this.rules.inline.del.exec($);if(J)return{type:"del",raw:J[0],text:J[2],tokens:this.lexer.inlineTokens(J[2])}}autolink($){const J=this.rules.inline.autolink.exec($);if(J){let Q,Z;if(J[2]==="@")Q=L(J[1]),Z="mailto:"+Q;else Q=L(J[1]),Z=Q;return{type:"link",raw:J[0],text:Q,href:Z,tokens:[{type:"text",raw:Q,text:Q}]}}}url($){let J;if(J=this.rules.inline.url.exec($)){let Q,Z;if(J[2]==="@")Q=L(J[0]),Z="mailto:"+Q;else{let q;do q=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])[0];while(q!==J[0]);if(Q=L(J[0]),J[1]==="www.")Z="http://"+J[0];else Z=J[0]}return{type:"link",raw:J[0],text:Q,href:Z,tokens:[{type:"text",raw:Q,text:Q}]}}}inlineText($){const J=this.rules.inline.text.exec($);if(J){let Q;if(this.lexer.state.inRawBlock)Q=J[0];else Q=L(J[0]);return{type:"text",raw:J[0],text:Q}}}}var O={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {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|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:n,lheading:/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};O._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;O._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;O.def=j(O.def).replace("label",O._label).replace("title",O._title).getRegex();O.bullet=/(?:[*+-]|\d{1,9}[.)])/;O.listItemStart=j(/^( *)(bull) */).replace("bull",O.bullet).getRegex();O.list=j(O.list).replace(/bull/g,O.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+O.def.source+")").getRegex();O._tag="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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";O._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/;O.html=j(O.html,"i").replace("comment",O._comment).replace("tag",O._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();O.lheading=j(O.lheading).replace(/bull/g,O.bullet).getRegex();O.paragraph=j(O._paragraph).replace("hr",O.hr).replace("heading"," {0,3}#{1,6} ").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",O._tag).getRegex();O.blockquote=j(O.blockquote).replace("paragraph",O.paragraph).getRegex();O.normal={...O};O.gfm={...O.normal,table:"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};O.gfm.table=j(O.gfm.table).replace("hr",O.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\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",O._tag).getRegex();O.gfm.paragraph=j(O._paragraph).replace("hr",O.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",O.gfm.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",O._tag).getRegex();O.pedantic={...O.normal,html:j('^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace("comment",O._comment).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:n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(O.normal._paragraph).replace("hr",O.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",O.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};var G={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:n,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:n,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^((?![*_])[\spunctuation])/};G._punctuation="\\p{P}$+<=>`^|~";G.punctuation=j(G.punctuation,"u").replace(/punctuation/g,G._punctuation).getRegex();G.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;G.anyPunctuation=/\\[punct]/g;G._escapes=/\\([punct])/g;G._comment=j(O._comment).replace("(?:-->|$)","-->").getRegex();G.emStrong.lDelim=j(G.emStrong.lDelim,"u").replace(/punct/g,G._punctuation).getRegex();G.emStrong.rDelimAst=j(G.emStrong.rDelimAst,"gu").replace(/punct/g,G._punctuation).getRegex();G.emStrong.rDelimUnd=j(G.emStrong.rDelimUnd,"gu").replace(/punct/g,G._punctuation).getRegex();G.anyPunctuation=j(G.anyPunctuation,"gu").replace(/punct/g,G._punctuation).getRegex();G._escapes=j(G._escapes,"gu").replace(/punct/g,G._punctuation).getRegex();G._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;G._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])?)+(?![-_])/;G.autolink=j(G.autolink).replace("scheme",G._scheme).replace("email",G._email).getRegex();G._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;G.tag=j(G.tag).replace("comment",G._comment).replace("attribute",G._attribute).getRegex();G._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;G._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;G._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;G.link=j(G.link).replace("label",G._label).replace("href",G._href).replace("title",G._title).getRegex();G.reflink=j(G.reflink).replace("label",G._label).replace("ref",O._label).getRegex();G.nolink=j(G.nolink).replace("ref",O._label).getRegex();G.reflinkSearch=j(G.reflinkSearch,"g").replace("reflink",G.reflink).replace("nolink",G.nolink).getRegex();G.normal={...G};G.pedantic={...G.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",G._label).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G._label).getRegex()};G.gfm={...G.normal,escape:j(G.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\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.!#$%&'*+\/=?_`{\|}~-]+@)))/};G.gfm.url=j(G.gfm.url,"i").replace("email",G.gfm._extended_email).getRegex();G.breaks={...G.gfm,br:j(G.br).replace("{2,}","*").getRegex(),text:j(G.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};class D{tokens;options;state;tokenizer;inlineQueue;constructor($){this.tokens=[],this.tokens.links=Object.create(null),this.options=$||g,this.options.tokenizer=this.options.tokenizer||new m,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const J={block:O.normal,inline:G.normal};if(this.options.pedantic)J.block=O.pedantic,J.inline=G.pedantic;else if(this.options.gfm)if(J.block=O.gfm,this.options.breaks)J.inline=G.breaks;else J.inline=G.gfm;this.tokenizer.rules=J}static get rules(){return{block:O,inline:G}}static lex($,J){return new D(J).lex($)}static lexInline($,J){return new D(J).inlineTokens($)}lex($){$=$.replace(/\r\n|\r/g,"\n"),this.blockTokens($,this.tokens);let J;while(J=this.inlineQueue.shift())this.inlineTokens(J.src,J.tokens);return this.tokens}blockTokens($,J=[]){if(this.options.pedantic)$=$.replace(/\t/g," ").replace(/^ +$/gm,"");else $=$.replace(/^( *)(\t+)/gm,(X,K,V)=>{return K+" ".repeat(V.length)});let Q,Z,q,Y;while($){if(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((X)=>{if(Q=X.call({lexer:this},$,J))return $=$.substring(Q.raw.length),J.push(Q),!0;return!1}))continue;if(Q=this.tokenizer.space($)){if($=$.substring(Q.raw.length),Q.raw.length===1&&J.length>0)J[J.length-1].raw+="\n";else J.push(Q);continue}if(Q=this.tokenizer.code($)){if($=$.substring(Q.raw.length),Z=J[J.length-1],Z&&(Z.type==="paragraph"||Z.type==="text"))Z.raw+="\n"+Q.raw,Z.text+="\n"+Q.text,this.inlineQueue[this.inlineQueue.length-1].src=Z.text;else J.push(Q);continue}if(Q=this.tokenizer.fences($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.heading($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.hr($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.blockquote($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.list($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.html($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.def($)){if($=$.substring(Q.raw.length),Z=J[J.length-1],Z&&(Z.type==="paragraph"||Z.type==="text"))Z.raw+="\n"+Q.raw,Z.text+="\n"+Q.raw,this.inlineQueue[this.inlineQueue.length-1].src=Z.text;else if(!this.tokens.links[Q.tag])this.tokens.links[Q.tag]={href:Q.href,title:Q.title};continue}if(Q=this.tokenizer.table($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.lheading($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(q=$,this.options.extensions&&this.options.extensions.startBlock){let X=Infinity;const K=$.slice(1);let V;if(this.options.extensions.startBlock.forEach((W)=>{if(V=W.call({lexer:this},K),typeof V==="number"&&V>=0)X=Math.min(X,V)}),X<Infinity&&X>=0)q=$.substring(0,X+1)}if(this.state.top&&(Q=this.tokenizer.paragraph(q))){if(Z=J[J.length-1],Y&&Z.type==="paragraph")Z.raw+="\n"+Q.raw,Z.text+="\n"+Q.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=Z.text;else J.push(Q);Y=q.length!==$.length,$=$.substring(Q.raw.length);continue}if(Q=this.tokenizer.text($)){if($=$.substring(Q.raw.length),Z=J[J.length-1],Z&&Z.type==="text")Z.raw+="\n"+Q.raw,Z.text+="\n"+Q.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=Z.text;else J.push(Q);continue}if($){const X="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(X);break}else throw new Error(X)}}return this.state.top=!0,J}inline($,J=[]){return this.inlineQueue.push({src:$,tokens:J}),J}inlineTokens($,J=[]){let Q,Z,q,Y=$,X,K,V;if(this.tokens.links){const W=Object.keys(this.tokens.links);if(W.length>0){while((X=this.tokenizer.rules.inline.reflinkSearch.exec(Y))!=null)if(W.includes(X[0].slice(X[0].lastIndexOf("[")+1,-1)))Y=Y.slice(0,X.index)+"["+"a".repeat(X[0].length-2)+"]"+Y.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex)}}while((X=this.tokenizer.rules.inline.blockSkip.exec(Y))!=null)Y=Y.slice(0,X.index)+"["+"a".repeat(X[0].length-2)+"]"+Y.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);while((X=this.tokenizer.rules.inline.anyPunctuation.exec(Y))!=null)Y=Y.slice(0,X.index)+"++"+Y.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);while($){if(!K)V="";if(K=!1,this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((W)=>{if(Q=W.call({lexer:this},$,J))return $=$.substring(Q.raw.length),J.push(Q),!0;return!1}))continue;if(Q=this.tokenizer.escape($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.tag($)){if($=$.substring(Q.raw.length),Z=J[J.length-1],Z&&Q.type==="text"&&Z.type==="text")Z.raw+=Q.raw,Z.text+=Q.text;else J.push(Q);continue}if(Q=this.tokenizer.link($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.reflink($,this.tokens.links)){if($=$.substring(Q.raw.length),Z=J[J.length-1],Z&&Q.type==="text"&&Z.type==="text")Z.raw+=Q.raw,Z.text+=Q.text;else J.push(Q);continue}if(Q=this.tokenizer.emStrong($,Y,V)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.codespan($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.br($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.del($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(Q=this.tokenizer.autolink($)){$=$.substring(Q.raw.length),J.push(Q);continue}if(!this.state.inLink&&(Q=this.tokenizer.url($))){$=$.substring(Q.raw.length),J.push(Q);continue}if(q=$,this.options.extensions&&this.options.extensions.startInline){let W=Infinity;const F=$.slice(1);let U;if(this.options.extensions.startInline.forEach((M)=>{if(U=M.call({lexer:this},F),typeof U==="number"&&U>=0)W=Math.min(W,U)}),W<Infinity&&W>=0)q=$.substring(0,W+1)}if(Q=this.tokenizer.inlineText(q)){if($=$.substring(Q.raw.length),Q.raw.slice(-1)!=="_")V=Q.raw.slice(-1);if(K=!0,Z=J[J.length-1],Z&&Z.type==="text")Z.raw+=Q.raw,Z.text+=Q.text;else J.push(Q);continue}if($){const W="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(W);break}else throw new Error(W)}}return J}}class p{options;constructor($){this.options=$||g}code($,J,Q){const Z=(J||"").match(/^\S*/)?.[0];if($=$.replace(/\n$/,"")+"\n",!Z)return"<pre><code>"+(Q?$:L($,!0))+"</code></pre>\n";return'<pre><code class="language-'+L(Z)+'">'+(Q?$:L($,!0))+"</code></pre>\n"}blockquote($){return`<blockquote>\n${$}</blockquote>\n`}html($,J){return $}heading($,J,Q){return`<h${J}>${$}</h${J}>\n`}hr(){return"<hr>\n"}list($,J,Q){const Z=J?"ol":"ul",q=J&&Q!==1?' start="'+Q+'"':"";return"<"+Z+q+">\n"+$+"</"+Z+">\n"}listitem($,J,Q){return`<li>${$}</li>\n`}checkbox($){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph($){return`<p>${$}</p>\n`}table($,J){if(J)J=`<tbody>${J}</tbody>`;return"<table>\n<thead>\n"+$+"</thead>\n"+J+"</table>\n"}tablerow($){return`<tr>\n${$}</tr>\n`}tablecell($,J){const Q=J.header?"th":"td";return(J.align?`<${Q} align="${J.align}">`:`<${Q}>`)+$+`</${Q}>\n`}strong($){return`<strong>${$}</strong>`}em($){return`<em>${$}</em>`}codespan($){return`<code>${$}</code>`}br(){return"<br>"}del($){return`<del>${$}</del>`}link($,J,Q){const Z=J1($);if(Z===null)return Q;$=Z;let q='<a href="'+$+'"';if(J)q+=' title="'+J+'"';return q+=">"+Q+"</a>",q}image($,J,Q){const Z=J1($);if(Z===null)return Q;$=Z;let q=`<img src="${$}" alt="${Q}"`;if(J)q+=` title="${J}"`;return q+=">",q}text($){return $}}class r{strong($){return $}em($){return $}codespan($){return $}del($){return $}html($){return $}text($){return $}link($,J,Q){return""+Q}image($,J,Q){return""+Q}br(){return""}}class N{options;renderer;textRenderer;constructor($){this.options=$||g,this.options.renderer=this.options.renderer||new p,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new r}static parse($,J){return new N(J).parse($)}static parseInline($,J){return new N(J).parseInline($)}parse($,J=!0){let Q="";for(let Z=0;Z<$.length;Z++){const q=$[Z];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[q.type]){const Y=q,X=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(X!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(Y.type)){Q+=X||"";continue}}switch(q.type){case"space":continue;case"hr":{Q+=this.renderer.hr();continue}case"heading":{const Y=q;Q+=this.renderer.heading(this.parseInline(Y.tokens),Y.depth,n1(this.parseInline(Y.tokens,this.textRenderer)));continue}case"code":{const Y=q;Q+=this.renderer.code(Y.text,Y.lang,!!Y.escaped);continue}case"table":{const Y=q;let X="",K="";for(let W=0;W<Y.header.length;W++)K+=this.renderer.tablecell(this.parseInline(Y.header[W].tokens),{header:!0,align:Y.align[W]});X+=this.renderer.tablerow(K);let V="";for(let W=0;W<Y.rows.length;W++){const F=Y.rows[W];K="";for(let U=0;U<F.length;U++)K+=this.renderer.tablecell(this.parseInline(F[U].tokens),{header:!1,align:Y.align[U]});V+=this.renderer.tablerow(K)}Q+=this.renderer.table(X,V);continue}case"blockquote":{const Y=q,X=this.parse(Y.tokens);Q+=this.renderer.blockquote(X);continue}case"list":{const Y=q,X=Y.ordered,K=Y.start,V=Y.loose;let W="";for(let F=0;F<Y.items.length;F++){const U=Y.items[F],M=U.checked,B=U.task;let P="";if(U.task){const H=this.renderer.checkbox(!!M);if(V)if(U.tokens.length>0&&U.tokens[0].type==="paragraph"){if(U.tokens[0].text=H+" "+U.tokens[0].text,U.tokens[0].tokens&&U.tokens[0].tokens.length>0&&U.tokens[0].tokens[0].type==="text")U.tokens[0].tokens[0].text=H+" "+U.tokens[0].tokens[0].text}else U.tokens.unshift({type:"text",text:H+" "});else P+=H+" "}P+=this.parse(U.tokens,V),W+=this.renderer.listitem(P,B,!!M)}Q+=this.renderer.list(W,X,K);continue}case"html":{const Y=q;Q+=this.renderer.html(Y.text,Y.block);continue}case"paragraph":{const Y=q;Q+=this.renderer.paragraph(this.parseInline(Y.tokens));continue}case"text":{let Y=q,X=Y.tokens?this.parseInline(Y.tokens):Y.text;while(Z+1<$.length&&$[Z+1].type==="text")Y=$[++Z],X+="\n"+(Y.tokens?this.parseInline(Y.tokens):Y.text);Q+=J?this.renderer.paragraph(X):X;continue}default:{const Y='Token with "'+q.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";else throw new Error(Y)}}}return Q}parseInline($,J){J=J||this.renderer;let Q="";for(let Z=0;Z<$.length;Z++){const q=$[Z];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[q.type]){const Y=this.options.extensions.renderers[q.type].call({parser:this},q);if(Y!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(q.type)){Q+=Y||"";continue}}switch(q.type){case"escape":{const Y=q;Q+=J.text(Y.text);break}case"html":{const Y=q;Q+=J.html(Y.text);break}case"link":{const Y=q;Q+=J.link(Y.href,Y.title,this.parseInline(Y.tokens,J));break}case"image":{const Y=q;Q+=J.image(Y.href,Y.title,Y.text);break}case"strong":{const Y=q;Q+=J.strong(this.parseInline(Y.tokens,J));break}case"em":{const Y=q;Q+=J.em(this.parseInline(Y.tokens,J));break}case"codespan":{const Y=q;Q+=J.codespan(Y.text);break}case"br":{Q+=J.br();break}case"del":{const Y=q;Q+=J.del(this.parseInline(Y.tokens,J));break}case"text":{const Y=q;Q+=J.text(Y.text);break}default:{const Y='Token with "'+q.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";else throw new Error(Y)}}}return Q}}class x{options;constructor($){this.options=$||g}static passThroughHooks=new Set(["preprocess","postprocess"]);preprocess($){return $}postprocess($){return $}}class K1{defaults=U0();options=this.setOptions;parse=this.#$(D.lex,N.parse);parseInline=this.#$(D.lexInline,N.parseInline);Parser=N;parser=N.parse;Renderer=p;TextRenderer=r;Lexer=D;lexer=D.lex;Tokenizer=m;Hooks=x;constructor(...$){this.use(...$)}walkTokens($,J){let Q=[];for(let Z of $)switch(Q=Q.concat(J.call(this,Z)),Z.type){case"table":{const q=Z;for(let Y of q.header)Q=Q.concat(this.walkTokens(Y.tokens,J));for(let Y of q.rows)for(let X of Y)Q=Q.concat(this.walkTokens(X.tokens,J));break}case"list":{const q=Z;Q=Q.concat(this.walkTokens(q.items,J));break}default:{const q=Z;if(this.defaults.extensions?.childTokens?.[q.type])this.defaults.extensions.childTokens[q.type].forEach((Y)=>{Q=Q.concat(this.walkTokens(q[Y],J))});else if(q.tokens)Q=Q.concat(this.walkTokens(q.tokens,J))}}return Q}use(...$){const J=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((Q)=>{const Z={...Q};if(Z.async=this.defaults.async||Z.async||!1,Q.extensions)Q.extensions.forEach((q)=>{if(!q.name)throw new Error("extension name required");if("renderer"in q){const Y=J.renderers[q.name];if(Y)J.renderers[q.name]=function(...X){let K=q.renderer.apply(this,X);if(K===!1)K=Y.apply(this,X);return K};else J.renderers[q.name]=q.renderer}if("tokenizer"in q){if(!q.level||q.level!=="block"&&q.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const Y=J[q.level];if(Y)Y.unshift(q.tokenizer);else J[q.level]=[q.tokenizer];if(q.start){if(q.level==="block")if(J.startBlock)J.startBlock.push(q.start);else J.startBlock=[q.start];else if(q.level==="inline")if(J.startInline)J.startInline.push(q.start);else J.startInline=[q.start]}}if(("childTokens"in q)&&q.childTokens)J.childTokens[q.name]=q.childTokens}),Z.extensions=J;if(Q.renderer){const q=this.defaults.renderer||new p(this.defaults);for(let Y in Q.renderer){const X=Q.renderer[Y],K=Y,V=q[K];q[K]=(...W)=>{let F=X.apply(q,W);if(F===!1)F=V.apply(q,W);return F||""}}Z.renderer=q}if(Q.tokenizer){const q=this.defaults.tokenizer||new m(this.defaults);for(let Y in Q.tokenizer){const X=Q.tokenizer[Y],K=Y,V=q[K];q[K]=(...W)=>{let F=X.apply(q,W);if(F===!1)F=V.apply(q,W);return F}}Z.tokenizer=q}if(Q.hooks){const q=this.defaults.hooks||new x;for(let Y in Q.hooks){const X=Q.hooks[Y],K=Y,V=q[K];if(x.passThroughHooks.has(Y))q[K]=(W)=>{if(this.defaults.async)return Promise.resolve(X.call(q,W)).then((U)=>{return V.call(q,U)});const F=X.call(q,W);return V.call(q,F)};else q[K]=(...W)=>{let F=X.apply(q,W);if(F===!1)F=V.apply(q,W);return F}}Z.hooks=q}if(Q.walkTokens){const q=this.defaults.walkTokens,Y=Q.walkTokens;Z.walkTokens=function(X){let K=[];if(K.push(Y.call(this,X)),q)K=K.concat(q.call(this,X));return K}}this.defaults={...this.defaults,...Z}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}#$($,J){return(Q,Z)=>{const q={...Z},Y={...this.defaults,...q};if(this.defaults.async===!0&&q.async===!1){if(!Y.silent)console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");Y.async=!0}const X=this.#J(!!Y.silent,!!Y.async);if(typeof Q==="undefined"||Q===null)return X(new Error("marked(): input parameter is undefined or null"));if(typeof Q!=="string")return X(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(Q)+", string expected"));if(Y.hooks)Y.hooks.options=Y;if(Y.async)return Promise.resolve(Y.hooks?Y.hooks.preprocess(Q):Q).then((K)=>$(K,Y)).then((K)=>Y.walkTokens?Promise.all(this.walkTokens(K,Y.walkTokens)).then(()=>K):K).then((K)=>J(K,Y)).then((K)=>Y.hooks?Y.hooks.postprocess(K):K).catch(X);try{if(Y.hooks)Q=Y.hooks.preprocess(Q);const K=$(Q,Y);if(Y.walkTokens)this.walkTokens(K,Y.walkTokens);let V=J(K,Y);if(Y.hooks)V=Y.hooks.postprocess(V);return V}catch(K){return X(K)}}}#J($,J){return(Q)=>{if(Q.message+="\nPlease report this to https://github.com/markedjs/marked.",$){const Z="<p>An error occurred:</p><pre>"+L(Q.message+"",!0)+"</pre>";if(J)return Promise.resolve(Z);return Z}if(J)return Promise.reject(Q);throw Q}}}var b=new K1;A.options=A.setOptions=function($){return b.setOptions($),A.defaults=b.defaults,q1(A.defaults),A};A.getDefaults=U0;A.defaults=g;A.use=function(...$){return b.use(...$),A.defaults=b.defaults,q1(A.defaults),A};A.walkTokens=function($,J){return b.walkTokens($,J)};A.parseInline=b.parseInline;A.Parser=N;A.parser=N.parse;A.Renderer=p;A.TextRenderer=r;A.Lexer=D;A.lexer=D.lex;A.Tokenizer=m;A.Hooks=x;A.parse=A;var{options:M$,setOptions:B$,use:A$,walkTokens:j$,parseInline:w$}=A;var H$=N.parse,P$=D.lex;var W1="DUMMY",$$=($)=>/^[a-zA-Z_][a-zA-Z_0-9]+$/.test($)?$:`"${$}"`,V1=($,J)=>$.filter((Q)=>Q.type==="tag"&&Q.name!==W1||Q.type==="text"&&(!J||/\S/.test(Q.data))||Q.type==="script"),O0=($,{indent:J=2,spacing:Q=!1,skipEmptyText:Z=!1,htmlTagPred:q=(Y)=>Y.toLowerCase()===Y}={})=>{const Y=(M,B)=>{const P=Q?" ":"";return Object.keys(M).length===0?"":`{${P}${Object.entries(M).flatMap(([H,w])=>H!==W1?`${$$(H)}: ${JSON.stringify(w)}`:[]).join(", ")}${P}}${B.length>0?",":""}`},X=(M,B,P,H)=>M.flatMap((w)=>{const C=!B&&M.length<=1?"":",";if(w.type==="text")return`${B}${JSON.stringify(w.data)}${C}`;H.add(w.name);const v=P&&w.name!=="pre",E=V1(w.children,v);return w.children.length>0?[`${B}${w.name}(${Y(w.attribs,E)}`,...X(E,B+" ".repeat(J),v,H),`${B})${C}`]:`${B}${w.name}(${Y(w.attribs,E)})${C}`}),K=W0($,{lowerCaseTags:!1,lowerCaseAttributeNames:!1}),V=new Set,W=X(V1(K,Z),"",Z,V),F=[],U=[];for(let M of V)(q(M)?F:U).push(M);return{code:W,tags:F.sort(),components:U.sort()}},G1=($,{indent:J=2,spacing:Q=!1,htmlTagPred:Z=(Y)=>Y.toLowerCase()===Y,renderer:q}={})=>O0(A.use({renderer:q}).parse($),{indent:J,spacing:Q,skipEmptyText:!0,htmlTagPred:Z});var{state:T,derive:k,add:J$,tags:{code:U1,div:d,h5:F0,input:z0,option:O1,pre:M0,select:Q$,span:Z$,textarea:q$}}=van,Y$=($)=>{$.style.height="5px",$.style.height=$.scrollHeight+5+"px"},X$=()=>{const $=T("HTML"),J=k(()=>$.val==="HTML"),Q=T('<div><p>\uD83D\uDC4BHello</p><ul><li>\uD83D\uDDFA\uFE0FWorld</li><li><a href="https://vanjs.org/">\uD83C\uDF66VanJS</a></li></ul></div>'),Z=T(`\uD83D\uDC4BHello
* \uD83D\uDDFA\uFE0FWorld
* [\uD83C\uDF66VanJS](https://vanjs.org/)
`),q=k(()=>(J.val?Q:Z).val),Y=q$({style:"width: 100%;",oninput:(B)=>(J.val?Q:Z).val=B.target.value,value:q});k(()=>(q.val,setTimeout(Y$.bind(null,Y),5)));const X=JSON.parse(localStorage.getItem("ui-states")??"{}"),K=T(X.indent??2),V=T(X.spacing??!1),W=T(X.skipEmpty??!1),F=T("");k(()=>localStorage.setItem("ui-states",JSON.stringify({indent:K.val,spacing:V.val,skipEmpty:W.val})));const U=k(()=>{F.val="";try{return J.val?O0(Q.val,{indent:K.val,spacing:V.val,skipEmptyText:W.val}):G1(Z.val,{indent:K.val,spacing:V.val})}catch(B){F.val=B.toString()}}),M=()=>J.val?"":"display: none";return d(F0("Paste your ",Q$({value:$,oninput:(B)=>$.val=B.target.value},O1("HTML"),O1("MD"))," snippet here:"),d(Y),d("Indent level: ",z0({type:"number",min:1,max:8,value:K,oninput:(B)=>K.val=B.target.value})," ",z0({type:"checkbox",checked:V,oninput:(B)=>V.val=B.target.checked}),"Spacing ",Z$({style:M},z0({type:"checkbox",checked:W,oninput:(B)=>W.val=B.target.checked}),"Skip empty text ")),M0({class:"err"},F),(B)=>{if(!U.val)return d();if(!B?.hasChildNodes())B=d(F0("Importing:"),M0(U1({class:"language-js"})),F0("Building the DOM tree:"),M0(U1({class:"language-js"})));const{code:P,tags:H}=U.val,w=V.val?" ":"",[C,v]=B.querySelectorAll("pre code[class='language-js']");return C.textContent=H.length?`const {${w}${H.join(", ")}${w}} = van.tags
`:"",v.textContent=P.map((E)=>E+"\n").join(""),setTimeout(()=>Prism.highlightAll(),5),B})};J$(document.getElementById("converter"),X$());