PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
← All changes | assets/milkdown.js +1 -1 2.11.0 → 2.10.01 View file →
@@ -1,5 +1,5 @@
1 -import{a3 as Gn,a4 as K,a5 as V,a6 as pa,a7 as xn,a8 as ua,a9 as ha,aa as ma,ab as Yl,ac as Fs,ad as Ks,ae as Jl,af as Vs,ag as Xl,ah as Ql,ai as Zl,aj as ec,ak as tc,al as nc,am as oc,an as ac,ao as rc,ap as ds,aq as Ao,ar as ga,as as sc,at as ic,au as lc,av as Bo,aw as $n,ax as cc,ay as Da,az as be,aA as Ho,aB as dc,aC as Us,aD as pc,aE as jo,aF as uc,aG as qs,aH as Wa,aI as hc,aJ as mc,aK as gc,aL as fc,aM as zs,aN as Ra,aO as Ot,aP as yc,aQ as kc,aR as vc,aS as wc,aT as $c,aU as Gs,aV as bc,aW as Nc,aX as Be,aY as Mc,aZ as Cc,a_ as xc,a$ as Ys,b0 as fa,b1 as ya,b2 as ka,b3 as Fo,b4 as oe,b5 as gn,b6 as fe,b7 as Do,b8 as Q,b9 as Sc,ba as Ic}from"./vendor.js?ver=2.11.0";import{R as Ko,r as Tc}from"./fcom-utils.js?ver=2.11.0";import{x as Sn,t as Qe,S as We,R as Js,r as Rt,y as _c,a5 as Vo,q as Oc,_ as Ec,g as Pc,s as Ct,T as Ba}from"./vue.js?ver=2.11.0";var q=(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))(q||{});let J=class extends Error{constructor(e,n){super(n),this.name="MilkdownError",this.code=e}};const Lc=(t,e)=>typeof e=="function"?"[Function]":e,Et=t=>JSON.stringify(t,Lc);function Ac(t){return new J(q.docTypeError,`Doc type error, unsupported type: ${Et(t)}`)}function Dc(t){return new J(q.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function Wc(t){return new J(q.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function Ha(){return new J(q.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Rc(...t){const e=t.reduce((n,o)=>{if(!o)return n;const a=r=>Array.isArray(r)?r.map(s=>a(s)).join(", "):r.toJSON?Et(r.toJSON()):r.spec?Et(r.spec):r.toString();return`${n}, ${a(o)}`},"Create prosemirror node from remark failed in parser");return new J(q.createNodeInParserFail,e)}function Xs(){return new J(q.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Bc(t){return new J(q.parserMatchError,`Cannot match target parser for node: ${Et(t)}.`)}function Hc(t){return new J(q.serializerMatchError,`Cannot match target serializer for node: ${Et(t)}.`)}function jc(t,e){return new J(q.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function le(t){return new J(q.expectDomTypeError,`Expect to be a dom, but get: ${Et(t)}.`)}function Fc(){return new J(q.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 Qs(t){return new J(q.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function Kc(t){return new J(q.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}var Zs=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},g=(t,e,n)=>(Zs(t,e,"read from private field"),n?n.call(t):e.get(t)),A=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},N=(t,e,n,o)=>(Zs(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);let ei=class{constructor(){this.sliceMap=new Map,this.get=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(o=>o.type.name===e):this.sliceMap.get(e.id);if(!n){const o=typeof e=="string"?e:e.name;throw Dc(o)}return n},this.remove=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(o=>o.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)}};var pe,Ce,Bt;let Vc=class{constructor(e,n,o){A(this,pe,void 0),A(this,Ce,void 0),A(this,Bt,void 0),N(this,pe,[]),N(this,Bt,()=>{g(this,pe).forEach(a=>a(g(this,Ce)))}),this.set=a=>{N(this,Ce,a),g(this,Bt).call(this)},this.get=()=>g(this,Ce),this.update=a=>{N(this,Ce,a(g(this,Ce))),g(this,Bt).call(this)},this.type=o,N(this,Ce,n),e.set(o.id,this)}on(e){return g(this,pe).push(e),()=>{N(this,pe,g(this,pe).filter(n=>n!==e))}}once(e){const n=this.on(o=>{e(o),n()});return n}off(e){N(this,pe,g(this,pe).filter(n=>n!==e))}offAll(){N(this,pe,[])}};pe=new WeakMap,Ce=new WeakMap,Bt=new WeakMap;let Uc=class{constructor(e,n){this.id=Symbol(`Context-${n}`),this.name=n,this._defaultValue=e,this._typeInfo=()=>{throw Ha()}}create(e,n=this._defaultValue){return new Vc(e,n,this)}};const M=(t,e)=>new Uc(t,e);var Yn,Jn,Xn,pt,Ht,qe,jt,Ft,Kt;let qc=class{constructor(e,n,o){A(this,Yn,void 0),A(this,Jn,void 0),A(this,Xn,void 0),A(this,pt,void 0),A(this,Ht,void 0),A(this,qe,void 0),A(this,jt,void 0),A(this,Ft,void 0),A(this,Kt,void 0),N(this,pt,new Set),N(this,Ht,new Set),N(this,qe,new Map),N(this,jt,new Map),this.read=()=>({metadata:g(this,Yn),injectedSlices:[...g(this,pt)].map(a=>({name:typeof a=="string"?a:a.name,value:g(this,Ft).call(this,a)})),consumedSlices:[...g(this,Ht)].map(a=>({name:typeof a=="string"?a:a.name,value:g(this,Ft).call(this,a)})),recordedTimers:[...g(this,qe)].map(([a,{duration:r}])=>({name:a.name,duration:r,status:g(this,Kt).call(this,a)})),waitTimers:[...g(this,jt)].map(([a,{duration:r}])=>({name:a.name,duration:r,status:g(this,Kt).call(this,a)}))}),this.onRecord=a=>{g(this,qe).set(a,{start:Date.now(),duration:0})},this.onClear=a=>{g(this,qe).delete(a)},this.onDone=a=>{const r=g(this,qe).get(a);r&&(r.duration=Date.now()-r.start)},this.onWait=(a,r)=>{const s=Date.now();r.finally(()=>{g(this,jt).set(a,{duration:Date.now()-s})})},this.onInject=a=>{g(this,pt).add(a)},this.onRemove=a=>{g(this,pt).delete(a)},this.onUse=a=>{g(this,Ht).add(a)},N(this,Ft,a=>g(this,Jn).get(a).get()),N(this,Kt,a=>g(this,Xn).get(a).status),N(this,Jn,e),N(this,Xn,n),N(this,Yn,o)}};Yn=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,pt=new WeakMap,Ht=new WeakMap,qe=new WeakMap,jt=new WeakMap,Ft=new WeakMap,Kt=new WeakMap;var xe,Se,Qn,te;const zc=class ti{constructor(e,n,o){A(this,xe,void 0),A(this,Se,void 0),A(this,Qn,void 0),A(this,te,void 0),this.produce=a=>a&&Object.keys(a).length?new ti(g(this,xe),g(this,Se),{...a}):this,this.inject=(a,r)=>{var s;const i=a.create(g(this,xe).sliceMap);return r!=null&&i.set(r),(s=g(this,te))==null||s.onInject(a),this},this.remove=a=>{var r;return g(this,xe).remove(a),(r=g(this,te))==null||r.onRemove(a),this},this.record=a=>{var r;return a.create(g(this,Se).store),(r=g(this,te))==null||r.onRecord(a),this},this.clearTimer=a=>{var r;return g(this,Se).remove(a),(r=g(this,te))==null||r.onClear(a),this},this.isInjected=a=>g(this,xe).has(a),this.isRecorded=a=>g(this,Se).has(a),this.use=a=>{var r;return(r=g(this,te))==null||r.onUse(a),g(this,xe).get(a)},this.get=a=>this.use(a).get(),this.set=(a,r)=>this.use(a).set(r),this.update=(a,r)=>this.use(a).update(r),this.timer=a=>g(this,Se).get(a),this.done=a=>{var r;this.timer(a).done(),(r=g(this,te))==null||r.onDone(a)},this.wait=a=>{var r;const s=this.timer(a).start();return(r=g(this,te))==null||r.onWait(a,s),s},this.waitTimers=async a=>{await Promise.all(this.get(a).map(r=>this.wait(r)))},N(this,xe,e),N(this,Se,n),N(this,Qn,o),o&&N(this,te,new qc(e,n,o))}get meta(){return g(this,Qn)}get inspector(){return g(this,te)}};xe=new WeakMap,Se=new WeakMap,Qn=new WeakMap,te=new WeakMap;let Gc=zc,Yc=class{constructor(){this.store=new Map,this.get=e=>{const n=this.store.get(e.id);if(!n)throw Wc(e.name);return n},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}};var ut,ze,Vt,Ie,Ut,Zn;let Jc=class{constructor(e,n){A(this,ut,void 0),A(this,ze,void 0),A(this,Vt,void 0),A(this,Ie,void 0),A(this,Ut,void 0),A(this,Zn,void 0),N(this,ut,null),N(this,ze,null),N(this,Ie,"pending"),this.start=()=>(g(this,ut)??N(this,ut,new Promise((o,a)=>{N(this,ze,r=>{r instanceof CustomEvent&&r.detail.id===g(this,Vt)&&(N(this,Ie,"resolved"),g(this,Ut).call(this),r.stopImmediatePropagation(),o())}),g(this,Zn).call(this,()=>{g(this,Ie)==="pending"&&N(this,Ie,"rejected"),g(this,Ut).call(this),a(new Error(`Timing ${this.type.name} timeout.`))}),N(this,Ie,"pending"),addEventListener(this.type.name,g(this,ze))})),g(this,ut)),this.done=()=>{const o=new CustomEvent(this.type.name,{detail:{id:g(this,Vt)}});dispatchEvent(o)},N(this,Ut,()=>{g(this,ze)&&removeEventListener(this.type.name,g(this,ze))}),N(this,Zn,o=>{setTimeout(()=>{o()},this.type.timeout)}),N(this,Vt,Symbol(n.name)),this.type=n,e.set(n.id,this)}get status(){return g(this,Ie)}};ut=new WeakMap,ze=new WeakMap,Vt=new WeakMap,Ie=new WeakMap,Ut=new WeakMap,Zn=new WeakMap;let Xc=class{constructor(e,n=3e3){this.create=o=>new Jc(o,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=n}};const He=(t,e=3e3)=>new Xc(t,e);var ni=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},w=(t,e,n)=>(ni(t,e,"read from private field"),n?n.call(t):e.get(t)),R=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},O=(t,e,n,o)=>(ni(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);let oi=class{},ai=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var n;(n=this.top())==null||n.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw Xs();return e}}},Qc=class ri extends oi{constructor(e,n,o){super(),this.type=e,this.content=n,this.attrs=o}push(e,...n){this.content.push(e,...n)}pop(){return this.content.pop()}static create(e,n,o){return new ri(e,n,o)}};var ue,qt,eo,to,no,zt,Gt;const va=class extends ai{constructor(e){super(),R(this,ue,void 0),R(this,qt,void 0),R(this,eo,void 0),R(this,to,void 0),R(this,no,void 0),R(this,zt,void 0),R(this,Gt,void 0),O(this,ue,Gn.none),O(this,qt,n=>n.isText),O(this,eo,(n,o)=>{if(w(this,qt).call(this,n)&&w(this,qt).call(this,o)&&Gn.sameSet(n.marks,o.marks))return this.schema.text(n.text+o.text,n.marks)}),O(this,to,n=>{const o=Object.values({...this.schema.nodes,...this.schema.marks}).find(a=>a.spec.parseMarkdown.match(n));if(!o)throw Bc(n);return o}),O(this,no,n=>{const o=w(this,to).call(this,n);o.spec.parseMarkdown.runner(this,n,o)}),this.injectRoot=(n,o,a)=>(this.openNode(o,a),this.next(n.children),this),this.openNode=(n,o)=>(this.open(Qc.create(n,[],o)),this),O(this,zt,()=>{O(this,ue,Gn.none);const n=this.close();return w(this,Gt).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>(w(this,zt).call(this),this),O(this,Gt,(n,o,a)=>{const r=n.createAndFill(o,a,w(this,ue));if(!r)throw Rc(n,o,a);return this.push(r),r}),this.addNode=(n,o,a)=>(w(this,Gt).call(this,n,o,a),this),this.openMark=(n,o)=>{const a=n.create(o);return O(this,ue,a.addToSet(w(this,ue))),this},this.closeMark=n=>(O(this,ue,n.removeFromSet(w(this,ue))),this),this.addText=n=>{const o=this.top();if(!o)throw Xs();const a=o.pop(),r=this.schema.text(n,w(this,ue));if(!a)return o.push(r),this;const s=w(this,eo).call(this,a,r);return s?(o.push(s),this):(o.push(a,r),this)},this.build=()=>{let n;do n=w(this,zt).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(o=>w(this,no).call(this,o)),this),this.toDoc=()=>this.build(),this.run=(n,o)=>{const a=n.runSync(n.parse(o),o);return this.next(a),this},this.schema=e}};ue=new WeakMap,qt=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,zt=new WeakMap,Gt=new WeakMap,va.create=(t,e)=>{const n=new va(t);return o=>(n.run(e,o),n.toDoc())};let Zc=va;const wa=class extends oi{constructor(e,n,o,a={}){super(),this.type=e,this.children=n,this.value=o,this.props=a,this.push=(r,...s)=>{this.children||(this.children=[]),this.children.push(r,...s)},this.pop=()=>{var r;return(r=this.children)==null?void 0:r.pop()}}};wa.create=(t,e,n,o={})=>new wa(t,e,n,o);let ps=wa;const ed=t=>Object.prototype.hasOwnProperty.call(t,"size");var we,Yt,oo,ao,Jt,ro,Xt,so,io,ht,Ge,lo,Qt;const $a=class extends ai{constructor(e){super(),R(this,we,void 0),R(this,Yt,void 0),R(this,oo,void 0),R(this,ao,void 0),R(this,Jt,void 0),R(this,ro,void 0),R(this,Xt,void 0),R(this,so,void 0),R(this,io,void 0),R(this,ht,void 0),R(this,Ge,void 0),R(this,lo,void 0),R(this,Qt,void 0),O(this,we,Gn.none),O(this,Yt,n=>{const o=Object.values({...this.schema.nodes,...this.schema.marks}).find(a=>a.spec.toMarkdown.match(n));if(!o)throw Hc(n.type);return o}),O(this,oo,n=>w(this,Yt).call(this,n).spec.toMarkdown.runner(this,n)),O(this,ao,(n,o)=>w(this,Yt).call(this,n).spec.toMarkdown.runner(this,n,o)),O(this,Jt,n=>{const{marks:o}=n,a=r=>r.type.spec.priority??50;[...o].sort((r,s)=>a(r)-a(s)).every(r=>!w(this,ao).call(this,r,n))&&w(this,oo).call(this,n),o.forEach(r=>w(this,Qt).call(this,r))}),O(this,ro,(n,o)=>{var a;if(n.type===o||((a=n.children)==null?void 0:a.length)!==1)return n;const r=c=>{var d;if(c.type===o)return c;if(((d=c.children)==null?void 0:d.length)!==1)return null;const[p]=c.children;return p?r(p):null},s=r(n);if(!s)return n;const i=s.children?[...s.children]:void 0,l={...n,children:i};return l.children=i,s.children=[l],s}),O(this,Xt,n=>{const{children:o}=n;return o&&(n.children=o.reduce((a,r,s)=>{if(s===0)return[r];const i=a.at(-1);if(i&&i.isMark&&r.isMark){r=w(this,ro).call(this,r,i.type);const{children:l,...c}=r,{children:d,...p}=i;if(r.type===i.type&&l&&d&&JSON.stringify(c)===JSON.stringify(p)){const h={...p,children:[...d,...l]};return a.slice(0,-1).concat(w(this,Xt).call(this,h))}}return a.concat(r)},[])),n}),O(this,so,n=>{const o={...n.props,type:n.type};return n.children&&(o.children=n.children),n.value&&(o.value=n.value),o}),this.openNode=(n,o,a)=>(this.open(ps.create(n,void 0,o,a)),this),O(this,io,(n,o)=>{let a="",r="";const s=n.children;let i=-1,l=-1;const c=p=>{p&&p.forEach((h,m)=>{h.type==="text"&&h.value&&(i<0&&(i=m),l=m)})};if(s){c(s);const p=s==null?void 0:s[l],h=s==null?void 0:s[i];p&&p.value.endsWith(" ")&&(r=p.value.match(/ +$/)[0],p.value=p.value.trimEnd()),h&&h.value.startsWith(" ")&&(a=h.value.match(/^ +/)[0],h.value=h.value.trimStart())}a.length&&w(this,Ge).call(this,"text",void 0,a);const d=o();return r.length&&w(this,Ge).call(this,"text",void 0,r),d}),O(this,ht,(n=!1)=>{const o=this.close(),a=()=>w(this,Ge).call(this,o.type,o.children,o.value,o.props);return n?w(this,io).call(this,o,a):a()}),this.closeNode=()=>(w(this,ht).call(this),this),O(this,Ge,(n,o,a,r)=>{const s=ps.create(n,o,a,r),i=w(this,Xt).call(this,w(this,so).call(this,s));return this.push(i),i}),this.addNode=(n,o,a,r)=>(w(this,Ge).call(this,n,o,a,r),this),O(this,lo,(n,o,a,r)=>n.isInSet(w(this,we))?this:(O(this,we,n.addToSet(w(this,we))),this.openNode(o,a,{...r,isMark:!0}))),O(this,Qt,n=>{n.isInSet(w(this,we))&&(O(this,we,n.type.removeFromSet(w(this,we))),w(this,ht).call(this,!0))}),this.withMark=(n,o,a,r)=>(w(this,lo).call(this,n,o,a,r),this),this.closeMark=n=>(w(this,Qt).call(this,n),this),this.build=()=>{let n=null;do n=w(this,ht).call(this);while(this.size());return n},this.next=n=>ed(n)?(n.forEach(o=>{w(this,Jt).call(this,o)}),this):(w(this,Jt).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(this.next(n),this),this.schema=e}};we=new WeakMap,Yt=new WeakMap,oo=new WeakMap,ao=new WeakMap,Jt=new WeakMap,ro=new WeakMap,Xt=new WeakMap,so=new WeakMap,io=new WeakMap,ht=new WeakMap,Ge=new WeakMap,lo=new WeakMap,Qt=new WeakMap,$a.create=(t,e)=>{const n=new $a(t);return o=>(n.run(o),n.toString(e))};let td=$a;const Re=typeof navigator<"u"?navigator:null,us=typeof document<"u"?document:null,je=Re&&Re.userAgent||"",ba=/Edge\/(\d+)/.exec(je),si=/MSIE \d/.exec(je),Na=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(je),Uo=!!(si||Na||ba),nd=si?document.documentMode:Na?+Na[1]:ba?+ba[1]:0,ii=!Uo&&/gecko\/(\d+)/i.test(je),od=ii&&+(/Firefox\/(\d+)/.exec(je)||[0,0])[1],Ma=!Uo&&/Chrome\/(\d+)/.exec(je),ad=!!Ma,rd=Ma?+Ma[1]:0,li=!Uo&&!!Re&&/Apple Computer/.test(Re.vendor),ci=li&&(/Mobile\/\w+/.test(je)||!!Re&&Re.maxTouchPoints>2),sd=ci||(Re?/Mac/.test(Re.platform):!1),id=/Android \d/.test(je),di=!!us&&"webkitFontSmoothing"in us.documentElement.style,ld=di?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var Vn=Object.freeze({__proto__:null,android:id,chrome:ad,chrome_version:rd,gecko:ii,gecko_version:od,ie:Uo,ie_version:nd,ios:ci,mac:sd,safari:li,webkit:di,webkit_version:ld});function Zo(t,e,n,o,a,r){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,"")+o;for(let c=0;c<a.length;c++){const d=a[c].match.exec(l),p=d&&d[0]&&a[c].handler(s,d,e-(d[0].length-o.length),n);if(p)return t.dispatch(p.setMeta(r,{transform:p,from:e,to:n,text:o})),!0}return!1}const cd=new K("MILKDOWN_CUSTOM_INPUTRULES");function dd({rules:t}){const e=new V({key:cd,isInputRules:!0,state:{init(){return null},apply(n,o){const a=n.getMeta(this);return a||(n.selectionSet||n.docChanged?null:o)}},props:{handleTextInput(n,o,a,r){return Zo(n,o,a,r,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:o}=n.state.selection;o&&Zo(n,o.pos,o.pos,"",t,e)}),!1)},handleKeyDown(n,o){if(o.key!=="Enter")return!1;const{$cursor:a}=n.state.selection;return a?Zo(n,a.pos,a.pos,`
1 +import{a3 as Gn,a4 as K,a5 as V,a6 as pa,a7 as xn,a8 as ua,a9 as ha,aa as ma,ab as Yl,ac as Fs,ad as Ks,ae as Jl,af as Vs,ag as Xl,ah as Ql,ai as Zl,aj as ec,ak as tc,al as nc,am as oc,an as ac,ao as rc,ap as ds,aq as Ao,ar as ga,as as sc,at as ic,au as lc,av as Bo,aw as $n,ax as cc,ay as Da,az as be,aA as Ho,aB as dc,aC as Us,aD as pc,aE as jo,aF as uc,aG as qs,aH as Wa,aI as hc,aJ as mc,aK as gc,aL as fc,aM as zs,aN as Ra,aO as Ot,aP as yc,aQ as kc,aR as vc,aS as wc,aT as $c,aU as Gs,aV as bc,aW as Nc,aX as Be,aY as Mc,aZ as Cc,a_ as xc,a$ as Ys,b0 as fa,b1 as ya,b2 as ka,b3 as Fo,b4 as oe,b5 as gn,b6 as fe,b7 as Do,b8 as Q,b9 as Sc,ba as Ic}from"./vendor.js?ver=2.10.01";import{R as Ko,r as Tc}from"./fcom-utils.js?ver=2.10.01";import{x as Sn,t as Qe,S as We,R as Js,r as Rt,y as _c,a5 as Vo,q as Oc,_ as Ec,g as Pc,s as Ct,T as Ba}from"./vue.js?ver=2.10.01";var q=(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))(q||{});let J=class extends Error{constructor(e,n){super(n),this.name="MilkdownError",this.code=e}};const Lc=(t,e)=>typeof e=="function"?"[Function]":e,Et=t=>JSON.stringify(t,Lc);function Ac(t){return new J(q.docTypeError,`Doc type error, unsupported type: ${Et(t)}`)}function Dc(t){return new J(q.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function Wc(t){return new J(q.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function Ha(){return new J(q.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Rc(...t){const e=t.reduce((n,o)=>{if(!o)return n;const a=r=>Array.isArray(r)?r.map(s=>a(s)).join(", "):r.toJSON?Et(r.toJSON()):r.spec?Et(r.spec):r.toString();return`${n}, ${a(o)}`},"Create prosemirror node from remark failed in parser");return new J(q.createNodeInParserFail,e)}function Xs(){return new J(q.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Bc(t){return new J(q.parserMatchError,`Cannot match target parser for node: ${Et(t)}.`)}function Hc(t){return new J(q.serializerMatchError,`Cannot match target serializer for node: ${Et(t)}.`)}function jc(t,e){return new J(q.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function le(t){return new J(q.expectDomTypeError,`Expect to be a dom, but get: ${Et(t)}.`)}function Fc(){return new J(q.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 Qs(t){return new J(q.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function Kc(t){return new J(q.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}var Zs=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},g=(t,e,n)=>(Zs(t,e,"read from private field"),n?n.call(t):e.get(t)),A=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},N=(t,e,n,o)=>(Zs(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);let ei=class{constructor(){this.sliceMap=new Map,this.get=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(o=>o.type.name===e):this.sliceMap.get(e.id);if(!n){const o=typeof e=="string"?e:e.name;throw Dc(o)}return n},this.remove=e=>{const n=typeof e=="string"?[...this.sliceMap.values()].find(o=>o.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)}};var pe,Ce,Bt;let Vc=class{constructor(e,n,o){A(this,pe,void 0),A(this,Ce,void 0),A(this,Bt,void 0),N(this,pe,[]),N(this,Bt,()=>{g(this,pe).forEach(a=>a(g(this,Ce)))}),this.set=a=>{N(this,Ce,a),g(this,Bt).call(this)},this.get=()=>g(this,Ce),this.update=a=>{N(this,Ce,a(g(this,Ce))),g(this,Bt).call(this)},this.type=o,N(this,Ce,n),e.set(o.id,this)}on(e){return g(this,pe).push(e),()=>{N(this,pe,g(this,pe).filter(n=>n!==e))}}once(e){const n=this.on(o=>{e(o),n()});return n}off(e){N(this,pe,g(this,pe).filter(n=>n!==e))}offAll(){N(this,pe,[])}};pe=new WeakMap,Ce=new WeakMap,Bt=new WeakMap;let Uc=class{constructor(e,n){this.id=Symbol(`Context-${n}`),this.name=n,this._defaultValue=e,this._typeInfo=()=>{throw Ha()}}create(e,n=this._defaultValue){return new Vc(e,n,this)}};const M=(t,e)=>new Uc(t,e);var Yn,Jn,Xn,pt,Ht,qe,jt,Ft,Kt;let qc=class{constructor(e,n,o){A(this,Yn,void 0),A(this,Jn,void 0),A(this,Xn,void 0),A(this,pt,void 0),A(this,Ht,void 0),A(this,qe,void 0),A(this,jt,void 0),A(this,Ft,void 0),A(this,Kt,void 0),N(this,pt,new Set),N(this,Ht,new Set),N(this,qe,new Map),N(this,jt,new Map),this.read=()=>({metadata:g(this,Yn),injectedSlices:[...g(this,pt)].map(a=>({name:typeof a=="string"?a:a.name,value:g(this,Ft).call(this,a)})),consumedSlices:[...g(this,Ht)].map(a=>({name:typeof a=="string"?a:a.name,value:g(this,Ft).call(this,a)})),recordedTimers:[...g(this,qe)].map(([a,{duration:r}])=>({name:a.name,duration:r,status:g(this,Kt).call(this,a)})),waitTimers:[...g(this,jt)].map(([a,{duration:r}])=>({name:a.name,duration:r,status:g(this,Kt).call(this,a)}))}),this.onRecord=a=>{g(this,qe).set(a,{start:Date.now(),duration:0})},this.onClear=a=>{g(this,qe).delete(a)},this.onDone=a=>{const r=g(this,qe).get(a);r&&(r.duration=Date.now()-r.start)},this.onWait=(a,r)=>{const s=Date.now();r.finally(()=>{g(this,jt).set(a,{duration:Date.now()-s})})},this.onInject=a=>{g(this,pt).add(a)},this.onRemove=a=>{g(this,pt).delete(a)},this.onUse=a=>{g(this,Ht).add(a)},N(this,Ft,a=>g(this,Jn).get(a).get()),N(this,Kt,a=>g(this,Xn).get(a).status),N(this,Jn,e),N(this,Xn,n),N(this,Yn,o)}};Yn=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,pt=new WeakMap,Ht=new WeakMap,qe=new WeakMap,jt=new WeakMap,Ft=new WeakMap,Kt=new WeakMap;var xe,Se,Qn,te;const zc=class ti{constructor(e,n,o){A(this,xe,void 0),A(this,Se,void 0),A(this,Qn,void 0),A(this,te,void 0),this.produce=a=>a&&Object.keys(a).length?new ti(g(this,xe),g(this,Se),{...a}):this,this.inject=(a,r)=>{var s;const i=a.create(g(this,xe).sliceMap);return r!=null&&i.set(r),(s=g(this,te))==null||s.onInject(a),this},this.remove=a=>{var r;return g(this,xe).remove(a),(r=g(this,te))==null||r.onRemove(a),this},this.record=a=>{var r;return a.create(g(this,Se).store),(r=g(this,te))==null||r.onRecord(a),this},this.clearTimer=a=>{var r;return g(this,Se).remove(a),(r=g(this,te))==null||r.onClear(a),this},this.isInjected=a=>g(this,xe).has(a),this.isRecorded=a=>g(this,Se).has(a),this.use=a=>{var r;return(r=g(this,te))==null||r.onUse(a),g(this,xe).get(a)},this.get=a=>this.use(a).get(),this.set=(a,r)=>this.use(a).set(r),this.update=(a,r)=>this.use(a).update(r),this.timer=a=>g(this,Se).get(a),this.done=a=>{var r;this.timer(a).done(),(r=g(this,te))==null||r.onDone(a)},this.wait=a=>{var r;const s=this.timer(a).start();return(r=g(this,te))==null||r.onWait(a,s),s},this.waitTimers=async a=>{await Promise.all(this.get(a).map(r=>this.wait(r)))},N(this,xe,e),N(this,Se,n),N(this,Qn,o),o&&N(this,te,new qc(e,n,o))}get meta(){return g(this,Qn)}get inspector(){return g(this,te)}};xe=new WeakMap,Se=new WeakMap,Qn=new WeakMap,te=new WeakMap;let Gc=zc,Yc=class{constructor(){this.store=new Map,this.get=e=>{const n=this.store.get(e.id);if(!n)throw Wc(e.name);return n},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}};var ut,ze,Vt,Ie,Ut,Zn;let Jc=class{constructor(e,n){A(this,ut,void 0),A(this,ze,void 0),A(this,Vt,void 0),A(this,Ie,void 0),A(this,Ut,void 0),A(this,Zn,void 0),N(this,ut,null),N(this,ze,null),N(this,Ie,"pending"),this.start=()=>(g(this,ut)??N(this,ut,new Promise((o,a)=>{N(this,ze,r=>{r instanceof CustomEvent&&r.detail.id===g(this,Vt)&&(N(this,Ie,"resolved"),g(this,Ut).call(this),r.stopImmediatePropagation(),o())}),g(this,Zn).call(this,()=>{g(this,Ie)==="pending"&&N(this,Ie,"rejected"),g(this,Ut).call(this),a(new Error(`Timing ${this.type.name} timeout.`))}),N(this,Ie,"pending"),addEventListener(this.type.name,g(this,ze))})),g(this,ut)),this.done=()=>{const o=new CustomEvent(this.type.name,{detail:{id:g(this,Vt)}});dispatchEvent(o)},N(this,Ut,()=>{g(this,ze)&&removeEventListener(this.type.name,g(this,ze))}),N(this,Zn,o=>{setTimeout(()=>{o()},this.type.timeout)}),N(this,Vt,Symbol(n.name)),this.type=n,e.set(n.id,this)}get status(){return g(this,Ie)}};ut=new WeakMap,ze=new WeakMap,Vt=new WeakMap,Ie=new WeakMap,Ut=new WeakMap,Zn=new WeakMap;let Xc=class{constructor(e,n=3e3){this.create=o=>new Jc(o,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=n}};const He=(t,e=3e3)=>new Xc(t,e);var ni=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},w=(t,e,n)=>(ni(t,e,"read from private field"),n?n.call(t):e.get(t)),R=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},O=(t,e,n,o)=>(ni(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);let oi=class{},ai=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var n;(n=this.top())==null||n.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw Xs();return e}}},Qc=class ri extends oi{constructor(e,n,o){super(),this.type=e,this.content=n,this.attrs=o}push(e,...n){this.content.push(e,...n)}pop(){return this.content.pop()}static create(e,n,o){return new ri(e,n,o)}};var ue,qt,eo,to,no,zt,Gt;const va=class extends ai{constructor(e){super(),R(this,ue,void 0),R(this,qt,void 0),R(this,eo,void 0),R(this,to,void 0),R(this,no,void 0),R(this,zt,void 0),R(this,Gt,void 0),O(this,ue,Gn.none),O(this,qt,n=>n.isText),O(this,eo,(n,o)=>{if(w(this,qt).call(this,n)&&w(this,qt).call(this,o)&&Gn.sameSet(n.marks,o.marks))return this.schema.text(n.text+o.text,n.marks)}),O(this,to,n=>{const o=Object.values({...this.schema.nodes,...this.schema.marks}).find(a=>a.spec.parseMarkdown.match(n));if(!o)throw Bc(n);return o}),O(this,no,n=>{const o=w(this,to).call(this,n);o.spec.parseMarkdown.runner(this,n,o)}),this.injectRoot=(n,o,a)=>(this.openNode(o,a),this.next(n.children),this),this.openNode=(n,o)=>(this.open(Qc.create(n,[],o)),this),O(this,zt,()=>{O(this,ue,Gn.none);const n=this.close();return w(this,Gt).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>(w(this,zt).call(this),this),O(this,Gt,(n,o,a)=>{const r=n.createAndFill(o,a,w(this,ue));if(!r)throw Rc(n,o,a);return this.push(r),r}),this.addNode=(n,o,a)=>(w(this,Gt).call(this,n,o,a),this),this.openMark=(n,o)=>{const a=n.create(o);return O(this,ue,a.addToSet(w(this,ue))),this},this.closeMark=n=>(O(this,ue,n.removeFromSet(w(this,ue))),this),this.addText=n=>{const o=this.top();if(!o)throw Xs();const a=o.pop(),r=this.schema.text(n,w(this,ue));if(!a)return o.push(r),this;const s=w(this,eo).call(this,a,r);return s?(o.push(s),this):(o.push(a,r),this)},this.build=()=>{let n;do n=w(this,zt).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(o=>w(this,no).call(this,o)),this),this.toDoc=()=>this.build(),this.run=(n,o)=>{const a=n.runSync(n.parse(o),o);return this.next(a),this},this.schema=e}};ue=new WeakMap,qt=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,zt=new WeakMap,Gt=new WeakMap,va.create=(t,e)=>{const n=new va(t);return o=>(n.run(e,o),n.toDoc())};let Zc=va;const wa=class extends oi{constructor(e,n,o,a={}){super(),this.type=e,this.children=n,this.value=o,this.props=a,this.push=(r,...s)=>{this.children||(this.children=[]),this.children.push(r,...s)},this.pop=()=>{var r;return(r=this.children)==null?void 0:r.pop()}}};wa.create=(t,e,n,o={})=>new wa(t,e,n,o);let ps=wa;const ed=t=>Object.prototype.hasOwnProperty.call(t,"size");var we,Yt,oo,ao,Jt,ro,Xt,so,io,ht,Ge,lo,Qt;const $a=class extends ai{constructor(e){super(),R(this,we,void 0),R(this,Yt,void 0),R(this,oo,void 0),R(this,ao,void 0),R(this,Jt,void 0),R(this,ro,void 0),R(this,Xt,void 0),R(this,so,void 0),R(this,io,void 0),R(this,ht,void 0),R(this,Ge,void 0),R(this,lo,void 0),R(this,Qt,void 0),O(this,we,Gn.none),O(this,Yt,n=>{const o=Object.values({...this.schema.nodes,...this.schema.marks}).find(a=>a.spec.toMarkdown.match(n));if(!o)throw Hc(n.type);return o}),O(this,oo,n=>w(this,Yt).call(this,n).spec.toMarkdown.runner(this,n)),O(this,ao,(n,o)=>w(this,Yt).call(this,n).spec.toMarkdown.runner(this,n,o)),O(this,Jt,n=>{const{marks:o}=n,a=r=>r.type.spec.priority??50;[...o].sort((r,s)=>a(r)-a(s)).every(r=>!w(this,ao).call(this,r,n))&&w(this,oo).call(this,n),o.forEach(r=>w(this,Qt).call(this,r))}),O(this,ro,(n,o)=>{var a;if(n.type===o||((a=n.children)==null?void 0:a.length)!==1)return n;const r=c=>{var d;if(c.type===o)return c;if(((d=c.children)==null?void 0:d.length)!==1)return null;const[p]=c.children;return p?r(p):null},s=r(n);if(!s)return n;const i=s.children?[...s.children]:void 0,l={...n,children:i};return l.children=i,s.children=[l],s}),O(this,Xt,n=>{const{children:o}=n;return o&&(n.children=o.reduce((a,r,s)=>{if(s===0)return[r];const i=a.at(-1);if(i&&i.isMark&&r.isMark){r=w(this,ro).call(this,r,i.type);const{children:l,...c}=r,{children:d,...p}=i;if(r.type===i.type&&l&&d&&JSON.stringify(c)===JSON.stringify(p)){const h={...p,children:[...d,...l]};return a.slice(0,-1).concat(w(this,Xt).call(this,h))}}return a.concat(r)},[])),n}),O(this,so,n=>{const o={...n.props,type:n.type};return n.children&&(o.children=n.children),n.value&&(o.value=n.value),o}),this.openNode=(n,o,a)=>(this.open(ps.create(n,void 0,o,a)),this),O(this,io,(n,o)=>{let a="",r="";const s=n.children;let i=-1,l=-1;const c=p=>{p&&p.forEach((h,m)=>{h.type==="text"&&h.value&&(i<0&&(i=m),l=m)})};if(s){c(s);const p=s==null?void 0:s[l],h=s==null?void 0:s[i];p&&p.value.endsWith(" ")&&(r=p.value.match(/ +$/)[0],p.value=p.value.trimEnd()),h&&h.value.startsWith(" ")&&(a=h.value.match(/^ +/)[0],h.value=h.value.trimStart())}a.length&&w(this,Ge).call(this,"text",void 0,a);const d=o();return r.length&&w(this,Ge).call(this,"text",void 0,r),d}),O(this,ht,(n=!1)=>{const o=this.close(),a=()=>w(this,Ge).call(this,o.type,o.children,o.value,o.props);return n?w(this,io).call(this,o,a):a()}),this.closeNode=()=>(w(this,ht).call(this),this),O(this,Ge,(n,o,a,r)=>{const s=ps.create(n,o,a,r),i=w(this,Xt).call(this,w(this,so).call(this,s));return this.push(i),i}),this.addNode=(n,o,a,r)=>(w(this,Ge).call(this,n,o,a,r),this),O(this,lo,(n,o,a,r)=>n.isInSet(w(this,we))?this:(O(this,we,n.addToSet(w(this,we))),this.openNode(o,a,{...r,isMark:!0}))),O(this,Qt,n=>{n.isInSet(w(this,we))&&(O(this,we,n.type.removeFromSet(w(this,we))),w(this,ht).call(this,!0))}),this.withMark=(n,o,a,r)=>(w(this,lo).call(this,n,o,a,r),this),this.closeMark=n=>(w(this,Qt).call(this,n),this),this.build=()=>{let n=null;do n=w(this,ht).call(this);while(this.size());return n},this.next=n=>ed(n)?(n.forEach(o=>{w(this,Jt).call(this,o)}),this):(w(this,Jt).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(this.next(n),this),this.schema=e}};we=new WeakMap,Yt=new WeakMap,oo=new WeakMap,ao=new WeakMap,Jt=new WeakMap,ro=new WeakMap,Xt=new WeakMap,so=new WeakMap,io=new WeakMap,ht=new WeakMap,Ge=new WeakMap,lo=new WeakMap,Qt=new WeakMap,$a.create=(t,e)=>{const n=new $a(t);return o=>(n.run(o),n.toString(e))};let td=$a;const Re=typeof navigator<"u"?navigator:null,us=typeof document<"u"?document:null,je=Re&&Re.userAgent||"",ba=/Edge\/(\d+)/.exec(je),si=/MSIE \d/.exec(je),Na=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(je),Uo=!!(si||Na||ba),nd=si?document.documentMode:Na?+Na[1]:ba?+ba[1]:0,ii=!Uo&&/gecko\/(\d+)/i.test(je),od=ii&&+(/Firefox\/(\d+)/.exec(je)||[0,0])[1],Ma=!Uo&&/Chrome\/(\d+)/.exec(je),ad=!!Ma,rd=Ma?+Ma[1]:0,li=!Uo&&!!Re&&/Apple Computer/.test(Re.vendor),ci=li&&(/Mobile\/\w+/.test(je)||!!Re&&Re.maxTouchPoints>2),sd=ci||(Re?/Mac/.test(Re.platform):!1),id=/Android \d/.test(je),di=!!us&&"webkitFontSmoothing"in us.documentElement.style,ld=di?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var Vn=Object.freeze({__proto__:null,android:id,chrome:ad,chrome_version:rd,gecko:ii,gecko_version:od,ie:Uo,ie_version:nd,ios:ci,mac:sd,safari:li,webkit:di,webkit_version:ld});function Zo(t,e,n,o,a,r){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,"")+o;for(let c=0;c<a.length;c++){const d=a[c].match.exec(l),p=d&&d[0]&&a[c].handler(s,d,e-(d[0].length-o.length),n);if(p)return t.dispatch(p.setMeta(r,{transform:p,from:e,to:n,text:o})),!0}return!1}const cd=new K("MILKDOWN_CUSTOM_INPUTRULES");function dd({rules:t}){const e=new V({key:cd,isInputRules:!0,state:{init(){return null},apply(n,o){const a=n.getMeta(this);return a||(n.selectionSet||n.docChanged?null:o)}},props:{handleTextInput(n,o,a,r){return Zo(n,o,a,r,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:o}=n.state.selection;o&&Zo(n,o.pos,o.pos,"",t,e)}),!1)},handleKeyDown(n,o){if(o.key!=="Enter")return!1;const{$cursor:a}=n.state.selection;return a?Zo(n,a.pos,a.pos,`
2 2 `,t,e):!1}}});return e}function In(t,e,n={}){return new xn(t,(o,a,r,s)=>{var i,l,c,d;const{tr:p}=o,h=a.length;let m=a[h-1],f=a[0],$=[],E=s;const x={group:m,fullMatch:f,start:r,end:s},H=(i=n.updateCaptured)==null?void 0:i.call(n,x);if(Object.assign(x,H),{group:m,fullMatch:f,start:r,end:s}=x,f===null||(m==null?void 0:m.trim())==="")return null;if(m){const D=f.search(/\S/),_=r+f.indexOf(m),ee=_+m.length;$=(l=p.storedMarks)!=null?l:[],ee<s&&p.delete(ee,s),_>r&&p.delete(r+D,_),E=r+D+m.length;const ke=(c=n.getAttr)==null?void 0:c.call(n,a);p.addMark(r,E,e.create(ke)),p.setStoredMarks($),(d=n.beforeDispatch)==null||d.call(n,{match:a,start:r,end:s,tr:p})}return p})}var pd=Object.defineProperty,ud=Object.defineProperties,hd=Object.getOwnPropertyDescriptors,hs=Object.getOwnPropertySymbols,md=Object.prototype.hasOwnProperty,gd=Object.prototype.propertyIsEnumerable,ms=(t,e,n)=>e in t?pd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fd=(t,e)=>{for(var n in e||(e={}))md.call(e,n)&&ms(t,n,e[n]);if(hs)for(var n of hs(e))gd.call(e,n)&&ms(t,n,e[n]);return t},yd=(t,e)=>ud(t,hd(e));function gs(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function qo(t,e,n){const a=t.state.doc.content.size,r=gs(e,0,a),s=gs(n,0,a),i=t.coordsAtPos(r),l=t.coordsAtPos(s,-1),c=Math.min(i.top,l.top),d=Math.max(i.bottom,l.bottom),p=Math.min(i.left,l.left),h=Math.max(i.right,l.right),m=h-p,f=d-c,x={top:c,bottom:d,left:p,right:h,width:m,height:f,x:p,y:c};return yd(fd({},x),{toJSON:()=>x})}function zo(t){return Object.assign(Object.create(t),t).setTime(Date.now())}function kd(t,e){return Array.isArray(t)&&t.includes(e.type)||e.type===t}function pi(t){return e=>{for(let n=e.depth;n>0;n-=1){const o=e.node(n);if(t(o)){const a=e.before(n),r=e.after(n);return{from:a,to:r,node:o}}}}}function vd(t,e){return pi(n=>n.type===e)(t)}function wd(t,e){const n=e.nodes[t];if(!n)throw jc("node",t);return n}function ja(t){return e=>{for(let n=e.depth;n>0;n--){const o=e.node(n);if(t(o))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:o}}}}function $d(t){return e=>ja(t)(e.$from)}function bd(t,e){if(!(t instanceof pa))return;const{node:n,$from:o}=t;if(kd(e,n))return{node:n,pos:o.pos,start:o.start(o.depth),depth:o.depth}}var ui=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},y=(t,e,n)=>(ui(t,e,"read from private field"),n?n.call(t):e.get(t)),j=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},L=(t,e,n,o)=>(ui(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);function Fe(t,e){return t.meta={package:"@milkdown/core",group:"System",...e},t}const hi={strong:(t,e,n,o)=>{const a=t.marker||n.options.strong||"*",r=n.enter("strong"),s=n.createTracker(o);let i=s.move(a+a);return i+=s.move(n.containerPhrasing(t,{before:i,after:a,...s.current()})),i+=s.move(a+a),r(),i},emphasis:(t,e,n,o)=>{const a=t.marker||n.options.emphasis||"*",r=n.enter("emphasis"),s=n.createTracker(o);let i=s.move(a);return i+=s.move(n.containerPhrasing(t,{before:i,after:a,...s.current()})),i+=s.move(a),r(),i}},ae=M({},"editorView"),Zt=M({},"editorState"),ea=M([],"initTimer"),fs=M({},"editor"),bn=M([],"inputRules"),ie=M([],"prosePlugins"),Nn=M([],"remarkPlugins"),Mn=M([],"nodeView"),Cn=M([],"markView"),Ze=M(ua().use(ha).use(ma),"remark"),fn=M({handlers:hi},"remarkStringifyOptions"),co=He("ConfigReady");function Nd(t){const e=n=>(n.record(co),async()=>(await t(n),n.done(co),()=>{n.clearTimer(co)}));return Fe(e,{displayName:"Config"}),e}const et=He("InitReady");function Md(t){const e=n=>(n.inject(fs,t).inject(ie,[]).inject(Nn,[]).inject(bn,[]).inject(Mn,[]).inject(Cn,[]).inject(fn,{handlers:hi}).inject(Ze,ua().use(ha).use(ma)).inject(ea,[co]).record(et),async()=>{await n.waitTimers(ea);const o=n.get(fn);return n.set(Ze,ua().use(ha).use(ma,o)),n.done(et),()=>{n.remove(fs).remove(ie).remove(Nn).remove(bn).remove(Mn).remove(Cn).remove(fn).remove(Ze).remove(ea).clearTimer(et)}});return Fe(e,{displayName:"Init"}),e}const re=He("SchemaReady"),ta=M([],"schemaTimer"),se=M({},"schema"),St=M([],"nodes"),It=M([],"marks");function ys(t){var e;return{...t,parseDOM:(e=t.parseDOM)==null?void 0:e.map(n=>({priority:t.priority,...n}))}}const mi=t=>(t.inject(se,{}).inject(St,[]).inject(It,[]).inject(ta,[et]).record(re),async()=>{await t.waitTimers(ta);const e=t.get(Ze),n=t.get(Nn).reduce((s,i)=>s.use(i.plugin,i.options),e);t.set(Ze,n);const o=Object.fromEntries(t.get(St).map(([s,i])=>[s,ys(i)])),a=Object.fromEntries(t.get(It).map(([s,i])=>[s,ys(i)])),r=new Yl({nodes:o,marks:a});return t.set(se,r),t.done(re),()=>{t.remove(se).remove(St).remove(It).remove(ta).clearTimer(re)}});Fe(mi,{displayName:"Schema"});var mt,Ye;let gi=class{constructor(){j(this,mt,void 0),j(this,Ye,void 0),L(this,mt,new ei),L(this,Ye,null),this.setCtx=e=>{L(this,Ye,e)}}get ctx(){return y(this,Ye)}create(e,n){const o=e.create(y(this,mt).sliceMap);return o.set(n),o}get(e){return y(this,mt).get(e).get()}remove(e){return y(this,mt).remove(e)}call(e,n){if(y(this,Ye)==null)throw Fc();const o=this.get(e)(n),a=y(this,Ye).get(ae);return o(a.state,a.dispatch,a)}};mt=new WeakMap,Ye=new WeakMap;function Cd(t="cmdKey"){return M(()=>()=>!1,t)}const C=M(new gi,"commands"),na=M([re],"commandsTimer"),yn=He("CommandsReady"),fi=t=>{const e=new gi;return e.setCtx(t),t.inject(C,e).inject(na,[re]).record(yn),async()=>(await t.waitTimers(na),t.done(yn),()=>{t.remove(C).remove(na).clearTimer(yn)})};Fe(fi,{displayName:"Commands"});const po=He("ParserReady"),yi=()=>{throw Ha()},Tt=M(yi,"parser"),oa=M([],"parserTimer"),ki=t=>(t.inject(Tt,yi).inject(oa,[re]).record(po),async()=>{await t.waitTimers(oa);const e=t.get(Ze),n=t.get(se);return t.set(Tt,Zc.create(n,e)),t.done(po),()=>{t.remove(Tt).remove(oa).clearTimer(po)}});Fe(ki,{displayName:"Parser"});const kn=He("SerializerReady"),aa=M([],"serializerTimer"),vi=()=>{throw Ha()},_t=M(vi,"serializer"),wi=t=>(t.inject(_t,vi).inject(aa,[re]).record(kn),async()=>{await t.waitTimers(aa);const e=t.get(Ze),n=t.get(se);return t.set(_t,td.create(n,e)),t.done(kn),()=>{t.remove(_t).remove(aa).clearTimer(kn)}});Fe(wi,{displayName:"Serializer"});const ra=M("","defaultValue"),uo=M(t=>t,"stateOptions"),sa=M([],"editorStateTimer"),ho=He("EditorStateReady");function xd(t,e,n){if(typeof t=="string")return e(t);if(t.type==="html")return Vs.fromSchema(n).parse(t.dom);if(t.type==="json")return Xl.fromJSON(n,t.value);throw Ac(t)}const Sd=new K("MILKDOWN_STATE_TRACKER");function Id(t){const e=Zl(oc,nc,tc,ec);return t.Backspace=e,t}const $i=t=>(t.inject(ra,"").inject(Zt,{}).inject(uo,e=>e).inject(sa,[po,kn,yn]).record(ho),async()=>{await t.waitTimers(sa);const e=t.get(se),n=t.get(Tt),o=t.get(bn),a=t.get(uo),r=t.get(ie),s=t.get(ra),i=xd(s,n,e),l=[...r,new V({key:Sd,state:{init:()=>{},apply:(p,h,m,f)=>{t.set(Zt,f)}}}),dd({rules:o}),Fs(Id(Ql))];t.set(ie,l);const c=a({schema:e,doc:i,plugins:l}),d=Ks.create(c);return t.set(Zt,d),t.done(ho),()=>{t.remove(ra).remove(Zt).remove(uo).remove(sa).clearTimer(ho)}});Fe($i,{displayName:"EditorState"});const mo=He("EditorViewReady"),ia=M([],"editorViewTimer"),go=M({},"editorViewOptions"),la=M(null,"root"),Ca=M(null,"rootDOM"),xa=M({},"rootAttrs");function Td(t,e){const n=document.createElement("div");n.className="milkdown",t.appendChild(n),e.set(Ca,n);const o=e.get(xa);return Object.entries(o).forEach(([a,r])=>n.setAttribute(a,r)),n}function _d(t){t.classList.add("editor"),t.setAttribute("role","textbox")}const Od=new K("MILKDOWN_VIEW_CLEAR"),bi=t=>(t.inject(la,document.body).inject(ae,{}).inject(go,{}).inject(Ca,null).inject(xa,{}).inject(ia,[ho]).record(mo),async()=>{await t.wait(et);const e=t.get(la)||document.body,n=typeof e=="string"?document.querySelector(e):e;t.update(ie,l=>[new V({key:Od,view:c=>{const d=n?Td(n,t):void 0;return(()=>{if(d&&n){const p=c.dom;n.replaceChild(d,p),d.appendChild(p)}})(),{destroy:()=>{d!=null&&d.parentNode&&(d==null||d.parentNode.replaceChild(c.dom,d)),d==null||d.remove()}}}}),...l]),await t.waitTimers(ia);const o=t.get(Zt),a=t.get(go),r=Object.fromEntries(t.get(Mn)),s=Object.fromEntries(t.get(Cn)),i=new Jl(n,{state:o,nodeViews:r,markViews:s,...a});return _d(i.dom),t.set(ae,i),t.done(mo),()=>{i==null||i.destroy(),t.remove(la).remove(ae).remove(go).remove(Ca).remove(xa).remove(ia).clearTimer(mo)}});Fe(bi,{displayName:"EditorView"});var gt,X,Te,en,fo,yo,Y,_e,ft,ko,yt,tn,vo,Je,nn;const Ed=class Ni{constructor(){j(this,gt,void 0),j(this,X,void 0),j(this,Te,void 0),j(this,en,void 0),j(this,fo,void 0),j(this,yo,void 0),j(this,Y,void 0),j(this,_e,void 0),j(this,ft,void 0),j(this,ko,void 0),j(this,yt,void 0),j(this,tn,void 0),j(this,vo,void 0),j(this,Je,void 0),j(this,nn,void 0),L(this,gt,!1),L(this,X,"Idle"),L(this,Te,[]),L(this,en,()=>{}),L(this,fo,new ei),L(this,yo,new Yc),L(this,Y,new Map),L(this,_e,new Map),L(this,ft,new Gc(y(this,fo),y(this,yo))),L(this,ko,()=>{const e=Nd(async o=>{await Promise.all(y(this,Te).map(a=>a(o)))}),n=[mi,ki,wi,fi,$i,bi,Md(this),e];y(this,yt).call(this,n,y(this,_e))}),L(this,yt,(e,n)=>{e.forEach(o=>{const a=y(this,ft).produce(y(this,gt)?o.meta:void 0),r=o(a);n.set(o,{ctx:a,handler:r,cleanup:void 0})})}),L(this,tn,(e,n=!1)=>Promise.all([e].flat().map(o=>{const a=y(this,Y).get(o),r=a==null?void 0:a.cleanup;return n?y(this,Y).delete(o):y(this,Y).set(o,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof r=="function"?r():r}))),L(this,vo,async()=>{await Promise.all([...y(this,_e).entries()].map(([e,{cleanup:n}])=>typeof n=="function"?n():n)),y(this,_e).clear()}),L(this,Je,e=>{L(this,X,e),y(this,en).call(this,e)}),L(this,nn,e=>[...e.entries()].map(async([n,o])=>{const{ctx:a,handler:r}=o;if(!r)return;const s=await r();e.set(n,{ctx:a,handler:r,cleanup:s})})),this.enableInspector=(e=!0)=>(L(this,gt,e),this),this.onStatusChange=e=>(L(this,en,e),this),this.config=e=>(y(this,Te).push(e),this),this.removeConfig=e=>(L(this,Te,y(this,Te).filter(n=>n!==e)),this),this.use=e=>{const n=[e].flat();return n.flat().forEach(o=>{y(this,Y).set(o,{ctx:void 0,handler:void 0,cleanup:void 0})}),y(this,X)==="Created"&&y(this,yt).call(this,n,y(this,Y)),this},this.remove=async e=>y(this,X)==="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 y(this,tn).call(this,[e].flat(),!0),this),this.create=async()=>y(this,X)==="OnCreate"?this:(y(this,X)==="Created"&&await this.destroy(),y(this,Je).call(this,"OnCreate"),y(this,ko).call(this),y(this,yt).call(this,[...y(this,Y).keys()],y(this,Y)),await Promise.all([y(this,nn).call(this,y(this,_e)),y(this,nn).call(this,y(this,Y))].flat()),y(this,Je).call(this,"Created"),this),this.destroy=async(e=!1)=>y(this,X)==="Destroyed"||y(this,X)==="OnDestroy"?this:y(this,X)==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(e))},50)}):(e&&L(this,Te,[]),y(this,Je).call(this,"OnDestroy"),await y(this,tn).call(this,[...y(this,Y).keys()],e),await y(this,vo).call(this),y(this,Je).call(this,"Destroyed"),this),this.action=e=>e(y(this,ft)),this.inspect=()=>y(this,gt)?[...y(this,_e).values(),...y(this,Y).values()].map(({ctx:e})=>{var n;return(n=e==null?void 0:e.inspector)==null?void 0:n.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 Ni}get ctx(){return y(this,ft)}get status(){return y(this,X)}};gt=new WeakMap,X=new WeakMap,Te=new WeakMap,en=new WeakMap,fo=new WeakMap,yo=new WeakMap,Y=new WeakMap,_e=new WeakMap,ft=new WeakMap,ko=new WeakMap,yt=new WeakMap,tn=new WeakMap,vo=new WeakMap,Je=new WeakMap,nn=new WeakMap;let rh=Ed;ac("abcedfghicklmn",10);function v(t,e){const n=Cd(t),o=a=>async()=>{o.key=n,await a.wait(yn);const r=e(a);return a.get(C).create(n,r),o.run=s=>a.get(C).call(t,s),()=>{a.get(C).remove(n)}};return o}function z(t){const e=n=>async()=>{await n.wait(re);const o=t(n);return n.update(bn,a=>[...a,o]),e.inputRule=o,()=>{n.update(bn,a=>a.filter(r=>r!==o))}};return e}function Pd(t,e){const n=o=>async()=>{const a=e(o);return o.update(It,r=>[...r.filter(s=>s[0]!==t),[t,a]]),n.id=t,n.schema=a,()=>{o.update(It,r=>r.filter(([s])=>s!==t))}};return n.type=o=>{const a=o.get(se).marks[t];if(!a)throw Kc(t);return a},n}function Fa(t,e){const n=o=>async()=>{const a=e(o);return o.update(St,r=>[...r.filter(s=>s[0]!==t),[t,a]]),n.id=t,n.schema=a,()=>{o.update(St,r=>r.filter(([s])=>s!==t))}};return n.type=o=>{const a=o.get(se).nodes[t];if(!a)throw Qs(t);return a},n}function U(t){let e;const n=o=>async()=>(await o.wait(re),e=t(o),o.update(ie,a=>[...a,e]),()=>{o.update(ie,a=>a.filter(r=>r!==e))});return n.plugin=()=>e,n.key=()=>e.spec.key,n}function Ld(t){const e=n=>async()=>{await n.wait(re);const o=t(n),a=Fs(o);return n.update(ie,r=>[...r,a]),e.keymap=o,()=>{n.update(ie,r=>r.filter(s=>s!==a))}};return e}function Mi(t,e){const n=o=>async()=>{await o.wait(re);const a=e(o);return t.type(o)instanceof ds?o.update(Mn,r=>[...r,[t.id,a]]):o.update(Cn,r=>[...r,[t.id,a]]),n.view=a,n.type=t,()=>{t.type(o)instanceof ds?o.update(Mn,r=>r.filter(s=>s[0]!==t.id)):o.update(Cn,r=>r.filter(s=>s[0]!==t.id))}};return n}function W(t,e){const n=M(t,e),o=a=>(a.inject(n),()=>()=>{a.remove(n)});return o.key=n,o}function B(t,e){const n=W(e,t),o=Fa(t,r=>r.get(n.key)(r)),a=[n,o];return a.id=o.id,a.node=o,a.type=r=>o.type(r),a.schema=o.schema,a.ctx=n,a.key=n.key,a.extendSchema=r=>s=>()=>{const i=s.get(n.key),l=r(i)(s);s.update(St,c=>[...c.filter(d=>d[0]!==t),[t,l]]),a.schema=l},a}function Tn(t,e){const n=W(e,t),o=Pd(t,r=>r.get(n.key)(r)),a=[n,o];return a.id=o.id,a.mark=o,a.type=o.type,a.schema=o.schema,a.ctx=n,a.key=n.key,a.extendSchema=r=>s=>()=>{const i=s.get(n.key),l=r(i)(s);s.update(It,c=>[...c.filter(d=>d[0]!==t),[t,l]]),a.schema=l},a}function G(t,e){const n=Object.fromEntries(Object.entries(e).map(([s,{shortcuts:i}])=>[s,i])),o=W(n,`${t}Keymap`),a=Ld(s=>{const i=s.get(o.key),l=Object.entries(e).flatMap(([c,{command:d}])=>[i[c]].flat().map(p=>[p,d(s)]));return Object.fromEntries(l)}),r=[o,a];return r.ctx=o,r.shortcuts=a,r.key=o.key,r.keymap=a.keymap,r}const ce=(t,e=()=>({}))=>W(e,`${t}Attr`),_n=(t,e=()=>({}))=>W(e,`${t}Attr`);function nt(t,e,n){const o=W(n??{},t),a=s=>async()=>{await s.wait(et);const i={plugin:e(s),options:s.get(o.key)};return s.update(Nn,l=>[...l,i]),()=>{s.update(Nn,l=>l.filter(c=>c!==i))}},r=[o,a];return r.id=t,r.plugin=a,r.options=o,r}function sh(){return t=>{const e=t.get(ae);return t.get(_t)(e.state.doc)}}function ih(t,e=!1){return n=>{const o=n.get(ae),a=n.get(Tt)(t);if(!a)return;if(!e){const{state:c}=o;return o.dispatch(c.tr.replace(0,c.doc.content.size,new rc(a.content,0,0)))}const r=n.get(se),s=n.get(uo),i=n.get(ie),l=Ks.create({schema:r,doc:a,plugins:i,...s});o.updateState(l)}}function Ci(t,e){var n;if(!(e.childCount>=1&&((n=e.lastChild)==null?void 0:n.type.name)==="hardbreak")){t.next(e.content);return}const o=[];e.content.forEach((a,r,s)=>{s!==e.childCount-1&&o.push(a)}),t.next(lc.fromArray(o))}function u(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}const Ka=_n("emphasis");u(Ka,{displayName:"Attr<emphasis>",group:"Emphasis"});const Pt=Tn("emphasis",t=>({attrs:{marker:{default:t.get(fn).emphasis||"*"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(Ka.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,n,o)=>{e.openMark(o,{marker:n.marker}),e.next(n.children),e.closeMark(o)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,n)=>{e.withMark(n,"emphasis",void 0,{marker:n.attrs.marker})}}}));u(Pt.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});u(Pt.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const Va=v("ToggleEmphasis",t=>()=>Bo(Pt.type(t)));u(Va,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const xi=z(t=>In(/(?:^|[^*])\*([^*]+)\*$/,Pt.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:n+1}}));u(xi,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const Si=z(t=>In(/(?:^|[^_])_([^_]+)_$/,Pt.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:n+1}}));u(Si,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const Ua=G("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{const e=t.get(C);return()=>e.call(Va.key)}}});u(Ua.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});u(Ua.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const qa=_n("strong");u(qa,{displayName:"Attr<strong>",group:"Strong"});const On=Tn("strong",t=>({attrs:{marker:{default:t.get(fn).strong||"*"}},parseDOM:[{tag:"b"},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"}],toDOM:e=>["strong",t.get(qa.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,n,o)=>{e.openMark(o,{marker:n.marker}),e.next(n.children),e.closeMark(o)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,n)=>{e.withMark(n,"strong",void 0,{marker:n.attrs.marker})}}}));u(On.mark,{displayName:"MarkSchema<strong>",group:"Strong"});u(On.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const za=v("ToggleStrong",t=>()=>Bo(On.type(t)));u(za,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const Ii=z(t=>In(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,On.type(t),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));u(Ii,{displayName:"InputRule<strong>",group:"Strong"});const Ga=G("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{const e=t.get(C);return()=>e.call(za.key)}}});u(Ga.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});u(Ga.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const Ya=_n("inlineCode");u(Ya,{displayName:"Attr<inlineCode>",group:"InlineCode"});const De=Tn("inlineCode",t=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(Ya.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,n,o)=>{e.openMark(o),e.addText(n.value),e.closeMark(o)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,n,o)=>{e.withMark(n,"inlineCode",o.text||"")}}}));u(De.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});u(De.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const Ja=v("ToggleInlineCode",t=>()=>(e,n)=>{const{selection:o,tr:a}=e;if(o.empty)return!1;const{from:r,to:s}=o;return e.doc.rangeHasMark(r,s,De.type(t))?(n==null||n(a.removeMark(r,s,De.type(t))),!0):(Object.keys(e.schema.marks).filter(i=>i!==De.type.name).map(i=>e.schema.marks[i]).forEach(i=>{a.removeMark(r,s,i)}),n==null||n(a.addMark(r,s,De.type(t).create())),!0)});u(Ja,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const Ti=z(t=>In(/(?:\`)([^\`]+)(?:\`)$/,De.type(t)));u(Ti,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const Xa=G("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{const e=t.get(C);return()=>e.call(Ja.key)}}});u(Xa.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});u(Xa.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const Qa=_n("link");u(Qa,{displayName:"Attr<link>",group:"Link"});const $e=Tn("link",t=>({attrs:{href:{},title:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(Qa.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,n,o)=>{const a=n.url,r=n.title;e.openMark(o,{href:a,title:r}),e.next(n.children),e.closeMark(o)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,n)=>{e.withMark(n,"link",void 0,{title:n.attrs.title,url:n.attrs.href})}}}));u($e.mark,{displayName:"MarkSchema<link>",group:"Link"});const _i=v("ToggleLink",t=>(e={})=>Bo($e.type(t),e));u(_i,{displayName:"Command<toggleLinkCommand>",group:"Link"});const Oi=v("UpdateLink",t=>(e={})=>(n,o)=>{if(!o)return!1;let a,r=-1;const{selection:s}=n,{from:i,to:l}=s;if(n.doc.nodesBetween(i,i===l?l+1:l,(f,$)=>{if($e.type(t).isInSet(f.marks))return a=f,r=$,!1}),!a)return!1;const c=a.marks.find(({type:f})=>f===$e.type(t));if(!c)return!1;const d=r,p=r+a.nodeSize,{tr:h}=n,m=$e.type(t).create({...c.attrs,...e});return m?(o(h.removeMark(d,p,c).addMark(d,p,m).setSelection(new be(h.selection.$anchor)).scrollIntoView()),!0):!1});u(Oi,{displayName:"Command<updateLinkCommand>",group:"Link"});const Ei=Fa("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)}}}));u(Ei,{displayName:"NodeSchema<doc>",group:"Doc"});const Za=ce("paragraph");u(Za,{displayName:"Attr<paragraph>",group:"Paragraph"});const Ke=B("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(Za.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,n,o)=>{e.openNode(o),n.children?e.next(n.children):e.addText(n.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,n)=>{e.openNode("paragraph"),Ci(e,n),e.closeNode()}}}));u(Ke.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});u(Ke.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const er=v("TurnIntoText",t=>()=>$n(Ke.type(t)));u(er,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const tr=G("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{const e=t.get(C);return()=>e.call(er.key)}}});u(tr.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});u(tr.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const Ad=Array(6).fill(0).map((t,e)=>e+1);function Dd(t){return cc(t.textContent)}const Go=W(Dd,"headingIdGenerator");u(Go,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const nr=ce("heading");u(nr,{displayName:"Attr<heading>",group:"Heading"});const ot=B("heading",t=>{const e=t.get(Go.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:""},level:{default:1}},parseDOM:Ad.map(n=>({tag:`h${n}`,getAttrs:o=>{if(!(o instanceof HTMLElement))throw le(o);return{level:n,id:o.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...t.get(nr.key)(n),id:n.attrs.id||e(n)},0],parseMarkdown:{match:({type:n})=>n==="heading",runner:(n,o,a)=>{const r=o.depth;n.openNode(a,{level:r}),n.next(o.children),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="heading",runner:(n,o)=>{n.openNode("heading",void 0,{depth:o.attrs.level}),Ci(n,o),n.closeNode()}}}});u(ot.node,{displayName:"NodeSchema<heading>",group:"Heading"});u(ot.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const Pi=z(t=>qs(/^(?<hashes>#+)\s$/,ot.type(t),e=>{var n,o;const a=((o=(n=e.groups)==null?void 0:n.hashes)==null?void 0:o.length)||0,r=t.get(ae),{$from:s}=r.state.selection,i=s.node();if(i.type.name==="heading"){let l=Number(i.attrs.level)+Number(a);return l>6&&(l=6),{level:l}}return{level:a}}));u(Pi,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const Le=v("WrapInHeading",t=>e=>(e??(e=1),e<1?$n(Ke.type(t)):$n(ot.type(t),{level:e})));u(Le,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const or=v("DowngradeHeading",t=>()=>(e,n,o)=>{const{$from:a}=e.selection,r=a.node();if(r.type!==ot.type(t)||!e.selection.empty||a.parentOffset!==0)return!1;const s=r.attrs.level-1;return s?(n==null||n(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...r.attrs,level:s})),!0):$n(Ke.type(t))(e,n,o)});u(or,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const ar=G("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{const e=t.get(C);return()=>e.call(Le.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{const e=t.get(C);return()=>e.call(Le.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{const e=t.get(C);return()=>e.call(Le.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{const e=t.get(C);return()=>e.call(Le.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{const e=t.get(C);return()=>e.call(Le.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{const e=t.get(C);return()=>e.call(Le.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{const e=t.get(C);return()=>e.call(or.key)}}});u(ar.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});u(ar.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const rr=ce("blockquote");u(rr,{displayName:"Attr<blockquote>",group:"Blockquote"});const En=B("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(rr.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,n,o)=>{e.openNode(o).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,n)=>{e.openNode("blockquote").next(n.content).closeNode()}}}));u(En.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});u(En.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const Li=z(t=>Wa(/^\s*>\s$/,En.type(t)));u(Li,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const sr=v("WrapInBlockquote",t=>()=>Da(En.type(t)));u(sr,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const ir=G("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{const e=t.get(C);return()=>e.call(sr.key)}}});u(ir.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});u(ir.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const lr=ce("codeBlock",()=>({pre:{},code:{}}));u(lr,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const Pn=B("code_block",t=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{language:e.dataset.language}}}],toDOM:e=>{const n=t.get(lr.key)(e);return["pre",{...n.pre,"data-language":e.attrs.language},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,n,o)=>{const a=n.lang,r=n.value;e.openNode(o,{language:a}),r&&e.addText(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,n)=>{var o;e.addNode("code",void 0,((o=n.content.firstChild)==null?void 0:o.text)||"",{lang:n.attrs.language})}}}));u(Pn.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});u(Pn.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const Ai=z(t=>qs(/^```(?<language>[a-z]*)?[\s\n]$/,Pn.type(t),e=>{var n;return{language:((n=e.groups)==null?void 0:n.language)??""}}));u(Ai,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const cr=v("CreateCodeBlock",t=>(e="")=>$n(Pn.type(t),{language:e}));u(cr,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const Wd=v("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(n,o)=>t>=0?(o==null||o(n.tr.setNodeAttribute(t,"language",e)),!0):!1);u(Wd,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const dr=G("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{const e=t.get(C);return()=>e.call(cr.key)}}});u(dr.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});u(dr.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const pr=ce("image");u(pr,{displayName:"Attr<image>",group:"Image"});const at=B("image",t=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(pr.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,n,o)=>{const a=n.url,r=n.alt,s=n.title;e.addNode(o,{src:a,alt:r,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})}}}));u(at.node,{displayName:"NodeSchema<image>",group:"Image"});u(at.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const Di=v("InsertImage",t=>(e={})=>(n,o)=>{if(!o)return!0;const{src:a="",alt:r="",title:s=""}=e,i=at.type(t).create({src:a,alt:r,title:s});return i&&o(n.tr.replaceSelectionWith(i).scrollIntoView()),!0});u(Di,{displayName:"Command<insertImageCommand>",group:"Image"});const Wi=v("UpdateImage",t=>(e={})=>(n,o)=>{const a=bd(n.selection,at.type(t));if(!a)return!1;const{node:r,pos:s}=a,i={...r.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),o==null||o(n.tr.setNodeMarkup(s,void 0,i).scrollIntoView()),!0});u(Wi,{displayName:"Command<updateImageCommand>",group:"Image"});const Rd=z(t=>new xn(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,n,o,a)=>{const[r,s,i="",l]=n;return r?e.tr.replaceWith(o,a,at.type(t).create({src:i,alt:s,title:l})):null}));u(Rd,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const Wo=ce("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));u(Wo,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const tt=B("hardbreak",t=>({inline:!0,group:"inline",attrs:{isInline:{default:!1}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",t.get(Wo.key)(e)," "]:["br",t.get(Wo.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,n,o)=>{var a;e.addNode(o,{isInline:!!((a=n.data)!=null&&a.isInline)})}},leafText:()=>`
3 3 `,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,n)=>{n.attrs.isInline?e.addNode("text",void 0,`
4 4 `):e.addNode("break")}}}));u(tt.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});u(tt.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const ur=v("InsertHardbreak",t=>()=>(e,n)=>{var o;const{selection:a,tr:r}=e;if(!(a instanceof be))return!1;if(a.empty){const s=a.$from.node();if(s.childCount>0&&((o=s.lastChild)==null?void 0:o.type.name)==="hardbreak")return n==null||n(r.replaceRangeWith(a.to-1,a.to,e.schema.node("paragraph")).setSelection(Ho.near(r.doc.resolve(a.to))).scrollIntoView()),!0}return n==null||n(r.setMeta("hardbreak",!0).replaceSelectionWith(tt.type(t).create()).scrollIntoView()),!0});u(ur,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const hr=G("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{const e=t.get(C);return()=>e.call(ur.key)}}});u(hr.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});u(hr.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const mr=ce("hr");u(mr,{displayName:"Attr<hr>",group:"Hr"});const Ln=B("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(mr.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,n,o)=>{e.addNode(o)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));u(Ln.node,{displayName:"NodeSchema<hr>",group:"Hr"});u(Ln.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const Ri=z(t=>new xn(/^(?:---|___\s|\*\*\*\s)$/,(e,n,o,a)=>{const{tr:r}=e;return n[0]&&r.replaceWith(o-1,a,Ln.type(t).create()),r}));u(Ri,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const Bi=v("InsertHr",t=>()=>(e,n)=>{if(!n)return!0;const o=Ke.node.type(t).create(),{tr:a,selection:r}=e,{from:s}=r,i=Ln.type(t).create();if(!i)return!0;const l=a.replaceSelectionWith(i).insert(s,o),c=Ho.findFrom(l.doc.resolve(s),1,!0);return c&&n(l.setSelection(c).scrollIntoView()),!0});u(Bi,{displayName:"Command<insertHrCommand>",group:"Hr"});const gr=ce("bulletList");u(gr,{displayName:"Attr<bulletList>",group:"BulletList"});const Lt=B("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{spread:e.dataset.spread}}}],toDOM:e=>["ul",{...t.get(gr.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:n})=>e==="list"&&!n,runner:(e,n,o)=>{const a=n.spread!=null?`${n.spread}`:"false";e.openNode(o,{spread:a}).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==="true"}).next(n.content).closeNode()}}}));u(Lt.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});u(Lt.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const Hi=z(t=>Wa(/^\s*([-+*])\s$/,Lt.type(t)));u(Hi,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const fr=v("WrapInBulletList",t=>()=>Da(Lt.type(t)));u(fr,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const yr=G("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{const e=t.get(C);return()=>e.call(fr.key)}}});u(yr.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});u(yr.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const kr=ce("orderedList");u(kr,{displayName:"Attr<orderedList>",group:"OrderedList"});const At=B("ordered_list",t=>({content:"listItem+",group:"block",attrs:{order:{default:1},spread:{default:!1}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(kr.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,o)=>{const a=n.spread!=null?`${n.spread}`:"true";e.openNode(o,{spread:a}).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()}}}));u(At.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});u(At.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const ji=z(t=>Wa(/^\s*(\d+)\.\s$/,At.type(t),e=>({order:Number(e[1])}),(e,n)=>n.childCount+n.attrs.order===Number(e[1])));u(ji,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const vr=v("WrapInOrderedList",t=>()=>Da(At.type(t)));u(vr,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const wr=G("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{const e=t.get(C);return()=>e.call(vr.key)}}});u(wr.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});u(wr.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const $r=ce("listItem");u($r,{displayName:"Attr<listItem>",group:"ListItem"});const ye=B("list_item",t=>({group:"listItem",content:"(paragraph|blockquote) block*",attrs:{label:{default:"•"},listType:{default:"bullet"},spread:{default:"true"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw le(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread}}}],toDOM:e=>["li",{...t.get($r.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,o)=>{const a=n.label!=null?`${n.label}.`:"•",r=n.label!=null?"ordered":"bullet",s=n.spread!=null?`${n.spread}`:"true";e.openNode(o,{label:a,listType:r,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==="true"}),e.next(n.content),e.closeNode()}}}));u(ye.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});u(ye.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const br=v("SinkListItem",t=>()=>dc(ye.type(t)));u(br,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const Nr=v("LiftListItem",t=>()=>Us(ye.type(t)));u(Nr,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const Mr=v("SplitListItem",t=>()=>pc(ye.type(t)));u(Mr,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function Bd(t){return(e,n,o)=>{const{selection:a}=e;if(!(a instanceof be))return!1;const{empty:r,$from:s}=a;if(!r||s.parentOffset!==0)return!1;const i=s.node(-1);return i.type!==ye.type(t)||i.firstChild!==s.node()||s.node(-2).childCount>1?!1:Us(ye.type(t))(e,n,o)}}const Cr=v("LiftFirstListItem",t=>()=>Bd(t));u(Cr,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const xr=G("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{const e=t.get(C);return()=>e.call(Mr.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{const e=t.get(C);return()=>e.call(br.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{const e=t.get(C);return()=>e.call(Nr.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{const e=t.get(C);return()=>e.call(Cr.key)}}});u(xr.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});u(xr.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const Fi=Fa("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)}}}));u(Fi,{displayName:"NodeSchema<text>",group:"Text"});const Sr=ce("html");u(Sr,{displayName:"Attr<html>",group:"Html"});const Ir=B("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:""}},toDOM:e=>{const n=document.createElement("span"),o={...t.get(Sr.key)(e),"data-value":e.attrs.value,"data-type":"html"};return n.textContent=e.attrs.value,["span",o,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,n,o)=>{e.addNode(o,{value:n.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,n)=>{e.addNode("html",void 0,n.attrs.value)}}}));u(Ir.node,{displayName:"NodeSchema<html>",group:"Html"});u(Ir.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const Hd=[Ei,Za,Ke,Go,nr,ot,Wo,tt,rr,En,lr,Pn,mr,Ln,pr,at,gr,Lt,kr,At,$r,ye,Ka,Pt,qa,On,Ya,De,Qa,$e,Sr,Ir,Fi].flat(),jd=[Li,Hi,ji,Ai,Ri,Pi].flat(),Fd=[xi,Si,Ti,Ii],Kd=[er,sr,Le,or,cr,ur,Bi,Di,Wi,vr,fr,br,Mr,Nr,Cr,Va,Ja,za,_i,Oi],Vd=[ir,dr,hr,ar,xr,wr,yr,tr,Ua,Xa,Ga].flat(),Tr=nt("remarkAddOrderInList",()=>()=>t=>{jo(t,"list",e=>{if(e.ordered){const n=e.start??1;e.children.forEach((o,a)=>{o.label=a+n})}})});u(Tr.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});u(Tr.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const _r=nt("remarkLineBreak",()=>()=>t=>{const e=/[\t ]*(?:\r?\n|\r)/g;jo(t,"text",(n,o,a)=>{if(!n.value||typeof n.value!="string")return;const r=[];let s=0;e.lastIndex=0;let i=e.exec(n.value);for(;i;){const l=i.index;s!==l&&r.push({type:"text",value:n.value.slice(s,l)}),r.push({type:"break",data:{isInline:!0}}),s=l+i[0].length,i=e.exec(n.value)}if(r.length>0&&a&&typeof o=="number")return s<n.value.length&&r.push({type:"text",value:n.value.slice(s)}),a.children.splice(o,1,...r),o+r.length})});u(_r.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});u(_r.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const Or=nt("remarkInlineLink",()=>uc);u(Or.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});u(Or.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const Ud=t=>!!t.children,qd=t=>t.type==="html";function zd(t,e){return n(t,0,null)[0];function n(o,a,r){if(Ud(o)){const s=[];for(let i=0,l=o.children.length;i<l;i++){const c=o.children[i];if(c){const d=n(c,i,o);if(d)for(let p=0,h=d.length;p<h;p++){const m=d[p];m&&s.push(m)}}}o.children=s}return e(o,a,r)}}const Er=nt("remarkHTMLTransformer",()=>()=>t=>{zd(t,(e,n,o)=>qd(e)?((o==null?void 0:o.type)==="root"&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});u(Er.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});u(Er.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const Pr=nt("remarkMarker",()=>()=>(t,e)=>{const n=o=>e.value.charAt(o.position.start.offset);jo(t,o=>["strong","emphasis"].includes(o.type),o=>{o.marker=n(o)})});u(Pr.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});u(Pr.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const Ki=U(()=>{let t=!1;const e=new K("MILKDOWN_INLINE_NODES_CURSOR"),n=new V({key:e,state:{init(){return!1},apply(o){if(!o.selection.empty)return!1;const a=o.selection.$from,r=a.nodeBefore,s=a.nodeAfter;return!!(r&&s&&r.isInline&&!r.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(o,a)=>t?(t=!1,requestAnimationFrame(()=>{if(n.getState(o.state)){const r=o.state.selection.from;a.preventDefault(),o.dispatch(o.state.tr.insertText(a.data||"",r))}}),!0):!1,compositionstart:o=>(n.getState(o.state)&&(t=!0),!1),beforeinput:(o,a)=>{if(n.getState(o.state)&&a instanceof InputEvent&&a.data&&!t){const r=o.state.selection.from;return a.preventDefault(),o.dispatch(o.state.tr.insertText(a.data||"",r)),!0}return!1}},decorations(o){if(n.getState(o)){const a=o.selection.$from.pos,r=document.createElement("span"),s=Ao.widget(a,r,{side:-1}),i=document.createElement("span"),l=Ao.widget(a,i);return setTimeout(()=>{r.contentEditable="true",i.contentEditable="true"}),ga.create(o.doc,[s,l])}return ga.empty}}});return n});u(Ki,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Vi=U(t=>new V({key:new K("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,n,o)=>{if(!e.length)return;const[a]=e;if(!a)return;const[r]=a.steps;if(a.getMeta("hardbreak")){if(!(r instanceof sc))return;const{from:s}=r;return o.tr.setNodeMarkup(s,tt.type(t),void 0,[])}if(r instanceof ic){let s=o.tr;const{from:i,to:l}=r;return o.doc.nodesBetween(i,l,(c,d)=>{c.type===tt.type(t)&&(s=s.setNodeMarkup(d,tt.type(t),void 0,[]))}),s}}}));u(Vi,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const Lr=W(["table","code_block"],"hardbreakFilterNodes");u(Lr,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const Ui=U(t=>{const e=t.get(Lr.key);return new V({key:new K("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(n,o)=>{const a=n.getMeta("hardbreak"),[r]=n.steps;if(a&&r){const{from:s}=r,i=o.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}})});u(Ui,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const qi=U(t=>{const e=new K("MILKDOWN_HEADING_ID"),n=o=>{if(o.composing)return;const a=t.get(Go.key),r=o.state.tr.setMeta("addToHistory",!1);let s=!1;o.state.doc.descendants((i,l)=>{if(i.type===ot.type(t)){if(i.textContent.trim().length===0)return;const c=i.attrs,d=a(i);c.id!==d&&(s=!0,r.setMeta(e,!0).setNodeMarkup(l,void 0,{...c,id:d}))}}),s&&o.dispatch(r)};return new V({key:e,view:o=>(n(o),{update:(a,r)=>{a.state.doc.eq(r.doc)||n(a)}})})});u(qi,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const zi=U(t=>{const e=n=>{if(n.composing||!n.editable)return;const o=At.type(t),a=Lt.type(t),r=ye.type(t),s=n.state,i=(d,p)=>{let h=!1;const m=`${p+1}.`;return d.label!==m&&(d.label=m,h=!0),h};let l=s.tr,c=!1;s.doc.descendants((d,p,h,m)=>{if(d.type===a){const f=d.maybeChild(0);(f==null?void 0:f.type)===r&&f.attrs.listType==="ordered"&&(c=!0,l.setNodeMarkup(p,o,{spread:"true"}),d.descendants(($,E,x,H)=>{if($.type===r){const D={...$.attrs};i(D,H)&&(l=l.setNodeMarkup(E,void 0,D))}return!1}))}else if(d.type===r&&(h==null?void 0:h.type)===o){const f={...d.attrs};let $=!1;f.listType!=="ordered"&&(f.listType="ordered",$=!0),h!=null&&h.maybeChild(0)&&($=i(f,m)),$&&(l=l.setNodeMarkup(p,void 0,f),c=!0)}}),c&&n.dispatch(l.setMeta("addToHistory",!1))};return new V({key:new K("MILKDOWN_KEEP_LIST_ORDER"),view:n=>(e(n),{update:o=>{e(o)}})})});u(zi,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const Gd=[Vi,Lr,Ui,Ki,Tr,Or,_r,Er,Pr,qi,zi].flat(),lh=[Hd,jd,Fd,Kd,Vd,Gd].flat();function k(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-gfm",...e}}),t}const Ar=_n("strike_through");k(Ar,{displayName:"Attr<strikethrough>",group:"Strikethrough"});const An=Tn("strike_through",t=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",t.get(Ar.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,n,o)=>{e.openMark(o),e.next(n.children),e.closeMark(o)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,n)=>{e.withMark(n,"delete")}}}));k(An.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});k(An.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});const Dr=v("ToggleStrikeThrough",t=>()=>Bo(An.type(t)));k(Dr,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});const Gi=z(t=>In(/~([^~]+)~$/,An.type(t)));k(Gi,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});const Wr=G("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:t=>{const e=t.get(C);return()=>e.call(Dr.key)}}});k(Wr.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});k(Wr.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});const Dn=hc({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:t=>t.style.textAlign||"left",setDOMAttr:(t,e)=>{e.style=`text-align: ${t||"left"}`}}}}),Dt=B("table",()=>({...Dn.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="table",runner:(t,e,n)=>{const o=e.align,a=e.children.map((r,s)=>({...r,align:o,isHeader:s===0}));t.openNode(n),t.next(a),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table",runner:(t,e)=>{var n;const o=(n=e.content.firstChild)==null?void 0:n.content;if(!o)return;const a=[];o.forEach(r=>{a.push(r.attrs.alignment)}),t.openNode("table",void 0,{align:a}),t.next(e.content),t.closeNode()}}}));k(Dt.node,{displayName:"NodeSchema<table>",group:"Table"});k(Dt.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});const Yo=B("table_header_row",()=>({...Dn.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:t=>!!(t.type==="tableRow"&&t.isHeader),runner:(t,e,n)=>{const o=e.align,a=e.children.map((r,s)=>({...r,align:o[s],isHeader:e.isHeader}));t.openNode(n),t.next(a),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()}}}));k(Yo.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});k(Yo.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});const Wn=B("table_row",()=>({...Dn.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:t=>t.type==="tableRow",runner:(t,e,n)=>{const o=e.align,a=e.children.map((r,s)=>({...r,align:o[s]}));t.openNode(n),t.next(a),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_row",runner:(t,e)=>{t.openNode("tableRow"),t.next(e.content),t.closeNode()}}}));k(Wn.node,{displayName:"NodeSchema<tableRow>",group:"Table"});k(Wn.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});const Rn=B("table_cell",()=>({...Dn.table_cell,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!t.isHeader,runner:(t,e,n)=>{const o=e.align;t.openNode(n,{alignment:o}).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()}}}));k(Rn.node,{displayName:"NodeSchema<tableCell>",group:"Table"});k(Rn.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});const Jo=B("table_header",()=>({...Dn.table_header,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!!t.isHeader,runner:(t,e,n)=>{const o=e.align;t.openNode(n,{alignment:o}),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()}}}));k(Jo.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});k(Jo.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function Yi(t,e=3,n=3){const o=Array(n).fill(0).map(()=>Rn.type(t).createAndFill()),a=Array(n).fill(0).map(()=>Jo.type(t).createAndFill()),r=Array(e).fill(0).map((s,i)=>i===0?Yo.type(t).create(null,a):Wn.type(t).create(null,o));return Dt.type(t).create(null,r)}function Bn(t){return ja(e=>e.type.spec.tableRole==="table")(t)}function kt(t,e){const n=Bn(e.$from);if(!n)return;const o=Be.get(n.node);if(!(t<0||t>=o.width))return o.cellsInRect({left:t,right:t+1,top:0,bottom:o.height}).map(a=>{const r=n.node.nodeAt(a);if(!r)return;const s=a+n.start;return{pos:s,start:s+1,node:r}}).filter(a=>a!=null)}function vt(t,e){const n=Bn(e.$from);if(!n)return;const o=Be.get(n.node);if(!(t<0||t>=o.height))return o.cellsInRect({left:0,right:o.width,top:t,bottom:t+1}).map(a=>{const r=n.node.nodeAt(a);if(!r)return;const s=a+n.start;return{pos:s,start:s+1,node:r}}).filter(a=>a!=null)}function Yd(t){const e=Bn(t.$from);if(!e)return;const n=Be.get(e.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(o=>{const a=e.node.nodeAt(o),r=o+e.start;return{pos:r,start:r+1,node:a}})}function Jd(t){const e=Yd(t.selection);if(e&&e[0]){const n=t.doc.resolve(e[0].pos),o=e[e.length-1];if(o){const a=t.doc.resolve(o.pos);return zo(t.setSelection(new Ot(a,n)))}}return t}function Ji(t,e,{map:n,tableStart:o,table:a},r){const s=Array(r).fill(0).reduce((l,c,d)=>l+a.child(d).nodeSize,o),i=Array(n.width).fill(0).map((l,c)=>{const d=a.nodeAt(n.map[c]);return Rn.type(t).createAndFill({alignment:d==null?void 0:d.attrs.alignment})});return e.insert(s,Wn.type(t).create(null,i)),e}function Xi(t){return(e,n)=>o=>{n=n??o.selection.from;const a=o.doc.resolve(n),r=ja(l=>l.type.name==="table")(a),s=r?{node:r.node,from:r.start}:void 0,i=t==="row";if(s){const l=Be.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=o.doc.resolve(s.from+c),p=i?Ot.rowSelection:Ot.colSelection,h=l.positionAt(i?e:0,i?0:e,s.node),m=o.doc.resolve(s.from+h);return zo(o.setSelection(p(d,m)))}}return o}}const Xd=Xi("row"),Qd=Xi("col");function ks(t){return t[0].map((e,n)=>t.map(o=>o[n]))}function Qi(t,e){const n=[],o=Be.get(t);for(let a=0;a<o.height;a++){const r=t.child(a),s=[];for(let i=0;i<o.width;i++){if(!e[a][i])continue;const l=o.map[a*o.width+i],c=e[a][i],d=t.nodeAt(l).type.createChecked(Object.assign({},c.attrs),c.content,c.marks);s.push(d)}n.push(r.type.createChecked(r.attrs,s,r.marks))}return t.type.createChecked(t.attrs,n,t.marks)}function Zi(t){const e=Be.get(t),n=[];for(let o=0;o<e.height;o++){const a=[],r={};for(let s=0;s<e.width;s++){const i=e.map[o*e.width+s],l=t.nodeAt(i),c=e.findCell(i);if(r[i]||c.top!==o){a.push(null);continue}r[i]=!0,a.push(l)}n.push(a)}return n}function el(t,e,n,o){const a=e[0]>n[0]?-1:1,r=t.splice(e[0],e.length),s=r.length%2===0?1:0;let i;return o===-1&&a===1?i=n[0]-1:o===1&&a===-1?i=n[n.length-1]-s+1:i=a===-1?n[0]:n[n.length-1]-s,t.splice(i,0,...r),t}function Zd(t,e,n,o){let a=ks(Zi(t.node));return a=el(a,e,n,o),a=ks(a),Qi(t.node,a)}function ep(t,e,n,o){let a=Zi(t.node);return a=el(a,e,n,o),Qi(t.node,a)}function vs(t,e){let n=t,o=t;for(let d=t;d>=0;d--){const p=kt(d,e.selection);p&&p.forEach(h=>{const m=h.node.attrs.colspan+d-1;m>=n&&(n=d),m>o&&(o=m)})}for(let d=t;d<=o;d++){const p=kt(d,e.selection);p&&p.forEach(h=>{const m=h.node.attrs.colspan+d-1;h.node.attrs.colspan>1&&m>o&&(o=m)})}const a=[];for(let d=n;d<=o;d++){const p=kt(d,e.selection);p&&p.length&&a.push(d)}n=a[0],o=a[a.length-1];const r=kt(n,e.selection),s=vt(0,e.selection),i=e.doc.resolve(r[r.length-1].pos);let l;for(let d=o;d>=n;d--){const p=kt(d,e.selection);if(p&&p.length){for(let h=s.length-1;h>=0;h--)if(s[h].pos===p[0].pos){l=p[0];break}if(l)break}}const c=e.doc.resolve(l.pos);return{$anchor:i,$head:c,indexes:a}}function ws(t,e){let n=t,o=t;for(let d=t;d>=0;d--)vt(d,e.selection).forEach(p=>{const h=p.node.attrs.rowspan+d-1;h>=n&&(n=d),h>o&&(o=h)});for(let d=t;d<=o;d++)vt(d,e.selection).forEach(p=>{const h=p.node.attrs.rowspan+d-1;p.node.attrs.rowspan>1&&h>o&&(o=h)});const a=[];for(let d=n;d<=o;d++){const p=vt(d,e.selection);p&&p.length&&a.push(d)}n=a[0],o=a[a.length-1];const r=vt(n,e.selection),s=kt(0,e.selection),i=e.doc.resolve(r[r.length-1].pos);let l;for(let d=o;d>=n;d--){const p=vt(d,e.selection);if(p&&p.length){for(let h=s.length-1;h>=0;h--)if(s[h].pos===p[0].pos){l=p[0];break}if(l)break}}const c=e.doc.resolve(l.pos);return{$anchor:i,$head:c,indexes:a}}function tp(t){const{tr:e,origin:n,target:o,select:a=!0,pos:r}=t,s=r!=null?e.doc.resolve(r):e.selection.$from,i=Bn(s);if(!i)return e;const{indexes:l}=vs(n,e),{indexes:c}=vs(o,e);if(l.includes(o))return e;const d=Zd(i,l,c,0),p=zo(e).replaceWith(i.pos,i.pos+i.node.nodeSize,d);if(!a)return p;const h=Be.get(d),m=i.start,f=o,$=h.positionAt(h.height-1,f,d),E=p.doc.resolve(m+$),x=Ot.colSelection,H=h.positionAt(0,f,d),D=p.doc.resolve(m+H);return p.setSelection(x(E,D))}function np(t){const{tr:e,origin:n,target:o,select:a=!0,pos:r}=t,s=r!=null?e.doc.resolve(r):e.selection.$from,i=Bn(s);if(!i)return e;const{indexes:l}=ws(n,e),{indexes:c}=ws(o,e);if(l.includes(o))return e;const d=ep(i,l,c,0),p=zo(e).replaceWith(i.pos,i.pos+i.node.nodeSize,d);if(!a)return p;const h=Be.get(d),m=i.start,f=o,$=h.positionAt(f,h.width-1,d),E=p.doc.resolve(m+$),x=Ot.rowSelection,H=h.positionAt(f,0,d),D=p.doc.resolve(m+H);return p.setSelection(x(E,D))}const Rr=v("GoToPrevTableCell",()=>()=>zs(-1));k(Rr,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});const Br=v("GoToNextTableCell",()=>()=>zs(1));k(Br,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});const Hr=v("ExitTable",t=>()=>(e,n)=>{if(!Ra(e))return!1;const{$head:o}=e.selection,a=vd(o,Dt.type(t));if(!a)return!1;const{to:r}=a,s=e.tr.replaceWith(r,r,Ke.type(t).createAndFill());return s.setSelection(Ho.near(s.doc.resolve(r),1)).scrollIntoView(),n==null||n(s),!0});k(Hr,{displayName:"Command<breakTableCommand>",group:"Table"});const tl=v("InsertTable",t=>({row:e,col:n}={})=>(o,a)=>{const{selection:r,tr:s}=o,{from:i}=r,l=Yi(t,e,n),c=s.replaceSelectionWith(l),d=Ho.findFrom(c.doc.resolve(i),1,!0);return d&&c.setSelection(d),a==null||a(c),!0});k(tl,{displayName:"Command<insertTableCommand>",group:"Table"});const nl=v("MoveRow",()=>({from:t,to:e,pos:n}={})=>(o,a)=>{const{tr:r}=o;return!!(a!=null&&a(np({tr:r,origin:t??0,target:e??0,pos:n,select:!0})))});k(nl,{displayName:"Command<moveRowCommand>",group:"Table"});const ol=v("MoveCol",()=>({from:t,to:e,pos:n}={})=>(o,a)=>{const{tr:r}=o;return!!(a!=null&&a(tp({tr:r,origin:t??0,target:e??0,pos:n,select:!0})))});k(ol,{displayName:"Command<moveColCommand>",group:"Table"});const al=v("SelectRow",()=>(t={index:0})=>(e,n)=>{const{tr:o}=e;return!!(n!=null&&n(Xd(t.index,t.pos)(o)))});k(al,{displayName:"Command<selectRowCommand>",group:"Table"});const rl=v("SelectCol",()=>(t={index:0})=>(e,n)=>{const{tr:o}=e;return!!(n!=null&&n(Qd(t.index,t.pos)(o)))});k(rl,{displayName:"Command<selectColCommand>",group:"Table"});const sl=v("SelectTable",()=>()=>(t,e)=>{const{tr:n}=t;return!!(e!=null&&e(Jd(n)))});k(sl,{displayName:"Command<selectTableCommand>",group:"Table"});const il=v("DeleteSelectedCells",()=>()=>(t,e)=>{const{selection:n}=t;if(!(n instanceof Ot))return!1;const o=n.isRowSelection(),a=n.isColSelection();return o&&a?yc(t,e):a?kc(t,e):vc(t,e)});k(il,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});const ll=v("AddColBefore",()=>()=>wc);k(ll,{displayName:"Command<addColBeforeCommand>",group:"Table"});const cl=v("AddColAfter",()=>()=>$c);k(cl,{displayName:"Command<addColAfterCommand>",group:"Table"});const dl=v("AddRowBefore",t=>()=>(e,n)=>{if(!Ra(e))return!1;if(n){const o=Gs(e);n(Ji(t,e.tr,o,o.top))}return!0});k(dl,{displayName:"Command<addRowBeforeCommand>",group:"Table"});const pl=v("AddRowAfter",t=>()=>(e,n)=>{if(!Ra(e))return!1;if(n){const o=Gs(e);n(Ji(t,e.tr,o,o.bottom))}return!0});k(pl,{displayName:"Command<addRowAfterCommand>",group:"Table"});const ul=v("SetAlign",()=>(t="left")=>bc("alignment",t));k(ul,{displayName:"Command<setAlignCommand>",group:"Table"});const hl=z(t=>new xn(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,n,o,a)=>{var r,s;const i=e.doc.resolve(o);if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),Dt.type(t)))return null;const l=Yi(t,Number((r=n.groups)==null?void 0:r.row),Number((s=n.groups)==null?void 0:s.col)),c=e.tr.replaceRangeWith(o,a,l);return c.setSelection(be.create(c.doc,o+3)).scrollIntoView()}));k(hl,{displayName:"InputRule<insertTableInputRule>",group:"Table"});const jr=G("tableKeymap",{NextCell:{shortcuts:["Mod-]","Tab"],command:t=>{const e=t.get(C);return()=>e.call(Br.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:t=>{const e=t.get(C);return()=>e.call(Rr.key)}},ExitTable:{shortcuts:["Mod-Enter"],command:t=>{const e=t.get(C);return()=>e.call(Hr.key)}}});k(jr.ctx,{displayName:"KeymapCtx<table>",group:"Table"});k(jr.shortcuts,{displayName:"Keymap<table>",group:"Table"});const ca="footnote_definition",$s="footnoteDefinition",Fr=B("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:""}},parseDOM:[{tag:`dl[data-type="${ca}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw le(t);return{label:t.dataset.label}},contentElement:"dd"}],toDOM:t=>{const e=t.attrs.label;return["dl",{"data-label":e,"data-type":ca},["dt",e],["dd",0]]},parseMarkdown:{match:({type:t})=>t===$s,runner:(t,e,n)=>{t.openNode(n,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name===ca,runner:(t,e)=>{t.openNode($s,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));k(Fr.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});k(Fr.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});const da="footnote_reference",Kr=B("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:""}},parseDOM:[{tag:`sup[data-type="${da}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw le(t);return{label:t.dataset.label}}}],toDOM:t=>{const e=t.attrs.label;return["sup",{"data-label":e,"data-type":da},e]},parseMarkdown:{match:({type:t})=>t==="footnoteReference",runner:(t,e,n)=>{t.addNode(n,{label:e.label})}},toMarkdown:{match:t=>t.type.name===da,runner:(t,e)=>{t.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));k(Kr.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});k(Kr.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});const ml=ye.extendSchema(t=>e=>{const n=t(e);return{...n,attrs:{...n.attrs,checked:{default:null}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:o=>{if(!(o instanceof HTMLElement))throw le(o);return{label:o.dataset.label,listType:o.dataset.listType,spread:o.dataset.spread,checked:o.dataset.checked?o.dataset.checked==="true":null}}},...(n==null?void 0:n.parseDOM)||[]],toDOM:o=>n.toDOM&&o.attrs.checked==null?n.toDOM(o):["li",{"data-item-type":"task","data-label":o.attrs.label,"data-list-type":o.attrs.listType,"data-spread":o.attrs.spread,"data-checked":o.attrs.checked},0],parseMarkdown:{match:({type:o})=>o==="listItem",runner:(o,a,r)=>{if(a.checked==null){n.parseMarkdown.runner(o,a,r);return}const s=a.label!=null?`${a.label}.`:"•",i=a.checked!=null?!!a.checked:null,l=a.label!=null?"ordered":"bullet",c=a.spread!=null?`${a.spread}`:"true";o.openNode(r,{label:s,listType:l,spread:c,checked:i}),o.next(a.children),o.closeNode()}},toMarkdown:{match:o=>o.type.name==="list_item",runner:(o,a)=>{if(a.attrs.checked==null){n.toMarkdown.runner(o,a);return}const r=a.attrs.label,s=a.attrs.listType,i=a.attrs.spread==="true",l=a.attrs.checked;o.openNode("listItem",void 0,{label:r,listType:s,spread:i,checked:l}),o.next(a.content),o.closeNode()}}}});k(ml,{displayName:"NodeSchema<listItem>",group:"ListItem"});const gl=z(()=>new xn(/^\[(?<checked>\s|x)\]\s$/,(t,e,n,o)=>{var a;const r=t.doc.resolve(n);let s=0,i=r.node(s);for(;i&&i.type.name!=="list_item";)s--,i=r.node(s);if(!i||i.attrs.checked!=null)return null;const l=((a=e.groups)==null?void 0:a.checked)==="x",c=r.before(s),d=t.tr;return d.deleteRange(n,o).setNodeMarkup(c,void 0,{...i.attrs,checked:l}),d}));k(gl,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});const op=[Wr,jr].flat(),ap=[hl,gl],rp=[Gi],fl=U(()=>mc);k(fl,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});const sp=U(()=>gc({}));k(sp,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});const yl=U(()=>fc({allowTableNodeSelection:!0}));k(yl,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});const Vr=nt("remarkGFM",()=>Nc);k(Vr.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});k(Vr.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});const ip=new K("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function lp(t,e){let n=0;return e.forEach((o,a,r)=>{o===t&&(n=r)}),n}const kl=U(()=>new V({key:ip,appendTransaction:(t,e,n)=>{let o;const a=(r,s)=>{if(o||(o=n.tr),r.type.name!=="table_cell")return;const i=n.doc.resolve(s),l=i.node(i.depth),c=i.node(i.depth-1).firstChild;if(!c)return;const d=lp(r,l),p=c.maybeChild(d);if(!p)return;const h=p.attrs.alignment,m=r.attrs.alignment;h!==m&&o.setNodeMarkup(s,void 0,{...r.attrs,alignment:h})};return e.doc!==n.doc&&n.doc.descendants(a),o}}));k(kl,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});const cp=[kl,fl,Vr,yl].flat(),dp=[ml,Dt,Yo,Wn,Jo,Rn,Fr,Kr,Ar,An].flat(),pp=[Br,Rr,Hr,tl,nl,ol,al,rl,sl,il,dl,pl,ll,cl,ul,Dr],ch=[dp,ap,rp,op,pp,cp].flat();function Wt(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-history",...e}}),t}const Ur=v("Undo",()=>()=>Cc);Wt(Ur,{displayName:"Command<undo>"});const qr=v("Redo",()=>()=>xc);Wt(qr,{displayName:"Command<redo>"});const zr=W({},"historyProviderConfig");Wt(zr,{displayName:"Ctx<historyProviderConfig>"});const vl=U(t=>Mc(t.get(zr.key)));Wt(vl,{displayName:"Ctx<historyProviderPlugin>"});const Gr=G("historyKeymap",{Undo:{shortcuts:"Mod-z",command:t=>{const e=t.get(C);return()=>e.call(Ur.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:t=>{const e=t.get(C);return()=>e.call(qr.key)}}});Wt(Gr.ctx,{displayName:"KeymapCtx<history>"});Wt(Gr.shortcuts,{displayName:"Keymap<history>"});const dh=[zr,vl,Gr,Ur,qr].flat();function Sa(t){if(!t)return!1;if(Array.isArray(t))return t.length>1?!1:Sa(t[0]);const e=t.content;return e?Sa(e):t.type==="text"}function up(t){if(t.content.childCount===1){const e=t.content.firstChild;if((e==null?void 0:e.type.name)==="text"&&e.marks.length===0)return e;if((e==null?void 0:e.type.name)==="paragraph"&&e.childCount===1){const n=e.firstChild;if((n==null?void 0:n.type.name)==="text"&&n.marks.length===0)return n}}return!1}const hp=U(t=>{const e=t.get(se);t.update(go,o=>({...o,editable:o.editable??(()=>!0)}));const n=new K("MILKDOWN_CLIPBOARD");return new V({key:n,props:{handlePaste:(o,a)=>{var r,s;const i=t.get(Tt),l=(s=(r=o.props).editable)==null?void 0:s.call(r,o.state),{clipboardData:c}=a;if(!l||!c||o.state.selection.$from.node().type.spec.code)return!1;const d=c.getData("text/plain"),p=c.getData("vscode-editor-data");if(p){const x=JSON.parse(p),H=x==null?void 0:x.mode;if(d&&H){const{tr:D}=o.state,_=wd("code_block",e);return D.replaceSelectionWith(_.create({language:H})).setSelection(be.near(D.doc.resolve(Math.max(0,D.selection.from-2)))).insertText(d.replace(/\r\n?/g,`
5 5 `)),o.dispatch(D),!0}}const h=c.getData("text/html");if(h.length===0&&d.length===0)return!1;const m=Vs.fromSchema(e);let f;if(h.length===0){const x=i(d);if(!x||typeof x=="string")return!1;f=Ys.fromSchema(e).serializeFragment(x.content)}else{const x=document.createElement("template");x.innerHTML=h,f=x.content.cloneNode(!0),x.remove()}const $=m.parseSlice(f),E=up($);return E?(o.dispatch(o.state.tr.replaceSelectionWith(E,!0)),!0):(o.dispatch(o.state.tr.replaceSelection($)),!0)},clipboardTextSerializer:o=>{const a=t.get(_t);if(Sa(o.content.toJSON()))return o.content.textBetween(0,o.content.size,`