snow-cms 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,43 +1,3 @@
1
- import{g as Nc}from"./index.js";var Ne=(n=>(n.docTypeError="docTypeError",n.contextNotFound="contextNotFound",n.timerNotFound="timerNotFound",n.ctxCallOutOfScope="ctxCallOutOfScope",n.createNodeInParserFail="createNodeInParserFail",n.stackOverFlow="stackOverFlow",n.parserMatchError="parserMatchError",n.serializerMatchError="serializerMatchError",n.getAtomFromSchemaFail="getAtomFromSchemaFail",n.expectDomTypeError="expectDomTypeError",n.callCommandBeforeEditorView="callCommandBeforeEditorView",n.missingRootElement="missingRootElement",n.missingNodeInSchema="missingNodeInSchema",n.missingMarkInSchema="missingMarkInSchema",n.ctxNotBind="ctxNotBind",n.missingYjsDoc="missingYjsDoc",n))(Ne||{});class Pe extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const Ic=(n,e)=>typeof e=="function"?"[Function]":e,wn=n=>JSON.stringify(n,Ic);function Ac(n){return new Pe(Ne.docTypeError,`Doc type error, unsupported type: ${wn(n)}`)}function Dc(n){return new Pe(Ne.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function zc(n){return new Pe(Ne.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function Ks(){return new Pe(Ne.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Rc(...n){const e=n.reduce((t,r)=>{if(!r)return t;const i=s=>Array.isArray(s)?s.map(o=>i(o)).join(", "):s.toJSON?wn(s.toJSON()):s.spec?wn(s.spec):s.toString();return`${t}, ${i(r)}`},"Create prosemirror node from remark failed in parser");return new Pe(Ne.createNodeInParserFail,e)}function aa(){return new Pe(Ne.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Pc(n){return new Pe(Ne.parserMatchError,`Cannot match target parser for node: ${wn(n)}.`)}function Fc(n){return new Pe(Ne.serializerMatchError,`Cannot match target serializer for node: ${wn(n)}.`)}function Gy(n){return new Pe(Ne.expectDomTypeError,`Expect to be a dom, but get: ${wn(n)}.`)}function Bc(){return new Pe(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 Xy(n){return new Pe(Ne.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function Zy(n){return new Pe(Ne.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var ua=n=>{throw TypeError(n)},ca=(n,e,t)=>e.has(n)||ua("Cannot "+t),O=(n,e,t)=>(ca(n,e,"read from private field"),t?t.call(n):e.get(n)),ee=(n,e,t)=>e.has(n)?ua("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),_=(n,e,t,r)=>(ca(n,e,"write to private field"),e.set(n,t),t);let ha=class{constructor(){this.sliceMap=new Map,this.get=e=>{const t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);if(!t){const r=typeof e=="string"?e:e.name;throw Dc(r)}return t},this.remove=e=>{const t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e=="string"?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}};var je,ht,Fn;let vc=class{constructor(e,t,r){ee(this,je),ee(this,ht),ee(this,Fn),_(this,je,[]),_(this,Fn,()=>{O(this,je).forEach(i=>i(O(this,ht)))}),this.set=i=>{_(this,ht,i),O(this,Fn).call(this)},this.get=()=>O(this,ht),this.update=i=>{_(this,ht,i(O(this,ht))),O(this,Fn).call(this)},this.type=r,_(this,ht,t),e.set(r.id,this)}on(e){return O(this,je).push(e),()=>{_(this,je,O(this,je).filter(t=>t!==e))}}once(e){const t=this.on(r=>{e(r),t()});return t}off(e){_(this,je,O(this,je).filter(t=>t!==e))}offAll(){_(this,je,[])}};je=new WeakMap,ht=new WeakMap,Fn=new WeakMap;let Lc=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Ks()}}create(e,t=this._defaultValue){return new vc(e,t,this)}};const H=(n,e)=>new Lc(n,e);var Ir,Ar,Dr,ln,Bn,Lt,vn,Ln,Vn;let Vc=class{constructor(e,t,r){ee(this,Ir),ee(this,Ar),ee(this,Dr),ee(this,ln),ee(this,Bn),ee(this,Lt),ee(this,vn),ee(this,Ln),ee(this,Vn),_(this,ln,new Set),_(this,Bn,new Set),_(this,Lt,new Map),_(this,vn,new Map),this.read=()=>({metadata:O(this,Ir),injectedSlices:[...O(this,ln)].map(i=>({name:typeof i=="string"?i:i.name,value:O(this,Ln).call(this,i)})),consumedSlices:[...O(this,Bn)].map(i=>({name:typeof i=="string"?i:i.name,value:O(this,Ln).call(this,i)})),recordedTimers:[...O(this,Lt)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:O(this,Vn).call(this,i)})),waitTimers:[...O(this,vn)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:O(this,Vn).call(this,i)}))}),this.onRecord=i=>{O(this,Lt).set(i,{start:Date.now(),duration:0})},this.onClear=i=>{O(this,Lt).delete(i)},this.onDone=i=>{const s=O(this,Lt).get(i);s&&(s.duration=Date.now()-s.start)},this.onWait=(i,s)=>{const o=Date.now();s.finally(()=>{O(this,vn).set(i,{duration:Date.now()-o})})},this.onInject=i=>{O(this,ln).add(i)},this.onRemove=i=>{O(this,ln).delete(i)},this.onUse=i=>{O(this,Bn).add(i)},_(this,Ln,i=>O(this,Ar).get(i).get()),_(this,Vn,i=>O(this,Dr).get(i).status),_(this,Ar,e),_(this,Dr,t),_(this,Ir,r)}};Ir=new WeakMap,Ar=new WeakMap,Dr=new WeakMap,ln=new WeakMap,Bn=new WeakMap,Lt=new WeakMap,vn=new WeakMap,Ln=new WeakMap,Vn=new WeakMap;var ft,dt,zr,Ve;const $c=class fa{constructor(e,t,r){ee(this,ft),ee(this,dt),ee(this,zr),ee(this,Ve),this.produce=i=>i&&Object.keys(i).length?new fa(O(this,ft),O(this,dt),{...i}):this,this.inject=(i,s)=>{var o;const l=i.create(O(this,ft).sliceMap);return s!=null&&l.set(s),(o=O(this,Ve))==null||o.onInject(i),this},this.remove=i=>{var s;return O(this,ft).remove(i),(s=O(this,Ve))==null||s.onRemove(i),this},this.record=i=>{var s;return i.create(O(this,dt).store),(s=O(this,Ve))==null||s.onRecord(i),this},this.clearTimer=i=>{var s;return O(this,dt).remove(i),(s=O(this,Ve))==null||s.onClear(i),this},this.isInjected=i=>O(this,ft).has(i),this.isRecorded=i=>O(this,dt).has(i),this.use=i=>{var s;return(s=O(this,Ve))==null||s.onUse(i),O(this,ft).get(i)},this.get=i=>this.use(i).get(),this.set=(i,s)=>this.use(i).set(s),this.update=(i,s)=>this.use(i).update(s),this.timer=i=>O(this,dt).get(i),this.done=i=>{var s;this.timer(i).done(),(s=O(this,Ve))==null||s.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=O(this,Ve))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(s=>this.wait(s)))},_(this,ft,e),_(this,dt,t),_(this,zr,r),r&&_(this,Ve,new Vc(e,t,r))}get meta(){return O(this,zr)}get inspector(){return O(this,Ve)}};ft=new WeakMap,dt=new WeakMap,zr=new WeakMap,Ve=new WeakMap;let Wc=$c,qc=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw zc(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}};var an,Vt,$n,pt,Wn,Rr;let _c=class{constructor(e,t){ee(this,an),ee(this,Vt),ee(this,$n),ee(this,pt),ee(this,Wn),ee(this,Rr),_(this,an,null),_(this,Vt,null),_(this,pt,"pending"),this.start=()=>(O(this,an)??_(this,an,new Promise((r,i)=>{_(this,Vt,s=>{s instanceof CustomEvent&&s.detail.id===O(this,$n)&&(_(this,pt,"resolved"),O(this,Wn).call(this),s.stopImmediatePropagation(),r())}),O(this,Rr).call(this,()=>{O(this,pt)==="pending"&&_(this,pt,"rejected"),O(this,Wn).call(this),i(new Error(`Timing ${this.type.name} timeout.`))}),_(this,pt,"pending"),addEventListener(this.type.name,O(this,Vt))})),O(this,an)),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:O(this,$n)}});dispatchEvent(r)},_(this,Wn,()=>{O(this,Vt)&&removeEventListener(this.type.name,O(this,Vt))}),_(this,Rr,r=>{setTimeout(()=>{r()},this.type.timeout)}),_(this,$n,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return O(this,pt)}};an=new WeakMap,Vt=new WeakMap,$n=new WeakMap,pt=new WeakMap,Wn=new WeakMap,Rr=new WeakMap;let jc=class{constructor(e,t=3e3){this.create=r=>new _c(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}};const Dt=(n,e=3e3)=>new jc(n,e);function ae(n){this.content=n}ae.prototype={constructor:ae,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ae(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ae(t)},addToStart:function(n,e){return new ae([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ae(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ae(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ae.from(n),n.size?new ae(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ae.from(n),n.size?new ae(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ae.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ae.from=function(n){if(n instanceof ae)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ae(e)};function da(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=da(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function pa(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let u=0,c=Math.min(o.text.length,l.text.length);for(;u<c&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let u=pa(o.content,l.content,t-1,r-1);if(u)return u}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new C(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new C(r,i)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new C(i,s)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return da(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return pa(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Er(0,e);if(e==this.size)return Er(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||t>0?Er(r+1,o):Er(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const Wi={index:0,offset:0};function Er(n,e){return Wi.index=n,Wi.offset=e,Wi}function pi(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!pi(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!pi(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class ${constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&pi(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return $.none;if(e instanceof $)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}}$.none=[];class mi extends Error{}class T{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ga(this.content,e+this.openStart,t);return r&&new T(r,this.openStart,this.openEnd)}removeBetween(e,t){return new T(ma(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return T.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new T(C.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new T(e,r,i)}}T.empty=new T(C.empty,0,0);function ma(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(ma(s.content,e-i-1,t-i-1)))}function ga(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ga(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function Jc(n,e,t){if(t.openStart>n.depth)throw new mi("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new mi("Inconsistent open depths");return ya(n,e,t,0)}function ya(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=ya(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Kt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Hc(t,n);return Kt(s,ka(n,o,l,e,r))}else return Kt(s,gi(n,e,r))}function xa(n,e){if(!e.type.compatibleContent(n.type))throw new mi("Cannot join "+e.type.name+" onto "+n.type.name)}function ms(n,e,t){let r=n.node(t);return xa(r,e.node(t)),r}function Ht(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function tr(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Ht(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Ht(i.child(l),r);e&&e.depth==t&&e.textOffset&&Ht(e.nodeBefore,r)}function Kt(n,e){return n.type.checkContent(e),n.copy(e)}function ka(n,e,t,r,i){let s=n.depth>i&&ms(n,e,i+1),o=r.depth>i&&ms(t,r,i+1),l=[];return tr(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(xa(s,o),Ht(Kt(s,ka(n,e,t,r,i+1)),l)):(s&&Ht(Kt(s,gi(n,e,i+1)),l),tr(e,t,i,l),o&&Ht(Kt(o,gi(t,r,i+1)),l)),tr(r,null,i,l),new C(l)}function gi(n,e,t){let r=[];if(tr(null,n,t,r),n.depth>t){let i=ms(n,e,t+1);Ht(Kt(i,gi(n,e,t+1)),r)}return tr(e,null,t,r),new C(r)}function Hc(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(C.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class pr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return $.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Qc(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),u=s-a;if(r.push(o,l,i+a),!u||(o=o.child(l),o.isText))break;s=u-1,i+=a+1}return new pr(t,r,s)}static resolveCached(e,t){let r=Fo.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Fo.set(e,r=new Kc);let i=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%Uc,i}}class Kc{constructor(){this.elts=[],this.i=0}}const Uc=12,Fo=new WeakMap;class Qc{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Yc=Object.create(null);class qe{constructor(e,t,r,i=$.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||C.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&pi(this.attrs,t||e.defaultAttrs||Yc)&&$.sameSet(this.marks,r||$.none)}copy(e=null){return e==this.content?this:new qe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return T.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new T(u,i.depth-o,s.depth-o)}replace(e,t,r){return Jc(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return pr.resolveCached(this,e)}resolveNoCache(e){return pr.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ba(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=C.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=$.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!$.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=C.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}qe.prototype.text=void 0;class yi extends qe{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ba(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new yi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ba(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Gt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Gc(e,t);if(r.next==null)return Gt.empty;let i=Sa(r);r.next&&r.err("Unexpected trailing text");let s=ih(rh(i));return sh(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return C.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:c,next:h}=o.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let d=s(h,l.concat(c));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
2
- `)}}Gt.empty=new Gt(!0);class Gc{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Sa(n){let e=[];do e.push(Xc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xc(n){let e=[];do e.push(Zc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Zc(n){let e=nh(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=eh(n,e);else break;return e}function Bo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function eh(n,e){let t=Bo(n),r=t;return n.eat(",")&&(n.next!="}"?r=Bo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function th(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function nh(n){if(n.eat("(")){let e=Sa(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=th(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function rh(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let u={term:a,to:l};return e[o].push(u),u}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,u)=>a.concat(s(u,l)),[]);if(o.type=="seq")for(let a=0;;a++){let u=s(o.exprs[a],l);if(a==o.exprs.length-1)return u;i(u,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let u=0;u<o.min;u++){let c=t();i(s(o.expr,a),c),a=c}if(o.max==-1)i(s(o.expr,a),a);else for(let u=o.min;u<o.max;u++){let c=t();r(a,c),i(s(o.expr,a),c),a=c}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function wa(n,e){return e-n}function vo(n,e){let t=[];return r(e),t.sort(wa);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function ih(n){let e=Object.create(null);return t(vo(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c<i.length;c++)i[c][0]==l&&(u=i[c][1]);vo(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new Gt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(wa);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function sh(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:u}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ca(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ma(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Ta(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function Ea(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new lh(n,r,e[r]);return t}let Lo=class Oa{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ea(e,r.attrs),this.defaultAttrs=Ca(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Gt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ma(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qe(this,this.computeAttrs(e),C.from(t),$.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new qe(this,this.computeAttrs(e),t,$.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(C.empty,!0);return s?new qe(this,e,t.append(s),$.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ta(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:$.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Oa(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function oh(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class lh{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?oh(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class zi{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Ea(e,i.attrs),this.excluded=null;let s=Ca(this.attrs);this.instance=s?new $(this,s):null}create(e=null){return!e&&this.instance?this.instance:new $(this,Ma(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new zi(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ta(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ah{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ae.from(e.nodes),t.marks=ae.from(e.marks||{}),this.nodes=Lo.compile(this.spec.nodes,this),this.marks=zi.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Gt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Vo(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Vo(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Lo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new yi(r,r.defaultAttrs,e,$.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return qe.fromJSON(this,e)}markFromJSON(e){return $.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Vo(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function uh(n){return n.tag!=null}function ch(n){return n.style!=null}class Cn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(uh(i))this.tags.push(i);else if(ch(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Wo(this,t,!1);return r.addAll(e,$.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Wo(this,t,!0);return r.addAll(e,$.none,t.from,t.to),T.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(dh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=qo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=qo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Cn(e,Cn.schemaRules(e)))}}const Na={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},hh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ia={ol:!0,ul:!0},mr=1,gs=2,Pr=4;function $o(n,e,t){return e!=null?(e?mr:0)|(e==="full"?gs:0):n&&n.whitespace=="pre"?mr|gs:t&-5}class Or{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=$.none,this.match=s||(o&Pr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&mr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Na.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Wo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=$o(null,t.preserveWhitespace,0)|(r?Pr:0);i?s=new Or(i.type,i.attrs,$.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Or(null,null,$.none,!0,null,o):s=new Or(e.schema.topNodeType,null,$.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&gs?"full":this.localPreserveWS||(i.options&mr)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
3
- `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Ia.hasOwnProperty(o)&&this.parser.normalizeLists&&fh(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:hh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let u,c=this.needsBlock;if(Na.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=a&&a.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),u&&this.sync(s),this.needsBlock=c}else{let u=this.readStyles(e,t);u&&this.addElementByRule(e,a,u,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(u=>!a.clearMark(u)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t){let r,i;for(let s=this.open;s>=0;s--){let o=this.nodes[s],l=o.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=o,!l.length)||o.solid)break}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=$.none;for(let o of r.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):_o(o.type,e.type))&&(s=o.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=$o(e,s,o.options);o.options&Pr&&o.content.length==0&&(l|=Pr);let a=$.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):_o(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Or(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=mr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let u=t[l];if(u==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function fh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ia.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function dh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function qo(n){let e={};for(let t in n)e[t]=n[t];return e}function _o(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:c}=l.edge(a);if(u==e||s.indexOf(c)<0&&o(c))return!0}};if(o(i.contentMatch))return!0}}class In{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=qi(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],c=this.serializeMark(u,o.isInline,t);c&&(s.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Fr(qi(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Fr(qi(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Fr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new In(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=jo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return jo(e.marks)}}function jo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function qi(n){return n.document||window.document}const Jo=new WeakMap;function ph(n){let e=Jo.get(n);return e===void 0&&Jo.set(n,e=mh(n)),e}function mh(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Fr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ph(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let h in u)if(u[h]!=null){let d=h.indexOf(" ");d>0?a.setAttributeNS(h.slice(0,d),h.slice(d+1),u[h]):a.setAttribute(h,u[h])}}for(let h=c;h<e.length;h++){let d=e[h];if(d===0){if(h<e.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Fr(n,d,t,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const gh={};function Us(n,e){const t=gh,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Aa(n,r,i)}function Aa(n,e,t){if(yh(n)){if("value"in n)return n.type==="html"&&!t?"":n.value;if(e&&"alt"in n&&n.alt)return n.alt;if("children"in n)return Ho(n.children,e,t)}return Array.isArray(n)?Ho(n,e,t):""}function Ho(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=Aa(n[i],e,t);return r.join("")}function yh(n){return!!(n&&typeof n=="object")}const Ko=document.createElement("i");function Qs(n){const e="&"+n+";";Ko.innerHTML=e;const t=Ko.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function Qe(n,e,t,r){const i=n.length;let s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,r.length<1e4)o=Array.from(r),o.unshift(e,t),n.splice(...o);else for(t&&n.splice(e,t);s<r.length;)o=r.slice(s,s+1e4),o.unshift(e,0),n.splice(...o),s+=1e4,e+=1e4}function De(n,e){return n.length>0?(Qe(n,n.length,0,e),n):e}const Uo={}.hasOwnProperty;function xh(n){const e={};let t=-1;for(;++t<n.length;)kh(e,n[t]);return e}function kh(n,e){let t;for(t in e){const i=(Uo.call(n,t)?n[t]:void 0)||(n[t]={}),s=e[t];let o;if(s)for(o in s){Uo.call(i,o)||(i[o]=[]);const l=s[o];bh(i[o],Array.isArray(l)?l:l?[l]:[])}}}function bh(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);Qe(n,0,0,r)}function Da(n,e){const t=Number.parseInt(n,e);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function xn(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ke=zt(/[A-Za-z]/),$e=zt(/[\dA-Za-z]/),Sh=zt(/[#-'*+\--9=?A-Z^-~]/);function ys(n){return n!==null&&(n<32||n===127)}const xs=zt(/\d/),wh=zt(/[\dA-Fa-f]/),Ch=zt(/[!-/:-@[-`{-~]/);function z(n){return n!==null&&n<-2}function be(n){return n!==null&&(n<0||n===32)}function j(n){return n===-2||n===-1||n===32}const Mh=zt(new RegExp("\\p{P}|\\p{S}","u")),Th=zt(/\s/);function zt(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Q(n,e,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(a){return j(a)?(n.enter(t),l(a)):e(a)}function l(a){return j(a)&&s++<i?(n.consume(a),l):(n.exit(t),e(a))}}const Eh={tokenize:Oh};function Oh(n){const e=n.attempt(this.parser.constructs.contentInitial,r,i);let t;return e;function r(l){if(l===null){n.consume(l);return}return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),Q(n,e,"linePrefix")}function i(l){return n.enter("paragraph"),s(l)}function s(l){const a=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,o(l)}function o(l){if(l===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(l);return}return z(l)?(n.consume(l),n.exit("chunkText"),s):(n.consume(l),o)}}const Nh={tokenize:Ih},Qo={tokenize:Ah};function Ih(n){const e=this,t=[];let r=0,i,s,o;return l;function l(M){if(r<t.length){const B=t[r];return e.containerState=B[1],n.attempt(B[0].continuation,a,u)(M)}return u(M)}function a(M){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&D();const B=e.events.length;let L=B,S;for(;L--;)if(e.events[L][0]==="exit"&&e.events[L][1].type==="chunkFlow"){S=e.events[L][1].end;break}x(r);let q=B;for(;q<e.events.length;)e.events[q][1].end={...S},q++;return Qe(e.events,L+1,0,e.events.slice(B)),e.events.length=q,u(M)}return l(M)}function u(M){if(r===t.length){if(!i)return d(M);if(i.currentConstruct&&i.currentConstruct.concrete)return p(M);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Qo,c,h)(M)}function c(M){return i&&D(),x(r),d(M)}function h(M){return e.parser.lazy[e.now().line]=r!==t.length,o=e.now().offset,p(M)}function d(M){return e.containerState={},n.attempt(Qo,f,p)(M)}function f(M){return r++,t.push([e.currentConstruct,e.containerState]),d(M)}function p(M){if(M===null){i&&D(),x(0),n.consume(M);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(M)}function y(M){if(M===null){k(n.exit("chunkFlow"),!0),x(0),n.consume(M);return}return z(M)?(n.consume(M),k(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(M),y)}function k(M,B){const L=e.sliceStream(M);if(B&&L.push(null),M.previous=s,s&&(s.next=M),s=M,i.defineSkip(M.start),i.write(L),e.parser.lazy[M.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const q=e.events.length;let Y=q,E,V;for(;Y--;)if(e.events[Y][0]==="exit"&&e.events[Y][1].type==="chunkFlow"){if(E){V=e.events[Y][1].end;break}E=!0}for(x(r),S=q;S<e.events.length;)e.events[S][1].end={...V},S++;Qe(e.events,Y+1,0,e.events.slice(q)),e.events.length=S}}function x(M){let B=t.length;for(;B-- >M;){const L=t[B];e.containerState=L[1],L[0].exit.call(e,n)}t.length=M}function D(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Ah(n,e,t){return Q(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function xi(n){if(n===null||be(n)||Th(n))return 1;if(Mh(n))return 2}function Ys(n,e,t){const r=[];let i=-1;for(;++i<n.length;){const s=n[i].resolveAll;s&&!r.includes(s)&&(e=s(e,t),r.push(s))}return e}const ks={name:"attention",resolveAll:Dh,tokenize:zh};function Dh(n,e){let t=-1,r,i,s,o,l,a,u,c;for(;++t<n.length;)if(n[t][0]==="enter"&&n[t][1].type==="attentionSequence"&&n[t][1]._close){for(r=t;r--;)if(n[r][0]==="exit"&&n[r][1].type==="attentionSequence"&&n[r][1]._open&&e.sliceSerialize(n[r][1]).charCodeAt(0)===e.sliceSerialize(n[t][1]).charCodeAt(0)){if((n[r][1]._close||n[t][1]._open)&&(n[t][1].end.offset-n[t][1].start.offset)%3&&!((n[r][1].end.offset-n[r][1].start.offset+n[t][1].end.offset-n[t][1].start.offset)%3))continue;a=n[r][1].end.offset-n[r][1].start.offset>1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1;const h={...n[r][1].end},d={...n[t][1].start};Yo(h,-a),Yo(d,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:{...n[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:d},s={type:a>1?"strongText":"emphasisText",start:{...n[r][1].end},end:{...n[t][1].start}},i={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},n[r][1].end={...o.start},n[t][1].start={...l.end},u=[],n[r][1].end.offset-n[r][1].start.offset&&(u=De(u,[["enter",n[r][1],e],["exit",n[r][1],e]])),u=De(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=De(u,Ys(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),u=De(u,[["exit",s,e],["enter",l,e],["exit",l,e],["exit",i,e]]),n[t][1].end.offset-n[t][1].start.offset?(c=2,u=De(u,[["enter",n[t][1],e],["exit",n[t][1],e]])):c=0,Qe(n,r-1,t-r+3,u),t=r+u.length-c-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function zh(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=xi(r);let s;return o;function o(a){return s=a,n.enter("attentionSequence"),l(a)}function l(a){if(a===s)return n.consume(a),l;const u=n.exit("attentionSequence"),c=xi(a),h=!c||c===2&&i||t.includes(a),d=!i||i===2&&c||t.includes(r);return u._open=!!(s===42?h:h&&(i||!d)),u._close=!!(s===42?d:d&&(c||!h)),e(a)}}function Yo(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const Rh={name:"autolink",tokenize:Ph};function Ph(n,e,t){let r=0;return i;function i(f){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),s}function s(f){return Ke(f)?(n.consume(f),o):f===64?t(f):u(f)}function o(f){return f===43||f===45||f===46||$e(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(n.consume(f),r=0,a):(f===43||f===45||f===46||$e(f))&&r++<32?(n.consume(f),l):(r=0,u(f))}function a(f){return f===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.exit("autolink"),e):f===null||f===32||f===60||ys(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):Sh(f)?(n.consume(f),u):t(f)}function c(f){return $e(f)?h(f):t(f)}function h(f){return f===46?(n.consume(f),r=0,c):f===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.exit("autolink"),e):d(f)}function d(f){if((f===45||$e(f))&&r++<63){const p=f===45?d:h;return n.consume(f),p}return t(f)}}const Ri={partial:!0,tokenize:Fh};function Fh(n,e,t){return r;function r(s){return j(s)?Q(n,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?e(s):t(s)}}const za={continuation:{tokenize:vh},exit:Lh,name:"blockQuote",tokenize:Bh};function Bh(n,e,t){const r=this;return i;function i(o){if(o===62){const l=r.containerState;return l.open||(n.enter("blockQuote",{_container:!0}),l.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(o),n.exit("blockQuoteMarker"),s}return t(o)}function s(o){return j(o)?(n.enter("blockQuotePrefixWhitespace"),n.consume(o),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(o))}}function vh(n,e,t){const r=this;return i;function i(o){return j(o)?Q(n,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return n.attempt(za,e,t)(o)}}function Lh(n){n.exit("blockQuote")}const Ra={name:"characterEscape",tokenize:Vh};function Vh(n,e,t){return r;function r(s){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(s),n.exit("escapeMarker"),i}function i(s){return Ch(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Pa={name:"characterReference",tokenize:$h};function $h(n,e,t){const r=this;let i=0,s,o;return l;function l(h){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(h),n.exit("characterReferenceMarker"),a}function a(h){return h===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(h),n.exit("characterReferenceMarkerNumeric"),u):(n.enter("characterReferenceValue"),s=31,o=$e,c(h))}function u(h){return h===88||h===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(h),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),s=6,o=wh,c):(n.enter("characterReferenceValue"),s=7,o=xs,c(h))}function c(h){if(h===59&&i){const d=n.exit("characterReferenceValue");return o===$e&&!Qs(r.sliceSerialize(d))?t(h):(n.enter("characterReferenceMarker"),n.consume(h),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return o(h)&&i++<s?(n.consume(h),c):t(h)}}const Go={partial:!0,tokenize:qh},Xo={concrete:!0,name:"codeFenced",tokenize:Wh};function Wh(n,e,t){const r=this,i={partial:!0,tokenize:L};let s=0,o=0,l;return a;function a(S){return u(S)}function u(S){const q=r.events[r.events.length-1];return s=q&&q[1].type==="linePrefix"?q[2].sliceSerialize(q[1],!0).length:0,l=S,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),c(S)}function c(S){return S===l?(o++,n.consume(S),c):o<3?t(S):(n.exit("codeFencedFenceSequence"),j(S)?Q(n,h,"whitespace")(S):h(S))}function h(S){return S===null||z(S)?(n.exit("codeFencedFence"),r.interrupt?e(S):n.check(Go,y,B)(S)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||z(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),h(S)):j(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),Q(n,f,"whitespace")(S)):S===96&&S===l?t(S):(n.consume(S),d)}function f(S){return S===null||z(S)?h(S):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||z(S)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),h(S)):S===96&&S===l?t(S):(n.consume(S),p)}function y(S){return n.attempt(i,B,k)(S)}function k(S){return n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),x}function x(S){return s>0&&j(S)?Q(n,D,"linePrefix",s+1)(S):D(S)}function D(S){return S===null||z(S)?n.check(Go,y,B)(S):(n.enter("codeFlowValue"),M(S))}function M(S){return S===null||z(S)?(n.exit("codeFlowValue"),D(S)):(n.consume(S),M)}function B(S){return n.exit("codeFenced"),e(S)}function L(S,q,Y){let E=0;return V;function V(W){return S.enter("lineEnding"),S.consume(W),S.exit("lineEnding"),N}function N(W){return S.enter("codeFencedFence"),j(W)?Q(S,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):I(W)}function I(W){return W===l?(S.enter("codeFencedFenceSequence"),X(W)):Y(W)}function X(W){return W===l?(E++,S.consume(W),X):E>=o?(S.exit("codeFencedFenceSequence"),j(W)?Q(S,te,"whitespace")(W):te(W)):Y(W)}function te(W){return W===null||z(W)?(S.exit("codeFencedFence"),q(W)):Y(W)}}}function qh(n,e,t){const r=this;return i;function i(o){return o===null?t(o):(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?t(o):e(o)}}const _i={name:"codeIndented",tokenize:jh},_h={partial:!0,tokenize:Jh};function jh(n,e,t){const r=this;return i;function i(u){return n.enter("codeIndented"),Q(n,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):t(u)}function o(u){return u===null?a(u):z(u)?n.attempt(_h,o,a)(u):(n.enter("codeFlowValue"),l(u))}function l(u){return u===null||z(u)?(n.exit("codeFlowValue"),o(u)):(n.consume(u),l)}function a(u){return n.exit("codeIndented"),e(u)}}function Jh(n,e,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):z(o)?(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),i):Q(n,s,"linePrefix",5)(o)}function s(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(o):z(o)?i(o):t(o)}}const Hh={name:"codeText",previous:Uh,resolve:Kh,tokenize:Qh};function Kh(n){let e=n.length-4,t=3,r,i;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(r=t;++r<e;)if(n[r][1].type==="codeTextData"){n[t][1].type="codeTextPadding",n[e][1].type="codeTextPadding",t+=2,e-=2;break}}for(r=t-1,e++;++r<=e;)i===void 0?r!==e&&n[r][1].type!=="lineEnding"&&(i=r):(r===e||n[r][1].type==="lineEnding")&&(n[i][1].type="codeTextData",r!==i+2&&(n[i][1].end=n[r-1][1].end,n.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return n}function Uh(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Qh(n,e,t){let r=0,i,s;return o;function o(h){return n.enter("codeText"),n.enter("codeTextSequence"),l(h)}function l(h){return h===96?(n.consume(h),r++,l):(n.exit("codeTextSequence"),a(h))}function a(h){return h===null?t(h):h===32?(n.enter("space"),n.consume(h),n.exit("space"),a):h===96?(s=n.enter("codeTextSequence"),i=0,c(h)):z(h)?(n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),a):(n.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||z(h)?(n.exit("codeTextData"),a(h)):(n.consume(h),u)}function c(h){return h===96?(n.consume(h),i++,c):i===r?(n.exit("codeTextSequence"),n.exit("codeText"),e(h)):(s.type="codeTextData",u(h))}}class Yh{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,t){const r=t??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,t,r){const i=t||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Rn(this.left,r),s.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),Rn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Rn(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){const t=this.left.splice(e,Number.POSITIVE_INFINITY);Rn(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Rn(this.left,t.reverse())}}}function Rn(n,e){let t=0;if(e.length<1e4)n.push(...e);else for(;t<e.length;)n.push(...e.slice(t,t+1e4)),t+=1e4}function Fa(n){const e={};let t=-1,r,i,s,o,l,a,u;const c=new Yh(n);for(;++t<c.length;){for(;t in e;)t=e[t];if(r=c.get(t),t&&r[1].type==="chunkFlow"&&c.get(t-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,s=0,s<a.length&&a[s][1].type==="lineEndingBlank"&&(s+=2),s<a.length&&a[s][1].type==="content"))for(;++s<a.length&&a[s][1].type!=="content";)a[s][1].type==="chunkText"&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,Gh(c,t)),t=e[t],u=!0);else if(r[1]._container){for(s=t,i=void 0;s--;)if(o=c.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},l=c.slice(i,t),l.unshift(r),c.splice(i,t-i+1,l))}}return Qe(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Gh(n,e){const t=n.get(e)[1],r=n.get(e)[2];let i=e-1;const s=[];let o=t._tokenizer;o||(o=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,a=[],u={};let c,h,d=-1,f=t,p=0,y=0;const k=[y];for(;f;){for(;n.get(++i)[1]!==f;);s.push(i),f._tokenizer||(c=r.sliceStream(f),f.next||c.push(null),h&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=t;++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,k.push(y),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):k.pop(),d=k.length;d--;){const x=l.slice(k[d],k[d+1]),D=s.pop();a.push([D,D+x.length-1]),n.splice(D,2,x)}for(a.reverse(),d=-1;++d<a.length;)u[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return u}const Xh={resolve:ef,tokenize:tf},Zh={partial:!0,tokenize:nf};function ef(n){return Fa(n),n}function tf(n,e){let t;return r;function r(l){return n.enter("content"),t=n.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):z(l)?n.check(Zh,o,s)(l):(n.consume(l),i)}function s(l){return n.exit("chunkContent"),n.exit("content"),e(l)}function o(l){return n.consume(l),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function nf(n,e,t){const r=this;return i;function i(o){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),Q(n,s,"linePrefix")}function s(o){if(o===null||z(o))return t(o);const 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(o):n.interrupt(r.parser.constructs.flow,t,e)(o)}}function Ba(n,e,t,r,i,s,o,l,a){const u=a||Number.POSITIVE_INFINITY;let c=0;return h;function h(x){return x===60?(n.enter(r),n.enter(i),n.enter(s),n.consume(x),n.exit(s),d):x===null||x===32||x===41||ys(x)?t(x):(n.enter(r),n.enter(o),n.enter(l),n.enter("chunkString",{contentType:"string"}),y(x))}function d(x){return x===62?(n.enter(s),n.consume(x),n.exit(s),n.exit(i),n.exit(r),e):(n.enter(l),n.enter("chunkString",{contentType:"string"}),f(x))}function f(x){return x===62?(n.exit("chunkString"),n.exit(l),d(x)):x===null||x===60||z(x)?t(x):(n.consume(x),x===92?p:f)}function p(x){return x===60||x===62||x===92?(n.consume(x),f):f(x)}function y(x){return!c&&(x===null||x===41||be(x))?(n.exit("chunkString"),n.exit(l),n.exit(o),n.exit(r),e(x)):c<u&&x===40?(n.consume(x),c++,y):x===41?(n.consume(x),c--,y):x===null||x===32||x===40||ys(x)?t(x):(n.consume(x),x===92?k:y)}function k(x){return x===40||x===41||x===92?(n.consume(x),y):y(x)}}function va(n,e,t,r,i,s){const o=this;let l=0,a;return u;function u(f){return n.enter(r),n.enter(i),n.consume(f),n.exit(i),n.enter(s),c}function c(f){return l>999||f===null||f===91||f===93&&!a||f===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?t(f):f===93?(n.exit(s),n.enter(i),n.consume(f),n.exit(i),n.exit(r),e):z(f)?(n.enter("lineEnding"),n.consume(f),n.exit("lineEnding"),c):(n.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||z(f)||l++>999?(n.exit("chunkString"),c(f)):(n.consume(f),a||(a=!j(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(n.consume(f),l++,h):h(f)}}function La(n,e,t,r,i,s){let o;return l;function l(d){return d===34||d===39||d===40?(n.enter(r),n.enter(i),n.consume(d),n.exit(i),o=d===40?41:d,a):t(d)}function a(d){return d===o?(n.enter(i),n.consume(d),n.exit(i),n.exit(r),e):(n.enter(s),u(d))}function u(d){return d===o?(n.exit(s),a(o)):d===null?t(d):z(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),Q(n,u,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===o||d===null||z(d)?(n.exit("chunkString"),u(d)):(n.consume(d),d===92?h:c)}function h(d){return d===o||d===92?(n.consume(d),c):c(d)}}function nr(n,e){let t;return r;function r(i){return z(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):j(i)?Q(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const rf={name:"definition",tokenize:of},sf={partial:!0,tokenize:lf};function of(n,e,t){const r=this;let i;return s;function s(f){return n.enter("definition"),o(f)}function o(f){return va.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=xn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(n.enter("definitionMarker"),n.consume(f),n.exit("definitionMarker"),a):t(f)}function a(f){return be(f)?nr(n,u)(f):u(f)}function u(f){return Ba(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return n.attempt(sf,h,h)(f)}function h(f){return j(f)?Q(n,d,"whitespace")(f):d(f)}function d(f){return f===null||z(f)?(n.exit("definition"),r.parser.defined.push(i),e(f)):t(f)}}function lf(n,e,t){return r;function r(l){return be(l)?nr(n,i)(l):t(l)}function i(l){return La(n,s,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return j(l)?Q(n,o,"whitespace")(l):o(l)}function o(l){return l===null||z(l)?e(l):t(l)}}const af={name:"hardBreakEscape",tokenize:uf};function uf(n,e,t){return r;function r(s){return n.enter("hardBreakEscape"),n.consume(s),i}function i(s){return z(s)?(n.exit("hardBreakEscape"),e(s)):t(s)}}const cf={name:"headingAtx",resolve:hf,tokenize:ff};function hf(n,e){let t=n.length-2,r=3,i,s;return n[r][1].type==="whitespace"&&(r+=2),t-2>r&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&n[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:n[r][1].start,end:n[t][1].end},s={type:"chunkText",start:n[r][1].start,end:n[t][1].end,contentType:"text"},Qe(n,r,t-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),n}function ff(n,e,t){let r=0;return i;function i(c){return n.enter("atxHeading"),s(c)}function s(c){return n.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(n.consume(c),o):c===null||be(c)?(n.exit("atxHeadingSequence"),l(c)):t(c)}function l(c){return c===35?(n.enter("atxHeadingSequence"),a(c)):c===null||z(c)?(n.exit("atxHeading"),e(c)):j(c)?Q(n,l,"whitespace")(c):(n.enter("atxHeadingText"),u(c))}function a(c){return c===35?(n.consume(c),a):(n.exit("atxHeadingSequence"),l(c))}function u(c){return c===null||c===35||be(c)?(n.exit("atxHeadingText"),l(c)):(n.consume(c),u)}}const df=["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"],Zo=["pre","script","style","textarea"],pf={concrete:!0,name:"htmlFlow",resolveTo:yf,tokenize:xf},mf={partial:!0,tokenize:bf},gf={partial:!0,tokenize:kf};function yf(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function xf(n,e,t){const r=this;let i,s,o,l,a;return u;function u(g){return c(g)}function c(g){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(g),h}function h(g){return g===33?(n.consume(g),d):g===47?(n.consume(g),s=!0,y):g===63?(n.consume(g),i=3,r.interrupt?e:m):Ke(g)?(n.consume(g),o=String.fromCharCode(g),k):t(g)}function d(g){return g===45?(n.consume(g),i=2,f):g===91?(n.consume(g),i=5,l=0,p):Ke(g)?(n.consume(g),i=4,r.interrupt?e:m):t(g)}function f(g){return g===45?(n.consume(g),r.interrupt?e:m):t(g)}function p(g){const ve="CDATA[";return g===ve.charCodeAt(l++)?(n.consume(g),l===ve.length?r.interrupt?e:I:p):t(g)}function y(g){return Ke(g)?(n.consume(g),o=String.fromCharCode(g),k):t(g)}function k(g){if(g===null||g===47||g===62||be(g)){const ve=g===47,Ft=o.toLowerCase();return!ve&&!s&&Zo.includes(Ft)?(i=1,r.interrupt?e(g):I(g)):df.includes(o.toLowerCase())?(i=6,ve?(n.consume(g),x):r.interrupt?e(g):I(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?D(g):M(g))}return g===45||$e(g)?(n.consume(g),o+=String.fromCharCode(g),k):t(g)}function x(g){return g===62?(n.consume(g),r.interrupt?e:I):t(g)}function D(g){return j(g)?(n.consume(g),D):V(g)}function M(g){return g===47?(n.consume(g),V):g===58||g===95||Ke(g)?(n.consume(g),B):j(g)?(n.consume(g),M):V(g)}function B(g){return g===45||g===46||g===58||g===95||$e(g)?(n.consume(g),B):L(g)}function L(g){return g===61?(n.consume(g),S):j(g)?(n.consume(g),L):M(g)}function S(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),a=g,q):j(g)?(n.consume(g),S):Y(g)}function q(g){return g===a?(n.consume(g),a=null,E):g===null||z(g)?t(g):(n.consume(g),q)}function Y(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||be(g)?L(g):(n.consume(g),Y)}function E(g){return g===47||g===62||j(g)?M(g):t(g)}function V(g){return g===62?(n.consume(g),N):t(g)}function N(g){return g===null||z(g)?I(g):j(g)?(n.consume(g),N):t(g)}function I(g){return g===45&&i===2?(n.consume(g),he):g===60&&i===1?(n.consume(g),se):g===62&&i===4?(n.consume(g),Be):g===63&&i===3?(n.consume(g),m):g===93&&i===5?(n.consume(g),Xe):z(g)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(mf,Ze,X)(g)):g===null||z(g)?(n.exit("htmlFlowData"),X(g)):(n.consume(g),I)}function X(g){return n.check(gf,te,Ze)(g)}function te(g){return n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),W}function W(g){return g===null||z(g)?X(g):(n.enter("htmlFlowData"),I(g))}function he(g){return g===45?(n.consume(g),m):I(g)}function se(g){return g===47?(n.consume(g),o="",Fe):I(g)}function Fe(g){if(g===62){const ve=o.toLowerCase();return Zo.includes(ve)?(n.consume(g),Be):I(g)}return Ke(g)&&o.length<8?(n.consume(g),o+=String.fromCharCode(g),Fe):I(g)}function Xe(g){return g===93?(n.consume(g),m):I(g)}function m(g){return g===62?(n.consume(g),Be):g===45&&i===2?(n.consume(g),m):I(g)}function Be(g){return g===null||z(g)?(n.exit("htmlFlowData"),Ze(g)):(n.consume(g),Be)}function Ze(g){return n.exit("htmlFlow"),e(g)}}function kf(n,e,t){const r=this;return i;function i(o){return z(o)?(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),s):t(o)}function s(o){return r.parser.lazy[r.now().line]?t(o):e(o)}}function bf(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(Ri,e,t)}}const Sf={name:"htmlText",tokenize:wf};function wf(n,e,t){const r=this;let i,s,o;return l;function l(m){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(m),a}function a(m){return m===33?(n.consume(m),u):m===47?(n.consume(m),L):m===63?(n.consume(m),M):Ke(m)?(n.consume(m),Y):t(m)}function u(m){return m===45?(n.consume(m),c):m===91?(n.consume(m),s=0,p):Ke(m)?(n.consume(m),D):t(m)}function c(m){return m===45?(n.consume(m),f):t(m)}function h(m){return m===null?t(m):m===45?(n.consume(m),d):z(m)?(o=h,se(m)):(n.consume(m),h)}function d(m){return m===45?(n.consume(m),f):h(m)}function f(m){return m===62?he(m):m===45?d(m):h(m)}function p(m){const Be="CDATA[";return m===Be.charCodeAt(s++)?(n.consume(m),s===Be.length?y:p):t(m)}function y(m){return m===null?t(m):m===93?(n.consume(m),k):z(m)?(o=y,se(m)):(n.consume(m),y)}function k(m){return m===93?(n.consume(m),x):y(m)}function x(m){return m===62?he(m):m===93?(n.consume(m),x):y(m)}function D(m){return m===null||m===62?he(m):z(m)?(o=D,se(m)):(n.consume(m),D)}function M(m){return m===null?t(m):m===63?(n.consume(m),B):z(m)?(o=M,se(m)):(n.consume(m),M)}function B(m){return m===62?he(m):M(m)}function L(m){return Ke(m)?(n.consume(m),S):t(m)}function S(m){return m===45||$e(m)?(n.consume(m),S):q(m)}function q(m){return z(m)?(o=q,se(m)):j(m)?(n.consume(m),q):he(m)}function Y(m){return m===45||$e(m)?(n.consume(m),Y):m===47||m===62||be(m)?E(m):t(m)}function E(m){return m===47?(n.consume(m),he):m===58||m===95||Ke(m)?(n.consume(m),V):z(m)?(o=E,se(m)):j(m)?(n.consume(m),E):he(m)}function V(m){return m===45||m===46||m===58||m===95||$e(m)?(n.consume(m),V):N(m)}function N(m){return m===61?(n.consume(m),I):z(m)?(o=N,se(m)):j(m)?(n.consume(m),N):E(m)}function I(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(n.consume(m),i=m,X):z(m)?(o=I,se(m)):j(m)?(n.consume(m),I):(n.consume(m),te)}function X(m){return m===i?(n.consume(m),i=void 0,W):m===null?t(m):z(m)?(o=X,se(m)):(n.consume(m),X)}function te(m){return m===null||m===34||m===39||m===60||m===61||m===96?t(m):m===47||m===62||be(m)?E(m):(n.consume(m),te)}function W(m){return m===47||m===62||be(m)?E(m):t(m)}function he(m){return m===62?(n.consume(m),n.exit("htmlTextData"),n.exit("htmlText"),e):t(m)}function se(m){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(m),n.exit("lineEnding"),Fe}function Fe(m){return j(m)?Q(n,Xe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):Xe(m)}function Xe(m){return n.enter("htmlTextData"),o(m)}}const Gs={name:"labelEnd",resolveAll:Ef,resolveTo:Of,tokenize:Nf},Cf={tokenize:If},Mf={tokenize:Af},Tf={tokenize:Df};function Ef(n){let e=-1;const t=[];for(;++e<n.length;){const r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&Qe(n,0,n.length,t),n}function Of(n,e){let t=n.length,r=0,i,s,o,l;for(;t--;)if(i=n[t][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;n[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(n[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=t);const a={type:n[s][1].type==="labelLink"?"link":"image",start:{...n[s][1].start},end:{...n[n.length-1][1].end}},u={type:"label",start:{...n[s][1].start},end:{...n[o][1].end}},c={type:"labelText",start:{...n[s+r+2][1].end},end:{...n[o-2][1].start}};return l=[["enter",a,e],["enter",u,e]],l=De(l,n.slice(s+1,s+r+3)),l=De(l,[["enter",c,e]]),l=De(l,Ys(e.parser.constructs.insideSpan.null,n.slice(s+r+4,o-3),e)),l=De(l,[["exit",c,e],n[o-2],n[o-1],["exit",u,e]]),l=De(l,n.slice(o+1)),l=De(l,[["exit",a,e]]),Qe(n,s,n.length,l),n}function Nf(n,e,t){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(d){return s?s._inactive?h(d):(o=r.parser.defined.includes(xn(r.sliceSerialize({start:s.end,end:r.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(d),n.exit("labelMarker"),n.exit("labelEnd"),a):t(d)}function a(d){return d===40?n.attempt(Cf,c,o?c:h)(d):d===91?n.attempt(Mf,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Tf,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function If(n,e,t){return r;function r(h){return n.enter("resource"),n.enter("resourceMarker"),n.consume(h),n.exit("resourceMarker"),i}function i(h){return be(h)?nr(n,s)(h):s(h)}function s(h){return h===41?c(h):Ba(n,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return be(h)?nr(n,a)(h):c(h)}function l(h){return t(h)}function a(h){return h===34||h===39||h===40?La(n,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return be(h)?nr(n,c)(h):c(h)}function c(h){return h===41?(n.enter("resourceMarker"),n.consume(h),n.exit("resourceMarker"),n.exit("resource"),e):t(h)}}function Af(n,e,t){const r=this;return i;function i(l){return va.call(r,n,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(xn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function o(l){return t(l)}}function Df(n,e,t){return r;function r(s){return n.enter("reference"),n.enter("referenceMarker"),n.consume(s),n.exit("referenceMarker"),i}function i(s){return s===93?(n.enter("referenceMarker"),n.consume(s),n.exit("referenceMarker"),n.exit("reference"),e):t(s)}}const zf={name:"labelStartImage",resolveAll:Gs.resolveAll,tokenize:Rf};function Rf(n,e,t){const r=this;return i;function i(l){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(l),n.exit("labelImageMarker"),s}function s(l){return l===91?(n.enter("labelMarker"),n.consume(l),n.exit("labelMarker"),n.exit("labelImage"),o):t(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(l):e(l)}}const Pf={name:"labelStartLink",resolveAll:Gs.resolveAll,tokenize:Ff};function Ff(n,e,t){const r=this;return i;function i(o){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(o),n.exit("labelMarker"),n.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(o):e(o)}}const ji={name:"lineEnding",tokenize:Bf};function Bf(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),Q(n,e,"linePrefix")}}const Br={name:"thematicBreak",tokenize:vf};function vf(n,e,t){let r=0,i;return s;function s(u){return n.enter("thematicBreak"),o(u)}function o(u){return i=u,l(u)}function l(u){return u===i?(n.enter("thematicBreakSequence"),a(u)):r>=3&&(u===null||z(u))?(n.exit("thematicBreak"),e(u)):t(u)}function a(u){return u===i?(n.consume(u),r++,a):(n.exit("thematicBreakSequence"),j(u)?Q(n,l,"whitespace")(u):l(u))}}const ke={continuation:{tokenize:Wf},exit:_f,name:"list",tokenize:$f},Lf={partial:!0,tokenize:jf},Vf={partial:!0,tokenize:qf};function $f(n,e,t){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:xs(f)){if(r.containerState.type||(r.containerState.type=p,n.enter(p,{_container:!0})),p==="listUnordered")return n.enter("listItemPrefix"),f===42||f===45?n.check(Br,t,u)(f):u(f);if(!r.interrupt||f===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),a(f)}return t(f)}function a(f){return xs(f)&&++o<10?(n.consume(f),a):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(n.exit("listItemValue"),u(f)):t(f)}function u(f){return n.enter("listItemMarker"),n.consume(f),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,n.check(Ri,r.interrupt?t:c,n.attempt(Lf,d,h))}function c(f){return r.containerState.initialBlankLine=!0,s++,d(f)}function h(f){return j(f)?(n.enter("listItemPrefixWhitespace"),n.consume(f),n.exit("listItemPrefixWhitespace"),d):t(f)}function d(f){return r.containerState.size=s+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(f)}}function Wf(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(Ri,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Q(n,e,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!j(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt(Vf,e,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Q(n,n.attempt(ke,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function qf(n,e,t){const r=this;return Q(n,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(s):t(s)}}function _f(n){n.exit(this.containerState.type)}function jf(n,e,t){const r=this;return Q(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!j(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):t(s)}}const el={name:"setextUnderline",resolveTo:Jf,tokenize:Hf};function Jf(n,e){let t=n.length,r,i,s;for(;t--;)if(n[t][0]==="enter"){if(n[t][1].type==="content"){r=t;break}n[t][1].type==="paragraph"&&(i=t)}else n[t][1].type==="content"&&n.splice(t,1),!s&&n[t][1].type==="definition"&&(s=t);const o={type:"setextHeading",start:{...n[r][1].start},end:{...n[n.length-1][1].end}};return n[i][1].type="setextHeadingText",s?(n.splice(i,0,["enter",o,e]),n.splice(s+1,0,["exit",n[r][1],e]),n[r][1].end={...n[s][1].end}):n[r][1]=o,n.push(["exit",o,e]),n}function Hf(n,e,t){const r=this;let i;return s;function s(u){let c=r.events.length,h;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){h=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(n.enter("setextHeadingLine"),i=u,o(u)):t(u)}function o(u){return n.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(n.consume(u),l):(n.exit("setextHeadingLineSequence"),j(u)?Q(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||z(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}const Kf={tokenize:Uf};function Uf(n){const e=this,t=n.attempt(Ri,r,n.attempt(this.parser.constructs.flowInitial,i,Q(n,n.attempt(this.parser.constructs.flow,i,n.attempt(Xh,i)),"linePrefix")));return t;function r(s){if(s===null){n.consume(s);return}return n.enter("lineEndingBlank"),n.consume(s),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(s){if(s===null){n.consume(s);return}return n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const Qf={resolveAll:$a()},Yf=Va("string"),Gf=Va("text");function Va(n){return{resolveAll:$a(n==="text"?Xf:void 0),tokenize:e};function e(t){const r=this,i=this.parser.constructs[n],s=t.attempt(i,o,l);return o;function o(c){return u(c)?s(c):l(c)}function l(c){if(c===null){t.consume(c);return}return t.enter("data"),t.consume(c),a}function a(c){return u(c)?(t.exit("data"),s(c)):(t.consume(c),a)}function u(c){if(c===null)return!0;const h=i[c];let d=-1;if(h)for(;++d<h.length;){const f=h[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function $a(n){return e;function e(t,r){let i=-1,s;for(;++i<=t.length;)s===void 0?t[i]&&t[i][1].type==="data"&&(s=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==s+2&&(t[s][1].end=t[i-1][1].end,t.splice(s+2,i-s-2),i=s+2),s=void 0);return n?n(t,r):t}}function Xf(n,e){let t=0;for(;++t<=n.length;)if((t===n.length||n[t][1].type==="lineEnding")&&n[t-1][1].type==="data"){const r=n[t-1][1],i=e.sliceStream(r);let s=i.length,o=-1,l=0,a;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(u===-2)a=!0,l++;else if(u!==-1){s++;break}}if(e._contentTypeTextTrailing&&t===n.length&&(l=0),l){const u={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(n.splice(t,0,["enter",u,e],["exit",u,e]),t+=2)}t++}return n}const Zf={42:ke,43:ke,45:ke,48:ke,49:ke,50:ke,51:ke,52:ke,53:ke,54:ke,55:ke,56:ke,57:ke,62:za},ed={91:rf},td={[-2]:_i,[-1]:_i,32:_i},nd={35:cf,42:Br,45:[el,Br],60:pf,61:el,95:Br,96:Xo,126:Xo},rd={38:Pa,92:Ra},id={[-5]:ji,[-4]:ji,[-3]:ji,33:zf,38:Pa,42:ks,60:[Rh,Sf],91:Pf,92:[af,Ra],93:Gs,95:ks,96:Hh},sd={null:[ks,Qf]},od={null:[42,95]},ld={null:[]},ad=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:od,contentInitial:ed,disable:ld,document:Zf,flow:nd,flowInitial:td,insideSpan:sd,string:rd,text:id},Symbol.toStringTag,{value:"Module"}));function ud(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0};const i={},s=[];let o=[],l=[];const a={attempt:q(L),check:q(S),consume:D,enter:M,exit:B,interrupt:q(S,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:p,parser:n,previous:null,sliceSerialize:d,sliceStream:f,write:h};let c=e.tokenize.call(u,a);return e.resolveAll&&s.push(e),u;function h(N){return o=De(o,N),k(),o[o.length-1]!==null?[]:(Y(e,0),u.events=Ys(s,u.events,u),u.events)}function d(N,I){return hd(f(N),I)}function f(N){return cd(o,N)}function p(){const{_bufferIndex:N,_index:I,line:X,column:te,offset:W}=r;return{_bufferIndex:N,_index:I,line:X,column:te,offset:W}}function y(N){i[N.line]=N.column,V()}function k(){let N;for(;r._index<o.length;){const I=o[r._index];if(typeof I=="string")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<I.length;)x(I.charCodeAt(r._bufferIndex));else x(I)}}function x(N){c=c(N)}function D(N){z(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,V()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=N}function M(N,I){const X=I||{};return X.type=N,X.start=p(),u.events.push(["enter",X,u]),l.push(X),X}function B(N){const I=l.pop();return I.end=p(),u.events.push(["exit",I,u]),I}function L(N,I){Y(N,I.from)}function S(N,I){I.restore()}function q(N,I){return X;function X(te,W,he){let se,Fe,Xe,m;return Array.isArray(te)?Ze(te):"tokenize"in te?Ze([te]):Be(te);function Be(oe){return An;function An(ut){const tn=ut!==null&&oe[ut],nn=ut!==null&&oe.null,Tr=[...Array.isArray(tn)?tn:tn?[tn]:[],...Array.isArray(nn)?nn:nn?[nn]:[]];return Ze(Tr)(ut)}}function Ze(oe){return se=oe,Fe=0,oe.length===0?he:g(oe[Fe])}function g(oe){return An;function An(ut){return m=E(),Xe=oe,oe.partial||(u.currentConstruct=oe),oe.name&&u.parser.constructs.disable.null.includes(oe.name)?Ft():oe.tokenize.call(I?Object.assign(Object.create(u),I):u,a,ve,Ft)(ut)}}function ve(oe){return N(Xe,m),W}function Ft(oe){return m.restore(),++Fe<se.length?g(se[Fe]):he}}}function Y(N,I){N.resolveAll&&!s.includes(N)&&s.push(N),N.resolve&&Qe(u.events,I,u.events.length-I,N.resolve(u.events.slice(I),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function E(){const N=p(),I=u.previous,X=u.currentConstruct,te=u.events.length,W=Array.from(l);return{from:te,restore:he};function he(){r=N,u.previous=I,u.currentConstruct=X,u.events.length=te,l=W,V()}}function V(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function cd(n,e){const t=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let o;if(t===i)o=[n[t].slice(r,s)];else{if(o=n.slice(t,i),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}s>0&&o.push(n[i].slice(0,s))}return o}function hd(n,e){let t=-1;const r=[];let i;for(;++t<n.length;){const s=n[t];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
5
- `;break}case-3:{o=`\r
6
- `;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function fd(n){const r={constructs:xh([ad,...(n||{}).extensions||[]]),content:i(Eh),defined:[],document:i(Nh),flow:i(Kf),lazy:{},string:i(Yf),text:i(Gf)};return r;function i(s){return o;function o(l){return ud(r,s,l)}}}function dd(n){for(;!Fa(n););return n}const tl=/[\0\t\n\r]/g;function pd(){let n=1,e="",t=!0,r;return i;function i(s,o,l){const a=[];let u,c,h,d,f;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,e="",t&&(s.charCodeAt(0)===65279&&h++,t=void 0);h<s.length;){if(tl.lastIndex=h,u=tl.exec(s),d=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(d),!u){e=s.slice(h);break}if(f===10&&h===d&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),h<d&&(a.push(s.slice(h,d)),n+=d-h),f){case 0:{a.push(65533),n++;break}case 9:{for(c=Math.ceil(n/4)*4,a.push(-2);n++<c;)a.push(-1);break}case 10:{a.push(-4),n=1;break}default:r=!0,n=1}h=d+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}const md=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wa(n){return n.replace(md,gd)}function gd(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){const i=t.charCodeAt(1),s=i===120||i===88;return Da(t.slice(s?2:1),s?16:10)}return Qs(t)||n}function rr(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?nl(n.position):"start"in n||"end"in n?nl(n):"line"in n||"column"in n?bs(n):""}function bs(n){return rl(n&&n.line)+":"+rl(n&&n.column)}function nl(n){return bs(n&&n.start)+"-"+bs(n&&n.end)}function rl(n){return n&&typeof n=="number"?n:1}const qa={}.hasOwnProperty;function yd(n,e,t){return typeof e!="string"&&(t=e,e=void 0),xd(t)(dd(fd(t).document().write(pd()(n,e,!0))))}function xd(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Ro),autolinkProtocol:E,autolinkEmail:E,atxHeading:s(Ao),blockQuote:s(nn),characterEscape:E,characterReference:E,codeFenced:s(Tr),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Tr,o),codeText:s(kc,o),codeTextData:E,data:E,codeFlowValue:E,definition:s(bc),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Sc),hardBreakEscape:s(Do),hardBreakTrailing:s(Do),htmlFlow:s(zo,o),htmlFlowData:E,htmlText:s(zo,o),htmlTextData:E,image:s(wc),label:o,link:s(Ro),listItem:s(Cc),listItemValue:d,listOrdered:s(Po,h),listUnordered:s(Po),paragraph:s(Mc),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Ao),strong:s(Tc),thematicBreak:s(Oc)},exit:{atxHeading:a(),atxHeadingSequence:L,autolink:a(),autolinkEmail:tn,autolinkProtocol:ut,blockQuote:a(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:Ft,characterReferenceMarkerNumeric:Ft,characterReferenceValue:oe,characterReference:An,codeFenced:a(k),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:V,codeIndented:a(x),codeText:a(W),codeTextData:V,data:V,definition:a(),definitionDestinationString:B,definitionLabelString:D,definitionTitleString:M,emphasis:a(),hardBreakEscape:a(I),hardBreakTrailing:a(I),htmlFlow:a(X),htmlFlowData:V,htmlText:a(te),htmlTextData:V,image:a(se),label:Xe,labelText:Fe,lineEnding:N,link:a(he),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:ve,resourceDestinationString:m,resourceTitleString:Be,resource:Ze,setextHeading:a(Y),setextHeadingLineSequence:q,setextHeadingText:S,strong:a(),thematicBreak:a()}};_a(e,(n||{}).mdastExtensions||[]);const t={};return r;function r(b){let w={type:"root",children:[]};const P={stack:[w],tokenStack:[],config:e,enter:l,exit:u,buffer:o,resume:c,data:t},v=[];let U=-1;for(;++U<b.length;)if(b[U][1].type==="listOrdered"||b[U][1].type==="listUnordered")if(b[U][0]==="enter")v.push(U);else{const Le=v.pop();U=i(b,Le,U)}for(U=-1;++U<b.length;){const Le=e[b[U][0]];qa.call(Le,b[U][1].type)&&Le[b[U][1].type].call(Object.assign({sliceSerialize:b[U][2].sliceSerialize},P),b[U][1])}if(P.tokenStack.length>0){const Le=P.tokenStack[P.tokenStack.length-1];(Le[1]||il).call(P,void 0,Le[0])}for(w.position={start:ct(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:ct(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},U=-1;++U<e.transforms.length;)w=e.transforms[U](w)||w;return w}function i(b,w,P){let v=w-1,U=-1,Le=!1,Bt,et,Dn,zn;for(;++v<=P;){const Ce=b[v];switch(Ce[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ce[0]==="enter"?U++:U--,zn=void 0;break}case"lineEndingBlank":{Ce[0]==="enter"&&(Bt&&!zn&&!U&&!Dn&&(Dn=v),zn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:zn=void 0}if(!U&&Ce[0]==="enter"&&Ce[1].type==="listItemPrefix"||U===-1&&Ce[0]==="exit"&&(Ce[1].type==="listUnordered"||Ce[1].type==="listOrdered")){if(Bt){let rn=v;for(et=void 0;rn--;){const tt=b[rn];if(tt[1].type==="lineEnding"||tt[1].type==="lineEndingBlank"){if(tt[0]==="exit")continue;et&&(b[et][1].type="lineEndingBlank",Le=!0),tt[1].type="lineEnding",et=rn}else if(!(tt[1].type==="linePrefix"||tt[1].type==="blockQuotePrefix"||tt[1].type==="blockQuotePrefixWhitespace"||tt[1].type==="blockQuoteMarker"||tt[1].type==="listItemIndent"))break}Dn&&(!et||Dn<et)&&(Bt._spread=!0),Bt.end=Object.assign({},et?b[et][1].start:Ce[1].end),b.splice(et||v,0,["exit",Bt,Ce[2]]),v++,P++}if(Ce[1].type==="listItemPrefix"){const rn={type:"listItem",_spread:!1,start:Object.assign({},Ce[1].start),end:void 0};Bt=rn,b.splice(v,0,["enter",rn,Ce[2]]),v++,P++,Dn=void 0,zn=!0}}}return b[w][1]._spread=Le,P}function s(b,w){return P;function P(v){l.call(this,b(v),v),w&&w.call(this,v)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(b,w,P){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([w,P||void 0]),b.position={start:ct(w.start),end:void 0}}function a(b){return w;function w(P){b&&b.call(this,P),u.call(this,P)}}function u(b,w){const P=this.stack.pop(),v=this.tokenStack.pop();if(v)v[0].type!==b.type&&(w?w.call(this,b,v[0]):(v[1]||il).call(this,b,v[0]));else throw new Error("Cannot close `"+b.type+"` ("+rr({start:b.start,end:b.end})+"): it’s not open");P.position.end=ct(b.end)}function c(){return Us(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function d(b){if(this.data.expectingFirstListItemValue){const w=this.stack[this.stack.length-2];w.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function f(){const b=this.resume(),w=this.stack[this.stack.length-1];w.lang=b}function p(){const b=this.resume(),w=this.stack[this.stack.length-1];w.meta=b}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b.replace(/(\r?\n|\r)$/g,"")}function D(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=xn(this.sliceSerialize(b)).toLowerCase()}function M(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function B(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function L(b){const w=this.stack[this.stack.length-1];if(!w.depth){const P=this.sliceSerialize(b).length;w.depth=P}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function q(b){const w=this.stack[this.stack.length-1];w.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function Y(){this.data.setextHeadingSlurpLineEnding=void 0}function E(b){const P=this.stack[this.stack.length-1].children;let v=P[P.length-1];(!v||v.type!=="text")&&(v=Ec(),v.position={start:ct(b.start),end:void 0},P.push(v)),this.stack.push(v)}function V(b){const w=this.stack.pop();w.value+=this.sliceSerialize(b),w.position.end=ct(b.end)}function N(b){const w=this.stack[this.stack.length-1];if(this.data.atHardBreak){const P=w.children[w.children.length-1];P.position.end=ct(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(w.type)&&(E.call(this,b),V.call(this,b))}function I(){this.data.atHardBreak=!0}function X(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function te(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function W(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function he(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const w=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=w,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function se(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const w=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=w,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function Fe(b){const w=this.sliceSerialize(b),P=this.stack[this.stack.length-2];P.label=Wa(w),P.identifier=xn(w).toLowerCase()}function Xe(){const b=this.stack[this.stack.length-1],w=this.resume(),P=this.stack[this.stack.length-1];if(this.data.inReference=!0,P.type==="link"){const v=b.children;P.children=v}else P.alt=w}function m(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function Be(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function Ze(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function ve(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=xn(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function Ft(b){this.data.characterReferenceType=b.type}function oe(b){const w=this.sliceSerialize(b),P=this.data.characterReferenceType;let v;P?(v=Da(w,P==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):v=Qs(w);const U=this.stack[this.stack.length-1];U.value+=v}function An(b){const w=this.stack.pop();w.position.end=ct(b.end)}function ut(b){V.call(this,b);const w=this.stack[this.stack.length-1];w.url=this.sliceSerialize(b)}function tn(b){V.call(this,b);const w=this.stack[this.stack.length-1];w.url="mailto:"+this.sliceSerialize(b)}function nn(){return{type:"blockquote",children:[]}}function Tr(){return{type:"code",lang:null,meta:null,value:""}}function kc(){return{type:"inlineCode",value:""}}function bc(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Sc(){return{type:"emphasis",children:[]}}function Ao(){return{type:"heading",depth:0,children:[]}}function Do(){return{type:"break"}}function zo(){return{type:"html",value:""}}function wc(){return{type:"image",title:null,url:"",alt:null}}function Ro(){return{type:"link",title:null,url:"",children:[]}}function Po(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Cc(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function Mc(){return{type:"paragraph",children:[]}}function Tc(){return{type:"strong",children:[]}}function Ec(){return{type:"text",value:""}}function Oc(){return{type:"thematicBreak"}}}function ct(n){return{line:n.line,column:n.column,offset:n.offset}}function _a(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?_a(n,r):kd(n,r)}}function kd(n,e){let t;for(t in e)if(qa.call(e,t))switch(t){case"canContainEols":{const r=e[t];r&&n[t].push(...r);break}case"transforms":{const r=e[t];r&&n[t].push(...r);break}case"enter":case"exit":{const r=e[t];r&&Object.assign(n[t],r);break}}}function il(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+rr({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+rr({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+rr({start:e.start,end:e.end})+") is still open")}function Ss(n){const e=this;e.parser=t;function t(r){return yd(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const sl={}.hasOwnProperty;function bd(n,e){const t=e||{};function r(i,...s){let o=r.invalid;const l=r.handlers;if(i&&sl.call(i,n)){const a=String(i[n]);o=sl.call(l,a)?l[a]:r.unknown}if(o)return o.call(this,i,...s)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}const Sd={}.hasOwnProperty;function ja(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)ja(n,e.extensions[t]);for(r in e)if(Sd.call(e,r))switch(r){case"extensions":break;case"unsafe":{ol(n[r],e[r]);break}case"join":{ol(n[r],e[r]);break}case"handlers":{wd(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function ol(n,e){e&&n.push(...e)}function wd(n,e){e&&Object.assign(n,e)}function Cd(n,e,t,r){const i=t.enter("blockquote"),s=t.createTracker(r);s.move("> "),s.shift(2);const o=t.indentLines(t.containerFlow(n,s.current()),Md);return i(),o}function Md(n,e,t){return">"+(t?"":" ")+n}function Ja(n,e){return ll(n,e.inConstruct,!0)&&!ll(n,e.notInConstruct,!1)}function ll(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let r=-1;for(;++r<e.length;)if(n.includes(e[r]))return!0;return!1}function al(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
7
- `&&Ja(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
8
- `}function Td(n,e){const t=String(n);let r=t.indexOf(e),i=r,s=0,o=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+e.length,r=t.indexOf(e,i);return o}function ws(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^ \r\n]/.test(n.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(n.value))}function Ed(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function Od(n,e,t,r){const i=Ed(t),s=n.value||"",o=i==="`"?"GraveAccent":"Tilde";if(ws(n,t)){const h=t.enter("codeIndented"),d=t.indentLines(s,Nd);return h(),d}const l=t.createTracker(r),a=i.repeat(Math.max(Td(s,i)+1,3)),u=t.enter("codeFenced");let c=l.move(a);if(n.lang){const h=t.enter(`codeFencedLang${o}`);c+=l.move(t.safe(n.lang,{before:c,after:" ",encode:["`"],...l.current()})),h()}if(n.lang&&n.meta){const h=t.enter(`codeFencedMeta${o}`);c+=l.move(" "),c+=l.move(t.safe(n.meta,{before:c,after:`
9
- `,encode:["`"],...l.current()})),h()}return c+=l.move(`
10
- `),s&&(c+=l.move(s+`
11
- `)),c+=l.move(a),u(),c}function Nd(n,e,t){return(t?"":" ")+n}function Xs(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function Id(n,e,t,r){const i=Xs(t),s=i==='"'?"Quote":"Apostrophe",o=t.enter("definition");let l=t.enter("label");const a=t.createTracker(r);let u=a.move("[");return u+=a.move(t.safe(t.associationId(n),{before:u,after:"]",...a.current()})),u+=a.move("]: "),l(),!n.url||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":`
12
- `,...a.current()}))),l(),n.title&&(l=t.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),o(),u}function Ad(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Nt(n){return"&#x"+n.toString(16).toUpperCase()+";"}function ki(n,e,t){const r=xi(n),i=xi(e);return r===void 0?i===void 0?t==="_"?{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}}Ha.peek=Dd;function Ha(n,e,t,r){const i=Ad(t),s=t.enter("emphasis"),o=t.createTracker(r),l=o.move(i);let a=o.move(t.containerPhrasing(n,{after:i,before:l,...o.current()}));const u=a.charCodeAt(0),c=ki(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=Nt(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=ki(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+Nt(h));const f=o.move(i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function Dd(n,e,t){return t.options.emphasis||"*"}const Zs=function(n){if(n==null)return Fd;if(typeof n=="function")return Pi(n);if(typeof n=="object")return Array.isArray(n)?zd(n):Rd(n);if(typeof n=="string")return Pd(n);throw new Error("Expected function, string, or object as test")};function zd(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=Zs(n[t]);return Pi(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function Rd(n){const e=n;return Pi(t);function t(r){const i=r;let s;for(s in n)if(i[s]!==e[s])return!1;return!0}}function Pd(n){return Pi(e);function e(t){return t&&t.type===n}}function Pi(n){return e;function e(t,r,i){return!!(Bd(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Fd(){return!0}function Bd(n){return n!==null&&typeof n=="object"&&"type"in n}const Ka=[],vd=!0,Cs=!1,Ld="skip";function Vd(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;const s=Zs(i),o=r?-1:1;l(n,void 0,[])();function l(a,u,c){const h=a&&typeof a=="object"?a:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(a.type+(f?"<"+f+">":""))+")"})}return d;function d(){let f=Ka,p,y,k;if((!e||s(a,u,c[c.length-1]||void 0))&&(f=$d(t(a,c)),f[0]===Cs))return f;if("children"in a&&a.children){const x=a;if(x.children&&f[0]!==Ld)for(y=(r?x.children.length:-1)+o,k=c.concat(x);y>-1&&y<x.children.length;){const D=x.children[y];if(p=l(D,y,k)(),p[0]===Cs)return p;y=typeof p[1]=="number"?p[1]:y+o}}return f}}}function $d(n){return Array.isArray(n)?n:typeof n=="number"?[vd,n]:n==null?Ka:[n]}function Wd(n,e,t,r){let i,s,o;typeof e=="function"&&typeof t!="function"?(s=void 0,o=e,i=t):(s=e,o=t,i=r),Vd(n,s,l,i);function l(a,u){const c=u[u.length-1],h=c?c.children.indexOf(a):void 0;return o(a,h,c)}}function Ua(n,e){let t=!1;return Wd(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,Cs}),!!((!n.depth||n.depth<3)&&Us(n)&&(e.options.setext||t))}function qd(n,e,t,r){const i=Math.max(Math.min(6,n.depth||1),1),s=t.createTracker(r);if(Ua(n,t)){const c=t.enter("headingSetext"),h=t.enter("phrasing"),d=t.containerPhrasing(n,{...s.current(),before:`
13
- `,after:`
14
- `});return h(),c(),d+`
15
- `+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
16
- `))+1))}const o="#".repeat(i),l=t.enter("headingAtx"),a=t.enter("phrasing");s.move(o+" ");let u=t.containerPhrasing(n,{before:"# ",after:`
17
- `,...s.current()});return/^[\t ]/.test(u)&&(u=Nt(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,t.options.closeAtx&&(u+=" "+o),a(),l(),u}Qa.peek=_d;function Qa(n){return n.value||""}function _d(){return"<"}Ya.peek=jd;function Ya(n,e,t,r){const i=Xs(t),s=i==='"'?"Quote":"Apostrophe",o=t.enter("image");let l=t.enter("label");const a=t.createTracker(r);let u=a.move("![");return u+=a.move(t.safe(n.alt,{before:u,after:"]",...a.current()})),u+=a.move("]("),l(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":")",...a.current()}))),l(),n.title&&(l=t.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),u+=a.move(")"),o(),u}function jd(){return"!"}Ga.peek=Jd;function Ga(n,e,t,r){const i=n.referenceType,s=t.enter("imageReference");let o=t.enter("label");const l=t.createTracker(r);let a=l.move("![");const u=t.safe(n.alt,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),o();const c=t.stack;t.stack=[],o=t.enter("reference");const h=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return o(),t.stack=c,s(),i==="full"||!u||u!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Jd(){return"!"}Xa.peek=Hd;function Xa(n,e,t){let r=n.value||"",i="`",s=-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+" ");++s<t.unsafe.length;){const o=t.unsafe[s],l=t.compilePattern(o);let a;if(o.atBreak)for(;a=l.exec(r);){let u=a.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(a.index+1)}}return i+r+i}function Hd(){return"`"}function Za(n,e){const t=Us(n);return!!(!e.options.resourceLink&&n.url&&!n.title&&n.children&&n.children.length===1&&n.children[0].type==="text"&&(t===n.url||"mailto:"+t===n.url)&&/^[a-z][a-z+.-]+:/i.test(n.url)&&!/[\0- <>\u007F]/.test(n.url))}eu.peek=Kd;function eu(n,e,t,r){const i=Xs(t),s=i==='"'?"Quote":"Apostrophe",o=t.createTracker(r);let l,a;if(Za(n,t)){const c=t.stack;t.stack=[],l=t.enter("autolink");let h=o.move("<");return h+=o.move(t.containerPhrasing(n,{before:h,after:">",...o.current()})),h+=o.move(">"),l(),t.stack=c,h}l=t.enter("link"),a=t.enter("label");let u=o.move("[");return u+=o.move(t.containerPhrasing(n,{before:u,after:"](",...o.current()})),u+=o.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(t.safe(n.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(a=t.enter("destinationRaw"),u+=o.move(t.safe(n.url,{before:u,after:n.title?" ":")",...o.current()}))),a(),n.title&&(a=t.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(t.safe(n.title,{before:u,after:i,...o.current()})),u+=o.move(i),a()),u+=o.move(")"),l(),u}function Kd(n,e,t){return Za(n,t)?"<":"["}tu.peek=Ud;function tu(n,e,t,r){const i=n.referenceType,s=t.enter("linkReference");let o=t.enter("label");const l=t.createTracker(r);let a=l.move("[");const u=t.containerPhrasing(n,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),o();const c=t.stack;t.stack=[],o=t.enter("reference");const h=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return o(),t.stack=c,s(),i==="full"||!u||u!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Ud(){return"["}function eo(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Qd(n){const e=eo(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function Yd(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function nu(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Gd(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?Yd(t):eo(t);const l=n.ordered?o==="."?")":".":Qd(t);let a=e&&t.bulletLastUsed?o===t.bulletLastUsed:!1;if(!n.ordered){const c=n.children?n.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(a=!0),nu(t)===o&&c){let h=-1;for(;++h<n.children.length;){const d=n.children[h];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(o=l),t.bulletCurrent=o;const u=t.containerFlow(n,r);return t.bulletLastUsed=o,t.bulletCurrent=s,i(),u}function Xd(n){const e=n.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 Zd(n,e,t,r){const i=Xd(t);let s=t.bulletCurrent||eo(t);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(o=Math.ceil(o/4)*4);const l=t.createTracker(r);l.move(s+" ".repeat(o-s.length)),l.shift(o);const a=t.enter("listItem"),u=t.indentLines(t.containerFlow(n,l.current()),c);return a(),u;function c(h,d,f){return d?(f?"":" ".repeat(o))+h:(f?s:s+" ".repeat(o-s.length))+h}}function ep(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const tp=Zs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function np(n,e,t,r){return(n.children.some(function(o){return tp(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function rp(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}ru.peek=ip;function ru(n,e,t,r){const i=rp(t),s=t.enter("strong"),o=t.createTracker(r),l=o.move(i+i);let a=o.move(t.containerPhrasing(n,{after:i,before:l,...o.current()}));const u=a.charCodeAt(0),c=ki(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=Nt(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=ki(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+Nt(h));const f=o.move(i+i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function ip(n,e,t){return t.options.strong||"*"}function sp(n,e,t,r){return t.safe(n.value,r)}function op(n){const e=n.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 lp(n,e,t){const r=(nu(t)+(t.options.ruleSpaces?" ":"")).repeat(op(t));return t.options.ruleSpaces?r.slice(0,-1):r}const ap={blockquote:Cd,break:al,code:Od,definition:Id,emphasis:Ha,hardBreak:al,heading:qd,html:Qa,image:Ya,imageReference:Ga,inlineCode:Xa,link:eu,linkReference:tu,list:Gd,listItem:Zd,paragraph:ep,root:np,strong:ru,text:sp,thematicBreak:lp},up=[cp];function cp(n,e,t,r){if(e.type==="code"&&ws(e,r)&&(n.type==="list"||n.type===e.type&&ws(n,r)))return!1;if("spread"in t&&typeof t.spread=="boolean")return n.type==="paragraph"&&(n.type===e.type||e.type==="definition"||e.type==="heading"&&Ua(e,r))?void 0:t.spread?1:0}const vt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],hp=[{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:`
18
- `,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:vt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
19
- ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:vt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
20
- *])`},{character:"*",inConstruct:"phrasing",notInConstruct:vt},{atBreak:!0,character:"+",after:`(?:[ \r
21
- ])`},{atBreak:!0,character:"-",after:`(?:[ \r
22
- -])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
23
- ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:vt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:vt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:vt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:vt},{atBreak:!0,character:"~"}];function fp(n){return n.label||!n.identifier?n.label||"":Wa(n.identifier)}function dp(n){if(!n._compiled){const e=(n.atBreak?"[\\r\\n][\\t ]*":"")+(n.before?"(?:"+n.before+")":"");n._compiled=new RegExp((e?"("+e+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(n.character)?"\\":"")+n.character+(n.after?"(?:"+n.after+")":""),"g")}return n._compiled}function pp(n,e,t){const r=e.indexStack,i=n.children||[],s=[];let o=-1,l=t.before,a;r.push(-1);let u=e.createTracker(t);for(;++o<i.length;){const c=i[o];let h;if(r[r.length-1]=o,o+1<i.length){let p=e.handle.handlers[i[o+1].type];p&&p.peek&&(p=p.peek),h=p?p(i[o+1],n,e,{before:"",after:"",...u.current()}).charAt(0):""}else h=t.after;s.length>0&&(l==="\r"||l===`
24
- `)&&c.type==="html"&&(s[s.length-1]=s[s.length-1].replace(/(\r?\n|\r)$/," "),l=" ",u=e.createTracker(t),u.move(s.join("")));let d=e.handle(c,n,e,{...u.current(),after:h,before:l});a&&a===d.slice(0,1)&&(d=Nt(a.charCodeAt(0))+d.slice(1));const f=e.attentionEncodeSurroundingInfo;e.attentionEncodeSurroundingInfo=void 0,a=void 0,f&&(s.length>0&&f.before&&l===s[s.length-1].slice(-1)&&(s[s.length-1]=s[s.length-1].slice(0,-1)+Nt(l.charCodeAt(0))),f.after&&(a=h)),u.move(d),s.push(d),l=d.slice(-1)}return r.pop(),s.join("")}function mp(n,e,t){const r=e.indexStack,i=n.children||[],s=e.createTracker(t),o=[];let l=-1;for(r.push(-1);++l<i.length;){const a=i[l];r[r.length-1]=l,o.push(s.move(e.handle(a,n,e,{before:`
25
- `,after:`
26
- `,...s.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&o.push(s.move(gp(a,i[l+1],n,e)))}return r.pop(),o.join("")}function gp(n,e,t,r){let i=r.join.length;for(;i--;){const s=r.join[i](n,e,t,r);if(s===!0||s===1)break;if(typeof s=="number")return`
27
- `.repeat(1+s);if(s===!1)return`
28
-
29
- <!---->
30
-
31
- `}return`
32
-
33
- `}const yp=/\r?\n|\r/g;function xp(n,e){const t=[];let r=0,i=0,s;for(;s=yp.exec(n);)o(n.slice(r,s.index)),t.push(s[0]),r=s.index+s[0].length,i++;return o(n.slice(r)),t.join("");function o(l){t.push(e(l,i,!l))}}function kp(n,e,t){const r=(t.before||"")+(e||"")+(t.after||""),i=[],s=[],o={};let l=-1;for(;++l<n.unsafe.length;){const c=n.unsafe[l];if(!Ja(n.stack,c))continue;const h=n.compilePattern(c);let d;for(;d=h.exec(r);){const f="before"in c||!!c.atBreak,p="after"in c,y=d.index+(f?d[1].length:0);i.includes(y)?(o[y].before&&!f&&(o[y].before=!1),o[y].after&&!p&&(o[y].after=!1)):(i.push(y),o[y]={before:f,after:p})}}i.sort(bp);let a=t.before?t.before.length:0;const u=r.length-(t.after?t.after.length:0);for(l=-1;++l<i.length;){const c=i[l];c<a||c>=u||c+1<u&&i[l+1]===c+1&&o[c].after&&!o[c+1].before&&!o[c+1].after||i[l-1]===c-1&&o[c].before&&!o[c-1].before&&!o[c-1].after||(a!==c&&s.push(ul(r.slice(a,c),"\\")),a=c,/[!-/:-@[-`{-~]/.test(r.charAt(c))&&(!t.encode||!t.encode.includes(r.charAt(c)))?s.push("\\"):(s.push(Nt(r.charCodeAt(c))),a++))}return s.push(ul(r.slice(a,u),t.after)),s.join("")}function bp(n,e){return n-e}function ul(n,e){const t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],s=n+e;let o=-1,l=0,a;for(;a=t.exec(s);)r.push(a.index);for(;++o<r.length;)l!==r[o]&&i.push(n.slice(l,r[o])),i.push("\\"),l=r[o];return i.push(n.slice(l)),i.join("")}function Sp(n){const e=n||{},t=e.now||{};let r=e.lineShift||0,i=t.line||1,s=t.column||1;return{move:a,current:o,shift:l};function o(){return{now:{line:i,column:s},lineShift:r}}function l(u){r+=u}function a(u){const c=u||"",h=c.split(/\r?\n|\r/g),d=h[h.length-1];return i+=h.length-1,s=h.length===1?s+d.length:1+d.length+r,c}}function wp(n,e){const t=e||{},r={associationId:fp,containerPhrasing:Ep,containerFlow:Op,createTracker:Sp,compilePattern:dp,enter:s,handlers:{...ap},handle:void 0,indentLines:xp,indexStack:[],join:[...up],options:{},safe:Np,stack:[],unsafe:[...hp]};ja(r,t),r.options.tightDefinitions&&r.join.push(Tp),r.handle=bd("type",{invalid:Cp,unknown:Mp,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:`
34
- `,after:`
35
- `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
36
- `),i;function s(o){return r.stack.push(o),l;function l(){r.stack.pop()}}}function Cp(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Mp(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Tp(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Ep(n,e){return pp(n,this,e)}function Op(n,e){return mp(n,this,e)}function Np(n,e){return kp(this,n,e)}function Ms(n){const e=this;e.compiler=t;function t(r){return wp(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function cl(n){if(n)throw n}var Ji,hl;function Ip(){if(hl)return Ji;hl=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):e.call(u)==="[object Array]"},s=function(u){if(!u||e.call(u)!=="[object Object]")return!1;var c=n.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&n.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!h)return!1;var d;for(d in u);return typeof d>"u"||n.call(u,d)},o=function(u,c){t&&c.name==="__proto__"?t(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},l=function(u,c){if(c==="__proto__")if(n.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return Ji=function a(){var u,c,h,d,f,p,y=arguments[0],k=1,x=arguments.length,D=!1;for(typeof y=="boolean"&&(D=y,y=arguments[1]||{},k=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});k<x;++k)if(u=arguments[k],u!=null)for(c in u)h=l(y,c),d=l(u,c),y!==d&&(D&&d&&(s(d)||(f=i(d)))?(f?(f=!1,p=h&&i(h)?h:[]):p=h&&s(h)?h:{},o(y,{name:c,newValue:a(D,p,d)})):typeof d<"u"&&o(y,{name:c,newValue:d}));return y},Ji}var Ap=Ip();const Hi=Nc(Ap);function Ts(n){if(typeof n!="object"||n===null)return!1;const e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function Dp(){const n=[],e={run:t,use:r};return e;function t(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(a,...u){const c=n[++s];let h=-1;if(a){o(a);return}for(;++h<i.length;)(u[h]===null||u[h]===void 0)&&(u[h]=i[h]);i=u,c?zp(c,l)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function zp(n,e){let t;return r;function r(...o){const l=n.length>o.length;let a;l&&o.push(i);try{a=n.apply(this,o)}catch(u){const c=u;if(l&&t)throw c;return i(c)}l||(a&&a.then&&typeof a.then=="function"?a.then(s,i):a instanceof Error?i(a):s(a))}function i(o,...l){t||(t=!0,e(o,...l))}function s(o){i(null,o)}}class we extends Error{constructor(e,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",s={},o=!1;if(t&&("line"in t&&"column"in t?s={place:t}:"start"in t&&"end"in t?s={place:t}:"type"in t?s={ancestors:[t],place:t.position}:s={...t}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof r=="string"){const a=r.indexOf(":");a===-1?s.ruleId=r:(s.source=r.slice(0,a),s.ruleId=r.slice(a+1))}if(!s.place&&s.ancestors&&s.ancestors){const a=s.ancestors[s.ancestors.length-1];a&&(s.place=a.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.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=rr(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual,this.expected,this.note,this.url}}we.prototype.file="";we.prototype.name="";we.prototype.reason="";we.prototype.message="";we.prototype.stack="";we.prototype.column=void 0;we.prototype.line=void 0;we.prototype.ancestors=void 0;we.prototype.cause=void 0;we.prototype.fatal=void 0;we.prototype.place=void 0;we.prototype.ruleId=void 0;we.prototype.source=void 0;const He={basename:Rp,dirname:Pp,extname:Fp,join:Bp,sep:"/"};function Rp(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Sr(n);let t=0,r=-1,i=n.length,s;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(s){t=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":n.slice(t,r)}if(e===n)return"";let o=-1,l=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(s){t=i+1;break}}else o<0&&(s=!0,o=i+1),l>-1&&(n.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return t===r?r=o:r<0&&(r=n.length),n.slice(t,r)}function Pp(n){if(Sr(n),n.length===0)return".";let e=-1,t=n.length,r;for(;--t;)if(n.codePointAt(t)===47){if(r){e=t;break}}else r||(r=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function Fp(n){Sr(n);let e=n.length,t=-1,r=0,i=-1,s=0,o;for(;e--;){const l=n.codePointAt(e);if(l===47){if(o){r=e+1;break}continue}t<0&&(o=!0,t=e+1),l===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||t<0||s===0||s===1&&i===t-1&&i===r+1?"":n.slice(i,t)}function Bp(...n){let e=-1,t;for(;++e<n.length;)Sr(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":vp(t)}function vp(n){Sr(n);const e=n.codePointAt(0)===47;let t=Lp(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Lp(n,e){let t="",r=0,i=-1,s=0,o=-1,l,a;for(;++o<=n.length;){if(o<n.length)l=n.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(a=t.lastIndexOf("/"),a!==t.length-1){a<0?(t="",r=0):(t=t.slice(0,a),r=t.length-1-t.lastIndexOf("/")),i=o,s=0;continue}}else if(t.length>0){t="",r=0,i=o,s=0;continue}}e&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+n.slice(i+1,o):t=n.slice(i+1,o),r=o-i-1;i=o,s=0}else l===46&&s>-1?s++:s=-1}return t}function Sr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const Vp={cwd:$p};function $p(){return"/"}function Es(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function Wp(n){if(typeof n=="string")n=new URL(n);else if(!Es(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return qp(n)}function qp(n){if(n.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=n.pathname;let t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){const r=e.codePointAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const Ki=["history","path","basename","stem","extname","dirname"];class _p{constructor(e){let t;e?Es(e)?t={path:e}:typeof e=="string"||jp(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":Vp.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ki.length;){const s=Ki[r];s in t&&t[s]!==void 0&&t[s]!==null&&(this[s]=s==="history"?[...t[s]]:t[s])}let i;for(i in t)Ki.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?He.basename(this.path):void 0}set basename(e){Qi(e,"basename"),Ui(e,"basename"),this.path=He.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?He.dirname(this.path):void 0}set dirname(e){fl(this.basename,"dirname"),this.path=He.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?He.extname(this.path):void 0}set extname(e){if(Ui(e,"extname"),fl(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=He.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Es(e)&&(e=Wp(e)),Qi(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?He.basename(this.path,this.extname):void 0}set stem(e){Qi(e,"stem"),Ui(e,"stem"),this.path=He.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){const i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){const i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){const i=new we(e,t,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 Ui(n,e){if(n&&n.includes(He.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+He.sep+"`")}function Qi(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function fl(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function jp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const Jp=function(n){const r=this.constructor.prototype,i=r[n],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},Hp={}.hasOwnProperty;class to extends Jp{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=Dp()}copy(){const e=new to;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(Hi(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Xi("data",this.frozen),this.namespace[e]=t,this):Hp.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Xi("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=t.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=Nr(e),r=this.parser||this.Parser;return Yi("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),Yi("process",this.parser||this.Parser),Gi("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(s,o){const l=Nr(e),a=r.parse(l);r.run(a,l,function(c,h,d){if(c||!h||!d)return u(c);const f=h,p=r.stringify(f,d);Up(p)?d.value=p:d.result=p,u(c,d)});function u(c,h){c||!h?o(c):s?s(h):t(void 0,h)}}}processSync(e){let t=!1,r;return this.freeze(),Yi("processSync",this.parser||this.Parser),Gi("processSync",this.compiler||this.Compiler),this.process(e,i),pl("processSync","process",t),r;function i(s,o){t=!0,cl(s),r=o}}run(e,t,r){dl(e),this.freeze();const i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?s(void 0,r):new Promise(s);function s(o,l){const a=Nr(t);i.run(e,a,u);function u(c,h,d){const f=h||e;c?l(c):o?o(f):r(void 0,f,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,s),pl("runSync","run",r),i;function s(o,l){cl(o),i=l,r=!0}}stringify(e,t){this.freeze();const r=Nr(t),i=this.compiler||this.Compiler;return Gi("stringify",i),dl(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Xi("use",this.frozen),e!=null)if(typeof e=="function")a(e,t);else if(typeof e=="object")Array.isArray(e)?l(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(u){if(typeof u=="function")a(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[c,...h]=u;a(c,h)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))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(u.plugins),u.settings&&(i.settings=Hi(!0,i.settings,u.settings))}function l(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const h=u[c];s(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function a(u,c){let h=-1,d=-1;for(;++h<r.length;)if(r[h][0]===u){d=h;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[f,...p]=c;const y=r[d][1];Ts(y)&&Ts(f)&&(f=Hi(!0,y,f)),r[d]=[u,f,...p]}}}}const Os=new to().freeze();function Yi(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Gi(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Xi(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function dl(n){if(!Ts(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function pl(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Nr(n){return Kp(n)?n:new _p(n)}function Kp(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Up(n){return typeof n=="string"||Qp(n)}function Qp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var iu=n=>{throw TypeError(n)},su=(n,e,t)=>e.has(n)||iu("Cannot "+t),F=(n,e,t)=>(su(n,e,"read from private field"),t?t.call(n):e.get(n)),ne=(n,e,t)=>e.has(n)?iu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),G=(n,e,t,r)=>(su(n,e,"write to private field"),e.set(n,t),t);let ou=class{},lu=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var t;(t=this.top())==null||t.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw aa();return e}}};class no extends ou{constructor(e,t,r){super(),this.type=e,this.content=t,this.attrs=r}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,r){return new no(e,t,r)}}var Je,qn,vr,Lr,Vr,_n,jn;const Ns=class extends lu{constructor(e){super(),ne(this,Je),ne(this,qn),ne(this,vr),ne(this,Lr),ne(this,Vr),ne(this,_n),ne(this,jn),G(this,Je,$.none),G(this,qn,t=>t.isText),G(this,vr,(t,r)=>{if(F(this,qn).call(this,t)&&F(this,qn).call(this,r)&&$.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)}),G(this,Lr,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw Pc(t);return r}),G(this,Vr,t=>{const r=F(this,Lr).call(this,t);r.spec.parseMarkdown.runner(this,t,r)}),this.injectRoot=(t,r,i)=>(this.openNode(r,i),this.next(t.children),this),this.openNode=(t,r)=>(this.open(no.create(t,[],r)),this),G(this,_n,()=>{G(this,Je,$.none);const t=this.close();return F(this,jn).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>(F(this,_n).call(this),this),G(this,jn,(t,r,i)=>{const s=t.createAndFill(r,i,F(this,Je));if(!s)throw Rc(t,r,i);return this.push(s),s}),this.addNode=(t,r,i)=>(F(this,jn).call(this,t,r,i),this),this.openMark=(t,r)=>{const i=t.create(r);return G(this,Je,i.addToSet(F(this,Je))),this},this.closeMark=t=>(G(this,Je,t.removeFromSet(F(this,Je))),this),this.addText=t=>{const r=this.top();if(!r)throw aa();const i=r.pop(),s=this.schema.text(t,F(this,Je));if(!i)return r.push(s),this;const o=F(this,vr).call(this,i,s);return o?(r.push(o),this):(r.push(i,s),this)},this.build=()=>{let t;do t=F(this,_n).call(this);while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(r=>F(this,Vr).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(t,r)=>{const i=t.runSync(t.parse(r),r);return this.next(i),this},this.schema=e}};Je=new WeakMap,qn=new WeakMap,vr=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,_n=new WeakMap,jn=new WeakMap,Ns.create=(n,e)=>{const t=new Ns(n);return r=>(t.run(e,r),t.toDoc())};let Yp=Ns;const Is=class extends ou{constructor(e,t,r,i={}){super(),this.type=e,this.children=t,this.value=r,this.props=i,this.push=(s,...o)=>{this.children||(this.children=[]),this.children.push(s,...o)},this.pop=()=>{var s;return(s=this.children)==null?void 0:s.pop()}}};Is.create=(n,e,t,r={})=>new Is(n,e,t,r);let ml=Is;const Gp=n=>Object.prototype.hasOwnProperty.call(n,"size");var rt,Jn,$r,Wr,Hn,qr,Kn,_r,jr,un,$t,Jr,Un;const As=class extends lu{constructor(e){super(),ne(this,rt),ne(this,Jn),ne(this,$r),ne(this,Wr),ne(this,Hn),ne(this,qr),ne(this,Kn),ne(this,_r),ne(this,jr),ne(this,un),ne(this,$t),ne(this,Jr),ne(this,Un),G(this,rt,$.none),G(this,Jn,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Fc(t.type);return r}),G(this,$r,t=>F(this,Jn).call(this,t).spec.toMarkdown.runner(this,t)),G(this,Wr,(t,r)=>F(this,Jn).call(this,t).spec.toMarkdown.runner(this,t,r)),G(this,Hn,t=>{const{marks:r}=t,i=s=>s.type.spec.priority??50;[...r].sort((s,o)=>i(s)-i(o)).every(s=>!F(this,Wr).call(this,s,t))&&F(this,$r).call(this,t),r.forEach(s=>F(this,Un).call(this,s))}),G(this,qr,(t,r)=>{var i;if(t.type===r||((i=t.children)==null?void 0:i.length)!==1)return t;const s=u=>{var c;if(u.type===r)return u;if(((c=u.children)==null?void 0:c.length)!==1)return null;const[h]=u.children;return h?s(h):null},o=s(t);if(!o)return t;const l=o.children?[...o.children]:void 0,a={...t,children:l};return a.children=l,o.children=[a],o}),G(this,Kn,t=>{const{children:r}=t;return r&&(t.children=r.reduce((i,s,o)=>{if(o===0)return[s];const l=i.at(-1);if(l&&l.isMark&&s.isMark){s=F(this,qr).call(this,s,l.type);const{children:a,...u}=s,{children:c,...h}=l;if(s.type===l.type&&a&&c&&JSON.stringify(u)===JSON.stringify(h)){const d={...h,children:[...c,...a]};return i.slice(0,-1).concat(F(this,Kn).call(this,d))}}return i.concat(s)},[])),t}),G(this,_r,t=>{const r={...t.props,type:t.type};return t.children&&(r.children=t.children),t.value&&(r.value=t.value),r}),this.openNode=(t,r,i)=>(this.open(ml.create(t,void 0,r,i)),this),G(this,jr,(t,r)=>{let i="",s="";const o=t.children;let l=-1,a=-1;const u=h=>{h&&h.forEach((d,f)=>{d.type==="text"&&d.value&&(l<0&&(l=f),a=f)})};if(o){u(o);const h=o==null?void 0:o[a],d=o==null?void 0:o[l];h&&h.value.endsWith(" ")&&(s=h.value.match(/ +$/)[0],h.value=h.value.trimEnd()),d&&d.value.startsWith(" ")&&(i=d.value.match(/^ +/)[0],d.value=d.value.trimStart())}i.length&&F(this,$t).call(this,"text",void 0,i);const c=r();return s.length&&F(this,$t).call(this,"text",void 0,s),c}),G(this,un,(t=!1)=>{const r=this.close(),i=()=>F(this,$t).call(this,r.type,r.children,r.value,r.props);return t?F(this,jr).call(this,r,i):i()}),this.closeNode=()=>(F(this,un).call(this),this),G(this,$t,(t,r,i,s)=>{const o=ml.create(t,r,i,s),l=F(this,Kn).call(this,F(this,_r).call(this,o));return this.push(l),l}),this.addNode=(t,r,i,s)=>(F(this,$t).call(this,t,r,i,s),this),G(this,Jr,(t,r,i,s)=>t.isInSet(F(this,rt))?this:(G(this,rt,t.addToSet(F(this,rt))),this.openNode(r,i,{...s,isMark:!0}))),G(this,Un,t=>{t.isInSet(F(this,rt))&&(G(this,rt,t.type.removeFromSet(F(this,rt))),F(this,un).call(this,!0))}),this.withMark=(t,r,i,s)=>(F(this,Jr).call(this,t,r,i,s),this),this.closeMark=t=>(F(this,Un).call(this,t),this),this.build=()=>{let t=null;do t=F(this,un).call(this);while(this.size());return t},this.next=t=>Gp(t)?(t.forEach(r=>{F(this,Hn).call(this,r)}),this):(F(this,Hn).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};rt=new WeakMap,Jn=new WeakMap,$r=new WeakMap,Wr=new WeakMap,Hn=new WeakMap,qr=new WeakMap,Kn=new WeakMap,_r=new WeakMap,jr=new WeakMap,un=new WeakMap,$t=new WeakMap,Jr=new WeakMap,Un=new WeakMap,As.create=(n,e)=>{const t=new As(n);return r=>(t.run(r),t.toString(e))};let Xp=As;const au=65535,uu=Math.pow(2,16);function Zp(n,e){return n+e*uu}function gl(n){return n&au}function em(n){return(n-(n&au))/uu}const cu=1,hu=2,Hr=4,fu=8;class Ds{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&fu)>0}get deletedBefore(){return(this.delInfo&(cu|Hr))>0}get deletedAfter(){return(this.delInfo&(hu|Hr))>0}get deletedAcross(){return(this.delInfo&Hr)>0}}class Te{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Te.empty)return Te.empty}recover(e){let t=0,r=gl(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+em(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=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 u=this.ranges[l+s],c=this.ranges[l+o],h=a+u;if(e<=h){let d=u?e==a?-1:e==h?1:t:t,f=a+i+(d<0?0:c);if(r)return f;let p=e==(t<0?a:h)?null:Zp(l/3,e-a),y=e==a?hu:e==h?cu:Hr;return(t<0?e!=a:e!=h)&&(y|=fu),new Ds(f,y,p)}i+=c-u}return r?e+i:new Ds(e+i,0,null)}touches(e,t){let r=0,i=gl(t),s=this.inverted?2:1,o=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 u=this.ranges[l+s],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),u=this.ranges[i+t],c=this.ranges[i+r];e(l,l+u,a,a+c),s+=c-u}}invert(){return new Te(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Te.empty:new Te(e<0?[0,-e,0]:[0,0,e])}}Te.empty=new Te([]);class ir{constructor(e=[],t,r=0,i=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=i}slice(e=0,t=this.maps.length){return new ir(this.maps,this.mirror,e,t)}copy(){return new ir(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new ir;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Ds(e,i,null)}}const Zi=Object.create(null);class me{getMap(){return Te.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Zi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Zi)throw new RangeError("Duplicate use of step JSON ID "+e);return Zi[e]=t,t.prototype.jsonID=e,t}}class re{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new re(e,null)}static fail(e){return new re(null,e)}static fromReplace(e,t,r,i){try{return re.ok(e.replace(t,r,i))}catch(s){if(s instanceof mi)return re.fail(s.message);throw s}}}function ro(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(ro(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return C.fromArray(r)}class bt extends me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new T(ro(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return re.fromReplace(e,this.from,this.to,s)}invert(){return new Ue(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new bt(t.pos,r.pos,this.mark)}merge(e){return e instanceof bt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bt(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new bt(t.from,t.to,e.markFromJSON(t.mark))}}me.jsonID("addMark",bt);class Ue extends me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new T(ro(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return re.fromReplace(e,this.from,this.to,r)}invert(){return new bt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ue(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ue&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ue(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ue(t.from,t.to,e.markFromJSON(t.mark))}}me.jsonID("removeMark",Ue);class St extends me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return re.fromReplace(e,this.pos,this.pos+1,new T(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new St(this.pos,t.marks[i]);return new St(this.pos,this.mark)}}return new Mn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new St(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new St(t.pos,e.markFromJSON(t.mark))}}me.jsonID("addNodeMark",St);class Mn extends me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return re.fromReplace(e,this.pos,this.pos+1,new T(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new St(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Mn(t.pos,e.markFromJSON(t.mark))}}me.jsonID("removeNodeMark",Mn);class de extends me{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&zs(e,this.from,this.to)?re.fail("Structure replace would overwrite content"):re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(e){return new de(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new de(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof de)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?T.empty:new T(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new de(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?T.empty:new T(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new de(e.from,this.to,t,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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new de(t.from,t.to,T.fromJSON(e,t.slice),!!t.structure)}}me.jsonID("replace",de);class Ee extends me{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(zs(e,this.from,this.gapFrom)||zs(e,this.gapTo,this.to)))return re.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return re.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?re.fromReplace(e,this.from,this.to,r):re.fail("Content does not fit in gap")}getMap(){return new Te([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ee(t.pos,r.pos,i,s,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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ee(t.from,t.to,t.gapFrom,t.gapTo,T.fromJSON(e,t.slice),t.insert,!!t.structure)}}me.jsonID("replaceAround",Ee);function zs(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function tm(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let h=a.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),f=Math.min(u+a.nodeSize,t),p=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(p)||(o&&o.to==d&&o.mark.eq(h[y])?o.to=f:i.push(o=new Ue(d,f,h[y])));l&&l.to==d?l.to=f:s.push(l=new bt(d,f,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function nm(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof zi){let u=o.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let u=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let h=a[c],d;for(let f=0;f<i.length;f++){let p=i[f];p.step==s-1&&h.eq(i[f].style)&&(d=p)}d?(d.to=u,d.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>n.step(new Ue(o.from,o.to,o.style)))}function io(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let u=s.child(a),c=l+u.nodeSize,h=r.matchType(u.type);if(!h)o.push(new de(l,c,T.empty));else{r=h;for(let d=0;d<u.marks.length;d++)t.allowsMarkType(u.marks[d].type)||n.step(new Ue(l,c,u.marks[d]));if(i&&u.isText&&t.whitespace!="pre"){let d,f=/\r?\n|\r/g,p;for(;d=f.exec(u.text);)p||(p=new T(C.from(t.schema.text(" ",t.allowedMarks(u.marks))),0,0)),o.push(new de(l+d.index,l+d.index+d[0].length,p))}}l=c}if(!r.validEnd){let a=r.fillBefore(C.empty,!0);n.replace(l,l,new T(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function rm(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function so(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!rm(i,s,o))break}return null}function im(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,u=l,c=C.empty,h=0;for(let p=s,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,c=C.from(r.node(p).copy(c)),h++):a--;let d=C.empty,f=0;for(let p=s,y=!1;p>t;p--)y||i.after(p+1)<i.end(p)?(y=!0,d=C.from(i.node(p).copy(d)),f++):u++;n.step(new Ee(a,u,o,l,new T(c.append(d),h,f),c.size-h,!0))}function du(n,e,t=null,r=n){let i=sm(n,e),s=i&&om(r,e);return s?i.map(yl).concat({type:e,attrs:t}).concat(s.map(yl)):null}function yl(n){return{type:n,attrs:null}}function sm(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function om(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;a&&u<i;u++)a=a.matchType(t.child(u).type);return!a||!a.validEnd?null:o}function lm(n,e,t){let r=C.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=C.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Ee(i,s,i,s,new T(r,0,0),t.length,!0))}function am(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&um(n.doc,n.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?u=!1:!f&&p&&(u=!0)}u===!1&&mu(n,o,l,s),io(n,n.mapping.slice(s).map(l,1),r,void 0,u===null);let c=n.mapping.slice(s),h=c.map(l,1),d=c.map(l+o.nodeSize,1);return n.step(new Ee(h,d,h+1,d-1,new T(C.from(r.create(a,null,o.marks)),0,0),1,!0)),u===!0&&pu(n,o,l,s),!1}})}function pu(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function mu(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
37
- `))}})}function um(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function cm(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new T(C.from(o),0,0),1,!0))}function Kr(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=t-2;u>s;u--,c--){let h=i.node(u),d=i.index(u);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(d,h.childCount),p=r&&r[c+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[c]||h;if(!h.canReplace(d+1,h.childCount)||!y.type.validContent(f))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function hm(n,e,t=1,r){let i=n.doc.resolve(e),s=C.empty,o=C.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){s=C.from(i.node(l).copy(s));let c=r&&r[u];o=C.from(c?c.type.create(c.attrs,o):i.node(l).copy(o))}n.step(new de(e,e,new T(s.append(o),t,t),!0))}function oo(n,e){let t=n.resolve(e),r=t.index();return dm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function fm(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function dm(n,e){return!!(n&&e&&!n.isLeaf&&fm(n,e))}function pm(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let c=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);c&&!h?r=!1:!c&&h&&(r=!0)}let l=n.steps.length;if(r===!1){let c=n.doc.resolve(e+t);mu(n,c.node(),c.before(),l)}o.inlineContent&&io(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),u=a.map(e-t);if(n.step(new de(u,a.map(e+t,-1),T.empty,!0)),r===!0){let c=n.doc.resolve(u);pu(n,c.node(),c.before(),n.steps.length)}return n}function mm(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function gm(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),u=r.node(o),c=!1;if(s==1)c=u.canReplace(a,a,i);else{let h=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=h&&u.canReplaceWith(a,a,h[0])}if(c)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function lo(n,e,t=e,r=T.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return gu(i,s,r)?new de(e,t,r):new ym(i,s,r).fit()}function gu(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ym{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=C.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=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 s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new T(s,o,l);return e>-1?new Ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new de(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=es(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,h=null;if(t==1&&(o?u.matchType(o.type)||(h=u.fillBefore(C.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};if(t==2&&o&&(c=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:c};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=es(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new T(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=es(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new T(Qn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new T(Qn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,u=0,c=[],{match:h,type:d}=this.frontier[t];if(i){for(let y=0;y<i.childCount;y++)c.push(i.child(y));h=h.matchFragment(i)}let f=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),k=h.matchType(y.type);if(!k)break;u++,(u>1||a==0||y.content.size)&&(h=k,c.push(yu(y.mark(d.allowedMarks(y.marks)),u==1?a:0,u==l.childCount?f:-1)))}let p=u==l.childCount;p||(f=-1),this.placed=Yn(this.placed,t,C.from(c)),this.frontier[t].match=h,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,k=l;y<f;y++){let x=k.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),k=x.content}this.unplaced=p?e==0?T.empty:new T(Qn(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new T(Qn(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ts(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.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 t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ts(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=ts(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Yn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Yn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=Yn(this.placed,this.frontier.length,t))}}function Qn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Qn(n.firstChild.content,e-1,t)))}function Yn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Yn(n.lastChild.content,e-1,t)))}function es(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function yu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,yu(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function ts(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!xm(t,s.content,o)?l:null}function xm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function km(n){return n.spec.defining||n.spec.definingForContent}function bm(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(gu(i,s,r))return n.step(new de(e,t,r));let o=ku(i,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,f=i.pos-1;d>0;d--,f--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==f&&o.splice(1,0,-d)}let a=o.indexOf(l),u=[],c=r.openStart;for(let d=r.content,f=0;;f++){let p=d.firstChild;if(u.push(p),f==r.openStart)break;d=p.content}for(let d=c-1;d>=0;d--){let f=u[d],p=km(f.type);if(p&&!f.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(p||!f.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let f=(d+c+1)%(r.openStart+1),p=u[f];if(p)for(let y=0;y<o.length;y++){let k=o[(y+a)%o.length],x=!0;k<0&&(x=!1,k=-k);let D=i.node(k-1),M=i.index(k-1);if(D.canReplaceWith(M,M,p.type,p.marks))return n.replace(i.before(k),x?s.after(k):t,new T(xu(r.content,0,r.openStart,f),f,r.openEnd))}}let h=n.steps.length;for(let d=o.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>h));d--){let f=o[d];f<0||(e=i.before(f),t=s.after(f))}}function xu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(xu(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(C.empty,!0))}return n}function Sm(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=mm(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new T(C.from(r),0,0))}function wm(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=ku(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.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 n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function ku(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class kn extends me{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return re.fromReplace(e,this.pos,this.pos+1,new T(C.from(i),0,t.isLeaf?0:1))}getMap(){return Te.empty}invert(e){return new kn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new kn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new kn(t.pos,t.attr,t.value)}}me.jsonID("attr",kn);class gr extends me{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return re.ok(r)}getMap(){return Te.empty}invert(e){return new gr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new gr(t.attr,t.value)}}me.jsonID("docAttr",gr);let Tn=class extends Error{};Tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Tn.prototype=Object.create(Error.prototype);Tn.prototype.constructor=Tn;Tn.prototype.name="TransformError";class Cm{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ir}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=T.empty){let i=lo(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new T(C.from(r),0,0))}delete(e,t){return this.replace(e,t,T.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return bm(this,e,t,r),this}replaceRangeWith(e,t,r){return Sm(this,e,t,r),this}deleteRange(e,t){return wm(this,e,t),this}lift(e,t){return im(this,e,t),this}join(e,t=1){return pm(this,e,t),this}wrap(e,t){return lm(this,e,t),this}setBlockType(e,t=e,r,i=null){return am(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return cm(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new kn(e,t,r)),this}setDocAttribute(e,t){return this.step(new gr(e,t)),this}addNodeMark(e,t){return this.step(new St(e,t)),this}removeNodeMark(e,t){if(!(t instanceof $)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Mn(e,t)),this}split(e,t=1,r){return hm(this,e,t,r),this}addMark(e,t,r){return tm(this,e,t,r),this}removeMark(e,t,r){return nm(this,e,t,r),this}clearIncompatible(e,t,r){return io(this,e,t,r),this}}const ns=Object.create(null);class J{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Mm(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=T.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:u}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(u.pos),l?T.empty:t),l==0&&bl(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),u=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(u,c):(e.replaceRangeWith(u,c,t),bl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new K(e):cn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?cn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):cn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Oe(e.node(0))}static atStart(e){return cn(e,e,0,0,1)||new Oe(e)}static atEnd(e){return cn(e,e,e.content.size,e.childCount,-1)||new Oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ns[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ns)throw new RangeError("Duplicate use of selection JSON ID "+e);return ns[e]=t,t.prototype.jsonID=e,t}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class Mm{constructor(e,t){this.$from=e,this.$to=t}}let xl=!1;function kl(n){!xl&&!n.parent.inlineContent&&(xl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class K extends J{constructor(e,t=e){kl(e),kl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return J.near(r);let i=e.resolve(t.map(this.anchor));return new K(i.parent.inlineContent?i:r,r)}replace(e,t=T.empty){if(super.replace(e,t),t==T.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof K&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new K(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=J.findFrom(t,r,!0)||J.findFrom(t,-r,!0);if(s)t=s.$head;else return J.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(J.findFrom(e,-r,!0)||J.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new K(e,t)}}J.jsonID("text",K);class Fi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Fi(e.map(this.anchor),e.map(this.head))}resolve(e){return K.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends J{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?J.near(s):new R(s)}content(){return new T(C.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ao(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1;J.jsonID("node",R);class ao{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Fi(r,r):new ao(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):J.near(t)}}class Oe extends J{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=T.empty){if(t==T.empty){e.delete(0,e.doc.content.size);let r=J.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Oe(e)}map(e){return new Oe(e)}eq(e){return e instanceof Oe}getBookmark(){return Tm}}J.jsonID("all",Oe);const Tm={map(){return this},resolve(n){return new Oe(n)}};function cn(n,e,t,r,i,s=!1){if(e.inlineContent)return K.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&R.isSelectable(l))return R.create(n,t-(i<0?l.nodeSize:0))}else{let a=cn(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function bl(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof de||i instanceof Ee))return;let s=n.mapping.maps[r],o;s.forEach((l,a,u,c)=>{o==null&&(o=c)}),n.setSelection(J.near(n.doc.resolve(o),t))}const Sl=1,wl=2,Cl=4;class Em extends Cm{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|Sl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Sl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=wl,this}ensureMarks(e){return $.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&wl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||$.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(J.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=Cl,this}get scrolledIntoView(){return(this.updated&Cl)>0}}function Ml(n,e){return!e||!n?n:n.bind(e)}class Gn{constructor(e,t,r){this.name=e,this.init=Ml(t.init,r),this.apply=Ml(t.apply,r)}}const Om=[new Gn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Gn("selection",{init(n,e){return n.selection||J.atStart(e.doc)},apply(n){return n.selection}}),new Gn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Gn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class rs{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Om.slice(),t&&t.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 Gn(r.key,r.spec.state,r))})}}class gn{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,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){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 t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,u=i?i[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,u,r);if(c&&r.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:r,n:t.length}:{state:this,n:0})}t.push(c),r=r.applyInner(c),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new gn(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Em(this)}static create(e){let t=new rs(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new gn(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new rs(this.schema,e.plugins),r=t.fields,i=new gn(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.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],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new rs(e.schema,e.plugins),s=new gn(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=qe.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=J.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=u.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function bu(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=bu(i,e,{})),t[r]=i}return t}class Bi{constructor(e){this.spec=e,this.props={},e.props&&bu(e.props,this,this.props),this.key=e.key?e.key.key:Su("plugin")}getState(e){return e[this.key]}}const is=Object.create(null);function Su(n){return n in is?n+"$"+ ++is[n]:(is[n]=0,n+"$")}class uo{constructor(e="key"){this.key=Su(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}class at{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Nm(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Nm(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}const Im=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){let o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1};new at(/--$/,"—");new at(/\.\.\.$/,"…");new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");new at(/"$/,"”");new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");new at(/'$/,"’");function f1(n,e,t=null,r){return new at(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,u=i.tr.delete(o,l),c=u.doc.resolve(o),h=c.blockRange(),d=h&&du(h,e,a);if(!d)return null;u.wrap(h,d);let f=u.doc.resolve(o-1).nodeBefore;return f&&f.type==e&&oo(u.doc,o-1)&&(!r||r(s,f))&&u.join(o-1),u})}function d1(n,e,t=null){return new at(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}const It=typeof navigator<"u"?navigator:null,Tl=typeof document<"u"?document:null,en=It&&It.userAgent||"",Rs=/Edge\/(\d+)/.exec(en),wu=/MSIE \d/.exec(en),Ps=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(en),co=!!(wu||Ps||Rs);wu?document.documentMode:Ps?+Ps[1]:Rs&&+Rs[1];const Am=!co&&/gecko\/(\d+)/i.test(en);Am&&+(/Firefox\/(\d+)/.exec(en)||[0,0])[1];const El=!co&&/Chrome\/(\d+)/.exec(en);El&&+El[1];const Dm=!co&&!!It&&/Apple Computer/.test(It.vendor),zm=Dm&&(/Mobile\/\w+/.test(en)||!!It&&It.maxTouchPoints>2);zm||It&&/Mac/.test(It.platform);const Rm=!!Tl&&"webkitFontSmoothing"in Tl.documentElement.style;Rm&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function ss(n,e,t,r,i,s){var o;if(n.composing)return!1;const l=n.state,a=l.doc.resolve(e);if(a.parent.type.spec.code)return!1;const u=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let c=0;c<i.length;c++){const h=i[c].match.exec(u),d=h&&h[0]&&i[c].handler(l,h,e-(h[0].length-r.length),t);if(d)return((o=i[c])==null?void 0:o.undoable)!==!1&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const Pm=new uo("MILKDOWN_CUSTOM_INPUTRULES");function Fm({rules:n}){const e=new Bi({key:Pm,isInputRules:!0,state:{init(){return null},apply(t,r){const i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return ss(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&ss(t,r.pos,r.pos,"",n,e)}),!1)},handleKeyDown(t,r){if(r.key!=="Enter")return!1;const{$cursor:i}=t.state.selection;return i?ss(t,i.pos,i.pos,`
38
- `,n,e):!1}}});return e}function p1(n,e,t={}){return new at(n,(r,i,s,o)=>{var l,a,u,c;const{tr:h}=r,d=i.length;let f=i[d-1],p=i[0],y=[],k=o;const x={group:f,fullMatch:p,start:s,end:o},D=(l=t.updateCaptured)==null?void 0:l.call(t,x);if(Object.assign(x,D),{group:f,fullMatch:p,start:s,end:o}=x,p===null||(f==null?void 0:f.trim())==="")return null;if(f){const M=p.search(/\S/),B=s+p.indexOf(f),L=B+f.length;y=(a=h.storedMarks)!=null?a:[],L<o&&h.delete(L,o),B>s&&h.delete(s+M,B),k=s+M+f.length;const S=(u=t.getAttr)==null?void 0:u.call(t,i);h.addMark(s,k,e.create(S)),h.setStoredMarks(y),(c=t.beforeDispatch)==null||c.call(t,{match:i,start:s,end:o,tr:h})}return h})}function Bm(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function m1(n,e){if(!(n instanceof R))return;const{node:t,$from:r}=n;if(Bm(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const ho=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function vm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Cu=(n,e,t)=>{let r=vm(n,t);if(!r)return!1;let i=Tu(r);if(!i){let o=r.blockRange(),l=o&&so(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Ou(n,i,e,-1))return!0;if(r.parent.content.size==0&&(En(s,"end")||R.isSelectable(s)))for(let o=r.depth;;o--){let l=lo(n.doc,r.before(o),r.after(o),T.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(En(s,"end")?J.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):R.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1};function En(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Mu=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Tu(r)}let o=s&&s.nodeBefore;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Tu(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Lm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Vm=(n,e,t)=>{let r=Lm(n,t);if(!r)return!1;let i=Eu(r);if(!i)return!1;let s=i.nodeAfter;if(Ou(n,i,e,1))return!0;if(r.parent.content.size==0&&(En(s,"start")||R.isSelectable(s))){let o=lo(n.doc,r.before(),r.after(),T.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(En(s,"start")?J.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):R.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},$m=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Eu(r)}let o=s&&s.nodeAfter;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos)).scrollIntoView()),!0)};function Eu(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Wm=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
39
- `).scrollIntoView()),!0)};function fo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const qm=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=fo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(J.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},_m=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=fo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(K.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},jm=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Kr(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&so(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Jm(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!r.parentOffset||!Kr(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,u=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),u=r.start(f)==r.pos-(r.depth-f),l=fo(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),s.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof K||e.selection instanceof Oe)&&c.deleteSelection();let h=c.mapping.map(r.pos),d=Kr(c.doc,h,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Kr(c.doc,h,s.length,s)),c.split(h,s.length,s),!a&&u&&r.node(o).type!=l){let f=c.mapping.map(r.before(o)),p=c.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&c.setNodeMarkup(c.mapping.map(r.before(o)),l)}return t&&t(c.scrollIntoView()),!0}}const Hm=Jm(),Km=(n,e)=>(e&&e(n.tr.setSelection(new Oe(n.doc))),!0);function Um(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||oo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ou(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Um(n,e,t))return!0;let u=!a&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let f=e.pos+s.nodeSize,p=C.empty;for(let x=o.length-1;x>=0;x--)p=C.from(o[x].create(null,p));p=C.from(i.copy(p));let y=n.tr.step(new Ee(e.pos-1,f,e.pos,f,new T(p,1,0),o.length,!0)),k=y.doc.resolve(f+2*o.length);k.nodeAfter&&k.nodeAfter.type==i.type&&oo(y.doc,k.pos)&&y.join(k.pos),t(y.scrollIntoView())}return!0}let c=s.type.spec.isolating||r>0&&a?null:J.findFrom(e,1),h=c&&c.$from.blockRange(c.$to),d=h&&so(h);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(h,d).scrollIntoView()),!0;if(u&&En(s,"start",!0)&&En(i,"end")){let f=i,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let y=s,k=1;for(;!y.isTextblock;y=y.firstChild)k++;if(f.canReplace(f.childCount,f.childCount,y.content)){if(t){let x=C.empty;for(let M=p.length-1;M>=0;M--)x=C.from(p[M].copy(x));let D=n.tr.step(new Ee(e.pos-p.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new T(x,p.length,0),0,!0));t(D.scrollIntoView())}return!0}}return!1}function Nu(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(K.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Qm=Nu(-1),Ym=Nu(1);function g1(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&du(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function y1(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,u)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let c=t.doc.resolve(u),h=c.index();i=c.parent.canReplaceWith(h,h+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Gm(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(a,u)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function x1(n,e=null,t){return function(r,i){let{empty:s,$cursor:o,ranges:l}=r.selection;if(s&&!o||!Gm(r.doc,l,n))return!1;if(i)if(o)n.isInSet(r.storedMarks||o.marks())?i(r.tr.removeStoredMark(n)):i(r.tr.addStoredMark(n.create(e)));else{let a,u=r.tr;a=!l.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,n));for(let c=0;c<l.length;c++){let{$from:h,$to:d}=l[c];if(!a)u.removeMark(h.pos,d.pos,n);else{let f=h.pos,p=d.pos,y=h.nodeAfter,k=d.nodeBefore,x=y&&y.isText?/^\s*/.exec(y.text)[0].length:0,D=k&&k.isText?/\s*$/.exec(k.text)[0].length:0;f+x<p&&(f+=x,p-=D),u.addMark(f,p,n.create(e))}}i(u.scrollIntoView())}return!0}}function vi(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}let ls=vi(ho,Cu,Mu),Ol=vi(ho,Vm,$m);const st={Enter:vi(Wm,_m,jm,Hm),"Mod-Enter":qm,Backspace:ls,"Mod-Backspace":ls,"Shift-Backspace":ls,Delete:Ol,"Mod-Delete":Ol,"Mod-a":Km},Iu={"Ctrl-h":st.Backspace,"Alt-Backspace":st["Mod-Backspace"],"Ctrl-d":st.Delete,"Ctrl-Alt-Backspace":st["Mod-Delete"],"Alt-Delete":st["Mod-Delete"],"Alt-d":st["Mod-Delete"],"Ctrl-a":Qm,"Ctrl-e":Ym};for(let n in st)Iu[n]=st[n];const Xm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Zm=Xm?Iu:st;var At={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},bi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eg=typeof navigator<"u"&&/Mac/.test(navigator.platform),tg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ue=0;ue<10;ue++)At[48+ue]=At[96+ue]=String(ue);for(var ue=1;ue<=24;ue++)At[ue+111]="F"+ue;for(var ue=65;ue<=90;ue++)At[ue]=String.fromCharCode(ue+32),bi[ue]=String.fromCharCode(ue);for(var as in At)bi.hasOwnProperty(as)||(bi[as]=At[as]);function ng(n){var e=eg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||tg&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?bi:At)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const rg=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ig(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!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))s=!0;else if(/^mod$/i.test(a))rg?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function sg(n){let e=Object.create(null);for(let t in n)e[ig(t)]=n[t];return e}function us(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function og(n){return new Bi({props:{handleKeyDown:lg(n)}})}function lg(n){let e=sg(n);return function(t,r){let i=ng(r),s,o=e[us(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[us(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=At[r.keyCode])&&s!=i){let l=e[us(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ce=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},yr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Fs=null;const it=function(n,e,t){let r=Fs||(Fs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},ag=function(){Fs=null},Xt=function(n,e,t,r){return t&&(Nl(n,e,t,r,-1)||Nl(n,e,t,r,1))},ug=/^(img|br|input|textarea|hr)$/i;function Nl(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ze(n))){let s=n.parentNode;if(!s||s.nodeType!=1||wr(n)||ug.test(n.nodeName)||n.contentEditable=="false")return!1;e=ce(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?ze(n):0}else return!1}}function ze(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function cg(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ze(n)}else if(n.parentNode&&!wr(n))e=ce(n),n=n.parentNode;else return null}}function hg(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!wr(n))e=ce(n)+1,n=n.parentNode;else return null}}function fg(n,e,t){for(let r=e==0,i=e==ze(n);r||i;){if(n==t)return!0;let s=ce(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==ze(n)}}function wr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Li=function(n){return n.focusNode&&Xt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function _t(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function dg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pg(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ze(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ze(r.startContainer),r.startOffset)}}}const Ye=typeof navigator<"u"?navigator:null,Il=typeof document<"u"?document:null,Rt=Ye&&Ye.userAgent||"",Bs=/Edge\/(\d+)/.exec(Rt),Au=/MSIE \d/.exec(Rt),vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Rt),Se=!!(Au||vs||Bs),Ct=Au?document.documentMode:vs?+vs[1]:Bs?+Bs[1]:0,_e=!Se&&/gecko\/(\d+)/i.test(Rt);_e&&+(/Firefox\/(\d+)/.exec(Rt)||[0,0])[1];const Ls=!Se&&/Chrome\/(\d+)/.exec(Rt),pe=!!Ls,Du=Ls?+Ls[1]:0,ge=!Se&&!!Ye&&/Apple Computer/.test(Ye.vendor),On=ge&&(/Mobile\/\w+/.test(Rt)||!!Ye&&Ye.maxTouchPoints>2),Ae=On||(Ye?/Mac/.test(Ye.platform):!1),mg=Ye?/Win/.test(Ye.platform):!1,ot=/Android \d/.test(Rt),Cr=!!Il&&"webkitFontSmoothing"in Il.documentElement.style,gg=Cr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yg(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function nt(n,e){return typeof n=="number"?n:n[e]}function xg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Al(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=yr(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,u=a?yg(s):xg(l),c=0,h=0;if(e.top<u.top+nt(r,"top")?h=-(u.top-e.top+nt(i,"top")):e.bottom>u.bottom-nt(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+nt(i,"top")-u.top:e.bottom-u.bottom+nt(i,"bottom")),e.left<u.left+nt(r,"left")?c=-(u.left-e.left+nt(i,"left")):e.right>u.right-nt(r,"right")&&(c=e.right-u.right+nt(i,"right")),c||h)if(a)s.defaultView.scrollBy(c,h);else{let d=l.scrollLeft,f=l.scrollTop;h&&(l.scrollTop+=h),c&&(l.scrollLeft+=c);let p=l.scrollLeft-d,y=l.scrollTop-f;e={left:e.left-p,top:e.top-y,right:e.right-p,bottom:e.bottom-y}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function kg(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:zu(n.dom)}}function zu(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=yr(r));return e}function bg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Ru(t,r==0?0:r-e)}function Ru(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let sn=null;function Sg(n){if(n.setActive)return n.setActive();if(sn)return n.focus(sn);let e=zu(n);n.focus(sn==null?{get preventScroll(){return sn={preventScroll:!0},!0}}:void 0),sn||(sn=!1,Ru(e,0))}function Pu(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,u;for(let c=n.firstChild,h=0;c;c=c.nextSibling,h++){let d;if(c.nodeType==1)d=c.getClientRects();else if(c.nodeType==3)d=it(c).getClientRects();else continue;for(let f=0;f<d.length;f++){let p=d[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),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){t=c,r=y,i=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,c.nodeType==1&&y&&(s=h+(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=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=h+1)}}return!t&&a&&(t=a,i=u,r=0),t&&t.nodeType==3?wg(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Pu(t,i)}function wg(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=mt(r,1);if(s.top!=s.bottom&&po(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function po(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Cg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Mg(n,e,t){let{node:r,offset:i}=Pu(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Tg(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!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;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Fu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let u=l[a];if(po(e,u))return Fu(o,e,u)}}if((s=(s+1)%r)==i)break}return n}function Eg(n,e){let t=n.dom.ownerDocument,r,i=0,s=pg(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=n.dom.getBoundingClientRect();if(!po(e,u)||(o=Fu(n.dom,e,u),!o))return null}if(ge)for(let u=o;r&&u;u=yr(u))u.draggable&&(r=void 0);if(o=Cg(o,e),r){if(_e&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let c=r.childNodes[i],h;c.nodeName=="IMG"&&(h=c.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let u;Cr&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Tg(n,r,i,e))}l==null&&(l=Mg(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Dl(n){return n.top<n.bottom||n.left<n.right}function mt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Dl(r))return r}return Array.prototype.find.call(t,Dl)||n.getBoundingClientRect()}const Og=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Bu(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Cr||_e;if(r.nodeType==3)if(o&&(Og.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=mt(it(r,i,i),t);if(_e&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=mt(it(r,i-1,i-1),-1);if(u.top==a.top){let c=mt(it(r,i,i+1),-1);if(c.top!=a.top)return Pn(c,c.left<u.left)}}return a}else{let a=i,u=i,c=t<0?1:-1;return t<0&&!i?(u++,c=-1):t>=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,Pn(mt(it(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==ze(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!0)}return cs(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==ze(r))){let a=r.childNodes[i-1],u=a.nodeType==3?it(a,ze(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Pn(mt(u,1),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?a.nodeType==3?it(a,0,o?0:1):a.nodeType==1?a:null:null;if(u)return Pn(mt(u,-1),!0)}return Pn(mt(r.nodeType==3?it(r):r,-t),t>=0)}function Pn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function cs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function vu(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Ng(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return vu(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Bu(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=it(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}const Ig=/[\u0590-\u08ac]/;function Ag(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!Ig.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:vu(n,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:h}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let f=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),k=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&u==y;try{l.collapse(c,h),a&&(a!=c||u!=h)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),k}):r.pos==r.start()||r.pos==r.end()}let zl=null,Rl=null,Pl=!1;function Dg(n,e,t){return zl==e&&Rl==t?Pl:(zl=e,Rl=t,Pl=t=="up"||t=="down"?Ng(n,e,t):Ag(n,e,t))}const Re=0,Fl=1,jt=2,Ge=3;class Mr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Re,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].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 t=0,r=this.posAtStart;;t++){let i=this.children[t];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,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>ce(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(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Vu){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Lu&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ce(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ce(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],u=o+a.size;if(i==-1&&e<=u){let c=o+a.border;if(e>=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ce(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;c<this.children.length;c++){let h=this.children[c];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=ce(h.dom);break}t+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let y=this.children[f],k=p+y.size;if(s>p&&o<k)return y.setSelection(e-p-y.border,t-p-y.border,r,i);p=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),u=r.root.getSelection(),c=r.domSelectionRange(),h=!1;if((_e||ge)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
40
- `),h&&p==f.nodeValue.length)for(let y=f,k;y;y=y.parentNode){if(k=y.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:ce(k)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=f.childNodes[p-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(_e&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||h&&ge)&&Xt(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Xt(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((u.extend||e==t)&&!h){u.collapse(l.node,l.offset);try{e!=t&&u.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?jt:Fl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Ge:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?jt:Ge}r=o}this.dirty=jt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?jt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Lu extends Mr{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Re&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(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 side(){return this.widget.type.side}}class zg extends Mr{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Zt extends Mr{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=In.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Zt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ge||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ge&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Re){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Re}}slice(e,t,r){let i=Zt.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=$s(s,t,o,r)),e>0&&(s=$s(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Mt extends Mr{constructor(e,t,r,i,s,o,l,a,u){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,u=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,h=u&&u.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:h}=In.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=qu(c,r,t),u?a=new Rg(e,t,r,i,c,h||null,d,u,s,o+1):t.isText?new Vi(e,t,r,i,c,d,s):new Mt(e,t,r,i,c,h||null,d,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==Re&&e.eq(this.node)&&Si(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Fg(this,o&&o.node,e);Lg(this.node,this.innerDeco,(u,c,h)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!h&&a.syncToMarks(c==this.node.childCount?$.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,h,d)=>{a.syncToMarks(u.marks,r,e);let f;a.findNodeMatch(u,c,h,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(f=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(u,c,h,f,e)||a.updateNextNode(u,c,h,e,d,i)||a.addNode(u,c,h,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==jt)&&(o&&this.protectLocalComposition(e,o),$u(this.contentDOM,this.children,e),On&&Vg(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof K)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=$g(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new zg(this,s,t,i);e.input.compositionNodes.push(o),this.children=$s(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Ge||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Re}updateOuterDeco(e){if(Si(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Wu(this.dom,this.nodeDOM,Vs(this.outerDeco,this.node,t),Vs(e,this.node,t)),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.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Bl(n,e,t,r,i){qu(r,e,n);let s=new Mt(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Vi extends Mt{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Ge||this.dirty!=Re&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Re||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=Re,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Vi(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ge)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Vu extends Mr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Re&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Rg extends Mt{constructor(e,t,r,i,s,o,l,a,u,c){super(e,t,r,i,s,o,l,u,c),this.spec=a}update(e,t,r,i){if(this.dirty==Ge)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,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 $u(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=vl(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof Zt){let a=r?r.previousSibling:n.lastChild;$u(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=vl(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const sr=function(n){n&&(this.nodeName=n)};sr.prototype=Object.create(null);const Jt=[new sr];function Vs(n,e,t){if(n.length==0)return Jt;let r=t?Jt[0]:new sr,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new sr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new sr(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 Wu(n,e,t,r){if(t==Jt&&r==Jt)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Jt[0]),i=a}Pg(i,l||Jt[0],o)}return i}function Pg(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function qu(n,e,t){return Wu(n,n,Jt,Vs(e,t,n.nodeType!=1))}function Si(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function vl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Fg{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Bg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Re,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let u=this.top.children[a];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Zt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let u=this.top.children[l];if(u.matchesNode(e,t,r)&&!this.preMatch.matched.has(u)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==Ge&&o.dom==o.contentDOM&&(o.dirty=jt),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==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=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Mt){let u=this.preMatch.matched.get(a);if(u!=null&&u!=s)return!1;let c=a.dom,h,d=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ge&&Si(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=jt,h.updateChildren(i,o+1),h.dirty=Re),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Si(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Mt.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=Mt.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,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 s=new Lu(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Zt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Vi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ge||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.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 Vu(this.top,[],r,null);t!=this.top?t.children.push(i):t.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 Bg(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=t.children[r-1];if(u instanceof Zt)t=u,r=u.children.length;else{l=u,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function vg(n,e){return n.type.side-e.type.side}function Lg(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let u=0;u<n.childCount;u++){let c=n.child(u);r(c,i,e.forChild(s,c),u),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let u=0;;){let c,h;for(;o<i.length&&i[o].to==s;){let k=i[o++];k.widget&&(c?(h||(h=[c])).push(k):c=k)}if(c)if(h){h.sort(vg);for(let k=0;k<h.length;k++)t(h[k],u,!!a)}else t(c,u,!!a);let d,f;if(a)f=-1,d=a,a=null;else if(u<n.childCount)f=u,d=n.child(u++);else break;for(let k=0;k<l.length;k++)l[k].to<=s&&l.splice(k--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+d.nodeSize;if(d.isText){let k=p;o<i.length&&i[o].from<k&&(k=i[o].from);for(let x=0;x<l.length;x++)l[x].to<k&&(k=l[x].to);k<p&&(a=d.cut(k-s),d=d.cut(0,k-s),p=k,f=-1)}else for(;o<i.length&&i[o].to<p;)o++;let y=d.isInline&&!d.isLeaf?l.filter(k=>!k.inline):l.slice();r(d,y,e.forChild(s,d),f),s=p}}function Vg(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function $g(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let u=n.child(i++);if(s+=u.nodeSize,!u.isText)break;a+=u.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?a.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=t)return l+u;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function $s(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],u=l,c=l+=a.size;u>=t||c<=e?s.push(a):(u<e&&s.push(a.slice(0,e-u,r)),i&&(s.push(i),i=void 0),c>t&&s.push(a.slice(t-u,a.size,r)))}return s}function mo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(Li(t)){for(a=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&R.isSelectable(h)&&i.parent&&!(h.isInline&&fg(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;u=new R(o==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,d=o;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,o]=d==n.state.selection.anchor?[d,h]:[h,d],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!u){let h=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;u=go(n,c,l,h)}return u}function _u(n){return n.editable?n.hasFocus():Ju(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function lt(n,e=!1){let t=n.state.selection;if(ju(n,t),!!_u(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Xt(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)qg(n);else{let{anchor:r,head:i}=t,s,o;Ll&&!(t instanceof K)&&(t.$from.parent.inlineContent||(s=Vl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Vl(n,t.to))),n.docView.setSelection(r,i,n,e),Ll&&(s&&$l(s),o&&$l(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Wg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ll=ge||pe&&Du<63;function Vl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ge&&i&&i.contentEditable=="false")return hs(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return hs(i);if(s)return hs(s)}}function hs(n){return n.contentEditable="true",ge&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function $l(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Wg(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!_u(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function qg(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,ce(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Se&&Ct<=11&&(r.disabled=!0,r.disabled=!1)}function ju(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Wl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Wl(n)}function Wl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function go(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||K.between(e,t,r)}function ql(n){return n.editable&&!n.hasFocus()?!1:Ju(n)}function Ju(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function _g(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Xt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ws(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&J.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function _l(n,e,t){let r=n.state.selection;if(r instanceof K)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return xt(n,new K(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Ws(n.state,e);return i&&i instanceof R?xt(n,i):!1}else if(!(Ae&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?R.isSelectable(s)?xt(n,new R(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Cr?xt(n,new K(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof R&&r.node.isInline)return xt(n,new K(e>0?r.$to:r.$from));{let i=Ws(n.state,e);return i?xt(n,i):!1}}}function wi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function or(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function on(n,e){return e<0?jg(n):Jg(n)}function jg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(_e&&t.nodeType==1&&r<wi(t)&&or(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(or(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Hu(t))break;{let l=t.previousSibling;for(;l&&or(l,-1);)i=t.parentNode,s=ce(l),l=l.previousSibling;if(l)t=l,r=wi(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?qs(n,t,r):i&&qs(n,i,s)}function Jg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=wi(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(or(l,1))s=t,o=++r;else break}else{if(Hu(t))break;{let l=t.nextSibling;for(;l&&or(l,1);)s=l.parentNode,o=ce(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=wi(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&qs(n,s,o)}function Hu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Hg(n,e){for(;n&&e==n.childNodes.length&&!wr(n);)e=ce(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Kg(n,e){for(;n&&!e&&!wr(n);)e=ce(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function qs(n,e,t){if(e.nodeType!=3){let s,o;(o=Hg(e,t))?(e=o,t=0):(s=Kg(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Li(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&lt(n)},50)}function jl(n,e){let t=n.state.doc.resolve(e);if(!(pe||mg)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Jl(n,e,t){let r=n.state.selection;if(r instanceof K&&!r.empty||t.indexOf("s")>-1||Ae&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ws(n.state,e);if(o&&o instanceof R)return xt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Oe?J.near(o,e):J.findFrom(o,e);return l?xt(n,l):!1}return!1}function Hl(n,e){if(!(n.state.selection instanceof K))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Kl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ug(n){if(!ge||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Kl(n,r,"true"),setTimeout(()=>Kl(n,r,"false"),20)}return!1}function Qg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Yg(n,e){let t=e.keyCode,r=Qg(e);if(t==8||Ae&&t==72&&r=="c")return Hl(n,-1)||on(n,-1);if(t==46&&!e.shiftKey||Ae&&t==68&&r=="c")return Hl(n,1)||on(n,1);if(t==13||t==27)return!0;if(t==37||Ae&&t==66&&r=="c"){let i=t==37?jl(n,n.state.selection.from)=="ltr"?-1:1:-1;return _l(n,i,r)||on(n,i)}else if(t==39||Ae&&t==70&&r=="c"){let i=t==39?jl(n,n.state.selection.from)=="ltr"?1:-1:1;return _l(n,i,r)||on(n,i)}else{if(t==38||Ae&&t==80&&r=="c")return Jl(n,-1,r)||on(n,-1);if(t==40||Ae&&t==78&&r=="c")return Ug(n)||Jl(n,1,r)||on(n,1);if(r==(Ae?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function yo(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=n.someProp("clipboardSerializer")||In.fromSchema(n.state.schema),l=Xu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=Gu[u.nodeName.toLowerCase()]);){for(let f=c.length-1;f>=0;f--){let p=l.createElement(c[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
41
-
42
- `);return{dom:a,text:d,slice:e}}function Ku(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new T(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
43
- `))),0,0):T.empty;let h=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(h)l=h;else{let d=i.marks(),{schema:f}=n.state,p=In.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let k=o.appendChild(document.createElement("p"));y&&k.appendChild(p.serializeNode(f.text(y,d)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=ey(t),Cr&&ty(o);let u=o&&o.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let h=+c[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Cn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Gg.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=ny(Ul(l,+c[1],+c[2]),c[4]);else if(l=T.maxOpen(Xg(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;d<l.openEnd&&!f.type.spec.isolating;d++,f=f.lastChild);l=Ul(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const Gg=/^(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 Xg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&s.length&&Qu(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Yu(o[o.length-1],s.length));let c=Uu(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return C.from(o)}return n}function Uu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function Qu(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Qu(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(C.from(Uu(t,n,i+1))))}}function Yu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Yu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function _s(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=_s(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ul(n,e,t){return e<n.openStart&&(n=new T(_s(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new T(_s(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Gu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ql=null;function Xu(){return Ql||(Ql=document.implementation.createHTMLDocument("title"))}let fs=null;function Zg(n){let e=window.trustedTypes;return e?(fs||(fs=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),fs.createHTML(n)):n}function ey(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Xu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Gu[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Zg(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function ty(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function ny(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=C.from(a.create(r[l+1],i)),s++,o++}return new T(i,s,o)}const ye={},xe={},ry={touchstart:!0,touchmove:!0};class iy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function sy(n){for(let e in ye){let t=ye[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{ly(n,r)&&!xo(n,r)&&(n.editable||!(r.type in xe))&&t(n,r)},ry[e]?{passive:!0}:void 0)}ge&&n.dom.addEventListener("input",()=>null),js(n)}function wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function oy(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function js(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>xo(n,r))})}function xo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function ly(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ay(n,e){!xo(n,e)&&ye[e.type]&&(n.editable||!(e.type in xe))&&ye[e.type](n,e)}xe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!ec(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ot&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),On&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,_t(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Yg(n,t)?t.preventDefault():wt(n,"key")};xe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};xe.keypress=(n,e)=>{let t=e;if(ec(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ae&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof K)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function $i(n){return{left:n.clientX,top:n.clientY}}function uy(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ko(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function bn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function cy(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(bn(n,new R(t)),!0):!1}function hy(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof R&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(R.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(bn(n,R.create(n.state.doc,i)),!0):!1}function fy(n,e,t,r,i){return ko(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?hy(n,t):cy(n,t))}function dy(n,e,t,r){return ko(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function py(n,e,t,r){return ko(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||my(n,t,r)}function my(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(bn(n,K.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)bn(n,K.create(r,l+1,l+1+o.content.size));else if(R.isSelectable(o))bn(n,R.create(r,l));else continue;return!0}}function bo(n){return Ci(n)}const Zu=Ae?"metaKey":"ctrlKey";ye.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=bo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&uy(t,n.input.lastClick)&&!t[Zu]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords($i(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new gy(n,o,t,!!r)):(s=="doubleClick"?dy:py)(n,o.pos,o.inside,t)?t.preventDefault():wt(n,"pointer"))};class gy{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Zu],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof R&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_e&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),wt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>lt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords($i(e))),this.updateAllowDefault(e),this.allowDefault||!t?wt(this.view,"pointer"):fy(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ge&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(bn(this.view,J.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):wt(this.view,"pointer")}move(e){this.updateAllowDefault(e),wt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ye.touchstart=n=>{n.input.lastTouch=Date.now(),bo(n),wt(n,"pointer")};ye.touchmove=n=>{n.input.lastTouch=Date.now(),wt(n,"pointer")};ye.contextmenu=n=>bo(n);function ec(n,e){return n.composing?!0:ge&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const yy=ot?5e3:-1;xe.compositionstart=xe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof K&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ci(n,!0),n.markCursor=null;else if(Ci(n,!e.selection.empty),_e&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}tc(n,yy)};xe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,tc(n,20))};function tc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ci(n),e))}function nc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ky());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function xy(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=cg(e.focusNode,e.focusOffset),r=hg(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function ky(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ci(n,e=!1){if(!(ot&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),nc(n),e||n.docView&&n.docView.dirty){let t=mo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function by(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const xr=Se&&Ct<15||On&&gg<604;ye.copy=xe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=xr?null:t.clipboardData,o=r.content(),{dom:l,text:a}=yo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):by(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Sy(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function wy(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?kr(n,r.value,null,i,e):kr(n,r.textContent,r.innerHTML,i,e)},50)}function kr(n,e,t,r,i){let s=Ku(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||T.empty)))return!0;if(!s)return!1;let o=Sy(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function rc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}xe.paste=(n,e)=>{let t=e;if(n.composing&&!ot)return;let r=xr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&kr(n,rc(r),r.getData("text/html"),i,t)?t.preventDefault():wy(n,t)};class ic{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const sc=Ae?"altKey":"ctrlKey";ye.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords($i(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof R?i.to-1:i.to))){if(r&&r.mightDrag)o=R.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=R.create(n.state.doc,h.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:u,slice:c}=yo(n,l);(!t.dataTransfer.files.length||!pe||Du>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(xr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",xr||t.dataTransfer.setData("text/plain",u),n.dragging=new ic(c,!t[sc],o)};ye.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};xe.dragover=xe.dragenter=(n,e)=>e.preventDefault();xe.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords($i(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=Ku(n,rc(t.dataTransfer),xr?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[sc]);if(n.someProp("handleDrop",p=>p(n,t,o||T.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?gm(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let u=n.state.tr;if(l){let{node:p}=r;p?p.replace(u):u.deleteSelection()}let c=u.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=u.doc;if(h?u.replaceRangeWith(c,c,o.content.firstChild):u.replaceRange(c,c,o),u.doc.eq(d))return;let f=u.doc.resolve(c);if(h&&R.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new R(f));else{let p=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((y,k,x,D)=>p=D),u.setSelection(go(n,f,u.doc.resolve(p)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};ye.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&lt(n)},20))};ye.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ye.beforeinput=(n,e)=>{if(pe&&ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,_t(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in xe)ye[n]=xe[n];function br(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Mi{constructor(e,t){this.toDOM=e,this.spec=t||Ut,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new We(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Mi&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&br(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Tt{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new We(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Tt&&br(this.attrs,e.attrs)&&br(this.spec,e.spec)}static is(e){return e.type instanceof Tt}destroy(){}}class So{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new We(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof So&&br(this.attrs,e.attrs)&&br(this.spec,e.spec)}destroy(){}}class We{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new We(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new We(e,e,new Mi(t,r))}static inline(e,t,r,i){return new We(e,t,new Tt(r,i))}static node(e,t,r,i){return new We(e,t,new So(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Tt}get widget(){return this.type instanceof Mi}}const hn=[],Ut={};class ie{constructor(e,t){this.local=e.length?e:hn,this.children=t.length?t:hn}static create(e,t){return t.length?Ti(t,e,0,Ut):fe}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==fe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ut)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Cy(this.children,o||[],e,t,r,i,s):o?new ie(o.sort(Qt),hn):fe}add(e,t){return t.length?this==fe?ie.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let u=a+r,c;if(c=lc(t,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,c,u+1):i.splice(s,0,a,a+l.nodeSize,Ti(c,l,u+1,Ut)),s+=3}});let o=oc(s?ac(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ie(o.length?this.local.concat(o).sort(Qt):this.local,i||this.children)}remove(e){return e.length==0||this==fe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let c=0,h;c<e.length;c++)(h=e[c])&&h.from>l&&h.to<a&&(e[c]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=fe?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ie(i,r):fe}forChild(e,t){if(this==fe)return this;if(t.isLeaf)return ie.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 s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Tt){let u=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;u<c&&(i||(i=[])).push(a.copy(u,c))}}if(i){let l=new ie(i.sort(Qt),hn);return r?new kt([l,r]):l}return r||fe}eq(e){if(this==e)return!0;if(!(e instanceof ie)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return wo(this.localsInner(e))}localsInner(e){if(this==fe)return hn;if(e.inlineContent||!this.local.some(Tt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Tt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ie.empty=new ie([],[]);ie.removeOverlap=wo;const fe=ie.empty;class kt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Ut));return kt.from(r)}forChild(e,t){if(t.isLeaf)return ie.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=fe&&(s instanceof kt?r=r.concat(s.members):r.push(s))}return kt.from(r)}eq(e){if(!(e instanceof kt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?wo(r?t:t.sort(Qt)):hn}static from(e){switch(e.length){case 0:return fe;case 1:return e[0];default:return new kt(e.every(t=>t instanceof ie)?e:e.reduce((t,r)=>t.concat(r instanceof ie?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cy(n,e,t,r,i,s,o){let l=n.slice();for(let u=0,c=s;u<t.maps.length;u++){let h=0;t.maps[u].forEach((d,f,p,y)=>{let k=y-p-(f-d);for(let x=0;x<l.length;x+=3){let D=l[x+1];if(D<0||d>D+c-h)continue;let M=l[x]+c-h;f>=M?l[x+1]=d<=M?-2:-1:d>=c&&k&&(l[x]+=k,l[x+1]+=k)}h+=k}),c=t.maps[u].map(c,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let c=t.map(n[u]+s),h=c-i;if(h<0||h>=r.content.size){a=!0;continue}let d=t.map(n[u+1]+s,-1),f=d-i,{index:p,offset:y}=r.content.findIndex(h),k=r.maybeChild(p);if(k&&y==h&&y+k.nodeSize==f){let x=l[u+2].mapInner(t,k,c+1,n[u]+s+1,o);x!=fe?(l[u]=h,l[u+1]=f,l[u+2]=x):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=My(l,n,e,t,i,s,o),c=Ti(u,r,0,o);e=c.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<c.children.length;h+=3){let f=c.children[h];for(;d<l.length&&l[d]<f;)d+=3;l.splice(d,0,c.children[h],c.children[h+1],c.children[h+2])}}return new ie(e.sort(Qt),l)}function oc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new We(i.from+e,i.to+e,i.type))}return t}function My(n,e,t,r,i,s,o){function l(a,u){for(let c=0;c<a.local.length;c++){let h=a.local[c].map(r,i,u);h?t.push(h):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+u+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function lc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function ac(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ti(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let u=lc(n,l,a+t);if(u){s=!0;let c=Ti(u,l,t+a+1,r);c!=fe&&i.push(a,a+l.nodeSize,c)}});let o=oc(s?ac(n):n,-t).sort(Qt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ie(o,i):fe}function Qt(n,e){return n.from-e.from||n.to-e.to}function wo(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Yl(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Yl(e,i,r.copy(s.from,r.to)));break}}}return e}function Yl(n,e,t){for(;e<n.length&&Qt(t,n[e])>0;)e++;n.splice(e,0,t)}function ds(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=fe&&e.push(r)}),n.cursorWrapper&&e.push(ie.create(n.state.doc,[n.cursorWrapper.deco])),kt.from(e)}const Ty={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ey=Se&&Ct<=11;class Oy{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}}class Ny{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Oy,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]);Se&&Ct<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Ey&&(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,Ty)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(ql(this.view)){if(this.suppressingSelectionUpdates)return lt(this.view);if(Se&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xt(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 t=new Set,r;for(let s=e.focusNode;s;s=yr(s))t.add(s);for(let s=e.anchorNode;s;s=yr(s))if(t.has(s)){r=s;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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ql(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let h=this.registerMutation(t[c],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(_e&&a.length){let c=a.filter(h=>h.nodeName=="BR");if(c.length==2){let[h,d]=c;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of c){let f=d.parentNode;f&&f.nodeName=="LI"&&(!h||Dy(e,h)!=f)&&d.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Li(r)&&(u=mo(e))&&u.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,lt(e),this.currentSelection.set(r)):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Iy(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||lt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.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 c=0;c<e.addedNodes.length;c++){let h=e.addedNodes[c];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Se&&Ct<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:h,nextSibling:d}=e.addedNodes[c];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?ce(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?ce(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,a,1);return{from:l,to:u}}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})}}let Gl=new WeakMap,Xl=!1;function Iy(n){if(!Gl.has(n)&&(Gl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=_e,Xl)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."),Xl=!0}}function Zl(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Xt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Ay(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Zl(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Zl(n,t):null}function Dy(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function zy(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),u,c=a.anchorNode;if(c&&n.dom.contains(c.nodeType==1?c:c.parentNode)&&(u=[{node:c,offset:a.anchorOffset}],Li(a)||u.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let x=r.childNodes[k-1],D=x.pmViewDesc;if(x.nodeName=="BR"&&!D){s=k;break}if(!D||D.size)break}let h=n.state.doc,d=n.someProp("domParser")||Cn.fromSchema(n.state.schema),f=h.resolve(o),p=null,y=d.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:s,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Ry,context:f});if(u&&u[0].pos!=null){let k=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=k),p={anchor:k+o,head:x+o}}return{doc:y,sel:p,from:o,to:l}}function Ry(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ge&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ge&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Py=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Fy(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,V=mo(n,E);if(V&&!n.state.selection.eq(V)){if(pe&&ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,_t(13,"Enter"))))return;let N=n.state.tr.setSelection(V);E=="pointer"?N.setMeta("pointer",!0):E=="key"&&N.scrollIntoView(),s&&N.setMeta("composition",s),n.dispatch(N)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,u=zy(n,e,t),c=n.state.doc,h=c.slice(u.from,u.to),d,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,f="end"):(d=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=Ly(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(On&&n.input.lastIOSEnter>Date.now()-225||ot)&&i.some(E=>E.nodeType==1&&!Py.test(E.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",E=>E(n,_t(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof K&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let E=ea(n,n.state.doc,u.sel);if(E&&!E.eq(n.state.selection)){let V=n.state.tr.setSelection(E);s&&V.setMeta("composition",s),n.dispatch(V)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof K&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Se&&Ct<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let y=u.doc.resolveNoCache(p.start-u.from),k=u.doc.resolveNoCache(p.endB-u.from),x=c.resolve(p.start),D=y.sameParent(k)&&y.parent.inlineContent&&x.end()>=p.endA,M;if((On&&n.input.lastIOSEnter>Date.now()-225&&(!D||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!D&&y.pos<u.doc.content.size&&!y.sameParent(k)&&(M=J.findFrom(u.doc.resolve(y.pos+1),1,!0))&&M.head==k.pos)&&n.someProp("handleKeyDown",E=>E(n,_t(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&vy(c,p.start,p.endA,y,k)&&n.someProp("handleKeyDown",E=>E(n,_t(8,"Backspace")))){ot&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ot&&!D&&y.start()!=k.start()&&k.parentOffset==0&&y.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA&&(p.endB-=2,k=u.doc.resolveNoCache(p.endB-u.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,_t(13,"Enter"))})},20));let B=p.start,L=p.endA,S,q,Y;if(D){if(y.pos==k.pos)Se&&Ct<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>lt(n),20)),S=n.state.tr.delete(B,L),q=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(Y=By(y.parent.content.cut(y.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))S=n.state.tr,Y.type=="add"?S.addMark(B,L,Y.mark):S.removeMark(B,L,Y.mark);else if(y.parent.child(y.index()).isText&&y.index()==k.index()-(k.textOffset?0:1)){let E=y.parent.textBetween(y.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",V=>V(n,B,L,E)))return;S=n.state.tr.insertText(E,B,L)}}if(S||(S=n.state.tr.replace(B,L,u.doc.slice(p.start-u.from,p.endB-u.from))),u.sel){let E=ea(n,S.doc,u.sel);E&&!(pe&&n.composing&&E.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(E.head==B||E.head==S.mapping.map(L)-1)||Se&&E.empty&&E.head==B)&&S.setSelection(E)}q&&S.ensureMarks(q),s&&S.setMeta("composition",s),n.dispatch(S.scrollIntoView())}function ea(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:go(n,e.resolve(t.anchor),e.resolve(t.head))}function By(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let c=0;c<r.length;c++)i=r[c].removeFromSet(i);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<e.childCount;c++)u.push(a(e.child(c)));if(C.from(u).eq(n))return{mark:l,type:o}}function vy(n,e,t,r,i){if(t-e<=i.pos-r.pos||ps(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(ps(s,!0,!0));return!o.parent.isTextblock||o.pos>t||ps(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ps(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Ly(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&ta(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&ta(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function ta(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Vy{constructor(e,t){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 iy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(oa),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=ia(this),ra(this),this.nodeViews=sa(this),this.docView=Bl(this.state.doc,na(this),ds(this),this.dom,this),this.domObserver=new Ny(this,(r,i,s,o)=>Fy(this,r,i,s,o)),this.domObserver.start(),sy(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&js(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(oa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(nc(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=sa(this);Wy(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&js(this),this.editable=ia(this),ra(this);let a=ds(this),u=na(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,u,a);(h||!e.selection.eq(i.selection))&&(o=!0);let d=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&kg(this);if(o){this.domObserver.stop();let f=h&&(Se||pe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&$y(i.selection,e.selection);if(h){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=xy(this)),(s||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Bl(e.doc,u,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_g(this))?lt(this,f):(ju(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),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&bg(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Al(this,t.getBoundingClientRect(),e)}else Al(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new ic(e.slice,e.move,i<0?void 0:R.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(Se){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&&Sg(this.dom),lt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Eg(this,e)}coordsAtPos(e,t=1){return Bu(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Dg(this,t||this.state,e)}pasteHTML(e,t){return kr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return kr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return yo(this,e)}destroy(){this.docView&&(oy(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ds(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ag())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ay(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ge&&this.root.nodeType===11&&dg(this.dom.ownerDocument)==this.dom&&Ay(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function na(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[We.node(0,n.state.doc.content.size,e)]}function ra(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:We.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ia(n){return!n.someProp("editable",e=>e(n.state)===!1)}function $y(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function sa(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Wy(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function oa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var uc=n=>{throw TypeError(n)},cc=(n,e,t)=>e.has(n)||uc("Cannot "+t),A=(n,e,t)=>(cc(n,e,"read from private field"),t?t.call(n):e.get(n)),le=(n,e,t)=>e.has(n)?uc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Z=(n,e,t,r)=>(cc(n,e,"write to private field"),e.set(n,t),t);function Pt(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}const hc={strong:(n,e,t,r)=>{const i=n.marker||t.options.strong||"*",s=t.enter("strong"),o=t.createTracker(r);let l=o.move(i+i);return l+=o.move(t.containerPhrasing(n,{before:l,after:i,...o.current()})),l+=o.move(i+i),s(),l},emphasis:(n,e,t,r)=>{const i=n.marker||t.options.emphasis||"*",s=t.enter("emphasis"),o=t.createTracker(r);let l=o.move(i);return l+=o.move(t.containerPhrasing(n,{before:l,after:i,...o.current()})),l+=o.move(i),s(),l}},lr=H({},"editorView"),yn=H({},"editorState"),Ur=H([],"initTimer"),Js=H({},"editor"),Ei=H([],"inputRules"),Nn=H([],"prosePlugins"),Oi=H([],"remarkPlugins"),Ni=H([],"nodeView"),Ii=H([],"markView"),Et=H(Os().use(Ss).use(Ms),"remark"),Qr=H({handlers:hc},"remarkStringifyOptions"),ar=Dt("ConfigReady");function fc(n){const e=t=>(t.record(ar),async()=>(await n(t),t.done(ar),()=>{t.clearTimer(ar)}));return Pt(e,{displayName:"Config"}),e}const Sn=Dt("InitReady");function dc(n){const e=t=>(t.inject(Js,n).inject(Nn,[]).inject(Oi,[]).inject(Ei,[]).inject(Ni,[]).inject(Ii,[]).inject(Qr,{handlers:hc}).inject(Et,Os().use(Ss).use(Ms)).inject(Ur,[ar]).record(Sn),async()=>{await t.waitTimers(Ur);const r=t.get(Qr);return t.set(Et,Os().use(Ss).use(Ms,r)),t.done(Sn),()=>{t.remove(Js).remove(Nn).remove(Oi).remove(Ei).remove(Ni).remove(Ii).remove(Qr).remove(Et).remove(Ur).clearTimer(Sn)}});return Pt(e,{displayName:"Init"}),e}const Ot=Dt("SchemaReady"),Yr=H([],"schemaTimer"),Yt=H({},"schema"),Gr=H([],"nodes"),Xr=H([],"marks");function la(n){var e;return{...n,parseDOM:(e=n.parseDOM)==null?void 0:e.map(t=>({priority:n.priority,...t}))}}const Co=n=>(n.inject(Yt,{}).inject(Gr,[]).inject(Xr,[]).inject(Yr,[Sn]).record(Ot),async()=>{await n.waitTimers(Yr);const e=n.get(Et),t=n.get(Oi).reduce((o,l)=>o.use(l.plugin,l.options),e);n.set(Et,t);const r=Object.fromEntries(n.get(Gr).map(([o,l])=>[o,la(l)])),i=Object.fromEntries(n.get(Xr).map(([o,l])=>[o,la(l)])),s=new ah({nodes:r,marks:i});return n.set(Yt,s),n.done(Ot),()=>{n.remove(Yt).remove(Gr).remove(Xr).remove(Yr).clearTimer(Ot)}});Pt(Co,{displayName:"Schema"});var fn,Wt;class Mo{constructor(){le(this,fn),le(this,Wt),Z(this,fn,new ha),Z(this,Wt,null),this.setCtx=e=>{Z(this,Wt,e)}}get ctx(){return A(this,Wt)}create(e,t){const r=e.create(A(this,fn).sliceMap);return r.set(t),r}get(e){return A(this,fn).get(e).get()}remove(e){return A(this,fn).remove(e)}call(e,t){if(A(this,Wt)==null)throw Bc();const r=this.get(e)(t),i=A(this,Wt).get(lr);return r(i.state,i.dispatch,i)}}fn=new WeakMap,Wt=new WeakMap;function qy(n="cmdKey"){return H(()=>()=>!1,n)}const Hs=H(new Mo,"commands"),Zr=H([Ot],"commandsTimer"),ur=Dt("CommandsReady"),To=n=>{const e=new Mo;return e.setCtx(n),n.inject(Hs,e).inject(Zr,[Ot]).record(ur),async()=>(await n.waitTimers(Zr),n.done(ur),()=>{n.remove(Hs).remove(Zr).clearTimer(ur)})};Pt(To,{displayName:"Commands"});const cr=Dt("ParserReady"),pc=()=>{throw Ks()},hr=H(pc,"parser"),ei=H([],"parserTimer"),Eo=n=>(n.inject(hr,pc).inject(ei,[Ot]).record(cr),async()=>{await n.waitTimers(ei);const e=n.get(Et),t=n.get(Yt);return n.set(hr,Yp.create(t,e)),n.done(cr),()=>{n.remove(hr).remove(ei).clearTimer(cr)}});Pt(Eo,{displayName:"Parser"});const fr=Dt("SerializerReady"),ti=H([],"serializerTimer"),mc=()=>{throw Ks()},ni=H(mc,"serializer"),Oo=n=>(n.inject(ni,mc).inject(ti,[Ot]).record(fr),async()=>{await n.waitTimers(ti);const e=n.get(Et),t=n.get(Yt);return n.set(ni,Xp.create(t,e)),n.done(fr),()=>{n.remove(ni).remove(ti).clearTimer(fr)}});Pt(Oo,{displayName:"Serializer"});const ri=H("","defaultValue"),ii=H(n=>n,"stateOptions"),si=H([],"editorStateTimer"),dr=Dt("EditorStateReady");function gc(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return Cn.fromSchema(t).parse(n.dom);if(n.type==="json")return qe.fromJSON(t,n.value);throw Ac(n)}const _y=new uo("MILKDOWN_STATE_TRACKER");function jy(n){const e=vi(Im,ho,Cu,Mu);return n.Backspace=e,n}const No=n=>(n.inject(ri,"").inject(yn,{}).inject(ii,e=>e).inject(si,[cr,fr,ur]).record(dr),async()=>{await n.waitTimers(si);const e=n.get(Yt),t=n.get(hr),r=n.get(Ei),i=n.get(ii),s=n.get(Nn),o=n.get(ri),l=gc(o,t,e),a=[...s,new Bi({key:_y,state:{init:()=>{},apply:(h,d,f,p)=>{n.set(yn,p)}}}),Fm({rules:r}),og(jy(Zm))];n.set(Nn,a);const u=i({schema:e,doc:l,plugins:a}),c=gn.create(u);return n.set(yn,c),n.done(dr),()=>{n.remove(ri).remove(yn).remove(ii).remove(si).clearTimer(dr)}});Pt(No,{displayName:"EditorState"});const oi=Dt("EditorViewReady"),li=H([],"editorViewTimer"),ai=H({},"editorViewOptions"),ui=H(null,"root"),Ai=H(null,"rootDOM"),Di=H({},"rootAttrs");function Jy(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(Ai,t);const r=e.get(Di);return Object.entries(r).forEach(([i,s])=>t.setAttribute(i,s)),t}function Hy(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const Ky=new uo("MILKDOWN_VIEW_CLEAR"),Io=n=>(n.inject(ui,document.body).inject(lr,{}).inject(ai,{}).inject(Ai,null).inject(Di,{}).inject(li,[dr]).record(oi),async()=>{await n.wait(Sn);const e=n.get(ui)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(Nn,a=>[new Bi({key:Ky,view:u=>{const c=t?Jy(t,n):void 0;return(()=>{if(c&&t){const h=u.dom;t.replaceChild(c,h),c.appendChild(h)}})(),{destroy:()=>{c!=null&&c.parentNode&&(c==null||c.parentNode.replaceChild(u.dom,c)),c==null||c.remove()}}}}),...a]),await n.waitTimers(li);const r=n.get(yn),i=n.get(ai),s=Object.fromEntries(n.get(Ni)),o=Object.fromEntries(n.get(Ii)),l=new Vy(t,{state:r,nodeViews:s,markViews:o,...i});return Hy(l.dom),n.set(lr,l),n.done(oi),()=>{l==null||l.destroy(),n.remove(ui).remove(lr).remove(ai).remove(Ai).remove(Di).remove(li).clearTimer(oi)}});Pt(Io,{displayName:"EditorView"});var yc=(n=>(n.Idle="Idle",n.OnCreate="OnCreate",n.Created="Created",n.OnDestroy="OnDestroy",n.Destroyed="Destroyed",n))(yc||{}),dn,Ie,gt,Xn,ci,hi,Me,yt,pn,fi,mn,Zn,di,qt,er;const Uy=class xc{constructor(){le(this,dn),le(this,Ie),le(this,gt),le(this,Xn),le(this,ci),le(this,hi),le(this,Me),le(this,yt),le(this,pn),le(this,fi),le(this,mn),le(this,Zn),le(this,di),le(this,qt),le(this,er),Z(this,dn,!1),Z(this,Ie,"Idle"),Z(this,gt,[]),Z(this,Xn,()=>{}),Z(this,ci,new ha),Z(this,hi,new qc),Z(this,Me,new Map),Z(this,yt,new Map),Z(this,pn,new Wc(A(this,ci),A(this,hi))),Z(this,fi,()=>{const e=fc(async r=>{await Promise.all(A(this,gt).map(i=>i(r)))}),t=[Co,Eo,Oo,To,No,Io,dc(this),e];A(this,mn).call(this,t,A(this,yt))}),Z(this,mn,(e,t)=>{e.forEach(r=>{const i=A(this,pn).produce(A(this,dn)?r.meta:void 0),s=r(i);t.set(r,{ctx:i,handler:s,cleanup:void 0})})}),Z(this,Zn,(e,t=!1)=>Promise.all([e].flat().map(r=>{const i=A(this,Me).get(r),s=i==null?void 0:i.cleanup;return t?A(this,Me).delete(r):A(this,Me).set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof s=="function"?s():s}))),Z(this,di,async()=>{await Promise.all([...A(this,yt).entries()].map(([e,{cleanup:t}])=>typeof t=="function"?t():t)),A(this,yt).clear()}),Z(this,qt,e=>{Z(this,Ie,e),A(this,Xn).call(this,e)}),Z(this,er,e=>[...e.entries()].map(async([t,r])=>{const{ctx:i,handler:s}=r;if(!s)return;const o=await s();e.set(t,{ctx:i,handler:s,cleanup:o})})),this.enableInspector=(e=!0)=>(Z(this,dn,e),this),this.onStatusChange=e=>(Z(this,Xn,e),this),this.config=e=>(A(this,gt).push(e),this),this.removeConfig=e=>(Z(this,gt,A(this,gt).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(r=>{A(this,Me).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),A(this,Ie)==="Created"&&A(this,mn).call(this,t,A(this,Me)),this},this.remove=async e=>A(this,Ie)==="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(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await A(this,Zn).call(this,[e].flat(),!0),this),this.create=async()=>A(this,Ie)==="OnCreate"?this:(A(this,Ie)==="Created"&&await this.destroy(),A(this,qt).call(this,"OnCreate"),A(this,fi).call(this),A(this,mn).call(this,[...A(this,Me).keys()],A(this,Me)),await Promise.all([A(this,er).call(this,A(this,yt)),A(this,er).call(this,A(this,Me))].flat()),A(this,qt).call(this,"Created"),this),this.destroy=async(e=!1)=>A(this,Ie)==="Destroyed"||A(this,Ie)==="OnDestroy"?this:A(this,Ie)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&Z(this,gt,[]),A(this,qt).call(this,"OnDestroy"),await A(this,Zn).call(this,[...A(this,Me).keys()],e),await A(this,di).call(this),A(this,qt).call(this,"Destroyed"),this),this.action=e=>e(A(this,pn)),this.inspect=()=>A(this,dn)?[...A(this,yt).values(),...A(this,Me).values()].map(({ctx:e})=>{var t;return(t=e==null?void 0:e.inspector)==null?void 0:t.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 xc}get ctx(){return A(this,pn)}get status(){return A(this,Ie)}};dn=new WeakMap,Ie=new WeakMap,gt=new WeakMap,Xn=new WeakMap,ci=new WeakMap,hi=new WeakMap,Me=new WeakMap,yt=new WeakMap,pn=new WeakMap,fi=new WeakMap,mn=new WeakMap,Zn=new WeakMap,di=new WeakMap,qt=new WeakMap,er=new WeakMap;let Qy=Uy;const k1=Object.freeze(Object.defineProperty({__proto__:null,CommandManager:Mo,CommandsReady:ur,ConfigReady:ar,Editor:Qy,EditorStateReady:dr,EditorStatus:yc,EditorViewReady:oi,InitReady:Sn,ParserReady:cr,SchemaReady:Ot,SerializerReady:fr,commands:To,commandsCtx:Hs,commandsTimerCtx:Zr,config:fc,createCmdKey:qy,defaultValueCtx:ri,editorCtx:Js,editorState:No,editorStateCtx:yn,editorStateOptionsCtx:ii,editorStateTimerCtx:si,editorView:Io,editorViewCtx:lr,editorViewOptionsCtx:ai,editorViewTimerCtx:li,getDoc:gc,init:dc,initTimerCtx:Ur,inputRulesCtx:Ei,markViewCtx:Ii,marksCtx:Xr,nodeViewCtx:Ni,nodesCtx:Gr,parser:Eo,parserCtx:hr,parserTimerCtx:ei,prosePluginsCtx:Nn,remarkCtx:Et,remarkPluginsCtx:Oi,remarkStringifyOptionsCtx:Qr,rootAttrsCtx:Di,rootCtx:ui,rootDOMCtx:Ai,schema:Co,schemaCtx:Yt,schemaTimerCtx:Yr,serializer:Oo,serializerCtx:ni,serializerTimerCtx:ti},Symbol.toStringTag,{value:"Module"}));export{si as $,ie as A,de as B,bt as C,We as D,ai as E,C as F,Dt as G,fr as H,qy as I,H as J,In as K,lr as L,Sn as M,Nn as N,Hs as O,uo as P,Qr as Q,Ot as R,T as S,K as T,hr as U,ii as V,gn as W,Gr as X,ur as Y,Xr as Z,Yr as _,Bi as a,Lo as a0,Ni as a1,Ii as a2,Zr as a3,li as a4,k1 as a5,Yt as b,Xy as c,Ee as d,J as e,Kr as f,Qc as g,oo as h,Ld as i,Gy as j,og as k,so as l,p1 as m,d1 as n,oi as o,Oi as p,g1 as q,ni as r,y1 as s,x1 as t,Ei as u,Wd as v,f1 as w,Zy as x,m1 as y,at as z};
1
+ import{i as P,t as b,c as Z,a as H,b as $,r as fe,f as ce}from"./index.es3.js";import{c as _,B as ee,p as G,g as z,M as C,i as w,n as W,s as te,a as d,E as x,N as I,b as oe,I as N,r as he,d as A,R as J,e as le,f as de,U as ie,Q as _e,h as ve,j as O,u as K,v as me,k as ge,l as ye,o as pe,m as we,q as De}from"./index-browser.es2.js";import{m as Ee,f as ke}from"./index.es4.js";import"./index.js";function Ce(n){return te(`"use strict";
2
+ return `+n+";",{})}function xe(n){var e=["return function(doc) {",' "use strict";'," var emitted = false;"," var emit = function (a, b) {"," emitted = true;"," };"," var view = "+n+";"," view(doc);"," if (emitted) {"," return true;"," }","};"].join(`
3
+ `);return te(e,{})}function Ae(n,e){if(n.selector&&n.filter&&n.filter!=="_selector"){var t=typeof n.filter=="string"?n.filter:"function";return e(new Error('selector invalid for filter "'+t+'"'))}e()}function Le(n){n.view&&!n.filter&&(n.filter="_view"),n.selector&&!n.filter&&(n.filter="_selector"),n.filter&&typeof n.filter=="string"&&(n.filter==="_view"?n.view=W(n.view):n.filter=W(n.filter))}function Oe(n,e){return e.filter&&typeof e.filter=="string"&&!e.doc_ids&&!w(n.db)}function Re(n,e){var t=e.complete;if(e.filter==="_view"){if(!e.view||typeof e.view!="string"){var i=_(ee,"`view` filter parameter not found or invalid.");return t(i)}var r=G(e.view);n.db.get("_design/"+r[0],function(s,f){if(n.isCancelled)return t(null,{status:"cancelled"});if(s)return t(z(s));var u=f&&f.views&&f.views[r[1]]&&f.views[r[1]].map;if(!u)return t(_(C,f.views?"missing json key: "+r[1]:"missing json key: views"));e.filter=xe(u),n.doChanges(e)})}else if(e.selector)e.filter=function(s){return Ee(s,e.selector)},n.doChanges(e);else{var a=G(e.filter);n.db.get("_design/"+a[0],function(s,f){if(n.isCancelled)return t(null,{status:"cancelled"});if(s)return t(z(s));var u=f&&f.filters&&f.filters[a[1]];if(!u)return t(_(C,f&&f.filters?"missing json key: "+a[1]:"missing json key: filters"));e.filter=Ce(u),n.doChanges(e)})}}function Te(n){n._changesFilterPlugin={validate:Ae,normalize:Le,shouldFilter:Oe,filter:Re}}function Se(n,e,t,i){try{n.emit("change",e,t,i)}catch(r){A("error",'Error in .on("change", function):',r)}}function Fe(n,e,t){var i=[{rev:n._rev}];t.style==="all_docs"&&(i=Z(e.rev_tree).map(function(a){return{rev:a.rev}}));var r={id:e.id,changes:i,doc:n};return $(e,n._rev)&&(r.deleted=!0),t.conflicts&&(r.doc._conflicts=H(e),r.doc._conflicts.length||delete r.doc._conflicts),r}class Pe extends x{constructor(e,t,i){super(),this.db=e,t=t?O(t):{};var r=t.complete=pe((f,u)=>{f?we(this,"error")>0&&this.emit("error",f):this.emit("complete",u),this.removeAllListeners(),e.removeListener("destroyed",a)});i&&(this.on("complete",function(f){i(null,f)}),this.on("error",i));const a=()=>{this.cancel()};e.once("destroyed",a),t.onChange=(f,u,o)=>{this.isCancelled||Se(this,f,u,o)};var s=new Promise(function(f,u){t.complete=function(o,c){o?u(o):f(c)}});this.once("cancel",function(){e.removeListener("destroyed",a),t.complete(null,{status:"cancelled"})}),this.then=s.then.bind(s),this.catch=s.catch.bind(s),this.then(function(f){r(null,f)},r),e.taskqueue.isReady?this.validateChanges(t):e.taskqueue.addTask(f=>{f?t.complete(f):this.isCancelled?this.emit("cancel"):this.validateChanges(t)})}cancel(){this.isCancelled=!0,this.db.taskqueue.isReady&&this.emit("cancel")}validateChanges(e){var t=e.complete;h._changesFilterPlugin?h._changesFilterPlugin.validate(e,i=>{if(i)return t(i);this.doChanges(e)}):this.doChanges(e)}doChanges(e){var t=e.complete;if(e=O(e),"live"in e&&!("continuous"in e)&&(e.continuous=e.live),e.processChange=Fe,e.since==="latest"&&(e.since="now"),e.since||(e.since=0),e.since==="now"){this.db.info().then(r=>{if(this.isCancelled){t(null,{status:"cancelled"});return}e.since=r.update_seq,this.doChanges(e)},t);return}if(h._changesFilterPlugin){if(h._changesFilterPlugin.normalize(e),h._changesFilterPlugin.shouldFilter(this,e))return h._changesFilterPlugin.filter(this,e)}else["doc_ids","filter","selector","view"].forEach(function(r){r in e&&A("warn",'The "'+r+'" option was passed in to changes/replicate, but pouchdb-changes-filter plugin is not installed, so it was ignored. Please install the plugin to enable filtering.')});"descending"in e||(e.descending=!1),e.limit=e.limit===0?1:e.limit,e.complete=t;var i=this.db._changes(e);if(i&&typeof i.cancel=="function"){const r=this.cancel;this.cancel=(...a)=>{i.cancel(),r.apply(this,a)}}}}function q(n,e){return function(t,i){t||i[0]&&i[0].error?(t=t||i[0],t.docId=e,n(t)):n(null,i.length?i[0]:i)}}function Ie(n){for(var e=0;e<n.length;e++){var t=n[e];if(t._deleted)delete t._attachments;else if(t._attachments)for(var i=Object.keys(t._attachments),r=0;r<i.length;r++){var a=i[r];t._attachments[a]=ye(t._attachments[a],["data","digest","content_type","length","revpos","stub"])}}}function Ne(n,e){if(n._id===e._id){const t=n._revisions?n._revisions.start:0,i=e._revisions?e._revisions.start:0;return t-i}return n._id<e._id?-1:1}function qe(n){var e={},t=[];return b(n,function(i,r,a,s){var f=r+"-"+a;return i&&(e[f]=0),s!==void 0&&t.push({from:s,to:f}),f}),t.reverse(),t.forEach(function(i){e[i.from]===void 0?e[i.from]=1+e[i.to]:e[i.from]=Math.min(e[i.from],1+e[i.to])}),e}function je(n){var e="limit"in n?n.keys.slice(n.skip,n.limit+n.skip):n.skip>0?n.keys.slice(n.skip):n.keys;n.keys=e,n.skip=0,delete n.limit,n.descending&&(e.reverse(),n.descending=!1)}function ne(n){var e=n._compactionQueue[0],t=e.opts,i=e.callback;n.get("_local/compaction").catch(function(){return!1}).then(function(r){r&&r.last_seq&&(t.last_seq=r.last_seq),n._compact(t,function(a,s){a?i(a):i(null,s),ge(function(){n._compactionQueue.shift(),n._compactionQueue.length&&ne(n)})})})}function Qe(n,e,t){return n.get("_local/purges").then(function(i){const r=i.purgeSeq+1;return i.purges.push({docId:e,rev:t,purgeSeq:r}),i.purges.length>self.purged_infos_limit&&i.purges.splice(0,i.purges.length-self.purged_infos_limit),i.purgeSeq=r,i}).catch(function(i){if(i.status!==404)throw i;return{_id:"_local/purges",purges:[{docId:e,rev:t,purgeSeq:0}],purgeSeq:0}}).then(function(i){return n.put(i)})}function be(n){return n.charAt(0)==="_"?n+" is not a valid attachment name, attachment names cannot start with '_'":!1}function j(n){return n===null||typeof n!="object"||Array.isArray(n)}const Be=/^\d+-[^-]*$/;function Q(n){return typeof n=="string"&&Be.test(n)}class re extends x{_setup(){this.post=d("post",function(e,t,i){if(typeof t=="function"&&(i=t,t={}),j(e))return i(_(I));this.bulkDocs({docs:[e]},t,q(i,e._id))}).bind(this),this.put=d("put",function(e,t,i){if(typeof t=="function"&&(i=t,t={}),j(e))return i(_(I));if(oe(e._id),"_rev"in e&&!Q(e._rev))return i(_(N));if(P(e._id)&&typeof this._putLocal=="function")return e._deleted?this._removeLocal(e,i):this._putLocal(e,i);const r=s=>{typeof this._put=="function"&&t.new_edits!==!1?this._put(e,t,s):this.bulkDocs({docs:[e]},t,q(s,e._id))};t.force&&e._rev?(a(),r(function(s){var f=s?null:{ok:!0,id:e._id,rev:e._rev};i(s,f)})):r(i);function a(){var s=e._rev.split("-"),f=s[1],u=parseInt(s[0],10),o=u+1,c=he();e._revisions={start:o,ids:[c,f]},e._rev=o+"-"+c,t.new_edits=!1}}).bind(this),this.putAttachment=d("putAttachment",function(e,t,i,r,a){var s=this;typeof a=="function"&&(a=r,r=i,i=null),typeof a>"u"&&(a=r,r=i,i=null),a||A("warn","Attachment",t,"on document",e,"is missing content_type");function f(u){var o="_rev"in u?parseInt(u._rev,10):0;return u._attachments=u._attachments||{},u._attachments[t]={content_type:a,data:r,revpos:++o},s.put(u)}return s.get(e).then(function(u){if(u._rev!==i)throw _(J);return f(u)},function(u){if(u.reason===C.message)return f({_id:e});throw u})}).bind(this),this.removeAttachment=d("removeAttachment",function(e,t,i,r){this.get(e,(a,s)=>{if(a){r(a);return}if(s._rev!==i){r(_(J));return}if(!s._attachments)return r();delete s._attachments[t],Object.keys(s._attachments).length===0&&delete s._attachments,this.put(s,r)})}).bind(this),this.remove=d("remove",function(e,t,i,r){var a;typeof t=="string"?(a={_id:e,_rev:t},typeof i=="function"&&(r=i,i={})):(a=e,typeof t=="function"?(r=t,i={}):(r=i,i=t)),i=i||{},i.was_delete=!0;var s={_id:a._id,_rev:a._rev||i.rev};if(s._deleted=!0,P(s._id)&&typeof this._removeLocal=="function")return this._removeLocal(a,r);this.bulkDocs({docs:[s]},i,q(r,s._id))}).bind(this),this.revsDiff=d("revsDiff",function(e,t,i){typeof t=="function"&&(i=t,t={});var r=Object.keys(e);if(!r.length)return i(null,{});var a=0,s=new Map;function f(o,c){s.has(o)||s.set(o,{missing:[]}),s.get(o).missing.push(c)}function u(o,c){var l=e[o].slice(0);b(c,function(v,y,g,L,R){var D=y+"-"+g,m=l.indexOf(D);m!==-1&&(l.splice(m,1),R.status!=="available"&&f(o,D))}),l.forEach(function(v){f(o,v)})}r.forEach(function(o){this._getRevisionTree(o,function(c,l){if(c&&c.status===404&&c.message==="missing")s.set(o,{missing:e[o]});else{if(c)return i(c);u(o,l)}if(++a===r.length){var v={};return s.forEach(function(y,g){v[g]=y}),i(null,v)}})},this)}).bind(this),this.bulkGet=d("bulkGet",function(e,t){le(this,e,t)}).bind(this),this.compactDocument=d("compactDocument",function(e,t,i){this._getRevisionTree(e,(r,a)=>{if(r)return i(r);var s=qe(a),f=[],u=[];Object.keys(s).forEach(function(o){s[o]>t&&f.push(o)}),b(a,function(o,c,l,v,y){var g=c+"-"+l;y.status==="available"&&f.indexOf(g)!==-1&&u.push(g)}),this._doCompaction(e,u,i)})}).bind(this),this.compact=d("compact",function(e,t){typeof e=="function"&&(t=e,e={}),e=e||{},this._compactionQueue=this._compactionQueue||[],this._compactionQueue.push({opts:e,callback:t}),this._compactionQueue.length===1&&ne(this)}).bind(this),this.get=d("get",function(e,t,i){if(typeof t=="function"&&(i=t,t={}),t=t||{},typeof e!="string")return i(_(de));if(P(e)&&typeof this._getLocal=="function")return this._getLocal(e,i);var r=[];const a=()=>{var u=[],o=r.length;if(!o)return i(null,u);r.forEach(c=>{this.get(e,{rev:c,revs:t.revs,latest:t.latest,attachments:t.attachments,binary:t.binary},function(l,v){if(l)u.push({missing:c});else{for(var y,g=0,L=u.length;g<L;g++)if(u[g].ok&&u[g].ok._rev===v._rev){y=!0;break}y||u.push({ok:v})}o--,o||i(null,u)})})};if(t.open_revs){if(t.open_revs==="all")this._getRevisionTree(e,function(u,o){if(u)return i(u);r=Z(o).map(function(c){return c.rev}),a()});else if(Array.isArray(t.open_revs)){r=t.open_revs;for(var s=0;s<r.length;s++){var f=r[s];if(!Q(f))return i(_(N))}a()}else return i(_(ie,"function_clause"));return}return this._get(e,t,(u,o)=>{if(u)return u.docId=e,i(u);var c=o.doc,l=o.metadata,v=o.ctx;if(t.conflicts){var y=H(l);y.length&&(c._conflicts=y)}if($(l,c._rev)&&(c._deleted=!0),t.revs||t.revs_info){for(var g=c._rev.split("-"),L=parseInt(g[0],10),R=g[1],D=fe(l.rev_tree),m=null,T=0;T<D.length;T++){var B=D[T];const p=B.ids.findIndex(k=>k.id===R);var ae=p===L-1;(ae||!m&&p!==-1)&&(m=B)}if(!m)return u=new Error("invalid rev tree"),u.docId=e,i(u);const E=c._rev.split("-")[1],F=m.ids.findIndex(p=>p.id===E)+1;var ue=m.ids.length-F;if(m.ids.splice(F,ue),m.ids.reverse(),t.revs&&(c._revisions={start:m.pos+m.ids.length-1,ids:m.ids.map(function(p){return p.id})}),t.revs_info){var M=m.pos+m.ids.length;c._revs_info=m.ids.map(function(p){return M--,{rev:M+"-"+p.id,status:p.opts.status}})}}if(t.attachments&&c._attachments){var S=c._attachments,U=Object.keys(S).length;if(U===0)return i(null,c);Object.keys(S).forEach(E=>{this._getAttachment(c._id,E,S[E],{binary:t.binary,metadata:l,ctx:v},function(F,p){var k=c._attachments[E];k.data=p,delete k.stub,delete k.length,--U||i(null,c)})})}else{if(c._attachments)for(var V in c._attachments)Object.prototype.hasOwnProperty.call(c._attachments,V)&&(c._attachments[V].stub=!0);i(null,c)}})}).bind(this),this.getAttachment=d("getAttachment",function(e,t,i,r){i instanceof Function&&(r=i,i={}),this._get(e,i,(a,s)=>{if(a)return r(a);if(s.doc._attachments&&s.doc._attachments[t])i.ctx=s.ctx,i.binary=!0,i.metadata=s.metadata,this._getAttachment(e,t,s.doc._attachments[t],i,r);else return r(_(C))})}).bind(this),this.allDocs=d("allDocs",function(e,t){if(typeof e=="function"&&(t=e,e={}),e.skip=typeof e.skip<"u"?e.skip:0,e.start_key&&(e.startkey=e.start_key),e.end_key&&(e.endkey=e.end_key),"keys"in e){if(!Array.isArray(e.keys))return t(new TypeError("options.keys must be an array"));var i=["startkey","endkey","key"].filter(function(r){return r in e})[0];if(i){t(_(_e,"Query parameter `"+i+"` is not compatible with multi-get"));return}if(!w(this)&&(je(e),e.keys.length===0))return this._allDocs({limit:0},t)}return this._allDocs(e,t)}).bind(this),this.close=d("close",function(e){return this._closed=!0,this.emit("closed"),this._close(e)}).bind(this),this.info=d("info",function(e){this._info((t,i)=>{if(t)return e(t);i.db_name=i.db_name||this.name,i.auto_compaction=!!(this.auto_compaction&&!w(this)),i.adapter=this.adapter,e(null,i)})}).bind(this),this.id=d("id",function(e){return this._id(e)}).bind(this),this.bulkDocs=d("bulkDocs",function(e,t,i){if(typeof t=="function"&&(i=t,t={}),t=t||{},Array.isArray(e)&&(e={docs:e}),!e||!e.docs||!Array.isArray(e.docs))return i(_(ve));for(var r=0;r<e.docs.length;++r){const u=e.docs[r];if(j(u))return i(_(I));if("_rev"in u&&!Q(u._rev))return i(_(N))}var a;if(e.docs.forEach(function(u){u._attachments&&Object.keys(u._attachments).forEach(function(o){a=a||be(o),u._attachments[o].content_type||A("warn","Attachment",o,"on document",u._id,"is missing content_type")})}),a)return i(_(ee,a));"new_edits"in t||("new_edits"in e?t.new_edits=e.new_edits:t.new_edits=!0);var s=this;!t.new_edits&&!w(s)&&e.docs.sort(Ne),Ie(e.docs);var f=e.docs.map(function(u){return u._id});this._bulkDocs(e,t,function(u,o){if(u)return i(u);if(t.new_edits||(o=o.filter(function(v){return v.error})),!w(s))for(var c=0,l=o.length;c<l;c++)o[c].id=o[c].id||f[c];i(null,o)})}).bind(this),this.registerDependentDatabase=d("registerDependentDatabase",function(e,t){var i=O(this.__opts);this.__opts.view_adapter&&(i.adapter=this.__opts.view_adapter);var r=new this.constructor(e,i);function a(s){return s.dependentDbs=s.dependentDbs||{},s.dependentDbs[e]?!1:(s.dependentDbs[e]=!0,s)}K(this,"_local/_pouch_dependentDbs",a).then(function(){t(null,{db:r})}).catch(t)}).bind(this),this.destroy=d("destroy",function(e,t){typeof e=="function"&&(t=e,e={});var i="use_prefix"in this?this.use_prefix:!0;const r=()=>{this._destroy(e,(a,s)=>{if(a)return t(a);this._destroyed=!0,this.emit("destroyed"),t(null,s||{ok:!0})})};if(w(this))return r();this.get("_local/_pouch_dependentDbs",(a,s)=>{if(a)return a.status!==404?t(a):r();var f=s.dependentDbs,u=this.constructor,o=Object.keys(f).map(c=>{var l=i?c.replace(new RegExp("^"+u.prefix),""):c;return new u(l,this.__opts).destroy()});Promise.all(o).then(r,t)})}).bind(this)}_compact(e,t){var i={return_docs:!1,last_seq:e.last_seq||0,since:e.last_seq||0},r=[],a,s=0;const f=c=>{this.activeTasks.update(a,{completed_items:++s}),r.push(this.compactDocument(c.id,0))},u=c=>{this.activeTasks.remove(a,c),t(c)},o=c=>{var l=c.last_seq;Promise.all(r).then(()=>K(this,"_local/compaction",v=>!v.last_seq||v.last_seq<l?(v.last_seq=l,v):!1)).then(()=>{this.activeTasks.remove(a),t(null,{ok:!0})}).catch(u)};this.info().then(c=>{a=this.activeTasks.add({name:"database_compaction",total_items:c.update_seq-i.last_seq}),this.changes(i).on("change",f).on("complete",o).on("error",u)})}changes(e,t){return typeof e=="function"&&(t=e,e={}),e=e||{},e.return_docs="return_docs"in e?e.return_docs:!e.live,new Pe(this,e,t)}type(){return typeof this._type=="function"?this._type():this.adapter}}re.prototype.purge=d("_purge",function(n,e,t){if(typeof this._purge>"u")return t(_(ie,"Purge is not implemented in the "+this.adapter+" adapter."));var i=this;i._getRevisionTree(n,(r,a)=>{if(r)return t(r);if(!a)return t(_(C));let s;try{s=ce(a,e)}catch(f){return t(f.message||f)}i._purge(n,s,(f,u)=>{if(f)return t(f);Qe(i,n,e).then(function(){return t(null,u)})})})});class Me{constructor(){this.isReady=!1,this.failed=!1,this.queue=[]}execute(){var e;if(this.failed)for(;e=this.queue.shift();)e(this.failed);else for(;e=this.queue.shift();)e()}fail(e){this.failed=e,this.execute()}ready(e){this.isReady=!0,this.db=e,this.execute()}addTask(e){this.queue.push(e),this.failed&&this.execute()}}function Ue(n,e){var t=n.match(/([a-z-]*):\/\/(.*)/);if(t)return{name:/https?/.test(t[1])?t[1]+"://"+t[2]:t[2],adapter:t[1]};var i=h.adapters,r=h.preferredAdapters,a=h.prefix,s=e.adapter;if(!s)for(var f=0;f<r.length;++f){if(s=r[f],s==="idb"&&"websql"in i&&De()&&localStorage["_pouch__websqldb_"+a+n]){A("log",'PouchDB is downgrading "'+n+'" to WebSQL to avoid data loss, because it was already opened with WebSQL.');continue}break}var u=i[s],o=u&&"use_prefix"in u?u.use_prefix:!0;return{name:o?a+n:n,adapter:s}}function Ve(n,e){n.prototype=Object.create(e.prototype,{constructor:{value:n}})}function se(n,e){let t=function(...i){if(!(this instanceof t))return new t(...i);e.apply(this,i)};return Ve(t,n),t}function Ge(n){function e(i){n.removeListener("closed",t),i||n.constructor.emit("destroyed",n.name)}function t(){n.removeListener("destroyed",e),n.constructor.emit("unref",n)}n.once("destroyed",e),n.once("closed",t),n.constructor.emit("ref",n)}class Y extends re{constructor(e,t){super(),this._setup(e,t)}_setup(e,t){if(super._setup(),t=t||{},e&&typeof e=="object"&&(t=e,e=t.name,delete t.name),t.deterministic_revs===void 0&&(t.deterministic_revs=!0),this.__opts=t=O(t),this.auto_compaction=t.auto_compaction,this.purged_infos_limit=t.purged_infos_limit||1e3,this.prefix=h.prefix,typeof e!="string")throw new Error("Missing/invalid DB name");var i=(t.prefix||"")+e,r=Ue(i,t);if(t.name=r.name,t.adapter=t.adapter||r.adapter,this.name=e,this._adapter=t.adapter,h.emit("debug",["adapter","Picked adapter: ",t.adapter]),!h.adapters[t.adapter]||!h.adapters[t.adapter].valid())throw new Error("Invalid Adapter: "+t.adapter);if(t.view_adapter&&(!h.adapters[t.view_adapter]||!h.adapters[t.view_adapter].valid()))throw new Error("Invalid View Adapter: "+t.view_adapter);this.taskqueue=new Me,this.adapter=t.adapter,h.adapters[t.adapter].call(this,t,a=>{if(a)return this.taskqueue.fail(a);Ge(this),this.emit("created",this),h.emit("created",this.name),this.taskqueue.ready(this)})}}const h=se(Y,function(n,e){Y.prototype._setup.call(this,n,e)});class ze{constructor(){this.tasks={}}list(){return Object.values(this.tasks)}add(e){const t=me();return this.tasks[t]={id:t,name:e.name,total_items:e.total_items,created_at:new Date().toJSON()},t}get(e){return this.tasks[e]}remove(e,t){return delete this.tasks[e],this.tasks}update(e,t){const i=this.tasks[e];if(typeof i<"u"){const r={id:i.id,name:i.name,created_at:i.created_at,total_items:t.total_items||i.total_items,completed_items:t.completed_items||i.completed_items,updated_at:new Date().toJSON()};this.tasks[e]=r}return this.tasks}}h.adapters={};h.preferredAdapters=[];h.prefix="_pouch_";var X=new x;function We(n){Object.keys(x.prototype).forEach(function(t){typeof x.prototype[t]=="function"&&(n[t]=X[t].bind(X))});var e=n._destructionListeners=new Map;n.on("ref",function(i){e.has(i.name)||e.set(i.name,[]),e.get(i.name).push(i)}),n.on("unref",function(i){if(e.has(i.name)){var r=e.get(i.name),a=r.indexOf(i);a<0||(r.splice(a,1),r.length>1?e.set(i.name,r):e.delete(i.name))}}),n.on("destroyed",function(i){if(e.has(i)){var r=e.get(i);e.delete(i),r.forEach(function(a){a.emit("destroyed",!0)})}})}We(h);h.adapter=function(n,e,t){e.valid()&&(h.adapters[n]=e,t&&h.preferredAdapters.push(n))};h.plugin=function(n){if(typeof n=="function")n(h);else{if(typeof n!="object"||Object.keys(n).length===0)throw new Error('Invalid plugin: got "'+n+'", expected an object or a function');Object.keys(n).forEach(function(e){h.prototype[e]=n[e]})}return this.__defaults&&(h.__defaults=Object.assign({},this.__defaults)),h};h.defaults=function(n){let e=se(h,function(t,i){i=i||{},t&&typeof t=="object"&&(i=t,t=i.name,delete i.name),i=Object.assign({},e.__defaults,i),h.call(this,t,i)});return e.preferredAdapters=h.preferredAdapters.slice(),Object.keys(h).forEach(function(t){t in e||(e[t]=h[t])}),e.__defaults=Object.assign({},this.__defaults,n),e};h.fetch=function(n,e){return ke(n,e)};h.prototype.activeTasks=h.activeTasks=new ze;var Je="9.0.0";h.plugin(Te);h.version=Je;export{h as default};