import{M as er,P as Y,a as X,I as Pt,N as it,S as Cc,k as bc,E as ua,b as _c,D as Mc,c as Ic,d as pa,e as zu,s as Uu,j as Yu,f as Xu,u as Ju,g as tr,h as Tl,R as Qu,A as ep,i as qo,l as Vo,F as nr,t as Kr,T as W,m as In,n as ha,w as ma,o as ga,p as Zr,q as tp,r as np,v as rp,x as op,y as ap,z as sp,B as ip,C as lp,G as Nc,H as fa,J as cp,K as dp,L as Nt,O as up,Q as pp,U as hp,V as mp,W as gp,X as xc,Y as fp,Z as vp,_ as Sc,$ as Lc,a0 as va,a1 as Nn,a2 as yp,a3 as wp,a4 as kp,a5 as Cp,a6 as bp,a7 as _p,a8 as Mp}from"./prosemirror-n4jms1hu.js";import{l as Ip}from"./cm-language-data-Bcb4c2CO.js";import{o as Np}from"./cm-theme-one-dark-DcoGA4wl.js";import{h as f,r as I,c as ye,d as J,w as Tt,F as ct,o as Gr,a as zr,b as xn,e as ya,s as qr}from"./vue-6zEhjBZz.js";import{d as xp,i as Sp}from"./cm-commands-BSG2z_PK.js";import{E as Ol,f as Lp,k as Pc}from"./cm-view-CiSFjroV.js";import{b as Pp}from"./vendor-codemirror-C9Wn9KcM.js";import{k as Tc}from"./katex-ClxlXyPc.js";import{c as Q}from"./vendor-clsx-B-dksMZM.js";import{t as Ur,d as wa,a as Tp}from"./vendor-lodash-es-XiV8Prow.js";import{u as jo}from"./vendor-unified-BIaImg-8.js";import{r as Wo}from"./vendor-remark-parse-CNDkPE6C.js";import{r as Fo}from"./vendor-remark-stringify-Bsh9PcD8.js";import{v as $n}from"./vendor-unist-util-visit-8PRsQcuP.js";import{r as Op}from"./vendor-remark-inline-links-BH8JVns0.js";import{v as Hp}from"./vendor-unist-util-visit-parents-BHoKBdZX.js";import{r as Rp}from"./vendor-remark-gfm-Bh4u6bYx.js";import{o as Hl,l as Mo}from"./cm-state-X9WpHEQO.js";import{p as he}from"./vendor-dompurify-HRjpPm7y.js";import{f as ka,o as lt,c as Ne,s as $p,a as Rl}from"./vendor-floating-ui-dom-Bo_IsNpa.js";import{r as Ep}from"./vendor-remark-math--xuta7zy.js";var oe=(t=>(t.docTypeError="docTypeError",t.contextNotFound="contextNotFound",t.timerNotFound="timerNotFound",t.ctxCallOutOfScope="ctxCallOutOfScope",t.createNodeInParserFail="createNodeInParserFail",t.stackOverFlow="stackOverFlow",t.parserMatchError="parserMatchError",t.serializerMatchError="serializerMatchError",t.getAtomFromSchemaFail="getAtomFromSchemaFail",t.expectDomTypeError="expectDomTypeError",t.callCommandBeforeEditorView="callCommandBeforeEditorView",t.missingRootElement="missingRootElement",t.missingNodeInSchema="missingNodeInSchema",t.missingMarkInSchema="missingMarkInSchema",t.ctxNotBind="ctxNotBind",t.missingYjsDoc="missingYjsDoc",t))(oe||{});class ue extends Error{constructor(e,n){super(n),this.name="MilkdownError",this.code=e}}const Bp=(t,e)=>typeof e=="function"?"[Function]":e,Yr=t=>JSON.stringify(t,Bp);function Ap(t){return new ue(oe.docTypeError,`Doc type error, unsupported type: ${Yr(t)}`)}function Dp(t){return new ue(oe.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function qp(t){return new ue(oe.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function Xr(){return new ue(oe.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Vp(t,e,n){const o=`Cannot create node for ${"name"in t?t.name:t}`,a=d=>{if(d==null)return"null";if(Array.isArray(d))return`[${d.map(a).join(", ")}]`;if(typeof d=="object")return"toJSON"in d&&typeof d.toJSON=="function"?JSON.stringify(d.toJSON()):"spec"in d?JSON.stringify(d.spec):JSON.stringify(d);if(typeof d=="string"||typeof d=="number"||typeof d=="boolean")return JSON.stringify(d);if(typeof d=="function")return`[Function: ${d.name||"anonymous"}]`;try{return String(d)}catch{return"[Unserializable]"}},s=["[Description]",o],i=["[Attributes]",e],l=["[Content]",(n??[]).map(d=>d?typeof d=="object"&&"type"in d?`${d}`:a(d):"null")],c=[s,i,l].reduce((d,[u,p])=>{const h=`${u}: ${a(p)}.`;return d.concat(h)},[]);return new ue(oe.createNodeInParserFail,c.join(` `))}function Oc(){return new ue(oe.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function jp(t){return new ue(oe.parserMatchError,`Cannot match target parser for node: ${Yr(t)}.`)}function Wp(t){return new ue(oe.serializerMatchError,`Cannot match target serializer for node: ${Yr(t)}.`)}function Fp(t,e){return new ue(oe.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function we(t){return new ue(oe.expectDomTypeError,`Expect to be a dom, but get: ${Yr(t)}.`)}function Io(){return new ue(oe.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Kp(t){return new ue(oe.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function Zp(t){return new ue(oe.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}class Hc{constructor(){this.sliceMap=new Map,this.get=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);if(!n){const r=typeof e=="string"?e:e.name;throw Dp(r)}return n},this.remove=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);n&&this.sliceMap.delete(n.type.id)},this.has=e=>typeof e=="string"?[...this.sliceMap.values()].some(n=>n.type.name===e):this.sliceMap.has(e.id)}}class Gp{constructor(e,n,r){this.#t=[],this.#r=()=>{this.#t.forEach(o=>o(this.#e))},this.set=o=>{this.#e=o,this.#r()},this.get=()=>this.#e,this.update=o=>{this.#e=o(this.#e),this.#r()},this.type=r,this.#e=n,e.set(r.id,this)}#t;#e;#r;on(e){return this.#t.push(e),()=>{this.#t=this.#t.filter(n=>n!==e)}}once(e){const n=this.on(r=>{e(r),n()});return n}off(e){this.#t=this.#t.filter(n=>n!==e)}offAll(){this.#t=[]}}class zp{constructor(e,n){this.id=Symbol(`Context-${n}`),this.name=n,this._defaultValue=e,this._typeInfo=()=>{throw Xr()}}create(e,n=this._defaultValue){return new Gp(e,n,this)}}const O=(t,e)=>new zp(t,e);class Up{constructor(e,n,r){this.#n=new Set,this.#i=new Set,this.#o=new Map,this.#a=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(o=>({name:typeof o=="string"?o:o.name,value:this.#s(o)})),consumedSlices:[...this.#i].map(o=>({name:typeof o=="string"?o:o.name,value:this.#s(o)})),recordedTimers:[...this.#o].map(([o,{duration:a}])=>({name:o.name,duration:a,status:this.#l(o)})),waitTimers:[...this.#a].map(([o,{duration:a}])=>({name:o.name,duration:a,status:this.#l(o)}))}),this.onRecord=o=>{this.#o.set(o,{start:Date.now(),duration:0})},this.onClear=o=>{this.#o.delete(o)},this.onDone=o=>{const a=this.#o.get(o);a&&(a.duration=Date.now()-a.start)},this.onWait=(o,a)=>{const s=Date.now();a.finally(()=>{this.#a.set(o,{duration:Date.now()-s})}).catch(console.error)},this.onInject=o=>{this.#n.add(o)},this.onRemove=o=>{this.#n.delete(o)},this.onUse=o=>{this.#i.add(o)},this.#s=o=>this.#e.get(o).get(),this.#l=o=>this.#r.get(o).status,this.#e=e,this.#r=n,this.#t=r}#t;#e;#r;#n;#i;#o;#a;#s;#l}class Ca{constructor(e,n,r){this.produce=o=>o&&Object.keys(o).length?new Ca(this.#t,this.#e,{...o}):this,this.inject=(o,a)=>{const s=o.create(this.#t.sliceMap);return a!=null&&s.set(a),this.#n?.onInject(o),this},this.remove=o=>(this.#t.remove(o),this.#n?.onRemove(o),this),this.record=o=>(o.create(this.#e.store),this.#n?.onRecord(o),this),this.clearTimer=o=>(this.#e.remove(o),this.#n?.onClear(o),this),this.isInjected=o=>this.#t.has(o),this.isRecorded=o=>this.#e.has(o),this.use=o=>(this.#n?.onUse(o),this.#t.get(o)),this.get=o=>this.use(o).get(),this.set=(o,a)=>this.use(o).set(a),this.update=(o,a)=>this.use(o).update(a),this.timer=o=>this.#e.get(o),this.done=o=>{this.timer(o).done(),this.#n?.onDone(o)},this.wait=o=>{const a=this.timer(o).start();return this.#n?.onWait(o,a),a},this.waitTimers=async o=>{await Promise.all(this.get(o).map(a=>this.wait(a)))},this.#t=e,this.#e=n,this.#r=r,r&&(this.#n=new Up(e,n,r))}#t;#e;#r;#n;get meta(){return this.#r}get inspector(){return this.#n}}class Yp{constructor(){this.store=new Map,this.get=e=>{const n=this.store.get(e.id);if(!n)throw qp(e.name);return n},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}class Xp{constructor(e,n){this.#t=null,this.#e=null,this.#n="pending",this.start=()=>(this.#t??=new Promise((r,o)=>{this.#e=a=>{a instanceof CustomEvent&&a.detail.id===this.#r&&(this.#n="resolved",this.#i(),a.stopImmediatePropagation(),r())},this.#o(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#i(),o(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(r)},this.#i=()=>{this.#e&&removeEventListener(this.type.name,this.#e)},this.#o=r=>{setTimeout(()=>{r()},this.type.timeout)},this.#r=Symbol(n.name),this.type=n,e.set(n.id,this)}#t;#e;#r;#n;get status(){return this.#n}#i;#o}class Jp{constructor(e,n=3e3){this.create=r=>new Xp(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=n}}const Se=(t,e=3e3)=>new Jp(t,e);var Rc=t=>{throw TypeError(t)},$c=(t,e,n)=>e.has(t)||Rc("Cannot "+n),T=(t,e,n)=>($c(t,e,"read from private field"),n?n.call(t):e.get(t)),Z=(t,e,n)=>e.has(t)?Rc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),V=(t,e,n,r)=>($c(t,e,"write to private field"),e.set(t,n),n),_e,Wt,rr,or,ar,Ft,Kt,Oe,Zt,sr,ir,Gt,lr,zt,cr,dr,yt,Xe,ur,Ut;class Ec{}class Bc{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw Oc();return e}}}class ba extends Ec{constructor(e,n,r){super(),this.type=e,this.content=n,this.attrs=r}push(e,...n){this.content.push(e,...n)}pop(){return this.content.pop()}static create(e,n,r){return new ba(e,n,r)}}const Ko=class extends Bc{constructor(e){super(),Z(this,_e),Z(this,Wt),Z(this,rr),Z(this,or),Z(this,ar),Z(this,Ft),Z(this,Kt),V(this,_e,er.none),V(this,Wt,n=>n.isText),V(this,rr,(n,r)=>{if(T(this,Wt).call(this,n)&&T(this,Wt).call(this,r)&&er.sameSet(n.marks,r.marks))return this.schema.text(n.text+r.text,n.marks)}),V(this,or,n=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(n));if(!r)throw jp(n);return r}),V(this,ar,n=>{const r=T(this,or).call(this,n);r.spec.parseMarkdown.runner(this,n,r)}),this.injectRoot=(n,r,o)=>(this.openNode(r,o),this.next(n.children),this),this.openNode=(n,r)=>(this.open(ba.create(n,[],r)),this),V(this,Ft,()=>{V(this,_e,er.none);const n=this.close();return T(this,Kt).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>{try{T(this,Ft).call(this)}catch(n){console.error(n)}return this},V(this,Kt,(n,r,o)=>{const a=n.createAndFill(r,o,T(this,_e));if(!a)throw Vp(n,r,o);return this.push(a),a}),this.addNode=(n,r,o)=>{try{T(this,Kt).call(this,n,r,o)}catch(a){console.error(a)}return this},this.openMark=(n,r)=>{const o=n.create(r);return V(this,_e,o.addToSet(T(this,_e))),this},this.closeMark=n=>(V(this,_e,n.removeFromSet(T(this,_e))),this),this.addText=n=>{try{const r=this.top();if(!r)throw Oc();const o=r.pop(),a=this.schema.text(n,T(this,_e));if(!o)return r.push(a),this;const s=T(this,rr).call(this,o,a);return s?(r.push(s),this):(r.push(o,a),this)}catch(r){return console.error(r),this}},this.build=()=>{let n;do n=T(this,Ft).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(r=>T(this,ar).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(n,r)=>{const o=n.runSync(n.parse(r),r);return this.next(o),this},this.schema=e}};_e=new WeakMap;Wt=new WeakMap;rr=new WeakMap;or=new WeakMap;ar=new WeakMap;Ft=new WeakMap;Kt=new WeakMap;Ko.create=(t,e)=>{const n=new Ko(t);return r=>(n.run(e,r),n.toDoc())};let Qp=Ko;const Zo=class extends Ec{constructor(e,n,r,o={}){super(),this.type=e,this.children=n,this.value=r,this.props=o,this.push=(a,...s)=>{this.children||(this.children=[]),this.children.push(a,...s)},this.pop=()=>this.children?.pop()}};Zo.create=(t,e,n,r={})=>new Zo(t,e,n,r);let $l=Zo;const eh=t=>Object.prototype.hasOwnProperty.call(t,"size"),Go=class extends Bc{constructor(e){super(),Z(this,Oe),Z(this,Zt),Z(this,sr),Z(this,ir),Z(this,Gt),Z(this,lr),Z(this,zt),Z(this,cr),Z(this,dr),Z(this,yt),Z(this,Xe),Z(this,ur),Z(this,Ut),V(this,Oe,er.none),V(this,Zt,n=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(n));if(!r)throw Wp(n.type);return r}),V(this,sr,n=>T(this,Zt).call(this,n).spec.toMarkdown.runner(this,n)),V(this,ir,(n,r)=>T(this,Zt).call(this,n).spec.toMarkdown.runner(this,n,r)),V(this,Gt,n=>{const{marks:r}=n,o=i=>i.type.spec.priority??50;[...r].sort((i,l)=>o(i)-o(l)).every(i=>!T(this,ir).call(this,i,n))&&T(this,sr).call(this,n),r.forEach(i=>T(this,Ut).call(this,i))}),V(this,lr,(n,r)=>{if(n.type===r||n.children?.length!==1)return n;const o=l=>{if(l.type===r)return l;if(l.children?.length!==1)return null;const[c]=l.children;return c?o(c):null},a=o(n);if(!a)return n;const s=a.children?[...a.children]:void 0,i={...n,children:s};return i.children=s,a.children=[i],a}),V(this,zt,n=>{const{children:r}=n;return r&&(n.children=r.reduce((o,a,s)=>{if(s===0)return[a];const i=o.at(-1);if(i&&i.isMark&&a.isMark){a=T(this,lr).call(this,a,i.type);const{children:l,...c}=a,{children:d,...u}=i;if(a.type===i.type&&l&&d&&JSON.stringify(c)===JSON.stringify(u)){const p={...u,children:[...d,...l]};return o.slice(0,-1).concat(T(this,zt).call(this,p))}}return o.concat(a)},[])),n}),V(this,cr,n=>{const r={...n.props,type:n.type};return n.children&&(r.children=n.children),n.value&&(r.value=n.value),r}),this.openNode=(n,r,o)=>(this.open($l.create(n,void 0,r,o)),this),V(this,dr,(n,r)=>{let o="",a="";const s=n.children;let i=-1,l=-1;const c=u=>{u&&u.forEach((p,h)=>{p.type==="text"&&p.value&&(i<0&&(i=h),l=h)})};if(s){c(s);const u=s?.[l],p=s?.[i];if(u&&u.value.endsWith(" ")){const h=u.value,k=h.trimEnd();a=h.slice(k.length),u.value=k}if(p&&p.value.startsWith(" ")){const h=p.value,k=h.trimStart();o=h.slice(0,h.length-k.length),p.value=k}}o.length&&T(this,Xe).call(this,"text",void 0,o);const d=r();return a.length&&T(this,Xe).call(this,"text",void 0,a),d}),V(this,yt,(n=!1)=>{const r=this.close(),o=()=>T(this,Xe).call(this,r.type,r.children,r.value,r.props);return n?T(this,dr).call(this,r,o):o()}),this.closeNode=()=>(T(this,yt).call(this),this),V(this,Xe,(n,r,o,a)=>{const s=$l.create(n,r,o,a),i=T(this,zt).call(this,T(this,cr).call(this,s));return this.push(i),i}),this.addNode=(n,r,o,a)=>(T(this,Xe).call(this,n,r,o,a),this),V(this,ur,(n,r,o,a)=>n.isInSet(T(this,Oe))?this:(V(this,Oe,n.addToSet(T(this,Oe))),this.openNode(r,o,{...a,isMark:!0}))),V(this,Ut,n=>{n.isInSet(T(this,Oe))&&(V(this,Oe,n.type.removeFromSet(T(this,Oe))),T(this,yt).call(this,!0))}),this.withMark=(n,r,o,a)=>(T(this,ur).call(this,n,r,o,a),this),this.closeMark=n=>(T(this,Ut).call(this,n),this),this.build=()=>{let n=null;do n=T(this,yt).call(this);while(this.size());return n},this.next=n=>eh(n)?(n.forEach(r=>{T(this,Gt).call(this,r)}),this):(T(this,Gt).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(this.next(n),this),this.schema=e}};Oe=new WeakMap;Zt=new WeakMap;sr=new WeakMap;ir=new WeakMap;Gt=new WeakMap;lr=new WeakMap;zt=new WeakMap;cr=new WeakMap;dr=new WeakMap;yt=new WeakMap;Xe=new WeakMap;ur=new WeakMap;Ut=new WeakMap;Go.create=(t,e)=>{const n=new Go(t);return r=>(n.run(r),n.toString(e))};let th=Go;const Ke=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,Ze=Ke&&Ke.userAgent||"",zo=/Edge\/(\d+)/.exec(Ze),Ac=/MSIE \d/.exec(Ze),Uo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ze),Jr=!!(Ac||Uo||zo),nh=Ac?document.documentMode:Uo?+Uo[1]:zo?+zo[1]:0,Dc=!Jr&&/gecko\/(\d+)/i.test(Ze),rh=Dc&&+(/Firefox\/(\d+)/.exec(Ze)||[0,0])[1],Yo=!Jr&&/Chrome\/(\d+)/.exec(Ze),oh=!!Yo,ah=Yo?+Yo[1]:0,qc=!Jr&&!!Ke&&/Apple Computer/.test(Ke.vendor),Vc=qc&&(/Mobile\/\w+/.test(Ze)||!!Ke&&Ke.maxTouchPoints>2),sh=Vc||(Ke?/Mac/.test(Ke.platform):!1),ih=/Android \d/.test(Ze),jc=!!El&&"webkitFontSmoothing"in El.documentElement.style,lh=jc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var zn=Object.freeze({__proto__:null,android:ih,chrome:oh,chrome_version:ah,gecko:Dc,gecko_version:rh,ie:Jr,ie_version:nh,ios:Vc,mac:sh,safari:qc,webkit:jc,webkit_version:lh});function No(t,e,n,r,o,a){if(t.composing)return!1;const s=t.state,i=s.doc.resolve(e);if(i.parent.type.spec.code)return!1;const l=i.parent.textBetween(Math.max(0,i.parentOffset-500),i.parentOffset,void 0,"")+r;for(let c of o){const d=c,u=d.match.exec(l),p=u&&u[0]&&d.handler(s,u,e-(u[0].length-r.length),n);if(p)return d.undoable!==!1&&p.setMeta(a,{transform:p,from:e,to:n,text:r}),t.dispatch(p),!0}return!1}const ch=new X("MILKDOWN_CUSTOM_INPUTRULES");function dh({rules:t}){const e=new Y({key:ch,isInputRules:!0,state:{init(){return null},apply(n,r){const o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,a){return No(n,r,o,a,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&No(n,r.pos,r.pos,"",t,e)}),!1)},handleKeyDown(n,r){if(r.key!=="Enter")return!1;const{$cursor:o}=n.state.selection;return o?No(n,o.pos,o.pos,` `,t,e):!1}}});return e}function En(t,e,n={}){return new Pt(t,(r,o,a,s)=>{var i,l,c,d;const{tr:u}=r,p=o.length;let h=o[p-1],k=o[0],g=[],m=s;const w={group:h,fullMatch:k,start:a,end:s},v=(i=n.updateCaptured)==null?void 0:i.call(n,w);if(Object.assign(w,v),{group:h,fullMatch:k,start:a,end:s}=w,k===null||h?.trim()==="")return null;if(h){const C=k.search(/\S/),b=a+k.indexOf(h),_=b+h.length;g=(l=u.storedMarks)!=null?l:[],_a&&u.delete(a+C,b),m=a+C+h.length;const S=(c=n.getAttr)==null?void 0:c.call(n,o);u.addMark(a,m,e.create(S)),u.setStoredMarks(g),(d=n.beforeDispatch)==null||d.call(n,{match:o,start:a,end:s,tr:u})}return u})}function uh(t,e,n={}){return new Pt(t,(r,o,a,s)=>{var i,l,c;const{tr:d}=r;let u=o[1],p=o[0];const h={group:u,fullMatch:p,start:a,end:s},k=(i=n.updateCaptured)==null?void 0:i.call(n,h);if(Object.assign(h,k),{group:u,fullMatch:p,start:a,end:s}=h,p===null||!u||u.trim()==="")return null;const g=(l=n.getAttr)==null?void 0:l.call(n,o),m=e.createAndFill(g);return m&&(d.replaceRangeWith(e.isBlock?d.doc.resolve(a).before():a,s,m),(c=n.beforeDispatch)==null||c.call(n,{match:[p,u??""],start:a,end:s,tr:d})),d})}var ph=Object.defineProperty,hh=Object.defineProperties,mh=Object.getOwnPropertyDescriptors,Bl=Object.getOwnPropertySymbols,gh=Object.prototype.hasOwnProperty,fh=Object.prototype.propertyIsEnumerable,Al=(t,e,n)=>e in t?ph(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vh=(t,e)=>{for(var n in e||(e={}))gh.call(e,n)&&Al(t,n,e[n]);if(Bl)for(var n of Bl(e))fh.call(e,n)&&Al(t,n,e[n]);return t},yh=(t,e)=>hh(t,mh(e));function Dl(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Qr(t,e,n){const o=t.state.doc.content.size,a=Dl(e,0,o),s=Dl(n,0,o),i=t.coordsAtPos(a),l=t.coordsAtPos(s,-1),c=Math.min(i.top,l.top),d=Math.max(i.bottom,l.bottom),u=Math.min(i.left,l.left),p=Math.max(i.right,l.right),h=p-u,k=d-c,w={top:c,bottom:d,left:u,right:p,width:h,height:k,x:u,y:c};return yh(vh({},w),{toJSON:()=>w})}function Wc(t){return Object.assign(Object.create(t),t).setTime(Date.now())}function wh(t,e){return Array.isArray(t)&&t.includes(e.type)||e.type===t}function kh(t){if(t.content.childCount===1){const e=t.content.firstChild;if(e?.type.name==="text"&&e.marks.length===0)return e;if(e?.type.name==="paragraph"&&e.childCount===1){const n=e.firstChild;if(n?.type.name==="text"&&n.marks.length===0)return n}}return!1}function Ie(t){return e=>{for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r)){const o=e.before(n),a=e.after(n);return{from:o,to:a,node:r}}}}}function Ch(t,e){return Ie(n=>n.type===e)(t)}function bh(t,e){const n=e.nodes[t];if(!n)throw Fp("node",t);return n}function Fc(t){return e=>{for(let n=e.depth;n>0;n--){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}}function _h(t){return e=>Fc(t)(e.$from)}function Mh(t,e){if(!(t instanceof it))return;const{node:n,$from:r}=t;if(wh(e,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const Kc=(t,e)=>{const{selection:n,doc:r}=t;if(n instanceof it)return{hasNode:n.node.type===e,pos:n.from,target:n.node};const{from:o,to:a}=n;let s=!1,i=-1,l=null;return r.nodesBetween(o,a,(c,d)=>l?!1:c.type===e?(s=!0,i=d,l=c,!1):!0),{hasNode:s,pos:i,target:l}};function Ae(t,e){return t.meta={package:"@milkdown/core",group:"System",...e},t}const Zc={text:(t,e,n,r)=>{const o=t.value;return/^[^*_\\]*\s+$/.test(o)?o:n.safe(o,{...r,encode:[]})},strong:(t,e,n,r)=>{const o=t.marker||n.options.strong||"*",a=n.enter("strong"),s=n.createTracker(r);let i=s.move(o+o);return i+=s.move(n.containerPhrasing(t,{before:i,after:o,...s.current()})),i+=s.move(o+o),a(),i},emphasis:(t,e,n,r)=>{const o=t.marker||n.options.emphasis||"*",a=n.enter("emphasis"),s=n.createTracker(r);let i=s.move(o);return i+=s.move(n.containerPhrasing(t,{before:i,after:o,...s.current()})),i+=s.move(o),a(),i}},q=O({},"editorView"),Yt=O({},"editorState"),xo=O([],"initTimer"),Xo=O({},"editor"),Sn=O([],"inputRules"),Ee=O([],"prosePlugins"),Ln=O([],"remarkPlugins"),Pn=O([],"nodeView"),Tn=O([],"markView"),ot=O(jo().use(Wo).use(Fo),"remark"),fn=O({handlers:Zc,encode:[]},"remarkStringifyOptions"),pr=Se("ConfigReady");function Ih(t){const e=n=>(n.record(pr),async()=>(await t(n),n.done(pr),()=>{n.clearTimer(pr)}));return Ae(e,{displayName:"Config"}),e}const at=Se("InitReady");function Nh(t){const e=n=>(n.inject(Xo,t).inject(Ee,[]).inject(Ln,[]).inject(Sn,[]).inject(Pn,[]).inject(Tn,[]).inject(fn,{handlers:Zc,encode:[]}).inject(ot,jo().use(Wo).use(Fo)).inject(xo,[pr]).record(at),async()=>{await n.waitTimers(xo);const r=n.get(fn);return n.set(ot,jo().use(Wo).use(Fo,r)),n.done(at),()=>{n.remove(Xo).remove(Ee).remove(Ln).remove(Sn).remove(Pn).remove(Tn).remove(fn).remove(ot).remove(xo).clearTimer(at)}});return Ae(e,{displayName:"Init"}),e}const te=Se("SchemaReady"),So=O([],"schemaTimer"),fe=O({},"schema"),vn=O([],"nodes"),yn=O([],"marks");function ql(t){return{...t,parseDOM:t.parseDOM?.map(e=>({priority:t.priority,...e}))}}const Gc=t=>(t.inject(fe,{}).inject(vn,[]).inject(yn,[]).inject(So,[at]).record(te),async()=>{await t.waitTimers(So);const e=t.get(ot),r=t.get(Ln).reduce((i,l)=>i.use(l.plugin,l.options),e);t.set(ot,r);const o=Object.fromEntries(t.get(vn).map(([i,l])=>[i,ql(l)])),a=Object.fromEntries(t.get(yn).map(([i,l])=>[i,ql(l)])),s=new Cc({nodes:o,marks:a});return t.set(fe,s),t.done(te),()=>{t.remove(fe).remove(vn).remove(yn).remove(So).clearTimer(te)}});Ae(Gc,{displayName:"Schema"});class zc{constructor(){this.#t=new Hc,this.#e=null,this.setCtx=e=>{this.#e=e},this.chain=()=>{if(this.#e==null)throw Io();const e=this.#e,n=[],r=this.get.bind(this),o={run:()=>{const s=pa(...n),i=e.get(q);return s(i.state,i.dispatch,i)},inline:s=>(n.push(s),o),pipe:a.bind(this)};function a(s,i){const l=r(s);return n.push(l(i)),o}return o}}#t;#e;get ctx(){return this.#e}create(e,n){const r=e.create(this.#t.sliceMap);return r.set(n),r}get(e){return this.#t.get(e).get()}remove(e){return this.#t.remove(e)}call(e,n){if(this.#e==null)throw Io();const o=this.get(e)(n),a=this.#e.get(q);return o(a.state,a.dispatch,a)}inline(e){if(this.#e==null)throw Io();const n=this.#e.get(q);return e(n.state,n.dispatch,n)}}function xh(t="cmdKey"){return O((()=>()=>!1),t)}const M=O(new zc,"commands"),Lo=O([te],"commandsTimer"),wn=Se("CommandsReady"),Uc=t=>{const e=new zc;return e.setCtx(t),t.inject(M,e).inject(Lo,[te]).record(wn),async()=>(await t.waitTimers(Lo),t.done(wn),()=>{t.remove(M).remove(Lo).clearTimer(wn)})};Ae(Uc,{displayName:"Commands"});function Sh(t){const e=pa(Ju,Xu,Yu,Uu);return t.Backspace=e,t}class Yc{constructor(){this.#t=null,this.#e=[],this.setCtx=e=>{this.#t=e},this.add=e=>(this.#e.push(e),()=>{this.#e=this.#e.filter(n=>n!==e)}),this.addObjectKeymap=e=>{const n=[];return Object.entries(e).forEach(([r,o])=>{if(typeof o=="function"){const a={key:r,onRun:()=>o};this.#e.push(a),n.push(()=>{this.#e=this.#e.filter(s=>s!==a)})}else this.#e.push(o),n.push(()=>{this.#e=this.#e.filter(a=>a!==o)})}),()=>{n.forEach(r=>r())}},this.addBaseKeymap=()=>{const e=Sh(zu);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#e.forEach(r=>{e[r.key]=[...e[r.key]||[],r]}),Object.fromEntries(Object.entries(e).map(([r,o])=>{const a=o.sort((i,l)=>(l.priority??50)-(i.priority??50));return[r,(i,l,c)=>{const d=this.#t;if(d==null)throw Xr();const u=a.map(h=>h.onRun(d));return pa(...u)(i,l,c)}]}))}}#t;#e;get ctx(){return this.#t}}const Vr=O(new Yc,"keymap"),Po=O([te],"keymapTimer"),kn=Se("KeymapReady"),Lh=t=>{const e=new Yc;return e.setCtx(t),t.inject(Vr,e).inject(Po,[te]).record(kn),async()=>(await t.waitTimers(Po),t.done(kn),()=>{t.remove(Vr).remove(Po).clearTimer(kn)})},hr=Se("ParserReady"),Xc=(()=>{throw Xr()}),_t=O(Xc,"parser"),To=O([],"parserTimer"),Jc=t=>(t.inject(_t,Xc).inject(To,[te]).record(hr),async()=>{await t.waitTimers(To);const e=t.get(ot),n=t.get(fe);return t.set(_t,Qp.create(n,e)),t.done(hr),()=>{t.remove(_t).remove(To).clearTimer(hr)}});Ae(Jc,{displayName:"Parser"});const Cn=Se("SerializerReady"),Oo=O([],"serializerTimer"),Qc=(()=>{throw Xr()}),Mt=O(Qc,"serializer"),ed=t=>(t.inject(Mt,Qc).inject(Oo,[te]).record(Cn),async()=>{await t.waitTimers(Oo);const e=t.get(ot),n=t.get(fe);return t.set(Mt,th.create(n,e)),t.done(Cn),()=>{t.remove(Mt).remove(Oo).clearTimer(Cn)}});Ae(ed,{displayName:"Serializer"});const mr=O("","defaultValue"),gr=O(t=>t,"stateOptions"),Ho=O([],"editorStateTimer"),fr=Se("EditorStateReady");function Ph(t,e,n){if(typeof t=="string")return e(t);if(t.type==="html")return Mc.fromSchema(n).parse(t.dom);if(t.type==="json")return Ic.fromJSON(n,t.value);throw Ap(t)}const Th=new X("MILKDOWN_STATE_TRACKER"),td=t=>(t.inject(mr,"").inject(Yt,{}).inject(gr,e=>e).inject(Ho,[hr,Cn,wn,kn]).record(fr),async()=>{await t.waitTimers(Ho);const e=t.get(fe),n=t.get(_t),r=t.get(Sn),o=t.get(gr),a=t.get(Ee),s=t.get(mr),i=Ph(s,n,e),l=t.get(Vr),c=l.addBaseKeymap(),d=[...a,new Y({key:Th,state:{init:()=>{},apply:(h,k,g,m)=>{t.set(Yt,m)}}}),dh({rules:r}),bc(l.build())];t.set(Ee,d);const u=o({schema:e,doc:i,plugins:d}),p=ua.create(u);return t.set(Yt,p),t.done(fr),()=>{c(),t.remove(mr).remove(Yt).remove(gr).remove(Ho).clearTimer(fr)}});Ae(td,{displayName:"EditorState"});const On=O([],"pasteRule"),Ro=O([te],"pasteRuleTimer"),vr=Se("PasteRuleReady"),nd=t=>(t.inject(On,[]).inject(Ro,[te]).record(vr),async()=>(await t.waitTimers(Ro),t.done(vr),()=>{t.remove(On).remove(Ro).clearTimer(vr)}));Ae(nd,{displayName:"PasteRule"});const yr=Se("EditorViewReady"),$o=O([],"editorViewTimer"),bn=O({},"editorViewOptions"),wr=O(null,"root"),Jo=O(null,"rootDOM"),Qo=O({},"rootAttrs");function Oh(t,e){const n=document.createElement("div");n.className="milkdown",t.appendChild(n),e.set(Jo,n);const r=e.get(Qo);return Object.entries(r).forEach(([o,a])=>n.setAttribute(o,a)),n}function Hh(t){t.classList.add("editor"),t.setAttribute("role","textbox")}const Rh=new X("MILKDOWN_VIEW_CLEAR"),rd=t=>(t.inject(wr,document.body).inject(q,{}).inject(bn,{}).inject(Jo,null).inject(Qo,{}).inject($o,[fr,vr]).record(yr),async()=>{await t.wait(at);const e=t.get(wr)||document.body,n=typeof e=="string"?document.querySelector(e):e;t.update(Ee,l=>[new Y({key:Rh,view:c=>{const d=n?Oh(n,t):void 0;return(()=>{if(d&&n){const p=c.dom;n.replaceChild(d,p),d.appendChild(p)}})(),{destroy:()=>{d?.parentNode&&d?.parentNode.replaceChild(c.dom,d),d?.remove()}}}}),...l]),await t.waitTimers($o);const r=t.get(Yt),o=t.get(bn),a=Object.fromEntries(t.get(Pn)),s=Object.fromEntries(t.get(Tn)),i=new _c(n,{state:r,nodeViews:a,markViews:s,transformPasted:(l,c,d)=>(t.get(On).sort((u,p)=>(p.priority??50)-(u.priority??50)).map(u=>u.run).forEach(u=>{l=u(l,c,d)}),l),...o});return Hh(i.dom),t.set(q,i),t.done(yr),()=>{i?.destroy(),t.remove(wr).remove(q).remove(bn).remove(Jo).remove(Qo).remove($o).clearTimer(yr)}});Ae(rd,{displayName:"EditorView"});var jr=(t=>(t.Idle="Idle",t.OnCreate="OnCreate",t.Created="Created",t.OnDestroy="OnDestroy",t.Destroyed="Destroyed",t))(jr||{});class _a{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#i=new Hc,this.#o=new Yp,this.#a=new Map,this.#s=new Map,this.#l=new Ca(this.#i,this.#o),this.#d=()=>{const e=Ih(async r=>{await Promise.all(this.#r.map(o=>Promise.resolve(o(r))))}),n=[Gc,Jc,ed,Uc,Lh,nd,td,rd,Nh(this),e];this.#c(n,this.#s)},this.#c=(e,n)=>{e.forEach(r=>{const o=this.#l.produce(this.#t?r.meta:void 0),a=r(o);n.set(r,{ctx:o,handler:a,cleanup:void 0})})},this.#u=(e,n=!1)=>Promise.all([e].flat().map(async r=>{const a=this.#a.get(r)?.cleanup;return n?this.#a.delete(r):this.#a.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof a=="function"?a():a})),this.#h=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:n}])=>typeof n=="function"?n():n)),this.#s.clear()},this.#p=e=>{this.#e=e,this.#n(e)},this.#m=e=>[...e.entries()].map(async([n,r])=>{const{ctx:o,handler:a}=r;if(!a)return;const s=await a();e.set(n,{ctx:o,handler:a,cleanup:s})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#r.push(e),this),this.removeConfig=e=>(this.#r=this.#r.filter(n=>n!==e),this),this.use=e=>{const n=[e].flat();return n.flat().forEach(r=>{this.#a.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(n,this.#a),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(n=>{setTimeout(()=>{n(this.remove(e))},50)})):(await this.#u([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#p("OnCreate"),this.#d(),this.#c([...this.#a.keys()],this.#a),await Promise.all([this.#m(this.#s),this.#m(this.#a)].flat()),this.#p("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(e))},50)}):(e&&(this.#r=[]),this.#p("OnDestroy"),await this.#u([...this.#a.keys()],e),await this.#h(),this.#p("Destroyed"),this),this.action=e=>e(this.#l),this.inspect=()=>this.#t?[...this.#s.values(),...this.#a.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new _a}#t;#e;#r;#n;#i;#o;#a;#s;#l;#d;#c;#u;#h;#p;#m;get ctx(){return this.#l}get status(){return this.#e}}function P(t,e){const n=xh(t),r=o=>async()=>{r.key=n,await o.wait(wn);const a=e(o);return o.get(M).create(n,a),r.run=s=>o.get(M).call(t,s),()=>{o.get(M).remove(n)}};return r}function ee(t){const e=n=>async()=>{await n.wait(te);const r=t(n);return n.update(Sn,o=>[...o,r]),e.inputRule=r,()=>{n.update(Sn,o=>o.filter(a=>a!==r))}};return e}function $h(t){const e=n=>async()=>{await n.wait(te);const r=t(n);return n.update(On,o=>[...o,r]),e.pasteRule=r,()=>{n.update(On,o=>o.filter(a=>a!==r))}};return e}function Eh(t,e){const n=r=>async()=>{const o=e(r);return r.update(yn,a=>[...a.filter(s=>s[0]!==t),[t,o]]),n.id=t,n.schema=o,()=>{r.update(yn,a=>a.filter(([s])=>s!==t))}};return n.type=r=>{const o=r.get(fe).marks[t];if(!o)throw Zp(t);return o},n}function Ma(t,e){const n=r=>async()=>{const o=e(r);return r.update(vn,a=>[...a.filter(s=>s[0]!==t),[t,o]]),n.id=t,n.schema=o,()=>{r.update(vn,a=>a.filter(([s])=>s!==t))}};return n.type=r=>{const o=r.get(fe).nodes[t];if(!o)throw Kp(t);return o},n}function G(t){let e;const n=r=>async()=>(await r.wait(te),e=t(r),r.update(Ee,o=>[...o,e]),()=>{r.update(Ee,o=>o.filter(a=>a!==e))});return n.plugin=()=>e,n.key=()=>e.spec.key,n}function od(t){const e=n=>async()=>{await n.wait(kn);const r=n.get(Vr),o=t(n),a=r.addObjectKeymap(o);return e.keymap=o,()=>{a()}};return e}function Bn(t,e){const n=r=>async()=>{await r.wait(te);const o=e(r);return t.type(r)instanceof Tl?r.update(Pn,a=>[...a,[t.id,o]]):r.update(Tn,a=>[...a,[t.id,o]]),n.view=o,n.type=t,()=>{t.type(r)instanceof Tl?r.update(Pn,a=>a.filter(s=>s[0]!==t.id)):r.update(Tn,a=>a.filter(s=>s[0]!==t.id))}};return n}function A(t,e){const n=O(t,e),r=o=>(o.inject(n),()=>()=>{o.remove(n)});return r.key=n,r}function F(t,e){const n=A(e,t),r=Ma(t,a=>a.get(n.key)(a)),o=[n,r];return o.id=r.id,o.node=r,o.type=a=>r.type(a),o.ctx=n,o.key=n.key,o.extendSchema=a=>{const s=a(e);return F(t,s)},o}function Ot(t,e){const n=A(e,t),r=Eh(t,a=>a.get(n.key)(a)),o=[n,r];return o.id=r.id,o.mark=r,o.type=a=>r.type(a),o.ctx=n,o.key=n.key,o.extendSchema=a=>{const s=a(e);return Ot(t,s)},o}function ae(t,e){const n=Object.fromEntries(Object.entries(e).map(([s,{shortcuts:i,priority:l}])=>[s,{shortcuts:i,priority:l}])),r=A(n,`${t}Keymap`),o=od(s=>{const i=s.get(r.key),l=Object.entries(e).flatMap(([c,{command:d}])=>{const u=i[c],p=[u.shortcuts].flat(),h=u.priority;return p.map(k=>[k,{key:k,onRun:d,priority:h}])});return Object.fromEntries(l)}),a=[r,o];return a.ctx=r,a.shortcuts=o,a.key=r.key,a.keymap=o.keymap,a}const ke=(t,e=()=>({}))=>A(e,`${t}Attr`),An=(t,e=()=>({}))=>A(e,`${t}Attr`);function Le(t,e,n){const r=A({},t),o=s=>async()=>{await s.wait(at);const l={plugin:e(s),options:s.get(r.key)};return s.update(Ln,c=>[...c,l]),()=>{s.update(Ln,c=>c.filter(d=>d!==l))}},a=[r,o];return a.id=t,a.plugin=o,a.options=r,a}function Bh(t){return e=>{const n=e.get(q);return e.get(fe),e.get(Mt)(n.state.doc)}}function k0(t,e=!1){return n=>{const r=n.get(q),a=n.get(_t)(t);if(!a)return;if(!e){const{state:d}=r;return r.dispatch(d.tr.replace(0,d.doc.content.size,new tr(a.content,0,0)))}const s=n.get(fe),i=n.get(gr),l=n.get(Ee),c=ua.create({schema:s,doc:a,plugins:l,...i});r.updateState(c)}}function Dn(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-block",...e}}),t}const Ah=t=>!Ie(n=>n.type.name==="table")(t),eo=A({filterNodes:Ah},"blockConfig");Dn(eo,{displayName:"Ctx"});function Dh(t,e,n){if(!t.dom.parentElement)return null;try{const o=t.posAtCoords({left:e.x,top:e.y})?.inside;if(o==null||o<0)return null;let a=t.state.doc.resolve(o),s=t.state.doc.nodeAt(o),i=t.nodeDOM(o);const l=d=>{const u=a.depth>=1&&a.index(a.depth)===0;if(!(d||u))return;const h=a.before(a.depth);s=t.state.doc.nodeAt(h),i=t.nodeDOM(h),a=t.state.doc.resolve(h),n(a,s)||l(!0)},c=n(a,s);return l(!c),!i||!s?null:{node:s,$pos:a,el:i}}catch{return null}}const Vl=zn.ie&&zn.ie_version<15||zn.ios&&zn.webkit_version<604,jl=20;class qh{constructor(){this.#e=()=>{if(!this.#n)return null;const e=this.#n,n=this.#s;if(n&&it.isSelectable(e.node)){const r=it.create(n.state.doc,e.$pos.pos);return n.dispatch(n.state.tr.setSelection(r)),n.focus(),this.#r=r,r}return null},this.#r=null,this.#n=null,this.#i=void 0,this.#o=!1,this.#d=()=>{this.#l?.({type:"hide"}),this.#n=null},this.#c=e=>{this.#n=e,this.#l?.({type:"show",active:e})},this.bind=(e,n)=>{this.#t=e,this.#l=n},this.addEvent=e=>{e.addEventListener("mousedown",this.#u),e.addEventListener("mouseup",this.#h),e.addEventListener("dragstart",this.#p),e.addEventListener("dragend",this.#m)},this.removeEvent=e=>{e.removeEventListener("mousedown",this.#u),e.removeEventListener("mouseup",this.#h),e.removeEventListener("dragstart",this.#p),e.removeEventListener("dragend",this.#m)},this.unBind=()=>{this.#l=void 0},this.#u=()=>{this.#i=this.#n?.el.getBoundingClientRect(),this.#e()},this.#h=()=>{if(!this.#o){requestAnimationFrame(()=>{this.#i&&this.#s?.focus()});return}this.#o=!1,this.#r=null},this.#p=e=>{this.#o=!0;const n=this.#s;if(!n)return;n.dom.dataset.dragging="true";const r=this.#r;if(e.dataTransfer&&r){const o=r.content();e.dataTransfer.effectAllowed="copyMove";const{dom:a,text:s}=n.serializeForClipboard(o);e.dataTransfer.clearData(),e.dataTransfer.setData(Vl?"Text":"text/html",a.innerHTML),Vl||e.dataTransfer.setData("text/plain",s);const i=this.#n?.el;i&&e.dataTransfer.setDragImage(i,0,0),n.dragging={slice:o,move:!0}}},this.#m=()=>{this.#s&&this.#g(this.#s)},this.keydownCallback=e=>(this.#d(),this.#o=!1,e.dom.dataset.dragging="false",!1),this.#f=Ur((e,n)=>{if(!e.editable)return;const r=e.dom.getBoundingClientRect(),o=r.left+r.width/2;if(!(e.root.elementFromPoint(o,n.clientY)instanceof Element)){this.#d();return}const s=this.#a;if(!s)return;const i=Dh(e,{x:o,y:n.clientY},s);if(!i){this.#d();return}this.#c(i)},200),this.mousemoveCallback=(e,n)=>(e.composing||!e.editable||this.#f(e,n),!1),this.dragoverCallback=(e,n)=>{if(this.#o){const r=this.#s?.dom.parentElement;if(!r)return!1;const o=r.scrollHeight>r.clientHeight,a=r.getBoundingClientRect();if(o){if(r.scrollTop>0&&Math.abs(n.y-a.y)10?r.scrollTop-10:0;return r.scrollTop=l,!1}const s=Math.round(e.dom.getBoundingClientRect().height);if(Math.round(r.scrollTop+a.height){e.dragging&&(this.#o=!0,e.dom.dataset.dragging="true")},this.dragleaveCallback=(e,n)=>{const r=n.clientX,o=n.clientY;(r<0||o<0||r>window.innerWidth||o>window.innerHeight)&&(this.#n=null,this.#g(e))},this.dropCallback=e=>(this.#g(e),!1),this.dragendCallback=e=>{this.#g(e)},this.#g=e=>{this.#o=!1,e.dom.dataset.dragging="false"}}#t;#e;#r;#n;#i;#o;get#a(){try{return this.#t?.get(eo.key).filterNodes}catch{return}}get#s(){return this.#t?.get(q)}#l;#d;#c;#u;#h;#p;#m;#f;#g}const Ia=A(()=>new qh,"blockService"),to=A({},"blockServiceInstance");Dn(Ia,{displayName:"Ctx"});Dn(to,{displayName:"Ctx"});const no=A({},"blockSpec");Dn(no,{displayName:"Ctx"});const Na=G(t=>{const e=new X("MILKDOWN_BLOCK"),r=t.get(Ia.key)();t.set(to.key,r);const o=t.get(no.key);return new Y({key:e,...o,props:{...o.props,handleDOMEvents:{drop:a=>r.dropCallback(a),pointermove:(a,s)=>r.mousemoveCallback(a,s),keydown:a=>r.keydownCallback(a),dragover:(a,s)=>r.dragoverCallback(a,s),dragleave:(a,s)=>r.dragleaveCallback(a,s),dragenter:a=>r.dragenterCallback(a),dragend:a=>r.dragendCallback(a)}}})});Dn(Na,{displayName:"Prose"});class Vh{constructor(e){this.#n=null,this.#o=!1,this.update=()=>{requestAnimationFrame(()=>{if(!this.#o)try{this.#u(),this.#o=!0}catch{}})},this.destroy=()=>{this.#r?.unBind(),this.#r?.removeEvent(this.#t),this.#t.remove()},this.show=n=>{const r=n.el,o=this.#e.get(q).dom,a={ctx:this.#e,active:n,editorDom:o,blockDom:this.#t},s={contextElement:r,getBoundingClientRect:()=>this.#d?this.#d(a):r.getBoundingClientRect()},i=[ka()];if(this.#l){const l=this.#l(a),c=lt(l);i.push(c)}Ne(s,this.#t,{placement:this.#c?this.#c(a):"left",middleware:[...i,...this.#a],...this.#s}).then(({x:l,y:c})=>{Object.assign(this.#t.style,{left:`${l}px`,top:`${c}px`}),this.#t.dataset.show="true"}).catch(console.error)},this.hide=()=>{this.#t.dataset.show="false"},this.#e=e.ctx,this.#t=e.content,this.#l=e.getOffset,this.#d=e.getPosition,this.#c=e.getPlacement,this.#a=e.middleware??[],this.#s=e.floatingUIOptions??{},this.#i=e.root,this.hide()}#t;#e;#r;#n;#i;#o;#a;#s;#l;#d;#c;get active(){return this.#n}#u(){const e=this.#e.get(q);(this.#i??e.dom.parentElement??document.body).appendChild(this.#t);const r=this.#e.get(to.key);r.bind(this.#e,o=>{o.type==="hide"?(this.hide(),this.#n=null):o.type==="show"&&(this.show(o.active),this.#n=o.active)}),this.#r=r,this.#r.addEvent(this.#t),this.#t.draggable=!0}}const ro=[no,eo,Ia,to,Na];ro.key=no.key;ro.pluginKey=Na.key;function ad(t,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){t.next(e.content);return}const r=[];e.content.forEach((o,a,s)=>{s!==e.childCount-1&&r.push(o)}),t.next(nr.fromArray(r))}function y(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}const xa=An("emphasis");y(xa,{displayName:"Attr",group:"Emphasis"});const dt=Ot("emphasis",t=>({attrs:{marker:{default:t.get(fn).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(xa.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,n,r)=>{e.openMark(r,{marker:n.marker}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,n)=>{e.withMark(n,"emphasis",void 0,{marker:n.attrs.marker})}}}));y(dt.mark,{displayName:"MarkSchema",group:"Emphasis"});y(dt.ctx,{displayName:"MarkSchemaCtx",group:"Emphasis"});const oo=P("ToggleEmphasis",t=>()=>Kr(dt.type(t)));y(oo,{displayName:"Command",group:"Emphasis"});const sd=ee(t=>En(/(?:^|[^*])\*([^*]+)\*$/,dt.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:n+1}}));y(sd,{displayName:"InputRule|Star",group:"Emphasis"});const id=ee(t=>En(/\b_(?![_\s])(.*?[^_\s])_\b/,dt.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:n+1}}));y(id,{displayName:"InputRule|Underscore",group:"Emphasis"});const Sa=ae("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{const e=t.get(M);return()=>e.call(oo.key)}}});y(Sa.ctx,{displayName:"KeymapCtx",group:"Emphasis"});y(Sa.shortcuts,{displayName:"Keymap",group:"Emphasis"});const La=An("strong");y(La,{displayName:"Attr",group:"Strong"});const Ht=Ot("strong",t=>({attrs:{marker:{default:t.get(fn).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",t.get(La.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,n,r)=>{e.openMark(r,{marker:n.marker}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,n)=>{e.withMark(n,"strong",void 0,{marker:n.attrs.marker})}}}));y(Ht.mark,{displayName:"MarkSchema",group:"Strong"});y(Ht.ctx,{displayName:"MarkSchemaCtx",group:"Strong"});const ao=P("ToggleStrong",t=>()=>Kr(Ht.type(t)));y(ao,{displayName:"Command",group:"Strong"});const ld=ee(t=>En(new RegExp("(?({marker:e[0].startsWith("*")?"*":"_"})}));y(ld,{displayName:"InputRule",group:"Strong"});const Pa=ae("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{const e=t.get(M);return()=>e.call(ao.key)}}});y(Pa.ctx,{displayName:"KeymapCtx",group:"Strong"});y(Pa.shortcuts,{displayName:"Keymap",group:"Strong"});const Ta=An("inlineCode");y(Ta,{displayName:"Attr",group:"InlineCode"});const $e=Ot("inlineCode",t=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(Ta.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,n,r)=>{e.openMark(r),e.addText(n.value),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,n,r)=>{e.withMark(n,"inlineCode",r.text||"")}}}));y($e.mark,{displayName:"MarkSchema",group:"InlineCode"});y($e.ctx,{displayName:"MarkSchemaCtx",group:"InlineCode"});const so=P("ToggleInlineCode",t=>()=>(e,n)=>{const{selection:r,tr:o}=e;if(r.empty)return!1;const{from:a,to:s}=r;return e.doc.rangeHasMark(a,s,$e.type(t))?(n?.(o.removeMark(a,s,$e.type(t))),!0):(Object.keys(e.schema.marks).filter(c=>c!==$e.type.name).map(c=>e.schema.marks[c]).forEach(c=>{o.removeMark(a,s,c)}),n?.(o.addMark(a,s,$e.type(t).create())),!0)});y(so,{displayName:"Command",group:"InlineCode"});const cd=ee(t=>En(/(?:`)([^`]+)(?:`)$/,$e.type(t)));y(cd,{displayName:"InputRule",group:"InlineCode"});const Oa=ae("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{const e=t.get(M);return()=>e.call(so.key)}}});y(Oa.ctx,{displayName:"KeymapCtx",group:"InlineCode"});y(Oa.shortcuts,{displayName:"Keymap",group:"InlineCode"});const Ha=An("link");y(Ha,{displayName:"Attr",group:"Link"});const ve=Ot("link",t=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(Ha.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,n,r)=>{const o=n.url,a=n.title;e.openMark(r,{href:o,title:a}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,n)=>{e.withMark(n,"link",void 0,{title:n.attrs.title,url:n.attrs.href})}}}));y(ve.mark,{displayName:"MarkSchema",group:"Link"});const dd=P("ToggleLink",t=>(e={})=>Kr(ve.type(t),e));y(dd,{displayName:"Command",group:"Link"});const ud=P("UpdateLink",t=>(e={})=>(n,r)=>{if(!r)return!1;let o,a=-1;const{selection:s}=n,{from:i,to:l}=s;if(n.doc.nodesBetween(i,i===l?l+1:l,(k,g)=>{if(ve.type(t).isInSet(k.marks))return o=k,a=g,!1}),!o)return!1;const c=o.marks.find(({type:k})=>k===ve.type(t));if(!c)return!1;const d=a,u=a+o.nodeSize,{tr:p}=n,h=ve.type(t).create({...c.attrs,...e});return h?(r(p.removeMark(d,u,c).addMark(d,u,h).setSelection(new W(p.selection.$anchor)).scrollIntoView()),!0):!1});y(ud,{displayName:"Command",group:"Link"});const pd=Ma("doc",()=>({content:"block+",parseMarkdown:{match:({type:t})=>t==="root",runner:(t,e,n)=>{t.injectRoot(e,n)}},toMarkdown:{match:t=>t.type.name==="doc",runner:(t,e)=>{t.openNode("root"),t.next(e.content)}}}));y(pd,{displayName:"NodeSchema",group:"Doc"});function jh(t){return Hp(t,e=>e.type==="html"&&["
","
","
","
"].includes(e.value?.trim()),(e,n)=>{if(!n.length)return;const r=n[n.length-1];if(!r)return;const o=r.children.indexOf(e);o!==-1&&r.children.splice(o,1)},!0)}const io=Le("remark-preserve-empty-line",()=>()=>jh);y(io.plugin,{displayName:"Remark",group:"Remark"});y(io.options,{displayName:"RemarkConfig",group:"Remark"});const Ra=ke("paragraph");y(Ra,{displayName:"Attr",group:"Paragraph"});const Ce=F("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(Ra.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,n,r)=>{e.openNode(r),n.children?e.next(n.children):e.addText(n.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,n)=>{const o=t.get(q).state?.doc.lastChild;e.openNode("paragraph"),(!n.content||n.content.size===0)&&n!==o&&Wh(t)?e.addNode("html",void 0,"
"):ad(e,n),e.closeNode()}}}));function Wh(t){let e=!1;try{t.get(io.id),e=!0}catch{e=!1}return e}y(Ce.node,{displayName:"NodeSchema",group:"Paragraph"});y(Ce.ctx,{displayName:"NodeSchemaCtx",group:"Paragraph"});const $a=P("TurnIntoText",t=>()=>In(Ce.type(t)));y($a,{displayName:"Command",group:"Paragraph"});const Ea=ae("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{const e=t.get(M);return()=>e.call($a.key)}}});y(Ea.ctx,{displayName:"KeymapCtx",group:"Paragraph"});y(Ea.shortcuts,{displayName:"Keymap",group:"Paragraph"});const Fh=Array(6).fill(0).map((t,e)=>e+1);function Kh(t){return t.textContent.toLowerCase().trim().replace(/\s+/g,"-")}const lo=A(Kh,"headingIdGenerator");y(lo,{displayName:"Ctx",group:"Heading"});const Ba=ke("heading");y(Ba,{displayName:"Attr",group:"Heading"});const de=F("heading",t=>{const e=t.get(lo.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Fh.map(n=>({tag:`h${n}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw we(r);return{level:n,id:r.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...t.get(Ba.key)(n),id:n.attrs.id||e(n)},0],parseMarkdown:{match:({type:n})=>n==="heading",runner:(n,r,o)=>{const a=r.depth;n.openNode(o,{level:a}),n.next(r.children),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="heading",runner:(n,r)=>{n.openNode("heading",void 0,{depth:r.attrs.level}),ad(n,r),n.closeNode()}}}});y(de.node,{displayName:"NodeSchema",group:"Heading"});y(de.ctx,{displayName:"NodeSchemaCtx",group:"Heading"});const hd=ee(t=>ha(/^(?#+)\s$/,de.type(t),e=>{const n=e.groups?.hashes?.length||0,r=t.get(q),{$from:o}=r.state.selection,a=o.node();if(a.type.name==="heading"){let s=Number(a.attrs.level)+Number(n);return s>6&&(s=6),{level:s}}return{level:n}}));y(hd,{displayName:"InputRule",group:"Heading"});const Fe=P("WrapInHeading",t=>e=>(e??=1,e<1?In(Ce.type(t)):In(de.type(t),{level:e})));y(Fe,{displayName:"Command",group:"Heading"});const Aa=P("DowngradeHeading",t=>()=>(e,n,r)=>{const{$from:o}=e.selection,a=o.node();if(a.type!==de.type(t)||!e.selection.empty||o.parentOffset!==0)return!1;const s=a.attrs.level-1;return s?(n?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...a.attrs,level:s})),!0):In(Ce.type(t))(e,n,r)});y(Aa,{displayName:"Command",group:"Heading"});const Da=ae("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{const e=t.get(M);return()=>e.call(Fe.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{const e=t.get(M);return()=>e.call(Aa.key)}}});y(Da.ctx,{displayName:"KeymapCtx",group:"Heading"});y(Da.shortcuts,{displayName:"Keymap",group:"Heading"});const qa=ke("blockquote");y(qa,{displayName:"Attr
",group:"Blockquote"});const Rt=F("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(qa.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,n,r)=>{e.openNode(r).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,n)=>{e.openNode("blockquote").next(n.content).closeNode()}}}));y(Rt.node,{displayName:"NodeSchema
",group:"Blockquote"});y(Rt.ctx,{displayName:"NodeSchemaCtx
",group:"Blockquote"});const md=ee(t=>ma(/^\s*>\s$/,Rt.type(t)));y(md,{displayName:"InputRule",group:"Blockquote"});const Va=P("WrapInBlockquote",t=>()=>ga(Rt.type(t)));y(Va,{displayName:"Command",group:"Blockquote"});const ja=ae("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{const e=t.get(M);return()=>e.call(Va.key)}}});y(ja.ctx,{displayName:"KeymapCtx
",group:"Blockquote"});y(ja.shortcuts,{displayName:"Keymap
",group:"Blockquote"});const Wa=ke("codeBlock",()=>({pre:{},code:{}}));y(Wa,{displayName:"Attr",group:"CodeBlock"});const xe=F("code_block",t=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{language:e.dataset.language}}}],toDOM:e=>{const n=t.get(Wa.key)(e),r=e.attrs.language,o=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...o},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,n,r)=>{const o=n.lang??"",a=n.value;e.openNode(r,{language:o}),a&&e.addText(a),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,n)=>{e.addNode("code",void 0,n.content.firstChild?.text||"",{lang:n.attrs.language})}}}));y(xe.node,{displayName:"NodeSchema",group:"CodeBlock"});y(xe.ctx,{displayName:"NodeSchemaCtx",group:"CodeBlock"});const gd=ee(t=>ha(/^```(?[a-z]*)?[\s\n]$/,xe.type(t),e=>({language:e.groups?.language??""})));y(gd,{displayName:"InputRule",group:"CodeBlock"});const Fa=P("CreateCodeBlock",t=>(e="")=>In(xe.type(t),{language:e}));y(Fa,{displayName:"Command",group:"CodeBlock"});const Zh=P("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(n,r)=>t>=0?(r?.(n.tr.setNodeAttribute(t,"language",e)),!0):!1);y(Zh,{displayName:"Command",group:"CodeBlock"});const Ka=ae("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{const e=t.get(M);return()=>e.call(Fa.key)}}});y(Ka.ctx,{displayName:"KeymapCtx",group:"CodeBlock"});y(Ka.shortcuts,{displayName:"Keymap",group:"CodeBlock"});const Za=ke("image");y(Za,{displayName:"Attr",group:"Image"});const ut=F("image",t=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(Za.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,n,r)=>{const o=n.url,a=n.alt,s=n.title;e.addNode(r,{src:o,alt:a,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,n)=>{e.addNode("image",void 0,void 0,{title:n.attrs.title,url:n.attrs.src,alt:n.attrs.alt})}}}));y(ut.node,{displayName:"NodeSchema",group:"Image"});y(ut.ctx,{displayName:"NodeSchemaCtx",group:"Image"});const fd=P("InsertImage",t=>(e={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:a="",title:s=""}=e,i=ut.type(t).create({src:o,alt:a,title:s});return i&&r(n.tr.replaceSelectionWith(i).scrollIntoView()),!0});y(fd,{displayName:"Command",group:"Image"});const vd=P("UpdateImage",t=>(e={})=>(n,r)=>{const o=Mh(n.selection,ut.type(t));if(!o)return!1;const{node:a,pos:s}=o,i={...a.attrs},{src:l,alt:c,title:d}=e;return l!==void 0&&(i.src=l),c!==void 0&&(i.alt=c),d!==void 0&&(i.title=d),r?.(n.tr.setNodeMarkup(s,void 0,i).scrollIntoView()),!0});y(vd,{displayName:"Command",group:"Image"});const Gh=ee(t=>new Pt(/!\[(?.*?)]\((?.*?)\s*(?="|\))"?(?[^"]+)?"?\)/,(e,n,r,o)=>{const[a,s,i="",l]=n;return a?e.tr.replaceWith(r,o,ut.type(t).create({src:i,alt:s,title:l})):null}));y(Gh,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const Wr=ke("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));y(Wr,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const st=F("hardbreak",t=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",t.get(Wr.key)(e)," "]:["br",t.get(Wr.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,n,r)=>{e.addNode(r,{isInline:!!n.data?.isInline})}},leafText:()=>` `,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,n)=>{n.attrs.isInline?e.addNode("text",void 0,` `):e.addNode("break")}}}));y(st.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});y(st.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const Ga=P("InsertHardbreak",t=>()=>(e,n)=>{const{selection:r,tr:o}=e;if(!(r instanceof W))return!1;if(r.empty){const a=r.$from.node();if(a.childCount>0&&a.lastChild?.type.name==="hardbreak")return n?.(o.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(Zr.near(o.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(o.setMeta("hardbreak",!0).replaceSelectionWith(st.type(t).create()).scrollIntoView()),!0});y(Ga,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const za=ae("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{const e=t.get(M);return()=>e.call(Ga.key)}}});y(za.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});y(za.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const Ua=ke("hr");y(Ua,{displayName:"Attr<hr>",group:"Hr"});const $t=F("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(Ua.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,n,r)=>{e.addNode(r)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));y($t.node,{displayName:"NodeSchema<hr>",group:"Hr"});y($t.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const yd=ee(t=>new Pt(/^(?:---|___\s|\*\*\*\s)$/,(e,n,r,o)=>{const{tr:a}=e;return n[0]&&a.replaceWith(r-1,o,$t.type(t).create()),a}));y(yd,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const wd=P("InsertHr",t=>()=>(e,n)=>{if(!n)return!0;const r=Ce.node.type(t).create(),{tr:o,selection:a}=e,{from:s}=a,i=$t.type(t).create();if(!i)return!0;const l=o.replaceSelectionWith(i).insert(s,r),c=Zr.findFrom(l.doc.resolve(s),1,!0);return c&&n(l.setSelection(c).scrollIntoView()),!0});y(wd,{displayName:"Command<insertHrCommand>",group:"Hr"});const Ya=ke("bulletList");y(Ya,{displayName:"Attr<bulletList>",group:"BulletList"});const pt=F("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...t.get(Ya.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:n})=>e==="list"&&!n,runner:(e,n,r)=>{const o=n.spread!=null?`${n.spread}`:"false";e.openNode(r,{spread:o}).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,n)=>{e.openNode("list",void 0,{ordered:!1,spread:n.attrs.spread}).next(n.content).closeNode()}}}));y(pt.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});y(pt.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const kd=ee(t=>ma(/^\s*([-+*])\s$/,pt.type(t)));y(kd,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const Xa=P("WrapInBulletList",t=>()=>ga(pt.type(t)));y(Xa,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const Ja=ae("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{const e=t.get(M);return()=>e.call(Xa.key)}}});y(Ja.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});y(Ja.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const Qa=ke("orderedList");y(Qa,{displayName:"Attr<orderedList>",group:"OrderedList"});const ht=F("ordered_list",t=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(Qa.key)(e),...e.attrs.order===1?{}:e.attrs.order,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:n})=>e==="list"&&!!n,runner:(e,n,r)=>{const o=n.spread!=null?`${n.spread}`:"true";e.openNode(r,{spread:o}).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,n)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:n.attrs.spread==="true"}),e.next(n.content),e.closeNode()}}}));y(ht.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});y(ht.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const Cd=ee(t=>ma(/^\s*(\d+)\.\s$/,ht.type(t),e=>({order:Number(e[1])}),(e,n)=>n.childCount+n.attrs.order===Number(e[1])));y(Cd,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const es=P("WrapInOrderedList",t=>()=>ga(ht.type(t)));y(es,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const ts=ae("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{const e=t.get(M);return()=>e.call(es.key)}}});y(ts.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});y(ts.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const ns=ke("listItem");y(ns,{displayName:"Attr<listItem>",group:"ListItem"});const be=F("list_item",t=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw we(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...t.get(ns.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,n,r)=>{const o=n.label!=null?`${n.label}.`:"•",a=n.label!=null?"ordered":"bullet",s=n.spread!=null?`${n.spread}`:"true";e.openNode(r,{label:o,listType:a,spread:s}),e.next(n.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,n)=>{e.openNode("listItem",void 0,{spread:n.attrs.spread}),e.next(n.content),e.closeNode()}}}));y(be.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});y(be.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const rs=P("SinkListItem",t=>()=>tp(be.type(t)));y(rs,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const os=P("LiftListItem",t=>()=>np(be.type(t)));y(os,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const as=P("SplitListItem",t=>()=>rp(be.type(t)));y(as,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function zh(t){return(e,n,r)=>{const{selection:o}=e;if(!(o instanceof W))return!1;const{empty:a,$from:s}=o;return!a||s.parentOffset!==0||s.node(-1).type!==be.type(t)?!1:ap(e,n,r)}}const ss=P("LiftFirstListItem",t=>()=>zh(t));y(ss,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const is=ae("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{const e=t.get(M);return()=>e.call(as.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{const e=t.get(M);return()=>e.call(rs.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{const e=t.get(M);return()=>e.call(os.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{const e=t.get(M);return()=>e.call(ss.key)}}});y(is.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});y(is.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const bd=Ma("text",()=>({group:"inline",parseMarkdown:{match:({type:t})=>t==="text",runner:(t,e)=>{t.addText(e.value)}},toMarkdown:{match:t=>t.type.name==="text",runner:(t,e)=>{t.addNode("text",void 0,e.text)}}}));y(bd,{displayName:"NodeSchema<text>",group:"Text"});const ls=ke("html");y(ls,{displayName:"Attr<html>",group:"Html"});const cs=F("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const n=document.createElement("span"),r={...t.get(ls.key)(e),"data-value":e.attrs.value,"data-type":"html"};return n.textContent=e.attrs.value,["span",r,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,n,r)=>{e.addNode(r,{value:n.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,n)=>{e.addNode("html",void 0,n.attrs.value)}}}));y(cs.node,{displayName:"NodeSchema<html>",group:"Html"});y(cs.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const Uh=[pd,Ra,Ce,lo,Ba,de,Wr,st,qa,Rt,Wa,xe,Ua,$t,Za,ut,Ya,pt,Qa,ht,ns,be,xa,dt,La,Ht,Ta,$e,Ha,ve,ls,cs,bd].flat(),Yh=[md,kd,Cd,gd,yd,hd].flat(),Xh=[sd,id,cd,ld],wt=P("IsMarkSelected",()=>t=>e=>{if(!t)return!1;const{doc:n,selection:r}=e;return n.rangeHasMark(r.from,r.to,t)}),_d=P("IsNoteSelected",()=>t=>e=>t?Kc(e,t).hasNode:!1),U=P("ClearTextInCurrentBlock",()=>()=>(t,e)=>{let n=t.tr;const{$from:r,$to:o}=n.selection,{pos:a}=r,{pos:s}=o,i=a-r.node().content.size;return i<0?!1:(n=n.deleteRange(i,s),e?.(n),!0)}),He=P("SetBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:o=null}=t??{};if(!r)return!1;const a=e.tr,{from:s,to:i}=a.selection;try{a.setBlockType(s,i,r,o)}catch{return!1}return n?.(a),!0}),Xt=P("WrapInBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:o=null}=t??{};if(!r)return!1;let a=e.tr;try{const{$from:s,$to:i}=a.selection,l=s.blockRange(i),c=l&&op(l,r,o);if(!c)return!1;a=a.wrap(l,c)}catch{return!1}return n?.(a),!0}),Jt=P("AddBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:o=null}=t??{};if(!r)return!1;const a=e.tr;try{const s=r instanceof Ic?r:r.createAndFill(o);if(!s)return!1;a.replaceSelectionWith(s)}catch{return!1}return n?.(a),!0}),Md=P("SelectTextNearPos",()=>t=>(e,n)=>{const{pos:r}=t??{};if(r==null)return!1;const o=(s,i,l)=>Math.min(Math.max(s,i),l),a=e.tr;try{const s=e.doc.resolve(o(r,0,e.doc.content.size));a.setSelection(W.near(s))}catch{return!1}return n?.(a.scrollIntoView()),!0}),Jh=[$a,Va,Fe,Aa,Fa,Ga,wd,fd,vd,es,Xa,rs,as,os,ss,oo,so,ao,dd,ud,wt,_d,U,He,Xt,Jt,Md],Qh=[ja,Ka,za,Da,is,ts,Ja,Ea,Sa,Oa,Pa].flat(),ds=Le("remarkAddOrderInList",()=>()=>t=>{$n(t,"list",e=>{if(e.ordered){const n=e.start??1;e.children.forEach((r,o)=>{r.label=o+n})}})});y(ds.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});y(ds.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const us=Le("remarkLineBreak",()=>()=>t=>{const e=/[\t ]*(?:\r?\n|\r)/g;$n(t,"text",(n,r,o)=>{if(!n.value||typeof n.value!="string")return;const a=[];let s=0;e.lastIndex=0;let i=e.exec(n.value);for(;i;){const c=i.index;s!==c&&a.push({type:"text",value:n.value.slice(s,c)}),a.push({type:"break",data:{isInline:!0}}),s=c+i[0].length,i=e.exec(n.value)}if(a.length>0&&o&&typeof r=="number")return s<n.value.length&&a.push({type:"text",value:n.value.slice(s)}),o.children.splice(r,1,...a),r+a.length})});y(us.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});y(us.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const ps=Le("remarkInlineLink",()=>Op);y(ps.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});y(ps.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const e1=t=>!!t.children,t1=t=>t.type==="html";function n1(t,e){return n(t,0,null)[0];function n(r,o,a){if(e1(r)){const s=[];for(let i=0,l=r.children.length;i<l;i++){const c=r.children[i];if(c){const d=n(c,i,r);if(d)for(let u=0,p=d.length;u<p;u++){const h=d[u];h&&s.push(h)}}}r.children=s}return e(r,o,a)}}const r1=["root","blockquote","listItem"],hs=Le("remarkHTMLTransformer",()=>()=>t=>{n1(t,(e,n,r)=>t1(e)?(r&&r1.includes(r.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});y(hs.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});y(hs.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const ms=Le("remarkMarker",()=>()=>(t,e)=>{const n=r=>e.value.charAt(r.position.start.offset);$n(t,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=n(r)})});y(ms.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});y(ms.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const Id=G(()=>{let t=!1;const e=new X("MILKDOWN_INLINE_NODES_CURSOR"),n=new Y({key:e,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;const o=r.selection.$from,a=o.nodeBefore,s=o.nodeAfter;return!!(a&&s&&a.isInline&&!a.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(r,o)=>t?(t=!1,requestAnimationFrame(()=>{if(n.getState(r.state)){const s=r.state.selection.from;o.preventDefault(),r.dispatch(r.state.tr.insertText(o.data||"",s))}}),!0):!1,compositionstart:r=>(n.getState(r.state)&&(t=!0),!1),beforeinput:(r,o)=>{if(n.getState(r.state)&&o instanceof InputEvent&&o.data&&!t){const s=r.state.selection.from;return o.preventDefault(),r.dispatch(r.state.tr.insertText(o.data||"",s)),!0}return!1}},decorations(r){if(n.getState(r)){const s=r.selection.$from.pos,i=document.createElement("span"),l=qo.widget(s,i,{side:-1}),c=document.createElement("span"),d=qo.widget(s,c);return setTimeout(()=>{i.contentEditable="true",c.contentEditable="true"}),Vo.create(r.doc,[l,d])}return Vo.empty}}});return n});y(Id,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Nd=G(t=>new Y({key:new X("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,n,r)=>{if(!e.length)return;const[o]=e;if(!o)return;const[a]=o.steps;if(o.getMeta("hardbreak")){if(!(a instanceof Qu))return;const{from:l}=a;return r.tr.setNodeMarkup(l,st.type(t),void 0,[])}if(a instanceof ep){let l=r.tr;const{from:c,to:d}=a;return r.doc.nodesBetween(c,d,(u,p)=>{u.type===st.type(t)&&(l=l.setNodeMarkup(p,st.type(t),void 0,[]))}),l}}}));y(Nd,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const gs=A(["table","code_block"],"hardbreakFilterNodes");y(gs,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const xd=G(t=>{const e=t.get(gs.key);return new Y({key:new X("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(n,r)=>{const o=n.getMeta("hardbreak"),[a]=n.steps;if(o&&a){const{from:s}=a,i=r.doc.resolve(s);let l=i.depth,c=!0;for(;l>0;)e.includes(i.node(l).type.name)&&(c=!1),l--;return c}return!0}})});y(xd,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const Sd=G(t=>{const e=new X("MILKDOWN_HEADING_ID"),n=r=>{if(r.composing)return;const o=t.get(lo.key),a=r.state.tr.setMeta("addToHistory",!1);let s=!1;const i={};r.state.doc.descendants((l,c)=>{if(l.type===de.type(t)){if(l.textContent.trim().length===0)return;const d=l.attrs;let u=o(l);i[u]?(i[u]+=1,u+=`-#${i[u]}`):i[u]=1,d.id!==u&&(s=!0,a.setMeta(e,!0).setNodeMarkup(c,void 0,{...d,id:u}))}}),s&&r.dispatch(a)};return new Y({key:e,view:r=>(n(r),{update:(o,a)=>{o.state.doc.eq(a.doc)||n(o)}})})});y(Sd,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const Ld=G(t=>{const e=(n,r,o)=>{if(!o.selection||n.some(u=>u.getMeta("addToHistory")===!1||!u.isGeneric))return null;const a=ht.type(t),s=pt.type(t),i=be.type(t),l=(u,p)=>{let h=!1;const k=`${p+1}.`;return u.label!==k&&(u.label=k,h=!0),h};let c=o.tr,d=!1;return o.doc.descendants((u,p,h,k)=>{if(u.type===s){const g=u.maybeChild(0);g?.type===i&&g.attrs.listType==="ordered"&&(d=!0,c.setNodeMarkup(p,a,{spread:"true"}),u.descendants((m,w,v,C)=>{if(m.type===i){const b={...m.attrs};l(b,C)&&(c=c.setNodeMarkup(w,void 0,b))}return!1}))}else if(u.type===i&&h?.type===a){const g={...u.attrs};let m=!1;g.listType!=="ordered"&&(g.listType="ordered",m=!0),h?.maybeChild(0)&&(m=l(g,k)),m&&(c=c.setNodeMarkup(p,void 0,g),d=!0)}}),d?c.setMeta("addToHistory",!1):null};return new Y({key:new X("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});y(Ld,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const o1=[Nd,gs,xd,Id,ds,ps,us,hs,ms,io,Sd,Ld].flat(),a1=[Uh,Yh,Xh,Jh,Qh,o1].flat();function s1(t){const e=A({},`${t}_SLASH_SPEC`),n=G(o=>{const a=o.get(e.key);return new Y({key:new X(`${t}_SLASH`),...a})}),r=[e,n];return r.key=e.key,r.pluginKey=n.key,e.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${t}`},n.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${t}`},r}class i1{constructor(e){this.#t=!1,this.onShow=()=>{},this.onHide=()=>{},this.#d=(n,r)=>{const{state:o,composing:a}=n,{selection:s,doc:i}=o,{ranges:l}=s,c=Math.min(...l.map(h=>h.$from.pos)),d=Math.max(...l.map(h=>h.$to.pos)),u=r&&r.doc.eq(i)&&r.selection.eq(s);if(this.#t||((this.#n??n.dom.parentElement??document.body).appendChild(this.element),this.#t=!0),a||u)return;if(!this.#a(n,r)){this.hide();return}Ne({getBoundingClientRect:()=>Qr(n,c,d)},this.element,{placement:"bottom-start",middleware:[ka(),lt(this.#l),...this.#e],...this.#r}).then(({x:h,y:k})=>{Object.assign(this.element.style,{left:`${h}px`,top:`${k}px`})}).catch(console.error),this.show()},this.update=(n,r)=>{this.#s(n,r)},this.getContent=(n,r=o=>o.type.name==="paragraph")=>{const{selection:o}=n.state,{empty:a,$from:s}=o,i=n.state.selection instanceof W;if(typeof document>"u")return;const l=this.element.contains(document.activeElement),c=!n.hasFocus()&&!l,d=!n.editable,p=!_h(r)(n.state.selection);if(!(c||d||!a||!i||p))return s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,"")},this.destroy=()=>{this.#s.cancel()},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=e.content,this.#i=e.debounce??200,this.#a=e.shouldShow??this.#c,this.#o=e.trigger??"/",this.#l=e.offset,this.#e=e.middleware??[],this.#r=e.floatingUIOptions??{},this.#n=e.root,this.#s=wa(this.#d,this.#i)}#t;#e;#r;#n;#i;#o;#a;#s;#l;#d;#c(e){const n=this.getContent(e);if(!n)return!1;const r=n.at(-1);return r?Array.isArray(this.#o)?this.#o.includes(r):this.#o===r:!1}}function xt({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}xt.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};let l1=t=>crypto.getRandomValues(new Uint8Array(t)),c1=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,o=-~(1.6*r*e/t.length);return(a=e)=>{let s="";for(;;){let i=n(o),l=o|0;for(;l--;)if(s+=t[i[l]&r]||"",s.length>=a)return s}}},Pd=(t,e=21)=>c1(t,e|0,l1);var d1=Object.defineProperty,Wl=Object.getOwnPropertySymbols,u1=Object.prototype.hasOwnProperty,p1=Object.prototype.propertyIsEnumerable,Fl=(t,e,n)=>e in t?d1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,h1=(t,e)=>{for(var n in e||(e={}))u1.call(e,n)&&Fl(t,n,e[n]);if(Wl)for(var n of Wl(e))p1.call(e,n)&&Fl(t,n,e[n]);return t};function qn(t,e){return Object.assign(t,{meta:h1({package:"@milkdown/components"},e)}),t}const m1={imageIcon:"🌌",captionIcon:"💬",uploadButton:"Upload file",confirmButton:"Confirm ⏎",uploadPlaceholderText:"or paste the image link ...",captionPlaceholderText:"Image caption",onUpload:t=>Promise.resolve(URL.createObjectURL(t))},co=A(m1,"imageBlockConfigCtx");qn(co,{displayName:"Config<image-block>",group:"ImageBlock"});function g1(t){return $n(t,"paragraph",(e,n,r)=>{var o,a;if(((o=e.children)==null?void 0:o.length)!==1)return;const s=(a=e.children)==null?void 0:a[0];if(!s||s.type!=="image")return;const{url:i,alt:l,title:c}=s,d={type:"image-block",url:i,alt:l,title:c};r.children.splice(n,1,d)})}const fs=Le("remark-image-block",()=>()=>g1);qn(fs.plugin,{displayName:"Remark<remarkImageBlock>",group:"ImageBlock"});qn(fs.options,{displayName:"RemarkConfig<remarkImageBlock>",group:"ImageBlock"});var f1=Object.defineProperty,Kl=Object.getOwnPropertySymbols,v1=Object.prototype.hasOwnProperty,y1=Object.prototype.propertyIsEnumerable,Zl=(t,e,n)=>e in t?f1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,w1=(t,e)=>{for(var n in e||(e={}))v1.call(e,n)&&Zl(t,n,e[n]);if(Kl)for(var n of Kl(e))y1.call(e,n)&&Zl(t,n,e[n]);return t};const ea="image-block",uo=F("image-block",()=>({inline:!1,group:"block",selectable:!0,draggable:!0,isolating:!0,marks:"",atom:!0,priority:100,attrs:{src:{default:"",validate:"string"},caption:{default:"",validate:"string"},ratio:{default:1,validate:"number"}},parseDOM:[{tag:`img[data-type="${ea}"]`,getAttrs:t=>{var e;if(!(t instanceof HTMLElement))throw we(t);return{src:t.getAttribute("src")||"",caption:t.getAttribute("caption")||"",ratio:Number((e=t.getAttribute("ratio"))!=null?e:1)}}}],toDOM:t=>["img",w1({"data-type":ea},t.attrs)],parseMarkdown:{match:({type:t})=>t==="image-block",runner:(t,e,n)=>{const r=e.url,o=e.title;let a=Number(e.alt||1);(Number.isNaN(a)||a===0)&&(a=1),t.addNode(n,{src:r,caption:o,ratio:a})}},toMarkdown:{match:t=>t.type.name==="image-block",runner:(t,e)=>{t.openNode("paragraph"),t.addNode("image",void 0,void 0,{title:e.attrs.caption,url:e.attrs.src,alt:`${Number.parseFloat(e.attrs.ratio).toFixed(2)}`}),t.closeNode()}}}));qn(uo.node,{displayName:"NodeSchema<image-block>",group:"ImageBlock"});function _n({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}_n.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};const k1=Pd("abcdefg",8),C1=J({props:{src:{type:Object,required:!0},selected:{type:Object,required:!0},readonly:{type:Object,required:!0},setLink:{type:Function,required:!0},imageIcon:{type:String,required:!1},uploadButton:{type:String,required:!1},confirmButton:{type:String,required:!1},uploadPlaceholderText:{type:String,required:!1},onUpload:{type:Function,required:!0}},setup({readonly:t,src:e,setLink:n,onUpload:r,imageIcon:o,uploadButton:a,confirmButton:s,uploadPlaceholderText:i,className:l}){var c,d;const u=I(!1),p=I(),h=I((c=e.value)!=null?c:""),k=I(k1()),g=I(((d=e.value)==null?void 0:d.length)!==0),m=b=>{const S=b.target.value;g.value=S.length!==0,h.value=S},w=b=>{var _,S;b.key==="Enter"&&n((S=(_=p.value)==null?void 0:_.value)!=null?S:"")},v=()=>{var b,_;n((_=(b=p.value)==null?void 0:b.value)!=null?_:"")},C=b=>{var _;const S=(_=b.target.files)==null?void 0:_[0];S&&r(S).then($=>{$&&(n($),g.value=!0)}).catch($=>{console.error("An error occurred while uploading image"),console.error($)})};return()=>f("div",{class:Q("image-edit",l)},f(_n,{icon:o,class:"image-icon"}),f("div",{class:Q("link-importer",u.value&&"focus")},f("input",{ref:p,draggable:"true",onDragstart:b=>{b.preventDefault(),b.stopPropagation()},disabled:t.value,class:"link-input-area",value:h.value,onInput:m,onKeydown:w,onFocus:()=>u.value=!0,onBlur:()=>u.value=!1}),!g.value&&f("div",{class:"placeholder"},f("input",{disabled:t.value,class:"hidden",id:k.value,type:"file",accept:"image/*",onChange:C}),f("label",{class:"uploader",for:k.value},f(_n,{icon:a})),f("span",{class:"text",onClick:()=>{var b;return(b=p.value)==null?void 0:b.focus()}},i))),h.value&&f("div",{class:"confirm",onClick:()=>v()},f(_n,{icon:s})))}}),b1=J({props:{src:{type:Object,required:!0},caption:{type:Object,required:!0},ratio:{type:Object,required:!0},selected:{type:Object,required:!0},readonly:{type:Object,required:!0},setAttr:{type:Function,required:!0},config:{type:Object,required:!0}},setup({src:t,caption:e,ratio:n,readonly:r,setAttr:o,config:a}){var s;const i=I(),l=I(),c=I(!!((s=e.value)!=null&&s.length)),d=I(0),u=()=>{var v;const C=i.value;if(!C)return;const b=C.closest(".milkdown-image-block");if(!b)return;const _=b.getBoundingClientRect().width;if(!_)return;const S=C.height,$=C.width,K=$<_?S:_*(S/$),ne=(K*((v=n.value)!=null?v:1)).toFixed(2);C.dataset.origin=K.toFixed(2),C.dataset.height=ne,C.style.height=`${ne}px`},p=v=>{v.preventDefault(),v.stopPropagation(),!r.value&&(c.value=!c.value)},h=v=>{const b=v.target.value;d.value&&window.clearTimeout(d.value),d.value=window.setTimeout(()=>{o("caption",b)},1e3)},k=v=>{const b=v.target.value;d.value&&(window.clearTimeout(d.value),d.value=0),o("caption",b)},g=v=>{v.preventDefault();const C=i.value;if(!C)return;const b=C.getBoundingClientRect().top,_=v.clientY-b,S=Number(_<100?100:_).toFixed(2);C.dataset.height=S,C.style.height=`${S}px`},m=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",m);const v=i.value;if(!v)return;const C=Number(v.dataset.origin),b=Number(v.dataset.height),_=Number.parseFloat(Number(b/C).toFixed(2));Number.isNaN(_)||o("ratio",_)},w=v=>{r.value||(v.preventDefault(),v.stopPropagation(),window.addEventListener("pointermove",g),window.addEventListener("pointerup",m))};return()=>f(ct,null,f("div",{class:"image-wrapper"},f("div",{class:"operation"},f("div",{class:"operation-item",onPointerdown:p},f(_n,{icon:a.captionIcon}))),f("img",{ref:i,"data-type":ea,onLoad:u,src:t.value,alt:e.value}),f("div",{ref:l,class:"image-resize-handle",onPointerdown:w})),c.value&&f("input",{draggable:"true",onDragstart:v=>{v.preventDefault(),v.stopPropagation()},class:"caption-input",placeholder:a?.captionPlaceholderText,onInput:h,onBlur:k,value:e.value}))}});var _1=Object.defineProperty,Gl=Object.getOwnPropertySymbols,M1=Object.prototype.hasOwnProperty,I1=Object.prototype.propertyIsEnumerable,zl=(t,e,n)=>e in t?_1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,N1=(t,e)=>{for(var n in e||(e={}))M1.call(e,n)&&zl(t,n,e[n]);if(Gl)for(var n of Gl(e))I1.call(e,n)&&zl(t,n,e[n]);return t};const x1=J({props:{src:{type:Object,required:!0},caption:{type:Object,required:!0},ratio:{type:Object,required:!0},selected:{type:Object,required:!0},readonly:{type:Object,required:!0},setAttr:{type:Function,required:!0},config:{type:Object,required:!0}},setup(t){const{src:e}=t;return()=>{var n;return(n=e.value)!=null&&n.length?f(b1,N1({},t)):f(C1,{src:t.src,selected:t.selected,readonly:t.readonly,setLink:r=>t.setAttr("src",r),imageIcon:t.config.imageIcon,uploadButton:t.config.uploadButton,confirmButton:t.config.confirmButton,uploadPlaceholderText:t.config.uploadPlaceholderText,onUpload:t.config.onUpload})}}}),Td=Bn(uo.node,t=>(e,n,r)=>{const o=I(e.attrs.src),a=I(e.attrs.caption),s=I(e.attrs.ratio),i=I(!1),l=I(!n.editable),c=(m,w)=>{if(!n.editable)return;const v=r();v!=null&&n.dispatch(n.state.tr.setNodeAttribute(v,m,m==="src"?he.sanitize(w):w))},d=t.get(co.key),u=ye(x1,{src:o,caption:a,ratio:s,selected:i,readonly:l,setAttr:c,config:d}),p=document.createElement("div");p.className="milkdown-image-block";const h=Tt(()=>{i.value?p.classList.add("selected"):p.classList.remove("selected")}),k=d.proxyDomURL,g=m=>{if(!k)o.value=m.attrs.src;else{const w=k(m.attrs.src);typeof w=="string"?o.value=w:w.then(v=>{o.value=v}).catch(console.error)}s.value=m.attrs.ratio,a.value=m.attrs.caption,l.value=!n.editable};return g(e),u.mount(p),{dom:p,update:m=>m.type!==e.type?!1:(g(m),!0),stopEvent:m=>m.target instanceof HTMLInputElement,selectNode:()=>{i.value=!0},deselectNode:()=>{i.value=!1},destroy:()=>{h(),u.unmount(),p.remove()}}});qn(Td,{displayName:"NodeView<image-block>",group:"ImageBlock"});const S1=[fs,uo,Td,co].flat();function L(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-gfm",...e}}),t}const vs=An("strike_through");L(vs,{displayName:"Attr<strikethrough>",group:"Strikethrough"});const Et=Ot("strike_through",t=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",t.get(vs.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,n,r)=>{e.openMark(r),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,n)=>{e.withMark(n,"delete")}}}));L(Et.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});L(Et.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});const po=P("ToggleStrikeThrough",t=>()=>Kr(Et.type(t)));L(po,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});const Od=ee(t=>En(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)"),Et.type(t)));L(Od,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});const ys=ae("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:t=>{const e=t.get(M);return()=>e.call(po.key)}}});L(ys.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});L(ys.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});const Vn=sp({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:t=>t.style.textAlign||"left",setDOMAttr:(t,e)=>{e.style=`text-align: ${t||"left"}`}}}}),Ge=F("table",()=>({...Vn.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="table",runner:(t,e,n)=>{const r=e.align,o=e.children.map((a,s)=>({...a,align:r,isHeader:s===0}));t.openNode(n),t.next(o),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table",runner:(t,e)=>{const n=e.content.firstChild?.content;if(!n)return;const r=[];n.forEach(o=>{r.push(o.attrs.alignment)}),t.openNode("table",void 0,{align:r}),t.next(e.content),t.closeNode()}}}));L(Ge.node,{displayName:"NodeSchema<table>",group:"Table"});L(Ge.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});const ho=F("table_header_row",()=>({...Vn.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:t=>t instanceof HTMLElement&&t.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:t=>!!(t.type==="tableRow"&&t.isHeader),runner:(t,e,n)=>{const r=e.align,o=e.children.map((a,s)=>({...a,align:r[s],isHeader:e.isHeader}));t.openNode(n),t.next(o),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_header_row",runner:(t,e)=>{t.openNode("tableRow",void 0,{isHeader:!0}),t.next(e.content),t.closeNode()}}}));L(ho.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});L(ho.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});const jn=F("table_row",()=>({...Vn.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:t=>t.type==="tableRow",runner:(t,e,n)=>{const r=e.align,o=e.children.map((a,s)=>({...a,align:r[s]}));t.openNode(n),t.next(o),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_row",runner:(t,e)=>{e.content.size!==0&&(t.openNode("tableRow"),t.next(e.content),t.closeNode())}}}));L(jn.node,{displayName:"NodeSchema<tableRow>",group:"Table"});L(jn.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});const Wn=F("table_cell",()=>({...Vn.table_cell,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!t.isHeader,runner:(t,e,n)=>{const r=e.align;t.openNode(n,{alignment:r}).openNode(t.schema.nodes.paragraph).next(e.children).closeNode().closeNode()}},toMarkdown:{match:t=>t.type.name==="table_cell",runner:(t,e)=>{t.openNode("tableCell").next(e.content).closeNode()}}}));L(Wn.node,{displayName:"NodeSchema<tableCell>",group:"Table"});L(Wn.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});const Fn=F("table_header",()=>({...Vn.table_header,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!!t.isHeader,runner:(t,e,n)=>{const r=e.align;t.openNode(n,{alignment:r}),t.openNode(t.schema.nodes.paragraph),t.next(e.children),t.closeNode(),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_header",runner:(t,e)=>{t.openNode("tableCell"),t.next(e.content),t.closeNode()}}}));L(Fn.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});L(Fn.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function ws(t,e=3,n=3){const r=Array(n).fill(0).map(()=>Wn.type(t).createAndFill()),o=Array(n).fill(0).map(()=>Fn.type(t).createAndFill()),a=Array(e).fill(0).map((s,i)=>i===0?ho.type(t).create(null,o):jn.type(t).create(null,r));return Ge.type(t).create(null,a)}function Hd(t){return(e,n)=>r=>{n=n??r.selection.from;const o=r.doc.resolve(n),a=Fc(l=>l.type.name==="table")(o),s=a?{node:a.node,from:a.start}:void 0,i=t==="row";if(s){const l=Sc.get(s.node);if(e>=0&&e<(i?l.height:l.width)){const c=l.positionAt(i?e:l.height-1,i?l.width-1:e,s.node),d=r.doc.resolve(s.from+c),u=i?Nt.rowSelection:Nt.colSelection,p=l.positionAt(i?e:0,i?0:e,s.node),h=r.doc.resolve(s.from+p);return Wc(r.setSelection(u(d,h)))}}return r}}const L1=Hd("row"),P1=Hd("col");function Rd(t,e,{map:n,tableStart:r,table:o},a){const s=Array(a).fill(0).reduce((l,c,d)=>l+o.child(d).nodeSize,r),i=Array(n.width).fill(0).map((l,c)=>{const d=o.nodeAt(n.map[c]);return Wn.type(t).createAndFill({alignment:d?.attrs.alignment})});return e.insert(s,jn.type(t).create(null,i)),e}function T1(t){const e=Lc(t.$from);if(!e)return;const n=Sc.get(e.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(o=>{const a=e.node.nodeAt(o),s=o+e.start;return{pos:s,start:s+1,node:a}})}function O1(t){const e=T1(t.selection);if(e&&e[0]){const n=t.doc.resolve(e[0].pos),r=e[e.length-1];if(r){const o=t.doc.resolve(r.pos);return Wc(t.setSelection(new Nt(o,n)))}}return t}const ks=P("GoToPrevTableCell",()=>()=>Nc(-1));L(ks,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});const Cs=P("GoToNextTableCell",()=>()=>Nc(1));L(Cs,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});const bs=P("ExitTable",t=>()=>(e,n)=>{if(!fa(e))return!1;const{$head:r}=e.selection,o=Ch(r,Ge.type(t));if(!o)return!1;const{to:a}=o,s=e.tr.replaceWith(a,a,Ce.type(t).createAndFill());return s.setSelection(Zr.near(s.doc.resolve(a),1)).scrollIntoView(),n?.(s),!0});L(bs,{displayName:"Command<breakTableCommand>",group:"Table"});const $d=P("InsertTable",t=>({row:e,col:n}={})=>(r,o)=>{const{selection:a,tr:s}=r,{from:i}=a,l=ws(t,e,n),c=s.replaceSelectionWith(l),d=Zr.findFrom(c.doc.resolve(i),1,!0);return d&&c.setSelection(d),o?.(c),!0});L($d,{displayName:"Command<insertTableCommand>",group:"Table"});const _s=P("MoveRow",()=>({from:t,to:e,pos:n}={})=>cp({from:t??0,to:e??0,pos:n}));L(_s,{displayName:"Command<moveRowCommand>",group:"Table"});const Ms=P("MoveCol",()=>({from:t,to:e,pos:n}={})=>dp({from:t??0,to:e??0,pos:n}));L(Ms,{displayName:"Command<moveColCommand>",group:"Table"});const nt=P("SelectRow",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!n?.(L1(t.index,t.pos)(r))});L(nt,{displayName:"Command<selectRowCommand>",group:"Table"});const rt=P("SelectCol",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!n?.(P1(t.index,t.pos)(r))});L(rt,{displayName:"Command<selectColCommand>",group:"Table"});const Ed=P("SelectTable",()=>()=>(t,e)=>{const{tr:n}=t;return!!e?.(O1(n))});L(Ed,{displayName:"Command<selectTableCommand>",group:"Table"});const Is=P("DeleteSelectedCells",()=>()=>(t,e)=>{const{selection:n}=t;if(!(n instanceof Nt))return!1;const r=n.isRowSelection(),o=n.isColSelection();return r&&o?up(t,e):o?pp(t,e):hp(t,e)});L(Is,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});const Ns=P("AddColBefore",()=>()=>mp);L(Ns,{displayName:"Command<addColBeforeCommand>",group:"Table"});const xs=P("AddColAfter",()=>()=>gp);L(xs,{displayName:"Command<addColAfterCommand>",group:"Table"});const Ss=P("AddRowBefore",t=>()=>(e,n)=>{if(!fa(e))return!1;if(n){const r=xc(e);n(Rd(t,e.tr,r,r.top))}return!0});L(Ss,{displayName:"Command<addRowBeforeCommand>",group:"Table"});const Ls=P("AddRowAfter",t=>()=>(e,n)=>{if(!fa(e))return!1;if(n){const r=xc(e);n(Rd(t,e.tr,r,r.bottom))}return!0});L(Ls,{displayName:"Command<addRowAfterCommand>",group:"Table"});const Ps=P("SetAlign",()=>(t="left")=>fp("alignment",t));L(Ps,{displayName:"Command<setAlignCommand>",group:"Table"});const Bd=ee(t=>new Pt(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,n,r,o)=>{const a=e.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),Ge.type(t)))return null;const s=Math.max(Number(n.groups?.row??0),2),i=ws(t,s,Number(n.groups?.col)),l=e.tr.replaceRangeWith(r,o,i);return l.setSelection(W.create(l.doc,r+3)).scrollIntoView()}));L(Bd,{displayName:"InputRule<insertTableInputRule>",group:"Table"});const Ad=$h(t=>({run:(e,n,r)=>{if(r)return e;let o=e.content;return e.content.forEach((a,s,i)=>{if(a?.type!==Ge.type(t))return;const l=a.childCount,c=a.lastChild?.childCount??0;if(l===0||c===0){o=o.replaceChild(i,Ce.type(t).create());return}const d=a.firstChild;if(!(c>0&&d&&d.childCount===0))return;const p=Array(c).fill(0).map(()=>Fn.type(t).createAndFill()),h=new tr(nr.from(p),0,0),k=d.replace(0,0,h),g=a.replace(0,d.nodeSize,new tr(nr.from(k),0,0));o=o.replaceChild(i,g)}),new tr(nr.from(o),e.openStart,e.openEnd)}}));L(Ad,{displayName:"PasteRule<table>",group:"Table"});const Ts=ae("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:t=>{const e=t.get(M);return()=>e.call(Cs.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:t=>{const e=t.get(M);return()=>e.call(ks.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:t=>{const e=t.get(M);return()=>e.call(bs.key)}}});L(Ts.ctx,{displayName:"KeymapCtx<table>",group:"Table"});L(Ts.shortcuts,{displayName:"Keymap<table>",group:"Table"});const Eo="footnote_definition",Ul="footnoteDefinition",Os=F("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${Eo}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw we(t);return{label:t.dataset.label}},contentElement:"dd"}],toDOM:t=>{const e=t.attrs.label;return["dl",{"data-label":e,"data-type":Eo},["dt",e],["dd",0]]},parseMarkdown:{match:({type:t})=>t===Ul,runner:(t,e,n)=>{t.openNode(n,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name===Eo,runner:(t,e)=>{t.openNode(Ul,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));L(Os.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});L(Os.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});const Bo="footnote_reference",Hs=F("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${Bo}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw we(t);return{label:t.dataset.label}}}],toDOM:t=>{const e=t.attrs.label;return["sup",{"data-label":e,"data-type":Bo},e]},parseMarkdown:{match:({type:t})=>t==="footnoteReference",runner:(t,e,n)=>{t.addNode(n,{label:e.label})}},toMarkdown:{match:t=>t.type.name===Bo,runner:(t,e)=>{t.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));L(Hs.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});L(Hs.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});const Rs=be.extendSchema(t=>e=>{const n=t(e);return{...n,attrs:{...n.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:r=>{if(!(r instanceof HTMLElement))throw we(r);return{label:r.dataset.label,listType:r.dataset.listType,spread:r.dataset.spread,checked:r.dataset.checked?r.dataset.checked==="true":null}}},...n?.parseDOM||[]],toDOM:r=>n.toDOM&&r.attrs.checked==null?n.toDOM(r):["li",{"data-item-type":"task","data-label":r.attrs.label,"data-list-type":r.attrs.listType,"data-spread":r.attrs.spread,"data-checked":r.attrs.checked},0],parseMarkdown:{match:({type:r})=>r==="listItem",runner:(r,o,a)=>{if(o.checked==null){n.parseMarkdown.runner(r,o,a);return}const s=o.label!=null?`${o.label}.`:"•",i=o.checked!=null?!!o.checked:null,l=o.label!=null?"ordered":"bullet",c=o.spread!=null?`${o.spread}`:"true";r.openNode(a,{label:s,listType:l,spread:c,checked:i}),r.next(o.children),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="list_item",runner:(r,o)=>{if(o.attrs.checked==null){n.toMarkdown.runner(r,o);return}const a=o.attrs.label,s=o.attrs.listType,i=o.attrs.spread==="true",l=o.attrs.checked;r.openNode("listItem",void 0,{label:a,listType:s,spread:i,checked:l}),r.next(o.content),r.closeNode()}}}});L(Rs.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});L(Rs.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});const Dd=ee(()=>new Pt(/^\[(?<checked>\s|x)\]\s$/,(t,e,n,r)=>{const o=t.doc.resolve(n);let a=0,s=o.node(a);for(;s&&s.type.name!=="list_item";)a--,s=o.node(a);if(!s||s.attrs.checked!=null)return null;const i=e.groups?.checked==="x",l=o.before(a),c=t.tr;return c.deleteRange(n,r).setNodeMarkup(l,void 0,{...s.attrs,checked:i}),c}));L(Dd,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});const H1=[ys,Ts].flat(),R1=[Bd,Dd],$1=[Od],E1=[Ad],qd=G(()=>ip);L(qd,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});const B1=G(()=>vp({}));L(B1,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});const Vd=G(()=>lp({allowTableNodeSelection:!0}));L(Vd,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});const $s=Le("remarkGFM",()=>Rp);L($s.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});L($s.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});const A1=new X("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function D1(t,e){let n=0;return e.forEach((r,o,a)=>{r===t&&(n=a)}),n}const jd=G(()=>new Y({key:A1,appendTransaction:(t,e,n)=>{let r;const o=(a,s)=>{if(r||(r=n.tr),a.type.name!=="table_cell")return;const i=n.doc.resolve(s),l=i.node(i.depth),d=i.node(i.depth-1).firstChild;if(!d)return;const u=D1(a,l),p=d.maybeChild(u);if(!p)return;const h=p.attrs.alignment,k=a.attrs.alignment;h!==k&&r.setNodeMarkup(s,void 0,{...a.attrs,alignment:h})};return e.doc!==n.doc&&n.doc.descendants(o),r}}));L(jd,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});const q1=[jd,qd,$s,Vd].flat(),V1=[Rs,Ge,ho,jn,Fn,Wn,Os,Hs,vs,Et].flat(),j1=[Cs,ks,bs,$d,_s,Ms,nt,rt,Ed,Is,Ss,Ls,Ns,xs,Ps,po],W1=[V1,R1,E1,$1,H1,j1,q1].flat();var F1=Object.defineProperty,Yl=Object.getOwnPropertySymbols,K1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable,Xl=(t,e,n)=>e in t?F1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,G1=(t,e)=>{for(var n in e||(e={}))K1.call(e,n)&&Xl(t,n,e[n]);if(Yl)for(var n of Yl(e))Z1.call(e,n)&&Xl(t,n,e[n]);return t};function Wd(t,e){return Object.assign(t,{meta:G1({package:"@milkdown/components"},e)}),t}const z1={extensions:[],languages:[],expandIcon:"⬇",searchIcon:"🔍",clearSearchIcon:"⌫",searchPlaceholder:"Search language",noResultText:"No result",copyText:"Copy",copyIcon:"📋",onCopy:()=>{},renderLanguage:t=>t,renderPreview:()=>null,previewToggleButton:t=>t?"Edit":"Hide",previewLabel:"Preview",previewLoading:"Loading..."},Kn=A(z1,"codeBlockConfigCtx");Wd(Kn,{displayName:"Config<code-block>",group:"CodeBlock"});class U1{constructor(e){this.languages=e,this.map={},e.forEach(n=>{n.alias.forEach(r=>{this.map[r]=n})})}getAll(){return this.languages.map(e=>({name:e.name,alias:e.alias}))}load(e){const r=this.map[e.toLowerCase()];return r?r.support?Promise.resolve(r.support):r.load():Promise.resolve(void 0)}}function It({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}It.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};var Y1=(t,e,n)=>new Promise((r,o)=>{var a=l=>{try{i(n.next(l))}catch(c){o(c)}},s=l=>{try{i(n.throw(l))}catch(c){o(c)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(a,s);i((n=n.apply(t,e)).next())});function X1(t){return Y1(this,null,function*(){try{return navigator.clipboard.writeText(t)}catch{const n=document.createElement("textarea"),r=document.activeElement;n.value=t,n.setAttribute("readonly",""),n.style.contain="strict",n.style.position="absolute",n.style.left="-9999px",n.style.fontSize="12pt";const o=document.getSelection(),a=o?o.rangeCount>0&&o.getRangeAt(0):null;document.body.appendChild(n),n.select(),n.selectionStart=0,n.selectionEnd=t.length,document.execCommand("copy"),document.body.removeChild(n),a&&(o.removeAllRanges(),o.addRange(a)),r&&r.focus()}})}const J1=J({props:{copyText:{type:String,required:!0},copyIcon:{type:String,required:!0},onCopy:{type:Function,required:!0},text:{type:String,required:!0}},setup(t){const e=()=>{X1(t.text).then(()=>t.onCopy(t.text)).catch(console.error)};return()=>f(ct,null,f("button",{type:"button",class:"copy-button",onClick:e},f(It,{icon:t.copyIcon}),t.copyText))}}),Q1=J({props:{language:{type:Object,required:!0},getReadOnly:{type:Function,required:!0},config:{type:Object,required:!0},getAllLanguages:{type:Function,required:!0},setLanguage:{type:Function,required:!0}},setup({language:t,config:e,setLanguage:n,getAllLanguages:r,getReadOnly:o}){const a=I(),s=I(!1),i=I(),l=I(),c=I("");zr([s,a,l],()=>{c.value="";const g=a.value,m=l.value;!g||!m||Ne(g,m,{placement:"bottom-start"}).then(({x:w,y:v})=>{Object.assign(m.style,{left:`${w}px`,top:`${v}px`})}).catch(console.error)});const d=g=>{if(g.preventDefault(),g.stopPropagation(),o())return;const m=!s.value;s.value=m,m&&setTimeout(()=>{var w;return(w=i.value)==null?void 0:w.focus()},0)},u=g=>{const m=g.target;c.value=m.value},p=g=>{g.key==="Escape"&&(c.value="")},h=xn(()=>{var g;if(!s.value)return[];const m=(g=r())!=null?g:[],w=m.find(C=>C.name.toLowerCase()===t.value.toLowerCase()),v=m.filter(C=>{const b=c.value.toLowerCase();return(C.name.toLowerCase().includes(b)||C.alias.some(_=>_.toLowerCase().includes(b)))&&C!==w});return v.length===0?[]:w?[w,...v]:v}),k=g=>{const m=g.target;if(a.value&&a.value.contains(m))return;const w=l.value,v=a.value;!v||!w||v.dataset.expanded==="true"&&(w.contains(m)||(s.value=!1))};return Gr(()=>{window.addEventListener("click",k)}),ya(()=>{window.removeEventListener("click",k)}),()=>f(ct,null,f("button",{type:"button",ref:a,class:"language-button",onClick:d,"data-expanded":String(s.value)},t.value||"Text",f("div",{class:"expand-icon"},f(It,{icon:e.expandIcon}))),f("div",{ref:l,class:"language-picker"},s.value?f("div",{class:"list-wrapper"},f("div",{class:"search-box"},f("div",{class:"search-icon"},f(It,{icon:e.searchIcon})),f("input",{ref:i,class:"search-input",placeholder:e.searchPlaceholder,value:c.value,onInput:u,onKeydown:p}),f("div",{class:Q("clear-icon",c.value.length===0&&"hidden"),onMousedown:g=>{g.preventDefault(),c.value=""}},f(It,{icon:e.clearSearchIcon}))),f("ul",{class:"language-list",role:"listbox",onKeydown:g=>{if(g.key==="Enter"){const m=document.activeElement;m instanceof HTMLElement&&m.dataset.language&&n(m.dataset.language)}}},h.value.length?h.value.map(g=>f("li",{role:"listitem",tabindex:"0",class:"language-list-item","aria-selected":g.name.toLowerCase()===t.value.toLowerCase(),"data-language":g.name,onClick:()=>{n(g.name),s.value=!1}},e.renderLanguage(g.name,g.name.toLowerCase()===t.value.toLowerCase()))):f("li",{class:"language-list-item no-result"},e.noResultText))):null))}}),em=J({props:{text:{type:Object,required:!0},language:{type:Object,required:!0},config:{type:Object,required:!0},previewOnlyMode:{type:Object,required:!0},preview:{type:Object,required:!0}},setup(t){const{previewOnlyMode:e,config:n,preview:r}=t,o=I();return Tt(()=>{const a=o.value;if(!a)return;for(;a.firstChild;)a.removeChild(a.firstChild);const s=r.value;(typeof s=="string"||s instanceof Element)&&(a.innerHTML=he.sanitize(s))}),()=>r.value?f("div",{class:"preview-panel"},!e.value&&f(ct,null,f("div",{class:"preview-divider"}),f("div",{class:"preview-label"},n.previewLabel)),f("div",{ref:o,class:"preview"})):null}}),tm=J({props:{text:{type:Object,required:!0},selected:{type:Object,required:!0},getReadOnly:{type:Function,required:!0},codemirror:{type:Object,required:!0},language:{type:Object,required:!0},getAllLanguages:{type:Function,required:!0},setLanguage:{type:Function,required:!0},config:{type:Object,required:!0}},setup(t){var e;const n=(e=t.config.previewOnlyByDefault)!=null?e:t.getReadOnly(),r=I(n),o=I(),a=I(null);Gr(()=>{for(var i;(i=o.value)!=null&&i.firstChild;)o.value.removeChild(o.value.firstChild);o.value&&o.value.appendChild(t.codemirror.dom)}),zr(()=>[t.text.value,t.language.value],()=>{const i=t.config.renderPreview(t.language.value,t.text.value,c=>a.value=c);i&&(a.value=i),i===void 0&&!a.value&&(a.value=he.sanitize(t.config.previewLoading)),i===null&&(a.value=null)},{immediate:!0});const s=()=>{};return()=>{var i;return f(ct,null,f("div",{class:"tools"},f(Q1,{language:t.language,config:t.config,setLanguage:t.setLanguage,getAllLanguages:t.getAllLanguages,getReadOnly:t.getReadOnly}),f("div",{class:"tools-button-group"},f(J1,{copyIcon:t.config.copyIcon,copyText:t.config.copyText,onCopy:(i=t.config.onCopy)!=null?i:s,text:t.text.value}),a.value?f("button",{class:"preview-toggle-button",onClick:()=>r.value=!r.value},f(It,{icon:t.config.previewToggleButton(r.value)})):null)),f("div",{ref:o,class:Q("codemirror-host",a.value&&r.value&&"hidden")}),f(em,{text:t.text,language:t.language,config:t.config,previewOnlyMode:r,preview:a}))}}});class nm{constructor(e,n,r,o,a){this.node=e,this.view=n,this.getPos=r,this.loader=o,this.config=a,this.selected=I(!1),this.language=I(""),this.text=I(""),this.updating=!1,this.languageName="",this.forwardUpdate=s=>{var i;if(this.updating||!this.cm.hasFocus)return;let l=((i=this.getPos())!=null?i:0)+1;const{main:c}=s.state.selection,d=l+c.from,u=l+c.to,p=this.view.state.selection;if(s.docChanged||p.from!==d||p.to!==u){const h=this.view.state.tr;s.changes.iterChanges((k,g,m,w,v)=>{v.length?h.replaceWith(l+k,l+g,this.view.state.schema.text(v.toString())):h.delete(l+k,l+g),l+=w-m-(g-k)}),h.setSelection(W.create(h.doc,d,u)),this.view.dispatch(h)}},this.createApp=()=>ye(tm,{text:this.text,selected:this.selected,codemirror:this.cm,language:this.language,getAllLanguages:this.getAllLanguages,getReadOnly:()=>!this.view.editable,setLanguage:this.setLanguage,config:this.config}),this.codeMirrorKeymap=()=>{const s=this.view;return[{key:"ArrowUp",run:()=>this.maybeEscape("line",-1)},{key:"ArrowLeft",run:()=>this.maybeEscape("char",-1)},{key:"ArrowDown",run:()=>this.maybeEscape("line",1)},{key:"ArrowRight",run:()=>this.maybeEscape("char",1)},{key:"Mod-Enter",run:()=>yp(s.state,s.dispatch)?(s.focus(),!0):!1},{key:"Mod-z",run:()=>va(s.state,s.dispatch)},{key:"Shift-Mod-z",run:()=>Nn(s.state,s.dispatch)},{key:"Mod-y",run:()=>Nn(s.state,s.dispatch)},{key:"Backspace",run:()=>{var i;const l=this.cm.state.selection.ranges;if(l.length>1)return!1;const c=l[0];if(c&&(!c.empty||c.anchor>0)||this.cm.state.doc.lines>=2)return!1;const d=this.view.state,u=(i=this.getPos())!=null?i:0,p=d.tr.replaceWith(u,u+this.node.nodeSize,d.schema.nodes.paragraph.createChecked({},this.node.content));return p.setSelection(W.near(p.doc.resolve(u))),this.view.dispatch(p),this.view.focus(),!0}}]},this.maybeEscape=(s,i)=>{var l;const{state:c}=this.cm;let d=c.selection.main;if(!d.empty||(s==="line"&&(d=c.doc.lineAt(d.head)),i<0?d.from>0:d.to<c.doc.length))return!1;const u=((l=this.getPos())!=null?l:0)+(i<0?0:this.node.nodeSize),p=W.near(this.view.state.doc.resolve(u),i),h=this.view.state.tr.setSelection(p).scrollIntoView();return this.view.dispatch(h),this.view.focus(),!0},this.setLanguage=s=>{var i;this.view.dispatch(this.view.state.tr.setNodeAttribute((i=this.getPos())!=null?i:0,"language",s))},this.getAllLanguages=()=>this.loader.getAll(),this.languageConf=new Hl,this.readOnlyConf=new Hl,this.cm=new Ol({doc:this.node.textContent,root:this.view.root,extensions:[this.readOnlyConf.of(Mo.readOnly.of(!this.view.editable)),Lp(),Pc.of(this.codeMirrorKeymap()),this.languageConf.of([]),Mo.changeFilter.of(()=>this.view.editable),...a.extensions,Ol.updateListener.of(this.forwardUpdate)]}),this.app=this.createApp(),this.dom=this.createDom(this.app),this.disposeSelectedWatcher=Tt(()=>{this.selected.value?this.dom.classList.add("selected"):this.dom.classList.remove("selected")}),this.updateLanguage()}createDom(e){const n=document.createElement("div");return n.className="milkdown-code-block",this.text.value=this.node.textContent,e.mount(n),n}updateLanguage(){const e=this.node.attrs.language;if(e===this.languageName)return;this.language.value=e,this.loader.load(e??"").then(r=>{r&&(this.cm.dispatch({effects:this.languageConf.reconfigure(r)}),this.languageName=e)}).catch(console.error)}setSelection(e,n){this.cm.dom.isConnected&&(this.cm.focus(),this.updating=!0,this.cm.dispatch({selection:{anchor:e,head:n}}),this.updating=!1)}update(e){if(e.type!==this.node.type)return!1;if(this.updating)return!0;this.node=e,this.text.value=e.textContent,this.updateLanguage(),this.view.editable===this.cm.state.readOnly&&this.cm.dispatch({effects:this.readOnlyConf.reconfigure(Mo.readOnly.of(!this.view.editable))});const n=rm(this.cm.state.doc.toString(),e.textContent);return n&&(this.updating=!0,this.cm.dispatch({changes:{from:n.from,to:n.to,insert:n.text},scrollIntoView:!0}),this.updating=!1),!0}selectNode(){this.selected.value=!0,this.cm.focus()}deselectNode(){this.selected.value=!1}stopEvent(){return!0}destroy(){this.app.unmount(),this.cm.destroy(),this.disposeSelectedWatcher()}}function rm(t,e){if(t===e)return null;let n=0,r=t.length,o=e.length;for(;n<r&&t.charCodeAt(n)===e.charCodeAt(n);)++n;for(;r>n&&o>n&&t.charCodeAt(r-1)===e.charCodeAt(o-1);)r--,o--;return{from:n,to:r,text:e.slice(n,o)}}const Fd=Bn(xe.node,t=>{const e=t.get(Kn.key),n=new U1(e.languages);return(r,o,a)=>new nm(r,o,a,n,e)});Wd(Fd,{displayName:"NodeView<code-block>",group:"CodeBlock"});const om=[Fd,Kn];function Zn(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-cursor",...e}}),t}const Hn=A(null,"dropIndicatorState");Zn(Hn,{displayName:"Ctx<dropIndicatorState>"});const mo=A({width:2,color:!1,class:"milkdown-drop-indicator"},"dropIndicatorConfig");Zn(mo,{displayName:"Ctx<dropIndicatorConfig>"});const am=new X("MILKDOWN_DROP_INDICATOR_DOM"),Kd=G(t=>new Y({key:am,view:e=>{const n=t.get(mo.key),r=document.createElement("div");Object.assign(r.style,{position:"fixed",pointerEvents:"none",display:"none",backgroundColor:n.color,top:"0",left:"0"}),r.classList.add(n.class),r.classList.add("milkdown-drop-indicator"),e.dom.parentNode?.appendChild(r);const o=t.use(Hn.key),a=s=>{sm(r,s,n)};return o.on(a),{destroy:()=>{o.off(a),r.remove()}}}}));Zn(Kd,{displayName:"Prose<dropIndicatorDOM>"});function sm(t,e,n){if(!e){Object.assign(t.style,{display:"none"});return}const{line:r}=e,{width:o}=n,{p1:{x:a,y:s},p2:{x:i,y:l}}=r,c=s===l;let d,u,p=s,h=a;c?(d=i-a,u=o,p-=o/2):(d=o,u=l-s,h-=o/2),p=Math.round(p),h=Math.round(h),Object.assign(t.style,{display:"block",width:`${d}px`,height:`${u}px`,transform:`translate(${h}px, ${p}px)`})}const Zd=G(t=>kp({onShow:o=>{t.set(Hn.key,o)},onHide:()=>{t.set(Hn.key,null)},onDrag:()=>!0}));Zn(Zd,{displayName:"Prose<dropIndicator>"});const Gd=G(()=>wp());Zn(Gd,{displayName:"Prose<gapCursor>"});const im=[Gd,mo,Hn,Kd,Zd].flat();var lm=Object.defineProperty,Jl=Object.getOwnPropertySymbols,cm=Object.prototype.hasOwnProperty,dm=Object.prototype.propertyIsEnumerable,Ql=(t,e,n)=>e in t?lm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,um=(t,e)=>{for(var n in e||(e={}))cm.call(e,n)&&Ql(t,n,e[n]);if(Jl)for(var n of Jl(e))dm.call(e,n)&&Ql(t,n,e[n]);return t};function zd(t,e){return Object.assign(t,{meta:um({package:"@milkdown/components"},e)}),t}const pm={imageIcon:"🌌",uploadButton:"Upload",confirmButton:"⏎",uploadPlaceholderText:"/Paste",onUpload:t=>Promise.resolve(URL.createObjectURL(t))},go=A(pm,"inlineImageConfigCtx");zd(go,{displayName:"Config<image-inline>",group:"ImageInline"});function kr({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}kr.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};const hm=Pd("abcdefg",8),mm=J({props:{src:{type:Object,required:!0},selected:{type:Object,required:!0},readonly:{type:Object,required:!0},setLink:{type:Function,required:!0},imageIcon:{type:String,required:!1},uploadButton:{type:String,required:!1},confirmButton:{type:String,required:!1},uploadPlaceholderText:{type:String,required:!1},onUpload:{type:Function,required:!0}},setup({readonly:t,src:e,setLink:n,onUpload:r,imageIcon:o,uploadButton:a,confirmButton:s,uploadPlaceholderText:i,className:l}){var c,d;const u=I(!1),p=I(),h=I((c=e.value)!=null?c:""),k=I(hm()),g=I(((d=e.value)==null?void 0:d.length)!==0),m=b=>{const S=b.target.value;g.value=S.length!==0,h.value=S},w=b=>{var _,S;b.key==="Enter"&&n((S=(_=p.value)==null?void 0:_.value)!=null?S:"")},v=()=>{var b,_;n((_=(b=p.value)==null?void 0:b.value)!=null?_:"")},C=b=>{var _;const S=(_=b.target.files)==null?void 0:_[0];S&&r(S).then($=>{$&&(n($),g.value=!0)}).catch($=>{console.error("An error occurred while uploading image"),console.error($)})};return()=>f("div",{class:Q("image-edit",l)},f(kr,{icon:o,class:"image-icon"}),f("div",{class:Q("link-importer",u.value&&"focus")},f("input",{ref:p,draggable:"true",onDragstart:b=>{b.preventDefault(),b.stopPropagation()},disabled:t.value,class:"link-input-area",value:h.value,onInput:m,onKeydown:w,onFocus:()=>u.value=!0,onBlur:()=>u.value=!1}),!g.value&&f("div",{class:"placeholder"},f("input",{disabled:t.value,class:"hidden",id:k.value,type:"file",accept:"image/*",onChange:C}),f("label",{class:"uploader",for:k.value},f(kr,{icon:a})),f("span",{class:"text",onClick:()=>{var b;return(b=p.value)==null?void 0:b.focus()}},i))),h.value&&f("div",{class:"confirm",onClick:()=>v()},f(kr,{icon:s})))}}),gm=J({props:{src:{type:Object,required:!0},alt:{type:Object,required:!0},title:{type:Object,required:!0},selected:{type:Object,required:!0},readonly:{type:Object,required:!0},setAttr:{type:Function,required:!0},config:{type:Object,required:!0}},setup(t){const{src:e,alt:n,title:r}=t;return()=>{var o;return(o=e.value)!=null&&o.length?f("img",{class:"image-inline",src:e.value,alt:n.value,title:r.value}):f(mm,{src:t.src,selected:t.selected,readonly:t.readonly,setLink:a=>t.setAttr("src",a),imageIcon:t.config.imageIcon,uploadButton:t.config.uploadButton,confirmButton:t.config.confirmButton,uploadPlaceholderText:t.config.uploadPlaceholderText,onUpload:t.config.onUpload,className:"empty-image-inline"})}}}),Ud=Bn(ut.node,t=>(e,n,r)=>{const o=I(e.attrs.src),a=I(e.attrs.alt),s=I(e.attrs.title),i=I(!1),l=I(!n.editable),c=(m,w)=>{if(!n.editable)return;const v=r();v!=null&&n.dispatch(n.state.tr.setNodeAttribute(v,m,m==="src"?he.sanitize(w):w))},d=t.get(go.key),u=ye(gm,{src:o,alt:a,title:s,selected:i,readonly:l,setAttr:c,config:d}),p=document.createElement("span");p.className="milkdown-image-inline";const h=Tt(()=>{i.value?p.classList.add("selected"):p.classList.remove("selected")}),k=d.proxyDomURL,g=m=>{if(!k)o.value=m.attrs.src;else{const w=k(m.attrs.src);typeof w=="string"?o.value=w:w.then(v=>{o.value=v}).catch(console.error)}a.value=m.attrs.alt,s.value=m.attrs.title};return g(e),u.mount(p),{dom:p,update:m=>m.type!==e.type?!1:(g(m),!0),stopEvent:m=>m.target instanceof HTMLInputElement,selectNode:()=>{i.value=!0},deselectNode:()=>{i.value=!1},destroy:()=>{h(),u.unmount(),p.remove()}}});zd(Ud,{displayName:"NodeView<image-inline>",group:"ImageInline"});const fm=[go,Ud];class fo{constructor(e){this.#o=!1,this.onShow=()=>{},this.onHide=()=>{},this.#c=n=>{Ne(n,this.element,{placement:this.#n.placement??"top",middleware:[ka(),lt(this.#s),$p(this.#l),...this.#r],...this.#n}).then(({x:r,y:o})=>{Object.assign(this.element.style,{left:`${r}px`,top:`${o}px`})}).catch(console.error)},this.#u=n=>this.#i!==n.dom.parentElement,this.#h=(n,r)=>{const{state:o,composing:a}=n,{selection:s,doc:i}=o,{ranges:l}=s,c=Math.min(...l.map(h=>h.$from.pos)),d=Math.max(...l.map(h=>h.$to.pos)),u=r&&r.doc.eq(i)&&r.selection.eq(s);if(this.#o||((this.#i??n.dom.parentElement??document.body).appendChild(this.element),this.#o=!0),a||u)return;if(this.#a?.(),this.#a=void 0,!this.#e(n,r)){this.hide();return}const p={getBoundingClientRect:()=>Qr(n,c,d),contextElement:n.dom};this.#u(n)?this.#a=Rl(p,this.element,()=>this.#c(p)):this.#c(p),this.show()},this.update=(n,r)=>{this.#d(n,r)},this.destroy=()=>{this.#a?.(),this.#d.cancel()},this.show=(n,r)=>{if(this.element.dataset.show="true",n){this.#a?.(),this.#a=void 0;const o={...n,contextElement:r?.dom};r&&this.#u(r)?this.#a=Rl(o,this.element,()=>this.#c(o)):this.#c(o)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=e.content,this.#t=e.debounce??200,this.#e=e.shouldShow??this.#p,this.#s=e.offset,this.#l=e.shift,this.#r=e.middleware??[],this.#n=e.floatingUIOptions??{},this.#i=e.root,this.element.dataset.show="false",this.#d=Ur(this.#h,this.#t)}#t;#e;#r;#n;#i;#o;#a;#s;#l;#d;#c;#u;#h;#p(e){const{doc:n,selection:r}=e.state,{empty:o,from:a,to:s}=r,i=!n.textBetween(a,s).length&&e.state.selection instanceof W,l=this.element.contains(document.activeElement),c=!e.hasFocus()&&!l,d=!e.editable;return!(c||o||i||d)}}function vo(t){const e=A({},`${t}_TOOLTIP_SPEC`),n=G(o=>{const a=o.get(e.key);return new Y({key:new X(`${t}_TOOLTIP`),...a})}),r=[e,n];return r.key=e.key,r.pluginKey=n.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${t}`},n.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${t}`},r}var vm=Object.defineProperty,ec=Object.getOwnPropertySymbols,ym=Object.prototype.hasOwnProperty,wm=Object.prototype.propertyIsEnumerable,tc=(t,e,n)=>e in t?vm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,km=(t,e)=>{for(var n in e||(e={}))ym.call(e,n)&&tc(t,n,e[n]);if(ec)for(var n of ec(e))wm.call(e,n)&&tc(t,n,e[n]);return t};function mt(t,e){return Object.assign(t,{meta:km({package:"@milkdown/components"},e)}),t}var Cm=Object.defineProperty,nc=Object.getOwnPropertySymbols,bm=Object.prototype.hasOwnProperty,_m=Object.prototype.propertyIsEnumerable,rc=(t,e,n)=>e in t?Cm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Es=(t,e)=>{for(var n in e||(e={}))bm.call(e,n)&&rc(t,n,e[n]);if(nc)for(var n of nc(e))_m.call(e,n)&&rc(t,n,e[n]);return t};const Mm={mode:"preview"},Be=A(Es({},Mm),"linkTooltipStateCtx");mt(Be,{displayName:"State<link-tooltip>",group:"LinkTooltip"});const Im={addLink:()=>{},editLink:()=>{},removeLink:()=>{}},St=A(Es({},Im),"linkTooltipAPICtx");mt(Be,{displayName:"API<link-tooltip>",group:"LinkTooltip"});const Nm={linkIcon:"🔗",editButton:"✎",removeButton:"⌫",confirmButton:"Confirm ⏎",onCopyLink:()=>{},inputPlaceholder:"Paste link..."},Lt=A(Es({},Nm),"linkTooltipConfigCtx");mt(Be,{displayName:"Config<link-tooltip>",group:"LinkTooltip"});const Yd=P("ToggleLink",t=>()=>e=>{const{doc:n,selection:r}=e,o=ve.type(t);return n.rangeHasMark(r.from,r.to,o)?(t.get(St.key).removeLink(r.from,r.to),!0):(t.get(St.key).addLink(r.from,r.to),!0)}),Gn=vo("LINK_PREVIEW");mt(Gn[0],{displayName:"PreviewTooltipSpec<link-tooltip>",group:"LinkTooltip"});mt(Gn[1],{displayName:"PreviewTooltipPlugin<link-tooltip>",group:"LinkTooltip"});const yo=vo("LINK_EDIT");mt(yo[0],{displayName:"EditTooltipSpec<link-tooltip>",group:"LinkTooltip"});mt(yo[1],{displayName:"EditTooltipPlugin<link-tooltip>",group:"LinkTooltip"});function Mn({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}Mn.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};const xm=J({props:{config:{type:Object,required:!0},src:{type:Object,required:!0},onConfirm:{type:Function,required:!0},onCancel:{type:Function,required:!0}},setup({config:t,src:e,onConfirm:n,onCancel:r}){const o=I(e);zr(e,i=>{o.value=i});const a=()=>{n(o.value)},s=i=>{i.stopPropagation(),i.key==="Enter"&&(i.preventDefault(),a()),i.key==="Escape"&&(i.preventDefault(),r())};return()=>f("div",{class:"link-edit"},f("input",{class:"input-area",placeholder:t.value.inputPlaceholder,onKeydown:s,onInput:i=>{o.value=i.target.value},value:o.value}),o.value?f(Mn,{class:"button confirm",icon:t.value.confirmButton,onClick:a}):null)}});var Sm=Object.defineProperty,Lm=Object.defineProperties,Pm=Object.getOwnPropertyDescriptors,oc=Object.getOwnPropertySymbols,Tm=Object.prototype.hasOwnProperty,Om=Object.prototype.propertyIsEnumerable,Xd=t=>{throw TypeError(t)},ac=(t,e,n)=>e in t?Sm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Un=(t,e)=>{for(var n in e||(e={}))Tm.call(e,n)&&ac(t,n,e[n]);if(oc)for(var n of oc(e))Om.call(e,n)&&ac(t,n,e[n]);return t},sc=(t,e)=>Lm(t,Pm(e)),Jd=(t,e,n)=>e.has(t)||Xd("Cannot "+n),j=(t,e,n)=>(Jd(t,e,"read from private field"),n?n.call(t):e.get(t)),Te=(t,e,n)=>e.has(t)?Xd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),ze=(t,e,n,r)=>(Jd(t,e,"write to private field"),e.set(t,n),n),Qt,Ve,je,Cr,en,br,Je,ta,_r;const ic={from:-1,to:-1,mark:null};class Hm{constructor(e,n){this.ctx=e,Te(this,Qt),Te(this,Ve),Te(this,je,Un({},ic)),Te(this,Cr),Te(this,en),Te(this,br,I("")),Te(this,Je,()=>{j(this,Ve).hide(),this.ctx.update(Be.key,a=>sc(Un({},a),{mode:"preview"})),ze(this,je,Un({},ic))}),Te(this,ta,a=>{const s=this.ctx.get(q),{from:i,to:l,mark:c}=j(this,je),d=ve.type(this.ctx),u=he.sanitize(a);if(c&&c.attrs.href===u){j(this,Je).call(this);return}const p=s.state.tr;c&&p.removeMark(i,l,c),p.addMark(i,l,d.create({href:u})),s.dispatch(p),j(this,Je).call(this)}),Te(this,_r,(a,s,i)=>{const l=this.ctx.get(Lt.key);j(this,en).value=l,j(this,br).value=a,this.ctx.update(Be.key,d=>sc(Un({},d),{mode:"edit"}));const c=this.ctx.get(q);c.dispatch(c.state.tr.setSelection(W.create(c.state.doc,s,i))),j(this,Ve).show({getBoundingClientRect:()=>Qr(c,s,i)},c),requestAnimationFrame(()=>{var d;(d=j(this,Qt).querySelector("input"))==null||d.focus()})}),this.update=a=>{const{state:s}=a,{selection:i}=s;if(!(i instanceof W))return;const{from:l,to:c}=i;l===j(this,je).from&&c===j(this,je).to||j(this,Je).call(this)},this.destroy=()=>{j(this,Cr).unmount(),j(this,Ve).destroy(),j(this,Qt).remove()},this.addLink=(a,s)=>{ze(this,je,{from:a,to:s,mark:null}),j(this,_r).call(this,"",a,s)},this.editLink=(a,s,i)=>{ze(this,je,{from:s,to:i,mark:a}),j(this,_r).call(this,a.attrs.href,s,i)},this.removeLink=(a,s)=>{const i=this.ctx.get(q),l=i.state.tr;l.removeMark(a,s,ve.type(this.ctx)),i.dispatch(l),j(this,Je).call(this)},ze(this,en,I(this.ctx.get(Lt.key)));const r=document.createElement("div");r.className="milkdown-link-edit";const o=ye(xm,{config:j(this,en),src:j(this,br),onConfirm:j(this,ta),onCancel:j(this,Je)});o.mount(r),ze(this,Cr,o),ze(this,Qt,r),ze(this,Ve,new fo({content:r,debounce:0,shouldShow:()=>!1})),j(this,Ve).onHide=()=>{requestAnimationFrame(()=>{n.dom.focus({preventScroll:!0})})},j(this,Ve).update(n)}}Qt=new WeakMap;Ve=new WeakMap;je=new WeakMap;Cr=new WeakMap;en=new WeakMap;br=new WeakMap;Je=new WeakMap;ta=new WeakMap;_r=new WeakMap;var Rm=Object.defineProperty,$m=Object.defineProperties,Em=Object.getOwnPropertyDescriptors,lc=Object.getOwnPropertySymbols,Bm=Object.prototype.hasOwnProperty,Am=Object.prototype.propertyIsEnumerable,cc=(t,e,n)=>e in t?Rm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Dm=(t,e)=>{for(var n in e||(e={}))Bm.call(e,n)&&cc(t,n,e[n]);if(lc)for(var n of lc(e))Am.call(e,n)&&cc(t,n,e[n]);return t},qm=(t,e)=>$m(t,Em(e));function Vm(t){let e;t.update(St.key,n=>qm(Dm({},n),{addLink:(r,o)=>{e?.addLink(r,o)},editLink:(r,o,a)=>{e?.editLink(r,o,a)},removeLink:(r,o)=>{e?.removeLink(r,o)}})),t.set(yo.key,{view:n=>(e=new Hm(t,n),e)})}function jm(t,e,n,r,o){let a={start:-1,end:-1};return n.nodesBetween(r,o,(s,i)=>{if(a.start>-1)return!1;a.start===-1&&t.isInSet(s.marks)&&e===s&&(a={start:i,end:i+Math.max(s.textContent.length,1)})}),a}function Wm(t,e,n){const r=e.posAtCoords({left:n.clientX,top:n.clientY});if(!r)return;const{pos:o}=r,a=e.state.doc.nodeAt(o);if(!a)return;const s=a.marks.find(l=>l.type===ve.mark.type(t));if(!(!s||!Gn.pluginKey()))return{show:!0,pos:o,node:a,mark:s}}const Fm=J({props:{config:{type:Object,required:!0},src:{type:Object,required:!0},onEdit:{type:Object,required:!0},onRemove:{type:Object,required:!0}},setup({config:t,src:e,onEdit:n,onRemove:r}){const o=i=>{i.preventDefault(),i.stopPropagation(),n.value()},a=i=>{i.preventDefault(),i.stopPropagation(),r.value()},s=i=>{i.preventDefault();const l=e.value;navigator.clipboard&&l&&navigator.clipboard.writeText(l).then(()=>{t.value.onCopyLink(l)}).catch(c=>console.error(c))};return()=>f("div",{class:"link-preview"},f(Mn,{class:"button link-icon",icon:t.value.linkIcon,onClick:s}),f("a",{href:e.value,target:"_blank",class:"link-display"},e.value),f(Mn,{class:"button link-edit-button",icon:t.value.editButton,onClick:o}),f(Mn,{class:"button link-remove-button",icon:t.value.removeButton,onClick:a}))}});var Qd=t=>{throw TypeError(t)},eu=(t,e,n)=>e.has(t)||Qd("Cannot "+n),R=(t,e,n)=>(eu(t,e,"read from private field"),n?n.call(t):e.get(t)),re=(t,e,n)=>e.has(t)?Qd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),De=(t,e,n,r)=>(eu(t,e,"write to private field"),e.set(t,n),n),Qe,ge,tn,nn,Mr,Ir,Nr,rn,xr,on,Sr,Lr,Pr,an;class Km{constructor(e,n){this.ctx=e,re(this,Qe),re(this,ge),re(this,tn,this.ctx.use(Be.key)),re(this,nn),re(this,Mr,I("")),re(this,Ir,I(()=>{})),re(this,Nr,I(()=>{})),re(this,rn),re(this,xr),re(this,on,!1),re(this,Sr,({mode:r})=>{r==="edit"&&R(this,an).call(this)}),re(this,Lr,()=>{De(this,on,!0)}),re(this,Pr,()=>{De(this,on,!1)}),re(this,an,()=>{R(this,ge).hide(),R(this,ge).element.removeEventListener("mouseenter",R(this,Lr)),R(this,ge).element.removeEventListener("mouseleave",R(this,Pr))}),this.show=(r,o,a,s)=>{R(this,nn).value=this.ctx.get(Lt.key),R(this,Mr).value=r.attrs.href,R(this,Ir).value=()=>{this.ctx.get(St.key).editLink(r,o,a)},R(this,Nr).value=()=>{this.ctx.get(St.key).removeLink(o,a),R(this,an).call(this)},R(this,ge).show({getBoundingClientRect:()=>s},R(this,xr)),R(this,ge).element.addEventListener("mouseenter",R(this,Lr)),R(this,ge).element.addEventListener("mouseleave",R(this,Pr))},this.hide=()=>{R(this,on)||R(this,an).call(this)},this.update=()=>{},this.destroy=()=>{R(this,rn).unmount(),R(this,tn).off(R(this,Sr)),R(this,ge).destroy(),R(this,Qe).remove()},De(this,xr,n),De(this,nn,I(this.ctx.get(Lt.key))),De(this,rn,ye(Fm,{config:R(this,nn),src:R(this,Mr),onEdit:R(this,Ir),onRemove:R(this,Nr)})),De(this,Qe,document.createElement("div")),R(this,Qe).className="milkdown-link-preview",R(this,rn).mount(R(this,Qe)),De(this,ge,new fo({debounce:0,content:R(this,Qe),shouldShow:()=>!1})),R(this,ge).update(n),De(this,tn,e.use(Be.key)),R(this,tn).on(R(this,Sr))}}Qe=new WeakMap;ge=new WeakMap;tn=new WeakMap;nn=new WeakMap;Mr=new WeakMap;Ir=new WeakMap;Nr=new WeakMap;rn=new WeakMap;xr=new WeakMap;on=new WeakMap;Sr=new WeakMap;Lr=new WeakMap;Pr=new WeakMap;an=new WeakMap;function Zm(t){let e;const r=wa((a,s)=>{if(!e||!a.hasFocus()||t.get(Be.key).mode==="edit")return;const l=Wm(t,a,s);if(l){const c=a.state.doc.resolve(l.pos),d=jm(l.mark,l.node,a.state.doc,c.before(),c.after()),u=d.start,p=d.end;e.show(l.mark,u,p,Qr(a,u,p));return}e.hide()},50),o=()=>{setTimeout(()=>{e?.hide()},50)};t.set(Gn.key,{props:{handleDOMEvents:{mousemove:r,mouseleave:o}},view:a=>(e=new Km(t,a),e)})}function Gm(t){Zm(t),Vm(t)}const zm=[Be,St,Lt,Gn,yo,Yd].flat();var Um=Object.defineProperty,dc=Object.getOwnPropertySymbols,Ym=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,uc=(t,e,n)=>e in t?Um(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Jm=(t,e)=>{for(var n in e||(e={}))Ym.call(e,n)&&uc(t,n,e[n]);if(dc)for(var n of dc(e))Xm.call(e,n)&&uc(t,n,e[n]);return t};function tu(t,e){return Object.assign(t,{meta:Jm({package:"@milkdown/components"},e)}),t}const Qm={renderLabel:({label:t,listType:e,checked:n})=>n==null?e==="bullet"?"⦿":t:n?"☑":"□"},wo=A(Qm,"listItemBlockConfigCtx");tu(wo,{displayName:"Config<list-item-block>",group:"ListItemBlock"});function nu({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}nu.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};const eg=J({props:{label:{type:Object,required:!0},checked:{type:Object,required:!0},listType:{type:Object,required:!0},config:{type:Object,required:!0},readonly:{type:Object,required:!0},selected:{type:Object,required:!0},setAttr:{type:Function,required:!0},onMount:{type:Function,required:!0}},setup({label:t,checked:e,listType:n,config:r,readonly:o,setAttr:a,onMount:s,selected:i}){const l=p=>{p!=null&&p instanceof Element&&s(p)},c=p=>{p.stopPropagation(),p.preventDefault(),e.value!=null&&a("checked",!e.value)},d=xn(()=>r.renderLabel({label:t.value,listType:n.value,checked:e.value,readonly:o.value})),u=xn(()=>e.value==null?n.value==="bullet"?"bullet":"ordered":e.value?"checked":"unchecked");return()=>f("li",{class:Q("list-item",i.value&&"ProseMirror-selectednode")},f("div",{class:"label-wrapper",onPointerdown:c,contenteditable:!1},f(nu,{class:Q("label",o.value&&"readonly",u.value),icon:d.value})),f("div",{class:"children",ref:l}))}}),ru=Bn(be.node,t=>(e,n,r)=>{const o=document.createElement("div");o.className="milkdown-list-item-block";const a=document.createElement("div");a.setAttribute("data-content-dom","true"),a.classList.add("content-dom");const s=I(e.attrs.label),i=I(e.attrs.checked),l=I(e.attrs.listType),c=I(!n.editable),d=t.get(wo.key),u=I(!1),p=(C,b)=>{if(!n.editable)return;const _=r();_!=null&&(n.hasFocus()||n.focus(),n.dispatch(n.state.tr.setNodeAttribute(_,C,b)))},h=Tt(()=>{u.value?o.classList.add("selected"):o.classList.remove("selected")});let k=0;const m=ye(eg,{label:s,checked:i,listType:l,readonly:c,config:d,selected:u,setAttr:p,onMount:C=>{const{anchor:b,head:_}=n.state.selection;C.appendChild(a);const S=n.state.doc.resolve(b),$=n.state.doc.resolve(_);k=requestAnimationFrame(()=>{if(cancelAnimationFrame(k),!S.doc.eq(n.state.doc))return;const K=new W(S,$);n.dispatch(n.state.tr.setSelection(K))})}});m.mount(o);const w=C=>{l.value=C.attrs.listType,s.value=C.attrs.label,i.value=C.attrs.checked,c.value=!n.editable};w(e);let v=e;return{dom:o,contentDOM:a,update:C=>C.type!==e.type?!1:(C.sameMarkup(v)&&C.content.eq(v.content)||(v=C,w(C)),!0),ignoreMutation:C=>!o||!a?!0:C.type==="selection"?!1:a===C.target&&C.type==="attributes"?!0:!a.contains(C.target),selectNode:()=>{u.value=!0},deselectNode:()=>{u.value=!1},destroy:()=>{h(),m.unmount(),o.remove(),a.remove()}}});tu(ru,{displayName:"NodeView<list-item-block>",group:"ListItemBlock"});const tg=[wo,ru];var ng=Object.defineProperty,pc=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,og=Object.prototype.propertyIsEnumerable,hc=(t,e,n)=>e in t?ng(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ag=(t,e)=>{for(var n in e||(e={}))rg.call(e,n)&&hc(t,n,e[n]);if(pc)for(var n of pc(e))og.call(e,n)&&hc(t,n,e[n]);return t};function ou(t,e){return Object.assign(t,{meta:ag({package:"@milkdown/components"},e)}),t}var sg=Object.defineProperty,mc=Object.getOwnPropertySymbols,ig=Object.prototype.hasOwnProperty,lg=Object.prototype.propertyIsEnumerable,gc=(t,e,n)=>e in t?sg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,cg=(t,e)=>{for(var n in e||(e={}))ig.call(e,n)&&gc(t,n,e[n]);if(mc)for(var n of mc(e))lg.call(e,n)&&gc(t,n,e[n]);return t};const dg={renderButton:t=>{switch(t){case"add_row":return"+";case"add_col":return"+";case"delete_row":return"-";case"delete_col":return"-";case"align_col_left":return"left";case"align_col_center":return"center";case"align_col_right":return"right";case"col_drag_handle":return"=";case"row_drag_handle":return"="}}},ko=A(cg({},dg),"tableBlockConfigCtx");ou(ko,{displayName:"Config<table-block>",group:"TableBlock"});function Me({icon:t,class:e,onClick:n}){return f("span",{class:Q("milkdown-icon",e),onPointerdown:n,innerHTML:t?he.sanitize(t.trim()):void 0})}Me.props={icon:{type:String,required:!1},class:{type:String,required:!1},onClick:{type:Function,required:!1}};function au(t){const{dragPreviewRef:e,tableWrapperRef:n,contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:a,colHandleRef:s,rowHandleRef:i}=t,l=e.value;if(!l)return;const c=n.value;if(!c)return;const d=r.value;if(!d)return;const u=d.querySelector("tbody");if(!u)return;const p=l.querySelector("tbody");if(!p)return;const h=o.value;if(!h)return;const k=a.value;if(!k)return;const g=s.value;if(!g)return;const m=i.value;return m?{preview:l,wrapper:c,content:d,contentRoot:u,previewRoot:p,yHandle:h,xHandle:k,colHandle:g,rowHandle:m}:void 0}function su(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function iu(t,e,n,r,o){const{width:a,height:s}=r.querySelector("tbody").getBoundingClientRect();if(t==="y"){const l=r.querySelectorAll("tr")[o];if(!l)return;n.appendChild(l.cloneNode(!0));const c=l.getBoundingClientRect().height;Object.assign(e.style,{width:`${a}px`,height:`${c}px`}),e.dataset.show="true";return}if(t==="x"){const i=r.querySelectorAll("tr");let l;Array.from(i).forEach(c=>{const d=c.children[o];if(!d)return;l===void 0&&(l=d.getBoundingClientRect().width);const u=d.parentElement.cloneNode(!1),p=d.cloneNode(!0);u.appendChild(p),n.appendChild(u)}),Object.assign(e.style,{width:`${l}px`,height:`${s}px`}),e.dataset.show="true";return}}function ug(t,e){return n=>{cu(t,n,e,r=>{lu("y",n,r,t);const{preview:o,content:a,previewRoot:s}=r;su(s);const{hoverIndex:i}=t,[l]=i.value;iu("y",o,s,a,l)})}}function pg(t,e){return n=>{cu(t,n,e,r=>{lu("x",n,r,t);const{preview:o,content:a,previewRoot:s}=r,{hoverIndex:i}=t,[l,c]=i.value;su(s),iu("x",o,s,a,c)})}}function lu(t,e,n,r){const{xHandle:o,yHandle:a,colHandle:s,rowHandle:i,preview:l}=n;o.dataset.displayType=t==="y"?"indicator":"none",a.dataset.displayType=t==="x"?"indicator":"none",t==="y"?(s.dataset.show="false",fc(i)):(i.dataset.show="false",fc(s));const{hoverIndex:c,dragInfo:d}=r,[u,p]=c.value;d.value={startCoords:[e.clientX,e.clientY],startIndex:t==="y"?u:p,endIndex:t==="y"?u:p,type:t==="y"?"row":"col"},l.dataset.direction=t==="y"?"vertical":"horizontal"}function cu(t,e,n,r){const o=n?.get(q);if(!o?.editable)return;e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.effectAllowed="move");const a=au(t);a&&requestAnimationFrame(()=>{r(a)})}function fc(t){var e;(e=t.querySelector(".button-group"))==null||e.setAttribute("data-show","false")}function na(t,e){for(let n=0;n<t.childCount;n++)if(t.child(n)===e)return n;return-1}function hg(t,e){var n,r,o;if(e)try{const a=e.posAtCoords({left:t.clientX,top:t.clientY});if(!a)return;const s=a?.inside;if(s==null||s<0)return;const i=e.state.doc.resolve(s),l=e.state.doc.nodeAt(s);if(!l)return;const c=["table_cell","table_header"],d=["table_row","table_header_row"],u=c.includes(l.type.name)?l:(n=Ie(m=>c.includes(m.type.name))(i))==null?void 0:n.node,p=(r=Ie(m=>d.includes(m.type.name))(i))==null?void 0:r.node,h=(o=Ie(m=>m.type.name==="table")(i))==null?void 0:o.node;if(!u||!p||!h)return;const k=na(p,u);return[na(h,p),k]}catch{return}}function Co(t,[e,n]){const r=t.value;if(!r)return;const o=r.querySelectorAll("tr"),a=o[e];if(!a)return;const s=o[0];if(!s)return;const i=s.children[n];if(!i)return;const l=a.children[n];if(l)return{row:a,col:l,headerCol:i}}function mg(t,e,n){if(!n||!e)return;const{selection:r}=e.state;if(!(r instanceof Nt))return;const{$from:o}=r,a=Lc(o);if(!(!a||a.node!==n)){if(r.isColSelection()){const{$head:s}=r,i=s.index(s.depth-1);Bs({refs:t,index:[0,i],before:l=>{var c;(c=l.querySelector(".button-group"))==null||c.setAttribute("data-show","true")}});return}if(r.isRowSelection()){const{$head:s}=r,i=Ie(c=>c.type.name==="table_row"||c.type.name==="table_header_row")(s);if(!i)return;const l=na(a.node,i.node);As({refs:t,index:[l,0],before:c=>{var d;l>0&&((d=c.querySelector(".button-group"))==null||d.setAttribute("data-show","true"))}})}}}function Bs({refs:t,index:e,before:n,after:r}){const{contentWrapperRef:o,colHandleRef:a,hoverIndex:s}=t,i=a.value;if(!i)return;s.value=e;const l=Co(o,e);if(!l)return;const{headerCol:c}=l;i.dataset.show="true",n&&n(i),Ne(c,i,{placement:"top"}).then(({x:d,y:u})=>{Object.assign(i.style,{left:`${d}px`,top:`${u}px`}),r&&r(i)}).catch(console.error)}function As({refs:t,index:e,before:n,after:r}){const{contentWrapperRef:o,rowHandleRef:a,hoverIndex:s}=t,i=a.value;if(!i)return;s.value=e;const l=Co(o,e);if(!l)return;const{row:c}=l;i.dataset.show="true",n&&n(i),Ne(c,i,{placement:"left"}).then(({x:d,y:u})=>{Object.assign(i.style,{left:`${d}px`,top:`${u}px`}),r&&r(i)}).catch(console.error)}function du(t,e,n){const r=n==="x"?"left":"top",o=n==="x"?"right":"bottom",a=t.length-1,s=t.findIndex((l,c)=>{const d=l.getBoundingClientRect(),u=d[r],p=d[o];return u<=e&&e<=p||c===a&&e>p||c===0&&e<u}),i=t[s];return i?[i,s]:void 0}function gg(t,e){const n=t.querySelector("tr");if(!n)return;const r=Array.from(n.children);return du(r,e,"x")}function fg(t,e){const n=Array.from(t.querySelectorAll("tr"));return du(n,e,"y")}function vg(t){return Ur(e=>{const n=au(t);if(!n)return;const{preview:r,content:o,contentRoot:a,xHandle:s,yHandle:i}=n,{dragInfo:l,hoverIndex:c}=t;if(r.dataset.show==="false")return;const d=Co(t.contentWrapperRef,c.value);if(!d||!a.querySelector("tr"))return;const p=l.value;if(!p||!a.offsetParent)return;const h=a.offsetParent.offsetTop,k=a.offsetParent.offsetLeft;if(p.type==="col"){const g=d.col.getBoundingClientRect().width,{left:m,width:w}=a.getBoundingClientRect(),v=k-m,C=e.clientX+v-g/2,[b]=p.startCoords,_=b<e.clientX?"right":"left";r.style.top=`${h}px`;const S=C<m+v-20?m+v-20:C>m+w+v-g+20?m+w+v-g+20:C;r.style.left=`${S}px`;const $=gg(a,e.clientX);if($){const[K,ne]=$,pe=i.getBoundingClientRect().width,se=o.getBoundingClientRect();p.endIndex=ne,Ne(K,i,{placement:_==="left"?"left":"right",middleware:[lt(_==="left"?-1*pe:0)]}).then(({x:H})=>{i.dataset.show="true",Object.assign(i.style,{height:`${se.height}px`,left:`${H}px`,top:`${h}px`})}).catch(console.error)}}else if(p.type==="row"){const g=d.row.getBoundingClientRect().height,{top:m,height:w}=a.getBoundingClientRect(),v=h-m,C=e.clientY+v-g/2,[b,_]=p.startCoords,S=_<e.clientY?"down":"up",$=C<m+v-20?m+v-20:C>m+w+v-g+20?m+w+v-g+20:C;r.style.top=`${$}px`,r.style.left=`${k}px`;const K=fg(a,e.clientY);if(K){const[ne,pe]=K,se=s.getBoundingClientRect().height,H=o.getBoundingClientRect();p.endIndex=pe,Ne(ne,s,{placement:S==="up"?"top":"bottom",middleware:[lt(S==="up"?-1*se:0)]}).then(({y:gt})=>{s.dataset.show="true",Object.assign(s.style,{width:`${H.width}px`,top:`${gt}px`})}).catch(console.error)}}},20)}function yg(t,e,n){const{dragPreviewRef:r,yLineHandleRef:o,xLineHandleRef:a,dragInfo:s}=t,i=ug(t,e),l=pg(t,e),c=()=>{const p=r.value;if(!p||p.dataset.show==="false")return;const h=p?.querySelector("tbody");for(;h?.firstChild;)h?.removeChild(h.firstChild);p&&(p.dataset.show="false")},d=()=>{var p;const h=r.value;if(!h)return;const k=o.value;if(!k)return;const g=a.value;if(!g)return;const m=s.value;if(!m||!e||h.dataset.show==="false"||!t.colHandleRef.value||!t.rowHandleRef.value||(k.dataset.show="false",g.dataset.show="false",m.startIndex===m.endIndex))return;const C=e.get(M),b={from:m.startIndex,to:m.endIndex,pos:((p=n?.())!=null?p:0)+1};if(m.type==="col"){C.call(rt.key,{pos:b.pos,index:m.startIndex}),C.call(Ms.key,b);const _=[0,m.endIndex];Bs({refs:t,index:_})}else{C.call(nt.key,{pos:b.pos,index:m.startIndex}),C.call(_s.key,b);const _=[m.endIndex,0];As({refs:t,index:_})}requestAnimationFrame(()=>{e.get(q).focus()})},u=vg(t);return Gr(()=>{window.addEventListener("dragover",u),window.addEventListener("dragend",c),window.addEventListener("drop",d)}),ya(()=>{window.removeEventListener("dragover",u),window.removeEventListener("dragend",c),window.removeEventListener("drop",d)}),{dragRow:i,dragCol:l}}function wg(t,e,n){const{xLineHandleRef:r,contentWrapperRef:o,colHandleRef:a,rowHandleRef:s,hoverIndex:i,lineHoverIndex:l}=t;return{onAddRow:()=>{var g,m,w;if(!e)return;const v=r.value;if(!v)return;const[C]=l.value;if(C<0||!e.get(q).editable)return;const b=Array.from((m=(g=o.value)==null?void 0:g.querySelectorAll("tr"))!=null?m:[]),_=e.get(M),S=((w=n?.())!=null?w:0)+1;b.length===C?(_.call(nt.key,{pos:S,index:C-1}),_.call(Ls.key)):(_.call(nt.key,{pos:S,index:C}),_.call(Ss.key)),_.call(nt.key,{pos:S,index:C}),v.dataset.show="false"},onAddCol:()=>{var g,m,w,v;if(!e||!r.value)return;const[b,_]=l.value;if(_<0||!e.get(q).editable)return;const S=Array.from((w=(m=(g=o.value)==null?void 0:g.querySelector("tr"))==null?void 0:m.children)!=null?w:[]),$=e.get(M),K=((v=n?.())!=null?v:0)+1;S.length===_?($.call(rt.key,{pos:K,index:_-1}),$.call(xs.key)):($.call(rt.key,{pos:K,index:_}),$.call(Ns.key)),$.call(rt.key,{pos:K,index:_})},selectCol:()=>{var g,m;if(!e)return;const[w,v]=i.value,C=e.get(M),b=((g=n?.())!=null?g:0)+1;C.call(rt.key,{pos:b,index:v});const _=(m=a.value)==null?void 0:m.querySelector(".button-group");_&&(_.dataset.show=_.dataset.show==="true"?"false":"true")},selectRow:()=>{var g,m;if(!e)return;const[w,v]=i.value,C=e.get(M),b=((g=n?.())!=null?g:0)+1;C.call(nt.key,{pos:b,index:w});const _=(m=s.value)==null?void 0:m.querySelector(".button-group");_&&w>0&&(_.dataset.show=_.dataset.show==="true"?"false":"true")},deleteSelected:g=>{if(!e||!e.get(q).editable)return;g.preventDefault(),g.stopPropagation(),e.get(M).call(Is.key),requestAnimationFrame(()=>{e.get(q).focus()})},onAlign:g=>m=>{if(!e||!e.get(q).editable)return;m.preventDefault(),m.stopPropagation(),e.get(M).call(Ps.key,g),requestAnimationFrame(()=>{e.get(q).focus()})}}}function kg(t,e){return Ur(n=>{if(!e?.editable)return;const{contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:a,colHandleRef:s,rowHandleRef:i,hoverIndex:l,lineHoverIndex:c}=t,d=o.value;if(!d)return;const u=a.value;if(!u)return;const p=r.value;if(!p)return;const h=i.value;if(!h)return;const k=s.value;if(!k)return;const g=hg(n,e);if(!g)return;const m=Co(r,g);if(!m)return;const[w,v]=g,C=m.col.getBoundingClientRect(),b=Math.abs(n.clientX-C.left)<8,_=Math.abs(C.right-n.clientX)<8,S=Math.abs(n.clientY-C.top)<8,$=Math.abs(C.bottom-n.clientY)<8,K=b||_||S||$,ne=h.querySelector(".button-group"),pe=k.querySelector(".button-group");if(ne&&(ne.dataset.show="false"),pe&&(pe.dataset.show="false"),K){const se=p.getBoundingClientRect();h.dataset.show="false",k.dataset.show="false",u.dataset.displayType="tool",d.dataset.displayType="tool";const H=d.getBoundingClientRect().width,gt=u.getBoundingClientRect().height;b||_?(c.value[1]=b?v:v+1,Ne(m.col,d,{placement:b?"left":"right",middleware:[lt(b?-1*H:0)]}).then(({x:ft})=>{d.dataset.show="true",Object.assign(d.style,{height:`${se.height}px`,left:`${ft}px`})}).catch(console.error)):d.dataset.show="false",g[0]!==0&&(S||$)?(c.value[0]=S?w:w+1,Ne(m.row,u,{placement:S?"top":"bottom",middleware:[lt(S?-1*gt:0)]}).then(({y:ft})=>{u.dataset.show="true",Object.assign(u.style,{width:`${se.width}px`,top:`${ft}px`})}).catch(console.error)):u.dataset.show="false";return}c.value=[-1,-1],d.dataset.show="false",u.dataset.show="false",h.dataset.show="true",k.dataset.show="true",As({refs:t,index:g}),Bs({refs:t,index:g}),l.value=g},20)}function Cg(t){return()=>{const{rowHandleRef:e,colHandleRef:n,yLineHandleRef:r,xLineHandleRef:o}=t;setTimeout(()=>{const a=e.value;if(!a)return;const s=n.value;if(!s)return;const i=r.value;if(!i)return;const l=o.value;l&&(a.dataset.show="false",s.dataset.show="false",i.dataset.show="false",l.dataset.show="false")},200)}}function bg(t,e){const n=kg(t,e),r=Cg(t);return{pointerMove:n,pointerLeave:r}}const _g=J({props:{view:{type:Object,required:!0},ctx:{type:Object,required:!0},getPos:{type:Function,required:!0},config:{type:Object,required:!0},onMount:{type:Function,required:!0},node:{type:Object,required:!0}},setup({view:t,node:e,ctx:n,getPos:r,config:o,onMount:a}){const s=I(),i=H=>{H!=null&&(H instanceof HTMLElement?(s.value=H,a(H)):s.value=void 0)},l=I(),c=I(),d=I(),u=I(),p=I(),h=I(),k=I([0,0]),g=I([-1,-1]),m=I(),w={dragPreviewRef:h,tableWrapperRef:p,contentWrapperRef:s,yLineHandleRef:u,xLineHandleRef:d,colHandleRef:l,rowHandleRef:c,hoverIndex:k,lineHoverIndex:g,dragInfo:m},{pointerLeave:v,pointerMove:C}=bg(w,t),{dragRow:b,dragCol:_}=yg(w,n,r),{onAddRow:S,onAddCol:$,selectCol:K,selectRow:ne,deleteSelected:pe,onAlign:se}=wg(w,n,r);return Gr(()=>{requestAnimationFrame(()=>{t.editable&&mg(w,t,e.value)})}),()=>f("div",{onDragstart:H=>H.preventDefault(),onDragover:H=>H.preventDefault(),onDragleave:H=>H.preventDefault(),onPointermove:C,onPointerleave:v},f("div",{"data-show":"false",contenteditable:"false",draggable:"true","data-role":"col-drag-handle",class:"handle cell-handle",onDragstart:_,onClick:K,onPointerdown:H=>H.stopPropagation(),onPointermove:H=>H.stopPropagation(),ref:l},f(Me,{icon:o.renderButton("col_drag_handle")}),f("div",{"data-show":"false",class:"button-group",onPointermove:H=>H.stopPropagation()},f("button",{type:"button",onPointerdown:se("left")},f(Me,{icon:o.renderButton("align_col_left")})),f("button",{type:"button",onPointerdown:se("center")},f(Me,{icon:o.renderButton("align_col_center")})),f("button",{type:"button",onPointerdown:se("right")},f(Me,{icon:o.renderButton("align_col_right")})),f("button",{type:"button",onPointerdown:pe},f(Me,{icon:o.renderButton("delete_col")})))),f("div",{"data-show":"false",contenteditable:"false",draggable:"true","data-role":"row-drag-handle",class:"handle cell-handle",onDragstart:b,onClick:ne,onPointerdown:H=>H.stopPropagation(),onPointermove:H=>H.stopPropagation(),ref:c},f(Me,{icon:o.renderButton("row_drag_handle")}),f("div",{"data-show":"false",class:"button-group",onPointermove:H=>H.stopPropagation()},f("button",{type:"button",onPointerdown:pe},f(Me,{icon:o.renderButton("delete_row")})))),f("div",{class:"table-wrapper",ref:p},f("div",{"data-show":"false",class:"drag-preview","data-direction":"vertical",ref:h},f("table",null,f("tbody",null))),f("div",{"data-show":"false",contenteditable:"false","data-display-type":"tool","data-role":"x-line-drag-handle",class:"handle line-handle",onPointermove:H=>H.stopPropagation(),ref:d},f("button",{type:"button",onClick:S,class:"add-button"},f(Me,{icon:o.renderButton("add_row")}))),f("div",{"data-show":"false",contenteditable:"false","data-display-type":"tool","data-role":"y-line-drag-handle",class:"handle line-handle",onPointermove:H=>H.stopPropagation(),ref:u},f("button",{type:"button",onClick:$,class:"add-button"},f(Me,{icon:o.renderButton("add_col")}))),f("table",{ref:i,class:"children"})))}});var uu=t=>{throw TypeError(t)},Mg=(t,e,n)=>e.has(t)||uu("Cannot "+n),Ig=(t,e,n)=>e.has(t)?uu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Ng=(t,e,n)=>(Mg(t,e,"access private method"),n),ra,pu;class xg{constructor(e,n,r,o){this.ctx=e,this.node=n,this.view=r,this.getPos=o,Ig(this,ra);const a=document.createElement("div");a.className="milkdown-table-block";const s=document.createElement("tbody");this.contentDOM=s,s.setAttribute("data-content-dom","true"),s.classList.add("content-dom"),this.nodeRef=qr(n);const i=ye(_g,{view:r,ctx:e,getPos:o,config:e.get(ko.key),onMount:l=>{l.appendChild(s)},node:this.nodeRef});i.mount(a),this.app=i,this.dom=a}update(e){return e.type!==this.node.type||e.sameMarkup(this.node)&&e.content.eq(this.node.content)?!1:(this.node=e,this.nodeRef.value=e,!0)}stopEvent(e){if(e.type==="drop"||e.type.startsWith("drag"))return!0;if(e.type==="mousedown"||e.type==="pointerdown"){if(e.target instanceof Element&&e.target.closest("button"))return!0;const n=e.target;if(n instanceof HTMLElement&&(n.closest("th")||n.closest("td"))){const r=e;return Ng(this,ra,pu).call(this,r)}}return!1}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:e.type==="selection"?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}destroy(){this.app.unmount(),this.dom.remove(),this.contentDOM.remove()}}ra=new WeakSet;pu=function(t){const e=this.view;if(!e.editable)return!1;const{state:n,dispatch:r}=e,o=e.posAtCoords({left:t.clientX,top:t.clientY});if(!o)return!1;const a=n.doc.resolve(o.inside),s=Ie(c=>c.type.name==="table_cell"||c.type.name==="table_header")(a);if(!s)return!1;if(n.selection instanceof W){const c=Ie(d=>d.type.name==="table_cell"||d.type.name==="table_header")(n.selection.$from);if(c?.node===s.node)return!1}const{from:i}=s,l=it.create(n.doc,i+1);return n.selection.eq(l)?!1:(n.selection instanceof Nt?setTimeout(()=>{r(n.tr.setSelection(l).scrollIntoView())},20):requestAnimationFrame(()=>{r(n.tr.setSelection(l).scrollIntoView())}),!0)};const hu=Bn(Ge.node,t=>(e,n,r)=>new xg(t,e,n,r));ou(hu,{displayName:"NodeView<table-block>",group:"TableBlock"});const Sg=[ko,hu];function oa(t){if(!t)return!1;if(Array.isArray(t))return t.length>1?!1:oa(t[0]);const e=t.content;return e?oa(e):t.type==="text"}function Lg(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-clipboard",...e}}),t}const mu=G(t=>{const e=t.get(fe);t.update(bn,o=>({...o,editable:o.editable??(()=>!0)}));const n=new X("MILKDOWN_CLIPBOARD");return new Y({key:n,props:{handlePaste:(o,a)=>{const s=t.get(_t),i=o.props.editable?.(o.state),{clipboardData:l}=a;if(!i||!l||o.state.selection.$from.node().type.spec.code)return!1;const d=l.getData("text/plain"),u=l.getData("vscode-editor-data");if(u){const v=JSON.parse(u)?.mode;if(d&&v){const{tr:C}=o.state,b=bh("code_block",e);return C.replaceSelectionWith(b.create({language:v})).setSelection(W.near(C.doc.resolve(Math.max(0,C.selection.from-2)))).insertText(d.replace(/\r\n?/g,` `)),o.dispatch(C),!0}}const p=l.getData("text/html");if(p.length===0&&d.length===0)return!1;const h=Mc.fromSchema(e);let k;if(p.length===0){const w=s(d);if(!w||typeof w=="string")return!1;k=Cp.fromSchema(e).serializeFragment(w.content)}else{const w=document.createElement("template");w.innerHTML=p,k=w.content.cloneNode(!0),w.remove()}const g=h.parseSlice(k),m=kh(g);if(m)return o.dispatch(o.state.tr.replaceSelectionWith(m,!0)),!0;try{return o.dispatch(o.state.tr.replaceSelection(g)),!0}catch{return!1}},clipboardTextSerializer:o=>{const a=t.get(Mt);if(oa(o.content.toJSON()))return o.content.textBetween(0,o.content.size,` `);const i=e.topNodeType.createAndFill(void 0,o.content);return i?a(i):""}}})});Lg(mu,{displayName:"Prose<clipboard>"});function Bt(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-history",...e}}),t}const Ds=P("Undo",()=>()=>va);Bt(Ds,{displayName:"Command<undo>"});const qs=P("Redo",()=>()=>Nn);Bt(qs,{displayName:"Command<redo>"});const Vs=A({},"historyProviderConfig");Bt(Vs,{displayName:"Ctx<historyProviderConfig>"});const gu=G(t=>bp(t.get(Vs.key)));Bt(gu,{displayName:"Ctx<historyProviderPlugin>"});const js=ae("historyKeymap",{Undo:{shortcuts:"Mod-z",command:t=>{const e=t.get(M);return()=>e.call(Ds.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:t=>{const e=t.get(M);return()=>e.call(qs.key)}}});Bt(js.ctx,{displayName:"KeymapCtx<history>"});Bt(js.shortcuts,{displayName:"Keymap<history>"});const Pg=[Vs,gu,js,Ds,qs].flat();function Tg(t,e){const{doc:n,selection:r}=t;if(!n||!r||!(r instanceof W||r instanceof _p))return t;const{to:o}=r,a=e.type==="space"?Array(e.size).fill(" ").join(""):" ";return t.insertText(a,o)}const bo=A({type:"space",size:2},"indentConfig");bo.meta={package:"@milkdown/plugin-indent",displayName:"Ctx<indentConfig>"};const fu=od(t=>({Tab:(e,n)=>{const r=t.get(bo.key),{tr:o}=e,a=Tg(o,r);return a.docChanged?(n?.(a),!0):!1}}));fu.meta={package:"@milkdown/plugin-indent",displayName:"Shortcut<indent>"};const Og=[bo,fu];class vu{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}}const Fr=O(new vu,"listener"),Hg=new X("MILKDOWN_LISTENER"),yu=t=>(t.inject(Fr,new vu),async()=>{await t.wait(at);const e=t.get(Fr),{listeners:n}=e;n.beforeMount.forEach(l=>l(t)),await t.wait(Cn);const r=t.get(Mt);let o=null,a=null,s=null;const i=new Y({key:Hg,view:()=>({destroy:()=>{n.destroy.forEach(l=>l(t))}}),props:{handleDOMEvents:{focus:()=>(n.focus.forEach(l=>l(t)),!1),blur:()=>(n.blur.forEach(l=>l(t)),!1)}},state:{init:(l,c)=>{o=c.doc,a=r(c.doc)},apply:l=>{const c=l.selection;return(!s&&c||s&&!c.eq(s))&&(n.selectionUpdated.forEach(u=>{u(t,c,s)}),s=c),!(l.docChanged||l.storedMarksSet)||l.getMeta("addToHistory")===!1?void 0:wa(()=>{const{doc:u}=l;if(n.updated.length>0&&o&&!o.eq(u)&&n.updated.forEach(p=>{p(t,u,o)}),n.markdownUpdated.length>0&&o&&!o.eq(u)){const p=r(u);n.markdownUpdated.forEach(h=>{h(t,p,a)}),a=p}o=u},200)()}}});t.update(Ee,l=>l.concat(i)),await t.wait(yr),n.mounted.forEach(l=>l(t))});yu.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};const Ws=A({shouldAppend:t=>!(!t||["heading","paragraph"].includes(t.type.name)),getNode:t=>t.schema.nodes.paragraph.create()},"trailingConfig");Ws.meta={package:"@milkdown/plugin-trailing",displayName:"Ctx<trailingConfig>"};const wu=G(t=>{const e=new X("MILKDOWN_TRAILING"),{shouldAppend:n,getNode:r}=t.get(Ws.key),o=new Y({key:e,state:{init:(a,s)=>{const i=s.tr.doc.lastChild;return n(i,s)},apply:(a,s,i,l)=>{if(!a.docChanged)return s;const c=a.doc.lastChild;return n(c,l)}},appendTransaction:(a,s,i)=>{const{doc:l,tr:c}=i,d=r?.(i),u=o.getState(i),p=l.content.size;if(!(!u||!d))return c.insert(p,d)}});return o});wu.meta={package:"@milkdown/plugin-trailing",displayName:"Prose<trailing>"};const Rg=[Ws,wu];var D=(t=>(t.CodeMirror="code-mirror",t.ListItem="list-item",t.LinkTooltip="link-tooltip",t.Cursor="cursor",t.ImageBlock="image-block",t.BlockEdit="block-edit",t.Toolbar="toolbar",t.Placeholder="placeholder",t.Table="table",t.Latex="latex",t))(D||{});const $g={cursor:!0,"list-item":!0,"link-tooltip":!0,"image-block":!0,"block-edit":!0,placeholder:!0,toolbar:!0,"code-mirror":!0,table:!0,latex:!0},Eg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM8.25 16.625C8.0375 16.625 7.85942 16.5531 7.71575 16.4093C7.57192 16.2654 7.5 16.0872 7.5 15.8748C7.5 15.6621 7.57192 15.484 7.71575 15.3405C7.85942 15.1968 8.0375 15.125 8.25 15.125H15.75C15.9625 15.125 16.1406 15.1969 16.2843 15.3408C16.4281 15.4846 16.5 15.6628 16.5 15.8753C16.5 16.0879 16.4281 16.266 16.2843 16.4095C16.1406 16.5532 15.9625 16.625 15.75 16.625H8.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM8.25 8.875C8.0375 8.875 7.85942 8.80308 7.71575 8.65925C7.57192 8.51542 7.5 8.33725 7.5 8.12475C7.5 7.91208 7.57192 7.734 7.71575 7.5905C7.85942 7.44683 8.0375 7.375 8.25 7.375H15.75C15.9625 7.375 16.1406 7.44692 16.2843 7.59075C16.4281 7.73458 16.5 7.91275 16.5 8.12525C16.5 8.33792 16.4281 8.516 16.2843 8.6595C16.1406 8.80317 15.9625 8.875 15.75 8.875H8.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z" /> </svg> `,Bg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM4.25 16.625C4.0375 16.625 3.85942 16.5531 3.71575 16.4093C3.57192 16.2654 3.5 16.0872 3.5 15.8748C3.5 15.6621 3.57192 15.484 3.71575 15.3405C3.85942 15.1968 4.0375 15.125 4.25 15.125H13.75C13.9625 15.125 14.1406 15.1969 14.2843 15.3408C14.4281 15.4846 14.5 15.6628 14.5 15.8753C14.5 16.0879 14.4281 16.266 14.2843 16.4095C14.1406 16.5532 13.9625 16.625 13.75 16.625H4.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM4.25 8.875C4.0375 8.875 3.85942 8.80308 3.71575 8.65925C3.57192 8.51542 3.5 8.33725 3.5 8.12475C3.5 7.91208 3.57192 7.734 3.71575 7.5905C3.85942 7.44683 4.0375 7.375 4.25 7.375H13.75C13.9625 7.375 14.1406 7.44692 14.2843 7.59075C14.4281 7.73458 14.5 7.91275 14.5 8.12525C14.5 8.33792 14.4281 8.516 14.2843 8.6595C14.1406 8.80317 13.9625 8.875 13.75 8.875H4.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z" /> </svg> `,Ag=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25ZM10.25 8.875C10.0375 8.875 9.85942 8.80308 9.71575 8.65925C9.57192 8.51542 9.5 8.33725 9.5 8.12475C9.5 7.91208 9.57192 7.734 9.71575 7.5905C9.85942 7.44683 10.0375 7.375 10.25 7.375H19.75C19.9625 7.375 20.1406 7.44692 20.2843 7.59075C20.4281 7.73458 20.5 7.91275 20.5 8.12525C20.5 8.33792 20.4281 8.516 20.2843 8.6595C20.1406 8.80317 19.9625 8.875 19.75 8.875H10.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM10.25 16.625C10.0375 16.625 9.85942 16.5531 9.71575 16.4093C9.57192 16.2654 9.5 16.0872 9.5 15.8748C9.5 15.6621 9.57192 15.484 9.71575 15.3405C9.85942 15.1968 10.0375 15.125 10.25 15.125H19.75C19.9625 15.125 20.1406 15.1969 20.2843 15.3408C20.4281 15.4846 20.5 15.6628 20.5 15.8753C20.5 16.0879 20.4281 16.266 20.2843 16.4095C20.1406 16.5532 19.9625 16.625 19.75 16.625H10.25ZM4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25Z" /> </svg> `,Dg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M8.85758 18.625C8.4358 18.625 8.07715 18.4772 7.78163 18.1817C7.48613 17.8862 7.33838 17.5275 7.33838 17.1058V6.8942C7.33838 6.47242 7.48613 6.11377 7.78163 5.81825C8.07715 5.52275 8.4358 5.375 8.85758 5.375H12.1999C13.2191 5.375 14.1406 5.69231 14.9643 6.32693C15.788 6.96154 16.1999 7.81603 16.1999 8.89038C16.1999 9.63779 16.0194 10.2471 15.6585 10.7183C15.2976 11.1894 14.9088 11.5314 14.4922 11.7442C15.005 11.9211 15.4947 12.2708 15.9614 12.7933C16.428 13.3157 16.6614 14.0192 16.6614 14.9038C16.6614 16.182 16.1902 17.1217 15.2479 17.723C14.3056 18.3243 13.3563 18.625 12.3999 18.625H8.85758ZM9.4883 16.6327H12.3191C13.1063 16.6327 13.6627 16.4141 13.9884 15.9769C14.314 15.5397 14.4768 15.1205 14.4768 14.7192C14.4768 14.3179 14.314 13.8987 13.9884 13.4615C13.6627 13.0243 13.0909 12.8057 12.273 12.8057H9.4883V16.6327ZM9.4883 10.875H12.0826C12.6903 10.875 13.172 10.7013 13.5278 10.3539C13.8836 10.0064 14.0615 9.59037 14.0615 9.10575C14.0615 8.59035 13.8733 8.16918 13.497 7.84225C13.1207 7.51533 12.6595 7.35188 12.1133 7.35188H9.4883V10.875Z" /> </svg> `,qg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_952_6527)"> <circle cx="12" cy="12" r="3" /> </g> <defs> <clipPath id="clip0_952_6527"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Vg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_8070)"> <path d="M4 10.5C3.17 10.5 2.5 11.17 2.5 12C2.5 12.83 3.17 13.5 4 13.5C4.83 13.5 5.5 12.83 5.5 12C5.5 11.17 4.83 10.5 4 10.5ZM4 4.5C3.17 4.5 2.5 5.17 2.5 6C2.5 6.83 3.17 7.5 4 7.5C4.83 7.5 5.5 6.83 5.5 6C5.5 5.17 4.83 4.5 4 4.5ZM4 16.5C3.17 16.5 2.5 17.18 2.5 18C2.5 18.82 3.18 19.5 4 19.5C4.82 19.5 5.5 18.82 5.5 18C5.5 17.18 4.83 16.5 4 16.5ZM8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19ZM8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13ZM7 6C7 6.55 7.45 7 8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6Z" /> </g> <defs> <clipPath id="clip0_977_8070"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,jg=` <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" > <path fill="currentColor" d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z" /> </svg> `,Wg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_1803_1151)"> <path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM10.71 16.29C10.32 16.68 9.69 16.68 9.3 16.29L5.71 12.7C5.32 12.31 5.32 11.68 5.71 11.29C6.1 10.9 6.73 10.9 7.12 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.71 16.29Z" /> </g> <defs> <clipPath id="clip0_1803_1151"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Fg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_1803_535)"> <path d="M18 19H6C5.45 19 5 18.55 5 18V6C5 5.45 5.45 5 6 5H18C18.55 5 19 5.45 19 6V18C19 18.55 18.55 19 18 19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3Z" /> </g> <defs> <clipPath id="clip0_1803_535"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,ku=` <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6" > <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /> </svg> `,Cu=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_1098_15553)"> <path d="M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z" /> </g> <defs> <clipPath id="clip0_1098_15553"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,bu=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_8081)"> <path d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z" /> </g> <defs> <clipPath id="clip0_977_8081"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Fs=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" > <g clip-path="url(#clip0_1013_1606)"> <path d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z" fill="#817567" /> </g> <defs> <clipPath id="clip0_1013_1606"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,_u=` <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="none" > <path d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z" /> </svg> `,Kg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_7900)"> <path fill-rule="evenodd" clip-rule="evenodd" d="M19 13H5C4.45 13 4 12.55 4 12C4 11.45 4.45 11 5 11H19C19.55 11 20 11.45 20 12C20 12.55 19.55 13 19 13Z" /> </g> <defs> <clipPath id="clip0_977_7900"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,vc=` <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" > <path d="M3.5 9.83366C3.35833 9.83366 3.23961 9.78571 3.14383 9.68983C3.04794 9.59394 3 9.47516 3 9.33349C3 9.19171 3.04794 9.07299 3.14383 8.97733C3.23961 8.88155 3.35833 8.83366 3.5 8.83366H12.5C12.6417 8.83366 12.7604 8.8816 12.8562 8.97749C12.9521 9.07338 13 9.19216 13 9.33383C13 9.4756 12.9521 9.59433 12.8562 9.68999C12.7604 9.78577 12.6417 9.83366 12.5 9.83366H3.5ZM3.5 7.16699C3.35833 7.16699 3.23961 7.11905 3.14383 7.02316C3.04794 6.92727 3 6.80849 3 6.66683C3 6.52505 3.04794 6.40633 3.14383 6.31066C3.23961 6.21488 3.35833 6.16699 3.5 6.16699H12.5C12.6417 6.16699 12.7604 6.21494 12.8562 6.31083C12.9521 6.40671 13 6.52549 13 6.66716C13 6.80894 12.9521 6.92766 12.8562 7.02333C12.7604 7.1191 12.6417 7.16699 12.5 7.16699H3.5Z" /> </svg> `,Ks=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_1013_1585)"> <path d="M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z" /> </g> <defs> <clipPath id="clip0_1013_1585"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Zg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_992_5553)"> <path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM12 17H14V7H10V9H12V17Z" /> </g> <defs> <clipPath id="clip0_992_5553"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Gg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_992_5559)"> <path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15H11V13H13C14.1 13 15 12.11 15 11V9C15 7.89 14.1 7 13 7H9V9H13V11H11C9.9 11 9 11.89 9 13V17H15V15Z" /> </g> <defs> <clipPath id="clip0_992_5559"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,zg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_992_5565)"> <path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13.5C15 12.67 14.33 12 13.5 12C14.33 12 15 11.33 15 10.5V9C15 7.89 14.1 7 13 7H9V9H13V11H11V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" /> </g> <defs> <clipPath id="clip0_992_5565"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Ug=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_7757)"> <path d="M19.04 3H5.04004C3.94004 3 3.04004 3.9 3.04004 5V19C3.04004 20.1 3.94004 21 5.04004 21H19.04C20.14 21 21.04 20.1 21.04 19V5C21.04 3.9 20.14 3 19.04 3ZM19.04 19H5.04004V5H19.04V19ZM13.04 17H15.04V7H13.04V11H11.04V7H9.04004V13H13.04V17Z" /> </g> <defs> <clipPath id="clip0_977_7757"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Yg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_7760)"> <path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H9V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" /> </g> <defs> <clipPath id="clip0_977_7760"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Xg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_7763)"> <path d="M11 17H13C14.1 17 15 16.11 15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H11C9.9 7 9 7.89 9 9V15C9 16.11 9.9 17 11 17ZM11 13H13V15H11V13ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19Z" /> </g> <defs> <clipPath id="clip0_977_7763"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,aa=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_8075)"> <path d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z" /> </g> <defs> <clipPath id="clip0_977_8075"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,Jg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M6.29811 18.625C6.04505 18.625 5.83115 18.5375 5.65641 18.3626C5.48166 18.1877 5.39429 17.9736 5.39429 17.7203C5.39429 17.467 5.48166 17.2532 5.65641 17.0788C5.83115 16.9045 6.04505 16.8173 6.29811 16.8173H9.21159L12.452 7.18265H9.53851C9.28545 7.18265 9.07155 7.0952 8.89681 6.9203C8.72206 6.7454 8.63469 6.5313 8.63469 6.278C8.63469 6.02472 8.72206 5.81089 8.89681 5.63652C9.07155 5.46217 9.28545 5.375 9.53851 5.375H16.8847C17.1377 5.375 17.3516 5.46245 17.5264 5.63735C17.7011 5.81225 17.7885 6.02634 17.7885 6.27962C17.7885 6.53293 17.7011 6.74676 17.5264 6.92113C17.3516 7.09548 17.1377 7.18265 16.8847 7.18265H14.2789L11.0385 16.8173H13.6443C13.8973 16.8173 14.1112 16.9048 14.286 17.0797C14.4607 17.2546 14.5481 17.4687 14.5481 17.722C14.5481 17.9752 14.4607 18.1891 14.286 18.3634C14.1112 18.5378 13.8973 18.625 13.6443 18.625H6.29811Z" /> </svg> `,Qg=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M17.0385 19.5003V16.5388H14.0769V15.0388H17.0385V12.0773H18.5384V15.0388H21.5V16.5388H18.5384V19.5003H17.0385ZM10.8077 16.5388H7.03845C5.78282 16.5388 4.7125 16.0963 3.8275 15.2114C2.9425 14.3266 2.5 13.2564 2.5 12.0009C2.5 10.7454 2.9425 9.67504 3.8275 8.78979C4.7125 7.90454 5.78282 7.46191 7.03845 7.46191H10.8077V8.96186H7.03845C6.1987 8.96186 5.48235 9.25834 4.8894 9.85129C4.29645 10.4442 3.99998 11.1606 3.99998 12.0003C3.99998 12.8401 4.29645 13.5564 4.8894 14.1494C5.48235 14.7423 6.1987 15.0388 7.03845 15.0388H10.8077V16.5388ZM8.25 12.7503V11.2504H15.75V12.7503H8.25ZM21.5 12.0003H20C20 11.1606 19.7035 10.4442 19.1106 9.85129C18.5176 9.25834 17.8013 8.96186 16.9615 8.96186H13.1923V7.46191H16.9615C18.2171 7.46191 19.2875 7.90441 20.1725 8.78939C21.0575 9.67439 21.5 10.7447 21.5 12.0003Z" /> </svg> `,ef=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_971_7680)"> <path d="M11 18C11 19.1 10.1 20 9 20C7.9 20 7 19.1 7 18C7 16.9 7.9 16 9 16C10.1 16 11 16.9 11 18ZM9 10C7.9 10 7 10.9 7 12C7 13.1 7.9 14 9 14C10.1 14 11 13.1 11 12C11 10.9 10.1 10 9 10ZM9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM15 8C16.1 8 17 7.1 17 6C17 4.9 16.1 4 15 4C13.9 4 13 4.9 13 6C13 7.1 13.9 8 15 8ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM15 16C13.9 16 13 16.9 13 18C13 19.1 13.9 20 15 20C16.1 20 17 19.1 17 18C17 16.9 16.1 16 15 16Z" /> </g> <defs> <clipPath id="clip0_971_7680"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,tf=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_8067)"> <path d="M8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6C7 6.55 7.45 7 8 7ZM20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17ZM20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11ZM4.5 16H2.5C2.22 16 2 16.22 2 16.5C2 16.78 2.22 17 2.5 17H4V17.5H3.5C3.22 17.5 3 17.72 3 18C3 18.28 3.22 18.5 3.5 18.5H4V19H2.5C2.22 19 2 19.22 2 19.5C2 19.78 2.22 20 2.5 20H4.5C4.78 20 5 19.78 5 19.5V16.5C5 16.22 4.78 16 4.5 16ZM2.5 5H3V7.5C3 7.78 3.22 8 3.5 8C3.78 8 4 7.78 4 7.5V4.5C4 4.22 3.78 4 3.5 4H2.5C2.22 4 2 4.22 2 4.5C2 4.78 2.22 5 2.5 5ZM4.5 10H2.5C2.22 10 2 10.22 2 10.5C2 10.78 2.22 11 2.5 11H3.8L2.12 12.96C2.04 13.05 2 13.17 2 13.28V13.5C2 13.78 2.22 14 2.5 14H4.5C4.78 14 5 13.78 5 13.5C5 13.22 4.78 13 4.5 13H3.2L4.88 11.04C4.96 10.95 5 10.83 5 10.72V10.5C5 10.22 4.78 10 4.5 10Z" /> </g> <defs> <clipPath id="clip0_977_8067"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,sa=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_971_7676)"> <path d="M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z" /> </g> <defs> <clipPath id="clip0_971_7676"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,nf=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_7897)"> <path d="M7.17 17C7.68 17 8.15 16.71 8.37 16.26L9.79 13.42C9.93 13.14 10 12.84 10 12.53V8C10 7.45 9.55 7 9 7H5C4.45 7 4 7.45 4 8V12C4 12.55 4.45 13 5 13H7L5.97 15.06C5.52 15.95 6.17 17 7.17 17ZM17.17 17C17.68 17 18.15 16.71 18.37 16.26L19.79 13.42C19.93 13.14 20 12.84 20 12.53V8C20 7.45 19.55 7 19 7H15C14.45 7 14 7.45 14 8V12C14 12.55 14.45 13 15 13H17L15.97 15.06C15.52 15.95 16.17 17 17.17 17Z" /> </g> <defs> <clipPath id="clip0_977_7897"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,ia=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z" /> </svg> `,Mu=` <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6" > <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z" /> </svg> `,rf=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M3.25 13.7404C3.0375 13.7404 2.85938 13.6684 2.71563 13.5246C2.57188 13.3808 2.5 13.2026 2.5 12.99C2.5 12.7774 2.57188 12.5993 2.71563 12.4558C2.85938 12.3122 3.0375 12.2404 3.25 12.2404H20.75C20.9625 12.2404 21.1406 12.3123 21.2843 12.4561C21.4281 12.5999 21.5 12.7781 21.5 12.9907C21.5 13.2033 21.4281 13.3814 21.2843 13.525C21.1406 13.6686 20.9625 13.7404 20.75 13.7404H3.25ZM10.9423 10.2596V6.62495H6.5673C6.2735 6.62495 6.02377 6.52201 5.8181 6.31613C5.61245 6.11026 5.50963 5.86027 5.50963 5.56615C5.50963 5.27205 5.61245 5.02083 5.8181 4.8125C6.02377 4.60417 6.2735 4.5 6.5673 4.5H17.4423C17.7361 4.5 17.9858 4.60294 18.1915 4.80883C18.3971 5.01471 18.5 5.2647 18.5 5.5588C18.5 5.85292 18.3971 6.10413 18.1915 6.31245C17.9858 6.52078 17.7361 6.62495 17.4423 6.62495H13.0673V10.2596H10.9423ZM10.9423 15.7211H13.0673V18.4423C13.0673 18.7361 12.9643 18.9858 12.7584 19.1915C12.5526 19.3971 12.3026 19.5 12.0085 19.5C11.7144 19.5 11.4631 19.3962 11.2548 19.1887C11.0465 18.9811 10.9423 18.7291 10.9423 18.4327V15.7211Z" /> </svg> `,of=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_977_8078)"> <path d="M20 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H20C21.1 21 22 20.1 22 19V5C22 3.9 21.1 3 20 3ZM20 5V8H5V5H20ZM15 19H10V10H15V19ZM5 10H8V19H5V10ZM17 19V10H20V19H17Z" /> </g> <defs> <clipPath id="clip0_977_8078"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,af=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <g clip-path="url(#clip0_992_5547)"> <path d="M5 5.5C5 6.33 5.67 7 6.5 7H10.5V17.5C10.5 18.33 11.17 19 12 19C12.83 19 13.5 18.33 13.5 17.5V7H17.5C18.33 7 19 6.33 19 5.5C19 4.67 18.33 4 17.5 4H6.5C5.67 4 5 4.67 5 5.5Z" /> </g> <defs> <clipPath id="clip0_992_5547"> <rect width="24" height="24" /> </clipPath> </defs> </svg> `,sf=` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" > <path d="M5.66936 16.3389L9.39244 12.6158C9.54115 12.4671 9.71679 12.3937 9.91936 12.3957C10.1219 12.3976 10.2975 12.4761 10.4463 12.6312C10.5847 12.7823 10.654 12.9585 10.654 13.1599C10.654 13.3613 10.5847 13.5363 10.4463 13.6851L6.32704 17.8197C6.14627 18.0004 5.93538 18.0908 5.69436 18.0908C5.45333 18.0908 5.24243 18.0004 5.06166 17.8197L3.01744 15.7754C2.87899 15.637 2.81136 15.4629 2.81456 15.2533C2.81776 15.0437 2.88859 14.8697 3.02706 14.7312C3.16551 14.5928 3.34008 14.5235 3.55076 14.5235C3.76144 14.5235 3.93494 14.5928 4.07126 14.7312L5.66936 16.3389ZM5.66936 8.72359L9.39244 5.00049C9.54115 4.85177 9.71679 4.77838 9.91936 4.78031C10.1219 4.78223 10.2975 4.86075 10.4463 5.01586C10.5847 5.16691 10.654 5.34314 10.654 5.54454C10.654 5.74592 10.5847 5.92097 10.4463 6.06969L6.32704 10.2043C6.14627 10.3851 5.93538 10.4755 5.69436 10.4755C5.45333 10.4755 5.24243 10.3851 5.06166 10.2043L3.01744 8.16009C2.87899 8.02162 2.81136 7.84759 2.81456 7.63799C2.81776 7.42837 2.88859 7.25433 3.02706 7.11586C3.16551 6.97741 3.34008 6.90819 3.55076 6.90819C3.76144 6.90819 3.93494 6.97741 4.07126 7.11586L5.66936 8.72359ZM13.7597 16.5581C13.5472 16.5581 13.3691 16.4862 13.2253 16.3424C13.0816 16.1986 13.0097 16.0204 13.0097 15.8078C13.0097 15.5952 13.0816 15.4171 13.2253 15.2735C13.3691 15.13 13.5472 15.0582 13.7597 15.0582H20.7597C20.9722 15.0582 21.1503 15.1301 21.2941 15.2739C21.4378 15.4177 21.5097 15.5959 21.5097 15.8085C21.5097 16.0211 21.4378 16.1992 21.2941 16.3427C21.1503 16.4863 20.9722 16.5581 20.7597 16.5581H13.7597ZM13.7597 8.94276C13.5472 8.94276 13.3691 8.87085 13.2253 8.72704C13.0816 8.58324 13.0097 8.40504 13.0097 8.19244C13.0097 7.97985 13.0816 7.80177 13.2253 7.65819C13.3691 7.5146 13.5472 7.44281 13.7597 7.44281H20.7597C20.9722 7.44281 21.1503 7.51471 21.2941 7.65851C21.4378 7.80233 21.5097 7.98053 21.5097 8.19311C21.5097 8.40571 21.4378 8.5838 21.2941 8.72739C21.1503 8.87097 20.9722 8.94276 20.7597 8.94276H13.7597Z" /> </svg> `,Iu=` <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" > <path fill="currentColor" d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z" /> </svg> `,Nu=` <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" > <path d="m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z" /> </svg> `,lf={[D.CodeMirror]:{theme:Np,languages:Ip,expandIcon:ku,searchIcon:Mu,clearSearchIcon:Cu,searchPlaceholder:"Search language",noResultText:"No result",previewToggleIcon:t=>t?Ks:Nu}},cf=O([],"FeaturesCtx"),df=O({},"CrepeCtx");function uf(t){return t.get("CrepeCtx")}function _o(t){return t.use("FeaturesCtx")}function Pe(t){return e=>{_o(e).update(n=>n.includes(t)?n:[...n,t])}}function xu(t){return t.$from.parent.type.name==="code_block"}function Su(t){var e;const n=(e=t.$from.node(t.$from.depth-1))==null?void 0:e.type;return n?.name==="list_item"}var Lu=t=>{throw TypeError(t)},Pu=(t,e,n)=>e.has(t)||Lu("Cannot "+n),qt=(t,e,n)=>(Pu(t,e,"read from private field"),n?n.call(t):e.get(t)),yc=(t,e,n)=>e.has(t)?Lu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),pf=(t,e,n,r)=>(Pu(t,e,"write to private field"),e.set(t,n),n),kt,Tr;class Tu{constructor(){yc(this,kt,[]),this.clear=()=>(pf(this,kt,[]),this),yc(this,Tr,e=>{const n={group:e,addItem:(r,o)=>{const a={...o,key:r};return e.items.push(a),n},clear:()=>(e.items=[],n)};return n}),this.addGroup=(e,n)=>{const o={key:e,label:n,items:[]};return qt(this,kt).push(o),qt(this,Tr).call(this,o)},this.getGroup=e=>{const n=qt(this,kt).find(r=>r.key===e);if(!n)throw new Error(`Group with key ${e} not found`);return qt(this,Tr).call(this,n)},this.build=()=>qt(this,kt)}}kt=new WeakMap;Tr=new WeakMap;function hf(t,e,n){var r,o,a,s,i,l,c,d,u,p,h,k,g,m,w,v,C,b,_,S,$,K,ne,pe,se,H,gt,ft,Gs,zs,Us,Ys,Xs,Js,Qs,ei,ti,ni,ri,oi,ai,si,ii,li,ci,di,ui,pi,hi,mi,gi,fi,vi,yi,wi,ki,Ci,bi,_i,Mi,Ii,Ni,xi,Si,Li,Pi,Ti,Oi,Hi,Ri,$i,Ei,Bi,Ai,Di,qi,Vi,ji,Wi,Fi,Ki,Zi,Gi,zi,Ui,Yi,Xi,Ji,Qi,el,tl,nl,rl,ol,al,sl,il,ll,cl,dl,ul,pl,hl,ml,gl,fl,vl,yl,wl,kl,Cl,bl,_l,Ml,Il,Nl,xl,Sl,Ll;const vt=n&&_o(n).get(),Fu=vt?.includes(D.Latex),Ku=vt?.includes(D.ImageBlock),Zu=vt?.includes(D.Table),At=new Tu;if(e?.textGroup!==null){const B=At.addGroup("text",(o=(r=e?.textGroup)==null?void 0:r.label)!=null?o:"Text");((a=e?.textGroup)==null?void 0:a.text)!==null&&B.addItem("text",{label:(l=(i=(s=e?.textGroup)==null?void 0:s.text)==null?void 0:i.label)!=null?l:"Text",icon:(u=(d=(c=e?.textGroup)==null?void 0:c.text)==null?void 0:d.icon)!=null?u:af,onRun:N=>{const x=N.get(M),E=Ce.type(N);x.call(U.key),x.call(He.key,{nodeType:E})}}),((p=e?.textGroup)==null?void 0:p.h1)!==null&&B.addItem("h1",{label:(g=(k=(h=e?.textGroup)==null?void 0:h.h1)==null?void 0:k.label)!=null?g:"Heading 1",icon:(v=(w=(m=e?.textGroup)==null?void 0:m.h1)==null?void 0:w.icon)!=null?v:Zg,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:1}})}}),((C=e?.textGroup)==null?void 0:C.h2)!==null&&B.addItem("h2",{label:(S=(_=(b=e?.textGroup)==null?void 0:b.h2)==null?void 0:_.label)!=null?S:"Heading 2",icon:(ne=(K=($=e?.textGroup)==null?void 0:$.h2)==null?void 0:K.icon)!=null?ne:Gg,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:2}})}}),((pe=e?.textGroup)==null?void 0:pe.h3)!==null&&B.addItem("h3",{label:(gt=(H=(se=e?.textGroup)==null?void 0:se.h3)==null?void 0:H.label)!=null?gt:"Heading 3",icon:(zs=(Gs=(ft=e?.textGroup)==null?void 0:ft.h3)==null?void 0:Gs.icon)!=null?zs:zg,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:3}})}}),((Us=e?.textGroup)==null?void 0:Us.h4)!==null&&B.addItem("h4",{label:(Js=(Xs=(Ys=e?.textGroup)==null?void 0:Ys.h4)==null?void 0:Xs.label)!=null?Js:"Heading 4",icon:(ti=(ei=(Qs=e?.textGroup)==null?void 0:Qs.h4)==null?void 0:ei.icon)!=null?ti:Ug,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:4}})}}),((ni=e?.textGroup)==null?void 0:ni.h5)!==null&&B.addItem("h5",{label:(ai=(oi=(ri=e?.textGroup)==null?void 0:ri.h5)==null?void 0:oi.label)!=null?ai:"Heading 5",icon:(li=(ii=(si=e?.textGroup)==null?void 0:si.h5)==null?void 0:ii.icon)!=null?li:Yg,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:5}})}}),((ci=e?.textGroup)==null?void 0:ci.h6)!==null&&B.addItem("h6",{label:(pi=(ui=(di=e?.textGroup)==null?void 0:di.h6)==null?void 0:ui.label)!=null?pi:"Heading 6",icon:(gi=(mi=(hi=e?.textGroup)==null?void 0:hi.h6)==null?void 0:mi.icon)!=null?gi:Xg,onRun:N=>{const x=N.get(M),E=de.type(N);x.call(U.key),x.call(He.key,{nodeType:E,attrs:{level:6}})}}),((fi=e?.textGroup)==null?void 0:fi.quote)!==null&&B.addItem("quote",{label:(wi=(yi=(vi=e?.textGroup)==null?void 0:vi.quote)==null?void 0:yi.label)!=null?wi:"Quote",icon:(bi=(Ci=(ki=e?.textGroup)==null?void 0:ki.quote)==null?void 0:Ci.icon)!=null?bi:nf,onRun:N=>{const x=N.get(M),E=Rt.type(N);x.call(U.key),x.call(Xt.key,{nodeType:E})}}),((_i=e?.textGroup)==null?void 0:_i.divider)!==null&&B.addItem("divider",{label:(Ni=(Ii=(Mi=e?.textGroup)==null?void 0:Mi.divider)==null?void 0:Ii.label)!=null?Ni:"Divider",icon:(Li=(Si=(xi=e?.textGroup)==null?void 0:xi.divider)==null?void 0:Si.icon)!=null?Li:Kg,onRun:N=>{const x=N.get(M),E=$t.type(N);x.call(U.key),x.call(Jt.key,{nodeType:E})}})}if(e?.listGroup!==null){const B=At.addGroup("list",(Ti=(Pi=e?.listGroup)==null?void 0:Pi.label)!=null?Ti:"List");((Oi=e?.listGroup)==null?void 0:Oi.bulletList)!==null&&B.addItem("bullet-list",{label:($i=(Ri=(Hi=e?.listGroup)==null?void 0:Hi.bulletList)==null?void 0:Ri.label)!=null?$i:"Bullet List",icon:(Ai=(Bi=(Ei=e?.listGroup)==null?void 0:Ei.bulletList)==null?void 0:Bi.icon)!=null?Ai:Vg,onRun:N=>{const x=N.get(M),E=pt.type(N);x.call(U.key),x.call(Xt.key,{nodeType:E})}}),((Di=e?.listGroup)==null?void 0:Di.orderedList)!==null&&B.addItem("ordered-list",{label:(ji=(Vi=(qi=e?.listGroup)==null?void 0:qi.orderedList)==null?void 0:Vi.label)!=null?ji:"Ordered List",icon:(Ki=(Fi=(Wi=e?.listGroup)==null?void 0:Wi.orderedList)==null?void 0:Fi.icon)!=null?Ki:tf,onRun:N=>{const x=N.get(M),E=ht.type(N);x.call(U.key),x.call(Xt.key,{nodeType:E})}}),((Zi=e?.listGroup)==null?void 0:Zi.taskList)!==null&&B.addItem("task-list",{label:(Ui=(zi=(Gi=e?.listGroup)==null?void 0:Gi.taskList)==null?void 0:zi.label)!=null?Ui:"Task List",icon:(Ji=(Xi=(Yi=e?.listGroup)==null?void 0:Yi.taskList)==null?void 0:Xi.icon)!=null?Ji:sf,onRun:N=>{const x=N.get(M),E=be.type(N);x.call(U.key),x.call(Xt.key,{nodeType:E,attrs:{checked:!1}})}})}if(e?.advancedGroup!==null){const B=At.addGroup("advanced",(el=(Qi=e?.advancedGroup)==null?void 0:Qi.label)!=null?el:"Advanced");((tl=e?.advancedGroup)==null?void 0:tl.image)!==null&&Ku&&B.addItem("image",{label:(ol=(rl=(nl=e?.advancedGroup)==null?void 0:nl.image)==null?void 0:rl.label)!=null?ol:"Image",icon:(il=(sl=(al=e?.advancedGroup)==null?void 0:al.image)==null?void 0:sl.icon)!=null?il:aa,onRun:N=>{const x=N.get(M),E=uo.type(N);x.call(U.key),x.call(Jt.key,{nodeType:E})}}),((ll=e?.advancedGroup)==null?void 0:ll.codeBlock)!==null&&B.addItem("code",{label:(ul=(dl=(cl=e?.advancedGroup)==null?void 0:cl.codeBlock)==null?void 0:dl.label)!=null?ul:"Code",icon:(ml=(hl=(pl=e?.advancedGroup)==null?void 0:pl.codeBlock)==null?void 0:hl.icon)!=null?ml:bu,onRun:N=>{const x=N.get(M),E=xe.type(N);x.call(U.key),x.call(He.key,{nodeType:E})}}),((gl=e?.advancedGroup)==null?void 0:gl.table)!==null&&Zu&&B.addItem("table",{label:(yl=(vl=(fl=e?.advancedGroup)==null?void 0:fl.table)==null?void 0:vl.label)!=null?yl:"Table",icon:(Cl=(kl=(wl=e?.advancedGroup)==null?void 0:wl.table)==null?void 0:kl.icon)!=null?Cl:of,onRun:N=>{const x=N.get(M),E=N.get(q);x.call(U.key);const{from:Gu}=E.state.selection;x.call(Jt.key,{nodeType:ws(N,3,3)}),x.call(Md.key,{pos:Gu})}}),((bl=e?.advancedGroup)==null?void 0:bl.math)!==null&&Fu&&B.addItem("math",{label:(Il=(Ml=(_l=e?.advancedGroup)==null?void 0:_l.math)==null?void 0:Ml.label)!=null?Il:"Math",icon:(Sl=(xl=(Nl=e?.advancedGroup)==null?void 0:Nl.math)==null?void 0:xl.icon)!=null?Sl:Iu,onRun:N=>{const x=N.get(M),E=xe.type(N);x.call(U.key),x.call(Jt.key,{nodeType:E,attrs:{language:"LaTex"}})}})}(Ll=e?.buildMenu)==null||Ll.call(e,At);let Dt=At.build();t&&(Dt=Dt.map(B=>{const N=B.items.filter(x=>x.label.toLowerCase().includes(t.toLowerCase()));return{...B,items:N}}).filter(B=>B.items.length>0));const Pl=Dt.flatMap(B=>B.items);return Pl.forEach((B,N)=>{Object.assign(B,{index:N})}),Dt.reduce((B,N)=>{const x=B+N.items.length;return Object.assign(N,{range:[B,x]}),x},0),{groups:Dt,size:Pl.length}}const mf=J({props:{ctx:{type:Object,required:!0},show:{type:Object,required:!0},filter:{type:Object,required:!0},hide:{type:Function,required:!0},config:{type:Object,required:!1}},setup({ctx:t,show:e,filter:n,hide:r,config:o}){const a=I(),s=xn(()=>hf(n.value,o,t)),i=I(0),l=I({x:-999,y:-999}),c=g=>{const{x:m,y:w}=g;l.value={x:m,y:w}};zr([s,e],()=>{const{size:g}=s.value;g===0&&e.value?r():i.value>=g&&(i.value=0)});const d=(g,m)=>{const w=i.value,v=typeof g=="function"?g(w):g;m?.(v),i.value=v},u=g=>{var m,w;const v=(m=a.value)==null?void 0:m.querySelector(`[data-index="${g}"]`),C=(w=a.value)==null?void 0:w.querySelector(".menu-groups");!v||!C||(C.scrollTop=v.offsetTop-C.offsetTop)},p=g=>{const m=s.value.groups.flatMap(w=>w.items).at(g);m&&t&&m.onRun(t),r()},h=g=>{const{size:m,groups:w}=s.value;if(g.key==="Escape"){g.preventDefault(),r?.();return}if(g.key==="ArrowDown")return g.preventDefault(),d(v=>v<m-1?v+1:v,u);if(g.key==="ArrowUp")return g.preventDefault(),d(v=>v<=0?v:v-1,u);if(g.key==="ArrowLeft")return g.preventDefault(),d(v=>{const C=w.find(_=>_.range[0]<=v&&_.range[1]>v);if(!C)return v;const b=w[w.indexOf(C)-1];return b?b.range[1]-1:v},u);if(g.key==="ArrowRight")return g.preventDefault(),d(v=>{const C=w.find(_=>_.range[0]<=v&&_.range[1]>v);if(!C)return v;const b=w[w.indexOf(C)+1];return b?b.range[0]:v},u);g.key==="Enter"&&(g.preventDefault(),p(i.value))},k=g=>m=>{const w=l.value;if(!w)return;const{x:v,y:C}=m;v===w.x&&C===w.y||d(g)};return Tt(()=>{e.value?window.addEventListener("keydown",h,{capture:!0}):window.removeEventListener("keydown",h,{capture:!0})}),ya(()=>{window.removeEventListener("keydown",h,{capture:!0})}),()=>f("div",{ref:a,onPointerdown:g=>g.preventDefault()},f("nav",{class:"tab-group"},f("ul",null,s.value.groups.map(g=>f("li",{key:g.key,onPointerdown:()=>d(g.range[0],u),class:i.value>=g.range[0]&&i.value<g.range[1]?"selected":""},g.label)))),f("div",{class:"menu-groups",onPointermove:c},s.value.groups.map(g=>f("div",{key:g.key,class:"menu-group"},f("h6",null,g.label),f("ul",null,g.items.map(m=>f("li",{key:m.key,"data-index":m.index,class:i.value===m.index?"hover":"",onPointerenter:k(m.index),onPointerdown:()=>{var w,v;(v=(w=a.value)==null?void 0:w.querySelector(`[data-index="${m.index}"]`))==null||v.classList.add("active")},onPointerup:()=>{var w,v;(v=(w=a.value)==null?void 0:w.querySelector(`[data-index="${m.index}"]`))==null||v.classList.remove("active"),p(m.index)}},f(xt,{icon:m.icon}),f("span",null,m.label))))))))}});var Ou=t=>{throw TypeError(t)},Hu=(t,e,n)=>e.has(t)||Ou("Cannot "+n),me=(t,e,n)=>(Hu(t,e,"read from private field"),n?n.call(t):e.get(t)),Vt=(t,e,n)=>e.has(t)?Ou("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Ue=(t,e,n,r)=>(Hu(t,e,"write to private field"),e.set(t,n),n),sn,Or,Hr,Re,Ct;const Ru=s1("CREPE_MENU"),Zs=A({show:()=>{},hide:()=>{}},"menuAPICtx");function gf(t,e){t.set(Ru.key,{view:n=>new ff(t,n,e)})}class ff{constructor(e,n,r){Vt(this,sn),Vt(this,Or),Vt(this,Hr),Vt(this,Re),Vt(this,Ct,null),this.update=d=>{me(this,Re).update(d)},this.show=d=>{Ue(this,Ct,d),me(this,Hr).value="",me(this,Re).show()},this.hide=()=>{Ue(this,Ct,null),me(this,Re).hide()},this.destroy=()=>{me(this,Re).destroy(),me(this,Or).unmount(),me(this,sn).remove()};const o=document.createElement("div");o.classList.add("milkdown-slash-menu");const a=I(!1),s=I("");Ue(this,Hr,s);const i=this.hide,l=ye(mf,{ctx:e,config:r,show:a,filter:s,hide:i});Ue(this,Or,l),l.mount(o),Ue(this,sn,o);const c=this;Ue(this,Re,new i1({content:me(this,sn),debounce:20,shouldShow(d){if(xu(d.state.selection)||Su(d.state.selection))return!1;const u=this.getContent(d,h=>["paragraph","heading"].includes(h.type.name));if(u==null||!vf(d.state.selection))return!1;const p=me(c,Ct);if(s.value=u.startsWith("/")?u.slice(1):u,typeof p=="number"){const h=d.state.doc.nodeSize-2,k=Math.min(p,h);return d.state.doc.resolve(k).node()!==d.state.doc.resolve(d.state.selection.from).node()?(Ue(c,Ct,null),!1):!0}return!!u.startsWith("/")},offset:10})),me(this,Re).onShow=()=>{a.value=!0},me(this,Re).onHide=()=>{a.value=!1},this.update(n),e.set(Zs.key,{show:d=>this.show(d),hide:()=>this.hide()})}}sn=new WeakMap;Or=new WeakMap;Hr=new WeakMap;Re=new WeakMap;Ct=new WeakMap;function vf(t){if(!(t instanceof W))return!1;const{$head:e}=t,n=e.parent;return e.parentOffset===n.content.size}const yf=J({props:{onAdd:{type:Function,required:!0},addIcon:{type:String,required:!0},handleIcon:{type:String,required:!0}},setup(t){const e=I();return()=>f(ct,null,f("div",{ref:e,class:"operation-item",onPointerdown:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.add("active")},onPointerup:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.remove("active"),t.onAdd()}},f(xt,{icon:t.addIcon})),f("div",{class:"operation-item"},f(xt,{icon:t.handleIcon})))}});var $u=t=>{throw TypeError(t)},Eu=(t,e,n)=>e.has(t)||$u("Cannot "+n),Ye=(t,e,n)=>(Eu(t,e,"read from private field"),n?n.call(t):e.get(t)),Yn=(t,e,n)=>e.has(t)?$u("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Xn=(t,e,n,r)=>(Eu(t,e,"write to private field"),e.set(t,n),n),Rr,et,$r,Er;class wf{constructor(e,n){Yn(this,Rr),Yn(this,et),Yn(this,$r),Yn(this,Er),this.update=()=>{Ye(this,et).update()},this.destroy=()=>{Ye(this,et).destroy(),Ye(this,Rr).remove(),Ye(this,$r).unmount()},this.onAdd=()=>{const c=Ye(this,Er),d=c.get(q);d.hasFocus()||d.focus();const{state:u,dispatch:p}=d,h=Ye(this,et).active;if(!h)return;const g=h.$pos.pos+h.node.nodeSize;let m=u.tr.insert(g,Ce.type(c).create());m=m.setSelection(W.near(m.doc.resolve(g))),p(m.scrollIntoView()),Ye(this,et).hide(),c.get(Zs.key).show(m.selection.from)};var r,o,a;Xn(this,Er,e);const s=document.createElement("div");s.classList.add("milkdown-block-handle");const i=ye(yf,{onAdd:this.onAdd,addIcon:(r=n?.handleAddIcon)!=null?r:sa,handleIcon:(o=n?.handleDragIcon)!=null?o:ef});i.mount(s),Xn(this,$r,i),Xn(this,Rr,s);const l=(a=n?.blockHandle)!=null?a:{};Xn(this,et,new Vh({ctx:e,content:s,getOffset:()=>16,getPlacement:({active:c,blockDom:d})=>{if(c.node.type.name==="heading")return"left";let u=0;c.node.descendants(b=>{u+=b.childCount});const p=c.el,h=p.getBoundingClientRect(),k=d.getBoundingClientRect(),g=window.getComputedStyle(p),m=Number.parseInt(g.paddingTop,10)||0,w=Number.parseInt(g.paddingBottom,10)||0,v=h.height-m-w,C=k.height;return u>2||C<v?"left-start":"left"},...l})),this.update()}}Rr=new WeakMap;et=new WeakMap;$r=new WeakMap;Er=new WeakMap;function kf(t,e){t.set(eo.key,{filterNodes:n=>!Ie(o=>["table","blockquote","math_inline"].includes(o.type.name))(n)}),t.set(ro.key,{view:()=>new wf(t,e)})}const Cf=(t,e)=>{t.config(Pe(D.BlockEdit)).config(n=>kf(n,e)).config(n=>gf(n,e)).use(Zs).use(ro).use(Ru)},bf=(t,e={})=>{t.config(Pe(D.CodeMirror)).config(n=>{const{languages:r=[],theme:o}=e,a=[Pc.of(xp.concat(Sp)),Pp];o&&a.push(o),e.extensions&&a.push(...e.extensions),n.update(Kn.key,s=>{var i;return{extensions:a,languages:r,expandIcon:e.expandIcon||ku,searchIcon:e.searchIcon||Mu,clearSearchIcon:e.clearSearchIcon||Cu,searchPlaceholder:e.searchPlaceholder||"Search language",copyText:e.copyText||"Copy",copyIcon:e.copyIcon||_u,onCopy:e.onCopy||(()=>{}),noResultText:e.noResultText||"No result",renderLanguage:e.renderLanguage||s.renderLanguage,renderPreview:e.renderPreview||s.renderPreview,previewToggleButton:l=>{var c,d;const u=((c=e.previewToggleIcon)==null?void 0:c.call(e,l))||(l?Ks:Nu),p=((d=e.previewToggleText)==null?void 0:d.call(e,l))||(l?"Edit":"Hide");return[u,p].map(h=>h.trim()).join(" ")},previewLabel:e.previewLabel||s.previewLabel,previewLoading:e.previewLoading||s.previewLoading,previewOnlyByDefault:(i=e.previewOnlyByDefault)!=null?i:s.previewOnlyByDefault}})}).use(om)},_f=(t,e)=>{if(t.config(Pe(D.Cursor)).config(r=>{r.update(mo.key,()=>{var o,a;return{class:"crepe-drop-cursor",width:(o=e?.width)!=null?o:4,color:(a=e?.color)!=null?a:!1}})}).use(im),e?.virtual===!1)return;const n=Mp();t.use(G(()=>n))},Mf=(t,e)=>{t.config(Pe(D.ImageBlock)).config(n=>{n.update(go.key,r=>{var o,a,s,i,l,c;return{uploadButton:(o=e?.inlineUploadButton)!=null?o:"Upload",imageIcon:(a=e?.inlineImageIcon)!=null?a:aa,confirmButton:(s=e?.inlineConfirmButton)!=null?s:Fs,uploadPlaceholderText:(i=e?.inlineUploadPlaceholderText)!=null?i:"or paste link",onUpload:(c=(l=e?.inlineOnUpload)!=null?l:e?.onUpload)!=null?c:r.onUpload,proxyDomURL:e?.proxyDomURL}}),n.update(co.key,r=>{var o,a,s,i,l,c,d,u;return{uploadButton:(o=e?.blockUploadButton)!=null?o:"Upload file",imageIcon:(a=e?.blockImageIcon)!=null?a:aa,captionIcon:(s=e?.blockCaptionIcon)!=null?s:jg,confirmButton:(i=e?.blockConfirmButton)!=null?i:"Confirm",captionPlaceholderText:(l=e?.blockCaptionPlaceholderText)!=null?l:"Write Image Caption",uploadPlaceholderText:(c=e?.blockUploadPlaceholderText)!=null?c:"or paste link",onUpload:(u=(d=e?.blockOnUpload)!=null?d:e?.onUpload)!=null?u:r.onUpload,proxyDomURL:e?.proxyDomURL}})}).use(S1).use(fm)},If=xe.extendSchema(t=>e=>{const n=t(e);return{...n,toMarkdown:{match:n.toMarkdown.match,runner:(r,o)=>{var a,s;if(((a=o.attrs.language)!=null?a:"").toLowerCase()==="latex")r.addNode("math",void 0,((s=o.content.firstChild)==null?void 0:s.text)||"");else return n.toMarkdown.runner(r,o)}}}}),ln="math_inline",Rn=F(ln,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${ln}"]`,getAttrs:t=>{var e;return{value:(e=t.dataset.value)!=null?e:""}}}],toDOM:t=>{const e=t.attrs.value,n=document.createElement("span");return n.dataset.type=ln,n.dataset.value=e,Tc.render(e,n,{throwOnError:!1}),n},parseMarkdown:{match:t=>t.type==="inlineMath",runner:(t,e,n)=>{t.addNode(n,{value:e.value})}},toMarkdown:{match:t=>t.type.name===ln,runner:(t,e)=>{t.addNode("inlineMath",void 0,e.attrs.value)}}})),Bu=P("ToggleLatex",t=>()=>(e,n)=>{const{hasNode:r,pos:o,target:a}=Kc(e,Rn.type(t)),{selection:s,doc:i,tr:l}=e;if(!r){const h=i.textBetween(s.from,s.to);let k=l.replaceSelectionWith(Rn.type(t).create({value:h}));return n&&n(k.setSelection(it.create(k.doc,s.from))),!0}const{from:c,to:d}=s;if(!a||o<0)return!1;let u=l.delete(o,o+1);const p=a.attrs.value;return u=u.insertText(p,o),n&&n(u.setSelection(W.create(u.doc,c,d+p.length-1))),!0}),wc=vo("INLINE_LATEX"),Nf=J({props:{config:{type:Object,required:!0},innerView:{type:Object,required:!0},updateValue:{type:Object,required:!0}},setup(t){const e=r=>{if(!(!r||!(r instanceof HTMLElement))){for(;r.firstChild;)r.removeChild(r.firstChild);t.innerView.value&&r.appendChild(t.innerView.value.dom)}},n=r=>{r.preventDefault(),t.updateValue.value()};return()=>f("div",{class:"container"},t.innerView&&f("div",{ref:e}),f("button",{type:"button",onPointerdown:n},f(xt,{icon:t.config.inlineEditConfirm})))}});var Au=t=>{throw TypeError(t)},Du=(t,e,n)=>e.has(t)||Au("Cannot "+n),z=(t,e,n)=>(Du(t,e,"read from private field"),n?n.call(t):e.get(t)),qe=(t,e,n)=>e.has(t)?Au("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Jn=(t,e,n,r)=>(Du(t,e,"write to private field"),e.set(t,n),n),cn,bt,Br,tt,dn,un,la,ca;class xf{constructor(e,n,r){this.ctx=e,qe(this,cn),qe(this,bt),qe(this,Br),qe(this,tt,qr(null)),qe(this,dn,qr(()=>{})),qe(this,un),qe(this,la,()=>{z(this,tt).value&&(z(this,tt).value.destroy(),z(this,tt).value=null)}),qe(this,ca,a=>{const i=(()=>{const{selection:l,schema:c}=a.state;if(l.empty||!(l instanceof it))return!1;const d=l.node;if(d.type.name!==ln)return!1;const u=l.from,p=c.nodes.paragraph.create(null,c.text(d.attrs.value)),h=new _c(z(this,Br),{state:ua.create({doc:p,schema:new Cc({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},text:{group:"inline"}}}),plugins:[bc({"Mod-z":va,"Mod-Z":Nn,"Mod-y":Nn,Enter:()=>(z(this,dn).value(),!0)})]})});return z(this,tt).value=h,z(this,dn).value=()=>{const{tr:k}=a.state;k.setNodeAttribute(u,"value",h.state.doc.textContent),a.dispatch(k),requestAnimationFrame(()=>{a.focus()})},!0})();return i||z(this,la).call(this),i}),this.update=(a,s)=>{z(this,bt).update(a,s)},this.destroy=()=>{z(this,un).unmount(),z(this,bt).destroy(),z(this,cn).remove()};const o=document.createElement("div");o.className="milkdown-latex-inline-edit",Jn(this,cn,o),Jn(this,un,ye(Nf,{config:r,innerView:z(this,tt),updateValue:z(this,dn)})),z(this,un).mount(o),Jn(this,bt,new fo({debounce:0,content:z(this,cn),shouldShow:z(this,ca),offset:10,floatingUIOptions:{placement:"bottom"}})),z(this,bt).update(n),Jn(this,Br,document.createElement("div"))}}cn=new WeakMap;bt=new WeakMap;Br=new WeakMap;tt=new WeakMap;dn=new WeakMap;un=new WeakMap;la=new WeakMap;ca=new WeakMap;const Sf=ee(t=>uh(/(?:\$)([^$]+)(?:\$)$/,Rn.type(t),{getAttr:e=>{var n;return{value:(n=e[1])!=null?n:""}}})),Lf=ee(t=>ha(/^\$\$[\s\n]$/,xe.type(t),()=>({language:"LaTeX"}))),Pf=Le("remarkMath",()=>Ep);function Tf(t){return $n(t,"math",(e,n,r)=>{const{value:o}=e,a={type:"code",lang:"LaTeX",value:o};r.children.splice(n,1,a)})}const Of=Le("remarkMathBlock",()=>()=>Tf),Hf=(t,e)=>{t.config(Pe(D.Latex)).config(n=>{if(!_o(n).get().includes(D.CodeMirror))throw new Error("You need to enable CodeMirror to use LaTeX feature");n.update(Kn.key,a=>({...a,renderPreview:(s,i,l)=>{if(s.toLowerCase()==="latex"&&i.length>0)return Rf(i,e?.katexOptions);const c=a.renderPreview;return c(s,i,l)}})),n.set(wc.key,{view:a=>{var s;return new xf(n,a,{inlineEditConfirm:(s=e?.inlineEditConfirm)!=null?s:Fs,...e})}})}).use(Pf).use(Of).use(Rn).use(wc).use(Sf).use(Lf).use(If).use(Bu)};function Rf(t,e){return Tc.renderToString(t,{...e,throwOnError:!1,displayMode:!0})}const $f=(t,e)=>{t.config(Pe(D.LinkTooltip)).config(Gm).config(n=>{n.update(Lt.key,r=>{var o,a,s,i,l,c;return{...r,linkIcon:(o=e?.linkIcon)!=null?o:_u,editButton:(a=e?.editButton)!=null?a:Ks,removeButton:(s=e?.removeButton)!=null?s:ia,confirmButton:(i=e?.confirmButton)!=null?i:Fs,inputPlaceholder:(l=e?.inputPlaceholder)!=null?l:"Paste link...",onCopyLink:(c=e?.onCopyLink)!=null?c:(()=>{})}})}).use(zm)};function Ef(t,e){t.set(wo.key,{renderLabel:({label:n,listType:r,checked:o})=>{var a,s,i;return o==null?r==="bullet"?(a=e?.bulletIcon)!=null?a:qg:n:o?(s=e?.checkBoxCheckedIcon)!=null?s:Wg:(i=e?.checkBoxUncheckedIcon)!=null?i:Fg}})}const Bf=(t,e)=>{t.config(Pe(D.ListItem)).config(n=>Ef(n,e)).use(tg)};function Af(t){var e;return t.childCount<=1&&!((e=t.firstChild)!=null&&e.content.size)}function Df(t,e){const{selection:n}=t;if(!n.empty)return null;const r=n.$anchor,o=r.parent;if(o.content.size>0||Ie(i=>i.type.name==="table")(r))return null;const s=r.before();return qo.node(s,s+o.nodeSize,{class:"crepe-placeholder","data-placeholder":e})}const da=A({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),qf=G(t=>new Y({key:new X("CREPE_PLACEHOLDER"),props:{decorations:e=>{var n;if(uf(t).readonly)return null;const o=t.get(da.key);if(o.mode==="doc"&&!Af(e.doc)||xu(e.selection)||Su(e.selection))return null;const a=(n=o.text)!=null?n:"Please enter...",s=Df(e,a);return s?Vo.create(e.doc,[s]):null}}})),Vf=(t,e)=>{t.config(Pe(D.Placeholder)).config(n=>{e&&n.update(da.key,r=>({...r,...e}))}).use(qf).use(da)},jf=(t,e)=>{t.config(Pe(D.Table)).config(n=>{n.update(ko.key,r=>({...r,renderButton:o=>{var a,s,i,l,c,d,u,p,h;switch(o){case"add_row":return(a=e?.addRowIcon)!=null?a:sa;case"add_col":return(s=e?.addColIcon)!=null?s:sa;case"delete_row":return(i=e?.deleteRowIcon)!=null?i:ia;case"delete_col":return(l=e?.deleteColIcon)!=null?l:ia;case"align_col_left":return(c=e?.alignLeftIcon)!=null?c:Bg;case"align_col_center":return(d=e?.alignCenterIcon)!=null?d:Eg;case"align_col_right":return(u=e?.alignRightIcon)!=null?u:Ag;case"col_drag_handle":return(p=e?.colDragHandleIcon)!=null?p:vc;case"row_drag_handle":return(h=e?.rowDragHandleIcon)!=null?h:vc}}}))}).use(Sg)};function Wf(t,e){var n,r,o,a,s,i,l;const c=new Tu;c.addGroup("formatting","Formatting").addItem("bold",{icon:(n=t?.boldIcon)!=null?n:Dg,active:h=>h.get(M).call(wt.key,Ht.type(h)),onRun:h=>{h.get(M).call(ao.key)}}).addItem("italic",{icon:(r=t?.italicIcon)!=null?r:Jg,active:h=>h.get(M).call(wt.key,dt.type(h)),onRun:h=>{h.get(M).call(oo.key)}}).addItem("strikethrough",{icon:(o=t?.strikethroughIcon)!=null?o:rf,active:h=>h.get(M).call(wt.key,Et.type(h)),onRun:h=>{h.get(M).call(po.key)}});const d=c.addGroup("function","Function");d.addItem("code",{icon:(a=t?.codeIcon)!=null?a:bu,active:h=>h.get(M).call(wt.key,$e.type(h)),onRun:h=>{h.get(M).call(so.key)}});const u=e&&_o(e).get();return u?.includes(D.Latex)&&d.addItem("latex",{icon:(s=t?.latexIcon)!=null?s:Iu,active:h=>h.get(M).call(_d.key,Rn.type(h)),onRun:h=>{h.get(M).call(Bu.key)}}),d.addItem("link",{icon:(i=t?.linkIcon)!=null?i:Qg,active:h=>h.get(M).call(wt.key,ve.type(h)),onRun:h=>{h.get(M).call(Yd.key)}}),(l=t?.buildToolbar)==null||l.call(t,c),c.build()}const Ff=J({props:{ctx:{type:Object,required:!0},hide:{type:Function,required:!0},show:{type:Object,required:!0},selection:{type:Object,required:!0},config:{type:Object,required:!1}},setup(t){const{ctx:e,config:n}=t,r=s=>i=>{i.preventDefault(),e&&s(e)};function o(s){return t.selection.value,e.get(Xo).status!==jr.Created?!1:s(e)}const a=xn(()=>Wf(n,e));return()=>f(ct,null,a.value.map(s=>s.items.map(i=>f("button",{type:"button",class:Q("toolbar-item",e&&o(i.active)&&"active"),onPointerdown:r(i.onRun)},f(xt,{icon:i.icon})))).reduce((s,i,l)=>(l===0?s.push(...i):s.push(f("div",{class:"divider"}),...i),s),[]))}});var qu=t=>{throw TypeError(t)},Vu=(t,e,n)=>e.has(t)||qu("Cannot "+n),ie=(t,e,n)=>(Vu(t,e,"read from private field"),n?n.call(t):e.get(t)),jt=(t,e,n)=>e.has(t)?qu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Qn=(t,e,n,r)=>(Vu(t,e,"write to private field"),e.set(t,n),n),We,pn,Ar,hn,mn;const kc=vo("CREPE_TOOLBAR");class Kf{constructor(e,n,r){jt(this,We),jt(this,pn),jt(this,Ar),jt(this,hn),jt(this,mn,I(!1)),this.update=(s,i)=>{ie(this,We).update(s,i),ie(this,hn).value=s.state.selection},this.destroy=()=>{ie(this,We).destroy(),ie(this,Ar).unmount(),ie(this,pn).remove()},this.hide=()=>{ie(this,We).hide()};const o=document.createElement("div");o.className="milkdown-toolbar",Qn(this,hn,qr(n.state.selection));const a=ye(Ff,{ctx:e,hide:this.hide,config:r,selection:ie(this,hn),show:ie(this,mn)});a.mount(o),Qn(this,pn,o),Qn(this,Ar,a),Qn(this,We,new fo({content:ie(this,pn),debounce:20,offset:10,shouldShow(s){const{doc:i,selection:l}=s.state,{empty:c,from:d,to:u}=l,p=!i.textBetween(d,u).length&&l instanceof W,h=!(l instanceof W),k=s.dom.getRootNode().activeElement,g=o.contains(k),m=!s.hasFocus()&&!g,w=!s.editable;return!(m||h||c||p||w)}})),ie(this,We).onShow=()=>{ie(this,mn).value=!0},ie(this,We).onHide=()=>{ie(this,mn).value=!1},this.update(n)}}We=new WeakMap;pn=new WeakMap;Ar=new WeakMap;hn=new WeakMap;mn=new WeakMap;const Zf=(t,e)=>{t.config(Pe(D.Toolbar)).config(n=>{n.set(kc.key,{view:r=>new Kf(n,r,e)})}).use(kc)};function Gf(t,e,n){switch(t){case D.CodeMirror:return bf(e,n);case D.ListItem:return Bf(e,n);case D.LinkTooltip:return $f(e,n);case D.ImageBlock:return Mf(e,n);case D.Cursor:return _f(e,n);case D.BlockEdit:return Cf(e,n);case D.Placeholder:return Vf(e,n);case D.Toolbar:return Zf(e,n);case D.Table:return jf(e,n);case D.Latex:return Hf(e,n)}}var ju=t=>{throw TypeError(t)},Wu=(t,e,n)=>e.has(t)||ju("Cannot "+n),le=(t,e,n)=>(Wu(t,e,"read from private field"),n?n.call(t):e.get(t)),Ao=(t,e,n)=>e.has(t)?ju("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Do=(t,e,n,r)=>(Wu(t,e,"write to private field"),e.set(t,n),n),ce,Dr,gn;class zf{constructor({root:e,defaultValue:n=""}={}){Ao(this,ce),Ao(this,Dr),Ao(this,gn,!0),this.addFeature=(o,a)=>(o(le(this,ce),a),this),this.create=()=>le(this,ce).create(),this.destroy=()=>le(this,ce).destroy(),this.setReadonly=o=>(Do(this,gn,!o),le(this,ce).action(a=>{le(this,ce).status===jr.Created&&a.get(q).setProps({editable:()=>!o})}),this),this.getMarkdown=()=>le(this,ce).action(Bh()),this.on=o=>le(this,ce).status!==jr.Created?(le(this,ce).config(a=>{const s=a.get(Fr);o(s)}),this):(le(this,ce).action(a=>{const s=a.get(Fr);o(s)}),this);var r;Do(this,Dr,(r=typeof e=="string"?document.querySelector(e):e)!=null?r:document.body),Do(this,ce,_a.make().config(o=>{o.inject(df,this),o.inject(cf,[])}).config(o=>{o.set(wr,le(this,Dr)),o.set(mr,n),o.set(bn,{editable:()=>le(this,gn)}),o.update(bo.key,a=>({...a,size:4}))}).use(a1).use(yu).use(Pg).use(Og).use(Rg).use(mu).use(W1))}get editor(){return le(this,ce)}get readonly(){return!le(this,gn)}}ce=new WeakMap;Dr=new WeakMap;gn=new WeakMap;class Uf extends zf{constructor({features:e={},featureConfigs:n={},...r}={}){super(r);const o=Tp(n,lf);Object.entries({...$g,...e}).filter(([,s])=>s).map(([s])=>s).forEach(s=>{const i=o[s];Gf(s,this.editor,i)})}}Uf.Feature=D;export{A as $,Uf as C,Ot as a,G as b,q as e,_t as p,k0 as r,Mt as s};