1Panel/node_modules/md-editor-v3/lib/md-editor-v3.umd.js
ssongliu e7af9de9ed feat: 增加从快照恢复功能
feat: 增加升级备份与恢复
2023-01-30 21:11:12 +08:00

126 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",h3:"Lv3 Heading",h4:"Lv4 Heading",h5:"Lv5 Heading",h6:"Lv6 Heading"},imgTitleItem:{link:"Add Img Link",upload:"Upload Img",clip2upload:"Clip Upload"},linkModalTips:{linkTitle:"Add Link",imageTitle:"Add Image",descLabel:"Desc:",descLabelPlaceHolder:"Enter a description...",urlLabel:"Link:",urlLabelPlaceHolder:"Enter a link...",buttonOK:"OK"},clipModalTips:{title:"Crop Image",buttonUpload:"Upload"},copyCode:{text:"Copy",successTips:"Copied!",failTips:"Copy failed!"},mermaid:{flow:"flow",sequence:"sequence",gantt:"gantt",class:"class",state:"state",pie:"pie",relationship:"relationship",journey:"journey"},katex:{inline:"inline",block:"block"},footer:{markdownTotal:"Word Count",scrollAuto:"Scroll Auto"}}},_t=`${O}/mermaid/9.3.0/mermaid.min.js`,Xe={js:`${O}/KaTeX/0.16.3/katex.min.js`,css:`${O}/KaTeX/0.16.3/katex.min.css`},Qe={a11y:{light:`${O}/highlight.js/11.7.0/styles/a11y-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/a11y-dark.min.css`},atom:{light:`${O}/highlight.js/11.7.0/styles/atom-one-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/atom-one-dark.min.css`},github:{light:`${O}/highlight.js/11.7.0/styles/github.min.css`,dark:`${O}/highlight.js/11.7.0/styles/github-dark.min.css`},gradient:{light:`${O}/highlight.js/11.7.0/styles/gradient-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/gradient-dark.min.css`},kimbie:{light:`${O}/highlight.js/11.7.0/styles/kimbie-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/kimbie-dark.min.css`},paraiso:{light:`${O}/highlight.js/11.7.0/styles/paraiso-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${O}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${O}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,dark:`${O}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`}},B={markedRenderer:i=>i,markedExtensions:[],markedOptions:{},editorExtensions:{},editorConfig:{}},Rt=i=>{if(i)for(const e in i){const t=i[e];t&&(B[e]=t)}};class jt{constructor(){this.pools={}}remove(e,t,n){const r=this.pools[e]&&this.pools[e][t];r&&(this.pools[e][t]=r.filter(s=>s!==n))}clear(e){this.pools[e]={}}on(e,t){return this.pools[e]||(this.pools[e]={}),this.pools[e][t.name]||(this.pools[e][t.name]=[]),this.pools[e][t.name].push(t.callback),this.pools[e][t.name].includes(t.callback)}emit(e,t,...n){this.pools[e]||(this.pools[e]={});const r=this.pools[e][t];r&&r.forEach(s=>{try{s(...n)}catch(a){console.error(`${t} monitor event exception\uFF01`,a)}})}}var b=new jt;const J=(i,e=0,t=e)=>new Promise((n,l)=>{i.setSelectionRange?setTimeout(()=>{i.setSelectionRange(e,t),i.focus(),n(!0)},0):(console.error("Can not reset position!"),l())}),Re=(i,e,t)=>{const{deviationStart:n=0,deviationEnd:l=0,direct:r=!1,select:s=!1}=t;let a="";if(i.selectionStart||i.selectionStart===0){const u=i.selectionStart,h=i.selectionEnd||0,{prefixVal:d=i.value.substring(0,u),subfixVal:m=i.value.substring(h,i.value.length)}=t;a=d+e+m,J(i,s?u+n:u+e.length+l,u+e.length+l)}else a+=e;return r&&(i.value=a),a},Dt=(i,e={newWindow:!0,nofollow:!0})=>{i||console.error("error link!");const t=document.createElement("a");t.href=i,t.style.display="none",e.newWindow&&(t.target="_blank"),e.nofollow&&(t.rel="noopener noreferrer"),document.body.appendChild(t),t.click(),document.body.removeChild(t)},Ye=(i,e)=>{const t=ke(()=>{i.removeEventListener("scroll",n),i.addEventListener("scroll",n),e.removeEventListener("scroll",n),e.addEventListener("scroll",n)},50),n=l=>{const r=i.clientHeight,s=e.clientHeight,a=i.scrollHeight,u=e.scrollHeight,h=(a-r)/(u-s);l.target===i?(e.removeEventListener("scroll",n),e.scrollTo({top:i.scrollTop/h}),t()):(i.removeEventListener("scroll",n),i.scrollTo({top:e.scrollTop*h}),t())};return[t,()=>{i.removeEventListener("scroll",n),e.removeEventListener("scroll",n)}]},Ht=(i,e="image.png")=>{const t=i.split(","),n=t[0].match(/:(.*?);/);if(n){const l=n[1],r=atob(t[1]);let s=r.length;const a=new Uint8Array(s);for(;s--;)a[s]=r.charCodeAt(s);return new File([a],e,{type:l})}return null},Je=i=>{if(!i.trim())return i;const e=i.split(`
`),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,"ctrlZ"),a.preventDefault());break}case"KeyW":if(a.key==="z"){a.shiftKey?(b.emit(t,"ctrlShiftZ"),a.preventDefault()):(b.emit(t,"ctrlZ"),a.preventDefault());break}else return;case"KeyF":{a.shiftKey&&(n||(b.emit(t,"replace","prettier"),a.preventDefault()));break}case"KeyT":{a.altKey&&a.shiftKey&&(b.emit(t,"replace","table"),a.preventDefault());break}case"KeyX":{b.emit(t,"replace","ctrlX"),a.preventDefault();break}case"KeyD":{a.preventDefault(),b.emit(t,"replace","ctrlD");break}}else a.code==="Tab"&&(a.preventDefault(),a.shiftKey?b.emit(t,"replace","shiftTab"):b.emit(t,"replace","tab"))};o.watch(()=>i.modelValue,()=>{r.buildFinished=!1}),o.onMounted(()=>{l||(window.addEventListener("keydown",s),b.on(t,{name:"buildFinished",callback(a){r.buildFinished=!0,r.html=a}}),b.on(t,{name:be,callback(){const a=new Promise(u=>{if(r.buildFinished)u(r.html);else{const h=d=>{u(d),b.remove(t,"buildFinished",h)};b.on(t,{name:"buildFinished",callback:h})}});i.onSave?i.onSave(i.modelValue,a):e.emit("onSave",i.modelValue,a)}}))}),o.onBeforeUnmount(()=>{l||window.removeEventListener("keydown",s)})},Kt=i=>{var r;const{editorId:e,previewOnly:t}=i,n=(r=B==null?void 0:B.editorExtensions)==null?void 0:r.highlight;o.provide("editorId",e),o.provide("tabWidth",i.tabWidth),o.provide("theme",o.computed(()=>i.theme)),o.provide("highlight",o.computed(()=>{const s=q(q({},Qe),n==null?void 0:n.css),a=i.codeStyleReverse&&i.codeStyleReverseList.includes(i.previewTheme)?"dark":i.theme;return{js:(n==null?void 0:n.js)||Ft,css:s[i.codeTheme]?s[i.codeTheme][a]:Qe.atom[a]}})),o.provide("historyLength",i.historyLength),o.provide("previewOnly",t),o.provide("showCodeRowNumber",i.showCodeRowNumber);const l=o.computed(()=>{var a;const s=q(q({},We),(a=B==null?void 0:B.editorConfig)==null?void 0:a.languageUserDefined);return s[i.language]?s[i.language]:We["zh-CN"]});o.provide("usedLanguageText",l),o.provide("previewTheme",o.computed(()=>i.previewTheme))},Zt=i=>{var h,d,m,p,f,v;const{noPrettier:e,previewOnly:t,noIconfont:n,noUploadImg:l}=i,{editorExtensions:r}=B,s=e||!!((d=(h=B.editorExtensions)==null?void 0:h.prettier)!=null&&d.prettierInstance),a=e||!!((p=(m=B.editorExtensions)==null?void 0:m.prettier)!=null&&p.parserMarkdownInstance),u=l||!!((v=(f=B.editorExtensions)==null?void 0:f.cropper)!=null&&v.instance);o.onMounted(()=>{var z,L,_,I;const x=document.createElement("script");x.src=(r==null?void 0:r.iconfont)||At,x.id=`${c}-icon`;const S=document.createElement("script"),k=document.createElement("script");S.src=((z=r==null?void 0:r.prettier)==null?void 0:z.standaloneJs)||qe.main,S.id=`${c}-prettier`,k.src=((L=r==null?void 0:r.prettier)==null?void 0:L.parserMarkdownJs)||qe.markdown,k.id=`${c}-prettierMD`;const y=document.createElement("link");y.rel="stylesheet",y.href=((_=r==null?void 0:r.cropper)==null?void 0:_.css)||Ke.css,y.id=`${c}-cropperCss`;const E=document.createElement("script");E.src=((I=r==null?void 0:r.cropper)==null?void 0:I.js)||Ke.js,E.id=`${c}-cropper`,t||(n||G(x),u||(G(y),G(E)),s||G(S),a||G(k))})},Gt=(i,e)=>{const{editorId:t,previewOnly:n}=i,l=o.reactive({pageFullscreen:i.pageFullscreen,fullscreen:!1,preview:i.preview,htmlPreview:i.preview?!1:i.htmlPreview}),r=(u,h)=>{l[u]=h===void 0?!l[u]:h,u==="preview"&&l.preview?l.htmlPreview=!1:u==="htmlPreview"&&l.htmlPreview&&(l.preview=!1)};let s="";const a=()=>{l.pageFullscreen||l.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=s};return o.watch(()=>[l.pageFullscreen,l.fullscreen],a),o.onMounted(()=>{n||b.on(t,{name:"uploadImage",callback(u,h){const d=m=>{b.emit(t,"replace","image",{desc:"",urls:m}),h&&h()};i.onUploadImg?i.onUploadImg(u,d):e.emit("onUploadImg",u,d)}}),s=document.body.style.overflow,a()}),[l,r]},Wt=i=>{const{editorId:e}=i,t=o.ref(!1);o.onMounted(()=>{b.on(e,{name:je,callback:l=>{l===void 0?t.value=!t.value:t.value=l}})});const n=o.computed(()=>!i.toolbarsExclude.includes("catalog")&&i.toolbars.includes("catalog"));return[t,n]},Xt=(i,e,t,n,l)=>{const{editorId:r}=i;o.watch(()=>n.pageFullscreen,a=>{b.emit(r,it,a)}),o.watch(()=>n.fullscreen,a=>{b.emit(r,lt,a)}),o.watch(()=>n.preview,a=>{b.emit(r,ot,a)}),o.watch(()=>n.htmlPreview,a=>{b.emit(r,rt,a)}),o.watch(t,a=>{b.emit(r,at,a)});const s={on(a,u){switch(a){case"pageFullscreen":{b.on(r,{name:it,callback(h){u(h)}});break}case"fullscreen":{b.on(r,{name:lt,callback(h){u(h)}});break}case"preview":{b.on(r,{name:ot,callback(h){u(h)}});break}case"htmlPreview":{b.on(r,{name:rt,callback(h){u(h)}});break}case"catalog":{b.on(r,{name:at,callback(h){u(h)}});break}}},togglePageFullscreen(a){l("pageFullscreen",a)},toggleFullscreen(a){b.emit(r,nt,a)},togglePreview(a){l("preview",a)},toggleHtmlPreview(a){l("htmlPreview",a)},toggleCatalog(a){b.emit(r,je,a)},triggerSave(){b.emit(r,be)},insert(a){b.emit(r,"replace","universal",{generate:a})},focus(){b.emit(r,st)}};e.expose(s)};var bi="",Qt=o.defineComponent({setup(){return()=>o.createVNode("div",{class:`${c}-divider`},null)}});const W=({instance:i,ctx:e,props:t={}},n="default")=>{const l=(i==null?void 0:i.$slots[n])||(e==null?void 0:e.slots[n]);return(l?l(i):"")||t[n]};var yi="";const Yt=()=>({trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}},relative:{type:String,default:"html"}});var re=o.defineComponent({props:Yt(),setup(i,e){const t=`${c}-dropdown-hidden`,n=o.reactive({overlayClass:[t],overlayStyle:{},triggerHover:!1,overlayHover:!1}),l=o.ref(),r=o.ref(),s=()=>{var E;i.trigger==="hover"&&(n.triggerHover=!0);const m=l.value,p=r.value,f=m.getBoundingClientRect(),v=m.offsetTop,x=m.offsetLeft,S=f.height,k=f.width,y=((E=document.querySelector(i.relative))==null?void 0:E.scrollLeft)||0;n.overlayStyle=fe(q({},n.overlayStyle),{top:v+S+"px",left:x-p.offsetWidth/2+k/2-y+"px"}),i.onChange(!0)},a=()=>{n.overlayHover=!0};o.watch(()=>i.visible,m=>{m?n.overlayClass=n.overlayClass.filter(p=>p!==t):n.overlayClass.push(t)});const u=m=>{const p=l.value,f=r.value;!p.contains(m.target)&&!f.contains(m.target)&&i.onChange(!1)};let h=-1;const d=m=>{l.value===m.target?n.triggerHover=!1:n.overlayHover=!1,clearTimeout(h),h=window.setTimeout(()=>{!n.overlayHover&&!n.triggerHover&&i.onChange(!1)},10)};return o.onMounted(()=>{i.trigger==="click"?(l.value.addEventListener("click",s),document.addEventListener("click",u)):(l.value.addEventListener("mouseenter",s),l.value.addEventListener("mouseleave",d),r.value.addEventListener("mouseenter",a),r.value.addEventListener("mouseleave",d))}),o.onBeforeUnmount(()=>{i.trigger==="click"?(l.value.removeEventListener("click",s),document.removeEventListener("click",u)):(l.value.removeEventListener("mouseenter",s),l.value.removeEventListener("mouseleave",d),r.value.removeEventListener("mouseenter",a),r.value.removeEventListener("mouseleave",d))}),()=>{const m=W({ctx:e}),p=W({props:i,ctx:e},"overlay"),f=o.cloneVNode(m instanceof Array?m[0]:m,{ref:l}),v=o.createVNode("div",{class:[`${c}-dropdown`,n.overlayClass],style:n.overlayStyle,ref:r},[o.createVNode("div",{class:`${c}-dropdown-overlay`},[p instanceof Array?p[0]:p])]);return[f,v]}}}),wi="";const Jt=()=>({title:{type:String,default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function,default:()=>()=>{}},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>()=>{}},class:{type:String}});var De=o.defineComponent({props:Jt(),setup(i,e){const t=o.ref(i.visible),n=o.ref([`${c}-modal`]),l=o.ref(),r=o.ref();let s=()=>{};const a=o.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),u=o.computed(()=>i.isFullscreen?{width:"100%",height:"100%"}:{width:i.width,height:i.height});return o.onMounted(()=>{s=tt(r.value,(h,d)=>{a.initPos.left=h+"px",a.initPos.top=d+"px"})}),o.onBeforeUnmount(()=>{s()}),o.watch(()=>i.isFullscreen,h=>{h?s():s=tt(r.value,(d,m)=>{a.initPos.left=d+"px",a.initPos.top=m+"px"})}),o.watch(()=>i.visible,h=>{h?(n.value.push("zoom-in"),t.value=h,o.nextTick(()=>{const d=l.value.offsetWidth/2,m=l.value.offsetHeight/2,p=document.documentElement.clientWidth/2,f=document.documentElement.clientHeight/2;a.initPos.left=p-d+"px",a.initPos.top=f-m+"px"}),setTimeout(()=>{n.value=n.value.filter(d=>d!=="zoom-in")},140)):(n.value.push("zoom-out"),setTimeout(()=>{n.value=n.value.filter(d=>d!=="zoom-out"),t.value=h},130))}),()=>{const h=W({ctx:e}),d=W({props:i,ctx:e},"title");return o.createVNode("div",{class:[i.class],style:{display:t.value?"block":"none"}},[o.createVNode("div",{class:`${c}-modal-mask`,onClick:i.onClose},null),o.createVNode("div",{class:n.value,style:q(q({},a.initPos),u.value),ref:l},[o.createVNode("div",{class:`${c}-modal-header`,ref:r},[d||""]),o.createVNode("div",{class:`${c}-modal-body`},[h]),o.createVNode("div",{class:`${c}-modal-func`},[i.showAdjust&&o.createVNode("div",{class:`${c}-modal-adjust`,onClick:m=>{m.stopPropagation(),i.isFullscreen?a.initPos=a.historyPos:(a.historyPos=a.initPos,a.initPos={left:"0",top:"0"}),i.onAdjust(!i.isFullscreen)}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.isFullscreen?"suoxiao":"fangda"}`},null)])]),o.createVNode("div",{class:`${c}-modal-close`,onClick:m=>{m.stopPropagation(),i.onClose&&i.onClose()}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}});const en=()=>({type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var tn=o.defineComponent({props:en(),setup(i){const e=o.inject("usedLanguageText"),t=o.inject("editorId"),n=o.computed(()=>{var r,s;switch(i.type){case"link":return(r=e.value.linkModalTips)==null?void 0:r.linkTitle;case"image":return(s=e.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),l=o.reactive({desc:"",url:""});return o.watch(()=>i.visible,r=>{r||setTimeout(()=>{l.desc="",l.url=""},200)}),()=>o.createVNode(De,{title:n.value,visible:i.visible,onClose:i.onCancel},{default:()=>{var r,s,a,u,h;return[o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("label",{class:`${c}-label`,for:`link-desc-${t}`},[(r=e.value.linkModalTips)==null?void 0:r.descLabel]),o.createVNode("input",{placeholder:(s=e.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${c}-input`,id:`link-desc-${t}`,type:"text",value:l.desc,onChange:d=>{l.desc=d.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("label",{class:`${c}-label`,for:`link-url-${t}`},[(a=e.value.linkModalTips)==null?void 0:a.urlLabel]),o.createVNode("input",{placeholder:(u=e.value.linkModalTips)==null?void 0:u.urlLabelPlaceHolder,class:`${c}-input`,id:`link-url-${t}`,type:"text",value:l.url,onChange:d=>{l.url=d.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("button",{class:[`${c}-btn`,`${c}-btn-row`],type:"button",onClick:()=>{i.onOk(l),l.desc="",l.url=""}},[(h=e.value.linkModalTips)==null?void 0:h.buttonOK])])]}})}}),xi="";const nn=()=>({visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var ln=o.defineComponent({props:nn(),setup(i){var d,m;const e=o.inject("usedLanguageText"),t=o.inject("editorId");let n=(m=(d=B==null?void 0:B.editorExtensions)==null?void 0:d.cropper)==null?void 0:m.instance;const l=o.ref(),r=o.ref(),s=o.ref(),a=o.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let u=null;o.watch(()=>i.visible,()=>{i.visible&&!a.cropperInited&&(n=n||window.Cropper,l.value.onchange=()=>{if(!n){b.emit(t,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const p=l.value.files||[];if(a.imgSelected=!0,(p==null?void 0:p.length)>0){const f=new FileReader;f.onload=v=>{a.imgSrc=v.target.result,o.nextTick(()=>{u=new n(r.value,{viewMode:2,preview:`.${c}-clip-preview-target`})})},f.readAsDataURL(p[0])}})}),o.watch(()=>[a.imgSelected],()=>{s.value.style=""}),o.watch(()=>a.isFullscreen,()=>{o.nextTick(()=>{u==null||u.destroy(),s.value.style="",r.value&&(u=new n(r.value,{viewMode:2,preview:`.${c}-clip-preview-target`}))})});const h=()=>{u.clear(),u.destroy(),u=null,l.value.value="",a.imgSelected=!1};return()=>{var p;return o.createVNode(De,{class:`${c}-modal-clip`,title:(p=e.value.clipModalTips)==null?void 0:p.title,visible:i.visible,onClose:i.onCancel,showAdjust:!0,isFullscreen:a.isFullscreen,onAdjust:f=>{a.isFullscreen=f},width:"668px",height:"421px"},{default:()=>{var f,v;return[o.createVNode("div",{class:`${c}-form-item ${c}-clip`},[o.createVNode("div",{class:`${c}-clip-main`},[a.imgSelected?o.createVNode("div",{class:`${c}-clip-cropper`},[o.createVNode("img",{src:a.imgSrc,ref:r,style:{display:"none"},alt:""},null),o.createVNode("div",{class:`${c}-clip-delete`,onClick:h},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):o.createVNode("div",{class:`${c}-clip-upload`,onClick:()=>{l.value.click()}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),o.createVNode("div",{class:`${c}-clip-preview`},[o.createVNode("div",{class:`${c}-clip-preview-target`,ref:s},null)])]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("button",{class:`${c}-btn`,type:"button",onClick:()=>{if(u){const x=u.getCroppedCanvas();b.emit(t,"uploadImage",[Ht(x.toDataURL("image/png"))],i.onOk),h()}}},[((f=e.value.clipModalTips)==null?void 0:f.buttonUpload)||((v=e.value.linkModalTips)==null?void 0:v.buttonOK)])]),o.createVNode("input",{ref:l,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}});const on=()=>({type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var rn=o.defineComponent({props:on(),setup(i){return()=>o.createVNode(o.Fragment,null,[o.createVNode(tn,{type:i.type,visible:i.linkVisible,onOk:i.onOk,onCancel:i.onCancel},null),o.createVNode(ln,{visible:i.clipVisible,onOk:i.onOk,onCancel:i.onCancel},null)])}});const an=i=>{var h,d,m,p;const e=o.inject("editorId"),t=o.inject("previewOnly");let n=(d=(h=B.editorExtensions)==null?void 0:h.screenfull)==null?void 0:d.instance;const l=(p=(m=B.editorExtensions)==null?void 0:m.screenfull)==null?void 0:p.js,r=o.ref(!1),s=f=>{if(!n){b.emit(e,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}n.isEnabled?(r.value=!0,(f===void 0?!n.isFullscreen:f)?n.request():n.exit()):console.error("browser does not support screenfull!")},a=()=>{n&&n.isEnabled&&n.on("change",()=>{(r.value||i.setting.fullscreen)&&(r.value=!1,i.updateSetting("fullscreen"))})},u=()=>{n=window.screenfull,a()};return o.onMounted(()=>{if(a(),!t&&!n){const f=document.createElement("script");f.src=l||Lt,f.onload=u,f.id=`${c}-screenfull`,G(f,"screenfull")}}),o.onMounted(()=>{t||b.on(e,{name:nt,callback:s})}),{fullscreenHandler:s}},sn=()=>({tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}}),cn=o.defineComponent({name:"TableShape",props:sn(),setup(i){const e=o.reactive({x:-1,y:-1});return()=>o.createVNode("div",{class:`${c}-table-shape`,onMouseleave:()=>{e.x=-1,e.y=-1}},[new Array(i.tableShape[1]).fill("").map((t,n)=>o.createVNode("div",{class:`${c}-table-shape-row`,key:`table-shape-row-${n}`},[new Array(i.tableShape[0]).fill("").map((l,r)=>o.createVNode("div",{class:`${c}-table-shape-col`,key:`table-shape-col-${r}`,onMouseenter:()=>{e.x=n,e.y=r},onClick:()=>{i.onSelected(e)}},[o.createVNode("div",{class:[`${c}-table-shape-col-default`,n<=e.x&&r<=e.y&&`${c}-table-shape-col-include`]},null)]))]))])}}),dn=()=>({noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean}});var un=o.defineComponent({name:"MDEditorToolbar",props:dn(),setup(i){const e=o.inject("editorId"),t=o.inject("usedLanguageText"),{fullscreenHandler:n}=an(i),l=`${e}-toolbar-wrapper`,r=o.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(f,v)=>{b.emit(e,"replace",f,v)},a=o.reactive({type:"link",linkVisible:!1,clipVisible:!1}),u=o.ref();o.onMounted(()=>{b.on(e,{name:"openModals",callback(f){a.type=f,a.linkVisible=!0}})});const h=o.computed(()=>{const f=i.toolbars.filter(k=>!i.toolbarsExclude.includes(k)),v=f.indexOf("="),x=v===-1?f:f.slice(0,v+1),S=v===-1?[]:f.slice(v,Number.MAX_SAFE_INTEGER);return[x,S]}),d=o.ref(),m=()=>{b.emit(e,"uploadImage",Array.from(d.value.files||[])),d.value.value=""};o.onMounted(()=>{d.value.addEventListener("change",m)});const p=f=>{var v,x,S,k,y,E,z,L,_,I,g,M,D,j,N,w,$,F,A,R,K,ne,Q,ce,Ee,Se,Ne,ie,Te,Ve,oe,ze,Ie,de,ue,Ae,Fe,he,Le,_e,ge,Tt,Vt;if(Ze.includes(f))switch(f){case"-":return o.createVNode(Qt,null,null);case"bold":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(v=t.value.toolbarTips)==null?void 0:v.bold,onClick:()=>{s("bold")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(x=t.value.toolbarTips)==null?void 0:x.underline,onClick:()=>{s("underline")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(S=t.value.toolbarTips)==null?void 0:S.italic,onClick:()=>{s("italic")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(k=t.value.toolbarTips)==null?void 0:k.strikeThrough,onClick:()=>{s("strikeThrough")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return o.createVNode(re,{relative:`#${l}`,visible:r.title,onChange:H=>{r.title=H},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h1")}},[(y=t.value.titleItem)==null?void 0:y.h1]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h2")}},[(E=t.value.titleItem)==null?void 0:E.h2]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h3")}},[(z=t.value.titleItem)==null?void 0:z.h3]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h4")}},[(L=t.value.titleItem)==null?void 0:L.h4]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h5")}},[(_=t.value.titleItem)==null?void 0:_.h5]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("h6")}},[(I=t.value.titleItem)==null?void 0:I.h6])])},{default:()=>{var H;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(H=t.value.toolbarTips)==null?void 0:H.title},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(g=t.value.toolbarTips)==null?void 0:g.sub,onClick:()=>{s("sub")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(M=t.value.toolbarTips)==null?void 0:M.sup,onClick:()=>{s("sup")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(D=t.value.toolbarTips)==null?void 0:D.quote,onClick:()=>{s("quote")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(j=t.value.toolbarTips)==null?void 0:j.unorderedList,onClick:()=>{s("unorderedList")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(N=t.value.toolbarTips)==null?void 0:N.orderedList,onClick:()=>{s("orderedList")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(w=t.value.toolbarTips)==null?void 0:w.task,onClick:()=>{s("task")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return o.createVNode("div",{class:`${c}-toolbar-item`,title:($=t.value.toolbarTips)==null?void 0:$.codeRow,onClick:()=>{s("codeRow")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(F=t.value.toolbarTips)==null?void 0:F.code,onClick:()=>{s("code")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(A=t.value.toolbarTips)==null?void 0:A.link,onClick:()=>{a.type="link",a.linkVisible=!0}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return i.noUploadImg?o.createVNode("div",{class:`${c}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.image,onClick:()=>{a.type="image",a.linkVisible=!0}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):o.createVNode(re,{relative:`#${l}`,visible:r.image,onChange:H=>{r.image=H},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a.type="image",a.linkVisible=!0}},[(K=t.value.imgTitleItem)==null?void 0:K.link]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{d.value.click()}},[(ne=t.value.imgTitleItem)==null?void 0:ne.upload]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a.clipVisible=!0}},[(Q=t.value.imgTitleItem)==null?void 0:Q.clip2upload])])},{default:()=>{var H;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(H=t.value.toolbarTips)==null?void 0:H.image},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return o.createVNode(re,{relative:`#${l}`,visible:r.table,onChange:H=>{r.table=H},key:"bar-table",overlay:o.createVNode(cn,{tableShape:i.tableShape,onSelected:H=>{s("table",{selectedShape:H})}},null)},{default:()=>{var H;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(H=t.value.toolbarTips)==null?void 0:H.table},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(ce=t.value.toolbarTips)==null?void 0:ce.revoke,onClick:()=>{b.emit(e,"ctrlZ")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ee=t.value.toolbarTips)==null?void 0:Ee.next,onClick:()=>{b.emit(e,"ctrlShiftZ")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Se=t.value.toolbarTips)==null?void 0:Se.save,onClick:()=>{b.emit(e,be)}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return i.noPrettier?"":o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ne=t.value.toolbarTips)==null?void 0:Ne.prettier,onClick:()=>{s("prettier")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!i.setting.fullscreen&&o.createVNode("div",{class:`${c}-toolbar-item`,title:(ie=t.value.toolbarTips)==null?void 0:ie.pageFullscreen,onClick:()=>{i.updateSetting("pageFullscreen")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Te=t.value.toolbarTips)==null?void 0:Te.fullscreen,onClick:()=>{n()}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ve=t.value.toolbarTips)==null?void 0:Ve.preview,onClick:()=>{i.updateSetting("preview")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(oe=t.value.toolbarTips)==null?void 0:oe.htmlPreview,onClick:()=>{i.updateSetting("htmlPreview")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(ze=t.value.toolbarTips)==null?void 0:ze.catalog,onClick:()=>{b.emit(e,je)},key:"bar-catalog"},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ie=t.value.toolbarTips)==null?void 0:Ie.github,onClick:()=>Dt("https://github.com/imzbf/md-editor-v3")},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return o.createVNode(re,{relative:`#${l}`,visible:r.mermaid,onChange:H=>{r.mermaid=H},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.mermaid=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("flow")}},[(de=t.value.mermaid)==null?void 0:de.flow]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("sequence")}},[(ue=t.value.mermaid)==null?void 0:ue.sequence]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("gantt")}},[(Ae=t.value.mermaid)==null?void 0:Ae.gantt]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("class")}},[(Fe=t.value.mermaid)==null?void 0:Fe.class]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("state")}},[(he=t.value.mermaid)==null?void 0:he.state]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("pie")}},[(Le=t.value.mermaid)==null?void 0:Le.pie]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("relationship")}},[(_e=t.value.mermaid)==null?void 0:_e.relationship]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("journey")}},[(ge=t.value.mermaid)==null?void 0:ge.journey])]),key:"bar-mermaid"},{default:()=>{var H;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(H=t.value.toolbarTips)==null?void 0:H.mermaid},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return o.createVNode(re,{relative:`#${l}`,visible:r.katex,onChange:H=>{r.katex=H},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.katex=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("katexInline")}},[(Tt=t.value.katex)==null?void 0:Tt.inline]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s("katexBlock")}},[(Vt=t.value.katex)==null?void 0:Vt.block])]),key:"bar-katex"},{default:()=>{var H;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(H=t.value.toolbarTips)==null?void 0:H.katex},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return i.defToolbars instanceof Array?i.defToolbars[f]||"":i.defToolbars&&i.defToolbars.children instanceof Array&&i.defToolbars.children[f]||""};return()=>{const f=h.value[0].map(x=>p(x)),v=h.value[1].map(x=>p(x));return o.createVNode(o.Fragment,null,[i.toolbars.length>0&&o.createVNode("div",{class:`${c}-toolbar-wrapper`,id:l},[o.createVNode("div",{class:`${c}-toolbar`},[o.createVNode("div",{class:`${c}-toolbar-left`,ref:u},[f]),o.createVNode("div",{class:`${c}-toolbar-right`},[v])])]),o.createVNode("input",{ref:d,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),o.createVNode(rn,{linkVisible:a.linkVisible,clipVisible:a.clipVisible,type:a.type,onCancel:()=>{a.linkVisible=!1,a.clipVisible=!1},onOk:x=>{x&&s(a.type,{desc:x.desc,url:x.url}),a.linkVisible=!1,a.clipVisible=!1}},null)])}}});function ct(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let ae=ct();function hn(i){ae=i}const dt=/[&<>"']/,fn=new RegExp(dt.source,"g"),ut=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,mn=new RegExp(ut.source,"g"),pn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ht=i=>pn[i];function U(i,e){if(e){if(dt.test(i))return i.replace(fn,ht)}else if(ut.test(i))return i.replace(mn,ht);return i}const gn=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ft(i){return i.replace(gn,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const kn=/(^|[^\[])\^/g;function P(i,e){i=typeof i=="string"?i:i.source,e=e||"";const t={replace:(n,l)=>(l=l.source||l,l=l.replace(kn,"$1"),i=i.replace(n,l),t),getRegex:()=>new RegExp(i,e)};return t}const bn=/[^\w:]/g,yn=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function mt(i,e,t){if(i){let n;try{n=decodeURIComponent(ft(t)).replace(bn,"").toLowerCase()}catch{return null}if(n.indexOf("javascript:")===0||n.indexOf("vbscript:")===0||n.indexOf("data:")===0)return null}e&&!yn.test(t)&&(t=$n(e,t));try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const ye={},wn=/^[^:]+:\/*[^/]*$/,xn=/^([^:]+:)[\s\S]*$/,vn=/^([^:]+:\/*[^/]*)[\s\S]*$/;function $n(i,e){ye[" "+i]||(wn.test(i)?ye[" "+i]=i+"/":ye[" "+i]=xe(i,"/",!0)),i=ye[" "+i];const t=i.indexOf(":")===-1;return e.substring(0,2)==="//"?t?e:i.replace(xn,"$1")+e:e.charAt(0)==="/"?t?e:i.replace(vn,"$1")+e:i+e}const we={exec:function(){}};function X(i){let e=1,t,n;for(;e<arguments.length;e++){t=arguments[e];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i}function pt(i,e){const t=i.replace(/\|/g,(r,s,a)=>{let u=!1,h=s;for(;--h>=0&&a[h]==="\\";)u=!u;return u?"|":" |"}),n=t.split(/ \|/);let l=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;l<n.length;l++)n[l]=n[l].trim().replace(/\\\|/g,"|");return n}function xe(i,e,t){const n=i.length;if(n===0)return"";let l=0;for(;l<n;){const r=i.charAt(n-l-1);if(r===e&&!t)l++;else if(r!==e&&t)l++;else break}return i.slice(0,n-l)}function Cn(i,e){if(i.indexOf(e[1])===-1)return-1;const t=i.length;let n=0,l=0;for(;l<t;l++)if(i[l]==="\\")l++;else if(i[l]===e[0])n++;else if(i[l]===e[1]&&(n--,n<0))return l;return-1}function gt(i){i&&i.sanitize&&!i.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function kt(i,e){if(e<1)return"";let t="";for(;e>1;)e&1&&(t+=i),e>>=1,i+=i;return t+i}function bt(i,e,t,n){const l=e.href,r=e.title?U(e.title):null,s=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const a={type:"link",raw:t,href:l,title:r,text:s,tokens:n.inlineTokens(s)};return n.state.inLink=!1,a}return{type:"image",raw:t,href:l,title:r,text:U(s)}}function En(i,e){const t=i.match(/^(\s+)(?:```)/);if(t===null)return e;const n=t[1];return e.split(`
`).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|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:we,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};T._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,T._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,T.def=P(T.def).replace("label",T._label).replace("title",T._title).getRegex(),T.bullet=/(?:[*+-]|\d{1,9}[.)])/,T.listItemStart=P(/^( *)(bull) */).replace("bull",T.bullet).getRegex(),T.list=P(T.list).replace(/bull/g,T.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+T.def.source+")").getRegex(),T._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",T._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,T.html=P(T.html,"i").replace("comment",T._comment).replace("tag",T._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),T.paragraph=P(T._paragraph).replace("hr",T.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T._tag).getRegex(),T.blockquote=P(T.blockquote).replace("paragraph",T.paragraph).getRegex(),T.normal=X({},T),T.gfm=X({},T.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),T.gfm.table=P(T.gfm.table).replace("hr",T.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T._tag).getRegex(),T.gfm.paragraph=P(T._paragraph).replace("hr",T.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",T.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T._tag).getRegex(),T.pedantic=X({},T.normal,{html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",T._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:we,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(T.normal._paragraph).replace("hr",T.hr).replace("heading",` *#{1,6} *[^
]`).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").replace("email",C.gfm._extended_email).getRegex(),C.breaks=X({},C.gfm,{br:P(C.br).replace("{2,}","*").getRegex(),text:P(C.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function Sn(i){return i.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function yt(i){let e="",t,n;const l=i.length;for(t=0;t<l;t++)n=i.charCodeAt(t),Math.random()>.5&&(n="x"+n.toString(16)),e+="&#"+n+";";return e}class ee{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ae,this.options.tokenizer=this.options.tokenizer||new He,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:T.normal,inline:C.normal};this.options.pedantic?(t.block=T.pedantic,t.inline=C.pedantic):this.options.gfm&&(t.block=T.gfm,this.options.breaks?t.inline=C.breaks:t.inline=C.gfm),this.tokenizer.rules=t}static get rules(){return{block:T,inline:C}}static lex(e,t){return new ee(t).lex(e)}static lexInline(e,t){return new ee(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
`),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.zoomedHd&&(g.zoomedHd.style.transform=ge)};return new n(function(F){if(w&&E.indexOf(w)===-1){F(D);return}var A=function ce(){L=!1,g.zoomed.removeEventListener("transitionend",ce),g.original.dispatchEvent(se("medium-zoom:opened",{detail:{zoom:D}})),F(D)};if(g.zoomed){F(D);return}if(w)g.original=w;else if(E.length>0){var R=E;g.original=R[0]}else{F(D);return}if(g.original.dispatchEvent(se("medium-zoom:open",{detail:{zoom:D}})),_=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,L=!0,g.zoomed=Ln(g.original),document.body.appendChild(M),I.template){var K=$e(I.template)?I.template:document.querySelector(I.template);g.template=document.createElement("div"),g.template.appendChild(K.content.cloneNode(!0)),document.body.appendChild(g.template)}if(g.original.parentElement&&g.original.parentElement.tagName==="PICTURE"&&g.original.currentSrc&&(g.zoomed.src=g.original.currentSrc),document.body.appendChild(g.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),g.original.classList.add("medium-zoom-image--hidden"),g.zoomed.classList.add("medium-zoom-image--opened"),g.zoomed.addEventListener("click",v),g.zoomed.addEventListener("transitionend",A),g.original.getAttribute("data-zoom-src")){g.zoomedHd=g.zoomed.cloneNode(),g.zoomedHd.removeAttribute("srcset"),g.zoomedHd.removeAttribute("sizes"),g.zoomedHd.removeAttribute("loading"),g.zoomedHd.src=g.zoomed.getAttribute("data-zoom-src"),g.zoomedHd.onerror=function(){clearInterval(ne),console.warn("Unable to reach the zoom image target "+g.zoomedHd.src),g.zoomedHd=null,$()};var ne=setInterval(function(){g.zoomedHd.complete&&(clearInterval(ne),g.zoomedHd.classList.add("medium-zoom-image--opened"),g.zoomedHd.addEventListener("click",v),document.body.appendChild(g.zoomedHd),$())},10)}else if(g.original.hasAttribute("srcset")){g.zoomedHd=g.zoomed.cloneNode(),g.zoomedHd.removeAttribute("sizes"),g.zoomedHd.removeAttribute("loading");var Q=g.zoomedHd.addEventListener("load",function(){g.zoomedHd.removeEventListener("load",Q),g.zoomedHd.classList.add("medium-zoom-image--opened"),g.zoomedHd.addEventListener("click",v),document.body.appendChild(g.zoomedHd),$()})}else $()})},v=function(){return new n(function(N){if(L||!g.original){N(D);return}var w=function $(){g.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(g.zoomed),g.zoomedHd&&document.body.removeChild(g.zoomedHd),document.body.removeChild(M),g.zoomed.classList.remove("medium-zoom-image--opened"),g.template&&document.body.removeChild(g.template),L=!1,g.zoomed.removeEventListener("transitionend",$),g.original.dispatchEvent(se("medium-zoom:closed",{detail:{zoom:D}})),g.original=null,g.zoomed=null,g.zoomedHd=null,g.template=null,N(D)};L=!0,document.body.classList.remove("medium-zoom--opened"),g.zoomed.style.transform="",g.zoomedHd&&(g.zoomedHd.style.transform=""),g.template&&(g.template.style.transition="opacity 150ms",g.template.style.opacity=0),g.original.dispatchEvent(se("medium-zoom:close",{detail:{zoom:D}})),g.zoomed.addEventListener("transitionend",w)})},x=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=N.target;return g.original?v():f({target:w})},S=function(){return I},k=function(){return E},y=function(){return g.original},E=[],z=[],L=!1,_=0,I=t,g={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(e)==="[object Object]"?I=e:(e||typeof e=="string")&&h(e),I=le({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},I);var M=Fn(I.background);document.addEventListener("click",l),document.addEventListener("keyup",s),document.addEventListener("scroll",r),window.addEventListener("resize",v);var D={open:f,close:v,toggle:x,update:a,clone:u,attach:h,detach:d,on:m,off:p,getOptions:S,getImages:k,getZoomedImage:y};return D};function Rn(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(!i||typeof document=="undefined")){var n=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css",t==="top"&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=i:l.appendChild(document.createTextNode(i))}}var jn=".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";Rn(jn);var Dn=_n;const pe=i=>{const e=i.value,t=e.substring(0,i.selectionStart),n=e.substring(i.selectionEnd,e.length),l=t.lastIndexOf(`
`),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){const w=document.createElement("script");w.src=(v==null?void 0:v.js)||Xe.js,w.onload=()=>{S.value=!0},w.id=`${c}-katex`;const $=document.createElement("link");$.rel="stylesheet",$.href=(v==null?void 0:v.css)||Xe.css,$.id=`${c}-katexCss`,G(w,"katex"),G($)}if(!m){const w=document.createElement("link");w.rel="stylesheet",w.href=h.value.css,w.id=`${c}-hlCss`;const $=document.createElement("script");$.src=h.value.js,$.onload=M,$.id=`${c}-hljs`,G(w),G($,"hljs")}}),o.watch(()=>h.value.css,w=>{Ut(`${c}-hlCss`,"href",w)}),o.onMounted(()=>{b.on(u,{name:"pushCatalog",callback(){b.emit(u,"catalogChanged",k.value)}})}),{html:I}},Un=(i,e,t,n,l)=>{const r=o.inject("previewOnly"),s=o.inject("usedLanguageText"),a=o.inject("editorId");let u=()=>{},h=()=>{};const d=()=>{document.querySelectorAll(`#${a}-preview pre`).forEach(f=>{var S,k;(S=f.querySelector(".copy-button"))==null||S.remove();const v=((k=s.value.copyCode)==null?void 0:k.text)||"\u590D\u5236\u4EE3\u7801",x=document.createElement("span");x.setAttribute("class","copy-button"),x.innerText=v,x.addEventListener("click",()=>{var _,I;const y=f.querySelector("code").innerText,E=me(i.formatCopiedText(y)),z=((_=s.value.copyCode)==null?void 0:_.successTips)||"\u5DF2\u590D\u5236\uFF01",L=((I=s.value.copyCode)==null?void 0:I.failTips)||"\u5DF2\u590D\u5236\uFF01";x.innerText=E?z:L,setTimeout(()=>{x.innerText=v},1500)}),f.appendChild(x)})},m=()=>{o.nextTick(()=>{i.setting.preview&&!r&&i.scrollAuto&&(u(),h()),d()})},p=f=>{f&&!r&&o.nextTick(()=>{u(),[h,u]=Ye(t.value,n.value||l.value),h()})};o.watch(()=>e.value,m),o.watch(()=>s.value,d),o.watch(()=>i.setting.preview,p),o.watch(()=>i.setting.htmlPreview,p),o.watch(()=>i.scrollAuto,f=>{f?h():u()}),o.onMounted(()=>{d(),!r&&(n.value||l.value)&&([h,u]=Ye(t.value,n.value||l.value)),i.scrollAuto&&h()})},qn=(i,e)=>{const t=o.inject("previewOnly"),n=o.inject("tabWidth"),l=o.inject("editorId"),r=o.ref("");o.onMounted(()=>{var s;t||((s=e.value)==null||s.addEventListener("keypress",a=>{var u,h,d;if(a.key==="Enter"){const m=(u=e.value)==null?void 0:u.selectionStart,p=(h=e.value)==null?void 0:h.value.substring(0,m),f=(d=e.value)==null?void 0:d.value.substring(m),v=p==null?void 0:p.lastIndexOf(`
`),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:`${c}-footer-item`},[o.createVNode("label",{class:`${c}-footer-label`},[`${(t=e.value.footer)==null?void 0:t.markdownTotal}:`]),o.createVNode("span",null,[((n=i.modelValue)==null?void 0:n.length)||0])])}}}),vi="";const Jn=()=>({checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}}});var ei=o.defineComponent({props:Jn(),setup(i){return()=>o.createVNode("div",{class:[`${c}-checkbox`,i.checked&&`${c}-checkbox-checked`],onClick:()=>{i.onChange(!i.checked)}},null)}});const ti=()=>({scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}}});var ni=o.defineComponent({props:ti(),setup(i){const e=o.inject("usedLanguageText");return()=>{var t;return o.createVNode("div",{class:`${c}-footer-item`},[o.createVNode("label",{class:`${c}-footer-label`,onClick:()=>{i.onScrollAutoChange(!i.scrollAuto)}},[(t=e.value.footer)==null?void 0:t.scrollAuto]),o.createVNode(ei,{checked:i.scrollAuto,onChange:i.onScrollAutoChange},null)])}}});const ii=()=>({modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}},defFooters:{type:Object}});var li=o.defineComponent({name:"MDEditorFooter",props:ii(),setup(i){const e=o.computed(()=>{const n=i.footers.indexOf("="),l=n===-1?i.footers:i.footers.slice(0,n),r=n===-1?[]:i.footers.slice(n,Number.MAX_SAFE_INTEGER);return[l,r]}),t=n=>{if(Ge.includes(n))switch(n){case"markdownTotal":return o.createVNode(Yn,{modelValue:i.modelValue},null);case"scrollSwitch":return o.createVNode(ni,{scrollAuto:i.scrollAuto,onScrollAutoChange:i.onScrollAutoChange},null)}else return i.defFooters instanceof Array?i.defFooters[n]||"":i.defFooters&&i.defFooters.children instanceof Array&&i.defFooters.children[n]||""};return()=>{const n=e.value[0].map(r=>t(r)),l=e.value[1].map(r=>t(r));return o.createVNode("div",{class:`${c}-footer`},[o.createVNode("div",{class:`${c}-footer-left`},[n]),o.createVNode("div",{class:`${c}-footer-right`},[l])])}}});const oi=()=>({tocItem:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:()=>()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>()=>{}},scrollElementOffsetTop:{type:Number,default:0}}),Nt=o.defineComponent({props:oi(),setup(i){return()=>{const{tocItem:e,markedHeadingId:t,scrollElement:n,onClick:l,scrollElementOffsetTop:r}=i;return o.createVNode("div",{class:[`${c}-catalog-link`,e.active&&`${c}-catalog-active`],onClick:s=>{l(s,e),s.stopPropagation();const a=t(e.text,e.level,e.index),u=document.getElementById(a),h=n instanceof Element?n:document.querySelector(n);if(u&&h){let d=u.offsetParent,m=u.offsetTop;if(h.contains(d))for(;d&&h!=d;)m+=d==null?void 0:d.offsetTop,d=d==null?void 0:d.offsetParent;h==null||h.scrollTo({top:m-r,behavior:"smooth"})}}},[o.createVNode("span",{title:e.text},[e.text]),o.createVNode("div",{class:`${c}-catalog-wrapper`},[e.children&&e.children.map(s=>o.createVNode(Nt,{markedHeadingId:t,key:`${e.text}-link-${s.level}-${s.text}`,tocItem:s,scrollElement:n,onClick:l,scrollElementOffsetTop:r},null))])])}}});var $i="";const ri=()=>({editorId:{type:String},class:{type:String,default:""},markedHeadingId:{type:Function,default:i=>i},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0}}),Ce=o.defineComponent({name:"MdCatalog",props:ri(),emits:["onClick"],setup(i,e){const t=i.editorId,n=o.reactive({list:[],show:!1,scrollElement:i.scrollElement||`#${t}-preview-wrapper`}),l=o.computed(()=>{const r=[];return n.list.forEach(({text:s,level:a,active:u},h)=>{const d={level:a,text:s,index:h+1,active:!!u};if(r.length===0)r.push(d);else{let m=r[r.length-1];if(d.level>m.level)for(let p=m.level+1;p<=6;p++){const{children:f}=m;if(!f){m.children=[d];break}if(m=f[f.length-1],d.level<=m.level){f.push(d);break}}else r.push(d)}}),r});return o.onMounted(()=>{b.on(t,{name:"catalogChanged",callback:r=>{n.list=r.map((s,a)=>a===0?fe(q({},s),{active:!0}):q({},s))}}),b.emit(t,"pushCatalog")}),o.onMounted(()=>{var s;const r=n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement);(s=r===document.documentElement?window:r)==null||s.addEventListener("scroll",Pt(()=>{if(n.list.length===0)return!1;const{activeHead:a}=n.list.reduce((u,h,d)=>{const m=document.getElementById(i.markedHeadingId(h.text,h.level,d+1));if(m instanceof HTMLElement){const p=Mt(m,r);if(p<i.offsetTop&&p>u.minTop)return{activeHead:h,minTop:p}}return u},{activeHead:n.list[0],minTop:Number.MIN_SAFE_INTEGER});n.list=n.list.map(u=>u===a?fe(q({},u),{active:!0}):fe(q({},u),{active:!1}))}))}),()=>o.createVNode("div",{class:`${c}-catalog${i.theme==="dark"?"-dark":""} ${i.class}`},[l.value.map(r=>o.createVNode(Nt,{markedHeadingId:i.markedHeadingId,tocItem:r,key:`link-${r.level}-${r.text}`,scrollElement:n.scrollElement,onClick:(s,a)=>{e.emit("onClick",s,a)},scrollElementOffsetTop:i.scrollElementOffsetTop},null))])}}),ai=()=>({modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},historyLength:{type:Number,default:10},onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},language:{type:String,default:"zh-CN"},toolbars:{type:Array,default:Ze},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:Z},tabWidth:{type:Number,default:2},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:si},tableShape:{type:Array,default:()=>[6,4]},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:i=>i},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},defToolbars:{type:[String,Object]},onError:{type:Function},codeTheme:{type:String,default:"atom"},footers:{type:Array,default:Ge},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:i=>i},noUploadImg:{type:Boolean},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean}}),si=i=>i;var Ci="",Ei="",Si="";const te=o.defineComponent({name:"MdEditorV3",props:ai(),emits:["onChange","onSave","onUploadImg","onHtmlChanged","onGetCatalog","onError","update:modelValue"],setup(i,e){const{editorId:t,previewOnly:n,noKatex:l,noMermaid:r,noPrettier:s,noUploadImg:a}=i,u=o.reactive({scrollAuto:i.scrollAuto});qt(i,e),Kt(i),Zt(i);const[h,d]=Gt(i,e),[m,p]=Wt(i);return o.onBeforeUnmount(()=>{b.clear(t)}),Xt(i,e,m,h,d),()=>{var x;const f=W({props:i,ctx:e},"defToolbars"),v=W({props:i,ctx:e},"defFooters");return o.createVNode("div",{id:t,class:[c,i.class,i.theme==="dark"&&`${c}-dark`,h.fullscreen||h.pageFullscreen?`${c}-fullscreen`:"",n&&`${c}-previewOnly`],style:i.style},[!n&&o.createVNode(un,{noPrettier:s,toolbars:i.toolbars,toolbarsExclude:i.toolbarsExclude,setting:h,updateSetting:d,tableShape:i.tableShape,defToolbars:f,noUploadImg:a},null),o.createVNode(Qn,{value:i.modelValue,onChange:S=>{b.emit(t,"saveHistoryPos"),i.onChange?i.onChange(S):(e.emit("update:modelValue",S),e.emit("onChange",S))},setting:h,onHtmlChanged:S=>{i.onHtmlChanged?i.onHtmlChanged(S):e.emit("onHtmlChanged",S)},onGetCatalog:S=>{i.onGetCatalog?i.onGetCatalog(S):e.emit("onGetCatalog",S)},markedHeadingId:i.markedHeadingId,noMermaid:r,sanitize:i.sanitize,placeholder:i.placeholder,noKatex:l,scrollAuto:u.scrollAuto,formatCopiedText:i.formatCopiedText,autofocus:i.autoFocus,disabled:i.disabled,readonly:i.readOnly,maxlength:i.maxLength,autoDetectCode:i.autoDetectCode},null),!n&&((x=i.footers)==null?void 0:x.length)>0&&o.createVNode(li,{modelValue:i.modelValue,footers:i.footers,defFooters:v,scrollAuto:u.scrollAuto,onScrollAutoChange:S=>u.scrollAuto=S},null),p.value&&!n&&o.createVNode(Ce,{theme:i.theme,style:{display:m.value?"block":"none"},class:`${c}-catalog-editor`,editorId:t,markedHeadingId:i.markedHeadingId},null)])}}}),ci=()=>({title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}});var Me=o.defineComponent({name:"NormalToolbar",props:ci(),emits:["onClick"],setup(i,e){return()=>{const t=W({props:i,ctx:e},"trigger");return o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title,onClick:n=>{i.onClick instanceof Function?i.onClick(n):e.emit("onClick",n)}},[t])}}});const di=()=>({title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]}});var Be=o.defineComponent({name:"DropdownToolbar",props:di(),emits:["onChange"],setup(i,e){const t=o.inject("editorId");return()=>{const n=W({props:i,ctx:e},"trigger"),l=W({props:i,ctx:e},"overlay");return o.createVNode(re,{relative:`#${t}-toolbar-wrapper`,visible:i.visible,onChange:r=>{i.onChange instanceof Function?i.onChange(r):e.emit("onChange",r)},overlay:l},{default:()=>[o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title||""},[n])]})}}});function ui(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!o.isVNode(i)}const hi=()=>({title:{type:String,default:""},modalTitle:{type:String,default:""},visible:{type:Boolean},width:{type:String,default:"auto"},height:{type:String,default:"auto"},trigger:{type:[String,Object]},onClick:{type:Function},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function}});var Ue=o.defineComponent({name:"ModalToolbar",props:hi(),emits:["onClick","onClose","onAdjust"],setup(i,e){return()=>{const t=W({props:i,ctx:e},"trigger"),n=W({props:i,ctx:e},"default");return o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title,onClick:()=>{i.onClick instanceof Function?i.onClick():e.emit("onClick")}},[t]),o.createVNode(De,{width:i.width,height:i.height,title:i.modalTitle,visible:i.visible,onClose:()=>{i.onClose instanceof Function?i.onClose():e.emit("onClose")},showAdjust:i.showAdjust,isFullscreen:i.isFullscreen,onAdjust:l=>{i.onAdjust instanceof Function?i.onAdjust(l):e.emit("onAdjust",l)}},ui(n)?n:{default:()=>[n]})])}}});return te.install=i=>(i.component(te.name,te),i.component(Me.name,Me),i.component(Be.name,Be),i.component(Ce.name,Ce),i.component(Ue.name,Ue),i),te.NormalToolbar=Me,te.DropdownToolbar=Be,te.MdCatalog=Ce,te.ModalToolbar=Ue,te.config=Rt,te});