snow-cms 1.1.2 → 1.1.4
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 +15 -15
- package/dist/index.js +35 -35
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{g as Tc}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 Ec=(n,e)=>typeof e=="function"?"[Function]":e,Sn=n=>JSON.stringify(n,Ec);function Nc(n){return new Pe(Ne.docTypeError,`Doc type error, unsupported type: ${Sn(n)}`)}function Ic(n){return new Pe(Ne.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Dc(n){return new Pe(Ne.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function _s(){return new Pe(Ne.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Ac(...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?Sn(s.toJSON()):s.spec?Sn(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 zc(n){return new Pe(Ne.parserMatchError,`Cannot match target parser for node: ${Sn(n)}.`)}function Rc(n){return new Pe(Ne.serializerMatchError,`Cannot match target serializer for node: ${Sn(n)}.`)}function Uy(n){return new Pe(Ne.expectDomTypeError,`Expect to be a dom, but get: ${Sn(n)}.`)}function Pc(){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 Qy(n){return new Pe(Ne.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function Yy(n){return new Pe(Ne.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var ua=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},E=(n,e,t)=>(ua(n,e,"read from private field"),t?t.call(n):e.get(n)),ee=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},q=(n,e,t,r)=>(ua(n,e,"write to private field"),e.set(n,t),t);let ca=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 Ic(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,Pn;let Fc=class{constructor(e,t,r){ee(this,Je,void 0),ee(this,ht,void 0),ee(this,Pn,void 0),q(this,Je,[]),q(this,Pn,()=>{E(this,Je).forEach(i=>i(E(this,ht)))}),this.set=i=>{q(this,ht,i),E(this,Pn).call(this)},this.get=()=>E(this,ht),this.update=i=>{q(this,ht,i(E(this,ht))),E(this,Pn).call(this)},this.type=r,q(this,ht,t),e.set(r.id,this)}on(e){return E(this,Je).push(e),()=>{q(this,Je,E(this,Je).filter(t=>t!==e))}}once(e){const t=this.on(r=>{e(r),t()});return t}off(e){q(this,Je,E(this,Je).filter(t=>t!==e))}offAll(){q(this,Je,[])}};Je=new WeakMap,ht=new WeakMap,Pn=new WeakMap;let vc=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw _s()}}create(e,t=this._defaultValue){return new Fc(e,t,this)}};const H=(n,e)=>new vc(n,e);var Ir,Dr,Ar,on,Fn,Bt,vn,Bn,Ln;let Bc=class{constructor(e,t,r){ee(this,Ir,void 0),ee(this,Dr,void 0),ee(this,Ar,void 0),ee(this,on,void 0),ee(this,Fn,void 0),ee(this,Bt,void 0),ee(this,vn,void 0),ee(this,Bn,void 0),ee(this,Ln,void 0),q(this,on,new Set),q(this,Fn,new Set),q(this,Bt,new Map),q(this,vn,new Map),this.read=()=>({metadata:E(this,Ir),injectedSlices:[...E(this,on)].map(i=>({name:typeof i=="string"?i:i.name,value:E(this,Bn).call(this,i)})),consumedSlices:[...E(this,Fn)].map(i=>({name:typeof i=="string"?i:i.name,value:E(this,Bn).call(this,i)})),recordedTimers:[...E(this,Bt)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:E(this,Ln).call(this,i)})),waitTimers:[...E(this,vn)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:E(this,Ln).call(this,i)}))}),this.onRecord=i=>{E(this,Bt).set(i,{start:Date.now(),duration:0})},this.onClear=i=>{E(this,Bt).delete(i)},this.onDone=i=>{const s=E(this,Bt).get(i);s&&(s.duration=Date.now()-s.start)},this.onWait=(i,s)=>{const o=Date.now();s.finally(()=>{E(this,vn).set(i,{duration:Date.now()-o})})},this.onInject=i=>{E(this,on).add(i)},this.onRemove=i=>{E(this,on).delete(i)},this.onUse=i=>{E(this,Fn).add(i)},q(this,Bn,i=>E(this,Dr).get(i).get()),q(this,Ln,i=>E(this,Ar).get(i).status),q(this,Dr,e),q(this,Ar,t),q(this,Ir,r)}};Ir=new WeakMap,Dr=new WeakMap,Ar=new WeakMap,on=new WeakMap,Fn=new WeakMap,Bt=new WeakMap,vn=new WeakMap,Bn=new WeakMap,Ln=new WeakMap;var ft,dt,zr,Ve;const Lc=class ha{constructor(e,t,r){ee(this,ft,void 0),ee(this,dt,void 0),ee(this,zr,void 0),ee(this,Ve,void 0),this.produce=i=>i&&Object.keys(i).length?new ha(E(this,ft),E(this,dt),{...i}):this,this.inject=(i,s)=>{var o;const l=i.create(E(this,ft).sliceMap);return s!=null&&l.set(s),(o=E(this,Ve))==null||o.onInject(i),this},this.remove=i=>{var s;return E(this,ft).remove(i),(s=E(this,Ve))==null||s.onRemove(i),this},this.record=i=>{var s;return i.create(E(this,dt).store),(s=E(this,Ve))==null||s.onRecord(i),this},this.clearTimer=i=>{var s;return E(this,dt).remove(i),(s=E(this,Ve))==null||s.onClear(i),this},this.isInjected=i=>E(this,ft).has(i),this.isRecorded=i=>E(this,dt).has(i),this.use=i=>{var s;return(s=E(this,Ve))==null||s.onUse(i),E(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=>E(this,dt).get(i),this.done=i=>{var s;this.timer(i).done(),(s=E(this,Ve))==null||s.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=E(this,Ve))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(s=>this.wait(s)))},q(this,ft,e),q(this,dt,t),q(this,zr,r),r&&q(this,Ve,new Bc(e,t,r))}get meta(){return E(this,zr)}get inspector(){return E(this,Ve)}};ft=new WeakMap,dt=new WeakMap,zr=new WeakMap,Ve=new WeakMap;let Vc=Lc,$c=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw Dc(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}};var ln,Lt,Vn,pt,$n,Rr;let Wc=class{constructor(e,t){ee(this,ln,void 0),ee(this,Lt,void 0),ee(this,Vn,void 0),ee(this,pt,void 0),ee(this,$n,void 0),ee(this,Rr,void 0),q(this,ln,null),q(this,Lt,null),q(this,pt,"pending"),this.start=()=>(E(this,ln)??q(this,ln,new Promise((r,i)=>{q(this,Lt,s=>{s instanceof CustomEvent&&s.detail.id===E(this,Vn)&&(q(this,pt,"resolved"),E(this,$n).call(this),s.stopImmediatePropagation(),r())}),E(this,Rr).call(this,()=>{E(this,pt)==="pending"&&q(this,pt,"rejected"),E(this,$n).call(this),i(new Error(`Timing ${this.type.name} timeout.`))}),q(this,pt,"pending"),addEventListener(this.type.name,E(this,Lt))})),E(this,ln)),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:E(this,Vn)}});dispatchEvent(r)},q(this,$n,()=>{E(this,Lt)&&removeEventListener(this.type.name,E(this,Lt))}),q(this,Rr,r=>{setTimeout(()=>{r()},this.type.timeout)}),q(this,Vn,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return E(this,pt)}};ln=new WeakMap,Lt=new WeakMap,Vn=new WeakMap,pt=new WeakMap,$n=new WeakMap,Rr=new WeakMap;let jc=class{constructor(e,t=3e3){this.create=r=>new Wc(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 fa(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=fa(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function da(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=da(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 fa(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return da(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Or(0,e);if(e==this.size)return Or(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?Or(r+1,o):Or(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 $i={index:0,offset:0};function Or(n,e){return $i.index=n,$i.offset=e,$i}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 O{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=ma(this.content,e+this.openStart,t);return r&&new O(r,this.openStart,this.openEnd)}removeBetween(e,t){return new O(pa(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 O.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 O(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 O(e,r,i)}}O.empty=new O(C.empty,0,0);function pa(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(pa(s.content,e-i-1,t-i-1)))}function ma(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=ma(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function qc(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 ga(n,e,t,0)}function ga(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=ga(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 Ht(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=_c(t,n);return Ht(s,xa(n,o,l,e,r))}else return Ht(s,gi(n,e,r))}function ya(n,e){if(!e.type.compatibleContent(n.type))throw new mi("Cannot join "+e.type.name+" onto "+n.type.name)}function fs(n,e,t){let r=n.node(t);return ya(r,e.node(t)),r}function Jt(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 er(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&&(Jt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Jt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Jt(e.nodeBefore,r)}function Ht(n,e){return n.type.checkContent(e),n.copy(e)}function xa(n,e,t,r,i){let s=n.depth>i&&fs(n,e,i+1),o=r.depth>i&&fs(t,r,i+1),l=[];return er(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(ya(s,o),Jt(Ht(s,xa(n,e,t,r,i+1)),l)):(s&&Jt(Ht(s,gi(n,e,i+1)),l),er(e,t,i,l),o&&Jt(Ht(o,gi(t,r,i+1)),l)),er(r,null,i,l),new C(l)}function gi(n,e,t){let r=[];if(er(null,n,t,r),n.depth>t){let i=fs(n,e,t+1);Jt(Ht(i,gi(n,e,t+1)),r)}return er(e,null,t,r),new C(r)}function _c(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 Kc(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=Do.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 Do.set(e,r=new Jc);let i=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%Hc,i}}class Jc{constructor(){this.elts=[],this.i=0}}const Hc=12,Do=new WeakMap;class Kc{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 Uc=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 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||Uc)&&$.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 O.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 O(u,i.depth-o,s.depth-o)}replace(e,t,r){return qc(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()+")"),ka(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):ka(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 ka(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Yt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Qc(e,t);if(r.next==null)return Yt.empty;let i=ba(r);r.next&&r.err("Unexpected trailing text");let s=nh(th(i));return rh(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
|
-
`)}}Yt.empty=new Yt(!0);class Qc{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 ba(n){let e=[];do e.push(Yc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Yc(n){let e=[];do e.push(Gc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Gc(n){let e=eh(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=Xc(n,e);else break;return e}function Ao(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Xc(n,e){let t=Ao(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ao(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Zc(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.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function eh(n){if(n.eat("(")){let e=ba(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=Zc(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 th(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 Sa(n,e){return e-n}function zo(n,e){let t=[];return r(e),t.sort(Sa);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 nh(n){let e=Object.create(null);return t(zo(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]);zo(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new Yt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Sa);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function rh(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 wa(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 Ca(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 Ma(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 Oa(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new sh(n,r,e[r]);return t}let Ro=class Ta{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=Oa(e,r.attrs),this.defaultAttrs=wa(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==Yt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:Ca(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){Ma(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 Ta(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 ih(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 sh{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ih(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ai{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Oa(e,i.attrs),this.excluded=null;let s=wa(this.attrs);this.instance=s?new $(this,s):null}create(e=null){return!e&&this.instance?this.instance:new $(this,Ca(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Ai(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){Ma(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class oh{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=Ro.compile(this.spec.nodes,this),this.marks=Ai.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]=Yt.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?Po(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==""?[]:Po(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 Ro){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 Po(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 lh(n){return n.tag!=null}function ah(n){return n.style!=null}class wn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(lh(i))this.tags.push(i);else if(ah(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 vo(this,t,!1);return r.addAll(e,$.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new vo(this,t,!0);return r.addAll(e,$.none,t.from,t.to),O.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(hh(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=Bo(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=Bo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new wn(e,wn.schemaRules(e)))}}const Ea={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},uh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Na={ol:!0,ul:!0},xi=1,ki=2,tr=4;function Fo(n,e,t){return e!=null?(e?xi:0)|(e==="full"?ki:0):n&&n.whitespace=="pre"?xi|ki:t&~tr}class Tr{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&tr?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&xi)){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&&!Ea.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class vo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,s,o=Fo(null,t.preserveWhitespace,0)|(r?tr:0);i?s=new Tr(i.type,i.attrs,$.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Tr(null,null,$.none,!0,null,o):s=new Tr(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;if(i.options&ki||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&xi)i.options&ki?r=r.replace(/\r\n?/g,`
|
|
1
|
+
import{g as Oc}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 Ec=(n,e)=>typeof e=="function"?"[Function]":e,Sn=n=>JSON.stringify(n,Ec);function Nc(n){return new Pe(Ne.docTypeError,`Doc type error, unsupported type: ${Sn(n)}`)}function Ic(n){return new Pe(Ne.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Dc(n){return new Pe(Ne.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function _s(){return new Pe(Ne.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Ac(...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?Sn(s.toJSON()):s.spec?Sn(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 zc(n){return new Pe(Ne.parserMatchError,`Cannot match target parser for node: ${Sn(n)}.`)}function Rc(n){return new Pe(Ne.serializerMatchError,`Cannot match target serializer for node: ${Sn(n)}.`)}function Qy(n){return new Pe(Ne.expectDomTypeError,`Expect to be a dom, but get: ${Sn(n)}.`)}function Pc(){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 Yy(n){return new Pe(Ne.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function Gy(n){return new Pe(Ne.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var ua=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},E=(n,e,t)=>(ua(n,e,"read from private field"),t?t.call(n):e.get(n)),ee=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},q=(n,e,t,r)=>(ua(n,e,"write to private field"),e.set(n,t),t);let ca=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 Ic(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,Pn;let Fc=class{constructor(e,t,r){ee(this,Je,void 0),ee(this,ht,void 0),ee(this,Pn,void 0),q(this,Je,[]),q(this,Pn,()=>{E(this,Je).forEach(i=>i(E(this,ht)))}),this.set=i=>{q(this,ht,i),E(this,Pn).call(this)},this.get=()=>E(this,ht),this.update=i=>{q(this,ht,i(E(this,ht))),E(this,Pn).call(this)},this.type=r,q(this,ht,t),e.set(r.id,this)}on(e){return E(this,Je).push(e),()=>{q(this,Je,E(this,Je).filter(t=>t!==e))}}once(e){const t=this.on(r=>{e(r),t()});return t}off(e){q(this,Je,E(this,Je).filter(t=>t!==e))}offAll(){q(this,Je,[])}};Je=new WeakMap,ht=new WeakMap,Pn=new WeakMap;let vc=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw _s()}}create(e,t=this._defaultValue){return new Fc(e,t,this)}};const H=(n,e)=>new vc(n,e);var Ir,Dr,Ar,on,Fn,Bt,vn,Bn,Ln;let Bc=class{constructor(e,t,r){ee(this,Ir,void 0),ee(this,Dr,void 0),ee(this,Ar,void 0),ee(this,on,void 0),ee(this,Fn,void 0),ee(this,Bt,void 0),ee(this,vn,void 0),ee(this,Bn,void 0),ee(this,Ln,void 0),q(this,on,new Set),q(this,Fn,new Set),q(this,Bt,new Map),q(this,vn,new Map),this.read=()=>({metadata:E(this,Ir),injectedSlices:[...E(this,on)].map(i=>({name:typeof i=="string"?i:i.name,value:E(this,Bn).call(this,i)})),consumedSlices:[...E(this,Fn)].map(i=>({name:typeof i=="string"?i:i.name,value:E(this,Bn).call(this,i)})),recordedTimers:[...E(this,Bt)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:E(this,Ln).call(this,i)})),waitTimers:[...E(this,vn)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:E(this,Ln).call(this,i)}))}),this.onRecord=i=>{E(this,Bt).set(i,{start:Date.now(),duration:0})},this.onClear=i=>{E(this,Bt).delete(i)},this.onDone=i=>{const s=E(this,Bt).get(i);s&&(s.duration=Date.now()-s.start)},this.onWait=(i,s)=>{const o=Date.now();s.finally(()=>{E(this,vn).set(i,{duration:Date.now()-o})})},this.onInject=i=>{E(this,on).add(i)},this.onRemove=i=>{E(this,on).delete(i)},this.onUse=i=>{E(this,Fn).add(i)},q(this,Bn,i=>E(this,Dr).get(i).get()),q(this,Ln,i=>E(this,Ar).get(i).status),q(this,Dr,e),q(this,Ar,t),q(this,Ir,r)}};Ir=new WeakMap,Dr=new WeakMap,Ar=new WeakMap,on=new WeakMap,Fn=new WeakMap,Bt=new WeakMap,vn=new WeakMap,Bn=new WeakMap,Ln=new WeakMap;var ft,dt,zr,Ve;const Lc=class ha{constructor(e,t,r){ee(this,ft,void 0),ee(this,dt,void 0),ee(this,zr,void 0),ee(this,Ve,void 0),this.produce=i=>i&&Object.keys(i).length?new ha(E(this,ft),E(this,dt),{...i}):this,this.inject=(i,s)=>{var o;const l=i.create(E(this,ft).sliceMap);return s!=null&&l.set(s),(o=E(this,Ve))==null||o.onInject(i),this},this.remove=i=>{var s;return E(this,ft).remove(i),(s=E(this,Ve))==null||s.onRemove(i),this},this.record=i=>{var s;return i.create(E(this,dt).store),(s=E(this,Ve))==null||s.onRecord(i),this},this.clearTimer=i=>{var s;return E(this,dt).remove(i),(s=E(this,Ve))==null||s.onClear(i),this},this.isInjected=i=>E(this,ft).has(i),this.isRecorded=i=>E(this,dt).has(i),this.use=i=>{var s;return(s=E(this,Ve))==null||s.onUse(i),E(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=>E(this,dt).get(i),this.done=i=>{var s;this.timer(i).done(),(s=E(this,Ve))==null||s.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=E(this,Ve))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(s=>this.wait(s)))},q(this,ft,e),q(this,dt,t),q(this,zr,r),r&&q(this,Ve,new Bc(e,t,r))}get meta(){return E(this,zr)}get inspector(){return E(this,Ve)}};ft=new WeakMap,dt=new WeakMap,zr=new WeakMap,Ve=new WeakMap;let Vc=Lc,$c=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw Dc(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}};var ln,Lt,Vn,pt,$n,Rr;let Wc=class{constructor(e,t){ee(this,ln,void 0),ee(this,Lt,void 0),ee(this,Vn,void 0),ee(this,pt,void 0),ee(this,$n,void 0),ee(this,Rr,void 0),q(this,ln,null),q(this,Lt,null),q(this,pt,"pending"),this.start=()=>(E(this,ln)??q(this,ln,new Promise((r,i)=>{q(this,Lt,s=>{s instanceof CustomEvent&&s.detail.id===E(this,Vn)&&(q(this,pt,"resolved"),E(this,$n).call(this),s.stopImmediatePropagation(),r())}),E(this,Rr).call(this,()=>{E(this,pt)==="pending"&&q(this,pt,"rejected"),E(this,$n).call(this),i(new Error(`Timing ${this.type.name} timeout.`))}),q(this,pt,"pending"),addEventListener(this.type.name,E(this,Lt))})),E(this,ln)),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:E(this,Vn)}});dispatchEvent(r)},q(this,$n,()=>{E(this,Lt)&&removeEventListener(this.type.name,E(this,Lt))}),q(this,Rr,r=>{setTimeout(()=>{r()},this.type.timeout)}),q(this,Vn,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return E(this,pt)}};ln=new WeakMap,Lt=new WeakMap,Vn=new WeakMap,pt=new WeakMap,$n=new WeakMap,Rr=new WeakMap;let jc=class{constructor(e,t=3e3){this.create=r=>new Wc(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 fa(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=fa(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function da(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=da(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 fa(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return da(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Tr(0,e);if(e==this.size)return Tr(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?Tr(r+1,o):Tr(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 $i={index:0,offset:0};function Tr(n,e){return $i.index=n,$i.offset=e,$i}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=ma(this.content,e+this.openStart,t);return r&&new T(r,this.openStart,this.openEnd)}removeBetween(e,t){return new T(pa(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 pa(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(pa(s.content,e-i-1,t-i-1)))}function ma(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=ma(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function qc(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 ga(n,e,t,0)}function ga(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=ga(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 Ht(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=_c(t,n);return Ht(s,xa(n,o,l,e,r))}else return Ht(s,gi(n,e,r))}function ya(n,e){if(!e.type.compatibleContent(n.type))throw new mi("Cannot join "+e.type.name+" onto "+n.type.name)}function fs(n,e,t){let r=n.node(t);return ya(r,e.node(t)),r}function Jt(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 er(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&&(Jt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Jt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Jt(e.nodeBefore,r)}function Ht(n,e){return n.type.checkContent(e),n.copy(e)}function xa(n,e,t,r,i){let s=n.depth>i&&fs(n,e,i+1),o=r.depth>i&&fs(t,r,i+1),l=[];return er(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(ya(s,o),Jt(Ht(s,xa(n,e,t,r,i+1)),l)):(s&&Jt(Ht(s,gi(n,e,i+1)),l),er(e,t,i,l),o&&Jt(Ht(o,gi(t,r,i+1)),l)),er(r,null,i,l),new C(l)}function gi(n,e,t){let r=[];if(er(null,n,t,r),n.depth>t){let i=fs(n,e,t+1);Jt(Ht(i,gi(n,e,t+1)),r)}return er(e,null,t,r),new C(r)}function _c(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 Kc(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=Do.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 Do.set(e,r=new Jc);let i=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%Hc,i}}class Jc{constructor(){this.elts=[],this.i=0}}const Hc=12,Do=new WeakMap;class Kc{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 Uc=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 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||Uc)&&$.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 qc(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()+")"),ka(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):ka(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 ka(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Yt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Qc(e,t);if(r.next==null)return Yt.empty;let i=ba(r);r.next&&r.err("Unexpected trailing text");let s=nh(th(i));return rh(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
|
+
`)}}Yt.empty=new Yt(!0);class Qc{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 ba(n){let e=[];do e.push(Yc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Yc(n){let e=[];do e.push(Gc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Gc(n){let e=eh(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=Xc(n,e);else break;return e}function Ao(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Xc(n,e){let t=Ao(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ao(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Zc(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.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function eh(n){if(n.eat("(")){let e=ba(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=Zc(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 th(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 Sa(n,e){return e-n}function zo(n,e){let t=[];return r(e),t.sort(Sa);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 nh(n){let e=Object.create(null);return t(zo(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]);zo(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new Yt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Sa);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function rh(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 wa(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 Ca(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 Ma(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 Ta(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new sh(n,r,e[r]);return t}let Ro=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=Ta(e,r.attrs),this.defaultAttrs=wa(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==Yt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:Ca(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){Ma(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 ih(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 sh{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ih(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ai{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Ta(e,i.attrs),this.excluded=null;let s=wa(this.attrs);this.instance=s?new $(this,s):null}create(e=null){return!e&&this.instance?this.instance:new $(this,Ca(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Ai(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){Ma(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class oh{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=Ro.compile(this.spec.nodes,this),this.marks=Ai.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]=Yt.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?Po(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==""?[]:Po(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 Ro){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 Po(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 lh(n){return n.tag!=null}function ah(n){return n.style!=null}class wn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(lh(i))this.tags.push(i);else if(ah(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 vo(this,t,!1);return r.addAll(e,$.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new vo(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(hh(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=Bo(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=Bo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new wn(e,wn.schemaRules(e)))}}const Ea={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},uh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Na={ol:!0,ul:!0},xi=1,ki=2,tr=4;function Fo(n,e,t){return e!=null?(e?xi:0)|(e==="full"?ki:0):n&&n.whitespace=="pre"?xi|ki:t&~tr}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&tr?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&xi)){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&&!Ea.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class vo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,s,o=Fo(null,t.preserveWhitespace,0)|(r?tr: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;if(i.options&ki||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&xi)i.options&ki?r=r.replace(/\r\n?/g,`
|
|
3
3
|
`):r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=i.content[i.content.length-1],o=e.previousSibling;(!s||o&&o.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.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=e.nodeName.toLowerCase(),s;Na.hasOwnProperty(i)&&this.parser.normalizeLists&&ch(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,r));if(o?o.ignore:uh.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let l,a=this.top,u=this.needsBlock;if(Ea.hasOwnProperty(i))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let c=o&&o.skip?t:this.readStyles(e,t);c&&this.addAll(e,c),l&&this.sync(a),this.needsBlock=u}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,o,l,o.consuming===!1?s:void 0)}}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)}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):Lo(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=Fo(e,s,o.options);o.options&tr&&o.content.length==0&&(l|=tr);let a=$.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Lo(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Tr(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;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.groups.indexOf(u)==-1)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 ch(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Na.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function hh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Bo(n){let e={};for(let t in n)e[t]=n[t];return e}function Lo(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 Nn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Wi(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}=Pr(Wi(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&&Pr(Wi(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Pr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Vo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Vo(e.marks)}}function Vo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Wi(n){return n.document||window.document}const $o=new WeakMap;function fh(n){let e=$o.get(n);return e===void 0&&$o.set(n,e=dh(n)),e}function dh(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 Pr(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=fh(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}=Pr(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 ph={};function Js(n,e){const t=ph,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Ia(n,r,i)}function Ia(n,e,t){if(mh(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 Wo(n.children,e,t)}return Array.isArray(n)?Wo(n,e,t):""}function Wo(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=Ia(n[i],e,t);return r.join("")}function mh(n){return!!(n&&typeof n=="object")}const jo=document.createElement("i");function Hs(n){const e="&"+n+";";jo.innerHTML=e;const t=jo.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function lt(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 Ae(n,e){return n.length>0?(lt(n,n.length,0,e),n):e}const qo={}.hasOwnProperty;function gh(n){const e={};let t=-1;for(;++t<n.length;)yh(e,n[t]);return e}function yh(n,e){let t;for(t in e){const i=(qo.call(n,t)?n[t]:void 0)||(n[t]={}),s=e[t];let o;if(s)for(o in s){qo.call(i,o)||(i[o]=[]);const l=s[o];xh(i[o],Array.isArray(l)?l:l?[l]:[])}}}function xh(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);lt(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 yn(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ue=At(/[A-Za-z]/),We=At(/[\dA-Za-z]/),kh=At(/[#-'*+\--9=?A-Z^-~]/);function ds(n){return n!==null&&(n<32||n===127)}const ps=At(/\d/),bh=At(/[\dA-Fa-f]/),Sh=At(/[!-/:-@[-`{-~]/);function z(n){return n!==null&&n<-2}function be(n){return n!==null&&(n<0||n===32)}function _(n){return n===-2||n===-1||n===32}const wh=At(new RegExp("\\p{P}|\\p{S}","u")),Ch=At(/\s/);function At(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 _(a)?(n.enter(t),l(a)):e(a)}function l(a){return _(a)&&s++<i?(n.consume(a),l):(n.exit(t),e(a))}}const Mh={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 Th={tokenize:Eh},_o={tokenize:Nh};function Eh(n){const e=this,t=[];let r=0,i,s,o;return l;function l(M){if(r<t.length){const v=t[r];return e.containerState=v[1],n.attempt(v[0].continuation,a,u)(M)}return u(M)}function a(M){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&A();const v=e.events.length;let L=v,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 j=v;for(;j<e.events.length;)e.events[j][1].end=Object.assign({},S),j++;return lt(e.events,L+1,0,e.events.slice(v)),e.events.length=j,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(_o,c,h)(M)}function c(M){return i&&A(),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(_o,f,p)(M)}function f(M){return r++,t.push([e.currentConstruct,e.containerState]),d(M)}function p(M){if(M===null){i&&A(),x(0),n.consume(M);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{contentType:"flow",previous:s,_tokenizer:i}),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,v){const L=e.sliceStream(M);if(v&&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 j=e.events.length;let Y=j,T,V;for(;Y--;)if(e.events[Y][0]==="exit"&&e.events[Y][1].type==="chunkFlow"){if(T){V=e.events[Y][1].end;break}T=!0}for(x(r),S=j;S<e.events.length;)e.events[S][1].end=Object.assign({},V),S++;lt(e.events,Y+1,0,e.events.slice(j)),e.events.length=S}}function x(M){let v=t.length;for(;v-- >M;){const L=t[v];e.containerState=L[1],L[0].exit.call(e,n)}t.length=M}function A(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Nh(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 Jo(n){if(n===null||be(n)||Ch(n))return 1;if(wh(n))return 2}function Ks(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 ms={name:"attention",tokenize:Dh,resolveAll:Ih};function Ih(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=Object.assign({},n[r][1].end),d=Object.assign({},n[t][1].start);Ho(h,-a),Ho(d,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},n[r][1].end)},l={type:a>1?"strongSequence":"emphasisSequence",start:Object.assign({},n[t][1].start),end:d},s={type:a>1?"strongText":"emphasisText",start:Object.assign({},n[r][1].end),end:Object.assign({},n[t][1].start)},i={type:a>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},l.end)},n[r][1].end=Object.assign({},o.start),n[t][1].start=Object.assign({},l.end),u=[],n[r][1].end.offset-n[r][1].start.offset&&(u=Ae(u,[["enter",n[r][1],e],["exit",n[r][1],e]])),u=Ae(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=Ae(u,Ks(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),u=Ae(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=Ae(u,[["enter",n[t][1],e],["exit",n[t][1],e]])):c=0,lt(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 Dh(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Jo(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=Jo(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 Ho(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const Ah={name:"autolink",tokenize:zh};function zh(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 Ue(f)?(n.consume(f),o):f===64?t(f):u(f)}function o(f){return f===43||f===45||f===46||We(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||We(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||ds(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):kh(f)?(n.consume(f),u):t(f)}function c(f){return We(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||We(f))&&r++<63){const p=f===45?d:h;return n.consume(f),p}return t(f)}}const zi={tokenize:Rh,partial:!0};function Rh(n,e,t){return r;function r(s){return _(s)?Q(n,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?e(s):t(s)}}const Aa={name:"blockQuote",tokenize:Ph,continuation:{tokenize:Fh},exit:vh};function Ph(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 _(o)?(n.enter("blockQuotePrefixWhitespace"),n.consume(o),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(o))}}function Fh(n,e,t){const r=this;return i;function i(o){return _(o)?Q(n,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return n.attempt(Aa,e,t)(o)}}function vh(n){n.exit("blockQuote")}const za={name:"characterEscape",tokenize:Bh};function Bh(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 Sh(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Ra={name:"characterReference",tokenize:Lh};function Lh(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=We,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=bh,c):(n.enter("characterReferenceValue"),s=7,o=ps,c(h))}function c(h){if(h===59&&i){const d=n.exit("characterReferenceValue");return o===We&&!Hs(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 Ko={tokenize:$h,partial:!0},Uo={name:"codeFenced",tokenize:Vh,concrete:!0};function Vh(n,e,t){const r=this,i={tokenize:L,partial:!0};let s=0,o=0,l;return a;function a(S){return u(S)}function u(S){const j=r.events[r.events.length-1];return s=j&&j[1].type==="linePrefix"?j[2].sliceSerialize(j[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"),_(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(Ko,y,v)(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)):_(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,v,k)(S)}function k(S){return n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),x}function x(S){return s>0&&_(S)?Q(n,A,"linePrefix",s+1)(S):A(S)}function A(S){return S===null||z(S)?n.check(Ko,y,v)(S):(n.enter("codeFlowValue"),M(S))}function M(S){return S===null||z(S)?(n.exit("codeFlowValue"),A(S)):(n.consume(S),M)}function v(S){return n.exit("codeFenced"),e(S)}function L(S,j,Y){let T=0;return V;function V(W){return S.enter("lineEnding"),S.consume(W),S.exit("lineEnding"),N}function N(W){return S.enter("codeFencedFence"),_(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?(T++,S.consume(W),X):T>=o?(S.exit("codeFencedFenceSequence"),_(W)?Q(S,te,"whitespace")(W):te(W)):Y(W)}function te(W){return W===null||z(W)?(S.exit("codeFencedFence"),j(W)):Y(W)}}}function $h(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 ji={name:"codeIndented",tokenize:jh},Wh={tokenize:qh,partial:!0};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(Wh,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 qh(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 _h={name:"codeText",tokenize:Kh,resolve:Jh,previous:Hh};function Jh(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 Hh(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Kh(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 Uh{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&&zn(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),zn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),zn(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);zn(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);zn(this.left,t.reverse())}}}function zn(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 Pa(n){const e={};let t=-1,r,i,s,o,l,a,u;const c=new Uh(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,Qh(c,t)),t=e[t],u=!0);else if(r[1]._container){for(s=t,i=void 0;s--&&(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);i&&(r[1].end=Object.assign({},c.get(i)[1].start),l=c.slice(i,t),l.unshift(r),c.splice(i,t-i+1,l))}}return lt(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Qh(n,e){const t=n.get(e)[1],r=n.get(e)[2];let i=e-1;const s=[],o=t._tokenizer||r.parser[t.contentType](t.start),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]),A=s.pop();a.push([A,A+x.length-1]),n.splice(A,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 Yh={tokenize:Zh,resolve:Xh},Gh={tokenize:ef,partial:!0};function Xh(n){return Pa(n),n}function Zh(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(Gh,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 ef(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 Fa(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||ds(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||ds(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=!_(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(n.consume(f),l++,h):h(f)}}function Ba(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):_(i)?Q(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const tf={name:"definition",tokenize:rf},nf={tokenize:sf,partial:!0};function rf(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=yn(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 Fa(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return n.attempt(nf,h,h)(f)}function h(f){return _(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 sf(n,e,t){return r;function r(l){return be(l)?nr(n,i)(l):t(l)}function i(l){return Ba(n,s,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return _(l)?Q(n,o,"whitespace")(l):o(l)}function o(l){return l===null||z(l)?e(l):t(l)}}const of={name:"hardBreakEscape",tokenize:lf};function lf(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 af={name:"headingAtx",tokenize:cf,resolve:uf};function uf(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"},lt(n,r,t-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),n}function cf(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)):_(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 hf=["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"],Qo=["pre","script","style","textarea"],ff={name:"htmlFlow",tokenize:gf,resolveTo:mf,concrete:!0},df={tokenize:xf,partial:!0},pf={tokenize:yf,partial:!0};function mf(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 gf(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):Ue(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):Ue(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 Be="CDATA[";return g===Be.charCodeAt(l++)?(n.consume(g),l===Be.length?r.interrupt?e:I:p):t(g)}function y(g){return Ue(g)?(n.consume(g),o=String.fromCharCode(g),k):t(g)}function k(g){if(g===null||g===47||g===62||be(g)){const Be=g===47,Pt=o.toLowerCase();return!Be&&!s&&Qo.includes(Pt)?(i=1,r.interrupt?e(g):I(g)):hf.includes(o.toLowerCase())?(i=6,Be?(n.consume(g),x):r.interrupt?e(g):I(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?A(g):M(g))}return g===45||We(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 A(g){return _(g)?(n.consume(g),A):V(g)}function M(g){return g===47?(n.consume(g),V):g===58||g===95||Ue(g)?(n.consume(g),v):_(g)?(n.consume(g),M):V(g)}function v(g){return g===45||g===46||g===58||g===95||We(g)?(n.consume(g),v):L(g)}function L(g){return g===61?(n.consume(g),S):_(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,j):_(g)?(n.consume(g),S):Y(g)}function j(g){return g===a?(n.consume(g),a=null,T):g===null||z(g)?t(g):(n.consume(g),j)}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 T(g){return g===47||g===62||_(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):_(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),ve):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(df,Ze,X)(g)):g===null||z(g)?(n.exit("htmlFlowData"),X(g)):(n.consume(g),I)}function X(g){return n.check(pf,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 Be=o.toLowerCase();return Qo.includes(Be)?(n.consume(g),ve):I(g)}return Ue(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),ve):g===45&&i===2?(n.consume(g),m):I(g)}function ve(g){return g===null||z(g)?(n.exit("htmlFlowData"),Ze(g)):(n.consume(g),ve)}function Ze(g){return n.exit("htmlFlow"),e(g)}}function yf(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 xf(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(zi,e,t)}}const kf={name:"htmlText",tokenize:bf};function bf(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):Ue(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):Ue(m)?(n.consume(m),A):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 ve="CDATA[";return m===ve.charCodeAt(s++)?(n.consume(m),s===ve.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 A(m){return m===null||m===62?he(m):z(m)?(o=A,se(m)):(n.consume(m),A)}function M(m){return m===null?t(m):m===63?(n.consume(m),v):z(m)?(o=M,se(m)):(n.consume(m),M)}function v(m){return m===62?he(m):M(m)}function L(m){return Ue(m)?(n.consume(m),S):t(m)}function S(m){return m===45||We(m)?(n.consume(m),S):j(m)}function j(m){return z(m)?(o=j,se(m)):_(m)?(n.consume(m),j):he(m)}function Y(m){return m===45||We(m)?(n.consume(m),Y):m===47||m===62||be(m)?T(m):t(m)}function T(m){return m===47?(n.consume(m),he):m===58||m===95||Ue(m)?(n.consume(m),V):z(m)?(o=T,se(m)):_(m)?(n.consume(m),T):he(m)}function V(m){return m===45||m===46||m===58||m===95||We(m)?(n.consume(m),V):N(m)}function N(m){return m===61?(n.consume(m),I):z(m)?(o=N,se(m)):_(m)?(n.consume(m),N):T(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)):_(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)?T(m):(n.consume(m),te)}function W(m){return m===47||m===62||be(m)?T(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 _(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 Us={name:"labelEnd",tokenize:Tf,resolveTo:Of,resolveAll:Mf},Sf={tokenize:Ef},wf={tokenize:Nf},Cf={tokenize:If};function Mf(n){let e=-1;for(;++e<n.length;){const t=n[e][1];(t.type==="labelImage"||t.type==="labelLink"||t.type==="labelEnd")&&(n.splice(e+1,t.type==="labelImage"?4:2),t.type="data",e++)}return 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:Object.assign({},n[s][1].start),end:Object.assign({},n[n.length-1][1].end)},u={type:"label",start:Object.assign({},n[s][1].start),end:Object.assign({},n[o][1].end)},c={type:"labelText",start:Object.assign({},n[s+r+2][1].end),end:Object.assign({},n[o-2][1].start)};return l=[["enter",a,e],["enter",u,e]],l=Ae(l,n.slice(s+1,s+r+3)),l=Ae(l,[["enter",c,e]]),l=Ae(l,Ks(e.parser.constructs.insideSpan.null,n.slice(s+r+4,o-3),e)),l=Ae(l,[["exit",c,e],n[o-2],n[o-1],["exit",u,e]]),l=Ae(l,n.slice(o+1)),l=Ae(l,[["exit",a,e]]),lt(n,s,n.length,l),n}function Tf(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(yn(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(Sf,c,o?c:h)(d):d===91?n.attempt(wf,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Cf,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function Ef(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):Fa(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?Ba(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 Nf(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(yn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function o(l){return t(l)}}function If(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 Df={name:"labelStartImage",tokenize:Af,resolveAll:Us.resolveAll};function Af(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 zf={name:"labelStartLink",tokenize:Rf,resolveAll:Us.resolveAll};function Rf(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 qi={name:"lineEnding",tokenize:Pf};function Pf(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),Q(n,e,"linePrefix")}}const Fr={name:"thematicBreak",tokenize:Ff};function Ff(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"),_(u)?Q(n,l,"whitespace")(u):l(u))}}const ke={name:"list",tokenize:Lf,continuation:{tokenize:Vf},exit:Wf},vf={tokenize:jf,partial:!0},Bf={tokenize:$f,partial:!0};function Lf(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:ps(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(Fr,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 ps(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(zi,r.interrupt?t:c,n.attempt(vf,d,h))}function c(f){return r.containerState.initialBlankLine=!0,s++,d(f)}function h(f){return _(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 Vf(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(zi,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||!_(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(Bf,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 $f(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 Wf(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!_(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):t(s)}}const Yo={name:"setextUnderline",tokenize:_f,resolveTo:qf};function qf(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:Object.assign({},n[i][1].start),end:Object.assign({},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=Object.assign({},n[s][1].end)):n[r][1]=o,n.push(["exit",o,e]),n}function _f(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"),_(u)?Q(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||z(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}const Jf={tokenize:Hf};function Hf(n){const e=this,t=n.attempt(zi,r,n.attempt(this.parser.constructs.flowInitial,i,Q(n,n.attempt(this.parser.constructs.flow,i,n.attempt(Yh,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 Kf={resolveAll:Va()},Uf=La("string"),Qf=La("text");function La(n){return{tokenize:e,resolveAll:Va(n==="text"?Yf:void 0)};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 Va(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 Yf(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(l){const u={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{line:r.end.line,column:r.end.column-l,offset:r.end.offset-l,_index:r.start._index+s,_bufferIndex:s?o:r.start._bufferIndex+o},end:Object.assign({},r.end)};r.end=Object.assign({},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}function Gf(n,e,t){let r=Object.assign(t?Object.assign({},t):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1});const i={},s=[];let o=[],l=[];const a={consume:A,enter:M,exit:v,attempt:j(L),check:j(S),interrupt:j(S,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:n,sliceStream:f,sliceSerialize:d,now:p,defineSkip:y,write:h};let c=e.tokenize.call(u,a);return e.resolveAll&&s.push(e),u;function h(N){return o=Ae(o,N),k(),o[o.length-1]!==null?[]:(Y(e,0),u.events=Ks(s,u.events,u),u.events)}function d(N,I){return Zf(f(N),I)}function f(N){return Xf(o,N)}function p(){const{line:N,column:I,offset:X,_index:te,_bufferIndex:W}=r;return{line:N,column:I,offset:X,_index:te,_bufferIndex: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 A(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 v(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 j(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]):ve(te);function ve(oe){return In;function In(ut){const en=ut!==null&&oe[ut],tn=ut!==null&&oe.null,Mr=[...Array.isArray(en)?en:en?[en]:[],...Array.isArray(tn)?tn:tn?[tn]:[]];return Ze(Mr)(ut)}}function Ze(oe){return se=oe,Fe=0,oe.length===0?he:g(oe[Fe])}function g(oe){return In;function In(ut){return m=T(),Xe=oe,oe.partial||(u.currentConstruct=oe),oe.name&&u.parser.constructs.disable.null.includes(oe.name)?Pt():oe.tokenize.call(I?Object.assign(Object.create(u),I):u,a,Be,Pt)(ut)}}function Be(oe){return N(Xe,m),W}function Pt(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&<(u.events,I,u.events.length-I,N.resolve(u.events.slice(I),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function T(){const N=p(),I=u.previous,X=u.currentConstruct,te=u.events.length,W=Array.from(l);return{restore:he,from:te};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 Xf(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 Zf(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=`
|
|
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)}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):Lo(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=Fo(e,s,o.options);o.options&tr&&o.content.length==0&&(l|=tr);let a=$.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Lo(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;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.groups.indexOf(u)==-1)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 ch(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Na.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function hh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Bo(n){let e={};for(let t in n)e[t]=n[t];return e}function Lo(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 Nn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Wi(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}=Pr(Wi(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&&Pr(Wi(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Pr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Vo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Vo(e.marks)}}function Vo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Wi(n){return n.document||window.document}const $o=new WeakMap;function fh(n){let e=$o.get(n);return e===void 0&&$o.set(n,e=dh(n)),e}function dh(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 Pr(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=fh(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}=Pr(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 ph={};function Js(n,e){const t=ph,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Ia(n,r,i)}function Ia(n,e,t){if(mh(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 Wo(n.children,e,t)}return Array.isArray(n)?Wo(n,e,t):""}function Wo(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=Ia(n[i],e,t);return r.join("")}function mh(n){return!!(n&&typeof n=="object")}const jo=document.createElement("i");function Hs(n){const e="&"+n+";";jo.innerHTML=e;const t=jo.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function lt(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 Ae(n,e){return n.length>0?(lt(n,n.length,0,e),n):e}const qo={}.hasOwnProperty;function gh(n){const e={};let t=-1;for(;++t<n.length;)yh(e,n[t]);return e}function yh(n,e){let t;for(t in e){const i=(qo.call(n,t)?n[t]:void 0)||(n[t]={}),s=e[t];let o;if(s)for(o in s){qo.call(i,o)||(i[o]=[]);const l=s[o];xh(i[o],Array.isArray(l)?l:l?[l]:[])}}}function xh(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);lt(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 yn(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ue=At(/[A-Za-z]/),We=At(/[\dA-Za-z]/),kh=At(/[#-'*+\--9=?A-Z^-~]/);function ds(n){return n!==null&&(n<32||n===127)}const ps=At(/\d/),bh=At(/[\dA-Fa-f]/),Sh=At(/[!-/:-@[-`{-~]/);function z(n){return n!==null&&n<-2}function be(n){return n!==null&&(n<0||n===32)}function _(n){return n===-2||n===-1||n===32}const wh=At(new RegExp("\\p{P}|\\p{S}","u")),Ch=At(/\s/);function At(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 _(a)?(n.enter(t),l(a)):e(a)}function l(a){return _(a)&&s++<i?(n.consume(a),l):(n.exit(t),e(a))}}const Mh={tokenize:Th};function Th(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 Oh={tokenize:Eh},_o={tokenize:Nh};function Eh(n){const e=this,t=[];let r=0,i,s,o;return l;function l(M){if(r<t.length){const v=t[r];return e.containerState=v[1],n.attempt(v[0].continuation,a,u)(M)}return u(M)}function a(M){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&A();const v=e.events.length;let L=v,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 j=v;for(;j<e.events.length;)e.events[j][1].end=Object.assign({},S),j++;return lt(e.events,L+1,0,e.events.slice(v)),e.events.length=j,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(_o,c,h)(M)}function c(M){return i&&A(),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(_o,f,p)(M)}function f(M){return r++,t.push([e.currentConstruct,e.containerState]),d(M)}function p(M){if(M===null){i&&A(),x(0),n.consume(M);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{contentType:"flow",previous:s,_tokenizer:i}),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,v){const L=e.sliceStream(M);if(v&&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 j=e.events.length;let Y=j,O,V;for(;Y--;)if(e.events[Y][0]==="exit"&&e.events[Y][1].type==="chunkFlow"){if(O){V=e.events[Y][1].end;break}O=!0}for(x(r),S=j;S<e.events.length;)e.events[S][1].end=Object.assign({},V),S++;lt(e.events,Y+1,0,e.events.slice(j)),e.events.length=S}}function x(M){let v=t.length;for(;v-- >M;){const L=t[v];e.containerState=L[1],L[0].exit.call(e,n)}t.length=M}function A(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Nh(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 Jo(n){if(n===null||be(n)||Ch(n))return 1;if(wh(n))return 2}function Ks(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 ms={name:"attention",tokenize:Dh,resolveAll:Ih};function Ih(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=Object.assign({},n[r][1].end),d=Object.assign({},n[t][1].start);Ho(h,-a),Ho(d,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},n[r][1].end)},l={type:a>1?"strongSequence":"emphasisSequence",start:Object.assign({},n[t][1].start),end:d},s={type:a>1?"strongText":"emphasisText",start:Object.assign({},n[r][1].end),end:Object.assign({},n[t][1].start)},i={type:a>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},l.end)},n[r][1].end=Object.assign({},o.start),n[t][1].start=Object.assign({},l.end),u=[],n[r][1].end.offset-n[r][1].start.offset&&(u=Ae(u,[["enter",n[r][1],e],["exit",n[r][1],e]])),u=Ae(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=Ae(u,Ks(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),u=Ae(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=Ae(u,[["enter",n[t][1],e],["exit",n[t][1],e]])):c=0,lt(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 Dh(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Jo(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=Jo(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 Ho(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const Ah={name:"autolink",tokenize:zh};function zh(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 Ue(f)?(n.consume(f),o):f===64?t(f):u(f)}function o(f){return f===43||f===45||f===46||We(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||We(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||ds(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):kh(f)?(n.consume(f),u):t(f)}function c(f){return We(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||We(f))&&r++<63){const p=f===45?d:h;return n.consume(f),p}return t(f)}}const zi={tokenize:Rh,partial:!0};function Rh(n,e,t){return r;function r(s){return _(s)?Q(n,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?e(s):t(s)}}const Aa={name:"blockQuote",tokenize:Ph,continuation:{tokenize:Fh},exit:vh};function Ph(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 _(o)?(n.enter("blockQuotePrefixWhitespace"),n.consume(o),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(o))}}function Fh(n,e,t){const r=this;return i;function i(o){return _(o)?Q(n,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return n.attempt(Aa,e,t)(o)}}function vh(n){n.exit("blockQuote")}const za={name:"characterEscape",tokenize:Bh};function Bh(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 Sh(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Ra={name:"characterReference",tokenize:Lh};function Lh(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=We,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=bh,c):(n.enter("characterReferenceValue"),s=7,o=ps,c(h))}function c(h){if(h===59&&i){const d=n.exit("characterReferenceValue");return o===We&&!Hs(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 Ko={tokenize:$h,partial:!0},Uo={name:"codeFenced",tokenize:Vh,concrete:!0};function Vh(n,e,t){const r=this,i={tokenize:L,partial:!0};let s=0,o=0,l;return a;function a(S){return u(S)}function u(S){const j=r.events[r.events.length-1];return s=j&&j[1].type==="linePrefix"?j[2].sliceSerialize(j[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"),_(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(Ko,y,v)(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)):_(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,v,k)(S)}function k(S){return n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),x}function x(S){return s>0&&_(S)?Q(n,A,"linePrefix",s+1)(S):A(S)}function A(S){return S===null||z(S)?n.check(Ko,y,v)(S):(n.enter("codeFlowValue"),M(S))}function M(S){return S===null||z(S)?(n.exit("codeFlowValue"),A(S)):(n.consume(S),M)}function v(S){return n.exit("codeFenced"),e(S)}function L(S,j,Y){let O=0;return V;function V(W){return S.enter("lineEnding"),S.consume(W),S.exit("lineEnding"),N}function N(W){return S.enter("codeFencedFence"),_(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?(O++,S.consume(W),X):O>=o?(S.exit("codeFencedFenceSequence"),_(W)?Q(S,te,"whitespace")(W):te(W)):Y(W)}function te(W){return W===null||z(W)?(S.exit("codeFencedFence"),j(W)):Y(W)}}}function $h(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 ji={name:"codeIndented",tokenize:jh},Wh={tokenize:qh,partial:!0};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(Wh,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 qh(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 _h={name:"codeText",tokenize:Kh,resolve:Jh,previous:Hh};function Jh(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 Hh(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Kh(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 Uh{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&&zn(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),zn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),zn(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);zn(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);zn(this.left,t.reverse())}}}function zn(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 Pa(n){const e={};let t=-1,r,i,s,o,l,a,u;const c=new Uh(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,Qh(c,t)),t=e[t],u=!0);else if(r[1]._container){for(s=t,i=void 0;s--&&(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);i&&(r[1].end=Object.assign({},c.get(i)[1].start),l=c.slice(i,t),l.unshift(r),c.splice(i,t-i+1,l))}}return lt(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Qh(n,e){const t=n.get(e)[1],r=n.get(e)[2];let i=e-1;const s=[],o=t._tokenizer||r.parser[t.contentType](t.start),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]),A=s.pop();a.push([A,A+x.length-1]),n.splice(A,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 Yh={tokenize:Zh,resolve:Xh},Gh={tokenize:ef,partial:!0};function Xh(n){return Pa(n),n}function Zh(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(Gh,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 ef(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 Fa(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||ds(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||ds(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=!_(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(n.consume(f),l++,h):h(f)}}function Ba(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):_(i)?Q(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const tf={name:"definition",tokenize:rf},nf={tokenize:sf,partial:!0};function rf(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=yn(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 Fa(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return n.attempt(nf,h,h)(f)}function h(f){return _(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 sf(n,e,t){return r;function r(l){return be(l)?nr(n,i)(l):t(l)}function i(l){return Ba(n,s,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return _(l)?Q(n,o,"whitespace")(l):o(l)}function o(l){return l===null||z(l)?e(l):t(l)}}const of={name:"hardBreakEscape",tokenize:lf};function lf(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 af={name:"headingAtx",tokenize:cf,resolve:uf};function uf(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"},lt(n,r,t-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),n}function cf(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)):_(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 hf=["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"],Qo=["pre","script","style","textarea"],ff={name:"htmlFlow",tokenize:gf,resolveTo:mf,concrete:!0},df={tokenize:xf,partial:!0},pf={tokenize:yf,partial:!0};function mf(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 gf(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):Ue(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):Ue(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 Be="CDATA[";return g===Be.charCodeAt(l++)?(n.consume(g),l===Be.length?r.interrupt?e:I:p):t(g)}function y(g){return Ue(g)?(n.consume(g),o=String.fromCharCode(g),k):t(g)}function k(g){if(g===null||g===47||g===62||be(g)){const Be=g===47,Pt=o.toLowerCase();return!Be&&!s&&Qo.includes(Pt)?(i=1,r.interrupt?e(g):I(g)):hf.includes(o.toLowerCase())?(i=6,Be?(n.consume(g),x):r.interrupt?e(g):I(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?A(g):M(g))}return g===45||We(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 A(g){return _(g)?(n.consume(g),A):V(g)}function M(g){return g===47?(n.consume(g),V):g===58||g===95||Ue(g)?(n.consume(g),v):_(g)?(n.consume(g),M):V(g)}function v(g){return g===45||g===46||g===58||g===95||We(g)?(n.consume(g),v):L(g)}function L(g){return g===61?(n.consume(g),S):_(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,j):_(g)?(n.consume(g),S):Y(g)}function j(g){return g===a?(n.consume(g),a=null,O):g===null||z(g)?t(g):(n.consume(g),j)}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 O(g){return g===47||g===62||_(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):_(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),ve):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(df,Ze,X)(g)):g===null||z(g)?(n.exit("htmlFlowData"),X(g)):(n.consume(g),I)}function X(g){return n.check(pf,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 Be=o.toLowerCase();return Qo.includes(Be)?(n.consume(g),ve):I(g)}return Ue(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),ve):g===45&&i===2?(n.consume(g),m):I(g)}function ve(g){return g===null||z(g)?(n.exit("htmlFlowData"),Ze(g)):(n.consume(g),ve)}function Ze(g){return n.exit("htmlFlow"),e(g)}}function yf(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 xf(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(zi,e,t)}}const kf={name:"htmlText",tokenize:bf};function bf(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):Ue(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):Ue(m)?(n.consume(m),A):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 ve="CDATA[";return m===ve.charCodeAt(s++)?(n.consume(m),s===ve.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 A(m){return m===null||m===62?he(m):z(m)?(o=A,se(m)):(n.consume(m),A)}function M(m){return m===null?t(m):m===63?(n.consume(m),v):z(m)?(o=M,se(m)):(n.consume(m),M)}function v(m){return m===62?he(m):M(m)}function L(m){return Ue(m)?(n.consume(m),S):t(m)}function S(m){return m===45||We(m)?(n.consume(m),S):j(m)}function j(m){return z(m)?(o=j,se(m)):_(m)?(n.consume(m),j):he(m)}function Y(m){return m===45||We(m)?(n.consume(m),Y):m===47||m===62||be(m)?O(m):t(m)}function O(m){return m===47?(n.consume(m),he):m===58||m===95||Ue(m)?(n.consume(m),V):z(m)?(o=O,se(m)):_(m)?(n.consume(m),O):he(m)}function V(m){return m===45||m===46||m===58||m===95||We(m)?(n.consume(m),V):N(m)}function N(m){return m===61?(n.consume(m),I):z(m)?(o=N,se(m)):_(m)?(n.consume(m),N):O(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)):_(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)?O(m):(n.consume(m),te)}function W(m){return m===47||m===62||be(m)?O(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 _(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 Us={name:"labelEnd",tokenize:Of,resolveTo:Tf,resolveAll:Mf},Sf={tokenize:Ef},wf={tokenize:Nf},Cf={tokenize:If};function Mf(n){let e=-1;for(;++e<n.length;){const t=n[e][1];(t.type==="labelImage"||t.type==="labelLink"||t.type==="labelEnd")&&(n.splice(e+1,t.type==="labelImage"?4:2),t.type="data",e++)}return n}function Tf(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:Object.assign({},n[s][1].start),end:Object.assign({},n[n.length-1][1].end)},u={type:"label",start:Object.assign({},n[s][1].start),end:Object.assign({},n[o][1].end)},c={type:"labelText",start:Object.assign({},n[s+r+2][1].end),end:Object.assign({},n[o-2][1].start)};return l=[["enter",a,e],["enter",u,e]],l=Ae(l,n.slice(s+1,s+r+3)),l=Ae(l,[["enter",c,e]]),l=Ae(l,Ks(e.parser.constructs.insideSpan.null,n.slice(s+r+4,o-3),e)),l=Ae(l,[["exit",c,e],n[o-2],n[o-1],["exit",u,e]]),l=Ae(l,n.slice(o+1)),l=Ae(l,[["exit",a,e]]),lt(n,s,n.length,l),n}function Of(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(yn(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(Sf,c,o?c:h)(d):d===91?n.attempt(wf,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Cf,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function Ef(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):Fa(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?Ba(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 Nf(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(yn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function o(l){return t(l)}}function If(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 Df={name:"labelStartImage",tokenize:Af,resolveAll:Us.resolveAll};function Af(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 zf={name:"labelStartLink",tokenize:Rf,resolveAll:Us.resolveAll};function Rf(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 qi={name:"lineEnding",tokenize:Pf};function Pf(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),Q(n,e,"linePrefix")}}const Fr={name:"thematicBreak",tokenize:Ff};function Ff(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"),_(u)?Q(n,l,"whitespace")(u):l(u))}}const ke={name:"list",tokenize:Lf,continuation:{tokenize:Vf},exit:Wf},vf={tokenize:jf,partial:!0},Bf={tokenize:$f,partial:!0};function Lf(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:ps(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(Fr,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 ps(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(zi,r.interrupt?t:c,n.attempt(vf,d,h))}function c(f){return r.containerState.initialBlankLine=!0,s++,d(f)}function h(f){return _(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 Vf(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(zi,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||!_(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(Bf,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 $f(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 Wf(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!_(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):t(s)}}const Yo={name:"setextUnderline",tokenize:_f,resolveTo:qf};function qf(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:Object.assign({},n[i][1].start),end:Object.assign({},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=Object.assign({},n[s][1].end)):n[r][1]=o,n.push(["exit",o,e]),n}function _f(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"),_(u)?Q(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||z(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}const Jf={tokenize:Hf};function Hf(n){const e=this,t=n.attempt(zi,r,n.attempt(this.parser.constructs.flowInitial,i,Q(n,n.attempt(this.parser.constructs.flow,i,n.attempt(Yh,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 Kf={resolveAll:Va()},Uf=La("string"),Qf=La("text");function La(n){return{tokenize:e,resolveAll:Va(n==="text"?Yf:void 0)};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 Va(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 Yf(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(l){const u={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{line:r.end.line,column:r.end.column-l,offset:r.end.offset-l,_index:r.start._index+s,_bufferIndex:s?o:r.start._bufferIndex+o},end:Object.assign({},r.end)};r.end=Object.assign({},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}function Gf(n,e,t){let r=Object.assign(t?Object.assign({},t):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1});const i={},s=[];let o=[],l=[];const a={consume:A,enter:M,exit:v,attempt:j(L),check:j(S),interrupt:j(S,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:n,sliceStream:f,sliceSerialize:d,now:p,defineSkip:y,write:h};let c=e.tokenize.call(u,a);return e.resolveAll&&s.push(e),u;function h(N){return o=Ae(o,N),k(),o[o.length-1]!==null?[]:(Y(e,0),u.events=Ks(s,u.events,u),u.events)}function d(N,I){return Zf(f(N),I)}function f(N){return Xf(o,N)}function p(){const{line:N,column:I,offset:X,_index:te,_bufferIndex:W}=r;return{line:N,column:I,offset:X,_index:te,_bufferIndex: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 A(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 v(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 j(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]):ve(te);function ve(oe){return In;function In(ut){const en=ut!==null&&oe[ut],tn=ut!==null&&oe.null,Mr=[...Array.isArray(en)?en:en?[en]:[],...Array.isArray(tn)?tn:tn?[tn]:[]];return Ze(Mr)(ut)}}function Ze(oe){return se=oe,Fe=0,oe.length===0?he:g(oe[Fe])}function g(oe){return In;function In(ut){return m=O(),Xe=oe,oe.partial||(u.currentConstruct=oe),oe.name&&u.parser.constructs.disable.null.includes(oe.name)?Pt():oe.tokenize.call(I?Object.assign(Object.create(u),I):u,a,Be,Pt)(ut)}}function Be(oe){return N(Xe,m),W}function Pt(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&<(u.events,I,u.events.length-I,N.resolve(u.events.slice(I),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function O(){const N=p(),I=u.previous,X=u.currentConstruct,te=u.events.length,W=Array.from(l);return{restore:he,from:te};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 Xf(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 Zf(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
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("")}const ed={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:Aa},td={91:tf},nd={[-2]:ji,[-1]:ji,32:ji},rd={35:af,42:Fr,45:[Yo,Fr],60:ff,61:Yo,95:Fr,96:Uo,126:Uo},id={38:Ra,92:za},sd={[-5]:qi,[-4]:qi,[-3]:qi,33:Df,38:Ra,42:ms,60:[Ah,kf],91:zf,92:[of,za],93:Us,95:ms,96:_h},od={null:[ms,Kf]},ld={null:[42,95]},ad={null:[]},ud=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ld,contentInitial:td,disable:ad,document:ed,flow:rd,flowInitial:nd,insideSpan:od,string:id,text:sd},Symbol.toStringTag,{value:"Module"}));function cd(n){const t=gh([ud,...(n||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:i(Mh),document:i(Th),flow:i(Jf),string:i(Uf),text:i(Qf)};return r;function i(s){return o;function o(l){return Gf(r,s,l)}}}function hd(n){for(;!Pa(n););return n}const Go=/[\0\t\n\r]/g;function fd(){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(Go.lastIndex=h,u=Go.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 dd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $a(n){return n.replace(dd,pd)}function pd(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 Hs(t)||n}function rr(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?Xo(n.position):"start"in n||"end"in n?Xo(n):"line"in n||"column"in n?gs(n):""}function gs(n){return Zo(n&&n.line)+":"+Zo(n&&n.column)}function Xo(n){return gs(n&&n.start)+"-"+gs(n&&n.end)}function Zo(n){return n&&typeof n=="number"?n:1}const Wa={}.hasOwnProperty;function md(n,e,t){return typeof e!="string"&&(t=e,e=void 0),gd(t)(hd(cd(t).document().write(fd()(n,e,!0))))}function gd(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(No),autolinkProtocol:T,autolinkEmail:T,atxHeading:s(Oo),blockQuote:s(tn),characterEscape:T,characterReference:T,codeFenced:s(Mr),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Mr,o),codeText:s(yc,o),codeTextData:T,data:T,codeFlowValue:T,definition:s(xc),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(kc),hardBreakEscape:s(To),hardBreakTrailing:s(To),htmlFlow:s(Eo,o),htmlFlowData:T,htmlText:s(Eo,o),htmlTextData:T,image:s(bc),label:o,link:s(No),listItem:s(Sc),listItemValue:d,listOrdered:s(Io,h),listUnordered:s(Io),paragraph:s(wc),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Oo),strong:s(Cc),thematicBreak:s(Oc)},exit:{atxHeading:a(),atxHeadingSequence:L,autolink:a(),autolinkEmail:en,autolinkProtocol:ut,blockQuote:a(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:Pt,characterReferenceMarkerNumeric:Pt,characterReferenceValue:oe,characterReference:In,codeFenced:a(k),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:V,codeIndented:a(x),codeText:a(W),codeTextData:V,data:V,definition:a(),definitionDestinationString:v,definitionLabelString:A,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:Be,resourceDestinationString:m,resourceTitleString:ve,resource:Ze,setextHeading:a(Y),setextHeadingLineSequence:j,setextHeadingText:S,strong:a(),thematicBreak:a()}};ja(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},B=[];let U=-1;for(;++U<b.length;)if(b[U][1].type==="listOrdered"||b[U][1].type==="listUnordered")if(b[U][0]==="enter")B.push(U);else{const Le=B.pop();U=i(b,Le,U)}for(U=-1;++U<b.length;){const Le=e[b[U][0]];Wa.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]||el).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 B=w-1,U=-1,Le=!1,Ft,et,Dn,An;for(;++B<=P;){const Ce=b[B];switch(Ce[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ce[0]==="enter"?U++:U--,An=void 0;break}case"lineEndingBlank":{Ce[0]==="enter"&&(Ft&&!An&&!U&&!Dn&&(Dn=B),An=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:An=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(Ft){let nn=B;for(et=void 0;nn--;){const tt=b[nn];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=nn}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)&&(Ft._spread=!0),Ft.end=Object.assign({},et?b[et][1].start:Ce[1].end),b.splice(et||B,0,["exit",Ft,Ce[2]]),B++,P++}if(Ce[1].type==="listItemPrefix"){const nn={type:"listItem",_spread:!1,start:Object.assign({},Ce[1].start),end:void 0};Ft=nn,b.splice(B,0,["enter",nn,Ce[2]]),B++,P++,Dn=void 0,An=!0}}}return b[w][1]._spread=Le,P}function s(b,w){return P;function P(B){l.call(this,b(B),B),w&&w.call(this,B)}}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]),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(),B=this.tokenStack.pop();if(B)B[0].type!==b.type&&(w?w.call(this,b,B[0]):(B[1]||el).call(this,b,B[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 Js(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 A(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=yn(this.sliceSerialize(b)).toLowerCase()}function M(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function v(){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 j(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 T(b){const P=this.stack[this.stack.length-1].children;let B=P[P.length-1];(!B||B.type!=="text")&&(B=Mc(),B.position={start:ct(b.start),end:void 0},P.push(B)),this.stack.push(B)}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)&&(T.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=$a(w),P.identifier=yn(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 B=b.children;P.children=B}else P.alt=w}function m(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function ve(){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 Be(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=yn(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function Pt(b){this.data.characterReferenceType=b.type}function oe(b){const w=this.sliceSerialize(b),P=this.data.characterReferenceType;let B;P?(B=Da(w,P==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):B=Hs(w);const U=this.stack[this.stack.length-1];U.value+=B}function In(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 en(b){V.call(this,b);const w=this.stack[this.stack.length-1];w.url="mailto:"+this.sliceSerialize(b)}function tn(){return{type:"blockquote",children:[]}}function Mr(){return{type:"code",lang:null,meta:null,value:""}}function yc(){return{type:"inlineCode",value:""}}function xc(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function kc(){return{type:"emphasis",children:[]}}function Oo(){return{type:"heading",depth:0,children:[]}}function To(){return{type:"break"}}function Eo(){return{type:"html",value:""}}function bc(){return{type:"image",title:null,url:"",alt:null}}function No(){return{type:"link",title:null,url:"",children:[]}}function Io(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Sc(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function wc(){return{type:"paragraph",children:[]}}function Cc(){return{type:"strong",children:[]}}function Mc(){return{type:"text",value:""}}function Oc(){return{type:"thematicBreak"}}}function ct(n){return{line:n.line,column:n.column,offset:n.offset}}function ja(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?ja(n,r):yd(n,r)}}function yd(n,e){let t;for(t in e)if(Wa.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 el(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 ys(n){const e=this;e.parser=t;function t(r){return md(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const tl={}.hasOwnProperty;function xd(n,e){const t=e||{};function r(i,...s){let o=r.invalid;const l=r.handlers;if(i&&tl.call(i,n)){const a=String(i[n]);o=tl.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 kd={}.hasOwnProperty;function qa(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)qa(n,e.extensions[t]);for(r in e)if(kd.call(e,r))switch(r){case"extensions":break;case"unsafe":{nl(n[r],e[r]);break}case"join":{nl(n[r],e[r]);break}case"handlers":{bd(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function nl(n,e){e&&n.push(...e)}function bd(n,e){e&&Object.assign(n,e)}function Sd(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()),wd);return i(),o}function wd(n,e,t){return">"+(t?"":" ")+n}function _a(n,e){return rl(n,e.inConstruct,!0)&&!rl(n,e.notInConstruct,!1)}function rl(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 il(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
|
|
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("")}const ed={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:Aa},td={91:tf},nd={[-2]:ji,[-1]:ji,32:ji},rd={35:af,42:Fr,45:[Yo,Fr],60:ff,61:Yo,95:Fr,96:Uo,126:Uo},id={38:Ra,92:za},sd={[-5]:qi,[-4]:qi,[-3]:qi,33:Df,38:Ra,42:ms,60:[Ah,kf],91:zf,92:[of,za],93:Us,95:ms,96:_h},od={null:[ms,Kf]},ld={null:[42,95]},ad={null:[]},ud=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ld,contentInitial:td,disable:ad,document:ed,flow:rd,flowInitial:nd,insideSpan:od,string:id,text:sd},Symbol.toStringTag,{value:"Module"}));function cd(n){const t=gh([ud,...(n||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:i(Mh),document:i(Oh),flow:i(Jf),string:i(Uf),text:i(Qf)};return r;function i(s){return o;function o(l){return Gf(r,s,l)}}}function hd(n){for(;!Pa(n););return n}const Go=/[\0\t\n\r]/g;function fd(){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(Go.lastIndex=h,u=Go.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 dd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $a(n){return n.replace(dd,pd)}function pd(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 Hs(t)||n}function rr(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?Xo(n.position):"start"in n||"end"in n?Xo(n):"line"in n||"column"in n?gs(n):""}function gs(n){return Zo(n&&n.line)+":"+Zo(n&&n.column)}function Xo(n){return gs(n&&n.start)+"-"+gs(n&&n.end)}function Zo(n){return n&&typeof n=="number"?n:1}const Wa={}.hasOwnProperty;function md(n,e,t){return typeof e!="string"&&(t=e,e=void 0),gd(t)(hd(cd(t).document().write(fd()(n,e,!0))))}function gd(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(No),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(To),blockQuote:s(tn),characterEscape:O,characterReference:O,codeFenced:s(Mr),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Mr,o),codeText:s(yc,o),codeTextData:O,data:O,codeFlowValue:O,definition:s(xc),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(kc),hardBreakEscape:s(Oo),hardBreakTrailing:s(Oo),htmlFlow:s(Eo,o),htmlFlowData:O,htmlText:s(Eo,o),htmlTextData:O,image:s(bc),label:o,link:s(No),listItem:s(Sc),listItemValue:d,listOrdered:s(Io,h),listUnordered:s(Io),paragraph:s(wc),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(To),strong:s(Cc),thematicBreak:s(Tc)},exit:{atxHeading:a(),atxHeadingSequence:L,autolink:a(),autolinkEmail:en,autolinkProtocol:ut,blockQuote:a(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:Pt,characterReferenceMarkerNumeric:Pt,characterReferenceValue:oe,characterReference:In,codeFenced:a(k),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:V,codeIndented:a(x),codeText:a(W),codeTextData:V,data:V,definition:a(),definitionDestinationString:v,definitionLabelString:A,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:Be,resourceDestinationString:m,resourceTitleString:ve,resource:Ze,setextHeading:a(Y),setextHeadingLineSequence:j,setextHeadingText:S,strong:a(),thematicBreak:a()}};ja(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},B=[];let U=-1;for(;++U<b.length;)if(b[U][1].type==="listOrdered"||b[U][1].type==="listUnordered")if(b[U][0]==="enter")B.push(U);else{const Le=B.pop();U=i(b,Le,U)}for(U=-1;++U<b.length;){const Le=e[b[U][0]];Wa.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]||el).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 B=w-1,U=-1,Le=!1,Ft,et,Dn,An;for(;++B<=P;){const Ce=b[B];switch(Ce[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ce[0]==="enter"?U++:U--,An=void 0;break}case"lineEndingBlank":{Ce[0]==="enter"&&(Ft&&!An&&!U&&!Dn&&(Dn=B),An=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:An=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(Ft){let nn=B;for(et=void 0;nn--;){const tt=b[nn];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=nn}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)&&(Ft._spread=!0),Ft.end=Object.assign({},et?b[et][1].start:Ce[1].end),b.splice(et||B,0,["exit",Ft,Ce[2]]),B++,P++}if(Ce[1].type==="listItemPrefix"){const nn={type:"listItem",_spread:!1,start:Object.assign({},Ce[1].start),end:void 0};Ft=nn,b.splice(B,0,["enter",nn,Ce[2]]),B++,P++,Dn=void 0,An=!0}}}return b[w][1]._spread=Le,P}function s(b,w){return P;function P(B){l.call(this,b(B),B),w&&w.call(this,B)}}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]),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(),B=this.tokenStack.pop();if(B)B[0].type!==b.type&&(w?w.call(this,b,B[0]):(B[1]||el).call(this,b,B[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 Js(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 A(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=yn(this.sliceSerialize(b)).toLowerCase()}function M(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function v(){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 j(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 O(b){const P=this.stack[this.stack.length-1].children;let B=P[P.length-1];(!B||B.type!=="text")&&(B=Mc(),B.position={start:ct(b.start),end:void 0},P.push(B)),this.stack.push(B)}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)&&(O.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=$a(w),P.identifier=yn(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 B=b.children;P.children=B}else P.alt=w}function m(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function ve(){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 Be(b){const w=this.resume(),P=this.stack[this.stack.length-1];P.label=w,P.identifier=yn(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function Pt(b){this.data.characterReferenceType=b.type}function oe(b){const w=this.sliceSerialize(b),P=this.data.characterReferenceType;let B;P?(B=Da(w,P==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):B=Hs(w);const U=this.stack[this.stack.length-1];U.value+=B}function In(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 en(b){V.call(this,b);const w=this.stack[this.stack.length-1];w.url="mailto:"+this.sliceSerialize(b)}function tn(){return{type:"blockquote",children:[]}}function Mr(){return{type:"code",lang:null,meta:null,value:""}}function yc(){return{type:"inlineCode",value:""}}function xc(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function kc(){return{type:"emphasis",children:[]}}function To(){return{type:"heading",depth:0,children:[]}}function Oo(){return{type:"break"}}function Eo(){return{type:"html",value:""}}function bc(){return{type:"image",title:null,url:"",alt:null}}function No(){return{type:"link",title:null,url:"",children:[]}}function Io(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Sc(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function wc(){return{type:"paragraph",children:[]}}function Cc(){return{type:"strong",children:[]}}function Mc(){return{type:"text",value:""}}function Tc(){return{type:"thematicBreak"}}}function ct(n){return{line:n.line,column:n.column,offset:n.offset}}function ja(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?ja(n,r):yd(n,r)}}function yd(n,e){let t;for(t in e)if(Wa.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 el(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 ys(n){const e=this;e.parser=t;function t(r){return md(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const tl={}.hasOwnProperty;function xd(n,e){const t=e||{};function r(i,...s){let o=r.invalid;const l=r.handlers;if(i&&tl.call(i,n)){const a=String(i[n]);o=tl.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 kd={}.hasOwnProperty;function qa(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)qa(n,e.extensions[t]);for(r in e)if(kd.call(e,r))switch(r){case"extensions":break;case"unsafe":{nl(n[r],e[r]);break}case"join":{nl(n[r],e[r]);break}case"handlers":{bd(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function nl(n,e){e&&n.push(...e)}function bd(n,e){e&&Object.assign(n,e)}function Sd(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()),wd);return i(),o}function wd(n,e,t){return">"+(t?"":" ")+n}function _a(n,e){return rl(n,e.inConstruct,!0)&&!rl(n,e.notInConstruct,!1)}function rl(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 il(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
|
|
7
7
|
`&&_a(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
8
|
-
`}function Cd(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 xs(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 Md(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
|
|
8
|
+
`}function Cd(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 xs(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 Md(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 Td(n,e,t,r){const i=Md(t),s=n.value||"",o=i==="`"?"GraveAccent":"Tilde";if(xs(n,t)){const h=t.enter("codeIndented"),d=t.indentLines(s,Od);return h(),d}const l=t.createTracker(r),a=i.repeat(Math.max(Cd(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
9
|
`,encode:["`"],...l.current()})),h()}return c+=l.move(`
|
|
10
10
|
`),s&&(c+=l.move(s+`
|
|
11
|
-
`)),c+=l.move(a),u(),c}function
|
|
11
|
+
`)),c+=l.move(a),u(),c}function Od(n,e,t){return(t?"":" ")+n}function Qs(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 Ed(n,e,t,r){const i=Qs(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
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 Nd(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}Ja.peek=Id;function Ja(n,e,t,r){const i=Nd(t),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}function Id(n,e,t){return t.options.emphasis||"*"}const Ys=function(n){if(n==null)return Rd;if(typeof n=="function")return Ri(n);if(typeof n=="object")return Array.isArray(n)?Dd(n):Ad(n);if(typeof n=="string")return zd(n);throw new Error("Expected function, string, or object as test")};function Dd(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=Ys(n[t]);return Ri(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function Ad(n){const e=n;return Ri(t);function t(r){const i=r;let s;for(s in n)if(i[s]!==e[s])return!1;return!0}}function zd(n){return Ri(e);function e(t){return t&&t.type===n}}function Ri(n){return e;function e(t,r,i){return!!(Pd(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Rd(){return!0}function Pd(n){return n!==null&&typeof n=="object"&&"type"in n}const Ha=[],Fd=!0,ks=!1,vd="skip";function Bd(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;const s=Ys(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=Ha,p,y,k;if((!e||s(a,u,c[c.length-1]||void 0))&&(f=Ld(t(a,c)),f[0]===ks))return f;if("children"in a&&a.children){const x=a;if(x.children&&f[0]!==vd)for(y=(r?x.children.length:-1)+o,k=c.concat(x);y>-1&&y<x.children.length;){const A=x.children[y];if(p=l(A,y,k)(),p[0]===ks)return p;y=typeof p[1]=="number"?p[1]:y+o}}return f}}}function Ld(n){return Array.isArray(n)?n:typeof n=="number"?[Fd,n]:n==null?Ha:[n]}function Vd(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),Bd(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 Ka(n,e){let t=!1;return Vd(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,ks}),!!((!n.depth||n.depth<3)&&Js(n)&&(e.options.setext||t))}function $d(n,e,t,r){const i=Math.max(Math.min(6,n.depth||1),1),s=t.createTracker(r);if(Ka(n,t)){const c=t.enter("headingSetext"),h=t.enter("phrasing"),d=t.containerPhrasing(n,{...s.current(),before:`
|
|
13
13
|
`,after:`
|
|
14
14
|
`});return h(),c(),d+`
|
|
15
15
|
`+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
|
|
16
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="&#x"+u.charCodeAt(0).toString(16).toUpperCase()+";"+u.slice(1)),u=u?o+" "+u:o,t.options.closeAtx&&(u+=" "+o),a(),l(),u}Ua.peek=Wd;function Ua(n){return n.value||""}function Wd(){return"<"}Qa.peek=jd;function Qa(n,e,t,r){const i=Qs(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"!"}Ya.peek=qd;function Ya(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 qd(){return"!"}Ga.peek=_d;function Ga(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 _d(){return"`"}function Xa(n,e){const t=Js(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))}Za.peek=Jd;function Za(n,e,t,r){const i=Qs(t),s=i==='"'?"Quote":"Apostrophe",o=t.createTracker(r);let l,a;if(Xa(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 Jd(n,e,t){return Xa(n,t)?"<":"["}eu.peek=Hd;function eu(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 Hd(){return"["}function Gs(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 Kd(n){const e=Gs(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 Ud(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 tu(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 Qd(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?Ud(t):Gs(t);const l=n.ordered?o==="."?")":".":Kd(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),tu(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 Yd(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 Gd(n,e,t,r){const i=Yd(t);let s=t.bulletCurrent||Gs(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 Xd(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const Zd=Ys(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ep(n,e,t,r){return(n.children.some(function(o){return Zd(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function tp(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}nu.peek=np;function nu(n,e,t,r){const i=tp(t),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}function np(n,e,t){return t.options.strong||"*"}function rp(n,e,t,r){return t.safe(n.value,r)}function ip(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 sp(n,e,t){const r=(tu(t)+(t.options.ruleSpaces?" ":"")).repeat(ip(t));return t.options.ruleSpaces?r.slice(0,-1):r}const op={blockquote:Sd,break:il,code:
|
|
17
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u="&#x"+u.charCodeAt(0).toString(16).toUpperCase()+";"+u.slice(1)),u=u?o+" "+u:o,t.options.closeAtx&&(u+=" "+o),a(),l(),u}Ua.peek=Wd;function Ua(n){return n.value||""}function Wd(){return"<"}Qa.peek=jd;function Qa(n,e,t,r){const i=Qs(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"!"}Ya.peek=qd;function Ya(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 qd(){return"!"}Ga.peek=_d;function Ga(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 _d(){return"`"}function Xa(n,e){const t=Js(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))}Za.peek=Jd;function Za(n,e,t,r){const i=Qs(t),s=i==='"'?"Quote":"Apostrophe",o=t.createTracker(r);let l,a;if(Xa(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 Jd(n,e,t){return Xa(n,t)?"<":"["}eu.peek=Hd;function eu(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 Hd(){return"["}function Gs(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 Kd(n){const e=Gs(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 Ud(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 tu(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 Qd(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?Ud(t):Gs(t);const l=n.ordered?o==="."?")":".":Kd(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),tu(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 Yd(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 Gd(n,e,t,r){const i=Yd(t);let s=t.bulletCurrent||Gs(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 Xd(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const Zd=Ys(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ep(n,e,t,r){return(n.children.some(function(o){return Zd(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function tp(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}nu.peek=np;function nu(n,e,t,r){const i=tp(t),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}function np(n,e,t){return t.options.strong||"*"}function rp(n,e,t,r){return t.safe(n.value,r)}function ip(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 sp(n,e,t){const r=(tu(t)+(t.options.ruleSpaces?" ":"")).repeat(ip(t));return t.options.ruleSpaces?r.slice(0,-1):r}const op={blockquote:Sd,break:il,code:Td,definition:Ed,emphasis:Ja,hardBreak:il,heading:$d,html:Ua,image:Qa,imageReference:Ya,inlineCode:Ga,link:Za,linkReference:eu,list:Qd,listItem:Gd,paragraph:Xd,root:ep,strong:nu,text:rp,thematicBreak:sp},lp=[ap];function ap(n,e,t,r){if(e.type==="code"&&xs(e,r)&&(n.type==="list"||n.type===e.type&&xs(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"&&Ka(e,r))?void 0:t.spread?1:0}const vt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],up=[{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
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
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
20
|
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:vt},{atBreak:!0,character:"+",after:`(?:[ \r
|
|
@@ -30,14 +30,14 @@ import{g as Tc}from"./index.js";var Ne=(n=>(n.docTypeError="docTypeError",n.cont
|
|
|
30
30
|
|
|
31
31
|
`}return`
|
|
32
32
|
|
|
33
|
-
`}const mp=/\r?\n|\r/g;function gp(n,e){const t=[];let r=0,i=0,s;for(;s=mp.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 yp(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(!_a(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(xp);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(sl(r.slice(a,c),"\\")),a=c,/[!-/:-@[-`{-~]/.test(r.charAt(c))&&(!t.encode||!t.encode.includes(r.charAt(c)))?s.push("\\"):(s.push("&#x"+r.charCodeAt(c).toString(16).toUpperCase()+";"),a++))}return s.push(sl(r.slice(a,u),t.after)),s.join("")}function xp(n,e){return n-e}function sl(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 kp(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 bp(n,e={}){const t={enter:i,indentLines:gp,associationId:cp,containerPhrasing:Mp,containerFlow:
|
|
33
|
+
`}const mp=/\r?\n|\r/g;function gp(n,e){const t=[];let r=0,i=0,s;for(;s=mp.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 yp(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(!_a(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(xp);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(sl(r.slice(a,c),"\\")),a=c,/[!-/:-@[-`{-~]/.test(r.charAt(c))&&(!t.encode||!t.encode.includes(r.charAt(c)))?s.push("\\"):(s.push("&#x"+r.charCodeAt(c).toString(16).toUpperCase()+";"),a++))}return s.push(sl(r.slice(a,u),t.after)),s.join("")}function xp(n,e){return n-e}function sl(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 kp(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 bp(n,e={}){const t={enter:i,indentLines:gp,associationId:cp,containerPhrasing:Mp,containerFlow:Tp,createTracker:kp,compilePattern:hp,safe:Op,stack:[],unsafe:[...up],join:[...lp],handlers:{...op},options:{},indexStack:[],handle:void 0};qa(t,e),t.options.tightDefinitions&&t.join.push(Cp),t.handle=xd("type",{invalid:Sp,unknown:wp,handlers:t.handlers});let r=t.handle(n,void 0,t,{before:`
|
|
34
34
|
`,after:`
|
|
35
35
|
`,now:{line:1,column:1},lineShift:0});return r&&r.charCodeAt(r.length-1)!==10&&r.charCodeAt(r.length-1)!==13&&(r+=`
|
|
36
|
-
`),r;function i(s){return t.stack.push(s),o;function o(){t.stack.pop()}}}function Sp(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function wp(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Cp(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Mp(n,e){return fp(n,this,e)}function Op(n,e){return dp(n,this,e)}function Tp(n,e){return yp(this,n,e)}function bs(n){const e=this;e.compiler=t;function t(r){return bp(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function ol(n){if(n)throw n}var vr=Object.prototype.hasOwnProperty,ru=Object.prototype.toString,ll=Object.defineProperty,al=Object.getOwnPropertyDescriptor,ul=function(e){return typeof Array.isArray=="function"?Array.isArray(e):ru.call(e)==="[object Array]"},cl=function(e){if(!e||ru.call(e)!=="[object Object]")return!1;var t=vr.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&vr.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||vr.call(e,i)},hl=function(e,t){ll&&t.name==="__proto__"?ll(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},fl=function(e,t){if(t==="__proto__")if(vr.call(e,t)){if(al)return al(e,t).value}else return;return e[t]},Ep=function n(){var e,t,r,i,s,o,l=arguments[0],a=1,u=arguments.length,c=!1;for(typeof l=="boolean"&&(c=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<u;++a)if(e=arguments[a],e!=null)for(t in e)r=fl(l,t),i=fl(e,t),l!==i&&(c&&i&&(cl(i)||(s=ul(i)))?(s?(s=!1,o=r&&ul(r)?r:[]):o=r&&cl(r)?r:{},hl(l,{name:t,newValue:n(c,o,i)})):typeof i<"u"&&hl(l,{name:t,newValue:i}));return l};const _i=Tc(Ep);function Ss(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 Np(){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?Ip(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 Ip(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 Ke={basename:Dp,dirname:Ap,extname:zp,join:Rp,sep:"/"};function Dp(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');br(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 Ap(n){if(br(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 zp(n){br(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 Rp(...n){let e=-1,t;for(;++e<n.length;)br(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Pp(t)}function Pp(n){br(n);const e=n.codePointAt(0)===47;let t=Fp(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Fp(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 br(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const vp={cwd:Bp};function Bp(){return"/"}function ws(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function Lp(n){if(typeof n=="string")n=new URL(n);else if(!ws(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 Vp(n)}function Vp(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 Ji=["history","path","basename","stem","extname","dirname"];class $p{constructor(e){let t;e?ws(e)?t={path:e}:typeof e=="string"||Wp(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<Ji.length;){const s=Ji[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)Ji.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Ke.basename(this.path):void 0}set basename(e){Ki(e,"basename"),Hi(e,"basename"),this.path=Ke.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Ke.dirname(this.path):void 0}set dirname(e){dl(this.basename,"dirname"),this.path=Ke.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Ke.extname(this.path):void 0}set extname(e){if(Hi(e,"extname"),dl(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=Ke.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){ws(e)&&(e=Lp(e)),Ki(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Ke.basename(this.path,this.extname):void 0}set stem(e){Ki(e,"stem"),Hi(e,"stem"),this.path=Ke.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 Hi(n,e){if(n&&n.includes(Ke.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Ke.sep+"`")}function Ki(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function dl(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Wp(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},qp={}.hasOwnProperty;class Xs 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=Np()}copy(){const e=new Xs;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(_i(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Yi("data",this.frozen),this.namespace[e]=t,this):qp.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Yi("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=Er(e),r=this.parser||this.Parser;return Ui("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),Ui("process",this.parser||this.Parser),Qi("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(s,o){const l=Er(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);Jp(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(),Ui("processSync",this.parser||this.Parser),Qi("processSync",this.compiler||this.Compiler),this.process(e,i),ml("processSync","process",t),r;function i(s,o){t=!0,ol(s),r=o}}run(e,t,r){pl(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=Er(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),ml("runSync","run",r),i;function s(o,l){ol(o),i=l,r=!0}}stringify(e,t){this.freeze();const r=Er(t),i=this.compiler||this.Compiler;return Qi("stringify",i),pl(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Yi("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=_i(!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];Ss(y)&&Ss(f)&&(f=_i(!0,y,f)),r[d]=[u,f,...p]}}}}const Cs=new Xs().freeze();function Ui(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Qi(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Yi(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 pl(n){if(!Ss(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function ml(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Er(n){return _p(n)?n:new $p(n)}function _p(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Jp(n){return typeof n=="string"||Hp(n)}function Hp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var iu=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},F=(n,e,t)=>(iu(n,e,"read from private field"),t?t.call(n):e.get(n)),ne=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},G=(n,e,t,r)=>(iu(n,e,"write to private field"),e.set(n,t),t);let su=class{},ou=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 Zs extends su{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 Zs(e,t,r)}}var He,Wn,Br,Lr,Vr,jn,qn;const Ms=class extends ou{constructor(e){super(),ne(this,He,void 0),ne(this,Wn,void 0),ne(this,Br,void 0),ne(this,Lr,void 0),ne(this,Vr,void 0),ne(this,jn,void 0),ne(this,qn,void 0),G(this,He,$.none),G(this,Wn,t=>t.isText),G(this,Br,(t,r)=>{if(F(this,Wn).call(this,t)&&F(this,Wn).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 zc(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(Zs.create(t,[],r)),this),G(this,jn,()=>{G(this,He,$.none);const t=this.close();return F(this,qn).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>(F(this,jn).call(this),this),G(this,qn,(t,r,i)=>{const s=t.createAndFill(r,i,F(this,He));if(!s)throw Ac(t,r,i);return this.push(s),s}),this.addNode=(t,r,i)=>(F(this,qn).call(this,t,r,i),this),this.openMark=(t,r)=>{const i=t.create(r);return G(this,He,i.addToSet(F(this,He))),this},this.closeMark=t=>(G(this,He,t.removeFromSet(F(this,He))),this),this.addText=t=>{const r=this.top();if(!r)throw aa();const i=r.pop(),s=this.schema.text(t,F(this,He));if(!i)return r.push(s),this;const o=F(this,Br).call(this,i,s);return o?(r.push(o),this):(r.push(i,s),this)},this.build=()=>{let t;do t=F(this,jn).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}};He=new WeakMap,Wn=new WeakMap,Br=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,jn=new WeakMap,qn=new WeakMap,Ms.create=(n,e)=>{const t=new Ms(n);return r=>(t.run(e,r),t.toDoc())};let Kp=Ms;const Os=class extends su{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()}}};Os.create=(n,e,t,r={})=>new Os(n,e,t,r);let gl=Os;const Up=n=>Object.prototype.hasOwnProperty.call(n,"size");var rt,_n,$r,Wr,Jn,jr,Hn,qr,_r,an,Vt,Jr,Kn;const Ts=class extends ou{constructor(e){super(),ne(this,rt,void 0),ne(this,_n,void 0),ne(this,$r,void 0),ne(this,Wr,void 0),ne(this,Jn,void 0),ne(this,jr,void 0),ne(this,Hn,void 0),ne(this,qr,void 0),ne(this,_r,void 0),ne(this,an,void 0),ne(this,Vt,void 0),ne(this,Jr,void 0),ne(this,Kn,void 0),G(this,rt,$.none),G(this,_n,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Rc(t.type);return r}),G(this,$r,t=>F(this,_n).call(this,t).spec.toMarkdown.runner(this,t)),G(this,Wr,(t,r)=>F(this,_n).call(this,t).spec.toMarkdown.runner(this,t,r)),G(this,Jn,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,Kn).call(this,s))}),G(this,jr,(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,Hn,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,jr).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,Hn).call(this,d))}}return i.concat(s)},[])),t}),G(this,qr,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(gl.create(t,void 0,r,i)),this),G(this,_r,(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,Vt).call(this,"text",void 0,i);const c=r();return s.length&&F(this,Vt).call(this,"text",void 0,s),c}),G(this,an,(t=!1)=>{const r=this.close(),i=()=>F(this,Vt).call(this,r.type,r.children,r.value,r.props);return t?F(this,_r).call(this,r,i):i()}),this.closeNode=()=>(F(this,an).call(this),this),G(this,Vt,(t,r,i,s)=>{const o=gl.create(t,r,i,s),l=F(this,Hn).call(this,F(this,qr).call(this,o));return this.push(l),l}),this.addNode=(t,r,i,s)=>(F(this,Vt).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,Kn,t=>{t.isInSet(F(this,rt))&&(G(this,rt,t.type.removeFromSet(F(this,rt))),F(this,an).call(this,!0))}),this.withMark=(t,r,i,s)=>(F(this,Jr).call(this,t,r,i,s),this),this.closeMark=t=>(F(this,Kn).call(this,t),this),this.build=()=>{let t=null;do t=F(this,an).call(this);while(this.size());return t},this.next=t=>Up(t)?(t.forEach(r=>{F(this,Jn).call(this,r)}),this):(F(this,Jn).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};rt=new WeakMap,_n=new WeakMap,$r=new WeakMap,Wr=new WeakMap,Jn=new WeakMap,jr=new WeakMap,Hn=new WeakMap,qr=new WeakMap,_r=new WeakMap,an=new WeakMap,Vt=new WeakMap,Jr=new WeakMap,Kn=new WeakMap,Ts.create=(n,e)=>{const t=new Ts(n);return r=>(t.run(r),t.toString(e))};let Qp=Ts;const lu=65535,au=Math.pow(2,16);function Yp(n,e){return n+e*au}function yl(n){return n&lu}function Gp(n){return(n-(n&lu))/au}const uu=1,cu=2,Hr=4,hu=8;class Es{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&hu)>0}get deletedBefore(){return(this.delInfo&(uu|Hr))>0}get deletedAfter(){return(this.delInfo&(cu|Hr))>0}get deletedAcross(){return(this.delInfo&Hr)>0}}class Oe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Oe.empty)return Oe.empty}recover(e){let t=0,r=yl(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+Gp(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:Yp(l/3,e-a),y=e==a?cu:e==h?uu:Hr;return(t<0?e!=a:e!=h)&&(y|=hu),new Es(f,y,p)}i+=c-u}return r?e+i:new Es(e+i,0,null)}touches(e,t){let r=0,i=yl(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 Oe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Oe.empty:new Oe(e<0?[0,-e,0]:[0,0,e])}}Oe.empty=new Oe([]);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 Es(e,i,null)}}const Gi=Object.create(null);class me{getMap(){return Oe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gi[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 Gi)throw new RangeError("Duplicate use of step JSON ID "+e);return Gi[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 eo(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(eo(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 O(eo(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 Qe(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 Qe 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 O(eo(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 Qe(t.pos,r.pos,this.mark)}merge(e){return e instanceof Qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qe(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 Qe(t.from,t.to,e.markFromJSON(t.mark))}}me.jsonID("removeMark",Qe);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 O(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 Cn(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 Cn 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 O(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 Cn(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 Cn(t.pos,e.markFromJSON(t.mark))}}me.jsonID("removeNodeMark",Cn);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&&Ns(e,this.from,this.to)?re.fail("Structure replace would overwrite content"):re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Oe([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?O.empty:new O(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?O.empty:new O(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,O.fromJSON(e,t.slice),!!t.structure)}}me.jsonID("replace",de);class Te 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&&(Ns(e,this.from,this.gapFrom)||Ns(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 Oe([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 Te(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 Te(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 Te(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}me.jsonID("replaceAround",Te);function Ns(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 Xp(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 Qe(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 Zp(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 Ai){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 Qe(o.from,o.to,o.style)))}function fu(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,O.empty));else{r=h;for(let d=0;d<u.marks.length;d++)t.allowsMarkType(u.marks[d].type)||n.step(new Qe(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 O(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 O(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function em(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function to(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||!em(i,s,o))break}return null}function tm(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 Te(a,u,o,l,new O(c.append(d),h,f),c.size-h,!0))}function du(n,e,t=null,r=n){let i=nm(n,e),s=i&&rm(r,e);return s?i.map(xl).concat({type:e,attrs:t}).concat(s.map(xl)):null}function xl(n){return{type:n,attrs:null}}function nm(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 rm(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 im(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 Te(i,s,i,s,new O(r,0,0),t.length,!0))}function sm(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)&&am(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&&lm(n,o,l,s),fu(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 Te(h,d,h+1,d-1,new O(C.from(r.create(a,null,o.marks)),0,0),1,!0)),u===!0&&om(n,o,l,s),!1}})}function om(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 lm(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 am(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function um(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 Te(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(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 cm(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 O(s.append(o),t,t),!0))}function no(n,e){let t=n.resolve(e),r=t.index();return hm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function hm(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function fm(n,e,t){let r=new de(e-t,e+t,O.empty,!0);n.step(r)}function dm(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 pm(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 ro(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return pu(i,s,r)?new de(e,t,r):new mm(i,s,r).fit()}function pu(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class mm{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 O(s,o,l);return e>-1?new Te(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=Xi(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=Xi(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new O(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=Xi(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new O(Un(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new O(Un(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(mu(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=Qn(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?O.empty:new O(Un(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new O(Un(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||!Zi(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=Zi(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=Zi(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=Qn(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=Qn(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=Qn(this.placed,this.frontier.length,t))}}function Un(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Un(n.firstChild.content,e-1,t)))}function Qn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qn(n.lastChild.content,e-1,t)))}function Xi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function mu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,mu(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 Zi(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&&!gm(t,s.content,o)?l:null}function gm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ym(n){return n.spec.defining||n.spec.definingForContent}function xm(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(pu(i,s,r))return n.step(new de(e,t,r));let o=yu(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=ym(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 A=i.node(k-1),M=i.index(k-1);if(A.canReplaceWith(M,M,p.type,p.marks))return n.replace(i.before(k),x?s.after(k):t,new O(gu(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 gu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(gu(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 km(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=dm(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new O(C.from(r),0,0))}function bm(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=yu(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)return n.delete(r.before(o),t);n.delete(e,t)}function yu(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 xn 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 O(C.from(i),0,t.isLeaf?0:1))}getMap(){return Oe.empty}invert(e){return new xn(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 xn(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 xn(t.pos,t.attr,t.value)}}me.jsonID("attr",xn);class mr 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 Oe.empty}invert(e){return new mr(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 mr(t.attr,t.value)}}me.jsonID("docAttr",mr);let Mn=class extends Error{};Mn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Mn.prototype=Object.create(Error.prototype);Mn.prototype.constructor=Mn;Mn.prototype.name="TransformError";class Sm{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 Mn(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=O.empty){let i=ro(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new O(C.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return xm(this,e,t,r),this}replaceRangeWith(e,t,r){return km(this,e,t,r),this}deleteRange(e,t){return bm(this,e,t),this}lift(e,t){return tm(this,e,t),this}join(e,t=1){return fm(this,e,t),this}wrap(e,t){return im(this,e,t),this}setBlockType(e,t=e,r,i=null){return sm(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return um(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new xn(e,t,r)),this}setDocAttribute(e,t){return this.step(new mr(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 Cn(e,t)),this}split(e,t=1,r){return cm(this,e,t,r),this}addMark(e,t,r){return Xp(this,e,t,r),this}removeMark(e,t,r){return Zp(this,e,t,r),this}clearIncompatible(e,t,r){return fu(this,e,t,r),this}}const es=Object.create(null);class J{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new wm(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=O.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?O.empty:t),l==0&&Sl(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),Sl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new K(e):un(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?un(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):un(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 Ee(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new Ee(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new Ee(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=es[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 es)throw new RangeError("Duplicate use of selection JSON ID "+e);return es[e]=t,t.prototype.jsonID=e,t}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class wm{constructor(e,t){this.$from=e,this.$to=t}}let kl=!1;function bl(n){!kl&&!n.parent.inlineContent&&(kl=!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){bl(e),bl(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=O.empty){if(super.replace(e,t),t==O.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 Pi(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 Pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pi(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 O(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 io(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 io{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Pi(r,r):new io(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):J.near(t)}}class Ee extends J{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.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 Ee(e)}map(e){return new Ee(e)}eq(e){return e instanceof Ee}getBookmark(){return Cm}}J.jsonID("all",Ee);const Cm={map(){return this},resolve(n){return new Ee(n)}};function un(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=un(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Sl(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof de||i instanceof Te))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 wl=1,Nr=2,Cl=4;class Mm extends Sm{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|wl)&~Nr,this.storedMarks=null,this}get selectionSet(){return(this.updated&wl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Nr,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&Nr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Nr,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 Yn{constructor(e,t,r){this.name=e,this.init=Ml(t.init,r),this.apply=Ml(t.apply,r)}}const Om=[new Yn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Yn("selection",{init(n,e){return n.selection||J.atStart(e.doc)},apply(n){return n.selection}}),new Yn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Yn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ts{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 Yn(r.key,r.spec.state,r))})}}class mn{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 mn(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 Mm(this)}static create(e){let t=new ts(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new mn(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 ts(this.schema,e.plugins),r=t.fields,i=new mn(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 ts(e.schema,e.plugins),s=new mn(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 xu(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xu(i,e,{})),t[r]=i}return t}class Fi{constructor(e){this.spec=e,this.props={},e.props&&xu(e.props,this,this.props),this.key=e.key?e.key.key:ku("plugin")}getState(e){return e[this.key]}}const ns=Object.create(null);function ku(n){return n in ns?n+"$"+ ++ns[n]:(ns[n]=0,n+"$")}class so{constructor(e="key"){this.key=ku(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"?Tm(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Tm(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 Em=(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 u1(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&&no(u.doc,o-1)&&(!r||r(s,f))&&u.join(o-1),u})}function c1(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 Nt=typeof navigator<"u"?navigator:null,Ol=typeof document<"u"?document:null,Zt=Nt&&Nt.userAgent||"",Is=/Edge\/(\d+)/.exec(Zt),bu=/MSIE \d/.exec(Zt),Ds=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zt),oo=!!(bu||Ds||Is);bu?document.documentMode:Ds?+Ds[1]:Is&&+Is[1];const Nm=!oo&&/gecko\/(\d+)/i.test(Zt);Nm&&+(/Firefox\/(\d+)/.exec(Zt)||[0,0])[1];const Tl=!oo&&/Chrome\/(\d+)/.exec(Zt);Tl&&+Tl[1];const Im=!oo&&!!Nt&&/Apple Computer/.test(Nt.vendor),Dm=Im&&(/Mobile\/\w+/.test(Zt)||!!Nt&&Nt.maxTouchPoints>2);Dm||Nt&&/Mac/.test(Nt.platform);const Am=!!Ol&&"webkitFontSmoothing"in Ol.documentElement.style;Am&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function rs(n,e,t,r,i,s){if(n.composing)return!1;const o=n.state,l=o.doc.resolve(e);if(l.parent.type.spec.code)return!1;const a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"")+r;for(let u=0;u<i.length;u++){const c=i[u].match.exec(a),h=c&&c[0]&&i[u].handler(o,c,e-(c[0].length-r.length),t);if(h)return n.dispatch(h.setMeta(s,{transform:h,from:e,to:t,text:r})),!0}return!1}const zm=new so("MILKDOWN_CUSTOM_INPUTRULES");function Rm({rules:n}){const e=new Fi({key:zm,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 rs(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&rs(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?rs(t,i.pos,i.pos,`
|
|
38
|
-
`,n,e):!1}}});return e}function
|
|
39
|
-
`).scrollIntoView()),!0)};function ao(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 $m=(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=ao(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},Wm=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ee||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ao(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&&to(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function qm(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.parent.isBlock)return!1;if(t){let s=i.parentOffset==i.parent.content.size,o=e.tr;(e.selection instanceof K||e.selection instanceof Ee)&&o.deleteSelection();let l=r.depth==0?null:ao(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=s&&l?[{type:l}]:void 0,u=Kr(o.doc,o.mapping.map(r.pos),1,a);if(!a&&!u&&Kr(o.doc,o.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(a=[{type:l}]),u=!0),u&&(o.split(o.mapping.map(r.pos),1,a),!s&&!r.parentOffset&&r.parent.type!=l)){let c=o.mapping.map(r.before()),h=o.doc.resolve(c);l&&r.node(-1).canReplaceWith(h.index(),h.index()+1,l)&&o.setNodeMarkup(o.mapping.map(r.before()),l)}t(o.scrollIntoView())}return!0}}const _m=qm(),Jm=(n,e)=>(e&&e(n.tr.setSelection(new Ee(n.doc))),!0);function Hm(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||no(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).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&&Hm(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 Te(e.pos-1,f,e.pos,f,new O(p,1,0),o.length,!0)),k=f+2*o.length;no(y.doc,k)&&y.join(k),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&&to(h);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(h,d).scrollIntoView()),!0;if(u&&On(s,"start",!0)&&On(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 A=n.tr.step(new Te(e.pos-p.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new O(x,p.length,0),0,!0));t(A.scrollIntoView())}return!0}}return!1}function Tu(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 Km=Tu(-1),Um=Tu(1);function d1(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 p1(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 Qm(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||!r)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function m1(n,e=null,t){let r=t!==!1;return function(i,s){let{empty:o,$cursor:l,ranges:a}=i.selection;if(o&&!l||!Qm(i.doc,a,n,r))return!1;if(s)if(l)n.isInSet(i.storedMarks||l.marks())?s(i.tr.removeStoredMark(n)):s(i.tr.addStoredMark(n.create(e)));else{let u,c=i.tr;u=!a.some(h=>i.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:d,$to:f}=a[h];if(!u)c.removeMark(d.pos,f.pos,n);else{let p=d.pos,y=f.pos,k=d.nodeAfter,x=f.nodeBefore,A=k&&k.isText?/^\s*/.exec(k.text)[0].length:0,M=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;p+A<y&&(p+=A,y-=M),c.addMark(p,y,n.create(e))}}s(c.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 is=vi(lo,Su,wu),El=vi(lo,Bm,Lm);const st={Enter:vi(Vm,Wm,jm,_m),"Mod-Enter":$m,Backspace:is,"Mod-Backspace":is,"Shift-Backspace":is,Delete:El,"Mod-Delete":El,"Mod-a":Jm},Eu={"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":Km,"Ctrl-e":Um};for(let n in st)Eu[n]=st[n];const Ym=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Gm=Ym?Eu:st;var It={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:'"'},Xm=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ue=0;ue<10;ue++)It[48+ue]=It[96+ue]=String(ue);for(var ue=1;ue<=24;ue++)It[ue+111]="F"+ue;for(var ue=65;ue<=90;ue++)It[ue]=String.fromCharCode(ue+32),bi[ue]=String.fromCharCode(ue);for(var ss in It)bi.hasOwnProperty(ss)||(bi[ss]=It[ss]);function eg(n){var e=Xm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Zm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?bi:It)[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 tg=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ng(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))tg?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 rg(n){let e=Object.create(null);for(let t in n)e[ng(t)]=n[t];return e}function ls(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 ig(n){return new Fi({props:{handleKeyDown:sg(n)}})}function sg(n){let e=rg(n);return function(t,r){let i=eg(r),s,o=e[ls(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ls(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=It[r.keyCode])&&s!=i){let l=e[ls(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},gr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let As=null;const it=function(n,e,t){let r=As||(As=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},og=function(){As=null},Gt=function(n,e,t,r){return t&&(Nl(n,e,t,r,-1)||Nl(n,e,t,r,1))},lg=/^(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||Sr(n)||lg.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 ag(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&&!Sr(n))e=ce(n),n=n.parentNode;else return null}}function ug(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&&!Sr(n))e=ce(n)+1,n=n.parentNode;else return null}}function cg(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 Sr(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 Bi=function(n){return n.focusNode&&Gt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function jt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function hg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fg(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,zt=Ye&&Ye.userAgent||"",zs=/Edge\/(\d+)/.exec(zt),Nu=/MSIE \d/.exec(zt),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zt),Se=!!(Nu||Rs||zs),Ct=Nu?document.documentMode:Rs?+Rs[1]:zs?+zs[1]:0,_e=!Se&&/gecko\/(\d+)/i.test(zt);_e&&+(/Firefox\/(\d+)/.exec(zt)||[0,0])[1];const Ps=!Se&&/Chrome\/(\d+)/.exec(zt),pe=!!Ps,Iu=Ps?+Ps[1]:0,ge=!Se&&!!Ye&&/Apple Computer/.test(Ye.vendor),Tn=ge&&(/Mobile\/\w+/.test(zt)||!!Ye&&Ye.maxTouchPoints>2),De=Tn||(Ye?/Mac/.test(Ye.platform):!1),dg=Ye?/Win/.test(Ye.platform):!1,$e=/Android \d/.test(zt),wr=!!Il&&"webkitFontSmoothing"in Il.documentElement.style,pg=wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mg(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 gg(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 Dl(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=gr(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,u=a?mg(s):gg(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 yg(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:Du(n.dom)}}function Du(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=gr(r));return e}function xg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Au(t,r==0?0:r-e)}function Au(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 rn=null;function kg(n){if(n.setActive)return n.setActive();if(rn)return n.focus(rn);let e=Du(n);n.focus(rn==null?{get preventScroll(){return rn={preventScroll:!0},!0}}:void 0),rn||(rn=!1,Au(e,0))}function zu(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?bg(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:zu(t,i)}function bg(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&&uo(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function uo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Sg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function wg(n,e,t){let{node:r,offset:i}=zu(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 Cg(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(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 Ru(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(uo(e,u))return Ru(o,e,u)}}if((s=(s+1)%r)==i)break}return n}function Mg(n,e){let t=n.dom.ownerDocument,r,i=0,s=fg(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(!uo(e,u)||(o=Ru(n.dom,e,u),!o))return null}if(ge)for(let u=o;r&&u;u=gr(u))u.draggable&&(r=void 0);if(o=Sg(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;wr&&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=Cg(n,r,i,e))}l==null&&(l=wg(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Al(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(Al(r))return r}return Array.prototype.find.call(t,Al)||n.getBoundingClientRect()}const Og=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pu(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=wr||_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 Rn(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++,Rn(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 as(a.getBoundingClientRect(),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];if(a.nodeType==1)return as(a.getBoundingClientRect(),!0)}return as(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 Rn(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 Rn(mt(u,-1),!0)}return Rn(mt(r.nodeType==3?it(r):r,-t),t>=0)}function Rn(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 as(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 Fu(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 Tg(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Fu(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=Pu(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 Eg=/[\u0590-\u08ac]/;function Ng(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?!Eg.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Fu(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 Ig(n,e,t){return zl==e&&Rl==t?Pl:(zl=e,Rl=t,Pl=t=="up"||t=="down"?Tg(n,e,t):Ng(n,e,t))}const Re=0,Fl=1,qt=2,Ge=3;class Cr{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;)i=i.children[0];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 Bu){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 vu&&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 d=0,f=0;d<this.children.length;d++){let p=this.children[d],y=f+p.size;if(s>f&&o<y)return p.setSelection(e-f-p.border,t-f-p.border,r,i);f=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),u=r.getSelection(),c=!1;if((_e||ge)&&e==t){let{node:d,offset:f}=l;if(d.nodeType==3){if(c=!!(f&&d.nodeValue[f-1]==`
|
|
40
|
-
`),c&&f==d.nodeValue.length)for(let p=d,y;p;p=p.parentNode){if(y=p.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ce(y)+1});break}let k=p.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let p=d.childNodes[f-1];c=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(_e&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let d=u.focusNode.childNodes[u.focusOffset];d&&d.contentEditable=="false"&&(i=!0)}if(!(i||c&&ge)&&Gt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Gt(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((u.extend||e==t)&&!c){u.collapse(l.node,l.offset);try{e!=t&&u.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>t){let f=l;l=a,a=f}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}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?qt: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?qt:Ge}r=o}this.dirty=qt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?qt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class vu extends Cr{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 Dg extends Cr{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 Xt extends Cr{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Nn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Xt(e,t,o.dom,o.contentDOM||o.dom)}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=Xt.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Bs(s,t,o,r)),e>0&&(s=Bs(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Mt extends Cr{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}=Nn.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=$u(c,r,t),u?a=new Ag(e,t,r,i,c,h||null,d,u,s,o+1):t.isText?new Li(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)&&vs(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 Rg(this,o&&o.node,e);vg(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==qt)&&(o&&this.protectLocalComposition(e,o),Lu(this.contentDOM,this.children,e),Tn&&Bg(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=Lg(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 Dg(this,s,t,i);e.input.compositionNodes.push(o),this.children=Bs(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(vs(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Vu(this.dom,this.nodeDOM,Fs(this.outerDeco,this.node,t),Fs(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 vl(n,e,t,r,i){$u(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 Li 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 Li(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 Bu extends Cr{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 Ag 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){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):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 Lu(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=Bl(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof Xt){let a=r?r.previousSibling:n.lastChild;Lu(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Bl(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const sr=function(n){n&&(this.nodeName=n)};sr.prototype=Object.create(null);const _t=[new sr];function Fs(n,e,t){if(n.length==0)return _t;let r=t?_t[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 Vu(n,e,t,r){if(t==_t&&r==_t)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=_t[0]),i=a}zg(i,l||_t[0],o)}return i}function zg(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 $u(n,e,t){return Vu(n,n,_t,Fs(e,t,n.nodeType!=1))}function vs(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 Bl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Rg{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Pg(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=Xt.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=qt),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&&vs(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.top.children[this.index]=h,h.contentDOM&&(h.dirty=qt,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))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 vu(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 Xt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Li)||/\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 Bu(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 Pg(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 Xt)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 Fg(n,e){return n.type.side-e.type.side}function vg(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(Fg);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 Bg(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 Lg(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 Bs(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 co(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(Bi(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&R.isSelectable(c)&&i.parent&&!(c.isInline&&cg(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;u=new R(o==h?l:r.resolve(h))}}else{let c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;u=ho(n,a,l,c)}return u}function Wu(n){return n.editable?n.hasFocus():qu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ot(n,e=!1){let t=n.state.selection;if(ju(n,t),!!Wu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Gt(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)$g(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.root,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&&Vg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ll=ge||pe&&Iu<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 us(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return us(i);if(s)return us(s)}}function us(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 Vg(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(()=>{(!Wu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $g(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 ho(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||K.between(e,t,r)}function jl(n){return n.editable&&!n.hasFocus()?!1:qu(n)}function qu(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 Wg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Gt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ls(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 ql(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=Ls(n.state,e);return i&&i instanceof R?xt(n,i):!1}else if(!(De&&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)):wr?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=Ls(n.state,e);return i?xt(n,i):!1}}}function Si(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 sn(n,e){return e<0?jg(n):qg(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<Si(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(_u(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=Si(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Vs(n,t,r):i&&Vs(n,i,s)}function qg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Si(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(_u(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=Si(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Vs(n,s,o)}function _u(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function _g(n,e){for(;n&&e==n.childNodes.length&&!Sr(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 Jg(n,e){for(;n&&!e&&!Sr(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 Vs(n,e,t){if(e.nodeType!=3){let s,o;(o=_g(e,t))?(e=o,t=0):(s=Jg(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Bi(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&&ot(n)},50)}function _l(n,e){let t=n.state.doc.resolve(e);if(!(pe||dg)&&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||De&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ls(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 Ee?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 Hg(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 Kg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ug(n,e){let t=e.keyCode,r=Kg(e);if(t==8||De&&t==72&&r=="c")return Hl(n,-1)||sn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return Hl(n,1)||sn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let i=t==37?_l(n,n.state.selection.from)=="ltr"?-1:1:-1;return ql(n,i,r)||sn(n,i)}else if(t==39||De&&t==70&&r=="c"){let i=t==39?_l(n,n.state.selection.from)=="ltr"?1:-1:1;return ql(n,i,r)||sn(n,i)}else{if(t==38||De&&t==80&&r=="c")return Jl(n,-1,r)||sn(n,-1);if(t==40||De&&t==78&&r=="c")return Hg(n)||Jl(n,1,r)||sn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ju(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")||Nn.fromSchema(n.state.schema),l=Gu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=Yu[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,`
|
|
36
|
+
`),r;function i(s){return t.stack.push(s),o;function o(){t.stack.pop()}}}function Sp(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function wp(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Cp(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Mp(n,e){return fp(n,this,e)}function Tp(n,e){return dp(n,this,e)}function Op(n,e){return yp(this,n,e)}function bs(n){const e=this;e.compiler=t;function t(r){return bp(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function ol(n){if(n)throw n}var vr=Object.prototype.hasOwnProperty,ru=Object.prototype.toString,ll=Object.defineProperty,al=Object.getOwnPropertyDescriptor,ul=function(e){return typeof Array.isArray=="function"?Array.isArray(e):ru.call(e)==="[object Array]"},cl=function(e){if(!e||ru.call(e)!=="[object Object]")return!1;var t=vr.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&vr.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||vr.call(e,i)},hl=function(e,t){ll&&t.name==="__proto__"?ll(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},fl=function(e,t){if(t==="__proto__")if(vr.call(e,t)){if(al)return al(e,t).value}else return;return e[t]},Ep=function n(){var e,t,r,i,s,o,l=arguments[0],a=1,u=arguments.length,c=!1;for(typeof l=="boolean"&&(c=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<u;++a)if(e=arguments[a],e!=null)for(t in e)r=fl(l,t),i=fl(e,t),l!==i&&(c&&i&&(cl(i)||(s=ul(i)))?(s?(s=!1,o=r&&ul(r)?r:[]):o=r&&cl(r)?r:{},hl(l,{name:t,newValue:n(c,o,i)})):typeof i<"u"&&hl(l,{name:t,newValue:i}));return l};const _i=Oc(Ep);function Ss(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 Np(){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?Ip(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 Ip(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 Ke={basename:Dp,dirname:Ap,extname:zp,join:Rp,sep:"/"};function Dp(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');br(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 Ap(n){if(br(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 zp(n){br(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 Rp(...n){let e=-1,t;for(;++e<n.length;)br(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Pp(t)}function Pp(n){br(n);const e=n.codePointAt(0)===47;let t=Fp(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Fp(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 br(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const vp={cwd:Bp};function Bp(){return"/"}function ws(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function Lp(n){if(typeof n=="string")n=new URL(n);else if(!ws(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 Vp(n)}function Vp(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 Ji=["history","path","basename","stem","extname","dirname"];class $p{constructor(e){let t;e?ws(e)?t={path:e}:typeof e=="string"||Wp(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<Ji.length;){const s=Ji[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)Ji.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Ke.basename(this.path):void 0}set basename(e){Ki(e,"basename"),Hi(e,"basename"),this.path=Ke.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Ke.dirname(this.path):void 0}set dirname(e){dl(this.basename,"dirname"),this.path=Ke.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Ke.extname(this.path):void 0}set extname(e){if(Hi(e,"extname"),dl(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=Ke.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){ws(e)&&(e=Lp(e)),Ki(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Ke.basename(this.path,this.extname):void 0}set stem(e){Ki(e,"stem"),Hi(e,"stem"),this.path=Ke.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 Hi(n,e){if(n&&n.includes(Ke.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Ke.sep+"`")}function Ki(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function dl(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Wp(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},qp={}.hasOwnProperty;class Xs 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=Np()}copy(){const e=new Xs;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(_i(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Yi("data",this.frozen),this.namespace[e]=t,this):qp.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Yi("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=Er(e),r=this.parser||this.Parser;return Ui("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),Ui("process",this.parser||this.Parser),Qi("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(s,o){const l=Er(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);Jp(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(),Ui("processSync",this.parser||this.Parser),Qi("processSync",this.compiler||this.Compiler),this.process(e,i),ml("processSync","process",t),r;function i(s,o){t=!0,ol(s),r=o}}run(e,t,r){pl(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=Er(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),ml("runSync","run",r),i;function s(o,l){ol(o),i=l,r=!0}}stringify(e,t){this.freeze();const r=Er(t),i=this.compiler||this.Compiler;return Qi("stringify",i),pl(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Yi("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=_i(!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];Ss(y)&&Ss(f)&&(f=_i(!0,y,f)),r[d]=[u,f,...p]}}}}const Cs=new Xs().freeze();function Ui(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Qi(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Yi(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 pl(n){if(!Ss(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function ml(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Er(n){return _p(n)?n:new $p(n)}function _p(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Jp(n){return typeof n=="string"||Hp(n)}function Hp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var iu=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},F=(n,e,t)=>(iu(n,e,"read from private field"),t?t.call(n):e.get(n)),ne=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},G=(n,e,t,r)=>(iu(n,e,"write to private field"),e.set(n,t),t);let su=class{},ou=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 Zs extends su{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 Zs(e,t,r)}}var He,Wn,Br,Lr,Vr,jn,qn;const Ms=class extends ou{constructor(e){super(),ne(this,He,void 0),ne(this,Wn,void 0),ne(this,Br,void 0),ne(this,Lr,void 0),ne(this,Vr,void 0),ne(this,jn,void 0),ne(this,qn,void 0),G(this,He,$.none),G(this,Wn,t=>t.isText),G(this,Br,(t,r)=>{if(F(this,Wn).call(this,t)&&F(this,Wn).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 zc(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(Zs.create(t,[],r)),this),G(this,jn,()=>{G(this,He,$.none);const t=this.close();return F(this,qn).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>(F(this,jn).call(this),this),G(this,qn,(t,r,i)=>{const s=t.createAndFill(r,i,F(this,He));if(!s)throw Ac(t,r,i);return this.push(s),s}),this.addNode=(t,r,i)=>(F(this,qn).call(this,t,r,i),this),this.openMark=(t,r)=>{const i=t.create(r);return G(this,He,i.addToSet(F(this,He))),this},this.closeMark=t=>(G(this,He,t.removeFromSet(F(this,He))),this),this.addText=t=>{const r=this.top();if(!r)throw aa();const i=r.pop(),s=this.schema.text(t,F(this,He));if(!i)return r.push(s),this;const o=F(this,Br).call(this,i,s);return o?(r.push(o),this):(r.push(i,s),this)},this.build=()=>{let t;do t=F(this,jn).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}};He=new WeakMap,Wn=new WeakMap,Br=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,jn=new WeakMap,qn=new WeakMap,Ms.create=(n,e)=>{const t=new Ms(n);return r=>(t.run(e,r),t.toDoc())};let Kp=Ms;const Ts=class extends su{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()}}};Ts.create=(n,e,t,r={})=>new Ts(n,e,t,r);let gl=Ts;const Up=n=>Object.prototype.hasOwnProperty.call(n,"size");var rt,_n,$r,Wr,Jn,jr,Hn,qr,_r,an,Vt,Jr,Kn;const Os=class extends ou{constructor(e){super(),ne(this,rt,void 0),ne(this,_n,void 0),ne(this,$r,void 0),ne(this,Wr,void 0),ne(this,Jn,void 0),ne(this,jr,void 0),ne(this,Hn,void 0),ne(this,qr,void 0),ne(this,_r,void 0),ne(this,an,void 0),ne(this,Vt,void 0),ne(this,Jr,void 0),ne(this,Kn,void 0),G(this,rt,$.none),G(this,_n,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Rc(t.type);return r}),G(this,$r,t=>F(this,_n).call(this,t).spec.toMarkdown.runner(this,t)),G(this,Wr,(t,r)=>F(this,_n).call(this,t).spec.toMarkdown.runner(this,t,r)),G(this,Jn,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,Kn).call(this,s))}),G(this,jr,(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,Hn,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,jr).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,Hn).call(this,d))}}return i.concat(s)},[])),t}),G(this,qr,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(gl.create(t,void 0,r,i)),this),G(this,_r,(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,Vt).call(this,"text",void 0,i);const c=r();return s.length&&F(this,Vt).call(this,"text",void 0,s),c}),G(this,an,(t=!1)=>{const r=this.close(),i=()=>F(this,Vt).call(this,r.type,r.children,r.value,r.props);return t?F(this,_r).call(this,r,i):i()}),this.closeNode=()=>(F(this,an).call(this),this),G(this,Vt,(t,r,i,s)=>{const o=gl.create(t,r,i,s),l=F(this,Hn).call(this,F(this,qr).call(this,o));return this.push(l),l}),this.addNode=(t,r,i,s)=>(F(this,Vt).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,Kn,t=>{t.isInSet(F(this,rt))&&(G(this,rt,t.type.removeFromSet(F(this,rt))),F(this,an).call(this,!0))}),this.withMark=(t,r,i,s)=>(F(this,Jr).call(this,t,r,i,s),this),this.closeMark=t=>(F(this,Kn).call(this,t),this),this.build=()=>{let t=null;do t=F(this,an).call(this);while(this.size());return t},this.next=t=>Up(t)?(t.forEach(r=>{F(this,Jn).call(this,r)}),this):(F(this,Jn).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};rt=new WeakMap,_n=new WeakMap,$r=new WeakMap,Wr=new WeakMap,Jn=new WeakMap,jr=new WeakMap,Hn=new WeakMap,qr=new WeakMap,_r=new WeakMap,an=new WeakMap,Vt=new WeakMap,Jr=new WeakMap,Kn=new WeakMap,Os.create=(n,e)=>{const t=new Os(n);return r=>(t.run(r),t.toString(e))};let Qp=Os;const lu=65535,au=Math.pow(2,16);function Yp(n,e){return n+e*au}function yl(n){return n&lu}function Gp(n){return(n-(n&lu))/au}const uu=1,cu=2,Hr=4,hu=8;class Es{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&hu)>0}get deletedBefore(){return(this.delInfo&(uu|Hr))>0}get deletedAfter(){return(this.delInfo&(cu|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=yl(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+Gp(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:Yp(l/3,e-a),y=e==a?cu:e==h?uu:Hr;return(t<0?e!=a:e!=h)&&(y|=hu),new Es(f,y,p)}i+=c-u}return r?e+i:new Es(e+i,0,null)}touches(e,t){let r=0,i=yl(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 Es(e,i,null)}}const Gi=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=Gi[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 Gi)throw new RangeError("Duplicate use of step JSON ID "+e);return Gi[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 eo(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(eo(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(eo(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 Qe(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 Qe 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(eo(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 Qe(t.pos,r.pos,this.mark)}merge(e){return e instanceof Qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qe(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 Qe(t.from,t.to,e.markFromJSON(t.mark))}}me.jsonID("removeMark",Qe);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 Cn(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 Cn 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 Cn(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 Cn(t.pos,e.markFromJSON(t.mark))}}me.jsonID("removeNodeMark",Cn);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&&Ns(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 Oe 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&&(Ns(e,this.from,this.gapFrom)||Ns(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 Oe(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 Oe(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 Oe(t.from,t.to,t.gapFrom,t.gapTo,T.fromJSON(e,t.slice),t.insert,!!t.structure)}}me.jsonID("replaceAround",Oe);function Ns(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 Xp(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 Qe(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 Zp(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 Ai){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 Qe(o.from,o.to,o.style)))}function fu(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 Qe(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 em(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function to(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||!em(i,s,o))break}return null}function tm(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 Oe(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=nm(n,e),s=i&&rm(r,e);return s?i.map(xl).concat({type:e,attrs:t}).concat(s.map(xl)):null}function xl(n){return{type:n,attrs:null}}function nm(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 rm(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 im(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 Oe(i,s,i,s,new T(r,0,0),t.length,!0))}function sm(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)&&am(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&&lm(n,o,l,s),fu(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 Oe(h,d,h+1,d-1,new T(C.from(r.create(a,null,o.marks)),0,0),1,!0)),u===!0&&om(n,o,l,s),!1}})}function om(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 lm(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 am(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function um(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 Oe(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 cm(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 no(n,e){let t=n.resolve(e),r=t.index();return hm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function hm(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function fm(n,e,t){let r=new de(e-t,e+t,T.empty,!0);n.step(r)}function dm(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 pm(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 ro(n,e,t=e,r=T.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return pu(i,s,r)?new de(e,t,r):new mm(i,s,r).fit()}function pu(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class mm{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 Oe(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=Xi(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=Xi(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=Xi(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new T(Un(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new T(Un(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(mu(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=Qn(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(Un(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new T(Un(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||!Zi(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=Zi(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=Zi(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=Qn(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=Qn(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=Qn(this.placed,this.frontier.length,t))}}function Un(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Un(n.firstChild.content,e-1,t)))}function Qn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qn(n.lastChild.content,e-1,t)))}function Xi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function mu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,mu(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 Zi(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&&!gm(t,s.content,o)?l:null}function gm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ym(n){return n.spec.defining||n.spec.definingForContent}function xm(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(pu(i,s,r))return n.step(new de(e,t,r));let o=yu(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=ym(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 A=i.node(k-1),M=i.index(k-1);if(A.canReplaceWith(M,M,p.type,p.marks))return n.replace(i.before(k),x?s.after(k):t,new T(gu(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 gu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(gu(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 km(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=dm(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new T(C.from(r),0,0))}function bm(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=yu(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)return n.delete(r.before(o),t);n.delete(e,t)}function yu(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 xn 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 xn(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 xn(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 xn(t.pos,t.attr,t.value)}}me.jsonID("attr",xn);class mr 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 mr(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 mr(t.attr,t.value)}}me.jsonID("docAttr",mr);let Mn=class extends Error{};Mn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Mn.prototype=Object.create(Error.prototype);Mn.prototype.constructor=Mn;Mn.prototype.name="TransformError";class Sm{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 Mn(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=ro(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 xm(this,e,t,r),this}replaceRangeWith(e,t,r){return km(this,e,t,r),this}deleteRange(e,t){return bm(this,e,t),this}lift(e,t){return tm(this,e,t),this}join(e,t=1){return fm(this,e,t),this}wrap(e,t){return im(this,e,t),this}setBlockType(e,t=e,r,i=null){return sm(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return um(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new xn(e,t,r)),this}setDocAttribute(e,t){return this.step(new mr(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 Cn(e,t)),this}split(e,t=1,r){return cm(this,e,t,r),this}addMark(e,t,r){return Xp(this,e,t,r),this}removeMark(e,t,r){return Zp(this,e,t,r),this}clearIncompatible(e,t,r){return fu(this,e,t,r),this}}const es=Object.create(null);class J{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new wm(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&&Sl(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),Sl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new K(e):un(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?un(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):un(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 Ee(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new Ee(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new Ee(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=es[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 es)throw new RangeError("Duplicate use of selection JSON ID "+e);return es[e]=t,t.prototype.jsonID=e,t}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class wm{constructor(e,t){this.$from=e,this.$to=t}}let kl=!1;function bl(n){!kl&&!n.parent.inlineContent&&(kl=!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){bl(e),bl(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 Pi(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 Pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pi(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 io(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 io{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Pi(r,r):new io(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):J.near(t)}}class Ee 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 Ee(e)}map(e){return new Ee(e)}eq(e){return e instanceof Ee}getBookmark(){return Cm}}J.jsonID("all",Ee);const Cm={map(){return this},resolve(n){return new Ee(n)}};function un(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=un(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Sl(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof de||i instanceof Oe))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 wl=1,Nr=2,Cl=4;class Mm extends Sm{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|wl)&~Nr,this.storedMarks=null,this}get selectionSet(){return(this.updated&wl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Nr,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&Nr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Nr,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 Yn{constructor(e,t,r){this.name=e,this.init=Ml(t.init,r),this.apply=Ml(t.apply,r)}}const Tm=[new Yn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Yn("selection",{init(n,e){return n.selection||J.atStart(e.doc)},apply(n){return n.selection}}),new Yn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Yn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ts{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tm.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 Yn(r.key,r.spec.state,r))})}}class mn{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 mn(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 Mm(this)}static create(e){let t=new ts(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new mn(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 ts(this.schema,e.plugins),r=t.fields,i=new mn(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 ts(e.schema,e.plugins),s=new mn(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 xu(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xu(i,e,{})),t[r]=i}return t}class Fi{constructor(e){this.spec=e,this.props={},e.props&&xu(e.props,this,this.props),this.key=e.key?e.key.key:ku("plugin")}getState(e){return e[this.key]}}const ns=Object.create(null);function ku(n){return n in ns?n+"$"+ ++ns[n]:(ns[n]=0,n+"$")}class so{constructor(e="key"){this.key=ku(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"?Om(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Om(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 Em=(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 c1(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&&no(u.doc,o-1)&&(!r||r(s,f))&&u.join(o-1),u})}function h1(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 Nt=typeof navigator<"u"?navigator:null,Tl=typeof document<"u"?document:null,Zt=Nt&&Nt.userAgent||"",Is=/Edge\/(\d+)/.exec(Zt),bu=/MSIE \d/.exec(Zt),Ds=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zt),oo=!!(bu||Ds||Is);bu?document.documentMode:Ds?+Ds[1]:Is&&+Is[1];const Nm=!oo&&/gecko\/(\d+)/i.test(Zt);Nm&&+(/Firefox\/(\d+)/.exec(Zt)||[0,0])[1];const Ol=!oo&&/Chrome\/(\d+)/.exec(Zt);Ol&&+Ol[1];const Im=!oo&&!!Nt&&/Apple Computer/.test(Nt.vendor),Dm=Im&&(/Mobile\/\w+/.test(Zt)||!!Nt&&Nt.maxTouchPoints>2);Dm||Nt&&/Mac/.test(Nt.platform);const Am=!!Tl&&"webkitFontSmoothing"in Tl.documentElement.style;Am&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function rs(n,e,t,r,i,s){if(n.composing)return!1;const o=n.state,l=o.doc.resolve(e);if(l.parent.type.spec.code)return!1;const a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"")+r;for(let u=0;u<i.length;u++){const c=i[u].match.exec(a),h=c&&c[0]&&i[u].handler(o,c,e-(c[0].length-r.length),t);if(h)return n.dispatch(h.setMeta(s,{transform:h,from:e,to:t,text:r})),!0}return!1}const zm=new so("MILKDOWN_CUSTOM_INPUTRULES");function Rm({rules:n}){const e=new Fi({key:zm,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 rs(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&rs(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?rs(t,i.pos,i.pos,`
|
|
38
|
+
`,n,e):!1}}});return e}function f1(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},A=(l=t.updateCaptured)==null?void 0:l.call(t,x);if(Object.assign(x,A),{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/),v=s+p.indexOf(f),L=v+f.length;y=(a=h.storedMarks)!=null?a:[],L<o&&h.delete(L,o),v>s&&h.delete(s+M,v),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 Pm(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function d1(n,e){if(!(n instanceof R))return;const{node:t,$from:r}=n;if(Pm(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const lo=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Fm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Su=(n,e,t)=>{let r=Fm(n,t);if(!r)return!1;let i=Cu(r);if(!i){let o=r.blockRange(),l=o&&to(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Tu(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Tn(s,"end")||R.isSelectable(s)))for(let o=r.depth;;o--){let l=ro(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(Tn(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 Tn(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 wu=(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=Cu(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 Cu(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 vm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Bm=(n,e,t)=>{let r=vm(n,t);if(!r)return!1;let i=Mu(r);if(!i)return!1;let s=i.nodeAfter;if(Tu(n,i,e,1))return!0;if(r.parent.content.size==0&&(Tn(s,"start")||R.isSelectable(s))){let o=ro(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(Tn(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},Lm=(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=Mu(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 Mu(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 Vm=(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 ao(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 $m=(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=ao(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},Wm=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ee||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ao(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&&to(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function qm(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.parent.isBlock)return!1;if(t){let s=i.parentOffset==i.parent.content.size,o=e.tr;(e.selection instanceof K||e.selection instanceof Ee)&&o.deleteSelection();let l=r.depth==0?null:ao(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=s&&l?[{type:l}]:void 0,u=Kr(o.doc,o.mapping.map(r.pos),1,a);if(!a&&!u&&Kr(o.doc,o.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(a=[{type:l}]),u=!0),u&&(o.split(o.mapping.map(r.pos),1,a),!s&&!r.parentOffset&&r.parent.type!=l)){let c=o.mapping.map(r.before()),h=o.doc.resolve(c);l&&r.node(-1).canReplaceWith(h.index(),h.index()+1,l)&&o.setNodeMarkup(o.mapping.map(r.before()),l)}t(o.scrollIntoView())}return!0}}const _m=qm(),Jm=(n,e)=>(e&&e(n.tr.setSelection(new Ee(n.doc))),!0);function Hm(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||no(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Tu(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Hm(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 Oe(e.pos-1,f,e.pos,f,new T(p,1,0),o.length,!0)),k=f+2*o.length;no(y.doc,k)&&y.join(k),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&&to(h);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(h,d).scrollIntoView()),!0;if(u&&Tn(s,"start",!0)&&Tn(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 A=n.tr.step(new Oe(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(A.scrollIntoView())}return!0}}return!1}function Ou(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 Km=Ou(-1),Um=Ou(1);function p1(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 m1(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 Qm(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||!r)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function g1(n,e=null,t){let r=t!==!1;return function(i,s){let{empty:o,$cursor:l,ranges:a}=i.selection;if(o&&!l||!Qm(i.doc,a,n,r))return!1;if(s)if(l)n.isInSet(i.storedMarks||l.marks())?s(i.tr.removeStoredMark(n)):s(i.tr.addStoredMark(n.create(e)));else{let u,c=i.tr;u=!a.some(h=>i.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:d,$to:f}=a[h];if(!u)c.removeMark(d.pos,f.pos,n);else{let p=d.pos,y=f.pos,k=d.nodeAfter,x=f.nodeBefore,A=k&&k.isText?/^\s*/.exec(k.text)[0].length:0,M=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;p+A<y&&(p+=A,y-=M),c.addMark(p,y,n.create(e))}}s(c.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 is=vi(lo,Su,wu),El=vi(lo,Bm,Lm);const st={Enter:vi(Vm,Wm,jm,_m),"Mod-Enter":$m,Backspace:is,"Mod-Backspace":is,"Shift-Backspace":is,Delete:El,"Mod-Delete":El,"Mod-a":Jm},Eu={"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":Km,"Ctrl-e":Um};for(let n in st)Eu[n]=st[n];const Ym=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Gm=Ym?Eu:st;var It={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:'"'},Xm=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ue=0;ue<10;ue++)It[48+ue]=It[96+ue]=String(ue);for(var ue=1;ue<=24;ue++)It[ue+111]="F"+ue;for(var ue=65;ue<=90;ue++)It[ue]=String.fromCharCode(ue+32),bi[ue]=String.fromCharCode(ue);for(var ss in It)bi.hasOwnProperty(ss)||(bi[ss]=It[ss]);function eg(n){var e=Xm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Zm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?bi:It)[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 tg=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ng(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))tg?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 rg(n){let e=Object.create(null);for(let t in n)e[ng(t)]=n[t];return e}function ls(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 ig(n){return new Fi({props:{handleKeyDown:sg(n)}})}function sg(n){let e=rg(n);return function(t,r){let i=eg(r),s,o=e[ls(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ls(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=It[r.keyCode])&&s!=i){let l=e[ls(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},gr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let As=null;const it=function(n,e,t){let r=As||(As=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},og=function(){As=null},Gt=function(n,e,t,r){return t&&(Nl(n,e,t,r,-1)||Nl(n,e,t,r,1))},lg=/^(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||Sr(n)||lg.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 ag(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&&!Sr(n))e=ce(n),n=n.parentNode;else return null}}function ug(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&&!Sr(n))e=ce(n)+1,n=n.parentNode;else return null}}function cg(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 Sr(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 Bi=function(n){return n.focusNode&&Gt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function jt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function hg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fg(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,zt=Ye&&Ye.userAgent||"",zs=/Edge\/(\d+)/.exec(zt),Nu=/MSIE \d/.exec(zt),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zt),Se=!!(Nu||Rs||zs),Ct=Nu?document.documentMode:Rs?+Rs[1]:zs?+zs[1]:0,_e=!Se&&/gecko\/(\d+)/i.test(zt);_e&&+(/Firefox\/(\d+)/.exec(zt)||[0,0])[1];const Ps=!Se&&/Chrome\/(\d+)/.exec(zt),pe=!!Ps,Iu=Ps?+Ps[1]:0,ge=!Se&&!!Ye&&/Apple Computer/.test(Ye.vendor),On=ge&&(/Mobile\/\w+/.test(zt)||!!Ye&&Ye.maxTouchPoints>2),De=On||(Ye?/Mac/.test(Ye.platform):!1),dg=Ye?/Win/.test(Ye.platform):!1,$e=/Android \d/.test(zt),wr=!!Il&&"webkitFontSmoothing"in Il.documentElement.style,pg=wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mg(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 gg(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 Dl(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=gr(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,u=a?mg(s):gg(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 yg(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:Du(n.dom)}}function Du(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=gr(r));return e}function xg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Au(t,r==0?0:r-e)}function Au(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 rn=null;function kg(n){if(n.setActive)return n.setActive();if(rn)return n.focus(rn);let e=Du(n);n.focus(rn==null?{get preventScroll(){return rn={preventScroll:!0},!0}}:void 0),rn||(rn=!1,Au(e,0))}function zu(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?bg(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:zu(t,i)}function bg(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&&uo(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function uo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Sg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function wg(n,e,t){let{node:r,offset:i}=zu(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 Cg(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(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 Ru(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(uo(e,u))return Ru(o,e,u)}}if((s=(s+1)%r)==i)break}return n}function Mg(n,e){let t=n.dom.ownerDocument,r,i=0,s=fg(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(!uo(e,u)||(o=Ru(n.dom,e,u),!o))return null}if(ge)for(let u=o;r&&u;u=gr(u))u.draggable&&(r=void 0);if(o=Sg(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;wr&&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=Cg(n,r,i,e))}l==null&&(l=wg(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Al(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(Al(r))return r}return Array.prototype.find.call(t,Al)||n.getBoundingClientRect()}const Tg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pu(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=wr||_e;if(r.nodeType==3)if(o&&(Tg.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 Rn(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++,Rn(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 as(a.getBoundingClientRect(),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];if(a.nodeType==1)return as(a.getBoundingClientRect(),!0)}return as(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 Rn(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 Rn(mt(u,-1),!0)}return Rn(mt(r.nodeType==3?it(r):r,-t),t>=0)}function Rn(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 as(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 Fu(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 Og(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Fu(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=Pu(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 Eg=/[\u0590-\u08ac]/;function Ng(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?!Eg.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Fu(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 Ig(n,e,t){return zl==e&&Rl==t?Pl:(zl=e,Rl=t,Pl=t=="up"||t=="down"?Og(n,e,t):Ng(n,e,t))}const Re=0,Fl=1,qt=2,Ge=3;class Cr{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;)i=i.children[0];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 Bu){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 vu&&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 d=0,f=0;d<this.children.length;d++){let p=this.children[d],y=f+p.size;if(s>f&&o<y)return p.setSelection(e-f-p.border,t-f-p.border,r,i);f=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),u=r.getSelection(),c=!1;if((_e||ge)&&e==t){let{node:d,offset:f}=l;if(d.nodeType==3){if(c=!!(f&&d.nodeValue[f-1]==`
|
|
40
|
+
`),c&&f==d.nodeValue.length)for(let p=d,y;p;p=p.parentNode){if(y=p.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ce(y)+1});break}let k=p.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let p=d.childNodes[f-1];c=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(_e&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let d=u.focusNode.childNodes[u.focusOffset];d&&d.contentEditable=="false"&&(i=!0)}if(!(i||c&&ge)&&Gt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Gt(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((u.extend||e==t)&&!c){u.collapse(l.node,l.offset);try{e!=t&&u.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>t){let f=l;l=a,a=f}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}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?qt: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?qt:Ge}r=o}this.dirty=qt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?qt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class vu extends Cr{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 Dg extends Cr{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 Xt extends Cr{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Nn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Xt(e,t,o.dom,o.contentDOM||o.dom)}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=Xt.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Bs(s,t,o,r)),e>0&&(s=Bs(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Mt extends Cr{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}=Nn.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=$u(c,r,t),u?a=new Ag(e,t,r,i,c,h||null,d,u,s,o+1):t.isText?new Li(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)&&vs(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 Rg(this,o&&o.node,e);vg(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==qt)&&(o&&this.protectLocalComposition(e,o),Lu(this.contentDOM,this.children,e),On&&Bg(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=Lg(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 Dg(this,s,t,i);e.input.compositionNodes.push(o),this.children=Bs(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(vs(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Vu(this.dom,this.nodeDOM,Fs(this.outerDeco,this.node,t),Fs(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 vl(n,e,t,r,i){$u(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 Li 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 Li(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 Bu extends Cr{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 Ag 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){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):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 Lu(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=Bl(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof Xt){let a=r?r.previousSibling:n.lastChild;Lu(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Bl(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const sr=function(n){n&&(this.nodeName=n)};sr.prototype=Object.create(null);const _t=[new sr];function Fs(n,e,t){if(n.length==0)return _t;let r=t?_t[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 Vu(n,e,t,r){if(t==_t&&r==_t)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=_t[0]),i=a}zg(i,l||_t[0],o)}return i}function zg(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 $u(n,e,t){return Vu(n,n,_t,Fs(e,t,n.nodeType!=1))}function vs(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 Bl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Rg{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Pg(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=Xt.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=qt),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&&vs(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.top.children[this.index]=h,h.contentDOM&&(h.dirty=qt,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))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 vu(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 Xt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Li)||/\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 Bu(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 Pg(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 Xt)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 Fg(n,e){return n.type.side-e.type.side}function vg(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(Fg);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 Bg(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 Lg(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 Bs(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 co(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(Bi(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&R.isSelectable(c)&&i.parent&&!(c.isInline&&cg(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;u=new R(o==h?l:r.resolve(h))}}else{let c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;u=ho(n,a,l,c)}return u}function Wu(n){return n.editable?n.hasFocus():qu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ot(n,e=!1){let t=n.state.selection;if(ju(n,t),!!Wu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Gt(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)$g(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.root,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&&Vg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ll=ge||pe&&Iu<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 us(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return us(i);if(s)return us(s)}}function us(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 Vg(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(()=>{(!Wu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $g(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 ho(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||K.between(e,t,r)}function jl(n){return n.editable&&!n.hasFocus()?!1:qu(n)}function qu(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 Wg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Gt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ls(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 ql(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=Ls(n.state,e);return i&&i instanceof R?xt(n,i):!1}else if(!(De&&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)):wr?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=Ls(n.state,e);return i?xt(n,i):!1}}}function Si(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 sn(n,e){return e<0?jg(n):qg(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<Si(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(_u(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=Si(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Vs(n,t,r):i&&Vs(n,i,s)}function qg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Si(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(_u(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=Si(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Vs(n,s,o)}function _u(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function _g(n,e){for(;n&&e==n.childNodes.length&&!Sr(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 Jg(n,e){for(;n&&!e&&!Sr(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 Vs(n,e,t){if(e.nodeType!=3){let s,o;(o=_g(e,t))?(e=o,t=0):(s=Jg(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Bi(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&&ot(n)},50)}function _l(n,e){let t=n.state.doc.resolve(e);if(!(pe||dg)&&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||De&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ls(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 Ee?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 Hg(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 Kg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ug(n,e){let t=e.keyCode,r=Kg(e);if(t==8||De&&t==72&&r=="c")return Hl(n,-1)||sn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return Hl(n,1)||sn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let i=t==37?_l(n,n.state.selection.from)=="ltr"?-1:1:-1;return ql(n,i,r)||sn(n,i)}else if(t==39||De&&t==70&&r=="c"){let i=t==39?_l(n,n.state.selection.from)=="ltr"?1:-1:1;return ql(n,i,r)||sn(n,i)}else{if(t==38||De&&t==80&&r=="c")return Jl(n,-1,r)||sn(n,-1);if(t==40||De&&t==78&&r=="c")return Hg(n)||Jl(n,1,r)||sn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ju(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")||Nn.fromSchema(n.state.schema),l=Gu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=Yu[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
41
|
|
|
42
|
-
`);return{dom:a,text:d,slice:e}}function Hu(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
|
|
43
|
-
`))),0,0):O.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=Nn.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=Gg(t),wr&&Xg(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")||wn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Qg.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Zg(Ul(l,+c[1],+c[2]),c[4]);else if(l=O.maxOpen(Yg(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 Qg=/^(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 Yg(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&&Uu(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Qu(o[o.length-1],s.length));let c=Ku(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return C.from(o)}return n}function Ku(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function Uu(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Uu(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(Ku(t,n,i+1))))}}function Qu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Qu(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 O($s(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O($s(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Yu={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 Gu(){return Ql||(Ql=document.implementation.createHTMLDocument("title"))}function Gg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Gu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Yu[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=n,i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Xg(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 Zg(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 O(i,s,o)}const ye={},xe={},ey={touchstart:!0,touchmove:!0};class ty{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.lastAndroidDelete=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 ny(n){for(let e in ye){let t=ye[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{iy(n,r)&&!fo(n,r)&&(n.editable||!(r.type in xe))&&t(n,r)},ey[e]?{passive:!0}:void 0)}ge&&n.dom.addEventListener("input",()=>null),Ws(n)}function wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function ry(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 Ws(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>fo(n,r))})}function fo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function iy(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 sy(n,e){!fo(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,!Zu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!($e&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Tn&&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,jt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ug(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(Zu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&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 Vi(n){return{left:n.clientX,top:n.clientY}}function oy(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function po(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 kn(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 ly(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(kn(n,new R(t)),!0):!1}function ay(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?(kn(n,R.create(n.state.doc,i)),!0):!1}function uy(n,e,t,r,i){return po(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?ay(n,t):ly(n,t))}function cy(n,e,t,r){return po(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function hy(n,e,t,r){return po(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||fy(n,t,r)}function fy(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(kn(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)kn(n,K.create(r,l+1,l+1+o.content.size));else if(R.isSelectable(o))kn(n,R.create(r,l));else continue;return!0}}function mo(n){return wi(n)}const Xu=De?"metaKey":"ctrlKey";ye.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=mo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&oy(t,n.input.lastClick)&&!t[Xu]&&(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(Vi(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new dy(n,o,t,!!r)):(s=="doubleClick"?cy:hy)(n,o.pos,o.inside,t)?t.preventDefault():wt(n,"pointer"))};class dy{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[Xu],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(()=>ot(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(Vi(e))),this.updateAllowDefault(e),this.allowDefault||!t?wt(this.view,"pointer"):uy(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)?(kn(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(),mo(n),wt(n,"pointer")};ye.touchmove=n=>{n.input.lastTouch=Date.now(),wt(n,"pointer")};ye.contextmenu=n=>mo(n);function Zu(n,e){return n.composing?!0:ge&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const py=$e?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(),wi(n,!0),n.markCursor=null;else if(wi(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}ec(n,py)};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++,ec(n,20))};function ec(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>wi(n),e))}function tc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=gy());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function my(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=ag(e.focusNode,e.focusOffset),r=ug(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 gy(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function wi(n,e=!1){if(!($e&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tc(n),e||n.docView&&n.docView.dirty){let t=co(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 yy(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 yr=Se&&Ct<15||Tn&&pg<604;ye.copy=xe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=yr?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Ju(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):yy(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function xy(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ky(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?xr(n,r.value,null,i,e):xr(n,r.textContent,r.innerHTML,i,e)},50)}function xr(n,e,t,r,i){let s=Hu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||O.empty)))return!0;if(!s)return!1;let o=xy(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 nc(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&&!$e)return;let r=yr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xr(n,nc(r),r.getData("text/html"),i,t)?t.preventDefault():ky(n,t)};class rc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ic=De?"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(Vi(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}=Ju(n,l);(!t.dataTransfer.files.length||!pe||Iu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(yr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",yr||t.dataTransfer.setData("text/plain",u),n.dragging=new rc(c,!t[ic],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(Vi(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=Hu(n,nc(t.dataTransfer),yr?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[ic]);if(n.someProp("handleDrop",p=>p(n,t,o||O.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?pm(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,A)=>p=A),u.setSelection(ho(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())&&ot(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&&$e&&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,jt(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 kr(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 Ci{constructor(e,t){this.toDOM=e,this.spec=t||Kt,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 je(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ci&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&kr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ot{constructor(e,t){this.attrs=e,this.spec=t||Kt}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 je(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ot&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}static is(e){return e.type instanceof Ot}destroy(){}}class go{constructor(e,t){this.attrs=e,this.spec=t||Kt}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 je(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 go&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}destroy(){}}class je{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new je(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 je(e,e,new Ci(t,r))}static inline(e,t,r,i){return new je(e,t,new Ot(r,i))}static node(e,t,r,i){return new je(e,t,new go(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ot}get widget(){return this.type instanceof Ci}}const cn=[],Kt={};class ie{constructor(e,t){this.local=e.length?e:cn,this.children=t.length?t:cn}static create(e,t){return t.length?Mi(t,e,0,Kt):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||Kt)}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?by(this.children,o||[],e,t,r,i,s):o?new ie(o.sort(Ut),cn):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=oc(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,Mi(c,l,u+1,Kt)),s+=3}});let o=sc(s?lc(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(Ut):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 Ot){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(Ut),cn);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 yo(this.localsInner(e))}localsInner(e){if(this==fe)return cn;if(e.inlineContent||!this.local.some(Ot.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ot||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ie.empty=new ie([],[]);ie.removeOverlap=yo;const fe=ie.empty;class kt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Kt));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?yo(r?t:t.sort(Ut)):cn}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 by(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 A=l[x+1];if(A<0||d>A+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=Sy(l,n,e,t,i,s,o),c=Mi(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(Ut),l)}function sc(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 je(i.from+e,i.to+e,i.type))}return t}function Sy(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 oc(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 lc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Mi(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let u=oc(n,l,a+t);if(u){s=!0;let c=Mi(u,l,t+a+1,r);c!=fe&&i.push(a,a+l.nodeSize,c)}});let o=sc(s?lc(n):n,-t).sort(Ut);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 Ut(n,e){return n.from-e.from||n.to-e.to}function yo(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&&Ut(t,n[e])>0;)e++;n.splice(e,0,t)}function cs(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 wy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Cy=Se&&Ct<=11;class My{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 Oy{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new My,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()}),Cy&&(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,wy)),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(jl(this.view)){if(this.suppressingSelectionUpdates)return ot(this.view);if(Se&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Gt(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=gr(s))t.add(s);for(let s=e.anchorNode;s;s=gr(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)&&jl(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||Ny(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&&Bi(r)&&(u=co(e))&&u.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ot(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Ty(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ot(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 Ty(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 Gt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Ey(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 Ny(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 Iy(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}],Bi(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],A=x.pmViewDesc;if(x.nodeName=="BR"&&!A){s=k;break}if(!A||A.size)break}let h=n.state.doc,d=n.someProp("domParser")||wn.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:Dy,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 Dy(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 Ay=/^(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 zy(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,V=co(n,T);if(V&&!n.state.selection.eq(V)){if(pe&&$e&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,jt(13,"Enter"))))return;let N=n.state.tr.setSelection(V);T=="pointer"?N.setMeta("pointer",!0):T=="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=Iy(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=Fy(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(Tn&&n.input.lastIOSEnter>Date.now()-225||$e)&&i.some(T=>T.nodeType==1&&!Ay.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,jt(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 T=ea(n,n.state.doc,u.sel);if(T&&!T.eq(n.state.selection)){let V=n.state.tr.setSelection(T);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),A=y.sameParent(k)&&y.parent.inlineContent&&x.end()>=p.endA,M;if((Tn&&n.input.lastIOSEnter>Date.now()-225&&(!A||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!A&&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",T=>T(n,jt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Py(c,p.start,p.endA,y,k)&&n.someProp("handleKeyDown",T=>T(n,jt(8,"Backspace")))){$e&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&$e&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),$e&&!A&&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(T){return T(n,jt(13,"Enter"))})},20));let v=p.start,L=p.endA,S,j,Y;if(A){if(y.pos==k.pos)Se&&Ct<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ot(n),20)),S=n.state.tr.delete(v,L),j=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(Y=Ry(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(v,L,Y.mark):S.removeMark(v,L,Y.mark);else if(y.parent.child(y.index()).isText&&y.index()==k.index()-(k.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",V=>V(n,v,L,T)))return;S=n.state.tr.insertText(T,v,L)}}if(S||(S=n.state.tr.replace(v,L,u.doc.slice(p.start-u.from,p.endB-u.from))),u.sel){let T=ea(n,S.doc,u.sel);T&&!(pe&&$e&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==v||T.head==S.mapping.map(L)-1)||Se&&T.empty&&T.head==v)&&S.setSelection(T)}j&&S.ensureMarks(j),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:ho(n,e.resolve(t.anchor),e.resolve(t.head))}function Ry(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 Py(n,e,t,r,i){if(t-e<=i.pos-r.pos||hs(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(hs(s,!0,!0));return!o.parent.isTextblock||o.pos>t||hs(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function hs(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 Fy(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 ty,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=vl(this.state.doc,na(this),cs(this),this.dom,this),this.domObserver=new Oy(this,(r,i,s,o)=>zy(this,r,i,s,o)),this.domObserver.start(),ny(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&&Ws(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&&(tc(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);Ly(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ws(this),this.editable=ia(this),ra(this);let a=cs(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&&yg(this);if(o){this.domObserver.stop();let f=h&&(Se||pe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&By(i.selection,e.selection);if(h){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=my(this)),(s||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=vl(e.doc,u,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Wg(this))?ot(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&&xg(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;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&&Dl(this,t.getBoundingClientRect(),e)}else Dl(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 rc(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&&kg(this.dom),ot(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 Mg(this,e)}coordsAtPos(e,t=1){return Pu(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 Ig(this,t||this.state,e)}pasteHTML(e,t){return xr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xr(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(ry(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],cs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,og())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return sy(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&&hg(this.dom.ownerDocument)==this.dom&&Ey(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"),[je.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:je.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 By(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 Ly(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 ac=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},D=(n,e,t)=>(ac(n,e,"read from private field"),e.get(n)),le=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Z=(n,e,t,r)=>(ac(n,e,"write to private field"),e.set(n,t),t);function Rt(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}const uc={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"),gn=H({},"editorState"),Ur=H([],"initTimer"),js=H({},"editor"),Oi=H([],"inputRules"),En=H([],"prosePlugins"),Ti=H([],"remarkPlugins"),Ei=H([],"nodeView"),Ni=H([],"markView"),Tt=H(Cs().use(ys).use(bs),"remark"),Qr=H({handlers:uc},"remarkStringifyOptions"),ar=Dt("ConfigReady");function cc(n){const e=t=>(t.record(ar),async()=>(await n(t),t.done(ar),()=>{t.clearTimer(ar)}));return Rt(e,{displayName:"Config"}),e}const bn=Dt("InitReady");function hc(n){const e=t=>(t.inject(js,n).inject(En,[]).inject(Ti,[]).inject(Oi,[]).inject(Ei,[]).inject(Ni,[]).inject(Qr,{handlers:uc}).inject(Tt,Cs().use(ys).use(bs)).inject(Ur,[ar]).record(bn),async()=>{await t.waitTimers(Ur);const r=t.get(Qr);return t.set(Tt,Cs().use(ys).use(bs,r)),t.done(bn),()=>{t.remove(js).remove(En).remove(Ti).remove(Oi).remove(Ei).remove(Ni).remove(Qr).remove(Tt).remove(Ur).clearTimer(bn)}});return Rt(e,{displayName:"Init"}),e}const Et=Dt("SchemaReady"),Yr=H([],"schemaTimer"),Qt=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 xo=n=>(n.inject(Qt,{}).inject(Gr,[]).inject(Xr,[]).inject(Yr,[bn]).record(Et),async()=>{await n.waitTimers(Yr);const e=n.get(Tt),t=n.get(Ti).reduce((o,l)=>o.use(l.plugin,l.options),e);n.set(Tt,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 oh({nodes:r,marks:i});return n.set(Qt,s),n.done(Et),()=>{n.remove(Qt).remove(Gr).remove(Xr).remove(Yr).clearTimer(Et)}});Rt(xo,{displayName:"Schema"});var hn,$t;class ko{constructor(){le(this,hn,void 0),le(this,$t,void 0),Z(this,hn,new ca),Z(this,$t,null),this.setCtx=e=>{Z(this,$t,e)}}get ctx(){return D(this,$t)}create(e,t){const r=e.create(D(this,hn).sliceMap);return r.set(t),r}get(e){return D(this,hn).get(e).get()}remove(e){return D(this,hn).remove(e)}call(e,t){if(D(this,$t)==null)throw Pc();const r=this.get(e)(t),i=D(this,$t).get(lr);return r(i.state,i.dispatch,i)}}hn=new WeakMap,$t=new WeakMap;function Vy(n="cmdKey"){return H(()=>()=>!1,n)}const qs=H(new ko,"commands"),Zr=H([Et],"commandsTimer"),ur=Dt("CommandsReady"),bo=n=>{const e=new ko;return e.setCtx(n),n.inject(qs,e).inject(Zr,[Et]).record(ur),async()=>(await n.waitTimers(Zr),n.done(ur),()=>{n.remove(qs).remove(Zr).clearTimer(ur)})};Rt(bo,{displayName:"Commands"});const cr=Dt("ParserReady"),fc=()=>{throw _s()},hr=H(fc,"parser"),ei=H([],"parserTimer"),So=n=>(n.inject(hr,fc).inject(ei,[Et]).record(cr),async()=>{await n.waitTimers(ei);const e=n.get(Tt),t=n.get(Qt);return n.set(hr,Kp.create(t,e)),n.done(cr),()=>{n.remove(hr).remove(ei).clearTimer(cr)}});Rt(So,{displayName:"Parser"});const fr=Dt("SerializerReady"),ti=H([],"serializerTimer"),dc=()=>{throw _s()},ni=H(dc,"serializer"),wo=n=>(n.inject(ni,dc).inject(ti,[Et]).record(fr),async()=>{await n.waitTimers(ti);const e=n.get(Tt),t=n.get(Qt);return n.set(ni,Qp.create(t,e)),n.done(fr),()=>{n.remove(ni).remove(ti).clearTimer(fr)}});Rt(wo,{displayName:"Serializer"});const ri=H("","defaultValue"),ii=H(n=>n,"stateOptions"),si=H([],"editorStateTimer"),dr=Dt("EditorStateReady");function pc(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return wn.fromSchema(t).parse(n.dom);if(n.type==="json")return qe.fromJSON(t,n.value);throw Nc(n)}const $y=new so("MILKDOWN_STATE_TRACKER");function Wy(n){const e=vi(Em,lo,Su,wu);return n.Backspace=e,n}const Co=n=>(n.inject(ri,"").inject(gn,{}).inject(ii,e=>e).inject(si,[cr,fr,ur]).record(dr),async()=>{await n.waitTimers(si);const e=n.get(Qt),t=n.get(hr),r=n.get(Oi),i=n.get(ii),s=n.get(En),o=n.get(ri),l=pc(o,t,e),a=[...s,new Fi({key:$y,state:{init:()=>{},apply:(h,d,f,p)=>{n.set(gn,p)}}}),Rm({rules:r}),ig(Wy(Gm))];n.set(En,a);const u=i({schema:e,doc:l,plugins:a}),c=mn.create(u);return n.set(gn,c),n.done(dr),()=>{n.remove(ri).remove(gn).remove(ii).remove(si).clearTimer(dr)}});Rt(Co,{displayName:"EditorState"});const oi=Dt("EditorViewReady"),li=H([],"editorViewTimer"),ai=H({},"editorViewOptions"),ui=H(null,"root"),Ii=H(null,"rootDOM"),Di=H({},"rootAttrs");function jy(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(Ii,t);const r=e.get(Di);return Object.entries(r).forEach(([i,s])=>t.setAttribute(i,s)),t}function qy(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const _y=new so("MILKDOWN_VIEW_CLEAR"),Mo=n=>(n.inject(ui,document.body).inject(lr,{}).inject(ai,{}).inject(Ii,null).inject(Di,{}).inject(li,[dr]).record(oi),async()=>{await n.wait(bn);const e=n.get(ui)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(En,a=>[new Fi({key:_y,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(gn),i=n.get(ai),s=Object.fromEntries(n.get(Ei)),o=Object.fromEntries(n.get(Ni)),l=new vy(t,{state:r,nodeViews:s,markViews:o,...i});return qy(l.dom),n.set(lr,l),n.done(oi),()=>{l==null||l.destroy(),n.remove(ui).remove(lr).remove(ai).remove(Ii).remove(Di).remove(li).clearTimer(oi)}});Rt(Mo,{displayName:"EditorView"});var mc=(n=>(n.Idle="Idle",n.OnCreate="OnCreate",n.Created="Created",n.OnDestroy="OnDestroy",n.Destroyed="Destroyed",n))(mc||{}),fn,Ie,gt,Gn,ci,hi,Me,yt,dn,fi,pn,Xn,di,Wt,Zn;const Jy=class gc{constructor(){le(this,fn,void 0),le(this,Ie,void 0),le(this,gt,void 0),le(this,Gn,void 0),le(this,ci,void 0),le(this,hi,void 0),le(this,Me,void 0),le(this,yt,void 0),le(this,dn,void 0),le(this,fi,void 0),le(this,pn,void 0),le(this,Xn,void 0),le(this,di,void 0),le(this,Wt,void 0),le(this,Zn,void 0),Z(this,fn,!1),Z(this,Ie,"Idle"),Z(this,gt,[]),Z(this,Gn,()=>{}),Z(this,ci,new ca),Z(this,hi,new $c),Z(this,Me,new Map),Z(this,yt,new Map),Z(this,dn,new Vc(D(this,ci),D(this,hi))),Z(this,fi,()=>{const e=cc(async r=>{await Promise.all(D(this,gt).map(i=>i(r)))}),t=[xo,So,wo,bo,Co,Mo,hc(this),e];D(this,pn).call(this,t,D(this,yt))}),Z(this,pn,(e,t)=>{e.forEach(r=>{const i=D(this,dn).produce(D(this,fn)?r.meta:void 0),s=r(i);t.set(r,{ctx:i,handler:s,cleanup:void 0})})}),Z(this,Xn,(e,t=!1)=>Promise.all([e].flat().map(r=>{const i=D(this,Me).get(r),s=i==null?void 0:i.cleanup;return t?D(this,Me).delete(r):D(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([...D(this,yt).entries()].map(([e,{cleanup:t}])=>typeof t=="function"?t():t)),D(this,yt).clear()}),Z(this,Wt,e=>{Z(this,Ie,e),D(this,Gn).call(this,e)}),Z(this,Zn,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,fn,e),this),this.onStatusChange=e=>(Z(this,Gn,e),this),this.config=e=>(D(this,gt).push(e),this),this.removeConfig=e=>(Z(this,gt,D(this,gt).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(r=>{D(this,Me).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),D(this,Ie)==="Created"&&D(this,pn).call(this,t,D(this,Me)),this},this.remove=async e=>D(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 D(this,Xn).call(this,[e].flat(),!0),this),this.create=async()=>D(this,Ie)==="OnCreate"?this:(D(this,Ie)==="Created"&&await this.destroy(),D(this,Wt).call(this,"OnCreate"),D(this,fi).call(this),D(this,pn).call(this,[...D(this,Me).keys()],D(this,Me)),await Promise.all([D(this,Zn).call(this,D(this,yt)),D(this,Zn).call(this,D(this,Me))].flat()),D(this,Wt).call(this,"Created"),this),this.destroy=async(e=!1)=>D(this,Ie)==="Destroyed"||D(this,Ie)==="OnDestroy"?this:D(this,Ie)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&Z(this,gt,[]),D(this,Wt).call(this,"OnDestroy"),await D(this,Xn).call(this,[...D(this,Me).keys()],e),await D(this,di).call(this),D(this,Wt).call(this,"Destroyed"),this),this.action=e=>e(D(this,dn)),this.inspect=()=>D(this,fn)?[...D(this,yt).values(),...D(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 gc}get ctx(){return D(this,dn)}get status(){return D(this,Ie)}};fn=new WeakMap,Ie=new WeakMap,gt=new WeakMap,Gn=new WeakMap,ci=new WeakMap,hi=new WeakMap,Me=new WeakMap,yt=new WeakMap,dn=new WeakMap,fi=new WeakMap,pn=new WeakMap,Xn=new WeakMap,di=new WeakMap,Wt=new WeakMap,Zn=new WeakMap;let Hy=Jy;const g1=Object.freeze(Object.defineProperty({__proto__:null,CommandManager:ko,CommandsReady:ur,ConfigReady:ar,Editor:Hy,EditorStateReady:dr,EditorStatus:mc,EditorViewReady:oi,InitReady:bn,ParserReady:cr,SchemaReady:Et,SerializerReady:fr,commands:bo,commandsCtx:qs,commandsTimerCtx:Zr,config:cc,createCmdKey:Vy,defaultValueCtx:ri,editorCtx:js,editorState:Co,editorStateCtx:gn,editorStateOptionsCtx:ii,editorStateTimerCtx:si,editorView:Mo,editorViewCtx:lr,editorViewOptionsCtx:ai,editorViewTimerCtx:li,getDoc:pc,init:hc,initTimerCtx:Ur,inputRulesCtx:Oi,markViewCtx:Ni,marksCtx:Xr,nodeViewCtx:Ei,nodesCtx:Gr,parser:So,parserCtx:hr,parserTimerCtx:ei,prosePluginsCtx:En,remarkCtx:Tt,remarkPluginsCtx:Ti,remarkStringifyOptionsCtx:Qr,rootAttrsCtx:Di,rootCtx:ui,rootDOMCtx:Ii,schema:xo,schemaCtx:Qt,schemaTimerCtx:Yr,serializer:wo,serializerCtx:ni,serializerTimerCtx:ti},Symbol.toStringTag,{value:"Module"}));export{Ni as $,bt as A,Oi as B,Qt as C,je as D,Vy as E,C as F,Yy as G,H,at as I,Qy as J,Dt as K,lr as L,bn as M,En as N,ig as O,so as P,Qr as Q,Te as R,O as S,K as T,Yr as U,li as V,Ro as W,Gr as X,ur as Y,Xr as Z,Ei as _,fr as a,Nn as a0,hr as a1,ii as a2,mn as a3,Ti as a4,g1 as a5,Fi as b,J as c,Kr as d,Kc as e,no as f,vd as g,Uy as h,c1 as i,qs as j,d1 as k,to as l,h1 as m,f1 as n,oi as o,ie as p,de as q,ni as r,p1 as s,m1 as t,ai as u,Vd as v,u1 as w,Zr as x,si as y,Et as z};
|
|
42
|
+
`);return{dom:a,text:d,slice:e}}function Hu(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=Nn.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=Xg(t),wr&&Zg(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")||wn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Qg.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=ey(Ul(l,+c[1],+c[2]),c[4]);else if(l=T.maxOpen(Yg(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 Qg=/^(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 Yg(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&&Uu(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Qu(o[o.length-1],s.length));let c=Ku(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return C.from(o)}return n}function Ku(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function Uu(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Uu(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(Ku(t,n,i+1))))}}function Qu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Qu(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 Yu={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 Gu(){return Ql||(Ql=document.implementation.createHTMLDocument("title"))}function Gg(n){let e=window.trustedTypes;return e?e.createPolicy("detachedDocument",{createHTML:t=>t}).createHTML(n):n}function Xg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Gu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Yu[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Gg(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Zg(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 ey(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={},ty={touchstart:!0,touchmove:!0};class ny{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.lastAndroidDelete=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 ry(n){for(let e in ye){let t=ye[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{sy(n,r)&&!fo(n,r)&&(n.editable||!(r.type in xe))&&t(n,r)},ty[e]?{passive:!0}:void 0)}ge&&n.dom.addEventListener("input",()=>null),Ws(n)}function wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function iy(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 Ws(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>fo(n,r))})}function fo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function sy(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 oy(n,e){!fo(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,!Zu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!($e&&pe&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():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,jt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ug(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(Zu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&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 Vi(n){return{left:n.clientX,top:n.clientY}}function ly(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function po(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 kn(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 ay(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(kn(n,new R(t)),!0):!1}function uy(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?(kn(n,R.create(n.state.doc,i)),!0):!1}function cy(n,e,t,r,i){return po(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?uy(n,t):ay(n,t))}function hy(n,e,t,r){return po(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function fy(n,e,t,r){return po(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||dy(n,t,r)}function dy(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(kn(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)kn(n,K.create(r,l+1,l+1+o.content.size));else if(R.isSelectable(o))kn(n,R.create(r,l));else continue;return!0}}function mo(n){return wi(n)}const Xu=De?"metaKey":"ctrlKey";ye.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=mo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&ly(t,n.input.lastClick)&&!t[Xu]&&(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(Vi(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new py(n,o,t,!!r)):(s=="doubleClick"?hy:fy)(n,o.pos,o.inside,t)?t.preventDefault():wt(n,"pointer"))};class py{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[Xu],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(()=>ot(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(Vi(e))),this.updateAllowDefault(e),this.allowDefault||!t?wt(this.view,"pointer"):cy(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)?(kn(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(),mo(n),wt(n,"pointer")};ye.touchmove=n=>{n.input.lastTouch=Date.now(),wt(n,"pointer")};ye.contextmenu=n=>mo(n);function Zu(n,e){return n.composing?!0:ge&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const my=$e?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(),wi(n,!0),n.markCursor=null;else if(wi(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}ec(n,my)};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++,ec(n,20))};function ec(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>wi(n),e))}function tc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=yy());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function gy(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=ag(e.focusNode,e.focusOffset),r=ug(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 yy(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function wi(n,e=!1){if(!($e&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tc(n),e||n.docView&&n.docView.dirty){let t=co(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 xy(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 yr=Se&&Ct<15||On&&pg<604;ye.copy=xe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=yr?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Ju(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):xy(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ky(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function by(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?xr(n,r.value,null,i,e):xr(n,r.textContent,r.innerHTML,i,e)},50)}function xr(n,e,t,r,i){let s=Hu(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=ky(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 nc(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&&!$e)return;let r=yr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xr(n,nc(r),r.getData("text/html"),i,t)?t.preventDefault():by(n,t)};class rc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ic=De?"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(Vi(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}=Ju(n,l);(!t.dataTransfer.files.length||!pe||Iu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(yr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",yr||t.dataTransfer.setData("text/plain",u),n.dragging=new rc(c,!t[ic],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(Vi(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=Hu(n,nc(t.dataTransfer),yr?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[ic]);if(n.someProp("handleDrop",p=>p(n,t,o||T.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?pm(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,A)=>p=A),u.setSelection(ho(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())&&ot(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&&$e&&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,jt(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 kr(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 Ci{constructor(e,t){this.toDOM=e,this.spec=t||Kt,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 je(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ci&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&kr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Tt{constructor(e,t){this.attrs=e,this.spec=t||Kt}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 je(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Tt&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}static is(e){return e.type instanceof Tt}destroy(){}}class go{constructor(e,t){this.attrs=e,this.spec=t||Kt}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 je(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 go&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}destroy(){}}class je{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new je(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 je(e,e,new Ci(t,r))}static inline(e,t,r,i){return new je(e,t,new Tt(r,i))}static node(e,t,r,i){return new je(e,t,new go(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Tt}get widget(){return this.type instanceof Ci}}const cn=[],Kt={};class ie{constructor(e,t){this.local=e.length?e:cn,this.children=t.length?t:cn}static create(e,t){return t.length?Mi(t,e,0,Kt):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||Kt)}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?Sy(this.children,o||[],e,t,r,i,s):o?new ie(o.sort(Ut),cn):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=oc(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,Mi(c,l,u+1,Kt)),s+=3}});let o=sc(s?lc(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(Ut):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(Ut),cn);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 yo(this.localsInner(e))}localsInner(e){if(this==fe)return cn;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=yo;const fe=ie.empty;class kt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Kt));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?yo(r?t:t.sort(Ut)):cn}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 Sy(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 A=l[x+1];if(A<0||d>A+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=wy(l,n,e,t,i,s,o),c=Mi(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(Ut),l)}function sc(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 je(i.from+e,i.to+e,i.type))}return t}function wy(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 oc(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 lc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Mi(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let u=oc(n,l,a+t);if(u){s=!0;let c=Mi(u,l,t+a+1,r);c!=fe&&i.push(a,a+l.nodeSize,c)}});let o=sc(s?lc(n):n,-t).sort(Ut);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 Ut(n,e){return n.from-e.from||n.to-e.to}function yo(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&&Ut(t,n[e])>0;)e++;n.splice(e,0,t)}function cs(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 Cy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},My=Se&&Ct<=11;class Ty{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 Oy{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ty,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()}),My&&(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,Cy)),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(jl(this.view)){if(this.suppressingSelectionUpdates)return ot(this.view);if(Se&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Gt(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=gr(s))t.add(s);for(let s=e.anchorNode;s;s=gr(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}selectionChanged(e){return!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&jl(this.view)&&!this.ignoreSelectionChange(e)}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.selectionChanged(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||Iy(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&&Bi(r)&&(u=co(e))&&u.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ot(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Ey(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ot(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 Ey(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 Gt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Ny(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 Iy(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 Dy(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}],Bi(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],A=x.pmViewDesc;if(x.nodeName=="BR"&&!A){s=k;break}if(!A||A.size)break}let h=n.state.doc,d=n.someProp("domParser")||wn.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:Ay,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 Ay(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 zy=/^(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 Ry(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,V=co(n,O);if(V&&!n.state.selection.eq(V)){if(pe&&$e&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,jt(13,"Enter"))))return;let N=n.state.tr.setSelection(V);O=="pointer"?N.setMeta("pointer",!0):O=="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=Dy(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=vy(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(On&&n.input.lastIOSEnter>Date.now()-225||$e)&&i.some(O=>O.nodeType==1&&!zy.test(O.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",O=>O(n,jt(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 O=ea(n,n.state.doc,u.sel);if(O&&!O.eq(n.state.selection)){let V=n.state.tr.setSelection(O);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),A=y.sameParent(k)&&y.parent.inlineContent&&x.end()>=p.endA,M;if((On&&n.input.lastIOSEnter>Date.now()-225&&(!A||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!A&&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",O=>O(n,jt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Fy(c,p.start,p.endA,y,k)&&n.someProp("handleKeyDown",O=>O(n,jt(8,"Backspace")))){$e&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&$e&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),$e&&!A&&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(O){return O(n,jt(13,"Enter"))})},20));let v=p.start,L=p.endA,S,j,Y;if(A){if(y.pos==k.pos)Se&&Ct<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ot(n),20)),S=n.state.tr.delete(v,L),j=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(Y=Py(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(v,L,Y.mark):S.removeMark(v,L,Y.mark);else if(y.parent.child(y.index()).isText&&y.index()==k.index()-(k.textOffset?0:1)){let O=y.parent.textBetween(y.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",V=>V(n,v,L,O)))return;S=n.state.tr.insertText(O,v,L)}}if(S||(S=n.state.tr.replace(v,L,u.doc.slice(p.start-u.from,p.endB-u.from))),u.sel){let O=ea(n,S.doc,u.sel);O&&!(pe&&$e&&n.composing&&O.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(O.head==v||O.head==S.mapping.map(L)-1)||Se&&O.empty&&O.head==v)&&S.setSelection(O)}j&&S.ensureMarks(j),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:ho(n,e.resolve(t.anchor),e.resolve(t.head))}function Py(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 Fy(n,e,t,r,i){if(t-e<=i.pos-r.pos||hs(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(hs(s,!0,!0));return!o.parent.isTextblock||o.pos>t||hs(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function hs(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 vy(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 By{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 ny,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=vl(this.state.doc,na(this),cs(this),this.dom,this),this.domObserver=new Oy(this,(r,i,s,o)=>Ry(this,r,i,s,o)),this.domObserver.start(),ry(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&&Ws(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&&(tc(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);Vy(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ws(this),this.editable=ia(this),ra(this);let a=cs(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&&yg(this);if(o){this.domObserver.stop();let f=h&&(Se||pe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ly(i.selection,e.selection);if(h){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gy(this)),(s||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=vl(e.doc,u,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Wg(this))?ot(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&&xg(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;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&&Dl(this,t.getBoundingClientRect(),e)}else Dl(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 rc(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&&kg(this.dom),ot(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 Mg(this,e)}coordsAtPos(e,t=1){return Pu(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 Ig(this,t||this.state,e)}pasteHTML(e,t){return xr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xr(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(iy(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],cs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,og())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return oy(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&&hg(this.dom.ownerDocument)==this.dom&&Ny(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"),[je.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:je.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 Ly(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 Vy(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 ac=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},D=(n,e,t)=>(ac(n,e,"read from private field"),e.get(n)),le=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Z=(n,e,t,r)=>(ac(n,e,"write to private field"),e.set(n,t),t);function Rt(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}const uc={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"),gn=H({},"editorState"),Ur=H([],"initTimer"),js=H({},"editor"),Ti=H([],"inputRules"),En=H([],"prosePlugins"),Oi=H([],"remarkPlugins"),Ei=H([],"nodeView"),Ni=H([],"markView"),Ot=H(Cs().use(ys).use(bs),"remark"),Qr=H({handlers:uc},"remarkStringifyOptions"),ar=Dt("ConfigReady");function cc(n){const e=t=>(t.record(ar),async()=>(await n(t),t.done(ar),()=>{t.clearTimer(ar)}));return Rt(e,{displayName:"Config"}),e}const bn=Dt("InitReady");function hc(n){const e=t=>(t.inject(js,n).inject(En,[]).inject(Oi,[]).inject(Ti,[]).inject(Ei,[]).inject(Ni,[]).inject(Qr,{handlers:uc}).inject(Ot,Cs().use(ys).use(bs)).inject(Ur,[ar]).record(bn),async()=>{await t.waitTimers(Ur);const r=t.get(Qr);return t.set(Ot,Cs().use(ys).use(bs,r)),t.done(bn),()=>{t.remove(js).remove(En).remove(Oi).remove(Ti).remove(Ei).remove(Ni).remove(Qr).remove(Ot).remove(Ur).clearTimer(bn)}});return Rt(e,{displayName:"Init"}),e}const Et=Dt("SchemaReady"),Yr=H([],"schemaTimer"),Qt=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 xo=n=>(n.inject(Qt,{}).inject(Gr,[]).inject(Xr,[]).inject(Yr,[bn]).record(Et),async()=>{await n.waitTimers(Yr);const e=n.get(Ot),t=n.get(Oi).reduce((o,l)=>o.use(l.plugin,l.options),e);n.set(Ot,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 oh({nodes:r,marks:i});return n.set(Qt,s),n.done(Et),()=>{n.remove(Qt).remove(Gr).remove(Xr).remove(Yr).clearTimer(Et)}});Rt(xo,{displayName:"Schema"});var hn,$t;class ko{constructor(){le(this,hn,void 0),le(this,$t,void 0),Z(this,hn,new ca),Z(this,$t,null),this.setCtx=e=>{Z(this,$t,e)}}get ctx(){return D(this,$t)}create(e,t){const r=e.create(D(this,hn).sliceMap);return r.set(t),r}get(e){return D(this,hn).get(e).get()}remove(e){return D(this,hn).remove(e)}call(e,t){if(D(this,$t)==null)throw Pc();const r=this.get(e)(t),i=D(this,$t).get(lr);return r(i.state,i.dispatch,i)}}hn=new WeakMap,$t=new WeakMap;function $y(n="cmdKey"){return H(()=>()=>!1,n)}const qs=H(new ko,"commands"),Zr=H([Et],"commandsTimer"),ur=Dt("CommandsReady"),bo=n=>{const e=new ko;return e.setCtx(n),n.inject(qs,e).inject(Zr,[Et]).record(ur),async()=>(await n.waitTimers(Zr),n.done(ur),()=>{n.remove(qs).remove(Zr).clearTimer(ur)})};Rt(bo,{displayName:"Commands"});const cr=Dt("ParserReady"),fc=()=>{throw _s()},hr=H(fc,"parser"),ei=H([],"parserTimer"),So=n=>(n.inject(hr,fc).inject(ei,[Et]).record(cr),async()=>{await n.waitTimers(ei);const e=n.get(Ot),t=n.get(Qt);return n.set(hr,Kp.create(t,e)),n.done(cr),()=>{n.remove(hr).remove(ei).clearTimer(cr)}});Rt(So,{displayName:"Parser"});const fr=Dt("SerializerReady"),ti=H([],"serializerTimer"),dc=()=>{throw _s()},ni=H(dc,"serializer"),wo=n=>(n.inject(ni,dc).inject(ti,[Et]).record(fr),async()=>{await n.waitTimers(ti);const e=n.get(Ot),t=n.get(Qt);return n.set(ni,Qp.create(t,e)),n.done(fr),()=>{n.remove(ni).remove(ti).clearTimer(fr)}});Rt(wo,{displayName:"Serializer"});const ri=H("","defaultValue"),ii=H(n=>n,"stateOptions"),si=H([],"editorStateTimer"),dr=Dt("EditorStateReady");function pc(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return wn.fromSchema(t).parse(n.dom);if(n.type==="json")return qe.fromJSON(t,n.value);throw Nc(n)}const Wy=new so("MILKDOWN_STATE_TRACKER");function jy(n){const e=vi(Em,lo,Su,wu);return n.Backspace=e,n}const Co=n=>(n.inject(ri,"").inject(gn,{}).inject(ii,e=>e).inject(si,[cr,fr,ur]).record(dr),async()=>{await n.waitTimers(si);const e=n.get(Qt),t=n.get(hr),r=n.get(Ti),i=n.get(ii),s=n.get(En),o=n.get(ri),l=pc(o,t,e),a=[...s,new Fi({key:Wy,state:{init:()=>{},apply:(h,d,f,p)=>{n.set(gn,p)}}}),Rm({rules:r}),ig(jy(Gm))];n.set(En,a);const u=i({schema:e,doc:l,plugins:a}),c=mn.create(u);return n.set(gn,c),n.done(dr),()=>{n.remove(ri).remove(gn).remove(ii).remove(si).clearTimer(dr)}});Rt(Co,{displayName:"EditorState"});const oi=Dt("EditorViewReady"),li=H([],"editorViewTimer"),ai=H({},"editorViewOptions"),ui=H(null,"root"),Ii=H(null,"rootDOM"),Di=H({},"rootAttrs");function qy(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(Ii,t);const r=e.get(Di);return Object.entries(r).forEach(([i,s])=>t.setAttribute(i,s)),t}function _y(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const Jy=new so("MILKDOWN_VIEW_CLEAR"),Mo=n=>(n.inject(ui,document.body).inject(lr,{}).inject(ai,{}).inject(Ii,null).inject(Di,{}).inject(li,[dr]).record(oi),async()=>{await n.wait(bn);const e=n.get(ui)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(En,a=>[new Fi({key:Jy,view:u=>{const c=t?qy(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(gn),i=n.get(ai),s=Object.fromEntries(n.get(Ei)),o=Object.fromEntries(n.get(Ni)),l=new By(t,{state:r,nodeViews:s,markViews:o,...i});return _y(l.dom),n.set(lr,l),n.done(oi),()=>{l==null||l.destroy(),n.remove(ui).remove(lr).remove(ai).remove(Ii).remove(Di).remove(li).clearTimer(oi)}});Rt(Mo,{displayName:"EditorView"});var mc=(n=>(n.Idle="Idle",n.OnCreate="OnCreate",n.Created="Created",n.OnDestroy="OnDestroy",n.Destroyed="Destroyed",n))(mc||{}),fn,Ie,gt,Gn,ci,hi,Me,yt,dn,fi,pn,Xn,di,Wt,Zn;const Hy=class gc{constructor(){le(this,fn,void 0),le(this,Ie,void 0),le(this,gt,void 0),le(this,Gn,void 0),le(this,ci,void 0),le(this,hi,void 0),le(this,Me,void 0),le(this,yt,void 0),le(this,dn,void 0),le(this,fi,void 0),le(this,pn,void 0),le(this,Xn,void 0),le(this,di,void 0),le(this,Wt,void 0),le(this,Zn,void 0),Z(this,fn,!1),Z(this,Ie,"Idle"),Z(this,gt,[]),Z(this,Gn,()=>{}),Z(this,ci,new ca),Z(this,hi,new $c),Z(this,Me,new Map),Z(this,yt,new Map),Z(this,dn,new Vc(D(this,ci),D(this,hi))),Z(this,fi,()=>{const e=cc(async r=>{await Promise.all(D(this,gt).map(i=>i(r)))}),t=[xo,So,wo,bo,Co,Mo,hc(this),e];D(this,pn).call(this,t,D(this,yt))}),Z(this,pn,(e,t)=>{e.forEach(r=>{const i=D(this,dn).produce(D(this,fn)?r.meta:void 0),s=r(i);t.set(r,{ctx:i,handler:s,cleanup:void 0})})}),Z(this,Xn,(e,t=!1)=>Promise.all([e].flat().map(r=>{const i=D(this,Me).get(r),s=i==null?void 0:i.cleanup;return t?D(this,Me).delete(r):D(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([...D(this,yt).entries()].map(([e,{cleanup:t}])=>typeof t=="function"?t():t)),D(this,yt).clear()}),Z(this,Wt,e=>{Z(this,Ie,e),D(this,Gn).call(this,e)}),Z(this,Zn,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,fn,e),this),this.onStatusChange=e=>(Z(this,Gn,e),this),this.config=e=>(D(this,gt).push(e),this),this.removeConfig=e=>(Z(this,gt,D(this,gt).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(r=>{D(this,Me).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),D(this,Ie)==="Created"&&D(this,pn).call(this,t,D(this,Me)),this},this.remove=async e=>D(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 D(this,Xn).call(this,[e].flat(),!0),this),this.create=async()=>D(this,Ie)==="OnCreate"?this:(D(this,Ie)==="Created"&&await this.destroy(),D(this,Wt).call(this,"OnCreate"),D(this,fi).call(this),D(this,pn).call(this,[...D(this,Me).keys()],D(this,Me)),await Promise.all([D(this,Zn).call(this,D(this,yt)),D(this,Zn).call(this,D(this,Me))].flat()),D(this,Wt).call(this,"Created"),this),this.destroy=async(e=!1)=>D(this,Ie)==="Destroyed"||D(this,Ie)==="OnDestroy"?this:D(this,Ie)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&Z(this,gt,[]),D(this,Wt).call(this,"OnDestroy"),await D(this,Xn).call(this,[...D(this,Me).keys()],e),await D(this,di).call(this),D(this,Wt).call(this,"Destroyed"),this),this.action=e=>e(D(this,dn)),this.inspect=()=>D(this,fn)?[...D(this,yt).values(),...D(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 gc}get ctx(){return D(this,dn)}get status(){return D(this,Ie)}};fn=new WeakMap,Ie=new WeakMap,gt=new WeakMap,Gn=new WeakMap,ci=new WeakMap,hi=new WeakMap,Me=new WeakMap,yt=new WeakMap,dn=new WeakMap,fi=new WeakMap,pn=new WeakMap,Xn=new WeakMap,di=new WeakMap,Wt=new WeakMap,Zn=new WeakMap;let Ky=Hy;const y1=Object.freeze(Object.defineProperty({__proto__:null,CommandManager:ko,CommandsReady:ur,ConfigReady:ar,Editor:Ky,EditorStateReady:dr,EditorStatus:mc,EditorViewReady:oi,InitReady:bn,ParserReady:cr,SchemaReady:Et,SerializerReady:fr,commands:bo,commandsCtx:qs,commandsTimerCtx:Zr,config:cc,createCmdKey:$y,defaultValueCtx:ri,editorCtx:js,editorState:Co,editorStateCtx:gn,editorStateOptionsCtx:ii,editorStateTimerCtx:si,editorView:Mo,editorViewCtx:lr,editorViewOptionsCtx:ai,editorViewTimerCtx:li,getDoc:pc,init:hc,initTimerCtx:Ur,inputRulesCtx:Ti,markViewCtx:Ni,marksCtx:Xr,nodeViewCtx:Ei,nodesCtx:Gr,parser:So,parserCtx:hr,parserTimerCtx:ei,prosePluginsCtx:En,remarkCtx:Ot,remarkPluginsCtx:Oi,remarkStringifyOptionsCtx:Qr,rootAttrsCtx:Di,rootCtx:ui,rootDOMCtx:Ii,schema:xo,schemaCtx:Qt,schemaTimerCtx:Yr,serializer:wo,serializerCtx:ni,serializerTimerCtx:ti},Symbol.toStringTag,{value:"Module"}));export{Ni as $,bt as A,Ti as B,Qt as C,je as D,$y as E,C as F,Gy as G,H,at as I,Yy as J,Dt as K,lr as L,bn as M,En as N,ig as O,so as P,Qr as Q,Oe as R,T as S,K as T,Yr as U,li as V,Ro as W,Gr as X,ur as Y,Xr as Z,Ei as _,fr as a,Nn as a0,hr as a1,ii as a2,mn as a3,Oi as a4,y1 as a5,Fi as b,J as c,Kr as d,Kc as e,no as f,vd as g,Qy as h,h1 as i,qs as j,p1 as k,to as l,f1 as m,d1 as n,oi as o,ie as p,de as q,ni as r,m1 as s,g1 as t,ai as u,Vd as v,c1 as w,Zr as x,si as y,Et as z};
|