md-editor-v3 4.16.1-0 → 4.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1417,15 +1417,11 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1417
1417
  let scale = 0;
1418
1418
  const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
1419
1419
  const firstLineScrollTop = getTopByLine(start);
1420
- let endLineScrollTop = getTopByLine(end === view2.state.doc.lines ? end : end + 1);
1420
+ const endLineScrollTop = getTopByLine(end === view2.state.doc.lines ? end : end + 1);
1421
1421
  let blockHeight = 0;
1422
1422
  if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.scrollTop > cEle.scrollHeight - cEle.clientHeight) {
1423
- scale = Math.max(
1424
- (cScrollTop - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop - cEle.clientHeight),
1425
- 0
1426
- );
1427
- endLineScrollTop = getTopByLine(view2.state.doc.lines) + getHeightByLine(view2.state.doc.lines);
1428
- blockHeight = 8 + endLineScrollTop - firstLineScrollTop - pEle.clientHeight;
1423
+ scale = (cScrollTop + cEle.clientHeight - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop);
1424
+ blockHeight = pEle.scrollHeight - firstLineScrollTop - pEle.clientHeight;
1429
1425
  } else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
1430
1426
  if (realEleStart === realEleEnd) {
1431
1427
  eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
@@ -1416,15 +1416,11 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1416
1416
  let scale = 0;
1417
1417
  const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
1418
1418
  const firstLineScrollTop = getTopByLine(start);
1419
- let endLineScrollTop = getTopByLine(end === view.state.doc.lines ? end : end + 1);
1419
+ const endLineScrollTop = getTopByLine(end === view.state.doc.lines ? end : end + 1);
1420
1420
  let blockHeight = 0;
1421
1421
  if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.scrollTop > cEle.scrollHeight - cEle.clientHeight) {
1422
- scale = Math.max(
1423
- (cScrollTop - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop - cEle.clientHeight),
1424
- 0
1425
- );
1426
- endLineScrollTop = getTopByLine(view.state.doc.lines) + getHeightByLine(view.state.doc.lines);
1427
- blockHeight = 8 + endLineScrollTop - firstLineScrollTop - pEle.clientHeight;
1422
+ scale = (cScrollTop + cEle.clientHeight - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop);
1423
+ blockHeight = pEle.scrollHeight - firstLineScrollTop - pEle.clientHeight;
1428
1424
  } else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
1429
1425
  if (realEleStart === realEleEnd) {
1430
1426
  eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(he,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(he=typeof globalThis<"u"?globalThis:he||self,g(he.MdEditorV3={},he.Vue))})(this,function(he,g){"use strict";var GOe=Object.defineProperty;var IOe=(he,g,ot)=>g in he?GOe(he,g,{enumerable:!0,configurable:!0,writable:!0,value:ot}):he[g]=ot;var Xe=(he,g,ot)=>(IOe(he,typeof g!="symbol"?g+"":g,ot),ot),LQ=(he,g,ot)=>{if(!g.has(he))throw TypeError("Cannot "+ot)};var T=(he,g,ot)=>(LQ(he,g,"read from private field"),ot?ot.call(he):g.get(he)),$e=(he,g,ot)=>{if(g.has(he))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(he):g.set(he,ot)},fe=(he,g,ot,ka)=>(LQ(he,g,"write to private field"),ka?ka.call(he,ot):g.set(he,ot),ot);var Nd=(he,g,ot,ka)=>({set _(Md){fe(he,g,Md,ot)},get _(){return T(he,g,ka)}}),le=(he,g,ot)=>(LQ(he,g,"access private method"),ot);var Gz,_O,Ti,En,_i,Ri,RO,Tt,zi,St,He,me,ln,Yn,Jt,Zt,Wi,Ut,qi,Zi,Vn,Ui,yo,sn,Gs,MQ,pa,qr,Is,Cn,_d,Kz,ma,zO,Ds,Or,ko,lr,xo,Ns,BQ,qOe,WO,Ld,qO,Fd,Ne,Je,Ls,HQ,ga,Js,ZO;function ot(e,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const o=Object.getOwnPropertyDescriptor(i,r);o&&Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const ka=e=>{const t=typeof e;return t!=="function"&&t!=="object"||e===null},Md=e=>{const t=e.flags===""?void 0:e.flags;return new RegExp(e.source,t)},GO=(e,t=new WeakMap)=>{if(e===null||ka(e))return e;if(t.has(e))return t.get(e);if(e instanceof RegExp)return Md(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Function)return e;if(e instanceof Map){const i=new Map;return t.set(e,i),e.forEach((r,o)=>{i.set(o,GO(r,t))}),i}if(e instanceof Set){const i=new Set;t.set(e,i);for(const r of e)i.add(GO(r,t));return i}if(Array.isArray(e)){const i=[];return t.set(e,i),e.forEach(r=>{i.push(GO(r,t))}),i}const n={};t.set(e,n);for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=GO(e[i],t));return n},Bd=(e,t=200)=>{let n=0;return(...i)=>new Promise(r=>{n&&(clearTimeout(n),r("cancel")),n=window.setTimeout(()=>{e.apply(void 0,i),n=0,r("done")},t)})},eW=(e,t={_blank:!0,nofollow:!0})=>{const n=document.createElement("a");n.href=e,t._blank&&(n.target="_blank"),t.nofollow&&(n.rel="noopener noreferrer"),n.click()},tW=()=>{let e=-1;return(t,n,i,r=100)=>{const o=()=>{i&&(typeof r=="number"?setTimeout(i,r):i())};e!==-1&&(cancelAnimationFrame(e),o());let a=t.scrollTop;const O=()=>{e=-1;const l=n-a;a=a+l/5,Math.abs(l)<1?(t.scrollTo(0,n),o()):(t.scrollTo(0,a),e=requestAnimationFrame(O))};e=requestAnimationFrame(O)}},KQ=(e,t=200)=>{let n=0,i=null;const r=o=>{n===0&&(n=o),o-n>=t?(e.apply(void 0,i),i=null,n=0):window.requestAnimationFrame(r)};return(...o)=>{i===null&&window.requestAnimationFrame(r),i=o}},nW=e=>{const t=n=>{const{scrollHeight:i,scrollWidth:r,offsetHeight:o,offsetWidth:a,scrollLeft:O,scrollTop:l}=e,s=n.x,u=n.y,c=h=>{const p=l+u-h.y,m=O+s-h.x,Q=i-o,$=r-a,b={};m>=0&&m<=$&&(b.left=m),p>=0&&p<=Q&&(b.top=p),e.scroll(b)};document.addEventListener("mousemove",c);const f=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f)};document.addEventListener("mouseup",f)};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},Hd=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,JQ=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Kd=(e,t)=>{for(const n in t)JQ(t[n])&&JQ(e[n])?e[n]=Kd(e[n],t[n]):e[n]=t[n];return e},R="md-editor",eb="https://at.alicdn.com/t/c/font_2605852_cmafimm6hot.js",tb="https://at.alicdn.com/t/c/font_2605852_cmafimm6hot.css",Fe="https://cdnjs.cloudflare.com/ajax/libs",iW=`${Fe}/highlight.js/11.8.0/highlight.min.js`,nb={main:`${Fe}/prettier/2.8.0/standalone.js`,markdown:`${Fe}/prettier/2.8.0/parser-markdown.js`},rW={css:`${Fe}/cropperjs/1.5.13/cropper.min.css`,js:`${Fe}/cropperjs/1.5.13/cropper.min.js`},oW=`${Fe}/screenfull.js/5.2.0/screenfull.min.js`,Jd=["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","previewOnly","htmlPreview","catalog","github"],eh=["markdownTotal","=","scrollSwitch"],eu={"zh-CN":{toolbarTips:{bold:"加粗",underline:"下划线",italic:"斜体",strikeThrough:"删除线",title:"标题",sub:"下标",sup:"上标",quote:"引用",unorderedList:"无序列表",orderedList:"有序列表",task:"任务列表",codeRow:"行内代码",code:"块级代码",link:"链接",image:"图片",table:"表格",mermaid:"mermaid图",katex:"katex公式",revoke:"后退",next:"前进",save:"保存",prettier:"美化",pageFullscreen:"浏览器全屏",fullscreen:"屏幕全屏",preview:"预览",previewOnly:"仅预览",htmlPreview:"html代码预览",catalog:"目录",github:"源码地址"},titleItem:{h1:"一级标题",h2:"二级标题",h3:"三级标题",h4:"四级标题",h5:"五级标题",h6:"六级标题"},imgTitleItem:{link:"添加链接",upload:"上传图片",clip2upload:"裁剪上传"},linkModalTips:{linkTitle:"添加链接",imageTitle:"添加图片",descLabel:"链接描述:",descLabelPlaceHolder:"请输入描述...",urlLabel:"链接地址:",urlLabelPlaceHolder:"请输入链接...",buttonOK:"确定"},clipModalTips:{title:"裁剪图片上传",buttonUpload:"上传"},copyCode:{text:"复制代码",successTips:"已复制!",failTips:"复制失败!"},mermaid:{flow:"流程图",sequence:"时序图",gantt:"甘特图",class:"类图",state:"状态图",pie:"饼图",relationship:"关系图",journey:"旅程图"},katex:{inline:"行内公式",block:"块级公式"},footer:{markdownTotal:"字数",scrollAuto:"同步滚动"}},"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",previewOnly:"preview only",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:"Character Count",scrollAuto:"Scroll Auto"}}},aW=`${Fe}/mermaid/10.6.1/mermaid.esm.min.mjs`,OW={js:`${Fe}/KaTeX/0.16.9/katex.min.js`,css:`${Fe}/KaTeX/0.16.9/katex.min.css`},th={a11y:{light:`${Fe}/highlight.js/11.8.0/styles/a11y-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/a11y-dark.min.css`},atom:{light:`${Fe}/highlight.js/11.8.0/styles/atom-one-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/atom-one-dark.min.css`},github:{light:`${Fe}/highlight.js/11.8.0/styles/github.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/github-dark.min.css`},gradient:{light:`${Fe}/highlight.js/11.8.0/styles/gradient-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/gradient-dark.min.css`},kimbie:{light:`${Fe}/highlight.js/11.8.0/styles/kimbie-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/kimbie-dark.min.css`},paraiso:{light:`${Fe}/highlight.js/11.8.0/styles/paraiso-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${Fe}/highlight.js/11.8.0/styles/qtcreator-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${Fe}/highlight.js/11.8.0/styles/stackoverflow-light.min.css`,dark:`${Fe}/highlight.js/11.8.0/styles/stackoverflow-dark.min.css`}},lW={highlight:{js:{integrity:"sha384-g4mRvs7AO0/Ol5LxcGyz4Doe21pVhGNnC3EQw5shw+z+aXDN86HqUdwXWO+Gz2zI",crossOrigin:"anonymous"},css:{a11y:{light:{integrity:"sha384-qdZDAN3jffvh670RHw1wxLekabidEFaNRninYgIzBvMbL6WlHdXeHS/Bt+vx33lN",crossOrigin:"anonymous"},dark:{integrity:"sha384-2QAAjX8pqaM5azX68KWI2wExF6Q13kY4kEiQFY4b/1zPe6rpgmTByNpDEllH3sb+",crossOrigin:"anonymous"}},atom:{light:{integrity:"sha384-w6Ujm1VWa9HYFqGc89oAPn/DWDi2gUamjNrq9DRvEYm2X3ClItg9Y9xs1ViVo5b5",crossOrigin:"anonymous"},dark:{integrity:"sha384-oaMLBGEzBOJx3UHwac0cVndtX5fxGQIfnAeFZ35RTgqPcYlbprH9o9PUV/F8Le07",crossOrigin:"anonymous"}},github:{light:{integrity:"sha384-eFTL69TLRZTkNfYZOLM+G04821K1qZao/4QLJbet1pP4tcF+fdXq/9CdqAbWRl/L",crossOrigin:"anonymous"},dark:{integrity:"sha384-wH75j6z1lH97ZOpMOInqhgKzFkAInZPPSPlZpYKYTOqsaizPvhQZmAtLcPKXpLyH",crossOrigin:"anonymous"}},gradient:{light:{integrity:"sha384-yErHBR8aEZPxRl3XmR8dGSRAclMlnSRRw8sXQLcmPWzWUvb56BzQmBw3EWHl7QGI",crossOrigin:"anonymous"},dark:{integrity:"sha384-lUCvtSOdvDbp5hLWKgwz/taFu1HxlpqES2OVP5UG2JMTfnU481gXcBhGF9lAGoSr",crossOrigin:"anonymous"}},kimbie:{light:{integrity:"sha384-tloeSLUPczAvoZ48TUz+OxRie0oYLCRwlkadUXovGzzJEIbNQB2TkfUuvJ6SW5Mi",crossOrigin:"anonymous"},dark:{integrity:"sha384-o5F1vUaMNOmou1sQrsWiFo4/QUGSV0svqNZW+EesmKxWC8MpFJcveBhAyfvTHbGb",crossOrigin:"anonymous"}},paraiso:{light:{integrity:"sha384-5j6QHU2Hwg1ehtlIQNDebhETDB8bga3/88hzBFsMRaGmgQHCftqIN7GZNDNw0vTL",crossOrigin:"anonymous"},dark:{integrity:"sha384-I5vnnMQu0LWDQnHpT61xyoMwKarAB8jpZkB2ioFOlmzUFnIFaV4QbUwlBBOMKhTH",crossOrigin:"anonymous"}},qtcreator:{light:{integrity:"sha384-iEBgHrwi8Hv4dSZBz+MOGvS05rF7I7fGKM2fASQyE9jn2Istg9Qd5dSoK18WyRTB",crossOrigin:"anonymous"},dark:{integrity:"sha384-D6LXJGWNR4QV7gnpuP3ccbvOYoR02td3cU0y7lESABPg/tzCSC4m+y+M2TtrmpHc",crossOrigin:"anonymous"}},stackoverflow:{light:{integrity:"sha384-FMwt7cTGo4aLxZnno5k0xTj0W4gmi48Kwept+y/oQmE6cFk36Kr+QJZOKNOQwORe",crossOrigin:"anonymous"},dark:{integrity:"sha384-iL+x+BroCyHm/p2c6sMA9umXhdCWp2cKe4QUjPeMzHgwXAk+ZxHyIGP3NZTZensU",crossOrigin:"anonymous"}}}},prettier:{standaloneJs:{integrity:"sha384-cBKW1A8TbwohtSsrm+VWpXevI1PWdPmUrozwqTw7aS51JIhz9IvgHHa/bV6icWeL",crossOrigin:"anonymous"},parserMarkdownJs:{integrity:"sha384-kXeeC2HiA6n3rpvz0MOjB7yZo9QjvYNAMihonwR5fdTOFs/rm/Bm3Xg8cOSE4900",crossOrigin:"anonymous"}},cropper:{js:{integrity:"sha384-r+ljwOAhwY4/kdyzMnuBg7MEVoWpTMp5EYUDntB/E9qzNwL9dAEcNrb2XaV+mJc2",crossOrigin:"anonymous"},css:{integrity:"sha384-oMy41mb/qJnpJlpXOF57hSu2KGi47l/UV9+tPNrBOs7/ap5Vubj/3phrCtjutHMQ",crossOrigin:"anonymous"}},iconfont:{integrity:"sha384-HRrf1e8/EiqrIZQftejl7pMTeuLeYczOz7rolAGxgw86N7UjiXkex67Uf2XTZz5z",crossOrigin:"anonymous"},iconfontClass:{integrity:"sha384-81pjilF/gLoQvAfd8madmeylVdv8IagPQaq1C/OZbysLav7k9g+Ir3XD5qK00Q5r",crossOrigin:"anonymous"},screenfull:{js:{integrity:"sha384-ELVAm9p9T4LGCG4lz8hbYalUYAppIpI1zV8IXYDCBUJFiVnV+EeG8vGSYQi+Wi4S",crossOrigin:"anonymous"}},mermaid:{js:{integrity:"sha384-zmipzuFBFDAekHS2uY4mN5cvpcSvgUi3aMjMJ2xnVRsU2kDHBtqLOJRnianHJeP1",crossOrigin:"anonymous"}},katex:{js:{integrity:"sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8",crossOrigin:"anonymous"},css:{integrity:"sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV",crossOrigin:"anonymous"}}},ft={editorExtensions:{highlight:{js:iW,css:th},prettier:{standaloneJs:nb.main,parserMarkdownJs:nb.markdown},cropper:{...rW},iconfont:eb,iconfontClass:tb,screenfull:{js:oW},mermaid:{js:aW},katex:{...OW}},editorExtensionsAttrs:{},editorConfig:{languageUserDefined:{},mermaidTemplate:{},renderDelay:500,zIndex:2e4},codeMirrorExtensions:(e,t)=>t,markdownItConfig:()=>{},markdownItPlugins:e=>e,iconfontType:"svg",mermaidConfig:e=>e},sW=e=>Kd(ft,e),tu=170,uW=g.defineComponent({setup(){return()=>g.createVNode("div",{class:`${R}-divider`},null)}}),Gn=({instance:e,ctx:t,props:n={}},i="default")=>{const r=(e==null?void 0:e.$slots[i])||(t==null?void 0:t.slots[i]);return(r?r(e):"")||n[i]},cW={overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},xa=g.defineComponent({props:cW,setup(e,t){const n=`${R}-dropdown-hidden`,i=g.reactive({overlayClass:[n],overlayStyle:{},triggerHover:!1,overlayHover:!1}),r=g.ref(),o=g.ref(),a=()=>{var k,P;i.triggerHover=!0;const u=r.value,c=o.value;if(!u||!c)return;const f=u.getBoundingClientRect(),h=u.offsetTop,p=u.offsetLeft,m=f.height,Q=f.width,$=((k=document.querySelector(e.relative))==null?void 0:k.scrollLeft)||0,b=((P=document.querySelector(e.relative))==null?void 0:P.clientWidth)||0;let S=p-c.offsetWidth/2+Q/2-$;S+c.offsetWidth>$+b&&(S=$+b-c.offsetWidth),S<0&&(S=0),i.overlayStyle={...i.overlayStyle,top:h+m+"px",left:S+"px"},e.onChange(!0)},O=()=>{i.overlayHover=!0};g.watch(()=>e.visible,u=>{u?i.overlayClass=i.overlayClass.filter(c=>c!==n):i.overlayClass.push(n)});let l=-1;const s=u=>{r.value===u.target?i.triggerHover=!1:i.overlayHover=!1,clearTimeout(l),l=window.setTimeout(()=>{!i.overlayHover&&!i.triggerHover&&e.onChange(!1)},10)};return g.onMounted(()=>{r.value.addEventListener("mouseenter",a),r.value.addEventListener("mouseleave",s),o.value.addEventListener("mouseenter",O),o.value.addEventListener("mouseleave",s)}),g.onBeforeUnmount(()=>{r.value.removeEventListener("mouseenter",a),r.value.removeEventListener("mouseleave",s),o.value.removeEventListener("mouseenter",O),o.value.removeEventListener("mouseleave",s)}),()=>{const u=Gn({ctx:t}),c=Gn({props:e,ctx:t},"overlay"),f=g.cloneVNode(u instanceof Array?u[0]:u,{ref:r,key:"cloned-dropdown-trigger"}),h=g.createVNode("div",{class:[`${R}-dropdown`,i.overlayClass],style:i.overlayStyle,ref:o},[g.createVNode("div",{class:`${R}-dropdown-overlay`},[c instanceof Array?c[0]:c])]);return[f,h]}}});class fW{constructor(){Xe(this,"pools",{})}remove(t,n,i){const o=this.pools[t]&&this.pools[t][n];o&&(this.pools[t][n]=o.filter(a=>a!==i))}clear(t){this.pools[t]={}}on(t,n){return this.pools[t]||(this.pools[t]={}),this.pools[t][n.name]||(this.pools[t][n.name]=[]),this.pools[t][n.name].push(n.callback),this.pools[t][n.name].includes(n.callback)}emit(t,n,...i){this.pools[t]||(this.pools[t]={});const o=this.pools[t][n];o&&o.forEach(a=>{try{a(...i)}catch(O){console.error(`${n} monitor event exception!`,O)}})}}const B=new fW,dW={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},showToolbarName:{type:Boolean}},nu="onSave",nh="changeCatalogVisible",ib="changeFullscreen",rb="pageFullscreenChanged",ob="fullscreenChanged",ab="previewChanged",Ob="previewOnlyChanged",lb="htmlPreviewChanged",sb="catalogVisibleChanged",iu="buildFinished",vo="errorCatcher",Ce="replace",ru="uploadImage",ih="openModals",ub="ctrlZ",cb="ctrlShiftZ",ou="catalogChanged",fb="pushCatalog",rh="rerender",db="eventListener",hb=(e,t)=>{const n=i=>{const r=e.parentElement||document.body,o=r.offsetWidth,a=r.offsetHeight,{clientWidth:O}=document.documentElement,{clientHeight:l}=document.documentElement,s=i.offsetX,u=i.offsetY,c=h=>{let p=h.x+document.body.scrollLeft-document.body.clientLeft-s,m=h.y+document.body.scrollTop-document.body.clientTop-u;p=p<1?1:p<O-o-1?p:O-o-1,m=m<1?1:m<l-a-1?m:l-a-1,t?t(p,m):(r.style.left=`${p}px`,r.style.top=`${m}px`)};document.addEventListener("mousemove",c);const f=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f)};document.addEventListener("mouseup",f)};return e.addEventListener("mousedown",n),()=>{e.removeEventListener("mousedown",n)}},un=(e,t,n="")=>{var r;const i=document.getElementById(t.id);if(i)n!==""&&(Reflect.get(window,n)?(r=t.onload)==null||r.call(i,new Event("load")):t.onload&&i.addEventListener("load",t.onload));else{const o={...t};o.onload=null;const a=pW(e,o);t.onload&&a.addEventListener("load",t.onload),document.head.appendChild(a)}},hW=(e,t)=>{const n=document.getElementById(t.id);n==null||n.remove(),un(e,t)},pW=(e,t)=>{const n=document.createElement(e);return Object.keys(t).forEach(i=>{t[i]!==void 0&&(n[i]=t[i])}),n},mW=e=>{const t=g.inject("editorId"),{editorExtensions:n,editorExtensionsAttrs:i}=ft;let r=n.screenfull.instance;const o=g.ref(!1),a=s=>{if(!r){B.emit(t,vo,{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(o.value=!0,(s===void 0?!r.isFullscreen:s)?r.request():r.exit()):console.error("browser does not support screenfull!")},O=()=>{r&&r.isEnabled&&r.on("change",()=>{(o.value||e.setting.fullscreen)&&(o.value=!1,e.updateSetting("fullscreen"))})},l=()=>{r=window.screenfull,O()};return g.onMounted(()=>{var s;O(),r||un("script",{...(s=i.screenfull)==null?void 0:s.js,src:n.screenfull.js,id:`${R}-screenfull`,onload:l},"screenfull")}),g.onMounted(()=>{B.on(t,{name:ib,callback:a})}),{fullscreenHandler:a}},gW={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},$W=g.defineComponent({name:"TableShape",props:gW,setup(e){const t=g.reactive({x:-1,y:-1}),n=()=>{const r=[...e.tableShape];return(!r[2]||r[2]<r[0])&&(r[2]=r[0]),(!r[3]||r[3]<r[3])&&(r[3]=r[1]),r},i=g.ref(n());return g.watch(()=>e.tableShape,()=>{i.value=n()}),()=>g.createVNode("div",{class:`${R}-table-shape`,onMouseleave:()=>{i.value=n(),t.x=-1,t.y=-1}},[new Array(i.value[1]).fill("").map((r,o)=>g.createVNode("div",{class:`${R}-table-shape-row`,key:`table-shape-row-${o}`},[new Array(i.value[0]).fill("").map((a,O)=>g.createVNode("div",{class:`${R}-table-shape-col`,key:`table-shape-col-${O}`,onMouseenter:()=>{t.x=o,t.y=O,O+1===i.value[0]&&O+1<i.value[2]?i.value[0]++:O+2<i.value[0]&&i.value[0]>e.tableShape[0]&&i.value[0]--,o+1===i.value[1]&&o+1<i.value[3]?i.value[1]++:o+2<i.value[1]&&i.value[1]>e.tableShape[1]&&i.value[1]--},onClick:()=>{e.onSelected(t)}},[g.createVNode("div",{class:[`${R}-table-shape-col-default`,o<=t.x&&O<=t.y&&`${R}-table-shape-col-include`]},null)]))]))])}}),QW=g.defineComponent({props:{name:{type:String,default:""}},setup(e){return()=>ft.iconfontType==="svg"?g.createVNode("svg",{class:`${R}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#${R}-icon-${e.name}`},null)]):g.createVNode("i",{class:`${R}-iconfont ${R}-icon-${e.name}`},null)}}),ve=g.defineComponent({props:{name:{type:String,default:""}},setup(e){const t=g.inject("customIcon");return()=>{const n=t.value[e.name];return typeof n=="object"?typeof n.component=="object"?g.h(n.component,n.props):g.createVNode("span",{innerHTML:n.component},null):g.createVNode(QW,{name:e.name},null)}}}),bW=(e,t="image.png")=>{const n=e.split(","),i=n[0].match(/:(.*?);/);if(i){const r=i[1],o=atob(n[1]);let a=o.length;const O=new Uint8Array(a);for(;a--;)O[a]=o.charCodeAt(a);return new File([O],t,{type:r})}return null},yW=e=>{if(!e)return e;const t=e.split(`
2
- `),n=['<span rn-wrapper aria-hidden="true">'];return t.forEach(()=>{n.push("<span></span>")}),n.push("</span>"),`<span class="${R}-code-block">${e}</span>${n.join("")}`},SW=(e,t)=>{if(!e||!t)return 0;const n=e==null?void 0:e.getBoundingClientRect();if(t===document.documentElement)return n.top-t.clientTop;const i=t==null?void 0:t.getBoundingClientRect();return n.top-i.top},PW=(()=>{let e=0;return t=>t+ ++e})(),pb=(()=>{let e=0;return()=>++e})(),kW={title:{type:String,default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String},style:{type:Object,default:()=>({})}},wo=g.defineComponent({name:"MdModal",props:kW,emits:["onClose"],setup(e,t){const n=g.inject("theme"),i=g.ref(e.visible),r=g.ref([`${R}-modal`]),o=g.ref(),a=g.ref(),O=g.ref(),l=g.shallowRef();let s=()=>{};const u=g.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),c=g.computed(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height});return g.watch(()=>e.isFullscreen,f=>{f?s():g.nextTick(()=>{s=hb(a.value,(h,p)=>{u.initPos.left=h+"px",u.initPos.top=p+"px"})})}),g.watch(()=>e.visible,f=>{f?(u.maskStyle.zIndex=ft.editorConfig.zIndex+pb(),u.modalStyle.zIndex=ft.editorConfig.zIndex+pb(),r.value.push("zoom-in"),i.value=f,g.nextTick(()=>{const h=o.value.offsetWidth/2,p=o.value.offsetHeight/2,m=document.documentElement.clientWidth/2,Q=document.documentElement.clientHeight/2;u.initPos.left=m-h+"px",u.initPos.top=Q-p+"px",e.isFullscreen||(s=hb(a.value,($,b)=>{u.initPos.left=$+"px",u.initPos.top=b+"px"}))}),setTimeout(()=>{r.value=r.value.filter(h=>h!=="zoom-in")},140)):(r.value.push("zoom-out"),s(),setTimeout(()=>{r.value=r.value.filter(h=>h!=="zoom-out"),i.value=f},130))}),g.onMounted(()=>{O.value=document.body}),()=>{const f=Gn({ctx:t}),h=Gn({props:e,ctx:t},"title");return O.value?g.createVNode(g.Teleport,{to:O.value},{default:()=>[g.createVNode("div",{ref:l,class:`${R}-modal-container`,"data-theme":n.value},[g.createVNode("div",{class:e.class,style:{...e.style,display:i.value?"block":"none"}},[g.createVNode("div",{class:`${R}-modal-mask`,style:u.maskStyle,onClick:()=>{e.onClose?e.onClose():t.emit("onClose")}},null),g.createVNode("div",{class:r.value,style:{...u.modalStyle,...u.initPos,...c.value},ref:o},[g.createVNode("div",{class:`${R}-modal-header`,ref:a},[h||""]),g.createVNode("div",{class:`${R}-modal-body`},[f]),g.createVNode("div",{class:`${R}-modal-func`},[e.showAdjust&&g.createVNode("div",{class:`${R}-modal-adjust`,onClick:p=>{p.stopPropagation(),e.isFullscreen?u.initPos=u.historyPos:(u.historyPos=u.initPos,u.initPos={left:"0",top:"0"}),e.onAdjust(!e.isFullscreen)}},[g.createVNode(ve,{name:e.isFullscreen?"suoxiao":"fangda"},null)]),g.createVNode("div",{class:`${R}-modal-close`,onClick:p=>{p.stopPropagation(),e.onClose?e.onClose():t.emit("onClose")}},[g.createVNode(ve,{name:"close"},null)])])])])])]}):""}}});wo.install=e=>(e.component(wo.name,wo),e);const xW={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},vW=g.defineComponent({props:xW,setup(e){const t=g.inject("usedLanguageText"),n=g.inject("editorId"),i=g.computed(()=>{var o,a;switch(e.type){case"link":return(o=t.value.linkModalTips)==null?void 0:o.linkTitle;case"image":return(a=t.value.linkModalTips)==null?void 0:a.imageTitle;default:return""}}),r=g.reactive({desc:"",url:""});return g.watch(()=>e.visible,o=>{o||setTimeout(()=>{r.desc="",r.url=""},200)}),()=>g.createVNode(wo,{title:i.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var o,a,O,l,s;return[g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("label",{class:`${R}-label`,for:`link-desc-${n}`},[(o=t.value.linkModalTips)==null?void 0:o.descLabel]),g.createVNode("input",{placeholder:(a=t.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${R}-input`,id:`link-desc-${n}`,type:"text",value:r.desc,onChange:u=>{r.desc=u.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("label",{class:`${R}-label`,for:`link-url-${n}`},[(O=t.value.linkModalTips)==null?void 0:O.urlLabel]),g.createVNode("input",{placeholder:(l=t.value.linkModalTips)==null?void 0:l.urlLabelPlaceHolder,class:`${R}-input`,id:`link-url-${n}`,type:"text",value:r.url,onChange:u=>{r.url=u.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("button",{class:[`${R}-btn`,`${R}-btn-row`],type:"button",onClick:()=>{e.onOk(r),r.desc="",r.url=""}},[(s=t.value.linkModalTips)==null?void 0:s.buttonOK])])]}})}}),wW={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},XW=g.defineComponent({props:wW,setup(e){const t=g.inject("usedLanguageText"),n=g.inject("editorId");let i=ft.editorExtensions.cropper.instance;const r=g.ref(),o=g.ref(),a=g.ref(),O=g.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let l=null;g.watch(()=>e.visible,()=>{e.visible&&!O.cropperInited&&(i=i||window.Cropper,r.value.onchange=()=>{if(!i){B.emit(n,vo,{name:"Cropper",message:"Cropper is undefined"});return}const u=r.value.files||[];if(O.imgSelected=!0,(u==null?void 0:u.length)>0){const c=new FileReader;c.onload=f=>{O.imgSrc=f.target.result,g.nextTick(()=>{l=new i(o.value,{viewMode:2,preview:`.${R}-clip-preview-target`})})},c.readAsDataURL(u[0])}})}),g.watch(()=>[O.imgSelected],()=>{a.value.style=""}),g.watch(()=>O.isFullscreen,()=>{g.nextTick(()=>{l==null||l.destroy(),a.value.style="",o.value&&(l=new i(o.value,{viewMode:2,preview:`.${R}-clip-preview-target`}))})});const s=()=>{l.clear(),l.destroy(),l=null,r.value.value="",O.imgSelected=!1};return()=>{var u;return g.createVNode(wo,{class:`${R}-modal-clip`,title:(u=t.value.clipModalTips)==null?void 0:u.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:O.isFullscreen,onAdjust:c=>{O.isFullscreen=c},width:"668px",height:"421px"},{default:()=>{var c,f;return[g.createVNode("div",{class:`${R}-form-item ${R}-clip`},[g.createVNode("div",{class:`${R}-clip-main`},[O.imgSelected?g.createVNode("div",{class:`${R}-clip-cropper`},[g.createVNode("img",{src:O.imgSrc,ref:o,style:{display:"none"},alt:""},null),g.createVNode("div",{class:`${R}-clip-delete`,onClick:s},[g.createVNode(ve,{name:"delete"},null)])]):g.createVNode("div",{class:`${R}-clip-upload`,onClick:()=>{r.value.click()}},[g.createVNode(ve,{name:"upload"},null)])]),g.createVNode("div",{class:`${R}-clip-preview`},[g.createVNode("div",{class:`${R}-clip-preview-target`,ref:a},null)])]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("button",{class:`${R}-btn`,type:"button",onClick:()=>{if(l){const h=l.getCroppedCanvas();B.emit(n,ru,[bW(h.toDataURL("image/png"))],e.onOk),s()}}},[((c=t.value.clipModalTips)==null?void 0:c.buttonUpload)||((f=t.value.linkModalTips)==null?void 0:f.buttonOK)])]),g.createVNode("input",{ref:r,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),TW={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},_W=g.defineComponent({props:TW,setup(e){return()=>g.createVNode(g.Fragment,null,[g.createVNode(vW,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),g.createVNode(XW,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),RW=g.defineComponent({name:"MDEditorToolbar",props:dW,setup(e){const t=g.inject("editorId"),n=g.inject("usedLanguageText"),i=g.inject("theme"),r=g.inject("previewTheme"),o=g.inject("language"),{fullscreenHandler:a}=mW(e),O=`${t}-toolbar-wrapper`,l=g.ref(),s=g.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),u=($,b)=>{B.emit(t,Ce,$,b)},c=g.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=g.ref();g.onMounted(()=>{B.on(t,{name:ih,callback($){c.type=$,c.linkVisible=!0}})});const h=g.computed(()=>{const $=e.toolbars.filter(P=>!e.toolbarsExclude.includes(P)),b=$.indexOf("="),S=b===-1?$:$.slice(0,b+1),k=b===-1?[]:$.slice(b,Number.MAX_SAFE_INTEGER);return[S,k]}),p=g.ref(),m=()=>{B.emit(t,ru,Array.from(p.value.files||[])),p.value.value=""};g.onMounted(()=>{p.value.addEventListener("change",m)});const Q=$=>{var b,S,k,P,z,w,x,v,E,q,V,Y,X,U,W,Z,N,F,G,I,re,Se,Et,L,Oe,Re,Ae,Pt,ui,jn,Ei,UO,$a,Zr,EO,YO,Qa,Rd,zd,ba,Wd,sr,kt,So,ya,Ur,qd,Fs,Zd,Ee,Ud,VO,Po,CO,Ed,jO,ci,Yd,Sa,Vd,AO,yn,Ms,Cd,Yi,jd,Bs,Hs,Ad;if(Jd.includes($))switch($){case"-":return g.createVNode(uW,null,null);case"bold":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(b=n.value.toolbarTips)==null?void 0:b.bold,onClick:()=>{u("bold")}},[g.createVNode(ve,{name:"bold"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(S=n.value.toolbarTips)==null?void 0:S.bold])]);case"underline":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(k=n.value.toolbarTips)==null?void 0:k.underline,onClick:()=>{u("underline")}},[g.createVNode(ve,{name:"underline"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(P=n.value.toolbarTips)==null?void 0:P.underline])]);case"italic":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(z=n.value.toolbarTips)==null?void 0:z.italic,onClick:()=>{u("italic")}},[g.createVNode(ve,{name:"italic"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(w=n.value.toolbarTips)==null?void 0:w.italic])]);case"strikeThrough":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(x=n.value.toolbarTips)==null?void 0:x.strikeThrough,onClick:()=>{u("strikeThrough")}},[g.createVNode(ve,{name:"strike-through"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(v=n.value.toolbarTips)==null?void 0:v.strikeThrough])]);case"title":return g.createVNode(xa,{relative:`#${O}`,visible:s.title,onChange:be=>{s.title=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.title=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h1")}},[(E=n.value.titleItem)==null?void 0:E.h1]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h2")}},[(q=n.value.titleItem)==null?void 0:q.h2]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h3")}},[(V=n.value.titleItem)==null?void 0:V.h3]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h4")}},[(Y=n.value.titleItem)==null?void 0:Y.h4]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h5")}},[(X=n.value.titleItem)==null?void 0:X.h5]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h6")}},[(U=n.value.titleItem)==null?void 0:U.h6])])},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.title},[g.createVNode(ve,{name:"title"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.title])])]}});case"sub":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(W=n.value.toolbarTips)==null?void 0:W.sub,onClick:()=>{u("sub")}},[g.createVNode(ve,{name:"sub"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Z=n.value.toolbarTips)==null?void 0:Z.sub])]);case"sup":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(N=n.value.toolbarTips)==null?void 0:N.sup,onClick:()=>{u("sup")}},[g.createVNode(ve,{name:"sup"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(F=n.value.toolbarTips)==null?void 0:F.sup])]);case"quote":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(G=n.value.toolbarTips)==null?void 0:G.quote,onClick:()=>{u("quote")}},[g.createVNode(ve,{name:"quote"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(I=n.value.toolbarTips)==null?void 0:I.quote])]);case"unorderedList":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(re=n.value.toolbarTips)==null?void 0:re.unorderedList,onClick:()=>{u("unorderedList")}},[g.createVNode(ve,{name:"unordered-list"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Se=n.value.toolbarTips)==null?void 0:Se.unorderedList])]);case"orderedList":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Et=n.value.toolbarTips)==null?void 0:Et.orderedList,onClick:()=>{u("orderedList")}},[g.createVNode(ve,{name:"ordered-list"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(L=n.value.toolbarTips)==null?void 0:L.orderedList])]);case"task":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Oe=n.value.toolbarTips)==null?void 0:Oe.task,onClick:()=>{u("task")}},[g.createVNode(ve,{name:"task"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Re=n.value.toolbarTips)==null?void 0:Re.task])]);case"codeRow":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ae=n.value.toolbarTips)==null?void 0:Ae.codeRow,onClick:()=>{u("codeRow")}},[g.createVNode(ve,{name:"code-row"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Pt=n.value.toolbarTips)==null?void 0:Pt.codeRow])]);case"code":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(ui=n.value.toolbarTips)==null?void 0:ui.code,onClick:()=>{u("code")}},[g.createVNode(ve,{name:"code"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(jn=n.value.toolbarTips)==null?void 0:jn.code])]);case"link":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ei=n.value.toolbarTips)==null?void 0:Ei.link,onClick:()=>{c.type="link",c.linkVisible=!0}},[g.createVNode(ve,{name:"link"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(UO=n.value.toolbarTips)==null?void 0:UO.link])]);case"image":return e.noUploadImg?g.createVNode("div",{class:`${R}-toolbar-item`,title:($a=n.value.toolbarTips)==null?void 0:$a.image,onClick:()=>{c.type="image",c.linkVisible=!0}},[g.createVNode(ve,{name:"image"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Zr=n.value.toolbarTips)==null?void 0:Zr.image])]):g.createVNode(xa,{relative:`#${O}`,visible:s.image,onChange:be=>{s.image=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.title=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{c.type="image",c.linkVisible=!0}},[(EO=n.value.imgTitleItem)==null?void 0:EO.link]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{p.value.click()}},[(YO=n.value.imgTitleItem)==null?void 0:YO.upload]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{c.clipVisible=!0}},[(Qa=n.value.imgTitleItem)==null?void 0:Qa.clip2upload])])},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.image},[g.createVNode(ve,{name:"image"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.image])])]}});case"table":return g.createVNode(xa,{relative:`#${O}`,visible:s.table,onChange:be=>{s.table=be},key:"bar-table",overlay:g.createVNode($W,{tableShape:e.tableShape,onSelected:be=>{u("table",{selectedShape:be})}},null)},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.table},[g.createVNode(ve,{name:"table"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.table])])]}});case"revoke":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Rd=n.value.toolbarTips)==null?void 0:Rd.revoke,onClick:()=>{B.emit(t,ub)}},[g.createVNode(ve,{name:"revoke"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(zd=n.value.toolbarTips)==null?void 0:zd.revoke])]);case"next":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(ba=n.value.toolbarTips)==null?void 0:ba.next,onClick:()=>{B.emit(t,cb)}},[g.createVNode(ve,{name:"next"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Wd=n.value.toolbarTips)==null?void 0:Wd.next])]);case"save":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(sr=n.value.toolbarTips)==null?void 0:sr.save,onClick:()=>{B.emit(t,nu)}},[g.createVNode(ve,{name:"baocun"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(kt=n.value.toolbarTips)==null?void 0:kt.save])]);case"prettier":return e.noPrettier?"":g.createVNode("div",{class:`${R}-toolbar-item`,title:(So=n.value.toolbarTips)==null?void 0:So.prettier,onClick:()=>{u("prettier")}},[g.createVNode(ve,{name:"prettier"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(ya=n.value.toolbarTips)==null?void 0:ya.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ur=n.value.toolbarTips)==null?void 0:Ur.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[g.createVNode(ve,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(qd=n.value.toolbarTips)==null?void 0:qd.pageFullscreen])]);case"fullscreen":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Fs=n.value.toolbarTips)==null?void 0:Fs.fullscreen,onClick:()=>{a()}},[g.createVNode(ve,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Zd=n.value.toolbarTips)==null?void 0:Zd.fullscreen])]);case"preview":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ee=n.value.toolbarTips)==null?void 0:Ee.preview,onClick:()=>{e.updateSetting("preview")}},[g.createVNode(ve,{name:"preview"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ud=n.value.toolbarTips)==null?void 0:Ud.preview])]);case"previewOnly":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(VO=n.value.toolbarTips)==null?void 0:VO.previewOnly,onClick:()=>{e.updateSetting("previewOnly")}},[g.createVNode(ve,{name:"preview-only"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Po=n.value.toolbarTips)==null?void 0:Po.previewOnly])]);case"htmlPreview":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(CO=n.value.toolbarTips)==null?void 0:CO.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[g.createVNode(ve,{name:"coding"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ed=n.value.toolbarTips)==null?void 0:Ed.htmlPreview])]);case"catalog":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(jO=n.value.toolbarTips)==null?void 0:jO.catalog,onClick:()=>{B.emit(t,nh)},key:"bar-catalog"},[g.createVNode(ve,{name:"catalog"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(ci=n.value.toolbarTips)==null?void 0:ci.catalog])]);case"github":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Yd=n.value.toolbarTips)==null?void 0:Yd.github,onClick:()=>eW("https://github.com/imzbf/md-editor-v3")},[g.createVNode(ve,{name:"github"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Sa=n.value.toolbarTips)==null?void 0:Sa.github])]);case"mermaid":return g.createVNode(xa,{relative:`#${O}`,visible:s.mermaid,onChange:be=>{s.mermaid=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.mermaid=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("flow")}},[(Vd=n.value.mermaid)==null?void 0:Vd.flow]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("sequence")}},[(AO=n.value.mermaid)==null?void 0:AO.sequence]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("gantt")}},[(yn=n.value.mermaid)==null?void 0:yn.gantt]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("class")}},[(Ms=n.value.mermaid)==null?void 0:Ms.class]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("state")}},[(Cd=n.value.mermaid)==null?void 0:Cd.state]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("pie")}},[(Yi=n.value.mermaid)==null?void 0:Yi.pie]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("relationship")}},[(jd=n.value.mermaid)==null?void 0:jd.relationship]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("journey")}},[(Bs=n.value.mermaid)==null?void 0:Bs.journey])]),key:"bar-mermaid"},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.mermaid},[g.createVNode(ve,{name:"mermaid"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.mermaid])])]}});case"katex":return g.createVNode(xa,{relative:`#${O}`,visible:s.katex,onChange:be=>{s.katex=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.katex=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-katex`,onClick:()=>{u("katexInline")}},[(Hs=n.value.katex)==null?void 0:Hs.inline]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-katex`,onClick:()=>{u("katexBlock")}},[(Ad=n.value.katex)==null?void 0:Ad.block])]),key:"bar-katex"},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.katex},[g.createVNode(ve,{name:"formula"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.katex])])]}})}else if(e.defToolbars instanceof Array){const be=e.defToolbars[$];return be?g.cloneVNode(be,{theme:i.value,previewTheme:r.value,language:o.value,insert(ur){B.emit(t,Ce,"universal",{generate:ur})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const be=e.defToolbars.children[$];return be?g.cloneVNode(be,{theme:i.value,previewTheme:r.value,language:o.value,insert(ur){B.emit(t,Ce,"universal",{generate:ur})}}):""}else return""};return g.watch(()=>e.toolbars,()=>{g.nextTick(()=>{l.value&&nW(l.value)})},{immediate:!0}),()=>{const $=h.value[0].map(S=>Q(S)),b=h.value[1].map(S=>Q(S));return g.createVNode(g.Fragment,null,[e.toolbars.length>0&&g.createVNode("div",{class:`${R}-toolbar-wrapper`,ref:l,id:O},[g.createVNode("div",{class:[`${R}-toolbar`,e.showToolbarName&&`${R}-stn`]},[g.createVNode("div",{class:`${R}-toolbar-left`,ref:f},[$]),g.createVNode("div",{class:`${R}-toolbar-right`},[b])])]),g.createVNode("input",{ref:p,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),g.createVNode(_W,{linkVisible:c.linkVisible,clipVisible:c.clipVisible,type:c.type,onCancel:()=>{c.linkVisible=!1,c.clipVisible=!1},onOk:S=>{S&&u(c.type,{desc:S.desc,url:S.url,transform:c.type==="image"}),c.linkVisible=!1,c.clipVisible=!1}},null)])}}}),zW=`.${R}-preview > [data-line]`,WW=(e,t)=>{const n=Bd(()=>{e.removeEventListener("scroll",i),e.addEventListener("scroll",i),t.removeEventListener("scroll",i),t.addEventListener("scroll",i)},50),i=r=>{const o=e.clientHeight,a=t.clientHeight,O=e.scrollHeight,l=t.scrollHeight,s=(O-o)/(l-a);r.target===e?(t.removeEventListener("scroll",i),t.scrollTo({top:e.scrollTop/s}),n()):(e.removeEventListener("scroll",i),e.scrollTo({top:t.scrollTop*s}),n())};return[()=>{n().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",i),t.removeEventListener("scroll",i)}]},qW=(e,t,n)=>{const{view:i}=n,r=tW(),o=Q=>i.lineBlockAt(i.state.doc.line(Q).from).top,a=Q=>i.lineBlockAt(i.state.doc.line(Q).from).height;let O=[],l=[],s=[];const u=()=>{O=[],l=[],s=[],l=l.concat(Array.from(t.querySelectorAll(zW)));const Q=l.map(k=>Number(k.dataset.line)+1);s=s.concat(Q);const{lines:$}=i.state.doc;let b=1,S=Q.shift()??$;for(let k=1;k<=$;k++)k===S&&(b=k,S=Q.shift()||$+1),O.push({start:b,end:S-1})};let c=0,f=0;const h=()=>{var X,U;if(f!==0)return!1;c++;const{scrollDOM:Q,contentHeight:$}=i;let b=+getComputedStyle(t).paddingTop.replace("px","");const S=i.lineBlockAtHeight(Q.scrollTop),{number:k}=i.state.doc.lineAt(S.from),P=O[k-1];if(!P)return!1;let z=o(P.end)+a(P.end),w=0;const x=o(P.start),v=t.querySelector(`[data-line="${P.start-1}"]`)||((X=t.firstElementChild)==null?void 0:X.firstElementChild),E=t.querySelector(`[data-line="${P.end}"]`)||((U=t.lastElementChild)==null?void 0:U.lastElementChild);let q=0,V=0;x===0?(w=Q.scrollTop/z,v===E?(b=0,z=$-Q.offsetHeight,q=E.offsetTop+E.offsetHeight-t.clientHeight):q=E.offsetTop):(w=(Q.scrollTop-x)/(z-x),V=v.offsetTop,q=E.offsetTop-V),z>=Q.scrollHeight-Q.clientHeight&&(w=(Q.scrollTop-x)/(Q.scrollHeight-Q.clientHeight-x),V=v.offsetTop,q=t.scrollHeight-t.clientHeight-V+10);const Y=V-b+q*w;r(t,Y,()=>{c--})},p=()=>{var Y,X,U,W,Z,N;if(c!==0)return;f++;const{scrollDOM:Q}=i,$=t.scrollTop,b=t.scrollHeight;let S=(Y=t.firstElementChild)==null?void 0:Y.firstElementChild,k=(X=t.firstElementChild)==null?void 0:X.lastElementChild;if(s.length>0){let F=Math.ceil(Number(s[s.length-1])*($/b)),G=s.findLastIndex(I=>I<=F);G=G===-1?0:G,F=s[G];for(let I=G;I>=0&&I<s.length;)if(l[I].offsetTop>$){if(I-1>=0){I--;continue}F=-1,G=I;break}else{if(I+1<s.length&&l[I+1].offsetTop<$){I++;continue}F=s[I],G=I;break}switch(F){case-1:{S=(U=t.firstElementChild)==null?void 0:U.firstElementChild,k=l[G];break}case s.length-1:{S=l[G],k=(W=t.firstElementChild)==null?void 0:W.lastElementChild;break}default:S=l[G],k=l[G+1===l.length?G:G+1]}}const P=S===((Z=t.firstElementChild)==null?void 0:Z.firstElementChild)?0:S.offsetTop;let z=k.offsetTop,w=0;const{start:x,end:v}=O[Number(S.dataset.line||0)],E=o(x);let q=o(v===i.state.doc.lines?v:v+1),V=0;q>Q.scrollHeight-Q.clientHeight||k.scrollTop>t.scrollHeight-t.clientHeight?(w=Math.max(($-P)/(t.scrollHeight-P-t.clientHeight),0),q=o(i.state.doc.lines)+a(i.state.doc.lines),V=8+q-E-e.clientHeight):S===((N=t.firstElementChild)==null?void 0:N.firstElementChild)?(S===k&&(z=k.offsetTop+k.offsetHeight+ +getComputedStyle(k).marginBottom.replace("px","")),V=q,w=Math.max($/z,0)):(w=Math.max(($-P)/(z-P),0),V=q-E),r(e,E+V*w,()=>{f--})},m=KQ(Q=>{var k;const{scrollDOM:$,contentHeight:b}=i,S=$.clientHeight;if(b<=S||t.firstElementChild.clientHeight<=t.clientHeight)return!1;if(i.state.doc.lines<((k=O[O.length-1])==null?void 0:k.end))return u(),!1;Q.target===e?h():p()},1);return[()=>{u(),e.addEventListener("scroll",m),t.addEventListener("scroll",m),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",m),t.removeEventListener("scroll",m)}]},ZW=(e,t,n)=>{const i=g.inject("editorId");let r=()=>{},o=()=>{};const a=()=>{r();const O=document.querySelector(`#${i} .cm-scroller`),l=document.querySelector(`[id="${i}-preview-wrapper"]`),s=document.querySelector(`[id="${i}-html-wrapper"]`);(l||s)&&([o,r]=(l?qW:WW)(O,l||s,n.value),e.scrollAuto&&o())};g.watch([t,g.toRef(e.setting,"preview"),g.toRef(e.setting,"htmlPreview"),g.toRef(e.setting,"fullscreen"),g.toRef(e.setting,"pageFullscreen")],()=>{g.nextTick(a)}),g.watch(()=>e.scrollAuto,O=>{O?o():r()}),g.watch(()=>e.setting.previewOnly,O=>{O?r():o()}),g.onMounted(a)};let Ye=class Mz{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,i){[t,n]=va(this,t,n);let r=[];return this.decompose(0,t,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),Vi.from(r,this.length-(n-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=va(this,t,n);let i=[];return this.decompose(t,n,i,0),Vi.from(i,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),r=new IO(this),o=new IO(t);for(let a=n,O=n;;){if(r.next(a),o.next(a),a=0,r.lineBreak!=o.lineBreak||r.done!=o.done||r.value!=o.value)return!1;if(O+=r.value.length,r.done||O>=i)return!0}}iter(t=1){return new IO(this,t)}iterRange(t,n=this.length){return new gb(this,t,n)}iterLines(t,n){let i;if(t==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(t).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new $b(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?Mz.empty:t.length<=32?new dt(t):Vi.from(dt.split(t,[]))}};class dt extends Ye{constructor(t,n=UW(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,i,r){for(let o=0;;o++){let a=this.text[o],O=r+a.length;if((n?i:O)>=t)return new EW(r,O,i,a);r=O+1,i++}}decompose(t,n,i,r){let o=t<=0&&n>=this.length?this:new dt(mb(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),O=au(o.text,a.text.slice(),0,o.length);if(O.length<=32)i.push(new dt(O,a.length+o.length));else{let l=O.length>>1;i.push(new dt(O.slice(0,l)),new dt(O.slice(l)))}}else i.push(o)}replace(t,n,i){if(!(i instanceof dt))return super.replace(t,n,i);[t,n]=va(this,t,n);let r=au(this.text,au(i.text,mb(this.text,0,t)),n),o=this.length+i.length-(n-t);return r.length<=32?new dt(r,o):Vi.from(dt.split(r,[]),o)}sliceString(t,n=this.length,i=`
2
+ `),n=['<span rn-wrapper aria-hidden="true">'];return t.forEach(()=>{n.push("<span></span>")}),n.push("</span>"),`<span class="${R}-code-block">${e}</span>${n.join("")}`},SW=(e,t)=>{if(!e||!t)return 0;const n=e==null?void 0:e.getBoundingClientRect();if(t===document.documentElement)return n.top-t.clientTop;const i=t==null?void 0:t.getBoundingClientRect();return n.top-i.top},PW=(()=>{let e=0;return t=>t+ ++e})(),pb=(()=>{let e=0;return()=>++e})(),kW={title:{type:String,default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String},style:{type:Object,default:()=>({})}},wo=g.defineComponent({name:"MdModal",props:kW,emits:["onClose"],setup(e,t){const n=g.inject("theme"),i=g.ref(e.visible),r=g.ref([`${R}-modal`]),o=g.ref(),a=g.ref(),O=g.ref(),l=g.shallowRef();let s=()=>{};const u=g.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),c=g.computed(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height});return g.watch(()=>e.isFullscreen,f=>{f?s():g.nextTick(()=>{s=hb(a.value,(h,p)=>{u.initPos.left=h+"px",u.initPos.top=p+"px"})})}),g.watch(()=>e.visible,f=>{f?(u.maskStyle.zIndex=ft.editorConfig.zIndex+pb(),u.modalStyle.zIndex=ft.editorConfig.zIndex+pb(),r.value.push("zoom-in"),i.value=f,g.nextTick(()=>{const h=o.value.offsetWidth/2,p=o.value.offsetHeight/2,m=document.documentElement.clientWidth/2,Q=document.documentElement.clientHeight/2;u.initPos.left=m-h+"px",u.initPos.top=Q-p+"px",e.isFullscreen||(s=hb(a.value,($,b)=>{u.initPos.left=$+"px",u.initPos.top=b+"px"}))}),setTimeout(()=>{r.value=r.value.filter(h=>h!=="zoom-in")},140)):(r.value.push("zoom-out"),s(),setTimeout(()=>{r.value=r.value.filter(h=>h!=="zoom-out"),i.value=f},130))}),g.onMounted(()=>{O.value=document.body}),()=>{const f=Gn({ctx:t}),h=Gn({props:e,ctx:t},"title");return O.value?g.createVNode(g.Teleport,{to:O.value},{default:()=>[g.createVNode("div",{ref:l,class:`${R}-modal-container`,"data-theme":n.value},[g.createVNode("div",{class:e.class,style:{...e.style,display:i.value?"block":"none"}},[g.createVNode("div",{class:`${R}-modal-mask`,style:u.maskStyle,onClick:()=>{e.onClose?e.onClose():t.emit("onClose")}},null),g.createVNode("div",{class:r.value,style:{...u.modalStyle,...u.initPos,...c.value},ref:o},[g.createVNode("div",{class:`${R}-modal-header`,ref:a},[h||""]),g.createVNode("div",{class:`${R}-modal-body`},[f]),g.createVNode("div",{class:`${R}-modal-func`},[e.showAdjust&&g.createVNode("div",{class:`${R}-modal-adjust`,onClick:p=>{p.stopPropagation(),e.isFullscreen?u.initPos=u.historyPos:(u.historyPos=u.initPos,u.initPos={left:"0",top:"0"}),e.onAdjust(!e.isFullscreen)}},[g.createVNode(ve,{name:e.isFullscreen?"suoxiao":"fangda"},null)]),g.createVNode("div",{class:`${R}-modal-close`,onClick:p=>{p.stopPropagation(),e.onClose?e.onClose():t.emit("onClose")}},[g.createVNode(ve,{name:"close"},null)])])])])])]}):""}}});wo.install=e=>(e.component(wo.name,wo),e);const xW={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},vW=g.defineComponent({props:xW,setup(e){const t=g.inject("usedLanguageText"),n=g.inject("editorId"),i=g.computed(()=>{var o,a;switch(e.type){case"link":return(o=t.value.linkModalTips)==null?void 0:o.linkTitle;case"image":return(a=t.value.linkModalTips)==null?void 0:a.imageTitle;default:return""}}),r=g.reactive({desc:"",url:""});return g.watch(()=>e.visible,o=>{o||setTimeout(()=>{r.desc="",r.url=""},200)}),()=>g.createVNode(wo,{title:i.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var o,a,O,l,s;return[g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("label",{class:`${R}-label`,for:`link-desc-${n}`},[(o=t.value.linkModalTips)==null?void 0:o.descLabel]),g.createVNode("input",{placeholder:(a=t.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${R}-input`,id:`link-desc-${n}`,type:"text",value:r.desc,onChange:u=>{r.desc=u.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("label",{class:`${R}-label`,for:`link-url-${n}`},[(O=t.value.linkModalTips)==null?void 0:O.urlLabel]),g.createVNode("input",{placeholder:(l=t.value.linkModalTips)==null?void 0:l.urlLabelPlaceHolder,class:`${R}-input`,id:`link-url-${n}`,type:"text",value:r.url,onChange:u=>{r.url=u.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("button",{class:[`${R}-btn`,`${R}-btn-row`],type:"button",onClick:()=>{e.onOk(r),r.desc="",r.url=""}},[(s=t.value.linkModalTips)==null?void 0:s.buttonOK])])]}})}}),wW={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},XW=g.defineComponent({props:wW,setup(e){const t=g.inject("usedLanguageText"),n=g.inject("editorId");let i=ft.editorExtensions.cropper.instance;const r=g.ref(),o=g.ref(),a=g.ref(),O=g.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let l=null;g.watch(()=>e.visible,()=>{e.visible&&!O.cropperInited&&(i=i||window.Cropper,r.value.onchange=()=>{if(!i){B.emit(n,vo,{name:"Cropper",message:"Cropper is undefined"});return}const u=r.value.files||[];if(O.imgSelected=!0,(u==null?void 0:u.length)>0){const c=new FileReader;c.onload=f=>{O.imgSrc=f.target.result,g.nextTick(()=>{l=new i(o.value,{viewMode:2,preview:`.${R}-clip-preview-target`})})},c.readAsDataURL(u[0])}})}),g.watch(()=>[O.imgSelected],()=>{a.value.style=""}),g.watch(()=>O.isFullscreen,()=>{g.nextTick(()=>{l==null||l.destroy(),a.value.style="",o.value&&(l=new i(o.value,{viewMode:2,preview:`.${R}-clip-preview-target`}))})});const s=()=>{l.clear(),l.destroy(),l=null,r.value.value="",O.imgSelected=!1};return()=>{var u;return g.createVNode(wo,{class:`${R}-modal-clip`,title:(u=t.value.clipModalTips)==null?void 0:u.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:O.isFullscreen,onAdjust:c=>{O.isFullscreen=c},width:"668px",height:"421px"},{default:()=>{var c,f;return[g.createVNode("div",{class:`${R}-form-item ${R}-clip`},[g.createVNode("div",{class:`${R}-clip-main`},[O.imgSelected?g.createVNode("div",{class:`${R}-clip-cropper`},[g.createVNode("img",{src:O.imgSrc,ref:o,style:{display:"none"},alt:""},null),g.createVNode("div",{class:`${R}-clip-delete`,onClick:s},[g.createVNode(ve,{name:"delete"},null)])]):g.createVNode("div",{class:`${R}-clip-upload`,onClick:()=>{r.value.click()}},[g.createVNode(ve,{name:"upload"},null)])]),g.createVNode("div",{class:`${R}-clip-preview`},[g.createVNode("div",{class:`${R}-clip-preview-target`,ref:a},null)])]),g.createVNode("div",{class:`${R}-form-item`},[g.createVNode("button",{class:`${R}-btn`,type:"button",onClick:()=>{if(l){const h=l.getCroppedCanvas();B.emit(n,ru,[bW(h.toDataURL("image/png"))],e.onOk),s()}}},[((c=t.value.clipModalTips)==null?void 0:c.buttonUpload)||((f=t.value.linkModalTips)==null?void 0:f.buttonOK)])]),g.createVNode("input",{ref:r,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),TW={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},_W=g.defineComponent({props:TW,setup(e){return()=>g.createVNode(g.Fragment,null,[g.createVNode(vW,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),g.createVNode(XW,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),RW=g.defineComponent({name:"MDEditorToolbar",props:dW,setup(e){const t=g.inject("editorId"),n=g.inject("usedLanguageText"),i=g.inject("theme"),r=g.inject("previewTheme"),o=g.inject("language"),{fullscreenHandler:a}=mW(e),O=`${t}-toolbar-wrapper`,l=g.ref(),s=g.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),u=($,b)=>{B.emit(t,Ce,$,b)},c=g.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=g.ref();g.onMounted(()=>{B.on(t,{name:ih,callback($){c.type=$,c.linkVisible=!0}})});const h=g.computed(()=>{const $=e.toolbars.filter(P=>!e.toolbarsExclude.includes(P)),b=$.indexOf("="),S=b===-1?$:$.slice(0,b+1),k=b===-1?[]:$.slice(b,Number.MAX_SAFE_INTEGER);return[S,k]}),p=g.ref(),m=()=>{B.emit(t,ru,Array.from(p.value.files||[])),p.value.value=""};g.onMounted(()=>{p.value.addEventListener("change",m)});const Q=$=>{var b,S,k,P,z,w,x,v,E,q,V,Y,X,U,W,Z,N,F,G,I,re,Se,Et,L,Oe,Re,Ae,Pt,ui,jn,Ei,UO,$a,Zr,EO,YO,Qa,Rd,zd,ba,Wd,sr,kt,So,ya,Ur,qd,Fs,Zd,Ee,Ud,VO,Po,CO,Ed,jO,ci,Yd,Sa,Vd,AO,yn,Ms,Cd,Yi,jd,Bs,Hs,Ad;if(Jd.includes($))switch($){case"-":return g.createVNode(uW,null,null);case"bold":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(b=n.value.toolbarTips)==null?void 0:b.bold,onClick:()=>{u("bold")}},[g.createVNode(ve,{name:"bold"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(S=n.value.toolbarTips)==null?void 0:S.bold])]);case"underline":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(k=n.value.toolbarTips)==null?void 0:k.underline,onClick:()=>{u("underline")}},[g.createVNode(ve,{name:"underline"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(P=n.value.toolbarTips)==null?void 0:P.underline])]);case"italic":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(z=n.value.toolbarTips)==null?void 0:z.italic,onClick:()=>{u("italic")}},[g.createVNode(ve,{name:"italic"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(w=n.value.toolbarTips)==null?void 0:w.italic])]);case"strikeThrough":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(x=n.value.toolbarTips)==null?void 0:x.strikeThrough,onClick:()=>{u("strikeThrough")}},[g.createVNode(ve,{name:"strike-through"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(v=n.value.toolbarTips)==null?void 0:v.strikeThrough])]);case"title":return g.createVNode(xa,{relative:`#${O}`,visible:s.title,onChange:be=>{s.title=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.title=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h1")}},[(E=n.value.titleItem)==null?void 0:E.h1]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h2")}},[(q=n.value.titleItem)==null?void 0:q.h2]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h3")}},[(V=n.value.titleItem)==null?void 0:V.h3]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h4")}},[(Y=n.value.titleItem)==null?void 0:Y.h4]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h5")}},[(X=n.value.titleItem)==null?void 0:X.h5]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-title`,onClick:()=>{u("h6")}},[(U=n.value.titleItem)==null?void 0:U.h6])])},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.title},[g.createVNode(ve,{name:"title"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.title])])]}});case"sub":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(W=n.value.toolbarTips)==null?void 0:W.sub,onClick:()=>{u("sub")}},[g.createVNode(ve,{name:"sub"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Z=n.value.toolbarTips)==null?void 0:Z.sub])]);case"sup":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(N=n.value.toolbarTips)==null?void 0:N.sup,onClick:()=>{u("sup")}},[g.createVNode(ve,{name:"sup"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(F=n.value.toolbarTips)==null?void 0:F.sup])]);case"quote":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(G=n.value.toolbarTips)==null?void 0:G.quote,onClick:()=>{u("quote")}},[g.createVNode(ve,{name:"quote"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(I=n.value.toolbarTips)==null?void 0:I.quote])]);case"unorderedList":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(re=n.value.toolbarTips)==null?void 0:re.unorderedList,onClick:()=>{u("unorderedList")}},[g.createVNode(ve,{name:"unordered-list"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Se=n.value.toolbarTips)==null?void 0:Se.unorderedList])]);case"orderedList":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Et=n.value.toolbarTips)==null?void 0:Et.orderedList,onClick:()=>{u("orderedList")}},[g.createVNode(ve,{name:"ordered-list"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(L=n.value.toolbarTips)==null?void 0:L.orderedList])]);case"task":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Oe=n.value.toolbarTips)==null?void 0:Oe.task,onClick:()=>{u("task")}},[g.createVNode(ve,{name:"task"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Re=n.value.toolbarTips)==null?void 0:Re.task])]);case"codeRow":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ae=n.value.toolbarTips)==null?void 0:Ae.codeRow,onClick:()=>{u("codeRow")}},[g.createVNode(ve,{name:"code-row"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Pt=n.value.toolbarTips)==null?void 0:Pt.codeRow])]);case"code":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(ui=n.value.toolbarTips)==null?void 0:ui.code,onClick:()=>{u("code")}},[g.createVNode(ve,{name:"code"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(jn=n.value.toolbarTips)==null?void 0:jn.code])]);case"link":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ei=n.value.toolbarTips)==null?void 0:Ei.link,onClick:()=>{c.type="link",c.linkVisible=!0}},[g.createVNode(ve,{name:"link"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(UO=n.value.toolbarTips)==null?void 0:UO.link])]);case"image":return e.noUploadImg?g.createVNode("div",{class:`${R}-toolbar-item`,title:($a=n.value.toolbarTips)==null?void 0:$a.image,onClick:()=>{c.type="image",c.linkVisible=!0}},[g.createVNode(ve,{name:"image"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Zr=n.value.toolbarTips)==null?void 0:Zr.image])]):g.createVNode(xa,{relative:`#${O}`,visible:s.image,onChange:be=>{s.image=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.title=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{c.type="image",c.linkVisible=!0}},[(EO=n.value.imgTitleItem)==null?void 0:EO.link]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{p.value.click()}},[(YO=n.value.imgTitleItem)==null?void 0:YO.upload]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-image`,onClick:()=>{c.clipVisible=!0}},[(Qa=n.value.imgTitleItem)==null?void 0:Qa.clip2upload])])},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.image},[g.createVNode(ve,{name:"image"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.image])])]}});case"table":return g.createVNode(xa,{relative:`#${O}`,visible:s.table,onChange:be=>{s.table=be},key:"bar-table",overlay:g.createVNode($W,{tableShape:e.tableShape,onSelected:be=>{u("table",{selectedShape:be})}},null)},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.table},[g.createVNode(ve,{name:"table"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.table])])]}});case"revoke":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Rd=n.value.toolbarTips)==null?void 0:Rd.revoke,onClick:()=>{B.emit(t,ub)}},[g.createVNode(ve,{name:"revoke"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(zd=n.value.toolbarTips)==null?void 0:zd.revoke])]);case"next":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(ba=n.value.toolbarTips)==null?void 0:ba.next,onClick:()=>{B.emit(t,cb)}},[g.createVNode(ve,{name:"next"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Wd=n.value.toolbarTips)==null?void 0:Wd.next])]);case"save":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(sr=n.value.toolbarTips)==null?void 0:sr.save,onClick:()=>{B.emit(t,nu)}},[g.createVNode(ve,{name:"baocun"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(kt=n.value.toolbarTips)==null?void 0:kt.save])]);case"prettier":return e.noPrettier?"":g.createVNode("div",{class:`${R}-toolbar-item`,title:(So=n.value.toolbarTips)==null?void 0:So.prettier,onClick:()=>{u("prettier")}},[g.createVNode(ve,{name:"prettier"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(ya=n.value.toolbarTips)==null?void 0:ya.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ur=n.value.toolbarTips)==null?void 0:Ur.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[g.createVNode(ve,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(qd=n.value.toolbarTips)==null?void 0:qd.pageFullscreen])]);case"fullscreen":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Fs=n.value.toolbarTips)==null?void 0:Fs.fullscreen,onClick:()=>{a()}},[g.createVNode(ve,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Zd=n.value.toolbarTips)==null?void 0:Zd.fullscreen])]);case"preview":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Ee=n.value.toolbarTips)==null?void 0:Ee.preview,onClick:()=>{e.updateSetting("preview")}},[g.createVNode(ve,{name:"preview"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ud=n.value.toolbarTips)==null?void 0:Ud.preview])]);case"previewOnly":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(VO=n.value.toolbarTips)==null?void 0:VO.previewOnly,onClick:()=>{e.updateSetting("previewOnly")}},[g.createVNode(ve,{name:"preview-only"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Po=n.value.toolbarTips)==null?void 0:Po.previewOnly])]);case"htmlPreview":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(CO=n.value.toolbarTips)==null?void 0:CO.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[g.createVNode(ve,{name:"coding"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ed=n.value.toolbarTips)==null?void 0:Ed.htmlPreview])]);case"catalog":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(jO=n.value.toolbarTips)==null?void 0:jO.catalog,onClick:()=>{B.emit(t,nh)},key:"bar-catalog"},[g.createVNode(ve,{name:"catalog"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(ci=n.value.toolbarTips)==null?void 0:ci.catalog])]);case"github":return g.createVNode("div",{class:`${R}-toolbar-item`,title:(Yd=n.value.toolbarTips)==null?void 0:Yd.github,onClick:()=>eW("https://github.com/imzbf/md-editor-v3")},[g.createVNode(ve,{name:"github"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Sa=n.value.toolbarTips)==null?void 0:Sa.github])]);case"mermaid":return g.createVNode(xa,{relative:`#${O}`,visible:s.mermaid,onChange:be=>{s.mermaid=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.mermaid=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("flow")}},[(Vd=n.value.mermaid)==null?void 0:Vd.flow]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("sequence")}},[(AO=n.value.mermaid)==null?void 0:AO.sequence]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("gantt")}},[(yn=n.value.mermaid)==null?void 0:yn.gantt]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("class")}},[(Ms=n.value.mermaid)==null?void 0:Ms.class]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("state")}},[(Cd=n.value.mermaid)==null?void 0:Cd.state]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("pie")}},[(Yi=n.value.mermaid)==null?void 0:Yi.pie]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("relationship")}},[(jd=n.value.mermaid)==null?void 0:jd.relationship]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-mermaid`,onClick:()=>{u("journey")}},[(Bs=n.value.mermaid)==null?void 0:Bs.journey])]),key:"bar-mermaid"},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.mermaid},[g.createVNode(ve,{name:"mermaid"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.mermaid])])]}});case"katex":return g.createVNode(xa,{relative:`#${O}`,visible:s.katex,onChange:be=>{s.katex=be},overlay:g.createVNode("ul",{class:`${R}-menu`,onClick:()=>{s.katex=!1}},[g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-katex`,onClick:()=>{u("katexInline")}},[(Hs=n.value.katex)==null?void 0:Hs.inline]),g.createVNode("li",{class:`${R}-menu-item ${R}-menu-item-katex`,onClick:()=>{u("katexBlock")}},[(Ad=n.value.katex)==null?void 0:Ad.block])]),key:"bar-katex"},{default:()=>{var be,Ke;return[g.createVNode("div",{class:`${R}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.katex},[g.createVNode(ve,{name:"formula"},null),e.showToolbarName&&g.createVNode("div",{class:`${R}-toolbar-item-name`},[(Ke=n.value.toolbarTips)==null?void 0:Ke.katex])])]}})}else if(e.defToolbars instanceof Array){const be=e.defToolbars[$];return be?g.cloneVNode(be,{theme:i.value,previewTheme:r.value,language:o.value,insert(ur){B.emit(t,Ce,"universal",{generate:ur})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const be=e.defToolbars.children[$];return be?g.cloneVNode(be,{theme:i.value,previewTheme:r.value,language:o.value,insert(ur){B.emit(t,Ce,"universal",{generate:ur})}}):""}else return""};return g.watch(()=>e.toolbars,()=>{g.nextTick(()=>{l.value&&nW(l.value)})},{immediate:!0}),()=>{const $=h.value[0].map(S=>Q(S)),b=h.value[1].map(S=>Q(S));return g.createVNode(g.Fragment,null,[e.toolbars.length>0&&g.createVNode("div",{class:`${R}-toolbar-wrapper`,ref:l,id:O},[g.createVNode("div",{class:[`${R}-toolbar`,e.showToolbarName&&`${R}-stn`]},[g.createVNode("div",{class:`${R}-toolbar-left`,ref:f},[$]),g.createVNode("div",{class:`${R}-toolbar-right`},[b])])]),g.createVNode("input",{ref:p,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),g.createVNode(_W,{linkVisible:c.linkVisible,clipVisible:c.clipVisible,type:c.type,onCancel:()=>{c.linkVisible=!1,c.clipVisible=!1},onOk:S=>{S&&u(c.type,{desc:S.desc,url:S.url,transform:c.type==="image"}),c.linkVisible=!1,c.clipVisible=!1}},null)])}}}),zW=`.${R}-preview > [data-line]`,WW=(e,t)=>{const n=Bd(()=>{e.removeEventListener("scroll",i),e.addEventListener("scroll",i),t.removeEventListener("scroll",i),t.addEventListener("scroll",i)},50),i=r=>{const o=e.clientHeight,a=t.clientHeight,O=e.scrollHeight,l=t.scrollHeight,s=(O-o)/(l-a);r.target===e?(t.removeEventListener("scroll",i),t.scrollTo({top:e.scrollTop/s}),n()):(e.removeEventListener("scroll",i),e.scrollTo({top:t.scrollTop*s}),n())};return[()=>{n().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",i),t.removeEventListener("scroll",i)}]},qW=(e,t,n)=>{const{view:i}=n,r=tW(),o=Q=>i.lineBlockAt(i.state.doc.line(Q).from).top,a=Q=>i.lineBlockAt(i.state.doc.line(Q).from).height;let O=[],l=[],s=[];const u=()=>{O=[],l=[],s=[],l=l.concat(Array.from(t.querySelectorAll(zW)));const Q=l.map(k=>Number(k.dataset.line)+1);s=s.concat(Q);const{lines:$}=i.state.doc;let b=1,S=Q.shift()??$;for(let k=1;k<=$;k++)k===S&&(b=k,S=Q.shift()||$+1),O.push({start:b,end:S-1})};let c=0,f=0;const h=()=>{var X,U;if(f!==0)return!1;c++;const{scrollDOM:Q,contentHeight:$}=i;let b=+getComputedStyle(t).paddingTop.replace("px","");const S=i.lineBlockAtHeight(Q.scrollTop),{number:k}=i.state.doc.lineAt(S.from),P=O[k-1];if(!P)return!1;let z=o(P.end)+a(P.end),w=0;const x=o(P.start),v=t.querySelector(`[data-line="${P.start-1}"]`)||((X=t.firstElementChild)==null?void 0:X.firstElementChild),E=t.querySelector(`[data-line="${P.end}"]`)||((U=t.lastElementChild)==null?void 0:U.lastElementChild);let q=0,V=0;x===0?(w=Q.scrollTop/z,v===E?(b=0,z=$-Q.offsetHeight,q=E.offsetTop+E.offsetHeight-t.clientHeight):q=E.offsetTop):(w=(Q.scrollTop-x)/(z-x),V=v.offsetTop,q=E.offsetTop-V),z>=Q.scrollHeight-Q.clientHeight&&(w=(Q.scrollTop-x)/(Q.scrollHeight-Q.clientHeight-x),V=v.offsetTop,q=t.scrollHeight-t.clientHeight-V+10);const Y=V-b+q*w;r(t,Y,()=>{c--})},p=()=>{var Y,X,U,W,Z,N;if(c!==0)return;f++;const{scrollDOM:Q}=i,$=t.scrollTop,b=t.scrollHeight;let S=(Y=t.firstElementChild)==null?void 0:Y.firstElementChild,k=(X=t.firstElementChild)==null?void 0:X.lastElementChild;if(s.length>0){let F=Math.ceil(Number(s[s.length-1])*($/b)),G=s.findLastIndex(I=>I<=F);G=G===-1?0:G,F=s[G];for(let I=G;I>=0&&I<s.length;)if(l[I].offsetTop>$){if(I-1>=0){I--;continue}F=-1,G=I;break}else{if(I+1<s.length&&l[I+1].offsetTop<$){I++;continue}F=s[I],G=I;break}switch(F){case-1:{S=(U=t.firstElementChild)==null?void 0:U.firstElementChild,k=l[G];break}case s.length-1:{S=l[G],k=(W=t.firstElementChild)==null?void 0:W.lastElementChild;break}default:S=l[G],k=l[G+1===l.length?G:G+1]}}const P=S===((Z=t.firstElementChild)==null?void 0:Z.firstElementChild)?0:S.offsetTop;let z=k.offsetTop,w=0;const{start:x,end:v}=O[Number(S.dataset.line||0)],E=o(x),q=o(v===i.state.doc.lines?v:v+1);let V=0;q>Q.scrollHeight-Q.clientHeight||k.scrollTop>t.scrollHeight-t.clientHeight?(w=($+t.clientHeight-P)/(t.scrollHeight-P),V=e.scrollHeight-E-e.clientHeight):S===((N=t.firstElementChild)==null?void 0:N.firstElementChild)?(S===k&&(z=k.offsetTop+k.offsetHeight+ +getComputedStyle(k).marginBottom.replace("px","")),V=q,w=Math.max($/z,0)):(w=Math.max(($-P)/(z-P),0),V=q-E),r(e,E+V*w,()=>{f--})},m=KQ(Q=>{var k;const{scrollDOM:$,contentHeight:b}=i,S=$.clientHeight;if(b<=S||t.firstElementChild.clientHeight<=t.clientHeight)return!1;if(i.state.doc.lines<((k=O[O.length-1])==null?void 0:k.end))return u(),!1;Q.target===e?h():p()},1);return[()=>{u(),e.addEventListener("scroll",m),t.addEventListener("scroll",m),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",m),t.removeEventListener("scroll",m)}]},ZW=(e,t,n)=>{const i=g.inject("editorId");let r=()=>{},o=()=>{};const a=()=>{r();const O=document.querySelector(`#${i} .cm-scroller`),l=document.querySelector(`[id="${i}-preview-wrapper"]`),s=document.querySelector(`[id="${i}-html-wrapper"]`);(l||s)&&([o,r]=(l?qW:WW)(O,l||s,n.value),e.scrollAuto&&o())};g.watch([t,g.toRef(e.setting,"preview"),g.toRef(e.setting,"htmlPreview"),g.toRef(e.setting,"fullscreen"),g.toRef(e.setting,"pageFullscreen")],()=>{g.nextTick(a)}),g.watch(()=>e.scrollAuto,O=>{O?o():r()}),g.watch(()=>e.setting.previewOnly,O=>{O?r():o()}),g.onMounted(a)};let Ye=class Mz{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,i){[t,n]=va(this,t,n);let r=[];return this.decompose(0,t,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),Vi.from(r,this.length-(n-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=va(this,t,n);let i=[];return this.decompose(t,n,i,0),Vi.from(i,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),r=new IO(this),o=new IO(t);for(let a=n,O=n;;){if(r.next(a),o.next(a),a=0,r.lineBreak!=o.lineBreak||r.done!=o.done||r.value!=o.value)return!1;if(O+=r.value.length,r.done||O>=i)return!0}}iter(t=1){return new IO(this,t)}iterRange(t,n=this.length){return new gb(this,t,n)}iterLines(t,n){let i;if(t==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(t).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new $b(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?Mz.empty:t.length<=32?new dt(t):Vi.from(dt.split(t,[]))}};class dt extends Ye{constructor(t,n=UW(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,i,r){for(let o=0;;o++){let a=this.text[o],O=r+a.length;if((n?i:O)>=t)return new EW(r,O,i,a);r=O+1,i++}}decompose(t,n,i,r){let o=t<=0&&n>=this.length?this:new dt(mb(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),O=au(o.text,a.text.slice(),0,o.length);if(O.length<=32)i.push(new dt(O,a.length+o.length));else{let l=O.length>>1;i.push(new dt(O.slice(0,l)),new dt(O.slice(l)))}}else i.push(o)}replace(t,n,i){if(!(i instanceof dt))return super.replace(t,n,i);[t,n]=va(this,t,n);let r=au(this.text,au(i.text,mb(this.text,0,t)),n),o=this.length+i.length-(n-t);return r.length<=32?new dt(r,o):Vi.from(dt.split(r,[]),o)}sliceString(t,n=this.length,i=`
3
3
  `){[t,n]=va(this,t,n);let r="";for(let o=0,a=0;o<=n&&a<this.text.length;a++){let O=this.text[a],l=o+O.length;o>t&&a&&(r+=i),t<l&&n>o&&(r+=O.slice(Math.max(0,t-o),n-o)),o=l+1}return r}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let i=[],r=-1;for(let o of t)i.push(o),r+=o.length+1,i.length==32&&(n.push(new dt(i,r)),i=[],r=-1);return r>-1&&n.push(new dt(i,r)),n}}class Vi extends Ye{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,n,i,r){for(let o=0;;o++){let a=this.children[o],O=r+a.length,l=i+a.lines-1;if((n?l:O)>=t)return a.lineInner(t,n,i,r);r=O+1,i=l+1}}decompose(t,n,i,r){for(let o=0,a=0;a<=n&&o<this.children.length;o++){let O=this.children[o],l=a+O.length;if(t<=l&&n>=a){let s=r&((a<=t?1:0)|(l>=n?2:0));a>=t&&l<=n&&!s?i.push(O):O.decompose(t-a,n-a,i,s)}a=l+1}}replace(t,n,i){if([t,n]=va(this,t,n),i.lines<this.lines)for(let r=0,o=0;r<this.children.length;r++){let a=this.children[r],O=o+a.length;if(t>=o&&n<=O){let l=a.replace(t-o,n-o,i),s=this.lines-a.lines+l.lines;if(l.lines<s>>4&&l.lines>s>>6){let u=this.children.slice();return u[r]=l,new Vi(u,this.length-(n-t)+i.length)}return super.replace(o,O,l)}o=O+1}return super.replace(t,n,i)}sliceString(t,n=this.length,i=`
4
4
  `){[t,n]=va(this,t,n);let r="";for(let o=0,a=0;o<this.children.length&&a<=n;o++){let O=this.children[o],l=a+O.length;a>t&&o&&(r+=i),t<l&&n>a&&(r+=O.sliceString(t-a,n-a,i)),a=l+1}return r}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof Vi))return 0;let i=0,[r,o,a,O]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;r+=n,o+=n){if(r==a||o==O)return i;let l=this.children[r],s=t.children[o];if(l!=s)return i+l.scanIdentical(s,n);i+=l.length+1}}static from(t,n=t.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let h of t)i+=h.lines;if(i<32){let h=[];for(let p of t)p.flatten(h);return new dt(h,n)}let r=Math.max(32,i>>5),o=r<<1,a=r>>1,O=[],l=0,s=-1,u=[];function c(h){let p;if(h.lines>o&&h instanceof Vi)for(let m of h.children)c(m);else h.lines>a&&(l>a||!l)?(f(),O.push(h)):h instanceof dt&&l&&(p=u[u.length-1])instanceof dt&&h.lines+p.lines<=32?(l+=h.lines,s+=h.length+1,u[u.length-1]=new dt(p.text.concat(h.text),p.length+1+h.length)):(l+h.lines>r&&f(),l+=h.lines,s+=h.length+1,u.push(h))}function f(){l!=0&&(O.push(u.length==1?u[0]:Vi.from(u,s)),s=-1,l=u.length=0)}for(let h of t)c(h);return f(),O.length==1?O[0]:new Vi(O,n)}}Ye.empty=new dt([""],0);function UW(e){let t=-1;for(let n of e)t+=n.length+1;return t}function au(e,t,n=0,i=1e9){for(let r=0,o=0,a=!0;o<e.length&&r<=i;o++){let O=e[o],l=r+O.length;l>=n&&(l>i&&(O=O.slice(0,i-r)),r<n&&(O=O.slice(n-r)),a?(t[t.length-1]+=O,a=!1):t.push(O)),r=l+1}return t}function mb(e,t,n){return au(e,[""],t,n)}class IO{constructor(t,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof dt?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],o=this.offsets[i],a=o>>1,O=r instanceof dt?r.text.length:r.children.length;if(a==(n>0?O:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[i]+=n,t==0)return this.lineBreak=!0,this.value=`
5
5
  `,this;t--}else if(r instanceof dt){let l=r.text[a+(n<0?-1:0)];if(this.offsets[i]+=n,l.length>Math.max(0,t))return this.value=t==0?l:n>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=r.children[a+(n<0?-1:0)];t>l.length?(t-=l.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof dt?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class gb{constructor(t,n,i){this.value="",this.done=!1,this.cursor=new IO(t,n>i?-1:1),this.pos=n>i?t.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(t,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class $b{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:n,lineBreak:i,value:r}=this.inner.next(t);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ye.prototype[Symbol.iterator]=function(){return this.iter()},IO.prototype[Symbol.iterator]=gb.prototype[Symbol.iterator]=$b.prototype[Symbol.iterator]=function(){return this});let EW=class{constructor(t,n,i,r){this.from=t,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}};function va(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}let wa="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=1;e<wa.length;e++)wa[e]+=wa[e-1];function YW(e){for(let t=1;t<wa.length;t+=2)if(wa[t]>e)return wa[t-1]<=e;return!1}function Qb(e){return e>=127462&&e<=127487}const bb=8205;function Yt(e,t,n=!0,i=!0){return(n?yb:VW)(e,t,i)}function yb(e,t,n){if(t==e.length)return t;t&&Sb(e.charCodeAt(t))&&Pb(e.charCodeAt(t-1))&&t--;let i=di(e,t);for(t+=cr(i);t<e.length;){let r=di(e,t);if(i==bb||r==bb||n&&YW(r))t+=cr(r),i=r;else if(Qb(r)){let o=0,a=t-2;for(;a>=0&&Qb(di(e,a));)o++,a-=2;if(o%2==0)break;t+=2}else break}return t}function VW(e,t,n){for(;t>0;){let i=yb(e,t-2,n);if(i<t)return i;t--}return 0}function Sb(e){return e>=56320&&e<57344}function Pb(e){return e>=55296&&e<56320}function di(e,t){let n=e.charCodeAt(t);if(!Pb(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Sb(i)?(n-55296<<10)+(i-56320)+65536:n}function kb(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function cr(e){return e<65536?1:2}const oh=/\r\n?|\n/;var en=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(en||(en={}));class Ci{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;n<this.sections.length;n+=2)t+=this.sections[n];return t}get newLength(){let t=0;for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n+1];t+=i<0?this.sections[n]:i}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let n=0,i=0,r=0;n<this.sections.length;){let o=this.sections[n++],a=this.sections[n++];a<0?(t(i,r,o),r+=o):r+=a,i+=o}}iterChangedRanges(t,n=!1){ah(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];r<0?t.push(i,r):t.push(r,i)}return new Ci(t)}composeDesc(t){return this.empty?t:t.empty?this:xb(this,t)}mapDesc(t,n=!1){return t.empty?this:Oh(this,t,n)}mapPos(t,n=-1,i=en.Simple){let r=0,o=0;for(let a=0;a<this.sections.length;){let O=this.sections[a++],l=this.sections[a++],s=r+O;if(l<0){if(s>t)return o+(t-r);o+=O}else{if(i!=en.Simple&&s>=t&&(i==en.TrackDel&&r<t&&s>t||i==en.TrackBefore&&r<t||i==en.TrackAfter&&s>t))return null;if(s>t||s==t&&n<0&&!O)return t==r||n<0?o:o+l;o+=l}r=s}if(t>r)throw new RangeError(`Position ${t} is out of range for changeset of length ${r}`);return o}touchesRange(t,n=t){for(let i=0,r=0;i<this.sections.length&&r<=n;){let o=this.sections[i++],a=this.sections[i++],O=r+o;if(a>=0&&r<=n&&O>=t)return r<t&&O>n?"cover":!0;r=O}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];t+=(t?" ":"")+i+(r>=0?":"+r:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ci(t)}static create(t){return new Ci(t)}}class xt extends Ci{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return ah(this,(n,i,r,o,a)=>t=t.replace(r,r+(i-n),a),!1),t}mapDesc(t,n=!1){return Oh(this,t,n,!0)}invert(t){let n=this.sections.slice(),i=[];for(let r=0,o=0;r<n.length;r+=2){let a=n[r],O=n[r+1];if(O>=0){n[r]=O,n[r+1]=a;let l=r>>1;for(;i.length<l;)i.push(Ye.empty);i.push(a?t.slice(o,o+a):Ye.empty)}o+=a}return new xt(n,i)}compose(t){return this.empty?t:t.empty?this:xb(this,t,!0)}map(t,n=!1){return t.empty?this:Oh(this,t,n,!0)}iterChanges(t,n=!1){ah(this,t,n)}get desc(){return Ci.create(this.sections)}filter(t){let n=[],i=[],r=[],o=new DO(this);e:for(let a=0,O=0;;){let l=a==t.length?1e9:t[a++];for(;O<l||O==l&&o.len==0;){if(o.done)break e;let u=Math.min(o.len,l-O);Gt(r,u,-1);let c=o.ins==-1?-1:o.off==0?o.ins:0;Gt(n,u,c),c>0&&Yr(i,n,o.text),o.forward(u),O+=u}let s=t[a++];for(;O<s;){if(o.done)break e;let u=Math.min(o.len,s-O);Gt(n,u,-1),Gt(r,u,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(u),O+=u}}return{changes:new xt(n,i),filtered:Ci.create(r)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n],r=this.sections[n+1];r<0?t.push(i):r==0?t.push([i]):t.push([i].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,i){let r=[],o=[],a=0,O=null;function l(u=!1){if(!u&&!r.length)return;a<n&&Gt(r,n-a,-1);let c=new xt(r,o);O=O?O.compose(c.map(O)):c,r=[],o=[],a=0}function s(u){if(Array.isArray(u))for(let c of u)s(c);else if(u instanceof xt){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),O=O?O.compose(u.map(O)):u}else{let{from:c,to:f=c,insert:h}=u;if(c>f||c<0||f>n)throw new RangeError(`Invalid change range ${c} to ${f} (in doc of length ${n})`);let p=h?typeof h=="string"?Ye.of(h.split(i||oh)):h:Ye.empty,m=p.length;if(c==f&&m==0)return;c<a&&l(),c>a&&Gt(r,c-a,-1),Gt(r,f-c,m),Yr(o,r,p),a=f}}return s(t),l(!O),O}static empty(t){return new xt(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;r<t.length;r++){let o=t[r];if(typeof o=="number")n.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((a,O)=>O&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;i.length<r;)i.push(Ye.empty);i[r]=Ye.of(o.slice(1)),n.push(o[0],i[r].length)}}}return new xt(n,i)}static createSet(t,n){return new xt(t,n)}}function Gt(e,t,n,i=!1){if(t==0&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:t==0&&e[r]==0?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function Yr(e,t,n){if(n.length==0)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(Ye.empty);e.push(n)}}function ah(e,t,n){let i=e.inserted;for(let r=0,o=0,a=0;a<e.sections.length;){let O=e.sections[a++],l=e.sections[a++];if(l<0)r+=O,o+=O;else{let s=r,u=o,c=Ye.empty;for(;s+=O,u+=l,l&&i&&(c=c.append(i[a-2>>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)O=e.sections[a++],l=e.sections[a++];t(r,s,o,u,c),r=s,o=u}}}function Oh(e,t,n,i=!1){let r=[],o=i?[]:null,a=new DO(e),O=new DO(t);for(let l=-1;;)if(a.ins==-1&&O.ins==-1){let s=Math.min(a.len,O.len);Gt(r,s,-1),a.forward(s),O.forward(s)}else if(O.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(O.len<a.len||O.len==a.len&&!n))){let s=O.len;for(Gt(r,O.ins,-1);s;){let u=Math.min(a.len,s);a.ins>=0&&l<a.i&&a.len<=u&&(Gt(r,0,a.ins),o&&Yr(o,r,a.text),l=a.i),a.forward(u),s-=u}O.next()}else if(a.ins>=0){let s=0,u=a.len;for(;u;)if(O.ins==-1){let c=Math.min(u,O.len);s+=c,u-=c,O.forward(c)}else if(O.ins==0&&O.len<u)u-=O.len,O.next();else break;Gt(r,s,l<a.i?a.ins:0),o&&l<a.i&&Yr(o,r,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&O.done)return o?xt.createSet(r,o):Ci.create(r);throw new Error("Mismatched change set lengths")}}function xb(e,t,n=!1){let i=[],r=n?[]:null,o=new DO(e),a=new DO(t);for(let O=!1;;){if(o.done&&a.done)return r?xt.createSet(i,r):Ci.create(i);if(o.ins==0)Gt(i,o.len,0,O),o.next();else if(a.len==0&&!a.done)Gt(i,0,a.ins,O),r&&Yr(r,i,a.text),a.next();else{if(o.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,a.len),s=i.length;if(o.ins==-1){let u=a.ins==-1?-1:a.off?0:a.ins;Gt(i,l,u,O),r&&u&&Yr(r,i,a.text)}else a.ins==-1?(Gt(i,o.off?0:o.len,l,O),r&&Yr(r,i,o.textBit(l))):(Gt(i,o.off?0:o.len,a.off?0:a.ins,O),r&&!a.off&&Yr(r,i,a.text));O=(o.ins>l||a.ins>=0&&a.len>l)&&(O||i.length>s),o.forward2(l),a.forward(l)}}}}class DO{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length?Ye.empty:t[n]}textBit(t){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!t?Ye.empty:n[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Xo{constructor(t,n,i){this.from=t,this.to=n,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,n=-1){let i,r;return this.empty?i=r=t.mapPos(this.from,n):(i=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Xo(i,r,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return A.range(t,n);let i=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return A.range(this.anchor,i)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(t.anchor,t.head)}static create(t,n,i){return new Xo(t,n,i)}}class A{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:A.create(this.ranges.map(i=>i.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new A([this.main],0)}addRange(t,n=!0){return A.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let i=this.ranges.slice();return i[n]=t,A.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new A(t.ranges.map(n=>Xo.fromJSON(n)),t.main)}static single(t,n=t){return new A([A.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<t.length;r++){let o=t[r];if(o.empty?o.from<=i:o.from<i)return A.normalized(t.slice(),n);i=o.to}return new A(t,n)}static cursor(t,n=0,i,r){return Xo.create(t,t,(n==0?0:n<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(t,n,i,r){let o=(i??16777215)<<6|(r==null?7:Math.min(6,r));return n<t?Xo.create(n,t,48|o):Xo.create(t,n,(n>t?8:0)|o)}static normalized(t,n=0){let i=t[n];t.sort((r,o)=>r.from-o.from),n=t.indexOf(i);for(let r=1;r<t.length;r++){let o=t[r],a=t[r-1];if(o.empty?o.from<=a.to:o.from<a.to){let O=a.from,l=Math.max(o.to,a.to);r<=n&&n--,t.splice(--r,2,o.anchor>o.head?A.range(l,O):A.range(O,l))}}return new A(t,n)}}function vb(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let lh=0;class se{constructor(t,n,i,r,o){this.combine=t,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=lh++,this.default=t([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(t={}){return new se(t.combine||(n=>n),t.compareInput||((n,i)=>n===i),t.compare||(t.combine?(n,i)=>n===i:sh),!!t.static,t.enables)}of(t){return new Ou([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ou(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ou(t,this,2,n)}from(t,n){return n||(n=i=>i),this.compute([t],i=>n(i.field(t)))}}function sh(e,t){return e==t||e.length==t.length&&e.every((n,i)=>n===t[i])}class Ou{constructor(t,n,i,r){this.dependencies=t,this.facet=n,this.type=i,this.value=r,this.id=lh++}dynamicSlot(t){var n;let i=this.value,r=this.facet.compareInput,o=this.id,a=t[o]>>1,O=this.type==2,l=!1,s=!1,u=[];for(let c of this.dependencies)c=="doc"?l=!0:c=="selection"?s=!0:((n=t[c.id])!==null&&n!==void 0?n:1)&1||u.push(t[c.id]);return{create(c){return c.values[a]=i(c),1},update(c,f){if(l&&f.docChanged||s&&(f.docChanged||f.selection)||uh(c,u)){let h=i(c);if(O?!wb(h,c.values[a],r):!r(h,c.values[a]))return c.values[a]=h,1}return 0},reconfigure:(c,f)=>{let h,p=f.config.address[o];if(p!=null){let m=su(f,p);if(this.dependencies.every(Q=>Q instanceof se?f.facet(Q)===c.facet(Q):Q instanceof In?f.field(Q,!1)==c.field(Q,!1):!0)||(O?wb(h=i(c),m,r):r(h=i(c),m)))return c.values[a]=m,0}else h=i(c);return c.values[a]=h,1}}}}function wb(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function uh(e,t){let n=!1;for(let i of t)LO(e,i)&1&&(n=!0);return n}function CW(e,t,n){let i=n.map(l=>e[l.id]),r=n.map(l=>l.type),o=i.filter(l=>!(l&1)),a=e[t.id]>>1;function O(l){let s=[];for(let u=0;u<i.length;u++){let c=su(l,i[u]);if(r[u]==2)for(let f of c)s.push(f);else s.push(c)}return t.combine(s)}return{create(l){for(let s of i)LO(l,s);return l.values[a]=O(l),1},update(l,s){if(!uh(l,o))return 0;let u=O(l);return t.compare(u,l.values[a])?0:(l.values[a]=u,1)},reconfigure(l,s){let u=uh(l,i),c=s.config.facets[t.id],f=s.facet(t);if(c&&!u&&sh(n,c))return l.values[a]=f,0;let h=O(l);return t.compare(h,f)?(l.values[a]=f,0):(l.values[a]=h,1)}}}const Xb=se.define({static:!0});class In{constructor(t,n,i,r,o){this.id=t,this.createF=n,this.updateF=i,this.compareF=r,this.spec=o,this.provides=void 0}static define(t){let n=new In(lh++,t.create,t.update,t.compare||((i,r)=>i===r),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(Xb).find(i=>i.field==this);return((n==null?void 0:n.create)||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let o=i.values[n],a=this.updateF(o,r);return this.compareF(o,a)?0:(i.values[n]=a,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}init(t){return[this,Xb.of({field:this,create:t})]}get extension(){return this}}const To={lowest:4,low:3,default:2,high:1,highest:0};function NO(e){return t=>new Tb(t,e)}const fr={highest:NO(To.highest),high:NO(To.high),default:NO(To.default),low:NO(To.low),lowest:NO(To.lowest)};class Tb{constructor(t,n){this.inner=t,this.prec=n}}class ji{of(t){return new ch(this,t)}reconfigure(t){return ji.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ch{constructor(t,n){this.compartment=t,this.inner=n}}class lu{constructor(t,n,i,r,o,a){for(this.base=t,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let n=this.address[t.id];return n==null?t.default:this.staticValues[n>>1]}static resolve(t,n,i){let r=[],o=Object.create(null),a=new Map;for(let f of jW(t,n,a))f instanceof In?r.push(f):(o[f.facet.id]||(o[f.facet.id]=[])).push(f);let O=Object.create(null),l=[],s=[];for(let f of r)O[f.id]=s.length<<1,s.push(h=>f.slot(h));let u=i==null?void 0:i.config.facets;for(let f in o){let h=o[f],p=h[0].facet,m=u&&u[f]||[];if(h.every(Q=>Q.type==0))if(O[p.id]=l.length<<1|1,sh(m,h))l.push(i.facet(p));else{let Q=p.combine(h.map($=>$.value));l.push(i&&p.compare(Q,i.facet(p))?i.facet(p):Q)}else{for(let Q of h)Q.type==0?(O[Q.id]=l.length<<1|1,l.push(Q.value)):(O[Q.id]=s.length<<1,s.push($=>Q.dynamicSlot($)));O[p.id]=s.length<<1,s.push(Q=>CW(Q,p,h))}}let c=s.map(f=>f(O));return new lu(t,a,c,O,l,o)}}function jW(e,t,n){let i=[[],[],[],[],[]],r=new Map;function o(a,O){let l=r.get(a);if(l!=null){if(l<=O)return;let s=i[l].indexOf(a);s>-1&&i[l].splice(s,1),a instanceof ch&&n.delete(a.compartment)}if(r.set(a,O),Array.isArray(a))for(let s of a)o(s,O);else if(a instanceof ch){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let s=t.get(a.compartment)||a.inner;n.set(a.compartment,s),o(s,O)}else if(a instanceof Tb)o(a.inner,a.prec);else if(a instanceof In)i[O].push(a),a.provides&&o(a.provides,O);else if(a instanceof Ou)i[O].push(a),a.facet.extensions&&o(a.facet.extensions,To.default);else{let s=a.extension;if(!s)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(s,O)}}return o(e,To.default),i.reduce((a,O)=>a.concat(O))}function LO(e,t){if(t&1)return 2;let n=t>>1,i=e.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function su(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const _b=se.define(),fh=se.define({combine:e=>e.some(t=>t),static:!0}),Rb=se.define({combine:e=>e.length?e[0]:void 0,static:!0}),zb=se.define(),Wb=se.define(),qb=se.define(),Zb=se.define({combine:e=>e.length?e[0]:!1});class dr{constructor(t,n){this.type=t,this.value=n}static define(){return new AW}}class AW{of(t){return new dr(this,t)}}class GW{constructor(t){this.map=t}of(t){return new We(this,t)}}class We{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new We(this.type,n)}is(t){return this.type==t}static define(t={}){return new GW(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let i=[];for(let r of t){let o=r.map(n);o&&i.push(o)}return i}}We.reconfigure=We.define(),We.appendConfig=We.define();class mt{constructor(t,n,i,r,o,a){this.startState=t,this.changes=n,this.selection=i,this.effects=r,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,i&&vb(i,n.newLength),o.some(O=>O.type==mt.time)||(this.annotations=o.concat(mt.time.of(Date.now())))}static create(t,n,i,r,o,a){return new mt(t,n,i,r,o,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(mt.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}mt.time=dr.define(),mt.userEvent=dr.define(),mt.addToHistory=dr.define(),mt.remote=dr.define();function IW(e,t){let n=[];for(let i=0,r=0;;){let o,a;if(i<e.length&&(r==t.length||t[r]>=e[i]))o=e[i++],a=e[i++];else if(r<t.length)o=t[r++],a=t[r++];else return n;!n.length||n[n.length-1]<o?n.push(o,a):n[n.length-1]<a&&(n[n.length-1]=a)}}function Ub(e,t,n){var i;let r,o,a;return n?(r=t.changes,o=xt.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(o):(i=e.selection)===null||i===void 0?void 0:i.map(r),effects:We.mapEffects(e.effects,r).concat(We.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function dh(e,t,n){let i=t.selection,r=Xa(t.annotations);return t.userEvent&&(r=r.concat(mt.userEvent.of(t.userEvent))),{changes:t.changes instanceof xt?t.changes:xt.of(t.changes||[],n,e.facet(Rb)),selection:i&&(i instanceof A?i:A.single(i.anchor,i.head)),effects:Xa(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function Eb(e,t,n){let i=dh(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let o=1;o<t.length;o++){t[o].filter===!1&&(n=!1);let a=!!t[o].sequential;i=Ub(i,dh(e,t[o],a?i.changes.newLength:e.doc.length),a)}let r=mt.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return NW(n?DW(r):r)}function DW(e){let t=e.startState,n=!0;for(let r of t.facet(zb)){let o=r(e);if(o===!1){n=!1;break}Array.isArray(o)&&(n=n===!0?o:IW(n,o))}if(n!==!0){let r,o;if(n===!1)o=e.changes.invertedDesc,r=xt.empty(t.doc.length);else{let a=e.changes.filter(n);r=a.changes,o=a.filtered.mapDesc(a.changes).invertedDesc}e=mt.create(t,r,e.selection&&e.selection.map(o),We.mapEffects(e.effects,o),e.annotations,e.scrollIntoView)}let i=t.facet(Wb);for(let r=i.length-1;r>=0;r--){let o=i[r](e);o instanceof mt?e=o:Array.isArray(o)&&o.length==1&&o[0]instanceof mt?e=o[0]:e=Eb(t,Xa(o),!1)}return e}function NW(e){let t=e.startState,n=t.facet(qb),i=e;for(let r=n.length-1;r>=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=Ub(i,dh(t,o,e.changes.newLength),!0))}return i==e?e:mt.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}const LW=[];function Xa(e){return e==null?LW:Array.isArray(e)?e:[e]}var Vt=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Vt||(Vt={}));const FW=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let hh;try{hh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function MW(e){if(hh)return hh.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||FW.test(n)))return!0}return!1}function BW(e){return t=>{if(!/\S/.test(t))return Vt.Space;if(MW(t))return Vt.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Vt.Word;return Vt.Other}}class xe{constructor(t,n,i,r,o,a){this.config=t,this.doc=n,this.selection=i,this.values=r,this.status=t.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let O=0;O<this.config.dynamicSlots.length;O++)LO(this,O<<1);this.computeSlot=null}field(t,n=!0){let i=this.config.address[t.id];if(i==null){if(n)throw new RangeError("Field is not present in this state");return}return LO(this,i),su(this,i)}update(...t){return Eb(this,t,!0)}applyTransaction(t){let n=this.config,{base:i,compartments:r}=n;for(let O of t.effects)O.is(ji.reconfigure)?(n&&(r=new Map,n.compartments.forEach((l,s)=>r.set(s,l)),n=null),r.set(O.value.compartment,O.value.extension)):O.is(We.reconfigure)?(n=null,i=O.value):O.is(We.appendConfig)&&(n=null,i=Xa(i).concat(O.value));let o;n?o=t.startState.values.slice():(n=lu.resolve(i,r,this),o=new xe(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,s)=>s.reconfigure(l,this),null).values);let a=t.startState.facet(fh)?t.newSelection:t.newSelection.asSingle();new xe(n,t.newDoc,a,o,(O,l)=>l.update(O,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:A.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,i=t(n.ranges[0]),r=this.changes(i.changes),o=[i.range],a=Xa(i.effects);for(let O=1;O<n.ranges.length;O++){let l=t(n.ranges[O]),s=this.changes(l.changes),u=s.map(r);for(let f=0;f<O;f++)o[f]=o[f].map(u);let c=r.mapDesc(s,!0);o.push(l.range.map(c)),r=r.compose(u),a=We.mapEffects(a,u).concat(We.mapEffects(Xa(l.effects),c))}return{changes:r,selection:A.create(o,n.mainIndex),effects:a}}changes(t=[]){return t instanceof xt?t:xt.of(t,this.doc.length,this.facet(xe.lineSeparator))}toText(t){return Ye.of(t.split(this.facet(xe.lineSeparator)||oh))}sliceDoc(t=0,n=this.doc.length){return this.doc.sliceString(t,n,this.lineBreak)}facet(t){let n=this.config.address[t.id];return n==null?t.default:(LO(this,n),su(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let r=t[i];r instanceof In&&this.config.address[r.id]!=null&&(n[i]=r.spec.toJSON(this.field(t[i]),this))}return n}static fromJSON(t,n={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let o in i)if(Object.prototype.hasOwnProperty.call(t,o)){let a=i[o],O=t[o];r.push(a.init(l=>a.spec.fromJSON(O,l)))}}return xe.create({doc:t.doc,selection:A.fromJSON(t.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(t={}){let n=lu.resolve(t.extensions||[],new Map),i=t.doc instanceof Ye?t.doc:Ye.of((t.doc||"").split(n.staticFacet(xe.lineSeparator)||oh)),r=t.selection?t.selection instanceof A?t.selection:A.single(t.selection.anchor,t.selection.head):A.single(0);return vb(r,i.length),n.staticFacet(fh)||(r=r.asSingle()),new xe(n,i,r,n.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(xe.tabSize)}get lineBreak(){return this.facet(xe.lineSeparator)||`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "4.16.1-0",
3
+ "version": "4.16.1",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",