md-editor-v3 5.5.0 → 5.5.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.
- package/lib/cjs/chunks/index3.cjs +6 -9
- package/lib/es/chunks/index3.mjs +7 -10
- package/lib/umd/index.js +1 -1
- package/package.json +1 -1
|
@@ -308,16 +308,13 @@ const CatalogLink = /* @__PURE__ */ vue.defineComponent({
|
|
|
308
308
|
const currRef = vue.ref();
|
|
309
309
|
vue.watch(() => props2.tocItem.active, (active) => {
|
|
310
310
|
if (active) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
311
|
+
props2.onActive(props2.tocItem, currRef.value);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
vue.onMounted(() => {
|
|
315
|
+
if (props2.tocItem.active) {
|
|
316
|
+
props2.onActive(props2.tocItem, currRef.value);
|
|
318
317
|
}
|
|
319
|
-
}, {
|
|
320
|
-
immediate: true
|
|
321
318
|
});
|
|
322
319
|
return () => {
|
|
323
320
|
const {
|
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, inject, ref, watch,
|
|
1
|
+
import { defineComponent, inject, ref, watch, onMounted, createVNode, reactive, shallowRef, provide, computed, onBeforeUnmount, Fragment } from "vue";
|
|
2
2
|
import { p as prefix } from "./config.mjs";
|
|
3
3
|
import { a as getRelativeTop } from "./index5.mjs";
|
|
4
4
|
import { b as bus, g as CATALOG_CHANGED, G as GET_EDITOR_VIEW, P as PUSH_CATALOG, S as SEND_EDITOR_VIEW } from "./event-name.mjs";
|
|
@@ -307,16 +307,13 @@ const CatalogLink = /* @__PURE__ */ defineComponent({
|
|
|
307
307
|
const currRef = ref();
|
|
308
308
|
watch(() => props2.tocItem.active, (active) => {
|
|
309
309
|
if (active) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
310
|
+
props2.onActive(props2.tocItem, currRef.value);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
onMounted(() => {
|
|
314
|
+
if (props2.tocItem.active) {
|
|
315
|
+
props2.onActive(props2.tocItem, currRef.value);
|
|
317
316
|
}
|
|
318
|
-
}, {
|
|
319
|
-
immediate: true
|
|
320
317
|
});
|
|
321
318
|
return () => {
|
|
322
319
|
const {
|
package/lib/umd/index.js
CHANGED
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
* This source code is licensed under the ISC license.
|
|
180
180
|
* See the LICENSE file in the root directory of this source tree.
|
|
181
181
|
*/const vW=Ze("XIcon",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),wW={bold:B5,underline:PW,italic:oW,"strike-through":$W,title:iW,sub:QW,sup:bW,quote:dW,"unordered-list":uW,"ordered-list":OW,task:lW,"code-row":J5,code:Yb,link:aW,image:rW,table:yW,revoke:hW,next:nW,save:pW,prettier:Yb,minimize:fW,maximize:cW,"fullscreen-exit":mW,fullscreen:eW,"preview-only":xW,preview:tW,"preview-html":K5,catalog:sW,github:()=>m.createVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-github-icon"},[m.createVNode("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"},null),m.createVNode("path",{d:"M9 18c-4.51 2-5-2-7-2"},null)]),mermaid:H5,formula:gW,close:vW,delete:SW,upload:kW},TW=m.defineComponent({name:`${T}-icon-set`,props:{name:{type:String,default:""}},setup(e){return()=>m.h(wW[e.name],{class:`${T}-icon`})}}),ve=m.defineComponent({name:`${T}-icon`,props:{name:{type:String,default:""}},setup(e){const t=m.inject("customIcon");return()=>{const n=t.value[e.name];return typeof n=="object"?typeof n.component=="object"?m.h(n.component,n.props):m.createVNode("span",{innerHTML:n.component},null):m.createVNode(TW,{name:e.name},null)}}}),XW=(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},_W=(e,t)=>{if(!e)return e;const n=t.split(`
|
|
182
|
-
`),i=['<span rn-wrapper aria-hidden="true">'];return n.forEach(()=>{i.push("<span></span>")}),i.push("</span>"),`<span class="${T}-code-block">${e}</span>${i.join("")}`},RW=(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},Cb=(()=>{let e=0;return()=>++e})(),zW={title:{type:[String,Object],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,default:void 0},style:{type:[Object,String],default:()=>({})},showMask:{type:Boolean,default:!0}},zo=m.defineComponent({name:"MdModal",props:zW,emits:["onClose"],setup(e,t){const n=m.inject("theme"),i=m.inject("rootRef"),r=m.ref(e.visible),o=m.ref([`${T}-modal`]),a=m.ref(),O=m.ref(),l=m.ref(),s=m.shallowRef();let u=()=>{};const c=m.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),f=m.computed(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height});m.watch(()=>e.isFullscreen,Q=>{Q?u():m.nextTick(()=>{u=Vb(O.value,(b,$)=>{c.initPos.left=b+"px",c.initPos.top=$+"px"})})}),m.watch(()=>e.visible,Q=>{Q?(c.maskStyle.zIndex=ht.editorConfig.zIndex+Cb(),c.modalStyle.zIndex=ht.editorConfig.zIndex+Cb(),o.value.push("zoom-in"),r.value=Q,m.nextTick(()=>{const b=a.value.offsetWidth/2,$=a.value.offsetHeight/2,g=document.documentElement.clientWidth/2,S=document.documentElement.clientHeight/2;c.initPos.left=g-b+"px",c.initPos.top=S-$+"px",e.isFullscreen||(u=Vb(O.value,(k,y)=>{c.initPos.left=k+"px",c.initPos.top=y+"px"}))}),setTimeout(()=>{o.value=o.value.filter(b=>b!=="zoom-in")},140)):(o.value.push("zoom-out"),u(),setTimeout(()=>{o.value=o.value.filter(b=>b!=="zoom-out"),r.value=Q},130))});const h=m.computed(()=>({display:r.value?"block":"none"})),p=m.computed(()=>typeof e.style=="string"?[e.style,h.value].join("; "):e.style instanceof Object?{...h.value,...e.style}:h.value);return m.onMounted(()=>{var b;const Q=(b=i.value)==null?void 0:b.getRootNode();l.value=Q instanceof Document?document.body:Q}),()=>{const Q=tn({ctx:t}),b=tn({props:e,ctx:t},"title");return l.value?m.createVNode(m.Teleport,{to:l.value},{default:()=>[m.createVNode("div",{ref:s,class:`${T}-modal-container`,"data-theme":n.value},[m.createVNode("div",{class:e.class,style:p.value},[e.showMask&&m.createVNode("div",{class:`${T}-modal-mask`,style:c.maskStyle,onClick:()=>{var $;($=e.onClose)==null||$.call(e),t.emit("onClose")}},null),m.createVNode("div",{class:o.value,style:{...c.modalStyle,...c.initPos,...f.value},ref:a},[m.createVNode("div",{class:`${T}-modal-header`,ref:O},[b||""]),m.createVNode("div",{class:`${T}-modal-body`},[Q]),m.createVNode("div",{class:`${T}-modal-func`},[e.showAdjust&&m.createVNode("div",{class:`${T}-modal-adjust`,onClick:$=>{$.stopPropagation(),e.isFullscreen?c.initPos=c.historyPos:(c.historyPos=c.initPos,c.initPos={left:"0",top:"0"}),e.onAdjust(!e.isFullscreen)}},[m.createVNode(ve,{name:e.isFullscreen?"minimize":"maximize"},null)]),m.createVNode("div",{class:`${T}-modal-close`,onClick:$=>{var g;$.stopPropagation(),(g=e.onClose)==null||g.call(e),t.emit("onClose")}},[m.createVNode(ve,{name:"close"},null)])])])])])]}):""}}});zo.install=e=>(e.component(zo.name,zo),e);const WW={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},qW=m.defineComponent({name:`${T}-modal-link`,props:WW,setup(e){const t=m.inject("usedLanguageText"),n=m.inject("editorId"),i=m.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=m.reactive({desc:"",url:""});return m.watch(()=>e.visible,o=>{o||setTimeout(()=>{r.desc="",r.url=""},200)}),()=>m.createVNode(zo,{title:i.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var o,a,O,l,s;return[m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("label",{class:`${T}-label`,for:`link-desc-${n}`},[(o=t.value.linkModalTips)==null?void 0:o.descLabel]),m.createVNode("input",{placeholder:(a=t.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${T}-input`,id:`link-desc-${n}`,type:"text",value:r.desc,onChange:u=>{r.desc=u.target.value},autocomplete:"off"},null)]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("label",{class:`${T}-label`,for:`link-url-${n}`},[(O=t.value.linkModalTips)==null?void 0:O.urlLabel]),m.createVNode("input",{placeholder:(l=t.value.linkModalTips)==null?void 0:l.urlLabelPlaceHolder,class:`${T}-input`,id:`link-url-${n}`,type:"text",value:r.url,onChange:u=>{r.url=u.target.value},autocomplete:"off"},null)]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("button",{class:[`${T}-btn`,`${T}-btn-row`],type:"button",onClick:()=>{e.onOk(r),r.desc="",r.url=""}},[(s=t.value.linkModalTips)==null?void 0:s.buttonOK])])]}})}}),ZW={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},UW=m.defineComponent({name:`${T}-modal-clip`,props:ZW,setup(e){const t=m.inject("usedLanguageText"),n=m.inject("editorId"),i=m.inject("rootRef");let r=ht.editorExtensions.cropper.instance;const o=m.ref(),a=m.ref(),O=m.ref(),l=m.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let s=null;m.watch(()=>e.visible,()=>{e.visible&&!l.cropperInited&&(r=r||window.Cropper,o.value.onchange=()=>{if(!r){F.emit(n,Ar,{name:"Cropper",message:"Cropper is undefined"});return}const c=o.value.files||[];if(l.imgSelected=!0,(c==null?void 0:c.length)>0){const f=new FileReader;f.onload=h=>{l.imgSrc=h.target.result},f.readAsDataURL(c[0])}})}),m.watch(()=>[l.imgSelected],()=>{O.value.style=""}),m.watch([m.toRef(()=>l.isFullscreen),m.toRef(()=>l.imgSrc)],()=>{l.imgSrc&&m.nextTick(()=>{s==null||s.destroy(),O.value.style="",a.value&&(s=new r(a.value,{viewMode:2,preview:i.value.getRootNode().querySelector(`.${T}-clip-preview-target`)}))})});const u=()=>{s.clear(),s.destroy(),s=null,o.value.value="",l.imgSelected=!1};return()=>{var c;return m.createVNode(zo,{class:`${T}-modal-clip`,title:(c=t.value.clipModalTips)==null?void 0:c.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:l.isFullscreen,onAdjust:f=>{l.isFullscreen=f},width:"668px",height:"421px"},{default:()=>{var f,h,p;return[m.createVNode("div",{class:`${T}-form-item ${T}-clip`},[m.createVNode("div",{class:`${T}-clip-main`},[l.imgSelected?m.createVNode("div",{class:`${T}-clip-cropper`},[m.createVNode("img",{src:l.imgSrc,ref:a,style:{display:"none"},alt:""},null),m.createVNode("div",{class:`${T}-clip-delete`,onClick:u},[m.createVNode(ve,{name:"delete"},null)])]):m.createVNode("div",{class:`${T}-clip-upload`,onClick:()=>{o.value.click()},role:"button",tabindex:"0","aria-label":(f=t.value.imgTitleItem)==null?void 0:f.upload},[m.createVNode(ve,{name:"upload"},null)])]),m.createVNode("div",{class:`${T}-clip-preview`},[m.createVNode("div",{class:`${T}-clip-preview-target`,ref:O},null)])]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("button",{class:`${T}-btn`,type:"button",onClick:()=>{if(s){const Q=s.getCroppedCanvas();F.emit(n,mu,[XW(Q.toDataURL("image/png"))],e.onOk),u()}}},[((h=t.value.clipModalTips)==null?void 0:h.buttonUpload)||((p=t.value.linkModalTips)==null?void 0:p.buttonOK)])]),m.createVNode("input",{ref:o,accept:"image/*",type:"file",multiple:!1,style:{display:"none"},"aria-hidden":"true"},null)]}})}}}),VW={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},EW=m.defineComponent({name:`${T}-modals`,props:VW,setup(e){return()=>m.createVNode(m.Fragment,null,[m.createVNode(qW,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),m.createVNode(UW,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),YW=m.defineComponent({name:"MDEditorToolbar",props:j5,setup(e){const t=m.inject("editorId"),n=m.inject("usedLanguageText"),i=m.inject("theme"),r=m.inject("previewTheme"),o=m.inject("language"),a=m.inject("disabled"),{fullscreenHandler:O}=D5(e),l=`${t}-toolbar-wrapper`,s=m.ref(),u=m.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),c=(g,S)=>{if(a!=null&&a.value)return!1;F.emit(t,Ge,g,S)},f=m.reactive({type:"link",linkVisible:!1,clipVisible:!1}),h=m.ref();m.onMounted(()=>{F.on(t,{name:$h,callback(g){f.type=g,f.linkVisible=!0}})});const p=m.computed(()=>{const g=e.toolbars.filter(X=>!e.toolbarsExclude.includes(X)),S=g.indexOf("="),k=S===-1?g:g.slice(0,S+1),y=S===-1?[]:g.slice(S,Number.MAX_SAFE_INTEGER);return[k,y]}),Q=m.ref(),b=()=>{F.emit(t,mu,Array.from(Q.value.files||[])),Q.value.value=""};m.onMounted(()=>{Q.value.addEventListener("change",b)});const $=g=>{var S,k,y,X,x,v,w,W,E,V,U,_,q,Z,Y,I,N,A,L,ee,se,Ue,M,ce,Re,De,xt,hi,Dn,Ai,IO,Sa,Er,DO,NO,Pa,Ld,Md,ka,Fd,hr,vt,wo,xa,Yr,Bd,nu,Hd,Ce,Kd,LO,To,MO,Jd,FO,pi,eh,va,th,BO,Pn,iu,nh,Gi,ih,ru,ou,rh,Cr,Ii,jr,au,pr,oh,Ou,wa,mi,Ta,ah,lu,Oh;if(ph.includes(g))switch(g){case"-":return m.createVNode(E5,null,null);case"bold":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(S=n.value.toolbarTips)==null?void 0:S.bold,onClick:()=>{c("bold")}},[m.createVNode(ve,{name:"bold"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(k=n.value.toolbarTips)==null?void 0:k.bold])]);case"underline":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(y=n.value.toolbarTips)==null?void 0:y.underline,onClick:()=>{c("underline")}},[m.createVNode(ve,{name:"underline"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(X=n.value.toolbarTips)==null?void 0:X.underline])]);case"italic":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(x=n.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{c("italic")}},[m.createVNode(ve,{name:"italic"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(v=n.value.toolbarTips)==null?void 0:v.italic])]);case"strikeThrough":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(w=n.value.toolbarTips)==null?void 0:w.strikeThrough,onClick:()=>{c("strikeThrough")}},[m.createVNode(ve,{name:"strike-through"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(W=n.value.toolbarTips)==null?void 0:W.strikeThrough])]);case"title":return m.createVNode(_a,{relative:`#${l}`,visible:u.title,onChange:me=>{u.title=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.title=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h1")},role:"menuitem",tabindex:"0"},[(E=n.value.titleItem)==null?void 0:E.h1]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h2")},role:"menuitem",tabindex:"0"},[(V=n.value.titleItem)==null?void 0:V.h2]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h3")},role:"menuitem",tabindex:"0"},[(U=n.value.titleItem)==null?void 0:U.h3]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h4")},role:"menuitem",tabindex:"0"},[(_=n.value.titleItem)==null?void 0:_.h4]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h5")},role:"menuitem",tabindex:"0"},[(q=n.value.titleItem)==null?void 0:q.h5]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h6")},role:"menuitem",tabindex:"0"},[(Z=n.value.titleItem)==null?void 0:Z.h6])])},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.title},[m.createVNode(ve,{name:"title"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.title])])]}});case"sub":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Y=n.value.toolbarTips)==null?void 0:Y.sub,onClick:()=>{c("sub")}},[m.createVNode(ve,{name:"sub"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(I=n.value.toolbarTips)==null?void 0:I.sub])]);case"sup":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(N=n.value.toolbarTips)==null?void 0:N.sup,onClick:()=>{c("sup")}},[m.createVNode(ve,{name:"sup"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(A=n.value.toolbarTips)==null?void 0:A.sup])]);case"quote":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(L=n.value.toolbarTips)==null?void 0:L.quote,onClick:()=>{c("quote")}},[m.createVNode(ve,{name:"quote"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ee=n.value.toolbarTips)==null?void 0:ee.quote])]);case"unorderedList":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(se=n.value.toolbarTips)==null?void 0:se.unorderedList,onClick:()=>{c("unorderedList")}},[m.createVNode(ve,{name:"unordered-list"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ue=n.value.toolbarTips)==null?void 0:Ue.unorderedList])]);case"orderedList":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(M=n.value.toolbarTips)==null?void 0:M.orderedList,onClick:()=>{c("orderedList")}},[m.createVNode(ve,{name:"ordered-list"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ce=n.value.toolbarTips)==null?void 0:ce.orderedList])]);case"task":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Re=n.value.toolbarTips)==null?void 0:Re.task,onClick:()=>{c("task")}},[m.createVNode(ve,{name:"task"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(De=n.value.toolbarTips)==null?void 0:De.task])]);case"codeRow":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(xt=n.value.toolbarTips)==null?void 0:xt.codeRow,onClick:()=>{c("codeRow")}},[m.createVNode(ve,{name:"code-row"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(hi=n.value.toolbarTips)==null?void 0:hi.codeRow])]);case"code":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Dn=n.value.toolbarTips)==null?void 0:Dn.code,onClick:()=>{c("code")}},[m.createVNode(ve,{name:"code"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ai=n.value.toolbarTips)==null?void 0:Ai.code])]);case"link":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(IO=n.value.toolbarTips)==null?void 0:IO.link,onClick:()=>{if(a!=null&&a.value)return!1;f.type="link",f.linkVisible=!0}},[m.createVNode(ve,{name:"link"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Sa=n.value.toolbarTips)==null?void 0:Sa.link])]);case"image":return e.noUploadImg?m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Er=n.value.toolbarTips)==null?void 0:Er.image,onClick:()=>{if(a!=null&&a.value)return!1;f.type="image",f.linkVisible=!0}},[m.createVNode(ve,{name:"image"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(DO=n.value.toolbarTips)==null?void 0:DO.image])]):m.createVNode(_a,{relative:`#${l}`,visible:u.image,onChange:me=>{u.image=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.title=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{f.type="image",f.linkVisible=!0},role:"menuitem",tabindex:"0"},[(NO=n.value.imgTitleItem)==null?void 0:NO.link]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{Q.value.click()},role:"menuitem",tabindex:"0"},[(Pa=n.value.imgTitleItem)==null?void 0:Pa.upload]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{f.clipVisible=!0},role:"menuitem",tabindex:"0"},[(Ld=n.value.imgTitleItem)==null?void 0:Ld.clip2upload])])},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.image},[m.createVNode(ve,{name:"image"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.image])])]}});case"table":return m.createVNode(_a,{relative:`#${l}`,visible:u.table,onChange:me=>{u.table=me},disabled:a==null?void 0:a.value,key:"bar-table",overlay:m.createVNode(L5,{tableShape:e.tableShape,onSelected:me=>{c("table",{selectedShape:me})}},null)},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.table},[m.createVNode(ve,{name:"table"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.table])])]}});case"revoke":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Md=n.value.toolbarTips)==null?void 0:Md.revoke,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,Rb)}},[m.createVNode(ve,{name:"revoke"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ka=n.value.toolbarTips)==null?void 0:ka.revoke])]);case"next":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Fd=n.value.toolbarTips)==null?void 0:Fd.next,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,zb)}},[m.createVNode(ve,{name:"next"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(hr=n.value.toolbarTips)==null?void 0:hr.next])]);case"save":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(vt=n.value.toolbarTips)==null?void 0:vt.save,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,hu)}},[m.createVNode(ve,{name:"save"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(wo=n.value.toolbarTips)==null?void 0:wo.save])]);case"prettier":return e.noPrettier?"":m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(xa=n.value.toolbarTips)==null?void 0:xa.prettier,onClick:()=>{c("prettier")}},[m.createVNode(ve,{name:"prettier"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Yr=n.value.toolbarTips)==null?void 0:Yr.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.pageFullscreen&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Bd=n.value.toolbarTips)==null?void 0:Bd.pageFullscreen,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("pageFullscreen")}},[m.createVNode(ve,{name:e.setting.pageFullscreen?"minimize":"maximize"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(nu=n.value.toolbarTips)==null?void 0:nu.pageFullscreen])]);case"fullscreen":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.fullscreen&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Hd=n.value.toolbarTips)==null?void 0:Hd.fullscreen,onClick:()=>{if(a!=null&&a.value)return!1;O()}},[m.createVNode(ve,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ce=n.value.toolbarTips)==null?void 0:Ce.fullscreen])]);case"preview":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.preview&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Kd=n.value.toolbarTips)==null?void 0:Kd.preview,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("preview")}},[m.createVNode(ve,{name:"preview"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(LO=n.value.toolbarTips)==null?void 0:LO.preview])]);case"previewOnly":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.previewOnly&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(To=n.value.toolbarTips)==null?void 0:To.previewOnly,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("previewOnly")}},[m.createVNode(ve,{name:"preview-only"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(MO=n.value.toolbarTips)==null?void 0:MO.previewOnly])]);case"htmlPreview":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.htmlPreview&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Jd=n.value.toolbarTips)==null?void 0:Jd.htmlPreview,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("htmlPreview")}},[m.createVNode(ve,{name:"preview-html"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(FO=n.value.toolbarTips)==null?void 0:FO.htmlPreview])]);case"catalog":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.catalogVisible&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(pi=n.value.toolbarTips)==null?void 0:pi.catalog,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,gh)},key:"bar-catalog"},[m.createVNode(ve,{name:"catalog"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(eh=n.value.toolbarTips)==null?void 0:eh.catalog])]);case"github":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(va=n.value.toolbarTips)==null?void 0:va.github,onClick:()=>{if(a!=null&&a.value)return!1;T5("https://github.com/imzbf/md-editor-v3")}},[m.createVNode(ve,{name:"github"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(th=n.value.toolbarTips)==null?void 0:th.github])]);case"mermaid":return m.createVNode(_a,{relative:`#${l}`,visible:u.mermaid,onChange:me=>{u.mermaid=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.mermaid=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("flow")},role:"menuitem",tabindex:"0"},[(BO=n.value.mermaid)==null?void 0:BO.flow]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("sequence")},role:"menuitem",tabindex:"0"},[(Pn=n.value.mermaid)==null?void 0:Pn.sequence]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("gantt")},role:"menuitem",tabindex:"0"},[(iu=n.value.mermaid)==null?void 0:iu.gantt]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("class")},role:"menuitem",tabindex:"0"},[(nh=n.value.mermaid)==null?void 0:nh.class]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("state")},role:"menuitem",tabindex:"0"},[(Gi=n.value.mermaid)==null?void 0:Gi.state]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("pie")},role:"menuitem",tabindex:"0"},[(ih=n.value.mermaid)==null?void 0:ih.pie]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("relationship")},role:"menuitem",tabindex:"0"},[(ru=n.value.mermaid)==null?void 0:ru.relationship]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("journey")},role:"menuitem",tabindex:"0"},[(ou=n.value.mermaid)==null?void 0:ou.journey])]),key:"bar-mermaid"},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.mermaid},[m.createVNode(ve,{name:"mermaid"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.mermaid])])]}});case"katex":return m.createVNode(_a,{relative:`#${l}`,visible:u.katex,onChange:me=>{u.katex=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.katex=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-katex`,onClick:()=>{c("katexInline")},role:"menuitem",tabindex:"0"},[(rh=n.value.katex)==null?void 0:rh.inline]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-katex`,onClick:()=>{c("katexBlock")},role:"menuitem",tabindex:"0"},[(Cr=n.value.katex)==null?void 0:Cr.block])]),key:"bar-katex"},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.katex},[m.createVNode(ve,{name:"formula"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.katex])])]}})}else if(e.defToolbars instanceof Array){const me=e.defToolbars[g];return me?m.cloneVNode(me,{theme:((Ii=me.props)==null?void 0:Ii.theme)||i.value,previewTheme:((jr=me.props)==null?void 0:jr.theme)||r.value,language:((au=me.props)==null?void 0:au.theme)||o.value,codeTheme:((pr=me.props)==null?void 0:pr.codeTheme)||e.codeTheme,disabled:((oh=me.props)==null?void 0:oh.disabled)||(a==null?void 0:a.value),showToolbarName:((Ou=me.props)==null?void 0:Ou.showToolbarName)||e.showToolbarName,insert(su){F.emit(t,Ge,"universal",{generate:su})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const me=e.defToolbars.children[g];return me?m.cloneVNode(me,{theme:((wa=me.props)==null?void 0:wa.theme)||i.value,previewTheme:((mi=me.props)==null?void 0:mi.theme)||r.value,language:((Ta=me.props)==null?void 0:Ta.theme)||o.value,codeTheme:((ah=me.props)==null?void 0:ah.codeTheme)||e.codeTheme,disabled:((lu=me.props)==null?void 0:lu.disabled)||(a==null?void 0:a.value),showToolbarName:((Oh=me.props)==null?void 0:Oh.showToolbarName)||e.showToolbarName,insert(su){F.emit(t,Ge,"universal",{generate:su})}}):""}else return""};return m.watch(()=>e.toolbars,()=>{m.nextTick(()=>{s.value&&_5(s.value)})},{immediate:!0}),()=>{var k;const g=p.value[0].map(y=>$(y)),S=p.value[1].map(y=>$(y));return m.createVNode(m.Fragment,null,[e.toolbars.length>0&&m.createVNode("div",{class:`${T}-toolbar-wrapper`,ref:s,id:l},[m.createVNode("div",{class:[`${T}-toolbar`,e.showToolbarName&&`${T}-stn`]},[m.createVNode("div",{class:`${T}-toolbar-left`,ref:h},[g]),m.createVNode("div",{class:`${T}-toolbar-right`},[S])])]),m.createVNode("label",{for:`${l}_label`,style:{display:"none"},"aria-label":(k=n.value.imgTitleItem)==null?void 0:k.upload},null),m.createVNode("input",{id:`${l}_label`,ref:Q,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),m.createVNode(EW,{linkVisible:f.linkVisible,clipVisible:f.clipVisible,type:f.type,onCancel:()=>{f.linkVisible=!1,f.clipVisible=!1},onOk:y=>{y&&c(f.type,{desc:y.desc,url:y.url,transform:f.type==="image"}),f.linkVisible=!1,f.clipVisible=!1}},null)])}}}),CW=`.${T}-preview > [data-line]`,Ra=(e,t)=>+getComputedStyle(e).getPropertyValue(t).replace("px",""),jW=(e,t)=>{const n=bb(()=>{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)}]},AW=(e,t,n)=>{const{view:i}=n,r=yb(),o=$=>i.lineBlockAt(i.state.doc.line($+1).from).top,a=$=>i.lineBlockAt(i.state.doc.line($+1).from).bottom;let O=[],l=[],s=[];const u=()=>{O=[],l=Array.from(t.querySelectorAll(CW)),s=l.map(y=>Number(y.dataset.line));const $=[...s],{lines:g}=i.state.doc;let S=$.shift()||0,k=$.shift()||g;for(let y=0;y<g;y++)y===k&&(S=y,k=$.shift()||g),O.push({start:S,end:k-1})},c=($,g)=>{let S=1;for(let k=l.length-1;k-1>=0;k--){const y=l[k],X=l[k-1];if(y.offsetTop+y.offsetHeight>g&&X.offsetTop<g){S=Number(X.dataset.line);break}}for(let k=O.length-1;k>=0;k--){const y=a(O[k].end),X=o(O[k].start);if(y>$&&X<=$){S=S<O[k].start?S:O[k].start;break}}return S};let f=0,h=0;const p=()=>{var I,N,A;if(h!==0)return!1;f++;const{scrollDOM:$,contentHeight:g}=i;let S=Ra(t,"padding-top");const k=i.lineBlockAtHeight($.scrollTop),{number:y}=i.state.doc.lineAt(k.from),X=O[y-1];if(!X)return!1;let x=1;const v=t.querySelector(`[data-line="${X.start}"]`)||((I=t.firstElementChild)==null?void 0:I.firstElementChild),w=t.querySelector(`[data-line="${X.end+1}"]`)||((N=t.lastElementChild)==null?void 0:N.lastElementChild),W=$.scrollHeight-$.clientHeight,E=t.scrollHeight-t.clientHeight;let V=o(X.start),U=a(X.end),_=v.offsetTop,q=w.offsetTop-_;V===0&&(_=0,v===w?(S=0,U=g-$.offsetHeight,q=E):q=w.offsetTop),x=($.scrollTop-V)/(U-V);const Z=w==((A=t.lastElementChild)==null?void 0:A.lastElementChild)?w.offsetTop+w.clientHeight:w.offsetTop;if(U>=W||Z>E){const L=c(W,E);V=o(L),x=($.scrollTop-V)/(W-V);const ee=t.querySelector(`[data-line="${L}"]`);V>0&&ee&&(_=ee.offsetTop),q=E-_+Ra(t,"padding-top")}const Y=_-S+q*x;r(t,Y,()=>{f--})},Q=()=>{var Z,Y,I,N,A,L;if(f!==0)return;h++;const{scrollDOM:$}=i,g=t.scrollTop,S=t.scrollHeight,k=$.scrollHeight-$.clientHeight,y=t.scrollHeight-t.clientHeight;let X=(Z=t.firstElementChild)==null?void 0:Z.firstElementChild,x=(Y=t.firstElementChild)==null?void 0:Y.lastElementChild;if(s.length>0){let ee=Math.ceil(s[s.length-1]*(g/S)),se=s.findLastIndex(Ue=>Ue<=ee);se=se===-1?0:se,ee=s[se];for(let Ue=se;Ue>=0&&Ue<s.length;)if(l[Ue].offsetTop>g){if(Ue-1>=0){Ue--;continue}ee=-1,se=Ue;break}else{if(Ue+1<s.length&&l[Ue+1].offsetTop<g){Ue++;continue}ee=s[Ue],se=Ue;break}switch(se){case-1:{X=(I=t.firstElementChild)==null?void 0:I.firstElementChild,x=l[se];break}case s.length-1:{X=l[se],x=(N=t.firstElementChild)==null?void 0:N.lastElementChild;break}default:X=l[se],x=l[se+1===l.length?se:se+1]}}let v=X===((A=t.firstElementChild)==null?void 0:A.firstElementChild)?0:X.offsetTop-Ra(X,"margin-top"),w=x.offsetTop,W=0;const{start:E,end:V}=O[Number(X.dataset.line||0)];let U=o(E);const _=o(V+1===i.state.doc.lines?V:V+1);let q=0;if(_>k||x.offsetTop+x.offsetHeight>y){const ee=c(k,y),se=t.querySelector(`[data-line="${ee}"]`);v=se?se.offsetTop-Ra(se,"margin-top"):v,U=o(ee),W=(g-v)/(y-v),q=k-U}else X===((L=t.firstElementChild)==null?void 0:L.firstElementChild)?(X===x&&(w=x.offsetTop+x.offsetHeight+ +getComputedStyle(x).marginBottom.replace("px","")),q=_,W=Math.max(g/w,0)):(W=Math.max((g-v)/(w-v),0),q=_-U);r(e,U+q*W,()=>{h--})},b=$=>{var y;const{scrollDOM:g,contentHeight:S}=i,k=g.clientHeight;if(S<=k||t.firstElementChild.clientHeight<=t.clientHeight||i.state.doc.lines<=((y=O[O.length-1])==null?void 0:y.end))return!1;$.target===e?p():Q()};return[()=>{u(),e.addEventListener("scroll",b),t.addEventListener("scroll",b),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",b),t.removeEventListener("scroll",b)}]},GW={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},onActive:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},jb=m.defineComponent({props:GW,setup(e){const t=m.inject("scrollElementRef"),n=m.inject("roorNodeRef"),i=m.ref();return m.watch(()=>e.tocItem.active,r=>{r&&(i.value?e.onActive(e.tocItem,i.value):m.nextTick(()=>{e.onActive(e.tocItem,i.value)}))},{immediate:!0}),()=>{const{tocItem:r,mdHeadingId:o,onClick:a,scrollElementOffsetTop:O}=e;return m.createVNode("div",{ref:i,class:[`${T}-catalog-link`,r.active&&`${T}-catalog-active`],onClick:l=>{if(l.stopPropagation(),a(l,r),l.defaultPrevented)return;const s=o(r.text,r.level,r.index),u=n.value.getElementById(s),c=t.value;if(u&&c){let f=u.offsetParent,h=u.offsetTop;if(c.contains(f))for(;f&&c!=f;)h+=f==null?void 0:f.offsetTop,f=f==null?void 0:f.offsetParent;const p=u.previousElementSibling;let Q=0;p||(Q=Ra(u,"margin-top")),c==null||c.scrollTo({top:h-O-Q,behavior:"smooth"})}}},[m.createVNode("span",{title:r.text},[r.text]),r.children&&r.children.length>0&&m.createVNode("div",{class:`${T}-catalog-wrapper`},[r.children.map(l=>m.createVNode(jb,{mdHeadingId:o,key:`${r.text}-link-${l.level}-${l.text}`,tocItem:l,onActive:e.onActive,onClick:a,scrollElementOffsetTop:O},null))])])}}}),IW={editorId:{type:String,default:void 0},class:{type:String,default:""},mdHeadingId:{type:Function,default:e=>e},scrollElement:{type:[String,Object],default:void 0},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function,default:void 0},onActive:{type:Function,default:void 0},isScrollElementInShadow:{type:Boolean,default:!1},syncWith:{type:String,default:"preview"},catalogMaxDepth:{type:Number,default:void 0}},za=m.defineComponent({name:"MdCatalog",props:IW,emits:["onClick","onActive"],setup(e,t){const n=e.editorId,i=`#${n}-preview-wrapper`,r=m.reactive({list:[],show:!1,scrollElement:e.scrollElement||i}),o=m.shallowRef(),a=m.ref(),O=m.ref(),l=m.ref(),s=m.ref(),u=m.shallowRef(),c=m.ref({});m.provide("scrollElementRef",O),m.provide("roorNodeRef",s);const f=m.computed(()=>{const S=[];return r.list.forEach((k,y)=>{if(e.catalogMaxDepth&&k.level>e.catalogMaxDepth)return;const{text:X,level:x,line:v}=k,w={level:x,text:X,line:v,index:y+1,active:o.value===k};if(S.length===0)S.push(w);else{let W=S[S.length-1];if(w.level>W.level)for(let E=W.level+1;E<=6;E++){const{children:V}=W;if(!V){W.children=[w];break}if(W=V[V.length-1],w.level<=W.level){V.push(w);break}}else S.push(w)}}),S}),h=()=>{var k;if(r.scrollElement instanceof HTMLElement)return r.scrollElement;let S=document;return(r.scrollElement===i||e.isScrollElementInShadow)&&(S=(k=a.value)==null?void 0:k.getRootNode()),S.querySelector(r.scrollElement)},p=S=>{if(S.length===0)return o.value=void 0,r.list=[],!1;const{activeHead:k}=S.reduce((y,X,x)=>{var w;let v=0;if(e.syncWith==="preview"){const W=(w=s.value)==null?void 0:w.getElementById(e.mdHeadingId(X.text,X.level,x+1));W instanceof HTMLElement&&(v=RW(W,O.value))}else{const W=u.value;if(W){const E=W.lineBlockAt(W.state.doc.line(X.line+1).from).top,V=W.scrollDOM.scrollTop;v=E-V}}return v<e.offsetTop&&v>y.minTop?{activeHead:X,minTop:v}:y},{activeHead:S[0],minTop:Number.MIN_SAFE_INTEGER});o.value=k,r.list=S},Q=(S,k)=>{var y;c.value.top=k.offsetTop+Ra(k,"padding-top")+"px",(y=e.onActive)==null||y.call(e,S,k),t.emit("onActive",S,k)},b=()=>{p(r.list)},$=S=>{var k,y,X;if((k=l.value)==null||k.removeEventListener("scroll",b),e.syncWith==="editor")l.value=(y=u.value)==null?void 0:y.scrollDOM;else{const x=h();O.value=x,l.value=x===document.documentElement?document:x}p(S),(X=l.value)==null||X.addEventListener("scroll",b)},g=S=>{u.value=S};return m.watch([()=>e.syncWith,u,()=>e.catalogMaxDepth],()=>{$(r.list)}),m.onMounted(()=>{s.value=a.value.getRootNode(),F.on(n,{name:KO,callback:$}),F.on(n,{name:gu,callback:g}),F.emit(n,Wb),F.emit(n,Ub)}),m.onBeforeUnmount(()=>{var S;F.remove(n,KO,$),F.remove(n,gu,g),(S=l.value)==null||S.removeEventListener("scroll",b)}),()=>m.createVNode("div",{class:[`${T}-catalog`,e.theme==="dark"&&`${T}-catalog-dark`,e.class||""],ref:a},[f.value.length>0&&m.createVNode(m.Fragment,null,[m.createVNode("div",{class:`${T}-catalog-indicator`,style:c.value},null),m.createVNode("div",{class:`${T}-catalog-container`},[f.value.map(S=>m.createVNode(jb,{mdHeadingId:e.mdHeadingId,tocItem:S,key:`link-${S.level}-${S.text}`,onActive:Q,onClick:(k,y)=>{var X;(X=e.onClick)==null||X.call(e,k,y),t.emit("onClick",k,y)},scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])])}});za.install=e=>(e.component(za.name,za),e);const DW=(e,t,n)=>{const i=m.inject("editorId");let r=()=>{},o=()=>{};const a=()=>{var c;r();const O=(c=n.value)==null?void 0:c.view.contentDOM.getRootNode(),l=O.querySelector(`#${i} .cm-scroller`),s=O.querySelector(`[id="${i}-preview-wrapper"]`),u=O.querySelector(`[id="${i}-html-wrapper"]`);(s||u)&&([o,r]=(s?AW:jW)(l,s||u,n.value),e.scrollAuto&&o())};m.watch([t,m.toRef(e.setting,"preview"),m.toRef(e.setting,"htmlPreview"),m.toRef(e.setting,"fullscreen"),m.toRef(e.setting,"pageFullscreen")],()=>{m.nextTick(a)}),m.watch(()=>e.scrollAuto,O=>{O?o():r()}),m.watch(()=>e.setting.previewOnly,O=>{O?r():o()}),m.onMounted(a)};let Ve=class k5{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]=Wa(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),Di.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]=Wa(this,t,n);let i=[];return this.decompose(t,n,i,0),Di.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 el(this),o=new el(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 el(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 Ib(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]?k5.empty:t.length<=32?new pt(t):Di.from(pt.split(t,[]))}};class pt extends Ve{constructor(t,n=NW(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 LW(r,O,i,a);r=O+1,i++}}decompose(t,n,i,r){let o=t<=0&&n>=this.length?this:new pt(Ab(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),O=Qu(o.text,a.text.slice(),0,o.length);if(O.length<=32)i.push(new pt(O,a.length+o.length));else{let l=O.length>>1;i.push(new pt(O.slice(0,l)),new pt(O.slice(l)))}}else i.push(o)}replace(t,n,i){if(!(i instanceof pt))return super.replace(t,n,i);[t,n]=Wa(this,t,n);let r=Qu(this.text,Qu(i.text,Ab(this.text,0,t)),n),o=this.length+i.length-(n-t);return r.length<=32?new pt(r,o):Di.from(pt.split(r,[]),o)}sliceString(t,n=this.length,i=`
|
|
182
|
+
`),i=['<span rn-wrapper aria-hidden="true">'];return n.forEach(()=>{i.push("<span></span>")}),i.push("</span>"),`<span class="${T}-code-block">${e}</span>${i.join("")}`},RW=(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},Cb=(()=>{let e=0;return()=>++e})(),zW={title:{type:[String,Object],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,default:void 0},style:{type:[Object,String],default:()=>({})},showMask:{type:Boolean,default:!0}},zo=m.defineComponent({name:"MdModal",props:zW,emits:["onClose"],setup(e,t){const n=m.inject("theme"),i=m.inject("rootRef"),r=m.ref(e.visible),o=m.ref([`${T}-modal`]),a=m.ref(),O=m.ref(),l=m.ref(),s=m.shallowRef();let u=()=>{};const c=m.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),f=m.computed(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height});m.watch(()=>e.isFullscreen,Q=>{Q?u():m.nextTick(()=>{u=Vb(O.value,(b,$)=>{c.initPos.left=b+"px",c.initPos.top=$+"px"})})}),m.watch(()=>e.visible,Q=>{Q?(c.maskStyle.zIndex=ht.editorConfig.zIndex+Cb(),c.modalStyle.zIndex=ht.editorConfig.zIndex+Cb(),o.value.push("zoom-in"),r.value=Q,m.nextTick(()=>{const b=a.value.offsetWidth/2,$=a.value.offsetHeight/2,g=document.documentElement.clientWidth/2,S=document.documentElement.clientHeight/2;c.initPos.left=g-b+"px",c.initPos.top=S-$+"px",e.isFullscreen||(u=Vb(O.value,(k,y)=>{c.initPos.left=k+"px",c.initPos.top=y+"px"}))}),setTimeout(()=>{o.value=o.value.filter(b=>b!=="zoom-in")},140)):(o.value.push("zoom-out"),u(),setTimeout(()=>{o.value=o.value.filter(b=>b!=="zoom-out"),r.value=Q},130))});const h=m.computed(()=>({display:r.value?"block":"none"})),p=m.computed(()=>typeof e.style=="string"?[e.style,h.value].join("; "):e.style instanceof Object?{...h.value,...e.style}:h.value);return m.onMounted(()=>{var b;const Q=(b=i.value)==null?void 0:b.getRootNode();l.value=Q instanceof Document?document.body:Q}),()=>{const Q=tn({ctx:t}),b=tn({props:e,ctx:t},"title");return l.value?m.createVNode(m.Teleport,{to:l.value},{default:()=>[m.createVNode("div",{ref:s,class:`${T}-modal-container`,"data-theme":n.value},[m.createVNode("div",{class:e.class,style:p.value},[e.showMask&&m.createVNode("div",{class:`${T}-modal-mask`,style:c.maskStyle,onClick:()=>{var $;($=e.onClose)==null||$.call(e),t.emit("onClose")}},null),m.createVNode("div",{class:o.value,style:{...c.modalStyle,...c.initPos,...f.value},ref:a},[m.createVNode("div",{class:`${T}-modal-header`,ref:O},[b||""]),m.createVNode("div",{class:`${T}-modal-body`},[Q]),m.createVNode("div",{class:`${T}-modal-func`},[e.showAdjust&&m.createVNode("div",{class:`${T}-modal-adjust`,onClick:$=>{$.stopPropagation(),e.isFullscreen?c.initPos=c.historyPos:(c.historyPos=c.initPos,c.initPos={left:"0",top:"0"}),e.onAdjust(!e.isFullscreen)}},[m.createVNode(ve,{name:e.isFullscreen?"minimize":"maximize"},null)]),m.createVNode("div",{class:`${T}-modal-close`,onClick:$=>{var g;$.stopPropagation(),(g=e.onClose)==null||g.call(e),t.emit("onClose")}},[m.createVNode(ve,{name:"close"},null)])])])])])]}):""}}});zo.install=e=>(e.component(zo.name,zo),e);const WW={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},qW=m.defineComponent({name:`${T}-modal-link`,props:WW,setup(e){const t=m.inject("usedLanguageText"),n=m.inject("editorId"),i=m.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=m.reactive({desc:"",url:""});return m.watch(()=>e.visible,o=>{o||setTimeout(()=>{r.desc="",r.url=""},200)}),()=>m.createVNode(zo,{title:i.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var o,a,O,l,s;return[m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("label",{class:`${T}-label`,for:`link-desc-${n}`},[(o=t.value.linkModalTips)==null?void 0:o.descLabel]),m.createVNode("input",{placeholder:(a=t.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${T}-input`,id:`link-desc-${n}`,type:"text",value:r.desc,onChange:u=>{r.desc=u.target.value},autocomplete:"off"},null)]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("label",{class:`${T}-label`,for:`link-url-${n}`},[(O=t.value.linkModalTips)==null?void 0:O.urlLabel]),m.createVNode("input",{placeholder:(l=t.value.linkModalTips)==null?void 0:l.urlLabelPlaceHolder,class:`${T}-input`,id:`link-url-${n}`,type:"text",value:r.url,onChange:u=>{r.url=u.target.value},autocomplete:"off"},null)]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("button",{class:[`${T}-btn`,`${T}-btn-row`],type:"button",onClick:()=>{e.onOk(r),r.desc="",r.url=""}},[(s=t.value.linkModalTips)==null?void 0:s.buttonOK])])]}})}}),ZW={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},UW=m.defineComponent({name:`${T}-modal-clip`,props:ZW,setup(e){const t=m.inject("usedLanguageText"),n=m.inject("editorId"),i=m.inject("rootRef");let r=ht.editorExtensions.cropper.instance;const o=m.ref(),a=m.ref(),O=m.ref(),l=m.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let s=null;m.watch(()=>e.visible,()=>{e.visible&&!l.cropperInited&&(r=r||window.Cropper,o.value.onchange=()=>{if(!r){F.emit(n,Ar,{name:"Cropper",message:"Cropper is undefined"});return}const c=o.value.files||[];if(l.imgSelected=!0,(c==null?void 0:c.length)>0){const f=new FileReader;f.onload=h=>{l.imgSrc=h.target.result},f.readAsDataURL(c[0])}})}),m.watch(()=>[l.imgSelected],()=>{O.value.style=""}),m.watch([m.toRef(()=>l.isFullscreen),m.toRef(()=>l.imgSrc)],()=>{l.imgSrc&&m.nextTick(()=>{s==null||s.destroy(),O.value.style="",a.value&&(s=new r(a.value,{viewMode:2,preview:i.value.getRootNode().querySelector(`.${T}-clip-preview-target`)}))})});const u=()=>{s.clear(),s.destroy(),s=null,o.value.value="",l.imgSelected=!1};return()=>{var c;return m.createVNode(zo,{class:`${T}-modal-clip`,title:(c=t.value.clipModalTips)==null?void 0:c.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:l.isFullscreen,onAdjust:f=>{l.isFullscreen=f},width:"668px",height:"421px"},{default:()=>{var f,h,p;return[m.createVNode("div",{class:`${T}-form-item ${T}-clip`},[m.createVNode("div",{class:`${T}-clip-main`},[l.imgSelected?m.createVNode("div",{class:`${T}-clip-cropper`},[m.createVNode("img",{src:l.imgSrc,ref:a,style:{display:"none"},alt:""},null),m.createVNode("div",{class:`${T}-clip-delete`,onClick:u},[m.createVNode(ve,{name:"delete"},null)])]):m.createVNode("div",{class:`${T}-clip-upload`,onClick:()=>{o.value.click()},role:"button",tabindex:"0","aria-label":(f=t.value.imgTitleItem)==null?void 0:f.upload},[m.createVNode(ve,{name:"upload"},null)])]),m.createVNode("div",{class:`${T}-clip-preview`},[m.createVNode("div",{class:`${T}-clip-preview-target`,ref:O},null)])]),m.createVNode("div",{class:`${T}-form-item`},[m.createVNode("button",{class:`${T}-btn`,type:"button",onClick:()=>{if(s){const Q=s.getCroppedCanvas();F.emit(n,mu,[XW(Q.toDataURL("image/png"))],e.onOk),u()}}},[((h=t.value.clipModalTips)==null?void 0:h.buttonUpload)||((p=t.value.linkModalTips)==null?void 0:p.buttonOK)])]),m.createVNode("input",{ref:o,accept:"image/*",type:"file",multiple:!1,style:{display:"none"},"aria-hidden":"true"},null)]}})}}}),VW={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},EW=m.defineComponent({name:`${T}-modals`,props:VW,setup(e){return()=>m.createVNode(m.Fragment,null,[m.createVNode(qW,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),m.createVNode(UW,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),YW=m.defineComponent({name:"MDEditorToolbar",props:j5,setup(e){const t=m.inject("editorId"),n=m.inject("usedLanguageText"),i=m.inject("theme"),r=m.inject("previewTheme"),o=m.inject("language"),a=m.inject("disabled"),{fullscreenHandler:O}=D5(e),l=`${t}-toolbar-wrapper`,s=m.ref(),u=m.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),c=(g,S)=>{if(a!=null&&a.value)return!1;F.emit(t,Ge,g,S)},f=m.reactive({type:"link",linkVisible:!1,clipVisible:!1}),h=m.ref();m.onMounted(()=>{F.on(t,{name:$h,callback(g){f.type=g,f.linkVisible=!0}})});const p=m.computed(()=>{const g=e.toolbars.filter(X=>!e.toolbarsExclude.includes(X)),S=g.indexOf("="),k=S===-1?g:g.slice(0,S+1),y=S===-1?[]:g.slice(S,Number.MAX_SAFE_INTEGER);return[k,y]}),Q=m.ref(),b=()=>{F.emit(t,mu,Array.from(Q.value.files||[])),Q.value.value=""};m.onMounted(()=>{Q.value.addEventListener("change",b)});const $=g=>{var S,k,y,X,x,v,w,W,E,V,U,_,q,Z,Y,I,N,A,L,ee,se,Ue,M,ce,Re,De,xt,hi,Dn,Ai,IO,Sa,Er,DO,NO,Pa,Ld,Md,ka,Fd,hr,vt,wo,xa,Yr,Bd,nu,Hd,Ce,Kd,LO,To,MO,Jd,FO,pi,eh,va,th,BO,Pn,iu,nh,Gi,ih,ru,ou,rh,Cr,Ii,jr,au,pr,oh,Ou,wa,mi,Ta,ah,lu,Oh;if(ph.includes(g))switch(g){case"-":return m.createVNode(E5,null,null);case"bold":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(S=n.value.toolbarTips)==null?void 0:S.bold,onClick:()=>{c("bold")}},[m.createVNode(ve,{name:"bold"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(k=n.value.toolbarTips)==null?void 0:k.bold])]);case"underline":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(y=n.value.toolbarTips)==null?void 0:y.underline,onClick:()=>{c("underline")}},[m.createVNode(ve,{name:"underline"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(X=n.value.toolbarTips)==null?void 0:X.underline])]);case"italic":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(x=n.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{c("italic")}},[m.createVNode(ve,{name:"italic"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(v=n.value.toolbarTips)==null?void 0:v.italic])]);case"strikeThrough":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(w=n.value.toolbarTips)==null?void 0:w.strikeThrough,onClick:()=>{c("strikeThrough")}},[m.createVNode(ve,{name:"strike-through"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(W=n.value.toolbarTips)==null?void 0:W.strikeThrough])]);case"title":return m.createVNode(_a,{relative:`#${l}`,visible:u.title,onChange:me=>{u.title=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.title=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h1")},role:"menuitem",tabindex:"0"},[(E=n.value.titleItem)==null?void 0:E.h1]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h2")},role:"menuitem",tabindex:"0"},[(V=n.value.titleItem)==null?void 0:V.h2]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h3")},role:"menuitem",tabindex:"0"},[(U=n.value.titleItem)==null?void 0:U.h3]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h4")},role:"menuitem",tabindex:"0"},[(_=n.value.titleItem)==null?void 0:_.h4]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h5")},role:"menuitem",tabindex:"0"},[(q=n.value.titleItem)==null?void 0:q.h5]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-title`,onClick:()=>{c("h6")},role:"menuitem",tabindex:"0"},[(Z=n.value.titleItem)==null?void 0:Z.h6])])},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.title},[m.createVNode(ve,{name:"title"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.title])])]}});case"sub":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Y=n.value.toolbarTips)==null?void 0:Y.sub,onClick:()=>{c("sub")}},[m.createVNode(ve,{name:"sub"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(I=n.value.toolbarTips)==null?void 0:I.sub])]);case"sup":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(N=n.value.toolbarTips)==null?void 0:N.sup,onClick:()=>{c("sup")}},[m.createVNode(ve,{name:"sup"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(A=n.value.toolbarTips)==null?void 0:A.sup])]);case"quote":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(L=n.value.toolbarTips)==null?void 0:L.quote,onClick:()=>{c("quote")}},[m.createVNode(ve,{name:"quote"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ee=n.value.toolbarTips)==null?void 0:ee.quote])]);case"unorderedList":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(se=n.value.toolbarTips)==null?void 0:se.unorderedList,onClick:()=>{c("unorderedList")}},[m.createVNode(ve,{name:"unordered-list"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ue=n.value.toolbarTips)==null?void 0:Ue.unorderedList])]);case"orderedList":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(M=n.value.toolbarTips)==null?void 0:M.orderedList,onClick:()=>{c("orderedList")}},[m.createVNode(ve,{name:"ordered-list"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ce=n.value.toolbarTips)==null?void 0:ce.orderedList])]);case"task":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Re=n.value.toolbarTips)==null?void 0:Re.task,onClick:()=>{c("task")}},[m.createVNode(ve,{name:"task"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(De=n.value.toolbarTips)==null?void 0:De.task])]);case"codeRow":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(xt=n.value.toolbarTips)==null?void 0:xt.codeRow,onClick:()=>{c("codeRow")}},[m.createVNode(ve,{name:"code-row"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(hi=n.value.toolbarTips)==null?void 0:hi.codeRow])]);case"code":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Dn=n.value.toolbarTips)==null?void 0:Dn.code,onClick:()=>{c("code")}},[m.createVNode(ve,{name:"code"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ai=n.value.toolbarTips)==null?void 0:Ai.code])]);case"link":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(IO=n.value.toolbarTips)==null?void 0:IO.link,onClick:()=>{if(a!=null&&a.value)return!1;f.type="link",f.linkVisible=!0}},[m.createVNode(ve,{name:"link"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Sa=n.value.toolbarTips)==null?void 0:Sa.link])]);case"image":return e.noUploadImg?m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Er=n.value.toolbarTips)==null?void 0:Er.image,onClick:()=>{if(a!=null&&a.value)return!1;f.type="image",f.linkVisible=!0}},[m.createVNode(ve,{name:"image"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(DO=n.value.toolbarTips)==null?void 0:DO.image])]):m.createVNode(_a,{relative:`#${l}`,visible:u.image,onChange:me=>{u.image=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.title=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{f.type="image",f.linkVisible=!0},role:"menuitem",tabindex:"0"},[(NO=n.value.imgTitleItem)==null?void 0:NO.link]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{Q.value.click()},role:"menuitem",tabindex:"0"},[(Pa=n.value.imgTitleItem)==null?void 0:Pa.upload]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-image`,onClick:()=>{f.clipVisible=!0},role:"menuitem",tabindex:"0"},[(Ld=n.value.imgTitleItem)==null?void 0:Ld.clip2upload])])},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.image},[m.createVNode(ve,{name:"image"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.image])])]}});case"table":return m.createVNode(_a,{relative:`#${l}`,visible:u.table,onChange:me=>{u.table=me},disabled:a==null?void 0:a.value,key:"bar-table",overlay:m.createVNode(L5,{tableShape:e.tableShape,onSelected:me=>{c("table",{selectedShape:me})}},null)},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.table},[m.createVNode(ve,{name:"table"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.table])])]}});case"revoke":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Md=n.value.toolbarTips)==null?void 0:Md.revoke,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,Rb)}},[m.createVNode(ve,{name:"revoke"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(ka=n.value.toolbarTips)==null?void 0:ka.revoke])]);case"next":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Fd=n.value.toolbarTips)==null?void 0:Fd.next,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,zb)}},[m.createVNode(ve,{name:"next"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(hr=n.value.toolbarTips)==null?void 0:hr.next])]);case"save":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(vt=n.value.toolbarTips)==null?void 0:vt.save,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,hu)}},[m.createVNode(ve,{name:"save"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(wo=n.value.toolbarTips)==null?void 0:wo.save])]);case"prettier":return e.noPrettier?"":m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(xa=n.value.toolbarTips)==null?void 0:xa.prettier,onClick:()=>{c("prettier")}},[m.createVNode(ve,{name:"prettier"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Yr=n.value.toolbarTips)==null?void 0:Yr.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.pageFullscreen&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Bd=n.value.toolbarTips)==null?void 0:Bd.pageFullscreen,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("pageFullscreen")}},[m.createVNode(ve,{name:e.setting.pageFullscreen?"minimize":"maximize"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(nu=n.value.toolbarTips)==null?void 0:nu.pageFullscreen])]);case"fullscreen":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.fullscreen&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Hd=n.value.toolbarTips)==null?void 0:Hd.fullscreen,onClick:()=>{if(a!=null&&a.value)return!1;O()}},[m.createVNode(ve,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Ce=n.value.toolbarTips)==null?void 0:Ce.fullscreen])]);case"preview":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.preview&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Kd=n.value.toolbarTips)==null?void 0:Kd.preview,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("preview")}},[m.createVNode(ve,{name:"preview"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(LO=n.value.toolbarTips)==null?void 0:LO.preview])]);case"previewOnly":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.previewOnly&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(To=n.value.toolbarTips)==null?void 0:To.previewOnly,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("previewOnly")}},[m.createVNode(ve,{name:"preview-only"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(MO=n.value.toolbarTips)==null?void 0:MO.previewOnly])]);case"htmlPreview":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.setting.htmlPreview&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(Jd=n.value.toolbarTips)==null?void 0:Jd.htmlPreview,onClick:()=>{if(a!=null&&a.value)return!1;e.updateSetting("htmlPreview")}},[m.createVNode(ve,{name:"preview-html"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(FO=n.value.toolbarTips)==null?void 0:FO.htmlPreview])]);case"catalog":return m.createVNode("div",{class:[`${T}-toolbar-item`,e.catalogVisible&&`${T}-toolbar-active`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(pi=n.value.toolbarTips)==null?void 0:pi.catalog,onClick:()=>{if(a!=null&&a.value)return!1;F.emit(t,gh)},key:"bar-catalog"},[m.createVNode(ve,{name:"catalog"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(eh=n.value.toolbarTips)==null?void 0:eh.catalog])]);case"github":return m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(va=n.value.toolbarTips)==null?void 0:va.github,onClick:()=>{if(a!=null&&a.value)return!1;T5("https://github.com/imzbf/md-editor-v3")}},[m.createVNode(ve,{name:"github"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(th=n.value.toolbarTips)==null?void 0:th.github])]);case"mermaid":return m.createVNode(_a,{relative:`#${l}`,visible:u.mermaid,onChange:me=>{u.mermaid=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.mermaid=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("flow")},role:"menuitem",tabindex:"0"},[(BO=n.value.mermaid)==null?void 0:BO.flow]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("sequence")},role:"menuitem",tabindex:"0"},[(Pn=n.value.mermaid)==null?void 0:Pn.sequence]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("gantt")},role:"menuitem",tabindex:"0"},[(iu=n.value.mermaid)==null?void 0:iu.gantt]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("class")},role:"menuitem",tabindex:"0"},[(nh=n.value.mermaid)==null?void 0:nh.class]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("state")},role:"menuitem",tabindex:"0"},[(Gi=n.value.mermaid)==null?void 0:Gi.state]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("pie")},role:"menuitem",tabindex:"0"},[(ih=n.value.mermaid)==null?void 0:ih.pie]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("relationship")},role:"menuitem",tabindex:"0"},[(ru=n.value.mermaid)==null?void 0:ru.relationship]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-mermaid`,onClick:()=>{c("journey")},role:"menuitem",tabindex:"0"},[(ou=n.value.mermaid)==null?void 0:ou.journey])]),key:"bar-mermaid"},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.mermaid},[m.createVNode(ve,{name:"mermaid"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.mermaid])])]}});case"katex":return m.createVNode(_a,{relative:`#${l}`,visible:u.katex,onChange:me=>{u.katex=me},disabled:a==null?void 0:a.value,overlay:m.createVNode("ul",{class:`${T}-menu`,onClick:()=>{u.katex=!1},role:"menu"},[m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-katex`,onClick:()=>{c("katexInline")},role:"menuitem",tabindex:"0"},[(rh=n.value.katex)==null?void 0:rh.inline]),m.createVNode("li",{class:`${T}-menu-item ${T}-menu-item-katex`,onClick:()=>{c("katexBlock")},role:"menuitem",tabindex:"0"},[(Cr=n.value.katex)==null?void 0:Cr.block])]),key:"bar-katex"},{default:()=>{var me,Rt;return[m.createVNode("div",{class:[`${T}-toolbar-item`,(a==null?void 0:a.value)&&`${T}-disabled`],title:(me=n.value.toolbarTips)==null?void 0:me.katex},[m.createVNode(ve,{name:"formula"},null),e.showToolbarName&&m.createVNode("div",{class:`${T}-toolbar-item-name`},[(Rt=n.value.toolbarTips)==null?void 0:Rt.katex])])]}})}else if(e.defToolbars instanceof Array){const me=e.defToolbars[g];return me?m.cloneVNode(me,{theme:((Ii=me.props)==null?void 0:Ii.theme)||i.value,previewTheme:((jr=me.props)==null?void 0:jr.theme)||r.value,language:((au=me.props)==null?void 0:au.theme)||o.value,codeTheme:((pr=me.props)==null?void 0:pr.codeTheme)||e.codeTheme,disabled:((oh=me.props)==null?void 0:oh.disabled)||(a==null?void 0:a.value),showToolbarName:((Ou=me.props)==null?void 0:Ou.showToolbarName)||e.showToolbarName,insert(su){F.emit(t,Ge,"universal",{generate:su})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const me=e.defToolbars.children[g];return me?m.cloneVNode(me,{theme:((wa=me.props)==null?void 0:wa.theme)||i.value,previewTheme:((mi=me.props)==null?void 0:mi.theme)||r.value,language:((Ta=me.props)==null?void 0:Ta.theme)||o.value,codeTheme:((ah=me.props)==null?void 0:ah.codeTheme)||e.codeTheme,disabled:((lu=me.props)==null?void 0:lu.disabled)||(a==null?void 0:a.value),showToolbarName:((Oh=me.props)==null?void 0:Oh.showToolbarName)||e.showToolbarName,insert(su){F.emit(t,Ge,"universal",{generate:su})}}):""}else return""};return m.watch(()=>e.toolbars,()=>{m.nextTick(()=>{s.value&&_5(s.value)})},{immediate:!0}),()=>{var k;const g=p.value[0].map(y=>$(y)),S=p.value[1].map(y=>$(y));return m.createVNode(m.Fragment,null,[e.toolbars.length>0&&m.createVNode("div",{class:`${T}-toolbar-wrapper`,ref:s,id:l},[m.createVNode("div",{class:[`${T}-toolbar`,e.showToolbarName&&`${T}-stn`]},[m.createVNode("div",{class:`${T}-toolbar-left`,ref:h},[g]),m.createVNode("div",{class:`${T}-toolbar-right`},[S])])]),m.createVNode("label",{for:`${l}_label`,style:{display:"none"},"aria-label":(k=n.value.imgTitleItem)==null?void 0:k.upload},null),m.createVNode("input",{id:`${l}_label`,ref:Q,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),m.createVNode(EW,{linkVisible:f.linkVisible,clipVisible:f.clipVisible,type:f.type,onCancel:()=>{f.linkVisible=!1,f.clipVisible=!1},onOk:y=>{y&&c(f.type,{desc:y.desc,url:y.url,transform:f.type==="image"}),f.linkVisible=!1,f.clipVisible=!1}},null)])}}}),CW=`.${T}-preview > [data-line]`,Ra=(e,t)=>+getComputedStyle(e).getPropertyValue(t).replace("px",""),jW=(e,t)=>{const n=bb(()=>{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)}]},AW=(e,t,n)=>{const{view:i}=n,r=yb(),o=$=>i.lineBlockAt(i.state.doc.line($+1).from).top,a=$=>i.lineBlockAt(i.state.doc.line($+1).from).bottom;let O=[],l=[],s=[];const u=()=>{O=[],l=Array.from(t.querySelectorAll(CW)),s=l.map(y=>Number(y.dataset.line));const $=[...s],{lines:g}=i.state.doc;let S=$.shift()||0,k=$.shift()||g;for(let y=0;y<g;y++)y===k&&(S=y,k=$.shift()||g),O.push({start:S,end:k-1})},c=($,g)=>{let S=1;for(let k=l.length-1;k-1>=0;k--){const y=l[k],X=l[k-1];if(y.offsetTop+y.offsetHeight>g&&X.offsetTop<g){S=Number(X.dataset.line);break}}for(let k=O.length-1;k>=0;k--){const y=a(O[k].end),X=o(O[k].start);if(y>$&&X<=$){S=S<O[k].start?S:O[k].start;break}}return S};let f=0,h=0;const p=()=>{var I,N,A;if(h!==0)return!1;f++;const{scrollDOM:$,contentHeight:g}=i;let S=Ra(t,"padding-top");const k=i.lineBlockAtHeight($.scrollTop),{number:y}=i.state.doc.lineAt(k.from),X=O[y-1];if(!X)return!1;let x=1;const v=t.querySelector(`[data-line="${X.start}"]`)||((I=t.firstElementChild)==null?void 0:I.firstElementChild),w=t.querySelector(`[data-line="${X.end+1}"]`)||((N=t.lastElementChild)==null?void 0:N.lastElementChild),W=$.scrollHeight-$.clientHeight,E=t.scrollHeight-t.clientHeight;let V=o(X.start),U=a(X.end),_=v.offsetTop,q=w.offsetTop-_;V===0&&(_=0,v===w?(S=0,U=g-$.offsetHeight,q=E):q=w.offsetTop),x=($.scrollTop-V)/(U-V);const Z=w==((A=t.lastElementChild)==null?void 0:A.lastElementChild)?w.offsetTop+w.clientHeight:w.offsetTop;if(U>=W||Z>E){const L=c(W,E);V=o(L),x=($.scrollTop-V)/(W-V);const ee=t.querySelector(`[data-line="${L}"]`);V>0&&ee&&(_=ee.offsetTop),q=E-_+Ra(t,"padding-top")}const Y=_-S+q*x;r(t,Y,()=>{f--})},Q=()=>{var Z,Y,I,N,A,L;if(f!==0)return;h++;const{scrollDOM:$}=i,g=t.scrollTop,S=t.scrollHeight,k=$.scrollHeight-$.clientHeight,y=t.scrollHeight-t.clientHeight;let X=(Z=t.firstElementChild)==null?void 0:Z.firstElementChild,x=(Y=t.firstElementChild)==null?void 0:Y.lastElementChild;if(s.length>0){let ee=Math.ceil(s[s.length-1]*(g/S)),se=s.findLastIndex(Ue=>Ue<=ee);se=se===-1?0:se,ee=s[se];for(let Ue=se;Ue>=0&&Ue<s.length;)if(l[Ue].offsetTop>g){if(Ue-1>=0){Ue--;continue}ee=-1,se=Ue;break}else{if(Ue+1<s.length&&l[Ue+1].offsetTop<g){Ue++;continue}ee=s[Ue],se=Ue;break}switch(se){case-1:{X=(I=t.firstElementChild)==null?void 0:I.firstElementChild,x=l[se];break}case s.length-1:{X=l[se],x=(N=t.firstElementChild)==null?void 0:N.lastElementChild;break}default:X=l[se],x=l[se+1===l.length?se:se+1]}}let v=X===((A=t.firstElementChild)==null?void 0:A.firstElementChild)?0:X.offsetTop-Ra(X,"margin-top"),w=x.offsetTop,W=0;const{start:E,end:V}=O[Number(X.dataset.line||0)];let U=o(E);const _=o(V+1===i.state.doc.lines?V:V+1);let q=0;if(_>k||x.offsetTop+x.offsetHeight>y){const ee=c(k,y),se=t.querySelector(`[data-line="${ee}"]`);v=se?se.offsetTop-Ra(se,"margin-top"):v,U=o(ee),W=(g-v)/(y-v),q=k-U}else X===((L=t.firstElementChild)==null?void 0:L.firstElementChild)?(X===x&&(w=x.offsetTop+x.offsetHeight+ +getComputedStyle(x).marginBottom.replace("px","")),q=_,W=Math.max(g/w,0)):(W=Math.max((g-v)/(w-v),0),q=_-U);r(e,U+q*W,()=>{h--})},b=$=>{var y;const{scrollDOM:g,contentHeight:S}=i,k=g.clientHeight;if(S<=k||t.firstElementChild.clientHeight<=t.clientHeight||i.state.doc.lines<=((y=O[O.length-1])==null?void 0:y.end))return!1;$.target===e?p():Q()};return[()=>{u(),e.addEventListener("scroll",b),t.addEventListener("scroll",b),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",b),t.removeEventListener("scroll",b)}]},GW={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},onActive:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},jb=m.defineComponent({props:GW,setup(e){const t=m.inject("scrollElementRef"),n=m.inject("roorNodeRef"),i=m.ref();return m.watch(()=>e.tocItem.active,r=>{r&&e.onActive(e.tocItem,i.value)}),m.onMounted(()=>{e.tocItem.active&&e.onActive(e.tocItem,i.value)}),()=>{const{tocItem:r,mdHeadingId:o,onClick:a,scrollElementOffsetTop:O}=e;return m.createVNode("div",{ref:i,class:[`${T}-catalog-link`,r.active&&`${T}-catalog-active`],onClick:l=>{if(l.stopPropagation(),a(l,r),l.defaultPrevented)return;const s=o(r.text,r.level,r.index),u=n.value.getElementById(s),c=t.value;if(u&&c){let f=u.offsetParent,h=u.offsetTop;if(c.contains(f))for(;f&&c!=f;)h+=f==null?void 0:f.offsetTop,f=f==null?void 0:f.offsetParent;const p=u.previousElementSibling;let Q=0;p||(Q=Ra(u,"margin-top")),c==null||c.scrollTo({top:h-O-Q,behavior:"smooth"})}}},[m.createVNode("span",{title:r.text},[r.text]),r.children&&r.children.length>0&&m.createVNode("div",{class:`${T}-catalog-wrapper`},[r.children.map(l=>m.createVNode(jb,{mdHeadingId:o,key:`${r.text}-link-${l.level}-${l.text}`,tocItem:l,onActive:e.onActive,onClick:a,scrollElementOffsetTop:O},null))])])}}}),IW={editorId:{type:String,default:void 0},class:{type:String,default:""},mdHeadingId:{type:Function,default:e=>e},scrollElement:{type:[String,Object],default:void 0},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function,default:void 0},onActive:{type:Function,default:void 0},isScrollElementInShadow:{type:Boolean,default:!1},syncWith:{type:String,default:"preview"},catalogMaxDepth:{type:Number,default:void 0}},za=m.defineComponent({name:"MdCatalog",props:IW,emits:["onClick","onActive"],setup(e,t){const n=e.editorId,i=`#${n}-preview-wrapper`,r=m.reactive({list:[],show:!1,scrollElement:e.scrollElement||i}),o=m.shallowRef(),a=m.ref(),O=m.ref(),l=m.ref(),s=m.ref(),u=m.shallowRef(),c=m.ref({});m.provide("scrollElementRef",O),m.provide("roorNodeRef",s);const f=m.computed(()=>{const S=[];return r.list.forEach((k,y)=>{if(e.catalogMaxDepth&&k.level>e.catalogMaxDepth)return;const{text:X,level:x,line:v}=k,w={level:x,text:X,line:v,index:y+1,active:o.value===k};if(S.length===0)S.push(w);else{let W=S[S.length-1];if(w.level>W.level)for(let E=W.level+1;E<=6;E++){const{children:V}=W;if(!V){W.children=[w];break}if(W=V[V.length-1],w.level<=W.level){V.push(w);break}}else S.push(w)}}),S}),h=()=>{var k;if(r.scrollElement instanceof HTMLElement)return r.scrollElement;let S=document;return(r.scrollElement===i||e.isScrollElementInShadow)&&(S=(k=a.value)==null?void 0:k.getRootNode()),S.querySelector(r.scrollElement)},p=S=>{if(S.length===0)return o.value=void 0,r.list=[],!1;const{activeHead:k}=S.reduce((y,X,x)=>{var w;let v=0;if(e.syncWith==="preview"){const W=(w=s.value)==null?void 0:w.getElementById(e.mdHeadingId(X.text,X.level,x+1));W instanceof HTMLElement&&(v=RW(W,O.value))}else{const W=u.value;if(W){const E=W.lineBlockAt(W.state.doc.line(X.line+1).from).top,V=W.scrollDOM.scrollTop;v=E-V}}return v<e.offsetTop&&v>y.minTop?{activeHead:X,minTop:v}:y},{activeHead:S[0],minTop:Number.MIN_SAFE_INTEGER});o.value=k,r.list=S},Q=(S,k)=>{var y;c.value.top=k.offsetTop+Ra(k,"padding-top")+"px",(y=e.onActive)==null||y.call(e,S,k),t.emit("onActive",S,k)},b=()=>{p(r.list)},$=S=>{var k,y,X;if((k=l.value)==null||k.removeEventListener("scroll",b),e.syncWith==="editor")l.value=(y=u.value)==null?void 0:y.scrollDOM;else{const x=h();O.value=x,l.value=x===document.documentElement?document:x}p(S),(X=l.value)==null||X.addEventListener("scroll",b)},g=S=>{u.value=S};return m.watch([()=>e.syncWith,u,()=>e.catalogMaxDepth],()=>{$(r.list)}),m.onMounted(()=>{s.value=a.value.getRootNode(),F.on(n,{name:KO,callback:$}),F.on(n,{name:gu,callback:g}),F.emit(n,Wb),F.emit(n,Ub)}),m.onBeforeUnmount(()=>{var S;F.remove(n,KO,$),F.remove(n,gu,g),(S=l.value)==null||S.removeEventListener("scroll",b)}),()=>m.createVNode("div",{class:[`${T}-catalog`,e.theme==="dark"&&`${T}-catalog-dark`,e.class||""],ref:a},[f.value.length>0&&m.createVNode(m.Fragment,null,[m.createVNode("div",{class:`${T}-catalog-indicator`,style:c.value},null),m.createVNode("div",{class:`${T}-catalog-container`},[f.value.map(S=>m.createVNode(jb,{mdHeadingId:e.mdHeadingId,tocItem:S,key:`link-${S.level}-${S.text}`,onActive:Q,onClick:(k,y)=>{var X;(X=e.onClick)==null||X.call(e,k,y),t.emit("onClick",k,y)},scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])])}});za.install=e=>(e.component(za.name,za),e);const DW=(e,t,n)=>{const i=m.inject("editorId");let r=()=>{},o=()=>{};const a=()=>{var c;r();const O=(c=n.value)==null?void 0:c.view.contentDOM.getRootNode(),l=O.querySelector(`#${i} .cm-scroller`),s=O.querySelector(`[id="${i}-preview-wrapper"]`),u=O.querySelector(`[id="${i}-html-wrapper"]`);(s||u)&&([o,r]=(s?AW:jW)(l,s||u,n.value),e.scrollAuto&&o())};m.watch([t,m.toRef(e.setting,"preview"),m.toRef(e.setting,"htmlPreview"),m.toRef(e.setting,"fullscreen"),m.toRef(e.setting,"pageFullscreen")],()=>{m.nextTick(a)}),m.watch(()=>e.scrollAuto,O=>{O?o():r()}),m.watch(()=>e.setting.previewOnly,O=>{O?r():o()}),m.onMounted(a)};let Ve=class k5{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]=Wa(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),Di.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]=Wa(this,t,n);let i=[];return this.decompose(t,n,i,0),Di.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 el(this),o=new el(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 el(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 Ib(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]?k5.empty:t.length<=32?new pt(t):Di.from(pt.split(t,[]))}};class pt extends Ve{constructor(t,n=NW(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 LW(r,O,i,a);r=O+1,i++}}decompose(t,n,i,r){let o=t<=0&&n>=this.length?this:new pt(Ab(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),O=Qu(o.text,a.text.slice(),0,o.length);if(O.length<=32)i.push(new pt(O,a.length+o.length));else{let l=O.length>>1;i.push(new pt(O.slice(0,l)),new pt(O.slice(l)))}}else i.push(o)}replace(t,n,i){if(!(i instanceof pt))return super.replace(t,n,i);[t,n]=Wa(this,t,n);let r=Qu(this.text,Qu(i.text,Ab(this.text,0,t)),n),o=this.length+i.length-(n-t);return r.length<=32?new pt(r,o):Di.from(pt.split(r,[]),o)}sliceString(t,n=this.length,i=`
|
|
183
183
|
`){[t,n]=Wa(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 pt(i,r)),i=[],r=-1);return r>-1&&n.push(new pt(i,r)),n}}class Di extends Ve{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]=Wa(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 Di(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=`
|
|
184
184
|
`){[t,n]=Wa(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 Di))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 pt(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 Di)for(let Q of h.children)c(Q);else h.lines>a&&(l>a||!l)?(f(),O.push(h)):h instanceof pt&&l&&(p=u[u.length-1])instanceof pt&&h.lines+p.lines<=32?(l+=h.lines,s+=h.length+1,u[u.length-1]=new pt(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]:Di.from(u,s)),s=-1,l=u.length=0)}for(let h of t)c(h);return f(),O.length==1?O[0]:new Di(O,n)}}Ve.empty=new pt([""],0);function NW(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Qu(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 Ab(e,t,n){return Qu(e,[""],t,n)}class el{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 pt?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 pt?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=`
|
|
185
185
|
`,this;t--}else if(r instanceof pt){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 pt?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 el(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 Ib{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"&&(Ve.prototype[Symbol.iterator]=function(){return this.iter()},el.prototype[Symbol.iterator]=Gb.prototype[Symbol.iterator]=Ib.prototype[Symbol.iterator]=function(){return this});let LW=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 Wa(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}let qa="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<qa.length;e++)qa[e]+=qa[e-1];function MW(e){for(let t=1;t<qa.length;t+=2)if(qa[t]>e)return qa[t-1]<=e;return!1}function Db(e){return e>=127462&&e<=127487}const Nb=8205;function Yt(e,t,n=!0,i=!0){return(n?Lb:FW)(e,t,i)}function Lb(e,t,n){if(t==e.length)return t;t&&Mb(e.charCodeAt(t))&&Fb(e.charCodeAt(t-1))&&t--;let i=$i(e,t);for(t+=mr(i);t<e.length;){let r=$i(e,t);if(i==Nb||r==Nb||n&&MW(r))t+=mr(r),i=r;else if(Db(r)){let o=0,a=t-2;for(;a>=0&&Db($i(e,a));)o++,a-=2;if(o%2==0)break;t+=2}else break}return t}function FW(e,t,n){for(;t>0;){let i=Lb(e,t-2,n);if(i<t)return i;t--}return 0}function Mb(e){return e>=56320&&e<57344}function Fb(e){return e>=55296&&e<56320}function $i(e,t){let n=e.charCodeAt(t);if(!Fb(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Mb(i)?(n-55296<<10)+(i-56320)+65536:n}function Bb(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function mr(e){return e<65536?1:2}const bh=/\r\n?|\n/;var nn=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(nn||(nn={}));class Ni{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){yh(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 Ni(t)}composeDesc(t){return this.empty?t:t.empty?this:Hb(this,t)}mapDesc(t,n=!1){return t.empty?this:Sh(this,t,n)}mapPos(t,n=-1,i=nn.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!=nn.Simple&&s>=t&&(i==nn.TrackDel&&r<t&&s>t||i==nn.TrackBefore&&r<t||i==nn.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 Ni(t)}static create(t){return new Ni(t)}}class wt extends Ni{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 yh(this,(n,i,r,o,a)=>t=t.replace(r,r+(i-n),a),!1),t}mapDesc(t,n=!1){return Sh(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(Ve.empty);i.push(a?t.slice(o,o+a):Ve.empty)}o+=a}return new wt(n,i)}compose(t){return this.empty?t:t.empty?this:Hb(this,t,!0)}map(t,n=!1){return t.empty?this:Sh(this,t,n,!0)}iterChanges(t,n=!1){yh(this,t,n)}get desc(){return Ni.create(this.sections)}filter(t){let n=[],i=[],r=[],o=new tl(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);It(r,u,-1);let c=o.ins==-1?-1:o.off==0?o.ins:0;It(n,u,c),c>0&&Gr(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);It(n,u,-1),It(r,u,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(u),O+=u}}return{changes:new wt(n,i),filtered:Ni.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&&It(r,n-a,-1);let c=new wt(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 wt){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"?Ve.of(h.split(i||bh)):h:Ve.empty,Q=p.length;if(c==f&&Q==0)return;c<a&&l(),c>a&&It(r,c-a,-1),It(r,f-c,Q),Gr(o,r,p),a=f}}return s(t),l(!O),O}static empty(t){return new wt(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(Ve.empty);i[r]=Ve.of(o.slice(1)),n.push(o[0],i[r].length)}}}return new wt(n,i)}static createSet(t,n){return new wt(t,n)}}function It(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 Gr(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(Ve.empty);e.push(n)}}function yh(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=Ve.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 Sh(e,t,n,i=!1){let r=[],o=i?[]:null,a=new tl(e),O=new tl(t);for(let l=-1;;)if(a.ins==-1&&O.ins==-1){let s=Math.min(a.len,O.len);It(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(It(r,O.ins,-1);s;){let u=Math.min(a.len,s);a.ins>=0&&l<a.i&&a.len<=u&&(It(r,0,a.ins),o&&Gr(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;It(r,s,l<a.i?a.ins:0),o&&l<a.i&&Gr(o,r,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&O.done)return o?wt.createSet(r,o):Ni.create(r);throw new Error("Mismatched change set lengths")}}function Hb(e,t,n=!1){let i=[],r=n?[]:null,o=new tl(e),a=new tl(t);for(let O=!1;;){if(o.done&&a.done)return r?wt.createSet(i,r):Ni.create(i);if(o.ins==0)It(i,o.len,0,O),o.next();else if(a.len==0&&!a.done)It(i,0,a.ins,O),r&&Gr(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;It(i,l,u,O),r&&u&&Gr(r,i,a.text)}else a.ins==-1?(It(i,o.off?0:o.len,l,O),r&&Gr(r,i,o.textBit(l))):(It(i,o.off?0:o.len,a.off?0:a.ins,O),r&&!a.off&&Gr(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 tl{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?Ve.empty:t[n]}textBit(t){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!t?Ve.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 Wo{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 Wo(i,r,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return G.range(t,n);let i=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return G.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 G.range(t.anchor,t.head)}static create(t,n,i){return new Wo(t,n,i)}}class G{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:G.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 G([this.main],0)}addRange(t,n=!0){return G.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let i=this.ranges.slice();return i[n]=t,G.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 G(t.ranges.map(n=>Wo.fromJSON(n)),t.main)}static single(t,n=t){return new G([G.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 G.normalized(t.slice(),n);i=o.to}return new G(t,n)}static cursor(t,n=0,i,r){return Wo.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?Wo.create(n,t,48|o):Wo.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?G.range(l,O):G.range(O,l))}}return new G(t,n)}}function Kb(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Ph=0;class ue{constructor(t,n,i,r,o){this.combine=t,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=Ph++,this.default=t([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(t={}){return new ue(t.combine||(n=>n),t.compareInput||((n,i)=>n===i),t.compare||(t.combine?(n,i)=>n===i:kh),!!t.static,t.enables)}of(t){return new bu([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new bu(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new bu(t,this,2,n)}from(t,n){return n||(n=i=>i),this.compute([t],i=>n(i.field(t)))}}function kh(e,t){return e==t||e.length==t.length&&e.every((n,i)=>n===t[i])}class bu{constructor(t,n,i,r){this.dependencies=t,this.facet=n,this.type=i,this.value=r,this.id=Ph++}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)||xh(c,u)){let h=i(c);if(O?!Jb(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 Q=Su(f,p);if(this.dependencies.every(b=>b instanceof ue?f.facet(b)===c.facet(b):b instanceof Mn?f.field(b,!1)==c.field(b,!1):!0)||(O?Jb(h=i(c),Q,r):r(h=i(c),Q)))return c.values[a]=Q,0}else h=i(c);return c.values[a]=h,1}}}}function Jb(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 xh(e,t){let n=!1;for(let i of t)il(e,i)&1&&(n=!0);return n}function BW(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)il(l,s);return l.values[a]=O(l),1},update(l,s){if(!xh(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=xh(l,i),c=s.config.facets[t.id],f=s.facet(t);if(c&&!u&&kh(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 e0=ue.define({static:!0});class Mn{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 Mn(Ph++,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(e0).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,e0.of({field:this,create:t})]}get extension(){return this}}const qo={lowest:4,low:3,default:2,high:1,highest:0};function nl(e){return t=>new t0(t,e)}const Li={highest:nl(qo.highest),high:nl(qo.high),default:nl(qo.default),low:nl(qo.low),lowest:nl(qo.lowest)};class t0{constructor(t,n){this.inner=t,this.prec=n}}class Mi{of(t){return new vh(this,t)}reconfigure(t){return Mi.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class vh{constructor(t,n){this.compartment=t,this.inner=n}}class yu{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 HW(t,n,a))f instanceof Mn?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,Q=u&&u[f]||[];if(h.every(b=>b.type==0))if(O[p.id]=l.length<<1|1,kh(Q,h))l.push(i.facet(p));else{let b=p.combine(h.map($=>$.value));l.push(i&&p.compare(b,i.facet(p))?i.facet(p):b)}else{for(let b of h)b.type==0?(O[b.id]=l.length<<1|1,l.push(b.value)):(O[b.id]=s.length<<1,s.push($=>b.dynamicSlot($)));O[p.id]=s.length<<1,s.push(b=>BW(b,p,h))}}let c=s.map(f=>f(O));return new yu(t,a,c,O,l,o)}}function HW(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 vh&&n.delete(a.compartment)}if(r.set(a,O),Array.isArray(a))for(let s of a)o(s,O);else if(a instanceof vh){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 t0)o(a.inner,a.prec);else if(a instanceof Mn)i[O].push(a),a.provides&&o(a.provides,O);else if(a instanceof bu)i[O].push(a),a.facet.extensions&&o(a.facet.extensions,qo.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,qo.default),i.reduce((a,O)=>a.concat(O))}function il(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 n0=ue.define(),wh=ue.define({combine:e=>e.some(t=>t),static:!0}),i0=ue.define({combine:e=>e.length?e[0]:void 0,static:!0}),r0=ue.define(),o0=ue.define(),a0=ue.define(),O0=ue.define({combine:e=>e.length?e[0]:!1});class gr{constructor(t,n){this.type=t,this.value=n}static define(){return new KW}}class KW{of(t){return new gr(this,t)}}class JW{constructor(t){this.map=t}of(t){return new Te(this,t)}}class Te{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 Te(this.type,n)}is(t){return this.type==t}static define(t={}){return new JW(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}}Te.reconfigure=Te.define(),Te.appendConfig=Te.define();class $t{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&&Kb(i,n.newLength),o.some(O=>O.type==$t.time)||(this.annotations=o.concat($t.time.of(Date.now())))}static create(t,n,i,r,o,a){return new $t(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($t.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}$t.time=gr.define(),$t.userEvent=gr.define(),$t.addToHistory=gr.define(),$t.remote=gr.define();function eq(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 l0(e,t,n){var i;let r,o,a;return n?(r=t.changes,o=wt.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:Te.mapEffects(e.effects,r).concat(Te.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Th(e,t,n){let i=t.selection,r=Za(t.annotations);return t.userEvent&&(r=r.concat($t.userEvent.of(t.userEvent))),{changes:t.changes instanceof wt?t.changes:wt.of(t.changes||[],n,e.facet(i0)),selection:i&&(i instanceof G?i:G.single(i.anchor,i.head)),effects:Za(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function s0(e,t,n){let i=Th(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=l0(i,Th(e,t[o],a?i.changes.newLength:e.doc.length),a)}let r=$t.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return nq(n?tq(r):r)}function tq(e){let t=e.startState,n=!0;for(let r of t.facet(r0)){let o=r(e);if(o===!1){n=!1;break}Array.isArray(o)&&(n=n===!0?o:eq(n,o))}if(n!==!0){let r,o;if(n===!1)o=e.changes.invertedDesc,r=wt.empty(t.doc.length);else{let a=e.changes.filter(n);r=a.changes,o=a.filtered.mapDesc(a.changes).invertedDesc}e=$t.create(t,r,e.selection&&e.selection.map(o),Te.mapEffects(e.effects,o),e.annotations,e.scrollIntoView)}let i=t.facet(o0);for(let r=i.length-1;r>=0;r--){let o=i[r](e);o instanceof $t?e=o:Array.isArray(o)&&o.length==1&&o[0]instanceof $t?e=o[0]:e=s0(t,Za(o),!1)}return e}function nq(e){let t=e.startState,n=t.facet(a0),i=e;for(let r=n.length-1;r>=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=l0(i,Th(t,o,e.changes.newLength),!0))}return i==e?e:$t.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}const iq=[];function Za(e){return e==null?iq:Array.isArray(e)?e:[e]}var Ct=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Ct||(Ct={}));const rq=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Xh;try{Xh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function oq(e){if(Xh)return Xh.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||rq.test(n)))return!0}return!1}function aq(e){return t=>{if(!/\S/.test(t))return Ct.Space;if(oq(t))return Ct.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Ct.Word;return Ct.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++)il(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 il(this,i),Su(this,i)}update(...t){return s0(this,t,!0)}applyTransaction(t){let n=this.config,{base:i,compartments:r}=n;for(let O of t.effects)O.is(Mi.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(Te.reconfigure)?(n=null,i=O.value):O.is(Te.appendConfig)&&(n=null,i=Za(i).concat(O.value));let o;n?o=t.startState.values.slice():(n=yu.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(wh)?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:G.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=Za(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=Te.mapEffects(a,u).concat(Te.mapEffects(Za(l.effects),c))}return{changes:r,selection:G.create(o,n.mainIndex),effects:a}}changes(t=[]){return t instanceof wt?t:wt.of(t,this.doc.length,this.facet(xe.lineSeparator))}toText(t){return Ve.of(t.split(this.facet(xe.lineSeparator)||bh))}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:(il(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 Mn&&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:G.fromJSON(t.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(t={}){let n=yu.resolve(t.extensions||[],new Map),i=t.doc instanceof Ve?t.doc:Ve.of((t.doc||"").split(n.staticFacet(xe.lineSeparator)||bh)),r=t.selection?t.selection instanceof G?t.selection:G.single(t.selection.anchor,t.selection.head):G.single(0);return Kb(r,i.length),n.staticFacet(wh)||(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)||`
|