mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-20 08:49:16 +08:00
127 lines
117 KiB
JavaScript
127 lines
117 KiB
JavaScript
|
(function(o,c){typeof exports=="object"&&typeof module!="undefined"?module.exports=c(require("vue")):typeof define=="function"&&define.amd?define(["vue"],c):(o=typeof globalThis!="undefined"?globalThis:o||self,o.MdEditorV3=c(o.Vue))})(this,function(o){"use strict";var fi=Object.defineProperty,mi=Object.defineProperties;var pi=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var gi=Object.prototype.hasOwnProperty,ki=Object.prototype.propertyIsEnumerable;var It=(o,c,Z)=>c in o?fi(o,c,{enumerable:!0,configurable:!0,writable:!0,value:Z}):o[c]=Z,q=(o,c)=>{for(var Z in c||(c={}))gi.call(c,Z)&&It(o,Z,c[Z]);if(zt)for(var Z of zt(c))ki.call(c,Z)&&It(o,Z,c[Z]);return o},fe=(o,c)=>mi(o,pi(c));const c="md-editor",Z="md-editor-v3",At="https://at.alicdn.com/t/c/font_2605852_gymddm8qwtd.js",O="https://cdnjs.cloudflare.com/ajax/libs",Ft=`${O}/highlight.js/11.7.0/highlight.min.js`,qe={main:`${O}/prettier/2.8.0/standalone.js`,markdown:`${O}/prettier/2.8.0/parser-markdown.js`},Ke={css:`${O}/cropperjs/1.5.13/cropper.min.css`,js:`${O}/cropperjs/1.5.13/cropper.min.js`},Lt=`${O}/screenfull.js/5.2.0/screenfull.min.js`,Ze=["bold","underline","italic","strikeThrough","-","title","sub","sup","quote","unorderedList","orderedList","task","-","codeRow","code","link","image","table","mermaid","katex","-","revoke","next","save","=","prettier","pageFullscreen","fullscreen","preview","htmlPreview","catalog","github"],Ge=["markdownTotal","=","scrollSwitch"],We={"zh-CN":{toolbarTips:{bold:"\u52A0\u7C97",underline:"\u4E0B\u5212\u7EBF",italic:"\u659C\u4F53",strikeThrough:"\u5220\u9664\u7EBF",title:"\u6807\u9898",sub:"\u4E0B\u6807",sup:"\u4E0A\u6807",quote:"\u5F15\u7528",unorderedList:"\u65E0\u5E8F\u5217\u8868",orderedList:"\u6709\u5E8F\u5217\u8868",task:"\u4EFB\u52A1\u5217\u8868",codeRow:"\u884C\u5185\u4EE3\u7801",code:"\u5757\u7EA7\u4EE3\u7801",link:"\u94FE\u63A5",image:"\u56FE\u7247",table:"\u8868\u683C",mermaid:"mermaid\u56FE",katex:"katex\u516C\u5F0F",revoke:"\u540E\u9000",next:"\u524D\u8FDB",save:"\u4FDD\u5B58",prettier:"\u7F8E\u5316",pageFullscreen:"\u6D4F\u89C8\u5668\u5168\u5C4F",fullscreen:"\u5C4F\u5E55\u5168\u5C4F",preview:"\u9884\u89C8",htmlPreview:"html\u4EE3\u7801\u9884\u89C8",catalog:"\u76EE\u5F55",github:"\u6E90\u7801\u5730\u5740"},titleItem:{h1:"\u4E00\u7EA7\u6807\u9898",h2:"\u4E8C\u7EA7\u6807\u9898",h3:"\u4E09\u7EA7\u6807\u9898",h4:"\u56DB\u7EA7\u6807\u9898",h5:"\u4E94\u7EA7\u6807\u9898",h6:"\u516D\u7EA7\u6807\u9898"},imgTitleItem:{link:"\u6DFB\u52A0\u94FE\u63A5",upload:"\u4E0A\u4F20\u56FE\u7247",clip2upload:"\u88C1\u526A\u4E0A\u4F20"},linkModalTips:{linkTitle:"\u6DFB\u52A0\u94FE\u63A5",imageTitle:"\u6DFB\u52A0\u56FE\u7247",descLabel:"\u94FE\u63A5\u63CF\u8FF0\uFF1A",descLabelPlaceHolder:"\u8BF7\u8F93\u5165\u63CF\u8FF0...",urlLabel:"\u94FE\u63A5\u5730\u5740\uFF1A",urlLabelPlaceHolder:"\u8BF7\u8F93\u5165\u94FE\u63A5...",buttonOK:"\u786E\u5B9A"},clipModalTips:{title:"\u88C1\u526A\u56FE\u7247\u4E0A\u4F20",buttonUpload:"\u4E0A\u4F20"},copyCode:{text:"\u590D\u5236\u4EE3\u7801",successTips:"\u5DF2\u590D\u5236\uFF01",failTips:"\u590D\u5236\u5931\u8D25\uFF01"},mermaid:{flow:"\u6D41\u7A0B\u56FE",sequence:"\u65F6\u5E8F\u56FE",gantt:"\u7518\u7279\u56FE",class:"\u7C7B\u56FE",state:"\u72B6\u6001\u56FE",pie:"\u997C\u56FE",relationship:"\u5173\u7CFB\u56FE",journey:"\u65C5\u7A0B\u56FE"},katex:{inline:"\u884C\u5185\u516C\u5F0F",block:"\u5757\u7EA7\u516C\u5F0F"},footer:{markdownTotal:"\u5B57\u6570",scrollAuto:"\u540C\u6B65\u6EDA\u52A8"}},"en-US":{toolbarTips:{bold:"bold",underline:"underline",italic:"italic",strikeThrough:"strikeThrough",title:"title",sub:"subscript",sup:"superscript",quote:"quote",unorderedList:"unordered list",orderedList:"ordered list",task:"task list",codeRow:"inline code",code:"block-level code",link:"link",image:"image",table:"table",mermaid:"mermaid",katex:"formula",revoke:"revoke",next:"undo revoke",save:"save",prettier:"prettier",pageFullscreen:"fullscreen in page",fullscreen:"fullscreen",preview:"preview",htmlPreview:"html preview",catalog:"catalog",github:"source code"},titleItem:{h1:"Lv1 Heading",h2:"Lv2 Heading
|
||
|
`),t=['<span rn-wrapper aria-hidden="true">'];return e.forEach(()=>{t.push("<span></span>")}),t.push("</span>"),`<span class="code-block">${i}</span>${t.join("")}`},ke=(i,e=200)=>{let t=0;return(...n)=>{t&&clearTimeout(t),t=window.setTimeout(()=>{i.apply(globalThis,n),t=0},e)}},Pt=(i,e=200)=>{let t=0,n=null;return(...l)=>{const r=s=>{t===0&&(t=s),s-t>=e?(i.apply(globalThis,n),n=null,t=0):window.requestAnimationFrame(r)};n===null&&window.requestAnimationFrame(r),n=l}},et=(i,e="$")=>{const t=i.split(e);let n=e,l="";for(let r=1;r<t.length;r++)if(/\\$/.test(t[r]))n+=t[r]+"$",l+=t[r]+"$";else{n+=t[r]+e,l+=t[r];break}return[n,l]},Ot=i=>{var t;return navigator.userAgent.indexOf("Firefox")>-1?i.value.substring(i.selectionStart,i.selectionEnd):((t=window.getSelection())==null?void 0:t.toString())||""},Mt=(i,e)=>{const t=i==null?void 0:i.getBoundingClientRect();if(e===document.documentElement)return t.top-e.clientTop;const n=e==null?void 0:e.getBoundingClientRect();return t.top-n.top},Bt=(i,e)=>{const t=q({},i);return e.forEach(n=>{Reflect.deleteProperty(t,n)}),t},tt=(i,e)=>{const t=n=>{const l=i.parentElement||document.body,r=l.offsetWidth,s=l.offsetHeight,{clientWidth:a}=document.documentElement,{clientHeight:u}=document.documentElement,h=n.offsetX,d=n.offsetY,m=f=>{let v=f.x+document.body.scrollLeft-document.body.clientLeft-h,x=f.y+document.body.scrollTop-document.body.clientTop-d;v=v<1?1:v<a-r-1?v:a-r-1,x=x<1?1:x<u-s-1?x:u-s-1,e?e(v,x):(l.style.left=`${v}px`,l.style.top=`${x}px`)};document.addEventListener("mousemove",m);const p=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)};document.addEventListener("mouseup",p)};return i.addEventListener("mousedown",t),()=>{i.removeEventListener("mousedown",t)}},G=(i,e="")=>{const t=document.getElementById(i.id);t?e!==""&&i.onload instanceof Function&&(Reflect.get(window,e)?i.onload(new Event("load")):t.addEventListener("load",i.onload)):document.head.appendChild(i)},Ut=ke((i,e,t)=>{const n=document.getElementById(i);n&&n.setAttribute(e,t)},10),be="onSave",je="changeCatalogVisible",nt="changeFullscreen",it="pageFullscreenChanged",lt="fullscreenChanged",ot="previewChanged",rt="htmlPreviewChanged",at="catalogVisibleChanged",st="textarea_focus",qt=(i,e)=>{const{editorId:t,noPrettier:n,previewOnly:l}=i,r=o.reactive({buildFinished:!1,html:""}),s=a=>{if(a.target===document.querySelector(`#${i.editorId}-textarea`))if(b.emit(t,"selectTextChange"),a.ctrlKey||a.metaKey)switch(a.code){case"KeyS":{a.shiftKey?b.emit(t,"replace","strikeThrough"):(b.emit(t,be,i.modelValue),a.preventDefault());break}case"KeyB":{b.emit(t,"replace","bold"),a.preventDefault();break}case"KeyU":{a.shiftKey?(b.emit(t,"replace","unorderedList"),a.preventDefault()):(b.emit(t,"replace","underline"),a.preventDefault());break}case"KeyI":{a.shiftKey?(b.emit(t,"openModals","image"),a.preventDefault()):(b.emit(t,"replace","italic"),a.preventDefault());break}case"Digit1":{b.emit(t,"replace","h1"),a.preventDefault();break}case"Digit2":{b.emit(t,"replace","h2"),a.preventDefault();break}case"Digit3":{b.emit(t,"replace","h3"),a.preventDefault();break}case"Digit4":{b.emit(t,"replace","h4"),a.preventDefault();break}case"Digit5":{b.emit(t,"replace","h5"),a.preventDefault();break}case"Digit6":{b.emit(t,"replace","h6"),a.preventDefault();break}case"ArrowUp":{b.emit(t,"replace","sup"),a.preventDefault();break}case"ArrowDown":{b.emit(t,"replace","sub"),a.preventDefault();break}case"KeyQ":{if(a.key==="a"){a.target.select();return}b.emit(t,"replace","quote"),a.preventDefault();break}case"KeyA":if(a.key==="q"){b.emit(t,"replace","quote"),a.preventDefault();break}else return;case"KeyO":{b.emit(t,"replace","orderedList"),a.preventDefault();break}case"KeyC":{if(a.shiftKey)b.emit(t,"replace","code"),a.preventDefault();else if(a.altKey)b.emit(t,"replace","codeRow"),a.preventDefault();else{a.preventDefault(),b.emit(t,"replace","ctrlC");break}break}case"KeyL":{b.emit(t,"openModals","link"),a.preventDefault();break}case"KeyZ":{if(a.key==="w")return;a.shiftKey?(b.emit(t,"ctrlShiftZ"),a.preventDefault()):(b.emit(t,"c
|
||
|
`).map(l=>{const r=l.match(/^\s+/);if(r===null)return l;const[s]=r;return s.length>=n.length?l.slice(n.length):l}).join(`
|
||
|
`)}class He{constructor(e){this.options=e||ae}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:xe(n,`
|
||
|
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],l=En(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:l}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const l=xe(n,"#");(this.options.pedantic||!l||/ $/.test(l))&&(n=l.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const n=t[0].replace(/^ *>[ \t]?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(n,[]),text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,l,r,s,a,u,h,d,m,p,f,v,x=t[1].trim();const S=x.length>1,k={type:"list",raw:"",ordered:S,start:S?+x.slice(0,-1):"",loose:!1,items:[]};x=S?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=S?x:"[*+-]");const y=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(v=!1,!(!(t=y.exec(e))||this.rules.block.hr.test(e)));){if(n=t[0],e=e.substring(n.length),d=t[2].split(`
|
||
|
`,1)[0],m=e.split(`
|
||
|
`,1)[0],this.options.pedantic?(s=2,f=d.trimLeft()):(s=t[2].search(/[^ ]/),s=s>4?1:s,f=d.slice(s),s+=t[1].length),u=!1,!d&&/^ *$/.test(m)&&(n+=m+`
|
||
|
`,e=e.substring(m.length+1),v=!0),!v){const z=new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`),L=new RegExp(`^ {0,${Math.min(3,s-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),_=new RegExp(`^ {0,${Math.min(3,s-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,s-1)}}#`);for(;e&&(p=e.split(`
|
||
|
`,1)[0],d=p,this.options.pedantic&&(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(_.test(d)||I.test(d)||z.test(d)||L.test(e)));){if(d.search(/[^ ]/)>=s||!d.trim())f+=`
|
||
|
`+d.slice(s);else if(!u)f+=`
|
||
|
`+d;else break;!u&&!d.trim()&&(u=!0),n+=p+`
|
||
|
`,e=e.substring(p.length+1)}}k.loose||(h?k.loose=!0:/\n *\n *$/.test(n)&&(h=!0)),this.options.gfm&&(l=/^\[[ xX]\] /.exec(f),l&&(r=l[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),k.items.push({type:"list_item",raw:n,task:!!l,checked:r,loose:!1,text:f}),k.raw+=n}k.items[k.items.length-1].raw=n.trimRight(),k.items[k.items.length-1].text=f.trimRight(),k.raw=k.raw.trimRight();const E=k.items.length;for(a=0;a<E;a++){this.lexer.state.top=!1,k.items[a].tokens=this.lexer.blockTokens(k.items[a].text,[]);const z=k.items[a].tokens.filter(_=>_.type==="space"),L=z.every(_=>{const I=_.raw.split("");let g=0;for(const M of I)if(M===`
|
||
|
`&&(g+=1),g>1)return!0;return!1});!k.loose&&z.length&&L&&(k.loose=!0,k.items[a].loose=!0)}return k}}html(e){const t=this.rules.block.html.exec(e);if(t){const n={type:"html",raw:t[0],pre:!this.options.sanitizer&&(t[1]==="pre"||t[1]==="script"||t[1]==="style"),text:t[0]};if(this.options.sanitize){const l=this.options.sanitizer?this.options.sanitizer(t[0]):U(t[0]);n.type="paragraph",n.text=l,n.tokens=this.lexer.inline(l)}return n}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(/\s+/g," "),l=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:l,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(t){const n={type:"table",header:pt(t[1]).map(l=>({text:l})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
||
|
`):[]};if(n.header.length===n.align.length){n.raw=t[0];let l=n.align.length,r,s,a,u;for(r=0;r<l;r++)/^ *-+: *$/.test(n.align[r])?n.align[r]="right":/^ *:-+: *$/.test(n.align[r])?n.align[r]="center":/^ *:-+ *$/.test(n.align[r])?n.align[r]="left":n.align[r]=null;for(l=n.rows.length,r=0;r<l;r++)n.rows[r]=pt(n.rows[r],n.header.length).map(h=>({text:h}));for(l=n.header.length,s=0;s<l;s++)n.header[s].tokens=this.lexer.inline(n.header[s].text);for(l=n.rows.length,s=0;s<l;s++)for(u=n.rows[s],a=0;a<u.length;a++)u[a].tokens=this.lexer.inline(u[a].text);return n}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n=t[1].charAt(t[1].length-1)===`
|
||
|
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:U(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):U(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const s=xe(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=Cn(t[2],"()");if(s>-1){const u=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,u).trim(),t[3]=""}}let l=t[2],r="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(l);s&&(l=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return l=l.trim(),/^</.test(l)&&(this.options.pedantic&&!/>$/.test(n)?l=l.slice(1):l=l.slice(1,-1)),bt(t,{href:l&&l.replace(this.rules.inline._escapes,"$1"),title:r&&r.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let l=(n[2]||n[1]).replace(/\s+/g," ");if(l=t[l.toLowerCase()],!l){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return bt(n,l,n[0],this.lexer)}}emStrong(e,t,n=""){let l=this.rules.inline.emStrong.lDelim.exec(e);if(!l||l[3]&&n.match(/[\p{L}\p{N}]/u))return;const r=l[1]||l[2]||"";if(!r||r&&(n===""||this.rules.inline.punctuation.exec(n))){const s=l[0].length-1;let a,u,h=s,d=0;const m=l[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+s);(l=m.exec(t))!=null;){if(a=l[1]||l[2]||l[3]||l[4]||l[5]||l[6],!a)continue;if(u=a.length,l[3]||l[4]){h+=u;continue}else if((l[5]||l[6])&&s%3&&!((s+u)%3)){d+=u;continue}if(h-=u,h>0)continue;u=Math.min(u,u+h+d);const p=e.slice(0,s+l.index+(l[0].length-a.length)+u);if(Math.min(s,u)%2){const v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}const f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const l=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return l&&r&&(n=n.substring(1,n.length-1)),n=U(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const n=this.rules.inline.autolink.exec(e);if(n){let l,r;return n[2]==="@"?(l=U(this.options.mangle?t(n[1]):n[1]),r="mailto:"+l):(l=U(n[1]),r=l),{type:"link",raw:n[0],text:l,href:r,tokens:[{type:"text",raw:l,text:l}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let l,r;if(n[2]==="@")l=U(this.options.mangle?t(n[0]):n[0]),r="mailto:"+l;else{let s;do s=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0];while(s!==n[0]);l=U(n[0]),n[1]==="www."?r="http://"+l:r=l}return{type:"link",raw:n[0],text:l,href:r,tokens:[{type:"text",raw:l,text:l}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let l;return this.lexer.state.inRawBlock?l=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):U(n[0]):n[0]:l=U(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:l}}}}const T={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)
|
||
|
]`).replace("lheading",T.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const C={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:we,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:we,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};C._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",C.punctuation=P(C.punctuation).replace(/punctuation/g,C._punctuation).getRegex(),C.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,C.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,C._comment=P(T._comment).replace("(?:-->|$)","-->").getRegex(),C.emStrong.lDelim=P(C.emStrong.lDelim).replace(/punct/g,C._punctuation).getRegex(),C.emStrong.rDelimAst=P(C.emStrong.rDelimAst,"g").replace(/punct/g,C._punctuation).getRegex(),C.emStrong.rDelimUnd=P(C.emStrong.rDelimUnd,"g").replace(/punct/g,C._punctuation).getRegex(),C._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,C._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,C._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])?)+(?![-_])/,C.autolink=P(C.autolink).replace("scheme",C._scheme).replace("email",C._email).getRegex(),C._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,C.tag=P(C.tag).replace("comment",C._comment).replace("attribute",C._attribute).getRegex(),C._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,C._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,C._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,C.link=P(C.link).replace("label",C._label).replace("href",C._href).replace("title",C._title).getRegex(),C.reflink=P(C.reflink).replace("label",C._label).replace("ref",T._label).getRegex(),C.nolink=P(C.nolink).replace("ref",T._label).getRegex(),C.reflinkSearch=P(C.reflinkSearch,"g").replace("reflink",C.reflink).replace("nolink",C.nolink).getRegex(),C.normal=X({},C),C.pedantic=X({},C.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:P(/^!?\[(label)\]\((.*?)\)/).replace("label",C._label).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C._label).getRegex()}),C.gfm=X({},C.normal,{escape:P(C.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.!#$%&'*+\/=?_`{\|}~-]+@)))/}),C.gfm.url=P(C.gfm.url,"i").repla
|
||
|
`),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(a,u,h)=>u+" ".repeat(h.length));let n,l,r,s;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(n=a.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
||
|
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
||
|
`+n.raw,l.text+=`
|
||
|
`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=l.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
||
|
`+n.raw,l.text+=`
|
||
|
`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=l.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const u=e.slice(1);let h;this.options.extensions.startBlock.forEach(function(d){h=d.call({lexer:this},u),typeof h=="number"&&h>=0&&(a=Math.min(a,h))}),a<1/0&&a>=0&&(r=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r))){l=t[t.length-1],s&&l.type==="paragraph"?(l.raw+=`
|
||
|
`+n.raw,l.text+=`
|
||
|
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):t.push(n),s=r.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&l.type==="text"?(l.raw+=`
|
||
|
`+n.raw,l.text+=`
|
||
|
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):t.push(n);continue}if(e){const a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,l,r,s=e,a,u,h;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+kt("a",a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+kt("a",a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(s))!=null;)s=s.slice(0,a.index+a[0].length-2)+"++"+s.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(u||(h=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(n=d.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&n.type==="text"&&l.type==="text"?(l.raw+=n.raw,l.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),l=t[t.length-1],l&&n.type==="text"&&l.type==="text"?(l.raw+=n.raw,l.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,s,h)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e,yt)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e,yt))){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const m=e.slice(1);let p;this.options.extensions.startInline.forEach(function(f){p=f.call({lexer:this},m),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(r=e.substring(0,d+1))}if(n=this.tokenizer.inlineText(r,Sn)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(h=n.raw.slice(-1)),u=!0,l=t[t.length-1],l&&l.type==="text"?(l.raw+=n.raw,l.text+=n.text):t.push(n);continue}if(e){const d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return t}}class Pe{constructor(e){this.options=e||ae}code(e,t,n){const l=(t||"").match(/\S*/)[0];if(this.options.highlight){const r=this.options.highlight(e,l);r!=null&&r!==e&&(n=!0,e=r)}return e=e.replace(/\n$/,"")+`
|
||
|
`,l?'<pre><code class="'+this.options.langPrefix+U(l)+'">'+(n?e:U(e,!0))+`</code></pre>
|
||
|
`:"<pre><code>"+(n?e:U(e,!0))+`</code></pre>
|
||
|
`}blockquote(e){return`<blockquote>
|
||
|
${e}</blockquote>
|
||
|
`}html(e){return e}heading(e,t,n,l){if(this.options.headerIds){const r=this.options.headerPrefix+l.slug(n);return`<h${t} id="${r}">${e}</h${t}>
|
||
|
`}return`<h${t}>${e}</h${t}>
|
||
|
`}hr(){return this.options.xhtml?`<hr/>
|
||
|
`:`<hr>
|
||
|
`}list(e,t,n){const l=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+l+r+`>
|
||
|
`+e+"</"+l+`>
|
||
|
`}listitem(e){return`<li>${e}</li>
|
||
|
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return`<p>${e}</p>
|
||
|
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
||
|
<thead>
|
||
|
`+e+`</thead>
|
||
|
`+t+`</table>
|
||
|
`}tablerow(e){return`<tr>
|
||
|
${e}</tr>
|
||
|
`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
||
|
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){if(e=mt(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>",l}image(e,t,n){if(e=mt(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let l=`<img src="${e}" alt="${n}"`;return t&&(l+=` title="${t}"`),l+=this.options.xhtml?"/>":">",l}text(e){return e}}class wt{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class xt{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,l=0;if(this.seen.hasOwnProperty(n)){l=this.seen[e];do l++,n=e+"-"+l;while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=l,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class Y{constructor(e){this.options=e||ae,this.options.renderer=this.options.renderer||new Pe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new wt,this.slugger=new xt}static parse(e,t){return new Y(t).parse(e)}static parseInline(e,t){return new Y(t).parseInline(e)}parse(e,t=!0){let n="",l,r,s,a,u,h,d,m,p,f,v,x,S,k,y,E,z,L,_;const I=e.length;for(l=0;l<I;l++){if(f=e[l],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(_=this.options.extensions.renderers[f.type].call({parser:this},f),_!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){n+=_||"";continue}switch(f.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{n+=this.renderer.heading(this.parseInline(f.tokens),f.depth,ft(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{n+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(m="",d="",a=f.header.length,r=0;r<a;r++)d+=this.renderer.tablecell(this.parseInline(f.header[r].tokens),{header:!0,align:f.align[r]});for(m+=this.renderer.tablerow(d),p="",a=f.rows.length,r=0;r<a;r++){for(h=f.rows[r],d="",u=h.length,s=0;s<u;s++)d+=this.renderer.tablecell(this.parseInline(h[s].tokens),{header:!1,align:f.align[s]});p+=this.renderer.tablerow(d)}n+=this.renderer.table(m,p);continue}case"blockquote":{p=this.parse(f.tokens),n+=this.renderer.blockquote(p);continue}case"list":{for(v=f.ordered,x=f.start,S=f.loose,a=f.items.length,p="",r=0;r<a;r++)y=f.items[r],E=y.checked,z=y.task,k="",y.task&&(L=this.renderer.checkbox(E),S?y.tokens.length>0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=L+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=L+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:L}):k+=L),k+=this.parse(y.tokens,S),p+=this.renderer.listitem(k,z,E);n+=this.renderer.list(p,v,x);continue}case"html":{n+=this.renderer.html(f.text);continue}case"paragraph":{n+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(p=f.tokens?this.parseInline(f.tokens):f.text;l+1<I&&e[l+1].type==="text";)f=e[++l],p+=`
|
||
|
`+(f.tokens?this.parseInline(f.tokens):f.text);n+=t?this.renderer.paragraph(p):p;continue}default:{const g='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(g);return}else throw new Error(g)}}}return n}parseInline(e,t){t=t||this.renderer;let n="",l,r,s;const a=e.length;for(l=0;l<a;l++){if(r=e[l],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]&&(s=this.options.extensions.renderers[r.type].call({parser:this},r),s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type))){n+=s||"";continue}switch(r.type){case"escape":{n+=t.text(r.text);break}case"html":{n+=t.html(r.text);break}case"link":{n+=t.link(r.href,r.title,this.parseInline(r.tokens,t));break}case"image":{n+=t.image(r.href,r.title,r.text);break}case"strong":{n+=t.strong(this.parseInline(r.tokens,t));break}case"em":{n+=t.em(this.parseInline(r.tokens,t));break}case"codespan":{n+=t.codespan(r.text);break}case"br":{n+=t.br();break}case"del":{n+=t.del(this.parseInline(r.tokens,t));break}case"text":{n+=t.text(r.text);break}default:{const u='Token with "'+r.type+'" type was not found.';if(this.options.silent){console.error(u);return}else throw new Error(u)}}}return n}}function V(i,e,t){if(typeof i=="undefined"||i===null)throw new Error("marked(): input parameter is undefined or null");if(typeof i!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected");if(typeof e=="function"&&(t=e,e=null),e=X({},V.defaults,e||{}),gt(e),t){const l=e.highlight;let r;try{r=ee.lex(i,e)}catch(u){return t(u)}const s=function(u){let h;if(!u)try{e.walkTokens&&V.walkTokens(r,e.walkTokens),h=Y.parse(r,e)}catch(d){u=d}return e.highlight=l,u?t(u):t(null,h)};if(!l||l.length<3||(delete e.highlight,!r.length))return s();let a=0;V.walkTokens(r,function(u){u.type==="code"&&(a++,setTimeout(()=>{l(u.text,u.lang,function(h,d){if(h)return s(h);d!=null&&d!==u.text&&(u.text=d,u.escaped=!0),a--,a===0&&s()})},0))}),a===0&&s();return}function n(l){if(l.message+=`
|
||
|
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+U(l.message+"",!0)+"</pre>";throw l}try{const l=ee.lex(i,e);if(e.walkTokens){if(e.async)return Promise.all(V.walkTokens(l,e.walkTokens)).then(()=>Y.parse(l,e)).catch(n);V.walkTokens(l,e.walkTokens)}return Y.parse(l,e)}catch(l){n(l)}}V.options=V.setOptions=function(i){return X(V.defaults,i),hn(V.defaults),V},V.getDefaults=ct,V.defaults=ae,V.use=function(...i){const e=V.defaults.extensions||{renderers:{},childTokens:{}};i.forEach(t=>{const n=X({},t);if(n.async=V.defaults.async||n.async,t.extensions&&(t.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if(l.renderer){const r=e.renderers[l.name];r?e.renderers[l.name]=function(...s){let a=l.renderer.apply(this,s);return a===!1&&(a=r.apply(this,s)),a}:e.renderers[l.name]=l.renderer}if(l.tokenizer){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[l.level]?e[l.level].unshift(l.tokenizer):e[l.level]=[l.tokenizer],l.start&&(l.level==="block"?e.startBlock?e.startBlock.push(l.start):e.startBlock=[l.start]:l.level==="inline"&&(e.startInline?e.startInline.push(l.start):e.startInline=[l.start]))}l.childTokens&&(e.childTokens[l.name]=l.childTokens)}),n.extensions=e),t.renderer){const l=V.defaults.renderer||new Pe;for(const r in t.renderer){const s=l[r];l[r]=(...a)=>{let u=t.renderer[r].apply(l,a);return u===!1&&(u=s.apply(l,a)),u}}n.renderer=l}if(t.tokenizer){const l=V.defaults.tokenizer||new He;for(const r in t.tokenizer){const s=l[r];l[r]=(...a)=>{let u=t.tokenizer[r].apply(l,a);return u===!1&&(u=s.apply(l,a)),u}}n.tokenizer=l}if(t.walkTokens){const l=V.defaults.walkTokens;n.walkTokens=function(r){let s=[];return s.push(t.walkTokens.call(this,r)),l&&(s=s.concat(l.call(this,r))),s}}V.setOptions(n)})},V.walkTokens=function(i,e){let t=[];for(const n of i)switch(t=t.concat(e.call(V,n)),n.type){case"table":{for(const l of n.header)t=t.concat(V.walkTokens(l.tokens,e));for(const l of n.rows)for(const r of l)t=t.concat(V.walkTokens(r.tokens,e));break}case"list":{t=t.concat(V.walkTokens(n.items,e));break}default:V.defaults.extensions&&V.defaults.extensions.childTokens&&V.defaults.extensions.childTokens[n.type]?V.defaults.extensions.childTokens[n.type].forEach(function(l){t=t.concat(V.walkTokens(n[l],e))}):n.tokens&&(t=t.concat(V.walkTokens(n.tokens,e)))}return t},V.parseInline=function(i,e){if(typeof i=="undefined"||i===null)throw new Error("marked.parseInline(): input parameter is undefined or null");if(typeof i!="string")throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected");e=X({},V.defaults,e||{}),gt(e);try{const t=ee.lexInline(i,e);return e.walkTokens&&V.walkTokens(t,e.walkTokens),Y.parseInline(t,e)}catch(t){if(t.message+=`
|
||
|
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+U(t.message+"",!0)+"</pre>";throw t}},V.Parser=Y,V.parser=Y.parse,V.Renderer=Pe,V.TextRenderer=wt,V.Lexer=ee,V.lexer=ee.lex,V.Tokenizer=He,V.Slugger=xt,V.parse=V,Y.parse,ee.lex;var Nn=function(){var i=document.getSelection();if(!i.rangeCount)return function(){};for(var e=document.activeElement,t=[],n=0;n<i.rangeCount;n++)t.push(i.getRangeAt(n));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return i.removeAllRanges(),function(){i.type==="Caret"&&i.removeAllRanges(),i.rangeCount||t.forEach(function(l){i.addRange(l)}),e&&e.focus()}},Tn=Nn,vt={"text/plain":"Text","text/html":"Url",default:"Text"},Vn="Copy to clipboard: #{key}, Enter";function zn(i){var e=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return i.replace(/#{\s*key\s*}/g,e)}function In(i,e){var t,n,l,r,s,a,u=!1;e||(e={}),t=e.debug||!1;try{l=Tn(),r=document.createRange(),s=document.getSelection(),a=document.createElement("span"),a.textContent=i,a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(d){if(d.stopPropagation(),e.format)if(d.preventDefault(),typeof d.clipboardData=="undefined"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var m=vt[e.format]||vt.default;window.clipboardData.setData(m,i)}else d.clipboardData.clearData(),d.clipboardData.setData(e.format,i);e.onCopy&&(d.preventDefault(),e.onCopy(d.clipboardData))}),document.body.appendChild(a),r.selectNodeContents(a),s.addRange(r);var h=document.execCommand("copy");if(!h)throw new Error("copy command was unsuccessful");u=!0}catch(d){t&&console.error("unable to copy using execCommand: ",d),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",i),e.onCopy&&e.onCopy(window.clipboardData),u=!0}catch(m){t&&console.error("unable to copy using clipboardData: ",m),t&&console.error("falling back to prompt"),n=zn("message"in e?e.message:Vn),window.prompt(n,i)}}finally{s&&(typeof s.removeRange=="function"?s.removeRange(r):s.removeAllRanges()),a&&document.body.removeChild(a),l()}return u}var me=In;/*! medium-zoom 1.0.8 | MIT License | https://github.com/francoischalifour/medium-zoom */var le=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},ve=function(e){return e.tagName==="IMG"},An=function(e){return NodeList.prototype.isPrototypeOf(e)},$e=function(e){return e&&e.nodeType===1},$t=function(e){var t=e.currentSrc||e.src;return t.substr(-4).toLowerCase()===".svg"},Ct=function(e){try{return Array.isArray(e)?e.filter(ve):An(e)?[].slice.call(e).filter(ve):$e(e)?[e].filter(ve):typeof e=="string"?[].slice.call(document.querySelectorAll(e)).filter(ve):[]}catch{throw new TypeError(`The provided selector is invalid.
|
||
|
Expects a CSS selector, a Node element, a NodeList or an array.
|
||
|
See: https://github.com/francoischalifour/medium-zoom`)}},Fn=function(e){var t=document.createElement("div");return t.classList.add("medium-zoom-overlay"),t.style.background=e,t},Ln=function(e){var t=e.getBoundingClientRect(),n=t.top,l=t.left,r=t.width,s=t.height,a=e.cloneNode(),u=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,h=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return a.removeAttribute("id"),a.style.position="absolute",a.style.top=n+u+"px",a.style.left=l+h+"px",a.style.width=r+"px",a.style.height=s+"px",a.style.transform="",a},se=function(e,t){var n=le({bubbles:!1,cancelable:!1,detail:void 0},t);if(typeof window.CustomEvent=="function")return new CustomEvent(e,n);var l=document.createEvent("CustomEvent");return l.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),l},_n=function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=window.Promise||function(N){function w(){}N(w,w)},l=function(N){var w=N.target;if(w===M){v();return}E.indexOf(w)!==-1&&x({target:w})},r=function(){if(!(L||!g.original)){var N=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(_-N)>I.scrollOffset&&setTimeout(v,150)}},s=function(N){var w=N.key||N.keyCode;(w==="Escape"||w==="Esc"||w===27)&&v()},a=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=N;if(N.background&&(M.style.background=N.background),N.container&&N.container instanceof Object&&(w.container=le({},I.container,N.container)),N.template){var $=$e(N.template)?N.template:document.querySelector(N.template);w.template=$}return I=le({},I,w),E.forEach(function(F){F.dispatchEvent(se("medium-zoom:update",{detail:{zoom:D}}))}),D},u=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return i(le({},I,N))},h=function(){for(var N=arguments.length,w=Array(N),$=0;$<N;$++)w[$]=arguments[$];var F=w.reduce(function(A,R){return[].concat(A,Ct(R))},[]);return F.filter(function(A){return E.indexOf(A)===-1}).forEach(function(A){E.push(A),A.classList.add("medium-zoom-image")}),z.forEach(function(A){var R=A.type,K=A.listener,ne=A.options;F.forEach(function(Q){Q.addEventListener(R,K,ne)})}),D},d=function(){for(var N=arguments.length,w=Array(N),$=0;$<N;$++)w[$]=arguments[$];g.zoomed&&v();var F=w.length>0?w.reduce(function(A,R){return[].concat(A,Ct(R))},[]):E;return F.forEach(function(A){A.classList.remove("medium-zoom-image"),A.dispatchEvent(se("medium-zoom:detach",{detail:{zoom:D}}))}),E=E.filter(function(A){return F.indexOf(A)===-1}),D},m=function(N,w){var $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return E.forEach(function(F){F.addEventListener("medium-zoom:"+N,w,$)}),z.push({type:"medium-zoom:"+N,listener:w,options:$}),D},p=function(N,w){var $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return E.forEach(function(F){F.removeEventListener("medium-zoom:"+N,w,$)}),z=z.filter(function(F){return!(F.type==="medium-zoom:"+N&&F.listener.toString()===w.toString())}),D},f=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=N.target,$=function(){var A={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},R=void 0,K=void 0;if(I.container)if(I.container instanceof Object)A=le({},A,I.container),R=A.width-A.left-A.right-I.margin*2,K=A.height-A.top-A.bottom-I.margin*2;else{var ne=$e(I.container)?I.container:document.querySelector(I.container),Q=ne.getBoundingClientRect(),ce=Q.width,Ee=Q.height,Se=Q.left,Ne=Q.top;A=le({},A,{width:ce,height:Ee,left:Se,top:Ne})}R=R||A.width-I.margin*2,K=K||A.height-I.margin*2;var ie=g.zoomedHd||g.original,Te=$t(ie)?R:ie.naturalWidth||R,Ve=$t(ie)?K:ie.naturalHeight||K,oe=ie.getBoundingClientRect(),ze=oe.top,Ie=oe.left,de=oe.width,ue=oe.height,Ae=Math.min(Math.max(de,Te),R)/de,Fe=Math.min(Math.max(ue,Ve),K)/ue,he=Math.min(Ae,Fe),Le=(-Ie+(R-de)/2+I.margin+A.left)/he,_e=(-ze+(K-ue)/2+I.margin+A.top)/he,ge="scale("+he+") translate3d("+Le+"px, "+_e+"px, 0)";g.zoomed.style.transform=ge,g.zo
|
||
|
`),r=t.substring(0,l+1),s=n.indexOf(`
|
||
|
`),a=n.substring(s===-1?n.length:s,n.length),u=t.substring(l+1,t.length),h=n.substring(0,s);return{prefixStr:t,subfixStr:n,prefixStrEndRow:r,subfixStrEndRow:a,prefixSupply:u,subfixSupply:h}},Hn=(i,e="",t,n)=>{var m,p,f,v,x,S;let l="",r=0,s=0,a=!1,u,h;const d=(m=B.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(i)){const k=i.replace(/^h(\d)/,(y,E)=>new Array(Number(E)).fill("#",0,E).join(""));l=`${k} ${e}`,r=k.length+1}else if(i==="prettier"){const k=window.prettier||((f=(p=B.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.prettierInstance),y=[((v=window.prettierPlugins)==null?void 0:v.markdown)||((S=(x=B.editorExtensions)==null?void 0:x.prettier)==null?void 0:S.parserMarkdownInstance)];return!k||y[0]===void 0?(b.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),t.value):k.format(t.value,{parser:"markdown",plugins:y})}else switch(i){case"bold":{l=`**${e}**`,r=2,s=-2;break}case"underline":{l=`<u>${e}</u>`,r=3,s=-4;break}case"italic":{l=`*${e}*`,r=1,s=-1;break}case"strikeThrough":{l=`~${e}~`,r=1,s=-1;break}case"sub":{l=`<sub>${e}</sub>`,r=5,s=-6;break}case"sup":{l=`<sup>${e}</sup>`,r=5,s=-6;break}case"codeRow":{l="`"+e+"`",r=1,s=-1;break}case"quote":{l=`> ${e}`,r=2;break}case"orderedList":{l=`1. ${e}`,r=3;break}case"unorderedList":{l=`- ${e}`,r=2;break}case"task":{l=`- [ ] ${e}`,r=6,a=!0;break}case"code":{const k=n.text||e||"",y=n.mode||"language";l=`\`\`\`${y}
|
||
|
${k}
|
||
|
\`\`\`
|
||
|
`,r=3,s=3+y.length-l.length,a=!0;break}case"table":{l="|";const{selectedShape:k={x:1,y:1}}=n,{x:y,y:E}=k;for(let z=0;z<=E;z++)l+=" col |";l+=`
|
||
|
|`;for(let z=0;z<=E;z++)l+=" - |";for(let z=0;z<=y;z++){l+=`
|
||
|
|`;for(let L=0;L<=E;L++)l+=" content |"}r=2,s=5-l.length,a=!0;break}case"link":{const{desc:k,url:y}=n;l=`[${k}](${y})`;break}case"image":{const{desc:k,url:y,urls:E}=n;E instanceof Array?l=E.reduce((z,L)=>z+`![${k}](${L})
|
||
|
`,""):l=`![${k}](${y})
|
||
|
`;break}case"tab":{const{tabWidth:k=2}=n,y=new Array(k).fill(" ").join("");if(e==="")l=y;else if(/\n/.test(e)){const{prefixStr:E,subfixStr:z,prefixSupply:L,subfixSupply:_}=pe(t);l=`${L}${e}${_}`.split(`
|
||
|
`).map(M=>`${y}${M}`).join(`
|
||
|
`),u=E.substring(0,E.length-L.length),h=z.substring(_.length,z.length),a=!0,r=k,s=-L.length-_.length}else{const z=t.value.substring(0,t.selectionStart);/\n$/.test(z)||z===""?(l=`${y}${e}`,a=!0):l=y}break}case"shiftTab":{const{tabWidth:k=2}=n,{prefixStr:y,prefixStrEndRow:E,subfixStrEndRow:z,prefixSupply:L,subfixSupply:_}=pe(t),I=new RegExp(`^\\s{${k}}`),g=(M=!1,D=!1)=>{const j=`${L}${e}${_}`;if(I.test(j)){const N=y.length-(D?0:k),w=M?N+e.length-k:N;return J(t,N,w),`${E}${j.replace(I,"")}${z}`}else if(/^\s/.test(j)){const N=j.replace(/^\s/,""),w=j.length-N.length,$=t.selectionStart-(D?0:w),F=M?$+e.length-w:$;return J(t,$,F),`${E}${N}${z}`}else l=e};if(e===""){const M=g();if(M)return M}else if(/\n/.test(e)){const D=`${L}${e}${_}`.split(`
|
||
|
`);let[j,N]=[0,0];const w=D.map(($,F)=>{if(I.test($))return F===0&&(j=k),N+=k,$.replace(I,"");if(/^\s/.test($)){const A=$.replace(/^\s/,"");return N+=$.length-A.length,A}return $}).join(`
|
||
|
`);return J(t,t.selectionStart-j,t.selectionEnd-N),`${E}${w}${z}`}else{const M=g(!0,!0);if(M)return M}break}case"ctrlC":{const{prefixSupply:k,subfixSupply:y}=pe(t);return me(e===""?`${k}${y}`:e),t.value}case"ctrlX":{const{prefixStrEndRow:k,subfixStrEndRow:y,prefixStr:E,subfixStr:z,prefixSupply:L,subfixSupply:_}=pe(t);return e===""?(me(`${L}${_}`),J(t,k.length),`${k}${y.replace(/^\n/,"")}`):(me(e),J(t,E.length),`${E}${z}`)}case"ctrlD":{const{prefixStrEndRow:k,subfixStrEndRow:y}=pe(t);return J(t,k.length),`${k}${y.replace(/^\n/,"")}`}case"flow":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.flow)||`flowchart TD
|
||
|
Start --> Stop`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"sequence":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.sequence)||`sequenceDiagram
|
||
|
A->>B: hello!
|
||
|
B-->>A: hi!
|
||
|
A-)B: bye!`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"gantt":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.gantt)||`gantt
|
||
|
title A Gantt Diagram
|
||
|
dateFormat YYYY-MM-DD
|
||
|
section Section
|
||
|
A task :a1, 2014-01-01, 30d
|
||
|
Another task :after a1, 20d`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"class":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.class)||`classDiagram
|
||
|
class Animal
|
||
|
Vehicle <|-- Car`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"state":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.state)||`stateDiagram-v2
|
||
|
s1 --> s2`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"pie":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.pie)||`pie title Pets adopted by volunteers
|
||
|
"Dogs" : 386
|
||
|
"Cats" : 85
|
||
|
"Rats" : 15`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"relationship":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.relationship)||`erDiagram
|
||
|
CAR ||--o{ NAMED-DRIVER : allows
|
||
|
PERSON ||--o{ NAMED-DRIVER : is`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"journey":{l=`\`\`\`mermaid
|
||
|
${(d==null?void 0:d.journey)||`journey
|
||
|
title My working day
|
||
|
section Go to work
|
||
|
Make tea: 5: Me
|
||
|
Go upstairs: 3: Me
|
||
|
Do work: 1: Me, Cat
|
||
|
section Go home
|
||
|
Go downstairs: 5: Me
|
||
|
Sit down: 5: Me`}
|
||
|
\`\`\`
|
||
|
`,r=2;break}case"katexInline":{l="$$",r=1,s=-1;break}case"katexBlock":{l=`$$
|
||
|
|
||
|
$$
|
||
|
`,r=1,s=-4;break}case"universal":{const{generate:k}=n,y=k(e);l=y.targetValue,a=y.select,r=y.deviationStart,s=y.deviationEnd}}return Re(t,l,{deviationStart:r,deviationEnd:s,select:a,prefixVal:u,subfixVal:h})};var Et={block(i,e){return{name:"KaTexBlockExtension",level:"block",start:t=>{var n;return(n=t.match(/\n\$\$\n/))==null?void 0:n.index},tokenizer(t){if(/^\$\$\n/.test(t)&&t.split("$$").length>2){const n=et(t,"$$");return{type:"KaTexBlockExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window!="undefined"&&window.katex;if(n){const l=n.renderToString(t.text,{throwOnError:!1,displayMode:!0});return`<p class="${i}-katex-block" data-processed>${l}</p>`}else return`<p class="${i}-katex-block">${t.text}</p>`}}},inline(i,e){return{name:"KaTexInlineExtension",level:"inline",start:t=>{var n;return(n=t.match(/\$[^\n]*/))==null?void 0:n.index},tokenizer(t){if(/^\$[^\n]*\$/.test(t)){const n=et(t);return{type:"KaTexInlineExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window!="undefined"&&window.katex;if(n){const l=n.renderToString(t.text,{throwOnError:!1});return`<span class="${i}-katex-inline" data-processed>${l}</span>`}else return`<span class="${i}-katex-inline">${t.text}</span>`}}}};const St=["abstract","attention","bug","caution","danger","error","example","failure","hint","info","note","question","quote","success","tip","warning"],Oe=new RegExp(`^!!!\\s+(${St.join("|")})\\s+(.*)$`),Pn=/^!!!\s*$/,On={name:"alert",level:"block",start(i){var t;return(t=i.match(new RegExp(`(^|[\\r\\n])!!!\\s+(${St.join("|")})\\s+(.*)`)))==null?void 0:t.index},tokenizer(i){const e=i.split(/\n/);if(Oe.test(e[0])){const t={x:-1,y:-1},n=[];for(let l=0,r=e.length;l<r;l++)Oe.test(e[l])?t.x=l:Pn.test(e[l])&&(t.y=l,t.x>=0&&(n.push(q({},t)),t.x=-1,t.y=-1));if(n.length){const l=n[0],[r,s,a]=Oe.exec(e[l.x])||[],u=e.slice(l.x+1,l.y).join(`
|
||
|
`),h=e.slice(l.x,l.y+1).join(`
|
||
|
`),d={type:"alert",raw:h,icon:s,title:a,text:u,titleTokens:[],tokens:[],childTokens:["title","text"]};return this.lexer.inlineTokens(d.title,d.titleTokens),this.lexer.blockTokens(d.text,d.tokens),d}}},renderer(i){return`<div class="md-editor-alert md-editor-alert-${i.icon}">
|
||
|
<p class="md-editor-alert-title">${this.parser.parseInline(i.titleTokens,null)}</p>
|
||
|
${this.parser.parse(i.tokens)}
|
||
|
</div>`}},Mn=(i,e,t)=>{var f,v;const n=o.inject("previewOnly"),l=o.inject("historyLength"),r=o.inject("editorId");if(n)return;let s=-1;const a={list:[{content:i.value,startPos:((f=e.value)==null?void 0:f.selectionStart)||0,endPos:((v=e.value)==null?void 0:v.selectionEnd)||0}],userUpdated:!0,curr:0},u=[0,0];let h=u;const d=x=>{var E,z;const S=((E=e.value)==null?void 0:E.selectionStart)||0,k=((z=e.value)==null?void 0:z.selectionEnd)||0;a.list[a.curr].startPos=S,a.list[a.curr].endPos=k,a.userUpdated=!1,a.curr=x;const y=a.list[a.curr];h=[y.startPos,y.endPos],i.onChange(y.content),J(e.value,y.startPos,y.endPos).then(()=>{b.emit(r,"selectTextChange")})},m=x=>{var y,E;clearTimeout(s);const S=((y=e.value)==null?void 0:y.selectionStart)||0,k=((E=e.value)==null?void 0:E.selectionEnd)||0;s=setTimeout(()=>{if(a.userUpdated){a.curr<a.list.length-1&&(a.list=a.list.slice(0,a.curr+1)),a.list.length>l&&a.list.shift();const z=a.list.pop()||{startPos:0,endPos:0,content:x};z.startPos=h[0],z.endPos=h[1],h=u,Array.prototype.push.call(a.list,z,{content:x,startPos:S,endPos:k}),a.curr=a.list.length-1}else a.userUpdated=!0},150)},p=x=>{var S,k;(h===u||x)&&(h=[(S=e.value)==null?void 0:S.selectionStart,(k=e.value)==null?void 0:k.selectionEnd])};o.watch([o.toRef(i,"value"),t],()=>{t.value&&m(i.value)}),o.watch(()=>i.value,()=>{b.emit(r,"selectTextChange")},{flush:"post"}),o.onMounted(()=>{b.on(r,{name:"ctrlZ",callback(){d(a.curr-1<0?0:a.curr-1)}}),b.on(r,{name:"ctrlShiftZ",callback(){d(a.curr+1===a.list.length?a.curr:a.curr+1)}}),b.on(r,{name:"saveHistoryPos",callback:p})})},Bn=(i,e)=>{var D,j,N;const{markedRenderer:t,markedExtensions:n,markedOptions:l,editorExtensions:r,editorConfig:s}=B,a=o.inject("showCodeRowNumber"),u=o.inject("editorId"),h=o.inject("highlight"),d=o.inject("previewOnly"),m=(D=r==null?void 0:r.highlight)==null?void 0:D.instance,p=(j=r==null?void 0:r.mermaid)==null?void 0:j.instance,f=(N=r==null?void 0:r.katex)==null?void 0:N.instance,v=r==null?void 0:r.katex,x=o.ref(!1),S=o.ref(!1),k=o.ref([]);let y=new V.Renderer;V.use({extensions:[On]});const E=y.code;y.code=(w,$,F)=>{if(!i.noMermaid&&$==="mermaid"){const A=`${c}-mermaid-${Date.now().toString(36)}`;try{let R;return p?R=p.render(A,w):typeof window!="undefined"&&window.mermaid?R=window.mermaid.render(A,w):R=`<p class="${c}-mermaid-loading">${w}</p>`,`<p class="${c}-mermaid">${R}</p>`}catch(R){return`<p class="${c}-mermaid-error">Error: ${(R==null?void 0:R.message)||""}</p>`}}return E.call(y,w,$,F)},y.image=(w,$,F)=>`<span class="figure"><img src="${w}" title="${$||""}" alt="${F||""}" zoom><span class="figcaption">${F||""}</span></span>`,y.listitem=(w,$)=>$?`<li class="li-task">${w}</li>`:`<li>${w}</li>`;const z=y.heading;t instanceof Function&&(y=t(y));const L=y.heading,_=z!==L;y.heading=(w,$,F,A)=>{if(k.value.push({text:F,level:$}),_)return L.call(y,w,$,F,A,k.value.length);const R=i.markedHeadingId(F,$,k.value.length);return w!==F?`<h${$} id="${R}">${w}</h${$}>`:`<h${$} id="${R}"><a href="#${R}">${F}</a></h${$}>`},V.setOptions(q({breaks:!0},l)),i.noKatex||V.use({extensions:[Et.inline(c,f),Et.block(c,f)]}),m&&V.setOptions({highlight:(w,$)=>{let F;const A=m.getLanguage($);return $&&A?F=m.highlight(w,{language:$,ignoreIllegals:!0}).value:F=m.highlightAuto(w).value,a?Je(F):`<span class="code-block">${F}</span>`}}),n instanceof Array&&n.length>0&&V.use({extensions:n});const I=o.ref(i.sanitize(V(i.value||"",{renderer:y}))),g=ke(()=>{k.value=[];const w=i.sanitize(V(i.value||"",{renderer:y}));I.value=w,b.emit(u,"buildFinished",w),i.onHtmlChanged(w)},(s==null?void 0:s.renderDelay)!==void 0?s==null?void 0:s.renderDelay:d?0:500);o.watch([x,o.toRef(e,"reRender"),o.toRef(e,"mermaidInited"),S,o.toRef(i,"value")],g);const M=()=>{V.setOptions({highlight:(w,$)=>{let F;const A=window.hljs.getLanguage($);return $&&A?F=window.hljs.highlight(w,{language:$,ignoreIllegals:!0}).value:F=window.hljs.highlightAuto(w).value,a?Je(F):`<span class="code-block">${F}</span>`}}),x.value=!0};return o.watch(()=>k.value,w=>{i.onGetCatalog(w),b.emit(u,"catalogChanged",w)}),o.onMounted(()=>{if(!i.noKatex&&!f){c
|
||
|
`),x=p==null?void 0:p.substring(v+1,m);if(/^\d+\.\s|^-\s/.test(x))if(a.cancelBubble=!0,a.preventDefault(),a.stopPropagation(),/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(x)){const S=p==null?void 0:p.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/,"");i.onChange(S+f),J(e.value,S==null?void 0:S.length)}else if(/^-\s+.+/.test(x)){const S=/^-\s+\[[x\s]\]/.test(x)?`
|
||
|
- [ ] `:`
|
||
|
- `;i.onChange(Re(e.value,S,{}))}else{const S=x==null?void 0:x.match(/\d+(?=\.)/),k=S&&Number(S[0])+1||1,y=/^\d\.\s+\[[x\s]\]/.test(x)?`
|
||
|
${k}. [ ] `:`
|
||
|
${k}. `;i.onChange(Re(e.value,y,{}))}}}),b.on(l,{name:"replace",callback(a,u={}){i.onChange(Hn(a,r.value,e.value,fe(q({},u),{tabWidth:n,editorId:l})))}}))}),o.watch(()=>i.value,()=>{r.value=""}),b.on(l,{name:"selectTextChange",callback(){r.value=Ot(e.value)}})},Kn=i=>{const e=o.inject("theme"),{editorExtensions:t}=B,n=t==null?void 0:t.mermaid,l=o.reactive({reRender:!1,mermaidInited:!!(n!=null&&n.instance)}),r=()=>{i.noMermaid||(n!=null&&n.instance?n.instance.initialize({theme:e.value==="dark"?"dark":"default"}):window.mermaid&&window.mermaid.initialize({theme:e.value==="dark"?"dark":"default"}),l.reRender=!l.reRender)};o.watch(()=>e.value,r);let s;return o.onMounted(()=>{!i.noMermaid&&!(n!=null&&n.instance)?(s=document.createElement("script"),s.src=(n==null?void 0:n.js)||_t,s.onload=()=>{window.mermaid.initialize({theme:e.value==="dark"?"dark":"default",logLevel:"Fatal"}),l.mermaidInited=!0},s.id=`${c}-mermaid`,G(s,"mermaid")):i.noMermaid||r()}),l},Zn=(i,e)=>{const t=o.inject("editorId"),n=o.inject("previewOnly"),l=r=>{if(!!r.clipboardData){if(r.clipboardData.files.length>0){const{files:s}=r.clipboardData;b.emit(t,"uploadImage",Array.from(s).filter(a=>/image\/.*/.test(a.type))),r.preventDefault()}if(i.autoDetectCode&&r.clipboardData.types.includes("vscode-editor-data")){const s=JSON.parse(r.clipboardData.getData("vscode-editor-data"));b.emit(t,"replace","code",{mode:s.mode,text:r.clipboardData.getData("text/plain")}),r.preventDefault()}}};o.onMounted(()=>{n||e.value.addEventListener("paste",l)}),o.onBeforeUnmount(()=>{n||e.value.removeEventListener("paste",l)})},Gn=(i,e)=>{const t=o.inject("editorId"),n=ke(()=>{const l=document.querySelectorAll(`#${t}-preview img[zoom]`);l.length!==0&&Dn(l,{background:"#00000073"})});o.onMounted(n),o.watch([e,o.toRef(i.setting,"preview")],n)},Wn=i=>{const e=o.inject("editorId");b.on(e,{name:st,callback(){var t;(t=i.value)==null||t.focus()}})},Xn=()=>({value:{type:String,default:""},onChange:{type:Function,default:()=>()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>()=>{}},onGetCatalog:{type:Function,default:()=>()=>{}},markedHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:i=>i},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:i=>i},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean}});var Qn=o.defineComponent({name:"MDEditorContent",props:Xn(),setup(i){const e=o.ref(!0),t=o.inject("previewOnly"),n=o.inject("showCodeRowNumber"),l=o.inject("previewTheme"),r=o.inject("editorId"),s=o.ref(),a=o.ref(),u=o.ref(),h=Kn(i),{html:d}=Bn(i,h);return Un(i,d,s,a,u),qn(i,s),Mn(i,s,e),Zn(i,s),Gn(i,d),Wn(s),()=>{const m=Bt(i,["formatCopiedText","markedHeadingId","noKatex","noMermaid","onChange","onGetCatalog","onHtmlChanged","sanitize","scrollAuto","setting","autoDetectCode"]);return o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${c}-content`},[!t&&o.createVNode("div",{class:`${c}-input-wrapper`},[o.createVNode("textarea",o.mergeProps(m,{id:`${r}-textarea`,ref:s,onBlur:()=>{b.emit(r,"selectTextChange")},onKeydown:()=>{b.emit(r,"saveHistoryPos",!0)},onCompositionstart:()=>{e.value=!1},onInput:p=>{i.onChange(p.target.value)},onCompositionend:()=>{e.value=!0},class:[i.setting.preview||i.setting.htmlPreview?"":"textarea-only"]}),null)]),i.setting.preview&&o.createVNode("div",{id:`${r}-preview-wrapper`,class:`${c}-preview-wrapper`,ref:a,key:"content-preview-wrapper"},[o.createVNode("article",{id:`${r}-preview`,class:[`${c}-preview`,`${l==null?void 0:l.value}-theme`,n&&`${c}-scrn`],innerHTML:d.value},null)]),i.setting.htmlPreview&&o.createVNode("div",{class:`${c}-preview-wrapper`,ref:u,key:"html-preview-wrapper"},[o.createVNode("div",{class:`${c}-html`},[d.value])])])])}}}),Yn=o.defineComponent({props:{modelValue:{type:String,default:""}},setup(i){const e=o.inject("usedLanguageText");return()=>{var t,n;return o.createVNode("div",{class:`$
|