UNPKG

@thebase/ui

Version:

CDN-installable Owl and Bootstrap 5 UI component library.

42 lines • 278 kB
import{a as R,b as Ve,c as Rl,d as I,g as li,j as Pl,k as zl,l as ir,m as or}from"./chunk-OQJVATGH.js";import{a as Bl,c as Fl}from"./chunk-ILE44FN6.js";import{b as Gf,c as Xf,d as Zf,f as k,g as O,h as C}from"./chunk-23NN352E.js";var of=Gf((kw,rf)=>{"use strict";var Qi=Object.prototype.hasOwnProperty,nf=Object.prototype.toString,Yu=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,Xu=function(e){return typeof Array.isArray=="function"?Array.isArray(e):nf.call(e)==="[object Array]"},Zu=function(e){if(!e||nf.call(e)!=="[object Object]")return!1;var n=Qi.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Qi.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;var i;for(i in e);return typeof i>"u"||Qi.call(e,i)},ef=function(e,n){Yu&&n.name==="__proto__"?Yu(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},tf=function(e,n){if(n==="__proto__")if(Qi.call(e,n)){if(Gu)return Gu(e,n).value}else return;return e[n]};rf.exports=function t(){var e,n,r,i,o,s,l=arguments[0],a=1,c=arguments.length,u=!1;for(typeof l=="boolean"&&(u=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<c;++a)if(e=arguments[a],e!=null)for(n in e)r=tf(l,n),i=tf(e,n),l!==i&&(u&&i&&(Zu(i)||(o=Xu(i)))?(o?(o=!1,s=r&&Xu(r)?r:[]):s=r&&Zu(r)?r:{},ef(l,{name:n,newValue:t(u,s,i)})):typeof i<"u"&&ef(l,{name:n,newValue:i}));return l}});var ne=(function(t){return 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.aiProviderError="aiProviderError",t.aiBuildContextError="aiBuildContextError",t})({}),re=class extends Error{constructor(t,e,n){super(e,n),this.name="MilkdownError",this.code=t,n?.cause!==void 0&&(this.cause=n.cause)}},eh=(t,e)=>typeof e=="function"?"[Function]":e,sr=t=>JSON.stringify(t,eh);function vl(t){return new re(ne.docTypeError,`Doc type error, unsupported type: ${sr(t)}`)}function Ll(t){return new re(ne.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function Vl(t){return new re(ne.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function hn(){return new re(ne.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function _l(t,e,n){let r=`Cannot create node for ${"name"in t?t.name:t}`,i=s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},o=[["[Description]",r],["[Attributes]",e],["[Content]",(n??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[l,a])=>{let c=`${l}: ${i(a)}.`;return s.concat(c)},[]);return new re(ne.createNodeInParserFail,o.join(`
`))}function co(){return new re(ne.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function $l(t){return new re(ne.parserMatchError,`Cannot match target parser for node: ${sr(t)}.`)}function jl(t){return new re(ne.serializerMatchError,`Cannot match target serializer for node: ${sr(t)}.`)}function ql(t,e){return new re(ne.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function th(t){return new re(ne.expectDomTypeError,`Expect to be a dom, but get: ${sr(t)}.`)}function ai(){return new re(ne.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 yy(t){return new re(ne.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function ky(t){return new re(ne.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}function xy(){return new re(ne.ctxNotBind,"Context not bind, please make sure the plugin has been initialized.")}function by(){return new re(ne.missingYjsDoc,"Missing yjs doc, please make sure you have bind one.")}function Wl(t){try{return sr(t)}catch{return"[Unserializable]"}}function Sy(t){let e=t instanceof Error?t.message:Wl(t);return new re(ne.aiProviderError,`AI provider error: ${e}`,{cause:t})}function wy(t){let e=t instanceof Error?t.message:Wl(t);return new re(ne.aiBuildContextError,`AI buildContext failed: ${e}`,{cause:t})}var uo=class{constructor(){this.sliceMap=new Map,this.get=t=>{let e=typeof t=="string"?[...this.sliceMap.values()].find(n=>n.type.name===t):this.sliceMap.get(t.id);if(!e){let n=typeof t=="string"?t:t.name;throw Ll(n)}return e},this.remove=t=>{let e=typeof t=="string"?[...this.sliceMap.values()].find(n=>n.type.name===t):this.sliceMap.get(t.id);e&&this.sliceMap.delete(e.type.id)},this.has=t=>typeof t=="string"?[...this.sliceMap.values()].some(e=>e.type.name===t):this.sliceMap.has(t.id)}},_e,Xe,dn,Hl,nh=(Hl=class{constructor(t,e,n){O(this,_e);O(this,Xe);O(this,dn);C(this,_e,[]),C(this,dn,()=>{k(this,_e).forEach(r=>r(k(this,Xe)))}),this.set=r=>{C(this,Xe,r),k(this,dn).call(this)},this.get=()=>k(this,Xe),this.update=r=>{C(this,Xe,r(k(this,Xe))),k(this,dn).call(this)},this.type=n,C(this,Xe,e),t.set(n.id,this)}on(t){return k(this,_e).push(t),()=>{C(this,_e,k(this,_e).filter(e=>e!==t))}}once(t){let e=this.on(n=>{t(n),e()});return e}off(t){C(this,_e,k(this,_e).filter(e=>e!==t))}offAll(){C(this,_e,[])}},_e=new WeakMap,Xe=new WeakMap,dn=new WeakMap,Hl),rh=class{constructor(t,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=t,this._typeInfo=()=>{throw hn()}}create(t,e=this._defaultValue){return new nh(t,e,this)}},W=(t,e)=>new rh(t,e),lr,ar,cr,Pt,pn,pt,mn,gn,yn,Kl,ih=(Kl=class{constructor(t,e,n){O(this,lr);O(this,ar);O(this,cr);O(this,Pt);O(this,pn);O(this,pt);O(this,mn);O(this,gn);O(this,yn);C(this,Pt,new Set),C(this,pn,new Set),C(this,pt,new Map),C(this,mn,new Map),this.read=()=>({metadata:k(this,lr),injectedSlices:[...k(this,Pt)].map(r=>({name:typeof r=="string"?r:r.name,value:k(this,gn).call(this,r)})),consumedSlices:[...k(this,pn)].map(r=>({name:typeof r=="string"?r:r.name,value:k(this,gn).call(this,r)})),recordedTimers:[...k(this,pt)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:k(this,yn).call(this,r)})),waitTimers:[...k(this,mn)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:k(this,yn).call(this,r)}))}),this.onRecord=r=>{k(this,pt).set(r,{start:Date.now(),duration:0})},this.onClear=r=>{k(this,pt).delete(r)},this.onDone=r=>{let i=k(this,pt).get(r);i&&(i.duration=Date.now()-i.start)},this.onWait=(r,i)=>{let o=Date.now();i.finally(()=>{k(this,mn).set(r,{duration:Date.now()-o})}).catch(console.error)},this.onInject=r=>{k(this,Pt).add(r)},this.onRemove=r=>{k(this,Pt).delete(r)},this.onUse=r=>{k(this,pn).add(r)},C(this,gn,r=>k(this,ar).get(r).get()),C(this,yn,r=>k(this,cr).get(r).status),C(this,ar,t),C(this,cr,e),C(this,lr,n)}},lr=new WeakMap,ar=new WeakMap,cr=new WeakMap,Pt=new WeakMap,pn=new WeakMap,pt=new WeakMap,mn=new WeakMap,gn=new WeakMap,yn=new WeakMap,Kl),Ze,et,ur,De,kn,Ul=(kn=class{constructor(e,n,r){O(this,Ze);O(this,et);O(this,ur);O(this,De);this.produce=i=>i&&Object.keys(i).length?new kn(k(this,Ze),k(this,et),{...i}):this,this.inject=(i,o)=>{let s=i.create(k(this,Ze).sliceMap);return o!=null&&s.set(o),k(this,De)?.onInject(i),this},this.remove=i=>(k(this,Ze).remove(i),k(this,De)?.onRemove(i),this),this.record=i=>(i.create(k(this,et).store),k(this,De)?.onRecord(i),this),this.clearTimer=i=>(k(this,et).remove(i),k(this,De)?.onClear(i),this),this.isInjected=i=>k(this,Ze).has(i),this.isRecorded=i=>k(this,et).has(i),this.use=i=>(k(this,De)?.onUse(i),k(this,Ze).get(i)),this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>k(this,et).get(i),this.done=i=>{this.timer(i).done(),k(this,De)?.onDone(i)},this.wait=i=>{let o=this.timer(i).start();return k(this,De)?.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},C(this,Ze,e),C(this,et,n),C(this,ur,r),r&&C(this,De,new ih(e,n,r))}get meta(){return k(this,ur)}get inspector(){return k(this,De)}},Ze=new WeakMap,et=new WeakMap,ur=new WeakMap,De=new WeakMap,kn),Ql=class{constructor(){this.store=new Map,this.get=t=>{let e=this.store.get(t.id);if(!e)throw Vl(t.name);return e},this.remove=t=>{this.store.delete(t.id)},this.has=t=>this.store.has(t.id)}},xn,mt,bn,tt,Sn,fr,Jl,oh=(Jl=class{constructor(t,e){O(this,xn);O(this,mt);O(this,bn);O(this,tt);O(this,Sn);O(this,fr);C(this,xn,null),C(this,mt,null),C(this,tt,"pending"),this.start=()=>(k(this,xn)??C(this,xn,new Promise((n,r)=>{C(this,mt,i=>{i instanceof CustomEvent&&i.detail.id===k(this,bn)&&(C(this,tt,"resolved"),k(this,Sn).call(this),i.stopImmediatePropagation(),n())}),k(this,fr).call(this,()=>{k(this,tt)==="pending"&&C(this,tt,"rejected"),k(this,Sn).call(this),r(new Error(`Timing ${this.type.name} timeout.`))}),C(this,tt,"pending"),addEventListener(this.type.name,k(this,mt))})),k(this,xn)),this.done=()=>{let n=new CustomEvent(this.type.name,{detail:{id:k(this,bn)}});dispatchEvent(n)},C(this,Sn,()=>{k(this,mt)&&removeEventListener(this.type.name,k(this,mt))}),C(this,fr,n=>{setTimeout(()=>{n()},this.type.timeout)}),C(this,bn,Symbol(e.name)),this.type=e,t.set(e.id,this)}get status(){return k(this,tt)}},xn=new WeakMap,mt=new WeakMap,bn=new WeakMap,tt=new WeakMap,Sn=new WeakMap,fr=new WeakMap,Jl),sh=class{constructor(t,e=3e3){this.create=n=>new oh(n,this),this.id=Symbol(`Timer-${t}`),this.name=t,this.timeout=e}},$e=(t,e=3e3)=>new sh(t,e);var wn=(function(t){if(t==null)return uh;if(typeof t=="function")return ci(t);if(typeof t=="object")return Array.isArray(t)?lh(t):ah(t);if(typeof t=="string")return ch(t);throw new Error("Expected function, string, or object as test")});function lh(t){let e=[],n=-1;for(;++n<t.length;)e[n]=wn(t[n]);return ci(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function ah(t){let e=t;return ci(n);function n(r){let i=r,o;for(o in t)if(i[o]!==e[o])return!1;return!0}}function ch(t){return ci(e);function e(n){return n&&n.type===t}}function ci(t){return e;function e(n,r,i){return!!(fh(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function uh(){return!0}function fh(t){return t!==null&&typeof t=="object"&&"type"in t}var Yl=[],ui=!0,zt=!1,fi="skip";function fo(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;let o=wn(i),s=r?-1:1;l(t,void 0,[])();function l(a,c,u){let f=a&&typeof a=="object"?a:{};if(typeof f.type=="string"){let h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(a.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=Yl,p,y,b;if((!e||o(a,c,u[u.length-1]||void 0))&&(h=hh(n(a,u)),h[0]===zt))return h;if("children"in a&&a.children){let x=a;if(x.children&&h[0]!==fi)for(y=(r?x.children.length:-1)+s,b=u.concat(x);y>-1&&y<x.children.length;){let A=x.children[y];if(p=l(A,y,b)(),p[0]===zt)return p;y=typeof p[1]=="number"?p[1]:y+s}}return h}}}function hh(t){return Array.isArray(t)?t:typeof t=="number"?[ui,t]:t==null?Yl:[t]}function ho(t,e,n,r){let i,o,s;typeof e=="function"&&typeof n!="function"?(o=void 0,s=e,i=n):(o=e,s=n,i=r),fo(t,o,l,i);function l(a,c){let u=c[c.length-1],f=u?u.children.indexOf(a):void 0;return s(a,f,u)}}var Zl=65535,ea=Math.pow(2,16);function dh(t,e){return t+e*ea}function Gl(t){return t&Zl}function ph(t){return(t-(t&Zl))/ea}var ta=1,na=2,hi=4,ra=8,pr=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ra)>0}get deletedBefore(){return(this.delInfo&(ta|hi))>0}get deletedAfter(){return(this.delInfo&(na|hi))>0}get deletedAcross(){return(this.delInfo&hi)>0}},nt=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Gl(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+ph(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:n:n,h=a+i+(d<0?0:u);if(r)return h;let p=e==(n<0?a:f)?null:dh(l/3,e-a),y=e==a?na:e==f?ta:hi;return(n<0?e!=a:e!=f)&&(y|=ra),new pr(h,y,p)}i+=u-c}return r?e+i:new pr(e+i,0,null)}touches(e,n){let r=0,i=Gl(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};nt.empty=new nt([]);var yo=class t{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new pr(e,i,null)}},po=Object.create(null),Z=class{getMap(){return nt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=po[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in po)throw new RangeError("Duplicate use of step JSON ID "+e);return po[e]=n,n.prototype.jsonID=e,n}},ie=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,i){try{return t.ok(e.replace(n,r,i))}catch(o){if(o instanceof Rl)return t.fail(o.message);throw o}}};function bo(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(bo(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return R.fromArray(r)}var mr=class t extends Z{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new I(bo(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ie.fromReplace(e,this.from,this.to,o)}invert(){return new Bt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Z.jsonID("addMark",mr);var Bt=class t extends Z{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new I(bo(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ie.fromReplace(e,this.from,this.to,r)}invert(){return new mr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Z.jsonID("removeMark",Bt);var gr=class t extends Z{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ie.fromReplace(e,this.pos,this.pos+1,new I(R.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new t(this.pos,n.marks[i]);return new t(this.pos,this.mark)}}return new Cn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Z.jsonID("addNodeMark",gr);var Cn=class t extends Z{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ie.fromReplace(e,this.pos,this.pos+1,new I(R.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new gr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Z.jsonID("removeNodeMark",Cn);var fe=class t extends Z{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&ko(e,this.from,this.to)?ie.fail("Structure replace would overwrite content"):ie.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new nt([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?I.empty:new I(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?I.empty:new I(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,I.fromJSON(e,n.slice),!!n.structure)}};fe.MAP_BIAS=1;Z.jsonID("replace",fe);var we=class t extends Z{constructor(e,n,r,i,o,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(ko(e,this.from,this.gapFrom)||ko(e,this.gapTo,this.to)))return ie.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ie.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ie.fromReplace(e,this.from,this.to,r):ie.fail("Content does not fit in gap")}getMap(){return new nt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new t(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,I.fromJSON(e,n.slice),n.insert,!!n.structure)}};Z.jsonID("replaceAround",we);function ko(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function mh(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(p)||(s&&s.to==d&&s.mark.eq(f[y])?s.to=h:i.push(s=new Bt(d,h,f[y])));l&&l.to==d?l.to=h:o.push(l=new mr(d,h,r))}}),i.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function gh(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Pl){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>t.step(new Bt(s.from,s.to,s.style)))}function So(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new fe(l,u,I.empty));else{r=f;for(let d=0;d<c.marks.length;d++)n.allowsMarkType(c.marks[d].type)||t.step(new Bt(l,u,c.marks[d]));if(i&&c.isText&&n.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new I(R.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new fe(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(R.empty,!0);t.replace(l,l,new I(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function yh(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function gi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!yh(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function kh(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=R.empty,f=0;for(let p=o,y=!1;p>n;p--)y||r.index(p)>0?(y=!0,u=R.from(r.node(p).copy(u)),f++):a--;let d=R.empty,h=0;for(let p=o,y=!1;p>n;p--)y||i.after(p+1)<i.end(p)?(y=!0,d=R.from(i.node(p).copy(d)),h++):c++;t.step(new we(a,c,s,l,new I(u.append(d),f,h),u.size-f,!0))}function yi(t,e,n=null,r=t){let i=xh(t,e),o=i&&bh(r,e);return o?i.map(Xl).concat({type:e,attrs:n}).concat(o.map(Xl)):null}function Xl(t){return{type:t,attrs:null}}function xh(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function bh(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function Sh(t,e,n){let r=R.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=R.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new we(i,o,i,o,new I(r,0,0),n.length,!0))}function wh(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&Ch(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&oa(t,s,l,o),So(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return t.step(new we(f,d,f+1,d-1,new I(R.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ia(t,s,l,o),!1}})}function ia(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function oa(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
`))}})}function Ch(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Th(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new we(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new I(R.from(s),0,0),1,!0))}function yr(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!y.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Mh(t,e,n=1,r){let i=t.doc.resolve(e),o=R.empty,s=R.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){o=R.from(i.node(l).copy(o));let u=r&&r[c];s=R.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}t.step(new fe(e,e,new I(o.append(s),n,n),!0))}function kr(t,e){let n=t.resolve(e),r=n.index();return Oh(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Nh(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function Oh(t,e){return!!(t&&e&&!t.isLeaf&&Nh(t,e))}function Eh(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);oa(t,u.node(),u.before(),l)}s.inlineContent&&So(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new fe(c,a.map(e+n,-1),I.empty,!0)),r===!0){let u=t.doc.resolve(c);ia(t,u.node(),u.before(),t.steps.length)}return t}function Ih(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function sa(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function xr(t,e,n=e,r=I.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return la(i,o,r)?new fe(e,n,r):new xo(i,o,r).fit()}function la(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var xo=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=R.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=R.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new I(o,s,l);return e>-1?new we(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new fe(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=mo(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(R.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=mo(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new I(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=mo(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new I(hr(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new I(hr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)u.push(i.child(y));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let y=l.child(c),b=f.matchType(y.type);if(!b)break;c++,(c>1||a==0||y.content.size)&&(f=b,u.push(aa(y.mark(d.allowedMarks(y.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=dr(this.placed,n,R.from(u)),this.frontier[n].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<h;y++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=p?e==0?I.empty:new I(hr(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new I(hr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!go(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=go(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=go(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=dr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=dr(this.placed,this.depth,R.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(R.empty,!0);n.childCount&&(this.placed=dr(this.placed,this.frontier.length,n))}};function hr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(hr(t.firstChild.content,e-1,n)))}function dr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(dr(t.lastChild.content,e-1,n)))}function mo(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function aa(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,aa(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(R.empty,!0)))),t.copy(r)}function go(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Dh(n,o.content,s)?l:null}function Dh(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Ah(t){return t.spec.defining||t.spec.definingForContent}function Rh(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(la(i,o,r))return t.step(new fe(e,n,r));let s=ua(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=Ah(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let y=0;y<s.length;y++){let b=s[(y+a)%s.length],x=!0;b<0&&(x=!1,b=-b);let A=i.node(b-1),T=i.index(b-1);if(A.canReplaceWith(T,T,p.type,p.marks))return t.replace(i.before(b),x?o.after(b):n,new I(ca(r.content,0,r.openStart,h),h,r.openEnd))}}let f=t.steps.length;for(let d=s.length-1;d>=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),n=o.after(h))}}function ca(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(ca(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(R.empty,!0))}return t}function Ph(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Ih(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new I(R.from(r),0,0))}function zh(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let o=ua(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ua(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}var di=class t extends Z{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ie.fromReplace(e,this.pos,this.pos+1,new I(R.from(i),0,n.isLeaf?0:1))}getMap(){return nt.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};Z.jsonID("attr",di);var pi=class t extends Z{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ie.ok(r)}getMap(){return nt.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};Z.jsonID("docAttr",pi);var Tn=class extends Error{};Tn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Tn.prototype=Object.create(Error.prototype);Tn.prototype.constructor=Tn;Tn.prototype.name="TransformError";var mi=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new yo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Tn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=I.empty){let i=xr(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new I(R.from(r),0,0))}delete(e,n){return this.replace(e,n,I.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Rh(this,e,n,r),this}replaceRangeWith(e,n,r){return Ph(this,e,n,r),this}deleteRange(e,n){return zh(this,e,n),this}lift(e,n){return kh(this,e,n),this}join(e,n=1){return Eh(this,e,n),this}wrap(e,n){return Sh(this,e,n),this}setBlockType(e,n=e,r,i=null){return wh(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Th(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new di(e,n,r)),this}setDocAttribute(e,n){return this.step(new pi(e,n)),this}addNodeMark(e,n){return this.step(new gr(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ve)n.isInSet(r.marks)&&this.step(new Cn(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Cn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return Mh(this,e,n,r),this}addMark(e,n,r){return mh(this,e,n,r),this}removeMark(e,n,r){return gh(this,e,n,r),this}clearIncompatible(e,n,r){return So(this,e,n,r),this}};var wo=Object.create(null),H=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Nn(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=I.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?I.empty:n),l==0&&da(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),da(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new K(e):Mn(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?Mn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Mn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ce(e.node(0))}static atStart(e){return Mn(e,e,0,0,1)||new Ce(e)}static atEnd(e){return Mn(e,e,e.content.size,e.childCount,-1)||new Ce(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=wo[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in wo)throw new RangeError("Duplicate use of selection JSON ID "+e);return wo[e]=n,n.prototype.jsonID=e,n}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}};H.prototype.visible=!0;var Nn=class{constructor(e,n){this.$from=e,this.$to=n}},fa=!1;function ha(t){!fa&&!t.parent.inlineContent&&(fa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var K=class t extends H{constructor(e,n=e){ha(e),ha(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return H.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(e,n=I.empty){if(super.replace(e,n),n==I.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new xi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=H.findFrom(n,r,!0)||H.findFrom(n,-r,!0);if(o)n=o.$head;else return H.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(H.findFrom(e,-r,!0)||H.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new t(e,n)}};H.jsonID("text",K);var xi=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return K.between(e.resolve(this.anchor),e.resolve(this.head))}},P=class t extends H{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?H.near(o):new t(o)}content(){return new I(R.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new To(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};P.prototype.visible=!1;H.jsonID("node",P);var To=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xi(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&P.isSelectable(r)?new P(n):H.near(n)}},Ce=class t extends H{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=I.empty){if(n==I.empty){e.delete(0,e.doc.content.size);let r=H.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Bh}};H.jsonID("all",Ce);var Bh={map(){return this},resolve(t){return new Ce(t)}};function Mn(t,e,n,r,i,o=!1){if(e.inlineContent)return K.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&P.isSelectable(l))return P.create(t,n-(i<0?l.nodeSize:0))}else{let a=Mn(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function da(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof fe||i instanceof we))return;let o=t.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(H.near(t.doc.resolve(s),n))}var pa=1,ki=2,ma=4,Mo=class extends mi{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pa)&~ki,this.storedMarks=null,this}get selectionSet(){return(this.updated&pa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ki,this}ensureMarks(e){return Ve.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ki)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ki,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ve.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(H.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ma,this}get scrolledIntoView(){return(this.updated&ma)>0}};function ga(t,e){return!e||!t?t:t.bind(e)}var Ft=class{constructor(e,n,r){this.name=e,this.init=ga(n.init,r),this.apply=ga(n.apply,r)}},Fh=[new Ft("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ft("selection",{init(t,e){return t.selection||H.atStart(e.doc)},apply(t){return t.selection}}),new Ft("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ft("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],br=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Fh.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ft(r.key,r.spec.state,r))})}},bi=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new Mo(this)}static create(e){let n=new br(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new br(this.schema,e.plugins),r=n.fields,i=new t(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new br(e.schema,e.plugins),o=new t(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=li.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=H.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=c.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function ya(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ya(i,e,{})),n[r]=i}return n}var rt=class{constructor(e){this.spec=e,this.props={},e.props&&ya(e.props,this,this.props),this.key=e.key?e.key.key:ka("plugin")}getState(e){return e[this.key]}},Co=Object.create(null);function ka(t){return t in Co?t+"$"+ ++Co[t]:(Co[t]=0,t+"$")}var vt=class{constructor(e="key"){this.key=ka(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Te=class{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?vh(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function vh(t){return function(e,n,r,i){let o=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>0&&(o=n[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var xa=(t,e)=>{let n=t.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){let s=t.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},tk=new Te(/--$/,"\u2014",{inCodeMark:!1}),nk=new Te(/\.\.\.$/,"\u2026",{inCodeMark:!1}),rk=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),ik=new Te(/"$/,"\u201D",{inCodeMark:!1}),ok=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),sk=new Te(/'$/,"\u2019",{inCodeMark:!1});function lk(t,e,n=null,r){return new Te(t,(i,o,s,l)=>{let a=n instanceof Function?n(o):n,c=i.tr.delete(s,l),u=c.doc.resolve(s),f=u.blockRange(),d=f&&yi(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==e&&kr(c.doc,s-1)&&(!r||r(o,h))&&c.join(s-1),c})}function ak(t,e,n=null){return new Te(t,(r,i,o,s)=>{let l=r.doc.resolve(o),a=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,a):null})}var gt=typeof navigator<"u"?navigator:null,ba=typeof document<"u"?document:null,yt=gt&&gt.userAgent||"",Oo=/Edge\/(\d+)/.exec(yt),Ma=/MSIE \d/.exec(yt),Eo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),Si=!!(Ma||Eo||Oo),Lh=Ma?document.documentMode:Eo?+Eo[1]:Oo?+Oo[1]:0,Na=!Si&&/gecko\/(\d+)/i.test(yt),Vh=Na&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1],Io=!Si&&/Chrome\/(\d+)/.exec(yt),Oa=!!Io,_h=Io?+Io[1]:0,Ea=!Si&&!!gt&&/Apple Computer/.test(gt.vendor),Ia=Ea&&(/Mobile\/\w+/.test(yt)||!!gt&&gt.maxTouchPoints>2),$h=Ia||(gt?/Mac/.test(gt.platform):!1),Da=/Android \d/.test(yt),Aa=!!ba&&"webkitFontSmoothing"in ba.documentElement.style,jh=Aa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,pk=Object.freeze({__proto__:null,android:Da,chrome:Oa,chrome_version:_h,gecko:Na,gecko_version:Vh,ie:Si,ie_version:Lh,ios:Ia,mac:$h,safari:Ea,webkit:Aa,webkit_version:jh});function No(t,e,n,r,i,o){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"\uFFFC")+r;for(let c of i){let u=c,f=u.match.exec(a),d=f&&f[0]&&u.handler(s,f,e-(f[0].length-r.length),n);if(d)return u.undoable!==!1&&d.setMeta(o,{transform:d,from:e,to:n,text:r}),t.dispatch(d),!0}return!1}var qh=new vt("MILKDOWN_CUSTOM_INPUTRULES");function Ra({rules:t}){let e=new rt({key:qh,isInputRules:!0,state:{init(){return null},apply(n,r){let i=n.getMeta(this);return i||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return No(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&No(n,r.pos,r.pos,"",t,e)}),!1),keydown:(n,r)=>!(Da&&Oa&&r.key==="Enter")||n.composing?!1:n.someProp("handleKeyDown",i=>i(n,r))?(r.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!=="Enter")return!1;let{$cursor:i}=n.state.selection;return i?No(n,i.pos,i.pos,`
`,t,e):!1}}});return e}function Pa(t){return t.some(e=>e.type.spec.code)}function Sa(t,e,n){if(e>=n)return!1;let r=!1;return t.doc.nodesBetween(e,n,i=>(i.isInline&&Pa(i.marks)&&(r=!0),!r)),r}function Wh(t,e){var n;return Pa((n=t.storedMarks)!=null?n:t.doc.resolve(e).marks())}function mk(t,e,n={}){return new Te(t,(r,i,o,s)=>{var l,a,c,u;let{tr:f}=r,d=i.length,h=i[d-1],p=i[0],y=[],b,x={group:h,fullMatch:p,start:o,end:s},A=(l=n.updateCaptured)==null?void 0:l.call(n,x);if(Object.assign(x,A),{group:h,fullMatch:p,start:o,end:s}=x,p===null||h?.trim()==="")return null;if(h){let T=p.search(/\S/),V=o+p.indexOf(h),j=V+h.length,w=Sa(r,o+T,V),E=j<s&&Sa(r,j,s);if(w||E||Wh(r,s))return null;y=(a=f.storedMarks)!=null?a:[],j<s&&f.delete(j,s),V>o&&f.delete(o+T,V),b=o+T+h.length;let L=(c=n.getAttr)==null?void 0:c.call(n,i);f.addMark(o,b,e.create(L)),f.setStoredMarks(y),(u=n.beforeDispatch)==null||u.call(n,{match:i,start:o,end:s,tr:f})}return f})}function gk(t,e,n={}){return new Te(t,(r,i,o,s)=>{var l,a,c;let{tr:u}=r,f=i[1],d=i[0],h={group:f,fullMatch:d,start:o,end:s},p=(l=n.updateCaptured)==null?void 0:l.call(n,h);if(Object.assign(h,p),{group:f,fullMatch:d,start:o,end:s}=h,d===null||!f||f.trim()==="")return null;let y=(a=n.getAttr)==null?void 0:a.call(n,i),b=e.createAndFill(y);return b&&(u.replaceRangeWith(e.isBlock?u.doc.resolve(o).before():o,s,b),(c=n.beforeDispatch)==null||c.call(n,{match:[d,f],start:o,end:s,tr:u})),u})}var Hh=Object.defineProperty,Kh=Object.defineProperties,Jh=Object.getOwnPropertyDescriptors,wa=Object.getOwnPropertySymbols,Uh=Object.prototype.hasOwnProperty,Qh=Object.prototype.propertyIsEnumerable,Ca=(t,e,n)=>e in t?Hh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Yh=(t,e)=>{for(var n in e||(e={}))Uh.call(e,n)&&Ca(t,n,e[n]);if(wa)for(var n of wa(e))Qh.call(e,n)&&Ca(t,n,e[n]);return t},Gh=(t,e)=>Kh(t,Jh(e));function Ta(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function yk(t,e,n){let i=t.state.doc.content.size,o=Ta(e,0,i),s=Ta(n,0,i),l=t.coordsAtPos(o),a=t.coordsAtPos(s,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-f,p=u-c,x={top:c,bottom:u,left:f,right:d,width:h,height:p,x:f,y:c};return Gh(Yh({},x),{toJSON:()=>x})}function kk(t){return Object.assign(Object.create(t),t).setTime(Date.now())}function Xh(t,e){return Array.isArray(t)&&t.includes(e.type)||e.type===t}function xk(t){if(t.content.childCount===1){let e=t.content.firstChild;if(e?.type.name==="text"&&e.marks.length===0)return e;if(e?.type.name==="paragraph"&&e.childCount===1){let n=e.firstChild;if(n?.type.name==="text"&&n.marks.length===0)return n}}return!1}function Zh(t){return e=>{for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r)){let i=e.before(n),o=e.after(n);return{from:i,to:o,node:r}}}}}function bk(t,e){return Zh(n=>n.type===e)(t)}function Sk(t,e){let n=e.nodes[t];if(!n)throw ql("node",t);return n}function ed(t){return e=>{for(let n=e.depth;n>0;n--){let r=e.node(n);if(t(r))return{pos:e.before(n),start:e.start(n),depth:n,node:r}}}}function wk(t){return e=>ed(t)(e.$from)}function Ck(t,e){if(!(t instanceof P))return;let{node:n,$from:r}=t;if(Xh(e,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}var Tk=(t,e)=>{let{selection:n,doc:r}=t;if(n instanceof P)return{hasNode:n.node.type===e,pos:n.from,target:n.node};let{from:i,to:o}=n,s=!1,l=-1,a=null;return r.nodesBetween(i,o,(c,u)=>a?!1:c.type===e?(s=!0,l=u,a=c,!1):!0),{hasNode:s,pos:l,target:a}};var td=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nd=typeof navigator<"u"&&/Win/.test(navigator.platform);function rd(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))td?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function id(t){let e=Object.create(null);for(let n in t)e[rd(n)]=t[n];return e}function Do(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function za(t){return new rt({props:{handleKeyDown:od(t)}})}function od(t){let e=id(t);return function(n,r){let i=Fl(r),o,s=e[Do(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Do(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(nd&&r.ctrlKey&&r.altKey)&&(o=Bl[r.keyCode])&&o!=i){let l=e[Do(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var oe=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Dn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Fo=null,ot=function(t,e,n){let r=Fo||(Fo=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},sd=function(){Fo=null},Ht=function(t,e,n,r){return n&&(Ba(t,e,n,r,-1)||Ba(t,e,n,r,1))},ld=/^(img|br|input|textarea|hr)$/i;function Ba(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Re(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Er(t)||ld.test(t.nodeName)||t.contentEditable=="false")return!1;e=oe(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Re(t):0}else return!1}}function Re(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ad(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Re(t)}else if(t.parentNode&&!Er(t))e=oe(t),t=t.parentNode;else return null}}function cd(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Er(t))e=oe(t)+1,t=t.parentNode;else return null}}function ud(t,e,n){for(let r=e==0,i=e==Re(t);r||i;){if(t==n)return!0;let o=oe(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Re(t)}}function Er(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Pi=function(t){return t.focusNode&&Ht(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Lt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function fd(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function hd(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Re(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Re(r.startContainer),r.startOffset)}}}var Je=typeof navigator<"u"?navigator:null,Fa=typeof document<"u"?document:null,Ct=Je&&Je.userAgent||"",vo=/Edge\/(\d+)/.exec(Ct),fc=/MSIE \d/.exec(Ct),Lo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ct),ye=!!(fc||Lo||vo),bt=fc?document.documentMode:Lo?+Lo[1]:vo?+vo[1]:0,Pe=!ye&&/gecko\/(\d+)/i.test(Ct);Pe&&+(/Firefox\/(\d+)/.exec(Ct)||[0,0])[1];var Vo=!ye&&/Chrome\/(\d+)/.exec(Ct),se=!!Vo,hc=Vo?+Vo[1]:0,ce=!ye&&!!Je&&/Apple Computer/.test(Je.vendor),An=ce&&(/Mobile\/\w+/.test(Ct)||!!Je&&Je.maxTouchPoints>2),Ae=An||(Je?/Mac/.test(Je.platform):!1),dc=Je?/Win/.test(Je.platform):!1,st=/Android \d/.test(Ct),Ir=!!Fa&&"webkitFontSmoothing"in Fa.documentElement.style,dd=Ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function pd(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function it(t,e){return typeof t=="number"?t:t[e]}function md(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function va(t,e,n){if(!_o(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Dn(s);continue}let l=s,a=l==o.body,c=a?pd(o):md(l),u=0,f=0;if(e.top<c.top+it(r,"top")?f=-(c.top-e.top+it(i,"top")):e.bottom>c.bottom-it(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+it(i,"top")-c.top:e.bottom-c.bottom+it(i,"bottom")),e.left<c.left+it(r,"left")?u=-(c.left-e.left+it(i,"left")):e.right>c.right-it(r,"right")&&(u=e.right-c.right+it(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let y=l.scrollLeft-h,b=l.scrollTop-p;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let d=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Dn(s)}}function gd(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(o,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:pc(t.dom)}}function pc(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Dn(r));return e}function yd({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;mc(n,r==0?0:r-e)}function mc(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}var On=null;function kd(t){if(t.setActive)return t.setActive();if(On)return t.focus(On);let e=pc(t);t.focus(On==null?{get preventScroll(){return On={preventScroll:!0},!0}}:void 0),On||(On=!1,mc(e,0))}function gc(t,e){let n,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=ot(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){n=u,r=y,i=y&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&y&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!n&&a&&(n=a,i=c,r=0),n&&n.nodeType==3?xd(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:gc(n,i)}function xd(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=kt(r,1);if(s.top!=s.bottom&&ns(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function ns(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function bd(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Sd(t,e,n){let{node:r,offset:i}=gc(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function wd(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function yc(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ns(e,c))return yc(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function Cd(t,e){let n=t.dom.ownerDocument,r,i=0,o=hd(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!ns(e,c)||(s=yc(t.dom,e,c),!s))return null}if(ce)for(let c=s;r&&c;c=Dn(c))c.draggable&&(r=void 0);if(s=bd(s,e),r){if(Pe&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Ir&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=wd(t,r,i,e))}l==null&&(l=Sd(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function _o(t){return t.top<t.bottom||t.left<t.right}function kt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_o(r))return r}return Array.prototype.find.call(n,_o)||t.getBoundingClientRect()}var Td=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function kc(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=Ir||Pe;if(r.nodeType==3)if(s&&(Td.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=kt(ot(r,i,i),n);if(Pe&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=kt(ot(r,i-1,i-1),-1);if(c.top==a.top){let u=kt(ot(r,i,i+1),-1);if(u.top!=a.top)return Sr(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Sr(kt(ot(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Re(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ao(a.getBoundingClientRect(),!1)}if(o==null&&i<Re(r)){let a=r.childNodes[i];if(a.nodeType==1)return Ao(a.getBoundingClientRect(),!0)}return Ao(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Re(r))){let a=r.childNodes[i-1],c=a.nodeType==3?ot(a,Re(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Sr(kt(c,1),!1)}if(o==null&&i<Re(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ot(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Sr(kt(c,-1),!0)}return Sr(kt(r.nodeType==3?ot(r):r,-n),n>=0)}function Sr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ao(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function xc(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function Md(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return xc(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=kc(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ot(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var Nd=/[\u0590-\u08ac]/;function Od(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return l?!Nd.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:xc(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:y}=t.domSelectionRange(),b=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==y;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),b}):r.pos==r.start()||r.pos==r.end()}var La=null,Va=null,_a=!1;function Ed(t,e,n){return La==e&&Va==n?_a:(La=e,Va=n,_a=n=="up"||n=="down"?Md(t,e,n):Od(t,e,n))}var ze=0,$a=1,Vt=2,je=3,Kt=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ze,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof Ti){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof wi&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?oe(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?oe(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=oe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=oe(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let y=this.children[h],b=p+y.size;if(o>p&&s<b)return y.setSelection(e-p-y.border,n-p-y.border,r,i);p=b}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Pe||ce)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==`
`),f&&p==h.nodeValue.length)for(let y=h,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=a={node:b.parentNode,offset:oe(b)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=h.childNodes[p-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Pe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&ce)&&Ht(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Ht(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==n)&&!(f&&Pe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Vt:$a,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=je:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Vt:je}r=s}this.dirty=Vt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Vt:$a;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},wi=class extends Kt{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==ze&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},$o=class extends Kt{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},$t=class t extends Kt{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=or.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&je||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=je&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ze){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ze}}slice(e,n,r){let i=t.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Ho(o,n,s,r)),e>0&&(o=Ho(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},St=class t extends Kt{constructor(e,n,r,i,o,s,l){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,o,s){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=or.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let d=u;return u=wc(u,r,n),c?a=new jo(e,n,r,i,u,f||null,d,c):n.isText?new Ci(e,n,r,i,u,d):new t(e,n,r,i,u,f||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>R.empty}}return n}matchesNode(e,n,r){return this.dirty==ze&&e.eq(this.node)&&Mi(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Wo(this,s&&s.node,e);Rd(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?Ve.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e,d);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Vt)&&(s&&this.protectLocalComposition(e,s),bc(this.contentDOM,this.children,e),An&&Pd(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof K)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=zd(this.node.content,s,r-n,i-n);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new $o(this,o,n,i);e.input.compositionNodes.push(s),this.children=Ho(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==je||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ze}updateOuterDeco(e){if(Mi(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Sc(this.dom,this.nodeDOM,qo(this.outerDeco,this.node,n),qo(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function ja(t,e,n,r,i){wc(r,e,t);let o=new St(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}var Ci=class t extends St{constructor(e,n,r,i,o,s){super(e,n,r,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==je||this.dirty!=ze&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ze||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ze,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new t(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=je)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ti=class extends Kt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ze&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},jo=class extends St{constructor(e,n,r,i,o,s,l,a){super(e,n,r,i,o,s,l),this.spec=a}update(e,n,r,i){if(this.dirty==je)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function bc(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=qa(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof $t){let a=r?r.previousSibling:t.lastChild;bc(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=qa(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}var wr=function(t){t&&(this.nodeName=t)};wr.prototype=Object.create(null);var _t=[new wr];function qo(t,e,n){if(t.length==0)return _t;let r=n?_t[0]:new wr,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new wr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new wr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Sc(t,e,n,r){if(n==_t&&r==_t)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=n[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=_t[0]),i=a}Id(i,l||_t[0],s)}return i}function Id(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function wc(t,e,n){return Sc(t,t,_t,qo(e,n,t.nodeType!=1))}function Mi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function qa(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Wo=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Dd(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=ze,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof $t&&u.dirty!=je&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=$t.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==je&&s.dom==s.contentDOM&&(s.dirty=Vt),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof St){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=je&&Mi(n,a.outerDeco));if(!d&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Vt,f.updateChildren(i,s+1),f.dirty=ze),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Mi(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=St.create(this.top,n,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,i,o){let s=St.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new wi(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof $t;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Ci)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ce||se)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ti(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function Dd(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof $t)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Ad(t,e){return t.type.side-e.type.side}function Rd(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let b=i[s++];b.widget&&(u?(f||(f=[u])).push(b):u=b)}if(u)if(f){f.sort(Ad);for(let b=0;b<f.length;b++)n(f[b],c,!!a)}else n(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<t.childCount)h=c,d=t.child(c++);else break;for(let b=0;b<l.length;b++)l[b].to<=o&&l.splice(b--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let b=p;s<i.length&&i[s].from<b&&(b=i[s].from);for(let x=0;x<l.length;x++)l[x].to<b&&(b=l[x].to);b<p&&(a=d.cut(b-o),d=d.cut(0,b-o),p=b,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let y=d.isInline&&!d.isLeaf?l.filter(b=>!b.inline):l.slice();r(d,y,e.forChild(o,d),h),o=p}}function Pd(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function zd(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ho(t,e,n,r,i){let o=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function rs(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Pi(n)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&P.isSelectable(f)&&i.parent&&!(f.isInline&&ud(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new P(s==d?l:r.resolve(d))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,d=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==t.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=is(t,u,l,f)}return c}function Cc(t){return t.editable?t.hasFocus():Mc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function at(t,e=!1){let n=t.state.selection;if(Tc(t,n),!Cc(t))return;let r=t.input.mouseDown;if(!e&&se&&r){let i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Ht(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Fd(t);else{let{anchor:i,head:o}=n,s,l;Wa&&!(n instanceof K)&&(n.$from.parent.inlineContent||(s=Ha(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Ha(t,n.to))),t.docView.setSelection(i,o,t,e),Wa&&(s&&Ka(s),l&&Ka(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Bd(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var Wa=ce||se&&hc<63;function Ha(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(ce&&i&&i.contentEditable=="false")return Ro(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Ro(i);if(o)return Ro(o)}}function Ro(t){return t.contentEditable="true",ce&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ka(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Bd(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Cc(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Fd(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,oe(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ye&&bt<=11&&(n.disabled=!0,n.disabled=!1)}function Tc(t,e){if(e instanceof P){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ja(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ja(t)}function Ja(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function is(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||K.between(e,n,r)}function Ua(t){return t.editable&&!t.hasFocus()?!1:Mc(t)}function Mc(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function vd(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ht(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ko(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&H.findFrom(o,e)}function xt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Qa(t,e,n){let r=t.state.selection;if(r instanceof K)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return xt(t,new K(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Ko(t.state,e);return i&&i instanceof P?xt(t,i):!1}else if(!(Ae&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?P.isSelectable(o)?xt(t,new P(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Ir?xt(t,new K(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof P&&r.node.isInline)return xt(t,new K(e>0?r.$to:r.$from));{let i=Ko(t.state,e);return i?xt(t,i):!1}}}function Ni(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Cr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function En(t,e){return e<0?Ld(t):Vd(t)}function Ld(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Pe&&n.nodeType==1&&r<Ni(n)&&Cr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Cr(l,-1))i=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Nc(n))break;{let l=n.previousSibling;for(;l&&Cr(l,-1);)i=n.parentNode,o=oe(l),l=l.previousSibling;if(l)n=l,r=Ni(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Jo(t,n,r):i&&Jo(t,i,o)}function Vd(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Ni(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Cr(l,1))o=n,s=++r;else break}else{if(Nc(n))break;{let l=n.nextSibling;for(;l&&Cr(l,1);)o=l.parentNode,s=oe(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Ni(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&Jo(t,o,s)}function Nc(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function _d(t,e){for(;t&&e==t.childNodes.length&&!Er(t);)e=oe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function $d(t,e){for(;t&&!e&&!Er(t);)e=oe(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Jo(t,e,n){if(e.nodeType!=3){let o,s;(s=_d(e,n))?(e=s,n=0):(o=$d(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Pi(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&at(t)},50)}function Ya(t,e){let n=t.state.doc.resolve(e);if(!(se||dc)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ga(t,e,n){let r=t.state.selection;if(r instanceof K&&!r.empty||n.indexOf("s")>-1||Ae&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Ko(t.state,e);if(s&&s instanceof P)return xt(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Ce?H.near(s,e):H.findFrom(s,e);return l?xt(t,l):!1}return!1}function Xa(t,e){if(!(t.state.selection instanceof K))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Za(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function jd(t){if(!ce||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Za(t,r,"true"),setTimeout(()=>Za(t,r,"false"),20)}return!1}function qd(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Wd(t,e){let n=e.keyCode,r=qd(e);if(n==8||Ae&&n==72&&r=="c")return Xa(t,-1)||En(t,-1);if(n==46&&!e.shiftKey||Ae&&n==68&&r=="c")return Xa(t,1)||En(t,1);if(n==13||n==27)return!0;if(n==37||Ae&&n==66&&r=="c"){let i=n==37?Ya(t,t.state.selection.from)=="ltr"?-1:1:-1;return Qa(t,i,r)||En(t,i)}else if(n==39||Ae&&n==70&&r=="c"){let i=n==39?Ya(t,t.state.selection.from)=="ltr"?1:-1:1;return Qa(t,i,r)||En(t,i)}else{if(n==38||Ae&&n==80&&r=="c")return Ga(t,-1,r)||En(t,-1);if(n==40||Ae&&n==78&&r=="c")return jd(t)||Ga(t,1,r)||En(t,1);if(r==(Ae?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ss(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||or.fromSchema(t.state.schema),l=Rc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Ac[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`

`);return{dom:a,text:d,slice:e}}function Oc(t,e,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",d=>{e=d(e,o||r,t)}),o)return l=new I(R.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",d=>{l=d(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)l=f;else{let d=i.marks(),{schema:h}=t.state,p=or.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=s.appendChild(document.createElement("p"));y&&b.appendChild(p.serializeNode(h.text(y,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=Ud(n),Ir&&Qd(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||ir.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Hd.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Yd(ec(l,+u[1],+u[2]),u[4]);else if(l=I.maxOpen(Kd(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=ec(l,f,d)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}var Hd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Kd(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Ic(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Dc(s[s.length-1],o.length));let u=Ec(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return R.from(s)}return t}function Ec(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,R.from(t));return t}function Ic(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Ic(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(R.from(Ec(n,t,i+1))))}}function Dc(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Dc(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(R.empty,!0);return t.copy(n.append(r))}function Uo(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(o=0),i<r-1&&(l=Uo(l,e,n,r,i+1,o)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(R.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function ec(t,e,n){return e<t.openStart&&(t=new I(Uo(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new I(Uo(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Ac={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Rc(){return document.implementation.createHTMLDocument("title")}var Po=null;function Jd(t){let e=window.trustedTypes;return e?(Po||(Po=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Po.createHTML(t)):t}function Ud(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Rc(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&Ac[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Jd(t),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let f=0;f<u.length;f++)u[f].style.cssText+=c.style.cssText}}}return r}function Qd(t){let e=t.querySelectorAll(se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Yd(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=R.from(a.create(r[l+1],i)),o++,s++}return new I(i,o,s)}var he={},de={},Gd={touchstart:!0,touchmove:!0},Qo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Xd(t){for(let e in he){let n=he[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{ep(t,r)&&!ls(t,r)&&(t.editable||!(r.type in de))&&n(t,r)},Gd[e]?{passive:!0}:void 0)}ce&&t.dom.addEventListener("input",()=>null),Yo(t)}function lt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Zd(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Yo(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ls(t,r))})}function ls(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function ep(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function tp(t,e){!ls(t,e)&&he[e.type]&&(t.editable||!(e.type in de))&&he[e.type](t,e)}de.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Bc(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(st&&se&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),An&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Lt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Wd(t,n)?n.preventDefault():lt(t,"key")};de.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};de.keypress=(t,e)=>{let n=e;if(Bc(t)||!n.charCode||n.ctrlKey&&!n.altKey||Ae&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof K)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function Dr(t){return{left:t.clientX,top:t.clientY}}function np(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function as(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Ar(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function rp(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&P.isSelectable(r)?(Ar(t,new P(n),"pointer"),!0):!1}function ip(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof P&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(P.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Ar(t,P.create(t.state.doc,i),"pointer"),!0):!1}function op(t,e,n,r,i){return as(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?ip(t,n):rp(t,n))}function sp(t,e,n,r){return as(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function lp(t,e,n,r){return as(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ap(t,n,r)}function ap(t,e,n){if(n.button!=0)return!1;let r=Pc(t,e,!0),i=t.state.doc;return r?(Ar(t,r,"pointer"),r instanceof K&&i.eq(t.state.doc)&&(t.input.mouseDown=new Xo(t,r)),!0):!1}function Pc(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?K.create(r,0,r.content.size):null;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return K.create(r,l+1,l+1+s.content.size);if(n&&P.isSelectable(s))return P.create(r,l)}return null}function cs(t){return Ei(t)}var zc=Ae?"metaKey":"ctrlKey";he.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=cs(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&np(n,t.input.lastClick)&&!n[zc]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Dr(n));s&&(o=="singleClick"?t.input.mouseDown=new Go(t,s,n,!!r):(o=="doubleClick"?sp:lp)(t,s.pos,s.inside,n)?n.preventDefault():lt(t,"pointer"))};var Oi=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Go=class extends Oi{constructor(e,n,r,i){super(e),this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[zc],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof P&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Pe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),lt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||at(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Dr(e))),this.updateAllowDefault(e),this.allowDefault||!n?lt(this.view,"pointer"):op(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||se&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ar(this.view,H.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):lt(this.view,"pointer")}move(e){this.updateAllowDefault(e),lt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Xo=class extends Oi{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),lt(this.view,"pointer");let n=this.view.posAtCoords(Dr(e)),r=n&&Pc(this.view,n.inside,!1);if(!r)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=r.from<o.from?[o.to,r.from]:[o.from,r.to];Ar(this.view,K.create(i,s,l),"pointer")}};he.touchstart=t=>{t.input.lastTouch=Date.now(),cs(t),lt(t,"pointer")};he.touchmove=t=>{t.input.lastTouch=Date.now(),lt(t,"pointer")};he.contextmenu=t=>cs(t);function Bc(t,e){return t.composing?!0:ce&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var cp=st?5e3:-1;de.compositionstart=de.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof K&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||se&&dc&&up(t)))t.markCursor=t.state.storedMarks||n.marks(),Ei(t,!0),t.markCursor=null;else if(Ei(t,!e.selection.empty),Pe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}Fc(t,cp)};function up(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}de.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Fc(t,20))};function Fc(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ei(t),e))}function vc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function fp(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=ad(e.focusNode,e.focusOffset),r=cd(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Ei(t,e=!1){if(!(st&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),vc(t),e||t.docView&&t.docView.dirty){let n=rs(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function hp(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Tr=ye&&bt<15||An&&dd<604;he.copy=de.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Tr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=ss(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):hp(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dp(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function pp(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Mr(t,r.value,null,i,e):Mr(t,r.textContent,r.innerHTML,i,e)},50)}function Mr(t,e,n,r,i){let o=Oc(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||I.empty)))return!0;if(!o)return!1;let s=dp(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Lc(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}de.paste=(t,e)=>{let n=e;if(t.composing&&!st)return;let r=Tr?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Mr(t,Lc(r),r.getData("text/html"),i,n)?n.preventDefault():pp(t,n)};var Ii=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},mp=Ae?"altKey":"ctrlKey";function Vc(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[mp]}he.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Dr(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof P?i.to-1:i.to))){if(r&&r.mightDrag)s=P.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=P.create(t.state.doc,f.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=ss(t,l);(!n.dataTransfer.files.length||!se||hc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Tr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Tr||n.dataTransfer.setData("text/plain",c),t.dragging=new Ii(u,Vc(t,n),s)};he.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};de.dragover=de.dragenter=(t,e)=>e.preventDefault();de.drop=(t,e)=>{try{gp(t,e,t.dragging)}finally{t.dragging=null}};function gp(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Dr(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=Oc(t,Lc(e.dataTransfer),Tr?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&Vc(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||I.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?sa(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&P.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new P(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,y,b,x)=>h=x),a.setSelection(is(t,d,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}he.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&at(t)},20))};he.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};he.beforeinput=(t,e)=>{if(st&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Lt(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in de)he[t]=de[t];function Nr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var Di=class t{constructor(e,n){this.toDOM=e,this.spec=n||qt,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new wt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Nr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},jt=class t{constructor(e,n){this.attrs=e,this.spec=n||qt}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new wt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Nr(this.attrs,e.attrs)&&Nr(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},Zo=class t{constructor(e,n){this.attrs=e,this.spec=n||qt}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new wt(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Nr(this.attrs,e.attrs)&&Nr(this.spec,e.spec)}destroy(){}},wt=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new Di(n,r))}static inline(e,n,r,i){return new t(e,n,new jt(r,i))}static node(e,n,r,i){return new t(e,n,new Zo(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof jt}get widget(){return this.type instanceof Di}},In=[],qt={},Be=class t{constructor(e,n){this.local=e.length?e:In,this.children=n.length?n:In}static create(e,n){return n.length?Ri(n,e,0,qt):ae}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||qt)}mapInner(e,n,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?yp(this.children,s||[],e,n,r,i,o):s?new t(s.sort(Wt),In):ae}add(e,n){return n.length?this==ae?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=$c(n,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,Ri(u,l,c+1,qt)),o+=3}});let s=_c(o?jc(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new t(s.length?this.local.concat(s).sort(Wt):this.local,i||this.children)}remove(e){return e.length==0||this==ae?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+n,a=r[o+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=ae?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new t(i,r):ae}forChild(e,n){if(this==ae)return this;if(n.isLeaf)return t.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof jt){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new t(i.sort(Wt),In);return r?new Ai([l,r]):l}return r||ae}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return us(this.localsInner(e))}localsInner(e){if(this==ae)return In;if(e.inlineContent||!this.local.some(jt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof jt||n.push(this.local[r]);return n}forEachSet(e){e(this)}};Be.empty=new Be([],[]);Be.removeOverlap=us;var ae=Be.empty,Ai=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(i=>i.map(e,n,qt));return t.from(r)}forChild(e,n){if(n.isLeaf)return Be.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=ae&&(o instanceof t?r=r.concat(o.members):r.push(o))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?us(r?n:n.sort(Wt)):In}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new t(e.every(n=>n instanceof Be)?e:e.reduce((n,r)=>n.concat(r instanceof Be?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function yp(t,e,n,r,i,o,s){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((d,h,p,y)=>{let b=y-p-(h-d);for(let x=0;x<l.length;x+=3){let A=l[x+1];if(A<0||d>A+u-f)continue;let T=l[x]+u-f;h>=T?l[x+1]=d<=T?-2:-1:d>=u&&b&&(l[x]+=b,l[x+1]+=b)}f+=b}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=n.map(t[c+1]+o,-1),h=d-i,{index:p,offset:y}=r.content.findIndex(f),b=r.maybeChild(p);if(b&&y==f&&y+b.nodeSize==h){let x=l[c+2].mapInner(n,b,u+1,t[c]+o+1,s);x!=ae?(l[c]=f,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=kp(l,t,e,n,i,o,s),u=Ri(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new Be(e.sort(Wt),l)}function _c(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new wt(i.from+e,i.to+e,i.type))}return n}function kp(t,e,n,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function $c(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function jc(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ri(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=$c(t,l,a+n);if(c){o=!0;let u=Ri(c,l,n+a+1,r);u!=ae&&i.push(a,a+l.nodeSize,u)}});let s=_c(o?jc(t):t,-n).sort(Wt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Be(s,i):ae}function Wt(t,e){return t.from-e.from||t.to-e.to}function us(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),tc(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),tc(e,i,r.copy(o.from,r.to)));break}}}return e}function tc(t,e,n){for(;e<t.length&&Wt(n,t[e])>0;)e++;t.splice(e,0,n)}function zo(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ae&&e.push(r)}),t.cursorWrapper&&e.push(Be.create(t.state.doc,[t.cursorWrapper.deco])),Ai.from(e)}var xp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bp=ye&&bt<=11,es=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ts=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new es,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ye&&bt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ce&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),bp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,xp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ua(this.view)){if(this.suppressingSelectionUpdates)return at(this.view);if(ye&&bt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ht(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Dn(o))n.add(o);for(let o=e.anchorNode;o;o=Dn(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ua(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||se&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(Pe&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||Cp(e,f)!=h)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Pi(r)&&(c=rs(e))&&c.eq(H.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,at(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Sp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Tp(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||at(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(ye&&bt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?oe(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?oe(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},nc=new WeakMap,rc=!1;function Sp(t){if(!nc.has(t)&&(nc.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Pe,rc)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),rc=!0}}function ic(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Ht(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function wp(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return ic(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?ic(t,n):null}function Cp(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Tp(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Mp(t,e,n,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,f=c.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)&&(u=[{node:f,offset:c.anchorOffset}],Pi(c)||u.push({node:c.focusNode,offset:c.focusOffset})),se&&t.input.lastKeyCode===8)for(let x=s;x>o;x--){let A=i.childNodes[x-1],T=A.pmViewDesc;if(A.nodeName=="BR"&&!T){s=x;break}if(!T||T.size)break}let d=t.state.doc,h=t.someProp("domParser")||ir.fromSchema(t.state.schema),p=d.resolve(l),y=null,b=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Np(r),context:p});if(u&&u[0].pos!=null){let x=u[0].pos,A=u[1]&&u[1].pos;A==null&&(A=x),y={anchor:x+l,head:A+l}}return{doc:b,sel:y,from:l,to:a}}var Np=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ce&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ce&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Op=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ep(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,L=rs(t,E);if(L&&!t.state.selection.eq(L)){if(se&&st&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",Q=>Q(t,Lt(13,"Enter"))))return;let z=t.state.tr.setSelection(L);E=="pointer"?z.setMeta("pointer",!0):E=="key"&&z.scrollIntoView(),o&&z.setMeta("composition",o),t.dispatch(z)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Mp(t,e,n,i),u=t.state.doc,f=u.slice(c.from,c.to),d,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(d=t.state.selection.to,h="end"):(d=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=Ap(f.content,c.doc.content,c.from,d,h);if(p&&t.input.domChangeCount++,(An&&t.input.lastIOSEnter>Date.now()-225||st)&&i.some(E=>E.nodeType==1&&!Op.test(E.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",E=>E(t,Lt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof K&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=oc(t,t.state.doc,c.sel);if(E&&!E.eq(t.state.selection)){let L=t.state.tr.setSelection(E);o&&L.setMeta("composition",o),t.dispatch(L)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof K&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ye&&bt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),b=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),A=y.sameParent(b)&&y.parent.inlineContent&&x.end()>=p.endA;if((An&&t.input.lastIOSEnter>Date.now()-225&&(!A||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!A&&y.pos<c.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(c.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,Lt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Dp(u,p.start,p.endA,y,b)&&t.someProp("handleKeyDown",E=>E(t,Lt(8,"Backspace")))){st&&se&&t.domObserver.suppressSelectionUpdates();return}se&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),st&&!A&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,b=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,Lt(13,"Enter"))})},20));let T=p.start,V=p.endA,j=E=>{let L=E||t.state.tr.replace(T,V,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let z=oc(t,L.doc,c.sel);z&&!(se&&t.composing&&z.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(z.head==T||z.head==L.mapping.map(V)-1)||ye&&z.empty&&z.head==T)&&L.setSelection(z)}return o&&L.setMeta("composition",o),L.scrollIntoView()},w;if(A)if(y.pos==b.pos){ye&&bt<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>at(t),20));let E=j(t.state.tr.delete(T,V)),L=u.resolve(p.start).marksAcross(u.resolve(p.endA));L&&E.ensureMarks(L),t.dispatch(E)}else if(p.endA==p.endB&&(w=Ip(y.parent.content.cut(y.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let E=j(t.state.tr);w.type=="add"?E.addMark(T,V,w.mark):E.removeMark(T,V,w.mark),t.dispatch(E)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let E=y.parent.textBetween(y.parentOffset,b.parentOffset),L=()=>j(t.state.tr.insertText(E,T,V));t.someProp("handleTextInput",z=>z(t,T,V,E,L))||t.dispatch(L())}else t.dispatch(j());else t.dispatch(j())}function oc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:is(t,e.resolve(n.anchor),e.resolve(n.head))}function Ip(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(R.from(c).eq(t))return{mark:l,type:s}}function Dp(t,e,n,r,i){if(n-e<=i.pos-r.pos||Bo(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(Bo(o,!0,!0));return!s.parent.isTextblock||s.pos>n||Bo(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Bo(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Ap(t,e,n,r,i){let o=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(o==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(i=="end"){let u=Math.max(0,o-Math.min(a,c));r-=a+u-o}if(a<o&&s<l){let u=r<=o&&r>=a?o-r:0;o-=u,c=o+(c-a),a=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,a=o+(a-c),c=o}return{start:o,endA:a,endB:c}}var Or=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Qo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(uc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ac(this),lc(this),this.nodeViews=cc(this),this.docView=ja(this.state.doc,sc(this),zo(this),this.dom,this),this.domObserver=new ts(this,(r,i,o,s)=>Ep(this,r,i,o,s)),this.domObserver.start(),Xd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Yo(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(uc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(vc(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=cc(this);Pp(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Yo(this),this.editable=ac(this),lc(this);let a=zo(this),c=sc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&gd(this);if(s){this.domObserver.stop();let h=f&&(ye||se)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Rp(i.selection,e.selection);if(f){let y=se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fp(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ja(e.doc,c,a,this.dom,this)),y&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&vd(this)&&p.delaySelUpdate())?at(this,h):(Tc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&yd(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof P){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&va(this,n.getBoundingClientRect(),e)}else va(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Ii(e.slice,e.move,i<0?void 0:P.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&kd(this.dom),at(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Cd(this,e)}coordsAtPos(e,n=1){return kc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return Ed(this,n||this.state,e)}pasteHTML(e,n){return Mr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Mr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ss(this,e)}destroy(){this.docView&&(Zd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],zo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,sd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tp(this,e)}domSelectionRange(){let e=this.domSelection();return e?ce&&this.root.nodeType===11&&fd(this.dom.ownerDocument)==this.dom&&wp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Or.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function sc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[wt.node(0,t.state.doc.content.size,e)]}function lc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:wt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ac(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Rp(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function cc(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Pp(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function uc(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var zp={};function Jt(t,e){let n=e||zp,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Wc(t,r,i)}function Wc(t,e,n){if(Bp(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return qc(t.children,e,n)}return Array.isArray(t)?qc(t,e,n):""}function qc(t,e,n){let r=[],i=-1;for(;++i<t.length;)r[i]=Wc(t[i],e,n);return r.join("")}function Bp(t){return!!(t&&typeof t=="object")}var Hc=document.createElement("i");function Rn(t){let e="&"+t+";";Hc.innerHTML=e;let n=Hc.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function le(t,e,n,r){let i=t.length,o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),t.splice(...s),o+=1e4,e+=1e4}function pe(t,e){return t.length>0?(le(t,t.length,0,e),t):e}var Kc={}.hasOwnProperty;function Jc(t){let e={},n=-1;for(;++n<t.length;)Fp(e,t[n]);return e}function Fp(t,e){let n;for(n in e){let i=(Kc.call(t,n)?t[n]:void 0)||(t[n]={}),o=e[n],s;if(o)for(s in o){Kc.call(i,s)||(i[s]=[]);let l=o[s];vp(i[s],Array.isArray(l)?l:l?[l]:[])}}}function vp(t,e){let n=-1,r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);le(t,0,0,r)}function zi(t,e){let n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function ct(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Me=Tt(/[A-Za-z]/),me=Tt(/[\dA-Za-z]/),Uc=Tt(/[#-'*+\--9=?A-Z^-~]/);function Rr(t){return t!==null&&(t<32||t===127)}var Pr=Tt(/\d/),Qc=Tt(/[\dA-Fa-f]/),Yc=Tt(/[!-/:-@[-`{-~]/);function N(t){return t!==null&&t<-2}function G(t){return t!==null&&(t<0||t===32)}function B(t){return t===-2||t===-1||t===32}var Gc=Tt(/\p{P}|\p{S}/u),Xc=Tt(/\s/);function Tt(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function v(t,e,n,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return s;function s(a){return B(a)?(t.enter(n),l(a)):e(a)}function l(a){return B(a)&&o++<i?(t.consume(a),l):(t.exit(n),e(a))}}var Zc={tokenize:Lp};function Lp(t){let e=t.attempt(this.parser.constructs.contentInitial,r,i),n;return e;function r(l){if(l===null){t.consume(l);return}return t.enter("lineEnding"),t.consume(l),t.exit("lineEnding"),v(t,e,"linePrefix")}function i(l){return t.enter("paragraph"),o(l)}function o(l){let a=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=a),n=a,s(l)}function s(l){if(l===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(l);return}return N(l)?(t.consume(l),t.exit("chunkText"),o):(t.consume(l),s)}}var tu={tokenize:Vp},eu={tokenize:_p};function Vp(t){let e=this,n=[],r=0,i,o,s;return l;function l(T){if(r<n.length){let V=n[r];return e.containerState=V[1],t.attempt(V[0].continuation,a,c)(T)}return c(T)}function a(T){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&A();let V=e.events.length,j=V,w;for(;j--;)if(e.events[j][0]==="exit"&&e.events[j][1].type==="chunkFlow"){w=e.events[j][1].end;break}x(r);let E=V;for(;E<e.events.length;)e.events[E][1].end={...w},E++;return le(e.events,j+1,0,e.events.slice(V)),e.events.length=E,c(T)}return l(T)}function c(T){if(r===n.length){if(!i)return d(T);if(i.currentConstruct&&i.currentConstruct.concrete)return p(T);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(eu,u,f)(T)}function u(T){return i&&A(),x(r),d(T)}function f(T){return e.parser.lazy[e.now().line]=r!==n.length,s=e.now().offset,p(T)}function d(T){return e.containerState={},t.attempt(eu,h,p)(T)}function h(T){return r++,n.push([e.currentConstruct,e.containerState]),d(T)}function p(T){if(T===null){i&&A(),x(0),t.consume(T);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),y(T)}function y(T){if(T===null){b(t.exit("chunkFlow"),!0),x(0),t.consume(T);return}return N(T)?(t.consume(T),b(t.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(t.consume(T),y)}function b(T,V){let j=e.sliceStream(T);if(V&&j.push(null),T.previous=o,o&&(o.next=T),o=T,i.defineSkip(T.start),i.write(j),e.parser.lazy[T.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<s&&(!i.events[w][1].end||i.events[w][1].end.offset>s))return;let E=e.events.length,L=E,z,Q;for(;L--;)if(e.events[L][0]==="exit"&&e.events[L][1].type==="chunkFlow"){if(z){Q=e.events[L][1].end;break}z=!0}for(x(r),w=E;w<e.events.length;)e.events[w][1].end={...Q},w++;le(e.events,L+1,0,e.events.slice(E)),e.events.length=w}}function x(T){let V=n.length;for(;V-- >T;){let j=n[V];e.containerState=j[1],j[0].exit.call(e,t)}n.length=T}function A(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function _p(t,e,n){return v(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Pn(t){if(t===null||G(t)||Xc(t))return 1;if(Gc(t))return 2}function zn(t,e,n){let r=[],i=-1;for(;++i<t.length;){let o=t[i].resolveAll;o&&!r.includes(o)&&(e=o(e,n),r.push(o))}return e}var zr={name:"attention",resolveAll:$p,tokenize:jp};function $p(t,e){let n=-1,r,i,o,s,l,a,c,u;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;a=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;let f={...t[r][1].end},d={...t[n][1].start};nu(f,-a),nu(d,a),s={type:a>1?"strongSequence":"emphasisSequence",start:f,end:{...t[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:d},o={type:a>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:a>1?"strong":"emphasis",start:{...s.start},end:{...l.end}},t[r][1].end={...s.start},t[n][1].start={...l.end},c=[],t[r][1].end.offset-t[r][1].start.offset&&(c=pe(c,[["enter",t[r][1],e],["exit",t[r][1],e]])),c=pe(c,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),c=pe(c,zn(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),c=pe(c,[["exit",o,e],["enter",l,e],["exit",l,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(u=2,c=pe(c,[["enter",t[n][1],e],["exit",t[n][1],e]])):u=0,le(t,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function jp(t,e){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Pn(r),o;return s;function s(a){return o=a,t.enter("attentionSequence"),l(a)}function l(a){if(a===o)return t.consume(a),l;let c=t.exit("attentionSequence"),u=Pn(a),f=!u||u===2&&i||n.includes(a),d=!i||i===2&&u||n.includes(r);return c._open=!!(o===42?f:f&&(i||!d)),c._close=!!(o===42?d:d&&(u||!f)),e(a)}}function nu(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var fs={name:"autolink",tokenize:qp};function qp(t,e,n){let r=0;return i;function i(h){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(h){return Me(h)?(t.consume(h),s):h===64?n(h):c(h)}function s(h){return h===43||h===45||h===46||me(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(t.consume(h),r=0,a):(h===43||h===45||h===46||me(h))&&r++<32?(t.consume(h),l):(r=0,c(h))}function a(h){return h===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):h===null||h===32||h===60||Rr(h)?n(h):(t.consume(h),a)}function c(h){return h===64?(t.consume(h),u):Uc(h)?(t.consume(h),c):n(h)}function u(h){return me(h)?f(h):n(h)}function f(h){return h===46?(t.consume(h),r=0,u):h===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):d(h)}function d(h){if((h===45||me(h))&&r++<63){let p=h===45?d:f;return t.consume(h),p}return n(h)}}var Mt={partial:!0,tokenize:Wp};function Wp(t,e,n){return r;function r(o){return B(o)?v(t,i,"linePrefix")(o):i(o)}function i(o){return o===null||N(o)?e(o):n(o)}}var Bi={continuation:{tokenize:Kp},exit:Jp,name:"blockQuote",tokenize:Hp};function Hp(t,e,n){let r=this;return i;function i(s){if(s===62){let l=r.containerState;return l.open||(t.enter("blockQuote",{_container:!0}),l.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(s),t.exit("blockQuoteMarker"),o}return n(s)}function o(s){return B(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}function Kp(t,e,n){let r=this;return i;function i(s){return B(s)?v(t,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return t.attempt(Bi,e,n)(s)}}function Jp(t){t.exit("blockQuote")}var Fi={name:"characterEscape",tokenize:Up};function Up(t,e,n){return r;function r(o){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(o),t.exit("escapeMarker"),i}function i(o){return Yc(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(o)}}var vi={name:"characterReference",tokenize:Qp};function Qp(t,e,n){let r=this,i=0,o,s;return l;function l(f){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),a}function a(f){return f===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(f),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),o=31,s=me,u(f))}function c(f){return f===88||f===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(f),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,s=Qc,u):(t.enter("characterReferenceValue"),o=7,s=Pr,u(f))}function u(f){if(f===59&&i){let d=t.exit("characterReferenceValue");return s===me&&!Rn(r.sliceSerialize(d))?n(f):(t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return s(f)&&i++<o?(t.consume(f),u):n(f)}}var ru={partial:!0,tokenize:Gp},Li={concrete:!0,name:"codeFenced",tokenize:Yp};function Yp(t,e,n){let r=this,i={partial:!0,tokenize:j},o=0,s=0,l;return a;function a(w){return c(w)}function c(w){let E=r.events[r.events.length-1];return o=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,l=w,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(w)}function u(w){return w===l?(s++,t.consume(w),u):s<3?n(w):(t.exit("codeFencedFenceSequence"),B(w)?v(t,f,"whitespace")(w):f(w))}function f(w){return w===null||N(w)?(t.exit("codeFencedFence"),r.interrupt?e(w):t.check(ru,y,V)(w)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),d(w))}function d(w){return w===null||N(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),f(w)):B(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),v(t,h,"whitespace")(w)):w===96&&w===l?n(w):(t.consume(w),d)}function h(w){return w===null||N(w)?f(w):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||N(w)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),f(w)):w===96&&w===l?n(w):(t.consume(w),p)}function y(w){return t.attempt(i,V,b)(w)}function b(w){return t.enter("lineEnding"),t.consume(w),t.exit("lineEnding"),x}function x(w){return o>0&&B(w)?v(t,A,"linePrefix",o+1)(w):A(w)}function A(w){return w===null||N(w)?t.check(ru,y,V)(w):(t.enter("codeFlowValue"),T(w))}function T(w){return w===null||N(w)?(t.exit("codeFlowValue"),A(w)):(t.consume(w),T)}function V(w){return t.exit("codeFenced"),e(w)}function j(w,E,L){let z=0;return Q;function Q(_){return w.enter("lineEnding"),w.consume(_),w.exit("lineEnding"),Ee}function Ee(_){return w.enter("codeFencedFence"),B(_)?v(w,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):J(_)}function J(_){return _===l?(w.enter("codeFencedFenceSequence"),D(_)):L(_)}function D(_){return _===l?(z++,w.consume(_),D):z>=s?(w.exit("codeFencedFenceSequence"),B(_)?v(w,$,"whitespace")(_):$(_)):L(_)}function $(_){return _===null||N(_)?(w.exit("codeFencedFence"),E(_)):L(_)}}}function Gp(t,e,n){let r=this;return i;function i(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}var Br={name:"codeIndented",tokenize:Zp},Xp={partial:!0,tokenize:em};function Zp(t,e,n){let r=this;return i;function i(c){return t.enter("codeIndented"),v(t,o,"linePrefix",5)(c)}function o(c){let u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?a(c):N(c)?t.attempt(Xp,s,a)(c):(t.enter("codeFlowValue"),l(c))}function l(c){return c===null||N(c)?(t.exit("codeFlowValue"),s(c)):(t.consume(c),l)}function a(c){return t.exit("codeIndented"),e(c)}}function em(t,e,n){let r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):N(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i):v(t,o,"linePrefix",5)(s)}function o(s){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):N(s)?i(s):n(s)}}var hs={name:"codeText",previous:nm,resolve:tm,tokenize:rm};function tm(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function nm(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function rm(t,e,n){let r=this,i=0,o,s;return l;function l(d){return t.enter("codeText"),t.enter("codeTextSequence"),a(d)}function a(d){return d===96?(t.consume(d),i++,a):(t.exit("codeTextSequence"),c(d))}function c(d){return d===null?n(d):d===32?(t.enter("space"),t.consume(d),t.exit("space"),c):d===96?(s=t.enter("codeTextSequence"),o=0,f(d)):N(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),c):(t.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||N(d)?(t.exit("codeTextData"),c(d)):(t.consume(d),u)}function f(d){return d===96?(t.consume(d),o++,f):o===i?(t.exit("codeTextSequence"),t.exit("codeText"),e(d)):(s.type="codeTextData",u(d))}}var Vi=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){let i=n||0;this.setCursor(Math.trunc(e));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Fr(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Fr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Fr(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let n=this.left.splice(e,Number.POSITIVE_INFINITY);Fr(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Fr(this.left,n.reverse())}}};function Fr(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function _i(t){let e={},n=-1,r,i,o,s,l,a,c,u=new Vi(t);for(;++n<u.length;){for(;n in e;)n=e[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,o=0,o<a.length&&a[o][1].type==="lineEndingBlank"&&(o+=2),o<a.length&&a[o][1].type==="content"))for(;++o<a.length&&a[o][1].type!=="content";)a[o][1].type==="chunkText"&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,im(u,n)),n=e[n],c=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(s=u.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},l=u.slice(i,n),l.unshift(r),u.splice(i,n-i+1,l))}}return le(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function im(t,e){let n=t.get(e)[1],r=t.get(e)[2],i=e-1,o=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let l=s.events,a=[],c={},u,f,d=-1,h=n,p=0,y=0,b=[y];for(;h;){for(;t.get(++i)[1]!==h;);o.push(i),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(y=d+1,b.push(y),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),d=b.length;d--;){let x=l.slice(b[d],b[d+1]),A=o.pop();a.push([A,A+x.length-1]),t.splice(A,2,x)}for(a.reverse(),d=-1;++d<a.length;)c[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return c}var ds={resolve:sm,tokenize:lm},om={partial:!0,tokenize:am};function sm(t){return _i(t),t}function lm(t,e){let n;return r;function r(l){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):N(l)?t.check(om,s,o)(l):(t.consume(l),i)}function o(l){return t.exit("chunkContent"),t.exit("content"),e(l)}function s(l){return t.consume(l),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function am(t,e,n){let r=this;return i;function i(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),v(t,o,"linePrefix")}function o(s){if(s===null||N(s))return n(s);let l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):t.interrupt(r.parser.constructs.flow,n,e)(s)}}function $i(t,e,n,r,i,o,s,l,a){let c=a||Number.POSITIVE_INFINITY,u=0;return f;function f(x){return x===60?(t.enter(r),t.enter(i),t.enter(o),t.consume(x),t.exit(o),d):x===null||x===32||x===41||Rr(x)?n(x):(t.enter(r),t.enter(s),t.enter(l),t.enter("chunkString",{contentType:"string"}),y(x))}function d(x){return x===62?(t.enter(o),t.consume(x),t.exit(o),t.exit(i),t.exit(r),e):(t.enter(l),t.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(t.exit("chunkString"),t.exit(l),d(x)):x===null||x===60||N(x)?n(x):(t.consume(x),x===92?p:h)}function p(x){return x===60||x===62||x===92?(t.consume(x),h):h(x)}function y(x){return!u&&(x===null||x===41||G(x))?(t.exit("chunkString"),t.exit(l),t.exit(s),t.exit(r),e(x)):u<c&&x===40?(t.consume(x),u++,y):x===41?(t.consume(x),u--,y):x===null||x===32||x===40||Rr(x)?n(x):(t.consume(x),x===92?b:y)}function b(x){return x===40||x===41||x===92?(t.consume(x),y):y(x)}}function ji(t,e,n,r,i,o){let s=this,l=0,a;return c;function c(h){return t.enter(r),t.enter(i),t.consume(h),t.exit(i),t.enter(o),u}function u(h){return l>999||h===null||h===91||h===93&&!a||h===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(h):h===93?(t.exit(o),t.enter(i),t.consume(h),t.exit(i),t.exit(r),e):N(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||N(h)||l++>999?(t.exit("chunkString"),u(h)):(t.consume(h),a||(a=!B(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(t.consume(h),l++,f):f(h)}}function qi(t,e,n,r,i,o){let s;return l;function l(d){return d===34||d===39||d===40?(t.enter(r),t.enter(i),t.consume(d),t.exit(i),s=d===40?41:d,a):n(d)}function a(d){return d===s?(t.enter(i),t.consume(d),t.exit(i),t.exit(r),e):(t.enter(o),c(d))}function c(d){return d===s?(t.exit(o),a(s)):d===null?n(d):N(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),v(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===s||d===null||N(d)?(t.exit("chunkString"),c(d)):(t.consume(d),d===92?f:u)}function f(d){return d===s||d===92?(t.consume(d),u):u(d)}}function Ut(t,e){let n;return r;function r(i){return N(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):B(i)?v(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}var ps={name:"definition",tokenize:um},cm={partial:!0,tokenize:fm};function um(t,e,n){let r=this,i;return o;function o(h){return t.enter("definition"),s(h)}function s(h){return ji.call(r,t,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=ct(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),a):n(h)}function a(h){return G(h)?Ut(t,c)(h):c(h)}function c(h){return $i(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return t.attempt(cm,f,f)(h)}function f(h){return B(h)?v(t,d,"whitespace")(h):d(h)}function d(h){return h===null||N(h)?(t.exit("definition"),r.parser.defined.push(i),e(h)):n(h)}}function fm(t,e,n){return r;function r(l){return G(l)?Ut(t,i)(l):n(l)}function i(l){return qi(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return B(l)?v(t,s,"whitespace")(l):s(l)}function s(l){return l===null||N(l)?e(l):n(l)}}var ms={name:"hardBreakEscape",tokenize:hm};function hm(t,e,n){return r;function r(o){return t.enter("hardBreakEscape"),t.consume(o),i}function i(o){return N(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}var gs={name:"headingAtx",resolve:dm,tokenize:pm};function dm(t,e){let n=t.length-2,r=3,i,o;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},o={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},le(t,r,n-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),t}function pm(t,e,n){let r=0;return i;function i(u){return t.enter("atxHeading"),o(u)}function o(u){return t.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&r++<6?(t.consume(u),s):u===null||G(u)?(t.exit("atxHeadingSequence"),l(u)):n(u)}function l(u){return u===35?(t.enter("atxHeadingSequence"),a(u)):u===null||N(u)?(t.exit("atxHeading"),e(u)):B(u)?v(t,l,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function a(u){return u===35?(t.consume(u),a):(t.exit("atxHeadingSequence"),l(u))}function c(u){return u===null||u===35||G(u)?(t.exit("atxHeadingText"),l(u)):(t.consume(u),c)}}var iu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ys=["pre","script","style","textarea"];var ks={concrete:!0,name:"htmlFlow",resolveTo:ym,tokenize:km},mm={partial:!0,tokenize:bm},gm={partial:!0,tokenize:xm};function ym(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function km(t,e,n){let r=this,i,o,s,l,a;return c;function c(g){return u(g)}function u(g){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(g),f}function f(g){return g===33?(t.consume(g),d):g===47?(t.consume(g),o=!0,y):g===63?(t.consume(g),i=3,r.interrupt?e:m):Me(g)?(t.consume(g),s=String.fromCharCode(g),b):n(g)}function d(g){return g===45?(t.consume(g),i=2,h):g===91?(t.consume(g),i=5,l=0,p):Me(g)?(t.consume(g),i=4,r.interrupt?e:m):n(g)}function h(g){return g===45?(t.consume(g),r.interrupt?e:m):n(g)}function p(g){let be="CDATA[";return g===be.charCodeAt(l++)?(t.consume(g),l===be.length?r.interrupt?e:J:p):n(g)}function y(g){return Me(g)?(t.consume(g),s=String.fromCharCode(g),b):n(g)}function b(g){if(g===null||g===47||g===62||G(g)){let be=g===47,Dt=s.toLowerCase();return!be&&!o&&ys.includes(Dt)?(i=1,r.interrupt?e(g):J(g)):iu.includes(s.toLowerCase())?(i=6,be?(t.consume(g),x):r.interrupt?e(g):J(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):o?A(g):T(g))}return g===45||me(g)?(t.consume(g),s+=String.fromCharCode(g),b):n(g)}function x(g){return g===62?(t.consume(g),r.interrupt?e:J):n(g)}function A(g){return B(g)?(t.consume(g),A):Q(g)}function T(g){return g===47?(t.consume(g),Q):g===58||g===95||Me(g)?(t.consume(g),V):B(g)?(t.consume(g),T):Q(g)}function V(g){return g===45||g===46||g===58||g===95||me(g)?(t.consume(g),V):j(g)}function j(g){return g===61?(t.consume(g),w):B(g)?(t.consume(g),j):T(g)}function w(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(t.consume(g),a=g,E):B(g)?(t.consume(g),w):L(g)}function E(g){return g===a?(t.consume(g),a=null,z):g===null||N(g)?n(g):(t.consume(g),E)}function L(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||G(g)?j(g):(t.consume(g),L)}function z(g){return g===47||g===62||B(g)?T(g):n(g)}function Q(g){return g===62?(t.consume(g),Ee):n(g)}function Ee(g){return g===null||N(g)?J(g):B(g)?(t.consume(g),Ee):n(g)}function J(g){return g===45&&i===2?(t.consume(g),Y):g===60&&i===1?(t.consume(g),X):g===62&&i===4?(t.consume(g),Ie):g===63&&i===3?(t.consume(g),m):g===93&&i===5?(t.consume(g),Ke):N(g)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(mm,Ue,D)(g)):g===null||N(g)?(t.exit("htmlFlowData"),D(g)):(t.consume(g),J)}function D(g){return t.check(gm,$,Ue)(g)}function $(g){return t.enter("lineEnding"),t.consume(g),t.exit("lineEnding"),_}function _(g){return g===null||N(g)?D(g):(t.enter("htmlFlowData"),J(g))}function Y(g){return g===45?(t.consume(g),m):J(g)}function X(g){return g===47?(t.consume(g),s="",ve):J(g)}function ve(g){if(g===62){let be=s.toLowerCase();return ys.includes(be)?(t.consume(g),Ie):J(g)}return Me(g)&&s.length<8?(t.consume(g),s+=String.fromCharCode(g),ve):J(g)}function Ke(g){return g===93?(t.consume(g),m):J(g)}function m(g){return g===62?(t.consume(g),Ie):g===45&&i===2?(t.consume(g),m):J(g)}function Ie(g){return g===null||N(g)?(t.exit("htmlFlowData"),Ue(g)):(t.consume(g),Ie)}function Ue(g){return t.exit("htmlFlow"),e(g)}}function xm(t,e,n){let r=this;return i;function i(s){return N(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o):n(s)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}function bm(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Mt,e,n)}}var xs={name:"htmlText",tokenize:Sm};function Sm(t,e,n){let r=this,i,o,s;return l;function l(m){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(m),a}function a(m){return m===33?(t.consume(m),c):m===47?(t.consume(m),j):m===63?(t.consume(m),T):Me(m)?(t.consume(m),L):n(m)}function c(m){return m===45?(t.consume(m),u):m===91?(t.consume(m),o=0,p):Me(m)?(t.consume(m),A):n(m)}function u(m){return m===45?(t.consume(m),h):n(m)}function f(m){return m===null?n(m):m===45?(t.consume(m),d):N(m)?(s=f,X(m)):(t.consume(m),f)}function d(m){return m===45?(t.consume(m),h):f(m)}function h(m){return m===62?Y(m):m===45?d(m):f(m)}function p(m){let Ie="CDATA[";return m===Ie.charCodeAt(o++)?(t.consume(m),o===Ie.length?y:p):n(m)}function y(m){return m===null?n(m):m===93?(t.consume(m),b):N(m)?(s=y,X(m)):(t.consume(m),y)}function b(m){return m===93?(t.consume(m),x):y(m)}function x(m){return m===62?Y(m):m===93?(t.consume(m),x):y(m)}function A(m){return m===null||m===62?Y(m):N(m)?(s=A,X(m)):(t.consume(m),A)}function T(m){return m===null?n(m):m===63?(t.consume(m),V):N(m)?(s=T,X(m)):(t.consume(m),T)}function V(m){return m===62?Y(m):T(m)}function j(m){return Me(m)?(t.consume(m),w):n(m)}function w(m){return m===45||me(m)?(t.consume(m),w):E(m)}function E(m){return N(m)?(s=E,X(m)):B(m)?(t.consume(m),E):Y(m)}function L(m){return m===45||me(m)?(t.consume(m),L):m===47||m===62||G(m)?z(m):n(m)}function z(m){return m===47?(t.consume(m),Y):m===58||m===95||Me(m)?(t.consume(m),Q):N(m)?(s=z,X(m)):B(m)?(t.consume(m),z):Y(m)}function Q(m){return m===45||m===46||m===58||m===95||me(m)?(t.consume(m),Q):Ee(m)}function Ee(m){return m===61?(t.consume(m),J):N(m)?(s=Ee,X(m)):B(m)?(t.consume(m),Ee):z(m)}function J(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(t.consume(m),i=m,D):N(m)?(s=J,X(m)):B(m)?(t.consume(m),J):(t.consume(m),$)}function D(m){return m===i?(t.consume(m),i=void 0,_):m===null?n(m):N(m)?(s=D,X(m)):(t.consume(m),D)}function $(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||G(m)?z(m):(t.consume(m),$)}function _(m){return m===47||m===62||G(m)?z(m):n(m)}function Y(m){return m===62?(t.consume(m),t.exit("htmlTextData"),t.exit("htmlText"),e):n(m)}function X(m){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),ve}function ve(m){return B(m)?v(t,Ke,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):Ke(m)}function Ke(m){return t.enter("htmlTextData"),s(m)}}var Qt={name:"labelEnd",resolveAll:Mm,resolveTo:Nm,tokenize:Om},wm={tokenize:Em},Cm={tokenize:Im},Tm={tokenize:Dm};function Mm(t){let e=-1,n=[];for(;++e<t.length;){let r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&le(t,0,t.length,n),t}function Nm(t,e){let n=t.length,r=0,i,o,s,l;for(;n--;)if(i=t[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(t[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=n);let a={type:t[o][1].type==="labelLink"?"link":"image",start:{...t[o][1].start},end:{...t[t.length-1][1].end}},c={type:"label",start:{...t[o][1].start},end:{...t[s][1].end}},u={type:"labelText",start:{...t[o+r+2][1].end},end:{...t[s-2][1].start}};return l=[["enter",a,e],["enter",c,e]],l=pe(l,t.slice(o+1,o+r+3)),l=pe(l,[["enter",u,e]]),l=pe(l,zn(e.parser.constructs.insideSpan.null,t.slice(o+r+4,s-3),e)),l=pe(l,[["exit",u,e],t[s-2],t[s-1],["exit",c,e]]),l=pe(l,t.slice(s+1)),l=pe(l,[["exit",a,e]]),le(t,o,t.length,l),t}function Om(t,e,n){let r=this,i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?f(d):(s=r.parser.defined.includes(ct(r.sliceSerialize({start:o.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(d),t.exit("labelMarker"),t.exit("labelEnd"),a):n(d)}function a(d){return d===40?t.attempt(wm,u,s?u:f)(d):d===91?t.attempt(Cm,u,s?c:f)(d):s?u(d):f(d)}function c(d){return t.attempt(Tm,u,f)(d)}function u(d){return e(d)}function f(d){return o._balanced=!0,n(d)}}function Em(t,e,n){return r;function r(f){return t.enter("resource"),t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),i}function i(f){return G(f)?Ut(t,o)(f):o(f)}function o(f){return f===41?u(f):$i(t,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return G(f)?Ut(t,a)(f):u(f)}function l(f){return n(f)}function a(f){return f===34||f===39||f===40?qi(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return G(f)?Ut(t,u)(f):u(f)}function u(f){return f===41?(t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),t.exit("resource"),e):n(f)}}function Im(t,e,n){let r=this;return i;function i(l){return ji.call(r,t,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(ct(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):n(l)}function s(l){return n(l)}}function Dm(t,e,n){return r;function r(o){return t.enter("reference"),t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),i}function i(o){return o===93?(t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),t.exit("reference"),e):n(o)}}var bs={name:"labelStartImage",resolveAll:Qt.resolveAll,tokenize:Am};function Am(t,e,n){let r=this;return i;function i(l){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(l),t.exit("labelImageMarker"),o}function o(l){return l===91?(t.enter("labelMarker"),t.consume(l),t.exit("labelMarker"),t.exit("labelImage"),s):n(l)}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):e(l)}}var Ss={name:"labelStartLink",resolveAll:Qt.resolveAll,tokenize:Rm};function Rm(t,e,n){let r=this;return i;function i(s){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):e(s)}}var vr={name:"lineEnding",tokenize:Pm};function Pm(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),v(t,e,"linePrefix")}}var Yt={name:"thematicBreak",tokenize:zm};function zm(t,e,n){let r=0,i;return o;function o(c){return t.enter("thematicBreak"),s(c)}function s(c){return i=c,l(c)}function l(c){return c===i?(t.enter("thematicBreakSequence"),a(c)):r>=3&&(c===null||N(c))?(t.exit("thematicBreak"),e(c)):n(c)}function a(c){return c===i?(t.consume(c),r++,a):(t.exit("thematicBreakSequence"),B(c)?v(t,l,"whitespace")(c):l(c))}}var ue={continuation:{tokenize:Lm},exit:_m,name:"list",tokenize:vm},Bm={partial:!0,tokenize:$m},Fm={partial:!0,tokenize:Vm};function vm(t,e,n){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(h){let p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Pr(h)){if(r.containerState.type||(r.containerState.type=p,t.enter(p,{_container:!0})),p==="listUnordered")return t.enter("listItemPrefix"),h===42||h===45?t.check(Yt,n,c)(h):c(h);if(!r.interrupt||h===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),a(h)}return n(h)}function a(h){return Pr(h)&&++s<10?(t.consume(h),a):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(t.exit("listItemValue"),c(h)):n(h)}function c(h){return t.enter("listItemMarker"),t.consume(h),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,t.check(Mt,r.interrupt?n:u,t.attempt(Bm,d,f))}function u(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return B(h)?(t.enter("listItemPrefixWhitespace"),t.consume(h),t.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(h)}}function Lm(t,e,n){let r=this;return r.containerState._closeFlow=void 0,t.check(Mt,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,v(t,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!B(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(Fm,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,v(t,t.attempt(ue,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Vm(t,e,n){let r=this;return v(t,i,"listItemIndent",r.containerState.size+1);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):n(o)}}function _m(t){t.exit(this.containerState.type)}function $m(t,e,n){let r=this;return v(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let s=r.events[r.events.length-1];return!B(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}var Wi={name:"setextUnderline",resolveTo:jm,tokenize:qm};function jm(t,e){let n=t.length,r,i,o;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!o&&t[n][1].type==="definition"&&(o=n);let s={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",o?(t.splice(i,0,["enter",s,e]),t.splice(o+1,0,["exit",t[r][1],e]),t[r][1].end={...t[o][1].end}):t[r][1]=s,t.push(["exit",s,e]),t}function qm(t,e,n){let r=this,i;return o;function o(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(t.enter("setextHeadingLine"),i=c,s(c)):n(c)}function s(c){return t.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(t.consume(c),l):(t.exit("setextHeadingLineSequence"),B(c)?v(t,a,"lineSuffix")(c):a(c))}function a(c){return c===null||N(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}var ou={tokenize:Wm};function Wm(t){let e=this,n=t.attempt(Mt,r,t.attempt(this.parser.constructs.flowInitial,i,v(t,t.attempt(this.parser.constructs.flow,i,t.attempt(ds,i)),"linePrefix")));return n;function r(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),e.currentConstruct=void 0,n}}var su={resolveAll:uu()},lu=cu("string"),au=cu("text");function cu(t){return{resolveAll:uu(t==="text"?Hm:void 0),tokenize:e};function e(n){let r=this,i=this.parser.constructs[t],o=n.attempt(i,s,l);return s;function s(u){return c(u)?o(u):l(u)}function l(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),a}function a(u){return c(u)?(n.exit("data"),o(u)):(n.consume(u),a)}function c(u){if(u===null)return!0;let f=i[u],d=-1;if(f)for(;++d<f.length;){let h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function uu(t){return e;function e(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return t?t(n,r):n}}function Hm(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){let r=t[n-1][1],i=e.sliceStream(r),o=i.length,s=-1,l=0,a;for(;o--;){let c=i[o];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)l++,s--;if(s)break;s=-1}else if(c===-2)a=!0,l++;else if(c!==-1){o++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(l=0),l){let c={type:n===t.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(t.splice(n,0,["enter",c,e],["exit",c,e]),n+=2)}n++}return t}var ws={};Xf(ws,{attentionMarkers:()=>Zm,contentInitial:()=>Jm,disable:()=>eg,document:()=>Km,flow:()=>Qm,flowInitial:()=>Um,insideSpan:()=>Xm,string:()=>Ym,text:()=>Gm});var Km={42:ue,43:ue,45:ue,48:ue,49:ue,50:ue,51:ue,52:ue,53:ue,54:ue,55:ue,56:ue,57:ue,62:Bi},Jm={91:ps},Um={[-2]:Br,[-1]:Br,32:Br},Qm={35:gs,42:Yt,45:[Wi,Yt],60:ks,61:Wi,95:Yt,96:Li,126:Li},Ym={38:vi,92:Fi},Gm={[-5]:vr,[-4]:vr,[-3]:vr,33:bs,38:vi,42:zr,60:[fs,xs],91:Ss,92:[ms,Fi],93:Qt,95:zr,96:hs},Xm={null:[zr,su]},Zm={null:[42,95]},eg={null:[]};function fu(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],s=[],l=[],a=!0,c={attempt:z(E),check:z(L),consume:V,enter:j,exit:w,interrupt:z(L,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:b,parser:t,previous:null,sliceSerialize:p,sliceStream:y,write:h},f=e.tokenize.call(u,c),d;return e.resolveAll&&o.push(e),u;function h(D){return s=pe(s,D),A(),s[s.length-1]!==null?[]:(Q(e,0),u.events=zn(o,u.events,u),u.events)}function p(D,$){return ng(y(D),$)}function y(D){return tg(s,D)}function b(){let{_bufferIndex:D,_index:$,line:_,column:Y,offset:X}=r;return{_bufferIndex:D,_index:$,line:_,column:Y,offset:X}}function x(D){i[D.line]=D.column,J()}function A(){let D;for(;r._index<s.length;){let $=s[r._index];if(typeof $=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<$.length;)T($.charCodeAt(r._bufferIndex));else T($)}}function T(D){a=void 0,d=D,f=f(D)}function V(D){N(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,J()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=D,a=!0}function j(D,$){let _=$||{};return _.type=D,_.start=b(),u.events.push(["enter",_,u]),l.push(_),_}function w(D){let $=l.pop();return $.end=b(),u.events.push(["exit",$,u]),$}function E(D,$){Q(D,$.from)}function L(D,$){$.restore()}function z(D,$){return _;function _(Y,X,ve){let Ke,m,Ie,Ue;return Array.isArray(Y)?be(Y):"tokenize"in Y?be([Y]):g(Y);function g(te){return tr;function tr(Qe){let At=Qe!==null&&te[Qe],un=Qe!==null&&te.null,ao=[...Array.isArray(At)?At:At?[At]:[],...Array.isArray(un)?un:un?[un]:[]];return be(ao)(Qe)}}function be(te){return Ke=te,m=0,te.length===0?ve:Dt(te[m])}function Dt(te){return tr;function tr(Qe){return Ue=Ee(),Ie=te,te.partial||(u.currentConstruct=te),te.name&&u.parser.constructs.disable.null.includes(te.name)?si(Qe):te.tokenize.call($?Object.assign(Object.create(u),$):u,c,lo,si)(Qe)}}function lo(te){return a=!0,D(Ie,Ue),X}function si(te){return a=!0,Ue.restore(),++m<Ke.length?Dt(Ke[m]):ve}}}function Q(D,$){D.resolveAll&&!o.includes(D)&&o.push(D),D.resolve&&le(u.events,$,u.events.length-$,D.resolve(u.events.slice($),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function Ee(){let D=b(),$=u.previous,_=u.currentConstruct,Y=u.events.length,X=Array.from(l);return{from:Y,restore:ve};function ve(){r=D,u.previous=$,u.currentConstruct=_,u.events.length=Y,l=X,J()}}function J(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function tg(t,e){let n=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex,s;if(n===i)s=[t[n].slice(r,o)];else{if(s=t.slice(n,i),r>-1){let l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(t[i].slice(0,o))}return s}function ng(t,e){let n=-1,r=[],i;for(;++n<t.length;){let o=t[n],s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=`
`;break}case-3:{s=`\r
`;break}case-2:{s=e?" ":"	";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function Cs(t){let r={constructs:Jc([ws,...(t||{}).extensions||[]]),content:i(Zc),defined:[],document:i(tu),flow:i(ou),lazy:{},string:i(lu),text:i(au)};return r;function i(o){return s;function s(l){return fu(r,o,l)}}}function Ts(t){for(;!_i(t););return t}var hu=/[\0\t\n\r]/g;function Ms(){let t=1,e="",n=!0,r;return i;function i(o,s,l){let a=[],c,u,f,d,h;for(o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),f=0,e="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(hu.lastIndex=f,c=hu.exec(o),d=c&&c.index!==void 0?c.index:o.length,h=o.charCodeAt(d),!c){e=o.slice(f);break}if(h===10&&f===d&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),f<d&&(a.push(o.slice(f,d)),t+=d-f),h){case 0:{a.push(65533),t++;break}case 9:{for(u=Math.ceil(t/4)*4,a.push(-2);t++<u;)a.push(-1);break}case 10:{a.push(-4),t=1;break}default:r=!0,t=1}f=d+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}var rg=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Hi(t){return t.replace(rg,ig)}function ig(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){let i=n.charCodeAt(1),o=i===120||i===88;return zi(n.slice(o?2:1),o?16:10)}return Rn(n)||t}function Nt(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?du(t.position):"start"in t||"end"in t?du(t):"line"in t||"column"in t?Ns(t):""}function Ns(t){return pu(t&&t.line)+":"+pu(t&&t.column)}function du(t){return Ns(t&&t.start)+"-"+Ns(t&&t.end)}function pu(t){return t&&typeof t=="number"?t:1}var gu={}.hasOwnProperty;function Os(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),og(n)(Ts(Cs(n).document().write(Ms()(t,e,!0))))}function og(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Dl),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(Ol),blockQuote:o(Qe),characterEscape:z,characterReference:z,codeFenced:o(At),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(At,s),codeText:o(un,s),codeTextData:z,data:z,codeFlowValue:z,definition:o(ao),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(Wf),hardBreakEscape:o(El),hardBreakTrailing:o(El),htmlFlow:o(Il,s),htmlFlowData:z,htmlText:o(Il,s),htmlTextData:z,image:o(Hf),label:s,link:o(Dl),listItem:o(Kf),listItemValue:d,listOrdered:o(Al,f),listUnordered:o(Al),paragraph:o(Jf),reference:g,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Ol),strong:o(Uf),thematicBreak:o(Yf)},exit:{atxHeading:a(),atxHeadingSequence:j,autolink:a(),autolinkEmail:tr,autolinkProtocol:te,blockQuote:a(),characterEscapeValue:Q,characterReferenceMarkerHexadecimal:Dt,characterReferenceMarkerNumeric:Dt,characterReferenceValue:lo,characterReference:si,codeFenced:a(b),codeFencedFence:y,codeFencedFenceInfo:h,codeFencedFenceMeta:p,codeFlowValue:Q,codeIndented:a(x),codeText:a(_),codeTextData:Q,data:Q,definition:a(),definitionDestinationString:V,definitionLabelString:A,definitionTitleString:T,emphasis:a(),hardBreakEscape:a(J),hardBreakTrailing:a(J),htmlFlow:a(D),htmlFlowData:Q,htmlText:a($),htmlTextData:Q,image:a(X),label:Ke,labelText:ve,lineEnding:Ee,link:a(Y),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:be,resourceDestinationString:m,resourceTitleString:Ie,resource:Ue,setextHeading:a(L),setextHeadingLineSequence:E,setextHeadingText:w,strong:a(),thematicBreak:a()}};yu(e,(t||{}).mdastExtensions||[]);let n={};return r;function r(S){let M={type:"root",children:[]},F={stack:[M],tokenStack:[],config:e,enter:l,exit:c,buffer:s,resume:u,data:n},q=[],U=-1;for(;++U<S.length;)if(S[U][1].type==="listOrdered"||S[U][1].type==="listUnordered")if(S[U][0]==="enter")q.push(U);else{let Le=q.pop();U=i(S,Le,U)}for(U=-1;++U<S.length;){let Le=e[S[U][0]];gu.call(Le,S[U][1].type)&&Le[S[U][1].type].call(Object.assign({sliceSerialize:S[U][2].sliceSerialize},F),S[U][1])}if(F.tokenStack.length>0){let Le=F.tokenStack[F.tokenStack.length-1];(Le[1]||mu).call(F,void 0,Le[0])}for(M.position={start:Ot(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Ot(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},U=-1;++U<e.transforms.length;)M=e.transforms[U](M)||M;return M}function i(S,M,F){let q=M-1,U=-1,Le=!1,Rt,Ye,nr,rr;for(;++q<=F;){let Se=S[q];switch(Se[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Se[0]==="enter"?U++:U--,rr=void 0;break}case"lineEndingBlank":{Se[0]==="enter"&&(Rt&&!rr&&!U&&!nr&&(nr=q),rr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:rr=void 0}if(!U&&Se[0]==="enter"&&Se[1].type==="listItemPrefix"||U===-1&&Se[0]==="exit"&&(Se[1].type==="listUnordered"||Se[1].type==="listOrdered")){if(Rt){let fn=q;for(Ye=void 0;fn--;){let Ge=S[fn];if(Ge[1].type==="lineEnding"||Ge[1].type==="lineEndingBlank"){if(Ge[0]==="exit")continue;Ye&&(S[Ye][1].type="lineEndingBlank",Le=!0),Ge[1].type="lineEnding",Ye=fn}else if(!(Ge[1].type==="linePrefix"||Ge[1].type==="blockQuotePrefix"||Ge[1].type==="blockQuotePrefixWhitespace"||Ge[1].type==="blockQuoteMarker"||Ge[1].type==="listItemIndent"))break}nr&&(!Ye||nr<Ye)&&(Rt._spread=!0),Rt.end=Object.assign({},Ye?S[Ye][1].start:Se[1].end),S.splice(Ye||q,0,["exit",Rt,Se[2]]),q++,F++}if(Se[1].type==="listItemPrefix"){let fn={type:"listItem",_spread:!1,start:Object.assign({},Se[1].start),end:void 0};Rt=fn,S.splice(q,0,["enter",fn,Se[2]]),q++,F++,nr=void 0,rr=!0}}}return S[M][1]._spread=Le,F}function o(S,M){return F;function F(q){l.call(this,S(q),q),M&&M.call(this,q)}}function s(){this.stack.push({type:"fragment",children:[]})}function l(S,M,F){this.stack[this.stack.length-1].children.push(S),this.stack.push(S),this.tokenStack.push([M,F||void 0]),S.position={start:Ot(M.start),end:void 0}}function a(S){return M;function M(F){S&&S.call(this,F),c.call(this,F)}}function c(S,M){let F=this.stack.pop(),q=this.tokenStack.pop();if(q)q[0].type!==S.type&&(M?M.call(this,S,q[0]):(q[1]||mu).call(this,S,q[0]));else throw new Error("Cannot close `"+S.type+"` ("+Nt({start:S.start,end:S.end})+"): it\u2019s not open");F.position.end=Ot(S.end)}function u(){return Jt(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(S){if(this.data.expectingFirstListItemValue){let M=this.stack[this.stack.length-2];M.start=Number.parseInt(this.sliceSerialize(S),10),this.data.expectingFirstListItemValue=void 0}}function h(){let S=this.resume(),M=this.stack[this.stack.length-1];M.lang=S}function p(){let S=this.resume(),M=this.stack[this.stack.length-1];M.meta=S}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){let S=this.resume(),M=this.stack[this.stack.length-1];M.value=S.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let S=this.resume(),M=this.stack[this.stack.length-1];M.value=S.replace(/(\r?\n|\r)$/g,"")}function A(S){let M=this.resume(),F=this.stack[this.stack.length-1];F.label=M,F.identifier=ct(this.sliceSerialize(S)).toLowerCase()}function T(){let S=this.resume(),M=this.stack[this.stack.length-1];M.title=S}function V(){let S=this.resume(),M=this.stack[this.stack.length-1];M.url=S}function j(S){let M=this.stack[this.stack.length-1];if(!M.depth){let F=this.sliceSerialize(S).length;M.depth=F}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function E(S){let M=this.stack[this.stack.length-1];M.depth=this.sliceSerialize(S).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function z(S){let F=this.stack[this.stack.length-1].children,q=F[F.length-1];(!q||q.type!=="text")&&(q=Qf(),q.position={start:Ot(S.start),end:void 0},F.push(q)),this.stack.push(q)}function Q(S){let M=this.stack.pop();M.value+=this.sliceSerialize(S),M.position.end=Ot(S.end)}function Ee(S){let M=this.stack[this.stack.length-1];if(this.data.atHardBreak){let F=M.children[M.children.length-1];F.position.end=Ot(S.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(M.type)&&(z.call(this,S),Q.call(this,S))}function J(){this.data.atHardBreak=!0}function D(){let S=this.resume(),M=this.stack[this.stack.length-1];M.value=S}function $(){let S=this.resume(),M=this.stack[this.stack.length-1];M.value=S}function _(){let S=this.resume(),M=this.stack[this.stack.length-1];M.value=S}function Y(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let M=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=M,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function X(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let M=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=M,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function ve(S){let M=this.sliceSerialize(S),F=this.stack[this.stack.length-2];F.label=Hi(M),F.identifier=ct(M).toLowerCase()}function Ke(){let S=this.stack[this.stack.length-1],M=this.resume(),F=this.stack[this.stack.length-1];if(this.data.inReference=!0,F.type==="link"){let q=S.children;F.children=q}else F.alt=M}function m(){let S=this.resume(),M=this.stack[this.stack.length-1];M.url=S}function Ie(){let S=this.resume(),M=this.stack[this.stack.length-1];M.title=S}function Ue(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function be(S){let M=this.resume(),F=this.stack[this.stack.length-1];F.label=M,F.identifier=ct(this.sliceSerialize(S)).toLowerCase(),this.data.referenceType="full"}function Dt(S){this.data.characterReferenceType=S.type}function lo(S){let M=this.sliceSerialize(S),F=this.data.characterReferenceType,q;F?(q=zi(M,F==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):q=Rn(M);let U=this.stack[this.stack.length-1];U.value+=q}function si(S){let M=this.stack.pop();M.position.end=Ot(S.end)}function te(S){Q.call(this,S);let M=this.stack[this.stack.length-1];M.url=this.sliceSerialize(S)}function tr(S){Q.call(this,S);let M=this.stack[this.stack.length-1];M.url="mailto:"+this.sliceSerialize(S)}function Qe(){return{type:"blockquote",children:[]}}function At(){return{type:"code",lang:null,meta:null,value:""}}function un(){return{type:"inlineCode",value:""}}function ao(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Wf(){return{type:"emphasis",children:[]}}function Ol(){return{type:"heading",depth:0,children:[]}}function El(){return{type:"break"}}function Il(){return{type:"html",value:""}}function Hf(){return{type:"image",title:null,url:"",alt:null}}function Dl(){return{type:"link",title:null,url:"",children:[]}}function Al(S){return{type:"list",ordered:S.type==="listOrdered",start:null,spread:S._spread,children:[]}}function Kf(S){return{type:"listItem",spread:S._spread,checked:null,children:[]}}function Jf(){return{type:"paragraph",children:[]}}function Uf(){return{type:"strong",children:[]}}function Qf(){return{type:"text",value:""}}function Yf(){return{type:"thematicBreak"}}}function Ot(t){return{line:t.line,column:t.column,offset:t.offset}}function yu(t,e){let n=-1;for(;++n<e.length;){let r=e[n];Array.isArray(r)?yu(t,r):sg(t,r)}}function sg(t,e){let n;for(n in e)if(gu.call(e,n))switch(n){case"canContainEols":{let r=e[n];r&&t[n].push(...r);break}case"transforms":{let r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{let r=e[n];r&&Object.assign(t[n],r);break}}}function mu(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Nt({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Nt({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Nt({start:e.start,end:e.end})+") is still open")}function Bn(t){let e=this;e.parser=n;function n(r){return Os(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}var ku={}.hasOwnProperty;function xu(t,e){let n=e||{};function r(i,...o){let s=r.invalid,l=r.handlers;if(i&&ku.call(i,t)){let a=String(i[t]);s=ku.call(l,a)?l[a]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var lg={}.hasOwnProperty;function Es(t,e){let n=-1,r;if(e.extensions)for(;++n<e.extensions.length;)Es(t,e.extensions[n]);for(r in e)if(lg.call(e,r))switch(r){case"extensions":break;case"unsafe":{bu(t[r],e[r]);break}case"join":{bu(t[r],e[r]);break}case"handlers":{ag(t[r],e[r]);break}default:t.options[r]=e[r]}return t}function bu(t,e){e&&t.push(...e)}function ag(t,e){e&&Object.assign(t,e)}function Su(t,e,n,r){let i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);let s=n.indentLines(n.containerFlow(t,o.current()),cg);return i(),s}function cg(t,e,n){return">"+(n?"":" ")+t}function Ki(t,e){return wu(t,e.inConstruct,!0)&&!wu(t,e.notInConstruct,!1)}function wu(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function Is(t,e,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
`&&Ki(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function Cu(t,e){let n=String(t),r=n.indexOf(e),i=r,o=0,s=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>s&&(s=o):o=1,i=r+e.length,r=n.indexOf(e,i);return s}function Lr(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function Tu(t){let e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function Mu(t,e,n,r){let i=Tu(n),o=t.value||"",s=i==="`"?"GraveAccent":"Tilde";if(Lr(t,n)){let f=n.enter("codeIndented"),d=n.indentLines(o,ug);return f(),d}let l=n.createTracker(r),a=i.repeat(Math.max(Cu(o,i)+1,3)),c=n.enter("codeFenced"),u=l.move(a);if(t.lang){let f=n.enter(`codeFencedLang${s}`);u+=l.move(n.safe(t.lang,{before:u,after:" ",encode:["`"],...l.current()})),f()}if(t.lang&&t.meta){let f=n.enter(`codeFencedMeta${s}`);u+=l.move(" "),u+=l.move(n.safe(t.meta,{before:u,after:`
`,encode:["`"],...l.current()})),f()}return u+=l.move(`
`),o&&(u+=l.move(o+`
`)),u+=l.move(a),c(),u}function ug(t,e,n){return(n?"":"    ")+t}function Fn(t){let e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function Nu(t,e,n,r){let i=Fn(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("definition"),l=n.enter("label"),a=n.createTracker(r),c=a.move("[");return c+=a.move(n.safe(n.associationId(t),{before:c,after:"]",...a.current()})),c+=a.move("]: "),l(),!t.url||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(t.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(t.url,{before:c,after:t.title?" ":`
`,...a.current()}))),l(),t.title&&(l=n.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(n.safe(t.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),s(),c}function Ou(t){let e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Ne(t){return"&#x"+t.toString(16).toUpperCase()+";"}function vn(t,e,n){let r=Pn(t),i=Pn(e);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Ds.peek=fg;function Ds(t,e,n,r){let i=Ou(n),o=n.enter("emphasis"),s=n.createTracker(r),l=s.move(i),a=s.move(n.containerPhrasing(t,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=vn(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ne(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=vn(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ne(f));let h=s.move(i);return o(),n.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function fg(t,e,n){return n.options.emphasis||"*"}function Ji(t,e){let n=!1;return ho(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,zt}),!!((!t.depth||t.depth<3)&&Jt(t)&&(e.options.setext||n))}function Eu(t,e,n,r){let i=Math.max(Math.min(6,t.depth||1),1),o=n.createTracker(r);if(Ji(t,n)){let u=n.enter("headingSetext"),f=n.enter("phrasing"),d=n.containerPhrasing(t,{...o.current(),before:`
`,after:`
`});return f(),u(),d+`
`+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
`))+1))}let s="#".repeat(i),l=n.enter("headingAtx"),a=n.enter("phrasing");o.move(s+" ");let c=n.containerPhrasing(t,{before:"# ",after:`
`,...o.current()});return/^[\t ]/.test(c)&&(c=Ne(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),a(),l(),c}As.peek=hg;function As(t){return t.value||""}function hg(){return"<"}Rs.peek=dg;function Rs(t,e,n,r){let i=Fn(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("image"),l=n.enter("label"),a=n.createTracker(r),c=a.move("![");return c+=a.move(n.safe(t.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(t.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(t.url,{before:c,after:t.title?" ":")",...a.current()}))),l(),t.title&&(l=n.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(n.safe(t.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),s(),c}function dg(){return"!"}Ps.peek=pg;function Ps(t,e,n,r){let i=t.referenceType,o=n.enter("imageReference"),s=n.enter("label"),l=n.createTracker(r),a=l.move("!["),c=n.safe(t.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=n.stack;n.stack=[],s=n.enter("reference");let f=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function pg(){return"!"}zs.peek=mg;function zs(t,e,n){let r=t.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){let s=n.unsafe[o],l=n.compilePattern(s),a;if(s.atBreak)for(;a=l.exec(r);){let c=a.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(a.index+1)}}return i+r+i}function mg(){return"`"}function Bs(t,e){let n=Jt(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Fs.peek=gg;function Fs(t,e,n,r){let i=Fn(n),o=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r),l,a;if(Bs(t,n)){let u=n.stack;n.stack=[],l=n.enter("autolink");let f=s.move("<");return f+=s.move(n.containerPhrasing(t,{before:f,after:">",...s.current()})),f+=s.move(">"),l(),n.stack=u,f}l=n.enter("link"),a=n.enter("label");let c=s.move("[");return c+=s.move(n.containerPhrasing(t,{before:c,after:"](",...s.current()})),c+=s.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(n.safe(t.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=n.enter("destinationRaw"),c+=s.move(n.safe(t.url,{before:c,after:t.title?" ":")",...s.current()}))),a(),t.title&&(a=n.enter(`title${o}`),c+=s.move(" "+i),c+=s.move(n.safe(t.title,{before:c,after:i,...s.current()})),c+=s.move(i),a()),c+=s.move(")"),l(),c}function gg(t,e,n){return Bs(t,n)?"<":"["}vs.peek=yg;function vs(t,e,n,r){let i=t.referenceType,o=n.enter("linkReference"),s=n.enter("label"),l=n.createTracker(r),a=l.move("["),c=n.containerPhrasing(t,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=n.stack;n.stack=[],s=n.enter("reference");let f=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function yg(){return"["}function Ln(t){let e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Iu(t){let e=Ln(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Du(t){let e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Ui(t){let e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Au(t,e,n,r){let i=n.enter("list"),o=n.bulletCurrent,s=t.ordered?Du(n):Ln(n),l=t.ordered?s==="."?")":".":Iu(n),a=e&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!t.ordered){let u=t.children?t.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(a=!0),Ui(n)===s&&u){let f=-1;for(;++f<t.children.length;){let d=t.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(s=l),n.bulletCurrent=s;let c=n.containerFlow(t,r);return n.bulletLastUsed=s,n.bulletCurrent=o,i(),c}function Ru(t){let e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Pu(t,e,n,r){let i=Ru(n),o=n.bulletCurrent||Ln(n);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(s=Math.ceil(s/4)*4);let l=n.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);let a=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,l.current()),u);return a(),c;function u(f,d,h){return d?(h?"":" ".repeat(s))+f:(h?o:o+" ".repeat(s-o.length))+f}}function zu(t,e,n,r){let i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(t,r);return o(),i(),s}var Ls=wn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Bu(t,e,n,r){return(t.children.some(function(s){return Ls(s)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Fu(t){let e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Vs.peek=kg;function Vs(t,e,n,r){let i=Fu(n),o=n.enter("strong"),s=n.createTracker(r),l=s.move(i+i),a=s.move(n.containerPhrasing(t,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=vn(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ne(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=vn(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ne(f));let h=s.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function kg(t,e,n){return n.options.strong||"*"}function vu(t,e,n,r){return n.safe(t.value,r)}function Lu(t){let e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Vu(t,e,n){let r=(Ui(n)+(n.options.ruleSpaces?" ":"")).repeat(Lu(n));return n.options.ruleSpaces?r.slice(0,-1):r}var _s={blockquote:Su,break:Is,code:Mu,definition:Nu,emphasis:Ds,hardBreak:Is,heading:Eu,html:As,image:Rs,imageReference:Ps,inlineCode:zs,link:Fs,linkReference:vs,list:Au,listItem:Pu,paragraph:zu,root:Bu,strong:Vs,text:vu,thematicBreak:Vu};var _u=[xg];function xg(t,e,n,r){if(e.type==="code"&&Lr(e,r)&&(t.type==="list"||t.type===e.type&&Lr(t,r)))return!1;if("spread"in n&&typeof n.spread=="boolean")return t.type==="paragraph"&&(t.type===e.type||e.type==="definition"||e.type==="heading"&&Ji(e,r))?void 0:n.spread?1:0}var Gt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],$u=[{character:"	",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"	",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"	",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
`,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:Gt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ 	\r
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"+",after:`(?:[ 	\r
])`},{atBreak:!0,character:"-",after:`(?:[ 	\r
-])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ 	\r
]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Gt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Gt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"~"}];function ju(t){return t.label||!t.identifier?t.label||"":Hi(t.identifier)}function qu(t){if(!t._compiled){let e=(t.atBreak?"[\\r\\n][\\t ]*":"")+(t.before?"(?:"+t.before+")":"");t._compiled=new RegExp((e?"("+e+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(t.character)?"\\":"")+t.character+(t.after?"(?:"+t.after+")":""),"g")}return t._compiled}function Wu(t,e,n){let r=e.indexStack,i=t.children||[],o=[],s=-1,l=n.before,a;r.push(-1);let c=e.createTracker(n);for(;++s<i.length;){let u=i[s],f;if(r[r.length-1]=s,s+1<i.length){let p=e.handle.handlers[i[s+1].type];p&&p.peek&&(p=p.peek),f=p?p(i[s+1],t,e,{before:"",after:"",...c.current()}).charAt(0):""}else f=n.after;o.length>0&&(l==="\r"||l===`
`)&&u.type==="html"&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=e.createTracker(n),c.move(o.join("")));let d=e.handle(u,t,e,{...c.current(),after:f,before:l});a&&a===d.slice(0,1)&&(d=Ne(a.charCodeAt(0))+d.slice(1));let h=e.attentionEncodeSurroundingInfo;e.attentionEncodeSurroundingInfo=void 0,a=void 0,h&&(o.length>0&&h.before&&l===o[o.length-1].slice(-1)&&(o[o.length-1]=o[o.length-1].slice(0,-1)+Ne(l.charCodeAt(0))),h.after&&(a=f)),c.move(d),o.push(d),l=d.slice(-1)}return r.pop(),o.join("")}function Hu(t,e,n){let r=e.indexStack,i=t.children||[],o=e.createTracker(n),s=[],l=-1;for(r.push(-1);++l<i.length;){let a=i[l];r[r.length-1]=l,s.push(o.move(e.handle(a,t,e,{before:`
`,after:`
`,...o.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&s.push(o.move(bg(a,i[l+1],t,e)))}return r.pop(),s.join("")}function bg(t,e,n,r){let i=r.join.length;for(;i--;){let o=r.join[i](t,e,n,r);if(o===!0||o===1)break;if(typeof o=="number")return`
`.repeat(1+o);if(o===!1)return`

<!---->

`}return`

`}var Sg=/\r?\n|\r/g;function Ku(t,e){let n=[],r=0,i=0,o;for(;o=Sg.exec(t);)s(t.slice(r,o.index)),n.push(o[0]),r=o.index+o[0].length,i++;return s(t.slice(r)),n.join("");function s(l){n.push(e(l,i,!l))}}function Uu(t,e,n){let r=(n.before||"")+(e||"")+(n.after||""),i=[],o=[],s={},l=-1;for(;++l<t.unsafe.length;){let u=t.unsafe[l];if(!Ki(t.stack,u))continue;let f=t.compilePattern(u),d;for(;d=f.exec(r);){let h="before"in u||!!u.atBreak,p="after"in u,y=d.index+(h?d[1].length:0);i.includes(y)?(s[y].before&&!h&&(s[y].before=!1),s[y].after&&!p&&(s[y].after=!1)):(i.push(y),s[y]={before:h,after:p})}}i.sort(wg);let a=n.before?n.before.length:0,c=r.length-(n.after?n.after.length:0);for(l=-1;++l<i.length;){let u=i[l];u<a||u>=c||u+1<c&&i[l+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||i[l-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(a!==u&&o.push(Ju(r.slice(a,u),"\\")),a=u,/[!-/:-@[-`{-~]/.test(r.charAt(u))&&(!n.encode||!n.encode.includes(r.charAt(u)))?o.push("\\"):(o.push(Ne(r.charCodeAt(u))),a++))}return o.push(Ju(r.slice(a,c),n.after)),o.join("")}function wg(t,e){return t-e}function Ju(t,e){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=t+e,s=-1,l=0,a;for(;a=n.exec(o);)r.push(a.index);for(;++s<r.length;)l!==r[s]&&i.push(t.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(t.slice(l)),i.join("")}function Qu(t){let e=t||{},n=e.now||{},r=e.lineShift||0,i=n.line||1,o=n.column||1;return{move:a,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(c){r+=c}function a(c){let u=c||"",f=u.split(/\r?\n|\r/g),d=f[f.length-1];return i+=f.length-1,o=f.length===1?o+d.length:1+d.length+r,u}}function $s(t,e){let n=e||{},r={associationId:ju,containerPhrasing:Ng,containerFlow:Og,createTracker:Qu,compilePattern:qu,enter:o,handlers:{..._s},handle:void 0,indentLines:Ku,indexStack:[],join:[..._u],options:{},safe:Eg,stack:[],unsafe:[...$u]};Es(r,n),r.options.tightDefinitions&&r.join.push(Mg),r.handle=xu("type",{invalid:Cg,unknown:Tg,handlers:r.handlers});let i=r.handle(t,void 0,r,{before:`
`,after:`
`,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
`),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}function Cg(t){throw new Error("Cannot handle value `"+t+"`, expected node")}function Tg(t){let e=t;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Mg(t,e){if(t.type==="definition"&&t.type===e.type)return 0}function Ng(t,e){return Wu(t,this,e)}function Og(t,e){return Hu(t,this,e)}function Eg(t,e){return Uu(this,t,e)}function Vn(t){let e=this;e.compiler=n;function n(r){return $s(r,{...e.data("settings"),...t,extensions:e.data("toMarkdownExtensions")||[]})}}function js(t){if(t)throw t}var Gi=Zf(of(),1);function Vr(t){if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function qs(){let t=[],e={run:n,use:r};return e;function n(...i){let o=-1,s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(a,...c){let u=t[++o],f=-1;if(a){s(a);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,u?sf(u,l)(...c):s(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function sf(t,e){let n;return r;function r(...s){let l=t.length>s.length,a;l&&s.push(i);try{a=t.apply(this,s)}catch(c){let u=c;if(l&&n)throw u;return i(u)}l||(a&&a.then&&typeof a.then=="function"?a.then(o,i):a instanceof Error?i(a):o(a))}function i(s,...l){n||(n=!0,e(s,...l))}function o(s){i(null,s)}}var ee=class extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){let a=r.indexOf(":");a===-1?o.ruleId=r:(o.source=r.slice(0,a),o.ruleId=r.slice(a+1))}if(!o.place&&o.ancestors&&o.ancestors){let a=o.ancestors[o.ancestors.length-1];a&&(o.place=a.position)}let l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Nt(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ee.prototype.file="";ee.prototype.name="";ee.prototype.reason="";ee.prototype.message="";ee.prototype.stack="";ee.prototype.column=void 0;ee.prototype.line=void 0;ee.prototype.ancestors=void 0;ee.prototype.cause=void 0;ee.prototype.fatal=void 0;ee.prototype.place=void 0;ee.prototype.ruleId=void 0;ee.prototype.source=void 0;var qe={basename:Ig,dirname:Dg,extname:Ag,join:Rg,sep:"/"};function Ig(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');_r(t);let n=0,r=-1,i=t.length,o;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let s=-1,l=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(t.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return n===r?r=s:r<0&&(r=t.length),t.slice(n,r)}function Dg(t){if(_r(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function Ag(t){_r(t);let e=t.length,n=-1,r=0,i=-1,o=0,s;for(;e--;){let l=t.codePointAt(e);if(l===47){if(s){r=e+1;break}continue}n<0&&(s=!0,n=e+1),l===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function Rg(...t){let e=-1,n;for(;++e<t.length;)_r(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":Pg(n)}function Pg(t){_r(t);let e=t.codePointAt(0)===47,n=zg(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function zg(t,e){let n="",r=0,i=-1,o=0,s=-1,l,a;for(;++s<=t.length;){if(s<t.length)l=t.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(a=n.lastIndexOf("/"),a!==n.length-1){a<0?(n="",r=0):(n=n.slice(0,a),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,s):n=t.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return n}function _r(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}var lf={cwd:Bg};function Bg(){return"/"}function _n(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function af(t){if(typeof t=="string")t=new URL(t);else if(!_n(t)){let e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){let e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Fg(t)}function Fg(t){if(t.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let e=t.pathname,n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){let r=e.codePointAt(n+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}var Ws=["history","path","basename","stem","extname","dirname"],$r=class{constructor(e){let n;e?_n(e)?n={path:e}:typeof e=="string"||vg(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":lf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ws.length;){let o=Ws[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)Ws.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?qe.basename(this.path):void 0}set basename(e){Ks(e,"basename"),Hs(e,"basename"),this.path=qe.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?qe.dirname(this.path):void 0}set dirname(e){cf(this.basename,"dirname"),this.path=qe.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?qe.extname(this.path):void 0}set extname(e){if(Hs(e,"extname"),cf(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=qe.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){_n(e)&&(e=af(e)),Ks(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?qe.basename(this.path,this.extname):void 0}set stem(e){Ks(e,"stem"),Hs(e,"stem"),this.path=qe.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){let i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){let i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){let i=new ee(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Hs(t,e){if(t&&t.includes(qe.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+qe.sep+"`")}function Ks(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function cf(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function vg(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}var uf=(function(t){let r=this.constructor.prototype,i=r[t],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o});var Lg={}.hasOwnProperty,Ys=class t extends uf{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qs()}copy(){let e=new t,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];e.use(...r)}return e.data((0,Gi.default)(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(Qs("data",this.frozen),this.namespace[e]=n,this):Lg.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Qs("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();let n=Yi(e),r=this.parser||this.Parser;return Js("parse",r),r(String(n),n)}process(e,n){let r=this;return this.freeze(),Js("process",this.parser||this.Parser),Us("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){let l=Yi(e),a=r.parse(l);r.run(a,l,function(u,f,d){if(u||!f||!d)return c(u);let h=f,p=r.stringify(h,d);_g(p)?d.value=p:d.result=p,c(u,d)});function c(u,f){u||!f?s(u):o?o(f):n(void 0,f)}}}processSync(e){let n=!1,r;return this.freeze(),Js("processSync",this.parser||this.Parser),Us("processSync",this.compiler||this.Compiler),this.process(e,i),hf("processSync","process",n),r;function i(o,s){n=!0,js(o),r=s}}run(e,n,r){ff(e),this.freeze();let i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,l){let a=Yi(n);i.run(e,a,c);function c(u,f,d){let h=f||e;u?l(u):s?s(h):r(void 0,h,d)}}}runSync(e,n){let r=!1,i;return this.run(e,n,o),hf("runSync","run",r),i;function o(s,l){js(s),i=l,r=!0}}stringify(e,n){this.freeze();let r=Yi(n),i=this.compiler||this.Compiler;return Us("stringify",i),ff(e),i(e,r)}use(e,...n){let r=this.attachers,i=this.namespace;if(Qs("use",this.frozen),e!=null)if(typeof e=="function")a(e,n);else if(typeof e=="object")Array.isArray(e)?l(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(c){if(typeof c=="function")a(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[u,...f]=c;a(u,f)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=(0,Gi.default)(!0,i.settings,c.settings))}function l(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){let f=c[u];o(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,u){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===c){d=f;break}if(d===-1)r.push([c,...u]);else if(u.length>0){let[h,...p]=u,y=r[d][1];Vr(y)&&Vr(h)&&(h=(0,Gi.default)(!0,y,h)),r[d]=[c,h,...p]}}}},jr=new Ys().freeze();function Js(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Us(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Qs(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ff(t){if(!Vr(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function hf(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Yi(t){return Vg(t)?t:new $r(t)}function Vg(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function _g(t){return typeof t=="string"||$g(t)}function $g(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}var Xi=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function pf(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var jg=(t,e,n)=>{let r=pf(t,n);if(!r)return!1;let i=Zs(r);if(!i){let s=r.blockRange(),l=s&&gi(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(yf(t,i,e,-1))return!0;if(r.parent.content.size==0&&($n(o,"end")||P.isSelectable(o)))for(let s=r.depth;;s--){let l=xr(t.doc,r.before(s),r.after(s),I.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection($n(o,"end")?H.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):P.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},mf=(t,e,n)=>{let r=pf(t,n);if(!r)return!1;let i=Zs(r);return i?qg(t,i,e):!1};function qg(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=xr(t.doc,o,a,I.empty);if(!c||c.from!=o||c instanceof fe&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(K.create(u.doc,o)),n(u.scrollIntoView())}return!0}function $n(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Xs=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Zs(r)}let s=o&&o.nodeBefore;return!s||!P.isSelectable(s)?!1:(e&&e(t.tr.setSelection(P.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Zs(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Wg(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var Hg=(t,e,n)=>{let r=Wg(t,n);if(!r)return!1;let i=gf(r);if(!i)return!1;let o=i.nodeAfter;if(yf(t,i,e,1))return!0;if(r.parent.content.size==0&&($n(o,"start")||P.isSelectable(o))){let s=xr(t.doc,r.before(),r.after(),I.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection($n(o,"start")?H.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):P.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Kg=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=gf(r)}let s=o&&o.nodeAfter;return!s||!P.isSelectable(s)?!1:(e&&e(t.tr.setSelection(P.create(t.doc,o.pos)).scrollIntoView()),!0)};function gf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}var Jg=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function el(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Ug=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=el(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(H.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Qg=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ce||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=el(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(s,o.createAndFill());l.setSelection(K.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Yg=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(yr(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&gi(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Gg(t){return(e,n)=>{if(e.selection instanceof P&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!yr(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof K||e.selection instanceof Ce)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,c=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){c=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=el(i.node(h-1).contentMatchAt(i.indexAfter(h-1)));let y=t&&t(i.parent,c,i);s.unshift(y||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;s.unshift(null)}let f=i.pos,d=yr(r.doc,f,s.length,s);if(d||(s[0]=a?{type:a}:null,d=yr(r.doc,f,s.length,s)),!d)return!1;if(r.split(f,s.length,s),!c&&u&&i.node(l).type!=a){let h=r.mapping.slice(o),p=h.map(i.before(l)),y=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(y.index(),y.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Xg=Gg();var Zg=(t,e)=>(e&&e(t.tr.setSelection(new Ce(t.doc))),!0);function ey(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||kr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function yf(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&ey(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(n){let h=e.pos+o.nodeSize,p=R.empty;for(let x=s.length-1;x>=0;x--)p=R.from(s[x].create(null,p));p=R.from(i.copy(p));let y=t.tr.step(new we(e.pos-1,h,e.pos,h,new I(p,1,0),s.length,!0)),b=y.doc.resolve(h+2*s.length);b.nodeAfter&&b.nodeAfter.type==i.type&&kr(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:H.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&gi(f);if(d!=null&&d>=e.depth)return n&&n(t.tr.lift(f,d).scrollIntoView()),!0;if(c&&$n(o,"start",!0)&&$n(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let y=o,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(h.canReplace(h.childCount,h.childCount,y.content)){if(n){let x=R.empty;for(let T=p.length-1;T>=0;T--)x=R.from(p[T].copy(x));let A=t.tr.step(new we(e.pos-p.length,e.pos+o.nodeSize,e.pos+b,e.pos+o.nodeSize-b,new I(x,p.length,0),0,!0));n(A.scrollIntoView())}return!0}}return!1}function kf(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(K.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}var ty=kf(-1),ny=kf(1);function Zw(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&yi(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function eC(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function ry(t,e,n,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(o.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=o.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function iy(t){let e=[];for(let n=0;n<t.length;n++){let{$from:r,$to:i}=t[n];r.doc.nodesBetween(r.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=r.pos&&s+o.nodeSize<=i.pos)return s+1>r.pos&&e.push(new Nn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+o.content.size),!1}),r.pos<i.pos&&e.push(new Nn(r,i))}return e}function tC(t,e=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,o=!(n&&n.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!ry(s.doc,u,t,i))return!1;if(l)if(c)t.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(t)):l(s.tr.addStoredMark(t.create(e)));else{let f,d=s.tr;i||(u=iy(u)),r?f=!u.some(h=>s.doc.rangeHasMark(h.$from.pos,h.$to.pos,t)):f=!u.every(h=>{let p=!1;return d.doc.nodesBetween(h.$from.pos,h.$to.pos,(y,b,x)=>{if(p)return!1;p=!t.isInSet(y.marks)&&!!x&&x.type.allowsMarkType(t)&&!(y.isText&&/^\s*$/.test(y.textBetween(Math.max(0,h.$from.pos-b),Math.min(y.nodeSize,h.$to.pos-b))))}),!p});for(let h=0;h<u.length;h++){let{$from:p,$to:y}=u[h];if(!f)d.removeMark(p.pos,y.pos,t);else{let b=p.pos,x=y.pos,A=p.nodeAfter,T=y.nodeBefore,V=o&&A&&A.isText?/^\s*/.exec(A.text)[0].length:0,j=o&&T&&T.isText?/\s*$/.exec(T.text)[0].length:0;b+V<x&&(b+=V,x-=j),d.addMark(b,x,t.create(e))}}l(d.scrollIntoView())}return!0}}function Xt(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}var Gs=Xt(Xi,jg,Xs),df=Xt(Xi,Hg,Kg),ut={Enter:Xt(Jg,Qg,Yg,Xg),"Mod-Enter":Ug,Backspace:Gs,"Mod-Backspace":Gs,"Shift-Backspace":Gs,Delete:df,"Mod-Delete":df,"Mod-a":Zg},xf={"Ctrl-h":ut.Backspace,"Alt-Backspace":ut["Mod-Backspace"],"Ctrl-d":ut.Delete,"Ctrl-Alt-Backspace":ut["Mod-Delete"],"Alt-Delete":ut["Mod-Delete"],"Alt-d":ut["Mod-Delete"],"Ctrl-a":ty,"Ctrl-e":ny};for(let t in ut)xf[t]=ut[t];var oy=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,bf=oy?xf:ut;var wf=class{},Cf=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=t=>{this.top()?.push(t)},this.open=t=>{this.elements.push(t)},this.close=()=>{let t=this.elements.pop();if(!t)throw co();return t}}},sy=class Tf extends wf{constructor(e,n,r){super(),this.type=e,this.content=n,this.attrs=r}push(e,...n){this.content.push(e,...n)}pop(){return this.content.pop()}static create(e,n,r){return new Tf(e,n,r)}},We,jn,qr,Wr,Hr,qn,Wn,en,Mf=(en=class extends Cf{constructor(n){super();O(this,We);O(this,jn);O(this,qr);O(this,Wr);O(this,Hr);O(this,qn);O(this,Wn);C(this,We,Ve.none),C(this,jn,r=>r.isText),C(this,qr,(r,i)=>{if(k(this,jn).call(this,r)&&k(this,jn).call(this,i)&&Ve.sameSet(r.marks,i.marks))return this.schema.text(r.text+i.text,r.marks)}),C(this,Wr,r=>{let i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(r));if(!i)throw $l(r);return i}),C(this,Hr,r=>{let i=k(this,Wr).call(this,r);i.spec.parseMarkdown.runner(this,r,i)}),this.injectRoot=(r,i,o)=>(this.openNode(i,o),this.next(r.children),this),this.openNode=(r,i)=>(this.open(sy.create(r,[],i)),this),C(this,qn,()=>{C(this,We,Ve.none);let r=this.close();return k(this,Wn).call(this,r.type,r.attrs,r.content)}),this.closeNode=()=>{try{k(this,qn).call(this)}catch(r){console.error(r)}return this},C(this,Wn,(r,i,o)=>{let s=r.createAndFill(i,o,k(this,We));if(!s)throw _l(r,i,o);return this.push(s),s}),this.addNode=(r,i,o)=>{try{k(this,Wn).call(this,r,i,o)}catch(s){console.error(s)}return this},this.openMark=(r,i)=>{let o=r.create(i);return C(this,We,o.addToSet(k(this,We))),this},this.closeMark=r=>(C(this,We,r.removeFromSet(k(this,We))),this),this.addText=r=>{try{let i=this.top();if(!i)throw co();let o=i.pop(),s=this.schema.text(r,k(this,We));if(!o)return i.push(s),this;let l=k(this,qr).call(this,o,s);return l?(i.push(l),this):(i.push(o,s),this)}catch(i){return console.error(i),this}},this.build=()=>{let r;do r=k(this,qn).call(this);while(this.size());return r},this.next=(r=[])=>([r].flat().forEach(i=>k(this,Hr).call(this,i)),this),this.toDoc=()=>this.build(),this.run=(r,i)=>{let o=r.runSync(r.parse(i),i);return this.next(o),this},this.schema=n}},We=new WeakMap,jn=new WeakMap,qr=new WeakMap,Wr=new WeakMap,Hr=new WeakMap,qn=new WeakMap,Wn=new WeakMap,en.create=(n,r)=>{let i=new en(n);return o=>(i.run(r,o),i.toDoc())},en),tn,Sf=(tn=class extends wf{constructor(e,n,r,i={}){super(),this.type=e,this.children=n,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>this.children?.pop()}},tn.create=(e,n,r,i={})=>new tn(e,n,r,i),tn),ly=t=>Object.prototype.hasOwnProperty.call(t,"size"),ge,Hn,Kr,Jr,Ur,Qr,Kn,Jn,Yr,Gr,Zt,Et,Xr,Un,nn,Nf=(nn=class extends Cf{constructor(n){super();O(this,ge);O(this,Hn);O(this,Kr);O(this,Jr);O(this,Ur);O(this,Qr);O(this,Kn);O(this,Jn);O(this,Yr);O(this,Gr);O(this,Zt);O(this,Et);O(this,Xr);O(this,Un);C(this,ge,[]),C(this,Hn,r=>{let i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(r));if(!i)throw jl(r.type);return i}),C(this,Kr,r=>k(this,Hn).call(this,r).spec.toMarkdown.runner(this,r)),C(this,Jr,(r,i)=>k(this,Hn).call(this,r).spec.toMarkdown.runner(this,r,i)),C(this,Ur,r=>{let i=l=>l.type.spec.priority??50,o=[...r].sort((l,a)=>i(l)-i(a)),s=[];return k(this,ge).forEach(({mark:l})=>{let a=o.findIndex(c=>c.eq(l));a>=0&&s.push(...o.splice(a,1))}),s.concat(o)}),C(this,Qr,r=>{let i=r?.marks,o=0;for(;o<k(this,ge).length;){let{mark:s,spanning:l}=k(this,ge)[o];if(l&&i?.some(a=>a.eq(s)))o++;else break}for(let s=k(this,ge).length-1;s>=o;s--)k(this,Un).call(this,k(this,ge)[s].mark)}),C(this,Kn,(r,i)=>{k(this,Ur).call(this,r.marks).every(o=>!k(this,Jr).call(this,o,r))&&k(this,Kr).call(this,r),k(this,Qr).call(this,i)}),C(this,Jn,r=>{let{children:i}=r;return i&&(r.children=i.reduce((o,s,l)=>{if(l===0)return[s];let a=o.at(-1);if(a&&a.isMark&&s.isMark){let{children:c,...u}=s,{children:f,...d}=a;if(s.type===a.type&&c&&f&&JSON.stringify(u)===JSON.stringify(d)){let h={...d,children:[...f,...c]};return o.slice(0,-1).concat(k(this,Jn).call(this,h))}}return o.concat(s)},[])),r}),C(this,Yr,r=>{let i={...r.props,type:r.type};return r.children&&(i.children=r.children),r.value&&(i.value=r.value),i}),this.openNode=(r,i,o)=>(this.open(Sf.create(r,void 0,i,o)),this),C(this,Gr,(r,i)=>{let o="",s="",l=r.children;if(l){let c=l[0],u=l.at(-1);if(u&&u.type==="text"&&u.value.endsWith(" ")){let f=u.value,d=f.trimEnd();s=f.slice(d.length),u.value=d}if(c&&c.type==="text"&&c.value.startsWith(" ")){let f=c.value,d=f.trimStart();o=f.slice(0,f.length-d.length),c.value=d}}o.length&&k(this,Et).call(this,"text",void 0,o);let a=i();return s.length&&k(this,Et).call(this,"text",void 0,s),a}),C(this,Zt,(r=!1)=>{let i=this.close(),o=()=>k(this,Et).call(this,i.type,i.children,i.value,i.props);return r?k(this,Gr).call(this,i,o):o()}),this.closeNode=()=>(k(this,Zt).call(this),this),C(this,Et,(r,i,o,s)=>{let l=Sf.create(r,i,o,s),a=k(this,Jn).call(this,k(this,Yr).call(this,l));return this.push(a),a}),this.addNode=(r,i,o,s)=>(k(this,Et).call(this,r,i,o,s),this),C(this,Xr,(r,i,o,s)=>k(this,ge).some(l=>l.mark.eq(r))?this:(k(this,ge).push({mark:r,spanning:o==null}),this.openNode(i,o,{...s,isMark:!0}))),C(this,Un,r=>{let i=-1;for(let o=k(this,ge).length-1;o>=0;o--)if(k(this,ge)[o].mark.eq(r)){i=o;break}i<0||(k(this,ge).splice(i,1),k(this,Zt).call(this,!0))}),this.withMark=(r,i,o,s)=>(k(this,Xr).call(this,r,i,o,s),this),this.closeMark=r=>(k(this,Un).call(this,r),this),this.build=()=>{let r=null;do r=k(this,Zt).call(this);while(this.size());return r},this.next=r=>ly(r)?(r.forEach((i,o,s)=>{k(this,Kn).call(this,i,r.maybeChild(s+1)??void 0)}),this):(k(this,Kn).call(this,r),this),this.toString=r=>r.stringify(this.build()),this.run=r=>(C(this,ge,[]),this.next(r),this),this.schema=n}},ge=new WeakMap,Hn=new WeakMap,Kr=new WeakMap,Jr=new WeakMap,Ur=new WeakMap,Qr=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,Yr=new WeakMap,Gr=new WeakMap,Zt=new WeakMap,Et=new WeakMap,Xr=new WeakMap,Un=new WeakMap,nn.create=(n,r)=>{let i=new nn(n);return o=>(i.run(o),i.toString(r))},nn);function dt(t,e){return t.meta={package:"@milkdown/core",group:"System",...e},t}var Rf={text:(t,e,n,r)=>{let i=t.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(t,e,n,r)=>{let i=t.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),l=s.move(i+i);return l+=s.move(n.containerPhrasing(t,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},emphasis:(t,e,n,r)=>{let i=t.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),l=s.move(i);return l+=s.move(n.containerPhrasing(t,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l}},Qn=W({},"editorView"),Zr=W({},"editorState"),tl=W([],"initTimer"),Of=W({},"editor"),xl=W([],"inputRules"),ti=W([],"prosePlugins"),bl=W([],"remarkPlugins"),Sl=W([],"nodeView"),wl=W([],"markView"),cn=W(jr().use(Bn).use(Vn),"remark"),nl=W({handlers:Rf,encode:[]},"remarkStringifyOptions"),Zi=$e("ConfigReady");function ay(t){let e=n=>(n.record(Zi),async()=>(await t(n),n.done(Zi),()=>{n.clearTimer(Zi)}));return dt(e,{displayName:"Config"}),e}var ei=$e("InitReady");function cy(t){let e=n=>(n.inject(Of,t).inject(ti,[]).inject(bl,[]).inject(xl,[]).inject(Sl,[]).inject(wl,[]).inject(nl,{handlers:Rf,encode:[]}).inject(cn,jr().use(Bn).use(Vn)).inject(tl,[Zi]).record(ei),async()=>{await n.waitTimers(tl);let r=n.get(nl);return n.set(cn,jr().use(Bn).use(Vn,r)),n.done(ei),()=>{n.remove(Of).remove(ti).remove(bl).remove(xl).remove(Sl).remove(wl).remove(nl).remove(cn).remove(tl).clearTimer(ei)}});return dt(e,{displayName:"Init"}),e}var He=$e("SchemaReady"),rl=W([],"schemaTimer"),Yn=W({},"schema"),il=W([],"nodes"),ol=W([],"marks");function Ef(t){return{...t,parseDOM:t.parseDOM?.map(e=>({priority:t.priority,...e}))}}var Pf=t=>(t.inject(Yn,{}).inject(il,[]).inject(ol,[]).inject(rl,[ei]).record(He),async()=>{await t.waitTimers(rl);let e=t.get(cn),n=t.get(bl).reduce((s,l)=>s.use(l.plugin,l.options),e);t.set(cn,n);let r=Object.fromEntries(t.get(il).map(([s,l])=>[s,Ef(l)])),i=Object.fromEntries(t.get(ol).map(([s,l])=>[s,Ef(l)])),o=new zl({nodes:r,marks:i});return t.set(Yn,o),t.done(He),()=>{t.remove(Yn).remove(il).remove(ol).remove(rl).clearTimer(He)}});dt(Pf,{displayName:"Schema"});var rn,Fe,Df,zf=(Df=class{constructor(){O(this,rn);O(this,Fe);C(this,rn,new uo),C(this,Fe,null),this.setCtx=t=>{C(this,Fe,t)},this.chain=()=>{if(k(this,Fe)==null)throw ai();let t=k(this,Fe),e=[],n=this.get.bind(this),r={run:()=>{let o=Xt(...e),s=t.get(Qn);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),r),pipe:i.bind(this)};function i(o,s){let l=n(o);return e.push(l(s)),r}return r}}get ctx(){return k(this,Fe)}create(t,e){let n=t.create(k(this,rn).sliceMap);return n.set(e),n}get(t){return k(this,rn).get(t).get()}remove(t){return k(this,rn).remove(t)}call(t,e){if(k(this,Fe)==null)throw ai();let n=this.get(t)(e),r=k(this,Fe).get(Qn);return n(r.state,r.dispatch,r)}inline(t){if(k(this,Fe)==null)throw ai();let e=k(this,Fe).get(Qn);return t(e.state,e.dispatch,e)}},rn=new WeakMap,Fe=new WeakMap,Df);function wC(t="cmdKey"){return W((()=>()=>!1),t)}var If=W(new zf,"commands"),sl=W([He],"commandsTimer"),eo=$e("CommandsReady"),Bf=t=>{let e=new zf;return e.setCtx(t),t.inject(If,e).inject(sl,[He]).record(eo),async()=>(await t.waitTimers(sl),t.done(eo),()=>{t.remove(If).remove(sl).clearTimer(eo)})};dt(Bf,{displayName:"Commands"});function uy(t){return t.Backspace=Xt(xa,Xi,mf,Xs),t}var on,ke,Af,Ff=(Af=class{constructor(){O(this,on);O(this,ke);C(this,on,null),C(this,ke,[]),this.setCtx=t=>{C(this,on,t)},this.add=t=>(k(this,ke).push(t),()=>{C(this,ke,k(this,ke).filter(e=>e!==t))}),this.addObjectKeymap=t=>{let e=[];return Object.entries(t).forEach(([n,r])=>{if(typeof r=="function"){let i={key:n,onRun:()=>r};k(this,ke).push(i),e.push(()=>{C(this,ke,k(this,ke).filter(o=>o!==i))})}else k(this,ke).push(r),e.push(()=>{C(this,ke,k(this,ke).filter(i=>i!==r))})}),()=>{e.forEach(n=>n())}},this.addBaseKeymap=()=>{let t=uy(bf);return this.addObjectKeymap(t)},this.build=()=>{let t={};return k(this,ke).forEach(e=>{t[e.key]=[...t[e.key]||[],e]}),Object.fromEntries(Object.entries(t).map(([e,n])=>{let r=n.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,l)=>{let a=k(this,on);if(a==null)throw hn();let c=r.map(u=>u.onRun(a));return Xt(...c)(o,s,l)}]}))}}get ctx(){return k(this,on)}},on=new WeakMap,ke=new WeakMap,Af),Cl=W(new Ff,"keymap"),ll=W([He],"keymapTimer"),to=$e("KeymapReady"),fy=t=>{let e=new Ff;return e.setCtx(t),t.inject(Cl,e).inject(ll,[He]).record(to),async()=>(await t.waitTimers(ll),t.done(to),()=>{t.remove(Cl).remove(ll).clearTimer(to)})},no=$e("ParserReady"),vf=(()=>{throw hn()}),ro=W(vf,"parser"),al=W([],"parserTimer"),Lf=t=>(t.inject(ro,vf).inject(al,[He]).record(no),async()=>{await t.waitTimers(al);let e=t.get(cn),n=t.get(Yn);return t.set(ro,Mf.create(n,e)),t.done(no),()=>{t.remove(ro).remove(al).clearTimer(no)}});dt(Lf,{displayName:"Parser"});var io=$e("SerializerReady"),cl=W([],"serializerTimer"),Vf=(()=>{throw hn()}),ul=W(Vf,"serializer"),_f=t=>(t.inject(ul,Vf).inject(cl,[He]).record(io),async()=>{await t.waitTimers(cl);let e=t.get(cn),n=t.get(Yn);return t.set(ul,Nf.create(n,e)),t.done(io),()=>{t.remove(ul).remove(cl).clearTimer(io)}});dt(_f,{displayName:"Serializer"});var fl=W("","defaultValue"),hl=W(t=>t,"stateOptions"),dl=W([],"editorStateTimer"),oo=$e("EditorStateReady");function hy(t,e,n){if(typeof t=="string")return e(t);if(t.type==="html")return ir.fromSchema(n).parse(t.dom);if(t.type==="json")return li.fromJSON(n,t.value);throw vl(t)}var dy=new vt("MILKDOWN_STATE_TRACKER"),$f=t=>(t.inject(fl,"").inject(Zr,{}).inject(hl,e=>e).inject(dl,[no,io,eo,to]).record(oo),async()=>{await t.waitTimers(dl);let e=t.get(Yn),n=t.get(ro),r=t.get(xl),i=t.get(hl),o=t.get(ti),s=hy(t.get(fl),n,e),l=t.get(Cl),a=l.addBaseKeymap(),c=[...o,new rt({key:dy,state:{init:()=>{},apply:(d,h,p,y)=>{t.set(Zr,y)}}}),Ra({rules:r}),za(l.build())];t.set(ti,c);let u=i({schema:e,doc:s,plugins:c}),f=bi.create(u);return t.set(Zr,f),t.done(oo),()=>{a(),t.remove(fl).remove(Zr).remove(hl).remove(dl).clearTimer(oo)}});dt($f,{displayName:"EditorState"});var Tl=W([],"pasteRule"),pl=W([He],"pasteRuleTimer"),so=$e("PasteRuleReady"),jf=t=>(t.inject(Tl,[]).inject(pl,[He]).record(so),async()=>(await t.waitTimers(pl),t.done(so),()=>{t.remove(Tl).remove(pl).clearTimer(so)}));dt(jf,{displayName:"PasteRule"});var ml=$e("EditorViewReady"),gl=W([],"editorViewTimer"),yl=W({},"editorViewOptions"),kl=W(null,"root"),Ml=W(null,"rootDOM"),Nl=W({},"rootAttrs");function py(t,e){let n=document.createElement("div");n.className="milkdown",t.appendChild(n),e.set(Ml,n);let r=e.get(Nl);return Object.entries(r).forEach(([i,o])=>n.setAttribute(i,o)),n}function my(t){t.classList.add("editor"),t.setAttribute("role","textbox")}var gy=new vt("MILKDOWN_VIEW_CLEAR"),qf=t=>(t.inject(kl,document.body).inject(Qn,{}).inject(yl,{}).inject(Ml,null).inject(Nl,{}).inject(gl,[oo,so]).record(ml),async()=>{await t.wait(ei);let e=t.get(kl)||document.body,n=typeof e=="string"?document.querySelector(e):e;t.update(ti,a=>[new rt({key:gy,view:c=>{let u=n?py(n,t):void 0;return(()=>{if(u&&n){let d=c.dom;n.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u?.parentNode&&u?.parentNode.replaceChild(c.dom,u),u?.remove()}}}}),...a]),await t.waitTimers(gl);let r=t.get(Zr),i=t.get(yl),o=Object.fromEntries(t.get(Sl)),s=Object.fromEntries(t.get(wl)),l=new Or(n,{state:r,nodeViews:o,markViews:s,transformPasted:(a,c,u)=>(t.get(Tl).sort((f,d)=>(d.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,c,u)}),a),...i});return my(l.dom),t.set(Qn,l),t.done(ml),()=>{l?.destroy(),t.remove(kl).remove(Qn).remove(yl).remove(Ml).remove(Nl).remove(gl).clearTimer(ml)}});dt(qf,{displayName:"EditorView"});var CC=(function(t){return t.Idle="Idle",t.OnCreate="OnCreate",t.Created="Created",t.OnDestroy="OnDestroy",t.Destroyed="Destroyed",t})({}),sn,Oe,ft,Gn,ni,ri,xe,ht,ln,ii,an,Xn,oi,It,Zn,er,TC=(er=class{constructor(){O(this,sn);O(this,Oe);O(this,ft);O(this,Gn);O(this,ni);O(this,ri);O(this,xe);O(this,ht);O(this,ln);O(this,ii);O(this,an);O(this,Xn);O(this,oi);O(this,It);O(this,Zn);C(this,sn,!1),C(this,Oe,"Idle"),C(this,ft,[]),C(this,Gn,()=>{}),C(this,ni,new uo),C(this,ri,new Ql),C(this,xe,new Map),C(this,ht,new Map),C(this,ln,new Ul(k(this,ni),k(this,ri))),C(this,ii,()=>{let e=ay(async r=>{await Promise.all(k(this,ft).map(i=>Promise.resolve(i(r))))}),n=[Pf,Lf,_f,Bf,fy,jf,$f,qf,cy(this),e];k(this,an).call(this,n,k(this,ht))}),C(this,an,(e,n)=>{e.forEach(r=>{let i=k(this,ln).produce(k(this,sn)?r.meta:void 0),o=r(i);n.set(r,{ctx:i,handler:o,cleanup:void 0})})}),C(this,Xn,(e,n=!1)=>Promise.all([e].flat().map(async r=>{let i=k(this,xe).get(r)?.cleanup;return n?k(this,xe).delete(r):k(this,xe).set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i}))),C(this,oi,async()=>{await Promise.all([...k(this,ht).entries()].map(async([e,{cleanup:n}])=>typeof n=="function"?n():n)),k(this,ht).clear()}),C(this,It,e=>{C(this,Oe,e),k(this,Gn).call(this,e)}),C(this,Zn,e=>[...e.entries()].map(async([n,r])=>{let{ctx:i,handler:o}=r;if(!o)return;let s=await o();e.set(n,{ctx:i,handler:o,cleanup:s})})),this.enableInspector=(e=!0)=>(C(this,sn,e),this),this.onStatusChange=e=>(C(this,Gn,e),this),this.config=e=>(k(this,ft).push(e),this),this.removeConfig=e=>(C(this,ft,k(this,ft).filter(n=>n!==e)),this),this.use=e=>{let n=[e].flat();return n.flat().forEach(r=>{k(this,xe).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),k(this,Oe)==="Created"&&k(this,an).call(this,n,k(this,xe)),this},this.remove=async e=>k(this,Oe)==="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 k(this,Xn).call(this,[e].flat(),!0),this),this.create=async()=>k(this,Oe)==="OnCreate"?this:(k(this,Oe)==="Created"&&await this.destroy(),k(this,It).call(this,"OnCreate"),k(this,ii).call(this),k(this,an).call(this,[...k(this,xe).keys()],k(this,xe)),await Promise.all([k(this,Zn).call(this,k(this,ht)),k(this,Zn).call(this,k(this,xe))].flat()),k(this,It).call(this,"Created"),this),this.destroy=async(e=!1)=>k(this,Oe)==="Destroyed"||k(this,Oe)==="OnDestroy"?this:k(this,Oe)==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(e))},50)}):(e&&C(this,ft,[]),k(this,It).call(this,"OnDestroy"),await k(this,Xn).call(this,[...k(this,xe).keys()],e),await k(this,oi).call(this),k(this,It).call(this,"Destroyed"),this),this.action=e=>e(k(this,ln)),this.inspect=()=>k(this,sn)?[...k(this,ht).values(),...k(this,xe).values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new er}get ctx(){return k(this,ln)}get status(){return k(this,Oe)}},sn=new WeakMap,Oe=new WeakMap,ft=new WeakMap,Gn=new WeakMap,ni=new WeakMap,ri=new WeakMap,xe=new WeakMap,ht=new WeakMap,ln=new WeakMap,ii=new WeakMap,an=new WeakMap,Xn=new WeakMap,oi=new WeakMap,It=new WeakMap,Zn=new WeakMap,er);export{th as a,yy as b,ky as c,xy as d,by as e,Sy as f,wy as g,W as h,$e as i,le as j,Jc as k,ct as l,Me as m,me as n,Rr as o,N as p,G as q,B as r,Gc as s,Xc as t,v as u,Pn as v,zn as w,Mt as x,Cu as y,wn as z,fi as A,fo as B,ho as C,_s as D,yo as E,mr as F,fe as G,we as H,gi as I,yi as J,yr as K,kr as L,mi as M,H as N,Nn as O,K as P,P as Q,Ce as R,bi as S,rt as T,vt as U,jg as V,Ug as W,Zw as X,eC as Y,tC as Z,Te as _,lk as $,ak as aa,pk as ba,mk as ca,gk as da,yk as ea,kk as fa,xk as ga,Zh as ha,bk as ia,Sk as ja,ed as ka,wk as la,Ck as ma,Tk as na,za as oa,od as pa,wt as qa,Be as ra,Or as sa,Qn as ta,Zr as ua,tl as va,Of as wa,xl as xa,ti as ya,bl as za,Sl as Aa,wl as Ba,cn as Ca,nl as Da,Zi as Ea,ay as Fa,ei as Ga,cy as Ha,He as Ia,rl as Ja,Yn as Ka,il as La,ol as Ma,Pf as Na,zf as Oa,wC as Pa,If as Qa,sl as Ra,eo as Sa,Bf as Ta,Ff as Ua,Cl as Va,ll as Wa,to as Xa,fy as Ya,no as Za,ro as _a,al as $a,Lf as ab,io as bb,cl as cb,ul as db,_f as eb,fl as fb,hl as gb,dl as hb,oo as ib,hy as jb,$f as kb,Tl as lb,pl as mb,so as nb,jf as ob,ml as pb,gl as qb,yl as rb,kl as sb,Ml as tb,Nl as ub,qf as vb,CC as wb,TC as xb};