Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com

fix(frontend): register collab PM plugin via editorViewOptionsCtx so sendableSteps has a state slot

+23 -17
+1 -1
milkdown-entry.js
··· 1 - export { Editor, rootCtx, defaultValueCtx, editorViewCtx, serializerCtx } from '@milkdown/kit/core'; 1 + export { Editor, rootCtx, defaultValueCtx, editorViewCtx, serializerCtx, editorViewOptionsCtx } from '@milkdown/kit/core'; 2 2 export { commonmark, toggleStrongCommand, toggleEmphasisCommand, wrapInHeadingCommand, turnIntoTextCommand, wrapInBulletListCommand, wrapInBlockquoteCommand } from '@milkdown/kit/preset/commonmark'; 3 3 export { listener, listenerCtx } from '@milkdown/kit/plugin/listener'; 4 4 export { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip';
+15 -15
static/vendor/milkdown.js
··· 1 - var Sg=Object.create;var nl=Object.defineProperty;var Cg=Object.getOwnPropertyDescriptor;var Mg=Object.getOwnPropertyNames;var Ng=Object.getPrototypeOf,Ig=Object.prototype.hasOwnProperty;var Tg=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Og=(n,e)=>{for(var t in e)nl(n,t,{get:e[t],enumerable:!0})},Eg=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Mg(e))!Ig.call(n,i)&&i!==t&&nl(n,i,{get:()=>e[i],enumerable:!(r=Cg(e,i))||r.enumerable});return n};var Ag=(n,e,t)=>(t=n!=null?Sg(Ng(n)):{},Eg(e||!n||!n.__esModule?nl(t,"default",{value:n,enumerable:!0}):t,n));var Zh=Tg((kO,Xh)=>{"use strict";var Bo=Object.prototype.hasOwnProperty,Qh=Object.prototype.toString,qh=Object.defineProperty,Kh=Object.getOwnPropertyDescriptor,Uh=function(e){return typeof Array.isArray=="function"?Array.isArray(e):Qh.call(e)==="[object Array]"},Jh=function(e){if(!e||Qh.call(e)!=="[object Object]")return!1;var t=Bo.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Bo.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||Bo.call(e,i)},Gh=function(e,t){qh&&t.name==="__proto__"?qh(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},Yh=function(e,t){if(t==="__proto__")if(Bo.call(e,t)){if(Kh)return Kh(e,t).value}else return;return e[t]};Xh.exports=function n(){var e,t,r,i,o,s,l=arguments[0],a=1,c=arguments.length,u=!1;for(typeof l=="boolean"&&(u=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<c;++a)if(e=arguments[a],e!=null)for(t in e)r=Yh(l,t),i=Yh(e,t),l!==i&&(u&&i&&(Jh(i)||(o=Uh(i)))?(o?(o=!1,s=r&&Uh(r)?r:[]):s=r&&Jh(r)?r:{},Gh(l,{name:t,newValue:n(u,s,i)})):typeof i<"u"&&Gh(l,{name:t,newValue:i}));return l}});var ze=(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))(ze||{}),Ee=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},Rg=(n,e)=>typeof e=="function"?"[Function]":e,Yi=n=>JSON.stringify(n,Rg);function Iu(n){return new Ee(ze.docTypeError,`Doc type error, unsupported type: ${Yi(n)}`)}function Tu(n){return new Ee(ze.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Ou(n){return new Ee(ze.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function Kn(){return new Ee(ze.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Eu(n,e,t){let i=`Cannot create node for ${"name"in n?n.name:n}`,o=u=>{if(u==null)return"null";if(Array.isArray(u))return`[${u.map(o).join(", ")}]`;if(typeof u=="object")return"toJSON"in u&&typeof u.toJSON=="function"?JSON.stringify(u.toJSON()):"spec"in u?JSON.stringify(u.spec):JSON.stringify(u);if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")return JSON.stringify(u);if(typeof u=="function")return`[Function: ${u.name||"anonymous"}]`;try{return String(u)}catch{return"[Unserializable]"}},s=["[Description]",i],l=["[Attributes]",e],a=["[Content]",(t??[]).map(u=>u?typeof u=="object"&&"type"in u?`${u}`:o(u):"null")],c=[s,l,a].reduce((u,[f,d])=>{let h=`${f}: ${o(d)}.`;return u.concat(h)},[]);return new Ee(ze.createNodeInParserFail,c.join(` 2 - `))}function rl(){return new Ee(ze.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Au(n){return new Ee(ze.parserMatchError,`Cannot match target parser for node: ${Yi(n)}.`)}function Ru(n){return new Ee(ze.serializerMatchError,`Cannot match target serializer for node: ${Yi(n)}.`)}function Lt(n){return new Ee(ze.expectDomTypeError,`Expect to be a dom, but get: ${Yi(n)}.`)}function Qi(){return new Ee(ze.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 vu(n){return new Ee(ze.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function Du(n){return new Ee(ze.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var jr=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);if(!t){let r=typeof e=="string"?e:e.name;throw Tu(r)}return t},this.remove=e=>{let 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)}},il=class{constructor(e,t,r){this.#t=[],this.#r=()=>{this.#t.forEach(i=>i(this.#e))},this.set=i=>{this.#e=i,this.#r()},this.get=()=>this.#e,this.update=i=>{this.#e=i(this.#e),this.#r()},this.type=r,this.#e=t,e.set(r.id,this)}#t;#e;#r;on(e){return this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}}once(e){let t=this.on(r=>{e(r),t()});return t}off(e){this.#t=this.#t.filter(t=>t!==e)}offAll(){this.#t=[]}},ol=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Kn()}}create(e,t=this._defaultValue){return new il(e,t,this)}},$=(n,e)=>new ol(n,e),sl=class{constructor(e,t,r){this.#n=new Set,this.#s=new Set,this.#o=new Map,this.#i=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),consumedSlices:[...this.#s].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),recordedTimers:[...this.#o].map(([i,{duration:o}])=>({name:i.name,duration:o,status:this.#a(i)})),waitTimers:[...this.#i].map(([i,{duration:o}])=>({name:i.name,duration:o,status:this.#a(i)}))}),this.onRecord=i=>{this.#o.set(i,{start:Date.now(),duration:0})},this.onClear=i=>{this.#o.delete(i)},this.onDone=i=>{let o=this.#o.get(i);o&&(o.duration=Date.now()-o.start)},this.onWait=(i,o)=>{let s=Date.now();o.finally(()=>{this.#i.set(i,{duration:Date.now()-s})}).catch(console.error)},this.onInject=i=>{this.#n.add(i)},this.onRemove=i=>{this.#n.delete(i)},this.onUse=i=>{this.#s.add(i)},this.#l=i=>this.#e.get(i).get(),this.#a=i=>this.#r.get(i).status,this.#e=e,this.#r=t,this.#t=r}#t;#e;#r;#n;#s;#o;#i;#l;#a},Xi=class n{constructor(e,t,r){this.produce=i=>i&&Object.keys(i).length?new n(this.#t,this.#e,{...i}):this,this.inject=(i,o)=>{let s=i.create(this.#t.sliceMap);return o!=null&&s.set(o),this.#n?.onInject(i),this},this.remove=i=>(this.#t.remove(i),this.#n?.onRemove(i),this),this.record=i=>(i.create(this.#e.store),this.#n?.onRecord(i),this),this.clearTimer=i=>(this.#e.remove(i),this.#n?.onClear(i),this),this.isInjected=i=>this.#t.has(i),this.isRecorded=i=>this.#e.has(i),this.use=i=>(this.#n?.onUse(i),this.#t.get(i)),this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>this.#e.get(i),this.done=i=>{this.timer(i).done(),this.#n?.onDone(i)},this.wait=i=>{let o=this.timer(i).start();return this.#n?.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},this.#t=e,this.#e=t,this.#r=r,r&&(this.#n=new sl(e,t,r))}#t;#e;#r;#n;get meta(){return this.#r}get inspector(){return this.#n}},Zi=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw Ou(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},ll=class{constructor(e,t){this.#t=null,this.#e=null,this.#n="pending",this.start=()=>(this.#t??=new Promise((r,i)=>{this.#e=o=>{o instanceof CustomEvent&&o.detail.id===this.#r&&(this.#n="resolved",this.#s(),o.stopImmediatePropagation(),r())},this.#o(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#s(),i(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{let r=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(r)},this.#s=()=>{this.#e&&removeEventListener(this.type.name,this.#e)},this.#o=r=>{setTimeout(()=>{r()},this.type.timeout)},this.#r=Symbol(t.name),this.type=t,e.set(t.id,this)}#t;#e;#r;#n;get status(){return this.#n}#s;#o},al=class{constructor(e,t=3e3){this.create=r=>new ll(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},He=(n,e=3e3)=>new al(n,e);function ye(n){this.content=n}ye.prototype={constructor:ye,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),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new ye(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ye(t)},addToStart:function(n,e){return new ye([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ye(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new ye(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=ye.from(n),n.size?new ye(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ye.from(n),n.size?new ye(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ye.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}};ye.from=function(n){if(n instanceof ye)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ye(e)};var cl=ye;function ju(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),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=ju(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Hu(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let c=Hu(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}var M=class n{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,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=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&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new n(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 o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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 ju(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Hu(this,e,t,r)}findIndex(e){if(e==0)return eo(0,e);if(e==this.size)return eo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?eo(t+1,o):eo(t,r);r=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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};M.empty=new M([],0);var ul={index:0,offset:0};function eo(n,e){return ul.index=n,ul.offset=e,ul}function no(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(!no(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!no(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}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&&no(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 n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};q.none=[];var nn=class extends Error{},O=class n{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=Ku(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(qu(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 n.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 n(M.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};O.empty=new O(M.empty,0,0);function qu(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(qu(o.content,e-i-1,t-i-1)))}function Ku(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Ku(s.content,e-o-1,t,s);return l&&n.replaceChild(i,s.copy(l))}function vg(n,e,t){if(t.openStart>n.depth)throw new nn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new nn("Inconsistent open depths");return Uu(n,e,t,0)}function Uu(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Uu(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return tn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Dg(t,n);return tn(o,Gu(n,s,l,e,r))}else return tn(o,ro(n,e,r))}function Ju(n,e){if(!e.type.compatibleContent(n.type))throw new nn("Cannot join "+e.type.name+" onto "+n.type.name)}function hl(n,e,t){let r=n.node(t);return Ju(r,e.node(t)),r}function en(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 Hr(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(en(n.nodeAfter,r),o++));for(let l=o;l<s;l++)en(i.child(l),r);e&&e.depth==t&&e.textOffset&&en(e.nodeBefore,r)}function tn(n,e){return n.type.checkContent(e),n.copy(e)}function Gu(n,e,t,r,i){let o=n.depth>i&&hl(n,e,i+1),s=r.depth>i&&hl(t,r,i+1),l=[];return Hr(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Ju(o,s),en(tn(o,Gu(n,e,t,r,i+1)),l)):(o&&en(tn(o,ro(n,e,i+1)),l),Hr(e,t,i,l),s&&en(tn(s,ro(t,r,i+1)),l)),Hr(r,null,i,l),new M(l)}function ro(n,e,t){let r=[];if(Hr(null,n,t,r),n.depth>t){let i=hl(n,e,t+1);en(tn(i,ro(n,e,t+1)),r)}return Hr(e,null,t,r),new M(r)}function Dg(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(M.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var io=class n{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 o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return q.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 o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}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 o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].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 Kr(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,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=Pu.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else Pu.set(e,r=new dl);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Pg,i}},dl=class{constructor(){this.elts=[],this.i=0}},Pg=12,Pu=new WeakMap,Kr=class{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)}},Lg=Object.create(null),Ae=class n{constructor(e,t,r,i=q.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&no(this.attrs,t||e.defaultAttrs||Lg)&&q.sameSet(this.marks,r||q.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new O(c,i.depth-s,o.depth-s)}replace(e,t,r){return vg(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 io.resolveCached(this,e)}resolveNoCache(e){return io.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.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()+")"),Yu(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=M.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<o;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 o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.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=q.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(!q.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=M.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Ae.prototype.text=void 0;var pl=class n extends Ae{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):Yu(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(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 Yu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var rn=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ml(e,t);if(r.next==null)return n.empty;let i=Qu(r);r.next&&r.err("Unexpected trailing text");let o=Wg($g(i));return jg(o,r),o}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 o=t;i&&o<r;o++)i=i.matchType(e.child(o).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 o(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return M.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=o(f,l.concat(u));if(d)return d}}return null}return o(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(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!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 o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(` 3 - `)}};rn.empty=new rn(!0);var ml=class{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 Qu(n){let e=[];do e.push(Bg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Bg(n){let e=[];do e.push(zg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zg(n){let e=Vg(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=Fg(n,e);else break;return e}function Lu(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Fg(n,e){let t=Lu(n),r=t;return n.eat(",")&&(n.next!="}"?r=Lu(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function _g(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Vg(n){if(n.eat("(")){let e=Qu(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=_g(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 $g(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Xu(n,e){return e-n}function Bu(n,e){let t=[];return r(e),t.sort(Xu);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Wg(n){let e=Object.create(null);return t(Bu(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Bu(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new rn(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Xu);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function jg(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Zu(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 ef(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function tf(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 o=n[i];o.validate&&o.validate(e[i])}}function nf(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new gl(n,r,e[r]);return t}var oo=class n{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=nf(e,r.attrs),this.defaultAttrs=Zu(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==rn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ef(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ae(this,this.computeAttrs(e),M.from(t),q.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Ae(this,this.computeAttrs(e),t,q.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(M.empty,!0);return o?new Ae(this,e,t.append(o),q.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){tf(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:q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new n(o,t,s));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 o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Hg(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var gl=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Hg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Ur=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=nf(e,i.attrs),this.excluded=null;let o=Zu(this.attrs);this.instance=o?new q(this,o):null}create(e=null){return!e&&this.instance?this.instance:new q(this,ef(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),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){tf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},so=class{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=cl.from(e.nodes),t.marks=cl.from(e.marks||{}),this.nodes=oo.compile(this.spec.nodes,this),this.marks=Ur.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 o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=rn.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?zu(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:zu(this,s.split(" "))}this.nodeFromJSON=i=>Ae.fromJSON(this,i),this.markFromJSON=i=>q.fromJSON(this,i),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 oo){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 pl(r,r.defaultAttrs,e,q.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function zu(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);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(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function qg(n){return n.tag!=null}function Kg(n){return n.style!=null}var on=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(qg(i))this.tags.push(i);else if(Kg(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new lo(this,t,!1);return r.addAll(e,q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new lo(this,t,!0);return r.addAll(e,q.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 o=this.tags[i];if(Gg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=_u(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=_u(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},rf={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},Ug={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},of={ol:!0,ul:!0},Jr=1,yl=2,qr=4;function Fu(n,e,t){return e!=null?(e?Jr:0)|(e==="full"?yl:0):n&&n.whitespace=="pre"?Jr|yl:t&~qr}var Un=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=q.none,this.match=o||(s&qr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.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&Jr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.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&&!rf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},lo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Fu(null,t.preserveWhitespace,0)|(r?qr:0);i?o=new Un(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Un(null,null,q.none,!0,null,s):o=new Un(e.schema.topNodeType,null,q.none,!0,null,s),this.nodes=[o],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,o=i.options&yl?"full":this.localPreserveWS||(i.options&Jr)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` 1 + var Sg=Object.create;var rl=Object.defineProperty;var Cg=Object.getOwnPropertyDescriptor;var Mg=Object.getOwnPropertyNames;var Ng=Object.getPrototypeOf,Ig=Object.prototype.hasOwnProperty;var Tg=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Og=(n,e)=>{for(var t in e)rl(n,t,{get:e[t],enumerable:!0})},Eg=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Mg(e))!Ig.call(n,i)&&i!==t&&rl(n,i,{get:()=>e[i],enumerable:!(r=Cg(e,i))||r.enumerable});return n};var Ag=(n,e,t)=>(t=n!=null?Sg(Ng(n)):{},Eg(e||!n||!n.__esModule?rl(t,"default",{value:n,enumerable:!0}):t,n));var Zh=Tg((kO,Xh)=>{"use strict";var Bo=Object.prototype.hasOwnProperty,Qh=Object.prototype.toString,qh=Object.defineProperty,Kh=Object.getOwnPropertyDescriptor,Uh=function(e){return typeof Array.isArray=="function"?Array.isArray(e):Qh.call(e)==="[object Array]"},Jh=function(e){if(!e||Qh.call(e)!=="[object Object]")return!1;var t=Bo.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Bo.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||Bo.call(e,i)},Gh=function(e,t){qh&&t.name==="__proto__"?qh(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},Yh=function(e,t){if(t==="__proto__")if(Bo.call(e,t)){if(Kh)return Kh(e,t).value}else return;return e[t]};Xh.exports=function n(){var e,t,r,i,o,s,l=arguments[0],a=1,c=arguments.length,u=!1;for(typeof l=="boolean"&&(u=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<c;++a)if(e=arguments[a],e!=null)for(t in e)r=Yh(l,t),i=Yh(e,t),l!==i&&(u&&i&&(Jh(i)||(o=Uh(i)))?(o?(o=!1,s=r&&Uh(r)?r:[]):s=r&&Jh(r)?r:{},Gh(l,{name:t,newValue:n(u,s,i)})):typeof i<"u"&&Gh(l,{name:t,newValue:i}));return l}});var ze=(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))(ze||{}),Ee=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},Rg=(n,e)=>typeof e=="function"?"[Function]":e,Yi=n=>JSON.stringify(n,Rg);function Iu(n){return new Ee(ze.docTypeError,`Doc type error, unsupported type: ${Yi(n)}`)}function Tu(n){return new Ee(ze.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Ou(n){return new Ee(ze.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function Kn(){return new Ee(ze.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Eu(n,e,t){let i=`Cannot create node for ${"name"in n?n.name:n}`,o=u=>{if(u==null)return"null";if(Array.isArray(u))return`[${u.map(o).join(", ")}]`;if(typeof u=="object")return"toJSON"in u&&typeof u.toJSON=="function"?JSON.stringify(u.toJSON()):"spec"in u?JSON.stringify(u.spec):JSON.stringify(u);if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")return JSON.stringify(u);if(typeof u=="function")return`[Function: ${u.name||"anonymous"}]`;try{return String(u)}catch{return"[Unserializable]"}},s=["[Description]",i],l=["[Attributes]",e],a=["[Content]",(t??[]).map(u=>u?typeof u=="object"&&"type"in u?`${u}`:o(u):"null")],c=[s,l,a].reduce((u,[f,d])=>{let h=`${f}: ${o(d)}.`;return u.concat(h)},[]);return new Ee(ze.createNodeInParserFail,c.join(` 2 + `))}function il(){return new Ee(ze.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Au(n){return new Ee(ze.parserMatchError,`Cannot match target parser for node: ${Yi(n)}.`)}function Ru(n){return new Ee(ze.serializerMatchError,`Cannot match target serializer for node: ${Yi(n)}.`)}function Lt(n){return new Ee(ze.expectDomTypeError,`Expect to be a dom, but get: ${Yi(n)}.`)}function Qi(){return new Ee(ze.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 vu(n){return new Ee(ze.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function Du(n){return new Ee(ze.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var jr=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);if(!t){let r=typeof e=="string"?e:e.name;throw Tu(r)}return t},this.remove=e=>{let 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)}},ol=class{constructor(e,t,r){this.#t=[],this.#r=()=>{this.#t.forEach(i=>i(this.#e))},this.set=i=>{this.#e=i,this.#r()},this.get=()=>this.#e,this.update=i=>{this.#e=i(this.#e),this.#r()},this.type=r,this.#e=t,e.set(r.id,this)}#t;#e;#r;on(e){return this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}}once(e){let t=this.on(r=>{e(r),t()});return t}off(e){this.#t=this.#t.filter(t=>t!==e)}offAll(){this.#t=[]}},sl=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Kn()}}create(e,t=this._defaultValue){return new ol(e,t,this)}},$=(n,e)=>new sl(n,e),ll=class{constructor(e,t,r){this.#n=new Set,this.#s=new Set,this.#o=new Map,this.#i=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),consumedSlices:[...this.#s].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),recordedTimers:[...this.#o].map(([i,{duration:o}])=>({name:i.name,duration:o,status:this.#a(i)})),waitTimers:[...this.#i].map(([i,{duration:o}])=>({name:i.name,duration:o,status:this.#a(i)}))}),this.onRecord=i=>{this.#o.set(i,{start:Date.now(),duration:0})},this.onClear=i=>{this.#o.delete(i)},this.onDone=i=>{let o=this.#o.get(i);o&&(o.duration=Date.now()-o.start)},this.onWait=(i,o)=>{let s=Date.now();o.finally(()=>{this.#i.set(i,{duration:Date.now()-s})}).catch(console.error)},this.onInject=i=>{this.#n.add(i)},this.onRemove=i=>{this.#n.delete(i)},this.onUse=i=>{this.#s.add(i)},this.#l=i=>this.#e.get(i).get(),this.#a=i=>this.#r.get(i).status,this.#e=e,this.#r=t,this.#t=r}#t;#e;#r;#n;#s;#o;#i;#l;#a},Xi=class n{constructor(e,t,r){this.produce=i=>i&&Object.keys(i).length?new n(this.#t,this.#e,{...i}):this,this.inject=(i,o)=>{let s=i.create(this.#t.sliceMap);return o!=null&&s.set(o),this.#n?.onInject(i),this},this.remove=i=>(this.#t.remove(i),this.#n?.onRemove(i),this),this.record=i=>(i.create(this.#e.store),this.#n?.onRecord(i),this),this.clearTimer=i=>(this.#e.remove(i),this.#n?.onClear(i),this),this.isInjected=i=>this.#t.has(i),this.isRecorded=i=>this.#e.has(i),this.use=i=>(this.#n?.onUse(i),this.#t.get(i)),this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>this.#e.get(i),this.done=i=>{this.timer(i).done(),this.#n?.onDone(i)},this.wait=i=>{let o=this.timer(i).start();return this.#n?.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},this.#t=e,this.#e=t,this.#r=r,r&&(this.#n=new ll(e,t,r))}#t;#e;#r;#n;get meta(){return this.#r}get inspector(){return this.#n}},Zi=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw Ou(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},al=class{constructor(e,t){this.#t=null,this.#e=null,this.#n="pending",this.start=()=>(this.#t??=new Promise((r,i)=>{this.#e=o=>{o instanceof CustomEvent&&o.detail.id===this.#r&&(this.#n="resolved",this.#s(),o.stopImmediatePropagation(),r())},this.#o(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#s(),i(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{let r=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(r)},this.#s=()=>{this.#e&&removeEventListener(this.type.name,this.#e)},this.#o=r=>{setTimeout(()=>{r()},this.type.timeout)},this.#r=Symbol(t.name),this.type=t,e.set(t.id,this)}#t;#e;#r;#n;get status(){return this.#n}#s;#o},cl=class{constructor(e,t=3e3){this.create=r=>new al(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},He=(n,e=3e3)=>new cl(n,e);function ye(n){this.content=n}ye.prototype={constructor:ye,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),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new ye(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ye(t)},addToStart:function(n,e){return new ye([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ye(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new ye(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=ye.from(n),n.size?new ye(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ye.from(n),n.size?new ye(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ye.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}};ye.from=function(n){if(n instanceof ye)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ye(e)};var ul=ye;function ju(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),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=ju(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Hu(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let c=Hu(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}var M=class n{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,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=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&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new n(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 o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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 ju(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Hu(this,e,t,r)}findIndex(e){if(e==0)return eo(0,e);if(e==this.size)return eo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?eo(t+1,o):eo(t,r);r=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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};M.empty=new M([],0);var fl={index:0,offset:0};function eo(n,e){return fl.index=n,fl.offset=e,fl}function no(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(!no(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!no(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}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&&no(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 n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};q.none=[];var nn=class extends Error{},O=class n{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=Ku(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(qu(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 n.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 n(M.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};O.empty=new O(M.empty,0,0);function qu(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(qu(o.content,e-i-1,t-i-1)))}function Ku(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Ku(s.content,e-o-1,t,s);return l&&n.replaceChild(i,s.copy(l))}function vg(n,e,t){if(t.openStart>n.depth)throw new nn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new nn("Inconsistent open depths");return Uu(n,e,t,0)}function Uu(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Uu(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return tn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Dg(t,n);return tn(o,Gu(n,s,l,e,r))}else return tn(o,ro(n,e,r))}function Ju(n,e){if(!e.type.compatibleContent(n.type))throw new nn("Cannot join "+e.type.name+" onto "+n.type.name)}function dl(n,e,t){let r=n.node(t);return Ju(r,e.node(t)),r}function en(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 Hr(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(en(n.nodeAfter,r),o++));for(let l=o;l<s;l++)en(i.child(l),r);e&&e.depth==t&&e.textOffset&&en(e.nodeBefore,r)}function tn(n,e){return n.type.checkContent(e),n.copy(e)}function Gu(n,e,t,r,i){let o=n.depth>i&&dl(n,e,i+1),s=r.depth>i&&dl(t,r,i+1),l=[];return Hr(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Ju(o,s),en(tn(o,Gu(n,e,t,r,i+1)),l)):(o&&en(tn(o,ro(n,e,i+1)),l),Hr(e,t,i,l),s&&en(tn(s,ro(t,r,i+1)),l)),Hr(r,null,i,l),new M(l)}function ro(n,e,t){let r=[];if(Hr(null,n,t,r),n.depth>t){let i=dl(n,e,t+1);en(tn(i,ro(n,e,t+1)),r)}return Hr(e,null,t,r),new M(r)}function Dg(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(M.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var io=class n{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 o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return q.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 o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}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 o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].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 Kr(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,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=Pu.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else Pu.set(e,r=new pl);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Pg,i}},pl=class{constructor(){this.elts=[],this.i=0}},Pg=12,Pu=new WeakMap,Kr=class{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)}},Lg=Object.create(null),Ae=class n{constructor(e,t,r,i=q.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&no(this.attrs,t||e.defaultAttrs||Lg)&&q.sameSet(this.marks,r||q.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new O(c,i.depth-s,o.depth-s)}replace(e,t,r){return vg(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 io.resolveCached(this,e)}resolveNoCache(e){return io.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.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()+")"),Yu(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=M.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<o;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 o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.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=q.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(!q.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=M.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Ae.prototype.text=void 0;var ml=class n extends Ae{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):Yu(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(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 Yu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var rn=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new gl(e,t);if(r.next==null)return n.empty;let i=Qu(r);r.next&&r.err("Unexpected trailing text");let o=Wg($g(i));return jg(o,r),o}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 o=t;i&&o<r;o++)i=i.matchType(e.child(o).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 o(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return M.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=o(f,l.concat(u));if(d)return d}}return null}return o(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(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!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 o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(` 3 + `)}};rn.empty=new rn(!0);var gl=class{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 Qu(n){let e=[];do e.push(Bg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Bg(n){let e=[];do e.push(zg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zg(n){let e=Vg(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=Fg(n,e);else break;return e}function Lu(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Fg(n,e){let t=Lu(n),r=t;return n.eat(",")&&(n.next!="}"?r=Lu(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function _g(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Vg(n){if(n.eat("(")){let e=Qu(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=_g(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 $g(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Xu(n,e){return e-n}function Bu(n,e){let t=[];return r(e),t.sort(Xu);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Wg(n){let e=Object.create(null);return t(Bu(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Bu(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new rn(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Xu);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function jg(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Zu(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 ef(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function tf(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 o=n[i];o.validate&&o.validate(e[i])}}function nf(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new yl(n,r,e[r]);return t}var oo=class n{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=nf(e,r.attrs),this.defaultAttrs=Zu(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==rn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ef(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ae(this,this.computeAttrs(e),M.from(t),q.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Ae(this,this.computeAttrs(e),t,q.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(M.empty,!0);return o?new Ae(this,e,t.append(o),q.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){tf(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:q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new n(o,t,s));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 o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Hg(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var yl=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Hg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Ur=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=nf(e,i.attrs),this.excluded=null;let o=Zu(this.attrs);this.instance=o?new q(this,o):null}create(e=null){return!e&&this.instance?this.instance:new q(this,ef(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),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){tf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},so=class{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=ul.from(e.nodes),t.marks=ul.from(e.marks||{}),this.nodes=oo.compile(this.spec.nodes,this),this.marks=Ur.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 o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=rn.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?zu(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:zu(this,s.split(" "))}this.nodeFromJSON=i=>Ae.fromJSON(this,i),this.markFromJSON=i=>q.fromJSON(this,i),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 oo){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 ml(r,r.defaultAttrs,e,q.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function zu(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);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(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function qg(n){return n.tag!=null}function Kg(n){return n.style!=null}var on=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(qg(i))this.tags.push(i);else if(Kg(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new lo(this,t,!1);return r.addAll(e,q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new lo(this,t,!0);return r.addAll(e,q.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 o=this.tags[i];if(Gg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=_u(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=_u(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},rf={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},Ug={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},of={ol:!0,ul:!0},Jr=1,xl=2,qr=4;function Fu(n,e,t){return e!=null?(e?Jr:0)|(e==="full"?xl:0):n&&n.whitespace=="pre"?Jr|xl:t&~qr}var Un=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=q.none,this.match=o||(s&qr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.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&Jr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.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&&!rf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},lo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Fu(null,t.preserveWhitespace,0)|(r?qr:0);i?o=new Un(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Un(null,null,q.none,!0,null,s):o=new Un(e.schema.topNodeType,null,q.none,!0,null,s),this.nodes=[o],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,o=i.options&xl?"full":this.localPreserveWS||(i.options&Jr)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` 4 4 `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else 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 l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;of.hasOwnProperty(s)&&this.parser.normalizeLists&&Jg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ug.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(rf.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 5 - `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):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 o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.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,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=q.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Vu(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Fu(e,o,s.options);s.options&qr&&s.content.length==0&&(l|=qr);let a=q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Vu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Un(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Jr)}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),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(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 Jg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&of.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Gg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function _u(n){let e={};for(let t in n)e[t]=n[t];return e}function Vu(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}var sn=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=fl(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=to(fl(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 o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&to(fl(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return to(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=$u(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return $u(e.marks)}};function $u(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function fl(n){return n.document||window.document}var Wu=new WeakMap;function Yg(n){let e=Wu.get(n);return e===void 0&&Wu.set(n,e=Qg(n)),e}function Qg(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 to(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],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Yg(r))&&o.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 s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=to(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var af=65535,cf=Math.pow(2,16);function Xg(n,e){return n+e*cf}function sf(n){return n&af}function Zg(n){return(n-(n&af))/cf}var uf=1,ff=2,ao=4,hf=8,Qr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&hf)>0}get deletedBefore(){return(this.delInfo&(uf|ao))>0}get deletedAfter(){return(this.delInfo&(ff|ao))>0}get deletedAcross(){return(this.delInfo&ao)>0}},xt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=sf(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+Zg(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,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:Xg(l/3,e-a),m=e==a?ff:e==f?uf:ao;return(t<0?e!=a:e!=f)&&(m|=hf),new Qr(h,m,p)}i+=u-c}return r?e+i:new Qr(e+i,0,null)}touches(e,t){let r=0,i=sf(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};xt.empty=new xt([]);var Xr=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),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 n;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 o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Qr(e,i,null)}},xl=Object.create(null),ae=class{getMap(){return xt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=xl[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 xl)throw new RangeError("Duplicate use of step JSON ID "+e);return xl[e]=t,t.prototype.jsonID=e,t}},fe=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(o){if(o instanceof nn)return n.fail(o.message);throw o}}};function Cl(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Cl(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return M.fromArray(r)}var ln=class n extends ae{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)),o=new O(Cl(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,o)}invert(){return new an(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 n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("addMark",ln);var an=class n extends ae{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(Cl(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,r)}invert(){return new ln(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 n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("removeMark",an);var Zr=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.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 n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Jn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("addNodeMark",Zr);var Jn=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Zr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("removeNodeMark",Jn);var xe=class n extends ae{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&wl(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(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 n(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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 n(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 n(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 n(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}};ae.jsonID("replace",xe);var he=class n extends ae{constructor(e,t,r,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(wl(e,this.from,this.gapFrom)||wl(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.fail("Content does not fit in gap")}getMap(){return new xt([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 n(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),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 n(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}};ae.jsonID("replaceAround",he);function wl(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function ey(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(s&&s.to==d&&s.mark.eq(f[m])?s.to=h:i.push(s=new an(d,h,f[m])));l&&l.to==d?l.to=h:o.push(l=new ln(d,h,r))}}),i.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function ty(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Ur){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>n.step(new an(s.from,s.to,s.style)))}function Ml(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new xe(l,u,O.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new an(l,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new O(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new xe(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(M.empty,!0);n.replace(l,l,new O(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function ny(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Yn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!ny(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function ry(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=M.empty,f=0;for(let p=o,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=M.from(r.node(p).copy(u)),f++):a--;let d=M.empty,h=0;for(let p=o,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=M.from(i.node(p).copy(d)),h++):c++;n.step(new he(a,c,s,l,new O(u.append(d),f,h),u.size-f,!0))}function cn(n,e,t=null,r=n){let i=iy(n,e),o=i&&oy(r,e);return o?i.map(lf).concat({type:e,attrs:t}).concat(o.map(lf)):null}function lf(n){return{type:n,attrs:null}}function iy(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function oy(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function sy(n,e,t){let r=M.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new he(i,o,i,o,new O(r,0,0),t.length,!0))}function ly(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&ay(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&pf(n,s,l,o),Ml(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return n.step(new he(f,d,f+1,d-1,new O(M.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&df(n,s,l,o),!1}})}function df(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function pf(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` 6 - `))}})}function ay(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function cy(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new he(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new O(M.from(s),0,0),1,!0))}function un(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function uy(n,e,t=1,r){let i=n.doc.resolve(e),o=M.empty,s=M.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=M.from(i.node(l).copy(o));let u=r&&r[c];s=M.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new xe(e,e,new O(o.append(s),t,t),!0))}function fn(n,e){let t=n.resolve(e),r=t.index();return hy(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function fy(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function hy(n,e){return!!(n&&e&&!n.isLeaf&&fy(n,e))}function dy(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);pf(n,u.node(),u.before(),l)}s.inlineContent&&Ml(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new xe(c,a.map(e+t,-1),O.empty,!0)),r===!0){let u=n.doc.resolve(c);df(n,u.node(),u.before(),n.steps.length)}return n}function py(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 o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function mf(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ei(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return gf(i,o,r)?new xe(e,t,r):new Sl(i,o,r).fit()}function gf(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Sl=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=M.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=M.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),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 o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new O(o,s,l);return e>-1?new he(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new xe(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 o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=kl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(s?c.matchType(s.type)||(f=c.fillBefore(M.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=kl(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=kl(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new O(Gr(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new O(Gr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),k=f.matchType(m.type);if(!k)break;c++,(c>1||a==0||m.content.size)&&(f=k,u.push(yf(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Yr(this.placed,t,M.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m<h;m++){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(Gr(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new O(Gr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!bl(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],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=bl(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=bl(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?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=Yr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Yr(this.placed,this.depth,M.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(M.empty,!0);t.childCount&&(this.placed=Yr(this.placed,this.frontier.length,t))}};function Gr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Gr(n.firstChild.content,e-1,t)))}function Yr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Yr(n.lastChild.content,e-1,t)))}function kl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function yf(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,yf(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(M.empty,!0)))),n.copy(r)}function bl(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!my(t,o.content,s)?l:null}function my(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function gy(n){return n.spec.defining||n.spec.definingForContent}function yy(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(gf(i,o,r))return n.step(new xe(e,t,r));let s=kf(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=gy(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let k=s[(m+a)%s.length],x=!0;k<0&&(x=!1,k=-k);let I=i.node(k-1),C=i.index(k-1);if(I.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(k),x?o.after(k):t,new O(xf(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=s.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),t=o.after(h))}}function xf(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(xf(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(M.empty,!0))}return n}function xy(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=py(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new O(M.from(r),0,0))}function ky(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=kf(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return 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 s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function kf(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<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;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var co=class n extends ae{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 fe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(i),0,t.isLeaf?0:1))}getMap(){return xt.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};ae.jsonID("attr",co);var uo=class n extends ae{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 fe.ok(r)}getMap(){return xt.empty}invert(e){return new n(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 n(t.attr,t.value)}};ae.jsonID("docAttr",uo);var Gn=class extends Error{};Gn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Gn.prototype=Object.create(Error.prototype);Gn.prototype.constructor=Gn;Gn.prototype.name="TransformError";var fo=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Gn(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}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}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=ei(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new O(M.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 yy(this,e,t,r),this}replaceRangeWith(e,t,r){return xy(this,e,t,r),this}deleteRange(e,t){return ky(this,e,t),this}lift(e,t){return ry(this,e,t),this}join(e,t=1){return dy(this,e,t),this}wrap(e,t){return sy(this,e,t),this}setBlockType(e,t=e,r,i=null){return ly(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return cy(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new co(e,t,r)),this}setDocAttribute(e,t){return this.step(new uo(e,t)),this}addNodeMark(e,t){return this.step(new Zr(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof q)t.isInSet(r.marks)&&this.step(new Jn(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Jn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return uy(this,e,t,r),this}addMark(e,t,r){return ey(this,e,t,r),this}removeMark(e,t,r){return ty(this,e,t,r),this}clearIncompatible(e,t,r){return Ml(this,e,t,r),this}};var Nl=Object.create(null),W=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Xn(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 o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?O.empty:t),l==0&&Sf(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Sf(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new j(e):Qn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Qn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Qn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Fe(e.node(0))}static atStart(e){return Qn(e,e,0,0,1)||new Fe(e)}static atEnd(e){return Qn(e,e,e.content.size,e.childCount,-1)||new Fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Nl[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 Nl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Nl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return j.between(this.$anchor,this.$head).getBookmark()}};W.prototype.visible=!0;var Xn=class{constructor(e,t){this.$from=e,this.$to=t}},bf=!1;function wf(n){!bf&&!n.parent.inlineContent&&(bf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var j=class n extends W{constructor(e,t=e){wf(e),wf(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 W.near(r);let i=e.resolve(t.map(this.anchor));return new n(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 n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new po(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 n(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 o=W.findFrom(t,r,!0)||W.findFrom(t,-r,!0);if(o)t=o.$head;else return W.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};W.jsonID("text",j);var po=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return j.between(e.resolve(this.anchor),e.resolve(this.head))}},B=class n extends W{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),o=e.resolve(i);return r?W.near(o):new n(o)}content(){return new O(M.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Tl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};B.prototype.visible=!1;W.jsonID("node",B);var Tl=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new po(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&B.isSelectable(r)?new B(t):W.near(t)}},Fe=class n extends W{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=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return by}};W.jsonID("all",Fe);var by={map(){return this},resolve(n){return new Fe(n)}};function Qn(n,e,t,r,i,o=!1){if(e.inlineContent)return j.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let a=Qn(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Sf(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof xe||i instanceof he))return;let o=n.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(W.near(n.doc.resolve(s),t))}var Cf=1,ho=2,Mf=4,Ol=class extends fo{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|Cf)&~ho,this.storedMarks=null,this}get selectionSet(){return(this.updated&Cf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ho,this}ensureMarks(e){return q.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&ho)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ho,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)||q.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),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.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|=Mf,this}get scrolledIntoView(){return(this.updated&Mf)>0}};function Nf(n,e){return!e||!n?n:n.bind(e)}var hn=class{constructor(e,t,r){this.name=e,this.init=Nf(t.init,r),this.apply=Nf(t.apply,r)}},wy=[new hn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new hn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new hn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new hn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],ti=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=wy.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 hn(r.key,r.spec.state,r))})}},mo=class n{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 o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Ol(this)}static create(e){let t=new ti(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(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 ti(this.schema,e.plugins),r=t.fields,i=new n(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let 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],o=i.spec.state;o&&o.toJSON&&(t[r]=o.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 ti(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Ae.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=W.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function If(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=If(i,e,{})),t[r]=i}return t}var ne=class{constructor(e){this.spec=e,this.props={},e.props&&If(e.props,this,this.props),this.key=e.key?e.key.key:Tf("plugin")}getState(e){return e[this.key]}},Il=Object.create(null);function Tf(n){return n in Il?n+"$"+ ++Il[n]:(Il[n]=0,n+"$")}var re=class{constructor(e="key"){this.key=Tf(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var go=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ef(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Al=(n,e,t)=>{let r=Ef(n,t);if(!r)return!1;let i=vl(r);if(!i){let s=r.blockRange(),l=s&&Yn(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(vf(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Zn(o,"end")||B.isSelectable(o)))for(let s=r.depth;;s--){let l=ei(n.doc,r.before(s),r.after(s),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Zn(o,"end")?W.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):B.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Af=(n,e,t)=>{let r=Ef(n,t);if(!r)return!1;let i=vl(r);return i?Sy(n,i,e):!1};function Sy(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=ei(n.doc,o,a,O.empty);if(!c||c.from!=o||c instanceof xe&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(j.create(u.doc,o)),t(u.scrollIntoView())}return!0}function Zn(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}var Rl=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=vl(r)}let s=o&&o.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function vl(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 Cy(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var My=(n,e,t)=>{let r=Cy(n,t);if(!r)return!1;let i=Rf(r);if(!i)return!1;let o=i.nodeAfter;if(vf(n,i,e,1))return!0;if(r.parent.content.size==0&&(Zn(o,"start")||B.isSelectable(o))){let s=ei(n.doc,r.before(),r.after(),O.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Zn(o,"start")?W.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):B.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Ny=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=Rf(r)}let s=o&&o.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos)).scrollIntoView()),!0)};function Rf(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}var Iy=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` 7 - `).scrollIntoView()),!0)};function Dl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Ty=(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),o=t.indexAfter(-1),s=Dl(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(W.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Oy=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Fe||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Dl(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(s,o.createAndFill());l.setSelection(j.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ey=(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 o=t.before();if(un(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Yn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Ay(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!un(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Dl(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=n&&n(i.parent,a,r);o.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof j||e.selection instanceof Fe)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=un(u.doc,f,o.length,o);if(d||(o[0]=l?{type:l}:null,d=un(u.doc,f,o.length,o)),!d)return!1;if(u.split(f,o.length,o),!a&&c&&r.node(s).type!=l){let h=u.mapping.map(r.before(s)),p=u.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return t&&t(u.scrollIntoView()),!0}}var Ry=Ay();var vy=(n,e)=>(e&&e(n.tr.setSelection(new Fe(n.doc))),!0);function Dy(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||fn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function vf(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Dy(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=M.empty;for(let x=s.length-1;x>=0;x--)p=M.from(s[x].create(null,p));p=M.from(i.copy(p));let m=n.tr.step(new he(e.pos-1,h,e.pos,h,new O(p,1,0),s.length,!0)),k=m.doc.resolve(h+2*s.length);k.nodeAfter&&k.nodeAfter.type==i.type&&fn(m.doc,k.pos)&&m.join(k.pos),t(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:W.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&Yn(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&Zn(o,"start",!0)&&Zn(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=o,k=1;for(;!m.isTextblock;m=m.firstChild)k++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let x=M.empty;for(let C=p.length-1;C>=0;C--)x=M.from(p[C].copy(x));let I=n.tr.step(new he(e.pos-p.length,e.pos+o.nodeSize,e.pos+k,e.pos+o.nodeSize-k,new O(x,p.length,0),0,!0));t(I.scrollIntoView())}return!0}}return!1}function Df(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(j.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Py=Df(-1),Ly=Df(1);function yo(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&cn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function er(n,e=null){return function(t,r){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function By(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(o.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=o.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function zy(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:i}=n[t];r.doc.nodesBetween(r.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=r.pos&&s+o.nodeSize<=i.pos)return s+1>r.pos&&e.push(new Xn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+o.content.size),!1}),r.pos<i.pos&&e.push(new Xn(r,i))}return e}function xo(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,o=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!By(s.doc,u,n,i))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let f,d=s.tr;i||(u=zy(u)),r?f=!u.some(h=>s.doc.rangeHasMark(h.$from.pos,h.$to.pos,n)):f=!u.every(h=>{let p=!1;return d.doc.nodesBetween(h.$from.pos,h.$to.pos,(m,k,x)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!x&&x.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,h.$from.pos-k),Math.min(m.nodeSize,h.$to.pos-k))))}),!p});for(let h=0;h<u.length;h++){let{$from:p,$to:m}=u[h];if(!f)d.removeMark(p.pos,m.pos,n);else{let k=p.pos,x=m.pos,I=p.nodeAfter,C=m.nodeBefore,A=o&&I&&I.isText?/^\s*/.exec(I.text)[0].length:0,v=o&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;k+A<x&&(k+=A,x-=v),d.addMark(k,x,n.create(e))}}l(d.scrollIntoView())}return!0}}function dn(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var El=dn(go,Al,Rl),Of=dn(go,My,Ny),kt={Enter:dn(Iy,Oy,Ey,Ry),"Mod-Enter":Ty,Backspace:El,"Mod-Backspace":El,"Shift-Backspace":El,Delete:Of,"Mod-Delete":Of,"Mod-a":vy},Pf={"Ctrl-h":kt.Backspace,"Alt-Backspace":kt["Mod-Backspace"],"Ctrl-d":kt.Delete,"Ctrl-Alt-Backspace":kt["Mod-Delete"],"Alt-Delete":kt["Mod-Delete"],"Alt-d":kt["Mod-Delete"],"Ctrl-a":Py,"Ctrl-e":Ly};for(let n in kt)Pf[n]=kt[n];var Fy=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Lf=Fy?Pf:kt;var _y={};function pn(n,e){let t=e||_y,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return zf(n,r,i)}function zf(n,e,t){if(Vy(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 Bf(n.children,e,t)}return Array.isArray(n)?Bf(n,e,t):""}function Bf(n,e,t){let r=[],i=-1;for(;++i<n.length;)r[i]=zf(n[i],e,t);return r.join("")}function Vy(n){return!!(n&&typeof n=="object")}var Ff=document.createElement("i");function tr(n){let e="&"+n+";";Ff.innerHTML=e;let t=Ff.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function de(n,e,t,r){let i=n.length,o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,r.length<1e4)s=Array.from(r),s.unshift(e,t),n.splice(...s);else for(t&&n.splice(e,t);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),n.splice(...s),o+=1e4,e+=1e4}function Ce(n,e){return n.length>0?(de(n,n.length,0,e),n):e}var _f={}.hasOwnProperty;function Vf(n){let e={},t=-1;for(;++t<n.length;)$y(e,n[t]);return e}function $y(n,e){let t;for(t in e){let i=(_f.call(n,t)?n[t]:void 0)||(n[t]={}),o=e[t],s;if(o)for(s in o){_f.call(i,s)||(i[s]=[]);let l=o[s];Wy(i[s],Array.isArray(l)?l:l?[l]:[])}}}function Wy(n,e){let t=-1,r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);de(n,0,0,r)}function ko(n,e){let 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?"\uFFFD":String.fromCodePoint(t)}function bt(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var _e=Bt(/[A-Za-z]/),Me=Bt(/[\dA-Za-z]/),$f=Bt(/[#-'*+\--9=?A-Z^-~]/);function ni(n){return n!==null&&(n<32||n===127)}var ri=Bt(/\d/),Wf=Bt(/[\dA-Fa-f]/),jf=Bt(/[!-/:-@[-`{-~]/);function E(n){return n!==null&&n<-2}function ie(n){return n!==null&&(n<0||n===32)}function z(n){return n===-2||n===-1||n===32}var Hf=Bt(/\p{P}|\p{S}/u),qf=Bt(/\s/);function Bt(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function V(n,e,t,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return s;function s(a){return z(a)?(n.enter(t),l(a)):e(a)}function l(a){return z(a)&&o++<i?(n.consume(a),l):(n.exit(t),e(a))}}var Kf={tokenize:jy};function jy(n){let e=n.attempt(this.parser.constructs.contentInitial,r,i),t;return e;function r(l){if(l===null){n.consume(l);return}return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),V(n,e,"linePrefix")}function i(l){return n.enter("paragraph"),o(l)}function o(l){let a=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,s(l)}function s(l){if(l===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(l);return}return E(l)?(n.consume(l),n.exit("chunkText"),o):(n.consume(l),s)}}var Jf={tokenize:Hy},Uf={tokenize:qy};function Hy(n){let e=this,t=[],r=0,i,o,s;return l;function l(C){if(r<t.length){let A=t[r];return e.containerState=A[1],n.attempt(A[0].continuation,a,c)(C)}return c(C)}function a(C){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&I();let A=e.events.length,v=A,b;for(;v--;)if(e.events[v][0]==="exit"&&e.events[v][1].type==="chunkFlow"){b=e.events[v][1].end;break}x(r);let T=A;for(;T<e.events.length;)e.events[T][1].end={...b},T++;return de(e.events,v+1,0,e.events.slice(A)),e.events.length=T,c(C)}return l(C)}function c(C){if(r===t.length){if(!i)return d(C);if(i.currentConstruct&&i.currentConstruct.concrete)return p(C);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Uf,u,f)(C)}function u(C){return i&&I(),x(r),d(C)}function f(C){return e.parser.lazy[e.now().line]=r!==t.length,s=e.now().offset,p(C)}function d(C){return e.containerState={},n.attempt(Uf,h,p)(C)}function h(C){return r++,t.push([e.currentConstruct,e.containerState]),d(C)}function p(C){if(C===null){i&&I(),x(0),n.consume(C);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),m(C)}function m(C){if(C===null){k(n.exit("chunkFlow"),!0),x(0),n.consume(C);return}return E(C)?(n.consume(C),k(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(C),m)}function k(C,A){let v=e.sliceStream(C);if(A&&v.push(null),C.previous=o,o&&(o.next=C),o=C,i.defineSkip(C.start),i.write(v),e.parser.lazy[C.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<s&&(!i.events[b][1].end||i.events[b][1].end.offset>s))return;let T=e.events.length,P=T,D,U;for(;P--;)if(e.events[P][0]==="exit"&&e.events[P][1].type==="chunkFlow"){if(D){U=e.events[P][1].end;break}D=!0}for(x(r),b=T;b<e.events.length;)e.events[b][1].end={...U},b++;de(e.events,P+1,0,e.events.slice(T)),e.events.length=b}}function x(C){let A=t.length;for(;A-- >C;){let v=t[A];e.containerState=v[1],v[0].exit.call(e,n)}t.length=C}function I(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function qy(n,e,t){return V(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function nr(n){if(n===null||ie(n)||qf(n))return 1;if(Hf(n))return 2}function rr(n,e,t){let r=[],i=-1;for(;++i<n.length;){let o=n[i].resolveAll;o&&!r.includes(o)&&(e=o(e,t),r.push(o))}return e}var ii={name:"attention",resolveAll:Ky,tokenize:Uy};function Ky(n,e){let t=-1,r,i,o,s,l,a,c,u;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;let f={...n[r][1].end},d={...n[t][1].start};Gf(f,-a),Gf(d,a),s={type:a>1?"strongSequence":"emphasisSequence",start:f,end:{...n[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:d},o={type:a>1?"strongText":"emphasisText",start:{...n[r][1].end},end:{...n[t][1].start}},i={type:a>1?"strong":"emphasis",start:{...s.start},end:{...l.end}},n[r][1].end={...s.start},n[t][1].start={...l.end},c=[],n[r][1].end.offset-n[r][1].start.offset&&(c=Ce(c,[["enter",n[r][1],e],["exit",n[r][1],e]])),c=Ce(c,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),c=Ce(c,rr(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),c=Ce(c,[["exit",o,e],["enter",l,e],["exit",l,e],["exit",i,e]]),n[t][1].end.offset-n[t][1].start.offset?(u=2,c=Ce(c,[["enter",n[t][1],e],["exit",n[t][1],e]])):u=0,de(n,r-1,t-r+3,c),t=r+c.length-u-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function Uy(n,e){let t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nr(r),o;return s;function s(a){return o=a,n.enter("attentionSequence"),l(a)}function l(a){if(a===o)return n.consume(a),l;let c=n.exit("attentionSequence"),u=nr(a),f=!u||u===2&&i||t.includes(a),d=!i||i===2&&u||t.includes(r);return c._open=!!(o===42?f:f&&(i||!d)),c._close=!!(o===42?d:d&&(u||!f)),e(a)}}function Gf(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}var Pl={name:"autolink",tokenize:Jy};function Jy(n,e,t){let r=0;return i;function i(h){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),o}function o(h){return _e(h)?(n.consume(h),s):h===64?t(h):c(h)}function s(h){return h===43||h===45||h===46||Me(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(n.consume(h),r=0,a):(h===43||h===45||h===46||Me(h))&&r++<32?(n.consume(h),l):(r=0,c(h))}function a(h){return h===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):h===null||h===32||h===60||ni(h)?t(h):(n.consume(h),a)}function c(h){return h===64?(n.consume(h),u):$f(h)?(n.consume(h),c):t(h)}function u(h){return Me(h)?f(h):t(h)}function f(h){return h===46?(n.consume(h),r=0,u):h===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):d(h)}function d(h){if((h===45||Me(h))&&r++<63){let p=h===45?d:f;return n.consume(h),p}return t(h)}}var zt={partial:!0,tokenize:Gy};function Gy(n,e,t){return r;function r(o){return z(o)?V(n,i,"linePrefix")(o):i(o)}function i(o){return o===null||E(o)?e(o):t(o)}}var bo={continuation:{tokenize:Qy},exit:Xy,name:"blockQuote",tokenize:Yy};function Yy(n,e,t){let r=this;return i;function i(s){if(s===62){let l=r.containerState;return l.open||(n.enter("blockQuote",{_container:!0}),l.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(s),n.exit("blockQuoteMarker"),o}return t(s)}function o(s){return z(s)?(n.enter("blockQuotePrefixWhitespace"),n.consume(s),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(s))}}function Qy(n,e,t){let r=this;return i;function i(s){return z(s)?V(n,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return n.attempt(bo,e,t)(s)}}function Xy(n){n.exit("blockQuote")}var wo={name:"characterEscape",tokenize:Zy};function Zy(n,e,t){return r;function r(o){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(o),n.exit("escapeMarker"),i}function i(o){return jf(o)?(n.enter("characterEscapeValue"),n.consume(o),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(o)}}var So={name:"characterReference",tokenize:ex};function ex(n,e,t){let r=this,i=0,o,s;return l;function l(f){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),a}function a(f){return f===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(f),n.exit("characterReferenceMarkerNumeric"),c):(n.enter("characterReferenceValue"),o=31,s=Me,u(f))}function c(f){return f===88||f===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(f),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),o=6,s=Wf,u):(n.enter("characterReferenceValue"),o=7,s=ri,u(f))}function u(f){if(f===59&&i){let d=n.exit("characterReferenceValue");return s===Me&&!tr(r.sliceSerialize(d))?t(f):(n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return s(f)&&i++<o?(n.consume(f),u):t(f)}}var Yf={partial:!0,tokenize:nx},Co={concrete:!0,name:"codeFenced",tokenize:tx};function tx(n,e,t){let r=this,i={partial:!0,tokenize:v},o=0,s=0,l;return a;function a(b){return c(b)}function c(b){let T=r.events[r.events.length-1];return o=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=b,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),u(b)}function u(b){return b===l?(s++,n.consume(b),u):s<3?t(b):(n.exit("codeFencedFenceSequence"),z(b)?V(n,f,"whitespace")(b):f(b))}function f(b){return b===null||E(b)?(n.exit("codeFencedFence"),r.interrupt?e(b):n.check(Yf,m,A)(b)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(b))}function d(b){return b===null||E(b)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),f(b)):z(b)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),V(n,h,"whitespace")(b)):b===96&&b===l?t(b):(n.consume(b),d)}function h(b){return b===null||E(b)?f(b):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||E(b)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),f(b)):b===96&&b===l?t(b):(n.consume(b),p)}function m(b){return n.attempt(i,A,k)(b)}function k(b){return n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),x}function x(b){return o>0&&z(b)?V(n,I,"linePrefix",o+1)(b):I(b)}function I(b){return b===null||E(b)?n.check(Yf,m,A)(b):(n.enter("codeFlowValue"),C(b))}function C(b){return b===null||E(b)?(n.exit("codeFlowValue"),I(b)):(n.consume(b),C)}function A(b){return n.exit("codeFenced"),e(b)}function v(b,T,P){let D=0;return U;function U(F){return b.enter("lineEnding"),b.consume(F),b.exit("lineEnding"),Se}function Se(F){return b.enter("codeFencedFence"),z(F)?V(b,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):Y(F)}function Y(F){return F===l?(b.enter("codeFencedFenceSequence"),R(F)):P(F)}function R(F){return F===l?(D++,b.consume(F),R):D>=s?(b.exit("codeFencedFenceSequence"),z(F)?V(b,L,"whitespace")(F):L(F)):P(F)}function L(F){return F===null||E(F)?(b.exit("codeFencedFence"),T(F)):P(F)}}}function nx(n,e,t){let r=this;return i;function i(s){return s===null?t(s):(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}var oi={name:"codeIndented",tokenize:ix},rx={partial:!0,tokenize:ox};function ix(n,e,t){let r=this;return i;function i(c){return n.enter("codeIndented"),V(n,o,"linePrefix",5)(c)}function o(c){let u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?s(c):t(c)}function s(c){return c===null?a(c):E(c)?n.attempt(rx,s,a)(c):(n.enter("codeFlowValue"),l(c))}function l(c){return c===null||E(c)?(n.exit("codeFlowValue"),s(c)):(n.consume(c),l)}function a(c){return n.exit("codeIndented"),e(c)}}function ox(n,e,t){let r=this;return i;function i(s){return r.parser.lazy[r.now().line]?t(s):E(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),i):V(n,o,"linePrefix",5)(s)}function o(s){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):E(s)?i(s):t(s)}}var Ll={name:"codeText",previous:lx,resolve:sx,tokenize:ax};function sx(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 lx(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ax(n,e,t){let r=this,i=0,o,s;return l;function l(d){return n.enter("codeText"),n.enter("codeTextSequence"),a(d)}function a(d){return d===96?(n.consume(d),i++,a):(n.exit("codeTextSequence"),c(d))}function c(d){return d===null?t(d):d===32?(n.enter("space"),n.consume(d),n.exit("space"),c):d===96?(s=n.enter("codeTextSequence"),o=0,f(d)):E(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),c):(n.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||E(d)?(n.exit("codeTextData"),c(d)):(n.consume(d),u)}function f(d){return d===96?(n.consume(d),o++,f):o===i?(n.exit("codeTextSequence"),n.exit("codeText"),e(d)):(s.type="codeTextData",u(d))}}var Mo=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let 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){let i=t||0;this.setCursor(Math.trunc(e));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&si(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),si(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),si(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);si(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);si(this.left,t.reverse())}}};function si(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 No(n){let e={},t=-1,r,i,o,s,l,a,c,u=new Mo(n);for(;++t<u.length;){for(;t in e;)t=e[t];if(r=u.get(t),t&&r[1].type==="chunkFlow"&&u.get(t-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,o=0,o<a.length&&a[o][1].type==="lineEndingBlank"&&(o+=2),o<a.length&&a[o][1].type==="content"))for(;++o<a.length&&a[o][1].type!=="content";)a[o][1].type==="chunkText"&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,cx(u,t)),t=e[t],c=!0);else if(r[1]._container){for(o=t,i=void 0;o--;)if(s=u.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},l=u.slice(i,t),l.unshift(r),u.splice(i,t-i+1,l))}}return de(n,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function cx(n,e){let t=n.get(e)[1],r=n.get(e)[2],i=e-1,o=[],s=t._tokenizer;s||(s=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let l=s.events,a=[],c={},u,f,d=-1,h=t,p=0,m=0,k=[m];for(;h;){for(;n.get(++i)[1]!==h;);o.push(i),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=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&&(m=d+1,k.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):k.pop(),d=k.length;d--;){let x=l.slice(k[d],k[d+1]),I=o.pop();a.push([I,I+x.length-1]),n.splice(I,2,x)}for(a.reverse(),d=-1;++d<a.length;)c[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return c}var Bl={resolve:fx,tokenize:hx},ux={partial:!0,tokenize:dx};function fx(n){return No(n),n}function hx(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?o(l):E(l)?n.check(ux,s,o)(l):(n.consume(l),i)}function o(l){return n.exit("chunkContent"),n.exit("content"),e(l)}function s(l){return n.consume(l),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function dx(n,e,t){let r=this;return i;function i(s){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),V(n,o,"linePrefix")}function o(s){if(s===null||E(s))return t(s);let l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):n.interrupt(r.parser.constructs.flow,t,e)(s)}}function Io(n,e,t,r,i,o,s,l,a){let c=a||Number.POSITIVE_INFINITY,u=0;return f;function f(x){return x===60?(n.enter(r),n.enter(i),n.enter(o),n.consume(x),n.exit(o),d):x===null||x===32||x===41||ni(x)?t(x):(n.enter(r),n.enter(s),n.enter(l),n.enter("chunkString",{contentType:"string"}),m(x))}function d(x){return x===62?(n.enter(o),n.consume(x),n.exit(o),n.exit(i),n.exit(r),e):(n.enter(l),n.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(n.exit("chunkString"),n.exit(l),d(x)):x===null||x===60||E(x)?t(x):(n.consume(x),x===92?p:h)}function p(x){return x===60||x===62||x===92?(n.consume(x),h):h(x)}function m(x){return!u&&(x===null||x===41||ie(x))?(n.exit("chunkString"),n.exit(l),n.exit(s),n.exit(r),e(x)):u<c&&x===40?(n.consume(x),u++,m):x===41?(n.consume(x),u--,m):x===null||x===32||x===40||ni(x)?t(x):(n.consume(x),x===92?k:m)}function k(x){return x===40||x===41||x===92?(n.consume(x),m):m(x)}}function To(n,e,t,r,i,o){let s=this,l=0,a;return c;function c(h){return n.enter(r),n.enter(i),n.consume(h),n.exit(i),n.enter(o),u}function u(h){return l>999||h===null||h===91||h===93&&!a||h===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?t(h):h===93?(n.exit(o),n.enter(i),n.consume(h),n.exit(i),n.exit(r),e):E(h)?(n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),u):(n.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||E(h)||l++>999?(n.exit("chunkString"),u(h)):(n.consume(h),a||(a=!z(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(n.consume(h),l++,f):f(h)}}function Oo(n,e,t,r,i,o){let s;return l;function l(d){return d===34||d===39||d===40?(n.enter(r),n.enter(i),n.consume(d),n.exit(i),s=d===40?41:d,a):t(d)}function a(d){return d===s?(n.enter(i),n.consume(d),n.exit(i),n.exit(r),e):(n.enter(o),c(d))}function c(d){return d===s?(n.exit(o),a(s)):d===null?t(d):E(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),V(n,c,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===s||d===null||E(d)?(n.exit("chunkString"),c(d)):(n.consume(d),d===92?f:u)}function f(d){return d===s||d===92?(n.consume(d),u):u(d)}}function mn(n,e){let t;return r;function r(i){return E(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):z(i)?V(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}var zl={name:"definition",tokenize:mx},px={partial:!0,tokenize:gx};function mx(n,e,t){let r=this,i;return o;function o(h){return n.enter("definition"),s(h)}function s(h){return To.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=bt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(n.enter("definitionMarker"),n.consume(h),n.exit("definitionMarker"),a):t(h)}function a(h){return ie(h)?mn(n,c)(h):c(h)}function c(h){return Io(n,u,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return n.attempt(px,f,f)(h)}function f(h){return z(h)?V(n,d,"whitespace")(h):d(h)}function d(h){return h===null||E(h)?(n.exit("definition"),r.parser.defined.push(i),e(h)):t(h)}}function gx(n,e,t){return r;function r(l){return ie(l)?mn(n,i)(l):t(l)}function i(l){return Oo(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return z(l)?V(n,s,"whitespace")(l):s(l)}function s(l){return l===null||E(l)?e(l):t(l)}}var Fl={name:"hardBreakEscape",tokenize:yx};function yx(n,e,t){return r;function r(o){return n.enter("hardBreakEscape"),n.consume(o),i}function i(o){return E(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}var _l={name:"headingAtx",resolve:xx,tokenize:kx};function xx(n,e){let t=n.length-2,r=3,i,o;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},o={type:"chunkText",start:n[r][1].start,end:n[t][1].end,contentType:"text"},de(n,r,t-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),n}function kx(n,e,t){let r=0;return i;function i(u){return n.enter("atxHeading"),o(u)}function o(u){return n.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&r++<6?(n.consume(u),s):u===null||ie(u)?(n.exit("atxHeadingSequence"),l(u)):t(u)}function l(u){return u===35?(n.enter("atxHeadingSequence"),a(u)):u===null||E(u)?(n.exit("atxHeading"),e(u)):z(u)?V(n,l,"whitespace")(u):(n.enter("atxHeadingText"),c(u))}function a(u){return u===35?(n.consume(u),a):(n.exit("atxHeadingSequence"),l(u))}function c(u){return u===null||u===35||ie(u)?(n.exit("atxHeadingText"),l(u)):(n.consume(u),c)}}var Qf=["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"],Vl=["pre","script","style","textarea"];var $l={concrete:!0,name:"htmlFlow",resolveTo:Sx,tokenize:Cx},bx={partial:!0,tokenize:Nx},wx={partial:!0,tokenize:Mx};function Sx(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 Cx(n,e,t){let r=this,i,o,s,l,a;return c;function c(y){return u(y)}function u(y){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(y),f}function f(y){return y===33?(n.consume(y),d):y===47?(n.consume(y),o=!0,m):y===63?(n.consume(y),i=3,r.interrupt?e:g):_e(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function d(y){return y===45?(n.consume(y),i=2,h):y===91?(n.consume(y),i=5,l=0,p):_e(y)?(n.consume(y),i=4,r.interrupt?e:g):t(y)}function h(y){return y===45?(n.consume(y),r.interrupt?e:g):t(y)}function p(y){let Le="CDATA[";return y===Le.charCodeAt(l++)?(n.consume(y),l===Le.length?r.interrupt?e:Y:p):t(y)}function m(y){return _e(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function k(y){if(y===null||y===47||y===62||ie(y)){let Le=y===47,Qt=s.toLowerCase();return!Le&&!o&&Vl.includes(Qt)?(i=1,r.interrupt?e(y):Y(y)):Qf.includes(s.toLowerCase())?(i=6,Le?(n.consume(y),x):r.interrupt?e(y):Y(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(y):o?I(y):C(y))}return y===45||Me(y)?(n.consume(y),s+=String.fromCharCode(y),k):t(y)}function x(y){return y===62?(n.consume(y),r.interrupt?e:Y):t(y)}function I(y){return z(y)?(n.consume(y),I):U(y)}function C(y){return y===47?(n.consume(y),U):y===58||y===95||_e(y)?(n.consume(y),A):z(y)?(n.consume(y),C):U(y)}function A(y){return y===45||y===46||y===58||y===95||Me(y)?(n.consume(y),A):v(y)}function v(y){return y===61?(n.consume(y),b):z(y)?(n.consume(y),v):C(y)}function b(y){return y===null||y===60||y===61||y===62||y===96?t(y):y===34||y===39?(n.consume(y),a=y,T):z(y)?(n.consume(y),b):P(y)}function T(y){return y===a?(n.consume(y),a=null,D):y===null||E(y)?t(y):(n.consume(y),T)}function P(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||ie(y)?v(y):(n.consume(y),P)}function D(y){return y===47||y===62||z(y)?C(y):t(y)}function U(y){return y===62?(n.consume(y),Se):t(y)}function Se(y){return y===null||E(y)?Y(y):z(y)?(n.consume(y),Se):t(y)}function Y(y){return y===45&&i===2?(n.consume(y),Q):y===60&&i===1?(n.consume(y),X):y===62&&i===4?(n.consume(y),je):y===63&&i===3?(n.consume(y),g):y===93&&i===5?(n.consume(y),le):E(y)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(bx,pt,R)(y)):y===null||E(y)?(n.exit("htmlFlowData"),R(y)):(n.consume(y),Y)}function R(y){return n.check(wx,L,pt)(y)}function L(y){return n.enter("lineEnding"),n.consume(y),n.exit("lineEnding"),F}function F(y){return y===null||E(y)?R(y):(n.enter("htmlFlowData"),Y(y))}function Q(y){return y===45?(n.consume(y),g):Y(y)}function X(y){return y===47?(n.consume(y),s="",te):Y(y)}function te(y){if(y===62){let Le=s.toLowerCase();return Vl.includes(Le)?(n.consume(y),je):Y(y)}return _e(y)&&s.length<8?(n.consume(y),s+=String.fromCharCode(y),te):Y(y)}function le(y){return y===93?(n.consume(y),g):Y(y)}function g(y){return y===62?(n.consume(y),je):y===45&&i===2?(n.consume(y),g):Y(y)}function je(y){return y===null||E(y)?(n.exit("htmlFlowData"),pt(y)):(n.consume(y),je)}function pt(y){return n.exit("htmlFlow"),e(y)}}function Mx(n,e,t){let r=this;return i;function i(s){return E(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o):t(s)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}function Nx(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(zt,e,t)}}var Wl={name:"htmlText",tokenize:Ix};function Ix(n,e,t){let r=this,i,o,s;return l;function l(g){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(g),a}function a(g){return g===33?(n.consume(g),c):g===47?(n.consume(g),v):g===63?(n.consume(g),C):_e(g)?(n.consume(g),P):t(g)}function c(g){return g===45?(n.consume(g),u):g===91?(n.consume(g),o=0,p):_e(g)?(n.consume(g),I):t(g)}function u(g){return g===45?(n.consume(g),h):t(g)}function f(g){return g===null?t(g):g===45?(n.consume(g),d):E(g)?(s=f,X(g)):(n.consume(g),f)}function d(g){return g===45?(n.consume(g),h):f(g)}function h(g){return g===62?Q(g):g===45?d(g):f(g)}function p(g){let je="CDATA[";return g===je.charCodeAt(o++)?(n.consume(g),o===je.length?m:p):t(g)}function m(g){return g===null?t(g):g===93?(n.consume(g),k):E(g)?(s=m,X(g)):(n.consume(g),m)}function k(g){return g===93?(n.consume(g),x):m(g)}function x(g){return g===62?Q(g):g===93?(n.consume(g),x):m(g)}function I(g){return g===null||g===62?Q(g):E(g)?(s=I,X(g)):(n.consume(g),I)}function C(g){return g===null?t(g):g===63?(n.consume(g),A):E(g)?(s=C,X(g)):(n.consume(g),C)}function A(g){return g===62?Q(g):C(g)}function v(g){return _e(g)?(n.consume(g),b):t(g)}function b(g){return g===45||Me(g)?(n.consume(g),b):T(g)}function T(g){return E(g)?(s=T,X(g)):z(g)?(n.consume(g),T):Q(g)}function P(g){return g===45||Me(g)?(n.consume(g),P):g===47||g===62||ie(g)?D(g):t(g)}function D(g){return g===47?(n.consume(g),Q):g===58||g===95||_e(g)?(n.consume(g),U):E(g)?(s=D,X(g)):z(g)?(n.consume(g),D):Q(g)}function U(g){return g===45||g===46||g===58||g===95||Me(g)?(n.consume(g),U):Se(g)}function Se(g){return g===61?(n.consume(g),Y):E(g)?(s=Se,X(g)):z(g)?(n.consume(g),Se):D(g)}function Y(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),i=g,R):E(g)?(s=Y,X(g)):z(g)?(n.consume(g),Y):(n.consume(g),L)}function R(g){return g===i?(n.consume(g),i=void 0,F):g===null?t(g):E(g)?(s=R,X(g)):(n.consume(g),R)}function L(g){return g===null||g===34||g===39||g===60||g===61||g===96?t(g):g===47||g===62||ie(g)?D(g):(n.consume(g),L)}function F(g){return g===47||g===62||ie(g)?D(g):t(g)}function Q(g){return g===62?(n.consume(g),n.exit("htmlTextData"),n.exit("htmlText"),e):t(g)}function X(g){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),te}function te(g){return z(g)?V(n,le,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(g):le(g)}function le(g){return n.enter("htmlTextData"),s(g)}}var gn={name:"labelEnd",resolveAll:Ax,resolveTo:Rx,tokenize:vx},Tx={tokenize:Dx},Ox={tokenize:Px},Ex={tokenize:Lx};function Ax(n){let e=-1,t=[];for(;++e<n.length;){let r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&de(n,0,n.length,t),n}function Rx(n,e){let t=n.length,r=0,i,o,s,l;for(;t--;)if(i=n[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;n[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(n[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=t);let a={type:n[o][1].type==="labelLink"?"link":"image",start:{...n[o][1].start},end:{...n[n.length-1][1].end}},c={type:"label",start:{...n[o][1].start},end:{...n[s][1].end}},u={type:"labelText",start:{...n[o+r+2][1].end},end:{...n[s-2][1].start}};return l=[["enter",a,e],["enter",c,e]],l=Ce(l,n.slice(o+1,o+r+3)),l=Ce(l,[["enter",u,e]]),l=Ce(l,rr(e.parser.constructs.insideSpan.null,n.slice(o+r+4,s-3),e)),l=Ce(l,[["exit",u,e],n[s-2],n[s-1],["exit",c,e]]),l=Ce(l,n.slice(s+1)),l=Ce(l,[["exit",a,e]]),de(n,o,n.length,l),n}function vx(n,e,t){let r=this,i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?f(d):(s=r.parser.defined.includes(bt(r.sliceSerialize({start:o.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(Tx,u,s?u:f)(d):d===91?n.attempt(Ox,u,s?c:f)(d):s?u(d):f(d)}function c(d){return n.attempt(Ex,u,f)(d)}function u(d){return e(d)}function f(d){return o._balanced=!0,t(d)}}function Dx(n,e,t){return r;function r(f){return n.enter("resource"),n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),i}function i(f){return ie(f)?mn(n,o)(f):o(f)}function o(f){return f===41?u(f):Io(n,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return ie(f)?mn(n,a)(f):u(f)}function l(f){return t(f)}function a(f){return f===34||f===39||f===40?Oo(n,c,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return ie(f)?mn(n,u)(f):u(f)}function u(f){return f===41?(n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),n.exit("resource"),e):t(f)}}function Px(n,e,t){let r=this;return i;function i(l){return To.call(r,n,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(bt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function s(l){return t(l)}}function Lx(n,e,t){return r;function r(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),i}function i(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}var jl={name:"labelStartImage",resolveAll:gn.resolveAll,tokenize:Bx};function Bx(n,e,t){let r=this;return i;function i(l){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(l),n.exit("labelImageMarker"),o}function o(l){return l===91?(n.enter("labelMarker"),n.consume(l),n.exit("labelMarker"),n.exit("labelImage"),s):t(l)}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(l):e(l)}}var Hl={name:"labelStartLink",resolveAll:gn.resolveAll,tokenize:zx};function zx(n,e,t){let r=this;return i;function i(s){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(s),n.exit("labelMarker"),n.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(s):e(s)}}var li={name:"lineEnding",tokenize:Fx};function Fx(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),V(n,e,"linePrefix")}}var yn={name:"thematicBreak",tokenize:_x};function _x(n,e,t){let r=0,i;return o;function o(c){return n.enter("thematicBreak"),s(c)}function s(c){return i=c,l(c)}function l(c){return c===i?(n.enter("thematicBreakSequence"),a(c)):r>=3&&(c===null||E(c))?(n.exit("thematicBreak"),e(c)):t(c)}function a(c){return c===i?(n.consume(c),r++,a):(n.exit("thematicBreakSequence"),z(c)?V(n,l,"whitespace")(c):l(c))}}var ke={continuation:{tokenize:jx},exit:qx,name:"list",tokenize:Wx},Vx={partial:!0,tokenize:Kx},$x={partial:!0,tokenize:Hx};function Wx(n,e,t){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(h){let p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:ri(h)){if(r.containerState.type||(r.containerState.type=p,n.enter(p,{_container:!0})),p==="listUnordered")return n.enter("listItemPrefix"),h===42||h===45?n.check(yn,t,c)(h):c(h);if(!r.interrupt||h===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),a(h)}return t(h)}function a(h){return ri(h)&&++s<10?(n.consume(h),a):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(n.exit("listItemValue"),c(h)):t(h)}function c(h){return n.enter("listItemMarker"),n.consume(h),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,n.check(zt,r.interrupt?t:u,n.attempt(Vx,d,f))}function u(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return z(h)?(n.enter("listItemPrefixWhitespace"),n.consume(h),n.exit("listItemPrefixWhitespace"),d):t(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(h)}}function jx(n,e,t){let r=this;return r.containerState._closeFlow=void 0,n.check(zt,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,V(n,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!z(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt($x,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,V(n,n.attempt(ke,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Hx(n,e,t){let r=this;return V(n,i,"listItemIndent",r.containerState.size+1);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):t(o)}}function qx(n){n.exit(this.containerState.type)}function Kx(n,e,t){let r=this;return V(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let s=r.events[r.events.length-1];return!z(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}var Eo={name:"setextUnderline",resolveTo:Ux,tokenize:Jx};function Ux(n,e){let t=n.length,r,i,o;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),!o&&n[t][1].type==="definition"&&(o=t);let s={type:"setextHeading",start:{...n[r][1].start},end:{...n[n.length-1][1].end}};return n[i][1].type="setextHeadingText",o?(n.splice(i,0,["enter",s,e]),n.splice(o+1,0,["exit",n[r][1],e]),n[r][1].end={...n[o][1].end}):n[r][1]=s,n.push(["exit",s,e]),n}function Jx(n,e,t){let r=this,i;return o;function o(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(n.enter("setextHeadingLine"),i=c,s(c)):t(c)}function s(c){return n.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(n.consume(c),l):(n.exit("setextHeadingLineSequence"),z(c)?V(n,a,"lineSuffix")(c):a(c))}function a(c){return c===null||E(c)?(n.exit("setextHeadingLine"),e(c)):t(c)}}var Xf={tokenize:Gx};function Gx(n){let e=this,t=n.attempt(zt,r,n.attempt(this.parser.constructs.flowInitial,i,V(n,n.attempt(this.parser.constructs.flow,i,n.attempt(Bl,i)),"linePrefix")));return t;function r(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}var Zf={resolveAll:rh()},eh=nh("string"),th=nh("text");function nh(n){return{resolveAll:rh(n==="text"?Yx:void 0),tokenize:e};function e(t){let r=this,i=this.parser.constructs[n],o=t.attempt(i,s,l);return s;function s(u){return c(u)?o(u):l(u)}function l(u){if(u===null){t.consume(u);return}return t.enter("data"),t.consume(u),a}function a(u){return c(u)?(t.exit("data"),o(u)):(t.consume(u),a)}function c(u){if(u===null)return!0;let f=i[u],d=-1;if(f)for(;++d<f.length;){let h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function rh(n){return e;function e(t,r){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return n?n(t,r):t}}function Yx(n,e){let t=0;for(;++t<=n.length;)if((t===n.length||n[t][1].type==="lineEnding")&&n[t-1][1].type==="data"){let r=n[t-1][1],i=e.sliceStream(r),o=i.length,s=-1,l=0,a;for(;o--;){let c=i[o];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)l++,s--;if(s)break;s=-1}else if(c===-2)a=!0,l++;else if(c!==-1){o++;break}}if(e._contentTypeTextTrailing&&t===n.length&&(l=0),l){let c={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(n.splice(t,0,["enter",c,e],["exit",c,e]),t+=2)}t++}return n}var ql={};Og(ql,{attentionMarkers:()=>ik,contentInitial:()=>Xx,disable:()=>ok,document:()=>Qx,flow:()=>ek,flowInitial:()=>Zx,insideSpan:()=>rk,string:()=>tk,text:()=>nk});var Qx={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:bo},Xx={91:zl},Zx={[-2]:oi,[-1]:oi,32:oi},ek={35:_l,42:yn,45:[Eo,yn],60:$l,61:Eo,95:yn,96:Co,126:Co},tk={38:So,92:wo},nk={[-5]:li,[-4]:li,[-3]:li,33:jl,38:So,42:ii,60:[Pl,Wl],91:Hl,92:[Fl,wo],93:gn,95:ii,96:Ll},rk={null:[ii,Zf]},ik={null:[42,95]},ok={null:[]};function ih(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0},i={},o=[],s=[],l=[],a=!0,c={attempt:D(T),check:D(P),consume:A,enter:v,exit:b,interrupt:D(P,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:k,parser:n,previous:null,sliceSerialize:p,sliceStream:m,write:h},f=e.tokenize.call(u,c),d;return e.resolveAll&&o.push(e),u;function h(R){return s=Ce(s,R),I(),s[s.length-1]!==null?[]:(U(e,0),u.events=rr(o,u.events,u),u.events)}function p(R,L){return lk(m(R),L)}function m(R){return sk(s,R)}function k(){let{_bufferIndex:R,_index:L,line:F,column:Q,offset:X}=r;return{_bufferIndex:R,_index:L,line:F,column:Q,offset:X}}function x(R){i[R.line]=R.column,Y()}function I(){let R;for(;r._index<s.length;){let L=s[r._index];if(typeof L=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<L.length;)C(L.charCodeAt(r._bufferIndex));else C(L)}}function C(R){a=void 0,d=R,f=f(R)}function A(R){E(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,Y()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R,a=!0}function v(R,L){let F=L||{};return F.type=R,F.start=k(),u.events.push(["enter",F,u]),l.push(F),F}function b(R){let L=l.pop();return L.end=k(),u.events.push(["exit",L,u]),L}function T(R,L){U(R,L.from)}function P(R,L){L.restore()}function D(R,L){return F;function F(Q,X,te){let le,g,je,pt;return Array.isArray(Q)?Le(Q):"tokenize"in Q?Le([Q]):y(Q);function y(ue){return Vr;function Vr(mt){let Xt=mt!==null&&ue[mt],Hn=mt!==null&&ue.null,tl=[...Array.isArray(Xt)?Xt:Xt?[Xt]:[],...Array.isArray(Hn)?Hn:Hn?[Hn]:[]];return Le(tl)(mt)}}function Le(ue){return le=ue,g=0,ue.length===0?te:Qt(ue[g])}function Qt(ue){return Vr;function Vr(mt){return pt=Se(),je=ue,ue.partial||(u.currentConstruct=ue),ue.name&&u.parser.constructs.disable.null.includes(ue.name)?Gi(mt):ue.tokenize.call(L?Object.assign(Object.create(u),L):u,c,el,Gi)(mt)}}function el(ue){return a=!0,R(je,pt),X}function Gi(ue){return a=!0,pt.restore(),++g<le.length?Qt(le[g]):te}}}function U(R,L){R.resolveAll&&!o.includes(R)&&o.push(R),R.resolve&&de(u.events,L,u.events.length-L,R.resolve(u.events.slice(L),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function Se(){let R=k(),L=u.previous,F=u.currentConstruct,Q=u.events.length,X=Array.from(l);return{from:Q,restore:te};function te(){r=R,u.previous=L,u.currentConstruct=F,u.events.length=Q,l=X,Y()}}function Y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sk(n,e){let t=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex,s;if(t===i)s=[n[t].slice(r,o)];else{if(s=n.slice(t,i),r>-1){let l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(n[i].slice(0,o))}return s}function lk(n,e){let t=-1,r=[],i;for(;++t<n.length;){let o=n[t],s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=` 5 + `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):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 o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.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,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=q.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Vu(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Fu(e,o,s.options);s.options&qr&&s.content.length==0&&(l|=qr);let a=q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Vu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Un(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Jr)}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),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(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 Jg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&of.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Gg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function _u(n){let e={};for(let t in n)e[t]=n[t];return e}function Vu(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}var sn=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=hl(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=to(hl(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 o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&to(hl(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return to(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=$u(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return $u(e.marks)}};function $u(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function hl(n){return n.document||window.document}var Wu=new WeakMap;function Yg(n){let e=Wu.get(n);return e===void 0&&Wu.set(n,e=Qg(n)),e}function Qg(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 to(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],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Yg(r))&&o.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 s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=to(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var af=65535,cf=Math.pow(2,16);function Xg(n,e){return n+e*cf}function sf(n){return n&af}function Zg(n){return(n-(n&af))/cf}var uf=1,ff=2,ao=4,hf=8,Qr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&hf)>0}get deletedBefore(){return(this.delInfo&(uf|ao))>0}get deletedAfter(){return(this.delInfo&(ff|ao))>0}get deletedAcross(){return(this.delInfo&ao)>0}},xt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=sf(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+Zg(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,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:Xg(l/3,e-a),m=e==a?ff:e==f?uf:ao;return(t<0?e!=a:e!=f)&&(m|=hf),new Qr(h,m,p)}i+=u-c}return r?e+i:new Qr(e+i,0,null)}touches(e,t){let r=0,i=sf(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};xt.empty=new xt([]);var Xr=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),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 n;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 o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Qr(e,i,null)}},kl=Object.create(null),ae=class{getMap(){return xt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=kl[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 kl)throw new RangeError("Duplicate use of step JSON ID "+e);return kl[e]=t,t.prototype.jsonID=e,t}},fe=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(o){if(o instanceof nn)return n.fail(o.message);throw o}}};function Ml(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Ml(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return M.fromArray(r)}var ln=class n extends ae{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)),o=new O(Ml(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,o)}invert(){return new an(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 n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("addMark",ln);var an=class n extends ae{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(Ml(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,r)}invert(){return new ln(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 n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("removeMark",an);var Zr=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.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 n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Jn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("addNodeMark",Zr);var Jn=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Zr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("removeNodeMark",Jn);var xe=class n extends ae{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Sl(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(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 n(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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 n(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 n(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 n(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}};ae.jsonID("replace",xe);var he=class n extends ae{constructor(e,t,r,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Sl(e,this.from,this.gapFrom)||Sl(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.fail("Content does not fit in gap")}getMap(){return new xt([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 n(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),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 n(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}};ae.jsonID("replaceAround",he);function Sl(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function ey(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(s&&s.to==d&&s.mark.eq(f[m])?s.to=h:i.push(s=new an(d,h,f[m])));l&&l.to==d?l.to=h:o.push(l=new ln(d,h,r))}}),i.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function ty(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Ur){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>n.step(new an(s.from,s.to,s.style)))}function Nl(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new xe(l,u,O.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new an(l,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new O(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new xe(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(M.empty,!0);n.replace(l,l,new O(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function ny(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Yn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!ny(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function ry(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=M.empty,f=0;for(let p=o,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=M.from(r.node(p).copy(u)),f++):a--;let d=M.empty,h=0;for(let p=o,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=M.from(i.node(p).copy(d)),h++):c++;n.step(new he(a,c,s,l,new O(u.append(d),f,h),u.size-f,!0))}function cn(n,e,t=null,r=n){let i=iy(n,e),o=i&&oy(r,e);return o?i.map(lf).concat({type:e,attrs:t}).concat(o.map(lf)):null}function lf(n){return{type:n,attrs:null}}function iy(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function oy(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function sy(n,e,t){let r=M.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new he(i,o,i,o,new O(r,0,0),t.length,!0))}function ly(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&ay(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&pf(n,s,l,o),Nl(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return n.step(new he(f,d,f+1,d-1,new O(M.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&df(n,s,l,o),!1}})}function df(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function pf(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` 6 + `))}})}function ay(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function cy(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new he(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new O(M.from(s),0,0),1,!0))}function un(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function uy(n,e,t=1,r){let i=n.doc.resolve(e),o=M.empty,s=M.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=M.from(i.node(l).copy(o));let u=r&&r[c];s=M.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new xe(e,e,new O(o.append(s),t,t),!0))}function fn(n,e){let t=n.resolve(e),r=t.index();return hy(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function fy(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function hy(n,e){return!!(n&&e&&!n.isLeaf&&fy(n,e))}function dy(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);pf(n,u.node(),u.before(),l)}s.inlineContent&&Nl(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new xe(c,a.map(e+t,-1),O.empty,!0)),r===!0){let u=n.doc.resolve(c);df(n,u.node(),u.before(),n.steps.length)}return n}function py(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 o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function mf(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ei(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return gf(i,o,r)?new xe(e,t,r):new Cl(i,o,r).fit()}function gf(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Cl=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=M.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=M.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),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 o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new O(o,s,l);return e>-1?new he(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new xe(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 o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=bl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(s?c.matchType(s.type)||(f=c.fillBefore(M.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=bl(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=bl(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new O(Gr(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new O(Gr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),k=f.matchType(m.type);if(!k)break;c++,(c>1||a==0||m.content.size)&&(f=k,u.push(yf(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Yr(this.placed,t,M.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m<h;m++){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(Gr(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new O(Gr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wl(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],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=wl(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=wl(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?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=Yr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Yr(this.placed,this.depth,M.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(M.empty,!0);t.childCount&&(this.placed=Yr(this.placed,this.frontier.length,t))}};function Gr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Gr(n.firstChild.content,e-1,t)))}function Yr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Yr(n.lastChild.content,e-1,t)))}function bl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function yf(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,yf(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(M.empty,!0)))),n.copy(r)}function wl(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!my(t,o.content,s)?l:null}function my(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function gy(n){return n.spec.defining||n.spec.definingForContent}function yy(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(gf(i,o,r))return n.step(new xe(e,t,r));let s=kf(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=gy(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let k=s[(m+a)%s.length],x=!0;k<0&&(x=!1,k=-k);let I=i.node(k-1),C=i.index(k-1);if(I.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(k),x?o.after(k):t,new O(xf(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=s.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),t=o.after(h))}}function xf(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(xf(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(M.empty,!0))}return n}function xy(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=py(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new O(M.from(r),0,0))}function ky(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=kf(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return 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 s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function kf(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<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;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var co=class n extends ae{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 fe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(i),0,t.isLeaf?0:1))}getMap(){return xt.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};ae.jsonID("attr",co);var uo=class n extends ae{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 fe.ok(r)}getMap(){return xt.empty}invert(e){return new n(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 n(t.attr,t.value)}};ae.jsonID("docAttr",uo);var Gn=class extends Error{};Gn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Gn.prototype=Object.create(Error.prototype);Gn.prototype.constructor=Gn;Gn.prototype.name="TransformError";var fo=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Gn(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}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}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=ei(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new O(M.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 yy(this,e,t,r),this}replaceRangeWith(e,t,r){return xy(this,e,t,r),this}deleteRange(e,t){return ky(this,e,t),this}lift(e,t){return ry(this,e,t),this}join(e,t=1){return dy(this,e,t),this}wrap(e,t){return sy(this,e,t),this}setBlockType(e,t=e,r,i=null){return ly(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return cy(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new co(e,t,r)),this}setDocAttribute(e,t){return this.step(new uo(e,t)),this}addNodeMark(e,t){return this.step(new Zr(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof q)t.isInSet(r.marks)&&this.step(new Jn(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Jn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return uy(this,e,t,r),this}addMark(e,t,r){return ey(this,e,t,r),this}removeMark(e,t,r){return ty(this,e,t,r),this}clearIncompatible(e,t,r){return Nl(this,e,t,r),this}};var Il=Object.create(null),W=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Xn(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 o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?O.empty:t),l==0&&Sf(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Sf(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new j(e):Qn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Qn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Qn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Fe(e.node(0))}static atStart(e){return Qn(e,e,0,0,1)||new Fe(e)}static atEnd(e){return Qn(e,e,e.content.size,e.childCount,-1)||new Fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Il[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 Il)throw new RangeError("Duplicate use of selection JSON ID "+e);return Il[e]=t,t.prototype.jsonID=e,t}getBookmark(){return j.between(this.$anchor,this.$head).getBookmark()}};W.prototype.visible=!0;var Xn=class{constructor(e,t){this.$from=e,this.$to=t}},bf=!1;function wf(n){!bf&&!n.parent.inlineContent&&(bf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var j=class n extends W{constructor(e,t=e){wf(e),wf(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 W.near(r);let i=e.resolve(t.map(this.anchor));return new n(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 n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new po(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 n(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 o=W.findFrom(t,r,!0)||W.findFrom(t,-r,!0);if(o)t=o.$head;else return W.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};W.jsonID("text",j);var po=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return j.between(e.resolve(this.anchor),e.resolve(this.head))}},B=class n extends W{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),o=e.resolve(i);return r?W.near(o):new n(o)}content(){return new O(M.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ol(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};B.prototype.visible=!1;W.jsonID("node",B);var Ol=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new po(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&B.isSelectable(r)?new B(t):W.near(t)}},Fe=class n extends W{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=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return by}};W.jsonID("all",Fe);var by={map(){return this},resolve(n){return new Fe(n)}};function Qn(n,e,t,r,i,o=!1){if(e.inlineContent)return j.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let a=Qn(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Sf(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof xe||i instanceof he))return;let o=n.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(W.near(n.doc.resolve(s),t))}var Cf=1,ho=2,Mf=4,El=class extends fo{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|Cf)&~ho,this.storedMarks=null,this}get selectionSet(){return(this.updated&Cf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ho,this}ensureMarks(e){return q.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&ho)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ho,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)||q.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),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.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|=Mf,this}get scrolledIntoView(){return(this.updated&Mf)>0}};function Nf(n,e){return!e||!n?n:n.bind(e)}var hn=class{constructor(e,t,r){this.name=e,this.init=Nf(t.init,r),this.apply=Nf(t.apply,r)}},wy=[new hn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new hn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new hn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new hn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],ti=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=wy.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 hn(r.key,r.spec.state,r))})}},mo=class n{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 o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new El(this)}static create(e){let t=new ti(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(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 ti(this.schema,e.plugins),r=t.fields,i=new n(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let 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],o=i.spec.state;o&&o.toJSON&&(t[r]=o.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 ti(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Ae.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=W.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function If(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=If(i,e,{})),t[r]=i}return t}var ne=class{constructor(e){this.spec=e,this.props={},e.props&&If(e.props,this,this.props),this.key=e.key?e.key.key:Tf("plugin")}getState(e){return e[this.key]}},Tl=Object.create(null);function Tf(n){return n in Tl?n+"$"+ ++Tl[n]:(Tl[n]=0,n+"$")}var re=class{constructor(e="key"){this.key=Tf(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var go=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ef(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Rl=(n,e,t)=>{let r=Ef(n,t);if(!r)return!1;let i=Dl(r);if(!i){let s=r.blockRange(),l=s&&Yn(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(vf(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Zn(o,"end")||B.isSelectable(o)))for(let s=r.depth;;s--){let l=ei(n.doc,r.before(s),r.after(s),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Zn(o,"end")?W.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):B.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Af=(n,e,t)=>{let r=Ef(n,t);if(!r)return!1;let i=Dl(r);return i?Sy(n,i,e):!1};function Sy(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=ei(n.doc,o,a,O.empty);if(!c||c.from!=o||c instanceof xe&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(j.create(u.doc,o)),t(u.scrollIntoView())}return!0}function Zn(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}var vl=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=Dl(r)}let s=o&&o.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Dl(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 Cy(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var My=(n,e,t)=>{let r=Cy(n,t);if(!r)return!1;let i=Rf(r);if(!i)return!1;let o=i.nodeAfter;if(vf(n,i,e,1))return!0;if(r.parent.content.size==0&&(Zn(o,"start")||B.isSelectable(o))){let s=ei(n.doc,r.before(),r.after(),O.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Zn(o,"start")?W.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):B.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Ny=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=Rf(r)}let s=o&&o.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos)).scrollIntoView()),!0)};function Rf(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}var Iy=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` 7 + `).scrollIntoView()),!0)};function Pl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Ty=(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),o=t.indexAfter(-1),s=Pl(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(W.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Oy=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Fe||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Pl(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(s,o.createAndFill());l.setSelection(j.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ey=(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 o=t.before();if(un(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Yn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Ay(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!un(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Pl(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=n&&n(i.parent,a,r);o.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof j||e.selection instanceof Fe)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=un(u.doc,f,o.length,o);if(d||(o[0]=l?{type:l}:null,d=un(u.doc,f,o.length,o)),!d)return!1;if(u.split(f,o.length,o),!a&&c&&r.node(s).type!=l){let h=u.mapping.map(r.before(s)),p=u.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return t&&t(u.scrollIntoView()),!0}}var Ry=Ay();var vy=(n,e)=>(e&&e(n.tr.setSelection(new Fe(n.doc))),!0);function Dy(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||fn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function vf(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Dy(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=M.empty;for(let x=s.length-1;x>=0;x--)p=M.from(s[x].create(null,p));p=M.from(i.copy(p));let m=n.tr.step(new he(e.pos-1,h,e.pos,h,new O(p,1,0),s.length,!0)),k=m.doc.resolve(h+2*s.length);k.nodeAfter&&k.nodeAfter.type==i.type&&fn(m.doc,k.pos)&&m.join(k.pos),t(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:W.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&Yn(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&Zn(o,"start",!0)&&Zn(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=o,k=1;for(;!m.isTextblock;m=m.firstChild)k++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let x=M.empty;for(let C=p.length-1;C>=0;C--)x=M.from(p[C].copy(x));let I=n.tr.step(new he(e.pos-p.length,e.pos+o.nodeSize,e.pos+k,e.pos+o.nodeSize-k,new O(x,p.length,0),0,!0));t(I.scrollIntoView())}return!0}}return!1}function Df(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(j.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Py=Df(-1),Ly=Df(1);function yo(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&cn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function er(n,e=null){return function(t,r){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function By(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(o.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=o.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function zy(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:i}=n[t];r.doc.nodesBetween(r.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=r.pos&&s+o.nodeSize<=i.pos)return s+1>r.pos&&e.push(new Xn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+o.content.size),!1}),r.pos<i.pos&&e.push(new Xn(r,i))}return e}function xo(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,o=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!By(s.doc,u,n,i))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let f,d=s.tr;i||(u=zy(u)),r?f=!u.some(h=>s.doc.rangeHasMark(h.$from.pos,h.$to.pos,n)):f=!u.every(h=>{let p=!1;return d.doc.nodesBetween(h.$from.pos,h.$to.pos,(m,k,x)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!x&&x.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,h.$from.pos-k),Math.min(m.nodeSize,h.$to.pos-k))))}),!p});for(let h=0;h<u.length;h++){let{$from:p,$to:m}=u[h];if(!f)d.removeMark(p.pos,m.pos,n);else{let k=p.pos,x=m.pos,I=p.nodeAfter,C=m.nodeBefore,A=o&&I&&I.isText?/^\s*/.exec(I.text)[0].length:0,v=o&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;k+A<x&&(k+=A,x-=v),d.addMark(k,x,n.create(e))}}l(d.scrollIntoView())}return!0}}function dn(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var Al=dn(go,Rl,vl),Of=dn(go,My,Ny),kt={Enter:dn(Iy,Oy,Ey,Ry),"Mod-Enter":Ty,Backspace:Al,"Mod-Backspace":Al,"Shift-Backspace":Al,Delete:Of,"Mod-Delete":Of,"Mod-a":vy},Pf={"Ctrl-h":kt.Backspace,"Alt-Backspace":kt["Mod-Backspace"],"Ctrl-d":kt.Delete,"Ctrl-Alt-Backspace":kt["Mod-Delete"],"Alt-Delete":kt["Mod-Delete"],"Alt-d":kt["Mod-Delete"],"Ctrl-a":Py,"Ctrl-e":Ly};for(let n in kt)Pf[n]=kt[n];var Fy=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Lf=Fy?Pf:kt;var _y={};function pn(n,e){let t=e||_y,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return zf(n,r,i)}function zf(n,e,t){if(Vy(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 Bf(n.children,e,t)}return Array.isArray(n)?Bf(n,e,t):""}function Bf(n,e,t){let r=[],i=-1;for(;++i<n.length;)r[i]=zf(n[i],e,t);return r.join("")}function Vy(n){return!!(n&&typeof n=="object")}var Ff=document.createElement("i");function tr(n){let e="&"+n+";";Ff.innerHTML=e;let t=Ff.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function de(n,e,t,r){let i=n.length,o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,r.length<1e4)s=Array.from(r),s.unshift(e,t),n.splice(...s);else for(t&&n.splice(e,t);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),n.splice(...s),o+=1e4,e+=1e4}function Ce(n,e){return n.length>0?(de(n,n.length,0,e),n):e}var _f={}.hasOwnProperty;function Vf(n){let e={},t=-1;for(;++t<n.length;)$y(e,n[t]);return e}function $y(n,e){let t;for(t in e){let i=(_f.call(n,t)?n[t]:void 0)||(n[t]={}),o=e[t],s;if(o)for(s in o){_f.call(i,s)||(i[s]=[]);let l=o[s];Wy(i[s],Array.isArray(l)?l:l?[l]:[])}}}function Wy(n,e){let t=-1,r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);de(n,0,0,r)}function ko(n,e){let 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?"\uFFFD":String.fromCodePoint(t)}function bt(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var _e=Bt(/[A-Za-z]/),Me=Bt(/[\dA-Za-z]/),$f=Bt(/[#-'*+\--9=?A-Z^-~]/);function ni(n){return n!==null&&(n<32||n===127)}var ri=Bt(/\d/),Wf=Bt(/[\dA-Fa-f]/),jf=Bt(/[!-/:-@[-`{-~]/);function E(n){return n!==null&&n<-2}function ie(n){return n!==null&&(n<0||n===32)}function z(n){return n===-2||n===-1||n===32}var Hf=Bt(/\p{P}|\p{S}/u),qf=Bt(/\s/);function Bt(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function V(n,e,t,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return s;function s(a){return z(a)?(n.enter(t),l(a)):e(a)}function l(a){return z(a)&&o++<i?(n.consume(a),l):(n.exit(t),e(a))}}var Kf={tokenize:jy};function jy(n){let e=n.attempt(this.parser.constructs.contentInitial,r,i),t;return e;function r(l){if(l===null){n.consume(l);return}return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),V(n,e,"linePrefix")}function i(l){return n.enter("paragraph"),o(l)}function o(l){let a=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,s(l)}function s(l){if(l===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(l);return}return E(l)?(n.consume(l),n.exit("chunkText"),o):(n.consume(l),s)}}var Jf={tokenize:Hy},Uf={tokenize:qy};function Hy(n){let e=this,t=[],r=0,i,o,s;return l;function l(C){if(r<t.length){let A=t[r];return e.containerState=A[1],n.attempt(A[0].continuation,a,c)(C)}return c(C)}function a(C){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&I();let A=e.events.length,v=A,b;for(;v--;)if(e.events[v][0]==="exit"&&e.events[v][1].type==="chunkFlow"){b=e.events[v][1].end;break}x(r);let T=A;for(;T<e.events.length;)e.events[T][1].end={...b},T++;return de(e.events,v+1,0,e.events.slice(A)),e.events.length=T,c(C)}return l(C)}function c(C){if(r===t.length){if(!i)return d(C);if(i.currentConstruct&&i.currentConstruct.concrete)return p(C);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Uf,u,f)(C)}function u(C){return i&&I(),x(r),d(C)}function f(C){return e.parser.lazy[e.now().line]=r!==t.length,s=e.now().offset,p(C)}function d(C){return e.containerState={},n.attempt(Uf,h,p)(C)}function h(C){return r++,t.push([e.currentConstruct,e.containerState]),d(C)}function p(C){if(C===null){i&&I(),x(0),n.consume(C);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),m(C)}function m(C){if(C===null){k(n.exit("chunkFlow"),!0),x(0),n.consume(C);return}return E(C)?(n.consume(C),k(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(C),m)}function k(C,A){let v=e.sliceStream(C);if(A&&v.push(null),C.previous=o,o&&(o.next=C),o=C,i.defineSkip(C.start),i.write(v),e.parser.lazy[C.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<s&&(!i.events[b][1].end||i.events[b][1].end.offset>s))return;let T=e.events.length,P=T,D,U;for(;P--;)if(e.events[P][0]==="exit"&&e.events[P][1].type==="chunkFlow"){if(D){U=e.events[P][1].end;break}D=!0}for(x(r),b=T;b<e.events.length;)e.events[b][1].end={...U},b++;de(e.events,P+1,0,e.events.slice(T)),e.events.length=b}}function x(C){let A=t.length;for(;A-- >C;){let v=t[A];e.containerState=v[1],v[0].exit.call(e,n)}t.length=C}function I(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function qy(n,e,t){return V(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function nr(n){if(n===null||ie(n)||qf(n))return 1;if(Hf(n))return 2}function rr(n,e,t){let r=[],i=-1;for(;++i<n.length;){let o=n[i].resolveAll;o&&!r.includes(o)&&(e=o(e,t),r.push(o))}return e}var ii={name:"attention",resolveAll:Ky,tokenize:Uy};function Ky(n,e){let t=-1,r,i,o,s,l,a,c,u;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;let f={...n[r][1].end},d={...n[t][1].start};Gf(f,-a),Gf(d,a),s={type:a>1?"strongSequence":"emphasisSequence",start:f,end:{...n[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:d},o={type:a>1?"strongText":"emphasisText",start:{...n[r][1].end},end:{...n[t][1].start}},i={type:a>1?"strong":"emphasis",start:{...s.start},end:{...l.end}},n[r][1].end={...s.start},n[t][1].start={...l.end},c=[],n[r][1].end.offset-n[r][1].start.offset&&(c=Ce(c,[["enter",n[r][1],e],["exit",n[r][1],e]])),c=Ce(c,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),c=Ce(c,rr(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),c=Ce(c,[["exit",o,e],["enter",l,e],["exit",l,e],["exit",i,e]]),n[t][1].end.offset-n[t][1].start.offset?(u=2,c=Ce(c,[["enter",n[t][1],e],["exit",n[t][1],e]])):u=0,de(n,r-1,t-r+3,c),t=r+c.length-u-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function Uy(n,e){let t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nr(r),o;return s;function s(a){return o=a,n.enter("attentionSequence"),l(a)}function l(a){if(a===o)return n.consume(a),l;let c=n.exit("attentionSequence"),u=nr(a),f=!u||u===2&&i||t.includes(a),d=!i||i===2&&u||t.includes(r);return c._open=!!(o===42?f:f&&(i||!d)),c._close=!!(o===42?d:d&&(u||!f)),e(a)}}function Gf(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}var Ll={name:"autolink",tokenize:Jy};function Jy(n,e,t){let r=0;return i;function i(h){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),o}function o(h){return _e(h)?(n.consume(h),s):h===64?t(h):c(h)}function s(h){return h===43||h===45||h===46||Me(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(n.consume(h),r=0,a):(h===43||h===45||h===46||Me(h))&&r++<32?(n.consume(h),l):(r=0,c(h))}function a(h){return h===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):h===null||h===32||h===60||ni(h)?t(h):(n.consume(h),a)}function c(h){return h===64?(n.consume(h),u):$f(h)?(n.consume(h),c):t(h)}function u(h){return Me(h)?f(h):t(h)}function f(h){return h===46?(n.consume(h),r=0,u):h===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):d(h)}function d(h){if((h===45||Me(h))&&r++<63){let p=h===45?d:f;return n.consume(h),p}return t(h)}}var zt={partial:!0,tokenize:Gy};function Gy(n,e,t){return r;function r(o){return z(o)?V(n,i,"linePrefix")(o):i(o)}function i(o){return o===null||E(o)?e(o):t(o)}}var bo={continuation:{tokenize:Qy},exit:Xy,name:"blockQuote",tokenize:Yy};function Yy(n,e,t){let r=this;return i;function i(s){if(s===62){let l=r.containerState;return l.open||(n.enter("blockQuote",{_container:!0}),l.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(s),n.exit("blockQuoteMarker"),o}return t(s)}function o(s){return z(s)?(n.enter("blockQuotePrefixWhitespace"),n.consume(s),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(s))}}function Qy(n,e,t){let r=this;return i;function i(s){return z(s)?V(n,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return n.attempt(bo,e,t)(s)}}function Xy(n){n.exit("blockQuote")}var wo={name:"characterEscape",tokenize:Zy};function Zy(n,e,t){return r;function r(o){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(o),n.exit("escapeMarker"),i}function i(o){return jf(o)?(n.enter("characterEscapeValue"),n.consume(o),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(o)}}var So={name:"characterReference",tokenize:ex};function ex(n,e,t){let r=this,i=0,o,s;return l;function l(f){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),a}function a(f){return f===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(f),n.exit("characterReferenceMarkerNumeric"),c):(n.enter("characterReferenceValue"),o=31,s=Me,u(f))}function c(f){return f===88||f===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(f),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),o=6,s=Wf,u):(n.enter("characterReferenceValue"),o=7,s=ri,u(f))}function u(f){if(f===59&&i){let d=n.exit("characterReferenceValue");return s===Me&&!tr(r.sliceSerialize(d))?t(f):(n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return s(f)&&i++<o?(n.consume(f),u):t(f)}}var Yf={partial:!0,tokenize:nx},Co={concrete:!0,name:"codeFenced",tokenize:tx};function tx(n,e,t){let r=this,i={partial:!0,tokenize:v},o=0,s=0,l;return a;function a(b){return c(b)}function c(b){let T=r.events[r.events.length-1];return o=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=b,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),u(b)}function u(b){return b===l?(s++,n.consume(b),u):s<3?t(b):(n.exit("codeFencedFenceSequence"),z(b)?V(n,f,"whitespace")(b):f(b))}function f(b){return b===null||E(b)?(n.exit("codeFencedFence"),r.interrupt?e(b):n.check(Yf,m,A)(b)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(b))}function d(b){return b===null||E(b)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),f(b)):z(b)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),V(n,h,"whitespace")(b)):b===96&&b===l?t(b):(n.consume(b),d)}function h(b){return b===null||E(b)?f(b):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||E(b)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),f(b)):b===96&&b===l?t(b):(n.consume(b),p)}function m(b){return n.attempt(i,A,k)(b)}function k(b){return n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),x}function x(b){return o>0&&z(b)?V(n,I,"linePrefix",o+1)(b):I(b)}function I(b){return b===null||E(b)?n.check(Yf,m,A)(b):(n.enter("codeFlowValue"),C(b))}function C(b){return b===null||E(b)?(n.exit("codeFlowValue"),I(b)):(n.consume(b),C)}function A(b){return n.exit("codeFenced"),e(b)}function v(b,T,P){let D=0;return U;function U(F){return b.enter("lineEnding"),b.consume(F),b.exit("lineEnding"),Se}function Se(F){return b.enter("codeFencedFence"),z(F)?V(b,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):Y(F)}function Y(F){return F===l?(b.enter("codeFencedFenceSequence"),R(F)):P(F)}function R(F){return F===l?(D++,b.consume(F),R):D>=s?(b.exit("codeFencedFenceSequence"),z(F)?V(b,L,"whitespace")(F):L(F)):P(F)}function L(F){return F===null||E(F)?(b.exit("codeFencedFence"),T(F)):P(F)}}}function nx(n,e,t){let r=this;return i;function i(s){return s===null?t(s):(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}var oi={name:"codeIndented",tokenize:ix},rx={partial:!0,tokenize:ox};function ix(n,e,t){let r=this;return i;function i(c){return n.enter("codeIndented"),V(n,o,"linePrefix",5)(c)}function o(c){let u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?s(c):t(c)}function s(c){return c===null?a(c):E(c)?n.attempt(rx,s,a)(c):(n.enter("codeFlowValue"),l(c))}function l(c){return c===null||E(c)?(n.exit("codeFlowValue"),s(c)):(n.consume(c),l)}function a(c){return n.exit("codeIndented"),e(c)}}function ox(n,e,t){let r=this;return i;function i(s){return r.parser.lazy[r.now().line]?t(s):E(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),i):V(n,o,"linePrefix",5)(s)}function o(s){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):E(s)?i(s):t(s)}}var Bl={name:"codeText",previous:lx,resolve:sx,tokenize:ax};function sx(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 lx(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ax(n,e,t){let r=this,i=0,o,s;return l;function l(d){return n.enter("codeText"),n.enter("codeTextSequence"),a(d)}function a(d){return d===96?(n.consume(d),i++,a):(n.exit("codeTextSequence"),c(d))}function c(d){return d===null?t(d):d===32?(n.enter("space"),n.consume(d),n.exit("space"),c):d===96?(s=n.enter("codeTextSequence"),o=0,f(d)):E(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),c):(n.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||E(d)?(n.exit("codeTextData"),c(d)):(n.consume(d),u)}function f(d){return d===96?(n.consume(d),o++,f):o===i?(n.exit("codeTextSequence"),n.exit("codeText"),e(d)):(s.type="codeTextData",u(d))}}var Mo=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let 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){let i=t||0;this.setCursor(Math.trunc(e));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&si(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),si(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),si(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);si(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);si(this.left,t.reverse())}}};function si(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 No(n){let e={},t=-1,r,i,o,s,l,a,c,u=new Mo(n);for(;++t<u.length;){for(;t in e;)t=e[t];if(r=u.get(t),t&&r[1].type==="chunkFlow"&&u.get(t-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,o=0,o<a.length&&a[o][1].type==="lineEndingBlank"&&(o+=2),o<a.length&&a[o][1].type==="content"))for(;++o<a.length&&a[o][1].type!=="content";)a[o][1].type==="chunkText"&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,cx(u,t)),t=e[t],c=!0);else if(r[1]._container){for(o=t,i=void 0;o--;)if(s=u.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},l=u.slice(i,t),l.unshift(r),u.splice(i,t-i+1,l))}}return de(n,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function cx(n,e){let t=n.get(e)[1],r=n.get(e)[2],i=e-1,o=[],s=t._tokenizer;s||(s=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let l=s.events,a=[],c={},u,f,d=-1,h=t,p=0,m=0,k=[m];for(;h;){for(;n.get(++i)[1]!==h;);o.push(i),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=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&&(m=d+1,k.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):k.pop(),d=k.length;d--;){let x=l.slice(k[d],k[d+1]),I=o.pop();a.push([I,I+x.length-1]),n.splice(I,2,x)}for(a.reverse(),d=-1;++d<a.length;)c[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return c}var zl={resolve:fx,tokenize:hx},ux={partial:!0,tokenize:dx};function fx(n){return No(n),n}function hx(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?o(l):E(l)?n.check(ux,s,o)(l):(n.consume(l),i)}function o(l){return n.exit("chunkContent"),n.exit("content"),e(l)}function s(l){return n.consume(l),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function dx(n,e,t){let r=this;return i;function i(s){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),V(n,o,"linePrefix")}function o(s){if(s===null||E(s))return t(s);let l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):n.interrupt(r.parser.constructs.flow,t,e)(s)}}function Io(n,e,t,r,i,o,s,l,a){let c=a||Number.POSITIVE_INFINITY,u=0;return f;function f(x){return x===60?(n.enter(r),n.enter(i),n.enter(o),n.consume(x),n.exit(o),d):x===null||x===32||x===41||ni(x)?t(x):(n.enter(r),n.enter(s),n.enter(l),n.enter("chunkString",{contentType:"string"}),m(x))}function d(x){return x===62?(n.enter(o),n.consume(x),n.exit(o),n.exit(i),n.exit(r),e):(n.enter(l),n.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(n.exit("chunkString"),n.exit(l),d(x)):x===null||x===60||E(x)?t(x):(n.consume(x),x===92?p:h)}function p(x){return x===60||x===62||x===92?(n.consume(x),h):h(x)}function m(x){return!u&&(x===null||x===41||ie(x))?(n.exit("chunkString"),n.exit(l),n.exit(s),n.exit(r),e(x)):u<c&&x===40?(n.consume(x),u++,m):x===41?(n.consume(x),u--,m):x===null||x===32||x===40||ni(x)?t(x):(n.consume(x),x===92?k:m)}function k(x){return x===40||x===41||x===92?(n.consume(x),m):m(x)}}function To(n,e,t,r,i,o){let s=this,l=0,a;return c;function c(h){return n.enter(r),n.enter(i),n.consume(h),n.exit(i),n.enter(o),u}function u(h){return l>999||h===null||h===91||h===93&&!a||h===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?t(h):h===93?(n.exit(o),n.enter(i),n.consume(h),n.exit(i),n.exit(r),e):E(h)?(n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),u):(n.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||E(h)||l++>999?(n.exit("chunkString"),u(h)):(n.consume(h),a||(a=!z(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(n.consume(h),l++,f):f(h)}}function Oo(n,e,t,r,i,o){let s;return l;function l(d){return d===34||d===39||d===40?(n.enter(r),n.enter(i),n.consume(d),n.exit(i),s=d===40?41:d,a):t(d)}function a(d){return d===s?(n.enter(i),n.consume(d),n.exit(i),n.exit(r),e):(n.enter(o),c(d))}function c(d){return d===s?(n.exit(o),a(s)):d===null?t(d):E(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),V(n,c,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===s||d===null||E(d)?(n.exit("chunkString"),c(d)):(n.consume(d),d===92?f:u)}function f(d){return d===s||d===92?(n.consume(d),u):u(d)}}function mn(n,e){let t;return r;function r(i){return E(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):z(i)?V(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}var Fl={name:"definition",tokenize:mx},px={partial:!0,tokenize:gx};function mx(n,e,t){let r=this,i;return o;function o(h){return n.enter("definition"),s(h)}function s(h){return To.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=bt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(n.enter("definitionMarker"),n.consume(h),n.exit("definitionMarker"),a):t(h)}function a(h){return ie(h)?mn(n,c)(h):c(h)}function c(h){return Io(n,u,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return n.attempt(px,f,f)(h)}function f(h){return z(h)?V(n,d,"whitespace")(h):d(h)}function d(h){return h===null||E(h)?(n.exit("definition"),r.parser.defined.push(i),e(h)):t(h)}}function gx(n,e,t){return r;function r(l){return ie(l)?mn(n,i)(l):t(l)}function i(l){return Oo(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return z(l)?V(n,s,"whitespace")(l):s(l)}function s(l){return l===null||E(l)?e(l):t(l)}}var _l={name:"hardBreakEscape",tokenize:yx};function yx(n,e,t){return r;function r(o){return n.enter("hardBreakEscape"),n.consume(o),i}function i(o){return E(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}var Vl={name:"headingAtx",resolve:xx,tokenize:kx};function xx(n,e){let t=n.length-2,r=3,i,o;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},o={type:"chunkText",start:n[r][1].start,end:n[t][1].end,contentType:"text"},de(n,r,t-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),n}function kx(n,e,t){let r=0;return i;function i(u){return n.enter("atxHeading"),o(u)}function o(u){return n.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&r++<6?(n.consume(u),s):u===null||ie(u)?(n.exit("atxHeadingSequence"),l(u)):t(u)}function l(u){return u===35?(n.enter("atxHeadingSequence"),a(u)):u===null||E(u)?(n.exit("atxHeading"),e(u)):z(u)?V(n,l,"whitespace")(u):(n.enter("atxHeadingText"),c(u))}function a(u){return u===35?(n.consume(u),a):(n.exit("atxHeadingSequence"),l(u))}function c(u){return u===null||u===35||ie(u)?(n.exit("atxHeadingText"),l(u)):(n.consume(u),c)}}var Qf=["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"],$l=["pre","script","style","textarea"];var Wl={concrete:!0,name:"htmlFlow",resolveTo:Sx,tokenize:Cx},bx={partial:!0,tokenize:Nx},wx={partial:!0,tokenize:Mx};function Sx(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 Cx(n,e,t){let r=this,i,o,s,l,a;return c;function c(y){return u(y)}function u(y){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(y),f}function f(y){return y===33?(n.consume(y),d):y===47?(n.consume(y),o=!0,m):y===63?(n.consume(y),i=3,r.interrupt?e:g):_e(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function d(y){return y===45?(n.consume(y),i=2,h):y===91?(n.consume(y),i=5,l=0,p):_e(y)?(n.consume(y),i=4,r.interrupt?e:g):t(y)}function h(y){return y===45?(n.consume(y),r.interrupt?e:g):t(y)}function p(y){let Le="CDATA[";return y===Le.charCodeAt(l++)?(n.consume(y),l===Le.length?r.interrupt?e:Y:p):t(y)}function m(y){return _e(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function k(y){if(y===null||y===47||y===62||ie(y)){let Le=y===47,Qt=s.toLowerCase();return!Le&&!o&&$l.includes(Qt)?(i=1,r.interrupt?e(y):Y(y)):Qf.includes(s.toLowerCase())?(i=6,Le?(n.consume(y),x):r.interrupt?e(y):Y(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(y):o?I(y):C(y))}return y===45||Me(y)?(n.consume(y),s+=String.fromCharCode(y),k):t(y)}function x(y){return y===62?(n.consume(y),r.interrupt?e:Y):t(y)}function I(y){return z(y)?(n.consume(y),I):U(y)}function C(y){return y===47?(n.consume(y),U):y===58||y===95||_e(y)?(n.consume(y),A):z(y)?(n.consume(y),C):U(y)}function A(y){return y===45||y===46||y===58||y===95||Me(y)?(n.consume(y),A):v(y)}function v(y){return y===61?(n.consume(y),b):z(y)?(n.consume(y),v):C(y)}function b(y){return y===null||y===60||y===61||y===62||y===96?t(y):y===34||y===39?(n.consume(y),a=y,T):z(y)?(n.consume(y),b):P(y)}function T(y){return y===a?(n.consume(y),a=null,D):y===null||E(y)?t(y):(n.consume(y),T)}function P(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||ie(y)?v(y):(n.consume(y),P)}function D(y){return y===47||y===62||z(y)?C(y):t(y)}function U(y){return y===62?(n.consume(y),Se):t(y)}function Se(y){return y===null||E(y)?Y(y):z(y)?(n.consume(y),Se):t(y)}function Y(y){return y===45&&i===2?(n.consume(y),Q):y===60&&i===1?(n.consume(y),X):y===62&&i===4?(n.consume(y),je):y===63&&i===3?(n.consume(y),g):y===93&&i===5?(n.consume(y),le):E(y)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(bx,pt,R)(y)):y===null||E(y)?(n.exit("htmlFlowData"),R(y)):(n.consume(y),Y)}function R(y){return n.check(wx,L,pt)(y)}function L(y){return n.enter("lineEnding"),n.consume(y),n.exit("lineEnding"),F}function F(y){return y===null||E(y)?R(y):(n.enter("htmlFlowData"),Y(y))}function Q(y){return y===45?(n.consume(y),g):Y(y)}function X(y){return y===47?(n.consume(y),s="",te):Y(y)}function te(y){if(y===62){let Le=s.toLowerCase();return $l.includes(Le)?(n.consume(y),je):Y(y)}return _e(y)&&s.length<8?(n.consume(y),s+=String.fromCharCode(y),te):Y(y)}function le(y){return y===93?(n.consume(y),g):Y(y)}function g(y){return y===62?(n.consume(y),je):y===45&&i===2?(n.consume(y),g):Y(y)}function je(y){return y===null||E(y)?(n.exit("htmlFlowData"),pt(y)):(n.consume(y),je)}function pt(y){return n.exit("htmlFlow"),e(y)}}function Mx(n,e,t){let r=this;return i;function i(s){return E(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o):t(s)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}function Nx(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(zt,e,t)}}var jl={name:"htmlText",tokenize:Ix};function Ix(n,e,t){let r=this,i,o,s;return l;function l(g){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(g),a}function a(g){return g===33?(n.consume(g),c):g===47?(n.consume(g),v):g===63?(n.consume(g),C):_e(g)?(n.consume(g),P):t(g)}function c(g){return g===45?(n.consume(g),u):g===91?(n.consume(g),o=0,p):_e(g)?(n.consume(g),I):t(g)}function u(g){return g===45?(n.consume(g),h):t(g)}function f(g){return g===null?t(g):g===45?(n.consume(g),d):E(g)?(s=f,X(g)):(n.consume(g),f)}function d(g){return g===45?(n.consume(g),h):f(g)}function h(g){return g===62?Q(g):g===45?d(g):f(g)}function p(g){let je="CDATA[";return g===je.charCodeAt(o++)?(n.consume(g),o===je.length?m:p):t(g)}function m(g){return g===null?t(g):g===93?(n.consume(g),k):E(g)?(s=m,X(g)):(n.consume(g),m)}function k(g){return g===93?(n.consume(g),x):m(g)}function x(g){return g===62?Q(g):g===93?(n.consume(g),x):m(g)}function I(g){return g===null||g===62?Q(g):E(g)?(s=I,X(g)):(n.consume(g),I)}function C(g){return g===null?t(g):g===63?(n.consume(g),A):E(g)?(s=C,X(g)):(n.consume(g),C)}function A(g){return g===62?Q(g):C(g)}function v(g){return _e(g)?(n.consume(g),b):t(g)}function b(g){return g===45||Me(g)?(n.consume(g),b):T(g)}function T(g){return E(g)?(s=T,X(g)):z(g)?(n.consume(g),T):Q(g)}function P(g){return g===45||Me(g)?(n.consume(g),P):g===47||g===62||ie(g)?D(g):t(g)}function D(g){return g===47?(n.consume(g),Q):g===58||g===95||_e(g)?(n.consume(g),U):E(g)?(s=D,X(g)):z(g)?(n.consume(g),D):Q(g)}function U(g){return g===45||g===46||g===58||g===95||Me(g)?(n.consume(g),U):Se(g)}function Se(g){return g===61?(n.consume(g),Y):E(g)?(s=Se,X(g)):z(g)?(n.consume(g),Se):D(g)}function Y(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),i=g,R):E(g)?(s=Y,X(g)):z(g)?(n.consume(g),Y):(n.consume(g),L)}function R(g){return g===i?(n.consume(g),i=void 0,F):g===null?t(g):E(g)?(s=R,X(g)):(n.consume(g),R)}function L(g){return g===null||g===34||g===39||g===60||g===61||g===96?t(g):g===47||g===62||ie(g)?D(g):(n.consume(g),L)}function F(g){return g===47||g===62||ie(g)?D(g):t(g)}function Q(g){return g===62?(n.consume(g),n.exit("htmlTextData"),n.exit("htmlText"),e):t(g)}function X(g){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),te}function te(g){return z(g)?V(n,le,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(g):le(g)}function le(g){return n.enter("htmlTextData"),s(g)}}var gn={name:"labelEnd",resolveAll:Ax,resolveTo:Rx,tokenize:vx},Tx={tokenize:Dx},Ox={tokenize:Px},Ex={tokenize:Lx};function Ax(n){let e=-1,t=[];for(;++e<n.length;){let r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&de(n,0,n.length,t),n}function Rx(n,e){let t=n.length,r=0,i,o,s,l;for(;t--;)if(i=n[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;n[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(n[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=t);let a={type:n[o][1].type==="labelLink"?"link":"image",start:{...n[o][1].start},end:{...n[n.length-1][1].end}},c={type:"label",start:{...n[o][1].start},end:{...n[s][1].end}},u={type:"labelText",start:{...n[o+r+2][1].end},end:{...n[s-2][1].start}};return l=[["enter",a,e],["enter",c,e]],l=Ce(l,n.slice(o+1,o+r+3)),l=Ce(l,[["enter",u,e]]),l=Ce(l,rr(e.parser.constructs.insideSpan.null,n.slice(o+r+4,s-3),e)),l=Ce(l,[["exit",u,e],n[s-2],n[s-1],["exit",c,e]]),l=Ce(l,n.slice(s+1)),l=Ce(l,[["exit",a,e]]),de(n,o,n.length,l),n}function vx(n,e,t){let r=this,i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?f(d):(s=r.parser.defined.includes(bt(r.sliceSerialize({start:o.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(Tx,u,s?u:f)(d):d===91?n.attempt(Ox,u,s?c:f)(d):s?u(d):f(d)}function c(d){return n.attempt(Ex,u,f)(d)}function u(d){return e(d)}function f(d){return o._balanced=!0,t(d)}}function Dx(n,e,t){return r;function r(f){return n.enter("resource"),n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),i}function i(f){return ie(f)?mn(n,o)(f):o(f)}function o(f){return f===41?u(f):Io(n,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return ie(f)?mn(n,a)(f):u(f)}function l(f){return t(f)}function a(f){return f===34||f===39||f===40?Oo(n,c,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return ie(f)?mn(n,u)(f):u(f)}function u(f){return f===41?(n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),n.exit("resource"),e):t(f)}}function Px(n,e,t){let r=this;return i;function i(l){return To.call(r,n,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(bt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function s(l){return t(l)}}function Lx(n,e,t){return r;function r(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),i}function i(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}var Hl={name:"labelStartImage",resolveAll:gn.resolveAll,tokenize:Bx};function Bx(n,e,t){let r=this;return i;function i(l){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(l),n.exit("labelImageMarker"),o}function o(l){return l===91?(n.enter("labelMarker"),n.consume(l),n.exit("labelMarker"),n.exit("labelImage"),s):t(l)}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(l):e(l)}}var ql={name:"labelStartLink",resolveAll:gn.resolveAll,tokenize:zx};function zx(n,e,t){let r=this;return i;function i(s){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(s),n.exit("labelMarker"),n.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(s):e(s)}}var li={name:"lineEnding",tokenize:Fx};function Fx(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),V(n,e,"linePrefix")}}var yn={name:"thematicBreak",tokenize:_x};function _x(n,e,t){let r=0,i;return o;function o(c){return n.enter("thematicBreak"),s(c)}function s(c){return i=c,l(c)}function l(c){return c===i?(n.enter("thematicBreakSequence"),a(c)):r>=3&&(c===null||E(c))?(n.exit("thematicBreak"),e(c)):t(c)}function a(c){return c===i?(n.consume(c),r++,a):(n.exit("thematicBreakSequence"),z(c)?V(n,l,"whitespace")(c):l(c))}}var ke={continuation:{tokenize:jx},exit:qx,name:"list",tokenize:Wx},Vx={partial:!0,tokenize:Kx},$x={partial:!0,tokenize:Hx};function Wx(n,e,t){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(h){let p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:ri(h)){if(r.containerState.type||(r.containerState.type=p,n.enter(p,{_container:!0})),p==="listUnordered")return n.enter("listItemPrefix"),h===42||h===45?n.check(yn,t,c)(h):c(h);if(!r.interrupt||h===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),a(h)}return t(h)}function a(h){return ri(h)&&++s<10?(n.consume(h),a):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(n.exit("listItemValue"),c(h)):t(h)}function c(h){return n.enter("listItemMarker"),n.consume(h),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,n.check(zt,r.interrupt?t:u,n.attempt(Vx,d,f))}function u(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return z(h)?(n.enter("listItemPrefixWhitespace"),n.consume(h),n.exit("listItemPrefixWhitespace"),d):t(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(h)}}function jx(n,e,t){let r=this;return r.containerState._closeFlow=void 0,n.check(zt,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,V(n,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!z(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt($x,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,V(n,n.attempt(ke,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Hx(n,e,t){let r=this;return V(n,i,"listItemIndent",r.containerState.size+1);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):t(o)}}function qx(n){n.exit(this.containerState.type)}function Kx(n,e,t){let r=this;return V(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let s=r.events[r.events.length-1];return!z(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}var Eo={name:"setextUnderline",resolveTo:Ux,tokenize:Jx};function Ux(n,e){let t=n.length,r,i,o;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),!o&&n[t][1].type==="definition"&&(o=t);let s={type:"setextHeading",start:{...n[r][1].start},end:{...n[n.length-1][1].end}};return n[i][1].type="setextHeadingText",o?(n.splice(i,0,["enter",s,e]),n.splice(o+1,0,["exit",n[r][1],e]),n[r][1].end={...n[o][1].end}):n[r][1]=s,n.push(["exit",s,e]),n}function Jx(n,e,t){let r=this,i;return o;function o(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(n.enter("setextHeadingLine"),i=c,s(c)):t(c)}function s(c){return n.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(n.consume(c),l):(n.exit("setextHeadingLineSequence"),z(c)?V(n,a,"lineSuffix")(c):a(c))}function a(c){return c===null||E(c)?(n.exit("setextHeadingLine"),e(c)):t(c)}}var Xf={tokenize:Gx};function Gx(n){let e=this,t=n.attempt(zt,r,n.attempt(this.parser.constructs.flowInitial,i,V(n,n.attempt(this.parser.constructs.flow,i,n.attempt(zl,i)),"linePrefix")));return t;function r(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}var Zf={resolveAll:rh()},eh=nh("string"),th=nh("text");function nh(n){return{resolveAll:rh(n==="text"?Yx:void 0),tokenize:e};function e(t){let r=this,i=this.parser.constructs[n],o=t.attempt(i,s,l);return s;function s(u){return c(u)?o(u):l(u)}function l(u){if(u===null){t.consume(u);return}return t.enter("data"),t.consume(u),a}function a(u){return c(u)?(t.exit("data"),o(u)):(t.consume(u),a)}function c(u){if(u===null)return!0;let f=i[u],d=-1;if(f)for(;++d<f.length;){let h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function rh(n){return e;function e(t,r){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return n?n(t,r):t}}function Yx(n,e){let t=0;for(;++t<=n.length;)if((t===n.length||n[t][1].type==="lineEnding")&&n[t-1][1].type==="data"){let r=n[t-1][1],i=e.sliceStream(r),o=i.length,s=-1,l=0,a;for(;o--;){let c=i[o];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)l++,s--;if(s)break;s=-1}else if(c===-2)a=!0,l++;else if(c!==-1){o++;break}}if(e._contentTypeTextTrailing&&t===n.length&&(l=0),l){let c={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(n.splice(t,0,["enter",c,e],["exit",c,e]),t+=2)}t++}return n}var Kl={};Og(Kl,{attentionMarkers:()=>ik,contentInitial:()=>Xx,disable:()=>ok,document:()=>Qx,flow:()=>ek,flowInitial:()=>Zx,insideSpan:()=>rk,string:()=>tk,text:()=>nk});var Qx={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:bo},Xx={91:Fl},Zx={[-2]:oi,[-1]:oi,32:oi},ek={35:Vl,42:yn,45:[Eo,yn],60:Wl,61:Eo,95:yn,96:Co,126:Co},tk={38:So,92:wo},nk={[-5]:li,[-4]:li,[-3]:li,33:Hl,38:So,42:ii,60:[Ll,jl],91:ql,92:[_l,wo],93:gn,95:ii,96:Bl},rk={null:[ii,Zf]},ik={null:[42,95]},ok={null:[]};function ih(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0},i={},o=[],s=[],l=[],a=!0,c={attempt:D(T),check:D(P),consume:A,enter:v,exit:b,interrupt:D(P,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:k,parser:n,previous:null,sliceSerialize:p,sliceStream:m,write:h},f=e.tokenize.call(u,c),d;return e.resolveAll&&o.push(e),u;function h(R){return s=Ce(s,R),I(),s[s.length-1]!==null?[]:(U(e,0),u.events=rr(o,u.events,u),u.events)}function p(R,L){return lk(m(R),L)}function m(R){return sk(s,R)}function k(){let{_bufferIndex:R,_index:L,line:F,column:Q,offset:X}=r;return{_bufferIndex:R,_index:L,line:F,column:Q,offset:X}}function x(R){i[R.line]=R.column,Y()}function I(){let R;for(;r._index<s.length;){let L=s[r._index];if(typeof L=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<L.length;)C(L.charCodeAt(r._bufferIndex));else C(L)}}function C(R){a=void 0,d=R,f=f(R)}function A(R){E(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,Y()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R,a=!0}function v(R,L){let F=L||{};return F.type=R,F.start=k(),u.events.push(["enter",F,u]),l.push(F),F}function b(R){let L=l.pop();return L.end=k(),u.events.push(["exit",L,u]),L}function T(R,L){U(R,L.from)}function P(R,L){L.restore()}function D(R,L){return F;function F(Q,X,te){let le,g,je,pt;return Array.isArray(Q)?Le(Q):"tokenize"in Q?Le([Q]):y(Q);function y(ue){return Vr;function Vr(mt){let Xt=mt!==null&&ue[mt],Hn=mt!==null&&ue.null,nl=[...Array.isArray(Xt)?Xt:Xt?[Xt]:[],...Array.isArray(Hn)?Hn:Hn?[Hn]:[]];return Le(nl)(mt)}}function Le(ue){return le=ue,g=0,ue.length===0?te:Qt(ue[g])}function Qt(ue){return Vr;function Vr(mt){return pt=Se(),je=ue,ue.partial||(u.currentConstruct=ue),ue.name&&u.parser.constructs.disable.null.includes(ue.name)?Gi(mt):ue.tokenize.call(L?Object.assign(Object.create(u),L):u,c,tl,Gi)(mt)}}function tl(ue){return a=!0,R(je,pt),X}function Gi(ue){return a=!0,pt.restore(),++g<le.length?Qt(le[g]):te}}}function U(R,L){R.resolveAll&&!o.includes(R)&&o.push(R),R.resolve&&de(u.events,L,u.events.length-L,R.resolve(u.events.slice(L),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function Se(){let R=k(),L=u.previous,F=u.currentConstruct,Q=u.events.length,X=Array.from(l);return{from:Q,restore:te};function te(){r=R,u.previous=L,u.currentConstruct=F,u.events.length=Q,l=X,Y()}}function Y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sk(n,e){let t=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex,s;if(t===i)s=[n[t].slice(r,o)];else{if(s=n.slice(t,i),r>-1){let l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(n[i].slice(0,o))}return s}function lk(n,e){let t=-1,r=[],i;for(;++t<n.length;){let o=n[t],s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=` 8 8 `;break}case-3:{s=`\r 9 - `;break}case-2:{s=e?" ":" ";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function Kl(n){let r={constructs:Vf([ql,...(n||{}).extensions||[]]),content:i(Kf),defined:[],document:i(Jf),flow:i(Xf),lazy:{},string:i(eh),text:i(th)};return r;function i(o){return s;function s(l){return ih(r,o,l)}}}function Ul(n){for(;!No(n););return n}var oh=/[\0\t\n\r]/g;function Jl(){let n=1,e="",t=!0,r;return i;function i(o,s,l){let a=[],c,u,f,d,h;for(o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),f=0,e="",t&&(o.charCodeAt(0)===65279&&f++,t=void 0);f<o.length;){if(oh.lastIndex=f,c=oh.exec(o),d=c&&c.index!==void 0?c.index:o.length,h=o.charCodeAt(d),!c){e=o.slice(f);break}if(h===10&&f===d&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),f<d&&(a.push(o.slice(f,d)),n+=d-f),h){case 0:{a.push(65533),n++;break}case 9:{for(u=Math.ceil(n/4)*4,a.push(-2);n++<u;)a.push(-1);break}case 10:{a.push(-4),n=1;break}default:r=!0,n=1}f=d+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}var ak=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ao(n){return n.replace(ak,ck)}function ck(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),o=i===120||i===88;return ko(t.slice(o?2:1),o?16:10)}return tr(t)||n}function Ft(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?sh(n.position):"start"in n||"end"in n?sh(n):"line"in n||"column"in n?Gl(n):""}function Gl(n){return lh(n&&n.line)+":"+lh(n&&n.column)}function sh(n){return Gl(n&&n.start)+"-"+Gl(n&&n.end)}function lh(n){return n&&typeof n=="number"?n:1}var ch={}.hasOwnProperty;function Yl(n,e,t){return e&&typeof e=="object"&&(t=e,e=void 0),uk(t)(Ul(Kl(t).document().write(Jl()(n,e,!0))))}function uk(n){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Mu),autolinkProtocol:D,autolinkEmail:D,atxHeading:o(wu),blockQuote:o(mt),characterEscape:D,characterReference:D,codeFenced:o(Xt),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Xt,s),codeText:o(Hn,s),codeTextData:D,data:D,codeFlowValue:D,definition:o(tl),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(mg),hardBreakEscape:o(Su),hardBreakTrailing:o(Su),htmlFlow:o(Cu,s),htmlFlowData:D,htmlText:o(Cu,s),htmlTextData:D,image:o(gg),label:s,link:o(Mu),listItem:o(yg),listItemValue:d,listOrdered:o(Nu,f),listUnordered:o(Nu),paragraph:o(xg),reference:y,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(wu),strong:o(kg),thematicBreak:o(wg)},exit:{atxHeading:a(),atxHeadingSequence:v,autolink:a(),autolinkEmail:Vr,autolinkProtocol:ue,blockQuote:a(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:Qt,characterReferenceMarkerNumeric:Qt,characterReferenceValue:el,characterReference:Gi,codeFenced:a(k),codeFencedFence:m,codeFencedFenceInfo:h,codeFencedFenceMeta:p,codeFlowValue:U,codeIndented:a(x),codeText:a(F),codeTextData:U,data:U,definition:a(),definitionDestinationString:A,definitionLabelString:I,definitionTitleString:C,emphasis:a(),hardBreakEscape:a(Y),hardBreakTrailing:a(Y),htmlFlow:a(R),htmlFlowData:U,htmlText:a(L),htmlTextData:U,image:a(X),label:le,labelText:te,lineEnding:Se,link:a(Q),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Le,resourceDestinationString:g,resourceTitleString:je,resource:pt,setextHeading:a(P),setextHeadingLineSequence:T,setextHeadingText:b,strong:a(),thematicBreak:a()}};uh(e,(n||{}).mdastExtensions||[]);let t={};return r;function r(S){let N={type:"root",children:[]},_={stack:[N],tokenStack:[],config:e,enter:l,exit:c,buffer:s,resume:u,data:t},K=[],Z=-1;for(;++Z<S.length;)if(S[Z][1].type==="listOrdered"||S[Z][1].type==="listUnordered")if(S[Z][0]==="enter")K.push(Z);else{let Ze=K.pop();Z=i(S,Ze,Z)}for(Z=-1;++Z<S.length;){let Ze=e[S[Z][0]];ch.call(Ze,S[Z][1].type)&&Ze[S[Z][1].type].call(Object.assign({sliceSerialize:S[Z][2].sliceSerialize},_),S[Z][1])}if(_.tokenStack.length>0){let Ze=_.tokenStack[_.tokenStack.length-1];(Ze[1]||ah).call(_,void 0,Ze[0])}for(N.position={start:_t(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:_t(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},Z=-1;++Z<e.transforms.length;)N=e.transforms[Z](N)||N;return N}function i(S,N,_){let K=N-1,Z=-1,Ze=!1,Zt,gt,$r,Wr;for(;++K<=_;){let Be=S[K];switch(Be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Be[0]==="enter"?Z++:Z--,Wr=void 0;break}case"lineEndingBlank":{Be[0]==="enter"&&(Zt&&!Wr&&!Z&&!$r&&($r=K),Wr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Wr=void 0}if(!Z&&Be[0]==="enter"&&Be[1].type==="listItemPrefix"||Z===-1&&Be[0]==="exit"&&(Be[1].type==="listUnordered"||Be[1].type==="listOrdered")){if(Zt){let qn=K;for(gt=void 0;qn--;){let yt=S[qn];if(yt[1].type==="lineEnding"||yt[1].type==="lineEndingBlank"){if(yt[0]==="exit")continue;gt&&(S[gt][1].type="lineEndingBlank",Ze=!0),yt[1].type="lineEnding",gt=qn}else if(!(yt[1].type==="linePrefix"||yt[1].type==="blockQuotePrefix"||yt[1].type==="blockQuotePrefixWhitespace"||yt[1].type==="blockQuoteMarker"||yt[1].type==="listItemIndent"))break}$r&&(!gt||$r<gt)&&(Zt._spread=!0),Zt.end=Object.assign({},gt?S[gt][1].start:Be[1].end),S.splice(gt||K,0,["exit",Zt,Be[2]]),K++,_++}if(Be[1].type==="listItemPrefix"){let qn={type:"listItem",_spread:!1,start:Object.assign({},Be[1].start),end:void 0};Zt=qn,S.splice(K,0,["enter",qn,Be[2]]),K++,_++,$r=void 0,Wr=!0}}}return S[N][1]._spread=Ze,_}function o(S,N){return _;function _(K){l.call(this,S(K),K),N&&N.call(this,K)}}function s(){this.stack.push({type:"fragment",children:[]})}function l(S,N,_){this.stack[this.stack.length-1].children.push(S),this.stack.push(S),this.tokenStack.push([N,_||void 0]),S.position={start:_t(N.start),end:void 0}}function a(S){return N;function N(_){S&&S.call(this,_),c.call(this,_)}}function c(S,N){let _=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==S.type&&(N?N.call(this,S,K[0]):(K[1]||ah).call(this,S,K[0]));else throw new Error("Cannot close `"+S.type+"` ("+Ft({start:S.start,end:S.end})+"): it\u2019s not open");_.position.end=_t(S.end)}function u(){return pn(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(S){if(this.data.expectingFirstListItemValue){let N=this.stack[this.stack.length-2];N.start=Number.parseInt(this.sliceSerialize(S),10),this.data.expectingFirstListItemValue=void 0}}function h(){let S=this.resume(),N=this.stack[this.stack.length-1];N.lang=S}function p(){let S=this.resume(),N=this.stack[this.stack.length-1];N.meta=S}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S.replace(/(\r?\n|\r)$/g,"")}function I(S){let N=this.resume(),_=this.stack[this.stack.length-1];_.label=N,_.identifier=bt(this.sliceSerialize(S)).toLowerCase()}function C(){let S=this.resume(),N=this.stack[this.stack.length-1];N.title=S}function A(){let S=this.resume(),N=this.stack[this.stack.length-1];N.url=S}function v(S){let N=this.stack[this.stack.length-1];if(!N.depth){let _=this.sliceSerialize(S).length;N.depth=_}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function T(S){let N=this.stack[this.stack.length-1];N.depth=this.sliceSerialize(S).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function D(S){let _=this.stack[this.stack.length-1].children,K=_[_.length-1];(!K||K.type!=="text")&&(K=bg(),K.position={start:_t(S.start),end:void 0},_.push(K)),this.stack.push(K)}function U(S){let N=this.stack.pop();N.value+=this.sliceSerialize(S),N.position.end=_t(S.end)}function Se(S){let N=this.stack[this.stack.length-1];if(this.data.atHardBreak){let _=N.children[N.children.length-1];_.position.end=_t(S.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(N.type)&&(D.call(this,S),U.call(this,S))}function Y(){this.data.atHardBreak=!0}function R(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function L(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function F(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function Q(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=N,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function X(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=N,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function te(S){let N=this.sliceSerialize(S),_=this.stack[this.stack.length-2];_.label=Ao(N),_.identifier=bt(N).toLowerCase()}function le(){let S=this.stack[this.stack.length-1],N=this.resume(),_=this.stack[this.stack.length-1];if(this.data.inReference=!0,_.type==="link"){let K=S.children;_.children=K}else _.alt=N}function g(){let S=this.resume(),N=this.stack[this.stack.length-1];N.url=S}function je(){let S=this.resume(),N=this.stack[this.stack.length-1];N.title=S}function pt(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function Le(S){let N=this.resume(),_=this.stack[this.stack.length-1];_.label=N,_.identifier=bt(this.sliceSerialize(S)).toLowerCase(),this.data.referenceType="full"}function Qt(S){this.data.characterReferenceType=S.type}function el(S){let N=this.sliceSerialize(S),_=this.data.characterReferenceType,K;_?(K=ko(N,_==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=tr(N);let Z=this.stack[this.stack.length-1];Z.value+=K}function Gi(S){let N=this.stack.pop();N.position.end=_t(S.end)}function ue(S){U.call(this,S);let N=this.stack[this.stack.length-1];N.url=this.sliceSerialize(S)}function Vr(S){U.call(this,S);let N=this.stack[this.stack.length-1];N.url="mailto:"+this.sliceSerialize(S)}function mt(){return{type:"blockquote",children:[]}}function Xt(){return{type:"code",lang:null,meta:null,value:""}}function Hn(){return{type:"inlineCode",value:""}}function tl(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function mg(){return{type:"emphasis",children:[]}}function wu(){return{type:"heading",depth:0,children:[]}}function Su(){return{type:"break"}}function Cu(){return{type:"html",value:""}}function gg(){return{type:"image",title:null,url:"",alt:null}}function Mu(){return{type:"link",title:null,url:"",children:[]}}function Nu(S){return{type:"list",ordered:S.type==="listOrdered",start:null,spread:S._spread,children:[]}}function yg(S){return{type:"listItem",spread:S._spread,checked:null,children:[]}}function xg(){return{type:"paragraph",children:[]}}function kg(){return{type:"strong",children:[]}}function bg(){return{type:"text",value:""}}function wg(){return{type:"thematicBreak"}}}function _t(n){return{line:n.line,column:n.column,offset:n.offset}}function uh(n,e){let t=-1;for(;++t<e.length;){let r=e[t];Array.isArray(r)?uh(n,r):fk(n,r)}}function fk(n,e){let t;for(t in e)if(ch.call(e,t))switch(t){case"canContainEols":{let r=e[t];r&&n[t].push(...r);break}case"transforms":{let r=e[t];r&&n[t].push(...r);break}case"enter":case"exit":{let r=e[t];r&&Object.assign(n[t],r);break}}}function ah(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+Ft({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+Ft({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ft({start:e.start,end:e.end})+") is still open")}function ir(n){let e=this;e.parser=t;function t(r){return Yl(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}var fh={}.hasOwnProperty;function hh(n,e){let t=e||{};function r(i,...o){let s=r.invalid,l=r.handlers;if(i&&fh.call(i,n)){let a=String(i[n]);s=fh.call(l,a)?l[a]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}var hk={}.hasOwnProperty;function Ql(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)Ql(n,e.extensions[t]);for(r in e)if(hk.call(e,r))switch(r){case"extensions":break;case"unsafe":{dh(n[r],e[r]);break}case"join":{dh(n[r],e[r]);break}case"handlers":{dk(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function dh(n,e){e&&n.push(...e)}function dk(n,e){e&&Object.assign(n,e)}function ph(n,e,t,r){let i=t.enter("blockquote"),o=t.createTracker(r);o.move("> "),o.shift(2);let s=t.indentLines(t.containerFlow(n,o.current()),pk);return i(),s}function pk(n,e,t){return">"+(t?"":" ")+n}function Ro(n,e){return mh(n,e.inConstruct,!0)&&!mh(n,e.notInConstruct,!1)}function mh(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 Xl(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===` 9 + `;break}case-2:{s=e?" ":" ";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function Ul(n){let r={constructs:Vf([Kl,...(n||{}).extensions||[]]),content:i(Kf),defined:[],document:i(Jf),flow:i(Xf),lazy:{},string:i(eh),text:i(th)};return r;function i(o){return s;function s(l){return ih(r,o,l)}}}function Jl(n){for(;!No(n););return n}var oh=/[\0\t\n\r]/g;function Gl(){let n=1,e="",t=!0,r;return i;function i(o,s,l){let a=[],c,u,f,d,h;for(o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),f=0,e="",t&&(o.charCodeAt(0)===65279&&f++,t=void 0);f<o.length;){if(oh.lastIndex=f,c=oh.exec(o),d=c&&c.index!==void 0?c.index:o.length,h=o.charCodeAt(d),!c){e=o.slice(f);break}if(h===10&&f===d&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),f<d&&(a.push(o.slice(f,d)),n+=d-f),h){case 0:{a.push(65533),n++;break}case 9:{for(u=Math.ceil(n/4)*4,a.push(-2);n++<u;)a.push(-1);break}case 10:{a.push(-4),n=1;break}default:r=!0,n=1}f=d+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}var ak=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ao(n){return n.replace(ak,ck)}function ck(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),o=i===120||i===88;return ko(t.slice(o?2:1),o?16:10)}return tr(t)||n}function Ft(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?sh(n.position):"start"in n||"end"in n?sh(n):"line"in n||"column"in n?Yl(n):""}function Yl(n){return lh(n&&n.line)+":"+lh(n&&n.column)}function sh(n){return Yl(n&&n.start)+"-"+Yl(n&&n.end)}function lh(n){return n&&typeof n=="number"?n:1}var ch={}.hasOwnProperty;function Ql(n,e,t){return e&&typeof e=="object"&&(t=e,e=void 0),uk(t)(Jl(Ul(t).document().write(Gl()(n,e,!0))))}function uk(n){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Mu),autolinkProtocol:D,autolinkEmail:D,atxHeading:o(wu),blockQuote:o(mt),characterEscape:D,characterReference:D,codeFenced:o(Xt),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Xt,s),codeText:o(Hn,s),codeTextData:D,data:D,codeFlowValue:D,definition:o(nl),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(mg),hardBreakEscape:o(Su),hardBreakTrailing:o(Su),htmlFlow:o(Cu,s),htmlFlowData:D,htmlText:o(Cu,s),htmlTextData:D,image:o(gg),label:s,link:o(Mu),listItem:o(yg),listItemValue:d,listOrdered:o(Nu,f),listUnordered:o(Nu),paragraph:o(xg),reference:y,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(wu),strong:o(kg),thematicBreak:o(wg)},exit:{atxHeading:a(),atxHeadingSequence:v,autolink:a(),autolinkEmail:Vr,autolinkProtocol:ue,blockQuote:a(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:Qt,characterReferenceMarkerNumeric:Qt,characterReferenceValue:tl,characterReference:Gi,codeFenced:a(k),codeFencedFence:m,codeFencedFenceInfo:h,codeFencedFenceMeta:p,codeFlowValue:U,codeIndented:a(x),codeText:a(F),codeTextData:U,data:U,definition:a(),definitionDestinationString:A,definitionLabelString:I,definitionTitleString:C,emphasis:a(),hardBreakEscape:a(Y),hardBreakTrailing:a(Y),htmlFlow:a(R),htmlFlowData:U,htmlText:a(L),htmlTextData:U,image:a(X),label:le,labelText:te,lineEnding:Se,link:a(Q),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Le,resourceDestinationString:g,resourceTitleString:je,resource:pt,setextHeading:a(P),setextHeadingLineSequence:T,setextHeadingText:b,strong:a(),thematicBreak:a()}};uh(e,(n||{}).mdastExtensions||[]);let t={};return r;function r(S){let N={type:"root",children:[]},_={stack:[N],tokenStack:[],config:e,enter:l,exit:c,buffer:s,resume:u,data:t},K=[],Z=-1;for(;++Z<S.length;)if(S[Z][1].type==="listOrdered"||S[Z][1].type==="listUnordered")if(S[Z][0]==="enter")K.push(Z);else{let Ze=K.pop();Z=i(S,Ze,Z)}for(Z=-1;++Z<S.length;){let Ze=e[S[Z][0]];ch.call(Ze,S[Z][1].type)&&Ze[S[Z][1].type].call(Object.assign({sliceSerialize:S[Z][2].sliceSerialize},_),S[Z][1])}if(_.tokenStack.length>0){let Ze=_.tokenStack[_.tokenStack.length-1];(Ze[1]||ah).call(_,void 0,Ze[0])}for(N.position={start:_t(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:_t(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},Z=-1;++Z<e.transforms.length;)N=e.transforms[Z](N)||N;return N}function i(S,N,_){let K=N-1,Z=-1,Ze=!1,Zt,gt,$r,Wr;for(;++K<=_;){let Be=S[K];switch(Be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Be[0]==="enter"?Z++:Z--,Wr=void 0;break}case"lineEndingBlank":{Be[0]==="enter"&&(Zt&&!Wr&&!Z&&!$r&&($r=K),Wr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Wr=void 0}if(!Z&&Be[0]==="enter"&&Be[1].type==="listItemPrefix"||Z===-1&&Be[0]==="exit"&&(Be[1].type==="listUnordered"||Be[1].type==="listOrdered")){if(Zt){let qn=K;for(gt=void 0;qn--;){let yt=S[qn];if(yt[1].type==="lineEnding"||yt[1].type==="lineEndingBlank"){if(yt[0]==="exit")continue;gt&&(S[gt][1].type="lineEndingBlank",Ze=!0),yt[1].type="lineEnding",gt=qn}else if(!(yt[1].type==="linePrefix"||yt[1].type==="blockQuotePrefix"||yt[1].type==="blockQuotePrefixWhitespace"||yt[1].type==="blockQuoteMarker"||yt[1].type==="listItemIndent"))break}$r&&(!gt||$r<gt)&&(Zt._spread=!0),Zt.end=Object.assign({},gt?S[gt][1].start:Be[1].end),S.splice(gt||K,0,["exit",Zt,Be[2]]),K++,_++}if(Be[1].type==="listItemPrefix"){let qn={type:"listItem",_spread:!1,start:Object.assign({},Be[1].start),end:void 0};Zt=qn,S.splice(K,0,["enter",qn,Be[2]]),K++,_++,$r=void 0,Wr=!0}}}return S[N][1]._spread=Ze,_}function o(S,N){return _;function _(K){l.call(this,S(K),K),N&&N.call(this,K)}}function s(){this.stack.push({type:"fragment",children:[]})}function l(S,N,_){this.stack[this.stack.length-1].children.push(S),this.stack.push(S),this.tokenStack.push([N,_||void 0]),S.position={start:_t(N.start),end:void 0}}function a(S){return N;function N(_){S&&S.call(this,_),c.call(this,_)}}function c(S,N){let _=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==S.type&&(N?N.call(this,S,K[0]):(K[1]||ah).call(this,S,K[0]));else throw new Error("Cannot close `"+S.type+"` ("+Ft({start:S.start,end:S.end})+"): it\u2019s not open");_.position.end=_t(S.end)}function u(){return pn(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(S){if(this.data.expectingFirstListItemValue){let N=this.stack[this.stack.length-2];N.start=Number.parseInt(this.sliceSerialize(S),10),this.data.expectingFirstListItemValue=void 0}}function h(){let S=this.resume(),N=this.stack[this.stack.length-1];N.lang=S}function p(){let S=this.resume(),N=this.stack[this.stack.length-1];N.meta=S}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S.replace(/(\r?\n|\r)$/g,"")}function I(S){let N=this.resume(),_=this.stack[this.stack.length-1];_.label=N,_.identifier=bt(this.sliceSerialize(S)).toLowerCase()}function C(){let S=this.resume(),N=this.stack[this.stack.length-1];N.title=S}function A(){let S=this.resume(),N=this.stack[this.stack.length-1];N.url=S}function v(S){let N=this.stack[this.stack.length-1];if(!N.depth){let _=this.sliceSerialize(S).length;N.depth=_}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function T(S){let N=this.stack[this.stack.length-1];N.depth=this.sliceSerialize(S).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function D(S){let _=this.stack[this.stack.length-1].children,K=_[_.length-1];(!K||K.type!=="text")&&(K=bg(),K.position={start:_t(S.start),end:void 0},_.push(K)),this.stack.push(K)}function U(S){let N=this.stack.pop();N.value+=this.sliceSerialize(S),N.position.end=_t(S.end)}function Se(S){let N=this.stack[this.stack.length-1];if(this.data.atHardBreak){let _=N.children[N.children.length-1];_.position.end=_t(S.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(N.type)&&(D.call(this,S),U.call(this,S))}function Y(){this.data.atHardBreak=!0}function R(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function L(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function F(){let S=this.resume(),N=this.stack[this.stack.length-1];N.value=S}function Q(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=N,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function X(){let S=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=N,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function te(S){let N=this.sliceSerialize(S),_=this.stack[this.stack.length-2];_.label=Ao(N),_.identifier=bt(N).toLowerCase()}function le(){let S=this.stack[this.stack.length-1],N=this.resume(),_=this.stack[this.stack.length-1];if(this.data.inReference=!0,_.type==="link"){let K=S.children;_.children=K}else _.alt=N}function g(){let S=this.resume(),N=this.stack[this.stack.length-1];N.url=S}function je(){let S=this.resume(),N=this.stack[this.stack.length-1];N.title=S}function pt(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function Le(S){let N=this.resume(),_=this.stack[this.stack.length-1];_.label=N,_.identifier=bt(this.sliceSerialize(S)).toLowerCase(),this.data.referenceType="full"}function Qt(S){this.data.characterReferenceType=S.type}function tl(S){let N=this.sliceSerialize(S),_=this.data.characterReferenceType,K;_?(K=ko(N,_==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=tr(N);let Z=this.stack[this.stack.length-1];Z.value+=K}function Gi(S){let N=this.stack.pop();N.position.end=_t(S.end)}function ue(S){U.call(this,S);let N=this.stack[this.stack.length-1];N.url=this.sliceSerialize(S)}function Vr(S){U.call(this,S);let N=this.stack[this.stack.length-1];N.url="mailto:"+this.sliceSerialize(S)}function mt(){return{type:"blockquote",children:[]}}function Xt(){return{type:"code",lang:null,meta:null,value:""}}function Hn(){return{type:"inlineCode",value:""}}function nl(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function mg(){return{type:"emphasis",children:[]}}function wu(){return{type:"heading",depth:0,children:[]}}function Su(){return{type:"break"}}function Cu(){return{type:"html",value:""}}function gg(){return{type:"image",title:null,url:"",alt:null}}function Mu(){return{type:"link",title:null,url:"",children:[]}}function Nu(S){return{type:"list",ordered:S.type==="listOrdered",start:null,spread:S._spread,children:[]}}function yg(S){return{type:"listItem",spread:S._spread,checked:null,children:[]}}function xg(){return{type:"paragraph",children:[]}}function kg(){return{type:"strong",children:[]}}function bg(){return{type:"text",value:""}}function wg(){return{type:"thematicBreak"}}}function _t(n){return{line:n.line,column:n.column,offset:n.offset}}function uh(n,e){let t=-1;for(;++t<e.length;){let r=e[t];Array.isArray(r)?uh(n,r):fk(n,r)}}function fk(n,e){let t;for(t in e)if(ch.call(e,t))switch(t){case"canContainEols":{let r=e[t];r&&n[t].push(...r);break}case"transforms":{let r=e[t];r&&n[t].push(...r);break}case"enter":case"exit":{let r=e[t];r&&Object.assign(n[t],r);break}}}function ah(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+Ft({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+Ft({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ft({start:e.start,end:e.end})+") is still open")}function ir(n){let e=this;e.parser=t;function t(r){return Ql(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}var fh={}.hasOwnProperty;function hh(n,e){let t=e||{};function r(i,...o){let s=r.invalid,l=r.handlers;if(i&&fh.call(i,n)){let a=String(i[n]);s=fh.call(l,a)?l[a]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}var hk={}.hasOwnProperty;function Xl(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)Xl(n,e.extensions[t]);for(r in e)if(hk.call(e,r))switch(r){case"extensions":break;case"unsafe":{dh(n[r],e[r]);break}case"join":{dh(n[r],e[r]);break}case"handlers":{dk(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function dh(n,e){e&&n.push(...e)}function dk(n,e){e&&Object.assign(n,e)}function ph(n,e,t,r){let i=t.enter("blockquote"),o=t.createTracker(r);o.move("> "),o.shift(2);let s=t.indentLines(t.containerFlow(n,o.current()),pk);return i(),s}function pk(n,e,t){return">"+(t?"":" ")+n}function Ro(n,e){return mh(n,e.inConstruct,!0)&&!mh(n,e.notInConstruct,!1)}function mh(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 Zl(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===` 10 10 `&&Ro(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\ 11 11 `}function gh(n,e){let t=String(n),r=t.indexOf(e),i=r,o=0,s=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>s&&(s=o):o=1,i=r+e.length,r=t.indexOf(e,i);return s}function ai(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 yh(n){let e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function xh(n,e,t,r){let i=yh(t),o=n.value||"",s=i==="`"?"GraveAccent":"Tilde";if(ai(n,t)){let f=t.enter("codeIndented"),d=t.indentLines(o,mk);return f(),d}let l=t.createTracker(r),a=i.repeat(Math.max(gh(o,i)+1,3)),c=t.enter("codeFenced"),u=l.move(a);if(n.lang){let f=t.enter(`codeFencedLang${s}`);u+=l.move(t.safe(n.lang,{before:u,after:" ",encode:["`"],...l.current()})),f()}if(n.lang&&n.meta){let f=t.enter(`codeFencedMeta${s}`);u+=l.move(" "),u+=l.move(t.safe(n.meta,{before:u,after:` 12 12 `,encode:["`"],...l.current()})),f()}return u+=l.move(` 13 13 `),o&&(u+=l.move(o+` 14 14 `)),u+=l.move(a),c(),u}function mk(n,e,t){return(t?"":" ")+n}function or(n){let e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function kh(n,e,t,r){let i=or(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("definition"),l=t.enter("label"),a=t.createTracker(r),c=a.move("[");return c+=a.move(t.safe(t.associationId(n),{before:c,after:"]",...a.current()})),c+=a.move("]: "),l(),!n.url||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(t.safe(n.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=t.enter("destinationRaw"),c+=a.move(t.safe(n.url,{before:c,after:n.title?" ":` 15 - `,...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(t.safe(n.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),s(),c}function bh(n){let e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Ve(n){return"&#x"+n.toString(16).toUpperCase()+";"}function sr(n,e,t){let r=nr(n),i=nr(e);return r===void 0?i===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Zl.peek=gk;function Zl(n,e,t,r){let i=bh(t),o=t.enter("emphasis"),s=t.createTracker(r),l=s.move(i),a=s.move(t.containerPhrasing(n,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=sr(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ve(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=sr(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ve(f));let h=s.move(i);return o(),t.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function gk(n,e,t){return t.options.emphasis||"*"}var lr=(function(n){if(n==null)return bk;if(typeof n=="function")return vo(n);if(typeof n=="object")return Array.isArray(n)?yk(n):xk(n);if(typeof n=="string")return kk(n);throw new Error("Expected function, string, or object as test")});function yk(n){let e=[],t=-1;for(;++t<n.length;)e[t]=lr(n[t]);return vo(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function xk(n){let e=n;return vo(t);function t(r){let i=r,o;for(o in n)if(i[o]!==e[o])return!1;return!0}}function kk(n){return vo(e);function e(t){return t&&t.type===n}}function vo(n){return e;function e(t,r,i){return!!(wk(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function bk(){return!0}function wk(n){return n!==null&&typeof n=="object"&&"type"in n}var wh=[],Do=!0,xn=!1,kn="skip";function ci(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;let o=lr(i),s=r?-1:1;l(n,void 0,[])();function l(a,c,u){let f=a&&typeof a=="object"?a:{};if(typeof f.type=="string"){let h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(a.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=wh,p,m,k;if((!e||o(a,c,u[u.length-1]||void 0))&&(h=Sk(t(a,u)),h[0]===xn))return h;if("children"in a&&a.children){let x=a;if(x.children&&h[0]!==kn)for(m=(r?x.children.length:-1)+s,k=u.concat(x);m>-1&&m<x.children.length;){let I=x.children[m];if(p=l(I,m,k)(),p[0]===xn)return p;m=typeof p[1]=="number"?p[1]:m+s}}return h}}}function Sk(n){return Array.isArray(n)?n:typeof n=="number"?[Do,n]:n==null?wh:[n]}function et(n,e,t,r){let i,o,s;typeof e=="function"&&typeof t!="function"?(o=void 0,s=e,i=t):(o=e,s=t,i=r),ci(n,o,l,i);function l(a,c){let u=c[c.length-1],f=u?u.children.indexOf(a):void 0;return s(a,f,u)}}function Po(n,e){let t=!1;return et(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,xn}),!!((!n.depth||n.depth<3)&&pn(n)&&(e.options.setext||t))}function Sh(n,e,t,r){let i=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(r);if(Po(n,t)){let u=t.enter("headingSetext"),f=t.enter("phrasing"),d=t.containerPhrasing(n,{...o.current(),before:` 15 + `,...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(t.safe(n.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),s(),c}function bh(n){let e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Ve(n){return"&#x"+n.toString(16).toUpperCase()+";"}function sr(n,e,t){let r=nr(n),i=nr(e);return r===void 0?i===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}ea.peek=gk;function ea(n,e,t,r){let i=bh(t),o=t.enter("emphasis"),s=t.createTracker(r),l=s.move(i),a=s.move(t.containerPhrasing(n,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=sr(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ve(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=sr(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ve(f));let h=s.move(i);return o(),t.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function gk(n,e,t){return t.options.emphasis||"*"}var lr=(function(n){if(n==null)return bk;if(typeof n=="function")return vo(n);if(typeof n=="object")return Array.isArray(n)?yk(n):xk(n);if(typeof n=="string")return kk(n);throw new Error("Expected function, string, or object as test")});function yk(n){let e=[],t=-1;for(;++t<n.length;)e[t]=lr(n[t]);return vo(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function xk(n){let e=n;return vo(t);function t(r){let i=r,o;for(o in n)if(i[o]!==e[o])return!1;return!0}}function kk(n){return vo(e);function e(t){return t&&t.type===n}}function vo(n){return e;function e(t,r,i){return!!(wk(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function bk(){return!0}function wk(n){return n!==null&&typeof n=="object"&&"type"in n}var wh=[],Do=!0,xn=!1,kn="skip";function ci(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;let o=lr(i),s=r?-1:1;l(n,void 0,[])();function l(a,c,u){let f=a&&typeof a=="object"?a:{};if(typeof f.type=="string"){let h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(a.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=wh,p,m,k;if((!e||o(a,c,u[u.length-1]||void 0))&&(h=Sk(t(a,u)),h[0]===xn))return h;if("children"in a&&a.children){let x=a;if(x.children&&h[0]!==kn)for(m=(r?x.children.length:-1)+s,k=u.concat(x);m>-1&&m<x.children.length;){let I=x.children[m];if(p=l(I,m,k)(),p[0]===xn)return p;m=typeof p[1]=="number"?p[1]:m+s}}return h}}}function Sk(n){return Array.isArray(n)?n:typeof n=="number"?[Do,n]:n==null?wh:[n]}function et(n,e,t,r){let i,o,s;typeof e=="function"&&typeof t!="function"?(o=void 0,s=e,i=t):(o=e,s=t,i=r),ci(n,o,l,i);function l(a,c){let u=c[c.length-1],f=u?u.children.indexOf(a):void 0;return s(a,f,u)}}function Po(n,e){let t=!1;return et(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,xn}),!!((!n.depth||n.depth<3)&&pn(n)&&(e.options.setext||t))}function Sh(n,e,t,r){let i=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(r);if(Po(n,t)){let u=t.enter("headingSetext"),f=t.enter("phrasing"),d=t.containerPhrasing(n,{...o.current(),before:` 16 16 `,after:` 17 17 `});return f(),u(),d+` 18 18 `+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(` 19 19 `))+1))}let s="#".repeat(i),l=t.enter("headingAtx"),a=t.enter("phrasing");o.move(s+" ");let c=t.containerPhrasing(n,{before:"# ",after:` 20 - `,...o.current()});return/^[\t ]/.test(c)&&(c=Ve(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,t.options.closeAtx&&(c+=" "+s),a(),l(),c}ea.peek=Ck;function ea(n){return n.value||""}function Ck(){return"<"}ta.peek=Mk;function ta(n,e,t,r){let i=or(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("image"),l=t.enter("label"),a=t.createTracker(r),c=a.move("![");return c+=a.move(t.safe(n.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(t.safe(n.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=t.enter("destinationRaw"),c+=a.move(t.safe(n.url,{before:c,after:n.title?" ":")",...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(t.safe(n.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),s(),c}function Mk(){return"!"}na.peek=Nk;function na(n,e,t,r){let i=n.referenceType,o=t.enter("imageReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("!["),c=t.safe(n.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=t.stack;t.stack=[],s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Nk(){return"!"}ra.peek=Ik;function ra(n,e,t){let r=n.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<t.unsafe.length;){let s=t.unsafe[o],l=t.compilePattern(s),a;if(s.atBreak)for(;a=l.exec(r);){let c=a.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(a.index+1)}}return i+r+i}function Ik(){return"`"}function ia(n,e){let t=pn(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))}oa.peek=Tk;function oa(n,e,t,r){let i=or(t),o=i==='"'?"Quote":"Apostrophe",s=t.createTracker(r),l,a;if(ia(n,t)){let u=t.stack;t.stack=[],l=t.enter("autolink");let f=s.move("<");return f+=s.move(t.containerPhrasing(n,{before:f,after:">",...s.current()})),f+=s.move(">"),l(),t.stack=u,f}l=t.enter("link"),a=t.enter("label");let c=s.move("[");return c+=s.move(t.containerPhrasing(n,{before:c,after:"](",...s.current()})),c+=s.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(t.safe(n.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=t.enter("destinationRaw"),c+=s.move(t.safe(n.url,{before:c,after:n.title?" ":")",...s.current()}))),a(),n.title&&(a=t.enter(`title${o}`),c+=s.move(" "+i),c+=s.move(t.safe(n.title,{before:c,after:i,...s.current()})),c+=s.move(i),a()),c+=s.move(")"),l(),c}function Tk(n,e,t){return ia(n,t)?"<":"["}sa.peek=Ok;function sa(n,e,t,r){let i=n.referenceType,o=t.enter("linkReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("["),c=t.containerPhrasing(n,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=t.stack;t.stack=[],s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Ok(){return"["}function ar(n){let e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Ch(n){let e=ar(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 Mh(n){let e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Lo(n){let e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Nh(n,e,t,r){let i=t.enter("list"),o=t.bulletCurrent,s=n.ordered?Mh(t):ar(t),l=n.ordered?s==="."?")":".":Ch(t),a=e&&t.bulletLastUsed?s===t.bulletLastUsed:!1;if(!n.ordered){let u=n.children?n.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.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),Lo(t)===s&&u){let f=-1;for(;++f<n.children.length;){let d=n.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(s=l),t.bulletCurrent=s;let c=t.containerFlow(n,r);return t.bulletLastUsed=s,t.bulletCurrent=o,i(),c}function Ih(n){let 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 Th(n,e,t,r){let i=Ih(t),o=t.bulletCurrent||ar(t);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(s=Math.ceil(s/4)*4);let l=t.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);let a=t.enter("listItem"),c=t.indentLines(t.containerFlow(n,l.current()),u);return a(),c;function u(f,d,h){return d?(h?"":" ".repeat(s))+f:(h?o:o+" ".repeat(s-o.length))+f}}function Oh(n,e,t,r){let i=t.enter("paragraph"),o=t.enter("phrasing"),s=t.containerPhrasing(n,r);return o(),i(),s}var la=lr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Eh(n,e,t,r){return(n.children.some(function(s){return la(s)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function Ah(n){let e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}aa.peek=Ek;function aa(n,e,t,r){let i=Ah(t),o=t.enter("strong"),s=t.createTracker(r),l=s.move(i+i),a=s.move(t.containerPhrasing(n,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=sr(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ve(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=sr(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ve(f));let h=s.move(i+i);return o(),t.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function Ek(n,e,t){return t.options.strong||"*"}function Rh(n,e,t,r){return t.safe(n.value,r)}function vh(n){let 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 Dh(n,e,t){let r=(Lo(t)+(t.options.ruleSpaces?" ":"")).repeat(vh(t));return t.options.ruleSpaces?r.slice(0,-1):r}var Ph={blockquote:ph,break:Xl,code:xh,definition:kh,emphasis:Zl,hardBreak:Xl,heading:Sh,html:ea,image:ta,imageReference:na,inlineCode:ra,link:oa,linkReference:sa,list:Nh,listItem:Th,paragraph:Oh,root:Eh,strong:aa,text:Rh,thematicBreak:Dh};var Lh=[Ak];function Ak(n,e,t,r){if(e.type==="code"&&ai(e,r)&&(n.type==="list"||n.type===e.type&&ai(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"&&Po(e,r))?void 0:t.spread?1:0}var bn=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Bh=[{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:` 20 + `,...o.current()});return/^[\t ]/.test(c)&&(c=Ve(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,t.options.closeAtx&&(c+=" "+s),a(),l(),c}ta.peek=Ck;function ta(n){return n.value||""}function Ck(){return"<"}na.peek=Mk;function na(n,e,t,r){let i=or(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("image"),l=t.enter("label"),a=t.createTracker(r),c=a.move("![");return c+=a.move(t.safe(n.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(t.safe(n.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=t.enter("destinationRaw"),c+=a.move(t.safe(n.url,{before:c,after:n.title?" ":")",...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(t.safe(n.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),s(),c}function Mk(){return"!"}ra.peek=Nk;function ra(n,e,t,r){let i=n.referenceType,o=t.enter("imageReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("!["),c=t.safe(n.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=t.stack;t.stack=[],s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Nk(){return"!"}ia.peek=Ik;function ia(n,e,t){let r=n.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<t.unsafe.length;){let s=t.unsafe[o],l=t.compilePattern(s),a;if(s.atBreak)for(;a=l.exec(r);){let c=a.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(a.index+1)}}return i+r+i}function Ik(){return"`"}function oa(n,e){let t=pn(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))}sa.peek=Tk;function sa(n,e,t,r){let i=or(t),o=i==='"'?"Quote":"Apostrophe",s=t.createTracker(r),l,a;if(oa(n,t)){let u=t.stack;t.stack=[],l=t.enter("autolink");let f=s.move("<");return f+=s.move(t.containerPhrasing(n,{before:f,after:">",...s.current()})),f+=s.move(">"),l(),t.stack=u,f}l=t.enter("link"),a=t.enter("label");let c=s.move("[");return c+=s.move(t.containerPhrasing(n,{before:c,after:"](",...s.current()})),c+=s.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(t.safe(n.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=t.enter("destinationRaw"),c+=s.move(t.safe(n.url,{before:c,after:n.title?" ":")",...s.current()}))),a(),n.title&&(a=t.enter(`title${o}`),c+=s.move(" "+i),c+=s.move(t.safe(n.title,{before:c,after:i,...s.current()})),c+=s.move(i),a()),c+=s.move(")"),l(),c}function Tk(n,e,t){return oa(n,t)?"<":"["}la.peek=Ok;function la(n,e,t,r){let i=n.referenceType,o=t.enter("linkReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("["),c=t.containerPhrasing(n,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();let u=t.stack;t.stack=[],s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Ok(){return"["}function ar(n){let e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Ch(n){let e=ar(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 Mh(n){let e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Lo(n){let e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Nh(n,e,t,r){let i=t.enter("list"),o=t.bulletCurrent,s=n.ordered?Mh(t):ar(t),l=n.ordered?s==="."?")":".":Ch(t),a=e&&t.bulletLastUsed?s===t.bulletLastUsed:!1;if(!n.ordered){let u=n.children?n.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.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),Lo(t)===s&&u){let f=-1;for(;++f<n.children.length;){let d=n.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(s=l),t.bulletCurrent=s;let c=t.containerFlow(n,r);return t.bulletLastUsed=s,t.bulletCurrent=o,i(),c}function Ih(n){let 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 Th(n,e,t,r){let i=Ih(t),o=t.bulletCurrent||ar(t);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(s=Math.ceil(s/4)*4);let l=t.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);let a=t.enter("listItem"),c=t.indentLines(t.containerFlow(n,l.current()),u);return a(),c;function u(f,d,h){return d?(h?"":" ".repeat(s))+f:(h?o:o+" ".repeat(s-o.length))+f}}function Oh(n,e,t,r){let i=t.enter("paragraph"),o=t.enter("phrasing"),s=t.containerPhrasing(n,r);return o(),i(),s}var aa=lr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Eh(n,e,t,r){return(n.children.some(function(s){return aa(s)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function Ah(n){let e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}ca.peek=Ek;function ca(n,e,t,r){let i=Ah(t),o=t.enter("strong"),s=t.createTracker(r),l=s.move(i+i),a=s.move(t.containerPhrasing(n,{after:i,before:l,...s.current()})),c=a.charCodeAt(0),u=sr(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(a=Ve(c)+a.slice(1));let f=a.charCodeAt(a.length-1),d=sr(r.after.charCodeAt(0),f,i);d.inside&&(a=a.slice(0,-1)+Ve(f));let h=s.move(i+i);return o(),t.attentionEncodeSurroundingInfo={after:d.outside,before:u.outside},l+a+h}function Ek(n,e,t){return t.options.strong||"*"}function Rh(n,e,t,r){return t.safe(n.value,r)}function vh(n){let 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 Dh(n,e,t){let r=(Lo(t)+(t.options.ruleSpaces?" ":"")).repeat(vh(t));return t.options.ruleSpaces?r.slice(0,-1):r}var Ph={blockquote:ph,break:Zl,code:xh,definition:kh,emphasis:ea,hardBreak:Zl,heading:Sh,html:ta,image:na,imageReference:ra,inlineCode:ia,link:sa,linkReference:la,list:Nh,listItem:Th,paragraph:Oh,root:Eh,strong:ca,text:Rh,thematicBreak:Dh};var Lh=[Ak];function Ak(n,e,t,r){if(e.type==="code"&&ai(e,r)&&(n.type==="list"||n.type===e.type&&ai(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"&&Po(e,r))?void 0:t.spread?1:0}var bn=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Bh=[{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:` 21 21 `,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:bn},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r 22 22 ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:bn},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r 23 23 *])`},{character:"*",inConstruct:"phrasing",notInConstruct:bn},{atBreak:!0,character:"+",after:`(?:[ \r ··· 33 33 34 34 `}return` 35 35 36 - `}var vk=/\r?\n|\r/g;function $h(n,e){let t=[],r=0,i=0,o;for(;o=vk.exec(n);)s(n.slice(r,o.index)),t.push(o[0]),r=o.index+o[0].length,i++;return s(n.slice(r)),t.join("");function s(l){t.push(e(l,i,!l))}}function jh(n,e,t){let r=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={},l=-1;for(;++l<n.unsafe.length;){let u=n.unsafe[l];if(!Ro(n.stack,u))continue;let f=n.compilePattern(u),d;for(;d=f.exec(r);){let h="before"in u||!!u.atBreak,p="after"in u,m=d.index+(h?d[1].length:0);i.includes(m)?(s[m].before&&!h&&(s[m].before=!1),s[m].after&&!p&&(s[m].after=!1)):(i.push(m),s[m]={before:h,after:p})}}i.sort(Dk);let a=t.before?t.before.length:0,c=r.length-(t.after?t.after.length:0);for(l=-1;++l<i.length;){let u=i[l];u<a||u>=c||u+1<c&&i[l+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||i[l-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(a!==u&&o.push(Wh(r.slice(a,u),"\\")),a=u,/[!-/:-@[-`{-~]/.test(r.charAt(u))&&(!t.encode||!t.encode.includes(r.charAt(u)))?o.push("\\"):(o.push(Ve(r.charCodeAt(u))),a++))}return o.push(Wh(r.slice(a,c),t.after)),o.join("")}function Dk(n,e){return n-e}function Wh(n,e){let t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=n+e,s=-1,l=0,a;for(;a=t.exec(o);)r.push(a.index);for(;++s<r.length;)l!==r[s]&&i.push(n.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(n.slice(l)),i.join("")}function Hh(n){let e=n||{},t=e.now||{},r=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:a,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(c){r+=c}function a(c){let u=c||"",f=u.split(/\r?\n|\r/g),d=f[f.length-1];return i+=f.length-1,o=f.length===1?o+d.length:1+d.length+r,u}}function ca(n,e){let t=e||{},r={associationId:zh,containerPhrasing:zk,containerFlow:Fk,createTracker:Hh,compilePattern:Fh,enter:o,handlers:{...Ph},handle:void 0,indentLines:$h,indexStack:[],join:[...Lh],options:{},safe:_k,stack:[],unsafe:[...Bh]};Ql(r,t),r.options.tightDefinitions&&r.join.push(Bk),r.handle=hh("type",{invalid:Pk,unknown:Lk,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:` 36 + `}var vk=/\r?\n|\r/g;function $h(n,e){let t=[],r=0,i=0,o;for(;o=vk.exec(n);)s(n.slice(r,o.index)),t.push(o[0]),r=o.index+o[0].length,i++;return s(n.slice(r)),t.join("");function s(l){t.push(e(l,i,!l))}}function jh(n,e,t){let r=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={},l=-1;for(;++l<n.unsafe.length;){let u=n.unsafe[l];if(!Ro(n.stack,u))continue;let f=n.compilePattern(u),d;for(;d=f.exec(r);){let h="before"in u||!!u.atBreak,p="after"in u,m=d.index+(h?d[1].length:0);i.includes(m)?(s[m].before&&!h&&(s[m].before=!1),s[m].after&&!p&&(s[m].after=!1)):(i.push(m),s[m]={before:h,after:p})}}i.sort(Dk);let a=t.before?t.before.length:0,c=r.length-(t.after?t.after.length:0);for(l=-1;++l<i.length;){let u=i[l];u<a||u>=c||u+1<c&&i[l+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||i[l-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(a!==u&&o.push(Wh(r.slice(a,u),"\\")),a=u,/[!-/:-@[-`{-~]/.test(r.charAt(u))&&(!t.encode||!t.encode.includes(r.charAt(u)))?o.push("\\"):(o.push(Ve(r.charCodeAt(u))),a++))}return o.push(Wh(r.slice(a,c),t.after)),o.join("")}function Dk(n,e){return n-e}function Wh(n,e){let t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=n+e,s=-1,l=0,a;for(;a=t.exec(o);)r.push(a.index);for(;++s<r.length;)l!==r[s]&&i.push(n.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(n.slice(l)),i.join("")}function Hh(n){let e=n||{},t=e.now||{},r=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:a,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(c){r+=c}function a(c){let u=c||"",f=u.split(/\r?\n|\r/g),d=f[f.length-1];return i+=f.length-1,o=f.length===1?o+d.length:1+d.length+r,u}}function ua(n,e){let t=e||{},r={associationId:zh,containerPhrasing:zk,containerFlow:Fk,createTracker:Hh,compilePattern:Fh,enter:o,handlers:{...Ph},handle:void 0,indentLines:$h,indexStack:[],join:[...Lh],options:{},safe:_k,stack:[],unsafe:[...Bh]};Xl(r,t),r.options.tightDefinitions&&r.join.push(Bk),r.handle=hh("type",{invalid:Pk,unknown:Lk,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:` 37 37 `,after:` 38 38 `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=` 39 - `),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}function Pk(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Lk(n){let e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Bk(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function zk(n,e){return _h(n,this,e)}function Fk(n,e){return Vh(n,this,e)}function _k(n,e){return jh(this,n,e)}function cr(n){let e=this;e.compiler=t;function t(r){return ca(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function ua(n){if(n)throw n}var Fo=Ag(Zh(),1);function ui(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function fa(){let n=[],e={run:t,use:r};return e;function t(...i){let o=-1,s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(a,...c){let u=n[++o],f=-1;if(a){s(a);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,u?ed(u,l)(...c):s(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function ed(n,e){let t;return r;function r(...s){let l=n.length>s.length,a;l&&s.push(i);try{a=n.apply(this,s)}catch(c){let u=c;if(l&&t)throw u;return i(u)}l||(a&&a.then&&typeof a.then=="function"?a.then(o,i):a instanceof Error?i(a):o(a))}function i(s,...l){t||(t=!0,e(s,...l))}function o(s){i(null,s)}}var ce=class extends Error{constructor(e,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},s=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){let a=r.indexOf(":");a===-1?o.ruleId=r:(o.source=r.slice(0,a),o.ruleId=r.slice(a+1))}if(!o.place&&o.ancestors&&o.ancestors){let a=o.ancestors[o.ancestors.length-1];a&&(o.place=a.position)}let l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Ft(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ce.prototype.file="";ce.prototype.name="";ce.prototype.reason="";ce.prototype.message="";ce.prototype.stack="";ce.prototype.column=void 0;ce.prototype.line=void 0;ce.prototype.ancestors=void 0;ce.prototype.cause=void 0;ce.prototype.fatal=void 0;ce.prototype.place=void 0;ce.prototype.ruleId=void 0;ce.prototype.source=void 0;var tt={basename:Vk,dirname:$k,extname:Wk,join:jk,sep:"/"};function Vk(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');fi(n);let t=0,r=-1,i=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":n.slice(t,r)}if(e===n)return"";let s=-1,l=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(n.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return t===r?r=s:r<0&&(r=n.length),n.slice(t,r)}function $k(n){if(fi(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 Wk(n){fi(n);let e=n.length,t=-1,r=0,i=-1,o=0,s;for(;e--;){let l=n.codePointAt(e);if(l===47){if(s){r=e+1;break}continue}t<0&&(s=!0,t=e+1),l===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||t<0||o===0||o===1&&i===t-1&&i===r+1?"":n.slice(i,t)}function jk(...n){let e=-1,t;for(;++e<n.length;)fi(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Hk(t)}function Hk(n){fi(n);let e=n.codePointAt(0)===47,t=qk(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function qk(n,e){let t="",r=0,i=-1,o=0,s=-1,l,a;for(;++s<=n.length;){if(s<n.length)l=n.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(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=s,o=0;continue}}else if(t.length>0){t="",r=0,i=s,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+n.slice(i+1,s):t=n.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return t}function fi(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}var td={cwd:Kk};function Kk(){return"/"}function ur(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function nd(n){if(typeof n=="string")n=new URL(n);else if(!ur(n)){let 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:"){let e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Uk(n)}function Uk(n){if(n.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let e=n.pathname,t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){let r=e.codePointAt(t+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}var ha=["history","path","basename","stem","extname","dirname"],hi=class{constructor(e){let t;e?ur(e)?t={path:e}:typeof e=="string"||Jk(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":td.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ha.length;){let o=ha[r];o in t&&t[o]!==void 0&&t[o]!==null&&(this[o]=o==="history"?[...t[o]]:t[o])}let i;for(i in t)ha.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?tt.basename(this.path):void 0}set basename(e){pa(e,"basename"),da(e,"basename"),this.path=tt.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?tt.dirname(this.path):void 0}set dirname(e){rd(this.basename,"dirname"),this.path=tt.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?tt.extname(this.path):void 0}set extname(e){if(da(e,"extname"),rd(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=tt.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){ur(e)&&(e=nd(e)),pa(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?tt.basename(this.path,this.extname):void 0}set stem(e){pa(e,"stem"),da(e,"stem"),this.path=tt.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){let i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){let i=new ce(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 da(n,e){if(n&&n.includes(tt.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+tt.sep+"`")}function pa(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function rd(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Jk(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var id=(function(n){let r=this.constructor.prototype,i=r[n],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o});var Gk={}.hasOwnProperty,xa=class n extends id{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=fa()}copy(){let e=new n,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];e.use(...r)}return e.data((0,Fo.default)(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(ya("data",this.frozen),this.namespace[e]=t,this):Gk.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ya("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let 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();let t=zo(e),r=this.parser||this.Parser;return ma("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),ma("process",this.parser||this.Parser),ga("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,s){let l=zo(e),a=r.parse(l);r.run(a,l,function(u,f,d){if(u||!f||!d)return c(u);let h=f,p=r.stringify(h,d);Qk(p)?d.value=p:d.result=p,c(u,d)});function c(u,f){u||!f?s(u):o?o(f):t(void 0,f)}}}processSync(e){let t=!1,r;return this.freeze(),ma("processSync",this.parser||this.Parser),ga("processSync",this.compiler||this.Compiler),this.process(e,i),sd("processSync","process",t),r;function i(o,s){t=!0,ua(o),r=s}}run(e,t,r){od(e),this.freeze();let i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(s,l){let a=zo(t);i.run(e,a,c);function c(u,f,d){let h=f||e;u?l(u):s?s(h):r(void 0,h,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,o),sd("runSync","run",r),i;function o(s,l){ua(s),i=l,r=!0}}stringify(e,t){this.freeze();let r=zo(t),i=this.compiler||this.Compiler;return ga("stringify",i),od(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(ya("use",this.frozen),e!=null)if(typeof e=="function")a(e,t);else if(typeof e=="object")Array.isArray(e)?l(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(c){if(typeof c=="function")a(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[u,...f]=c;a(u,f)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=(0,Fo.default)(!0,i.settings,c.settings))}function l(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){let f=c[u];o(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,u){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===c){d=f;break}if(d===-1)r.push([c,...u]);else if(u.length>0){let[h,...p]=u,m=r[d][1];ui(m)&&ui(h)&&(h=(0,Fo.default)(!0,m,h)),r[d]=[c,h,...p]}}}},di=new xa().freeze();function ma(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function ga(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function ya(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 od(n){if(!ui(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function sd(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function zo(n){return Yk(n)?n:new hi(n)}function Yk(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Qk(n){return typeof n=="string"||Xk(n)}function Xk(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var ad=n=>{throw TypeError(n)},cd=(n,e,t)=>e.has(n)||ad("Cannot "+t),H=(n,e,t)=>(cd(n,e,"read from private field"),t?t.call(n):e.get(n)),oe=(n,e,t)=>e.has(n)?ad("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ee=(n,e,t,r)=>(cd(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),st,pi,_o,Vo,$o,mi,gi,wt,yi,Wo,jo,xi,Ho,ki,qo,Ko,fr,wn,Uo,bi,Jo=class{},Go=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw rl();return e}}},ka=class n extends Jo{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 n(e,t,r)}},ba=class extends Go{constructor(e){super(),oe(this,st),oe(this,pi),oe(this,_o),oe(this,Vo),oe(this,$o),oe(this,mi),oe(this,gi),ee(this,st,q.none),ee(this,pi,t=>t.isText),ee(this,_o,(t,r)=>{if(H(this,pi).call(this,t)&&H(this,pi).call(this,r)&&q.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)}),ee(this,Vo,t=>{let r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw Au(t);return r}),ee(this,$o,t=>{let r=H(this,Vo).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(ka.create(t,[],r)),this),ee(this,mi,()=>{ee(this,st,q.none);let t=this.close();return H(this,gi).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>{try{H(this,mi).call(this)}catch(t){console.error(t)}return this},ee(this,gi,(t,r,i)=>{let o=t.createAndFill(r,i,H(this,st));if(!o)throw Eu(t,r,i);return this.push(o),o}),this.addNode=(t,r,i)=>{try{H(this,gi).call(this,t,r,i)}catch(o){console.error(o)}return this},this.openMark=(t,r)=>{let i=t.create(r);return ee(this,st,i.addToSet(H(this,st))),this},this.closeMark=t=>(ee(this,st,t.removeFromSet(H(this,st))),this),this.addText=t=>{try{let r=this.top();if(!r)throw rl();let i=r.pop(),o=this.schema.text(t,H(this,st));if(!i)return r.push(o),this;let s=H(this,_o).call(this,i,o);return s?(r.push(s),this):(r.push(i,o),this)}catch(r){return console.error(r),this}},this.build=()=>{let t;do t=H(this,mi).call(this);while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(r=>H(this,$o).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(t,r)=>{let i=t.runSync(t.parse(r),r);return this.next(i),this},this.schema=e}};st=new WeakMap;pi=new WeakMap;_o=new WeakMap;Vo=new WeakMap;$o=new WeakMap;mi=new WeakMap;gi=new WeakMap;ba.create=(n,e)=>{let t=new ba(n);return r=>(t.run(e,r),t.toDoc())};var ud=ba,wa=class extends Jo{constructor(e,t,r,i={}){super(),this.type=e,this.children=t,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>this.children?.pop()}};wa.create=(n,e,t,r={})=>new wa(n,e,t,r);var ld=wa,Zk=n=>Object.prototype.hasOwnProperty.call(n,"size"),Sa=class extends Go{constructor(e){super(),oe(this,wt),oe(this,yi),oe(this,Wo),oe(this,jo),oe(this,xi),oe(this,Ho),oe(this,ki),oe(this,qo),oe(this,Ko),oe(this,fr),oe(this,wn),oe(this,Uo),oe(this,bi),ee(this,wt,q.none),ee(this,yi,t=>{let r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Ru(t.type);return r}),ee(this,Wo,t=>H(this,yi).call(this,t).spec.toMarkdown.runner(this,t)),ee(this,jo,(t,r)=>H(this,yi).call(this,t).spec.toMarkdown.runner(this,t,r)),ee(this,xi,t=>{let{marks:r}=t,i=l=>l.type.spec.priority??50;[...r].sort((l,a)=>i(l)-i(a)).every(l=>!H(this,jo).call(this,l,t))&&H(this,Wo).call(this,t),r.forEach(l=>H(this,bi).call(this,l))}),ee(this,Ho,(t,r)=>{if(t.type===r||t.children?.length!==1)return t;let i=a=>{if(a.type===r)return a;if(a.children?.length!==1)return null;let[c]=a.children;return c?i(c):null},o=i(t);if(!o)return t;let s=o.children?[...o.children]:void 0,l={...t,children:s};return l.children=s,o.children=[l],o}),ee(this,ki,t=>{let{children:r}=t;return r&&(t.children=r.reduce((i,o,s)=>{if(s===0)return[o];let l=i.at(-1);if(l&&l.isMark&&o.isMark){o=H(this,Ho).call(this,o,l.type);let{children:a,...c}=o,{children:u,...f}=l;if(o.type===l.type&&a&&u&&JSON.stringify(c)===JSON.stringify(f)){let d={...f,children:[...u,...a]};return i.slice(0,-1).concat(H(this,ki).call(this,d))}}return i.concat(o)},[])),t}),ee(this,qo,t=>{let 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(ld.create(t,void 0,r,i)),this),ee(this,Ko,(t,r)=>{let i="",o="",s=t.children,l=-1,a=-1,c=f=>{f&&f.forEach((d,h)=>{d.type==="text"&&d.value&&(l<0&&(l=h),a=h)})};if(s){c(s);let f=s?.[a],d=s?.[l];if(f&&f.value.endsWith(" ")){let h=f.value,p=h.trimEnd();o=h.slice(p.length),f.value=p}if(d&&d.value.startsWith(" ")){let h=d.value,p=h.trimStart();i=h.slice(0,h.length-p.length),d.value=p}}i.length&&H(this,wn).call(this,"text",void 0,i);let u=r();return o.length&&H(this,wn).call(this,"text",void 0,o),u}),ee(this,fr,(t=!1)=>{let r=this.close(),i=()=>H(this,wn).call(this,r.type,r.children,r.value,r.props);return t?H(this,Ko).call(this,r,i):i()}),this.closeNode=()=>(H(this,fr).call(this),this),ee(this,wn,(t,r,i,o)=>{let s=ld.create(t,r,i,o),l=H(this,ki).call(this,H(this,qo).call(this,s));return this.push(l),l}),this.addNode=(t,r,i,o)=>(H(this,wn).call(this,t,r,i,o),this),ee(this,Uo,(t,r,i,o)=>t.isInSet(H(this,wt))?this:(ee(this,wt,t.addToSet(H(this,wt))),this.openNode(r,i,{...o,isMark:!0}))),ee(this,bi,t=>{t.isInSet(H(this,wt))&&(ee(this,wt,t.type.removeFromSet(H(this,wt))),H(this,fr).call(this,!0))}),this.withMark=(t,r,i,o)=>(H(this,Uo).call(this,t,r,i,o),this),this.closeMark=t=>(H(this,bi).call(this,t),this),this.build=()=>{let t=null;do t=H(this,fr).call(this);while(this.size());return t},this.next=t=>Zk(t)?(t.forEach(r=>{H(this,xi).call(this,r)}),this):(H(this,xi).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};wt=new WeakMap;yi=new WeakMap;Wo=new WeakMap;jo=new WeakMap;xi=new WeakMap;Ho=new WeakMap;ki=new WeakMap;qo=new WeakMap;Ko=new WeakMap;fr=new WeakMap;wn=new WeakMap;Uo=new WeakMap;bi=new WeakMap;Sa.create=(n,e)=>{let t=new Sa(n);return r=>(t.run(r),t.toString(e))};var fd=Sa;var Ne=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?eb(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function eb(n){return function(e,t,r,i){let o=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),r+=s;let l=r-i;l>0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var hd=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],o;if(i.spec.isInputRules&&(o=i.getState(n))){if(e){let s=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},rE=new Ne(/--$/,"\u2014",{inCodeMark:!1}),iE=new Ne(/\.\.\.$/,"\u2026",{inCodeMark:!1}),oE=new Ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),sE=new Ne(/"$/,"\u201D",{inCodeMark:!1}),lE=new Ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),aE=new Ne(/'$/,"\u2019",{inCodeMark:!1});function Yo(n,e,t=null,r){return new Ne(n,(i,o,s,l)=>{let a=t instanceof Function?t(o):t,c=i.tr.delete(s,l),u=c.doc.resolve(s),f=u.blockRange(),d=f&&cn(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==e&&fn(c.doc,s-1)&&(!r||r(o,h))&&c.join(s-1),c})}function Ca(n,e,t=null){return new Ne(n,(r,i,o,s)=>{let l=r.doc.resolve(o),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,a):null})}var Vt=typeof navigator<"u"?navigator:null,dd=typeof document<"u"?document:null,$t=Vt&&Vt.userAgent||"",Na=/Edge\/(\d+)/.exec($t),xd=/MSIE \d/.exec($t),Ia=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($t),Ta=!!(xd||Ia||Na),hE=xd?document.documentMode:Ia?+Ia[1]:Na?+Na[1]:0,tb=!Ta&&/gecko\/(\d+)/i.test($t),dE=tb&&+(/Firefox\/(\d+)/.exec($t)||[0,0])[1],pd=!Ta&&/Chrome\/(\d+)/.exec($t);var pE=pd?+pd[1]:0,nb=!Ta&&!!Vt&&/Apple Computer/.test(Vt.vendor),rb=nb&&(/Mobile\/\w+/.test($t)||!!Vt&&Vt.maxTouchPoints>2),mE=rb||(Vt?/Mac/.test(Vt.platform):!1),gE=/Android \d/.test($t),ib=!!dd&&"webkitFontSmoothing"in dd.documentElement.style,yE=ib?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ma(n,e,t,r,i,o){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"\uFFFC")+r;for(let c of i){let u=c,f=u.match.exec(a),d=f&&f[0]&&u.handler(s,f,e-(f[0].length-r.length),t);if(d)return u.undoable!==!1&&d.setMeta(o,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}var ob=new re("MILKDOWN_CUSTOM_INPUTRULES");function kd({rules:n}){let e=new ne({key:ob,isInputRules:!0,state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,o){return Ma(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Ma(t,r.pos,r.pos,"",n,e)}),!1)},handleKeyDown(t,r){if(r.key!=="Enter")return!1;let{$cursor:i}=t.state.selection;return i?Ma(t,i.pos,i.pos,` 40 - `,n,e):!1}}});return e}function wi(n,e,t={}){return new Ne(n,(r,i,o,s)=>{var l,a,c,u;let{tr:f}=r,d=i.length,h=i[d-1],p=i[0],m=[],k=s,x={group:h,fullMatch:p,start:o,end:s},I=(l=t.updateCaptured)==null?void 0:l.call(t,x);if(Object.assign(x,I),{group:h,fullMatch:p,start:o,end:s}=x,p===null||h?.trim()==="")return null;if(h){let C=p.search(/\S/),A=o+p.indexOf(h),v=A+h.length;m=(a=f.storedMarks)!=null?a:[],v<s&&f.delete(v,s),A>o&&f.delete(o+C,A),k=o+C+h.length;let b=(c=t.getAttr)==null?void 0:c.call(t,i);f.addMark(o,k,e.create(b)),f.setStoredMarks(m),(u=t.beforeDispatch)==null||u.call(t,{match:i,start:o,end:s,tr:f})}return f})}var sb=Object.defineProperty,lb=Object.defineProperties,ab=Object.getOwnPropertyDescriptors,md=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,gd=(n,e,t)=>e in n?sb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,fb=(n,e)=>{for(var t in e||(e={}))cb.call(e,t)&&gd(n,t,e[t]);if(md)for(var t of md(e))ub.call(e,t)&&gd(n,t,e[t]);return n},hb=(n,e)=>lb(n,ab(e));function yd(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function bd(n,e,t){let i=n.state.doc.content.size,o=yd(e,0,i),s=yd(t,0,i),l=n.coordsAtPos(o),a=n.coordsAtPos(s,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-f,p=u-c,x={top:c,bottom:u,left:f,right:d,width:h,height:p,x:f,y:c};return hb(fb({},x),{toJSON:()=>x})}function db(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function wd(n,e){if(!(n instanceof B))return;let{node:t,$from:r}=n;if(db(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}var Sd=(n,e)=>{let{selection:t,doc:r}=n;if(t instanceof B)return{hasNode:t.node.type===e,pos:t.from,target:t.node};let{from:i,to:o}=t,s=!1,l=-1,a=null;return r.nodesBetween(i,o,(c,u)=>a?!1:c.type===e?(s=!0,l=u,a=c,!1):!0),{hasNode:s,pos:l,target:a}};var St={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:"'"},Xo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pb=typeof navigator<"u"&&/Mac/.test(navigator.platform),mb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(se=0;se<10;se++)St[48+se]=St[96+se]=String(se);var se;for(se=1;se<=24;se++)St[se+111]="F"+se;var se;for(se=65;se<=90;se++)St[se]=String.fromCharCode(se+32),Xo[se]=String.fromCharCode(se);var se;for(Qo in St)Xo.hasOwnProperty(Qo)||(Xo[Qo]=St[Qo]);var Qo;function Cd(n){var e=pb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||mb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Xo:St)[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}var gb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),yb=typeof navigator<"u"&&/Win/.test(navigator.platform);function xb(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))gb?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function kb(n){let e=Object.create(null);for(let t in n)e[xb(t)]=n[t];return e}function Oa(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 Md(n){return new ne({props:{handleKeyDown:bb(n)}})}function bb(n){let e=kb(n);return function(t,r){let i=Cd(r),o,s=e[Oa(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Oa(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(yb&&r.ctrlKey&&r.altKey)&&(o=St[r.keyCode])&&o!=i){let l=e[Oa(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var pe=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},Pa=null,Mt=function(n,e,t){let r=Pa||(Pa=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},wb=function(){Pa=null},On=function(n,e,t,r){return t&&(Nd(n,e,t,r,-1)||Nd(n,e,t,r,1))},Sb=/^(img|br|input|textarea|hr)$/i;function Nd(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ke(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Ei(n)||Sb.test(n.nodeName)||n.contentEditable=="false")return!1;e=pe(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cb(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=Ke(n)}else if(n.parentNode&&!Ei(n))e=pe(n),n=n.parentNode;else return null}}function Mb(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&&!Ei(n))e=pe(n)+1,n=n.parentNode;else return null}}function Nb(n,e,t){for(let r=e==0,i=e==Ke(n);r||i;){if(n==t)return!0;let o=pe(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Ke(n)}}function Ei(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)}var us=function(n){return n.focusNode&&On(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Sn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ib(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Tb(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}var lt=typeof navigator<"u"?navigator:null,Id=typeof document<"u"?document:null,Ut=lt&&lt.userAgent||"",La=/Edge\/(\d+)/.exec(Ut),ip=/MSIE \d/.exec(Ut),Ba=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ut),Re=!!(ip||Ba||La),qt=ip?document.documentMode:Ba?+Ba[1]:La?+La[1]:0,Ue=!Re&&/gecko\/(\d+)/i.test(Ut);Ue&&+(/Firefox\/(\d+)/.exec(Ut)||[0,0])[1];var za=!Re&&/Chrome\/(\d+)/.exec(Ut),me=!!za,op=za?+za[1]:0,we=!Re&&!!lt&&/Apple Computer/.test(lt.vendor),yr=we&&(/Mobile\/\w+/.test(Ut)||!!lt&&lt.maxTouchPoints>2),qe=yr||(lt?/Mac/.test(lt.platform):!1),sp=lt?/Win/.test(lt.platform):!1,Nt=/Android \d/.test(Ut),Ai=!!Id&&"webkitFontSmoothing"in Id.documentElement.style,Ob=Ai?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Eb(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 Ct(n,e){return typeof n=="number"?n:n[e]}function Ab(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 Td(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=gr(s);continue}let l=s,a=l==o.body,c=a?Eb(o):Ab(l),u=0,f=0;if(e.top<c.top+Ct(r,"top")?f=-(c.top-e.top+Ct(i,"top")):e.bottom>c.bottom-Ct(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ct(i,"top")-c.top:e.bottom-c.bottom+Ct(i,"bottom")),e.left<c.left+Ct(r,"left")?u=-(c.left-e.left+Ct(i,"left")):e.right>c.right-Ct(r,"right")&&(u=e.right-c.right+Ct(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,k=l.scrollTop-p;e={left:e.left-m,top:e.top-k,right:e.right-m,bottom:e.bottom-k}}let d=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:gr(s)}}function Rb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(o,s);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:lp(n.dom)}}function lp(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 vb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ap(t,r==0?0:r-e)}function ap(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}var hr=null;function Db(n){if(n.setActive)return n.setActive();if(hr)return n.focus(hr);let e=lp(n);n.focus(hr==null?{get preventScroll(){return hr={preventScroll:!0},!0}}:void 0),hr||(hr=!1,ap(e,0))}function cp(n,e){let t,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Mt(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=u,r=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Pb(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:cp(t,i)}function Pb(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=Wt(r,1);if(s.top!=s.bottom&&Xa(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Xa(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Lb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Bb(n,e,t){let{node:r,offset:i}=cp(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function zb(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function up(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)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Xa(e,c))return up(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function Fb(n,e){let t=n.dom.ownerDocument,r,i=0,o=Tb(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Xa(e,c)||(s=up(n.dom,e,c),!s))return null}if(we)for(let c=s;r&&c;c=gr(c))c.draggable&&(r=void 0);if(s=Lb(s,e),r){if(Ue&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Ai&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.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=zb(n,r,i,e))}l==null&&(l=Bb(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Od(n){return n.top<n.bottom||n.left<n.right}function Wt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Od(r))return r}return Array.prototype.find.call(t,Od)||n.getBoundingClientRect()}var _b=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fp(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Ai||Ue;if(r.nodeType==3)if(s&&(_b.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Wt(Mt(r,i,i),t);if(Ue&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Wt(Mt(r,i-1,i-1),-1);if(c.top==a.top){let u=Wt(Mt(r,i,i+1),-1);if(u.top!=a.top)return Si(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Si(Wt(Mt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Ke(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ea(a.getBoundingClientRect(),!1)}if(o==null&&i<Ke(r)){let a=r.childNodes[i];if(a.nodeType==1)return Ea(a.getBoundingClientRect(),!0)}return Ea(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==Ke(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Mt(a,Ke(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Si(Wt(c,1),!1)}if(o==null&&i<Ke(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Mt(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Si(Wt(c,-1),!0)}return Si(Wt(r.nodeType==3?Mt(r):r,-t),t>=0)}function Si(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 Ea(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 hp(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 Vb(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return hp(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=fp(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Mt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var $b=/[\u0590-\u08ac]/;function Wb(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!$b.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:hp(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),k=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),k}):r.pos==r.start()||r.pos==r.end()}var Ed=null,Ad=null,Rd=!1;function jb(n,e,t){return Ed==e&&Ad==t?Rd:(Ed=e,Ad=t,Rd=t=="up"||t=="down"?Vb(n,e,t):Wb(n,e,t))}var Je=0,vd=1,Cn=2,at=3,En=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Je,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 o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>pe(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 o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let 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 o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof ts){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Zo&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?pe(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?pe(o.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,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=pe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=pe(f.dom);break}t+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}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 o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],k=p+m.size;if(o>p&&s<k)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ue||we)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==` 41 - `),f&&p==h.nodeValue.length)for(let m=h,k;m;m=m.parentNode){if(k=m.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:pe(k)+1});break}let x=m.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ue&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&we)&&On(l.node,l.offset,u.anchorNode,u.anchorOffset)&&On(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(f&&Ue)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Cn:vd,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=at:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Cn:at}r=s}this.dirty=Cn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Cn:vd;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Zo=class extends En{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Je&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Fa=class extends En{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}},xr=class n extends En{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=sn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Je){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Je}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=Wa(o,t,s,r)),e>0&&(o=Wa(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Kt=class n extends En{constructor(e,t,r,i,o,s,l,a,c){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=sn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=mp(u,r,t),c?a=new _a(e,t,r,i,u,f||null,d,c,o,s+1):t.isText?new es(e,t,r,i,u,d,o):new n(e,t,r,i,u,f||null,d,o,s+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=()=>M.empty)}return e}matchesNode(e,t,r){return this.dirty==Je&&e.eq(this.node)&&ns(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,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new $a(this,s&&s.node,e);Ub(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?q.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e,d);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Cn)&&(s&&this.protectLocalComposition(e,s),dp(this.contentDOM,this.children,e),yr&&Jb(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof j)||r<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Gb(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Fa(this,o,t,i);e.input.compositionNodes.push(s),this.children=Wa(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==at||!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=Je}updateOuterDeco(e){if(ns(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=pp(this.dom,this.nodeDOM,Va(this.outerDeco,this.node,t),Va(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Dd(n,e,t,r,i){mp(r,e,n);let o=new Kt(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var es=class n extends Kt{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,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==at||this.dirty!=Je&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Je||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=Je,!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),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}},ts=class extends En{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Je&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},_a=class extends Kt{constructor(e,t,r,i,o,s,l,a,c,u){super(e,t,r,i,o,s,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function dp(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Pd(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(s instanceof xr){let a=r?r.previousSibling:n.lastChild;dp(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Pd(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var Ci=function(n){n&&(this.nodeName=n)};Ci.prototype=Object.create(null);var Mn=[new Ci];function Va(n,e,t){if(n.length==0)return Mn;let r=t?Mn[0]:new Ci,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new Ci(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(r=new Ci(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 pp(n,e,t,r){if(t==Mn&&r==Mn)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Mn[0]),i=a}Hb(i,l||Mn[0],s)}return i}function Hb(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 o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);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 mp(n,e,t){return pp(n,n,Mn,Va(e,t,n.nodeType!=1))}function ns(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 Pd(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var $a=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=qb(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,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Je,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=xr.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==at&&s.dom==s.contentDOM&&(s.dirty=Cn),s.update(e,t,r,o)?(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,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Kt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=at&&ns(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Cn,f.updateChildren(i,s+1),f.dirty=Je),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ns(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Kt.create(this.top,t,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,o){let s=Kt.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),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 o=new Zo(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof xr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof es)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((we||me)&&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 ts(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 qb(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof xr)t=c,r=c.children.length;else{l=c,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,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Kb(n,e){return n.type.side-e.type.side}function Ub(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let k=i[s++];k.widget&&(u?(f||(f=[u])).push(k):u=k)}if(u)if(f){f.sort(Kb);for(let k=0;k<f.length;k++)t(f[k],c,!!a)}else t(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<n.childCount)h=c,d=n.child(c++);else break;for(let k=0;k<l.length;k++)l[k].to<=o&&l.splice(k--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let k=p;s<i.length&&i[s].from<k&&(k=i[s].from);for(let x=0;x<l.length;x++)l[x].to<k&&(k=l[x].to);k<p&&(a=d.cut(k-o),d=d.cut(0,k-o),p=k,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let m=d.isInline&&!d.isLeaf?l.filter(k=>!k.inline):l.slice();r(d,m,e.forChild(o,d),h),o=p}}function Jb(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 Gb(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<n.childCount;){let c=n.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Wa(n,e,t,r,i){let o=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>t&&o.push(a.slice(t-c,a.size,r)))}return o}function Za(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(us(t)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&B.isSelectable(f)&&i.parent&&!(f.isInline&&Nb(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new B(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=ec(n,u,l,f)}return c}function gp(n){return n.editable?n.hasFocus():xp(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function It(n,e=!1){let t=n.state.selection;if(yp(n,t),!!gp(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&me){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&On(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Qb(n);else{let{anchor:r,head:i}=t,o,s;Ld&&!(t instanceof j)&&(t.$from.parent.inlineContent||(o=Bd(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Bd(n,t.to))),n.docView.setSelection(r,i,n,e),Ld&&(o&&zd(o),s&&zd(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Yb(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}var Ld=we||me&&op<63;function Bd(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(we&&i&&i.contentEditable=="false")return Aa(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Aa(i);if(o)return Aa(o)}}function Aa(n){return n.contentEditable="true",we&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function zd(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Yb(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(()=>{(!gp(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Qb(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,pe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Re&&qt<=11&&(t.disabled=!0,t.disabled=!1)}function yp(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Fd(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Fd(n)}function Fd(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ec(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||j.between(e,t,r)}function _d(n){return n.editable&&!n.hasFocus()?!1:xp(n)}function xp(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 Xb(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return On(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ja(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&W.findFrom(o,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Vd(n,e,t){let r=n.state.selection;if(r instanceof j)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return jt(n,new j(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=ja(n.state,e);return i&&i instanceof B?jt(n,i):!1}else if(!(qe&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?B.isSelectable(o)?jt(n,new B(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Ai?jt(n,new j(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return jt(n,new j(e>0?r.$to:r.$from));{let i=ja(n.state,e);return i?jt(n,i):!1}}}function rs(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dr(n,e){return e<0?Zb(n):ew(n)}function Zb(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Ue&&t.nodeType==1&&r<rs(t)&&Mi(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Mi(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(kp(t))break;{let l=t.previousSibling;for(;l&&Mi(l,-1);)i=t.parentNode,o=pe(l),l=l.previousSibling;if(l)t=l,r=rs(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Ha(n,t,r):i&&Ha(n,i,o)}function ew(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=rs(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Mi(l,1))o=t,s=++r;else break}else{if(kp(t))break;{let l=t.nextSibling;for(;l&&Mi(l,1);)o=l.parentNode,s=pe(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=rs(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&Ha(n,o,s)}function kp(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function tw(n,e){for(;n&&e==n.childNodes.length&&!Ei(n);)e=pe(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 nw(n,e){for(;n&&!e&&!Ei(n);)e=pe(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 Ha(n,e,t){if(e.nodeType!=3){let o,s;(s=tw(e,t))?(e=s,t=0):(o=nw(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(us(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&It(n)},50)}function $d(n,e){let t=n.state.doc.resolve(e);if(!(me||sp)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Wd(n,e,t){let r=n.state.selection;if(r instanceof j&&!r.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=ja(n.state,e);if(s&&s instanceof B)return jt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Fe?W.near(s,e):W.findFrom(s,e);return l?jt(n,l):!1}return!1}function jd(n,e){if(!(n.state.selection instanceof j))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 o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Hd(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function rw(n){if(!we||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;Hd(n,r,"true"),setTimeout(()=>Hd(n,r,"false"),20)}return!1}function iw(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ow(n,e){let t=e.keyCode,r=iw(e);if(t==8||qe&&t==72&&r=="c")return jd(n,-1)||dr(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&r=="c")return jd(n,1)||dr(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&r=="c"){let i=t==37?$d(n,n.state.selection.from)=="ltr"?-1:1:-1;return Vd(n,i,r)||dr(n,i)}else if(t==39||qe&&t==70&&r=="c"){let i=t==39?$d(n,n.state.selection.from)=="ltr"?1:-1:1;return Vd(n,i,r)||dr(n,i)}else{if(t==38||qe&&t==80&&r=="c")return Wd(n,-1,r)||dr(n,-1);if(t==40||qe&&t==78&&r=="c")return rw(n)||Wd(n,1,r)||dr(n,1);if(r==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function tc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||sn.fromSchema(n.state.schema),l=Np(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Mp[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` 39 + `),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}function Pk(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Lk(n){let e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Bk(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function zk(n,e){return _h(n,this,e)}function Fk(n,e){return Vh(n,this,e)}function _k(n,e){return jh(this,n,e)}function cr(n){let e=this;e.compiler=t;function t(r){return ua(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function fa(n){if(n)throw n}var Fo=Ag(Zh(),1);function ui(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function ha(){let n=[],e={run:t,use:r};return e;function t(...i){let o=-1,s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(a,...c){let u=n[++o],f=-1;if(a){s(a);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,u?ed(u,l)(...c):s(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function ed(n,e){let t;return r;function r(...s){let l=n.length>s.length,a;l&&s.push(i);try{a=n.apply(this,s)}catch(c){let u=c;if(l&&t)throw u;return i(u)}l||(a&&a.then&&typeof a.then=="function"?a.then(o,i):a instanceof Error?i(a):o(a))}function i(s,...l){t||(t=!0,e(s,...l))}function o(s){i(null,s)}}var ce=class extends Error{constructor(e,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},s=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){let a=r.indexOf(":");a===-1?o.ruleId=r:(o.source=r.slice(0,a),o.ruleId=r.slice(a+1))}if(!o.place&&o.ancestors&&o.ancestors){let a=o.ancestors[o.ancestors.length-1];a&&(o.place=a.position)}let l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Ft(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ce.prototype.file="";ce.prototype.name="";ce.prototype.reason="";ce.prototype.message="";ce.prototype.stack="";ce.prototype.column=void 0;ce.prototype.line=void 0;ce.prototype.ancestors=void 0;ce.prototype.cause=void 0;ce.prototype.fatal=void 0;ce.prototype.place=void 0;ce.prototype.ruleId=void 0;ce.prototype.source=void 0;var tt={basename:Vk,dirname:$k,extname:Wk,join:jk,sep:"/"};function Vk(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');fi(n);let t=0,r=-1,i=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":n.slice(t,r)}if(e===n)return"";let s=-1,l=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(n.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return t===r?r=s:r<0&&(r=n.length),n.slice(t,r)}function $k(n){if(fi(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 Wk(n){fi(n);let e=n.length,t=-1,r=0,i=-1,o=0,s;for(;e--;){let l=n.codePointAt(e);if(l===47){if(s){r=e+1;break}continue}t<0&&(s=!0,t=e+1),l===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||t<0||o===0||o===1&&i===t-1&&i===r+1?"":n.slice(i,t)}function jk(...n){let e=-1,t;for(;++e<n.length;)fi(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Hk(t)}function Hk(n){fi(n);let e=n.codePointAt(0)===47,t=qk(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function qk(n,e){let t="",r=0,i=-1,o=0,s=-1,l,a;for(;++s<=n.length;){if(s<n.length)l=n.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(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=s,o=0;continue}}else if(t.length>0){t="",r=0,i=s,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+n.slice(i+1,s):t=n.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return t}function fi(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}var td={cwd:Kk};function Kk(){return"/"}function ur(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function nd(n){if(typeof n=="string")n=new URL(n);else if(!ur(n)){let 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:"){let e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Uk(n)}function Uk(n){if(n.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let e=n.pathname,t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){let r=e.codePointAt(t+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}var da=["history","path","basename","stem","extname","dirname"],hi=class{constructor(e){let t;e?ur(e)?t={path:e}:typeof e=="string"||Jk(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":td.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<da.length;){let o=da[r];o in t&&t[o]!==void 0&&t[o]!==null&&(this[o]=o==="history"?[...t[o]]:t[o])}let i;for(i in t)da.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?tt.basename(this.path):void 0}set basename(e){ma(e,"basename"),pa(e,"basename"),this.path=tt.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?tt.dirname(this.path):void 0}set dirname(e){rd(this.basename,"dirname"),this.path=tt.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?tt.extname(this.path):void 0}set extname(e){if(pa(e,"extname"),rd(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=tt.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){ur(e)&&(e=nd(e)),ma(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?tt.basename(this.path,this.extname):void 0}set stem(e){ma(e,"stem"),pa(e,"stem"),this.path=tt.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){let i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){let i=new ce(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 pa(n,e){if(n&&n.includes(tt.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+tt.sep+"`")}function ma(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function rd(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Jk(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var id=(function(n){let r=this.constructor.prototype,i=r[n],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o});var Gk={}.hasOwnProperty,ka=class n extends id{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=ha()}copy(){let e=new n,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];e.use(...r)}return e.data((0,Fo.default)(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(xa("data",this.frozen),this.namespace[e]=t,this):Gk.call(this.namespace,e)&&this.namespace[e]||void 0:e?(xa("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let 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();let t=zo(e),r=this.parser||this.Parser;return ga("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),ga("process",this.parser||this.Parser),ya("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,s){let l=zo(e),a=r.parse(l);r.run(a,l,function(u,f,d){if(u||!f||!d)return c(u);let h=f,p=r.stringify(h,d);Qk(p)?d.value=p:d.result=p,c(u,d)});function c(u,f){u||!f?s(u):o?o(f):t(void 0,f)}}}processSync(e){let t=!1,r;return this.freeze(),ga("processSync",this.parser||this.Parser),ya("processSync",this.compiler||this.Compiler),this.process(e,i),sd("processSync","process",t),r;function i(o,s){t=!0,fa(o),r=s}}run(e,t,r){od(e),this.freeze();let i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(s,l){let a=zo(t);i.run(e,a,c);function c(u,f,d){let h=f||e;u?l(u):s?s(h):r(void 0,h,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,o),sd("runSync","run",r),i;function o(s,l){fa(s),i=l,r=!0}}stringify(e,t){this.freeze();let r=zo(t),i=this.compiler||this.Compiler;return ya("stringify",i),od(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(xa("use",this.frozen),e!=null)if(typeof e=="function")a(e,t);else if(typeof e=="object")Array.isArray(e)?l(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(c){if(typeof c=="function")a(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[u,...f]=c;a(u,f)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=(0,Fo.default)(!0,i.settings,c.settings))}function l(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){let f=c[u];o(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,u){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===c){d=f;break}if(d===-1)r.push([c,...u]);else if(u.length>0){let[h,...p]=u,m=r[d][1];ui(m)&&ui(h)&&(h=(0,Fo.default)(!0,m,h)),r[d]=[c,h,...p]}}}},di=new ka().freeze();function ga(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function ya(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function xa(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 od(n){if(!ui(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function sd(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function zo(n){return Yk(n)?n:new hi(n)}function Yk(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Qk(n){return typeof n=="string"||Xk(n)}function Xk(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var ad=n=>{throw TypeError(n)},cd=(n,e,t)=>e.has(n)||ad("Cannot "+t),H=(n,e,t)=>(cd(n,e,"read from private field"),t?t.call(n):e.get(n)),oe=(n,e,t)=>e.has(n)?ad("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ee=(n,e,t,r)=>(cd(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),st,pi,_o,Vo,$o,mi,gi,wt,yi,Wo,jo,xi,Ho,ki,qo,Ko,fr,wn,Uo,bi,Jo=class{},Go=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw il();return e}}},ba=class n extends Jo{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 n(e,t,r)}},wa=class extends Go{constructor(e){super(),oe(this,st),oe(this,pi),oe(this,_o),oe(this,Vo),oe(this,$o),oe(this,mi),oe(this,gi),ee(this,st,q.none),ee(this,pi,t=>t.isText),ee(this,_o,(t,r)=>{if(H(this,pi).call(this,t)&&H(this,pi).call(this,r)&&q.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)}),ee(this,Vo,t=>{let r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw Au(t);return r}),ee(this,$o,t=>{let r=H(this,Vo).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(ba.create(t,[],r)),this),ee(this,mi,()=>{ee(this,st,q.none);let t=this.close();return H(this,gi).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>{try{H(this,mi).call(this)}catch(t){console.error(t)}return this},ee(this,gi,(t,r,i)=>{let o=t.createAndFill(r,i,H(this,st));if(!o)throw Eu(t,r,i);return this.push(o),o}),this.addNode=(t,r,i)=>{try{H(this,gi).call(this,t,r,i)}catch(o){console.error(o)}return this},this.openMark=(t,r)=>{let i=t.create(r);return ee(this,st,i.addToSet(H(this,st))),this},this.closeMark=t=>(ee(this,st,t.removeFromSet(H(this,st))),this),this.addText=t=>{try{let r=this.top();if(!r)throw il();let i=r.pop(),o=this.schema.text(t,H(this,st));if(!i)return r.push(o),this;let s=H(this,_o).call(this,i,o);return s?(r.push(s),this):(r.push(i,o),this)}catch(r){return console.error(r),this}},this.build=()=>{let t;do t=H(this,mi).call(this);while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(r=>H(this,$o).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(t,r)=>{let i=t.runSync(t.parse(r),r);return this.next(i),this},this.schema=e}};st=new WeakMap;pi=new WeakMap;_o=new WeakMap;Vo=new WeakMap;$o=new WeakMap;mi=new WeakMap;gi=new WeakMap;wa.create=(n,e)=>{let t=new wa(n);return r=>(t.run(e,r),t.toDoc())};var ud=wa,Sa=class extends Jo{constructor(e,t,r,i={}){super(),this.type=e,this.children=t,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>this.children?.pop()}};Sa.create=(n,e,t,r={})=>new Sa(n,e,t,r);var ld=Sa,Zk=n=>Object.prototype.hasOwnProperty.call(n,"size"),Ca=class extends Go{constructor(e){super(),oe(this,wt),oe(this,yi),oe(this,Wo),oe(this,jo),oe(this,xi),oe(this,Ho),oe(this,ki),oe(this,qo),oe(this,Ko),oe(this,fr),oe(this,wn),oe(this,Uo),oe(this,bi),ee(this,wt,q.none),ee(this,yi,t=>{let r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Ru(t.type);return r}),ee(this,Wo,t=>H(this,yi).call(this,t).spec.toMarkdown.runner(this,t)),ee(this,jo,(t,r)=>H(this,yi).call(this,t).spec.toMarkdown.runner(this,t,r)),ee(this,xi,t=>{let{marks:r}=t,i=l=>l.type.spec.priority??50;[...r].sort((l,a)=>i(l)-i(a)).every(l=>!H(this,jo).call(this,l,t))&&H(this,Wo).call(this,t),r.forEach(l=>H(this,bi).call(this,l))}),ee(this,Ho,(t,r)=>{if(t.type===r||t.children?.length!==1)return t;let i=a=>{if(a.type===r)return a;if(a.children?.length!==1)return null;let[c]=a.children;return c?i(c):null},o=i(t);if(!o)return t;let s=o.children?[...o.children]:void 0,l={...t,children:s};return l.children=s,o.children=[l],o}),ee(this,ki,t=>{let{children:r}=t;return r&&(t.children=r.reduce((i,o,s)=>{if(s===0)return[o];let l=i.at(-1);if(l&&l.isMark&&o.isMark){o=H(this,Ho).call(this,o,l.type);let{children:a,...c}=o,{children:u,...f}=l;if(o.type===l.type&&a&&u&&JSON.stringify(c)===JSON.stringify(f)){let d={...f,children:[...u,...a]};return i.slice(0,-1).concat(H(this,ki).call(this,d))}}return i.concat(o)},[])),t}),ee(this,qo,t=>{let 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(ld.create(t,void 0,r,i)),this),ee(this,Ko,(t,r)=>{let i="",o="",s=t.children,l=-1,a=-1,c=f=>{f&&f.forEach((d,h)=>{d.type==="text"&&d.value&&(l<0&&(l=h),a=h)})};if(s){c(s);let f=s?.[a],d=s?.[l];if(f&&f.value.endsWith(" ")){let h=f.value,p=h.trimEnd();o=h.slice(p.length),f.value=p}if(d&&d.value.startsWith(" ")){let h=d.value,p=h.trimStart();i=h.slice(0,h.length-p.length),d.value=p}}i.length&&H(this,wn).call(this,"text",void 0,i);let u=r();return o.length&&H(this,wn).call(this,"text",void 0,o),u}),ee(this,fr,(t=!1)=>{let r=this.close(),i=()=>H(this,wn).call(this,r.type,r.children,r.value,r.props);return t?H(this,Ko).call(this,r,i):i()}),this.closeNode=()=>(H(this,fr).call(this),this),ee(this,wn,(t,r,i,o)=>{let s=ld.create(t,r,i,o),l=H(this,ki).call(this,H(this,qo).call(this,s));return this.push(l),l}),this.addNode=(t,r,i,o)=>(H(this,wn).call(this,t,r,i,o),this),ee(this,Uo,(t,r,i,o)=>t.isInSet(H(this,wt))?this:(ee(this,wt,t.addToSet(H(this,wt))),this.openNode(r,i,{...o,isMark:!0}))),ee(this,bi,t=>{t.isInSet(H(this,wt))&&(ee(this,wt,t.type.removeFromSet(H(this,wt))),H(this,fr).call(this,!0))}),this.withMark=(t,r,i,o)=>(H(this,Uo).call(this,t,r,i,o),this),this.closeMark=t=>(H(this,bi).call(this,t),this),this.build=()=>{let t=null;do t=H(this,fr).call(this);while(this.size());return t},this.next=t=>Zk(t)?(t.forEach(r=>{H(this,xi).call(this,r)}),this):(H(this,xi).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};wt=new WeakMap;yi=new WeakMap;Wo=new WeakMap;jo=new WeakMap;xi=new WeakMap;Ho=new WeakMap;ki=new WeakMap;qo=new WeakMap;Ko=new WeakMap;fr=new WeakMap;wn=new WeakMap;Uo=new WeakMap;bi=new WeakMap;Ca.create=(n,e)=>{let t=new Ca(n);return r=>(t.run(r),t.toString(e))};var fd=Ca;var Ne=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?eb(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function eb(n){return function(e,t,r,i){let o=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),r+=s;let l=r-i;l>0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var hd=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],o;if(i.spec.isInputRules&&(o=i.getState(n))){if(e){let s=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},rE=new Ne(/--$/,"\u2014",{inCodeMark:!1}),iE=new Ne(/\.\.\.$/,"\u2026",{inCodeMark:!1}),oE=new Ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),sE=new Ne(/"$/,"\u201D",{inCodeMark:!1}),lE=new Ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),aE=new Ne(/'$/,"\u2019",{inCodeMark:!1});function Yo(n,e,t=null,r){return new Ne(n,(i,o,s,l)=>{let a=t instanceof Function?t(o):t,c=i.tr.delete(s,l),u=c.doc.resolve(s),f=u.blockRange(),d=f&&cn(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==e&&fn(c.doc,s-1)&&(!r||r(o,h))&&c.join(s-1),c})}function Ma(n,e,t=null){return new Ne(n,(r,i,o,s)=>{let l=r.doc.resolve(o),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,a):null})}var Vt=typeof navigator<"u"?navigator:null,dd=typeof document<"u"?document:null,$t=Vt&&Vt.userAgent||"",Ia=/Edge\/(\d+)/.exec($t),xd=/MSIE \d/.exec($t),Ta=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($t),Oa=!!(xd||Ta||Ia),hE=xd?document.documentMode:Ta?+Ta[1]:Ia?+Ia[1]:0,tb=!Oa&&/gecko\/(\d+)/i.test($t),dE=tb&&+(/Firefox\/(\d+)/.exec($t)||[0,0])[1],pd=!Oa&&/Chrome\/(\d+)/.exec($t);var pE=pd?+pd[1]:0,nb=!Oa&&!!Vt&&/Apple Computer/.test(Vt.vendor),rb=nb&&(/Mobile\/\w+/.test($t)||!!Vt&&Vt.maxTouchPoints>2),mE=rb||(Vt?/Mac/.test(Vt.platform):!1),gE=/Android \d/.test($t),ib=!!dd&&"webkitFontSmoothing"in dd.documentElement.style,yE=ib?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Na(n,e,t,r,i,o){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"\uFFFC")+r;for(let c of i){let u=c,f=u.match.exec(a),d=f&&f[0]&&u.handler(s,f,e-(f[0].length-r.length),t);if(d)return u.undoable!==!1&&d.setMeta(o,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}var ob=new re("MILKDOWN_CUSTOM_INPUTRULES");function kd({rules:n}){let e=new ne({key:ob,isInputRules:!0,state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,o){return Na(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Na(t,r.pos,r.pos,"",n,e)}),!1)},handleKeyDown(t,r){if(r.key!=="Enter")return!1;let{$cursor:i}=t.state.selection;return i?Na(t,i.pos,i.pos,` 40 + `,n,e):!1}}});return e}function wi(n,e,t={}){return new Ne(n,(r,i,o,s)=>{var l,a,c,u;let{tr:f}=r,d=i.length,h=i[d-1],p=i[0],m=[],k=s,x={group:h,fullMatch:p,start:o,end:s},I=(l=t.updateCaptured)==null?void 0:l.call(t,x);if(Object.assign(x,I),{group:h,fullMatch:p,start:o,end:s}=x,p===null||h?.trim()==="")return null;if(h){let C=p.search(/\S/),A=o+p.indexOf(h),v=A+h.length;m=(a=f.storedMarks)!=null?a:[],v<s&&f.delete(v,s),A>o&&f.delete(o+C,A),k=o+C+h.length;let b=(c=t.getAttr)==null?void 0:c.call(t,i);f.addMark(o,k,e.create(b)),f.setStoredMarks(m),(u=t.beforeDispatch)==null||u.call(t,{match:i,start:o,end:s,tr:f})}return f})}var sb=Object.defineProperty,lb=Object.defineProperties,ab=Object.getOwnPropertyDescriptors,md=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,gd=(n,e,t)=>e in n?sb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,fb=(n,e)=>{for(var t in e||(e={}))cb.call(e,t)&&gd(n,t,e[t]);if(md)for(var t of md(e))ub.call(e,t)&&gd(n,t,e[t]);return n},hb=(n,e)=>lb(n,ab(e));function yd(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function bd(n,e,t){let i=n.state.doc.content.size,o=yd(e,0,i),s=yd(t,0,i),l=n.coordsAtPos(o),a=n.coordsAtPos(s,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-f,p=u-c,x={top:c,bottom:u,left:f,right:d,width:h,height:p,x:f,y:c};return hb(fb({},x),{toJSON:()=>x})}function db(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function wd(n,e){if(!(n instanceof B))return;let{node:t,$from:r}=n;if(db(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}var Sd=(n,e)=>{let{selection:t,doc:r}=n;if(t instanceof B)return{hasNode:t.node.type===e,pos:t.from,target:t.node};let{from:i,to:o}=t,s=!1,l=-1,a=null;return r.nodesBetween(i,o,(c,u)=>a?!1:c.type===e?(s=!0,l=u,a=c,!1):!0),{hasNode:s,pos:l,target:a}};var St={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:"'"},Xo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pb=typeof navigator<"u"&&/Mac/.test(navigator.platform),mb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(se=0;se<10;se++)St[48+se]=St[96+se]=String(se);var se;for(se=1;se<=24;se++)St[se+111]="F"+se;var se;for(se=65;se<=90;se++)St[se]=String.fromCharCode(se+32),Xo[se]=String.fromCharCode(se);var se;for(Qo in St)Xo.hasOwnProperty(Qo)||(Xo[Qo]=St[Qo]);var Qo;function Cd(n){var e=pb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||mb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Xo:St)[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}var gb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),yb=typeof navigator<"u"&&/Win/.test(navigator.platform);function xb(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))gb?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function kb(n){let e=Object.create(null);for(let t in n)e[xb(t)]=n[t];return e}function Ea(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 Md(n){return new ne({props:{handleKeyDown:bb(n)}})}function bb(n){let e=kb(n);return function(t,r){let i=Cd(r),o,s=e[Ea(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Ea(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(yb&&r.ctrlKey&&r.altKey)&&(o=St[r.keyCode])&&o!=i){let l=e[Ea(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var pe=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},La=null,Mt=function(n,e,t){let r=La||(La=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},wb=function(){La=null},On=function(n,e,t,r){return t&&(Nd(n,e,t,r,-1)||Nd(n,e,t,r,1))},Sb=/^(img|br|input|textarea|hr)$/i;function Nd(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ke(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Ei(n)||Sb.test(n.nodeName)||n.contentEditable=="false")return!1;e=pe(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cb(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=Ke(n)}else if(n.parentNode&&!Ei(n))e=pe(n),n=n.parentNode;else return null}}function Mb(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&&!Ei(n))e=pe(n)+1,n=n.parentNode;else return null}}function Nb(n,e,t){for(let r=e==0,i=e==Ke(n);r||i;){if(n==t)return!0;let o=pe(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Ke(n)}}function Ei(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)}var us=function(n){return n.focusNode&&On(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Sn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ib(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Tb(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}var lt=typeof navigator<"u"?navigator:null,Id=typeof document<"u"?document:null,Ut=lt&&lt.userAgent||"",Ba=/Edge\/(\d+)/.exec(Ut),ip=/MSIE \d/.exec(Ut),za=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ut),Re=!!(ip||za||Ba),qt=ip?document.documentMode:za?+za[1]:Ba?+Ba[1]:0,Ue=!Re&&/gecko\/(\d+)/i.test(Ut);Ue&&+(/Firefox\/(\d+)/.exec(Ut)||[0,0])[1];var Fa=!Re&&/Chrome\/(\d+)/.exec(Ut),me=!!Fa,op=Fa?+Fa[1]:0,we=!Re&&!!lt&&/Apple Computer/.test(lt.vendor),yr=we&&(/Mobile\/\w+/.test(Ut)||!!lt&&lt.maxTouchPoints>2),qe=yr||(lt?/Mac/.test(lt.platform):!1),sp=lt?/Win/.test(lt.platform):!1,Nt=/Android \d/.test(Ut),Ai=!!Id&&"webkitFontSmoothing"in Id.documentElement.style,Ob=Ai?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Eb(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 Ct(n,e){return typeof n=="number"?n:n[e]}function Ab(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 Td(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=gr(s);continue}let l=s,a=l==o.body,c=a?Eb(o):Ab(l),u=0,f=0;if(e.top<c.top+Ct(r,"top")?f=-(c.top-e.top+Ct(i,"top")):e.bottom>c.bottom-Ct(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ct(i,"top")-c.top:e.bottom-c.bottom+Ct(i,"bottom")),e.left<c.left+Ct(r,"left")?u=-(c.left-e.left+Ct(i,"left")):e.right>c.right-Ct(r,"right")&&(u=e.right-c.right+Ct(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,k=l.scrollTop-p;e={left:e.left-m,top:e.top-k,right:e.right-m,bottom:e.bottom-k}}let d=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:gr(s)}}function Rb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(o,s);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:lp(n.dom)}}function lp(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 vb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ap(t,r==0?0:r-e)}function ap(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}var hr=null;function Db(n){if(n.setActive)return n.setActive();if(hr)return n.focus(hr);let e=lp(n);n.focus(hr==null?{get preventScroll(){return hr={preventScroll:!0},!0}}:void 0),hr||(hr=!1,ap(e,0))}function cp(n,e){let t,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Mt(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=u,r=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Pb(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:cp(t,i)}function Pb(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=Wt(r,1);if(s.top!=s.bottom&&Za(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Za(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Lb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Bb(n,e,t){let{node:r,offset:i}=cp(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function zb(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function up(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)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Za(e,c))return up(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function Fb(n,e){let t=n.dom.ownerDocument,r,i=0,o=Tb(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Za(e,c)||(s=up(n.dom,e,c),!s))return null}if(we)for(let c=s;r&&c;c=gr(c))c.draggable&&(r=void 0);if(s=Lb(s,e),r){if(Ue&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Ai&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.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=zb(n,r,i,e))}l==null&&(l=Bb(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Od(n){return n.top<n.bottom||n.left<n.right}function Wt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Od(r))return r}return Array.prototype.find.call(t,Od)||n.getBoundingClientRect()}var _b=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fp(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Ai||Ue;if(r.nodeType==3)if(s&&(_b.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Wt(Mt(r,i,i),t);if(Ue&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Wt(Mt(r,i-1,i-1),-1);if(c.top==a.top){let u=Wt(Mt(r,i,i+1),-1);if(u.top!=a.top)return Si(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Si(Wt(Mt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Ke(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Aa(a.getBoundingClientRect(),!1)}if(o==null&&i<Ke(r)){let a=r.childNodes[i];if(a.nodeType==1)return Aa(a.getBoundingClientRect(),!0)}return Aa(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==Ke(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Mt(a,Ke(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Si(Wt(c,1),!1)}if(o==null&&i<Ke(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Mt(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Si(Wt(c,-1),!0)}return Si(Wt(r.nodeType==3?Mt(r):r,-t),t>=0)}function Si(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 Aa(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 hp(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 Vb(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return hp(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=fp(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Mt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var $b=/[\u0590-\u08ac]/;function Wb(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!$b.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:hp(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),k=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),k}):r.pos==r.start()||r.pos==r.end()}var Ed=null,Ad=null,Rd=!1;function jb(n,e,t){return Ed==e&&Ad==t?Rd:(Ed=e,Ad=t,Rd=t=="up"||t=="down"?Vb(n,e,t):Wb(n,e,t))}var Je=0,vd=1,Cn=2,at=3,En=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Je,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 o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>pe(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 o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let 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 o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof ts){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Zo&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?pe(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?pe(o.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,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=pe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=pe(f.dom);break}t+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}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 o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],k=p+m.size;if(o>p&&s<k)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ue||we)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==` 41 + `),f&&p==h.nodeValue.length)for(let m=h,k;m;m=m.parentNode){if(k=m.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:pe(k)+1});break}let x=m.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ue&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&we)&&On(l.node,l.offset,u.anchorNode,u.anchorOffset)&&On(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(f&&Ue)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Cn:vd,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=at:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Cn:at}r=s}this.dirty=Cn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Cn:vd;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Zo=class extends En{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Je&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},_a=class extends En{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}},xr=class n extends En{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=sn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Je){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Je}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=ja(o,t,s,r)),e>0&&(o=ja(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Kt=class n extends En{constructor(e,t,r,i,o,s,l,a,c){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=sn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=mp(u,r,t),c?a=new Va(e,t,r,i,u,f||null,d,c,o,s+1):t.isText?new es(e,t,r,i,u,d,o):new n(e,t,r,i,u,f||null,d,o,s+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=()=>M.empty)}return e}matchesNode(e,t,r){return this.dirty==Je&&e.eq(this.node)&&ns(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,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Wa(this,s&&s.node,e);Ub(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?q.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e,d);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Cn)&&(s&&this.protectLocalComposition(e,s),dp(this.contentDOM,this.children,e),yr&&Jb(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof j)||r<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Gb(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new _a(this,o,t,i);e.input.compositionNodes.push(s),this.children=ja(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==at||!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=Je}updateOuterDeco(e){if(ns(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=pp(this.dom,this.nodeDOM,$a(this.outerDeco,this.node,t),$a(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Dd(n,e,t,r,i){mp(r,e,n);let o=new Kt(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var es=class n extends Kt{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,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==at||this.dirty!=Je&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Je||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=Je,!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),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}},ts=class extends En{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Je&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Va=class extends Kt{constructor(e,t,r,i,o,s,l,a,c,u){super(e,t,r,i,o,s,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function dp(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Pd(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(s instanceof xr){let a=r?r.previousSibling:n.lastChild;dp(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Pd(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var Ci=function(n){n&&(this.nodeName=n)};Ci.prototype=Object.create(null);var Mn=[new Ci];function $a(n,e,t){if(n.length==0)return Mn;let r=t?Mn[0]:new Ci,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new Ci(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(r=new Ci(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 pp(n,e,t,r){if(t==Mn&&r==Mn)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Mn[0]),i=a}Hb(i,l||Mn[0],s)}return i}function Hb(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 o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);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 mp(n,e,t){return pp(n,n,Mn,$a(e,t,n.nodeType!=1))}function ns(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 Pd(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Wa=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=qb(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,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Je,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=xr.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==at&&s.dom==s.contentDOM&&(s.dirty=Cn),s.update(e,t,r,o)?(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,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Kt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=at&&ns(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Cn,f.updateChildren(i,s+1),f.dirty=Je),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ns(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Kt.create(this.top,t,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,o){let s=Kt.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),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 o=new Zo(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof xr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof es)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((we||me)&&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 ts(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 qb(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof xr)t=c,r=c.children.length;else{l=c,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,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Kb(n,e){return n.type.side-e.type.side}function Ub(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let k=i[s++];k.widget&&(u?(f||(f=[u])).push(k):u=k)}if(u)if(f){f.sort(Kb);for(let k=0;k<f.length;k++)t(f[k],c,!!a)}else t(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<n.childCount)h=c,d=n.child(c++);else break;for(let k=0;k<l.length;k++)l[k].to<=o&&l.splice(k--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let k=p;s<i.length&&i[s].from<k&&(k=i[s].from);for(let x=0;x<l.length;x++)l[x].to<k&&(k=l[x].to);k<p&&(a=d.cut(k-o),d=d.cut(0,k-o),p=k,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let m=d.isInline&&!d.isLeaf?l.filter(k=>!k.inline):l.slice();r(d,m,e.forChild(o,d),h),o=p}}function Jb(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 Gb(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<n.childCount;){let c=n.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ja(n,e,t,r,i){let o=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>t&&o.push(a.slice(t-c,a.size,r)))}return o}function ec(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(us(t)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&B.isSelectable(f)&&i.parent&&!(f.isInline&&Nb(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new B(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=tc(n,u,l,f)}return c}function gp(n){return n.editable?n.hasFocus():xp(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function It(n,e=!1){let t=n.state.selection;if(yp(n,t),!!gp(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&me){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&On(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Qb(n);else{let{anchor:r,head:i}=t,o,s;Ld&&!(t instanceof j)&&(t.$from.parent.inlineContent||(o=Bd(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Bd(n,t.to))),n.docView.setSelection(r,i,n,e),Ld&&(o&&zd(o),s&&zd(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Yb(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}var Ld=we||me&&op<63;function Bd(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(we&&i&&i.contentEditable=="false")return Ra(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Ra(i);if(o)return Ra(o)}}function Ra(n){return n.contentEditable="true",we&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function zd(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Yb(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(()=>{(!gp(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Qb(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,pe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Re&&qt<=11&&(t.disabled=!0,t.disabled=!1)}function yp(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Fd(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Fd(n)}function Fd(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function tc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||j.between(e,t,r)}function _d(n){return n.editable&&!n.hasFocus()?!1:xp(n)}function xp(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 Xb(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return On(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ha(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&W.findFrom(o,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Vd(n,e,t){let r=n.state.selection;if(r instanceof j)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return jt(n,new j(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Ha(n.state,e);return i&&i instanceof B?jt(n,i):!1}else if(!(qe&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?B.isSelectable(o)?jt(n,new B(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Ai?jt(n,new j(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return jt(n,new j(e>0?r.$to:r.$from));{let i=Ha(n.state,e);return i?jt(n,i):!1}}}function rs(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dr(n,e){return e<0?Zb(n):ew(n)}function Zb(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Ue&&t.nodeType==1&&r<rs(t)&&Mi(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Mi(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(kp(t))break;{let l=t.previousSibling;for(;l&&Mi(l,-1);)i=t.parentNode,o=pe(l),l=l.previousSibling;if(l)t=l,r=rs(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?qa(n,t,r):i&&qa(n,i,o)}function ew(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=rs(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Mi(l,1))o=t,s=++r;else break}else{if(kp(t))break;{let l=t.nextSibling;for(;l&&Mi(l,1);)o=l.parentNode,s=pe(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=rs(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&qa(n,o,s)}function kp(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function tw(n,e){for(;n&&e==n.childNodes.length&&!Ei(n);)e=pe(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 nw(n,e){for(;n&&!e&&!Ei(n);)e=pe(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 qa(n,e,t){if(e.nodeType!=3){let o,s;(s=tw(e,t))?(e=s,t=0):(o=nw(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(us(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&It(n)},50)}function $d(n,e){let t=n.state.doc.resolve(e);if(!(me||sp)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Wd(n,e,t){let r=n.state.selection;if(r instanceof j&&!r.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Ha(n.state,e);if(s&&s instanceof B)return jt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Fe?W.near(s,e):W.findFrom(s,e);return l?jt(n,l):!1}return!1}function jd(n,e){if(!(n.state.selection instanceof j))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 o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Hd(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function rw(n){if(!we||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;Hd(n,r,"true"),setTimeout(()=>Hd(n,r,"false"),20)}return!1}function iw(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ow(n,e){let t=e.keyCode,r=iw(e);if(t==8||qe&&t==72&&r=="c")return jd(n,-1)||dr(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&r=="c")return jd(n,1)||dr(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&r=="c"){let i=t==37?$d(n,n.state.selection.from)=="ltr"?-1:1:-1;return Vd(n,i,r)||dr(n,i)}else if(t==39||qe&&t==70&&r=="c"){let i=t==39?$d(n,n.state.selection.from)=="ltr"?1:-1:1;return Vd(n,i,r)||dr(n,i)}else{if(t==38||qe&&t==80&&r=="c")return Wd(n,-1,r)||dr(n,-1);if(t==40||qe&&t==78&&r=="c")return rw(n)||Wd(n,1,r)||dr(n,1);if(r==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function nc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||sn.fromSchema(n.state.schema),l=Np(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Mp[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` 42 42 43 43 `);return{dom:a,text:d,slice:e}}function bp(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return l=new O(M.from(n.state.schema.text(e.replace(/\r\n?/g,` 44 - `))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:h}=n.state,p=sn.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let k=s.appendChild(document.createElement("p"));m&&k.appendChild(p.serializeNode(h.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=cw(t),Ai&&uw(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||on.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!sw.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=fw(qd(l,+u[1],+u[2]),u[4]);else if(l=O.maxOpen(lw(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=qd(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var sw=/^(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 lw(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)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Sp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Cp(s[s.length-1],o.length));let u=wp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return M.from(s)}return n}function wp(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,M.from(n));return n}function Sp(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=Sp(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(M.from(wp(t,n,i+1))))}}function Cp(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Cp(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(r))}function qa(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(o=0),i<r-1&&(l=qa(l,e,t,r,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function qd(n,e,t){return e<n.openStart&&(n=new O(qa(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(qa(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Mp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Kd=null;function Np(){return Kd||(Kd=document.implementation.createHTMLDocument("title"))}var Ra=null;function aw(n){let e=window.trustedTypes;return e?(Ra||(Ra=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ra.createHTML(n)):n}function cw(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Np().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Mp[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=aw(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function uw(n){let e=n.querySelectorAll(me?"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=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fw(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:o,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=M.from(a.create(r[l+1],i)),o++,s++}return new O(i,o,s)}var Te={},Oe={},hw={touchstart:!0,touchmove:!0},Ka=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function dw(n){for(let e in Te){let t=Te[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{mw(n,r)&&!nc(n,r)&&(n.editable||!(r.type in Oe))&&t(n,r)},hw[e]?{passive:!0}:void 0)}we&&n.dom.addEventListener("input",()=>null),Ua(n)}function Ht(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function pw(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 Ua(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>nc(n,r))})}function nc(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function mw(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 gw(n,e){!nc(n,e)&&Te[e.type]&&(n.editable||!(e.type in Oe))&&Te[e.type](n,e)}Oe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Tp(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Nt&&me&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),yr&&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,Sn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ow(n,t)?t.preventDefault():Ht(n,"key")};Oe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Oe.keypress=(n,e)=>{let t=e;if(Tp(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof j)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function fs(n){return{left:n.clientX,top:n.clientY}}function yw(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function rc(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function mr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function xw(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(mr(n,new B(t),"pointer"),!0):!1}function kw(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof B&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(B.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(mr(n,B.create(n.state.doc,i),"pointer"),!0):!1}function bw(n,e,t,r,i){return rc(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?kw(n,t):xw(n,t))}function ww(n,e,t,r){return rc(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Sw(n,e,t,r){return rc(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Cw(n,t,r)}function Cw(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(mr(n,j.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)mr(n,j.create(r,l+1,l+1+s.content.size),"pointer");else if(B.isSelectable(s))mr(n,B.create(r,l),"pointer");else continue;return!0}}function ic(n){return is(n)}var Ip=qe?"metaKey":"ctrlKey";Te.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ic(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&yw(t,n.input.lastClick)&&!t[Ip]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=n.posAtCoords(fs(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ja(n,s,t,!!r)):(o=="doubleClick"?ww:Sw)(n,s.pos,s.inside,t)?t.preventDefault():Ht(n,"pointer"))};var Ja=class{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[Ip],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof B&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ue&&!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)),Ht(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(()=>It(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(fs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ht(this.view,"pointer"):bw(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||we&&this.mightDrag&&!this.mightDrag.node.isAtom||me&&!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)?(mr(this.view,W.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ht(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ht(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)}};Te.touchstart=n=>{n.input.lastTouch=Date.now(),ic(n),Ht(n,"pointer")};Te.touchmove=n=>{n.input.lastTouch=Date.now(),Ht(n,"pointer")};Te.contextmenu=n=>ic(n);function Tp(n,e){return n.composing?!0:we&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Mw=Nt?5e3:-1;Oe.compositionstart=Oe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof j&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||me&&sp&&Nw(n)))n.markCursor=n.state.storedMarks||t.marks(),is(n,!0),n.markCursor=null;else if(is(n,!e.selection.empty),Ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Op(n,Mw)};function Nw(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Oe.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.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Op(n,20))};function Op(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>is(n),e))}function Ep(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Tw());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Iw(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Cb(e.focusNode,e.focusOffset),r=Mb(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Tw(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function is(n,e=!1){if(!(Nt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ep(n),e||n.docView&&n.docView.dirty){let t=Za(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ow(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)}var Ni=Re&&qt<15||yr&&Ob<604;Te.copy=Oe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Ni?null:t.clipboardData,s=r.content(),{dom:l,text:a}=tc(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ow(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ew(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Aw(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?Ii(n,r.value,null,i,e):Ii(n,r.textContent,r.innerHTML,i,e)},50)}function Ii(n,e,t,r,i){let o=bp(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||O.empty)))return!0;if(!o)return!1;let s=Ew(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ap(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," "):""}Oe.paste=(n,e)=>{let t=e;if(n.composing&&!Nt)return;let r=Ni?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ii(n,Ap(r),r.getData("text/html"),i,t)?t.preventDefault():Aw(n,t)};var ss=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Rw=qe?"altKey":"ctrlKey";function Rp(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Rw]}Te.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(fs(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof B?i.to-1:i.to))){if(r&&r.mightDrag)s=B.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=B.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=tc(n,l);(!t.dataTransfer.files.length||!me||op>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ni?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ni||t.dataTransfer.setData("text/plain",c),n.dragging=new ss(u,Rp(n,t),s)};Te.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Oe.dragover=Oe.dragenter=(n,e)=>e.preventDefault();Oe.drop=(n,e)=>{try{vw(n,e,n.dragging)}finally{n.dragging=null}};function vw(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(fs(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=bp(n,Ap(e.dataTransfer),Ni?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Rp(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||O.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?mf(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&B.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new B(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,k,x)=>h=x),a.setSelection(ec(n,d,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Te.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())&&It(n)},20))};Te.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)};Te.beforeinput=(n,e)=>{if(me&&Nt&&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",o=>o(n,Sn(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 Oe)Te[n]=Oe[n];function Ti(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}var ls=class n{constructor(e,t){this.toDOM=e,this.spec=t||In,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new nt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ti(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Nn=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new nt(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Ti(this.attrs,e.attrs)&&Ti(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Ga=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new nt(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Ti(this.attrs,e.attrs)&&Ti(this.spec,e.spec)}destroy(){}},nt=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(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 n(e,e,new ls(t,r))}static inline(e,t,r,i){return new n(e,t,new Nn(r,i))}static node(e,t,r,i){return new n(e,t,new Ga(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Nn}get widget(){return this.type instanceof ls}},pr=[],In={},Ie=class n{constructor(e,t){this.local=e.length?e:pr,this.children=t.length?t:pr}static create(e,t){return t.length?cs(t,e,0,In):be}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==be||e.maps.length==0?this:this.mapInner(e,t,0,0,r||In)}mapInner(e,t,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Dw(this.children,s||[],e,t,r,i,o):s?new n(s.sort(Tn),pr):be}add(e,t){return t.length?this==be?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Dp(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,cs(u,l,c+1,In)),o+=3}});let s=vp(o?Pp(t):t,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new n(s.length?this.local.concat(s).sort(Tn):this.local,i||this.children)}remove(e){return e.length==0||this==be?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+t,a=r[o+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=be?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,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 n(i,r):be}forChild(e,t){if(this==be)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Nn){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new n(i.sort(Tn),pr);return r?new as([l,r]):l}return r||be}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 oc(this.localsInner(e))}localsInner(e){if(this==be)return pr;if(e.inlineContent||!this.local.some(Nn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Nn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Ie.empty=new Ie([],[]);Ie.removeOverlap=oc;var be=Ie.empty,as=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,In));return n.from(r)}forChild(e,t){if(t.isLeaf)return Ie.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=be&&(o instanceof n?r=r.concat(o.members):r.push(o))}return n.from(r)}eq(e){if(!(e instanceof n)||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 o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?oc(r?t:t.sort(Tn)):pr}static from(e){switch(e.length){case 0:return be;case 1:return e[0];default:return new n(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 Dw(n,e,t,r,i,o,s){let l=n.slice();for(let c=0,u=o;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,m)=>{let k=m-p-(h-d);for(let x=0;x<l.length;x+=3){let I=l[x+1];if(I<0||d>I+u-f)continue;let C=l[x]+u-f;h>=C?l[x+1]=d<=C?-2:-1:d>=u&&k&&(l[x]+=k,l[x+1]+=k)}f+=k}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),h=d-i,{index:p,offset:m}=r.content.findIndex(f),k=r.maybeChild(p);if(k&&m==f&&m+k.nodeSize==h){let x=l[c+2].mapInner(t,k,u+1,n[c]+o+1,s);x!=be?(l[c]=f,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Pw(l,n,e,t,i,o,s),u=cs(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new Ie(e.sort(Tn),l)}function vp(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 nt(i.from+e,i.to+e,i.type))}return t}function Pw(n,e,t,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?t.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function Dp(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function Pp(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function cs(n,e,t,r){let i=[],o=!1;e.forEach((l,a)=>{let c=Dp(n,l,a+t);if(c){o=!0;let u=cs(c,l,t+a+1,r);u!=be&&i.push(a,a+l.nodeSize,u)}});let s=vp(o?Pp(n):n,-t).sort(Tn);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Ie(s,i):be}function Tn(n,e){return n.from-e.from||n.to-e.to}function oc(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 o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),Ud(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Ud(e,i,r.copy(o.from,r.to)));break}}}return e}function Ud(n,e,t){for(;e<n.length&&Tn(t,n[e])>0;)e++;n.splice(e,0,t)}function va(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=be&&e.push(r)}),n.cursorWrapper&&e.push(Ie.create(n.state.doc,[n.cursorWrapper.deco])),as.from(e)}var Lw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Bw=Re&&qt<=11,Ya=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Qa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ya,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]);Re&&qt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():we&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Bw&&(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,Lw)),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(_d(this.view)){if(this.suppressingSelectionUpdates)return It(this.view);if(Re&&qt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&On(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 o=e.focusNode;o;o=gr(o))t.add(o);for(let o=e.anchorNode;o;o=gr(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&_d(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Ue&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||_w(e,f)!=h)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&us(r)&&(c=Za(e))&&c.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,It(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),zw(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Vw(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||It(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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(Re&&qt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?pe(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?pe(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Jd=new WeakMap,Gd=!1;function zw(n){if(!Jd.has(n)&&(Jd.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ue,Gd)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."),Gd=!0}}function Yd(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return On(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function Fw(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Yd(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?Yd(n,t):null}function _w(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 Vw(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function $w(n,e,t){let{node:r,fromOffset:i,toOffset:o,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],us(a)||c.push({node:a.focusNode,offset:a.focusOffset})),me&&n.input.lastKeyCode===8)for(let k=o;k>i;k--){let x=r.childNodes[k-1],I=x.pmViewDesc;if(x.nodeName=="BR"&&!I){o=k;break}if(!I||I.size)break}let f=n.state.doc,d=n.someProp("domParser")||on.fromSchema(n.state.schema),h=f.resolve(s),p=null,m=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ww,context:h});if(c&&c[0].pos!=null){let k=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=k),p={anchor:k+s,head:x+s}}return{doc:m,sel:p,from:s,to:l}}function Ww(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(we&&/^(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||we&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var jw=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Hw(n,e,t,r,i){let o=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,P=Za(n,T);if(P&&!n.state.selection.eq(P)){if(me&&Nt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",U=>U(n,Sn(13,"Enter"))))return;let D=n.state.tr.setSelection(P);T=="pointer"?D.setMeta("pointer",!0):T=="key"&&D.scrollIntoView(),o&&D.setMeta("composition",o),n.dispatch(D)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=$w(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Uw(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(yr&&n.input.lastIOSEnter>Date.now()-225||Nt)&&i.some(T=>T.nodeType==1&&!jw.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof j&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Qd(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let P=n.state.tr.setSelection(T);o&&P.setMeta("composition",o),n.dispatch(P)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof j&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Re&&qt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),k=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),I=m.sameParent(k)&&m.parent.inlineContent&&x.end()>=p.endA;if((yr&&n.input.lastIOSEnter>Date.now()-225&&(!I||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!I&&m.pos<c.doc.content.size&&(!m.sameParent(k)||!m.parent.inlineContent)&&m.pos<k.pos&&!/\S/.test(c.doc.textBetween(m.pos,k.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Kw(u,p.start,p.endA,m,k)&&n.someProp("handleKeyDown",T=>T(n,Sn(8,"Backspace")))){Nt&&me&&n.domObserver.suppressSelectionUpdates();return}me&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Nt&&!I&&m.start()!=k.start()&&k.parentOffset==0&&m.depth==k.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,k=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Sn(13,"Enter"))})},20));let C=p.start,A=p.endA,v=T=>{let P=T||n.state.tr.replace(C,A,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let D=Qd(n,P.doc,c.sel);D&&!(me&&n.composing&&D.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==C||D.head==P.mapping.map(A)-1)||Re&&D.empty&&D.head==C)&&P.setSelection(D)}return o&&P.setMeta("composition",o),P.scrollIntoView()},b;if(I)if(m.pos==k.pos){Re&&qt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>It(n),20));let T=v(n.state.tr.delete(C,A)),P=u.resolve(p.start).marksAcross(u.resolve(p.endA));P&&T.ensureMarks(P),n.dispatch(T)}else if(p.endA==p.endB&&(b=qw(m.parent.content.cut(m.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let T=v(n.state.tr);b.type=="add"?T.addMark(C,A,b.mark):T.removeMark(C,A,b.mark),n.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==k.index()-(k.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,k.parentOffset),P=()=>v(n.state.tr.insertText(T,C,A));n.someProp("handleTextInput",D=>D(n,C,A,T,P))||n.dispatch(P())}else n.dispatch(v());else n.dispatch(v())}function Qd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ec(n,e.resolve(t.anchor),e.resolve(t.head))}function qw(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(M.from(c).eq(n))return{mark:l,type:s}}function Kw(n,e,t,r,i){if(t-e<=i.pos-r.pos||Da(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(Da(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Da(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Da(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 o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Uw(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s<o&&n.size<e.size){let a=r<=o&&r>=s?o-r:0;o-=a,o&&o<e.size&&Xd(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&Xd(n.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function Xd(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}var Oi=class{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 Ka,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(rp),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=tp(this),ep(this),this.nodeViews=np(this),this.docView=Dd(this.state.doc,Zd(this),va(this),this.dom,this),this.domObserver=new Qa(this,(r,i,o,s)=>Hw(this,r,i,o,s)),this.domObserver.start(),dw(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&&Ua(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(rp),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,o=!1,s=!1;e.storedMarks&&this.composing&&(Ep(this),s=!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 h=np(this);Gw(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ua(this),this.editable=tp(this),ep(this);let a=va(this),c=Zd(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Rb(this);if(s){this.domObserver.stop();let h=f&&(Re||me)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Jw(i.selection,e.selection);if(f){let p=me?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Iw(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Dd(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Xb(this))?It(this,h):(yp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&vb(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Td(this,t.getBoundingClientRect(),e)}else Td(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 o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new ss(e.slice,e.move,i<0?void 0:B.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 s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(Re){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&&Db(this.dom),It(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 Fb(this,e)}coordsAtPos(e,t=1){return fp(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 jb(this,t||this.state,e)}pasteHTML(e,t){return Ii(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ii(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return tc(this,e)}destroy(){this.docView&&(pw(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],va(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return gw(this,e)}domSelectionRange(){let e=this.domSelection();return e?we&&this.root.nodeType===11&&Ib(this.dom.ownerDocument)==this.dom&&Fw(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Oi.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Zd(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"),[nt.node(0,n.state.doc.content.size,e)]}function ep(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:nt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function tp(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Jw(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 np(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 Gw(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 rp(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")}function Et(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}var zp={text:(n,e,t,r)=>{let i=n.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...r,encode:[]})},strong:(n,e,t,r)=>{let i=n.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(r),l=s.move(i+i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},emphasis:(n,e,t,r)=>{let i=n.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(r),l=s.move(i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l}},rt=$({},"editorView"),Ri=$({},"editorState"),sc=$([],"initTimer"),Lp=$({},"editor"),Nr=$([],"inputRules"),ct=$([],"prosePlugins"),Ir=$([],"remarkPlugins"),Ms=$([],"nodeView"),Ns=$([],"markView"),An=$(di().use(ir).use(cr),"remark"),kr=$({handlers:zp,encode:[]},"remarkStringifyOptions"),hs=He("ConfigReady");function Yw(n){let e=t=>(t.record(hs),async()=>(await n(t),t.done(hs),()=>{t.clearTimer(hs)}));return Et(e,{displayName:"Config"}),e}var Tt=He("InitReady");function Qw(n){let e=t=>(t.inject(Lp,n).inject(ct,[]).inject(Ir,[]).inject(Nr,[]).inject(Ms,[]).inject(Ns,[]).inject(kr,{handlers:zp,encode:[]}).inject(An,di().use(ir).use(cr)).inject(sc,[hs]).record(Tt),async()=>{await t.waitTimers(sc);let r=t.get(kr);return t.set(An,di().use(ir).use(cr,r)),t.done(Tt),()=>{t.remove(Lp).remove(ct).remove(Ir).remove(Nr).remove(Ms).remove(Ns).remove(kr).remove(An).remove(sc).clearTimer(Tt)}});return Et(e,{displayName:"Init"}),e}var ve=He("SchemaReady"),ds=$([],"schemaTimer"),Ot=$({},"schema"),br=$([],"nodes"),wr=$([],"marks");function Bp(n){return{...n,parseDOM:n.parseDOM?.map(e=>({priority:n.priority,...e}))}}var Fp=n=>(n.inject(Ot,{}).inject(br,[]).inject(wr,[]).inject(ds,[Tt]).record(ve),async()=>{await n.waitTimers(ds);let e=n.get(An),r=n.get(Ir).reduce((l,a)=>l.use(a.plugin,a.options),e);n.set(An,r);let i=Object.fromEntries(n.get(br).map(([l,a])=>[l,Bp(a)])),o=Object.fromEntries(n.get(wr).map(([l,a])=>[l,Bp(a)])),s=new so({nodes:i,marks:o});return n.set(Ot,s),n.done(ve),()=>{n.remove(Ot).remove(br).remove(wr).remove(ds).clearTimer(ve)}});Et(Fp,{displayName:"Schema"});var Is=class{constructor(){this.#t=new jr,this.#e=null,this.setCtx=e=>{this.#e=e},this.chain=()=>{if(this.#e==null)throw Qi();let e=this.#e,t=[],r=this.get.bind(this),i={run:()=>{let s=dn(...t),l=e.get(rt);return s(l.state,l.dispatch,l)},inline:s=>(t.push(s),i),pipe:o.bind(this)};function o(s,l){let a=r(s);return t.push(a(l)),i}return i}}#t;#e;get ctx(){return this.#e}create(e,t){let r=e.create(this.#t.sliceMap);return r.set(t),r}get(e){return this.#t.get(e).get()}remove(e){return this.#t.remove(e)}call(e,t){if(this.#e==null)throw Qi();let i=this.get(e)(t),o=this.#e.get(rt);return i(o.state,o.dispatch,o)}inline(e){if(this.#e==null)throw Qi();let t=this.#e.get(rt);return e(t.state,t.dispatch,t)}};function _p(n="cmdKey"){return $((()=>()=>!1),n)}var G=$(new Is,"commands"),ps=$([ve],"commandsTimer"),Sr=He("CommandsReady"),Vp=n=>{let e=new Is;return e.setCtx(n),n.inject(G,e).inject(ps,[ve]).record(Sr),async()=>(await n.waitTimers(ps),n.done(Sr),()=>{n.remove(G).remove(ps).clearTimer(Sr)})};Et(Vp,{displayName:"Commands"});function Xw(n){let e=dn(hd,go,Af,Rl);return n.Backspace=e,n}var Ts=class{constructor(){this.#t=null,this.#e=[],this.setCtx=e=>{this.#t=e},this.add=e=>(this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([r,i])=>{if(typeof i=="function"){let o={key:r,onRun:()=>i};this.#e.push(o),t.push(()=>{this.#e=this.#e.filter(s=>s!==o)})}else this.#e.push(i),t.push(()=>{this.#e=this.#e.filter(o=>o!==i)})}),()=>{t.forEach(r=>r())}},this.addBaseKeymap=()=>{let e=Xw(Lf);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#e.forEach(r=>{e[r.key]=[...e[r.key]||[],r]}),Object.fromEntries(Object.entries(e).map(([r,i])=>{let o=i.sort((l,a)=>(a.priority??50)-(l.priority??50));return[r,(l,a,c)=>{let u=this.#t;if(u==null)throw Kn();let f=o.map(h=>h.onRun(u));return dn(...f)(l,a,c)}]}))}}#t;#e;get ctx(){return this.#t}},Pi=$(new Ts,"keymap"),lc=$([ve],"keymapTimer"),Cr=He("KeymapReady"),Zw=n=>{let e=new Ts;return e.setCtx(n),n.inject(Pi,e).inject(lc,[ve]).record(Cr),async()=>(await n.waitTimers(lc),n.done(Cr),()=>{n.remove(Pi).remove(lc).clearTimer(Cr)})},ms=He("ParserReady"),$p=(()=>{throw Kn()}),vi=$($p,"parser"),ac=$([],"parserTimer"),Wp=n=>(n.inject(vi,$p).inject(ac,[ve]).record(ms),async()=>{await n.waitTimers(ac);let e=n.get(An),t=n.get(Ot);return n.set(vi,ud.create(t,e)),n.done(ms),()=>{n.remove(vi).remove(ac).clearTimer(ms)}});Et(Wp,{displayName:"Parser"});var Mr=He("SerializerReady"),cc=$([],"serializerTimer"),jp=(()=>{throw Kn()}),Rn=$(jp,"serializer"),Hp=n=>(n.inject(Rn,jp).inject(cc,[ve]).record(Mr),async()=>{await n.waitTimers(cc);let e=n.get(An),t=n.get(Ot);return n.set(Rn,fd.create(t,e)),n.done(Mr),()=>{n.remove(Rn).remove(cc).clearTimer(Mr)}});Et(Hp,{displayName:"Serializer"});var gs=$("","defaultValue"),ys=$(n=>n,"stateOptions"),xs=$([],"editorStateTimer"),ks=He("EditorStateReady");function e0(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return on.fromSchema(t).parse(n.dom);if(n.type==="json")return Ae.fromJSON(t,n.value);throw Iu(n)}var t0=new re("MILKDOWN_STATE_TRACKER"),qp=n=>(n.inject(gs,"").inject(Ri,{}).inject(ys,e=>e).inject(xs,[ms,Mr,Sr,Cr]).record(ks),async()=>{await n.waitTimers(xs);let e=n.get(Ot),t=n.get(vi),r=n.get(Nr),i=n.get(ys),o=n.get(ct),s=n.get(gs),l=e0(s,t,e),a=n.get(Pi),c=a.addBaseKeymap(),u=[...o,new ne({key:t0,state:{init:()=>{},apply:(h,p,m,k)=>{n.set(Ri,k)}}}),kd({rules:r}),Md(a.build())];n.set(ct,u);let f=i({schema:e,doc:l,plugins:u}),d=mo.create(f);return n.set(Ri,d),n.done(ks),()=>{c(),n.remove(gs).remove(Ri).remove(ys).remove(xs).clearTimer(ks)}});Et(qp,{displayName:"EditorState"});var Os=$([],"pasteRule"),bs=$([ve],"pasteRuleTimer"),ws=He("PasteRuleReady"),Kp=n=>(n.inject(Os,[]).inject(bs,[ve]).record(ws),async()=>(await n.waitTimers(bs),n.done(ws),()=>{n.remove(Os).remove(bs).clearTimer(ws)}));Et(Kp,{displayName:"PasteRule"});var Di=He("EditorViewReady"),Ss=$([],"editorViewTimer"),uc=$({},"editorViewOptions"),Cs=$(null,"root"),fc=$(null,"rootDOM"),hc=$({},"rootAttrs");function n0(n,e){let t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(fc,t);let r=e.get(hc);return Object.entries(r).forEach(([i,o])=>t.setAttribute(i,o)),t}function r0(n){n.classList.add("editor"),n.setAttribute("role","textbox")}var i0=new re("MILKDOWN_VIEW_CLEAR"),Up=n=>(n.inject(Cs,document.body).inject(rt,{}).inject(uc,{}).inject(fc,null).inject(hc,{}).inject(Ss,[ks,ws]).record(Di),async()=>{await n.wait(Tt);let e=n.get(Cs)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(ct,a=>[new ne({key:i0,view:c=>{let u=t?n0(t,n):void 0;return(()=>{if(u&&t){let d=c.dom;t.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u?.parentNode&&u?.parentNode.replaceChild(c.dom,u),u?.remove()}}}}),...a]),await n.waitTimers(Ss);let r=n.get(Ri),i=n.get(uc),o=Object.fromEntries(n.get(Ms)),s=Object.fromEntries(n.get(Ns)),l=new Oi(t,{state:r,nodeViews:o,markViews:s,transformPasted:(a,c,u)=>(n.get(Os).sort((f,d)=>(d.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,c,u)}),a),...i});return r0(l.dom),n.set(rt,l),n.done(Di),()=>{l?.destroy(),n.remove(Cs).remove(rt).remove(uc).remove(fc).remove(hc).remove(Ss).clearTimer(Di)}});Et(Up,{displayName:"EditorView"});var dc=class n{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#s=new jr,this.#o=new Zi,this.#i=new Map,this.#l=new Map,this.#a=new Xi(this.#s,this.#o),this.#h=()=>{let e=Yw(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),t=[Fp,Wp,Hp,Vp,Zw,Kp,qp,Up,Qw(this),e];this.#c(t,this.#l)},this.#c=(e,t)=>{e.forEach(r=>{let i=this.#a.produce(this.#t?r.meta:void 0),o=r(i);t.set(r,{ctx:i,handler:o,cleanup:void 0})})},this.#u=(e,t=!1)=>Promise.all([e].flat().map(async r=>{let o=this.#i.get(r)?.cleanup;return t?this.#i.delete(r):this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof o=="function"?o():o})),this.#d=async()=>{await Promise.all([...this.#l.entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),this.#l.clear()},this.#f=e=>{this.#e=e,this.#n(e)},this.#p=e=>[...e.entries()].map(async([t,r])=>{let{ctx:i,handler:o}=r;if(!o)return;let s=await o();e.set(t,{ctx:i,handler:o,cleanup:s})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#r.push(e),this),this.removeConfig=e=>(this.#r=this.#r.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(r=>{this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(t,this.#i),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#u([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#f("OnCreate"),this.#h(),this.#c([...this.#i.keys()],this.#i),await Promise.all([this.#p(this.#l),this.#p(this.#i)].flat()),this.#f("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#r=[]),this.#f("OnDestroy"),await this.#u([...this.#i.keys()],e),await this.#d(),this.#f("Destroyed"),this),this.action=e=>e(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#i.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new n}#t;#e;#r;#n;#s;#o;#i;#l;#a;#h;#c;#u;#d;#f;#p;get ctx(){return this.#a}get status(){return this.#e}};var o0=n=>crypto.getRandomValues(new Uint8Array(n)),s0=(n,e,t)=>{let r=(2<<Math.log2(n.length-1))-1,i=-~(1.6*r*e/n.length);return(o=e)=>{let s="";for(;;){let l=t(i),a=i|0;for(;a--;)if(s+=n[l[a]&r]||"",s.length>=o)return s}}},Jp=(n,e=21)=>s0(n,e|0,o0);var KE=Jp("abcedfghicklmn",10);function J(n,e){let t=_p(n),r=i=>async()=>{r.key=t,await i.wait(Sr);let o=e(i);return i.get(G).create(t,o),r.run=s=>i.get(G).call(n,s),()=>{i.get(G).remove(t)}};return r}function Ge(n){let e=t=>async()=>{await t.wait(ve);let r=n(t);return t.update(Nr,i=>[...i,r]),e.inputRule=r,()=>{t.update(Nr,i=>i.filter(o=>o!==r))}};return e}function l0(n,e){let t=r=>async()=>{let i=e(r);return r.update(wr,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(wr,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(Ot).marks[n];if(!i)throw Du(n);return i},t}function Es(n,e){let t=r=>async()=>{let i=e(r);return r.update(br,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(br,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(Ot).nodes[n];if(!i)throw vu(n);return i},t}function ut(n){let e,t=r=>async()=>(await r.wait(ve),e=n(r),r.update(ct,i=>[...i,e]),()=>{r.update(ct,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function a0(n){let e=t=>async()=>{await t.wait(Cr);let r=t.get(Pi),i=n(t),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function $e(n,e){let t=$(n,e),r=i=>(i.inject(t),()=>()=>{i.remove(t)});return r.key=t,r}function We(n,e){let t=$e(e,n),r=Es(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.node=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>{let s=o(e);return We(n,s)},i}function Tr(n,e){let t=$e(e,n),r=l0(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.mark=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>{let s=o(e);return Tr(n,s)},i}function De(n,e){let t=Object.fromEntries(Object.entries(e).map(([s,{shortcuts:l,priority:a}])=>[s,{shortcuts:l,priority:a}])),r=$e(t,`${n}Keymap`),i=a0(s=>{let l=s.get(r.key),a=Object.entries(e).flatMap(([c,{command:u}])=>{let f=l[c],d=[f.shortcuts].flat(),h=f.priority;return d.map(p=>[p,{key:p,onRun:u,priority:h}])});return Object.fromEntries(a)}),o=[r,i];return o.ctx=r,o.shortcuts=i,o.key=r.key,o.keymap=i.keymap,o}var Ye=(n,e=()=>({}))=>$e(e,`${n}Attr`),Li=(n,e=()=>({}))=>$e(e,`${n}Attr`);function vn(n,e,t){let r=$e(t??{},n),i=s=>async()=>{await s.wait(Tt);let a={plugin:e(s),options:s.get(r.key)};return s.update(Ir,c=>[...c,a]),()=>{s.update(Ir,c=>c.filter(u=>u!==a))}},o=[r,i];return o.id=n,o.plugin=i,o.options=r,o}function c0(n,e){return t=>t.get(G).call(n,e)}function Gp(n,e){return function(t,r){let{$from:i,$to:o,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let l=i.node(-1);if(l.type!=n)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=n||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let f=M.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let x=i.depth-d;x>=i.depth-3;x--)f=M.from(i.node(x).copy(f));let h=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;f=f.append(M.from(n.createAndFill()));let p=i.before(i.depth-(d-1)),m=t.tr.replace(p,i.after(-h),new O(f,4-d,0)),k=-1;m.doc.nodesBetween(p,m.doc.content.size,(x,I)=>{if(k>-1)return!1;x.isTextblock&&x.content.size==0&&(k=I+1)}),k>-1&&m.setSelection(W.near(m.doc.resolve(k))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),u=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return un(c.doc,i.pos,2,u)?(r&&r(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Yp(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?u0(e,t,n,o):f0(e,t,o):!0:!1}}function u0(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new he(o-1,s,o,s,new O(M.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Kr(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let l=Yn(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return fn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function f0(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?M.empty:M.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new he(f-(l?1:0),d+(a?1:0),f+1,d-1,new O((l?M.empty:M.from(i.copy(M.empty))).append(a?M.empty:M.from(i.copy(M.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Qp(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=M.from(c?n.create():null),f=new O(M.from(n.create(null,M.from(l.type.create(null,u)))),c?3:1,0),d=o.start,h=o.end;t(e.tr.step(new he(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function pc(n){let e=new Map;if(!n||!n.type)throw new Error("mdast-util-definitions expected node");return et(n,"definition",function(r){let i=Xp(r.identifier);i&&!e.get(i)&&e.set(i,r)}),t;function t(r){let i=Xp(r);return e.get(i)}}function Xp(n){return String(n||"").toUpperCase()}function As(){return function(n){let e=pc(n);et(n,function(t,r,i){if(t.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[kn,r];if(t.type==="imageReference"||t.type==="linkReference"){let o=e(t.identifier);if(o&&i&&typeof r=="number")return i.children[r]=t.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:t.alt}:{type:"link",url:o.url,title:o.title,children:t.children},[kn,r]}})}}function Zp(n,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){n.next(e.content);return}let r=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&r.push(i)}),n.next(M.fromArray(r))}function w(n,e){return Object.assign(n,{meta:{package:"@milkdown/preset-commonmark",...e}}),n}var mc=Li("emphasis");w(mc,{displayName:"Attr<emphasis>",group:"Emphasis"});var Er=Tr("emphasis",n=>({attrs:{marker:{default:n.get(kr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",n.get(mc.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));w(Er.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});w(Er.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var vs=J("ToggleEmphasis",n=>()=>xo(Er.type(n)));w(vs,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var em=Ge(n=>wi(/(?:^|[^*])\*([^*]+)\*$/,Er.type(n),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));w(em,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var tm=Ge(n=>wi(/\b_(?![_\s])(.*?[^_\s])_\b/,Er.type(n),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));w(tm,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var gc=De("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:n=>{let e=n.get(G);return()=>e.call(vs.key)}}});w(gc.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});w(gc.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var yc=Li("strong");w(yc,{displayName:"Attr<strong>",group:"Strong"});var Bi=Tr("strong",n=>({attrs:{marker:{default:n.get(kr).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",n.get(yc.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));w(Bi.mark,{displayName:"MarkSchema<strong>",group:"Strong"});w(Bi.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Ds=J("ToggleStrong",n=>()=>xo(Bi.type(n)));w(Ds,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var nm=Ge(n=>wi(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),Bi.type(n),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));w(nm,{displayName:"InputRule<strong>",group:"Strong"});var xc=De("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:n=>{let e=n.get(G);return()=>e.call(Ds.key)}}});w(xc.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});w(xc.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var kc=Li("inlineCode");w(kc,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Jt=Tr("inlineCode",n=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:e=>["code",n.get(kc.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,r)=>{e.openMark(r),e.addText(t.value),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,r)=>{e.withMark(t,"inlineCode",r.text||"")}}}));w(Jt.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});w(Jt.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var bc=J("ToggleInlineCode",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(r.empty)return!1;let{from:o,to:s}=r;return e.doc.rangeHasMark(o,s,Jt.type(n))?(t?.(i.removeMark(o,s,Jt.type(n))),!0):(Object.keys(e.schema.marks).filter(c=>c!==Jt.type.name).map(c=>e.schema.marks[c]).forEach(c=>{i.removeMark(o,s,c)}),t?.(i.addMark(o,s,Jt.type(n).create())),!0)});w(bc,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var rm=Ge(n=>wi(/(?:`)([^`]+)(?:`)$/,Jt.type(n)));w(rm,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var wc=De("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:n=>{let e=n.get(G);return()=>e.call(bc.key)}}});w(wc.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});w(wc.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Sc=Li("link");w(Sc,{displayName:"Attr<link>",group:"Link"});var Or=Tr("link",n=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...n.get(Sc.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,r)=>{let i=t.url,o=t.title;e.openMark(r,{href:i,title:o}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));w(Or.mark,{displayName:"MarkSchema<link>",group:"Link"});var im=J("ToggleLink",n=>(e={})=>xo(Or.type(n),e));w(im,{displayName:"Command<toggleLinkCommand>",group:"Link"});var om=J("UpdateLink",n=>(e={})=>(t,r)=>{if(!r)return!1;let i,o=-1,{selection:s}=t,{from:l,to:a}=s;if(t.doc.nodesBetween(l,l===a?a+1:a,(p,m)=>{if(Or.type(n).isInSet(p.marks))return i=p,o=m,!1}),!i)return!1;let c=i.marks.find(({type:p})=>p===Or.type(n));if(!c)return!1;let u=o,f=o+i.nodeSize,{tr:d}=t,h=Or.type(n).create({...c.attrs,...e});return h?(r(d.removeMark(u,f,c).addMark(u,f,h).setSelection(new j(d.selection.$anchor)).scrollIntoView()),!0):!1});w(om,{displayName:"Command<updateLinkCommand>",group:"Link"});var sm=Es("doc",()=>({content:"block+",parseMarkdown:{match:({type:n})=>n==="root",runner:(n,e,t)=>{n.injectRoot(e,t)}},toMarkdown:{match:n=>n.type.name==="doc",runner:(n,e)=>{n.openNode("root"),n.next(e.content)}}}));w(sm,{displayName:"NodeSchema<doc>",group:"Doc"});function h0(n){return ci(n,e=>e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let r=t[t.length-1];if(!r)return;let i=r.children.indexOf(e);i!==-1&&r.children.splice(i,1)},!0)}var Ps=vn("remark-preserve-empty-line",()=>()=>h0);w(Ps.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});w(Ps.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Cc=Ye("paragraph");w(Cc,{displayName:"Attr<paragraph>",group:"Paragraph"});var Pn=We("paragraph",n=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",n.get(Cc.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,r)=>{e.openNode(r),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{let i=n.get(rt).state?.doc.lastChild;e.openNode("paragraph"),(!t.content||t.content.size===0)&&t!==i&&d0(n)?e.addNode("html",void 0,"<br />"):Zp(e,t),e.closeNode()}}}));function d0(n){let e=!1;try{n.get(Ps.id),e=!0}catch{e=!1}return e}w(Pn.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});w(Pn.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Ls=J("TurnIntoText",n=>()=>er(Pn.type(n)));w(Ls,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Mc=De("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:n=>{let e=n.get(G);return()=>e.call(Ls.key)}}});w(Mc.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});w(Mc.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var p0=Array(6).fill(0).map((n,e)=>e+1);function m0(n){return n.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var Bs=$e(m0,"headingIdGenerator");w(Bs,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Nc=Ye("heading");w(Nc,{displayName:"Attr<heading>",group:"Heading"});var Ln=We("heading",n=>{let e=n.get(Bs.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:p0.map(t=>({tag:`h${t}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Lt(r);return{level:t,id:r.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...n.get(Nc.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,r,i)=>{let o=r.depth;t.openNode(i,{level:o}),t.next(r.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,r)=>{t.openNode("heading",void 0,{depth:r.attrs.level}),Zp(t,r),t.closeNode()}}}});w(Ln.node,{displayName:"NodeSchema<heading>",group:"Heading"});w(Ln.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var lm=Ge(n=>Ca(/^(?<hashes>#+)\s$/,Ln.type(n),e=>{let t=e.groups?.hashes?.length||0,r=n.get(rt),{$from:i}=r.state.selection,o=i.node();if(o.type.name==="heading"){let s=Number(o.attrs.level)+Number(t);return s>6&&(s=6),{level:s}}return{level:t}}));w(lm,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var At=J("WrapInHeading",n=>e=>(e??=1,e<1?er(Pn.type(n)):er(Ln.type(n),{level:e})));w(At,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Ic=J("DowngradeHeading",n=>()=>(e,t,r)=>{let{$from:i}=e.selection,o=i.node();if(o.type!==Ln.type(n)||!e.selection.empty||i.parentOffset!==0)return!1;let s=o.attrs.level-1;return s?(t?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):er(Pn.type(n))(e,t,r)});w(Ic,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Tc=De("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:n=>{let e=n.get(G);return()=>e.call(At.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:n=>{let e=n.get(G);return()=>e.call(At.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:n=>{let e=n.get(G);return()=>e.call(At.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:n=>{let e=n.get(G);return()=>e.call(At.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:n=>{let e=n.get(G);return()=>e.call(At.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:n=>{let e=n.get(G);return()=>e.call(At.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:n=>{let e=n.get(G);return()=>e.call(Ic.key)}}});w(Tc.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});w(Tc.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Oc=Ye("blockquote");w(Oc,{displayName:"Attr<blockquote>",group:"Blockquote"});var zi=We("blockquote",n=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",n.get(Oc.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,r)=>{e.openNode(r).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));w(zi.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});w(zi.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var am=Ge(n=>Yo(/^\s*>\s$/,zi.type(n)));w(am,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var zs=J("WrapInBlockquote",n=>()=>yo(zi.type(n)));w(zs,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Ec=De("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:n=>{let e=n.get(G);return()=>e.call(zs.key)}}});w(Ec.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});w(Ec.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Ac=Ye("codeBlock",()=>({pre:{},code:{}}));w(Ac,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Fi=We("code_block",n=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{language:e.dataset.language}}}],toDOM:e=>{let t=n.get(Ac.key)(e),r=e.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...t.pre,...i},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,r)=>{let i=t.lang??"",o=t.value;e.openNode(r,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));w(Fi.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});w(Fi.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var cm=Ge(n=>Ca(/^```(?<language>[a-z]*)?[\s\n]$/,Fi.type(n),e=>({language:e.groups?.language??""})));w(cm,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Rc=J("CreateCodeBlock",n=>(e="")=>er(Fi.type(n),{language:e}));w(Rc,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var g0=J("UpdateCodeBlockLanguage",()=>({pos:n,language:e}={pos:-1,language:""})=>(t,r)=>n>=0?(r?.(t.tr.setNodeAttribute(n,"language",e)),!0):!1);w(g0,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var vc=De("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:n=>{let e=n.get(G);return()=>e.call(Rc.key)}}});w(vc.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});w(vc.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Dc=Ye("image");w(Dc,{displayName:"Attr<image>",group:"Image"});var Ar=We("image",n=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...n.get(Dc.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,r)=>{let i=t.url,o=t.alt,s=t.title;e.addNode(r,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));w(Ar.node,{displayName:"NodeSchema<image>",group:"Image"});w(Ar.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var um=J("InsertImage",n=>(e={})=>(t,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=e,l=Ar.type(n).create({src:i,alt:o,title:s});return l&&r(t.tr.replaceSelectionWith(l).scrollIntoView()),!0});w(um,{displayName:"Command<insertImageCommand>",group:"Image"});var fm=J("UpdateImage",n=>(e={})=>(t,r)=>{let i=wd(t.selection,Ar.type(n));if(!i)return!1;let{node:o,pos:s}=i,l={...o.attrs},{src:a,alt:c,title:u}=e;return a!==void 0&&(l.src=a),c!==void 0&&(l.alt=c),u!==void 0&&(l.title=u),r?.(t.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0});w(fm,{displayName:"Command<updateImageCommand>",group:"Image"});var y0=Ge(n=>new Ne(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,r,i)=>{let[o,s,l="",a]=t;return o?e.tr.replaceWith(r,i,Ar.type(n).create({src:l,alt:s,title:a})):null}));w(y0,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Rs=Ye("hardbreak",n=>({"data-type":"hardbreak","data-is-inline":n.attrs.isInline}));w(Rs,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Dn=We("hardbreak",n=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",n.get(Rs.key)(e)," "]:["br",n.get(Rs.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,r)=>{e.addNode(r,{isInline:!!t.data?.isInline})}},leafText:()=>` 44 + `))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:h}=n.state,p=sn.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let k=s.appendChild(document.createElement("p"));m&&k.appendChild(p.serializeNode(h.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=cw(t),Ai&&uw(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||on.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!sw.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=fw(qd(l,+u[1],+u[2]),u[4]);else if(l=O.maxOpen(lw(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=qd(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var sw=/^(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 lw(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)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Sp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Cp(s[s.length-1],o.length));let u=wp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return M.from(s)}return n}function wp(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,M.from(n));return n}function Sp(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=Sp(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(M.from(wp(t,n,i+1))))}}function Cp(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Cp(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(r))}function Ka(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(o=0),i<r-1&&(l=Ka(l,e,t,r,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function qd(n,e,t){return e<n.openStart&&(n=new O(Ka(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(Ka(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Mp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Kd=null;function Np(){return Kd||(Kd=document.implementation.createHTMLDocument("title"))}var va=null;function aw(n){let e=window.trustedTypes;return e?(va||(va=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),va.createHTML(n)):n}function cw(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Np().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Mp[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=aw(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function uw(n){let e=n.querySelectorAll(me?"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=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fw(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:o,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=M.from(a.create(r[l+1],i)),o++,s++}return new O(i,o,s)}var Te={},Oe={},hw={touchstart:!0,touchmove:!0},Ua=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function dw(n){for(let e in Te){let t=Te[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{mw(n,r)&&!rc(n,r)&&(n.editable||!(r.type in Oe))&&t(n,r)},hw[e]?{passive:!0}:void 0)}we&&n.dom.addEventListener("input",()=>null),Ja(n)}function Ht(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function pw(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 Ja(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rc(n,r))})}function rc(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function mw(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 gw(n,e){!rc(n,e)&&Te[e.type]&&(n.editable||!(e.type in Oe))&&Te[e.type](n,e)}Oe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Tp(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Nt&&me&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),yr&&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,Sn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ow(n,t)?t.preventDefault():Ht(n,"key")};Oe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Oe.keypress=(n,e)=>{let t=e;if(Tp(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof j)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function fs(n){return{left:n.clientX,top:n.clientY}}function yw(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ic(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function mr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function xw(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(mr(n,new B(t),"pointer"),!0):!1}function kw(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof B&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(B.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(mr(n,B.create(n.state.doc,i),"pointer"),!0):!1}function bw(n,e,t,r,i){return ic(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?kw(n,t):xw(n,t))}function ww(n,e,t,r){return ic(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Sw(n,e,t,r){return ic(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Cw(n,t,r)}function Cw(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(mr(n,j.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)mr(n,j.create(r,l+1,l+1+s.content.size),"pointer");else if(B.isSelectable(s))mr(n,B.create(r,l),"pointer");else continue;return!0}}function oc(n){return is(n)}var Ip=qe?"metaKey":"ctrlKey";Te.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=oc(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&yw(t,n.input.lastClick)&&!t[Ip]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=n.posAtCoords(fs(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ga(n,s,t,!!r)):(o=="doubleClick"?ww:Sw)(n,s.pos,s.inside,t)?t.preventDefault():Ht(n,"pointer"))};var Ga=class{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[Ip],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof B&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ue&&!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)),Ht(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(()=>It(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(fs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ht(this.view,"pointer"):bw(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||we&&this.mightDrag&&!this.mightDrag.node.isAtom||me&&!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)?(mr(this.view,W.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ht(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ht(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)}};Te.touchstart=n=>{n.input.lastTouch=Date.now(),oc(n),Ht(n,"pointer")};Te.touchmove=n=>{n.input.lastTouch=Date.now(),Ht(n,"pointer")};Te.contextmenu=n=>oc(n);function Tp(n,e){return n.composing?!0:we&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Mw=Nt?5e3:-1;Oe.compositionstart=Oe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof j&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||me&&sp&&Nw(n)))n.markCursor=n.state.storedMarks||t.marks(),is(n,!0),n.markCursor=null;else if(is(n,!e.selection.empty),Ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Op(n,Mw)};function Nw(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Oe.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.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Op(n,20))};function Op(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>is(n),e))}function Ep(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Tw());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Iw(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Cb(e.focusNode,e.focusOffset),r=Mb(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Tw(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function is(n,e=!1){if(!(Nt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ep(n),e||n.docView&&n.docView.dirty){let t=ec(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ow(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)}var Ni=Re&&qt<15||yr&&Ob<604;Te.copy=Oe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Ni?null:t.clipboardData,s=r.content(),{dom:l,text:a}=nc(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ow(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ew(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Aw(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?Ii(n,r.value,null,i,e):Ii(n,r.textContent,r.innerHTML,i,e)},50)}function Ii(n,e,t,r,i){let o=bp(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||O.empty)))return!0;if(!o)return!1;let s=Ew(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ap(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," "):""}Oe.paste=(n,e)=>{let t=e;if(n.composing&&!Nt)return;let r=Ni?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ii(n,Ap(r),r.getData("text/html"),i,t)?t.preventDefault():Aw(n,t)};var ss=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Rw=qe?"altKey":"ctrlKey";function Rp(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Rw]}Te.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(fs(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof B?i.to-1:i.to))){if(r&&r.mightDrag)s=B.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=B.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=nc(n,l);(!t.dataTransfer.files.length||!me||op>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ni?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ni||t.dataTransfer.setData("text/plain",c),n.dragging=new ss(u,Rp(n,t),s)};Te.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Oe.dragover=Oe.dragenter=(n,e)=>e.preventDefault();Oe.drop=(n,e)=>{try{vw(n,e,n.dragging)}finally{n.dragging=null}};function vw(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(fs(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=bp(n,Ap(e.dataTransfer),Ni?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Rp(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||O.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?mf(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&B.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new B(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,k,x)=>h=x),a.setSelection(tc(n,d,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Te.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())&&It(n)},20))};Te.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)};Te.beforeinput=(n,e)=>{if(me&&Nt&&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",o=>o(n,Sn(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 Oe)Te[n]=Oe[n];function Ti(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}var ls=class n{constructor(e,t){this.toDOM=e,this.spec=t||In,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new nt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ti(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Nn=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new nt(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Ti(this.attrs,e.attrs)&&Ti(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Ya=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new nt(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Ti(this.attrs,e.attrs)&&Ti(this.spec,e.spec)}destroy(){}},nt=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(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 n(e,e,new ls(t,r))}static inline(e,t,r,i){return new n(e,t,new Nn(r,i))}static node(e,t,r,i){return new n(e,t,new Ya(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Nn}get widget(){return this.type instanceof ls}},pr=[],In={},Ie=class n{constructor(e,t){this.local=e.length?e:pr,this.children=t.length?t:pr}static create(e,t){return t.length?cs(t,e,0,In):be}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==be||e.maps.length==0?this:this.mapInner(e,t,0,0,r||In)}mapInner(e,t,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Dw(this.children,s||[],e,t,r,i,o):s?new n(s.sort(Tn),pr):be}add(e,t){return t.length?this==be?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Dp(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,cs(u,l,c+1,In)),o+=3}});let s=vp(o?Pp(t):t,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new n(s.length?this.local.concat(s).sort(Tn):this.local,i||this.children)}remove(e){return e.length==0||this==be?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+t,a=r[o+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=be?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,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 n(i,r):be}forChild(e,t){if(this==be)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Nn){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new n(i.sort(Tn),pr);return r?new as([l,r]):l}return r||be}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 sc(this.localsInner(e))}localsInner(e){if(this==be)return pr;if(e.inlineContent||!this.local.some(Nn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Nn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Ie.empty=new Ie([],[]);Ie.removeOverlap=sc;var be=Ie.empty,as=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,In));return n.from(r)}forChild(e,t){if(t.isLeaf)return Ie.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=be&&(o instanceof n?r=r.concat(o.members):r.push(o))}return n.from(r)}eq(e){if(!(e instanceof n)||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 o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?sc(r?t:t.sort(Tn)):pr}static from(e){switch(e.length){case 0:return be;case 1:return e[0];default:return new n(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 Dw(n,e,t,r,i,o,s){let l=n.slice();for(let c=0,u=o;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,m)=>{let k=m-p-(h-d);for(let x=0;x<l.length;x+=3){let I=l[x+1];if(I<0||d>I+u-f)continue;let C=l[x]+u-f;h>=C?l[x+1]=d<=C?-2:-1:d>=u&&k&&(l[x]+=k,l[x+1]+=k)}f+=k}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),h=d-i,{index:p,offset:m}=r.content.findIndex(f),k=r.maybeChild(p);if(k&&m==f&&m+k.nodeSize==h){let x=l[c+2].mapInner(t,k,u+1,n[c]+o+1,s);x!=be?(l[c]=f,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Pw(l,n,e,t,i,o,s),u=cs(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new Ie(e.sort(Tn),l)}function vp(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 nt(i.from+e,i.to+e,i.type))}return t}function Pw(n,e,t,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?t.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function Dp(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function Pp(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function cs(n,e,t,r){let i=[],o=!1;e.forEach((l,a)=>{let c=Dp(n,l,a+t);if(c){o=!0;let u=cs(c,l,t+a+1,r);u!=be&&i.push(a,a+l.nodeSize,u)}});let s=vp(o?Pp(n):n,-t).sort(Tn);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Ie(s,i):be}function Tn(n,e){return n.from-e.from||n.to-e.to}function sc(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 o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),Ud(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Ud(e,i,r.copy(o.from,r.to)));break}}}return e}function Ud(n,e,t){for(;e<n.length&&Tn(t,n[e])>0;)e++;n.splice(e,0,t)}function Da(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=be&&e.push(r)}),n.cursorWrapper&&e.push(Ie.create(n.state.doc,[n.cursorWrapper.deco])),as.from(e)}var Lw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Bw=Re&&qt<=11,Qa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Xa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Qa,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]);Re&&qt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():we&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Bw&&(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,Lw)),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(_d(this.view)){if(this.suppressingSelectionUpdates)return It(this.view);if(Re&&qt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&On(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 o=e.focusNode;o;o=gr(o))t.add(o);for(let o=e.anchorNode;o;o=gr(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&_d(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Ue&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||_w(e,f)!=h)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&us(r)&&(c=ec(e))&&c.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,It(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),zw(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Vw(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||It(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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(Re&&qt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?pe(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?pe(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Jd=new WeakMap,Gd=!1;function zw(n){if(!Jd.has(n)&&(Jd.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ue,Gd)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."),Gd=!0}}function Yd(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return On(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function Fw(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Yd(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?Yd(n,t):null}function _w(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 Vw(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function $w(n,e,t){let{node:r,fromOffset:i,toOffset:o,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],us(a)||c.push({node:a.focusNode,offset:a.focusOffset})),me&&n.input.lastKeyCode===8)for(let k=o;k>i;k--){let x=r.childNodes[k-1],I=x.pmViewDesc;if(x.nodeName=="BR"&&!I){o=k;break}if(!I||I.size)break}let f=n.state.doc,d=n.someProp("domParser")||on.fromSchema(n.state.schema),h=f.resolve(s),p=null,m=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ww,context:h});if(c&&c[0].pos!=null){let k=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=k),p={anchor:k+s,head:x+s}}return{doc:m,sel:p,from:s,to:l}}function Ww(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(we&&/^(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||we&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var jw=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Hw(n,e,t,r,i){let o=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,P=ec(n,T);if(P&&!n.state.selection.eq(P)){if(me&&Nt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",U=>U(n,Sn(13,"Enter"))))return;let D=n.state.tr.setSelection(P);T=="pointer"?D.setMeta("pointer",!0):T=="key"&&D.scrollIntoView(),o&&D.setMeta("composition",o),n.dispatch(D)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=$w(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Uw(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(yr&&n.input.lastIOSEnter>Date.now()-225||Nt)&&i.some(T=>T.nodeType==1&&!jw.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof j&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Qd(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let P=n.state.tr.setSelection(T);o&&P.setMeta("composition",o),n.dispatch(P)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof j&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Re&&qt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),k=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),I=m.sameParent(k)&&m.parent.inlineContent&&x.end()>=p.endA;if((yr&&n.input.lastIOSEnter>Date.now()-225&&(!I||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!I&&m.pos<c.doc.content.size&&(!m.sameParent(k)||!m.parent.inlineContent)&&m.pos<k.pos&&!/\S/.test(c.doc.textBetween(m.pos,k.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Kw(u,p.start,p.endA,m,k)&&n.someProp("handleKeyDown",T=>T(n,Sn(8,"Backspace")))){Nt&&me&&n.domObserver.suppressSelectionUpdates();return}me&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Nt&&!I&&m.start()!=k.start()&&k.parentOffset==0&&m.depth==k.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,k=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Sn(13,"Enter"))})},20));let C=p.start,A=p.endA,v=T=>{let P=T||n.state.tr.replace(C,A,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let D=Qd(n,P.doc,c.sel);D&&!(me&&n.composing&&D.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==C||D.head==P.mapping.map(A)-1)||Re&&D.empty&&D.head==C)&&P.setSelection(D)}return o&&P.setMeta("composition",o),P.scrollIntoView()},b;if(I)if(m.pos==k.pos){Re&&qt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>It(n),20));let T=v(n.state.tr.delete(C,A)),P=u.resolve(p.start).marksAcross(u.resolve(p.endA));P&&T.ensureMarks(P),n.dispatch(T)}else if(p.endA==p.endB&&(b=qw(m.parent.content.cut(m.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let T=v(n.state.tr);b.type=="add"?T.addMark(C,A,b.mark):T.removeMark(C,A,b.mark),n.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==k.index()-(k.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,k.parentOffset),P=()=>v(n.state.tr.insertText(T,C,A));n.someProp("handleTextInput",D=>D(n,C,A,T,P))||n.dispatch(P())}else n.dispatch(v());else n.dispatch(v())}function Qd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:tc(n,e.resolve(t.anchor),e.resolve(t.head))}function qw(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(M.from(c).eq(n))return{mark:l,type:s}}function Kw(n,e,t,r,i){if(t-e<=i.pos-r.pos||Pa(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(Pa(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Pa(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Pa(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 o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Uw(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s<o&&n.size<e.size){let a=r<=o&&r>=s?o-r:0;o-=a,o&&o<e.size&&Xd(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&Xd(n.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function Xd(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}var Oi=class{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 Ua,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(rp),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=tp(this),ep(this),this.nodeViews=np(this),this.docView=Dd(this.state.doc,Zd(this),Da(this),this.dom,this),this.domObserver=new Xa(this,(r,i,o,s)=>Hw(this,r,i,o,s)),this.domObserver.start(),dw(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&&Ja(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(rp),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,o=!1,s=!1;e.storedMarks&&this.composing&&(Ep(this),s=!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 h=np(this);Gw(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ja(this),this.editable=tp(this),ep(this);let a=Da(this),c=Zd(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Rb(this);if(s){this.domObserver.stop();let h=f&&(Re||me)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Jw(i.selection,e.selection);if(f){let p=me?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Iw(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Dd(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Xb(this))?It(this,h):(yp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&vb(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Td(this,t.getBoundingClientRect(),e)}else Td(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 o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new ss(e.slice,e.move,i<0?void 0:B.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 s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(Re){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&&Db(this.dom),It(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 Fb(this,e)}coordsAtPos(e,t=1){return fp(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 jb(this,t||this.state,e)}pasteHTML(e,t){return Ii(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ii(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return nc(this,e)}destroy(){this.docView&&(pw(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Da(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return gw(this,e)}domSelectionRange(){let e=this.domSelection();return e?we&&this.root.nodeType===11&&Ib(this.dom.ownerDocument)==this.dom&&Fw(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Oi.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Zd(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"),[nt.node(0,n.state.doc.content.size,e)]}function ep(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:nt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function tp(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Jw(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 np(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 Gw(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 rp(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")}function Et(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}var zp={text:(n,e,t,r)=>{let i=n.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...r,encode:[]})},strong:(n,e,t,r)=>{let i=n.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(r),l=s.move(i+i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},emphasis:(n,e,t,r)=>{let i=n.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(r),l=s.move(i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l}},rt=$({},"editorView"),Ri=$({},"editorState"),lc=$([],"initTimer"),Lp=$({},"editor"),Nr=$([],"inputRules"),ct=$([],"prosePlugins"),Ir=$([],"remarkPlugins"),Ns=$([],"nodeView"),Is=$([],"markView"),An=$(di().use(ir).use(cr),"remark"),kr=$({handlers:zp,encode:[]},"remarkStringifyOptions"),hs=He("ConfigReady");function Yw(n){let e=t=>(t.record(hs),async()=>(await n(t),t.done(hs),()=>{t.clearTimer(hs)}));return Et(e,{displayName:"Config"}),e}var Tt=He("InitReady");function Qw(n){let e=t=>(t.inject(Lp,n).inject(ct,[]).inject(Ir,[]).inject(Nr,[]).inject(Ns,[]).inject(Is,[]).inject(kr,{handlers:zp,encode:[]}).inject(An,di().use(ir).use(cr)).inject(lc,[hs]).record(Tt),async()=>{await t.waitTimers(lc);let r=t.get(kr);return t.set(An,di().use(ir).use(cr,r)),t.done(Tt),()=>{t.remove(Lp).remove(ct).remove(Ir).remove(Nr).remove(Ns).remove(Is).remove(kr).remove(An).remove(lc).clearTimer(Tt)}});return Et(e,{displayName:"Init"}),e}var ve=He("SchemaReady"),ds=$([],"schemaTimer"),Ot=$({},"schema"),br=$([],"nodes"),wr=$([],"marks");function Bp(n){return{...n,parseDOM:n.parseDOM?.map(e=>({priority:n.priority,...e}))}}var Fp=n=>(n.inject(Ot,{}).inject(br,[]).inject(wr,[]).inject(ds,[Tt]).record(ve),async()=>{await n.waitTimers(ds);let e=n.get(An),r=n.get(Ir).reduce((l,a)=>l.use(a.plugin,a.options),e);n.set(An,r);let i=Object.fromEntries(n.get(br).map(([l,a])=>[l,Bp(a)])),o=Object.fromEntries(n.get(wr).map(([l,a])=>[l,Bp(a)])),s=new so({nodes:i,marks:o});return n.set(Ot,s),n.done(ve),()=>{n.remove(Ot).remove(br).remove(wr).remove(ds).clearTimer(ve)}});Et(Fp,{displayName:"Schema"});var Ts=class{constructor(){this.#t=new jr,this.#e=null,this.setCtx=e=>{this.#e=e},this.chain=()=>{if(this.#e==null)throw Qi();let e=this.#e,t=[],r=this.get.bind(this),i={run:()=>{let s=dn(...t),l=e.get(rt);return s(l.state,l.dispatch,l)},inline:s=>(t.push(s),i),pipe:o.bind(this)};function o(s,l){let a=r(s);return t.push(a(l)),i}return i}}#t;#e;get ctx(){return this.#e}create(e,t){let r=e.create(this.#t.sliceMap);return r.set(t),r}get(e){return this.#t.get(e).get()}remove(e){return this.#t.remove(e)}call(e,t){if(this.#e==null)throw Qi();let i=this.get(e)(t),o=this.#e.get(rt);return i(o.state,o.dispatch,o)}inline(e){if(this.#e==null)throw Qi();let t=this.#e.get(rt);return e(t.state,t.dispatch,t)}};function _p(n="cmdKey"){return $((()=>()=>!1),n)}var G=$(new Ts,"commands"),ps=$([ve],"commandsTimer"),Sr=He("CommandsReady"),Vp=n=>{let e=new Ts;return e.setCtx(n),n.inject(G,e).inject(ps,[ve]).record(Sr),async()=>(await n.waitTimers(ps),n.done(Sr),()=>{n.remove(G).remove(ps).clearTimer(Sr)})};Et(Vp,{displayName:"Commands"});function Xw(n){let e=dn(hd,go,Af,vl);return n.Backspace=e,n}var Os=class{constructor(){this.#t=null,this.#e=[],this.setCtx=e=>{this.#t=e},this.add=e=>(this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([r,i])=>{if(typeof i=="function"){let o={key:r,onRun:()=>i};this.#e.push(o),t.push(()=>{this.#e=this.#e.filter(s=>s!==o)})}else this.#e.push(i),t.push(()=>{this.#e=this.#e.filter(o=>o!==i)})}),()=>{t.forEach(r=>r())}},this.addBaseKeymap=()=>{let e=Xw(Lf);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#e.forEach(r=>{e[r.key]=[...e[r.key]||[],r]}),Object.fromEntries(Object.entries(e).map(([r,i])=>{let o=i.sort((l,a)=>(a.priority??50)-(l.priority??50));return[r,(l,a,c)=>{let u=this.#t;if(u==null)throw Kn();let f=o.map(h=>h.onRun(u));return dn(...f)(l,a,c)}]}))}}#t;#e;get ctx(){return this.#t}},Pi=$(new Os,"keymap"),ac=$([ve],"keymapTimer"),Cr=He("KeymapReady"),Zw=n=>{let e=new Os;return e.setCtx(n),n.inject(Pi,e).inject(ac,[ve]).record(Cr),async()=>(await n.waitTimers(ac),n.done(Cr),()=>{n.remove(Pi).remove(ac).clearTimer(Cr)})},ms=He("ParserReady"),$p=(()=>{throw Kn()}),vi=$($p,"parser"),cc=$([],"parserTimer"),Wp=n=>(n.inject(vi,$p).inject(cc,[ve]).record(ms),async()=>{await n.waitTimers(cc);let e=n.get(An),t=n.get(Ot);return n.set(vi,ud.create(t,e)),n.done(ms),()=>{n.remove(vi).remove(cc).clearTimer(ms)}});Et(Wp,{displayName:"Parser"});var Mr=He("SerializerReady"),uc=$([],"serializerTimer"),jp=(()=>{throw Kn()}),Rn=$(jp,"serializer"),Hp=n=>(n.inject(Rn,jp).inject(uc,[ve]).record(Mr),async()=>{await n.waitTimers(uc);let e=n.get(An),t=n.get(Ot);return n.set(Rn,fd.create(t,e)),n.done(Mr),()=>{n.remove(Rn).remove(uc).clearTimer(Mr)}});Et(Hp,{displayName:"Serializer"});var gs=$("","defaultValue"),ys=$(n=>n,"stateOptions"),xs=$([],"editorStateTimer"),ks=He("EditorStateReady");function e0(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return on.fromSchema(t).parse(n.dom);if(n.type==="json")return Ae.fromJSON(t,n.value);throw Iu(n)}var t0=new re("MILKDOWN_STATE_TRACKER"),qp=n=>(n.inject(gs,"").inject(Ri,{}).inject(ys,e=>e).inject(xs,[ms,Mr,Sr,Cr]).record(ks),async()=>{await n.waitTimers(xs);let e=n.get(Ot),t=n.get(vi),r=n.get(Nr),i=n.get(ys),o=n.get(ct),s=n.get(gs),l=e0(s,t,e),a=n.get(Pi),c=a.addBaseKeymap(),u=[...o,new ne({key:t0,state:{init:()=>{},apply:(h,p,m,k)=>{n.set(Ri,k)}}}),kd({rules:r}),Md(a.build())];n.set(ct,u);let f=i({schema:e,doc:l,plugins:u}),d=mo.create(f);return n.set(Ri,d),n.done(ks),()=>{c(),n.remove(gs).remove(Ri).remove(ys).remove(xs).clearTimer(ks)}});Et(qp,{displayName:"EditorState"});var Es=$([],"pasteRule"),bs=$([ve],"pasteRuleTimer"),ws=He("PasteRuleReady"),Kp=n=>(n.inject(Es,[]).inject(bs,[ve]).record(ws),async()=>(await n.waitTimers(bs),n.done(ws),()=>{n.remove(Es).remove(bs).clearTimer(ws)}));Et(Kp,{displayName:"PasteRule"});var Di=He("EditorViewReady"),Ss=$([],"editorViewTimer"),Cs=$({},"editorViewOptions"),Ms=$(null,"root"),fc=$(null,"rootDOM"),hc=$({},"rootAttrs");function n0(n,e){let t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(fc,t);let r=e.get(hc);return Object.entries(r).forEach(([i,o])=>t.setAttribute(i,o)),t}function r0(n){n.classList.add("editor"),n.setAttribute("role","textbox")}var i0=new re("MILKDOWN_VIEW_CLEAR"),Up=n=>(n.inject(Ms,document.body).inject(rt,{}).inject(Cs,{}).inject(fc,null).inject(hc,{}).inject(Ss,[ks,ws]).record(Di),async()=>{await n.wait(Tt);let e=n.get(Ms)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(ct,a=>[new ne({key:i0,view:c=>{let u=t?n0(t,n):void 0;return(()=>{if(u&&t){let d=c.dom;t.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u?.parentNode&&u?.parentNode.replaceChild(c.dom,u),u?.remove()}}}}),...a]),await n.waitTimers(Ss);let r=n.get(Ri),i=n.get(Cs),o=Object.fromEntries(n.get(Ns)),s=Object.fromEntries(n.get(Is)),l=new Oi(t,{state:r,nodeViews:o,markViews:s,transformPasted:(a,c,u)=>(n.get(Es).sort((f,d)=>(d.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,c,u)}),a),...i});return r0(l.dom),n.set(rt,l),n.done(Di),()=>{l?.destroy(),n.remove(Ms).remove(rt).remove(Cs).remove(fc).remove(hc).remove(Ss).clearTimer(Di)}});Et(Up,{displayName:"EditorView"});var dc=class n{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#s=new jr,this.#o=new Zi,this.#i=new Map,this.#l=new Map,this.#a=new Xi(this.#s,this.#o),this.#h=()=>{let e=Yw(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),t=[Fp,Wp,Hp,Vp,Zw,Kp,qp,Up,Qw(this),e];this.#c(t,this.#l)},this.#c=(e,t)=>{e.forEach(r=>{let i=this.#a.produce(this.#t?r.meta:void 0),o=r(i);t.set(r,{ctx:i,handler:o,cleanup:void 0})})},this.#u=(e,t=!1)=>Promise.all([e].flat().map(async r=>{let o=this.#i.get(r)?.cleanup;return t?this.#i.delete(r):this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof o=="function"?o():o})),this.#d=async()=>{await Promise.all([...this.#l.entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),this.#l.clear()},this.#f=e=>{this.#e=e,this.#n(e)},this.#p=e=>[...e.entries()].map(async([t,r])=>{let{ctx:i,handler:o}=r;if(!o)return;let s=await o();e.set(t,{ctx:i,handler:o,cleanup:s})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#r.push(e),this),this.removeConfig=e=>(this.#r=this.#r.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(r=>{this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(t,this.#i),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#u([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#f("OnCreate"),this.#h(),this.#c([...this.#i.keys()],this.#i),await Promise.all([this.#p(this.#l),this.#p(this.#i)].flat()),this.#f("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#r=[]),this.#f("OnDestroy"),await this.#u([...this.#i.keys()],e),await this.#d(),this.#f("Destroyed"),this),this.action=e=>e(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#i.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new n}#t;#e;#r;#n;#s;#o;#i;#l;#a;#h;#c;#u;#d;#f;#p;get ctx(){return this.#a}get status(){return this.#e}};var o0=n=>crypto.getRandomValues(new Uint8Array(n)),s0=(n,e,t)=>{let r=(2<<Math.log2(n.length-1))-1,i=-~(1.6*r*e/n.length);return(o=e)=>{let s="";for(;;){let l=t(i),a=i|0;for(;a--;)if(s+=n[l[a]&r]||"",s.length>=o)return s}}},Jp=(n,e=21)=>s0(n,e|0,o0);var KE=Jp("abcedfghicklmn",10);function J(n,e){let t=_p(n),r=i=>async()=>{r.key=t,await i.wait(Sr);let o=e(i);return i.get(G).create(t,o),r.run=s=>i.get(G).call(n,s),()=>{i.get(G).remove(t)}};return r}function Ge(n){let e=t=>async()=>{await t.wait(ve);let r=n(t);return t.update(Nr,i=>[...i,r]),e.inputRule=r,()=>{t.update(Nr,i=>i.filter(o=>o!==r))}};return e}function l0(n,e){let t=r=>async()=>{let i=e(r);return r.update(wr,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(wr,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(Ot).marks[n];if(!i)throw Du(n);return i},t}function As(n,e){let t=r=>async()=>{let i=e(r);return r.update(br,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(br,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(Ot).nodes[n];if(!i)throw vu(n);return i},t}function ut(n){let e,t=r=>async()=>(await r.wait(ve),e=n(r),r.update(ct,i=>[...i,e]),()=>{r.update(ct,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function a0(n){let e=t=>async()=>{await t.wait(Cr);let r=t.get(Pi),i=n(t),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function $e(n,e){let t=$(n,e),r=i=>(i.inject(t),()=>()=>{i.remove(t)});return r.key=t,r}function We(n,e){let t=$e(e,n),r=As(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.node=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>{let s=o(e);return We(n,s)},i}function Tr(n,e){let t=$e(e,n),r=l0(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.mark=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>{let s=o(e);return Tr(n,s)},i}function De(n,e){let t=Object.fromEntries(Object.entries(e).map(([s,{shortcuts:l,priority:a}])=>[s,{shortcuts:l,priority:a}])),r=$e(t,`${n}Keymap`),i=a0(s=>{let l=s.get(r.key),a=Object.entries(e).flatMap(([c,{command:u}])=>{let f=l[c],d=[f.shortcuts].flat(),h=f.priority;return d.map(p=>[p,{key:p,onRun:u,priority:h}])});return Object.fromEntries(a)}),o=[r,i];return o.ctx=r,o.shortcuts=i,o.key=r.key,o.keymap=i.keymap,o}var Ye=(n,e=()=>({}))=>$e(e,`${n}Attr`),Li=(n,e=()=>({}))=>$e(e,`${n}Attr`);function vn(n,e,t){let r=$e(t??{},n),i=s=>async()=>{await s.wait(Tt);let a={plugin:e(s),options:s.get(r.key)};return s.update(Ir,c=>[...c,a]),()=>{s.update(Ir,c=>c.filter(u=>u!==a))}},o=[r,i];return o.id=n,o.plugin=i,o.options=r,o}function c0(n,e){return t=>t.get(G).call(n,e)}function Gp(n,e){return function(t,r){let{$from:i,$to:o,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let l=i.node(-1);if(l.type!=n)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=n||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let f=M.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let x=i.depth-d;x>=i.depth-3;x--)f=M.from(i.node(x).copy(f));let h=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;f=f.append(M.from(n.createAndFill()));let p=i.before(i.depth-(d-1)),m=t.tr.replace(p,i.after(-h),new O(f,4-d,0)),k=-1;m.doc.nodesBetween(p,m.doc.content.size,(x,I)=>{if(k>-1)return!1;x.isTextblock&&x.content.size==0&&(k=I+1)}),k>-1&&m.setSelection(W.near(m.doc.resolve(k))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),u=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return un(c.doc,i.pos,2,u)?(r&&r(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Yp(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?u0(e,t,n,o):f0(e,t,o):!0:!1}}function u0(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new he(o-1,s,o,s,new O(M.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Kr(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let l=Yn(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return fn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function f0(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?M.empty:M.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new he(f-(l?1:0),d+(a?1:0),f+1,d-1,new O((l?M.empty:M.from(i.copy(M.empty))).append(a?M.empty:M.from(i.copy(M.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Qp(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=M.from(c?n.create():null),f=new O(M.from(n.create(null,M.from(l.type.create(null,u)))),c?3:1,0),d=o.start,h=o.end;t(e.tr.step(new he(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function pc(n){let e=new Map;if(!n||!n.type)throw new Error("mdast-util-definitions expected node");return et(n,"definition",function(r){let i=Xp(r.identifier);i&&!e.get(i)&&e.set(i,r)}),t;function t(r){let i=Xp(r);return e.get(i)}}function Xp(n){return String(n||"").toUpperCase()}function Rs(){return function(n){let e=pc(n);et(n,function(t,r,i){if(t.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[kn,r];if(t.type==="imageReference"||t.type==="linkReference"){let o=e(t.identifier);if(o&&i&&typeof r=="number")return i.children[r]=t.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:t.alt}:{type:"link",url:o.url,title:o.title,children:t.children},[kn,r]}})}}function Zp(n,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){n.next(e.content);return}let r=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&r.push(i)}),n.next(M.fromArray(r))}function w(n,e){return Object.assign(n,{meta:{package:"@milkdown/preset-commonmark",...e}}),n}var mc=Li("emphasis");w(mc,{displayName:"Attr<emphasis>",group:"Emphasis"});var Er=Tr("emphasis",n=>({attrs:{marker:{default:n.get(kr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",n.get(mc.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));w(Er.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});w(Er.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Ds=J("ToggleEmphasis",n=>()=>xo(Er.type(n)));w(Ds,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var em=Ge(n=>wi(/(?:^|[^*])\*([^*]+)\*$/,Er.type(n),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));w(em,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var tm=Ge(n=>wi(/\b_(?![_\s])(.*?[^_\s])_\b/,Er.type(n),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));w(tm,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var gc=De("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:n=>{let e=n.get(G);return()=>e.call(Ds.key)}}});w(gc.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});w(gc.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var yc=Li("strong");w(yc,{displayName:"Attr<strong>",group:"Strong"});var Bi=Tr("strong",n=>({attrs:{marker:{default:n.get(kr).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",n.get(yc.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));w(Bi.mark,{displayName:"MarkSchema<strong>",group:"Strong"});w(Bi.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Ps=J("ToggleStrong",n=>()=>xo(Bi.type(n)));w(Ps,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var nm=Ge(n=>wi(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),Bi.type(n),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));w(nm,{displayName:"InputRule<strong>",group:"Strong"});var xc=De("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:n=>{let e=n.get(G);return()=>e.call(Ps.key)}}});w(xc.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});w(xc.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var kc=Li("inlineCode");w(kc,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Jt=Tr("inlineCode",n=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:e=>["code",n.get(kc.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,r)=>{e.openMark(r),e.addText(t.value),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,r)=>{e.withMark(t,"inlineCode",r.text||"")}}}));w(Jt.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});w(Jt.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var bc=J("ToggleInlineCode",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(r.empty)return!1;let{from:o,to:s}=r;return e.doc.rangeHasMark(o,s,Jt.type(n))?(t?.(i.removeMark(o,s,Jt.type(n))),!0):(Object.keys(e.schema.marks).filter(c=>c!==Jt.type.name).map(c=>e.schema.marks[c]).forEach(c=>{i.removeMark(o,s,c)}),t?.(i.addMark(o,s,Jt.type(n).create())),!0)});w(bc,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var rm=Ge(n=>wi(/(?:`)([^`]+)(?:`)$/,Jt.type(n)));w(rm,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var wc=De("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:n=>{let e=n.get(G);return()=>e.call(bc.key)}}});w(wc.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});w(wc.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Sc=Li("link");w(Sc,{displayName:"Attr<link>",group:"Link"});var Or=Tr("link",n=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...n.get(Sc.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,r)=>{let i=t.url,o=t.title;e.openMark(r,{href:i,title:o}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));w(Or.mark,{displayName:"MarkSchema<link>",group:"Link"});var im=J("ToggleLink",n=>(e={})=>xo(Or.type(n),e));w(im,{displayName:"Command<toggleLinkCommand>",group:"Link"});var om=J("UpdateLink",n=>(e={})=>(t,r)=>{if(!r)return!1;let i,o=-1,{selection:s}=t,{from:l,to:a}=s;if(t.doc.nodesBetween(l,l===a?a+1:a,(p,m)=>{if(Or.type(n).isInSet(p.marks))return i=p,o=m,!1}),!i)return!1;let c=i.marks.find(({type:p})=>p===Or.type(n));if(!c)return!1;let u=o,f=o+i.nodeSize,{tr:d}=t,h=Or.type(n).create({...c.attrs,...e});return h?(r(d.removeMark(u,f,c).addMark(u,f,h).setSelection(new j(d.selection.$anchor)).scrollIntoView()),!0):!1});w(om,{displayName:"Command<updateLinkCommand>",group:"Link"});var sm=As("doc",()=>({content:"block+",parseMarkdown:{match:({type:n})=>n==="root",runner:(n,e,t)=>{n.injectRoot(e,t)}},toMarkdown:{match:n=>n.type.name==="doc",runner:(n,e)=>{n.openNode("root"),n.next(e.content)}}}));w(sm,{displayName:"NodeSchema<doc>",group:"Doc"});function h0(n){return ci(n,e=>e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let r=t[t.length-1];if(!r)return;let i=r.children.indexOf(e);i!==-1&&r.children.splice(i,1)},!0)}var Ls=vn("remark-preserve-empty-line",()=>()=>h0);w(Ls.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});w(Ls.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Cc=Ye("paragraph");w(Cc,{displayName:"Attr<paragraph>",group:"Paragraph"});var Pn=We("paragraph",n=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",n.get(Cc.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,r)=>{e.openNode(r),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{let i=n.get(rt).state?.doc.lastChild;e.openNode("paragraph"),(!t.content||t.content.size===0)&&t!==i&&d0(n)?e.addNode("html",void 0,"<br />"):Zp(e,t),e.closeNode()}}}));function d0(n){let e=!1;try{n.get(Ls.id),e=!0}catch{e=!1}return e}w(Pn.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});w(Pn.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Bs=J("TurnIntoText",n=>()=>er(Pn.type(n)));w(Bs,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Mc=De("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:n=>{let e=n.get(G);return()=>e.call(Bs.key)}}});w(Mc.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});w(Mc.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var p0=Array(6).fill(0).map((n,e)=>e+1);function m0(n){return n.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var zs=$e(m0,"headingIdGenerator");w(zs,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Nc=Ye("heading");w(Nc,{displayName:"Attr<heading>",group:"Heading"});var Ln=We("heading",n=>{let e=n.get(zs.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:p0.map(t=>({tag:`h${t}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Lt(r);return{level:t,id:r.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...n.get(Nc.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,r,i)=>{let o=r.depth;t.openNode(i,{level:o}),t.next(r.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,r)=>{t.openNode("heading",void 0,{depth:r.attrs.level}),Zp(t,r),t.closeNode()}}}});w(Ln.node,{displayName:"NodeSchema<heading>",group:"Heading"});w(Ln.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var lm=Ge(n=>Ma(/^(?<hashes>#+)\s$/,Ln.type(n),e=>{let t=e.groups?.hashes?.length||0,r=n.get(rt),{$from:i}=r.state.selection,o=i.node();if(o.type.name==="heading"){let s=Number(o.attrs.level)+Number(t);return s>6&&(s=6),{level:s}}return{level:t}}));w(lm,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var At=J("WrapInHeading",n=>e=>(e??=1,e<1?er(Pn.type(n)):er(Ln.type(n),{level:e})));w(At,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Ic=J("DowngradeHeading",n=>()=>(e,t,r)=>{let{$from:i}=e.selection,o=i.node();if(o.type!==Ln.type(n)||!e.selection.empty||i.parentOffset!==0)return!1;let s=o.attrs.level-1;return s?(t?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):er(Pn.type(n))(e,t,r)});w(Ic,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Tc=De("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:n=>{let e=n.get(G);return()=>e.call(At.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:n=>{let e=n.get(G);return()=>e.call(At.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:n=>{let e=n.get(G);return()=>e.call(At.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:n=>{let e=n.get(G);return()=>e.call(At.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:n=>{let e=n.get(G);return()=>e.call(At.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:n=>{let e=n.get(G);return()=>e.call(At.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:n=>{let e=n.get(G);return()=>e.call(Ic.key)}}});w(Tc.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});w(Tc.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Oc=Ye("blockquote");w(Oc,{displayName:"Attr<blockquote>",group:"Blockquote"});var zi=We("blockquote",n=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",n.get(Oc.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,r)=>{e.openNode(r).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));w(zi.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});w(zi.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var am=Ge(n=>Yo(/^\s*>\s$/,zi.type(n)));w(am,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Fs=J("WrapInBlockquote",n=>()=>yo(zi.type(n)));w(Fs,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Ec=De("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:n=>{let e=n.get(G);return()=>e.call(Fs.key)}}});w(Ec.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});w(Ec.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Ac=Ye("codeBlock",()=>({pre:{},code:{}}));w(Ac,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Fi=We("code_block",n=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{language:e.dataset.language}}}],toDOM:e=>{let t=n.get(Ac.key)(e),r=e.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...t.pre,...i},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,r)=>{let i=t.lang??"",o=t.value;e.openNode(r,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));w(Fi.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});w(Fi.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var cm=Ge(n=>Ma(/^```(?<language>[a-z]*)?[\s\n]$/,Fi.type(n),e=>({language:e.groups?.language??""})));w(cm,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Rc=J("CreateCodeBlock",n=>(e="")=>er(Fi.type(n),{language:e}));w(Rc,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var g0=J("UpdateCodeBlockLanguage",()=>({pos:n,language:e}={pos:-1,language:""})=>(t,r)=>n>=0?(r?.(t.tr.setNodeAttribute(n,"language",e)),!0):!1);w(g0,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var vc=De("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:n=>{let e=n.get(G);return()=>e.call(Rc.key)}}});w(vc.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});w(vc.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Dc=Ye("image");w(Dc,{displayName:"Attr<image>",group:"Image"});var Ar=We("image",n=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...n.get(Dc.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,r)=>{let i=t.url,o=t.alt,s=t.title;e.addNode(r,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));w(Ar.node,{displayName:"NodeSchema<image>",group:"Image"});w(Ar.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var um=J("InsertImage",n=>(e={})=>(t,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=e,l=Ar.type(n).create({src:i,alt:o,title:s});return l&&r(t.tr.replaceSelectionWith(l).scrollIntoView()),!0});w(um,{displayName:"Command<insertImageCommand>",group:"Image"});var fm=J("UpdateImage",n=>(e={})=>(t,r)=>{let i=wd(t.selection,Ar.type(n));if(!i)return!1;let{node:o,pos:s}=i,l={...o.attrs},{src:a,alt:c,title:u}=e;return a!==void 0&&(l.src=a),c!==void 0&&(l.alt=c),u!==void 0&&(l.title=u),r?.(t.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0});w(fm,{displayName:"Command<updateImageCommand>",group:"Image"});var y0=Ge(n=>new Ne(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,r,i)=>{let[o,s,l="",a]=t;return o?e.tr.replaceWith(r,i,Ar.type(n).create({src:l,alt:s,title:a})):null}));w(y0,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var vs=Ye("hardbreak",n=>({"data-type":"hardbreak","data-is-inline":n.attrs.isInline}));w(vs,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Dn=We("hardbreak",n=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",n.get(vs.key)(e)," "]:["br",n.get(vs.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,r)=>{e.addNode(r,{isInline:!!t.data?.isInline})}},leafText:()=>` 45 45 `,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,` 46 - `):e.addNode("break")}}}));w(Dn.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});w(Dn.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Pc=J("InsertHardbreak",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(!(r instanceof j))return!1;if(r.empty){let o=r.$from.node();if(o.childCount>0&&o.lastChild?.type.name==="hardbreak")return t?.(i.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(W.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return t?.(i.setMeta("hardbreak",!0).replaceSelectionWith(Dn.type(n).create()).scrollIntoView()),!0});w(Pc,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Lc=De("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:n=>{let e=n.get(G);return()=>e.call(Pc.key)}}});w(Lc.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});w(Lc.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Bc=Ye("hr");w(Bc,{displayName:"Attr<hr>",group:"Hr"});var _i=We("hr",n=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",n.get(Bc.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,r)=>{e.addNode(r)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));w(_i.node,{displayName:"NodeSchema<hr>",group:"Hr"});w(_i.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var hm=Ge(n=>new Ne(/^(?:---|___\s|\*\*\*\s)$/,(e,t,r,i)=>{let{tr:o}=e;return t[0]&&o.replaceWith(r-1,i,_i.type(n).create()),o}));w(hm,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var dm=J("InsertHr",n=>()=>(e,t)=>{if(!t)return!0;let r=Pn.node.type(n).create(),{tr:i,selection:o}=e,{from:s}=o,l=_i.type(n).create();if(!l)return!0;let a=i.replaceSelectionWith(l).insert(s,r),c=W.findFrom(a.doc.resolve(s),1,!0);return c&&t(a.setSelection(c).scrollIntoView()),!0});w(dm,{displayName:"Command<insertHrCommand>",group:"Hr"});var zc=Ye("bulletList");w(zc,{displayName:"Attr<bulletList>",group:"BulletList"});var Rr=We("bullet_list",n=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...n.get(zc.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,r)=>{let i=t.spread!=null?`${t.spread}`:"false";e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));w(Rr.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});w(Rr.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var pm=Ge(n=>Yo(/^\s*([-+*])\s$/,Rr.type(n)));w(pm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Fs=J("WrapInBulletList",n=>()=>yo(Rr.type(n)));w(Fs,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Fc=De("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:n=>{let e=n.get(G);return()=>e.call(Fs.key)}}});w(Fc.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});w(Fc.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var _c=Ye("orderedList");w(_c,{displayName:"Attr<orderedList>",group:"OrderedList"});var vr=We("ordered_list",n=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...n.get(_c.key)(e),...e.attrs.order===1?{}:e.attrs.order,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,r)=>{let i=t.spread!=null?`${t.spread}`:"true";e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:t.attrs.spread==="true"}),e.next(t.content),e.closeNode()}}}));w(vr.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});w(vr.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var mm=Ge(n=>Yo(/^\s*(\d+)\.\s$/,vr.type(n),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));w(mm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Vc=J("WrapInOrderedList",n=>()=>yo(vr.type(n)));w(Vc,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var $c=De("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:n=>{let e=n.get(G);return()=>e.call(Vc.key)}}});w($c.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});w($c.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Wc=Ye("listItem");w(Wc,{displayName:"Attr<listItem>",group:"ListItem"});var Gt=We("list_item",n=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"\u2022",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...n.get(Wc.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,r)=>{let i=t.label!=null?`${t.label}.`:"\u2022",o=t.label!=null?"ordered":"bullet",s=t.spread!=null?`${t.spread}`:"true";e.openNode(r,{label:i,listType:o,spread:s}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));w(Gt.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});w(Gt.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var jc=J("SinkListItem",n=>()=>Qp(Gt.type(n)));w(jc,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Hc=J("LiftListItem",n=>()=>Yp(Gt.type(n)));w(Hc,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var qc=J("SplitListItem",n=>()=>Gp(Gt.type(n)));w(qc,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function x0(n){return(e,t,r)=>{let{selection:i}=e;if(!(i instanceof j))return!1;let{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==Gt.type(n)?!1:Al(e,t,r)}}var Kc=J("LiftFirstListItem",n=>()=>x0(n));w(Kc,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Uc=De("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:n=>{let e=n.get(G);return()=>e.call(qc.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:n=>{let e=n.get(G);return()=>e.call(jc.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:n=>{let e=n.get(G);return()=>e.call(Hc.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:n=>{let e=n.get(G);return()=>e.call(Kc.key)}}});w(Uc.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});w(Uc.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var gm=Es("text",()=>({group:"inline",parseMarkdown:{match:({type:n})=>n==="text",runner:(n,e)=>{n.addText(e.value)}},toMarkdown:{match:n=>n.type.name==="text",runner:(n,e)=>{n.addNode("text",void 0,e.text)}}}));w(gm,{displayName:"NodeSchema<text>",group:"Text"});var Jc=Ye("html");w(Jc,{displayName:"Attr<html>",group:"Html"});var Gc=We("html",n=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{let t=document.createElement("span"),r={...n.get(Jc.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",r,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,r)=>{e.addNode(r,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));w(Gc.node,{displayName:"NodeSchema<html>",group:"Html"});w(Gc.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var k0=[sm,Cc,Pn,Bs,Nc,Ln,Rs,Dn,Oc,zi,Ac,Fi,Bc,_i,Dc,Ar,zc,Rr,_c,vr,Wc,Gt,mc,Er,yc,Bi,kc,Jt,Sc,Or,Jc,Gc,gm].flat(),b0=[am,pm,mm,cm,hm,lm].flat(),w0=[em,tm,rm,nm],S0=J("IsMarkSelected",()=>n=>e=>{if(!n)return!1;let{doc:t,selection:r}=e;return t.rangeHasMark(r.from,r.to,n)}),C0=J("IsNoteSelected",()=>n=>e=>n?Sd(e,n).hasNode:!1),M0=J("ClearTextInCurrentBlock",()=>()=>(n,e)=>{let t=n.tr,{$from:r,$to:i}=t.selection,{pos:o}=r,{pos:s}=i,l=o-r.node().content.size;return l<0?!1:(t=t.deleteRange(l,s),e?.(t),!0)}),N0=J("SetBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr,{from:s,to:l}=o.selection;try{o.setBlockType(s,l,r,i)}catch{return!1}return t?.(o),!0}),I0=J("WrapInBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let{$from:s,$to:l}=o.selection,a=s.blockRange(l),c=a&&cn(a,r,i);if(!c)return!1;o=o.wrap(a,c)}catch{return!1}return t?.(o),!0}),T0=J("AddBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let s=r instanceof Ae?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t?.(o),!0}),O0=J("SelectTextNearPos",()=>n=>(e,t)=>{let{pos:r}=n??{};if(r==null)return!1;let i=(s,l,a)=>Math.min(Math.max(s,l),a),o=e.tr;try{let s=e.doc.resolve(i(r,0,e.doc.content.size));o.setSelection(j.near(s))}catch{return!1}return t?.(o.scrollIntoView()),!0}),E0=[Ls,zs,At,Ic,Rc,Pc,dm,um,fm,Vc,Fs,jc,qc,Hc,Kc,vs,bc,Ds,im,om,S0,C0,M0,N0,I0,T0,O0],A0=[Ec,vc,Lc,Tc,Uc,$c,Fc,Mc,gc,wc,xc].flat(),Yc=vn("remarkAddOrderInList",()=>()=>n=>{et(n,"list",e=>{if(e.ordered){let t=e.start??1;e.children.forEach((r,i)=>{r.label=i+t})}})});w(Yc.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});w(Yc.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var Qc=vn("remarkLineBreak",()=>()=>n=>{let e=/[\t ]*(?:\r?\n|\r)/g;et(n,"text",(t,r,i)=>{if(!t.value||typeof t.value!="string")return;let o=[],s=0;e.lastIndex=0;let l=e.exec(t.value);for(;l;){let c=l.index;s!==c&&o.push({type:"text",value:t.value.slice(s,c)}),o.push({type:"break",data:{isInline:!0}}),s=c+l[0].length,l=e.exec(t.value)}if(o.length>0&&i&&typeof r=="number")return s<t.value.length&&o.push({type:"text",value:t.value.slice(s)}),i.children.splice(r,1,...o),r+o.length})});w(Qc.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});w(Qc.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var Xc=vn("remarkInlineLink",()=>As);w(Xc.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});w(Xc.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var R0=n=>!!n.children,v0=n=>n.type==="html";function D0(n,e){return t(n,0,null)[0];function t(r,i,o){if(R0(r)){let s=[];for(let l=0,a=r.children.length;l<a;l++){let c=r.children[l];if(c){let u=t(c,l,r);if(u)for(let f=0,d=u.length;f<d;f++){let h=u[f];h&&s.push(h)}}}r.children=s}return e(r,i,o)}}var P0=["root","blockquote","listItem"],Zc=vn("remarkHTMLTransformer",()=>()=>n=>{D0(n,(e,t,r)=>v0(e)?(r&&P0.includes(r.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});w(Zc.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});w(Zc.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var eu=vn("remarkMarker",()=>()=>(n,e)=>{let t=r=>e.value.charAt(r.position.start.offset);et(n,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=t(r)})});w(eu.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});w(eu.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var ym=ut(()=>{let n=!1,e=new re("MILKDOWN_INLINE_NODES_CURSOR"),t=new ne({key:e,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;let i=r.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(r,i)=>n?(n=!1,requestAnimationFrame(()=>{if(t.getState(r.state)){let s=r.state.selection.from;i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",s))}}),!0):!1,compositionstart:r=>(t.getState(r.state)&&(n=!0),!1),beforeinput:(r,i)=>{if(t.getState(r.state)&&i instanceof InputEvent&&i.data&&!n){let s=r.state.selection.from;return i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",s)),!0}return!1}},decorations(r){if(t.getState(r)){let s=r.selection.$from.pos,l=document.createElement("span"),a=nt.widget(s,l,{side:-1}),c=document.createElement("span"),u=nt.widget(s,c);return setTimeout(()=>{l.contentEditable="true",c.contentEditable="true"}),Ie.create(r.doc,[a,u])}return Ie.empty}}});return t});w(ym,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var xm=ut(n=>new ne({key:new re("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,r)=>{if(!e.length)return;let[i]=e;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof xe))return;let{from:a}=o;return r.tr.setNodeMarkup(a,Dn.type(n),void 0,[])}if(o instanceof ln){let a=r.tr,{from:c,to:u}=o;return r.doc.nodesBetween(c,u,(f,d)=>{f.type===Dn.type(n)&&(a=a.setNodeMarkup(d,Dn.type(n),void 0,[]))}),a}}}));w(xm,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var tu=$e(["table","code_block"],"hardbreakFilterNodes");w(tu,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var km=ut(n=>{let e=n.get(tu.key);return new ne({key:new re("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,r)=>{let i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){let{from:s}=o,l=r.doc.resolve(s),a=l.depth,c=!0;for(;a>0;)e.includes(l.node(a).type.name)&&(c=!1),a--;return c}return!0}})});w(km,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var bm=ut(n=>{let e=new re("MILKDOWN_HEADING_ID"),t=r=>{if(r.composing)return;let i=n.get(Bs.key),o=r.state.tr.setMeta("addToHistory",!1),s=!1,l={};r.state.doc.descendants((a,c)=>{if(a.type===Ln.type(n)){if(a.textContent.trim().length===0)return;let u=a.attrs,f=i(a);l[f]?(l[f]+=1,f+=`-#${l[f]}`):l[f]=1,u.id!==f&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:f}))}}),s&&r.dispatch(o)};return new ne({key:e,view:r=>(t(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});w(bm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var wm=ut(n=>{let e=(t,r,i)=>{if(!i.selection||t.some(f=>f.getMeta("addToHistory")===!1||!f.isGeneric))return null;let o=vr.type(n),s=Rr.type(n),l=Gt.type(n),a=(f,d)=>{let h=!1,p=`${d+1}.`;return f.label!==p&&(f.label=p,h=!0),h},c=i.tr,u=!1;return i.doc.descendants((f,d,h,p)=>{if(f.type===s){let m=f.maybeChild(0);m?.type===l&&m.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(d,o,{spread:"true"}),f.descendants((k,x,I,C)=>{if(k.type===l){let A={...k.attrs};a(A,C)&&(c=c.setNodeMarkup(x,void 0,A))}return!1}))}else if(f.type===l&&h?.type===o){let m={...f.attrs},k=!1;m.listType!=="ordered"&&(m.listType="ordered",k=!0),h?.maybeChild(0)&&(k=a(m,p)),k&&(c=c.setNodeMarkup(d,void 0,m),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new ne({key:new re("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});w(wm,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var L0=[xm,tu,km,ym,Yc,Xc,Qc,Zc,eu,Ps,bm,wm].flat(),B0=[k0,b0,w0,E0,A0,L0].flat();var z0=typeof global=="object"&&global&&global.Object===Object&&global,Sm=z0;var F0=typeof self=="object"&&self&&self.Object===Object&&self,_0=Sm||F0||Function("return this")(),_s=_0;var V0=_s.Symbol,Dr=V0;var Cm=Object.prototype,$0=Cm.hasOwnProperty,W0=Cm.toString,Vi=Dr?Dr.toStringTag:void 0;function j0(n){var e=$0.call(n,Vi),t=n[Vi];try{n[Vi]=void 0;var r=!0}catch{}var i=W0.call(n);return r&&(e?n[Vi]=t:delete n[Vi]),i}var Mm=j0;var H0=Object.prototype,q0=H0.toString;function K0(n){return q0.call(n)}var Nm=K0;var U0="[object Null]",J0="[object Undefined]",Im=Dr?Dr.toStringTag:void 0;function G0(n){return n==null?n===void 0?J0:U0:Im&&Im in Object(n)?Mm(n):Nm(n)}var Tm=G0;function Y0(n){return n!=null&&typeof n=="object"}var Om=Y0;var Q0="[object Symbol]";function X0(n){return typeof n=="symbol"||Om(n)&&Tm(n)==Q0}var Em=X0;var Z0=/\s/;function e1(n){for(var e=n.length;e--&&Z0.test(n.charAt(e)););return e}var Am=e1;var t1=/^\s+/;function n1(n){return n&&n.slice(0,Am(n)+1).replace(t1,"")}var Rm=n1;function r1(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Bn=r1;var vm=NaN,i1=/^[-+]0x[0-9a-f]+$/i,o1=/^0b[01]+$/i,s1=/^0o[0-7]+$/i,l1=parseInt;function a1(n){if(typeof n=="number")return n;if(Em(n))return vm;if(Bn(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Bn(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Rm(n);var t=o1.test(n);return t||s1.test(n)?l1(n.slice(2),t?2:8):i1.test(n)?vm:+n}var nu=a1;var c1=function(){return _s.Date.now()},Vs=c1;var u1="Expected a function",f1=Math.max,h1=Math.min;function d1(n,e,t){var r,i,o,s,l,a,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(u1);e=nu(e)||0,Bn(t)&&(u=!!t.leading,f="maxWait"in t,o=f?f1(nu(t.maxWait)||0,e):o,d="trailing"in t?!!t.trailing:d);function h(b){var T=r,P=i;return r=i=void 0,c=b,s=n.apply(P,T),s}function p(b){return c=b,l=setTimeout(x,e),u?h(b):s}function m(b){var T=b-a,P=b-c,D=e-T;return f?h1(D,o-P):D}function k(b){var T=b-a,P=b-c;return a===void 0||T>=e||T<0||f&&P>=o}function x(){var b=Vs();if(k(b))return I(b);l=setTimeout(x,m(b))}function I(b){return l=void 0,d&&r?h(b):(r=i=void 0,s)}function C(){l!==void 0&&clearTimeout(l),c=0,r=a=i=l=void 0}function A(){return l===void 0?s:I(Vs())}function v(){var b=Vs(),T=k(b);if(r=arguments,i=this,a=b,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(x,e),h(a)}return l===void 0&&(l=setTimeout(x,e)),s}return v.cancel=C,v.flush=A,v}var $i=d1;var p1="Expected a function";function m1(n,e,t){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(p1);return Bn(t)&&(r="leading"in t?!!t.leading:r,i="trailing"in t?!!t.trailing:i),$i(n,e,{leading:r,maxWait:e,trailing:i})}var ru=m1;var $s=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},iu=$(new $s,"listener"),g1=new re("MILKDOWN_LISTENER"),Dm=n=>(n.inject(iu,new $s),async()=>{await n.wait(Tt);let e=n.get(iu),{listeners:t}=e;t.beforeMount.forEach(a=>a(n)),await n.wait(Mr);let r=n.get(Rn),i=null,o=null,s=null,l=new ne({key:g1,view:()=>({destroy:()=>{t.destroy.forEach(a=>a(n))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(a=>a(n)),!1),blur:()=>(t.blur.forEach(a=>a(n)),!1)}},state:{init:(a,c)=>{i=c.doc,o=r(c.doc)},apply:a=>{let c=a.selection;return(!s&&c||s&&!c.eq(s))&&(t.selectionUpdated.forEach(f=>{f(n,c,s)}),s=c),!(a.docChanged||a.storedMarksSet)||a.getMeta("addToHistory")===!1?void 0:$i(()=>{let{doc:f}=a;if(t.updated.length>0&&i&&!i.eq(f)&&t.updated.forEach(d=>{d(n,f,i)}),t.markdownUpdated.length>0&&i&&!i.eq(f)){let d=r(f);t.markdownUpdated.forEach(h=>{h(n,d,o)}),o=d}i=f},200)()}}});n.update(ct,a=>a.concat(l)),await n.wait(Di),t.mounted.forEach(a=>a(n))});Dm.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var Pr=Math.min,Rt=Math.max,ji=Math.round,Hi=Math.floor,it=n=>({x:n,y:n}),y1={left:"right",right:"left",bottom:"top",top:"bottom"};function ou(n,e,t){return Rt(n,Pr(e,t))}function qi(n,e){return typeof n=="function"?n(e):n}function Yt(n){return n.split("-")[0]}function Ki(n){return n.split("-")[1]}function su(n){return n==="x"?"y":"x"}function lu(n){return n==="y"?"height":"width"}function vt(n){let e=n[0];return e==="t"||e==="b"?"y":"x"}function au(n){return su(vt(n))}function Bm(n,e,t){t===void 0&&(t=!1);let r=Ki(n),i=au(n),o=lu(i),s=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Wi(s)),[s,Wi(s)]}function zm(n){let e=Wi(n);return[Ws(n),e,Ws(e)]}function Ws(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}var Pm=["left","right"],Lm=["right","left"],x1=["top","bottom"],k1=["bottom","top"];function b1(n,e,t){switch(n){case"top":case"bottom":return t?e?Lm:Pm:e?Pm:Lm;case"left":case"right":return e?x1:k1;default:return[]}}function Fm(n,e,t,r){let i=Ki(n),o=b1(Yt(n),t==="start",r);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Ws)))),o}function Wi(n){let e=Yt(n);return y1[e]+n.slice(e.length)}function w1(n){return{top:0,right:0,bottom:0,left:0,...n}}function _m(n){return typeof n!="number"?w1(n):{top:n,right:n,bottom:n,left:n}}function zn(n){let{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function Vm(n,e,t){let{reference:r,floating:i}=n,o=vt(e),s=au(e),l=lu(s),a=Yt(e),c=o==="y",u=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,d=r[l]/2-i[l]/2,h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-i.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Ki(e)){case"start":h[s]-=d*(t&&c?-1:1);break;case"end":h[s]+=d*(t&&c?-1:1);break}return h}async function $m(n,e){var t;e===void 0&&(e={});let{x:r,y:i,platform:o,rects:s,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=qi(e,n),p=_m(h),k=l[d?f==="floating"?"reference":"floating":f],x=zn(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(k)))==null||t?k:k.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),I=f==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),A=await(o.isElement==null?void 0:o.isElement(C))?await(o.getScale==null?void 0:o.getScale(C))||{x:1,y:1}:{x:1,y:1},v=zn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:I,offsetParent:C,strategy:a}):I);return{top:(x.top-v.top+p.top)/A.y,bottom:(v.bottom-x.bottom+p.bottom)/A.y,left:(x.left-v.left+p.left)/A.x,right:(v.right-x.right+p.right)/A.x}}var S1=50,Wm=async(n,e,t)=>{let{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,l=s.detectOverflow?s:{...s,detectOverflow:$m},a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:f}=Vm(c,r,a),d=r,h=0,p={};for(let m=0;m<o.length;m++){let k=o[m];if(!k)continue;let{name:x,fn:I}=k,{x:C,y:A,data:v,reset:b}=await I({x:u,y:f,initialPlacement:r,placement:d,strategy:i,middlewareData:p,rects:c,platform:l,elements:{reference:n,floating:e}});u=C??u,f=A??f,p[x]={...p[x],...v},b&&h<S1&&(h++,typeof b=="object"&&(b.placement&&(d=b.placement),b.rects&&(c=b.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:i}):b.rects),{x:u,y:f}=Vm(c,d,a)),m=-1)}return{x:u,y:f,placement:d,strategy:i,middlewareData:p}};var jm=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;let{placement:i,middlewareData:o,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...k}=qi(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};let x=Yt(i),I=vt(l),C=Yt(l)===l,A=await(a.isRTL==null?void 0:a.isRTL(c.floating)),v=d||(C||!m?[Wi(l)]:zm(l)),b=p!=="none";!d&&b&&v.push(...Fm(l,m,p,A));let T=[l,...v],P=await a.detectOverflow(e,k),D=[],U=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&D.push(P[x]),f){let L=Bm(i,s,A);D.push(P[L[0]],P[L[1]])}if(U=[...U,{placement:i,overflows:D}],!D.every(L=>L<=0)){var Se,Y;let L=(((Se=o.flip)==null?void 0:Se.index)||0)+1,F=T[L];if(F&&(!(f==="alignment"?I!==vt(F):!1)||U.every(te=>vt(te.placement)===I?te.overflows[0]>0:!0)))return{data:{index:L,overflows:U},reset:{placement:F}};let Q=(Y=U.filter(X=>X.overflows[0]<=0).sort((X,te)=>X.overflows[1]-te.overflows[1])[0])==null?void 0:Y.placement;if(!Q)switch(h){case"bestFit":{var R;let X=(R=U.filter(te=>{if(b){let le=vt(te.placement);return le===I||le==="y"}return!0}).map(te=>[te.placement,te.overflows.filter(le=>le>0).reduce((le,g)=>le+g,0)]).sort((te,le)=>te[1]-le[1])[0])==null?void 0:R[0];X&&(Q=X);break}case"initialPlacement":Q=l;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};var C1=new Set(["left","top"]);async function M1(n,e){let{placement:t,platform:r,elements:i}=n,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Yt(t),l=Ki(t),a=vt(t)==="y",c=C1.has(s)?-1:1,u=o&&a?-1:1,f=qi(e,n),{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:d*c}:{x:d*c,y:h*u}}var Hm=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:s,middlewareData:l}=e,a=await M1(e,n);return s===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:o+a.y,data:{...a,placement:s}}}}},qm=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:r,placement:i,platform:o}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:a={fn:x=>{let{x:I,y:C}=x;return{x:I,y:C}}},...c}=qi(n,e),u={x:t,y:r},f=await o.detectOverflow(e,c),d=vt(Yt(i)),h=su(d),p=u[h],m=u[d];if(s){let x=h==="y"?"top":"left",I=h==="y"?"bottom":"right",C=p+f[x],A=p-f[I];p=ou(C,p,A)}if(l){let x=d==="y"?"top":"left",I=d==="y"?"bottom":"right",C=m+f[x],A=m-f[I];m=ou(C,m,A)}let k=a.fn({...e,[h]:p,[d]:m});return{...k,data:{x:k.x-t,y:k.y-r,enabled:{[h]:s,[d]:l}}}}}};function js(){return typeof window<"u"}function _n(n){return Um(n)?(n.nodeName||"").toLowerCase():"#document"}function Pe(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ot(n){var e;return(e=(Um(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Um(n){return js()?n instanceof Node||n instanceof Pe(n).Node:!1}function Qe(n){return js()?n instanceof Element||n instanceof Pe(n).Element:!1}function ft(n){return js()?n instanceof HTMLElement||n instanceof Pe(n).HTMLElement:!1}function Km(n){return!js()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Pe(n).ShadowRoot}function Br(n){let{overflow:e,overflowX:t,overflowY:r,display:i}=Xe(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&i!=="inline"&&i!=="contents"}function Jm(n){return/^(table|td|th)$/.test(_n(n))}function Ui(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}var N1=/transform|translate|scale|rotate|perspective|filter/,I1=/paint|layout|strict|content/,Fn=n=>!!n&&n!=="none",cu;function Hs(n){let e=Qe(n)?Xe(n):n;return Fn(e.transform)||Fn(e.translate)||Fn(e.scale)||Fn(e.rotate)||Fn(e.perspective)||!qs()&&(Fn(e.backdropFilter)||Fn(e.filter))||N1.test(e.willChange||"")||I1.test(e.contain||"")}function Gm(n){let e=Dt(n);for(;ft(e)&&!Vn(e);){if(Hs(e))return e;if(Ui(e))return null;e=Dt(e)}return null}function qs(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Vn(n){return/^(html|body|#document)$/.test(_n(n))}function Xe(n){return Pe(n).getComputedStyle(n)}function Ji(n){return Qe(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Dt(n){if(_n(n)==="html")return n;let e=n.assignedSlot||n.parentNode||Km(n)&&n.host||ot(n);return Km(e)?e.host:e}function Ym(n){let e=Dt(n);return Vn(e)?n.ownerDocument?n.ownerDocument.body:n.body:ft(e)&&Br(e)?e:Ym(e)}function Lr(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);let i=Ym(n),o=i===((r=n.ownerDocument)==null?void 0:r.body),s=Pe(i);if(o){let l=Ks(s);return e.concat(s,s.visualViewport||[],Br(i)?i:[],l&&t?Lr(l):[])}else return e.concat(i,Lr(i,[],t))}function Ks(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function eg(n){let e=Xe(n),t=parseFloat(e.width)||0,r=parseFloat(e.height)||0,i=ft(n),o=i?n.offsetWidth:t,s=i?n.offsetHeight:r,l=ji(t)!==o||ji(r)!==s;return l&&(t=o,r=s),{width:t,height:r,$:l}}function fu(n){return Qe(n)?n:n.contextElement}function zr(n){let e=fu(n);if(!ft(e))return it(1);let t=e.getBoundingClientRect(),{width:r,height:i,$:o}=eg(e),s=(o?ji(t.width):t.width)/r,l=(o?ji(t.height):t.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var T1=it(0);function tg(n){let e=Pe(n);return!qs()||!e.visualViewport?T1:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function O1(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Pe(n)?!1:e}function $n(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);let i=n.getBoundingClientRect(),o=fu(n),s=it(1);e&&(r?Qe(r)&&(s=zr(r)):s=zr(n));let l=O1(o,t,r)?tg(o):it(0),a=(i.left+l.x)/s.x,c=(i.top+l.y)/s.y,u=i.width/s.x,f=i.height/s.y;if(o){let d=Pe(o),h=r&&Qe(r)?Pe(r):r,p=d,m=Ks(p);for(;m&&r&&h!==p;){let k=zr(m),x=m.getBoundingClientRect(),I=Xe(m),C=x.left+(m.clientLeft+parseFloat(I.paddingLeft))*k.x,A=x.top+(m.clientTop+parseFloat(I.paddingTop))*k.y;a*=k.x,c*=k.y,u*=k.x,f*=k.y,a+=C,c+=A,p=Pe(m),m=Ks(p)}}return zn({width:u,height:f,x:a,y:c})}function Us(n,e){let t=Ji(n).scrollLeft;return e?e.left+t:$n(ot(n)).left+t}function ng(n,e){let t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Us(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function E1(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n,o=i==="fixed",s=ot(r),l=e?Ui(e.floating):!1;if(r===s||l&&o)return t;let a={scrollLeft:0,scrollTop:0},c=it(1),u=it(0),f=ft(r);if((f||!f&&!o)&&((_n(r)!=="body"||Br(s))&&(a=Ji(r)),f)){let h=$n(r);c=zr(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}let d=s&&!f&&!o?ng(s,a):it(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x+d.x,y:t.y*c.y-a.scrollTop*c.y+u.y+d.y}}function A1(n){return Array.from(n.getClientRects())}function R1(n){let e=ot(n),t=Ji(n),r=n.ownerDocument.body,i=Rt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=Rt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-t.scrollLeft+Us(n),l=-t.scrollTop;return Xe(r).direction==="rtl"&&(s+=Rt(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:l}}var Qm=25;function v1(n,e){let t=Pe(n),r=ot(n),i=t.visualViewport,o=r.clientWidth,s=r.clientHeight,l=0,a=0;if(i){o=i.width,s=i.height;let u=qs();(!u||u&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}let c=Us(r);if(c<=0){let u=r.ownerDocument,f=u.body,d=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(r.clientWidth-f.clientWidth-h);p<=Qm&&(o-=p)}else c<=Qm&&(o+=c);return{width:o,height:s,x:l,y:a}}function D1(n,e){let t=$n(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,o=ft(n)?zr(n):it(1),s=n.clientWidth*o.x,l=n.clientHeight*o.y,a=i*o.x,c=r*o.y;return{width:s,height:l,x:a,y:c}}function Xm(n,e,t){let r;if(e==="viewport")r=v1(n,t);else if(e==="document")r=R1(ot(n));else if(Qe(e))r=D1(e,t);else{let i=tg(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return zn(r)}function rg(n,e){let t=Dt(n);return t===e||!Qe(t)||Vn(t)?!1:Xe(t).position==="fixed"||rg(t,e)}function P1(n,e){let t=e.get(n);if(t)return t;let r=Lr(n,[],!1).filter(l=>Qe(l)&&_n(l)!=="body"),i=null,o=Xe(n).position==="fixed",s=o?Dt(n):n;for(;Qe(s)&&!Vn(s);){let l=Xe(s),a=Hs(s);!a&&l.position==="fixed"&&(i=null),(o?!a&&!i:!a&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Br(s)&&!a&&rg(n,s))?r=r.filter(u=>u!==s):i=l,s=Dt(s)}return e.set(n,r),r}function L1(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n,s=[...t==="clippingAncestors"?Ui(e)?[]:P1(e,this._c):[].concat(t),r],l=Xm(e,s[0],i),a=l.top,c=l.right,u=l.bottom,f=l.left;for(let d=1;d<s.length;d++){let h=Xm(e,s[d],i);a=Rt(h.top,a),c=Pr(h.right,c),u=Pr(h.bottom,u),f=Rt(h.left,f)}return{width:c-f,height:u-a,x:f,y:a}}function B1(n){let{width:e,height:t}=eg(n);return{width:e,height:t}}function z1(n,e,t){let r=ft(e),i=ot(e),o=t==="fixed",s=$n(n,!0,o,e),l={scrollLeft:0,scrollTop:0},a=it(0);function c(){a.x=Us(i)}if(r||!r&&!o)if((_n(e)!=="body"||Br(i))&&(l=Ji(e)),r){let h=$n(e,!0,o,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else i&&c();o&&!r&&i&&c();let u=i&&!r&&!o?ng(i,l):it(0),f=s.left+l.scrollLeft-a.x-u.x,d=s.top+l.scrollTop-a.y-u.y;return{x:f,y:d,width:s.width,height:s.height}}function uu(n){return Xe(n).position==="static"}function Zm(n,e){if(!ft(n)||Xe(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return ot(n)===t&&(t=t.ownerDocument.body),t}function ig(n,e){let t=Pe(n);if(Ui(n))return t;if(!ft(n)){let i=Dt(n);for(;i&&!Vn(i);){if(Qe(i)&&!uu(i))return i;i=Dt(i)}return t}let r=Zm(n,e);for(;r&&Jm(r)&&uu(r);)r=Zm(r,e);return r&&Vn(r)&&uu(r)&&!Hs(r)?t:r||Gm(n)||t}var F1=async function(n){let e=this.getOffsetParent||ig,t=this.getDimensions,r=await t(n.floating);return{reference:z1(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _1(n){return Xe(n).direction==="rtl"}var V1={convertOffsetParentRelativeRectToViewportRelativeRect:E1,getDocumentElement:ot,getClippingRect:L1,getOffsetParent:ig,getElementRects:F1,getClientRects:A1,getDimensions:B1,getScale:zr,isElement:Qe,isRTL:_1};function og(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function $1(n,e){let t=null,r,i=ot(n);function o(){var l;clearTimeout(r),(l=t)==null||l.disconnect(),t=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),o();let c=n.getBoundingClientRect(),{left:u,top:f,width:d,height:h}=c;if(l||e(),!d||!h)return;let p=Hi(f),m=Hi(i.clientWidth-(u+d)),k=Hi(i.clientHeight-(f+h)),x=Hi(u),C={rootMargin:-p+"px "+-m+"px "+-k+"px "+-x+"px",threshold:Rt(0,Pr(1,a))||1},A=!0;function v(b){let T=b[0].intersectionRatio;if(T!==a){if(!A)return s();T?s(!1,T):r=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!og(c,n.getBoundingClientRect())&&s(),A=!1}try{t=new IntersectionObserver(v,{...C,root:i.ownerDocument})}catch{t=new IntersectionObserver(v,C)}t.observe(n)}return s(!0),o}function hu(n,e,t,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=fu(n),u=i||o?[...c?Lr(c):[],...e?Lr(e):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});let f=c&&l?$1(c,t):null,d=-1,h=null;s&&(h=new ResizeObserver(x=>{let[I]=x;I&&I.target===c&&h&&e&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(e)})),t()}),c&&!a&&h.observe(c),e&&h.observe(e));let p,m=a?$n(n):null;a&&k();function k(){let x=$n(n);m&&!og(m,x)&&t(),m=x,p=requestAnimationFrame(k)}return t(),()=>{var x;u.forEach(I=>{i&&I.removeEventListener("scroll",t),o&&I.removeEventListener("resize",t)}),f?.(),(x=h)==null||x.disconnect(),h=null,a&&cancelAnimationFrame(p)}}var sg=Hm;var lg=qm,ag=jm;var cg=(n,e,t)=>{let r=new Map,i={platform:V1,...t},o={...i.platform,_c:r};return Wm(n,e,{...i,platform:o})};var du=class{constructor(e){this.#o=!1,this.onShow=()=>{},this.onHide=()=>{},this.#c=t=>{cg(t,this.element,{placement:this.#n.placement??"top",middleware:[ag(),sg(this.#l),lg(this.#a),...this.#r],...this.#n}).then(({x:r,y:i})=>{Object.assign(this.element.style,{left:`${r}px`,top:`${i}px`})}).catch(console.error)},this.#u=t=>this.#s!==t.dom.parentElement,this.#d=(t,r)=>{let{state:i,composing:o}=t,{selection:s,doc:l}=i,{ranges:a}=s,c=Math.min(...a.map(h=>h.$from.pos)),u=Math.max(...a.map(h=>h.$to.pos)),f=r&&r.doc.eq(l)&&r.selection.eq(s);if(this.#o||((this.#s??t.dom.parentElement??document.body).appendChild(this.element),this.#o=!0),o||f)return;if(this.#i?.(),this.#i=void 0,!this.#e(t,r)){this.hide();return}let d={getBoundingClientRect:()=>bd(t,c,u),contextElement:t.dom};this.#u(t)?this.#i=hu(d,this.element,()=>this.#c(d)):this.#c(d),this.show()},this.update=(t,r)=>{this.#h(t,r)},this.destroy=()=>{this.#i?.(),this.#h.cancel()},this.show=(t,r)=>{if(this.element.dataset.show="true",t){this.#i?.(),this.#i=void 0;let i={...t,contextElement:r?.dom};r&&this.#u(r)?this.#i=hu(i,this.element,()=>this.#c(i)):this.#c(i)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=e.content,this.#t=e.debounce??200,this.#e=e.shouldShow??this.#f,this.#l=e.offset,this.#a=e.shift,this.#r=e.middleware??[],this.#n=e.floatingUIOptions??{},this.#s=e.root,this.element.dataset.show="false",this.#h=ru(this.#d,this.#t)}#t;#e;#r;#n;#s;#o;#i;#l;#a;#h;#c;#u;#d;#f(e){let{doc:t,selection:r}=e.state,{empty:i,from:o,to:s}=r,l=!t.textBetween(o,s).length&&e.state.selection instanceof j,a=this.element.contains(document.activeElement),c=!e.hasFocus()&&!a,u=!e.editable;return!(c||i||l||u)}};function W1(n){let e=$e({},`${n}_TOOLTIP_SPEC`),t=ut(i=>{let o=i.get(e.key);return new ne({key:new re(`${n}_TOOLTIP`),...o})}),r=[e,t];return r.key=e.key,r.pluginKey=t.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${n}`},t.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${n}`},r}var Js=200,ge=function(){};ge.prototype.append=function(e){return e.length?(e=ge.from(e),!this.length&&e||e.length<Js&&this.leafAppend(e)||this.length<Js&&e.leafPrepend(this)||this.appendInner(e)):this};ge.prototype.prepend=function(e){return e.length?ge.from(e).append(this):this};ge.prototype.appendInner=function(e){return new j1(this,e)};ge.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ge.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ge.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ge.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ge.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};ge.from=function(e){return e instanceof ge?e:e&&e.length?new ug(e):ge.empty};var ug=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Js)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Js)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ge);ge.empty=new ug([]);var j1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ge),pu=ge;var H1=500,jn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new ht(f.map));let h=f.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new ht(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new ht(e.mapping.maps[u],f,t),h;(h=a&&a.merge(d))&&(d=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(d),t&&(s++,t=void 0),i||(a=d)}let c=s-r.depth;return c>K1&&(l=q1(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new Xr;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new ht(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(d.step){let m=e.steps[h].invert(e.docs[h]),k=d.selection&&d.selection.map(o.slice(a+1,h));k&&l++,r.push(new ht(p,m,k))}else r.push(new ht(p))},i);let c=[];for(let d=t;d<s;d++)c.push(new ht(o.maps[d]));let u=this.items.slice(0,i).append(c).append(r),f=new n(u,l);return f.emptyItemCount()>H1&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let f=new ht(c.invert(),a,u),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(pu.from(i.reverse()),o)}};jn.empty=new jn(pu.empty,0);function q1(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var ht=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},dt=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},K1=20;function U1(n,e,t,r){let i=t.getMeta(Wn),o;if(i)return i.historyState;t.getMeta(Y1)&&(n=new dt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Wn))return s.getMeta(Wn).redo?new dt(n.done.addTransform(t,void 0,r,Gs(e)),n.undone,fg(t.mapping.maps),n.prevTime,n.prevComposition):new dt(n.done,n.undone.addTransform(t,void 0,r,Gs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!J1(t,n.prevRanges)),c=s?mu(n.prevRanges,t.mapping):fg(t.mapping.maps);return new dt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Gs(e)),jn.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new dt(n.done.rebased(t,o),n.undone.rebased(t,o),mu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new dt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),mu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function J1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function fg(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function mu(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function G1(n,e,t){let r=Gs(e),i=Wn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new dt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(Wn,{redo:t,historyState:a})}var gu=!1,hg=null;function Gs(n){let e=n.plugins;if(hg!=e){gu=!1,hg=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){gu=!0;break}}return gu}var Wn=new re("history"),Y1=new re("closeHistory");function dg(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ne({key:Wn,state:{init(){return new dt(jn.empty,jn.empty,null,0,-1)},apply(e,t,r){return U1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?yu:r=="historyRedo"?xu:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Ys(n,e){return(t,r)=>{let i=Wn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=G1(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var yu=Ys(!1,!0),xu=Ys(!0,!0),BR=Ys(!1,!1),zR=Ys(!0,!1);function Fr(n,e){return Object.assign(n,{meta:{package:"@milkdown/plugin-history",...e}}),n}var Qs=J("Undo",()=>()=>yu);Fr(Qs,{displayName:"Command<undo>"});var Xs=J("Redo",()=>()=>xu);Fr(Xs,{displayName:"Command<redo>"});var ku=$e({},"historyProviderConfig");Fr(ku,{displayName:"Ctx<historyProviderConfig>"});var pg=ut(n=>dg(n.get(ku.key)));Fr(pg,{displayName:"Ctx<historyProviderPlugin>"});var bu=De("historyKeymap",{Undo:{shortcuts:"Mod-z",command:n=>{let e=n.get(G);return()=>e.call(Qs.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:n=>{let e=n.get(G);return()=>e.call(Xs.key)}}});Fr(bu.ctx,{displayName:"KeymapCtx<history>"});Fr(bu.shortcuts,{displayName:"Keymap<history>"});var Q1=[ku,pg,bu,Qs,Xs].flat();var Zs=class{constructor(e,t,r){this.step=e,this.inverted=t,this.origin=r}};function X1(n,e,t){for(let i=n.length-1;i>=0;i--)t.step(n[i].inverted);for(let i=0;i<e.length;i++)t.step(e[i]);let r=[];for(let i=0,o=n.length;i<n.length;i++){let s=n[i].step.map(t.mapping.slice(o));o--,s&&!t.maybeStep(s).failed&&(t.mapping.setMirror(o,t.steps.length-1),r.push(new Zs(s,s.invert(t.docs[t.docs.length-1]),n[i].origin)))}return r}var _r=class{constructor(e,t){this.version=e,this.unconfirmed=t}};function Z1(n){let e=[];for(let t=0;t<n.steps.length;t++)e.push(new Zs(n.steps[t],n.steps[t].invert(n.docs[t]),n));return e}var Pt=new re("collab");function eS(n={}){let e={version:n.version||0,clientID:n.clientID==null?Math.floor(Math.random()*4294967295):n.clientID};return new ne({key:Pt,state:{init:()=>new _r(e.version,[]),apply(t,r){let i=t.getMeta(Pt);return i||(t.docChanged?new _r(r.version,r.unconfirmed.concat(Z1(t))):r)}},config:e,historyPreserveItems:!0})}function tS(n,e,t,r={}){let i=Pt.getState(n),o=i.version+e.length,s=Pt.get(n).spec.config.clientID,l=0;for(;l<t.length&&t[l]==s;)++l;let a=i.unconfirmed.slice(l);if(e=l?e.slice(l):e,!e.length)return n.tr.setMeta(Pt,new _r(o,a));let c=a.length,u=n.tr;if(c)a=X1(a,e,u);else{for(let d=0;d<e.length;d++)u.step(e[d]);a=[]}let f=new _r(o,a);return r&&r.mapSelectionBackward&&n.selection instanceof j&&(u.setSelection(j.between(u.doc.resolve(u.mapping.map(n.selection.anchor,-1)),u.doc.resolve(u.mapping.map(n.selection.head,-1)),-1)),u.updated&=-2),u.setMeta("rebased",c).setMeta("addToHistory",!1).setMeta(Pt,f)}function nS(n){let e=Pt.getState(n);return e.unconfirmed.length==0?null:{version:e.version,steps:e.unconfirmed.map(t=>t.step),clientID:Pt.get(n).spec.config.clientID,get origins(){return this._origins||(this._origins=e.unconfirmed.map(t=>t.origin))}}}function rS(n){return Pt.getState(n).version}export{dc as Editor,ae as Step,du as TooltipProvider,c0 as callCommand,eS as collab,B0 as commonmark,gs as defaultValueCtx,rt as editorViewCtx,rS as getVersion,Q1 as history,Dm as listener,iu as listenerCtx,tS as receiveTransaction,Xs as redoCommand,Cs as rootCtx,nS as sendableSteps,Rn as serializerCtx,vs as toggleEmphasisCommand,Ds as toggleStrongCommand,W1 as tooltipFactory,Ls as turnIntoTextCommand,Qs as undoCommand,zs as wrapInBlockquoteCommand,Fs as wrapInBulletListCommand,At as wrapInHeadingCommand}; 46 + `):e.addNode("break")}}}));w(Dn.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});w(Dn.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Pc=J("InsertHardbreak",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(!(r instanceof j))return!1;if(r.empty){let o=r.$from.node();if(o.childCount>0&&o.lastChild?.type.name==="hardbreak")return t?.(i.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(W.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return t?.(i.setMeta("hardbreak",!0).replaceSelectionWith(Dn.type(n).create()).scrollIntoView()),!0});w(Pc,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Lc=De("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:n=>{let e=n.get(G);return()=>e.call(Pc.key)}}});w(Lc.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});w(Lc.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Bc=Ye("hr");w(Bc,{displayName:"Attr<hr>",group:"Hr"});var _i=We("hr",n=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",n.get(Bc.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,r)=>{e.addNode(r)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));w(_i.node,{displayName:"NodeSchema<hr>",group:"Hr"});w(_i.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var hm=Ge(n=>new Ne(/^(?:---|___\s|\*\*\*\s)$/,(e,t,r,i)=>{let{tr:o}=e;return t[0]&&o.replaceWith(r-1,i,_i.type(n).create()),o}));w(hm,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var dm=J("InsertHr",n=>()=>(e,t)=>{if(!t)return!0;let r=Pn.node.type(n).create(),{tr:i,selection:o}=e,{from:s}=o,l=_i.type(n).create();if(!l)return!0;let a=i.replaceSelectionWith(l).insert(s,r),c=W.findFrom(a.doc.resolve(s),1,!0);return c&&t(a.setSelection(c).scrollIntoView()),!0});w(dm,{displayName:"Command<insertHrCommand>",group:"Hr"});var zc=Ye("bulletList");w(zc,{displayName:"Attr<bulletList>",group:"BulletList"});var Rr=We("bullet_list",n=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...n.get(zc.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,r)=>{let i=t.spread!=null?`${t.spread}`:"false";e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));w(Rr.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});w(Rr.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var pm=Ge(n=>Yo(/^\s*([-+*])\s$/,Rr.type(n)));w(pm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var _s=J("WrapInBulletList",n=>()=>yo(Rr.type(n)));w(_s,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Fc=De("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:n=>{let e=n.get(G);return()=>e.call(_s.key)}}});w(Fc.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});w(Fc.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var _c=Ye("orderedList");w(_c,{displayName:"Attr<orderedList>",group:"OrderedList"});var vr=We("ordered_list",n=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...n.get(_c.key)(e),...e.attrs.order===1?{}:e.attrs.order,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,r)=>{let i=t.spread!=null?`${t.spread}`:"true";e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:t.attrs.spread==="true"}),e.next(t.content),e.closeNode()}}}));w(vr.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});w(vr.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var mm=Ge(n=>Yo(/^\s*(\d+)\.\s$/,vr.type(n),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));w(mm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Vc=J("WrapInOrderedList",n=>()=>yo(vr.type(n)));w(Vc,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var $c=De("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:n=>{let e=n.get(G);return()=>e.call(Vc.key)}}});w($c.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});w($c.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Wc=Ye("listItem");w(Wc,{displayName:"Attr<listItem>",group:"ListItem"});var Gt=We("list_item",n=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"\u2022",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Lt(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...n.get(Wc.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,r)=>{let i=t.label!=null?`${t.label}.`:"\u2022",o=t.label!=null?"ordered":"bullet",s=t.spread!=null?`${t.spread}`:"true";e.openNode(r,{label:i,listType:o,spread:s}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));w(Gt.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});w(Gt.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var jc=J("SinkListItem",n=>()=>Qp(Gt.type(n)));w(jc,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Hc=J("LiftListItem",n=>()=>Yp(Gt.type(n)));w(Hc,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var qc=J("SplitListItem",n=>()=>Gp(Gt.type(n)));w(qc,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function x0(n){return(e,t,r)=>{let{selection:i}=e;if(!(i instanceof j))return!1;let{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==Gt.type(n)?!1:Rl(e,t,r)}}var Kc=J("LiftFirstListItem",n=>()=>x0(n));w(Kc,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Uc=De("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:n=>{let e=n.get(G);return()=>e.call(qc.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:n=>{let e=n.get(G);return()=>e.call(jc.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:n=>{let e=n.get(G);return()=>e.call(Hc.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:n=>{let e=n.get(G);return()=>e.call(Kc.key)}}});w(Uc.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});w(Uc.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var gm=As("text",()=>({group:"inline",parseMarkdown:{match:({type:n})=>n==="text",runner:(n,e)=>{n.addText(e.value)}},toMarkdown:{match:n=>n.type.name==="text",runner:(n,e)=>{n.addNode("text",void 0,e.text)}}}));w(gm,{displayName:"NodeSchema<text>",group:"Text"});var Jc=Ye("html");w(Jc,{displayName:"Attr<html>",group:"Html"});var Gc=We("html",n=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{let t=document.createElement("span"),r={...n.get(Jc.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",r,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,r)=>{e.addNode(r,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));w(Gc.node,{displayName:"NodeSchema<html>",group:"Html"});w(Gc.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var k0=[sm,Cc,Pn,zs,Nc,Ln,vs,Dn,Oc,zi,Ac,Fi,Bc,_i,Dc,Ar,zc,Rr,_c,vr,Wc,Gt,mc,Er,yc,Bi,kc,Jt,Sc,Or,Jc,Gc,gm].flat(),b0=[am,pm,mm,cm,hm,lm].flat(),w0=[em,tm,rm,nm],S0=J("IsMarkSelected",()=>n=>e=>{if(!n)return!1;let{doc:t,selection:r}=e;return t.rangeHasMark(r.from,r.to,n)}),C0=J("IsNoteSelected",()=>n=>e=>n?Sd(e,n).hasNode:!1),M0=J("ClearTextInCurrentBlock",()=>()=>(n,e)=>{let t=n.tr,{$from:r,$to:i}=t.selection,{pos:o}=r,{pos:s}=i,l=o-r.node().content.size;return l<0?!1:(t=t.deleteRange(l,s),e?.(t),!0)}),N0=J("SetBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr,{from:s,to:l}=o.selection;try{o.setBlockType(s,l,r,i)}catch{return!1}return t?.(o),!0}),I0=J("WrapInBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let{$from:s,$to:l}=o.selection,a=s.blockRange(l),c=a&&cn(a,r,i);if(!c)return!1;o=o.wrap(a,c)}catch{return!1}return t?.(o),!0}),T0=J("AddBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let s=r instanceof Ae?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t?.(o),!0}),O0=J("SelectTextNearPos",()=>n=>(e,t)=>{let{pos:r}=n??{};if(r==null)return!1;let i=(s,l,a)=>Math.min(Math.max(s,l),a),o=e.tr;try{let s=e.doc.resolve(i(r,0,e.doc.content.size));o.setSelection(j.near(s))}catch{return!1}return t?.(o.scrollIntoView()),!0}),E0=[Bs,Fs,At,Ic,Rc,Pc,dm,um,fm,Vc,_s,jc,qc,Hc,Kc,Ds,bc,Ps,im,om,S0,C0,M0,N0,I0,T0,O0],A0=[Ec,vc,Lc,Tc,Uc,$c,Fc,Mc,gc,wc,xc].flat(),Yc=vn("remarkAddOrderInList",()=>()=>n=>{et(n,"list",e=>{if(e.ordered){let t=e.start??1;e.children.forEach((r,i)=>{r.label=i+t})}})});w(Yc.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});w(Yc.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var Qc=vn("remarkLineBreak",()=>()=>n=>{let e=/[\t ]*(?:\r?\n|\r)/g;et(n,"text",(t,r,i)=>{if(!t.value||typeof t.value!="string")return;let o=[],s=0;e.lastIndex=0;let l=e.exec(t.value);for(;l;){let c=l.index;s!==c&&o.push({type:"text",value:t.value.slice(s,c)}),o.push({type:"break",data:{isInline:!0}}),s=c+l[0].length,l=e.exec(t.value)}if(o.length>0&&i&&typeof r=="number")return s<t.value.length&&o.push({type:"text",value:t.value.slice(s)}),i.children.splice(r,1,...o),r+o.length})});w(Qc.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});w(Qc.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var Xc=vn("remarkInlineLink",()=>Rs);w(Xc.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});w(Xc.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var R0=n=>!!n.children,v0=n=>n.type==="html";function D0(n,e){return t(n,0,null)[0];function t(r,i,o){if(R0(r)){let s=[];for(let l=0,a=r.children.length;l<a;l++){let c=r.children[l];if(c){let u=t(c,l,r);if(u)for(let f=0,d=u.length;f<d;f++){let h=u[f];h&&s.push(h)}}}r.children=s}return e(r,i,o)}}var P0=["root","blockquote","listItem"],Zc=vn("remarkHTMLTransformer",()=>()=>n=>{D0(n,(e,t,r)=>v0(e)?(r&&P0.includes(r.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});w(Zc.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});w(Zc.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var eu=vn("remarkMarker",()=>()=>(n,e)=>{let t=r=>e.value.charAt(r.position.start.offset);et(n,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=t(r)})});w(eu.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});w(eu.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var ym=ut(()=>{let n=!1,e=new re("MILKDOWN_INLINE_NODES_CURSOR"),t=new ne({key:e,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;let i=r.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(r,i)=>n?(n=!1,requestAnimationFrame(()=>{if(t.getState(r.state)){let s=r.state.selection.from;i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",s))}}),!0):!1,compositionstart:r=>(t.getState(r.state)&&(n=!0),!1),beforeinput:(r,i)=>{if(t.getState(r.state)&&i instanceof InputEvent&&i.data&&!n){let s=r.state.selection.from;return i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",s)),!0}return!1}},decorations(r){if(t.getState(r)){let s=r.selection.$from.pos,l=document.createElement("span"),a=nt.widget(s,l,{side:-1}),c=document.createElement("span"),u=nt.widget(s,c);return setTimeout(()=>{l.contentEditable="true",c.contentEditable="true"}),Ie.create(r.doc,[a,u])}return Ie.empty}}});return t});w(ym,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var xm=ut(n=>new ne({key:new re("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,r)=>{if(!e.length)return;let[i]=e;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof xe))return;let{from:a}=o;return r.tr.setNodeMarkup(a,Dn.type(n),void 0,[])}if(o instanceof ln){let a=r.tr,{from:c,to:u}=o;return r.doc.nodesBetween(c,u,(f,d)=>{f.type===Dn.type(n)&&(a=a.setNodeMarkup(d,Dn.type(n),void 0,[]))}),a}}}));w(xm,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var tu=$e(["table","code_block"],"hardbreakFilterNodes");w(tu,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var km=ut(n=>{let e=n.get(tu.key);return new ne({key:new re("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,r)=>{let i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){let{from:s}=o,l=r.doc.resolve(s),a=l.depth,c=!0;for(;a>0;)e.includes(l.node(a).type.name)&&(c=!1),a--;return c}return!0}})});w(km,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var bm=ut(n=>{let e=new re("MILKDOWN_HEADING_ID"),t=r=>{if(r.composing)return;let i=n.get(zs.key),o=r.state.tr.setMeta("addToHistory",!1),s=!1,l={};r.state.doc.descendants((a,c)=>{if(a.type===Ln.type(n)){if(a.textContent.trim().length===0)return;let u=a.attrs,f=i(a);l[f]?(l[f]+=1,f+=`-#${l[f]}`):l[f]=1,u.id!==f&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:f}))}}),s&&r.dispatch(o)};return new ne({key:e,view:r=>(t(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});w(bm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var wm=ut(n=>{let e=(t,r,i)=>{if(!i.selection||t.some(f=>f.getMeta("addToHistory")===!1||!f.isGeneric))return null;let o=vr.type(n),s=Rr.type(n),l=Gt.type(n),a=(f,d)=>{let h=!1,p=`${d+1}.`;return f.label!==p&&(f.label=p,h=!0),h},c=i.tr,u=!1;return i.doc.descendants((f,d,h,p)=>{if(f.type===s){let m=f.maybeChild(0);m?.type===l&&m.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(d,o,{spread:"true"}),f.descendants((k,x,I,C)=>{if(k.type===l){let A={...k.attrs};a(A,C)&&(c=c.setNodeMarkup(x,void 0,A))}return!1}))}else if(f.type===l&&h?.type===o){let m={...f.attrs},k=!1;m.listType!=="ordered"&&(m.listType="ordered",k=!0),h?.maybeChild(0)&&(k=a(m,p)),k&&(c=c.setNodeMarkup(d,void 0,m),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new ne({key:new re("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});w(wm,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var L0=[xm,tu,km,ym,Yc,Xc,Qc,Zc,eu,Ls,bm,wm].flat(),B0=[k0,b0,w0,E0,A0,L0].flat();var z0=typeof global=="object"&&global&&global.Object===Object&&global,Sm=z0;var F0=typeof self=="object"&&self&&self.Object===Object&&self,_0=Sm||F0||Function("return this")(),Vs=_0;var V0=Vs.Symbol,Dr=V0;var Cm=Object.prototype,$0=Cm.hasOwnProperty,W0=Cm.toString,Vi=Dr?Dr.toStringTag:void 0;function j0(n){var e=$0.call(n,Vi),t=n[Vi];try{n[Vi]=void 0;var r=!0}catch{}var i=W0.call(n);return r&&(e?n[Vi]=t:delete n[Vi]),i}var Mm=j0;var H0=Object.prototype,q0=H0.toString;function K0(n){return q0.call(n)}var Nm=K0;var U0="[object Null]",J0="[object Undefined]",Im=Dr?Dr.toStringTag:void 0;function G0(n){return n==null?n===void 0?J0:U0:Im&&Im in Object(n)?Mm(n):Nm(n)}var Tm=G0;function Y0(n){return n!=null&&typeof n=="object"}var Om=Y0;var Q0="[object Symbol]";function X0(n){return typeof n=="symbol"||Om(n)&&Tm(n)==Q0}var Em=X0;var Z0=/\s/;function e1(n){for(var e=n.length;e--&&Z0.test(n.charAt(e)););return e}var Am=e1;var t1=/^\s+/;function n1(n){return n&&n.slice(0,Am(n)+1).replace(t1,"")}var Rm=n1;function r1(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Bn=r1;var vm=NaN,i1=/^[-+]0x[0-9a-f]+$/i,o1=/^0b[01]+$/i,s1=/^0o[0-7]+$/i,l1=parseInt;function a1(n){if(typeof n=="number")return n;if(Em(n))return vm;if(Bn(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Bn(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Rm(n);var t=o1.test(n);return t||s1.test(n)?l1(n.slice(2),t?2:8):i1.test(n)?vm:+n}var nu=a1;var c1=function(){return Vs.Date.now()},$s=c1;var u1="Expected a function",f1=Math.max,h1=Math.min;function d1(n,e,t){var r,i,o,s,l,a,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(u1);e=nu(e)||0,Bn(t)&&(u=!!t.leading,f="maxWait"in t,o=f?f1(nu(t.maxWait)||0,e):o,d="trailing"in t?!!t.trailing:d);function h(b){var T=r,P=i;return r=i=void 0,c=b,s=n.apply(P,T),s}function p(b){return c=b,l=setTimeout(x,e),u?h(b):s}function m(b){var T=b-a,P=b-c,D=e-T;return f?h1(D,o-P):D}function k(b){var T=b-a,P=b-c;return a===void 0||T>=e||T<0||f&&P>=o}function x(){var b=$s();if(k(b))return I(b);l=setTimeout(x,m(b))}function I(b){return l=void 0,d&&r?h(b):(r=i=void 0,s)}function C(){l!==void 0&&clearTimeout(l),c=0,r=a=i=l=void 0}function A(){return l===void 0?s:I($s())}function v(){var b=$s(),T=k(b);if(r=arguments,i=this,a=b,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(x,e),h(a)}return l===void 0&&(l=setTimeout(x,e)),s}return v.cancel=C,v.flush=A,v}var $i=d1;var p1="Expected a function";function m1(n,e,t){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(p1);return Bn(t)&&(r="leading"in t?!!t.leading:r,i="trailing"in t?!!t.trailing:i),$i(n,e,{leading:r,maxWait:e,trailing:i})}var ru=m1;var Ws=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},iu=$(new Ws,"listener"),g1=new re("MILKDOWN_LISTENER"),Dm=n=>(n.inject(iu,new Ws),async()=>{await n.wait(Tt);let e=n.get(iu),{listeners:t}=e;t.beforeMount.forEach(a=>a(n)),await n.wait(Mr);let r=n.get(Rn),i=null,o=null,s=null,l=new ne({key:g1,view:()=>({destroy:()=>{t.destroy.forEach(a=>a(n))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(a=>a(n)),!1),blur:()=>(t.blur.forEach(a=>a(n)),!1)}},state:{init:(a,c)=>{i=c.doc,o=r(c.doc)},apply:a=>{let c=a.selection;return(!s&&c||s&&!c.eq(s))&&(t.selectionUpdated.forEach(f=>{f(n,c,s)}),s=c),!(a.docChanged||a.storedMarksSet)||a.getMeta("addToHistory")===!1?void 0:$i(()=>{let{doc:f}=a;if(t.updated.length>0&&i&&!i.eq(f)&&t.updated.forEach(d=>{d(n,f,i)}),t.markdownUpdated.length>0&&i&&!i.eq(f)){let d=r(f);t.markdownUpdated.forEach(h=>{h(n,d,o)}),o=d}i=f},200)()}}});n.update(ct,a=>a.concat(l)),await n.wait(Di),t.mounted.forEach(a=>a(n))});Dm.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var Pr=Math.min,Rt=Math.max,ji=Math.round,Hi=Math.floor,it=n=>({x:n,y:n}),y1={left:"right",right:"left",bottom:"top",top:"bottom"};function ou(n,e,t){return Rt(n,Pr(e,t))}function qi(n,e){return typeof n=="function"?n(e):n}function Yt(n){return n.split("-")[0]}function Ki(n){return n.split("-")[1]}function su(n){return n==="x"?"y":"x"}function lu(n){return n==="y"?"height":"width"}function vt(n){let e=n[0];return e==="t"||e==="b"?"y":"x"}function au(n){return su(vt(n))}function Bm(n,e,t){t===void 0&&(t=!1);let r=Ki(n),i=au(n),o=lu(i),s=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Wi(s)),[s,Wi(s)]}function zm(n){let e=Wi(n);return[js(n),e,js(e)]}function js(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}var Pm=["left","right"],Lm=["right","left"],x1=["top","bottom"],k1=["bottom","top"];function b1(n,e,t){switch(n){case"top":case"bottom":return t?e?Lm:Pm:e?Pm:Lm;case"left":case"right":return e?x1:k1;default:return[]}}function Fm(n,e,t,r){let i=Ki(n),o=b1(Yt(n),t==="start",r);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(js)))),o}function Wi(n){let e=Yt(n);return y1[e]+n.slice(e.length)}function w1(n){return{top:0,right:0,bottom:0,left:0,...n}}function _m(n){return typeof n!="number"?w1(n):{top:n,right:n,bottom:n,left:n}}function zn(n){let{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function Vm(n,e,t){let{reference:r,floating:i}=n,o=vt(e),s=au(e),l=lu(s),a=Yt(e),c=o==="y",u=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,d=r[l]/2-i[l]/2,h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-i.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Ki(e)){case"start":h[s]-=d*(t&&c?-1:1);break;case"end":h[s]+=d*(t&&c?-1:1);break}return h}async function $m(n,e){var t;e===void 0&&(e={});let{x:r,y:i,platform:o,rects:s,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=qi(e,n),p=_m(h),k=l[d?f==="floating"?"reference":"floating":f],x=zn(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(k)))==null||t?k:k.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),I=f==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),A=await(o.isElement==null?void 0:o.isElement(C))?await(o.getScale==null?void 0:o.getScale(C))||{x:1,y:1}:{x:1,y:1},v=zn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:I,offsetParent:C,strategy:a}):I);return{top:(x.top-v.top+p.top)/A.y,bottom:(v.bottom-x.bottom+p.bottom)/A.y,left:(x.left-v.left+p.left)/A.x,right:(v.right-x.right+p.right)/A.x}}var S1=50,Wm=async(n,e,t)=>{let{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,l=s.detectOverflow?s:{...s,detectOverflow:$m},a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:f}=Vm(c,r,a),d=r,h=0,p={};for(let m=0;m<o.length;m++){let k=o[m];if(!k)continue;let{name:x,fn:I}=k,{x:C,y:A,data:v,reset:b}=await I({x:u,y:f,initialPlacement:r,placement:d,strategy:i,middlewareData:p,rects:c,platform:l,elements:{reference:n,floating:e}});u=C??u,f=A??f,p[x]={...p[x],...v},b&&h<S1&&(h++,typeof b=="object"&&(b.placement&&(d=b.placement),b.rects&&(c=b.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:i}):b.rects),{x:u,y:f}=Vm(c,d,a)),m=-1)}return{x:u,y:f,placement:d,strategy:i,middlewareData:p}};var jm=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;let{placement:i,middlewareData:o,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...k}=qi(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};let x=Yt(i),I=vt(l),C=Yt(l)===l,A=await(a.isRTL==null?void 0:a.isRTL(c.floating)),v=d||(C||!m?[Wi(l)]:zm(l)),b=p!=="none";!d&&b&&v.push(...Fm(l,m,p,A));let T=[l,...v],P=await a.detectOverflow(e,k),D=[],U=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&D.push(P[x]),f){let L=Bm(i,s,A);D.push(P[L[0]],P[L[1]])}if(U=[...U,{placement:i,overflows:D}],!D.every(L=>L<=0)){var Se,Y;let L=(((Se=o.flip)==null?void 0:Se.index)||0)+1,F=T[L];if(F&&(!(f==="alignment"?I!==vt(F):!1)||U.every(te=>vt(te.placement)===I?te.overflows[0]>0:!0)))return{data:{index:L,overflows:U},reset:{placement:F}};let Q=(Y=U.filter(X=>X.overflows[0]<=0).sort((X,te)=>X.overflows[1]-te.overflows[1])[0])==null?void 0:Y.placement;if(!Q)switch(h){case"bestFit":{var R;let X=(R=U.filter(te=>{if(b){let le=vt(te.placement);return le===I||le==="y"}return!0}).map(te=>[te.placement,te.overflows.filter(le=>le>0).reduce((le,g)=>le+g,0)]).sort((te,le)=>te[1]-le[1])[0])==null?void 0:R[0];X&&(Q=X);break}case"initialPlacement":Q=l;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};var C1=new Set(["left","top"]);async function M1(n,e){let{placement:t,platform:r,elements:i}=n,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Yt(t),l=Ki(t),a=vt(t)==="y",c=C1.has(s)?-1:1,u=o&&a?-1:1,f=qi(e,n),{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:d*c}:{x:d*c,y:h*u}}var Hm=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:s,middlewareData:l}=e,a=await M1(e,n);return s===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:o+a.y,data:{...a,placement:s}}}}},qm=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:r,placement:i,platform:o}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:a={fn:x=>{let{x:I,y:C}=x;return{x:I,y:C}}},...c}=qi(n,e),u={x:t,y:r},f=await o.detectOverflow(e,c),d=vt(Yt(i)),h=su(d),p=u[h],m=u[d];if(s){let x=h==="y"?"top":"left",I=h==="y"?"bottom":"right",C=p+f[x],A=p-f[I];p=ou(C,p,A)}if(l){let x=d==="y"?"top":"left",I=d==="y"?"bottom":"right",C=m+f[x],A=m-f[I];m=ou(C,m,A)}let k=a.fn({...e,[h]:p,[d]:m});return{...k,data:{x:k.x-t,y:k.y-r,enabled:{[h]:s,[d]:l}}}}}};function Hs(){return typeof window<"u"}function _n(n){return Um(n)?(n.nodeName||"").toLowerCase():"#document"}function Pe(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ot(n){var e;return(e=(Um(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Um(n){return Hs()?n instanceof Node||n instanceof Pe(n).Node:!1}function Qe(n){return Hs()?n instanceof Element||n instanceof Pe(n).Element:!1}function ft(n){return Hs()?n instanceof HTMLElement||n instanceof Pe(n).HTMLElement:!1}function Km(n){return!Hs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Pe(n).ShadowRoot}function Br(n){let{overflow:e,overflowX:t,overflowY:r,display:i}=Xe(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&i!=="inline"&&i!=="contents"}function Jm(n){return/^(table|td|th)$/.test(_n(n))}function Ui(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}var N1=/transform|translate|scale|rotate|perspective|filter/,I1=/paint|layout|strict|content/,Fn=n=>!!n&&n!=="none",cu;function qs(n){let e=Qe(n)?Xe(n):n;return Fn(e.transform)||Fn(e.translate)||Fn(e.scale)||Fn(e.rotate)||Fn(e.perspective)||!Ks()&&(Fn(e.backdropFilter)||Fn(e.filter))||N1.test(e.willChange||"")||I1.test(e.contain||"")}function Gm(n){let e=Dt(n);for(;ft(e)&&!Vn(e);){if(qs(e))return e;if(Ui(e))return null;e=Dt(e)}return null}function Ks(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Vn(n){return/^(html|body|#document)$/.test(_n(n))}function Xe(n){return Pe(n).getComputedStyle(n)}function Ji(n){return Qe(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Dt(n){if(_n(n)==="html")return n;let e=n.assignedSlot||n.parentNode||Km(n)&&n.host||ot(n);return Km(e)?e.host:e}function Ym(n){let e=Dt(n);return Vn(e)?n.ownerDocument?n.ownerDocument.body:n.body:ft(e)&&Br(e)?e:Ym(e)}function Lr(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);let i=Ym(n),o=i===((r=n.ownerDocument)==null?void 0:r.body),s=Pe(i);if(o){let l=Us(s);return e.concat(s,s.visualViewport||[],Br(i)?i:[],l&&t?Lr(l):[])}else return e.concat(i,Lr(i,[],t))}function Us(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function eg(n){let e=Xe(n),t=parseFloat(e.width)||0,r=parseFloat(e.height)||0,i=ft(n),o=i?n.offsetWidth:t,s=i?n.offsetHeight:r,l=ji(t)!==o||ji(r)!==s;return l&&(t=o,r=s),{width:t,height:r,$:l}}function fu(n){return Qe(n)?n:n.contextElement}function zr(n){let e=fu(n);if(!ft(e))return it(1);let t=e.getBoundingClientRect(),{width:r,height:i,$:o}=eg(e),s=(o?ji(t.width):t.width)/r,l=(o?ji(t.height):t.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var T1=it(0);function tg(n){let e=Pe(n);return!Ks()||!e.visualViewport?T1:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function O1(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Pe(n)?!1:e}function $n(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);let i=n.getBoundingClientRect(),o=fu(n),s=it(1);e&&(r?Qe(r)&&(s=zr(r)):s=zr(n));let l=O1(o,t,r)?tg(o):it(0),a=(i.left+l.x)/s.x,c=(i.top+l.y)/s.y,u=i.width/s.x,f=i.height/s.y;if(o){let d=Pe(o),h=r&&Qe(r)?Pe(r):r,p=d,m=Us(p);for(;m&&r&&h!==p;){let k=zr(m),x=m.getBoundingClientRect(),I=Xe(m),C=x.left+(m.clientLeft+parseFloat(I.paddingLeft))*k.x,A=x.top+(m.clientTop+parseFloat(I.paddingTop))*k.y;a*=k.x,c*=k.y,u*=k.x,f*=k.y,a+=C,c+=A,p=Pe(m),m=Us(p)}}return zn({width:u,height:f,x:a,y:c})}function Js(n,e){let t=Ji(n).scrollLeft;return e?e.left+t:$n(ot(n)).left+t}function ng(n,e){let t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Js(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function E1(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n,o=i==="fixed",s=ot(r),l=e?Ui(e.floating):!1;if(r===s||l&&o)return t;let a={scrollLeft:0,scrollTop:0},c=it(1),u=it(0),f=ft(r);if((f||!f&&!o)&&((_n(r)!=="body"||Br(s))&&(a=Ji(r)),f)){let h=$n(r);c=zr(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}let d=s&&!f&&!o?ng(s,a):it(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x+d.x,y:t.y*c.y-a.scrollTop*c.y+u.y+d.y}}function A1(n){return Array.from(n.getClientRects())}function R1(n){let e=ot(n),t=Ji(n),r=n.ownerDocument.body,i=Rt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=Rt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-t.scrollLeft+Js(n),l=-t.scrollTop;return Xe(r).direction==="rtl"&&(s+=Rt(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:l}}var Qm=25;function v1(n,e){let t=Pe(n),r=ot(n),i=t.visualViewport,o=r.clientWidth,s=r.clientHeight,l=0,a=0;if(i){o=i.width,s=i.height;let u=Ks();(!u||u&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}let c=Js(r);if(c<=0){let u=r.ownerDocument,f=u.body,d=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(r.clientWidth-f.clientWidth-h);p<=Qm&&(o-=p)}else c<=Qm&&(o+=c);return{width:o,height:s,x:l,y:a}}function D1(n,e){let t=$n(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,o=ft(n)?zr(n):it(1),s=n.clientWidth*o.x,l=n.clientHeight*o.y,a=i*o.x,c=r*o.y;return{width:s,height:l,x:a,y:c}}function Xm(n,e,t){let r;if(e==="viewport")r=v1(n,t);else if(e==="document")r=R1(ot(n));else if(Qe(e))r=D1(e,t);else{let i=tg(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return zn(r)}function rg(n,e){let t=Dt(n);return t===e||!Qe(t)||Vn(t)?!1:Xe(t).position==="fixed"||rg(t,e)}function P1(n,e){let t=e.get(n);if(t)return t;let r=Lr(n,[],!1).filter(l=>Qe(l)&&_n(l)!=="body"),i=null,o=Xe(n).position==="fixed",s=o?Dt(n):n;for(;Qe(s)&&!Vn(s);){let l=Xe(s),a=qs(s);!a&&l.position==="fixed"&&(i=null),(o?!a&&!i:!a&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Br(s)&&!a&&rg(n,s))?r=r.filter(u=>u!==s):i=l,s=Dt(s)}return e.set(n,r),r}function L1(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n,s=[...t==="clippingAncestors"?Ui(e)?[]:P1(e,this._c):[].concat(t),r],l=Xm(e,s[0],i),a=l.top,c=l.right,u=l.bottom,f=l.left;for(let d=1;d<s.length;d++){let h=Xm(e,s[d],i);a=Rt(h.top,a),c=Pr(h.right,c),u=Pr(h.bottom,u),f=Rt(h.left,f)}return{width:c-f,height:u-a,x:f,y:a}}function B1(n){let{width:e,height:t}=eg(n);return{width:e,height:t}}function z1(n,e,t){let r=ft(e),i=ot(e),o=t==="fixed",s=$n(n,!0,o,e),l={scrollLeft:0,scrollTop:0},a=it(0);function c(){a.x=Js(i)}if(r||!r&&!o)if((_n(e)!=="body"||Br(i))&&(l=Ji(e)),r){let h=$n(e,!0,o,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else i&&c();o&&!r&&i&&c();let u=i&&!r&&!o?ng(i,l):it(0),f=s.left+l.scrollLeft-a.x-u.x,d=s.top+l.scrollTop-a.y-u.y;return{x:f,y:d,width:s.width,height:s.height}}function uu(n){return Xe(n).position==="static"}function Zm(n,e){if(!ft(n)||Xe(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return ot(n)===t&&(t=t.ownerDocument.body),t}function ig(n,e){let t=Pe(n);if(Ui(n))return t;if(!ft(n)){let i=Dt(n);for(;i&&!Vn(i);){if(Qe(i)&&!uu(i))return i;i=Dt(i)}return t}let r=Zm(n,e);for(;r&&Jm(r)&&uu(r);)r=Zm(r,e);return r&&Vn(r)&&uu(r)&&!qs(r)?t:r||Gm(n)||t}var F1=async function(n){let e=this.getOffsetParent||ig,t=this.getDimensions,r=await t(n.floating);return{reference:z1(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _1(n){return Xe(n).direction==="rtl"}var V1={convertOffsetParentRelativeRectToViewportRelativeRect:E1,getDocumentElement:ot,getClippingRect:L1,getOffsetParent:ig,getElementRects:F1,getClientRects:A1,getDimensions:B1,getScale:zr,isElement:Qe,isRTL:_1};function og(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function $1(n,e){let t=null,r,i=ot(n);function o(){var l;clearTimeout(r),(l=t)==null||l.disconnect(),t=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),o();let c=n.getBoundingClientRect(),{left:u,top:f,width:d,height:h}=c;if(l||e(),!d||!h)return;let p=Hi(f),m=Hi(i.clientWidth-(u+d)),k=Hi(i.clientHeight-(f+h)),x=Hi(u),C={rootMargin:-p+"px "+-m+"px "+-k+"px "+-x+"px",threshold:Rt(0,Pr(1,a))||1},A=!0;function v(b){let T=b[0].intersectionRatio;if(T!==a){if(!A)return s();T?s(!1,T):r=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!og(c,n.getBoundingClientRect())&&s(),A=!1}try{t=new IntersectionObserver(v,{...C,root:i.ownerDocument})}catch{t=new IntersectionObserver(v,C)}t.observe(n)}return s(!0),o}function hu(n,e,t,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=fu(n),u=i||o?[...c?Lr(c):[],...e?Lr(e):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});let f=c&&l?$1(c,t):null,d=-1,h=null;s&&(h=new ResizeObserver(x=>{let[I]=x;I&&I.target===c&&h&&e&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(e)})),t()}),c&&!a&&h.observe(c),e&&h.observe(e));let p,m=a?$n(n):null;a&&k();function k(){let x=$n(n);m&&!og(m,x)&&t(),m=x,p=requestAnimationFrame(k)}return t(),()=>{var x;u.forEach(I=>{i&&I.removeEventListener("scroll",t),o&&I.removeEventListener("resize",t)}),f?.(),(x=h)==null||x.disconnect(),h=null,a&&cancelAnimationFrame(p)}}var sg=Hm;var lg=qm,ag=jm;var cg=(n,e,t)=>{let r=new Map,i={platform:V1,...t},o={...i.platform,_c:r};return Wm(n,e,{...i,platform:o})};var du=class{constructor(e){this.#o=!1,this.onShow=()=>{},this.onHide=()=>{},this.#c=t=>{cg(t,this.element,{placement:this.#n.placement??"top",middleware:[ag(),sg(this.#l),lg(this.#a),...this.#r],...this.#n}).then(({x:r,y:i})=>{Object.assign(this.element.style,{left:`${r}px`,top:`${i}px`})}).catch(console.error)},this.#u=t=>this.#s!==t.dom.parentElement,this.#d=(t,r)=>{let{state:i,composing:o}=t,{selection:s,doc:l}=i,{ranges:a}=s,c=Math.min(...a.map(h=>h.$from.pos)),u=Math.max(...a.map(h=>h.$to.pos)),f=r&&r.doc.eq(l)&&r.selection.eq(s);if(this.#o||((this.#s??t.dom.parentElement??document.body).appendChild(this.element),this.#o=!0),o||f)return;if(this.#i?.(),this.#i=void 0,!this.#e(t,r)){this.hide();return}let d={getBoundingClientRect:()=>bd(t,c,u),contextElement:t.dom};this.#u(t)?this.#i=hu(d,this.element,()=>this.#c(d)):this.#c(d),this.show()},this.update=(t,r)=>{this.#h(t,r)},this.destroy=()=>{this.#i?.(),this.#h.cancel()},this.show=(t,r)=>{if(this.element.dataset.show="true",t){this.#i?.(),this.#i=void 0;let i={...t,contextElement:r?.dom};r&&this.#u(r)?this.#i=hu(i,this.element,()=>this.#c(i)):this.#c(i)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=e.content,this.#t=e.debounce??200,this.#e=e.shouldShow??this.#f,this.#l=e.offset,this.#a=e.shift,this.#r=e.middleware??[],this.#n=e.floatingUIOptions??{},this.#s=e.root,this.element.dataset.show="false",this.#h=ru(this.#d,this.#t)}#t;#e;#r;#n;#s;#o;#i;#l;#a;#h;#c;#u;#d;#f(e){let{doc:t,selection:r}=e.state,{empty:i,from:o,to:s}=r,l=!t.textBetween(o,s).length&&e.state.selection instanceof j,a=this.element.contains(document.activeElement),c=!e.hasFocus()&&!a,u=!e.editable;return!(c||i||l||u)}};function W1(n){let e=$e({},`${n}_TOOLTIP_SPEC`),t=ut(i=>{let o=i.get(e.key);return new ne({key:new re(`${n}_TOOLTIP`),...o})}),r=[e,t];return r.key=e.key,r.pluginKey=t.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${n}`},t.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${n}`},r}var Gs=200,ge=function(){};ge.prototype.append=function(e){return e.length?(e=ge.from(e),!this.length&&e||e.length<Gs&&this.leafAppend(e)||this.length<Gs&&e.leafPrepend(this)||this.appendInner(e)):this};ge.prototype.prepend=function(e){return e.length?ge.from(e).append(this):this};ge.prototype.appendInner=function(e){return new j1(this,e)};ge.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ge.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ge.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ge.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ge.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};ge.from=function(e){return e instanceof ge?e:e&&e.length?new ug(e):ge.empty};var ug=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Gs)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Gs)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ge);ge.empty=new ug([]);var j1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ge),pu=ge;var H1=500,jn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new ht(f.map));let h=f.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new ht(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new ht(e.mapping.maps[u],f,t),h;(h=a&&a.merge(d))&&(d=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(d),t&&(s++,t=void 0),i||(a=d)}let c=s-r.depth;return c>K1&&(l=q1(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new Xr;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new ht(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(d.step){let m=e.steps[h].invert(e.docs[h]),k=d.selection&&d.selection.map(o.slice(a+1,h));k&&l++,r.push(new ht(p,m,k))}else r.push(new ht(p))},i);let c=[];for(let d=t;d<s;d++)c.push(new ht(o.maps[d]));let u=this.items.slice(0,i).append(c).append(r),f=new n(u,l);return f.emptyItemCount()>H1&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let f=new ht(c.invert(),a,u),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(pu.from(i.reverse()),o)}};jn.empty=new jn(pu.empty,0);function q1(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var ht=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},dt=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},K1=20;function U1(n,e,t,r){let i=t.getMeta(Wn),o;if(i)return i.historyState;t.getMeta(Y1)&&(n=new dt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Wn))return s.getMeta(Wn).redo?new dt(n.done.addTransform(t,void 0,r,Ys(e)),n.undone,fg(t.mapping.maps),n.prevTime,n.prevComposition):new dt(n.done,n.undone.addTransform(t,void 0,r,Ys(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!J1(t,n.prevRanges)),c=s?mu(n.prevRanges,t.mapping):fg(t.mapping.maps);return new dt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ys(e)),jn.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new dt(n.done.rebased(t,o),n.undone.rebased(t,o),mu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new dt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),mu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function J1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function fg(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function mu(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function G1(n,e,t){let r=Ys(e),i=Wn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new dt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(Wn,{redo:t,historyState:a})}var gu=!1,hg=null;function Ys(n){let e=n.plugins;if(hg!=e){gu=!1,hg=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){gu=!0;break}}return gu}var Wn=new re("history"),Y1=new re("closeHistory");function dg(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ne({key:Wn,state:{init(){return new dt(jn.empty,jn.empty,null,0,-1)},apply(e,t,r){return U1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?yu:r=="historyRedo"?xu:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Qs(n,e){return(t,r)=>{let i=Wn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=G1(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var yu=Qs(!1,!0),xu=Qs(!0,!0),BR=Qs(!1,!1),zR=Qs(!0,!1);function Fr(n,e){return Object.assign(n,{meta:{package:"@milkdown/plugin-history",...e}}),n}var Xs=J("Undo",()=>()=>yu);Fr(Xs,{displayName:"Command<undo>"});var Zs=J("Redo",()=>()=>xu);Fr(Zs,{displayName:"Command<redo>"});var ku=$e({},"historyProviderConfig");Fr(ku,{displayName:"Ctx<historyProviderConfig>"});var pg=ut(n=>dg(n.get(ku.key)));Fr(pg,{displayName:"Ctx<historyProviderPlugin>"});var bu=De("historyKeymap",{Undo:{shortcuts:"Mod-z",command:n=>{let e=n.get(G);return()=>e.call(Xs.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:n=>{let e=n.get(G);return()=>e.call(Zs.key)}}});Fr(bu.ctx,{displayName:"KeymapCtx<history>"});Fr(bu.shortcuts,{displayName:"Keymap<history>"});var Q1=[ku,pg,bu,Xs,Zs].flat();var el=class{constructor(e,t,r){this.step=e,this.inverted=t,this.origin=r}};function X1(n,e,t){for(let i=n.length-1;i>=0;i--)t.step(n[i].inverted);for(let i=0;i<e.length;i++)t.step(e[i]);let r=[];for(let i=0,o=n.length;i<n.length;i++){let s=n[i].step.map(t.mapping.slice(o));o--,s&&!t.maybeStep(s).failed&&(t.mapping.setMirror(o,t.steps.length-1),r.push(new el(s,s.invert(t.docs[t.docs.length-1]),n[i].origin)))}return r}var _r=class{constructor(e,t){this.version=e,this.unconfirmed=t}};function Z1(n){let e=[];for(let t=0;t<n.steps.length;t++)e.push(new el(n.steps[t],n.steps[t].invert(n.docs[t]),n));return e}var Pt=new re("collab");function eS(n={}){let e={version:n.version||0,clientID:n.clientID==null?Math.floor(Math.random()*4294967295):n.clientID};return new ne({key:Pt,state:{init:()=>new _r(e.version,[]),apply(t,r){let i=t.getMeta(Pt);return i||(t.docChanged?new _r(r.version,r.unconfirmed.concat(Z1(t))):r)}},config:e,historyPreserveItems:!0})}function tS(n,e,t,r={}){let i=Pt.getState(n),o=i.version+e.length,s=Pt.get(n).spec.config.clientID,l=0;for(;l<t.length&&t[l]==s;)++l;let a=i.unconfirmed.slice(l);if(e=l?e.slice(l):e,!e.length)return n.tr.setMeta(Pt,new _r(o,a));let c=a.length,u=n.tr;if(c)a=X1(a,e,u);else{for(let d=0;d<e.length;d++)u.step(e[d]);a=[]}let f=new _r(o,a);return r&&r.mapSelectionBackward&&n.selection instanceof j&&(u.setSelection(j.between(u.doc.resolve(u.mapping.map(n.selection.anchor,-1)),u.doc.resolve(u.mapping.map(n.selection.head,-1)),-1)),u.updated&=-2),u.setMeta("rebased",c).setMeta("addToHistory",!1).setMeta(Pt,f)}function nS(n){let e=Pt.getState(n);return e.unconfirmed.length==0?null:{version:e.version,steps:e.unconfirmed.map(t=>t.step),clientID:Pt.get(n).spec.config.clientID,get origins(){return this._origins||(this._origins=e.unconfirmed.map(t=>t.origin))}}}function rS(n){return Pt.getState(n).version}export{dc as Editor,ae as Step,du as TooltipProvider,c0 as callCommand,eS as collab,B0 as commonmark,gs as defaultValueCtx,rt as editorViewCtx,Cs as editorViewOptionsCtx,rS as getVersion,Q1 as history,Dm as listener,iu as listenerCtx,tS as receiveTransaction,Zs as redoCommand,Ms as rootCtx,nS as sendableSteps,Rn as serializerCtx,Ds as toggleEmphasisCommand,Ps as toggleStrongCommand,W1 as tooltipFactory,Bs as turnIntoTextCommand,Xs as undoCommand,Fs as wrapInBlockquoteCommand,_s as wrapInBulletListCommand,At as wrapInHeadingCommand}; 47 47 /*! Bundled license information: 48 48 49 49 lodash-es/lodash.js:
+7 -1
templates/document_edit.html
··· 95 95 <script type="module"> 96 96 import {EditorView, basicSetup, markdown, oneDark, Compartment, Annotation} from '/static/vendor/editor.js'; 97 97 import { 98 - Editor, rootCtx, defaultValueCtx, editorViewCtx, serializerCtx, 98 + Editor, rootCtx, defaultValueCtx, editorViewCtx, editorViewOptionsCtx, serializerCtx, 99 99 commonmark, 100 100 listener, listenerCtx, 101 101 history, undoCommand, redoCommand, callCommand, ··· 319 319 .config((ctx) => { 320 320 ctx.set(rootCtx, container); 321 321 ctx.set(defaultValueCtx, initialMarkdown); 322 + // Register the prosemirror-collab plugin so sendableSteps/receiveTransaction 323 + // have a state slot to read from. 324 + ctx.update(editorViewOptionsCtx, (prev) => ({ 325 + ...prev, 326 + plugins: [...(prev.plugins || []), collab({ version: collabClient.version })], 327 + })); 322 328 }) 323 329 .use(commonmark) 324 330 .use(history)