UNPKG

vue-renderer-markdown

Version:

Vue 3 Markdown renderer optimized for large docs: progressive Mermaid, streaming diff code blocks, and fast real-time preview.

1 lines 212 kB
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,i=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&i(e,n,t[n]);if(o)for(var n of o(t))r.call(t,n)&&i(e,n,t[n]);return e},s=(e,o)=>t(e,n(o)),c=(e,t)=>{var n={};for(var i in e)l.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&o)for(var i of o(e))t.indexOf(i)<0&&r.call(e,i)&&(n[i]=e[i]);return n},u=(e,t,n)=>new Promise((o,l)=>{var r=e=>{try{a(n.next(e))}catch(t){l(t)}},i=e=>{try{a(n.throw(e))}catch(t){l(t)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);a((n=n.apply(e,t)).next())});import{full as d}from"markdown-it-emoji";import h from"markdown-it-footnote";import p from"markdown-it-ins";import m from"markdown-it-mark";import f from"markdown-it-sub";import g from"markdown-it-sup";import*as v from"markdown-it-task-checkbox";import w from"markdown-it-ts";import y from"markdown-it-container";import{defineComponent as k,createElementBlock as x,openBlock as b,createVNode as _,unref as M,createElementVNode as $,Fragment as S,renderList as C,toDisplayString as B,computed as T,ref as L,watch as E,nextTick as j,onBeforeUnmount as I,createBlock as A,Teleport as H,Transition as O,withCtx as R,withDirectives as N,normalizeClass as z,normalizeStyle as P,vShow as W,createApp as D,h as F,defineAsyncComponent as V,resolveDynamicComponent as K,useAttrs as Y,mergeProps as q,createCommentVNode as X,renderSlot as Z,onMounted as U,onUnmounted as G,withModifiers as J,createTextVNode as Q,provide as ee,inject as te}from"vue";let ne;function oe(e){ne=e}function le(e){["admonition","info","warning","error","tip","danger","note","caution"].forEach(t=>{e.use(y,t,{render:(e,n)=>1===e[n].nesting?`<div class="vmr-container vmr-container-${t}">`:"</div>\n"})}),e.block.ruler.before("fence","vmr_container_fallback",(e,t,n,o)=>{const l=e,r=l.bMarks[t]+l.tShift[t],i=l.eMarks[t],a=l.src.slice(r,i).match(/^:::\s*(\w+)/);if(!a)return!1;if(o)return!0;const s=a[1];let c=t+1,u=!1;for(;c<=n;){const e=l.bMarks[c]+l.tShift[c],t=l.eMarks[c];if(":::"===l.src.slice(e,t).trim()){u=!0;break}c++}if(!u)return!1;l.push("vmr_container_open","div",1).attrSet("class",`vmr-container vmr-container-${s}`);const d=[];for(let p=t+1;p<c;p++){const e=l.bMarks[p]+l.tShift[p],t=l.eMarks[p];d.push(l.src.slice(e,t))}l.push("paragraph_open","p",1);const h=l.push("inline","",0);return h.content=d.join("\n"),h.map=[t+1,c],h.children=[],l.md.inline.parse(h.content,l.md,l.env,h.children),l.push("paragraph_close","p",-1),l.push("vmr_container_close","div",-1),l.line=c+1,!0})}function re(e){var t,n,o;const l=e;if(e=function(e){var t,n,o,l,r,i,a,s,c;const u=e,d=[...e];for(let h=e.length-1;h>=3;h--){const p=e[h];if(p&&"link_close"===p.type&&(null==(n=null==(t=e[h-3])?void 0:t.content)?void 0:n.endsWith("("))){const t=e[h+1];if(t&&"text"===(null==t?void 0:t.type)){if("text"===e[h-1].type&&"text"===(null==(o=e[h-3])?void 0:o.type)){const e=String(null!=(l=t.content)?l:""),n=u[h-3],o=u[h-1],a=String(null!=(r=n.content)?r:"")+String(null!=(i=o.content)?i:"")+e;d.splice(h-3,5,{type:"text",content:a,raw:a}),h-=3}}else{if("text"===e[h-1].type&&"text"===(null==(a=e[h-3])?void 0:a.type)){const e=u[h-3],t=u[h-1],n=String(null!=(s=e.content)?s:"")+String(null!=(c=t.content)?c:"");d.splice(h-3,4,{type:"text",content:n,raw:n})}h-=3}}}return d}(function(e){var t,n,o,l,r,i;const c=e,u=e[e.length-1],d=e[e.length-2],h=[...e];if(!u)return e;if("text"!==u.type||!(null==(t=u.content)?void 0:t.startsWith(")")))return e;if("link_close"!==d.type)return e;if((p=e[e.length-5])&&"text"===p.type&&"string"==typeof p.content&&String(null!=(n=e[e.length-5].content)?n:"").endsWith("(")){const t=c[e.length-5],n=c[e.length-3],i=String(null!=(o=t.content)?o:"")+String(null!=(l=n.content)?l:"")+String(null!=(r=u.content)?r:"");h.splice(e.length-5,5,{type:"text",content:i,raw:i})}else{const e=(null!=(i=u.content)?i:"").slice(1);h[h.length-1]=s(a({},u),{content:e})}var p;return h}(e)),e.length<5)return e;const r=e[e.length-5],i=String(null!=(t=r.content)?t:"");if("text"!==r.type||!i.endsWith("["))return ie(e);if("em"!==e[e.length-4].tag)return ie(e);const c=e[e.length-1],u=String(null!=(n=c.content)?n:"");if("text"===(null==c?void 0:c.type)&&!u.startsWith("]"))return ie(e);const d=e[e.length-3],h=String(null!=(o=d.content)?o:""),p=u.replace(/^\]\(*/,""),m=!u.includes(")");return l[e.length-5].content=i.replace(/\[$/,""),e.splice(e.length-3,1,{type:"link",href:p,text:h,children:[{type:"text",content:h,raw:h}],loading:m}),e.splice(e.length-1,1),e}function ie(e){var t,n,o,l,r;const i=e;if(e.length<8)return e;let a=e.length,s=e[a-1];if(!s)return e;if("link_close"!==s.type&&(a--,s=e[a-1],"link_close"!==s.type))return e;if("em_open"!==e[a-7].type)return e;const c=e[a-6],u=e[a-8];if("text"!==u.type)return e;let d=String(null!=(n=null==(t=i[a-2])?void 0:t.content)?n:""),h=4;a!==e.length&&(d+=String(null!=(o=s.content)?o:""),h++),e.splice(a-4,h);const p=String(null!=(l=c.content)?l:"");a-=4;const m=u;return i[a-8].content=String(null!=(r=m.content)?r:"").replace(/\[$/,""),e.splice(a-2,1,{type:"link",href:d,text:p,children:[{type:"text",content:p,raw:p}],loading:!0}),e}function ae(e){var t,n;const o=e[e.length-1],l=String(null!=(t=null==o?void 0:o.content)?t:"");return"text"===(null==o?void 0:o.type)&&/^\s*\d+\.\s*$/.test(l)&&"br"===(null==(n=e[e.length-2])?void 0:n.tag)&&e.splice(e.length-1,1),e}function se(e){var t,n;const o=[...e];if(e.length<4)return o;const l=e.length-4,r=e[l],i=e[l+1],a=String(null!=(t=r.content)?t:"");if("text"===r.type&&a.endsWith("*")&&"em_open"===i.type){const t=e[l+2],r="text"===(null==t?void 0:t.type)?4:3,i=[{type:"strong_open",tag:"strong",attrs:null,map:null,children:null,content:"",markup:"**",info:"",meta:null},{type:"text",content:"text"===(null==t?void 0:t.type)?String(null!=(n=t.content)?n:""):""},{type:"strong_close",tag:"strong",attrs:null,map:null,children:null,content:"",markup:"**",info:"",meta:null}],s=a.slice(0,-1);return s&&i.unshift({type:"text",content:s,raw:s}),o.splice(l,r,...i),o}return o}function ce(e){return[{type:"th_open",tag:"th",attrs:null,block:!0,level:3,children:null},{type:"inline",tag:"",children:[{tag:"",type:"text",block:!1,content:e,children:null}],content:e,level:4,attrs:null,block:!0},{type:"th_close",tag:"th",attrs:null,block:!0,level:3,children:null}]}function ue(e,t,n,o){const l=e.length;if("$$"===n&&"$$"===o){let n=t;for(;n<l-1;){if("$"===e[n]&&"$"===e[n+1]){let t=n-1,o=0;for(;t>=0&&"\\"===e[t];)o++,t--;if(o%2==0)return n}n++}return-1}const r=n[n.length-1],i=o;let a=0,s=t;for(;s<l;){if(e.slice(s,s+i.length)===i){let t=s-1,n=0;for(;t>=0&&"\\"===e[t];)n++,t--;if(n%2==0){if(0===a)return s;a--,s+=i.length;continue}}const t=e[s];"\\"!==t?(t===r?a++:t===i[i.length-1]&&a>0&&a--,s++):s+=2}return-1}var de=ue;const he=["mathbf","boldsymbol","mathbb","mathcal","mathfrak","mathrm","mathit","mathsf","vec","hat","bar","tilde","overline","underline","mathscr","mathnormal","operatorname","mathbf*"],pe=he.map(e=>e.replace(/[.*+?^${}()|[\\]"\]/g,"\\$&")).join("|"),me=/\\[a-z]+/i,fe="(?:\\\\|\\u0008)",ge=new RegExp(`${fe}(?:${pe})\\s*\\{[^}]+\\}`,"i"),ve=new RegExp(`(?:${fe})?(?:${pe})s*{`,"i"),we=/\\(?:text|frac|left|right|times)/,ye=/* @__PURE__ */new RegExp("(?<!\\+)\\+(?!\\+)|[=\\-*/^<>]|\\\\times|\\\\pm|\\\\cdot|\\\\le|\\\\ge|\\\\neq"),ke=/[A-Z]+\s*\([^)]+\)/i,xe=/\b(?:sin|cos|tan|log|ln|exp|sqrt|frac|sum|lim|int|prod)\b/,be=/\b\d{4}\/\d{1,2}\/\d{1,2}(?:[ T]\d{1,2}:\d{2}(?::\d{2})?)?\b/;function _e(e){if(!e)return!1;const t=e.replace(/\u0008/g,"\\b"),n=t.trim();if(be.test(n))return!1;if(n.includes("**"))return!1;if(n.length>2e3)return!0;if(/[./]\s*\D|\D\s*[./]/.test(e))return!1;const o=me.test(t),l=ge.test(t),r=ve.test(t),i=we.test(t),a=/(?:^|[^\w\\])(?:[A-Z]|\\[A-Z]+)_(?:\{[^}]+\}|[A-Z0-9\\])/i.test(t)||/(?:^|[^\w\\])(?:[A-Z]|\\[A-Z]+)\^(?:\{[^}]+\}|[A-Z0-9\\])/i.test(t),s=ye.test(t),c=ke.test(t),u=xe.test(t);return o||l||r||i||a||s||c||u}const Me=["ldots","cdots","quad","in","end","infty","perp","mid","operatorname","to","rightarrow","leftarrow","math","mathrm","mathbf","mathit","mathbb","mathcal","mathfrak","alpha","beta","gamma","delta","epsilon","lambda","sum","prod","int","sqrt","fbox","boxed","color","rule","edef","fcolorbox","hline","hdashline","cdot","times","pm","le","ge","neq","sin","cos","tan","log","ln","exp","lim","frac","text","left","right"],$e=Me.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\\]\\\]/g,"\\$&")).join("|"),Se="[\t\r\b\f\v]",Ce={"\t":"t","\r":"r","\b":"b","\f":"f","\v":"v"};function Be(e){const t=/(^|[^\\])(__|\*\*)/g;let n=0;for(;null!==t.exec(e);)n++;return n}function Te(e,t){var n,o;const l=null!=(n=null==t?void 0:t.commands)?n:Me,r=null==(o=null==t?void 0:t.escapeExclamation)||o,i=null==(null==t?void 0:t.commands);let a;if(i)a=new RegExp(`${Se}|(?<!\\\\|\\w)(${$e})\\b`,"g");else{const e=`(?:${l.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\\]\\"\]/g,"\\$&")).join("|")})`;a=new RegExp(`${Se}|(?<!\\\\|\\w)(${e})\\b`,"g")}let s=e.replace(a,(e,t)=>void 0!==Ce[e]?`\\${Ce[e]}`:t&&l.includes(t)?`\\${t}`:e);r&&(s=s.replace(/(^|[^\\])!/g,"$1\\!"));const c=i?[pe,$e].filter(Boolean).join("|"):[l.map(e=>e.replace(/[.*+?^${}()|[\\]\\\]/g,"\\$&")).join("|"),pe].filter(Boolean).join("|");let u=s;if(c){const e=new RegExp(`(^|[^\\\\\\w])(${c})\\s*\\{`,"g");u=u.replace(e,(e,t,n)=>`${t}\\${n}{`)}return u=u.replace(/span\{([^}]+)\}/,"span\\{$1\\}").replace(/\\operatorname\{span\}\{((?:[^{}]|\{[^}]*\})+)\}/,"\\operatorname{span}\\{$1\\}"),u=u.replace(/(^|[^\\])\\\r?\n/g,"$1\\\\\n"),u=u.replace(/(^|[^\\])\\$/g,"$1\\\\"),u}function Le(e,t){e.inline.ruler.before("escape","math",(e,n)=>{const o=e;if(/^\*[^*]+/.test(o.src))return!1;const l=[["$$","$$"],["\\(","\\)"],["(",")"]];let r=0,i=0;for(const[a,s]of l){const e=o.src;let l=!1;const c=e=>{if("undefined"!==e&&null!=e||(e=""),"\\"===e)return o.pos=o.pos+e.length,void(r=o.pos);if("\\)"===e||"\\("===e){const t=o.push("text_special","",0);return t.content="\\)"===e?")":"(",t.markup=e,o.pos=o.pos+e.length,void(r=o.pos)}e&&(o.push("text","",0).content=e,o.pos=o.pos+e.length,r=o.pos)};for(;!(r>=e.length);){const u=e.indexOf(a,r);if(-1===u)break;if(u>0){let t=u-1;for(;t>=0&&" "===e[t];)t--;if(t>=0&&"]"===e[t])return!1}const d=de(e,u+a.length,a,s);if(-1===d){const h=e.slice(u+a.length);if(h.includes(a)){r=e.indexOf(a,u+a.length);continue}if(-1===d){if(_e(h)){if(r=u+a.length,l=!0,!n){o.pending="";const n=Be(i?e.slice(i,r):e.slice(0,r))%2==1;if(i)c(e.slice(i,r));else{let t=e.slice(0,r);t.endsWith(a)&&(t=t.slice(0,t.length-a.length)),c(t)}if(n){const n=o.push("strong_open","",0);n.markup=e.slice(0,u+2);const l=o.push("math_inline","math",0);l.content=Te(h,t),l.markup="$$"===a?"$$":"\\("===a?"\\(\\)":"$"===a?"$":"()",l.raw=`${a}${h}${s}`,l.loading=!0,n.content=h,o.push("strong_close","",0)}else{const e=o.push("math_inline","math",0);e.content=Te(h,t),e.markup="$$"===a?"$$":"\\("===a?"\\(\\)":"$"===a?"$":"()",e.raw=`${a}${h}${s}`,e.loading=!0}o.pos=e.length}r=e.length,i=r}break}}const h=e.slice(u+a.length,d);if(!_e(h)){r=d+s.length;const t=e.slice(o.pos,r);o.pending||c(t);continue}if(l=!0,!n){const n=e.slice(0,u);let l=e.slice(0,r)?e.slice(i,u):n;const p=Be(l)%2==1;if(u!==o.pos&&p&&(l=o.pending+e.slice(o.pos,u)),o.pending!==l)if(o.pending="",p){const e=l.match(/(\*+)/),t=l.slice(e.index+e[0].length);c(l.slice(0,e.index)),o.push("strong_open","",0).markup=e[0],o.push("text","",0).content=t,o.push("strong_close","",0)}else c(l);if(p){o.push("strong_open","",0).markup="**";const n=o.push("math_inline","math",0);n.content=Te(h,t),n.markup="$$"===a?"$$":"\\("===a?"\\(\\)":"$"===a?"$":"()",n.raw=`${a}${h}${s}`,n.loading=!1;const l=e.slice(d+s.length),c=l.startsWith("*");c&&o.push("strong_close","",0),l&&(o.push("text","",0).content=(null==l?"":String(l)).replace(/^\*+/,"")),c||o.push("strong_close","",0),o.pos=e.length,r=e.length,i=r;continue}{const e=o.push("math_inline","math",0);e.content=Te(h,t),e.markup="$$"===a?"$$":"\\("===a?"\\(\\)":"$"===a?"$":"()",e.raw=`${a}${h}${s}`,e.loading=!1}}r=d+s.length,i=r,o.pos=r}if(l)return n?o.pos=r:(r<e.length&&c(e.slice(r)),o.pos=e.length),!0}return!1}),e.block.ruler.before("paragraph","math_block",(e,t,n,o)=>{const l=e,r=[["\\[","\\]"],["[","]"],["$$","$$"]],i=l.bMarks[t]+l.tShift[t],a=l.src.slice(i,l.eMarks[t]).trim();let s=!1,c="",u="";for(const[g,v]of r)if(a===g||a.startsWith(g)){if(!g.includes("[")){s=!0,c=g,u=v;break}if("["===a.replace("\\","")){if(t+1<n){s=!0,c=g,u=v;break}continue}}if(!s)return!1;if(o)return!0;if(a.includes(u)&&a.indexOf(u)>c.length){const e=a.indexOf(c),n=a.indexOf(u,e+c.length),o=a.slice(e+c.length,n),r=l.push("math_block","math",0);return r.content=Te(o),r.markup="$$"===c?"$$":"["===c?"[]":"\\[\\]",r.map=[t,t+1],r.raw=`${c}${o}${u}`,r.block=!0,r.loading=!1,l.line=t+1,!0}let d=t,h="",p=!1;const m=a===c?"":a.slice(c.length);if(m.includes(u)){const e=m.indexOf(u);h=m.slice(0,e),p=!0,d=t}else for(m&&(h=m),d=t+1;d<n;d++){const e=l.bMarks[d]+l.tShift[d],t=l.eMarks[d],n=l.src.slice(e-1,t);if(n.trim()===u){p=!0;break}if(n.includes(u)){p=!0;const e=n.indexOf(u);h+=(h?"\n":"")+n.slice(0,e);break}h+=(h?"\n":"")+n}const f=l.push("math_block","math",0);return f.content=Te(h),f.markup="$$"===c?"$$":"["===c?"[]":"\\[\\]",f.raw=`${c}${h}${h.startsWith("\n")?"\n":""}${u}`,f.map=[t,d+1],f.block=!0,f.loading=!p,l.line=d+1,!0},{alt:["paragraph","reference","blockquote","list"]})}function Ee(e={}){var t,n,o,l,r;const i=new w(a({html:!0,linkify:!0,typographer:!0,stream:!0},null!=(t=e.markdownItOptions)?t:{}));return(null==(n=e.enableMath)||n)&&Le(i,a(a({},null!=(o=ne)?o:{}),null!=(l=e.mathOptions)?l:{})),(null==(r=e.enableContainers)||r)&&le(i),function(e){e.inline.ruler.before("link","fix_link_inline",(e,t)=>{var n,o;const l=e,r=l.pos;if("["!==l.src[r])return!1;if(r>0&&"!"===l.src[r-1])return!1;const i=l.src.slice(r),a=/^\[([^\]]*)\]\(([^)\s]*)?/.exec(i);if(!a)return!1;if(t)return!0;const s=null!=(n=a[1])?n:"",c=null!=(o=a[2])?o:"";if(s.includes("*")||s.includes(":"))return!1;const u=i.indexOf(")"),d=-1!==u;return l.push("link_open","a",1).attrs=[["href",c]],l.push("text","",0).content=s,d?(l.push("link_close","a",-1),l.pos+=u+1):l.pos+=a[0].length,!0})}(i),function(e){e.core.ruler.after("inline","fix_link_tokens",e=>{var t;const n=null!=(t=e.tokens)?t:[];for(let l=0;l<n.length;l++){const e=n[l];if(e&&"inline"===e.type&&Array.isArray(e.children))try{e.children=re(e.children)}catch(o){console.error("[applyFixLinkTokens] failed to fix inline children",o)}}})}(i),function(e){e.core.ruler.after("inline","fix_strong_tokens",e=>{var t;const n=null!=(t=e.tokens)?t:[];for(let l=0;l<n.length;l++){const e=n[l];if(e&&"inline"===e.type&&Array.isArray(e.children))try{e.children=se(e.children)}catch(o){console.error("[applyFixStrongTokens] failed to fix inline children",o)}}})}(i),function(e){e.core.ruler.after("inline","fix_list_item_tokens",e=>{var t;const n=null!=(t=e.tokens)?t:[];for(let l=0;l<n.length;l++){const e=n[l];if(e&&"inline"===e.type&&Array.isArray(e.children))try{e.children=ae(e.children)}catch(o){console.error("[applyFixListItem] failed to fix inline children",o)}}})}(i),function(e){e.core.ruler.after("block","fix_table_tokens",e=>{var t;const n=e;try{const e=function(e){var t,n,o,l;const r=[...e];if(e.length<3)return r;const i=e.length-2,a=e[i];if("inline"===a.type){const e=String(null!=(t=a.content)?t:""),s=String(null!=(l=null==(o=null==(n=a.children)?void 0:n[0])?void 0:o.content)?l:"");if(/^\|(?:[^|\n]+\|?)+/.test(e)){const e=[{type:"table_open",tag:"table",attrs:null,map:null,children:null,content:"",markup:"",info:"",level:0,loading:!0,meta:null},{type:"thead_open",tag:"thead",attrs:null,block:!0,level:1,children:null},{type:"tr_open",tag:"tr",attrs:null,block:!0,level:2,children:null},...s.slice(1).split("|").map(e=>e.trim()).filter(Boolean).flatMap(e=>ce(e)),{type:"tr_close",tag:"tr",attrs:null,block:!0,level:2,children:null},{type:"thead_close",tag:"thead",attrs:null,block:!0,level:1,children:null},{type:"table_close",tag:"table",attrs:null,map:null,children:null,content:"",markup:"",info:"",level:0,meta:null}];r.splice(i-1,3,...e)}else if(/^\|(?:[^|\n]+\|)+\n\|:?-/.test(e)){const e=[{type:"table_open",tag:"table",attrs:null,map:null,children:null,content:"",markup:"",info:"",level:0,loading:!0,meta:null},{type:"thead_open",tag:"thead",attrs:null,block:!0,level:1,children:null},{type:"tr_open",tag:"tr",attrs:null,block:!0,level:2,children:null},...s.slice(1,-1).split("|").map(e=>e.trim()).flatMap(e=>ce(e)),{type:"tr_close",tag:"tr",attrs:null,block:!0,level:2,children:null},{type:"thead_close",tag:"thead",attrs:null,block:!0,level:1,children:null},{type:"table_close",tag:"table",attrs:null,map:null,children:null,content:"",markup:"",info:"",level:0,meta:null}];r.splice(i-1,3,...e)}else/^\|(?:[^|\n:]+\|)+\n\|:?$/.test(e)&&(a.content=e.slice(0,-2),a.children.splice(2,1))}return r}(null!=(t=n.tokens)?t:[]);Array.isArray(e)&&(n.tokens=e)}catch(o){console.error("[applyFixTableTokens] failed to fix table tokens",o)}})}(i),function(e){const t=e.renderer.rules.image||function(e,t,n,o,l){const r=e,i=l;return i.renderToken?i.renderToken(r,t,n):""};e.renderer.rules.image=(e,n,o,l,r)=>{var i,a;const s=e;return null==(a=(i=s[n]).attrSet)||a.call(i,"loading","lazy"),t(s,n,o,l,r)},e.renderer.rules.fence=e.renderer.rules.fence||((t,n)=>{var o,l;const r=t[n],i=String(null!=(o=r.info)?o:"").trim();return`<pre class="${i?`language-${e.utils.escapeHtml(i.split(/\s+/g)[0])}`:""}"><code>${e.utils.escapeHtml(String(null!=(l=r.content)?l:""))}</code></pre>`})}(i),function(e){e.core.ruler.push("fix_html_inline_tokens",e=>{var t,n,o,l,r,i,a,s;const c=null!=(t=e.tokens)?t:[],u=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);for(let d=0;d<c.length;d++){const e=c[d];if(!e||"inline"!==e.type)continue;if(/\s*<$/.test(e.content)){e.children.length=0;continue}if(2===e.children.length&&"html_inline"===e.children[0].type){e.children=[{type:"html_block",content:e.children[0].content+e.children[1].content,tag:null!=(o=null==(n=e.children[0].content.match(/<([^\s>/]+)/))?void 0:n[1])?o:"",loading:!0}];continue}if(!(null==(l=e.content)?void 0:l.startsWith("<"))||1!==(null==(r=e.children)?void 0:r.length))continue;const t=String(e.content),h=null!=(s=null==(a=null==(i=t.match(/<([^\s>/]+)/))?void 0:i[1])?void 0:a.toLowerCase())?s:"";if(!h)continue;const p=e;/\/\s*>\s*$/.test(t)||u.has(h)?p.children=[{type:"html_inline",content:t}]:p.children.length=0}})}(i),i}function je(e,t){var n;const o=[];let l="",r=t+1;const i=[];for(;r<e.length&&"em_close"!==e[r].type;)l+=String(null!=(n=e[r].content)?n:""),i.push(e[r]),r++;return o.push(...ze(i)),{node:{type:"emphasis",children:o,raw:`*${l}*`},nextIndex:r<e.length?r+1:e.length}}function Ie(e){var t,n,o,l;const r=Array.isArray(e.map)&&2===e.map.length,i=null!=(t=e.meta)?t:{},a="boolean"==typeof i.closed?i.closed:void 0,s=String(null!=(n=e.info)?n:""),c=s.startsWith("diff"),u=c?String(null!=(o=s.split(" ")[1])?o:""):s;let d=String(null!=(l=e.content)?l:"");const h=/\r?\n[ \t]*`+\s*$/;if(h.test(d)&&(d=d.replace(h,"")),c){const{original:e,updated:t}=function(e){const t=[],n=[];for(const o of e.split(/\r?\n/)){const e=o;/^(?:diff |index |--- |\+\+\+ |@@ )/.test(e)||(e.startsWith("- ")?t.push(` ${e.slice(1)}`):e.startsWith("+ ")?n.push(` ${e.slice(1)}`):(t.push(e),n.push(e)))}return{original:t.join("\n"),updated:n.join("\n")}}(d);return{type:"code_block",language:u,code:String(null!=t?t:""),raw:String(null!=d?d:""),diff:c,loading:!0!==a&&(!1===a||!r),originalCode:e,updatedCode:t}}return{type:"code_block",language:u,code:String(null!=d?d:""),raw:String(null!=d?d:""),diff:c,loading:!0!==a&&(!1===a||!r)}}function Ae(e,t=!1){var n,o,l,r,i,a,s,c,u;let d=null!=(n=e.attrs)?n:[],h=null;if((!d||0===d.length)&&Array.isArray(e.children))for(const v of e.children){const e=null==v?void 0:v.attrs;if(Array.isArray(e)&&e.length>0){d=e,h=v;break}}const p=String(null!=(l=null==(o=d.find(e=>"src"===e[0]))?void 0:o[1])?l:""),m=null==(r=d.find(e=>"alt"===e[0]))?void 0:r[1];let f="";null!=m&&String(m).length>0?f=String(m):null!=(null==h?void 0:h.content)&&String(h.content).length>0?f=String(h.content):Array.isArray(null==h?void 0:h.children)&&(null==(i=h.children[0])?void 0:i.content)?f=String(h.children[0].content):Array.isArray(e.children)&&(null==(a=e.children[0])?void 0:a.content)?f=String(e.children[0].content):null!=e.content&&String(e.content).length>0&&(f=String(e.content));const g=null!=(c=null==(s=d.find(e=>"title"===e[0]))?void 0:s[1])?c:null;return{type:"image",src:p,alt:f,title:null===g?null:String(g),raw:String(null!=(u=e.content)?u:""),loading:t}}function He(e,t){var n;const o=[];let l="",r=t+1;const i=[];for(;r<e.length&&"s_close"!==e[r].type;)l+=String(null!=(n=e[r].content)?n:""),i.push(e[r]),r++;return o.push(...ze(i)),{node:{type:"strikethrough",children:o,raw:`~~${l}~~`},nextIndex:r<e.length?r+1:e.length}}function Oe(e,t,n){var o;const l=[];let r="",i=t+1;const a=[];for(;i<e.length&&"strong_close"!==e[i].type;)r+=String(null!=(o=e[i].content)?o:""),a.push(e[i]),i++;return l.push(...ze(a,n)),{node:{type:"strong",children:l,raw:`**${String(r)}**`},nextIndex:i<e.length?i+1:e.length}}const Re=/^(?:https?:\/\/|mailto:|ftp:\/\/)/i,Ne=/:\/\//;function ze(e,t,n){if(!e||0===e.length)return[];const o=[];let l=null,r=0;function i(){l=null}function c(e,n){var a,s;if(/[^~]*~{2,}[^~]+/.test(e)){let t=e.indexOf("~~");-1===t&&(t=0);const s=e.slice(0,t);s&&(l?(l.content+=s,l.raw+=s):(l={type:"text",content:String(null!=s?s:""),raw:String(null!=(a=n.content)?a:"")},o.push(l)));const{node:c}=He([{type:"s_open",tag:"s",content:"",markup:"*",info:"",meta:null},{type:"text",tag:"",content:e.slice(t).replace(/~/g,""),markup:"",info:"",meta:null},{type:"s_close",tag:"s",content:"",markup:"*",info:"",meta:null}],0);return i(),d(c),r++,!0}if(/\*\*/.test(e)){const n=e.indexOf("**"),o=n>-1?e.slice(0,n):"";if(o&&h(o,o),-1===n)return r++,!0;const l=/\*\*([\s\S]*?)\*\*/.exec(e);let a="",s="";l&&"number"==typeof l.index?(a=l[1],s=e.slice(l.index+l[0].length)):(a=e.slice(n+2),s="");const{node:c}=Oe([{type:"strong_open",tag:"strong",content:"",markup:"*",info:"",meta:null},{type:"text",tag:"",content:a,markup:"",info:"",meta:null},{type:"strong_close",tag:"strong",content:"",markup:"*",info:"",meta:null}],0,t);return i(),d(c),s&&(p({type:"text",content:s,raw:s}),r--),r++,!0}if(/[^*]*\*[^*]+/.test(e)){let t=e.indexOf("*");-1===t&&(t=0);const a=e.slice(0,t);a&&(l?(l.content+=a,l.raw+=a):(l={type:"text",content:String(null!=a?a:""),raw:String(null!=(s=n.content)?s:"")},o.push(l)));const{node:c}=je([{type:"em_open",tag:"em",content:"",markup:"*",info:"",meta:null},{type:"text",tag:"",content:e.slice(t).replace(/\*/g,""),markup:"",info:"",meta:null},{type:"em_close",tag:"em",content:"",markup:"*",info:"",meta:null}],0);return i(),d(c),r++,!0}return!1}function u(e){i(),o.push(e)}function d(e){u(e)}function h(e,t){var n;l?(l.content+=e,l.raw+=null!=t?t:e):(l={type:"text",content:String(null!=e?e:""),raw:String(null!=(n=null!=t?t:e)?n:"")},o.push(l))}for(;r<e.length;)p(e[r]);function p(m){var f,g,v,w,y,k,x;switch(m.type){case"text":!function(d){var m,f,g;let v=o.length-1,w=String(null!=(m=d.content)?m:"").replace(/\\/g,"");for(w.startsWith(")")&&"link"===(null==(f=o[o.length-1])?void 0:f.type)&&(w=w.slice(1)),w.endsWith("undefined")&&!(null==t?void 0:t.endsWith("undefined"))&&(w=w.slice(0,-9));v>=0;v--){const e=o[v];if("text"!==e.type)break;l=null,w=e.content+w}v<o.length-1&&o.splice(v+1);const y=e[r+1];if("list_item_open"===(null==n?void 0:n.type)&&/^\d$/.test(w))return void r++;if("`"===w||"|"===w||"$"===w||/^\*+$/.test(w))return void r++;if(!y&&/[^\]]\s*\(\s*$/.test(w)&&(w=w.replace(/\(\s*$/,"")),function(e){if(!(null==e?void 0:e.startsWith("["))||"list_item_open"!==(null==n?void 0:n.type))return!1;const t=e.slice(1).match(/[^\s\]]/);if(null===t)return r++,!0;if(t&&/x/i.test(t[0])){const e="x"===t[0]||"X"===t[0];return u({type:"checkbox_input",checked:e,raw:e?"[x]":"[ ]"}),r++,!0}return!1}(w))return;if("["===w)return void r++;if(function(t,n){var o,l;if(!/`[^`]*/.test(t))return!1;i();const a=t.indexOf("`"),s=t.indexOf("`",a+1),d=t.slice(0,a),m=-1===s?t.slice(a):t.slice(a,s),f=-1===s?"":t.slice(s+1);d&&(c(d,n)?r--:h(d,d));const g=m.replace(/`/g,"");if(u({type:"inline_code",code:g,raw:String(null!=g?g:"")}),f)p({type:"text",content:f,raw:String(null!=f?f:"")}),r--;else if(-1===s&&e[r+1]){let t=f;for(let n=r+1;n<e.length;n++)t+=String((null!=(o=e[n].content)?o:"")+(null!=(l=e[n].markup)?l:""));r=e.length-1,p({type:"text",content:t,raw:String(null!=t?t:"")})}return r++,!0}(w,d))return;if(c(w,d))return;if(function(e,t){const n=e.indexOf("![");if(-1===n)return!1;const i=e.slice(0,n);return l?l.content+=i:l={type:"text",content:i,raw:i},o.push(l),l=null,u(Ae(t,!0)),r++,!0}(w,d))return;const k=function(e){var t;const n=String(null!=(t=e.content)?t:"");return{type:"text",content:n,raw:n}}(s(a({},d),{content:w}));if(function(t){var n;const o=t.indexOf("[");if(-1===o)return!1;let l=t.slice(0,o);const i=t.indexOf("](",o);if(-1!==i){const a=e[r+2];let s=t.slice(o+1,i);if(s.includes("[")){const e=s.indexOf("[");l+=t.slice(0,o+e+1);const n=o+e+1;s=t.slice(n+1,i)}const c=e[r+1];if(t.endsWith("](")&&"link_open"===(null==c?void 0:c.type)&&a){const t=e[r+4];let o=4,i=!0;return"text"===(null==t?void 0:t.type)&&")"===t.content?(o++,i=!1):"text"===(null==t?void 0:t.type)&&"."===t.content&&r++,l&&h(l,l),u({type:"link",href:String(null!=(n=a.content)?n:""),title:null,text:s,children:[{type:"text",content:s,raw:s}],loading:i}),r+=o,!0}const d=t.indexOf(")",i),m=-1!==d?t.slice(i+2,d):"",f=-1===d;l&&h(l,l),u({type:"link",href:m,title:null,text:s,children:[{type:"text",content:s,raw:s}],loading:f});const g=-1!==d?t.slice(d+1):"";return g&&(p({type:"text",content:g,raw:g}),r--),r++,!0}return!1}(w))return;const x=e[r-1];if(l)l.content+=k.content.replace(/(\*+|\(|\\)$/,""),l.raw+=k.raw;else{const t="br"===(null==x?void 0:x.tag)&&"["===(null==(g=e[r-2])?void 0:g.content);e[r+1]||(k.content=k.content.replace(/(\*+|\(|\\)$/,"")),l=k,l.center=t,o.push(l)}r++}(m);break;case"softbreak":l&&(l.content+="\n",l.raw+="\n"),r++;break;case"code_inline":d(function(e){var t;const n=String(null!=(t=e.content)?t:"");return{type:"inline_code",code:n,raw:n}}(m)),r++;break;case"html_inline":{const[t,n]=function(e,t,n){var o,l,r;let i=String(null!=(o=e.content)?o:"").trim();const a=t[n+1],s=t[n+2],c=i.match(/^<\s*([\w-]+)/),u=c?c[1].toLowerCase():"";if("a"===u){let e=!1;if(a&&("text"!==(null==a?void 0:a.type)||s&&"html_inline"===s.type)&&a||(e=!0),"text"===(null==a?void 0:a.type)&&("html_inline"===(null==s?void 0:s.type)||!s)){const t=i.match(/href\s*=\s*"([^"]+)"|href\s*=\s*'([^']+)'|href\s*=\s*([^\s>]+)/i),o=t?t[1]||t[2]||t[3]:"";let c=n+1;"text"===a.type&&(i=null!=(r=null==(l=a.content)?void 0:l.replace(/<[^>]*$/,""))?r:"",c=n+2),"html_inline"===(null==s?void 0:s.type)&&"text"===a.type&&(c=n+3);const u=i||o||"";return[{type:"link",href:String(null!=o?o:""),title:null,text:i,children:[{type:"text",content:u,raw:u}],loading:e,raw:i},c]}}if("p"===u||"div"===u){const e=function(e){const t=e.match(/>([\s\S]*?)<\s*\/\s*[\w-]+>/);return t?t[1]:""}(i)||"";return[{type:"paragraph",children:[{type:"text",content:e,raw:e}],raw:i},n+1]}return[{type:"inline_code",code:i,raw:i},n+1]}(m,e,r);d(t),r=n;break}case"link_open":!function(n){var l,a,s,c,d,p,m,f,g,v,w,y,k,x;i();const b=null==(a=null==(l=n.attrs)?void 0:l.find(([e])=>"href"===e))?void 0:a[1];function _(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}if(t&&"text"===e[r+1].type){const o=String(null!=(c=null==(s=e[r+1])?void 0:s.content)?c:""),l=_(o);if(!/* @__PURE__ */new RegExp(`\\[${l}\\s*\\]`).test(t)){const e=null!=(m=null==(p=null==(d=n.attrs)?void 0:d.find(([e])=>"href"===e))?void 0:p[1])?m:"";return!t.includes("[")&&function(e){return!!e&&(Re.test(e)||Ne.test(e))}(String(e))?(i(),u({type:"link",href:String(e),title:null,text:o,children:[{type:"text",content:o,raw:o}],loading:!1}),void(r+=3)):(h(o,o),void(r+=3))}}if(t&&b){const n=/* @__PURE__ */new RegExp(`\\(\\s*${_(b)}\\s*\\)`),l=o.length>0?o[o.length-1]:void 0,a=!n.test(t);if(a&&l){let n="";if(l&&("link"===l.type?n=String(null!=(f=l.text)?f:""):"text"===l.type?n=String(null!=(g=l.content)?g:""):l.content&&"string"==typeof l.content&&(n=String(null!=(v=l.content)?v:"").slice(1,-1))),/* @__PURE__ */new RegExp(`\\[${_(n)}\\s*\\]\\(`).test(t)){const t=String(null!=n?n:"");i();const l={type:"link",href:"",title:null,text:t,children:[{type:"text",content:t,raw:t}],loading:a};return o.splice(o.length-1,1,l),r+=3,void("."===String(null!=(y=null==(w=e[r])?void 0:w.content)?y:"")&&r++)}}}const{node:M,nextIndex:$}=function(e,t){var n,o,l,r,i;const a=null!=(n=e[t].attrs)?n:[],s=String(null!=(l=null==(o=a.find(e=>"href"===e[0]))?void 0:o[1])?l:""),c=null!=(i=null==(r=a.find(e=>"title"===e[0]))?void 0:r[1])?i:null,u=null===c?null:String(c);let d=t+1;const h=[];for(;d<e.length&&"link_close"!==e[d].type;)h.push(e[d]),d++;const p=ze(h),m=p.map(e=>{var t,n;const o=e;return String("content"in e?null!=(t=o.content)?t:"":null!=(n=o.raw)?n:"")}).join("");return{node:{type:"link",href:s,title:u,text:m,children:p,raw:String(`[${m}](${s}${u?` "${u}"`:""})`),loading:!0},nextIndex:d<e.length?d+1:e.length}}(e,r);r=$;const S=null==(x=null==(k=n.attrs)?void 0:k.find(([e])=>"href"===e))?void 0:x[1],C=String(null!=S?S:"");if(t&&C){const e=t.indexOf("](");if(-1===e);else{const n=t.indexOf(")",e+2);-1===n?M.loading=!0:t.slice(e+2,n).includes(C)?M.loading=!1:M.loading=!0}}u(M)}(m);break;case"image":i(),d(Ae(m)),r++;break;case"strong_open":{i();const{node:t,nextIndex:n}=Oe(e,r,m.content);d(t),r=n;break}case"em_open":{i();const{node:t,nextIndex:n}=je(e,r);d(t),r=n;break}case"s_open":{i();const{node:t,nextIndex:n}=He(e,r);d(t),r=n;break}case"mark_open":{i();const{node:t,nextIndex:n}=function(e,t){var n;const o=[];let l="",r=t+1;const i=[];for(;r<e.length&&"mark_close"!==e[r].type;)l+=String(null!=(n=e[r].content)?n:""),i.push(e[r]),r++;return o.push(...ze(i)),{node:{type:"highlight",children:o,raw:`==${l}==`},nextIndex:r<e.length?r+1:e.length}}(e,r);d(t),r=n;break}case"ins_open":{i();const{node:t,nextIndex:n}=function(e,t){var n;const o=[];let l="",r=t+1;const i=[];for(;r<e.length&&"ins_close"!==e[r].type;)l+=String(null!=(n=e[r].content)?n:""),i.push(e[r]),r++;return o.push(...ze(i)),{node:{type:"insert",children:o,raw:`++${String(l)}++`},nextIndex:r<e.length?r+1:e.length}}(e,r);d(t),r=n;break}case"sub_open":{i();const{node:t,nextIndex:n}=function(e,t){var n,o;const l=[];let r="",i=t+1;const a=[];for(;i<e.length&&"sub_close"!==e[i].type;)r+=String(null!=(n=e[i].content)?n:""),a.push(e[i]),i++;l.push(...ze(a));const s=String(null!=(o=e[t].content)?o:""),c=r||s;return{node:{type:"subscript",children:l.length>0?l:[{type:"text",content:c,raw:c}],raw:`~${c}~`},nextIndex:i<e.length?i+1:e.length}}(e,r);d(t),r=n;break}case"sup_open":{i();const{node:t,nextIndex:n}=function(e,t){var n,o,l,r;const i=[];let a="",s=t+1;const c=[];for(;s<e.length&&"sup_close"!==e[s].type;)a+=String(null!=(n=e[s].content)?n:""),c.push(e[s]),s++;return i.push(...ze(c)),{node:{type:"superscript",children:i.length>0?i:[{type:"text",content:a||String(null!=(o=e[t].content)?o:""),raw:a||String(null!=(l=e[t].content)?l:"")}],raw:`^${a||String(null!=(r=e[t].content)?r:"")}^`},nextIndex:s<e.length?s+1:e.length}}(e,r);d(t),r=n;break}case"sub":i(),d({type:"subscript",children:[{type:"text",content:String(null!=(f=m.content)?f:""),raw:String(null!=(g=m.content)?g:"")}],raw:`~${String(null!=(v=m.content)?v:"")}~`}),r++;break;case"sup":i(),d({type:"superscript",children:[{type:"text",content:String(null!=(w=m.content)?w:""),raw:String(null!=(y=m.content)?y:"")}],raw:`^${String(null!=(k=m.content)?k:"")}^`}),r++;break;case"emoji":{i();const t=e[r-1];"text"===(null==t?void 0:t.type)&&/\|:-+/.test(String(null!=(x=t.content)?x:""))?h("",""):d(function(e){var t,n;const o=String(null!=(t=e.content)?t:"");return{type:"emoji",name:o,markup:String(null!=(n=e.markup)?n:""),raw:`:${o}:`}}(m)),r++;break}case"checkbox":i(),d(function(e){var t;const n=null!=(t=e.meta)?t:{};return{type:"checkbox",checked:!0===n.checked,raw:n.checked?"[x]":"[ ]"}}(m)),r++;break;case"checkbox_input":i(),d(function(e){const t=e,n=t.attrGet?t.attrGet("checked"):void 0,o=""===n||"true"===n;return{type:"checkbox_input",checked:o,raw:o?"[x]":"[ ]"}}(m)),r++;break;case"footnote_ref":i(),d(function(e){var t,n,o;const l=null!=(t=e.meta)?t:{};return{type:"footnote_reference",id:String(null!=(n=l.label)?n:""),raw:`[^${String(null!=(o=l.label)?o:"")}]`}}(m)),r++;break;case"hardbreak":i(),d({type:"hardbreak",raw:"\\\n"}),r++;break;case"fence":i(),d(Ie(e[r])),r++;break;case"math_inline":i(),d(function(e){var t;return{type:"math_inline",content:String(null!=(t=e.content)?t:""),loading:!!e.loading,raw:e.raw}}(m)),r++;break;case"reference":!function(t){var n,l,a,s,c,u,h,p;i();const m=e[r+1],f=e[r-1],g=o[o.length-1],v="text"===(null==m?void 0:m.type)&&!String(null!=(n=m.content)?n:"").startsWith("("),w="text"===(null==f?void 0:f.type)&&/\]$|^\s*$/.test(String(null!=(l=f.content)?l:""));v||w?d(function(e){var t,n,o;return{type:"reference",id:String(null!=(t=e.content)?t:""),raw:String(null!=(o=e.markup)?o:`[${null!=(n=e.content)?n:""}]`)}}(t)):m&&"text"===m.type?m.content=String(null!=(a=t.markup)?a:"")+String(null!=(s=m.content)?s:""):g&&"text"===g.type&&(g.content=String(null!=(c=g.content)?c:"")+String(null!=(u=t.markup)?u:""),g.raw=String(null!=(h=g.raw)?h:"")+String(null!=(p=t.markup)?p:"")),r++}(m);break;default:!function(e){i(),o.push(e)}(m),r++}}return o}function Pe(e,t){var n;const o=[];let l=t+1;for(;l<e.length&&"blockquote_close"!==e[l].type;)if("paragraph_open"===e[l].type){const t=e[l+1];o.push({type:"paragraph",children:ze(t.children||[]),raw:String(null!=(n=t.content)?n:"")}),l+=3}else if("bullet_list_open"===e[l].type||"ordered_list_open"===e[l].type){const[t,n]=Xe(e,l);o.push(t),l=n}else l++;return[{type:"blockquote",children:o,raw:o.map(e=>e.raw).join("\n")},l+1]}function We(e){var t,n,o,l,r;if(null==(t=e.info)?void 0:t.startsWith("diff"))return Ie(e);const i=String(null!=(n=e.content)?n:""),a=i.match(/ type="application\/vnd\.ant\.([^"]+)"/);(null==a?void 0:a[1])&&(e.content=i.replace(/<antArtifact[^>]*>/g,"").replace(/<\/antArtifact>/g,""));const s=Array.isArray(e.map)&&2===e.map.length;return{type:"code_block",language:a?a[1]:String(null!=(o=e.info)?o:""),code:String(null!=(l=e.content)?l:""),raw:String(null!=(r=e.content)?r:""),loading:!s}}function De(e,t){var n,o;const l=[];let r=t+1,i=[],a=[];for(;r<e.length&&"dl_close"!==e[r].type;)if("dt_open"===e[r].type)i=ze(e[r+1].children||[]),r+=3;else if("dd_open"===e[r].type){let t=r+1;for(a=[];t<e.length&&"dd_close"!==e[t].type;)if("paragraph_open"===e[t].type){const l=e[t+1];a.push({type:"paragraph",children:ze(l.children||[],String(null!=(n=l.content)?n:"")),raw:String(null!=(o=l.content)?o:"")}),t+=3}else t++;i.length>0&&(l.push({type:"definition_item",term:i,definition:a,raw:`${i.map(e=>e.raw).join("")}: ${a.map(e=>e.raw).join("\n")}`}),i=[]),r=t+1}else r++;return[{type:"definition_list",items:l,raw:l.map(e=>e.raw).join("\n")},r+1]}function Fe(e,t){var n,o,l;const r=null!=(n=e[t].meta)?n:{},i=String(null!=(o=null==r?void 0:r.label)?o:"0"),a=[];let s=t+1;for(;s<e.length&&"footnote_close"!==e[s].type;)if("paragraph_open"===e[s].type){const t=e[s+1];a.push({type:"paragraph",children:ze(t.children||[]),raw:String(null!=(l=t.content)?l:"")}),s+=3}else s++;return[{type:"footnote",id:i,children:a,raw:`[^${i}]: ${a.map(e=>e.raw).join("\n")}`},s+1]}function Ve(e,t){var n,o,l;const r=e[t],i=String(null!=(o=null==(n=r.tag)?void 0:n.substring(1))?o:"1"),a=Number.parseInt(i,10),s=e[t+1],c=String(null!=(l=s.content)?l:"");return{type:"heading",level:a,text:c,children:ze(s.children||[]),raw:c}}function Ke(e){var t,n;return{type:"math_block",content:String(null!=(t=e.content)?t:""),loading:!!e.loading,raw:String(null!=(n=e.raw)?n:"")}}function Ye(e,t){var n,o;let l=t+1,r=null;const i=[];let a=!1;for(;l<e.length&&"table_close"!==e[l].type;)if("thead_open"===e[l].type)a=!0,l++;else if("thead_close"===e[l].type)a=!1,l++;else if("tbody_open"===e[l].type||"tbody_close"===e[l].type)l++;else if("tr_open"===e[l].type){const t=[];let o=l+1;for(;o<e.length&&"tr_close"!==e[o].type;)if("th_open"===e[o].type||"td_open"===e[o].type){const l="th_open"===e[o].type,r=e[o+1],i=String(null!=(n=r.content)?n:"");t.push({type:"table_cell",header:l||a,children:ze(r.children||[],i),raw:i}),o+=3}else o++;const s={type:"table_row",cells:t,raw:t.map(e=>e.raw).join("|")};a?r=s:i.push(s),l=o+1}else l++;return r||(r={type:"table_row",cells:[],raw:""}),[{type:"table",header:r,rows:i,loading:null!=(o=e[t].loading)&&o,raw:[r,...i].map(e=>e.raw).join("\n")},l+1]}function qe(){return{type:"thematic_break",raw:"---"}}function Xe(e,t){var n,o,l,r,i;const a=e[t],s=[];let c=t+1;for(;c<e.length&&"bullet_list_close"!==e[c].type&&"ordered_list_close"!==e[c].type;)if("list_item_open"===e[c].type){const t=[];let a=c+1;for(;a<e.length&&"list_item_close"!==e[a].type;)if("paragraph_open"===e[a].type){const i=e[a+1],s=e[a-1],c=String(null!=(n=i.content)?n:"");/\n\d+$/.test(c)&&(i.content=c.replace(/\n\d+$/,""),null==(o=i.children)||o.splice(-1,1)),t.push({type:"paragraph",children:ze(i.children||[],String(null!=(l=i.content)?l:""),s),raw:String(null!=(r=i.content)?r:"")}),a+=3}else if("blockquote_open"===e[a].type){const[n,o]=Pe(e,a);t.push(n),a=o}else if("bullet_list_open"===e[a].type||"ordered_list_open"===e[a].type){if("*"===e[a].markup){a++;continue}const[n,o]=Ze(e,a);t.push(n),a=o}else if("code_block"===e[a].type)t.push(We(e[a])),a+=1;else if("fence"===e[a].type)t.push(Ie(e[a])),a+=1;else if("math_block"===e[a].type)t.push(Ke(e[a])),a+=1;else if("table_open"===e[a].type){const[n,o]=Ye(e,a);t.push(n),a=o}else if("dl_open"===e[a].type){const[n,o]=De(e,a);t.push(n),a=o}else if("footnote_open"===e[a].type){const[n,o]=Fe(e,a);t.push(n),a=o}else if("heading_open"===e[a].type){const n=Ve(e,a);t.push(n),a+=3}else if("hr"===e[a].type)t.push(qe()),a+=1;else if("container_open"===e[a].type){const n=/^::: ?(warning|info|note|tip|danger|caution) ?(.*)$/.exec(String(null!=(i=e[a].info)?i:""));if(n){const[o,l]=Ue(e,a,n);t.push(o),a=l}else a+=1}else a+=1;s.push({type:"list_item",children:t,raw:t.map(e=>e.raw).join("")}),c=a+1}else c+=1;return[{type:"list",ordered:"ordered_list_open"===a.type,start:(()=>{if(a.attrs&&a.attrs.length){const e=a.attrs.find(e=>"start"===e[0]);if(e){const t=Number(e[1]);return Number.isFinite(t)&&0!==t?t:1}}})(),items:s,raw:s.map(e=>e.raw).join("\n")},c+1]}function Ze(e,t){var n,o;const l=e[t],r=[];let i=t+1;for(;i<e.length&&"bullet_list_close"!==e[i].type&&"ordered_list_close"!==e[i].type;)if("list_item_open"===e[i].type){const t=[];let l=i+1;for(;l<e.length&&"list_item_close"!==e[l].type;)if("paragraph_open"===e[l].type){const r=e[l+1],i=e[l-1];t.push({type:"paragraph",children:ze(r.children||[],String(null!=(n=r.content)?n:""),i),raw:String(null!=(o=r.content)?o:"")}),l+=3}else if("bullet_list_open"===e[l].type||"ordered_list_open"===e[l].type){if("*"===e[l].markup){l++;continue}const[n,o]=Ze(e,l);t.push(n),l=o}else"code_block"===e[l].type?(t.push(We(e[l])),l+=1):"fence"===e[l].type?(t.push(Ie(e[l])),l+=1):"math_block"===e[l].type?(t.push(Ke(e[l])),l+=1):l+=1;r.push({type:"list_item",children:t,raw:t.map(e=>e.raw).join("")}),i=l+1}else i+=1;return[{type:"list",ordered:"ordered_list_open"===l.type,start:(()=>{if(l.attrs&&l.attrs.length){const e=l.attrs.find(e=>"start"===e[0]);if(e){const t=Number(e[1]);return Number.isFinite(t)&&0!==t?t:1}}})(),items:r,raw:r.map(e=>e.raw).join("\n")},i+1]}function Ue(e,t,n){var o,l,r;const i=String(null!=(o=n[1])?o:"note"),a=String(null!=(l=n[2])?l:i.charAt(0).toUpperCase()+i.slice(1)),s=[];let c=t+1;for(;c<e.length&&"container_close"!==e[c].type;)if("paragraph_open"===e[c].type){const t=e[c+1];t&&s.push({type:"paragraph",children:ze(t.children||[]),raw:String(null!=(r=t.content)?r:"")}),c+=3}else if("bullet_list_open"===e[c].type||"ordered_list_open"===e[c].type){const[t,n]=Xe(e,c);s.push(t),c=n}else c++;return[{type:"admonition",kind:i,title:a,children:s,raw:`:::${i} ${a}\n${s.map(e=>e.raw).join("\n")}\n:::`},c+1]}function Ge(e,t){var n,o,l,r;const i=e[t];let a="note",s="";const c=i.type.match(/^container_(\w+)_open$/);if(c){a=c[1];const e=String(null!=(n=i.info)?n:"").trim();if(e&&!e.startsWith(":::")){const t=e.replace(/* @__PURE__ */new RegExp(`^${a}`),"").trim();t&&(s=t)}}else{const e=String(null!=(o=i.info)?o:"").trim(),t=/^:{1,3}\s*(warning|info|note|tip|danger|caution)\s*(.*)$/i.exec(e);t&&(a=t[1],s=String(null!=(l=t[2])?l:""))}s||(s=a.charAt(0).toUpperCase()+a.slice(1));const u=[];let d=t+1;const h=/* @__PURE__ */new RegExp(`^container_${a}_close$`);for(;d<e.length&&"container_close"!==e[d].type&&!h.test(e[d].type);)if("paragraph_open"===e[d].type){const t=e[d+1];if(t){const e=t.children||[];let n=-1;for(let t=e.length-1;t>=0;t--){const o=e[t];if("text"===o.type&&/:+/.test(o.content)){n=t;break}}const o=-1!==n?e.slice(0,n):e;u.push({type:"paragraph",children:ze(o||[]),raw:String(null!=(r=t.content)?r:"").replace(/\n:+$/,"").replace(/\n\s*:::\s*$/,"")})}d+=3}else if("bullet_list_open"===e[d].type||"ordered_list_open"===e[d].type){const[t,n]=Xe(e,d);u.push(t),d=n}else d++;return[{type:"admonition",kind:a,title:s,children:u,raw:`:::${a} ${s}\n${u.map(e=>e.raw).join("\n")}\n:::`},d+1]}function Je(){return{type:"hardbreak",raw:"\\\n"}}function Qe(e){var t,n;const o=String(null!=(t=e.content)?t:"");if(/^\s*<!--/.test(o)||/^\s*<!/.test(o)||/^\s*<\?/.test(o))return{type:"html_block",content:o,raw:o,tag:"",loading:!1};const l=((null==(n=o.match(/^\s*<([A-Z][\w:-]*)/i))?void 0:n[1])||"").toLowerCase();if(!l)return{type:"html_block",content:o,raw:o,tag:"",loading:!1};const r=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i=/^\s*<[^>]*\/\s*>/.test(o),a=r.has(l),s=new RegExp(`<\\/\\s*${l}\\b`,"i").test(o),c=!(a||i||s);return{type:"html_block",content:c?`${o.replace(/<[^>]*$/,"")}\n</${l}>`:o,raw:o,tag:l,loading:c}}function et(e,t){var n;const o=e[t+1],l=String(null!=(n=o.content)?n:"");return{type:"paragraph",children:ze(o.children||[],l),raw:l}}function tt(e,t,n={}){let o=(null!=e?e:"").toString().replace(/([^\\])\right/g,"$1\\right");o.endsWith("- *")&&(o=o.replace(/- \*$/,"- \\*")),/\n\s*-\s*$/.test(o)?o=o.replace(/\n\s*-\s*$/,"\n"):/\n[[(]\n*$/.test(o)&&(o=o.replace(/(\n\[|\n\()+\n*$/g,"\n"));const l=t.parse(o,{});if(!l||!Array.isArray(l))return[];const r=n.preTransformTokens,i=n.postTransformTokens;let a=l;r&&"function"==typeof r&&(a=r(a)||a);let s=nt(a);if(i&&"function"==typeof i){const e=i(a);if(Array.isArray(e)){const t=e[0],n=null==t?void 0:t.type;s=t&&"string"==typeof n?nt(e):e}}return s}function nt(e){var t;if(!e||!Array.isArray(e))return[];const n=[];let o=0;for(;o<e.length;){const l=e[o];switch(l.type){case"container_warning_open":case"container_info_open":case"container_note_open":case"container_tip_open":case"container_danger_open":case"container_caution_open":case"container_error_open":{const[t,l]=Ge(e,o);n.push(t),o=l;break}case"heading_open":n.push(Ve(e,o)),o+=3;break;case"paragraph_open":n.push(et(e,o)),o+=3;break;case"html_block":n.push(Qe(l)),o+=1;break;case"code_block":n.push(We(e[o])),o+=1;break;case"fence":n.push(Ie(e[o])),o+=1;break;case"bullet_list_open":case"ordered_list_open":{const[t,l]=Xe(e,o);n.push(t),o=l;break}case"hr":n.push(qe()),o+=1;break;case"blockquote_open":{const[t,l]=Pe(e,o);n.push(t),o=l;break}case"table_open":{const[t,l]=Ye(e,o);n.push(t),o=l;break}case"dl_open":{const[t,l]=De(e,o);n.push(t),o=l;break}case"footnote_open":{const[t,l]=Fe(e,o);n.push(t),o=l;break}case"container_open":{const r=/^::: ?(warning|info|note|tip|danger|caution|error) ?(.*)$/.exec(String(null!=(t=l.info)?t:""));if(r){const[t,l]=Ue(e,o,r);n.push(t),o=l}else o+=1;break}case"hardbreak":n.push(Je()),o++;break;case"math_block":n.push(Ke(e[o])),o+=1;break;default:o+=1}}return n}function ot(e=`editor-${Date.now()}`,t={}){var n;const o=Ee(t),l={"common.copy":"Copy"};let r;if("function"==typeof t.i18n)r=t.i18n;else if(t.i18n&&"object"==typeof t.i18n){const e=t.i18n;r=t=>{var n,o;return null!=(o=null!=(n=e[t])?n:l[t])?o:t}}else r=e=>{var t;return null!=(t=l[e])?t:e};if(Array.isArray(t.plugin))for(const s of t.plugin){const e=s;if(Array.isArray(e)){const t=e[0],n=e[1];"function"==typeof t&&o.use(t,n)}else"function"==typeof e&&o.use(e)}if(Array.isArray(t.apply))for(const s of t.apply)try{s(o)}catch(a){console.error("[getMarkdown] apply function threw an error",a)}o.use(f),o.use(g),o.use(m),o.use(d);const i=null!=(n=v.default)?n:v;return o.use(i),o.use(p),o.use(h),o.core.ruler.after("block","mark_fence_closed",e=>{var t,n;const o=e,l=o.src.split(/\r?\n/);for(const r of o.tokens){if("fence"!==r.type||!r.map||!r.markup)continue;const e=r.map[0],o=r.map[1],i=r.markup,a=i[0],s=i.length,c=null!=(t=l[Math.max(0,o-1)])?t:"";let u=0;for(;u<c.length&&(" "===c[u]||"\t"===c[u]);)u++;let d=0;for(;u+d<c.length&&c[u+d]===a;)d++;let h=u+d;for(;h<c.length&&(" "===c[h]||"\t"===c[h]);)h++;const p=o>e+1&&d>=s&&h===c.length,m=r;m.meta=null!=(n=m.meta)?n:{},m.meta.unclosed=!p,m.meta.closed=!!p}}),o.inline.ruler.before("sub","wave",(e,t)=>{const n=e,o=n.pos;if("~"!==n.src[o])return!1;const l=n.src[o-1],r=n.src[o+1];return!(!/\d/.test(l)||!/\d/.test(r))&&(t||(n.push("text","",0).content="~"),n.pos+=1,!0)}),o.renderer.rules.fence=(t,n)=>{var o,l;const i=t[n],a=String(null!=(o=i.info)?o:"").trim(),s=String(null!=(l=i.content)?l:""),c=btoa(unescape(encodeURIComponent(s))),u=String(null!=a?a:"text");return`<div class="code-block" data-code="${c}" data-lang="${u}" id="editor-${e}-${n}-${u}">\n <div class="code-header">\n <span class="code-lang">${u.toUpperCase()}</span>\n <button class="copy-button" data-code="${c}">${r("common.copy")}</button>\n </div>\n <div class="code-editor"></div>\n </div>`},o.inline.ruler.before("escape","reference",(e,t)=>{const n=e;if("["!==n.src[n.pos])return!1;const o=/^\[(\d+)\]/.exec(n.src.slice(n.pos));if(!o)return!1;if(!t){const e=o[1],t=n.push("reference","span",0);t.content=e,t.markup=o[0]}return n.pos+=o[0].length,!0}),o.renderer.rules.reference=(e,t)=>{var n;const o=String(null!=(n=e[t].content)?n:"");return`<span class="reference-link" data-reference-id="${o}" role="button" tabindex="0" title="Click to view reference">${o}</span>`},o}const lt=["cite"],rt=(e,t)=>{const n=e.__vccOpts||e;for(const[o,l]of t)n[o]=l;return n},it=/* @__PURE__ */rt(/* @__PURE__ */k({__name:"BlockquoteNode",props:{node:{},indexKey:{}},emits:["copy"],setup:e=>(t,n)=>(b(),x("blockquote",{class:"blockquote",dir:"auto",cite:e.node.cite},[_(M(nr),{"index-key":`blockquote-${e.indexKey}`,nodes:e.node.children||[],onCopy:n[0]||(n[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes"])],8,lt))}),[["__scopeId","data-v-b7686a5f"]]);it.install=e=>{e.component(it.__name,it)};const at={class:"checkbox-node"},st=["checked"],ct=/* @__PURE__ */rt(/* @__PURE__ */k({__name:"CheckboxNode",props:{node:{}},setup:e=>(t,n)=>(b(),x("span",at,[$("input",{type:"checkbox",checked:e.node.checked,disabled:"",class:"checkbox-input"},null,8,st)]))}),[["__scopeId","data-v-8dc6c46f"]]);ct.install=e=>{e.component(ct.__name,ct)};const ut={class:"definition-list"},dt={class:"definition-term"},ht={class:"definition-desc"},pt=/* @__PURE__ */rt(/* @__PURE__ */k({__name:"DefinitionListNode",props:{node:{},indexKey:{}},emits:["copy"],setup:e=>(t,n)=>(b(),x("dl",ut,[(b(!0),x(S,null,C(e.node.items,(o,l)=>(b(),x(S,{key:l},[$("dt",dt,[_(M(nr),{"index-key":`definition-term-${e.indexKey}-${l}`,nodes:o.term,onCopy:n[0]||(n[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes"])]),$("dd",ht,[_(M(nr),{"index-key":`definition-desc-${e.indexKey}-${l}`,nodes:o.definition,onCopy:n[1]||(n[1]=e=>t.$emit("copy",e))},null,8,["index-key","nodes"])])],64))),128))]))}),[["__scopeId","data-v-9ac7e23c"]]);pt.install=e=>{e.component(pt.__name,pt)};const mt={class:"emoji-node"},ft=/* @__PURE__ */rt(/* @__PURE__ */k({__name:"EmojiNode",props:{node:{}},setup:e=>(t,n)=>(b(),x("span",mt,B(e.node.name),1))}),[["__scopeId","data-v-de55dc97"]]);ft.install=e=>{e.component(ft.__name,ft)};const gt="__global__",vt={};function wt(e,t){"string"==typeof e?vt[e]=t||{}:vt[gt]=e||{}}function yt(e){return e?vt[e]||{}:vt[gt]||{}}function kt(e){if(e===gt)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete vt[e]}function xt(){delete vt[gt]}const bt=["title"],_t=/* @__PURE__ */rt(/* @__PURE__ */k({__name:"FootnoteReferenceNode",props:{node:{}},setup(e){const t=`#footnote-${e.node.id}`;function n(){if("undefined"==typeof document)return;const e=document.querySelector(t);e?e.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${t} not found`)}return(o,l)=>(b(),x("sup",{class:"footnote-reference",onClick:n},[$("span",{href:t,title:`查看脚注 ${e.node.id}`,class:"footnote-link cursor-pointer"},"["+B(e.node.id)+"]",9,bt)]))}}),[["__scopeId","data-v-7c1ed642"]]);_t.install=e=>{e.component(_t.__name,_t)};const Mt={class:"inline-block px-1 py-0.5 rounded text-xs font-mono bg-secondary before:content-[''] after:content-['']"},$t=/* @__PURE__ */k({__name:"InlineCodeNode",props:{node:{}},setup:e=>(t,n)=>(b(),x("code",Mt,B(e.node.code),1))});$t.install=e=>{e.component($t.__name,$t)};const St=Math.min,Ct=Math.max,Bt=Math.round,Tt=Math.floor,Lt=e=>({x:e,y:e}),Et={left:"right",right:"left",bottom:"top",top:"bottom"},jt={start:"end",end:"start"};function It(e,t,n){return Ct(e,St(t,n))}function At(e,t){return"function"==typeof e?e(t):e}function Ht(e){return e.split("-")[0]}function Ot(e){return