@kystverket/styrbord 1.4.10 → 1.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.js CHANGED
@@ -26310,7 +26310,13 @@ class Tk {
26310
26310
  for (let u of s)
26311
26311
  if (u.nodeName == "BR" && u.parentNode) {
26312
26312
  let A = u.nextSibling;
26313
- A && A.nodeType == 1 && A.contentEditable == "false" && u.parentNode.removeChild(u);
26313
+ for (; A && A.nodeType == 1; ) {
26314
+ if (A.contentEditable == "false") {
26315
+ u.parentNode.removeChild(u);
26316
+ break;
26317
+ }
26318
+ A = A.firstChild;
26319
+ }
26314
26320
  }
26315
26321
  } else if (Je && s.length) {
26316
26322
  let u = s.filter((A) => A.nodeName == "BR");
@@ -26730,11 +26736,11 @@ class Bu {
26730
26736
  }
26731
26737
  updateDraggedNode(e, t) {
26732
26738
  let n = e.node, i = -1;
26733
- if (this.state.doc.nodeAt(n.from) == n.node)
26739
+ if (n.from < this.state.doc.content.size && this.state.doc.nodeAt(n.from) == n.node)
26734
26740
  i = n.from;
26735
26741
  else {
26736
26742
  let l = n.from + (this.state.doc.content.size - t.doc.content.size);
26737
- (l > 0 && this.state.doc.nodeAt(l)) == n.node && (i = l);
26743
+ (l > 0 && l < this.state.doc.content.size && this.state.doc.nodeAt(l)) == n.node && (i = l);
26738
26744
  }
26739
26745
  this.dragging = new yu(e.slice, e.move, i < 0 ? void 0 : n2.create(this.state.doc, i));
26740
26746
  }
@@ -69,6 +69,6 @@ Please create an issue at https://github.com/MikeKovarik/exifr with this file`),
69
69
  `),A&&h==f.nodeValue.length)for(let m=f,I;m;m=m.parentNode){if(I=m.nextSibling){I.nodeName=="BR"&&(o=s={node:I.parentNode,offset:ee(I)+1});break}let M=m.pmViewDesc;if(M&&M.node&&M.node.isBlock)break}}else{let m=f.childNodes[h-1];A=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Pe&&u.focusNode&&u.focusNode!=s.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||A&&le)&&v0(o.node,o.offset,u.anchorNode,u.anchorOffset)&&v0(s.node,s.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||t==e)&&!(A&&Pe)){c.collapse(o.node,o.offset);try{t!=e&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(t>e){let h=o;o=s,s=h}let f=document.createRange();f.setEnd(s.node,s.offset),f.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,i=0;i<this.children.length;i++){let l=this.children[i],a=n+l.size;if(n==a?t<=a&&e>=n:t<a&&e>n){let o=n+l.border,s=a-l.border;if(t>=o&&e<=s){this.dirty=t==n||e==a?z0:Fc,t==o&&e==s&&(l.contentLost||l.dom.parentNode!=this.contentDOM)?l.dirty=Yt:l.markDirty(t-o,e-o);return}else l.dirty=l.dom==l.contentDOM&&l.dom.parentNode==this.contentDOM&&!l.children.length?z0:Yt}n=a}this.dirty=z0}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=t==1?z0:Fc;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class wc extends W7{constructor(t,e,n,i){let l,a=e.type.toDOM;if(typeof a=="function"&&(a=a(n,()=>{if(!l)return i;if(l.parent)return l.parent.posBeforeChild(l)})),!e.type.spec.raw){if(a.nodeType!=1){let o=document.createElement("span");o.appendChild(a),a=o}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(t,[],a,null),this.widget=e,this.widget=e,l=this}matchesWidget(t){return this.dirty==Ge&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):!1}ignoreMutation(t){return t.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}}class Yb extends W7{constructor(t,e,n,i){super(t,[],e,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Q0 extends W7{constructor(t,e,n,i,l){super(t,[],n,i),this.mark=e,this.spec=l}static create(t,e,n,i){let l=i.nodeViews[e.type.name],a=l&&l(e,i,n);return(!a||!a.dom)&&(a=A3.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new Q0(t,e,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&Yt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Yt&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),this.dirty!=Ge){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Ge}}slice(t,e,n){let i=Q0.create(this.parent,this.mark,!0,n),l=this.children,a=this.size;e<a&&(l=d9(l,e,a,n)),t>0&&(l=d9(l,0,t,n));for(let o=0;o<l.length;o++)l[o].parent=i;return i.children=l,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class V1 extends W7{constructor(t,e,n,i,l,a,o,s,c){super(t,[],l,a),this.node=e,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=o}static create(t,e,n,i,l,a){let o=l.nodeViews[e.type.name],s,c=o&&o(e,l,()=>{if(!s)return a;if(s.parent)return s.parent.posBeforeChild(s)},n,i),u=c&&c.dom,A=c&&c.contentDOM;if(e.isText){if(!u)u=document.createTextNode(e.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:A}=A3.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs));!A&&!e.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),e.type.spec.draggable&&(u.draggable=!0));let d=u;return u=$c(u,n,e),c?s=new Vb(t,e,n,i,u,A||null,d,c,l,a+1):e.isText?new l5(t,e,n,i,u,d,l):new V1(t,e,n,i,u,A||null,d,l,a+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>j.empty)}return t}matchesNode(t,e,n){return this.dirty==Ge&&t.eq(this.node)&&a5(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,i=e,l=t.composing?this.localCompositionInfo(t,e):null,a=l&&l.pos>-1?l:null,o=l&&l.pos<0,s=new Kb(this,a&&a.node,t);Tb(this.node,this.innerDeco,(c,u,A)=>{c.spec.marks?s.syncToMarks(c.spec.marks,n,t,u):c.type.side>=0&&!A&&s.syncToMarks(u==this.node.childCount?p2.none:this.node.child(u).marks,n,t,u),s.placeWidget(c,t,i)},(c,u,A,d)=>{s.syncToMarks(c.marks,n,t,d);let f;s.findNodeMatch(c,u,A,d)||o&&t.state.selection.from>i&&t.state.selection.to<i+c.nodeSize&&(f=s.findIndexWithChild(l.node))>-1&&s.updateNodeAt(c,u,A,f,t)||s.updateNextNode(c,u,A,t,d,i)||s.addNode(c,u,A,t,i),i+=c.nodeSize}),s.syncToMarks([],n,t,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==z0)&&(a&&this.protectLocalComposition(t,a),Lc(this.contentDOM,this.children,t),v3&&Wb(this.dom))}localCompositionInfo(t,e){let{from:n,to:i}=t.state.selection;if(!(t.state.selection instanceof m2)||n<e||i>e+this.node.content.size)return null;let l=t.input.compositionNode;if(!l||!this.dom.contains(l.parentNode))return null;if(this.node.inlineContent){let a=l.nodeValue,o=Pb(this.node.content,a,n-e,i-e);return o<0?null:{node:l,pos:o,text:a}}else return{node:l,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:i}){if(this.getDesc(e))return;let l=e;for(;l.parentNode!=this.contentDOM;l=l.parentNode){for(;l.previousSibling;)l.parentNode.removeChild(l.previousSibling);for(;l.nextSibling;)l.parentNode.removeChild(l.nextSibling);l.pmViewDesc&&(l.pmViewDesc=void 0)}let a=new Yb(this,l,e,i);t.input.compositionNodes.push(a),this.children=d9(this.children,n,n+i.length,t,a)}update(t,e,n,i){return this.dirty==Yt||!t.sameMarkup(this.node)?!1:(this.updateInner(t,e,n,i),!0)}updateInner(t,e,n,i){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ge}updateOuterDeco(t){if(a5(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=_c(this.dom,this.nodeDOM,f9(this.outerDeco,this.node,e),f9(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}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 Nc(r,t,e,n,i){$c(n,t,r);let l=new V1(void 0,r,t,e,n,n,n,i,0);return l.contentDOM&&l.updateChildren(i,0),l}class l5 extends V1{constructor(t,e,n,i,l,a,o){super(t,e,n,i,l,null,a,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,i){return this.dirty==Yt||this.dirty!=Ge&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(e),(this.dirty!=Ge||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=Ge,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,n){let i=this.node.cut(t,e),l=document.createTextNode(i.text);return new l5(this.parent,i,this.outerDeco,this.innerDeco,l,l,n)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length)&&(this.dirty=Yt)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Dc extends W7{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==Ge&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Vb extends V1{constructor(t,e,n,i,l,a,o,s,c,u){super(t,e,n,i,l,a,o,c,u),this.spec=s}update(t,e,n,i){if(this.dirty==Yt)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let l=this.spec.update(t,e,n);return l&&this.updateInner(t,e,n,i),l}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,e,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,i){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Lc(r,t,e){let n=r.firstChild,i=!1;for(let l=0;l<t.length;l++){let a=t[l],o=a.dom;if(o.parentNode==r){for(;o!=n;)n=e8(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(o,n);if(a instanceof Q0){let s=n?n.previousSibling:r.lastChild;Lc(a.contentDOM,a.children,e),n=s?s.nextSibling:r.firstChild}}for(;n;)n=e8(n),i=!0;i&&e.trackWrites==r&&(e.trackWrites=null)}const P7=function(r){r&&(this.nodeName=r)};P7.prototype=Object.create(null);const b0=[new P7];function f9(r,t,e){if(r.length==0)return b0;let n=e?b0[0]:new P7,i=[n];for(let l=0;l<r.length;l++){let a=r[l].type.attrs;if(a){a.nodeName&&i.push(n=new P7(a.nodeName));for(let o in a){let s=a[o];s!=null&&(e&&i.length==1&&i.push(n=new P7(t.isInline?"span":"div")),o=="class"?n.class=(n.class?n.class+" ":"")+s:o=="style"?n.style=(n.style?n.style+";":"")+s:o!="nodeName"&&(n[o]=s))}}}return i}function _c(r,t,e,n){if(e==b0&&n==b0)return t;let i=t;for(let l=0;l<n.length;l++){let a=n[l],o=e[l];if(l){let s;o&&o.nodeName==a.nodeName&&i!=r&&(s=i.parentNode)&&s.nodeName.toLowerCase()==a.nodeName||(s=document.createElement(a.nodeName),s.pmIsDeco=!0,s.appendChild(i),o=b0[0]),i=s}Ob(i,o||b0[0],a)}return i}function Ob(r,t,e){for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&!(n in e)&&r.removeAttribute(n);for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&e[n]!=t[n]&&r.setAttribute(n,e[n]);if(t.class!=e.class){let n=t.class?t.class.split(" ").filter(Boolean):[],i=e.class?e.class.split(" ").filter(Boolean):[];for(let l=0;l<n.length;l++)i.indexOf(n[l])==-1&&r.classList.remove(n[l]);for(let l=0;l<i.length;l++)n.indexOf(i[l])==-1&&r.classList.add(i[l]);r.classList.length==0&&r.removeAttribute("class")}if(t.style!=e.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(t.style);)r.style.removeProperty(i[1])}e.style&&(r.style.cssText+=e.style)}}function $c(r,t,e){return _c(r,r,b0,f9(t,e,r.nodeType!=1))}function a5(r,t){if(r.length!=t.length)return!1;for(let e=0;e<r.length;e++)if(!r[e].type.eq(t[e].type))return!1;return!0}function e8(r){let t=r.nextSibling;return r.parentNode.removeChild(r),t}class Kb{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=qb(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n,i){let l=0,a=this.stack.length>>1,o=Math.min(a,t.length);for(;l<o&&(l==a-1?this.top:this.stack[l+1<<1]).matchesMark(t[l])&&t[l].type.spec.spanning!==!1;)l++;for(;l<a;)this.destroyRest(),this.top.dirty=Ge,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<t.length;){this.stack.push(this.top,this.index+1);let s=-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 A=this.top.children[u];if(A.matchesMark(t[a])&&!this.isLocked(A.dom)){s=u;break}}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let u=Q0.create(this.top,t[a],e,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,a++}}findNodeMatch(t,e,n,i){let l=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(t,e,n))l=this.top.children.indexOf(a,this.index);else for(let o=this.index,s=Math.min(this.top.children.length,o+5);o<s;o++){let c=this.top.children[o];if(c.matchesNode(t,e,n)&&!this.preMatch.matched.has(c)){l=o;break}}return l<0?!1:(this.destroyBetween(this.index,l),this.index++,!0)}updateNodeAt(t,e,n,i,l){let a=this.top.children[i];return a.dirty==Yt&&a.dom==a.contentDOM&&(a.dirty=z0),a.update(t,e,n,l)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let n=t.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}t=e}}updateNextNode(t,e,n,i,l,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof V1){let c=this.preMatch.matched.get(s);if(c!=null&&c!=l)return!1;let u=s.dom,A,d=this.isLocked(u)&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&s.dirty!=Yt&&a5(e,s.outerDeco));if(!d&&s.update(t,e,n,i))return this.destroyBetween(this.index,o),s.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(A=this.recreateWrapper(s,t,e,n,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=A,A.contentDOM&&(A.dirty=z0,A.updateChildren(i,a+1),A.dirty=Ge),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,i,l,a){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!a5(n,t.outerDeco)||!i.eq(t.innerDeco))return null;let o=V1.create(this.top,e,n,i,l,a);if(o.contentDOM){o.children=t.children,t.children=[];for(let s of o.children)s.parent=o}return t.destroy(),o}addNode(t,e,n,i,l){let a=V1.create(this.top,t,e,n,i,l);a.contentDOM&&a.updateChildren(i,l+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(t,e,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let l=new wc(this.top,t,e,n);this.top.children.splice(this.index++,0,l),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Q0;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof l5)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((le||te)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);t=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),t=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new Dc(this.top,[],n,null);e!=this.top?e.children.push(i):e.children.splice(this.index++,0,i),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function qb(r,t){let e=t,n=e.children.length,i=r.childCount,l=new Map,a=[];e:for(;i>0;){let o;for(;;)if(n){let c=e.children[n-1];if(c instanceof Q0)e=c,n=c.children.length;else{o=c,n--;break}}else{if(e==t)break e;n=e.parent.children.indexOf(e),e=e.parent}let s=o.node;if(s){if(s!=r.child(i-1))break;--i,l.set(o,i),a.push(o)}}return{index:i,matched:l,matches:a.reverse()}}function jb(r,t){return r.type.side-t.type.side}function Tb(r,t,e,n){let i=t.locals(r),l=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,i,t.forChild(l,u),c),l+=u.nodeSize}return}let a=0,o=[],s=null;for(let c=0;;){let u,A;for(;a<i.length&&i[a].to==l;){let I=i[a++];I.widget&&(u?(A||(A=[u])).push(I):u=I)}if(u)if(A){A.sort(jb);for(let I=0;I<A.length;I++)e(A[I],c,!!s)}else e(u,c,!!s);let d,f;if(s)f=-1,d=s,s=null;else if(c<r.childCount)f=c,d=r.child(c++);else break;for(let I=0;I<o.length;I++)o[I].to<=l&&o.splice(I--,1);for(;a<i.length&&i[a].from<=l&&i[a].to>l;)o.push(i[a++]);let h=l+d.nodeSize;if(d.isText){let I=h;a<i.length&&i[a].from<I&&(I=i[a].from);for(let M=0;M<o.length;M++)o[M].to<I&&(I=o[M].to);I<h&&(s=d.cut(I-l),d=d.cut(0,I-l),h=I,f=-1)}else for(;a<i.length&&i[a].to<h;)a++;let m=d.isInline&&!d.isLeaf?o.filter(I=>!I.inline):o.slice();n(d,m,t.forChild(l,d),f),l=h}}function Wb(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let t=r.style.cssText;r.style.cssText=t+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=t}}function Pb(r,t,e,n){for(let i=0,l=0;i<r.childCount&&l<=n;){let a=r.child(i++),o=l;if(l+=a.nodeSize,!a.isText)continue;let s=a.text;for(;i<r.childCount;){let c=r.child(i++);if(l+=c.nodeSize,!c.isText)break;s+=c.text}if(l>=e){if(l>=n&&s.slice(n-t.length-o,n-o)==t)return n-t.length;let c=o<n?s.lastIndexOf(t,n-o-1):-1;if(c>=0&&c+t.length+o>=e)return o+c;if(e==n&&s.length>=n+t.length-o&&s.slice(n-o,n-o+t.length)==t)return n}}return-1}function d9(r,t,e,n,i){let l=[];for(let a=0,o=0;a<r.length;a++){let s=r[a],c=o,u=o+=s.size;c>=e||u<=t?l.push(s):(c<t&&l.push(s.slice(0,t-c,n)),i&&(l.push(i),i=void 0),u>e&&l.push(s.slice(e-c,s.size,n)))}return l}function h9(r,t=null){let e=r.domSelectionRange(),n=r.state.doc;if(!e.focusNode)return null;let i=r.docView.nearestDesc(e.focusNode),l=i&&i.size==0,a=r.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(a<0)return null;let o=n.resolve(a),s,c;if(i5(e)){for(s=a;i&&!i.node;)i=i.parent;let A=i.node;if(i&&A.isAtom&&i2.isSelectable(A)&&i.parent&&!(A.isInline&&pb(e.focusNode,e.focusOffset,i.dom))){let d=i.posBefore;c=new i2(a==d?o:n.resolve(d))}}else{if(e instanceof r.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let A=a,d=a;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);A=Math.min(A,r.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,r.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(A<0)return null;[s,a]=d==r.state.selection.anchor?[d,A]:[A,d],o=n.resolve(a)}else s=r.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(s<0)return null}let u=n.resolve(s);if(!c){let A=t=="pointer"||r.state.selection.head<o.pos&&!l?1:-1;c=m9(r,u,o,A)}return c}function t8(r){return r.editable?r.hasFocus():s8(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function e1(r,t=!1){let e=r.state.selection;if(l8(r,e),!!t8(r)){if(!t&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&te){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&v0(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Gb(r);else{let{anchor:n,head:i}=e,l,a;n8&&!(e instanceof m2)&&(e.$from.parent.inlineContent||(l=r8(r,e.from)),!e.empty&&!e.$from.parent.inlineContent&&(a=r8(r,e.to))),r.docView.setSelection(n,i,r,t),n8&&(l&&i8(l),a&&i8(a)),e.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Xb(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const n8=le||te&&Yc<63;function r8(r,t){let{node:e,offset:n}=r.docView.domFromPos(t,0),i=n<e.childNodes.length?e.childNodes[n]:null,l=n?e.childNodes[n-1]:null;if(le&&i&&i.contentEditable=="false")return p9(i);if((!i||i.contentEditable=="false")&&(!l||l.contentEditable=="false")){if(i)return p9(i);if(l)return p9(l)}}function p9(r){return r.contentEditable="true",le&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function i8(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Xb(r){let t=r.dom.ownerDocument;t.removeEventListener("selectionchange",r.input.hideSelectionGuard);let e=r.domSelectionRange(),n=e.anchorNode,i=e.anchorOffset;t.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(e.anchorNode!=n||e.anchorOffset!=i)&&(t.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!t8(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Gb(r){let t=r.domSelection();if(!t)return;let e=r.cursorWrapper.dom,n=e.nodeName=="IMG";n?t.collapse(e.parentNode,ee(e)+1):t.collapse(e,0),!n&&!r.state.selection.visible&&Ee&&U1<=11&&(e.disabled=!0,e.disabled=!1)}function l8(r,t){if(t instanceof i2){let e=r.docView.descAt(t.from);e!=r.lastSelectedViewDesc&&(a8(r),e&&e.selectNode(),r.lastSelectedViewDesc=e)}else a8(r)}function a8(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function m9(r,t,e,n){return r.someProp("createSelectionBetween",i=>i(r,t,e))||m2.between(t,e,n)}function o8(r){return r.editable&&!r.hasFocus()?!1:s8(r)}function s8(r){let t=r.domSelectionRange();if(!t.anchorNode)return!1;try{return r.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(r.editable||r.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Hb(r){let t=r.docView.domFromPos(r.state.selection.anchor,0),e=r.domSelectionRange();return v0(t.node,t.offset,e.anchorNode,e.anchorOffset)}function I9(r,t){let{$anchor:e,$head:n}=r.selection,i=t>0?e.max(n):e.min(n),l=i.parent.inlineContent?i.depth?r.doc.resolve(t>0?i.after():i.before()):null:i;return l&&E2.findFrom(l,t)}function O1(r,t){return r.dispatch(r.state.tr.setSelection(t).scrollIntoView()),!0}function c8(r,t,e){let n=r.state.selection;if(n instanceof m2)if(e.indexOf("s")>-1){let{$head:i}=n,l=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!l||l.isText||!l.isLeaf)return!1;let a=r.state.doc.resolve(i.pos+l.nodeSize*(t<0?-1:1));return O1(r,new m2(n.$anchor,a))}else if(n.empty){if(r.endOfTextblock(t>0?"forward":"backward")){let i=I9(r.state,t);return i&&i instanceof i2?O1(r,i):!1}else if(!(Xe&&e.indexOf("m")>-1)){let i=n.$head,l=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter,a;if(!l||l.isText)return!1;let o=t<0?i.pos-l.nodeSize:i.pos;return l.isAtom||(a=r.docView.descAt(o))&&!a.contentDOM?i2.isSelectable(l)?O1(r,new i2(t<0?r.state.doc.resolve(i.pos-l.nodeSize):i)):j7?O1(r,new m2(r.state.doc.resolve(t<0?o:o+l.nodeSize))):!1:!1}}else return!1;else{if(n instanceof i2&&n.node.isInline)return O1(r,new m2(t>0?n.$to:n.$from));{let i=I9(r.state,t);return i?O1(r,i):!1}}}function o5(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function X7(r,t){let e=r.pmViewDesc;return e&&e.size==0&&(t<0||r.nextSibling||r.nodeName!="BR")}function z3(r,t){return t<0?Jb(r):Fb(r)}function Jb(r){let t=r.domSelectionRange(),e=t.focusNode,n=t.focusOffset;if(!e)return;let i,l,a=!1;for(Pe&&e.nodeType==1&&n<o5(e)&&X7(e.childNodes[n],-1)&&(a=!0);;)if(n>0){if(e.nodeType!=1)break;{let o=e.childNodes[n-1];if(X7(o,-1))i=e,l=--n;else if(o.nodeType==3)e=o,n=e.nodeValue.length;else break}}else{if(u8(e))break;{let o=e.previousSibling;for(;o&&X7(o,-1);)i=e.parentNode,l=ee(o),o=o.previousSibling;if(o)e=o,n=o5(e);else{if(e=e.parentNode,e==r.dom)break;n=0}}}a?C9(r,e,n):i&&C9(r,i,l)}function Fb(r){let t=r.domSelectionRange(),e=t.focusNode,n=t.focusOffset;if(!e)return;let i=o5(e),l,a;for(;;)if(n<i){if(e.nodeType!=1)break;let o=e.childNodes[n];if(X7(o,1))l=e,a=++n;else break}else{if(u8(e))break;{let o=e.nextSibling;for(;o&&X7(o,1);)l=o.parentNode,a=ee(o)+1,o=o.nextSibling;if(o)e=o,n=0,i=o5(e);else{if(e=e.parentNode,e==r.dom)break;n=i=0}}}l&&C9(r,l,a)}function u8(r){let t=r.pmViewDesc;return t&&t.node&&t.node.isBlock}function wb(r,t){for(;r&&t==r.childNodes.length&&!q7(r);)t=ee(r)+1,r=r.parentNode;for(;r&&t<r.childNodes.length;){let e=r.childNodes[t];if(e.nodeType==3)return e;if(e.nodeType==1&&e.contentEditable=="false")break;r=e,t=0}}function Nb(r,t){for(;r&&!t&&!q7(r);)t=ee(r),r=r.parentNode;for(;r&&t;){let e=r.childNodes[t-1];if(e.nodeType==3)return e;if(e.nodeType==1&&e.contentEditable=="false")break;r=e,t=r.childNodes.length}}function C9(r,t,e){if(t.nodeType!=3){let l,a;(a=wb(t,e))?(t=a,e=0):(l=Nb(t,e))&&(t=l,e=l.nodeValue.length)}let n=r.domSelection();if(!n)return;if(i5(n)){let l=document.createRange();l.setEnd(t,e),l.setStart(t,e),n.removeAllRanges(),n.addRange(l)}else n.extend&&n.extend(t,e);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&e1(r)},50)}function A8(r,t){let e=r.state.doc.resolve(t);if(!(te||Vc)&&e.parent.inlineContent){let i=r.coordsAtPos(t);if(t>e.start()){let l=r.coordsAtPos(t-1),a=(l.top+l.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(l.left-i.left)>1)return l.left<i.left?"ltr":"rtl"}if(t<e.end()){let l=r.coordsAtPos(t+1),a=(l.top+l.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(l.left-i.left)>1)return l.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function f8(r,t,e){let n=r.state.selection;if(n instanceof m2&&!n.empty||e.indexOf("s")>-1||Xe&&e.indexOf("m")>-1)return!1;let{$from:i,$to:l}=n;if(!i.parent.inlineContent||r.endOfTextblock(t<0?"up":"down")){let a=I9(r.state,t);if(a&&a instanceof i2)return O1(r,a)}if(!i.parent.inlineContent){let a=t<0?i:l,o=n instanceof Be?E2.near(a,t):E2.findFrom(a,t);return o?O1(r,o):!1}return!1}function d8(r,t){if(!(r.state.selection instanceof m2))return!0;let{$head:e,$anchor:n,empty:i}=r.state.selection;if(!e.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(t>0?"forward":"backward"))return!0;let l=!e.textOffset&&(t<0?e.nodeBefore:e.nodeAfter);if(l&&!l.isText){let a=r.state.tr;return t<0?a.delete(e.pos-l.nodeSize,e.pos):a.delete(e.pos,e.pos+l.nodeSize),r.dispatch(a),!0}return!1}function h8(r,t,e){r.domObserver.stop(),t.contentEditable=e,r.domObserver.start()}function Db(r){if(!le||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:e}=r.domSelectionRange();if(t&&t.nodeType==1&&e==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let n=t.firstChild;h8(r,n,"true"),setTimeout(()=>h8(r,n,"false"),20)}return!1}function Lb(r){let t="";return r.ctrlKey&&(t+="c"),r.metaKey&&(t+="m"),r.altKey&&(t+="a"),r.shiftKey&&(t+="s"),t}function _b(r,t){let e=t.keyCode,n=Lb(t);if(e==8||Xe&&e==72&&n=="c")return d8(r,-1)||z3(r,-1);if(e==46&&!t.shiftKey||Xe&&e==68&&n=="c")return d8(r,1)||z3(r,1);if(e==13||e==27)return!0;if(e==37||Xe&&e==66&&n=="c"){let i=e==37?A8(r,r.state.selection.from)=="ltr"?-1:1:-1;return c8(r,i,n)||z3(r,i)}else if(e==39||Xe&&e==70&&n=="c"){let i=e==39?A8(r,r.state.selection.from)=="ltr"?1:-1:1;return c8(r,i,n)||z3(r,i)}else{if(e==38||Xe&&e==80&&n=="c")return f8(r,-1,n)||z3(r,-1);if(e==40||Xe&&e==78&&n=="c")return Db(r)||f8(r,1,n)||z3(r,1);if(n==(Xe?"m":"c")&&(e==66||e==73||e==89||e==90))return!0}return!1}function E9(r,t){r.someProp("transformCopied",f=>{t=f(t,r)});let e=[],{content:n,openStart:i,openEnd:l}=t;for(;i>1&&l>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,l--;let f=n.firstChild;e.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),n=f.content}let a=r.someProp("clipboardSerializer")||A3.fromSchema(r.state.schema),o=g8(),s=o.createElement("div");s.appendChild(a.serializeFragment(n,{document:o}));let c=s.firstChild,u,A=0;for(;c&&c.nodeType==1&&(u=M8[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=o.createElement(u[f]);for(;s.firstChild;)h.appendChild(s.firstChild);s.appendChild(h),A++}c=s.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${l}${A?` -${A}`:""} ${JSON.stringify(e)}`);let d=r.someProp("clipboardTextSerializer",f=>f(t,r))||t.content.textBetween(0,t.content.size,`
70
70
 
71
71
  `);return{dom:s,text:d,slice:t}}function p8(r,t,e,n,i){let l=i.parent.type.spec.code,a,o;if(!e&&!t)return null;let s=!!t&&(n||l||!e);if(s){if(r.someProp("transformPastedText",d=>{t=d(t,l||n,r)}),l)return o=new J(j.from(r.state.schema.text(t.replace(/\r\n?/g,`
72
- `))),0,0),r.someProp("transformPasted",d=>{o=d(o,r,!0)}),o;let A=r.someProp("clipboardTextParser",d=>d(t,i,n,r));if(A)o=A;else{let d=i.marks(),{schema:f}=r.state,h=A3.fromSchema(f);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let I=a.appendChild(document.createElement("p"));m&&I.appendChild(h.serializeNode(f.text(m,d)))})}}else r.someProp("transformPastedHTML",A=>{e=A(e,r)}),a=nS(e),j7&&rS(a);let c=a&&a.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let A=+u[3];A>0;A--){let d=a.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;a=d}if(o||(o=(r.someProp("clipboardParser")||r.someProp("domParser")||u3.fromSchema(r.state.schema)).parseSlice(a,{preserveWhitespace:!!(s||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$b.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)o=iS(E8(o,+u[1],+u[2]),u[4]);else if(o=J.maxOpen(eS(o.content,i),!0),o.openStart||o.openEnd){let A=0,d=0;for(let f=o.content.firstChild;A<o.openStart&&!f.type.spec.isolating;A++,f=f.firstChild);for(let f=o.content.lastChild;d<o.openEnd&&!f.type.spec.isolating;d++,f=f.lastChild);o=E8(o,A,d)}return r.someProp("transformPasted",A=>{o=A(o,r,s)}),o}const $b=/^(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 eS(r,t){if(r.childCount<2)return r;for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.index(e)),l,a=[];if(r.forEach(o=>{if(!a)return;let s=i.findWrapping(o.type),c;if(!s)return a=null;if(c=a.length&&l.length&&I8(s,l,o,a[a.length-1],0))a[a.length-1]=c;else{a.length&&(a[a.length-1]=C8(a[a.length-1],l.length));let u=m8(o,s);a.push(u),i=i.matchType(u.type),l=s}}),a)return j.from(a)}return r}function m8(r,t,e=0){for(let n=t.length-1;n>=e;n--)r=t[n].create(null,j.from(r));return r}function I8(r,t,e,n,i){if(i<r.length&&i<t.length&&r[i]==t[i]){let l=I8(r,t,e,n.lastChild,i+1);if(l)return n.copy(n.content.replaceChild(n.childCount-1,l));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?e.type:r[i+1]))return n.copy(n.content.append(j.from(m8(e,r,i+1))))}}function C8(r,t){if(t==0)return r;let e=r.content.replaceChild(r.childCount-1,C8(r.lastChild,t-1)),n=r.contentMatchAt(r.childCount).fillBefore(j.empty,!0);return r.copy(e.append(n))}function M9(r,t,e,n,i,l){let a=t<0?r.firstChild:r.lastChild,o=a.content;return r.childCount>1&&(l=0),i<n-1&&(o=M9(o,t,e,n,i+1,l)),i>=e&&(o=t<0?a.contentMatchAt(0).fillBefore(o,l<=i).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(j.empty,!0))),r.replaceChild(t<0?0:r.childCount-1,a.copy(o))}function E8(r,t,e){return t<r.openStart&&(r=new J(M9(r.content,-1,t,r.openStart,0,r.openEnd),t,r.openEnd)),e<r.openEnd&&(r=new J(M9(r.content,1,e,r.openEnd,0,0),r.openStart,e)),r}const M8={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let v8=null;function g8(){return v8||(v8=document.implementation.createHTMLDocument("title"))}let v9=null;function tS(r){let t=window.trustedTypes;return t?(v9||(v9=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),v9.createHTML(r)):r}function nS(r){let t=/^(\s*<meta [^>]*>)*/.exec(r);t&&(r=r.slice(t[0].length));let e=g8().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&M8[n[1].toLowerCase()])&&(r=i.map(l=>"<"+l+">").join("")+r+i.map(l=>"</"+l+">").reverse().join("")),e.innerHTML=tS(r),i)for(let l=0;l<i.length;l++)e=e.querySelector(i[l])||e;return e}function rS(r){let t=r.querySelectorAll(te?"span:not([class]):not([style])":"span.Apple-converted-space");for(let e=0;e<t.length;e++){let n=t[e];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function iS(r,t){if(!r.size)return r;let e=r.content.firstChild.type.schema,n;try{n=JSON.parse(t)}catch{return r}let{content:i,openStart:l,openEnd:a}=r;for(let o=n.length-2;o>=0;o-=2){let s=e.nodes[n[o]];if(!s||s.hasRequiredAttrs())break;i=j.from(s.create(n[o+1],i)),l++,a++}return new J(i,l,a)}const ue={},Ae={},lS={touchstart:!0,touchmove:!0};class aS{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 oS(r){for(let t in ue){let e=ue[t];r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>{cS(r,n)&&!z9(r,n)&&(r.editable||!(n.type in Ae))&&e(r,n)},lS[t]?{passive:!0}:void 0)}le&&r.dom.addEventListener("input",()=>null),g9(r)}function K1(r,t){r.input.lastSelectionOrigin=t,r.input.lastSelectionTime=Date.now()}function sS(r){r.domObserver.stop();for(let t in r.input.eventHandlers)r.dom.removeEventListener(t,r.input.eventHandlers[t]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function g9(r){r.someProp("handleDOMEvents",t=>{for(let e in t)r.input.eventHandlers[e]||r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>z9(r,n))})}function z9(r,t){return r.someProp("handleDOMEvents",e=>{let n=e[t.type];return n?n(r,t)||t.defaultPrevented:!1})}function cS(r,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target;e!=r.dom;e=e.parentNode)if(!e||e.nodeType==11||e.pmViewDesc&&e.pmViewDesc.stopEvent(t))return!1;return!0}function uS(r,t){!z9(r,t)&&ue[t.type]&&(r.editable||!(t.type in Ae))&&ue[t.type](r,t)}Ae.keydown=(r,t)=>{let e=t;if(r.input.shiftKey=e.keyCode==16||e.shiftKey,!Q8(r,e)&&(r.input.lastKeyCode=e.keyCode,r.input.lastKeyCodeTime=Date.now(),!(_t&&te&&e.keyCode==13)))if(e.keyCode!=229&&r.domObserver.forceFlush(),v3&&e.keyCode==13&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,g0(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,e))||_b(r,e)?e.preventDefault():K1(r,"key")},Ae.keyup=(r,t)=>{t.keyCode==16&&(r.input.shiftKey=!1)},Ae.keypress=(r,t)=>{let e=t;if(Q8(r,e)||!e.charCode||e.ctrlKey&&!e.altKey||Xe&&e.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,e))){e.preventDefault();return}let n=r.state.selection;if(!(n instanceof m2)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(e.charCode),l=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",a=>a(r,n.$from.pos,n.$to.pos,i,l))&&r.dispatch(l()),e.preventDefault()}};function s5(r){return{left:r.clientX,top:r.clientY}}function AS(r,t){let e=t.x-r.clientX,n=t.y-r.clientY;return e*e+n*n<100}function Q9(r,t,e,n,i){if(n==-1)return!1;let l=r.state.doc.resolve(n);for(let a=l.depth+1;a>0;a--)if(r.someProp(t,o=>a>l.depth?o(r,e,l.nodeAfter,l.before(a),i,!0):o(r,e,l.node(a),l.before(a),i,!1)))return!0;return!1}function Q3(r,t,e){if(r.focused||r.focus(),r.state.selection.eq(t))return;let n=r.state.tr.setSelection(t);n.setMeta("pointer",!0),r.dispatch(n)}function fS(r,t){if(t==-1)return!1;let e=r.state.doc.resolve(t),n=e.nodeAfter;return n&&n.isAtom&&i2.isSelectable(n)?(Q3(r,new i2(e)),!0):!1}function dS(r,t){if(t==-1)return!1;let e=r.state.selection,n,i;e instanceof i2&&(n=e.node);let l=r.state.doc.resolve(t);for(let a=l.depth+1;a>0;a--){let o=a>l.depth?l.nodeAfter:l.node(a);if(i2.isSelectable(o)){n&&e.$from.depth>0&&a>=e.$from.depth&&l.before(e.$from.depth+1)==e.$from.pos?i=l.before(e.$from.depth):i=l.before(a);break}}return i!=null?(Q3(r,i2.create(r.state.doc,i)),!0):!1}function hS(r,t,e,n,i){return Q9(r,"handleClickOn",t,e,n)||r.someProp("handleClick",l=>l(r,t,n))||(i?dS(r,e):fS(r,e))}function pS(r,t,e,n){return Q9(r,"handleDoubleClickOn",t,e,n)||r.someProp("handleDoubleClick",i=>i(r,t,n))}function mS(r,t,e,n){return Q9(r,"handleTripleClickOn",t,e,n)||r.someProp("handleTripleClick",i=>i(r,t,n))||IS(r,e,n)}function IS(r,t,e){if(e.button!=0)return!1;let n=r.state.doc;if(t==-1)return n.inlineContent?(Q3(r,m2.create(n,0,n.content.size)),!0):!1;let i=n.resolve(t);for(let l=i.depth+1;l>0;l--){let a=l>i.depth?i.nodeAfter:i.node(l),o=i.before(l);if(a.inlineContent)Q3(r,m2.create(n,o+1,o+1+a.content.size));else if(i2.isSelectable(a))Q3(r,i2.create(n,o));else continue;return!0}}function b9(r){return c5(r)}const z8=Xe?"metaKey":"ctrlKey";ue.mousedown=(r,t)=>{let e=t;r.input.shiftKey=e.shiftKey;let n=b9(r),i=Date.now(),l="singleClick";i-r.input.lastClick.time<500&&AS(e,r.input.lastClick)&&!e[z8]&&r.input.lastClick.button==e.button&&(r.input.lastClick.type=="singleClick"?l="doubleClick":r.input.lastClick.type=="doubleClick"&&(l="tripleClick")),r.input.lastClick={time:i,x:e.clientX,y:e.clientY,type:l,button:e.button};let a=r.posAtCoords(s5(e));a&&(l=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new CS(r,a,e,!!n)):(l=="doubleClick"?pS:mS)(r,a.pos,a.inside,e)?e.preventDefault():K1(r,"pointer"))};class CS{constructor(t,e,n,i){this.view=t,this.pos=e,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[z8],this.allowDefault=n.shiftKey;let l,a;if(e.inside>-1)l=t.state.doc.nodeAt(e.inside),a=e.inside;else{let u=t.state.doc.resolve(e.pos);l=u.parent,a=u.depth?u.before():0}const o=i?null:n.target,s=o?t.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=t.state;(n.button==0&&l.type.spec.draggable&&l.type.spec.selectable!==!1||c instanceof i2&&c.from<=a&&c.to>a)&&(this.mightDrag={node:l,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Pe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),K1(t,"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(()=>e1(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(s5(t))),this.updateAllowDefault(t),this.allowDefault||!e?K1(this.view,"pointer"):hS(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||le&&this.mightDrag&&!this.mightDrag.node.isAtom||te&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Q3(this.view,E2.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):K1(this.view,"pointer")}move(t){this.updateAllowDefault(t),K1(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}ue.touchstart=r=>{r.input.lastTouch=Date.now(),b9(r),K1(r,"pointer")},ue.touchmove=r=>{r.input.lastTouch=Date.now(),K1(r,"pointer")},ue.contextmenu=r=>b9(r);function Q8(r,t){return r.composing?!0:le&&Math.abs(t.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const ES=_t?5e3:-1;Ae.compositionstart=Ae.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:t}=r,e=t.selection.$to;if(t.selection instanceof m2&&(t.storedMarks||!e.textOffset&&e.parentOffset&&e.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||te&&Vc&&MS(r)))r.markCursor=r.state.storedMarks||e.marks(),c5(r,!0),r.markCursor=null;else if(c5(r,!t.selection.empty),Pe&&t.selection.empty&&e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,l=n.focusOffset;i&&i.nodeType==1&&l!=0;){let a=l<0?i.lastChild:i.childNodes[l-1];if(!a)break;if(a.nodeType==3){let o=r.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else i=a,l=-1}}r.input.composing=!0}b8(r,ES)};function MS(r){let{focusNode:t,focusOffset:e}=r.domSelectionRange();if(!t||t.nodeType!=1||e>=t.childNodes.length)return!1;let n=t.childNodes[e];return n.nodeType==1&&n.contentEditable=="false"}Ae.compositionend=(r,t)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=t.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,b8(r,20))};function b8(r,t){clearTimeout(r.input.composingTimeout),t>-1&&(r.input.composingTimeout=setTimeout(()=>c5(r),t))}function S8(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=gS());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function vS(r){let t=r.domSelectionRange();if(!t.focusNode)return null;let e=db(t.focusNode,t.focusOffset),n=hb(t.focusNode,t.focusOffset);if(e&&n&&e!=n){let i=n.pmViewDesc,l=r.domObserver.lastChangedTextNode;if(e==l||n==l)return l;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let a=e.pmViewDesc;if(!(!a||!a.isText(e.nodeValue)))return n}}return e||n}function gS(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function c5(r,t=!1){if(!(_t&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),S8(r),t||r.docView&&r.docView.dirty){let e=h9(r),n=r.state.selection;return e&&!e.eq(n)?r.dispatch(r.state.tr.setSelection(e)):(r.markCursor||t)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function zS(r,t){if(!r.dom.parentNode)return;let e=r.dom.parentNode.appendChild(document.createElement("div"));e.appendChild(t),e.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(t),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e),r.focus()},50)}const G7=Ee&&U1<15||v3&&Cb<604;ue.copy=Ae.cut=(r,t)=>{let e=t,n=r.state.selection,i=e.type=="cut";if(n.empty)return;let l=G7?null:e.clipboardData,a=n.content(),{dom:o,text:s}=E9(r,a);l?(e.preventDefault(),l.clearData(),l.setData("text/html",o.innerHTML),l.setData("text/plain",s)):zS(r,o),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function QS(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function bS(r,t){if(!r.dom.parentNode)return;let e=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(e?"textarea":"div"));e||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),e?H7(r,n.value,null,i,t):H7(r,n.textContent,n.innerHTML,i,t)},50)}function H7(r,t,e,n,i){let l=p8(r,t,e,n,r.state.selection.$from);if(r.someProp("handlePaste",s=>s(r,i,l||J.empty)))return!0;if(!l)return!1;let a=QS(l),o=a?r.state.tr.replaceSelectionWith(a,n):r.state.tr.replaceSelection(l);return r.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function k8(r){let t=r.getData("text/plain")||r.getData("Text");if(t)return t;let e=r.getData("text/uri-list");return e?e.replace(/\r?\n/g," "):""}Ae.paste=(r,t)=>{let e=t;if(r.composing&&!_t)return;let n=G7?null:e.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&H7(r,k8(n),n.getData("text/html"),i,e)?e.preventDefault():bS(r,e)};class y8{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const SS=Xe?"altKey":"ctrlKey";function R8(r,t){let e=r.someProp("dragCopies",n=>!n(t));return e??!t[SS]}ue.dragstart=(r,t)=>{let e=t,n=r.input.mouseDown;if(n&&n.done(),!e.dataTransfer)return;let i=r.state.selection,l=i.empty?null:r.posAtCoords(s5(e)),a;if(!(l&&l.pos>=i.from&&l.pos<=(i instanceof i2?i.to-1:i.to))){if(n&&n.mightDrag)a=i2.create(r.state.doc,n.mightDrag.pos);else if(e.target&&e.target.nodeType==1){let A=r.docView.nearestDesc(e.target,!0);A&&A.node.type.spec.draggable&&A!=r.docView&&(a=i2.create(r.state.doc,A.posBefore))}}let o=(a||r.state.selection).content(),{dom:s,text:c,slice:u}=E9(r,o);(!e.dataTransfer.files.length||!te||Yc>120)&&e.dataTransfer.clearData(),e.dataTransfer.setData(G7?"Text":"text/html",s.innerHTML),e.dataTransfer.effectAllowed="copyMove",G7||e.dataTransfer.setData("text/plain",c),r.dragging=new y8(u,R8(r,e),a)},ue.dragend=r=>{let t=r.dragging;window.setTimeout(()=>{r.dragging==t&&(r.dragging=null)},50)},Ae.dragover=Ae.dragenter=(r,t)=>t.preventDefault(),Ae.drop=(r,t)=>{try{kS(r,t,r.dragging)}finally{r.dragging=null}};function kS(r,t,e){if(!t.dataTransfer)return;let n=r.posAtCoords(s5(t));if(!n)return;let i=r.state.doc.resolve(n.pos),l=e&&e.slice;l?r.someProp("transformPasted",f=>{l=f(l,r,!1)}):l=p8(r,k8(t.dataTransfer),G7?null:t.dataTransfer.getData("text/html"),!1,i);let a=!!(e&&R8(r,t));if(r.someProp("handleDrop",f=>f(r,t,l||J.empty,a))){t.preventDefault();return}if(!l)return;t.preventDefault();let o=l?DM(r.state.doc,i.pos,l):i.pos;o==null&&(o=i.pos);let s=r.state.tr;if(a){let{node:f}=e;f?f.replace(s):s.deleteSelection()}let c=s.mapping.map(o),u=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,A=s.doc;if(u?s.replaceRangeWith(c,c,l.content.firstChild):s.replaceRange(c,c,l),s.doc.eq(A))return;let d=s.doc.resolve(c);if(u&&i2.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild))s.setSelection(new i2(d));else{let f=s.mapping.map(o);s.mapping.maps[s.mapping.maps.length-1].forEach((h,m,I,M)=>f=M),s.setSelection(m9(r,d,s.doc.resolve(f)))}r.focus(),r.dispatch(s.setMeta("uiEvent","drop"))}ue.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&e1(r)},20))},ue.blur=(r,t)=>{let e=t;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),e.relatedTarget&&r.dom.contains(e.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)},ue.beforeinput=(r,t)=>{if(te&&_t&&t.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",l=>l(r,g0(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in Ae)ue[r]=Ae[r];function J7(r,t){if(r==t)return!0;for(let e in r)if(r[e]!==t[e])return!1;for(let e in t)if(!(e in r))return!1;return!0}class u5{constructor(t,e){this.toDOM=t,this.spec=e||S0,this.side=this.spec.side||0}map(t,e,n,i){let{pos:l,deleted:a}=t.mapResult(e.from+i,this.side<0?-1:1);return a?null:new Ue(l-n,l-n,this)}valid(){return!0}eq(t){return this==t||t instanceof u5&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&J7(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class q1{constructor(t,e){this.attrs=t,this.spec=e||S0}map(t,e,n,i){let l=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-n,a=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-n;return l>=a?null:new Ue(l,a,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof q1&&J7(this.attrs,t.attrs)&&J7(this.spec,t.spec)}static is(t){return t.type instanceof q1}destroy(){}}class S9{constructor(t,e){this.attrs=t,this.spec=e||S0}map(t,e,n,i){let l=t.mapResult(e.from+i,1);if(l.deleted)return null;let a=t.mapResult(e.to+i,-1);return a.deleted||a.pos<=l.pos?null:new Ue(l.pos-n,a.pos-n,this)}valid(t,e){let{index:n,offset:i}=t.content.findIndex(e.from),l;return i==e.from&&!(l=t.child(n)).isText&&i+l.nodeSize==e.to}eq(t){return this==t||t instanceof S9&&J7(this.attrs,t.attrs)&&J7(this.spec,t.spec)}destroy(){}}class Ue{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new Ue(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Ue(t,t,new u5(e,n))}static inline(t,e,n,i){return new Ue(t,e,new q1(n,i))}static node(t,e,n,i){return new Ue(t,e,new S9(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof q1}get widget(){return this.type instanceof u5}}const b3=[],S0={};class X2{constructor(t,e){this.local=t.length?t:b3,this.children=e.length?e:b3}static create(t,e){return e.length?A5(e,t,0,S0):ae}find(t,e,n){let i=[];return this.findInner(t??0,e??1e9,i,0,n),i}findInner(t,e,n,i,l){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=e&&o.to>=t&&(!l||l(o.spec))&&n.push(o.copy(o.from+i,o.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){let o=this.children[a]+1;this.children[a+2].findInner(t-o,e-o,n,i+o,l)}}map(t,e,n){return this==ae||t.maps.length==0?this:this.mapInner(t,e,0,0,n||S0)}mapInner(t,e,n,i,l){let a;for(let o=0;o<this.local.length;o++){let s=this.local[o].map(t,n,i);s&&s.type.valid(e,s)?(a||(a=[])).push(s):l.onRemove&&l.onRemove(this.local[o].spec)}return this.children.length?yS(this.children,a||[],t,e,n,i,l):a?new X2(a.sort(k0),b3):ae}add(t,e){return e.length?this==ae?X2.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let i,l=0;t.forEach((o,s)=>{let c=s+n,u;if(u=x8(e,o,c)){for(i||(i=this.children.slice());l<i.length&&i[l]<s;)l+=3;i[l]==s?i[l+2]=i[l+2].addInner(o,u,c+1):i.splice(l,0,s,s+o.nodeSize,A5(u,o,c+1,S0)),l+=3}});let a=Z8(l?B8(e):e,-n);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||a.splice(o--,1);return new X2(a.length?this.local.concat(a).sort(k0):this.local,i||this.children)}remove(t){return t.length==0||this==ae?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,i=this.local;for(let l=0;l<n.length;l+=3){let a,o=n[l]+e,s=n[l+1]+e;for(let u=0,A;u<t.length;u++)(A=t[u])&&A.from>o&&A.to<s&&(t[u]=null,(a||(a=[])).push(A));if(!a)continue;n==this.children&&(n=this.children.slice());let c=n[l+2].removeInner(a,o+1);c!=ae?n[l+2]=c:(n.splice(l,3),l-=3)}if(i.length){for(let l=0,a;l<t.length;l++)if(a=t[l])for(let o=0;o<i.length;o++)i[o].eq(a,e)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new X2(i,n):ae}forChild(t,e){if(this==ae)return this;if(e.isLeaf)return X2.empty;let n,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}let l=t+1,a=l+e.content.size;for(let o=0;o<this.local.length;o++){let s=this.local[o];if(s.from<a&&s.to>l&&s.type instanceof q1){let c=Math.max(l,s.from)-l,u=Math.min(a,s.to)-l;c<u&&(i||(i=[])).push(s.copy(c,u))}}if(i){let o=new X2(i.sort(k0),b3);return n?new j1([o,n]):o}return n||ae}eq(t){if(this==t)return!0;if(!(t instanceof X2)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return k9(this.localsInner(t))}localsInner(t){if(this==ae)return b3;if(t.inlineContent||!this.local.some(q1.is))return this.local;let e=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof q1||e.push(this.local[n]);return e}forEachSet(t){t(this)}}X2.empty=new X2([],[]),X2.removeOverlap=k9;const ae=X2.empty;class j1{constructor(t){this.members=t}map(t,e){const n=this.members.map(i=>i.map(t,e,S0));return j1.from(n)}forChild(t,e){if(e.isLeaf)return X2.empty;let n=[];for(let i=0;i<this.members.length;i++){let l=this.members[i].forChild(t,e);l!=ae&&(l instanceof j1?n=n.concat(l.members):n.push(l))}return j1.from(n)}eq(t){if(!(t instanceof j1)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let i=0;i<this.members.length;i++){let l=this.members[i].localsInner(t);if(l.length)if(!e)e=l;else{n&&(e=e.slice(),n=!1);for(let a=0;a<l.length;a++)e.push(l[a])}}return e?k9(n?e:e.sort(k0)):b3}static from(t){switch(t.length){case 0:return ae;case 1:return t[0];default:return new j1(t.every(e=>e instanceof X2)?t:t.reduce((e,n)=>e.concat(n instanceof X2?n:n.members),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function yS(r,t,e,n,i,l,a){let o=r.slice();for(let c=0,u=l;c<e.maps.length;c++){let A=0;e.maps[c].forEach((d,f,h,m)=>{let I=m-h-(f-d);for(let M=0;M<o.length;M+=3){let k=o[M+1];if(k<0||d>k+u-A)continue;let S=o[M]+u-A;f>=S?o[M+1]=d<=S?-2:-1:d>=u&&I&&(o[M]+=I,o[M+1]+=I)}A+=I}),u=e.maps[c].map(u,-1)}let s=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){s=!0,o[c+1]=-1;continue}let u=e.map(r[c]+l),A=u-i;if(A<0||A>=n.content.size){s=!0;continue}let d=e.map(r[c+1]+l,-1),f=d-i,{index:h,offset:m}=n.content.findIndex(A),I=n.maybeChild(h);if(I&&m==A&&m+I.nodeSize==f){let M=o[c+2].mapInner(e,I,u+1,r[c]+l+1,a);M!=ae?(o[c]=A,o[c+1]=f,o[c+2]=M):(o[c+1]=-2,s=!0)}else s=!0}if(s){let c=RS(o,r,t,e,i,l,a),u=A5(c,n,0,a);t=u.local;for(let A=0;A<o.length;A+=3)o[A+1]<0&&(o.splice(A,3),A-=3);for(let A=0,d=0;A<u.children.length;A+=3){let f=u.children[A];for(;d<o.length&&o[d]<f;)d+=3;o.splice(d,0,u.children[A],u.children[A+1],u.children[A+2])}}return new X2(t.sort(k0),o)}function Z8(r,t){if(!t||!r.length)return r;let e=[];for(let n=0;n<r.length;n++){let i=r[n];e.push(new Ue(i.from+t,i.to+t,i.type))}return e}function RS(r,t,e,n,i,l,a){function o(s,c){for(let u=0;u<s.local.length;u++){let A=s.local[u].map(n,i,c);A?e.push(A):a.onRemove&&a.onRemove(s.local[u].spec)}for(let u=0;u<s.children.length;u+=3)o(s.children[u+2],s.children[u]+c+1)}for(let s=0;s<r.length;s+=3)r[s+1]==-1&&o(r[s+2],t[s]+l+1);return e}function x8(r,t,e){if(t.isLeaf)return null;let n=e+t.nodeSize,i=null;for(let l=0,a;l<r.length;l++)(a=r[l])&&a.from>e&&a.to<n&&((i||(i=[])).push(a),r[l]=null);return i}function B8(r){let t=[];for(let e=0;e<r.length;e++)r[e]!=null&&t.push(r[e]);return t}function A5(r,t,e,n){let i=[],l=!1;t.forEach((o,s)=>{let c=x8(r,o,s+e);if(c){l=!0;let u=A5(c,o,e+s+1,n);u!=ae&&i.push(s,s+o.nodeSize,u)}});let a=Z8(l?B8(r):r,-e).sort(k0);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||(n.onRemove&&n.onRemove(a[o].spec),a.splice(o--,1));return a.length||i.length?new X2(a,i):ae}function k0(r,t){return r.from-t.from||r.to-t.to}function k9(r){let t=r;for(let e=0;e<t.length-1;e++){let n=t[e];if(n.from!=n.to)for(let i=e+1;i<t.length;i++){let l=t[i];if(l.from==n.from){l.to!=n.to&&(t==r&&(t=r.slice()),t[i]=l.copy(l.from,n.to),U8(t,i+1,l.copy(n.to,l.to)));continue}else{l.from<n.to&&(t==r&&(t=r.slice()),t[e]=n.copy(n.from,l.from),U8(t,i,n.copy(l.from,n.to)));break}}}return t}function U8(r,t,e){for(;t<r.length&&k0(e,r[t])>0;)t++;r.splice(t,0,e)}function y9(r){let t=[];return r.someProp("decorations",e=>{let n=e(r.state);n&&n!=ae&&t.push(n)}),r.cursorWrapper&&t.push(X2.create(r.state.doc,[r.cursorWrapper.deco])),j1.from(t)}const ZS={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xS=Ee&&U1<=11;class BS{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class US{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new BS,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);Ee&&U1<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():le&&t.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),xS&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,ZS)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(o8(this.view)){if(this.suppressingSelectionUpdates)return e1(this.view);if(Ee&&U1<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&v0(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e=new Set,n;for(let l=t.focusNode;l;l=M3(l))e.add(l);for(let l=t.anchorNode;l;l=M3(l))if(e.has(l)){n=l;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&o8(t)&&!this.ignoreSelectionChange(n),l=-1,a=-1,o=!1,s=[];if(t.editable)for(let u=0;u<e.length;u++){let A=this.registerMutation(e[u],s);A&&(l=l<0?A.from:Math.min(A.from,l),a=a<0?A.to:Math.max(A.to,a),A.typeOver&&(o=!0))}if(s.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46)){for(let u of s)if(u.nodeName=="BR"&&u.parentNode){let A=u.nextSibling;A&&A.nodeType==1&&A.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Pe&&s.length){let u=s.filter(A=>A.nodeName=="BR");if(u.length==2){let[A,d]=u;A.parentNode&&A.parentNode.parentNode==d.parentNode?d.remove():A.remove()}else{let{focusNode:A}=this.currentSelection;for(let d of u){let f=d.parentNode;f&&f.nodeName=="LI"&&(!A||OS(t,A)!=f)&&d.remove()}}}let c=null;l<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&i5(n)&&(c=h9(t))&&c.eq(E2.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,e1(t),this.currentSelection.set(n),t.scrollToSelection()):(l>-1||i)&&(l>-1&&(t.docView.markDirty(l,a),YS(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,KS(t,s)),this.handleDOMChange(l,a,o,s),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||e1(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;u<t.addedNodes.length;u++){let A=t.addedNodes[u];e.push(A),A.nodeType==3&&(this.lastChangedTextNode=A)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let i=t.previousSibling,l=t.nextSibling;if(Ee&&U1<=11&&t.addedNodes.length)for(let u=0;u<t.addedNodes.length;u++){let{previousSibling:A,nextSibling:d}=t.addedNodes[u];(!A||Array.prototype.indexOf.call(t.addedNodes,A)<0)&&(i=A),(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(l=d)}let a=i&&i.parentNode==t.target?ee(i)+1:0,o=n.localPosFromDOM(t.target,a,-1),s=l&&l.parentNode==t.target?ee(l):t.target.childNodes.length,c=n.localPosFromDOM(t.target,s,1);return{from:o,to:c}}else return t.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Y8=new WeakMap,V8=!1;function YS(r){if(!Y8.has(r)&&(Y8.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=Pe,V8)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."),V8=!0}}function O8(r,t){let e=t.startContainer,n=t.startOffset,i=t.endContainer,l=t.endOffset,a=r.domAtPos(r.state.selection.anchor);return v0(a.node,a.offset,i,l)&&([e,n,i,l]=[i,l,e,n]),{anchorNode:e,anchorOffset:n,focusNode:i,focusOffset:l}}function VS(r,t){if(t.getComposedRanges){let i=t.getComposedRanges(r.root)[0];if(i)return O8(r,i)}let e;function n(i){i.preventDefault(),i.stopImmediatePropagation(),e=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),e?O8(r,e):null}function OS(r,t){for(let e=t.parentNode;e&&e!=r.dom;e=e.parentNode){let n=r.docView.nearestDesc(e,!0);if(n&&n.node.isBlock)return e}return null}function KS(r,t){var e;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let l of t)if(((e=l.parentNode)===null||e===void 0?void 0:e.nodeName)=="TR"){let a=l.nextSibling;for(;a&&a.nodeName!="TD"&&a.nodeName!="TH";)a=a.nextSibling;if(a){let o=a;for(;;){let s=o.firstChild;if(!s||s.nodeType!=1||s.contentEditable=="false"||/^(BR|IMG)$/.test(s.nodeName))break;o=s}o.insertBefore(l,o.firstChild),n==l&&r.domSelection().collapse(l,i)}else l.parentNode.removeChild(l)}}function qS(r,t,e){let{node:n,fromOffset:i,toOffset:l,from:a,to:o}=r.docView.parseRange(t,e),s=r.domSelectionRange(),c,u=s.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:s.anchorOffset}],i5(s)||c.push({node:s.focusNode,offset:s.focusOffset})),te&&r.input.lastKeyCode===8)for(let I=l;I>i;I--){let M=n.childNodes[I-1],k=M.pmViewDesc;if(M.nodeName=="BR"&&!k){l=I;break}if(!k||k.size)break}let A=r.state.doc,d=r.someProp("domParser")||u3.fromSchema(r.state.schema),f=A.resolve(a),h=null,m=d.parse(n,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:l,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:jS,context:f});if(c&&c[0].pos!=null){let I=c[0].pos,M=c[1]&&c[1].pos;M==null&&(M=I),h={anchor:I+a,head:M+a}}return{doc:m,sel:h,from:a,to:o}}function jS(r){let t=r.pmViewDesc;if(t)return t.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(le&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(r.parentNode.lastChild==r||le&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const TS=/^(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 WS(r,t,e,n,i){let l=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,t<0){let y=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,R=h9(r,y);if(R&&!r.state.selection.eq(R)){if(te&&_t&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",T=>T(r,g0(13,"Enter"))))return;let Z=r.state.tr.setSelection(R);y=="pointer"?Z.setMeta("pointer",!0):y=="key"&&Z.scrollIntoView(),l&&Z.setMeta("composition",l),r.dispatch(Z)}return}let a=r.state.doc.resolve(t),o=a.sharedDepth(e);t=a.before(o+1),e=r.state.doc.resolve(e).after(o+1);let s=r.state.selection,c=qS(r,t,e),u=r.state.doc,A=u.slice(c.from,c.to),d,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(d=r.state.selection.to,f="end"):(d=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let h=GS(A.content,c.doc.content,c.from,d,f);if(h&&r.input.domChangeCount++,(v3&&r.input.lastIOSEnter>Date.now()-225||_t)&&i.some(y=>y.nodeType==1&&!TS.test(y.nodeName))&&(!h||h.endA>=h.endB)&&r.someProp("handleKeyDown",y=>y(r,g0(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!h)if(n&&s instanceof m2&&!s.empty&&s.$head.sameParent(s.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:s.from,endA:s.to,endB:s.to};else{if(c.sel){let y=K8(r,r.state.doc,c.sel);if(y&&!y.eq(r.state.selection)){let R=r.state.tr.setSelection(y);l&&R.setMeta("composition",l),r.dispatch(R)}}return}r.state.selection.from<r.state.selection.to&&h.start==h.endB&&r.state.selection instanceof m2&&(h.start>r.state.selection.from&&h.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?h.start=r.state.selection.from:h.endA<r.state.selection.to&&h.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(h.endB+=r.state.selection.to-h.endA,h.endA=r.state.selection.to)),Ee&&U1<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),I=c.doc.resolveNoCache(h.endB-c.from),M=u.resolve(h.start),k=m.sameParent(I)&&m.parent.inlineContent&&M.end()>=h.endA;if((v3&&r.input.lastIOSEnter>Date.now()-225&&(!k||i.some(y=>y.nodeName=="DIV"||y.nodeName=="P"))||!k&&m.pos<c.doc.content.size&&(!m.sameParent(I)||!m.parent.inlineContent)&&m.pos<I.pos&&!/\S/.test(c.doc.textBetween(m.pos,I.pos,"","")))&&r.someProp("handleKeyDown",y=>y(r,g0(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>h.start&&XS(u,h.start,h.endA,m,I)&&r.someProp("handleKeyDown",y=>y(r,g0(8,"Backspace")))){_t&&te&&r.domObserver.suppressSelectionUpdates();return}te&&h.endB==h.start&&(r.input.lastChromeDelete=Date.now()),_t&&!k&&m.start()!=I.start()&&I.parentOffset==0&&m.depth==I.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,I=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(y){return y(r,g0(13,"Enter"))})},20));let S=h.start,B=h.endA,K=y=>{let R=y||r.state.tr.replace(S,B,c.doc.slice(h.start-c.from,h.endB-c.from));if(c.sel){let Z=K8(r,R.doc,c.sel);Z&&!(te&&r.composing&&Z.empty&&(h.start!=h.endB||r.input.lastChromeDelete<Date.now()-100)&&(Z.head==S||Z.head==R.mapping.map(B)-1)||Ee&&Z.empty&&Z.head==S)&&R.setSelection(Z)}return l&&R.setMeta("composition",l),R.scrollIntoView()},b;if(k)if(m.pos==I.pos){Ee&&U1<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>e1(r),20));let y=K(r.state.tr.delete(S,B)),R=u.resolve(h.start).marksAcross(u.resolve(h.endA));R&&y.ensureMarks(R),r.dispatch(y)}else if(h.endA==h.endB&&(b=PS(m.parent.content.cut(m.parentOffset,I.parentOffset),M.parent.content.cut(M.parentOffset,h.endA-M.start())))){let y=K(r.state.tr);b.type=="add"?y.addMark(S,B,b.mark):y.removeMark(S,B,b.mark),r.dispatch(y)}else if(m.parent.child(m.index()).isText&&m.index()==I.index()-(I.textOffset?0:1)){let y=m.parent.textBetween(m.parentOffset,I.parentOffset),R=()=>K(r.state.tr.insertText(y,S,B));r.someProp("handleTextInput",Z=>Z(r,S,B,y,R))||r.dispatch(R())}else r.dispatch(K());else r.dispatch(K())}function K8(r,t,e){return Math.max(e.anchor,e.head)>t.content.size?null:m9(r,t.resolve(e.anchor),t.resolve(e.head))}function PS(r,t){let e=r.firstChild.marks,n=t.firstChild.marks,i=e,l=n,a,o,s;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<e.length;u++)l=e[u].removeFromSet(l);if(i.length==1&&l.length==0)o=i[0],a="add",s=u=>u.mark(o.addToSet(u.marks));else if(i.length==0&&l.length==1)o=l[0],a="remove",s=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<t.childCount;u++)c.push(s(t.child(u)));if(j.from(c).eq(r))return{mark:o,type:a}}function XS(r,t,e,n,i){if(e-t<=i.pos-n.pos||R9(n,!0,!1)<i.pos)return!1;let l=r.resolve(t);if(!n.parent.isTextblock){let o=l.nodeAfter;return o!=null&&e==t+o.nodeSize}if(l.parentOffset<l.parent.content.size||!l.parent.isTextblock)return!1;let a=r.resolve(R9(l,!0,!0));return!a.parent.isTextblock||a.pos>e||R9(a,!0,!1)<e?!1:n.parent.content.cut(n.parentOffset).eq(a.parent.content)}function R9(r,t,e){let n=r.depth,i=t?r.end():r.pos;for(;n>0&&(t||r.indexAfter(n)==r.node(n).childCount);)n--,i++,t=!1;if(e){let l=r.node(n).maybeChild(r.indexAfter(n));for(;l&&!l.isLeaf;)l=l.firstChild,i++}return i}function GS(r,t,e,n,i){let l=r.findDiffStart(t,e);if(l==null)return null;let{a,b:o}=r.findDiffEnd(t,e+r.size,e+t.size);if(i=="end"){let s=Math.max(0,l-Math.min(a,o));n-=a+s-l}if(a<l&&r.size<t.size){let s=n<=l&&n>=a?l-n:0;l-=s,l&&l<t.size&&q8(t.textBetween(l-1,l+1))&&(l+=s?1:-1),o=l+(o-a),a=l}else if(o<l){let s=n<=l&&n>=o?l-n:0;l-=s,l&&l<r.size&&q8(r.textBetween(l-1,l+1))&&(l+=s?1:-1),a=l+(a-o),o=l}return{start:l,endA:a,endB:o}}function q8(r){if(r.length!=2)return!1;let t=r.charCodeAt(0),e=r.charCodeAt(1);return t>=56320&&t<=57343&&e>=55296&&e<=56319}class j8{constructor(t,e){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 aS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(G8),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=P8(this),W8(this),this.nodeViews=X8(this),this.docView=Nc(this.state.doc,T8(this),y9(this),this.dom,this),this.domObserver=new US(this,(n,i,l,a)=>WS(this,n,i,l,a)),this.domObserver.start(),oS(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&g9(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(G8),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let n in this._props)e[n]=this._props[n];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let i=this.state,l=!1,a=!1;t.storedMarks&&this.composing&&(S8(this),a=!0),this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let f=X8(this);JS(f,this.nodeViews)&&(this.nodeViews=f,l=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&g9(this),this.editable=P8(this),W8(this);let s=y9(this),c=T8(this),u=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve",A=l||!this.docView.matchesNode(t.doc,c,s);(A||!t.selection.eq(i.selection))&&(a=!0);let d=u=="preserve"&&a&&this.dom.style.overflowAnchor==null&&vb(this);if(a){this.domObserver.stop();let f=A&&(Ee||te)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&HS(i.selection,t.selection);if(A){let h=te?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vS(this)),(l||!this.docView.update(t.doc,c,s,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Nc(t.doc,c,s,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hb(this))?e1(this,f):(l8(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&gb(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof i2){let e=this.docView.domAfterPos(this.state.selection.from);e.nodeType==1&&Oc(this,e.getBoundingClientRect(),t)}else Oc(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let n=this.directPlugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let n=this.state.plugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}}updateDraggedNode(t,e){let n=t.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let l=n.from+(this.state.doc.content.size-e.doc.content.size);(l>0&&this.state.doc.nodeAt(l))==n.node&&(i=l)}this.dragging=new y8(t.slice,t.move,i<0?void 0:i2.create(this.state.doc,i))}someProp(t,e){let n=this._props&&this._props[t],i;if(n!=null&&(i=e?e(n):n))return i;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[t];if(o!=null&&(i=e?e(o):o))return i}let l=this.state.plugins;if(l)for(let a=0;a<l.length;a++){let o=l[a].props[t];if(o!=null&&(i=e?e(o):o))return i}}hasFocus(){if(Ee){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&zb(this.dom),e1(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(t){return yb(this,t)}coordsAtPos(t,e=1){return Pc(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let i=this.docView.posFromDOM(t,e,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return Ub(this,e||this.state,t)}pasteHTML(t,e){return H7(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return H7(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return E9(this,t)}destroy(){this.docView&&(sS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],y9(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ab())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return uS(this,t)}domSelectionRange(){let t=this.domSelection();return t?le&&this.root.nodeType===11&&mb(this.dom.ownerDocument)==this.dom&&VS(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}j8.prototype.dispatch=function(r){let t=this._props.dispatchTransaction;t?t.call(this,r):this.updateState(this.state.apply(r))};function T8(r){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(r.editable),r.someProp("attributes",e=>{if(typeof e=="function"&&(e=e(r.state)),e)for(let n in e)n=="class"?t.class+=" "+e[n]:n=="style"?t.style=(t.style?t.style+";":"")+e[n]:!t[n]&&n!="contenteditable"&&n!="nodeName"&&(t[n]=String(e[n]))}),t.translate||(t.translate="no"),[Ue.node(0,r.state.doc.content.size,t)]}function W8(r){if(r.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),r.cursorWrapper={dom:t,deco:Ue.widget(r.state.selection.from,t,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function P8(r){return!r.someProp("editable",t=>t(r.state)===!1)}function HS(r,t){let e=Math.min(r.$anchor.sharedDepth(r.head),t.$anchor.sharedDepth(t.head));return r.$anchor.start(e)!=t.$anchor.start(e)}function X8(r){let t=Object.create(null);function e(n){for(let i in n)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=n[i])}return r.someProp("nodeViews",e),r.someProp("markViews",e),t}function JS(r,t){let e=0,n=0;for(let i in r){if(r[i]!=t[i])return!0;e++}for(let i in t)n++;return e!=n}function G8(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function t1(r,t){return r.meta={package:"@milkdown/core",group:"System",...t},r}const H8={text:(r,t,e,n)=>{const i=r.value;return/^[^*_\\]*\s+$/.test(i)?i:e.safe(i,{...n,encode:[]})},strong:(r,t,e,n)=>{const i=r.marker||e.options.strong||"*",l=e.enter("strong"),a=e.createTracker(n);let o=a.move(i+i);return o+=a.move(e.containerPhrasing(r,{before:o,after:i,...a.current()})),o+=a.move(i+i),l(),o},emphasis:(r,t,e,n)=>{const i=r.marker||e.options.emphasis||"*",l=e.enter("emphasis"),a=e.createTracker(n);let o=a.move(i);return o+=a.move(e.containerPhrasing(r,{before:o,after:i,...a.current()})),o+=a.move(i),l(),o}},fe=d2({},"editorView"),F7=d2({},"editorState"),Z9=d2([],"initTimer"),J8=d2({},"editor"),w7=d2([],"inputRules"),n1=d2([],"prosePlugins"),N7=d2([],"remarkPlugins"),x9=d2([],"nodeView"),B9=d2([],"markView"),y0=d2(Hi().use(Ri).use(Oi),"remark"),D7=d2({handlers:H8,encode:[]},"remarkStringifyOptions"),f5=kt("ConfigReady");function FS(r){const t=e=>(e.record(f5),async()=>(await r(e),e.done(f5),()=>{e.clearTimer(f5)}));return t1(t,{displayName:"Config"}),t}const R0=kt("InitReady");function wS(r){const t=e=>(e.inject(J8,r).inject(n1,[]).inject(N7,[]).inject(w7,[]).inject(x9,[]).inject(B9,[]).inject(D7,{handlers:H8,encode:[]}).inject(y0,Hi().use(Ri).use(Oi)).inject(Z9,[f5]).record(R0),async()=>{await e.waitTimers(Z9);const n=e.get(D7);return e.set(y0,Hi().use(Ri).use(Oi,n)),e.done(R0),()=>{e.remove(J8).remove(n1).remove(N7).remove(w7).remove(x9).remove(B9).remove(D7).remove(y0).remove(Z9).clearTimer(R0)}});return t1(t,{displayName:"Init"}),t}const Ye=kt("SchemaReady"),U9=d2([],"schemaTimer"),r1=d2({},"schema"),L7=d2([],"nodes"),_7=d2([],"marks");function F8(r){var t;return{...r,parseDOM:(t=r.parseDOM)==null?void 0:t.map(e=>({priority:r.priority,...e}))}}const w8=r=>(r.inject(r1,{}).inject(L7,[]).inject(_7,[]).inject(U9,[R0]).record(Ye),async()=>{await r.waitTimers(U9);const t=r.get(y0),n=r.get(N7).reduce((o,s)=>o.use(s.plugin,s.options),t);r.set(y0,n);const i=Object.fromEntries(r.get(L7).map(([o,s])=>[o,F8(s)])),l=Object.fromEntries(r.get(_7).map(([o,s])=>[o,F8(s)])),a=new bM({nodes:i,marks:l});return r.set(r1,a),r.done(Ye),()=>{r.remove(r1).remove(L7).remove(_7).remove(U9).clearTimer(Ye)}});t1(w8,{displayName:"Schema"});class N8{constructor(){o2(this,K0);o2(this,we);N(this,K0,new Eo),N(this,we,null),this.setCtx=t=>{N(this,we,t)},this.chain=()=>{if(U(this,we)==null)throw N4();const t=U(this,we),e=[],n=this.get.bind(this),i={run:()=>{const a=m3(...e),o=t.get(fe);return a(o.state,o.dispatch,o)},inline:a=>(e.push(a),i),pipe:l.bind(this)};function l(a,o){const s=n(a);return e.push(s(o)),i}return i}}get ctx(){return U(this,we)}create(t,e){const n=t.create(U(this,K0).sliceMap);return n.set(e),n}get(t){return U(this,K0).get(t).get()}remove(t){return U(this,K0).remove(t)}call(t,e){if(U(this,we)==null)throw N4();const i=this.get(t)(e),l=U(this,we).get(fe);return i(l.state,l.dispatch,l)}inline(t){if(U(this,we)==null)throw N4();const e=U(this,we).get(fe);return t(e.state,e.dispatch,e)}}K0=new WeakMap,we=new WeakMap;function NS(r="cmdKey"){return d2((()=>()=>!1),r)}const b2=d2(new N8,"commands"),Y9=d2([Ye],"commandsTimer"),$7=kt("CommandsReady"),D8=r=>{const t=new N8;return t.setCtx(r),r.inject(b2,t).inject(Y9,[Ye]).record($7),async()=>(await r.waitTimers(Y9),r.done($7),()=>{r.remove(b2).remove(Y9).clearTimer($7)})};t1(D8,{displayName:"Commands"});function DS(r){const t=m3(DQ,di,sv,Cs);return r.Backspace=t,r}class L8{constructor(){o2(this,q0);o2(this,Me);N(this,q0,null),N(this,Me,[]),this.setCtx=t=>{N(this,q0,t)},this.add=t=>(U(this,Me).push(t),()=>{N(this,Me,U(this,Me).filter(e=>e!==t))}),this.addObjectKeymap=t=>{const e=[];return Object.entries(t).forEach(([n,i])=>{if(typeof i=="function"){const l={key:n,onRun:()=>i};U(this,Me).push(l),e.push(()=>{N(this,Me,U(this,Me).filter(a=>a!==l))})}else U(this,Me).push(i),e.push(()=>{N(this,Me,U(this,Me).filter(l=>l!==i))})}),()=>{e.forEach(n=>n())}},this.addBaseKeymap=()=>{const t=DS(Qv);return this.addObjectKeymap(t)},this.build=()=>{const t={};return U(this,Me).forEach(n=>{t[n.key]=[...t[n.key]||[],n]}),Object.fromEntries(Object.entries(t).map(([n,i])=>{const l=i.sort((o,s)=>(s.priority??50)-(o.priority??50));return[n,(o,s,c)=>{const u=U(this,q0);if(u==null)throw Sr();const A=l.map(f=>f.onRun(u));return m3(...A)(o,s,c)}]}))}}get ctx(){return U(this,q0)}}q0=new WeakMap,Me=new WeakMap;const d5=d2(new L8,"keymap"),V9=d2([Ye],"keymapTimer"),en=kt("KeymapReady"),LS=r=>{const t=new L8;return t.setCtx(r),r.inject(d5,t).inject(V9,[Ye]).record(en),async()=>(await r.waitTimers(V9),r.done(en),()=>{r.remove(d5).remove(V9).clearTimer(en)})},h5=kt("ParserReady"),_8=(()=>{throw Sr()}),tn=d2(_8,"parser"),O9=d2([],"parserTimer"),$8=r=>(r.inject(tn,_8).inject(O9,[Ye]).record(h5),async()=>{await r.waitTimers(O9);const t=r.get(y0),e=r.get(r1);return r.set(tn,JQ.create(e,t)),r.done(h5),()=>{r.remove(tn).remove(O9).clearTimer(h5)}});t1($8,{displayName:"Parser"});const nn=kt("SerializerReady"),K9=d2([],"serializerTimer"),eu=(()=>{throw Sr()}),p5=d2(eu,"serializer"),tu=r=>(r.inject(p5,eu).inject(K9,[Ye]).record(nn),async()=>{await r.waitTimers(K9);const t=r.get(y0),e=r.get(r1);return r.set(p5,wQ.create(e,t)),r.done(nn),()=>{r.remove(p5).remove(K9).clearTimer(nn)}});t1(tu,{displayName:"Serializer"});const m5=d2("","defaultValue"),I5=d2(r=>r,"stateOptions"),q9=d2([],"editorStateTimer"),C5=kt("EditorStateReady");function _S(r,t,e){if(typeof r=="string")return t(r);if(r.type==="html")return u3.fromSchema(e).parse(r.dom);if(r.type==="json")return Ft.fromJSON(e,r.value);throw NE(r)}const $S=new rt("MILKDOWN_STATE_TRACKER"),nu=r=>(r.inject(m5,"").inject(F7,{}).inject(I5,t=>t).inject(q9,[h5,nn,$7,en]).record(C5),async()=>{await r.waitTimers(q9);const t=r.get(r1),e=r.get(tn),n=r.get(w7),i=r.get(I5),l=r.get(n1),a=r.get(m5),o=_S(a,e,t),s=r.get(d5),c=s.addBaseKeymap(),u=[...l,new nt({key:$S,state:{init:()=>{},apply:(f,h,m,I)=>{r.set(F7,I)}}}),_Q({rules:n}),cb(s.build())];r.set(n1,u);const A=i({schema:t,doc:o,plugins:u}),d=I0.create(A);return r.set(F7,d),r.done(C5),()=>{c(),r.remove(m5).remove(F7).remove(I5).remove(q9).clearTimer(C5)}});t1(nu,{displayName:"EditorState"});const j9=d2([],"pasteRule"),T9=d2([Ye],"pasteRuleTimer"),E5=kt("PasteRuleReady"),ru=r=>(r.inject(j9,[]).inject(T9,[Ye]).record(E5),async()=>(await r.waitTimers(T9),r.done(E5),()=>{r.remove(j9).remove(T9).clearTimer(E5)}));t1(ru,{displayName:"PasteRule"});const M5=kt("EditorViewReady"),W9=d2([],"editorViewTimer"),v5=d2({},"editorViewOptions"),g5=d2(null,"root"),P9=d2(null,"rootDOM"),X9=d2({},"rootAttrs");function ek(r,t){const e=document.createElement("div");e.className="milkdown",r.appendChild(e),t.set(P9,e);const n=t.get(X9);return Object.entries(n).forEach(([i,l])=>e.setAttribute(i,l)),e}function tk(r){r.classList.add("editor"),r.setAttribute("role","textbox")}const nk=new rt("MILKDOWN_VIEW_CLEAR"),iu=r=>(r.inject(g5,document.body).inject(fe,{}).inject(v5,{}).inject(P9,null).inject(X9,{}).inject(W9,[C5,E5]).record(M5),async()=>{await r.wait(R0);const t=r.get(g5)||document.body,e=typeof t=="string"?document.querySelector(t):t;r.update(n1,s=>[new nt({key:nk,view:c=>{const u=e?ek(e,r):void 0;return(()=>{if(u&&e){const d=c.dom;e.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(c.dom,u)),u==null||u.remove()}}}}),...s]),await r.waitTimers(W9);const n=r.get(F7),i=r.get(v5),l=Object.fromEntries(r.get(x9)),a=Object.fromEntries(r.get(B9)),o=new j8(e,{state:n,nodeViews:l,markViews:a,transformPasted:(s,c,u)=>(r.get(j9).sort((A,d)=>(d.priority??50)-(A.priority??50)).map(A=>A.run).forEach(A=>{s=A(s,c,u)}),s),...i});return tk(o.dom),r.set(fe,o),r.done(M5),()=>{o==null||o.destroy(),r.remove(g5).remove(fe).remove(v5).remove(P9).remove(X9).remove(W9).clearTimer(M5)}});t1(iu,{displayName:"EditorView"});const Pl=class Pl{constructor(){o2(this,j0);o2(this,Ve);o2(this,u1);o2(this,J3);o2(this,En);o2(this,Mn);o2(this,ve);o2(this,A1);o2(this,T0);o2(this,vn);o2(this,W0);o2(this,F3);o2(this,gn);o2(this,H1);o2(this,w3);N(this,j0,!1),N(this,Ve,"Idle"),N(this,u1,[]),N(this,J3,()=>{}),N(this,En,new Eo),N(this,Mn,new aM),N(this,ve,new Map),N(this,A1,new Map),N(this,T0,new D4(U(this,En),U(this,Mn))),N(this,vn,()=>{const t=FS(async n=>{await Promise.all(U(this,u1).map(i=>Promise.resolve(i(n))))}),e=[w8,$8,tu,D8,LS,ru,nu,iu,wS(this),t];U(this,W0).call(this,e,U(this,A1))}),N(this,W0,(t,e)=>{t.forEach(n=>{const i=U(this,T0).produce(U(this,j0)?n.meta:void 0),l=n(i);e.set(n,{ctx:i,handler:l,cleanup:void 0})})}),N(this,F3,(t,e=!1)=>Promise.all([t].flat().map(async n=>{const i=U(this,ve).get(n),l=i==null?void 0:i.cleanup;return e?U(this,ve).delete(n):U(this,ve).set(n,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof l=="function"?l():l}))),N(this,gn,async()=>{await Promise.all([...U(this,A1).entries()].map(async([t,{cleanup:e}])=>typeof e=="function"?e():e)),U(this,A1).clear()}),N(this,H1,t=>{N(this,Ve,t),U(this,J3).call(this,t)}),N(this,w3,t=>[...t.entries()].map(async([e,n])=>{const{ctx:i,handler:l}=n;if(!l)return;const a=await l();t.set(e,{ctx:i,handler:l,cleanup:a})})),this.enableInspector=(t=!0)=>(N(this,j0,t),this),this.onStatusChange=t=>(N(this,J3,t),this),this.config=t=>(U(this,u1).push(t),this),this.removeConfig=t=>(N(this,u1,U(this,u1).filter(e=>e!==t)),this),this.use=t=>{const e=[t].flat();return e.flat().forEach(n=>{U(this,ve).set(n,{ctx:void 0,handler:void 0,cleanup:void 0})}),U(this,Ve)==="Created"&&U(this,W0).call(this,e,U(this,ve)),this},this.remove=async t=>U(this,Ve)==="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(e=>{setTimeout(()=>{e(this.remove(t))},50)})):(await U(this,F3).call(this,[t].flat(),!0),this),this.create=async()=>U(this,Ve)==="OnCreate"?this:(U(this,Ve)==="Created"&&await this.destroy(),U(this,H1).call(this,"OnCreate"),U(this,vn).call(this),U(this,W0).call(this,[...U(this,ve).keys()],U(this,ve)),await Promise.all([U(this,w3).call(this,U(this,A1)),U(this,w3).call(this,U(this,ve))].flat()),U(this,H1).call(this,"Created"),this),this.destroy=async(t=!1)=>U(this,Ve)==="Destroyed"||U(this,Ve)==="OnDestroy"?this:U(this,Ve)==="OnCreate"?new Promise(e=>{setTimeout(()=>{e(this.destroy(t))},50)}):(t&&N(this,u1,[]),U(this,H1).call(this,"OnDestroy"),await U(this,F3).call(this,[...U(this,ve).keys()],t),await U(this,gn).call(this),U(this,H1).call(this,"Destroyed"),this),this.action=t=>t(U(this,T0)),this.inspect=()=>U(this,j0)?[...U(this,A1).values(),...U(this,ve).values()].map(({ctx:t})=>{var e;return(e=t==null?void 0:t.inspector)==null?void 0:e.read()}).filter(t=>!!t):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Pl}get ctx(){return U(this,T0)}get status(){return U(this,Ve)}};j0=new WeakMap,Ve=new WeakMap,u1=new WeakMap,J3=new WeakMap,En=new WeakMap,Mn=new WeakMap,ve=new WeakMap,A1=new WeakMap,T0=new WeakMap,vn=new WeakMap,W0=new WeakMap,F3=new WeakMap,gn=new WeakMap,H1=new WeakMap,w3=new WeakMap;let G9=Pl;var z5=200,J2=function(){};J2.prototype.append=function(t){return t.length?(t=J2.from(t),!this.length&&t||t.length<z5&&this.leafAppend(t)||this.length<z5&&t.leafPrepend(this)||this.appendInner(t)):this},J2.prototype.prepend=function(t){return t.length?J2.from(t).append(this):this},J2.prototype.appendInner=function(t){return new rk(this,t)},J2.prototype.slice=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=this.length),t>=e?J2.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},J2.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},J2.prototype.forEach=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},J2.prototype.map=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(l,a){return i.push(t(l,a))},e,n),i},J2.from=function(t){return t instanceof J2?t:t&&t.length?new lu(t):J2.empty};var lu=(function(r){function t(n){r.call(this),this.values=n}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(i,l){return i==0&&l==this.length?this:new t(this.values.slice(i,l))},t.prototype.getInner=function(i){return this.values[i]},t.prototype.forEachInner=function(i,l,a,o){for(var s=l;s<a;s++)if(i(this.values[s],o+s)===!1)return!1},t.prototype.forEachInvertedInner=function(i,l,a,o){for(var s=l-1;s>=a;s--)if(i(this.values[s],o+s)===!1)return!1},t.prototype.leafAppend=function(i){if(this.length+i.length<=z5)return new t(this.values.concat(i.flatten()))},t.prototype.leafPrepend=function(i){if(this.length+i.length<=z5)return new t(i.flatten().concat(this.values))},e.length.get=function(){return this.values.length},e.depth.get=function(){return 0},Object.defineProperties(t.prototype,e),t})(J2);J2.empty=new lu([]);var rk=(function(r){function t(e,n){r.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},t.prototype.forEachInner=function(n,i,l,a){var o=this.left.length;if(i<o&&this.left.forEachInner(n,i,Math.min(l,o),a)===!1||l>o&&this.right.forEachInner(n,Math.max(i-o,0),Math.min(this.length,l)-o,a+o)===!1)return!1},t.prototype.forEachInvertedInner=function(n,i,l,a){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(n,i-o,Math.max(l,o)-o,a+o)===!1||l<o&&this.left.forEachInvertedInner(n,Math.min(i,o),l,a)===!1)return!1},t.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var l=this.left.length;return i<=l?this.left.slice(n,i):n>=l?this.right.slice(n-l,i-l):this.left.slice(n,l).append(this.right.slice(0,i-l))},t.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new t(this.left,i)},t.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new t(i,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t})(J2);const ik=500;class at{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,l;e&&(i=this.remapping(n,this.items.length),l=i.maps.length);let a=t.tr,o,s,c=[],u=[];return this.items.forEach((A,d)=>{if(!A.step){i||(i=this.remapping(n,d+1),l=i.maps.length),l--,u.push(A);return}if(i){u.push(new Vt(A.map));let f=A.step.map(i.slice(l)),h;f&&a.maybeStep(f).doc&&(h=a.mapping.maps[a.mapping.maps.length-1],c.push(new Vt(h,void 0,void 0,c.length+u.length))),l--,h&&i.appendMap(h,l)}else a.maybeStep(A.step);if(A.selection)return o=i?A.selection.map(i.slice(l)):A.selection,s=new at(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:s,transform:a,selection:o}}addTransform(t,e,n,i){let l=[],a=this.eventCount,o=this.items,s=!i&&o.length?o.get(o.length-1):null;for(let u=0;u<t.steps.length;u++){let A=t.steps[u].invert(t.docs[u]),d=new Vt(t.mapping.maps[u],A,e),f;(f=s&&s.merge(d))&&(d=f,u?l.pop():o=o.slice(0,o.length-1)),l.push(d),e&&(a++,e=void 0),i||(s=d)}let c=a-n.depth;return c>ak&&(o=lk(o,c),a-=c),new at(o.append(l),a)}remapping(t,e){let n=new M7;return this.items.forEach((i,l)=>{let a=i.mirrorOffset!=null&&l-i.mirrorOffset>=t?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,a)},t,e),n}addMaps(t){return this.eventCount==0?this:new at(this.items.append(t.map(e=>new Vt(e))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-e),l=t.mapping,a=t.steps.length,o=this.eventCount;this.items.forEach(d=>{d.selection&&o--},i);let s=e;this.items.forEach(d=>{let f=l.getMirror(--s);if(f==null)return;a=Math.min(a,f);let h=l.maps[f];if(d.step){let m=t.steps[f].invert(t.docs[f]),I=d.selection&&d.selection.map(l.slice(s+1,f));I&&o++,n.push(new Vt(h,m,I))}else n.push(new Vt(h))},i);let c=[];for(let d=e;d<a;d++)c.push(new Vt(l.maps[d]));let u=this.items.slice(0,i).append(c).append(n),A=new at(u,o);return A.emptyItemCount()>ik&&(A=A.compress(this.items.length-n.length)),A}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,i=[],l=0;return this.items.forEach((a,o)=>{if(o>=t)i.push(a),a.selection&&l++;else if(a.step){let s=a.step.map(e.slice(n)),c=s&&s.getMap();if(n--,c&&e.appendMap(c,n),s){let u=a.selection&&a.selection.map(e.slice(n));u&&l++;let A=new Vt(c.invert(),s,u),d,f=i.length-1;(d=i.length&&i[f].merge(A))?i[f]=d:i.push(A)}}else a.map&&n--},this.items.length,0),new at(J2.from(i.reverse()),l)}}at.empty=new at(J2.empty,0);function lk(r,t){let e;return r.forEach((n,i)=>{if(n.selection&&t--==0)return e=i,!1}),r.slice(e)}class Vt{constructor(t,e,n,i){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Vt(e.getMap().invert(),e,this.selection)}}}class T1{constructor(t,e,n,i,l){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=i,this.prevComposition=l}}const ak=20;function ok(r,t,e,n){let i=e.getMeta(Z0),l;if(i)return i.historyState;e.getMeta(uk)&&(r=new T1(r.done,r.undone,null,0,-1));let a=e.getMeta("appendedTransaction");if(e.steps.length==0)return r;if(a&&a.getMeta(Z0))return a.getMeta(Z0).redo?new T1(r.done.addTransform(e,void 0,n,Q5(t)),r.undone,au(e.mapping.maps),r.prevTime,r.prevComposition):new T1(r.done,r.undone.addTransform(e,void 0,n,Q5(t)),null,r.prevTime,r.prevComposition);if(e.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=e.getMeta("composition"),s=r.prevTime==0||!a&&r.prevComposition!=o&&(r.prevTime<(e.time||0)-n.newGroupDelay||!sk(e,r.prevRanges)),c=a?H9(r.prevRanges,e.mapping):au(e.mapping.maps);return new T1(r.done.addTransform(e,s?t.selection.getBookmark():void 0,n,Q5(t)),at.empty,c,e.time,o??r.prevComposition)}else return(l=e.getMeta("rebased"))?new T1(r.done.rebased(e,l),r.undone.rebased(e,l),H9(r.prevRanges,e.mapping),r.prevTime,r.prevComposition):new T1(r.done.addMaps(e.mapping.maps),r.undone.addMaps(e.mapping.maps),H9(r.prevRanges,e.mapping),r.prevTime,r.prevComposition)}function sk(r,t){if(!t)return!1;if(!r.docChanged)return!0;let e=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let l=0;l<t.length;l+=2)n<=t[l+1]&&i>=t[l]&&(e=!0)}),e}function au(r){let t=[];for(let e=r.length-1;e>=0&&t.length==0;e--)r[e].forEach((n,i,l,a)=>t.push(l,a));return t}function H9(r,t){if(!r)return null;let e=[];for(let n=0;n<r.length;n+=2){let i=t.map(r[n],1),l=t.map(r[n+1],-1);i<=l&&e.push(i,l)}return e}function ck(r,t,e){let n=Q5(t),i=Z0.get(t).spec.config,l=(e?r.undone:r.done).popEvent(t,n);if(!l)return null;let a=l.selection.resolve(l.transform.doc),o=(e?r.done:r.undone).addTransform(l.transform,t.selection.getBookmark(),i,n),s=new T1(e?o:l.remaining,e?l.remaining:o,null,0,-1);return l.transform.setSelection(a).setMeta(Z0,{redo:e,historyState:s})}let J9=!1,ou=null;function Q5(r){let t=r.plugins;if(ou!=t){J9=!1,ou=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){J9=!0;break}}return J9}const Z0=new rt("history"),uk=new rt("closeHistory");function Ak(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new nt({key:Z0,state:{init(){return new T1(at.empty,at.empty,null,0,-1)},apply(t,e,n){return ok(e,n,t,r)}},config:r,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,i=n=="historyUndo"?cu:n=="historyRedo"?uu:null;return!i||!t.editable?!1:(e.preventDefault(),i(t.state,t.dispatch))}}}})}function su(r,t){return(e,n)=>{let i=Z0.getState(e);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let l=ck(i,e,r);l&&n(t?l.scrollIntoView():l)}return!0}}const cu=su(!1,!0),uu=su(!0,!0);function g2(r,t){const e=NS(r),n=i=>async()=>{n.key=e,await i.wait($7);const l=t(i);return i.get(b2).create(e,l),n.run=a=>i.get(b2).call(r,a),()=>{i.get(b2).remove(e)}};return n}function ot(r){const t=e=>async()=>{await e.wait(Ye);const n=r(e);return e.update(w7,i=>[...i,n]),t.inputRule=n,()=>{e.update(w7,i=>i.filter(l=>l!==n))}};return t}function fk(r,t){const e=n=>async()=>{const i=t(n);return n.update(_7,l=>[...l.filter(a=>a[0]!==r),[r,i]]),e.id=r,e.schema=i,()=>{n.update(_7,l=>l.filter(([a])=>a!==r))}};return e.type=n=>{const i=n.get(r1).marks[r];if(!i)throw nM(r);return i},e}function F9(r,t){const e=n=>async()=>{const i=t(n);return n.update(L7,l=>[...l.filter(a=>a[0]!==r),[r,i]]),e.id=r,e.schema=i,()=>{n.update(L7,l=>l.filter(([a])=>a!==r))}};return e.type=n=>{const i=n.get(r1).nodes[r];if(!i)throw tM(r);return i},e}function S3(r){let t;const e=n=>async()=>(await n.wait(Ye),t=r(n),n.update(n1,i=>[...i,t]),()=>{n.update(n1,i=>i.filter(l=>l!==t))});return e.plugin=()=>t,e.key=()=>t.spec.key,e}function dk(r){const t=e=>async()=>{await e.wait(en);const n=e.get(d5),i=r(e),l=n.addObjectKeymap(i);return t.keymap=i,()=>{l()}};return t}function i1(r,t){const e=d2(r,t),n=i=>(i.inject(e),()=>()=>{i.remove(e)});return n.key=e,n}function He(r,t){const e=i1(t,r),n=F9(r,l=>l.get(e.key)(l)),i=[e,n];return i.id=n.id,i.node=n,i.type=l=>n.type(l),i.ctx=e,i.key=e.key,i.extendSchema=l=>{const a=l(t);return He(r,a)},i}function rn(r,t){const e=i1(t,r),n=fk(r,l=>l.get(e.key)(l)),i=[e,n];return i.id=n.id,i.mark=n,i.type=l=>n.type(l),i.ctx=e,i.key=e.key,i.extendSchema=l=>{const a=l(t);return rn(r,a)},i}function Je(r,t){const e=Object.fromEntries(Object.entries(t).map(([a,{shortcuts:o,priority:s}])=>[a,{shortcuts:o,priority:s}])),n=i1(e,`${r}Keymap`),i=dk(a=>{const o=a.get(n.key),s=Object.entries(t).flatMap(([c,{command:u}])=>{const A=o[c],d=[A.shortcuts].flat(),f=A.priority;return d.map(h=>[h,{key:h,onRun:u,priority:f}])});return Object.fromEntries(s)}),l=[n,i];return l.ctx=n,l.shortcuts=i,l.key=n.key,l.keymap=i.keymap,l}const st=(r,t=()=>({}))=>i1(t,`${r}Attr`),b5=(r,t=()=>({}))=>i1(t,`${r}Attr`);function k3(r,t,e){const n=i1({},r),i=a=>async()=>{await a.wait(R0);const s={plugin:t(a),options:a.get(n.key)};return a.update(N7,c=>[...c,s]),()=>{a.update(N7,c=>c.filter(u=>u!==s))}},l=[n,i];return l.id=r,l.plugin=i,l.options=n,l}function hk(r,t=!1){return e=>{const n=e.get(fe),l=e.get(tn)(r);if(!l)return;if(!t){const{state:u}=n;return n.dispatch(u.tr.replace(0,u.doc.content.size,new J(l.content,0,0)))}const a=e.get(r1),o=e.get(I5),s=e.get(n1),c=I0.create({schema:a,doc:l,plugins:s,...o});n.updateState(c)}}function y3(r,t){return Object.assign(r,{meta:{package:"@milkdown/plugin-history",...t}}),r}const S5=g2("Undo",()=>()=>cu);y3(S5,{displayName:"Command<undo>"});const k5=g2("Redo",()=>()=>uu);y3(k5,{displayName:"Command<redo>"});const w9=i1({},"historyProviderConfig");y3(w9,{displayName:"Ctx<historyProviderConfig>"});const Au=S3(r=>Ak(r.get(w9.key)));y3(Au,{displayName:"Ctx<historyProviderPlugin>"});const N9=Je("historyKeymap",{Undo:{shortcuts:"Mod-z",command:r=>{const t=r.get(b2);return()=>t.call(S5.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:r=>{const t=r.get(b2);return()=>t.call(k5.key)}}});y3(N9.ctx,{displayName:"KeymapCtx<history>"}),y3(N9.shortcuts,{displayName:"Keymap<history>"});const pk=[w9,Au,N9,S5,k5].flat();function mk(r,t){return function(e,n){let{$from:i,$to:l,node:a}=e.selection;if(a&&a.isBlock||i.depth<2||!i.sameParent(l))return!1;let o=i.node(-1);if(o.type!=r)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(n){let A=j.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let M=i.depth-d;M>=i.depth-3;M--)A=j.from(i.node(M).copy(A));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;A=A.append(j.from(r.createAndFill()));let h=i.before(i.depth-(d-1)),m=e.tr.replace(h,i.after(-f),new J(A,4-d,0)),I=-1;m.doc.nodesBetween(h,m.doc.content.size,(M,k)=>{if(I>-1)return!1;M.isTextblock&&M.content.size==0&&(I=k+1)}),I>-1&&m.setSelection(E2.near(m.doc.resolve(I))),n(m.scrollIntoView())}return!0}let s=l.pos==i.end()?o.contentMatchAt(0).defaultType:null,c=e.tr.delete(i.pos,l.pos),u=s?[null,{type:s}]:void 0;return v7(c.doc,i.pos,2,u)?(n&&n(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Ik(r){return function(t,e){let{$from:n,$to:i}=t.selection,l=n.blockRange(i,a=>a.childCount>0&&a.firstChild.type==r);return l?e?n.node(l.depth-1).type==r?Ck(t,e,r,l):Ek(t,e,l):!0:!1}}function Ck(r,t,e,n){let i=r.tr,l=n.end,a=n.$to.end(n.depth);l<a&&(i.step(new ie(l-1,a,l,a,new J(j.from(e.create(null,n.parent.copy())),1,0),1,!0)),n=new yo(i.doc.resolve(n.$from.pos),i.doc.resolve(a),n.depth));const o=Or(n);if(o==null)return!1;i.lift(n,o);let s=i.doc.resolve(i.mapping.map(l,-1)-1);return Kr(i.doc,s.pos)&&s.nodeBefore.type==s.nodeAfter.type&&i.join(s.pos),t(i.scrollIntoView()),!0}function Ek(r,t,e){let n=r.tr,i=e.parent;for(let f=e.end,h=e.endIndex-1,m=e.startIndex;h>m;h--)f-=i.child(h).nodeSize,n.delete(f-1,f+1);let l=n.doc.resolve(e.start),a=l.nodeAfter;if(n.mapping.map(e.end)!=e.start+l.nodeAfter.nodeSize)return!1;let o=e.startIndex==0,s=e.endIndex==i.childCount,c=l.node(-1),u=l.index(-1);if(!c.canReplace(u+(o?0:1),u+1,a.content.append(s?j.empty:j.from(i))))return!1;let A=l.pos,d=A+a.nodeSize;return n.step(new ie(A-(o?1:0),d+(s?1:0),A+1,d-1,new J((o?j.empty:j.from(i.copy(j.empty))).append(s?j.empty:j.from(i.copy(j.empty))),o?0:1,s?0:1),o?0:1)),t(n.scrollIntoView()),!0}function Mk(r){return function(t,e){let{$from:n,$to:i}=t.selection,l=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!l)return!1;let a=l.startIndex;if(a==0)return!1;let o=l.parent,s=o.child(a-1);if(s.type!=r)return!1;if(e){let c=s.lastChild&&s.lastChild.type==o.type,u=j.from(c?r.create():null),A=new J(j.from(r.create(null,j.from(o.type.create(null,u)))),c?3:1,0),d=l.start,f=l.end;e(t.tr.step(new ie(d-(c?3:1),f,d,f,A,1,!0)).scrollIntoView())}return!0}}function vk(r){const t=new Map;if(!r||!r.type)throw new Error("mdast-util-definitions expected node");return C3(r,"definition",function(n){const i=fu(n.identifier);i&&!t.get(i)&&t.set(i,n)}),e;function e(n){const i=fu(n);return t.get(i)}}function fu(r){return String(r||"").toUpperCase()}function gk(){return function(r){const t=vk(r);C3(r,function(e,n,i){if(e.type==="definition"&&i!==void 0&&typeof n=="number")return i.children.splice(n,1),[Yi,n];if(e.type==="imageReference"||e.type==="linkReference"){const l=t(e.identifier);if(l&&i&&typeof n=="number")return i.children[n]=e.type==="imageReference"?{type:"image",url:l.url,title:l.title,alt:e.alt}:{type:"link",url:l.url,title:l.title,children:e.children},[Yi,n]}})}}function du(r,t){var i;if(!(t.childCount>=1&&((i=t.lastChild)==null?void 0:i.type.name)==="hardbreak")){r.next(t.content);return}const n=[];t.content.forEach((l,a,o)=>{o!==t.childCount-1&&n.push(l)}),r.next(j.fromArray(n))}function Y(r,t){return Object.assign(r,{meta:{package:"@milkdown/preset-commonmark",...t}}),r}const D9=b5("emphasis");Y(D9,{displayName:"Attr<emphasis>",group:"Emphasis"});const R3=rn("emphasis",r=>({attrs:{marker:{default:r.get(D7).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:t=>t==="italic"}],toDOM:t=>["em",r.get(D9.key)(t)],parseMarkdown:{match:t=>t.type==="emphasis",runner:(t,e,n)=>{t.openMark(n,{marker:e.marker}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="emphasis",runner:(t,e)=>{t.withMark(e,"emphasis",void 0,{marker:e.attrs.marker})}}}));Y(R3.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Y(R3.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const y5=g2("ToggleEmphasis",r=>()=>Ii(R3.type(r)));Y(y5,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const hu=ot(r=>n5(/(?:^|[^*])\*([^*]+)\*$/,R3.type(r),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:t,start:e})=>t.startsWith("*")?{}:{fullMatch:t.slice(1),start:e+1}}));Y(hu,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const pu=ot(r=>n5(/\b_(?![_\s])(.*?[^_\s])_\b/,R3.type(r),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:t,start:e})=>t.startsWith("_")?{}:{fullMatch:t.slice(1),start:e+1}}));Y(pu,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const L9=Je("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:r=>{const t=r.get(b2);return()=>t.call(y5.key)}}});Y(L9.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Y(L9.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const _9=b5("strong");Y(_9,{displayName:"Attr<strong>",group:"Strong"});const ln=rn("strong",r=>({attrs:{marker:{default:r.get(D7).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:t=>t==="bold"},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:t=>["strong",r.get(_9.key)(t)],parseMarkdown:{match:t=>t.type==="strong",runner:(t,e,n)=>{t.openMark(n,{marker:e.marker}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="strong",runner:(t,e)=>{t.withMark(e,"strong",void 0,{marker:e.attrs.marker})}}}));Y(ln.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Y(ln.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const R5=g2("ToggleStrong",r=>()=>Ii(ln.type(r)));Y(R5,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const mu=ot(r=>n5(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),ln.type(r),{getAttr:t=>({marker:t[0].startsWith("*")?"*":"_"})}));Y(mu,{displayName:"InputRule<strong>",group:"Strong"});const $9=Je("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:r=>{const t=r.get(b2);return()=>t.call(R5.key)}}});Y($9.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Y($9.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const el=b5("inlineCode");Y(el,{displayName:"Attr<inlineCode>",group:"InlineCode"});const W1=rn("inlineCode",r=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",r.get(el.key)(t)],parseMarkdown:{match:t=>t.type==="inlineCode",runner:(t,e,n)=>{t.openMark(n),t.addText(e.value),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="inlineCode",runner:(t,e,n)=>{t.withMark(e,"inlineCode",n.text||"")}}}));Y(W1.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Y(W1.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const tl=g2("ToggleInlineCode",r=>()=>(t,e)=>{const{selection:n,tr:i}=t;if(n.empty)return!1;const{from:l,to:a}=n;return t.doc.rangeHasMark(l,a,W1.type(r))?(e==null||e(i.removeMark(l,a,W1.type(r))),!0):(Object.keys(t.schema.marks).filter(c=>c!==W1.type.name).map(c=>t.schema.marks[c]).forEach(c=>{i.removeMark(l,a,c)}),e==null||e(i.addMark(l,a,W1.type(r).create())),!0)});Y(tl,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const Iu=ot(r=>n5(/(?:`)([^`]+)(?:`)$/,W1.type(r)));Y(Iu,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const nl=Je("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:r=>{const t=r.get(b2);return()=>t.call(tl.key)}}});Y(nl.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Y(nl.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const rl=b5("link");Y(rl,{displayName:"Attr<link>",group:"Link"});const Z3=rn("link",r=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:t=>["a",{...r.get(rl.key)(t),...t.attrs}],parseMarkdown:{match:t=>t.type==="link",runner:(t,e,n)=>{const i=e.url,l=e.title;t.openMark(n,{href:i,title:l}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="link",runner:(t,e)=>{t.withMark(e,"link",void 0,{title:e.attrs.title,url:e.attrs.href})}}}));Y(Z3.mark,{displayName:"MarkSchema<link>",group:"Link"});const Cu=g2("ToggleLink",r=>(t={})=>Ii(Z3.type(r),t));Y(Cu,{displayName:"Command<toggleLinkCommand>",group:"Link"});const Eu=g2("UpdateLink",r=>(t={})=>(e,n)=>{if(!n)return!1;let i,l=-1;const{selection:a}=e,{from:o,to:s}=a;if(e.doc.nodesBetween(o,o===s?s+1:s,(h,m)=>{if(Z3.type(r).isInSet(h.marks))return i=h,l=m,!1}),!i)return!1;const c=i.marks.find(({type:h})=>h===Z3.type(r));if(!c)return!1;const u=l,A=l+i.nodeSize,{tr:d}=e,f=Z3.type(r).create({...c.attrs,...t});return f?(n(d.removeMark(u,A,c).addMark(u,A,f).setSelection(new m2(d.selection.$anchor)).scrollIntoView()),!0):!1});Y(Eu,{displayName:"Command<updateLinkCommand>",group:"Link"});const Mu=F9("doc",()=>({content:"block+",parseMarkdown:{match:({type:r})=>r==="root",runner:(r,t,e)=>{r.injectRoot(t,e)}},toMarkdown:{match:r=>r.type.name==="doc",runner:(r,t)=>{r.openNode("root"),r.next(t.content)}}}));Y(Mu,{displayName:"NodeSchema<doc>",group:"Doc"});function zk(r){return lc(r,t=>{var e;return t.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((e=t.value)==null?void 0:e.trim())},(t,e)=>{if(!e.length)return;const n=e[e.length-1];if(!n)return;const i=n.children.indexOf(t);i!==-1&&n.children.splice(i,1)},!0)}const Z5=k3("remark-preserve-empty-line",()=>()=>zk);Y(Z5.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Y(Z5.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});const il=st("paragraph");Y(il,{displayName:"Attr<paragraph>",group:"Paragraph"});const x0=He("paragraph",r=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",r.get(il.key)(t),0],parseMarkdown:{match:t=>t.type==="paragraph",runner:(t,e,n)=>{t.openNode(n),e.children?t.next(e.children):t.addText(e.value||""),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="paragraph",runner:(t,e)=>{var l;const i=(l=r.get(fe).state)==null?void 0:l.doc.lastChild;t.openNode("paragraph"),(!e.content||e.content.size===0)&&e!==i&&Qk(r)?t.addNode("html",void 0,"<br />"):du(t,e),t.closeNode()}}}));function Qk(r){let t=!1;try{r.get(Z5.id),t=!0}catch{t=!1}return t}Y(x0.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Y(x0.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const x5=g2("TurnIntoText",r=>()=>S7(x0.type(r)));Y(x5,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const ll=Je("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:r=>{const t=r.get(b2);return()=>t.call(x5.key)}}});Y(ll.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Y(ll.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const bk=Array(6).fill(0).map((r,t)=>t+1);function Sk(r){return r.textContent.toLowerCase().trim().replace(/\s+/g,"-")}const B5=i1(Sk,"headingIdGenerator");Y(B5,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const al=st("heading");Y(al,{displayName:"Attr<heading>",group:"Heading"});const B0=He("heading",r=>{const t=r.get(B5.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:bk.map(e=>({tag:`h${e}`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw f0(n);return{level:e,id:n.id}}})),toDOM:e=>[`h${e.attrs.level}`,{...r.get(al.key)(e),id:e.attrs.id||t(e)},0],parseMarkdown:{match:({type:e})=>e==="heading",runner:(e,n,i)=>{const l=n.depth;e.openNode(i,{level:l}),e.next(n.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="heading",runner:(e,n)=>{e.openNode("heading",void 0,{depth:n.attrs.level}),du(e,n),e.closeNode()}}}});Y(B0.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Y(B0.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const vu=ot(r=>kc(/^(?<hashes>#+)\s$/,B0.type(r),t=>{var a,o;const e=((o=(a=t.groups)==null?void 0:a.hashes)==null?void 0:o.length)||0,n=r.get(fe),{$from:i}=n.state.selection,l=i.node();if(l.type.name==="heading"){let s=Number(l.attrs.level)+Number(e);return s>6&&(s=6),{level:s}}return{level:e}}));Y(vu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const l1=g2("WrapInHeading",r=>t=>(t??(t=1),t<1?S7(x0.type(r)):S7(B0.type(r),{level:t})));Y(l1,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const ol=g2("DowngradeHeading",r=>()=>(t,e,n)=>{const{$from:i}=t.selection,l=i.node();if(l.type!==B0.type(r)||!t.selection.empty||i.parentOffset!==0)return!1;const a=l.attrs.level-1;return a?(e==null||e(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...l.attrs,level:a})),!0):S7(x0.type(r))(t,e,n)});Y(ol,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const sl=Je("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:r=>{const t=r.get(b2);return()=>t.call(ol.key)}}});Y(sl.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Y(sl.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const cl=st("blockquote");Y(cl,{displayName:"Attr<blockquote>",group:"Blockquote"});const an=He("blockquote",r=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",r.get(cl.key)(t),0],parseMarkdown:{match:({type:t})=>t==="blockquote",runner:(t,e,n)=>{t.openNode(n).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name==="blockquote",runner:(t,e)=>{t.openNode("blockquote").next(e.content).closeNode()}}}));Y(an.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Y(an.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const gu=ot(r=>$i(/^\s*>\s$/,an.type(r)));Y(gu,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const ul=g2("WrapInBlockquote",r=>()=>mi(an.type(r)));Y(ul,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const Al=Je("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:r=>{const t=r.get(b2);return()=>t.call(ul.key)}}});Y(Al.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Y(Al.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const fl=st("codeBlock",()=>({pre:{},code:{}}));Y(fl,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const on=He("code_block",r=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{language:t.dataset.language}}}],toDOM:t=>{const e=r.get(fl.key)(t),n=t.attrs.language,i=n&&n.length>0?{"data-language":n}:void 0;return["pre",{...e.pre,...i},["code",e.code,0]]},parseMarkdown:{match:({type:t})=>t==="code",runner:(t,e,n)=>{const i=e.lang??"",l=e.value;t.openNode(n,{language:i}),l&&t.addText(l),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="code_block",runner:(t,e)=>{var n;t.addNode("code",void 0,((n=e.content.firstChild)==null?void 0:n.text)||"",{lang:e.attrs.language})}}}));Y(on.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Y(on.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const zu=ot(r=>kc(/^```(?<language>[a-z]*)?[\s\n]$/,on.type(r),t=>{var e;return{language:((e=t.groups)==null?void 0:e.language)??""}}));Y(zu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const dl=g2("CreateCodeBlock",r=>(t="")=>S7(on.type(r),{language:t}));Y(dl,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const kk=g2("UpdateCodeBlockLanguage",()=>({pos:r,language:t}={pos:-1,language:""})=>(e,n)=>r>=0?(n==null||n(e.tr.setNodeAttribute(r,"language",t)),!0):!1);Y(kk,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const hl=Je("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:r=>{const t=r.get(b2);return()=>t.call(dl.key)}}});Y(hl.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Y(hl.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const pl=st("image");Y(pl,{displayName:"Attr<image>",group:"Image"});const x3=He("image",r=>({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:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"",title:t.getAttribute("title")||t.getAttribute("alt")||""}}}],toDOM:t=>["img",{...r.get(pl.key)(t),...t.attrs}],parseMarkdown:{match:({type:t})=>t==="image",runner:(t,e,n)=>{const i=e.url,l=e.alt,a=e.title;t.addNode(n,{src:i,alt:l,title:a})}},toMarkdown:{match:t=>t.type.name==="image",runner:(t,e)=>{t.addNode("image",void 0,void 0,{title:e.attrs.title,url:e.attrs.src,alt:e.attrs.alt})}}}));Y(x3.node,{displayName:"NodeSchema<image>",group:"Image"}),Y(x3.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const Qu=g2("InsertImage",r=>(t={})=>(e,n)=>{if(!n)return!0;const{src:i="",alt:l="",title:a=""}=t,o=x3.type(r).create({src:i,alt:l,title:a});return o&&n(e.tr.replaceSelectionWith(o).scrollIntoView()),!0});Y(Qu,{displayName:"Command<insertImageCommand>",group:"Image"});const bu=g2("UpdateImage",r=>(t={})=>(e,n)=>{const i=eb(e.selection,x3.type(r));if(!i)return!1;const{node:l,pos:a}=i,o={...l.attrs},{src:s,alt:c,title:u}=t;return s!==void 0&&(o.src=s),c!==void 0&&(o.alt=c),u!==void 0&&(o.title=u),n==null||n(e.tr.setNodeMarkup(a,void 0,o).scrollIntoView()),!0});Y(bu,{displayName:"Command<updateImageCommand>",group:"Image"});const yk=ot(r=>new lt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,e,n,i)=>{const[l,a,o="",s]=e;return l?t.tr.replaceWith(n,i,x3.type(r).create({src:o,alt:a,title:s})):null}));Y(yk,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const U5=st("hardbreak",r=>({"data-type":"hardbreak","data-is-inline":r.attrs.isInline}));Y(U5,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const U0=He("hardbreak",r=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",r.get(U5.key)(t)," "]:["br",r.get(U5.key)(t)],parseMarkdown:{match:({type:t})=>t==="break",runner:(t,e,n)=>{var i;t.addNode(n,{isInline:!!((i=e.data)!=null&&i.isInline)})}},leafText:()=>`
72
+ `))),0,0),r.someProp("transformPasted",d=>{o=d(o,r,!0)}),o;let A=r.someProp("clipboardTextParser",d=>d(t,i,n,r));if(A)o=A;else{let d=i.marks(),{schema:f}=r.state,h=A3.fromSchema(f);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let I=a.appendChild(document.createElement("p"));m&&I.appendChild(h.serializeNode(f.text(m,d)))})}}else r.someProp("transformPastedHTML",A=>{e=A(e,r)}),a=nS(e),j7&&rS(a);let c=a&&a.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let A=+u[3];A>0;A--){let d=a.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;a=d}if(o||(o=(r.someProp("clipboardParser")||r.someProp("domParser")||u3.fromSchema(r.state.schema)).parseSlice(a,{preserveWhitespace:!!(s||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$b.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)o=iS(E8(o,+u[1],+u[2]),u[4]);else if(o=J.maxOpen(eS(o.content,i),!0),o.openStart||o.openEnd){let A=0,d=0;for(let f=o.content.firstChild;A<o.openStart&&!f.type.spec.isolating;A++,f=f.firstChild);for(let f=o.content.lastChild;d<o.openEnd&&!f.type.spec.isolating;d++,f=f.lastChild);o=E8(o,A,d)}return r.someProp("transformPasted",A=>{o=A(o,r,s)}),o}const $b=/^(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 eS(r,t){if(r.childCount<2)return r;for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.index(e)),l,a=[];if(r.forEach(o=>{if(!a)return;let s=i.findWrapping(o.type),c;if(!s)return a=null;if(c=a.length&&l.length&&I8(s,l,o,a[a.length-1],0))a[a.length-1]=c;else{a.length&&(a[a.length-1]=C8(a[a.length-1],l.length));let u=m8(o,s);a.push(u),i=i.matchType(u.type),l=s}}),a)return j.from(a)}return r}function m8(r,t,e=0){for(let n=t.length-1;n>=e;n--)r=t[n].create(null,j.from(r));return r}function I8(r,t,e,n,i){if(i<r.length&&i<t.length&&r[i]==t[i]){let l=I8(r,t,e,n.lastChild,i+1);if(l)return n.copy(n.content.replaceChild(n.childCount-1,l));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?e.type:r[i+1]))return n.copy(n.content.append(j.from(m8(e,r,i+1))))}}function C8(r,t){if(t==0)return r;let e=r.content.replaceChild(r.childCount-1,C8(r.lastChild,t-1)),n=r.contentMatchAt(r.childCount).fillBefore(j.empty,!0);return r.copy(e.append(n))}function M9(r,t,e,n,i,l){let a=t<0?r.firstChild:r.lastChild,o=a.content;return r.childCount>1&&(l=0),i<n-1&&(o=M9(o,t,e,n,i+1,l)),i>=e&&(o=t<0?a.contentMatchAt(0).fillBefore(o,l<=i).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(j.empty,!0))),r.replaceChild(t<0?0:r.childCount-1,a.copy(o))}function E8(r,t,e){return t<r.openStart&&(r=new J(M9(r.content,-1,t,r.openStart,0,r.openEnd),t,r.openEnd)),e<r.openEnd&&(r=new J(M9(r.content,1,e,r.openEnd,0,0),r.openStart,e)),r}const M8={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let v8=null;function g8(){return v8||(v8=document.implementation.createHTMLDocument("title"))}let v9=null;function tS(r){let t=window.trustedTypes;return t?(v9||(v9=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),v9.createHTML(r)):r}function nS(r){let t=/^(\s*<meta [^>]*>)*/.exec(r);t&&(r=r.slice(t[0].length));let e=g8().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&M8[n[1].toLowerCase()])&&(r=i.map(l=>"<"+l+">").join("")+r+i.map(l=>"</"+l+">").reverse().join("")),e.innerHTML=tS(r),i)for(let l=0;l<i.length;l++)e=e.querySelector(i[l])||e;return e}function rS(r){let t=r.querySelectorAll(te?"span:not([class]):not([style])":"span.Apple-converted-space");for(let e=0;e<t.length;e++){let n=t[e];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function iS(r,t){if(!r.size)return r;let e=r.content.firstChild.type.schema,n;try{n=JSON.parse(t)}catch{return r}let{content:i,openStart:l,openEnd:a}=r;for(let o=n.length-2;o>=0;o-=2){let s=e.nodes[n[o]];if(!s||s.hasRequiredAttrs())break;i=j.from(s.create(n[o+1],i)),l++,a++}return new J(i,l,a)}const ue={},Ae={},lS={touchstart:!0,touchmove:!0};class aS{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 oS(r){for(let t in ue){let e=ue[t];r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>{cS(r,n)&&!z9(r,n)&&(r.editable||!(n.type in Ae))&&e(r,n)},lS[t]?{passive:!0}:void 0)}le&&r.dom.addEventListener("input",()=>null),g9(r)}function K1(r,t){r.input.lastSelectionOrigin=t,r.input.lastSelectionTime=Date.now()}function sS(r){r.domObserver.stop();for(let t in r.input.eventHandlers)r.dom.removeEventListener(t,r.input.eventHandlers[t]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function g9(r){r.someProp("handleDOMEvents",t=>{for(let e in t)r.input.eventHandlers[e]||r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>z9(r,n))})}function z9(r,t){return r.someProp("handleDOMEvents",e=>{let n=e[t.type];return n?n(r,t)||t.defaultPrevented:!1})}function cS(r,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target;e!=r.dom;e=e.parentNode)if(!e||e.nodeType==11||e.pmViewDesc&&e.pmViewDesc.stopEvent(t))return!1;return!0}function uS(r,t){!z9(r,t)&&ue[t.type]&&(r.editable||!(t.type in Ae))&&ue[t.type](r,t)}Ae.keydown=(r,t)=>{let e=t;if(r.input.shiftKey=e.keyCode==16||e.shiftKey,!Q8(r,e)&&(r.input.lastKeyCode=e.keyCode,r.input.lastKeyCodeTime=Date.now(),!(_t&&te&&e.keyCode==13)))if(e.keyCode!=229&&r.domObserver.forceFlush(),v3&&e.keyCode==13&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,g0(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,e))||_b(r,e)?e.preventDefault():K1(r,"key")},Ae.keyup=(r,t)=>{t.keyCode==16&&(r.input.shiftKey=!1)},Ae.keypress=(r,t)=>{let e=t;if(Q8(r,e)||!e.charCode||e.ctrlKey&&!e.altKey||Xe&&e.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,e))){e.preventDefault();return}let n=r.state.selection;if(!(n instanceof m2)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(e.charCode),l=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",a=>a(r,n.$from.pos,n.$to.pos,i,l))&&r.dispatch(l()),e.preventDefault()}};function s5(r){return{left:r.clientX,top:r.clientY}}function AS(r,t){let e=t.x-r.clientX,n=t.y-r.clientY;return e*e+n*n<100}function Q9(r,t,e,n,i){if(n==-1)return!1;let l=r.state.doc.resolve(n);for(let a=l.depth+1;a>0;a--)if(r.someProp(t,o=>a>l.depth?o(r,e,l.nodeAfter,l.before(a),i,!0):o(r,e,l.node(a),l.before(a),i,!1)))return!0;return!1}function Q3(r,t,e){if(r.focused||r.focus(),r.state.selection.eq(t))return;let n=r.state.tr.setSelection(t);n.setMeta("pointer",!0),r.dispatch(n)}function fS(r,t){if(t==-1)return!1;let e=r.state.doc.resolve(t),n=e.nodeAfter;return n&&n.isAtom&&i2.isSelectable(n)?(Q3(r,new i2(e)),!0):!1}function dS(r,t){if(t==-1)return!1;let e=r.state.selection,n,i;e instanceof i2&&(n=e.node);let l=r.state.doc.resolve(t);for(let a=l.depth+1;a>0;a--){let o=a>l.depth?l.nodeAfter:l.node(a);if(i2.isSelectable(o)){n&&e.$from.depth>0&&a>=e.$from.depth&&l.before(e.$from.depth+1)==e.$from.pos?i=l.before(e.$from.depth):i=l.before(a);break}}return i!=null?(Q3(r,i2.create(r.state.doc,i)),!0):!1}function hS(r,t,e,n,i){return Q9(r,"handleClickOn",t,e,n)||r.someProp("handleClick",l=>l(r,t,n))||(i?dS(r,e):fS(r,e))}function pS(r,t,e,n){return Q9(r,"handleDoubleClickOn",t,e,n)||r.someProp("handleDoubleClick",i=>i(r,t,n))}function mS(r,t,e,n){return Q9(r,"handleTripleClickOn",t,e,n)||r.someProp("handleTripleClick",i=>i(r,t,n))||IS(r,e,n)}function IS(r,t,e){if(e.button!=0)return!1;let n=r.state.doc;if(t==-1)return n.inlineContent?(Q3(r,m2.create(n,0,n.content.size)),!0):!1;let i=n.resolve(t);for(let l=i.depth+1;l>0;l--){let a=l>i.depth?i.nodeAfter:i.node(l),o=i.before(l);if(a.inlineContent)Q3(r,m2.create(n,o+1,o+1+a.content.size));else if(i2.isSelectable(a))Q3(r,i2.create(n,o));else continue;return!0}}function b9(r){return c5(r)}const z8=Xe?"metaKey":"ctrlKey";ue.mousedown=(r,t)=>{let e=t;r.input.shiftKey=e.shiftKey;let n=b9(r),i=Date.now(),l="singleClick";i-r.input.lastClick.time<500&&AS(e,r.input.lastClick)&&!e[z8]&&r.input.lastClick.button==e.button&&(r.input.lastClick.type=="singleClick"?l="doubleClick":r.input.lastClick.type=="doubleClick"&&(l="tripleClick")),r.input.lastClick={time:i,x:e.clientX,y:e.clientY,type:l,button:e.button};let a=r.posAtCoords(s5(e));a&&(l=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new CS(r,a,e,!!n)):(l=="doubleClick"?pS:mS)(r,a.pos,a.inside,e)?e.preventDefault():K1(r,"pointer"))};class CS{constructor(t,e,n,i){this.view=t,this.pos=e,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[z8],this.allowDefault=n.shiftKey;let l,a;if(e.inside>-1)l=t.state.doc.nodeAt(e.inside),a=e.inside;else{let u=t.state.doc.resolve(e.pos);l=u.parent,a=u.depth?u.before():0}const o=i?null:n.target,s=o?t.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=t.state;(n.button==0&&l.type.spec.draggable&&l.type.spec.selectable!==!1||c instanceof i2&&c.from<=a&&c.to>a)&&(this.mightDrag={node:l,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Pe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),K1(t,"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(()=>e1(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(s5(t))),this.updateAllowDefault(t),this.allowDefault||!e?K1(this.view,"pointer"):hS(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||le&&this.mightDrag&&!this.mightDrag.node.isAtom||te&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Q3(this.view,E2.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):K1(this.view,"pointer")}move(t){this.updateAllowDefault(t),K1(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}ue.touchstart=r=>{r.input.lastTouch=Date.now(),b9(r),K1(r,"pointer")},ue.touchmove=r=>{r.input.lastTouch=Date.now(),K1(r,"pointer")},ue.contextmenu=r=>b9(r);function Q8(r,t){return r.composing?!0:le&&Math.abs(t.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const ES=_t?5e3:-1;Ae.compositionstart=Ae.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:t}=r,e=t.selection.$to;if(t.selection instanceof m2&&(t.storedMarks||!e.textOffset&&e.parentOffset&&e.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||te&&Vc&&MS(r)))r.markCursor=r.state.storedMarks||e.marks(),c5(r,!0),r.markCursor=null;else if(c5(r,!t.selection.empty),Pe&&t.selection.empty&&e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,l=n.focusOffset;i&&i.nodeType==1&&l!=0;){let a=l<0?i.lastChild:i.childNodes[l-1];if(!a)break;if(a.nodeType==3){let o=r.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else i=a,l=-1}}r.input.composing=!0}b8(r,ES)};function MS(r){let{focusNode:t,focusOffset:e}=r.domSelectionRange();if(!t||t.nodeType!=1||e>=t.childNodes.length)return!1;let n=t.childNodes[e];return n.nodeType==1&&n.contentEditable=="false"}Ae.compositionend=(r,t)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=t.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,b8(r,20))};function b8(r,t){clearTimeout(r.input.composingTimeout),t>-1&&(r.input.composingTimeout=setTimeout(()=>c5(r),t))}function S8(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=gS());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function vS(r){let t=r.domSelectionRange();if(!t.focusNode)return null;let e=db(t.focusNode,t.focusOffset),n=hb(t.focusNode,t.focusOffset);if(e&&n&&e!=n){let i=n.pmViewDesc,l=r.domObserver.lastChangedTextNode;if(e==l||n==l)return l;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let a=e.pmViewDesc;if(!(!a||!a.isText(e.nodeValue)))return n}}return e||n}function gS(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function c5(r,t=!1){if(!(_t&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),S8(r),t||r.docView&&r.docView.dirty){let e=h9(r),n=r.state.selection;return e&&!e.eq(n)?r.dispatch(r.state.tr.setSelection(e)):(r.markCursor||t)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function zS(r,t){if(!r.dom.parentNode)return;let e=r.dom.parentNode.appendChild(document.createElement("div"));e.appendChild(t),e.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(t),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e),r.focus()},50)}const G7=Ee&&U1<15||v3&&Cb<604;ue.copy=Ae.cut=(r,t)=>{let e=t,n=r.state.selection,i=e.type=="cut";if(n.empty)return;let l=G7?null:e.clipboardData,a=n.content(),{dom:o,text:s}=E9(r,a);l?(e.preventDefault(),l.clearData(),l.setData("text/html",o.innerHTML),l.setData("text/plain",s)):zS(r,o),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function QS(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function bS(r,t){if(!r.dom.parentNode)return;let e=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(e?"textarea":"div"));e||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),e?H7(r,n.value,null,i,t):H7(r,n.textContent,n.innerHTML,i,t)},50)}function H7(r,t,e,n,i){let l=p8(r,t,e,n,r.state.selection.$from);if(r.someProp("handlePaste",s=>s(r,i,l||J.empty)))return!0;if(!l)return!1;let a=QS(l),o=a?r.state.tr.replaceSelectionWith(a,n):r.state.tr.replaceSelection(l);return r.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function k8(r){let t=r.getData("text/plain")||r.getData("Text");if(t)return t;let e=r.getData("text/uri-list");return e?e.replace(/\r?\n/g," "):""}Ae.paste=(r,t)=>{let e=t;if(r.composing&&!_t)return;let n=G7?null:e.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&H7(r,k8(n),n.getData("text/html"),i,e)?e.preventDefault():bS(r,e)};class y8{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const SS=Xe?"altKey":"ctrlKey";function R8(r,t){let e=r.someProp("dragCopies",n=>!n(t));return e??!t[SS]}ue.dragstart=(r,t)=>{let e=t,n=r.input.mouseDown;if(n&&n.done(),!e.dataTransfer)return;let i=r.state.selection,l=i.empty?null:r.posAtCoords(s5(e)),a;if(!(l&&l.pos>=i.from&&l.pos<=(i instanceof i2?i.to-1:i.to))){if(n&&n.mightDrag)a=i2.create(r.state.doc,n.mightDrag.pos);else if(e.target&&e.target.nodeType==1){let A=r.docView.nearestDesc(e.target,!0);A&&A.node.type.spec.draggable&&A!=r.docView&&(a=i2.create(r.state.doc,A.posBefore))}}let o=(a||r.state.selection).content(),{dom:s,text:c,slice:u}=E9(r,o);(!e.dataTransfer.files.length||!te||Yc>120)&&e.dataTransfer.clearData(),e.dataTransfer.setData(G7?"Text":"text/html",s.innerHTML),e.dataTransfer.effectAllowed="copyMove",G7||e.dataTransfer.setData("text/plain",c),r.dragging=new y8(u,R8(r,e),a)},ue.dragend=r=>{let t=r.dragging;window.setTimeout(()=>{r.dragging==t&&(r.dragging=null)},50)},Ae.dragover=Ae.dragenter=(r,t)=>t.preventDefault(),Ae.drop=(r,t)=>{try{kS(r,t,r.dragging)}finally{r.dragging=null}};function kS(r,t,e){if(!t.dataTransfer)return;let n=r.posAtCoords(s5(t));if(!n)return;let i=r.state.doc.resolve(n.pos),l=e&&e.slice;l?r.someProp("transformPasted",f=>{l=f(l,r,!1)}):l=p8(r,k8(t.dataTransfer),G7?null:t.dataTransfer.getData("text/html"),!1,i);let a=!!(e&&R8(r,t));if(r.someProp("handleDrop",f=>f(r,t,l||J.empty,a))){t.preventDefault();return}if(!l)return;t.preventDefault();let o=l?DM(r.state.doc,i.pos,l):i.pos;o==null&&(o=i.pos);let s=r.state.tr;if(a){let{node:f}=e;f?f.replace(s):s.deleteSelection()}let c=s.mapping.map(o),u=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,A=s.doc;if(u?s.replaceRangeWith(c,c,l.content.firstChild):s.replaceRange(c,c,l),s.doc.eq(A))return;let d=s.doc.resolve(c);if(u&&i2.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild))s.setSelection(new i2(d));else{let f=s.mapping.map(o);s.mapping.maps[s.mapping.maps.length-1].forEach((h,m,I,M)=>f=M),s.setSelection(m9(r,d,s.doc.resolve(f)))}r.focus(),r.dispatch(s.setMeta("uiEvent","drop"))}ue.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&e1(r)},20))},ue.blur=(r,t)=>{let e=t;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),e.relatedTarget&&r.dom.contains(e.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)},ue.beforeinput=(r,t)=>{if(te&&_t&&t.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",l=>l(r,g0(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in Ae)ue[r]=Ae[r];function J7(r,t){if(r==t)return!0;for(let e in r)if(r[e]!==t[e])return!1;for(let e in t)if(!(e in r))return!1;return!0}class u5{constructor(t,e){this.toDOM=t,this.spec=e||S0,this.side=this.spec.side||0}map(t,e,n,i){let{pos:l,deleted:a}=t.mapResult(e.from+i,this.side<0?-1:1);return a?null:new Ue(l-n,l-n,this)}valid(){return!0}eq(t){return this==t||t instanceof u5&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&J7(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class q1{constructor(t,e){this.attrs=t,this.spec=e||S0}map(t,e,n,i){let l=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-n,a=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-n;return l>=a?null:new Ue(l,a,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof q1&&J7(this.attrs,t.attrs)&&J7(this.spec,t.spec)}static is(t){return t.type instanceof q1}destroy(){}}class S9{constructor(t,e){this.attrs=t,this.spec=e||S0}map(t,e,n,i){let l=t.mapResult(e.from+i,1);if(l.deleted)return null;let a=t.mapResult(e.to+i,-1);return a.deleted||a.pos<=l.pos?null:new Ue(l.pos-n,a.pos-n,this)}valid(t,e){let{index:n,offset:i}=t.content.findIndex(e.from),l;return i==e.from&&!(l=t.child(n)).isText&&i+l.nodeSize==e.to}eq(t){return this==t||t instanceof S9&&J7(this.attrs,t.attrs)&&J7(this.spec,t.spec)}destroy(){}}class Ue{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new Ue(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Ue(t,t,new u5(e,n))}static inline(t,e,n,i){return new Ue(t,e,new q1(n,i))}static node(t,e,n,i){return new Ue(t,e,new S9(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof q1}get widget(){return this.type instanceof u5}}const b3=[],S0={};class X2{constructor(t,e){this.local=t.length?t:b3,this.children=e.length?e:b3}static create(t,e){return e.length?A5(e,t,0,S0):ae}find(t,e,n){let i=[];return this.findInner(t??0,e??1e9,i,0,n),i}findInner(t,e,n,i,l){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=e&&o.to>=t&&(!l||l(o.spec))&&n.push(o.copy(o.from+i,o.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){let o=this.children[a]+1;this.children[a+2].findInner(t-o,e-o,n,i+o,l)}}map(t,e,n){return this==ae||t.maps.length==0?this:this.mapInner(t,e,0,0,n||S0)}mapInner(t,e,n,i,l){let a;for(let o=0;o<this.local.length;o++){let s=this.local[o].map(t,n,i);s&&s.type.valid(e,s)?(a||(a=[])).push(s):l.onRemove&&l.onRemove(this.local[o].spec)}return this.children.length?yS(this.children,a||[],t,e,n,i,l):a?new X2(a.sort(k0),b3):ae}add(t,e){return e.length?this==ae?X2.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let i,l=0;t.forEach((o,s)=>{let c=s+n,u;if(u=x8(e,o,c)){for(i||(i=this.children.slice());l<i.length&&i[l]<s;)l+=3;i[l]==s?i[l+2]=i[l+2].addInner(o,u,c+1):i.splice(l,0,s,s+o.nodeSize,A5(u,o,c+1,S0)),l+=3}});let a=Z8(l?B8(e):e,-n);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||a.splice(o--,1);return new X2(a.length?this.local.concat(a).sort(k0):this.local,i||this.children)}remove(t){return t.length==0||this==ae?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,i=this.local;for(let l=0;l<n.length;l+=3){let a,o=n[l]+e,s=n[l+1]+e;for(let u=0,A;u<t.length;u++)(A=t[u])&&A.from>o&&A.to<s&&(t[u]=null,(a||(a=[])).push(A));if(!a)continue;n==this.children&&(n=this.children.slice());let c=n[l+2].removeInner(a,o+1);c!=ae?n[l+2]=c:(n.splice(l,3),l-=3)}if(i.length){for(let l=0,a;l<t.length;l++)if(a=t[l])for(let o=0;o<i.length;o++)i[o].eq(a,e)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new X2(i,n):ae}forChild(t,e){if(this==ae)return this;if(e.isLeaf)return X2.empty;let n,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}let l=t+1,a=l+e.content.size;for(let o=0;o<this.local.length;o++){let s=this.local[o];if(s.from<a&&s.to>l&&s.type instanceof q1){let c=Math.max(l,s.from)-l,u=Math.min(a,s.to)-l;c<u&&(i||(i=[])).push(s.copy(c,u))}}if(i){let o=new X2(i.sort(k0),b3);return n?new j1([o,n]):o}return n||ae}eq(t){if(this==t)return!0;if(!(t instanceof X2)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return k9(this.localsInner(t))}localsInner(t){if(this==ae)return b3;if(t.inlineContent||!this.local.some(q1.is))return this.local;let e=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof q1||e.push(this.local[n]);return e}forEachSet(t){t(this)}}X2.empty=new X2([],[]),X2.removeOverlap=k9;const ae=X2.empty;class j1{constructor(t){this.members=t}map(t,e){const n=this.members.map(i=>i.map(t,e,S0));return j1.from(n)}forChild(t,e){if(e.isLeaf)return X2.empty;let n=[];for(let i=0;i<this.members.length;i++){let l=this.members[i].forChild(t,e);l!=ae&&(l instanceof j1?n=n.concat(l.members):n.push(l))}return j1.from(n)}eq(t){if(!(t instanceof j1)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let i=0;i<this.members.length;i++){let l=this.members[i].localsInner(t);if(l.length)if(!e)e=l;else{n&&(e=e.slice(),n=!1);for(let a=0;a<l.length;a++)e.push(l[a])}}return e?k9(n?e:e.sort(k0)):b3}static from(t){switch(t.length){case 0:return ae;case 1:return t[0];default:return new j1(t.every(e=>e instanceof X2)?t:t.reduce((e,n)=>e.concat(n instanceof X2?n:n.members),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function yS(r,t,e,n,i,l,a){let o=r.slice();for(let c=0,u=l;c<e.maps.length;c++){let A=0;e.maps[c].forEach((d,f,h,m)=>{let I=m-h-(f-d);for(let M=0;M<o.length;M+=3){let k=o[M+1];if(k<0||d>k+u-A)continue;let S=o[M]+u-A;f>=S?o[M+1]=d<=S?-2:-1:d>=u&&I&&(o[M]+=I,o[M+1]+=I)}A+=I}),u=e.maps[c].map(u,-1)}let s=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){s=!0,o[c+1]=-1;continue}let u=e.map(r[c]+l),A=u-i;if(A<0||A>=n.content.size){s=!0;continue}let d=e.map(r[c+1]+l,-1),f=d-i,{index:h,offset:m}=n.content.findIndex(A),I=n.maybeChild(h);if(I&&m==A&&m+I.nodeSize==f){let M=o[c+2].mapInner(e,I,u+1,r[c]+l+1,a);M!=ae?(o[c]=A,o[c+1]=f,o[c+2]=M):(o[c+1]=-2,s=!0)}else s=!0}if(s){let c=RS(o,r,t,e,i,l,a),u=A5(c,n,0,a);t=u.local;for(let A=0;A<o.length;A+=3)o[A+1]<0&&(o.splice(A,3),A-=3);for(let A=0,d=0;A<u.children.length;A+=3){let f=u.children[A];for(;d<o.length&&o[d]<f;)d+=3;o.splice(d,0,u.children[A],u.children[A+1],u.children[A+2])}}return new X2(t.sort(k0),o)}function Z8(r,t){if(!t||!r.length)return r;let e=[];for(let n=0;n<r.length;n++){let i=r[n];e.push(new Ue(i.from+t,i.to+t,i.type))}return e}function RS(r,t,e,n,i,l,a){function o(s,c){for(let u=0;u<s.local.length;u++){let A=s.local[u].map(n,i,c);A?e.push(A):a.onRemove&&a.onRemove(s.local[u].spec)}for(let u=0;u<s.children.length;u+=3)o(s.children[u+2],s.children[u]+c+1)}for(let s=0;s<r.length;s+=3)r[s+1]==-1&&o(r[s+2],t[s]+l+1);return e}function x8(r,t,e){if(t.isLeaf)return null;let n=e+t.nodeSize,i=null;for(let l=0,a;l<r.length;l++)(a=r[l])&&a.from>e&&a.to<n&&((i||(i=[])).push(a),r[l]=null);return i}function B8(r){let t=[];for(let e=0;e<r.length;e++)r[e]!=null&&t.push(r[e]);return t}function A5(r,t,e,n){let i=[],l=!1;t.forEach((o,s)=>{let c=x8(r,o,s+e);if(c){l=!0;let u=A5(c,o,e+s+1,n);u!=ae&&i.push(s,s+o.nodeSize,u)}});let a=Z8(l?B8(r):r,-e).sort(k0);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||(n.onRemove&&n.onRemove(a[o].spec),a.splice(o--,1));return a.length||i.length?new X2(a,i):ae}function k0(r,t){return r.from-t.from||r.to-t.to}function k9(r){let t=r;for(let e=0;e<t.length-1;e++){let n=t[e];if(n.from!=n.to)for(let i=e+1;i<t.length;i++){let l=t[i];if(l.from==n.from){l.to!=n.to&&(t==r&&(t=r.slice()),t[i]=l.copy(l.from,n.to),U8(t,i+1,l.copy(n.to,l.to)));continue}else{l.from<n.to&&(t==r&&(t=r.slice()),t[e]=n.copy(n.from,l.from),U8(t,i,n.copy(l.from,n.to)));break}}}return t}function U8(r,t,e){for(;t<r.length&&k0(e,r[t])>0;)t++;r.splice(t,0,e)}function y9(r){let t=[];return r.someProp("decorations",e=>{let n=e(r.state);n&&n!=ae&&t.push(n)}),r.cursorWrapper&&t.push(X2.create(r.state.doc,[r.cursorWrapper.deco])),j1.from(t)}const ZS={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xS=Ee&&U1<=11;class BS{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class US{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new BS,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);Ee&&U1<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():le&&t.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),xS&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,ZS)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(o8(this.view)){if(this.suppressingSelectionUpdates)return e1(this.view);if(Ee&&U1<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&v0(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e=new Set,n;for(let l=t.focusNode;l;l=M3(l))e.add(l);for(let l=t.anchorNode;l;l=M3(l))if(e.has(l)){n=l;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&o8(t)&&!this.ignoreSelectionChange(n),l=-1,a=-1,o=!1,s=[];if(t.editable)for(let u=0;u<e.length;u++){let A=this.registerMutation(e[u],s);A&&(l=l<0?A.from:Math.min(A.from,l),a=a<0?A.to:Math.max(A.to,a),A.typeOver&&(o=!0))}if(s.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46)){for(let u of s)if(u.nodeName=="BR"&&u.parentNode){let A=u.nextSibling;for(;A&&A.nodeType==1;){if(A.contentEditable=="false"){u.parentNode.removeChild(u);break}A=A.firstChild}}}else if(Pe&&s.length){let u=s.filter(A=>A.nodeName=="BR");if(u.length==2){let[A,d]=u;A.parentNode&&A.parentNode.parentNode==d.parentNode?d.remove():A.remove()}else{let{focusNode:A}=this.currentSelection;for(let d of u){let f=d.parentNode;f&&f.nodeName=="LI"&&(!A||OS(t,A)!=f)&&d.remove()}}}let c=null;l<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&i5(n)&&(c=h9(t))&&c.eq(E2.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,e1(t),this.currentSelection.set(n),t.scrollToSelection()):(l>-1||i)&&(l>-1&&(t.docView.markDirty(l,a),YS(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,KS(t,s)),this.handleDOMChange(l,a,o,s),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||e1(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;u<t.addedNodes.length;u++){let A=t.addedNodes[u];e.push(A),A.nodeType==3&&(this.lastChangedTextNode=A)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let i=t.previousSibling,l=t.nextSibling;if(Ee&&U1<=11&&t.addedNodes.length)for(let u=0;u<t.addedNodes.length;u++){let{previousSibling:A,nextSibling:d}=t.addedNodes[u];(!A||Array.prototype.indexOf.call(t.addedNodes,A)<0)&&(i=A),(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(l=d)}let a=i&&i.parentNode==t.target?ee(i)+1:0,o=n.localPosFromDOM(t.target,a,-1),s=l&&l.parentNode==t.target?ee(l):t.target.childNodes.length,c=n.localPosFromDOM(t.target,s,1);return{from:o,to:c}}else return t.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Y8=new WeakMap,V8=!1;function YS(r){if(!Y8.has(r)&&(Y8.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=Pe,V8)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."),V8=!0}}function O8(r,t){let e=t.startContainer,n=t.startOffset,i=t.endContainer,l=t.endOffset,a=r.domAtPos(r.state.selection.anchor);return v0(a.node,a.offset,i,l)&&([e,n,i,l]=[i,l,e,n]),{anchorNode:e,anchorOffset:n,focusNode:i,focusOffset:l}}function VS(r,t){if(t.getComposedRanges){let i=t.getComposedRanges(r.root)[0];if(i)return O8(r,i)}let e;function n(i){i.preventDefault(),i.stopImmediatePropagation(),e=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),e?O8(r,e):null}function OS(r,t){for(let e=t.parentNode;e&&e!=r.dom;e=e.parentNode){let n=r.docView.nearestDesc(e,!0);if(n&&n.node.isBlock)return e}return null}function KS(r,t){var e;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let l of t)if(((e=l.parentNode)===null||e===void 0?void 0:e.nodeName)=="TR"){let a=l.nextSibling;for(;a&&a.nodeName!="TD"&&a.nodeName!="TH";)a=a.nextSibling;if(a){let o=a;for(;;){let s=o.firstChild;if(!s||s.nodeType!=1||s.contentEditable=="false"||/^(BR|IMG)$/.test(s.nodeName))break;o=s}o.insertBefore(l,o.firstChild),n==l&&r.domSelection().collapse(l,i)}else l.parentNode.removeChild(l)}}function qS(r,t,e){let{node:n,fromOffset:i,toOffset:l,from:a,to:o}=r.docView.parseRange(t,e),s=r.domSelectionRange(),c,u=s.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:s.anchorOffset}],i5(s)||c.push({node:s.focusNode,offset:s.focusOffset})),te&&r.input.lastKeyCode===8)for(let I=l;I>i;I--){let M=n.childNodes[I-1],k=M.pmViewDesc;if(M.nodeName=="BR"&&!k){l=I;break}if(!k||k.size)break}let A=r.state.doc,d=r.someProp("domParser")||u3.fromSchema(r.state.schema),f=A.resolve(a),h=null,m=d.parse(n,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:l,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:jS,context:f});if(c&&c[0].pos!=null){let I=c[0].pos,M=c[1]&&c[1].pos;M==null&&(M=I),h={anchor:I+a,head:M+a}}return{doc:m,sel:h,from:a,to:o}}function jS(r){let t=r.pmViewDesc;if(t)return t.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(le&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(r.parentNode.lastChild==r||le&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const TS=/^(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 WS(r,t,e,n,i){let l=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,t<0){let y=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,R=h9(r,y);if(R&&!r.state.selection.eq(R)){if(te&&_t&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",T=>T(r,g0(13,"Enter"))))return;let Z=r.state.tr.setSelection(R);y=="pointer"?Z.setMeta("pointer",!0):y=="key"&&Z.scrollIntoView(),l&&Z.setMeta("composition",l),r.dispatch(Z)}return}let a=r.state.doc.resolve(t),o=a.sharedDepth(e);t=a.before(o+1),e=r.state.doc.resolve(e).after(o+1);let s=r.state.selection,c=qS(r,t,e),u=r.state.doc,A=u.slice(c.from,c.to),d,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(d=r.state.selection.to,f="end"):(d=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let h=GS(A.content,c.doc.content,c.from,d,f);if(h&&r.input.domChangeCount++,(v3&&r.input.lastIOSEnter>Date.now()-225||_t)&&i.some(y=>y.nodeType==1&&!TS.test(y.nodeName))&&(!h||h.endA>=h.endB)&&r.someProp("handleKeyDown",y=>y(r,g0(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!h)if(n&&s instanceof m2&&!s.empty&&s.$head.sameParent(s.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:s.from,endA:s.to,endB:s.to};else{if(c.sel){let y=K8(r,r.state.doc,c.sel);if(y&&!y.eq(r.state.selection)){let R=r.state.tr.setSelection(y);l&&R.setMeta("composition",l),r.dispatch(R)}}return}r.state.selection.from<r.state.selection.to&&h.start==h.endB&&r.state.selection instanceof m2&&(h.start>r.state.selection.from&&h.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?h.start=r.state.selection.from:h.endA<r.state.selection.to&&h.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(h.endB+=r.state.selection.to-h.endA,h.endA=r.state.selection.to)),Ee&&U1<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),I=c.doc.resolveNoCache(h.endB-c.from),M=u.resolve(h.start),k=m.sameParent(I)&&m.parent.inlineContent&&M.end()>=h.endA;if((v3&&r.input.lastIOSEnter>Date.now()-225&&(!k||i.some(y=>y.nodeName=="DIV"||y.nodeName=="P"))||!k&&m.pos<c.doc.content.size&&(!m.sameParent(I)||!m.parent.inlineContent)&&m.pos<I.pos&&!/\S/.test(c.doc.textBetween(m.pos,I.pos,"","")))&&r.someProp("handleKeyDown",y=>y(r,g0(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>h.start&&XS(u,h.start,h.endA,m,I)&&r.someProp("handleKeyDown",y=>y(r,g0(8,"Backspace")))){_t&&te&&r.domObserver.suppressSelectionUpdates();return}te&&h.endB==h.start&&(r.input.lastChromeDelete=Date.now()),_t&&!k&&m.start()!=I.start()&&I.parentOffset==0&&m.depth==I.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,I=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(y){return y(r,g0(13,"Enter"))})},20));let S=h.start,B=h.endA,K=y=>{let R=y||r.state.tr.replace(S,B,c.doc.slice(h.start-c.from,h.endB-c.from));if(c.sel){let Z=K8(r,R.doc,c.sel);Z&&!(te&&r.composing&&Z.empty&&(h.start!=h.endB||r.input.lastChromeDelete<Date.now()-100)&&(Z.head==S||Z.head==R.mapping.map(B)-1)||Ee&&Z.empty&&Z.head==S)&&R.setSelection(Z)}return l&&R.setMeta("composition",l),R.scrollIntoView()},b;if(k)if(m.pos==I.pos){Ee&&U1<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>e1(r),20));let y=K(r.state.tr.delete(S,B)),R=u.resolve(h.start).marksAcross(u.resolve(h.endA));R&&y.ensureMarks(R),r.dispatch(y)}else if(h.endA==h.endB&&(b=PS(m.parent.content.cut(m.parentOffset,I.parentOffset),M.parent.content.cut(M.parentOffset,h.endA-M.start())))){let y=K(r.state.tr);b.type=="add"?y.addMark(S,B,b.mark):y.removeMark(S,B,b.mark),r.dispatch(y)}else if(m.parent.child(m.index()).isText&&m.index()==I.index()-(I.textOffset?0:1)){let y=m.parent.textBetween(m.parentOffset,I.parentOffset),R=()=>K(r.state.tr.insertText(y,S,B));r.someProp("handleTextInput",Z=>Z(r,S,B,y,R))||r.dispatch(R())}else r.dispatch(K());else r.dispatch(K())}function K8(r,t,e){return Math.max(e.anchor,e.head)>t.content.size?null:m9(r,t.resolve(e.anchor),t.resolve(e.head))}function PS(r,t){let e=r.firstChild.marks,n=t.firstChild.marks,i=e,l=n,a,o,s;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<e.length;u++)l=e[u].removeFromSet(l);if(i.length==1&&l.length==0)o=i[0],a="add",s=u=>u.mark(o.addToSet(u.marks));else if(i.length==0&&l.length==1)o=l[0],a="remove",s=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<t.childCount;u++)c.push(s(t.child(u)));if(j.from(c).eq(r))return{mark:o,type:a}}function XS(r,t,e,n,i){if(e-t<=i.pos-n.pos||R9(n,!0,!1)<i.pos)return!1;let l=r.resolve(t);if(!n.parent.isTextblock){let o=l.nodeAfter;return o!=null&&e==t+o.nodeSize}if(l.parentOffset<l.parent.content.size||!l.parent.isTextblock)return!1;let a=r.resolve(R9(l,!0,!0));return!a.parent.isTextblock||a.pos>e||R9(a,!0,!1)<e?!1:n.parent.content.cut(n.parentOffset).eq(a.parent.content)}function R9(r,t,e){let n=r.depth,i=t?r.end():r.pos;for(;n>0&&(t||r.indexAfter(n)==r.node(n).childCount);)n--,i++,t=!1;if(e){let l=r.node(n).maybeChild(r.indexAfter(n));for(;l&&!l.isLeaf;)l=l.firstChild,i++}return i}function GS(r,t,e,n,i){let l=r.findDiffStart(t,e);if(l==null)return null;let{a,b:o}=r.findDiffEnd(t,e+r.size,e+t.size);if(i=="end"){let s=Math.max(0,l-Math.min(a,o));n-=a+s-l}if(a<l&&r.size<t.size){let s=n<=l&&n>=a?l-n:0;l-=s,l&&l<t.size&&q8(t.textBetween(l-1,l+1))&&(l+=s?1:-1),o=l+(o-a),a=l}else if(o<l){let s=n<=l&&n>=o?l-n:0;l-=s,l&&l<r.size&&q8(r.textBetween(l-1,l+1))&&(l+=s?1:-1),a=l+(a-o),o=l}return{start:l,endA:a,endB:o}}function q8(r){if(r.length!=2)return!1;let t=r.charCodeAt(0),e=r.charCodeAt(1);return t>=56320&&t<=57343&&e>=55296&&e<=56319}class j8{constructor(t,e){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 aS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(G8),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=P8(this),W8(this),this.nodeViews=X8(this),this.docView=Nc(this.state.doc,T8(this),y9(this),this.dom,this),this.domObserver=new US(this,(n,i,l,a)=>WS(this,n,i,l,a)),this.domObserver.start(),oS(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&g9(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(G8),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let n in this._props)e[n]=this._props[n];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let i=this.state,l=!1,a=!1;t.storedMarks&&this.composing&&(S8(this),a=!0),this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let f=X8(this);JS(f,this.nodeViews)&&(this.nodeViews=f,l=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&g9(this),this.editable=P8(this),W8(this);let s=y9(this),c=T8(this),u=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve",A=l||!this.docView.matchesNode(t.doc,c,s);(A||!t.selection.eq(i.selection))&&(a=!0);let d=u=="preserve"&&a&&this.dom.style.overflowAnchor==null&&vb(this);if(a){this.domObserver.stop();let f=A&&(Ee||te)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&HS(i.selection,t.selection);if(A){let h=te?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vS(this)),(l||!this.docView.update(t.doc,c,s,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Nc(t.doc,c,s,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hb(this))?e1(this,f):(l8(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&gb(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof i2){let e=this.docView.domAfterPos(this.state.selection.from);e.nodeType==1&&Oc(this,e.getBoundingClientRect(),t)}else Oc(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let n=this.directPlugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let n=this.state.plugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}}updateDraggedNode(t,e){let n=t.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let l=n.from+(this.state.doc.content.size-e.doc.content.size);(l>0&&l<this.state.doc.content.size&&this.state.doc.nodeAt(l))==n.node&&(i=l)}this.dragging=new y8(t.slice,t.move,i<0?void 0:i2.create(this.state.doc,i))}someProp(t,e){let n=this._props&&this._props[t],i;if(n!=null&&(i=e?e(n):n))return i;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[t];if(o!=null&&(i=e?e(o):o))return i}let l=this.state.plugins;if(l)for(let a=0;a<l.length;a++){let o=l[a].props[t];if(o!=null&&(i=e?e(o):o))return i}}hasFocus(){if(Ee){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&zb(this.dom),e1(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(t){return yb(this,t)}coordsAtPos(t,e=1){return Pc(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let i=this.docView.posFromDOM(t,e,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return Ub(this,e||this.state,t)}pasteHTML(t,e){return H7(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return H7(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return E9(this,t)}destroy(){this.docView&&(sS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],y9(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ab())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return uS(this,t)}domSelectionRange(){let t=this.domSelection();return t?le&&this.root.nodeType===11&&mb(this.dom.ownerDocument)==this.dom&&VS(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}j8.prototype.dispatch=function(r){let t=this._props.dispatchTransaction;t?t.call(this,r):this.updateState(this.state.apply(r))};function T8(r){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(r.editable),r.someProp("attributes",e=>{if(typeof e=="function"&&(e=e(r.state)),e)for(let n in e)n=="class"?t.class+=" "+e[n]:n=="style"?t.style=(t.style?t.style+";":"")+e[n]:!t[n]&&n!="contenteditable"&&n!="nodeName"&&(t[n]=String(e[n]))}),t.translate||(t.translate="no"),[Ue.node(0,r.state.doc.content.size,t)]}function W8(r){if(r.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),r.cursorWrapper={dom:t,deco:Ue.widget(r.state.selection.from,t,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function P8(r){return!r.someProp("editable",t=>t(r.state)===!1)}function HS(r,t){let e=Math.min(r.$anchor.sharedDepth(r.head),t.$anchor.sharedDepth(t.head));return r.$anchor.start(e)!=t.$anchor.start(e)}function X8(r){let t=Object.create(null);function e(n){for(let i in n)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=n[i])}return r.someProp("nodeViews",e),r.someProp("markViews",e),t}function JS(r,t){let e=0,n=0;for(let i in r){if(r[i]!=t[i])return!0;e++}for(let i in t)n++;return e!=n}function G8(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function t1(r,t){return r.meta={package:"@milkdown/core",group:"System",...t},r}const H8={text:(r,t,e,n)=>{const i=r.value;return/^[^*_\\]*\s+$/.test(i)?i:e.safe(i,{...n,encode:[]})},strong:(r,t,e,n)=>{const i=r.marker||e.options.strong||"*",l=e.enter("strong"),a=e.createTracker(n);let o=a.move(i+i);return o+=a.move(e.containerPhrasing(r,{before:o,after:i,...a.current()})),o+=a.move(i+i),l(),o},emphasis:(r,t,e,n)=>{const i=r.marker||e.options.emphasis||"*",l=e.enter("emphasis"),a=e.createTracker(n);let o=a.move(i);return o+=a.move(e.containerPhrasing(r,{before:o,after:i,...a.current()})),o+=a.move(i),l(),o}},fe=d2({},"editorView"),F7=d2({},"editorState"),Z9=d2([],"initTimer"),J8=d2({},"editor"),w7=d2([],"inputRules"),n1=d2([],"prosePlugins"),N7=d2([],"remarkPlugins"),x9=d2([],"nodeView"),B9=d2([],"markView"),y0=d2(Hi().use(Ri).use(Oi),"remark"),D7=d2({handlers:H8,encode:[]},"remarkStringifyOptions"),f5=kt("ConfigReady");function FS(r){const t=e=>(e.record(f5),async()=>(await r(e),e.done(f5),()=>{e.clearTimer(f5)}));return t1(t,{displayName:"Config"}),t}const R0=kt("InitReady");function wS(r){const t=e=>(e.inject(J8,r).inject(n1,[]).inject(N7,[]).inject(w7,[]).inject(x9,[]).inject(B9,[]).inject(D7,{handlers:H8,encode:[]}).inject(y0,Hi().use(Ri).use(Oi)).inject(Z9,[f5]).record(R0),async()=>{await e.waitTimers(Z9);const n=e.get(D7);return e.set(y0,Hi().use(Ri).use(Oi,n)),e.done(R0),()=>{e.remove(J8).remove(n1).remove(N7).remove(w7).remove(x9).remove(B9).remove(D7).remove(y0).remove(Z9).clearTimer(R0)}});return t1(t,{displayName:"Init"}),t}const Ye=kt("SchemaReady"),U9=d2([],"schemaTimer"),r1=d2({},"schema"),L7=d2([],"nodes"),_7=d2([],"marks");function F8(r){var t;return{...r,parseDOM:(t=r.parseDOM)==null?void 0:t.map(e=>({priority:r.priority,...e}))}}const w8=r=>(r.inject(r1,{}).inject(L7,[]).inject(_7,[]).inject(U9,[R0]).record(Ye),async()=>{await r.waitTimers(U9);const t=r.get(y0),n=r.get(N7).reduce((o,s)=>o.use(s.plugin,s.options),t);r.set(y0,n);const i=Object.fromEntries(r.get(L7).map(([o,s])=>[o,F8(s)])),l=Object.fromEntries(r.get(_7).map(([o,s])=>[o,F8(s)])),a=new bM({nodes:i,marks:l});return r.set(r1,a),r.done(Ye),()=>{r.remove(r1).remove(L7).remove(_7).remove(U9).clearTimer(Ye)}});t1(w8,{displayName:"Schema"});class N8{constructor(){o2(this,K0);o2(this,we);N(this,K0,new Eo),N(this,we,null),this.setCtx=t=>{N(this,we,t)},this.chain=()=>{if(U(this,we)==null)throw N4();const t=U(this,we),e=[],n=this.get.bind(this),i={run:()=>{const a=m3(...e),o=t.get(fe);return a(o.state,o.dispatch,o)},inline:a=>(e.push(a),i),pipe:l.bind(this)};function l(a,o){const s=n(a);return e.push(s(o)),i}return i}}get ctx(){return U(this,we)}create(t,e){const n=t.create(U(this,K0).sliceMap);return n.set(e),n}get(t){return U(this,K0).get(t).get()}remove(t){return U(this,K0).remove(t)}call(t,e){if(U(this,we)==null)throw N4();const i=this.get(t)(e),l=U(this,we).get(fe);return i(l.state,l.dispatch,l)}inline(t){if(U(this,we)==null)throw N4();const e=U(this,we).get(fe);return t(e.state,e.dispatch,e)}}K0=new WeakMap,we=new WeakMap;function NS(r="cmdKey"){return d2((()=>()=>!1),r)}const b2=d2(new N8,"commands"),Y9=d2([Ye],"commandsTimer"),$7=kt("CommandsReady"),D8=r=>{const t=new N8;return t.setCtx(r),r.inject(b2,t).inject(Y9,[Ye]).record($7),async()=>(await r.waitTimers(Y9),r.done($7),()=>{r.remove(b2).remove(Y9).clearTimer($7)})};t1(D8,{displayName:"Commands"});function DS(r){const t=m3(DQ,di,sv,Cs);return r.Backspace=t,r}class L8{constructor(){o2(this,q0);o2(this,Me);N(this,q0,null),N(this,Me,[]),this.setCtx=t=>{N(this,q0,t)},this.add=t=>(U(this,Me).push(t),()=>{N(this,Me,U(this,Me).filter(e=>e!==t))}),this.addObjectKeymap=t=>{const e=[];return Object.entries(t).forEach(([n,i])=>{if(typeof i=="function"){const l={key:n,onRun:()=>i};U(this,Me).push(l),e.push(()=>{N(this,Me,U(this,Me).filter(a=>a!==l))})}else U(this,Me).push(i),e.push(()=>{N(this,Me,U(this,Me).filter(l=>l!==i))})}),()=>{e.forEach(n=>n())}},this.addBaseKeymap=()=>{const t=DS(Qv);return this.addObjectKeymap(t)},this.build=()=>{const t={};return U(this,Me).forEach(n=>{t[n.key]=[...t[n.key]||[],n]}),Object.fromEntries(Object.entries(t).map(([n,i])=>{const l=i.sort((o,s)=>(s.priority??50)-(o.priority??50));return[n,(o,s,c)=>{const u=U(this,q0);if(u==null)throw Sr();const A=l.map(f=>f.onRun(u));return m3(...A)(o,s,c)}]}))}}get ctx(){return U(this,q0)}}q0=new WeakMap,Me=new WeakMap;const d5=d2(new L8,"keymap"),V9=d2([Ye],"keymapTimer"),en=kt("KeymapReady"),LS=r=>{const t=new L8;return t.setCtx(r),r.inject(d5,t).inject(V9,[Ye]).record(en),async()=>(await r.waitTimers(V9),r.done(en),()=>{r.remove(d5).remove(V9).clearTimer(en)})},h5=kt("ParserReady"),_8=(()=>{throw Sr()}),tn=d2(_8,"parser"),O9=d2([],"parserTimer"),$8=r=>(r.inject(tn,_8).inject(O9,[Ye]).record(h5),async()=>{await r.waitTimers(O9);const t=r.get(y0),e=r.get(r1);return r.set(tn,JQ.create(e,t)),r.done(h5),()=>{r.remove(tn).remove(O9).clearTimer(h5)}});t1($8,{displayName:"Parser"});const nn=kt("SerializerReady"),K9=d2([],"serializerTimer"),eu=(()=>{throw Sr()}),p5=d2(eu,"serializer"),tu=r=>(r.inject(p5,eu).inject(K9,[Ye]).record(nn),async()=>{await r.waitTimers(K9);const t=r.get(y0),e=r.get(r1);return r.set(p5,wQ.create(e,t)),r.done(nn),()=>{r.remove(p5).remove(K9).clearTimer(nn)}});t1(tu,{displayName:"Serializer"});const m5=d2("","defaultValue"),I5=d2(r=>r,"stateOptions"),q9=d2([],"editorStateTimer"),C5=kt("EditorStateReady");function _S(r,t,e){if(typeof r=="string")return t(r);if(r.type==="html")return u3.fromSchema(e).parse(r.dom);if(r.type==="json")return Ft.fromJSON(e,r.value);throw NE(r)}const $S=new rt("MILKDOWN_STATE_TRACKER"),nu=r=>(r.inject(m5,"").inject(F7,{}).inject(I5,t=>t).inject(q9,[h5,nn,$7,en]).record(C5),async()=>{await r.waitTimers(q9);const t=r.get(r1),e=r.get(tn),n=r.get(w7),i=r.get(I5),l=r.get(n1),a=r.get(m5),o=_S(a,e,t),s=r.get(d5),c=s.addBaseKeymap(),u=[...l,new nt({key:$S,state:{init:()=>{},apply:(f,h,m,I)=>{r.set(F7,I)}}}),_Q({rules:n}),cb(s.build())];r.set(n1,u);const A=i({schema:t,doc:o,plugins:u}),d=I0.create(A);return r.set(F7,d),r.done(C5),()=>{c(),r.remove(m5).remove(F7).remove(I5).remove(q9).clearTimer(C5)}});t1(nu,{displayName:"EditorState"});const j9=d2([],"pasteRule"),T9=d2([Ye],"pasteRuleTimer"),E5=kt("PasteRuleReady"),ru=r=>(r.inject(j9,[]).inject(T9,[Ye]).record(E5),async()=>(await r.waitTimers(T9),r.done(E5),()=>{r.remove(j9).remove(T9).clearTimer(E5)}));t1(ru,{displayName:"PasteRule"});const M5=kt("EditorViewReady"),W9=d2([],"editorViewTimer"),v5=d2({},"editorViewOptions"),g5=d2(null,"root"),P9=d2(null,"rootDOM"),X9=d2({},"rootAttrs");function ek(r,t){const e=document.createElement("div");e.className="milkdown",r.appendChild(e),t.set(P9,e);const n=t.get(X9);return Object.entries(n).forEach(([i,l])=>e.setAttribute(i,l)),e}function tk(r){r.classList.add("editor"),r.setAttribute("role","textbox")}const nk=new rt("MILKDOWN_VIEW_CLEAR"),iu=r=>(r.inject(g5,document.body).inject(fe,{}).inject(v5,{}).inject(P9,null).inject(X9,{}).inject(W9,[C5,E5]).record(M5),async()=>{await r.wait(R0);const t=r.get(g5)||document.body,e=typeof t=="string"?document.querySelector(t):t;r.update(n1,s=>[new nt({key:nk,view:c=>{const u=e?ek(e,r):void 0;return(()=>{if(u&&e){const d=c.dom;e.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(c.dom,u)),u==null||u.remove()}}}}),...s]),await r.waitTimers(W9);const n=r.get(F7),i=r.get(v5),l=Object.fromEntries(r.get(x9)),a=Object.fromEntries(r.get(B9)),o=new j8(e,{state:n,nodeViews:l,markViews:a,transformPasted:(s,c,u)=>(r.get(j9).sort((A,d)=>(d.priority??50)-(A.priority??50)).map(A=>A.run).forEach(A=>{s=A(s,c,u)}),s),...i});return tk(o.dom),r.set(fe,o),r.done(M5),()=>{o==null||o.destroy(),r.remove(g5).remove(fe).remove(v5).remove(P9).remove(X9).remove(W9).clearTimer(M5)}});t1(iu,{displayName:"EditorView"});const Pl=class Pl{constructor(){o2(this,j0);o2(this,Ve);o2(this,u1);o2(this,J3);o2(this,En);o2(this,Mn);o2(this,ve);o2(this,A1);o2(this,T0);o2(this,vn);o2(this,W0);o2(this,F3);o2(this,gn);o2(this,H1);o2(this,w3);N(this,j0,!1),N(this,Ve,"Idle"),N(this,u1,[]),N(this,J3,()=>{}),N(this,En,new Eo),N(this,Mn,new aM),N(this,ve,new Map),N(this,A1,new Map),N(this,T0,new D4(U(this,En),U(this,Mn))),N(this,vn,()=>{const t=FS(async n=>{await Promise.all(U(this,u1).map(i=>Promise.resolve(i(n))))}),e=[w8,$8,tu,D8,LS,ru,nu,iu,wS(this),t];U(this,W0).call(this,e,U(this,A1))}),N(this,W0,(t,e)=>{t.forEach(n=>{const i=U(this,T0).produce(U(this,j0)?n.meta:void 0),l=n(i);e.set(n,{ctx:i,handler:l,cleanup:void 0})})}),N(this,F3,(t,e=!1)=>Promise.all([t].flat().map(async n=>{const i=U(this,ve).get(n),l=i==null?void 0:i.cleanup;return e?U(this,ve).delete(n):U(this,ve).set(n,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof l=="function"?l():l}))),N(this,gn,async()=>{await Promise.all([...U(this,A1).entries()].map(async([t,{cleanup:e}])=>typeof e=="function"?e():e)),U(this,A1).clear()}),N(this,H1,t=>{N(this,Ve,t),U(this,J3).call(this,t)}),N(this,w3,t=>[...t.entries()].map(async([e,n])=>{const{ctx:i,handler:l}=n;if(!l)return;const a=await l();t.set(e,{ctx:i,handler:l,cleanup:a})})),this.enableInspector=(t=!0)=>(N(this,j0,t),this),this.onStatusChange=t=>(N(this,J3,t),this),this.config=t=>(U(this,u1).push(t),this),this.removeConfig=t=>(N(this,u1,U(this,u1).filter(e=>e!==t)),this),this.use=t=>{const e=[t].flat();return e.flat().forEach(n=>{U(this,ve).set(n,{ctx:void 0,handler:void 0,cleanup:void 0})}),U(this,Ve)==="Created"&&U(this,W0).call(this,e,U(this,ve)),this},this.remove=async t=>U(this,Ve)==="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(e=>{setTimeout(()=>{e(this.remove(t))},50)})):(await U(this,F3).call(this,[t].flat(),!0),this),this.create=async()=>U(this,Ve)==="OnCreate"?this:(U(this,Ve)==="Created"&&await this.destroy(),U(this,H1).call(this,"OnCreate"),U(this,vn).call(this),U(this,W0).call(this,[...U(this,ve).keys()],U(this,ve)),await Promise.all([U(this,w3).call(this,U(this,A1)),U(this,w3).call(this,U(this,ve))].flat()),U(this,H1).call(this,"Created"),this),this.destroy=async(t=!1)=>U(this,Ve)==="Destroyed"||U(this,Ve)==="OnDestroy"?this:U(this,Ve)==="OnCreate"?new Promise(e=>{setTimeout(()=>{e(this.destroy(t))},50)}):(t&&N(this,u1,[]),U(this,H1).call(this,"OnDestroy"),await U(this,F3).call(this,[...U(this,ve).keys()],t),await U(this,gn).call(this),U(this,H1).call(this,"Destroyed"),this),this.action=t=>t(U(this,T0)),this.inspect=()=>U(this,j0)?[...U(this,A1).values(),...U(this,ve).values()].map(({ctx:t})=>{var e;return(e=t==null?void 0:t.inspector)==null?void 0:e.read()}).filter(t=>!!t):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Pl}get ctx(){return U(this,T0)}get status(){return U(this,Ve)}};j0=new WeakMap,Ve=new WeakMap,u1=new WeakMap,J3=new WeakMap,En=new WeakMap,Mn=new WeakMap,ve=new WeakMap,A1=new WeakMap,T0=new WeakMap,vn=new WeakMap,W0=new WeakMap,F3=new WeakMap,gn=new WeakMap,H1=new WeakMap,w3=new WeakMap;let G9=Pl;var z5=200,J2=function(){};J2.prototype.append=function(t){return t.length?(t=J2.from(t),!this.length&&t||t.length<z5&&this.leafAppend(t)||this.length<z5&&t.leafPrepend(this)||this.appendInner(t)):this},J2.prototype.prepend=function(t){return t.length?J2.from(t).append(this):this},J2.prototype.appendInner=function(t){return new rk(this,t)},J2.prototype.slice=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=this.length),t>=e?J2.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},J2.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},J2.prototype.forEach=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},J2.prototype.map=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(l,a){return i.push(t(l,a))},e,n),i},J2.from=function(t){return t instanceof J2?t:t&&t.length?new lu(t):J2.empty};var lu=(function(r){function t(n){r.call(this),this.values=n}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(i,l){return i==0&&l==this.length?this:new t(this.values.slice(i,l))},t.prototype.getInner=function(i){return this.values[i]},t.prototype.forEachInner=function(i,l,a,o){for(var s=l;s<a;s++)if(i(this.values[s],o+s)===!1)return!1},t.prototype.forEachInvertedInner=function(i,l,a,o){for(var s=l-1;s>=a;s--)if(i(this.values[s],o+s)===!1)return!1},t.prototype.leafAppend=function(i){if(this.length+i.length<=z5)return new t(this.values.concat(i.flatten()))},t.prototype.leafPrepend=function(i){if(this.length+i.length<=z5)return new t(i.flatten().concat(this.values))},e.length.get=function(){return this.values.length},e.depth.get=function(){return 0},Object.defineProperties(t.prototype,e),t})(J2);J2.empty=new lu([]);var rk=(function(r){function t(e,n){r.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},t.prototype.forEachInner=function(n,i,l,a){var o=this.left.length;if(i<o&&this.left.forEachInner(n,i,Math.min(l,o),a)===!1||l>o&&this.right.forEachInner(n,Math.max(i-o,0),Math.min(this.length,l)-o,a+o)===!1)return!1},t.prototype.forEachInvertedInner=function(n,i,l,a){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(n,i-o,Math.max(l,o)-o,a+o)===!1||l<o&&this.left.forEachInvertedInner(n,Math.min(i,o),l,a)===!1)return!1},t.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var l=this.left.length;return i<=l?this.left.slice(n,i):n>=l?this.right.slice(n-l,i-l):this.left.slice(n,l).append(this.right.slice(0,i-l))},t.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new t(this.left,i)},t.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new t(i,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t})(J2);const ik=500;class at{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,l;e&&(i=this.remapping(n,this.items.length),l=i.maps.length);let a=t.tr,o,s,c=[],u=[];return this.items.forEach((A,d)=>{if(!A.step){i||(i=this.remapping(n,d+1),l=i.maps.length),l--,u.push(A);return}if(i){u.push(new Vt(A.map));let f=A.step.map(i.slice(l)),h;f&&a.maybeStep(f).doc&&(h=a.mapping.maps[a.mapping.maps.length-1],c.push(new Vt(h,void 0,void 0,c.length+u.length))),l--,h&&i.appendMap(h,l)}else a.maybeStep(A.step);if(A.selection)return o=i?A.selection.map(i.slice(l)):A.selection,s=new at(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:s,transform:a,selection:o}}addTransform(t,e,n,i){let l=[],a=this.eventCount,o=this.items,s=!i&&o.length?o.get(o.length-1):null;for(let u=0;u<t.steps.length;u++){let A=t.steps[u].invert(t.docs[u]),d=new Vt(t.mapping.maps[u],A,e),f;(f=s&&s.merge(d))&&(d=f,u?l.pop():o=o.slice(0,o.length-1)),l.push(d),e&&(a++,e=void 0),i||(s=d)}let c=a-n.depth;return c>ak&&(o=lk(o,c),a-=c),new at(o.append(l),a)}remapping(t,e){let n=new M7;return this.items.forEach((i,l)=>{let a=i.mirrorOffset!=null&&l-i.mirrorOffset>=t?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,a)},t,e),n}addMaps(t){return this.eventCount==0?this:new at(this.items.append(t.map(e=>new Vt(e))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-e),l=t.mapping,a=t.steps.length,o=this.eventCount;this.items.forEach(d=>{d.selection&&o--},i);let s=e;this.items.forEach(d=>{let f=l.getMirror(--s);if(f==null)return;a=Math.min(a,f);let h=l.maps[f];if(d.step){let m=t.steps[f].invert(t.docs[f]),I=d.selection&&d.selection.map(l.slice(s+1,f));I&&o++,n.push(new Vt(h,m,I))}else n.push(new Vt(h))},i);let c=[];for(let d=e;d<a;d++)c.push(new Vt(l.maps[d]));let u=this.items.slice(0,i).append(c).append(n),A=new at(u,o);return A.emptyItemCount()>ik&&(A=A.compress(this.items.length-n.length)),A}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,i=[],l=0;return this.items.forEach((a,o)=>{if(o>=t)i.push(a),a.selection&&l++;else if(a.step){let s=a.step.map(e.slice(n)),c=s&&s.getMap();if(n--,c&&e.appendMap(c,n),s){let u=a.selection&&a.selection.map(e.slice(n));u&&l++;let A=new Vt(c.invert(),s,u),d,f=i.length-1;(d=i.length&&i[f].merge(A))?i[f]=d:i.push(A)}}else a.map&&n--},this.items.length,0),new at(J2.from(i.reverse()),l)}}at.empty=new at(J2.empty,0);function lk(r,t){let e;return r.forEach((n,i)=>{if(n.selection&&t--==0)return e=i,!1}),r.slice(e)}class Vt{constructor(t,e,n,i){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Vt(e.getMap().invert(),e,this.selection)}}}class T1{constructor(t,e,n,i,l){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=i,this.prevComposition=l}}const ak=20;function ok(r,t,e,n){let i=e.getMeta(Z0),l;if(i)return i.historyState;e.getMeta(uk)&&(r=new T1(r.done,r.undone,null,0,-1));let a=e.getMeta("appendedTransaction");if(e.steps.length==0)return r;if(a&&a.getMeta(Z0))return a.getMeta(Z0).redo?new T1(r.done.addTransform(e,void 0,n,Q5(t)),r.undone,au(e.mapping.maps),r.prevTime,r.prevComposition):new T1(r.done,r.undone.addTransform(e,void 0,n,Q5(t)),null,r.prevTime,r.prevComposition);if(e.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=e.getMeta("composition"),s=r.prevTime==0||!a&&r.prevComposition!=o&&(r.prevTime<(e.time||0)-n.newGroupDelay||!sk(e,r.prevRanges)),c=a?H9(r.prevRanges,e.mapping):au(e.mapping.maps);return new T1(r.done.addTransform(e,s?t.selection.getBookmark():void 0,n,Q5(t)),at.empty,c,e.time,o??r.prevComposition)}else return(l=e.getMeta("rebased"))?new T1(r.done.rebased(e,l),r.undone.rebased(e,l),H9(r.prevRanges,e.mapping),r.prevTime,r.prevComposition):new T1(r.done.addMaps(e.mapping.maps),r.undone.addMaps(e.mapping.maps),H9(r.prevRanges,e.mapping),r.prevTime,r.prevComposition)}function sk(r,t){if(!t)return!1;if(!r.docChanged)return!0;let e=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let l=0;l<t.length;l+=2)n<=t[l+1]&&i>=t[l]&&(e=!0)}),e}function au(r){let t=[];for(let e=r.length-1;e>=0&&t.length==0;e--)r[e].forEach((n,i,l,a)=>t.push(l,a));return t}function H9(r,t){if(!r)return null;let e=[];for(let n=0;n<r.length;n+=2){let i=t.map(r[n],1),l=t.map(r[n+1],-1);i<=l&&e.push(i,l)}return e}function ck(r,t,e){let n=Q5(t),i=Z0.get(t).spec.config,l=(e?r.undone:r.done).popEvent(t,n);if(!l)return null;let a=l.selection.resolve(l.transform.doc),o=(e?r.done:r.undone).addTransform(l.transform,t.selection.getBookmark(),i,n),s=new T1(e?o:l.remaining,e?l.remaining:o,null,0,-1);return l.transform.setSelection(a).setMeta(Z0,{redo:e,historyState:s})}let J9=!1,ou=null;function Q5(r){let t=r.plugins;if(ou!=t){J9=!1,ou=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){J9=!0;break}}return J9}const Z0=new rt("history"),uk=new rt("closeHistory");function Ak(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new nt({key:Z0,state:{init(){return new T1(at.empty,at.empty,null,0,-1)},apply(t,e,n){return ok(e,n,t,r)}},config:r,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,i=n=="historyUndo"?cu:n=="historyRedo"?uu:null;return!i||!t.editable?!1:(e.preventDefault(),i(t.state,t.dispatch))}}}})}function su(r,t){return(e,n)=>{let i=Z0.getState(e);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let l=ck(i,e,r);l&&n(t?l.scrollIntoView():l)}return!0}}const cu=su(!1,!0),uu=su(!0,!0);function g2(r,t){const e=NS(r),n=i=>async()=>{n.key=e,await i.wait($7);const l=t(i);return i.get(b2).create(e,l),n.run=a=>i.get(b2).call(r,a),()=>{i.get(b2).remove(e)}};return n}function ot(r){const t=e=>async()=>{await e.wait(Ye);const n=r(e);return e.update(w7,i=>[...i,n]),t.inputRule=n,()=>{e.update(w7,i=>i.filter(l=>l!==n))}};return t}function fk(r,t){const e=n=>async()=>{const i=t(n);return n.update(_7,l=>[...l.filter(a=>a[0]!==r),[r,i]]),e.id=r,e.schema=i,()=>{n.update(_7,l=>l.filter(([a])=>a!==r))}};return e.type=n=>{const i=n.get(r1).marks[r];if(!i)throw nM(r);return i},e}function F9(r,t){const e=n=>async()=>{const i=t(n);return n.update(L7,l=>[...l.filter(a=>a[0]!==r),[r,i]]),e.id=r,e.schema=i,()=>{n.update(L7,l=>l.filter(([a])=>a!==r))}};return e.type=n=>{const i=n.get(r1).nodes[r];if(!i)throw tM(r);return i},e}function S3(r){let t;const e=n=>async()=>(await n.wait(Ye),t=r(n),n.update(n1,i=>[...i,t]),()=>{n.update(n1,i=>i.filter(l=>l!==t))});return e.plugin=()=>t,e.key=()=>t.spec.key,e}function dk(r){const t=e=>async()=>{await e.wait(en);const n=e.get(d5),i=r(e),l=n.addObjectKeymap(i);return t.keymap=i,()=>{l()}};return t}function i1(r,t){const e=d2(r,t),n=i=>(i.inject(e),()=>()=>{i.remove(e)});return n.key=e,n}function He(r,t){const e=i1(t,r),n=F9(r,l=>l.get(e.key)(l)),i=[e,n];return i.id=n.id,i.node=n,i.type=l=>n.type(l),i.ctx=e,i.key=e.key,i.extendSchema=l=>{const a=l(t);return He(r,a)},i}function rn(r,t){const e=i1(t,r),n=fk(r,l=>l.get(e.key)(l)),i=[e,n];return i.id=n.id,i.mark=n,i.type=l=>n.type(l),i.ctx=e,i.key=e.key,i.extendSchema=l=>{const a=l(t);return rn(r,a)},i}function Je(r,t){const e=Object.fromEntries(Object.entries(t).map(([a,{shortcuts:o,priority:s}])=>[a,{shortcuts:o,priority:s}])),n=i1(e,`${r}Keymap`),i=dk(a=>{const o=a.get(n.key),s=Object.entries(t).flatMap(([c,{command:u}])=>{const A=o[c],d=[A.shortcuts].flat(),f=A.priority;return d.map(h=>[h,{key:h,onRun:u,priority:f}])});return Object.fromEntries(s)}),l=[n,i];return l.ctx=n,l.shortcuts=i,l.key=n.key,l.keymap=i.keymap,l}const st=(r,t=()=>({}))=>i1(t,`${r}Attr`),b5=(r,t=()=>({}))=>i1(t,`${r}Attr`);function k3(r,t,e){const n=i1({},r),i=a=>async()=>{await a.wait(R0);const s={plugin:t(a),options:a.get(n.key)};return a.update(N7,c=>[...c,s]),()=>{a.update(N7,c=>c.filter(u=>u!==s))}},l=[n,i];return l.id=r,l.plugin=i,l.options=n,l}function hk(r,t=!1){return e=>{const n=e.get(fe),l=e.get(tn)(r);if(!l)return;if(!t){const{state:u}=n;return n.dispatch(u.tr.replace(0,u.doc.content.size,new J(l.content,0,0)))}const a=e.get(r1),o=e.get(I5),s=e.get(n1),c=I0.create({schema:a,doc:l,plugins:s,...o});n.updateState(c)}}function y3(r,t){return Object.assign(r,{meta:{package:"@milkdown/plugin-history",...t}}),r}const S5=g2("Undo",()=>()=>cu);y3(S5,{displayName:"Command<undo>"});const k5=g2("Redo",()=>()=>uu);y3(k5,{displayName:"Command<redo>"});const w9=i1({},"historyProviderConfig");y3(w9,{displayName:"Ctx<historyProviderConfig>"});const Au=S3(r=>Ak(r.get(w9.key)));y3(Au,{displayName:"Ctx<historyProviderPlugin>"});const N9=Je("historyKeymap",{Undo:{shortcuts:"Mod-z",command:r=>{const t=r.get(b2);return()=>t.call(S5.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:r=>{const t=r.get(b2);return()=>t.call(k5.key)}}});y3(N9.ctx,{displayName:"KeymapCtx<history>"}),y3(N9.shortcuts,{displayName:"Keymap<history>"});const pk=[w9,Au,N9,S5,k5].flat();function mk(r,t){return function(e,n){let{$from:i,$to:l,node:a}=e.selection;if(a&&a.isBlock||i.depth<2||!i.sameParent(l))return!1;let o=i.node(-1);if(o.type!=r)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(n){let A=j.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let M=i.depth-d;M>=i.depth-3;M--)A=j.from(i.node(M).copy(A));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;A=A.append(j.from(r.createAndFill()));let h=i.before(i.depth-(d-1)),m=e.tr.replace(h,i.after(-f),new J(A,4-d,0)),I=-1;m.doc.nodesBetween(h,m.doc.content.size,(M,k)=>{if(I>-1)return!1;M.isTextblock&&M.content.size==0&&(I=k+1)}),I>-1&&m.setSelection(E2.near(m.doc.resolve(I))),n(m.scrollIntoView())}return!0}let s=l.pos==i.end()?o.contentMatchAt(0).defaultType:null,c=e.tr.delete(i.pos,l.pos),u=s?[null,{type:s}]:void 0;return v7(c.doc,i.pos,2,u)?(n&&n(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Ik(r){return function(t,e){let{$from:n,$to:i}=t.selection,l=n.blockRange(i,a=>a.childCount>0&&a.firstChild.type==r);return l?e?n.node(l.depth-1).type==r?Ck(t,e,r,l):Ek(t,e,l):!0:!1}}function Ck(r,t,e,n){let i=r.tr,l=n.end,a=n.$to.end(n.depth);l<a&&(i.step(new ie(l-1,a,l,a,new J(j.from(e.create(null,n.parent.copy())),1,0),1,!0)),n=new yo(i.doc.resolve(n.$from.pos),i.doc.resolve(a),n.depth));const o=Or(n);if(o==null)return!1;i.lift(n,o);let s=i.doc.resolve(i.mapping.map(l,-1)-1);return Kr(i.doc,s.pos)&&s.nodeBefore.type==s.nodeAfter.type&&i.join(s.pos),t(i.scrollIntoView()),!0}function Ek(r,t,e){let n=r.tr,i=e.parent;for(let f=e.end,h=e.endIndex-1,m=e.startIndex;h>m;h--)f-=i.child(h).nodeSize,n.delete(f-1,f+1);let l=n.doc.resolve(e.start),a=l.nodeAfter;if(n.mapping.map(e.end)!=e.start+l.nodeAfter.nodeSize)return!1;let o=e.startIndex==0,s=e.endIndex==i.childCount,c=l.node(-1),u=l.index(-1);if(!c.canReplace(u+(o?0:1),u+1,a.content.append(s?j.empty:j.from(i))))return!1;let A=l.pos,d=A+a.nodeSize;return n.step(new ie(A-(o?1:0),d+(s?1:0),A+1,d-1,new J((o?j.empty:j.from(i.copy(j.empty))).append(s?j.empty:j.from(i.copy(j.empty))),o?0:1,s?0:1),o?0:1)),t(n.scrollIntoView()),!0}function Mk(r){return function(t,e){let{$from:n,$to:i}=t.selection,l=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!l)return!1;let a=l.startIndex;if(a==0)return!1;let o=l.parent,s=o.child(a-1);if(s.type!=r)return!1;if(e){let c=s.lastChild&&s.lastChild.type==o.type,u=j.from(c?r.create():null),A=new J(j.from(r.create(null,j.from(o.type.create(null,u)))),c?3:1,0),d=l.start,f=l.end;e(t.tr.step(new ie(d-(c?3:1),f,d,f,A,1,!0)).scrollIntoView())}return!0}}function vk(r){const t=new Map;if(!r||!r.type)throw new Error("mdast-util-definitions expected node");return C3(r,"definition",function(n){const i=fu(n.identifier);i&&!t.get(i)&&t.set(i,n)}),e;function e(n){const i=fu(n);return t.get(i)}}function fu(r){return String(r||"").toUpperCase()}function gk(){return function(r){const t=vk(r);C3(r,function(e,n,i){if(e.type==="definition"&&i!==void 0&&typeof n=="number")return i.children.splice(n,1),[Yi,n];if(e.type==="imageReference"||e.type==="linkReference"){const l=t(e.identifier);if(l&&i&&typeof n=="number")return i.children[n]=e.type==="imageReference"?{type:"image",url:l.url,title:l.title,alt:e.alt}:{type:"link",url:l.url,title:l.title,children:e.children},[Yi,n]}})}}function du(r,t){var i;if(!(t.childCount>=1&&((i=t.lastChild)==null?void 0:i.type.name)==="hardbreak")){r.next(t.content);return}const n=[];t.content.forEach((l,a,o)=>{o!==t.childCount-1&&n.push(l)}),r.next(j.fromArray(n))}function Y(r,t){return Object.assign(r,{meta:{package:"@milkdown/preset-commonmark",...t}}),r}const D9=b5("emphasis");Y(D9,{displayName:"Attr<emphasis>",group:"Emphasis"});const R3=rn("emphasis",r=>({attrs:{marker:{default:r.get(D7).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:t=>t==="italic"}],toDOM:t=>["em",r.get(D9.key)(t)],parseMarkdown:{match:t=>t.type==="emphasis",runner:(t,e,n)=>{t.openMark(n,{marker:e.marker}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="emphasis",runner:(t,e)=>{t.withMark(e,"emphasis",void 0,{marker:e.attrs.marker})}}}));Y(R3.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Y(R3.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const y5=g2("ToggleEmphasis",r=>()=>Ii(R3.type(r)));Y(y5,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const hu=ot(r=>n5(/(?:^|[^*])\*([^*]+)\*$/,R3.type(r),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:t,start:e})=>t.startsWith("*")?{}:{fullMatch:t.slice(1),start:e+1}}));Y(hu,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const pu=ot(r=>n5(/\b_(?![_\s])(.*?[^_\s])_\b/,R3.type(r),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:t,start:e})=>t.startsWith("_")?{}:{fullMatch:t.slice(1),start:e+1}}));Y(pu,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const L9=Je("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:r=>{const t=r.get(b2);return()=>t.call(y5.key)}}});Y(L9.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Y(L9.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const _9=b5("strong");Y(_9,{displayName:"Attr<strong>",group:"Strong"});const ln=rn("strong",r=>({attrs:{marker:{default:r.get(D7).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:t=>t==="bold"},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:t=>["strong",r.get(_9.key)(t)],parseMarkdown:{match:t=>t.type==="strong",runner:(t,e,n)=>{t.openMark(n,{marker:e.marker}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="strong",runner:(t,e)=>{t.withMark(e,"strong",void 0,{marker:e.attrs.marker})}}}));Y(ln.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Y(ln.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const R5=g2("ToggleStrong",r=>()=>Ii(ln.type(r)));Y(R5,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const mu=ot(r=>n5(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),ln.type(r),{getAttr:t=>({marker:t[0].startsWith("*")?"*":"_"})}));Y(mu,{displayName:"InputRule<strong>",group:"Strong"});const $9=Je("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:r=>{const t=r.get(b2);return()=>t.call(R5.key)}}});Y($9.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Y($9.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const el=b5("inlineCode");Y(el,{displayName:"Attr<inlineCode>",group:"InlineCode"});const W1=rn("inlineCode",r=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",r.get(el.key)(t)],parseMarkdown:{match:t=>t.type==="inlineCode",runner:(t,e,n)=>{t.openMark(n),t.addText(e.value),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="inlineCode",runner:(t,e,n)=>{t.withMark(e,"inlineCode",n.text||"")}}}));Y(W1.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Y(W1.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const tl=g2("ToggleInlineCode",r=>()=>(t,e)=>{const{selection:n,tr:i}=t;if(n.empty)return!1;const{from:l,to:a}=n;return t.doc.rangeHasMark(l,a,W1.type(r))?(e==null||e(i.removeMark(l,a,W1.type(r))),!0):(Object.keys(t.schema.marks).filter(c=>c!==W1.type.name).map(c=>t.schema.marks[c]).forEach(c=>{i.removeMark(l,a,c)}),e==null||e(i.addMark(l,a,W1.type(r).create())),!0)});Y(tl,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const Iu=ot(r=>n5(/(?:`)([^`]+)(?:`)$/,W1.type(r)));Y(Iu,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const nl=Je("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:r=>{const t=r.get(b2);return()=>t.call(tl.key)}}});Y(nl.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Y(nl.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const rl=b5("link");Y(rl,{displayName:"Attr<link>",group:"Link"});const Z3=rn("link",r=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:t=>["a",{...r.get(rl.key)(t),...t.attrs}],parseMarkdown:{match:t=>t.type==="link",runner:(t,e,n)=>{const i=e.url,l=e.title;t.openMark(n,{href:i,title:l}),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="link",runner:(t,e)=>{t.withMark(e,"link",void 0,{title:e.attrs.title,url:e.attrs.href})}}}));Y(Z3.mark,{displayName:"MarkSchema<link>",group:"Link"});const Cu=g2("ToggleLink",r=>(t={})=>Ii(Z3.type(r),t));Y(Cu,{displayName:"Command<toggleLinkCommand>",group:"Link"});const Eu=g2("UpdateLink",r=>(t={})=>(e,n)=>{if(!n)return!1;let i,l=-1;const{selection:a}=e,{from:o,to:s}=a;if(e.doc.nodesBetween(o,o===s?s+1:s,(h,m)=>{if(Z3.type(r).isInSet(h.marks))return i=h,l=m,!1}),!i)return!1;const c=i.marks.find(({type:h})=>h===Z3.type(r));if(!c)return!1;const u=l,A=l+i.nodeSize,{tr:d}=e,f=Z3.type(r).create({...c.attrs,...t});return f?(n(d.removeMark(u,A,c).addMark(u,A,f).setSelection(new m2(d.selection.$anchor)).scrollIntoView()),!0):!1});Y(Eu,{displayName:"Command<updateLinkCommand>",group:"Link"});const Mu=F9("doc",()=>({content:"block+",parseMarkdown:{match:({type:r})=>r==="root",runner:(r,t,e)=>{r.injectRoot(t,e)}},toMarkdown:{match:r=>r.type.name==="doc",runner:(r,t)=>{r.openNode("root"),r.next(t.content)}}}));Y(Mu,{displayName:"NodeSchema<doc>",group:"Doc"});function zk(r){return lc(r,t=>{var e;return t.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((e=t.value)==null?void 0:e.trim())},(t,e)=>{if(!e.length)return;const n=e[e.length-1];if(!n)return;const i=n.children.indexOf(t);i!==-1&&n.children.splice(i,1)},!0)}const Z5=k3("remark-preserve-empty-line",()=>()=>zk);Y(Z5.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Y(Z5.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});const il=st("paragraph");Y(il,{displayName:"Attr<paragraph>",group:"Paragraph"});const x0=He("paragraph",r=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",r.get(il.key)(t),0],parseMarkdown:{match:t=>t.type==="paragraph",runner:(t,e,n)=>{t.openNode(n),e.children?t.next(e.children):t.addText(e.value||""),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="paragraph",runner:(t,e)=>{var l;const i=(l=r.get(fe).state)==null?void 0:l.doc.lastChild;t.openNode("paragraph"),(!e.content||e.content.size===0)&&e!==i&&Qk(r)?t.addNode("html",void 0,"<br />"):du(t,e),t.closeNode()}}}));function Qk(r){let t=!1;try{r.get(Z5.id),t=!0}catch{t=!1}return t}Y(x0.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Y(x0.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const x5=g2("TurnIntoText",r=>()=>S7(x0.type(r)));Y(x5,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const ll=Je("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:r=>{const t=r.get(b2);return()=>t.call(x5.key)}}});Y(ll.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Y(ll.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const bk=Array(6).fill(0).map((r,t)=>t+1);function Sk(r){return r.textContent.toLowerCase().trim().replace(/\s+/g,"-")}const B5=i1(Sk,"headingIdGenerator");Y(B5,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const al=st("heading");Y(al,{displayName:"Attr<heading>",group:"Heading"});const B0=He("heading",r=>{const t=r.get(B5.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:bk.map(e=>({tag:`h${e}`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw f0(n);return{level:e,id:n.id}}})),toDOM:e=>[`h${e.attrs.level}`,{...r.get(al.key)(e),id:e.attrs.id||t(e)},0],parseMarkdown:{match:({type:e})=>e==="heading",runner:(e,n,i)=>{const l=n.depth;e.openNode(i,{level:l}),e.next(n.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="heading",runner:(e,n)=>{e.openNode("heading",void 0,{depth:n.attrs.level}),du(e,n),e.closeNode()}}}});Y(B0.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Y(B0.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const vu=ot(r=>kc(/^(?<hashes>#+)\s$/,B0.type(r),t=>{var a,o;const e=((o=(a=t.groups)==null?void 0:a.hashes)==null?void 0:o.length)||0,n=r.get(fe),{$from:i}=n.state.selection,l=i.node();if(l.type.name==="heading"){let s=Number(l.attrs.level)+Number(e);return s>6&&(s=6),{level:s}}return{level:e}}));Y(vu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const l1=g2("WrapInHeading",r=>t=>(t??(t=1),t<1?S7(x0.type(r)):S7(B0.type(r),{level:t})));Y(l1,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const ol=g2("DowngradeHeading",r=>()=>(t,e,n)=>{const{$from:i}=t.selection,l=i.node();if(l.type!==B0.type(r)||!t.selection.empty||i.parentOffset!==0)return!1;const a=l.attrs.level-1;return a?(e==null||e(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...l.attrs,level:a})),!0):S7(x0.type(r))(t,e,n)});Y(ol,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const sl=Je("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:r=>{const t=r.get(b2);return()=>t.call(l1.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:r=>{const t=r.get(b2);return()=>t.call(ol.key)}}});Y(sl.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Y(sl.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const cl=st("blockquote");Y(cl,{displayName:"Attr<blockquote>",group:"Blockquote"});const an=He("blockquote",r=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",r.get(cl.key)(t),0],parseMarkdown:{match:({type:t})=>t==="blockquote",runner:(t,e,n)=>{t.openNode(n).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name==="blockquote",runner:(t,e)=>{t.openNode("blockquote").next(e.content).closeNode()}}}));Y(an.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Y(an.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const gu=ot(r=>$i(/^\s*>\s$/,an.type(r)));Y(gu,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const ul=g2("WrapInBlockquote",r=>()=>mi(an.type(r)));Y(ul,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const Al=Je("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:r=>{const t=r.get(b2);return()=>t.call(ul.key)}}});Y(Al.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Y(Al.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const fl=st("codeBlock",()=>({pre:{},code:{}}));Y(fl,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const on=He("code_block",r=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{language:t.dataset.language}}}],toDOM:t=>{const e=r.get(fl.key)(t),n=t.attrs.language,i=n&&n.length>0?{"data-language":n}:void 0;return["pre",{...e.pre,...i},["code",e.code,0]]},parseMarkdown:{match:({type:t})=>t==="code",runner:(t,e,n)=>{const i=e.lang??"",l=e.value;t.openNode(n,{language:i}),l&&t.addText(l),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="code_block",runner:(t,e)=>{var n;t.addNode("code",void 0,((n=e.content.firstChild)==null?void 0:n.text)||"",{lang:e.attrs.language})}}}));Y(on.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Y(on.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const zu=ot(r=>kc(/^```(?<language>[a-z]*)?[\s\n]$/,on.type(r),t=>{var e;return{language:((e=t.groups)==null?void 0:e.language)??""}}));Y(zu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const dl=g2("CreateCodeBlock",r=>(t="")=>S7(on.type(r),{language:t}));Y(dl,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const kk=g2("UpdateCodeBlockLanguage",()=>({pos:r,language:t}={pos:-1,language:""})=>(e,n)=>r>=0?(n==null||n(e.tr.setNodeAttribute(r,"language",t)),!0):!1);Y(kk,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const hl=Je("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:r=>{const t=r.get(b2);return()=>t.call(dl.key)}}});Y(hl.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Y(hl.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const pl=st("image");Y(pl,{displayName:"Attr<image>",group:"Image"});const x3=He("image",r=>({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:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"",title:t.getAttribute("title")||t.getAttribute("alt")||""}}}],toDOM:t=>["img",{...r.get(pl.key)(t),...t.attrs}],parseMarkdown:{match:({type:t})=>t==="image",runner:(t,e,n)=>{const i=e.url,l=e.alt,a=e.title;t.addNode(n,{src:i,alt:l,title:a})}},toMarkdown:{match:t=>t.type.name==="image",runner:(t,e)=>{t.addNode("image",void 0,void 0,{title:e.attrs.title,url:e.attrs.src,alt:e.attrs.alt})}}}));Y(x3.node,{displayName:"NodeSchema<image>",group:"Image"}),Y(x3.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const Qu=g2("InsertImage",r=>(t={})=>(e,n)=>{if(!n)return!0;const{src:i="",alt:l="",title:a=""}=t,o=x3.type(r).create({src:i,alt:l,title:a});return o&&n(e.tr.replaceSelectionWith(o).scrollIntoView()),!0});Y(Qu,{displayName:"Command<insertImageCommand>",group:"Image"});const bu=g2("UpdateImage",r=>(t={})=>(e,n)=>{const i=eb(e.selection,x3.type(r));if(!i)return!1;const{node:l,pos:a}=i,o={...l.attrs},{src:s,alt:c,title:u}=t;return s!==void 0&&(o.src=s),c!==void 0&&(o.alt=c),u!==void 0&&(o.title=u),n==null||n(e.tr.setNodeMarkup(a,void 0,o).scrollIntoView()),!0});Y(bu,{displayName:"Command<updateImageCommand>",group:"Image"});const yk=ot(r=>new lt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,e,n,i)=>{const[l,a,o="",s]=e;return l?t.tr.replaceWith(n,i,x3.type(r).create({src:o,alt:a,title:s})):null}));Y(yk,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const U5=st("hardbreak",r=>({"data-type":"hardbreak","data-is-inline":r.attrs.isInline}));Y(U5,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const U0=He("hardbreak",r=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",r.get(U5.key)(t)," "]:["br",r.get(U5.key)(t)],parseMarkdown:{match:({type:t})=>t==="break",runner:(t,e,n)=>{var i;t.addNode(n,{isInline:!!((i=e.data)!=null&&i.isInline)})}},leafText:()=>`
73
73
  `,toMarkdown:{match:t=>t.type.name==="hardbreak",runner:(t,e)=>{e.attrs.isInline?t.addNode("text",void 0,`
74
74
  `):t.addNode("break")}}}));Y(U0.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),Y(U0.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const ml=g2("InsertHardbreak",r=>()=>(t,e)=>{var l;const{selection:n,tr:i}=t;if(!(n instanceof m2))return!1;if(n.empty){const a=n.$from.node();if(a.childCount>0&&((l=a.lastChild)==null?void 0:l.type.name)==="hardbreak")return e==null||e(i.replaceRangeWith(n.to-1,n.to,t.schema.node("paragraph")).setSelection(E2.near(i.doc.resolve(n.to))).scrollIntoView()),!0}return e==null||e(i.setMeta("hardbreak",!0).replaceSelectionWith(U0.type(r).create()).scrollIntoView()),!0});Y(ml,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const Il=Je("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:r=>{const t=r.get(b2);return()=>t.call(ml.key)}}});Y(Il.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),Y(Il.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const Cl=st("hr");Y(Cl,{displayName:"Attr<hr>",group:"Hr"});const sn=He("hr",r=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",r.get(Cl.key)(t)],parseMarkdown:{match:({type:t})=>t==="thematicBreak",runner:(t,e,n)=>{t.addNode(n)}},toMarkdown:{match:t=>t.type.name==="hr",runner:t=>{t.addNode("thematicBreak")}}}));Y(sn.node,{displayName:"NodeSchema<hr>",group:"Hr"}),Y(sn.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const Su=ot(r=>new lt(/^(?:---|___\s|\*\*\*\s)$/,(t,e,n,i)=>{const{tr:l}=t;return e[0]&&l.replaceWith(n-1,i,sn.type(r).create()),l}));Y(Su,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const ku=g2("InsertHr",r=>()=>(t,e)=>{if(!e)return!0;const n=x0.node.type(r).create(),{tr:i,selection:l}=t,{from:a}=l,o=sn.type(r).create();if(!o)return!0;const s=i.replaceSelectionWith(o).insert(a,n),c=E2.findFrom(s.doc.resolve(a),1,!0);return c&&e(s.setSelection(c).scrollIntoView()),!0});Y(ku,{displayName:"Command<insertHrCommand>",group:"Hr"});const El=st("bulletList");Y(El,{displayName:"Attr<bulletList>",group:"BulletList"});const B3=He("bullet_list",r=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{spread:t.dataset.spread==="true"}}}],toDOM:t=>["ul",{...r.get(El.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:t,ordered:e})=>t==="list"&&!e,runner:(t,e,n)=>{const i=e.spread!=null?`${e.spread}`:"false";t.openNode(n,{spread:i}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name==="bullet_list",runner:(t,e)=>{t.openNode("list",void 0,{ordered:!1,spread:e.attrs.spread}).next(e.content).closeNode()}}}));Y(B3.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),Y(B3.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const yu=ot(r=>$i(/^\s*([-+*])\s$/,B3.type(r)));Y(yu,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const Y5=g2("WrapInBulletList",r=>()=>mi(B3.type(r)));Y(Y5,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const Ml=Je("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:r=>{const t=r.get(b2);return()=>t.call(Y5.key)}}});Y(Ml.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),Y(Ml.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const vl=st("orderedList");Y(vl,{displayName:"Attr<orderedList>",group:"OrderedList"});const U3=He("ordered_list",r=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{spread:t.dataset.spread,order:t.hasAttribute("start")?Number(t.getAttribute("start")):1}}}],toDOM:t=>["ol",{...r.get(vl.key)(t),...t.attrs.order===1?{}:t.attrs.order,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:t,ordered:e})=>t==="list"&&!!e,runner:(t,e,n)=>{const i=e.spread!=null?`${e.spread}`:"true";t.openNode(n,{spread:i}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name==="ordered_list",runner:(t,e)=>{t.openNode("list",void 0,{ordered:!0,start:1,spread:e.attrs.spread==="true"}),t.next(e.content),t.closeNode()}}}));Y(U3.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),Y(U3.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const Ru=ot(r=>$i(/^\s*(\d+)\.\s$/,U3.type(r),t=>({order:Number(t[1])}),(t,e)=>e.childCount+e.attrs.order===Number(t[1])));Y(Ru,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const V5=g2("WrapInOrderedList",r=>()=>mi(U3.type(r)));Y(V5,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const gl=Je("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:r=>{const t=r.get(b2);return()=>t.call(V5.key)}}});Y(gl.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),Y(gl.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const zl=st("listItem");Y(zl,{displayName:"Attr<listItem>",group:"ListItem"});const P1=He("list_item",r=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:t=>{if(!(t instanceof HTMLElement))throw f0(t);return{label:t.dataset.label,listType:t.dataset.listType,spread:t.dataset.spread==="true"}}}],toDOM:t=>["li",{...r.get(zl.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:t})=>t==="listItem",runner:(t,e,n)=>{const i=e.label!=null?`${e.label}.`:"•",l=e.label!=null?"ordered":"bullet",a=e.spread!=null?`${e.spread}`:"true";t.openNode(n,{label:i,listType:l,spread:a}),t.next(e.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="list_item",runner:(t,e)=>{t.openNode("listItem",void 0,{spread:e.attrs.spread}),t.next(e.content),t.closeNode()}}}));Y(P1.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),Y(P1.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const Ql=g2("SinkListItem",r=>()=>Mk(P1.type(r)));Y(Ql,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const cn=g2("LiftListItem",r=>()=>Ik(P1.type(r)));Y(cn,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const bl=g2("SplitListItem",r=>()=>mk(P1.type(r)));Y(bl,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function Rk(r){return(t,e,n)=>{const{selection:i}=t;if(!(i instanceof m2))return!1;const{empty:l,$from:a}=i;return!l||a.parentOffset!==0||a.node(-1).type!==P1.type(r)?!1:Is(t,e,n)}}const Sl=g2("LiftFirstListItem",r=>()=>Rk(r));Y(Sl,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const kl=Je("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:r=>{const t=r.get(b2);return()=>t.call(bl.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:r=>{const t=r.get(b2);return()=>t.call(Ql.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:r=>{const t=r.get(b2);return()=>t.call(cn.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:r=>{const t=r.get(b2);return()=>t.call(Sl.key)}}});Y(kl.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),Y(kl.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const Zu=F9("text",()=>({group:"inline",parseMarkdown:{match:({type:r})=>r==="text",runner:(r,t)=>{r.addText(t.value)}},toMarkdown:{match:r=>r.type.name==="text",runner:(r,t)=>{r.addNode("text",void 0,t.text)}}}));Y(Zu,{displayName:"NodeSchema<text>",group:"Text"});const yl=st("html");Y(yl,{displayName:"Attr<html>",group:"Html"});const Rl=He("html",r=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const e=document.createElement("span"),n={...r.get(yl.key)(t),"data-value":t.attrs.value,"data-type":"html"};return e.textContent=t.attrs.value,["span",n,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:t=>({value:t.dataset.value??""})}],parseMarkdown:{match:({type:t})=>t==="html",runner:(t,e,n)=>{t.addNode(n,{value:e.value})}},toMarkdown:{match:t=>t.type.name==="html",runner:(t,e)=>{t.addNode("html",void 0,e.attrs.value)}}}));Y(Rl.node,{displayName:"NodeSchema<html>",group:"Html"}),Y(Rl.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const Zk=[Mu,il,x0,B5,al,B0,U5,U0,cl,an,fl,on,Cl,sn,pl,x3,El,B3,vl,U3,zl,P1,D9,R3,_9,ln,el,W1,rl,Z3,yl,Rl,Zu].flat(),xk=[gu,yu,Ru,zu,Su,vu].flat(),Bk=[hu,pu,Iu,mu],Uk=g2("IsMarkSelected",()=>r=>t=>{if(!r)return!1;const{doc:e,selection:n}=t;return e.rangeHasMark(n.from,n.to,r)}),Yk=g2("IsNoteSelected",()=>r=>t=>r?tb(t,r).hasNode:!1),Vk=g2("ClearTextInCurrentBlock",()=>()=>(r,t)=>{let e=r.tr;const{$from:n,$to:i}=e.selection,{pos:l}=n,{pos:a}=i,o=l-n.node().content.size;return o<0?!1:(e=e.deleteRange(o,a),t==null||t(e),!0)}),Ok=g2("SetBlockType",()=>r=>(t,e)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const l=t.tr,{from:a,to:o}=l.selection;try{l.setBlockType(a,o,n,i)}catch{return!1}return e==null||e(l),!0}),Kk=g2("WrapInBlockType",()=>r=>(t,e)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;let l=t.tr;try{const{$from:a,$to:o}=l.selection,s=a.blockRange(o),c=s&&ai(s,n,i);if(!c)return!1;l=l.wrap(s,c)}catch{return!1}return e==null||e(l),!0}),qk=g2("AddBlockType",()=>r=>(t,e)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const l=t.tr;try{const a=n instanceof Ft?n:n.createAndFill(i);if(!a)return!1;l.replaceSelectionWith(a)}catch{return!1}return e==null||e(l),!0}),jk=g2("SelectTextNearPos",()=>r=>(t,e)=>{const{pos:n}=r??{};if(n==null)return!1;const i=(a,o,s)=>Math.min(Math.max(a,o),s),l=t.tr;try{const a=t.doc.resolve(i(n,0,t.doc.content.size));l.setSelection(m2.near(a))}catch{return!1}return e==null||e(l.scrollIntoView()),!0}),Tk=[x5,ul,l1,ol,dl,ml,ku,Qu,bu,V5,Y5,Ql,bl,cn,Sl,y5,tl,R5,Cu,Eu,Uk,Yk,Vk,Ok,Kk,qk,jk],Wk=[Al,hl,Il,sl,kl,gl,Ml,ll,L9,nl,$9].flat(),Zl=k3("remarkAddOrderInList",()=>()=>r=>{C3(r,"list",t=>{if(t.ordered){const e=t.start??1;t.children.forEach((n,i)=>{n.label=i+e})}})});Y(Zl.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),Y(Zl.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const xl=k3("remarkLineBreak",()=>()=>r=>{const t=/[\t ]*(?:\r?\n|\r)/g;C3(r,"text",(e,n,i)=>{if(!e.value||typeof e.value!="string")return;const l=[];let a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){const c=o.index;a!==c&&l.push({type:"text",value:e.value.slice(a,c)}),l.push({type:"break",data:{isInline:!0}}),a=c+o[0].length,o=t.exec(e.value)}if(l.length>0&&i&&typeof n=="number")return a<e.value.length&&l.push({type:"text",value:e.value.slice(a)}),i.children.splice(n,1,...l),n+l.length})});Y(xl.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),Y(xl.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const Bl=k3("remarkInlineLink",()=>gk);Y(Bl.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),Y(Bl.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const Pk=r=>!!r.children,Xk=r=>r.type==="html";function Gk(r,t){return e(r,0,null)[0];function e(n,i,l){if(Pk(n)){const a=[];for(let o=0,s=n.children.length;o<s;o++){const c=n.children[o];if(c){const u=e(c,o,n);if(u)for(let A=0,d=u.length;A<d;A++){const f=u[A];f&&a.push(f)}}}n.children=a}return t(n,i,l)}}const Hk=["root","blockquote","listItem"],Ul=k3("remarkHTMLTransformer",()=>()=>r=>{Gk(r,(t,e,n)=>Xk(t)?(n&&Hk.includes(n.type)&&(t.children=[{...t}],delete t.value,t.type="paragraph"),[t]):[t])});Y(Ul.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),Y(Ul.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const Yl=k3("remarkMarker",()=>()=>(r,t)=>{const e=n=>t.value.charAt(n.position.start.offset);C3(r,n=>["strong","emphasis"].includes(n.type),n=>{n.marker=e(n)})});Y(Yl.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),Y(Yl.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const xu=S3(()=>{let r=!1;const t=new rt("MILKDOWN_INLINE_NODES_CURSOR"),e=new nt({key:t,state:{init(){return!1},apply(n){if(!n.selection.empty)return!1;const i=n.selection.$from,l=i.nodeBefore,a=i.nodeAfter;return!!(l&&a&&l.isInline&&!l.isText&&a.isInline&&!a.isText)}},props:{handleDOMEvents:{compositionend:(n,i)=>r?(r=!1,requestAnimationFrame(()=>{if(e.getState(n.state)){const a=n.state.selection.from;i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",a))}}),!0):!1,compositionstart:n=>(e.getState(n.state)&&(r=!0),!1),beforeinput:(n,i)=>{if(e.getState(n.state)&&i instanceof InputEvent&&i.data&&!r){const a=n.state.selection.from;return i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",a)),!0}return!1}},decorations(n){if(e.getState(n)){const a=n.selection.$from.pos,o=document.createElement("span"),s=Ue.widget(a,o,{side:-1}),c=document.createElement("span"),u=Ue.widget(a,c);return setTimeout(()=>{o.contentEditable="true",c.contentEditable="true"}),X2.create(n.doc,[s,u])}return X2.empty}}});return e});Y(xu,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Bu=S3(r=>new nt({key:new rt("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,e,n)=>{if(!t.length)return;const[i]=t;if(!i)return;const[l]=i.steps;if(i.getMeta("hardbreak")){if(!(l instanceof H2))return;const{from:s}=l;return n.tr.setNodeMarkup(s,U0.type(r),void 0,[])}if(l instanceof wt){let s=n.tr;const{from:c,to:u}=l;return n.doc.nodesBetween(c,u,(A,d)=>{A.type===U0.type(r)&&(s=s.setNodeMarkup(d,U0.type(r),void 0,[]))}),s}}}));Y(Bu,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const Vl=i1(["table","code_block"],"hardbreakFilterNodes");Y(Vl,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const Uu=S3(r=>{const t=r.get(Vl.key);return new nt({key:new rt("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const i=e.getMeta("hardbreak"),[l]=e.steps;if(i&&l){const{from:a}=l,o=n.doc.resolve(a);let s=o.depth,c=!0;for(;s>0;)t.includes(o.node(s).type.name)&&(c=!1),s--;return c}return!0}})});Y(Uu,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const Yu=S3(r=>{const t=new rt("MILKDOWN_HEADING_ID"),e=n=>{if(n.composing)return;const i=r.get(B5.key),l=n.state.tr.setMeta("addToHistory",!1);let a=!1;const o={};n.state.doc.descendants((s,c)=>{if(s.type===B0.type(r)){if(s.textContent.trim().length===0)return;const u=s.attrs;let A=i(s);o[A]?(o[A]+=1,A+=`-#${o[A]}`):o[A]=1,u.id!==A&&(a=!0,l.setMeta(t,!0).setNodeMarkup(c,void 0,{...u,id:A}))}}),a&&n.dispatch(l)};return new nt({key:t,view:n=>(e(n),{update:(i,l)=>{i.state.doc.eq(l.doc)||e(i)}})})});Y(Yu,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const Vu=S3(r=>{const t=(e,n,i)=>{if(!i.selection||e.some(A=>A.getMeta("addToHistory")===!1||!A.isGeneric))return null;const l=U3.type(r),a=B3.type(r),o=P1.type(r),s=(A,d)=>{let f=!1;const h=`${d+1}.`;return A.label!==h&&(A.label=h,f=!0),f};let c=i.tr,u=!1;return i.doc.descendants((A,d,f,h)=>{if(A.type===a){const m=A.maybeChild(0);(m==null?void 0:m.type)===o&&m.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(d,l,{spread:"true"}),A.descendants((I,M,k,S)=>{if(I.type===o){const B={...I.attrs};s(B,S)&&(c=c.setNodeMarkup(M,void 0,B))}return!1}))}else if(A.type===o&&(f==null?void 0:f.type)===l){const m={...A.attrs};let I=!1;m.listType!=="ordered"&&(m.listType="ordered",I=!0),(f==null?void 0:f.maybeChild(0))&&(I=s(m,h)),I&&(c=c.setNodeMarkup(d,void 0,m),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new nt({key:new rt("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:t})});Y(Vu,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const Jk=[Bu,Vl,Uu,xu,Zl,Bl,xl,Ul,Yl,Z5,Yu,Vu].flat(),Fk=[Zk,xk,Bk,Tk,Wk,Jk].flat();var wk=typeof global=="object"&&global&&global.Object===Object&&global,Nk=typeof self=="object"&&self&&self.Object===Object&&self,Ou=wk||Nk||Function("return this")(),O5=Ou.Symbol,Ku=Object.prototype,Dk=Ku.hasOwnProperty,Lk=Ku.toString,un=O5?O5.toStringTag:void 0;function _k(r){var t=Dk.call(r,un),e=r[un];try{r[un]=void 0;var n=!0}catch{}var i=Lk.call(r);return n&&(t?r[un]=e:delete r[un]),i}var $k=Object.prototype,ey=$k.toString;function ty(r){return ey.call(r)}var ny="[object Null]",ry="[object Undefined]",qu=O5?O5.toStringTag:void 0;function iy(r){return r==null?r===void 0?ry:ny:qu&&qu in Object(r)?_k(r):ty(r)}function ly(r){return r!=null&&typeof r=="object"}var ay="[object Symbol]";function oy(r){return typeof r=="symbol"||ly(r)&&iy(r)==ay}var sy=/\s/;function cy(r){for(var t=r.length;t--&&sy.test(r.charAt(t)););return t}var uy=/^\s+/;function Ay(r){return r&&r.slice(0,cy(r)+1).replace(uy,"")}function Ol(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var ju=NaN,fy=/^[-+]0x[0-9a-f]+$/i,dy=/^0b[01]+$/i,hy=/^0o[0-7]+$/i,py=parseInt;function Tu(r){if(typeof r=="number")return r;if(oy(r))return ju;if(Ol(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Ol(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=Ay(r);var e=dy.test(r);return e||hy.test(r)?py(r.slice(2),e?2:8):fy.test(r)?ju:+r}var Kl=function(){return Ou.Date.now()},my="Expected a function",Iy=Math.max,Cy=Math.min;function Ey(r,t,e){var n,i,l,a,o,s,c=0,u=!1,A=!1,d=!0;if(typeof r!="function")throw new TypeError(my);t=Tu(t)||0,Ol(e)&&(u=!!e.leading,A="maxWait"in e,l=A?Iy(Tu(e.maxWait)||0,t):l,d="trailing"in e?!!e.trailing:d);function f(b){var y=n,R=i;return n=i=void 0,c=b,a=r.apply(R,y),a}function h(b){return c=b,o=setTimeout(M,t),u?f(b):a}function m(b){var y=b-s,R=b-c,Z=t-y;return A?Cy(Z,l-R):Z}function I(b){var y=b-s,R=b-c;return s===void 0||y>=t||y<0||A&&R>=l}function M(){var b=Kl();if(I(b))return k(b);o=setTimeout(M,m(b))}function k(b){return o=void 0,d&&n?f(b):(n=i=void 0,a)}function S(){o!==void 0&&clearTimeout(o),c=0,n=s=i=o=void 0}function B(){return o===void 0?a:k(Kl())}function K(){var b=Kl(),y=I(b);if(n=arguments,i=this,s=b,y){if(o===void 0)return h(s);if(A)return clearTimeout(o),o=setTimeout(M,t),f(s)}return o===void 0&&(o=setTimeout(M,t)),a}return K.cancel=S,K.flush=B,K}class Wu{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=t=>(this.beforeMountedListeners.push(t),this),this.mounted=t=>(this.mountedListeners.push(t),this),this.updated=t=>(this.updatedListeners.push(t),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(t){return this.markdownUpdatedListeners.push(t),this}blur(t){return this.blurListeners.push(t),this}focus(t){return this.focusListeners.push(t),this}destroy(t){return this.destroyListeners.push(t),this}selectionUpdated(t){return this.selectionUpdatedListeners.push(t),this}}const K5=d2(new Wu,"listener"),My=new rt("MILKDOWN_LISTENER"),Pu=r=>(r.inject(K5,new Wu),async()=>{await r.wait(R0);const t=r.get(K5),{listeners:e}=t;e.beforeMount.forEach(s=>s(r)),await r.wait(nn);const n=r.get(p5);let i=null,l=null,a=null;const o=new nt({key:My,view:()=>({destroy:()=>{e.destroy.forEach(s=>s(r))}}),props:{handleDOMEvents:{focus:()=>(e.focus.forEach(s=>s(r)),!1),blur:()=>(e.blur.forEach(s=>s(r)),!1)}},state:{init:(s,c)=>{i=c.doc,l=n(c.doc)},apply:s=>{const c=s.selection;return(!a&&c||a&&!c.eq(a))&&(e.selectionUpdated.forEach(A=>{A(r,c,a)}),a=c),!(s.docChanged||s.storedMarksSet)||s.getMeta("addToHistory")===!1?void 0:Ey(()=>{const{doc:A}=s;if(e.updated.length>0&&i&&!i.eq(A)&&e.updated.forEach(d=>{d(r,A,i)}),e.markdownUpdated.length>0&&i&&!i.eq(A)){const d=n(A);e.markdownUpdated.forEach(f=>{f(r,d,l)}),l=d}i=A},200)()}}});r.update(n1,s=>s.concat(o)),await r.wait(M5),e.mounted.forEach(s=>s(r))});Pu.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};const Y3={wrapper:"_wrapper_1039w_1",editorContainer:"_editorContainer_1039w_6",editorContainerDisabled:"_editorContainerDisabled_1039w_16",editor:"_editor_1039w_6",placeholder:"_placeholder_1039w_72",error:"_error_1039w_80"},V3={container:"_container_10dwq_3",divider:"_divider_10dwq_40",noSelection:"_noSelection_10dwq_46"},vy=({href:r,open:t,hasSelection:e,onSave:n,onClose:i,anchorId:l,onRemove:a})=>{const[o,s]=E.useState(r),[c,u]=E.useState("empty");E.useEffect(()=>{t&&(s(r),u(r?"view":"empty"))},[t,r]);const A=()=>{const d=o.trim();if(!d)return;const f=/^https?:\/\//i.test(d)?d:`https://${d}`;try{const h=new URL(f);if(!["http:","https:"].includes(h.protocol))return;window.open(h.toString(),"_blank","noopener,noreferrer")}catch{}};return e?p.jsxs(v.Popover,{id:l,"data-color":"neutral",open:t,onClose:i,children:[c==="empty"&&e&&p.jsxs("div",{className:V3.container,children:[p.jsx(v.Input,{value:o,placeholder:"Skriv eller lim inn lenke",onChange:d=>s(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(n(o),i())}}),p.jsx(R2,{onClick:()=>n(o),variant:"ghost",color:"primary",children:p.jsx(l2,{material:"check"})})]}),c==="view"&&e&&p.jsxs("div",{className:V3.container,children:[p.jsxs(R2,{onClick:A,variant:"ghost",color:"primary",children:[p.jsx(l2,{material:"open_in_new"}),"Åpne i ny fane"]}),p.jsx("span",{className:V3.divider}),p.jsxs(R2,{onClick:()=>u("edit"),variant:"ghost",color:"primary",children:[p.jsx(l2,{material:"edit_square"}),"Rediger"]})]}),c==="edit"&&e&&p.jsxs("div",{className:V3.container,children:[p.jsx(v.Input,{value:o,onChange:d=>s(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(n(o),i())}}),p.jsx(R2,{onClick:()=>n(o),variant:"ghost",color:"primary",children:p.jsx(l2,{material:"check"})}),p.jsx("span",{className:V3.divider}),p.jsx(R2,{onClick:a,variant:"ghost",color:"danger",children:p.jsx(l2,{material:"delete"})})]})]}):p.jsx(v.Popover,{id:l,open:t,onClose:i,"data-color":"info",variant:"tinted",children:p.jsxs("div",{className:V3.noSelection,children:[p.jsx(l2,{material:"info"}),"Marker tekst for å legge til en lenke"]})})},An={toolbar:"_toolbar_imxx1_2",toolbarGroup:"_toolbarGroup_imxx1_11",toolbarButton:"_toolbarButton_imxx1_18",toolbarSelect:"_toolbarSelect_imxx1_31"},gy=["paragraph","h1","h2","h3"],Y0=({id:r,popoverTarget:t,label:e,icon:n,active:i,disabled:l,onClick:a})=>p.jsx("button",{id:r,type:"button",className:An.toolbarButton,onClick:a,disabled:l,popoverTarget:t,"aria-label":e,"aria-pressed":i,children:p.jsx(l2,{material:n,size:"sm"})}),zy=({disabled:r=!1,isBoldActive:t,isItalicActive:e,isBulletListActive:n,isOrderedListActive:i,isLinkActive:l,selectedFormat:a,linkPopoverTarget:o,onBulletList:s,onOrderedList:c,onBold:u,onItalic:A,onUndo:d,onRedo:f,onFormatChange:h,onLink:m})=>p.jsxs("div",{className:An.toolbar,role:"toolbar","aria-label":"Rich text formatting",children:[p.jsxs("div",{className:An.toolbarGroup,children:[p.jsx(Y0,{label:"Bold",icon:"format_bold",active:t,disabled:r,onClick:u}),p.jsx(Y0,{label:"Italic",icon:"format_italic",active:e,disabled:r,onClick:A}),p.jsx(Y0,{label:"Bullet List",icon:"format_list_bulleted",active:n,disabled:r,onClick:s}),p.jsx(Y0,{label:"Ordered List",icon:"format_list_numbered",active:i,disabled:r,onClick:c}),p.jsx(Y0,{label:"Link",icon:"link",active:l,disabled:r,id:o,popoverTarget:o,onClick:m}),p.jsxs("select",{className:An.toolbarSelect,disabled:r,"aria-label":"Heading levels",value:a,onChange:I=>{const M=I.target.value;gy.includes(M)&&h(M)},children:[p.jsx("option",{value:"paragraph",children:"Paragraph"}),p.jsx("option",{value:"h1",children:"Heading 1"}),p.jsx("option",{value:"h2",children:"Heading 2"})]})]}),p.jsxs("div",{className:An.toolbarGroup,children:[p.jsx(Y0,{label:"Undo",icon:"undo",disabled:r,onClick:d}),p.jsx(Y0,{label:"Redo",icon:"redo",disabled:r,onClick:f})]})]}),Xu=r=>{const t=r.trim();return t?/^(https?:|mailto:|tel:|ftp:|\/|#|\?|\/\/)/i.test(t)?t:`https://${t}`:""},Qy=r=>{const{from:t,to:e,empty:n,$from:i}=r.selection,l=r.schema.marks.link;if(!l||!n)return{from:t,to:e};const a=r.storedMarks??i.marks();if(!l.isInSet(a))return{from:t,to:e};let o=t,s=e,c=!1;const u=Math.max(0,t-1),A=Math.min(r.doc.content.size,t+1);if(r.doc.nodesBetween(u,A,(d,f)=>{if(c||!d.isText||!l.isInSet(d.marks))return;const h=f,m=f+d.nodeSize;if(!(t<h||t>m))return o=h,s=m,c=!0,!1}),!c)return{from:t,to:e};for(;o>0;){const f=r.doc.resolve(o).nodeBefore;if(!(f!=null&&f.isText)||!l.isInSet(f.marks))break;o-=f.nodeSize}for(;s<r.doc.content.size;){const f=r.doc.resolve(s).nodeAfter;if(!(f!=null&&f.isText)||!l.isInSet(f.marks))break;s+=f.nodeSize}return{from:o,to:s}},by=(r,t,e)=>{const n=r.schema.marks.link;if(!n)return"";let i="";return r.doc.nodesBetween(t,e,l=>{if(i||!l.isText)return;const a=n.isInSet(l.marks);if(a)return i=String(a.attrs.href??""),!1}),i},Sy={isBoldActive:!1,isItalicActive:!1,isBulletListActive:!1,isOrderedListActive:!1,selectedFormat:"paragraph",isLinkActive:!1},ky=(r,t)=>r.isBoldActive===t.isBoldActive&&r.isItalicActive===t.isItalicActive&&r.isBulletListActive===t.isBulletListActive&&r.isOrderedListActive===t.isOrderedListActive&&r.selectedFormat===t.selectedFormat&&r.isLinkActive===t.isLinkActive,yy=()=>{const[r,t]=E.useState(Sy);return{toolbarState:r,updateToolbarState:n=>{const i=n.get(fe),{state:l}=i,{from:a,to:o,empty:s,$from:c}=l.selection,u=f=>{const h=f.map(I=>l.schema.marks[I]).filter(I=>!!I);if(h.length===0)return!1;if(s)return(l.storedMarks??c.marks()).some(M=>h.includes(M.type));let m=!1;return l.doc.nodesBetween(a,o,I=>{if(m)return!1;if(h.some(M=>M.isInSet(I.marks)))return m=!0,!1}),m},A=f=>{const h=l.schema.nodes[f];if(!h)return!1;if(s){for(let I=c.depth;I>=0;I-=1)if(c.node(I).type===h)return!0;return!1}let m=!1;return l.doc.nodesBetween(a,o,I=>{if(m)return!1;if(I.type===h)return m=!0,!1}),m},d={isBoldActive:u(["strong"]),isItalicActive:u(["emphasis","em"]),isBulletListActive:A("bullet_list"),isOrderedListActive:A("ordered_list"),selectedFormat:A("heading")?`h${c.node(c.depth).attrs.level}`:"paragraph",isLinkActive:u(["link"])};t(f=>ky(f,d)?f:d)}}},Ry=({disabled:r,executeInEditor:t})=>{const[e,n]=E.useState(!1),[i,l]=E.useState(null),a=()=>{n(!1),l(null)};return{linkEditorOpen:e,linkEditorState:i,closeLinkEditor:a,openLinkEditor:()=>{t(u=>{const A=u.get(fe),d=Qy(A.state),f=by(A.state,d.from,d.to),h=d.from!==d.to||!!f;l({from:d.from,to:d.to,href:f,hasSelection:h}),n(!0)})},handleLinkSave:u=>{r||!i||t(A=>{const d=A.get(fe),f=d.state.schema.marks.link;if(!f){a();return}const h=Xu(u),m=d.state.tr.removeMark(i.from,i.to,f);h&&m.addMark(i.from,i.to,f.create({href:h})),d.dispatch(m),a()})},handleLinkRemove:()=>{r||!i||t(u=>{const A=u.get(fe),d=A.state.schema.marks.link;if(!d){a();return}A.dispatch(A.state.tr.removeMark(i.from,i.to,d)),a()})}}},Zy=({value:r,onChange:t,placeholder:e,disabled:n=!1,label:i,description:l,optional:a=!1,required:o=!1,error:s})=>{const c=E.useRef(t),u=E.useRef(r),{toolbarState:A,updateToolbarState:d}=yy(),f=`rich-text-link-editor-${E.useId().replace(/:/g,"")}`;c.current=t;const{loading:h,get:m}=FE(x=>G9.make().config(W=>{W.set(g5,x),W.set(m5,r),W.update(v5,(P={})=>({...P,editable:()=>!n,handleDOMEvents:{...P.handleDOMEvents,click:(H,L)=>{const w=L.target;if(!(w instanceof HTMLElement))return!1;const t2=w.closest("a[href]");if(!t2)return!1;const A2=t2.getAttribute("href");return A2?(L.preventDefault(),window.open(Xu(A2),"_blank","noopener,noreferrer"),!0):!1},keydown:(H,L)=>{if(L.key!==" "||L.ctrlKey||L.metaKey||L.altKey)return!1;const{state:w}=H,{selection:t2}=w,A2=w.schema.marks.link;if(!A2||!t2.empty)return!1;const{from:Q,$from:V}=t2,$=V.nodeBefore,g=V.nodeAfter,I2=A2.isInSet(w.storedMarks??V.marks()),ge=!!($!=null&&$.isText&&A2.isInSet($.marks));if(!I2&&!ge||g!=null&&g.isText&&A2.isInSet(g.marks))return!1;L.preventDefault();const U2=w.tr.setStoredMarks([]).insertText(" ",Q,Q);return H.dispatch(U2),!0}}})),W.get(K5).markdownUpdated((P,H)=>{if(H===u.current){d(P);return}u.current=H,c.current(H),d(P)}),W.get(K5).selectionUpdated(P=>{d(P)})}).use(Fk).use(pk).use(Pu),[n]);E.useEffect(()=>{const x=m();if(!x||r===u.current)return;let W=!1;x.action(P=>{W=P.get(fe).hasFocus()}),!W&&(u.current=r,x.action(hk(r)))},[m,r]),E.useEffect(()=>{const x=m();x&&x.action(W=>{d(W)})},[m]);const I=x=>{if(n)return;const W=m();W&&W.action(P=>{P.get(fe).focus(),x(P),d(P)})},M=x=>{I(W=>{W.get(b2).call(x.key,x.value)})},k=x=>{I(W=>{const P=W.get(b2);x.forEach(H=>P.call(H.key,H.value))})},{linkEditorOpen:S,linkEditorState:B,closeLinkEditor:K,openLinkEditor:b,handleLinkSave:y,handleLinkRemove:R}=Ry({disabled:n,executeInEditor:I}),Z=({isTargetListActive:x,isOtherListActive:W,wrapCommand:P})=>{if(x){M(cn);return}if(W){k([cn,P]);return}M(P)},T=x=>{M(x==="paragraph"?x5:{key:l1.key,value:parseInt(x.slice(1),10)})},q=!r&&!!e;return p.jsxs(v.Fieldset,{children:[i&&p.jsx(v.Fieldset.Legend,{children:p.jsx(Ne,{text:i,required:o,optional:a})}),l&&p.jsx(v.Fieldset.Description,{children:l}),p.jsxs("div",{className:Y3.wrapper,children:[p.jsx(zy,{disabled:n||h,isBoldActive:A.isBoldActive,isItalicActive:A.isItalicActive,isBulletListActive:A.isBulletListActive,isOrderedListActive:A.isOrderedListActive,selectedFormat:A.selectedFormat,isLinkActive:A.isLinkActive,onBold:()=>M(R5),onItalic:()=>M(y5),onUndo:()=>M(S5),onRedo:()=>M(k5),onLink:b,linkPopoverTarget:f,onBulletList:()=>Z({isTargetListActive:A.isBulletListActive,isOtherListActive:A.isOrderedListActive,wrapCommand:Y5}),onOrderedList:()=>Z({isTargetListActive:A.isOrderedListActive,isOtherListActive:A.isBulletListActive,wrapCommand:V5}),onFormatChange:T}),p.jsxs("div",{className:[Y3.editorContainer,n&&Y3.editorContainerDisabled].filter(Boolean).join(" "),children:[q?p.jsx("span",{className:Y3.placeholder,"aria-hidden":"true",children:e}):null,p.jsx("div",{className:Y3.editor,children:p.jsx(HE,{})})]}),p.jsx(vy,{open:S,anchorId:f,href:(B==null?void 0:B.href)??"",hasSelection:(B==null?void 0:B.hasSelection)??!1,onSave:y,onRemove:R,onClose:K}),s&&p.jsx(v.ValidationMessage,{className:Y3.error,children:s})]})]})},xy=({className:r,...t})=>p.jsx("div",{className:r,children:p.jsx(JE,{children:p.jsx(Zy,{...t})})}),By=({...r})=>{var l,a;const t=r.value?{value:r.value}:{defaultValue:""},[e,n]=E.useState(!1),i=[r.className,"override",e?"select-open":""].filter(Boolean).join(" ");return p.jsxs(v.Field,{children:[p.jsx(v.Label,{children:p.jsx(Ne,{text:r.label,required:r.required,optional:r.optional})}),r.description&&p.jsx(v.Field.Description,{children:r.description}),p.jsxs(v.Select,{id:r.id,className:i,width:"full",onChange:o=>{var s;(s=r.onChange)==null||s.call(r,o.target.value),n(!1)},onBlur:()=>{var o;(o=r.onBlur)==null||o.call(r),n(!1)},disabled:r.disabled,onMouseDown:()=>n(o=>!o),onKeyDown:o=>{o.key==="Enter"||o.key===" "||o.key==="ArrowDown"||o.key==="ArrowUp"?n(!0):o.key==="Escape"&&n(!1)},...t,children:[r.placeholder&&p.jsx(v.Select.Option,{disabled:!0,value:"",children:r.placeholder}),!r.placeholder&&(!r.value||!((l=r.options)!=null&&l.find(o=>o.value===r.value)))&&p.jsx(v.Select.Option,{disabled:!0,value:""}),(a=r.options)==null?void 0:a.map(o=>p.jsx(v.Select.Option,{value:o.value,children:o.label??o.value},o.value))]}),r.error&&p.jsx(v.ValidationMessage,{children:r.error})]})},Uy={notUnderlined:"_notUnderlined_jhlgm_1"},q5=({underlined:r=!0,className:t="",...e})=>{const n=[t];return r||n.push(Uy.notUnderlined),p.jsx(v.Tabs,{className:n.join(""),...e})};q5.List=v.Tabs.List,q5.Tab=v.Tabs.Tab,q5.Panel=v.Tabs.Panel;const Gu={bordered:"_bordered_103m7_2",rounded:"_rounded_103m7_33"},fn=({bordered:r=!1,rounded:t=!1,className:e="",...n})=>{const i=[e];return r&&i.push(Gu.bordered),t&&i.push(Gu.rounded),p.jsx(v.Tag,{className:i.join(" "),...n})},O3={"with-icon":"_with-icon_1cp54_2","link-icon":"_link-icon_1cp54_8","with-underline":"_with-underline_1cp54_12","link-icon-text":"_link-icon-text_1cp54_12","without-underline":"_without-underline_1cp54_16","without-icon":"_without-icon_1cp54_20"},ql=({underline:r,className:t,children:e,...n})=>{const i=[t];return r===void 0||r===!0?i.push(O3["with-underline"]):i.push(O3["without-underline"]),n.icon?(i.push(O3["with-icon"]),e=p.jsxs(p.Fragment,{children:[p.jsx(l2,{material:n.icon,size:"sm",className:O3["link-icon"]}),p.jsx("span",{className:O3["link-icon-text"],children:e})]})):i.push(O3["without-icon"]),p.jsx(v.Link,{className:i.join(" "),...n,children:e})},dn={opaqueHeader:"_opaqueHeader_yxlz3_1",table:"_table_yxlz3_6",white:"_white_yxlz3_10","cell-padding-md":"_cell-padding-md_yxlz3_50","radius-sm":"_radius-sm_yxlz3_55","radius-md":"_radius-md_yxlz3_59","radius-lg":"_radius-lg_yxlz3_63"},V0=({header:r="transparent",body:t="transparent",radius:e="none",className:n="","cell-padding":i="sm",...l})=>{l["data-color"]||(l["data-color"]="neutral");const a=[n,dn.table];return r&&r!=="transparent"&&a.push(dn.opaqueHeader),t&&t==="white"&&a.push(dn.white),e&&a.push(dn[`radius-${e}`]),i&&a.push(dn[`cell-padding-${i}`]),p.jsx(v.Table,{className:a.join(" "),...l})};V0.Cell=v.Table.Cell,V0.HeaderCell=v.Table.HeaderCell,V0.Head=v.Table.Head,V0.Body=v.Table.Body,V0.Row=v.Table.Row,V0.Foot=v.Table.Foot;const j5={size2xs:"_size2xs_1uyqe_1",size3xs:"_size3xs_1uyqe_8",surfaceTinted:"_surfaceTinted_1uyqe_15","border-solid":"_border-solid_1uyqe_92","border-dashed":"_border-dashed_1uyqe_96","border-dotted":"_border-dotted_1uyqe_100","border-double":"_border-double_1uyqe_104"},jl=({"data-size":r="md","data-color-variant":t="base",border:e,className:n,...i})=>{const l=[n];r==="2xs"?l.push(j5.size2xs):r==="3xs"&&l.push(j5.size3xs),t==="surface-tinted"&&l.push(j5.surfaceTinted),e&&l.push(j5[`border-${e}`]);const a={"data-size":r,className:l.join(" "),...i};return p.jsx(v.Avatar,{...a})},Tl=E.createContext({path:[]});function Yy({id:r,children:t}){const e=E.useContext(Tl),n=E.useMemo(()=>({path:[...e.path,r]}),[e.path,r]);return p.jsx(Tl.Provider,{value:n,children:t})}const Vy=()=>{const{path:r}=E.useContext(Tl);return{getId:(...e)=>[...r,...e].map(String).map(n=>n.toLocaleLowerCase()).join("__")}},K3={slotDialogOverrides:"_slotDialogOverrides_1foq3_2",dialogBlockBase:"_dialogBlockBase_1foq3_24",longContent:"_longContent_1foq3_27",headerBlock:"_headerBlock_1foq3_32",contentBlock:"_contentBlock_1foq3_42",buttonBlock:"_buttonBlock_1foq3_53"};function Oy({title:r,subtitle:t,open:e,onClose:n,ref:i,buttons:l,children:a,longContent:o}){const s=`${K3.dialogBlockBase} ${o?K3.longContent:""}`;return p.jsxs(v.Dialog,{open:e,onClose:n,ref:i,className:K3.slotDialogOverrides,closedby:"any",children:[p.jsxs(_,{gap:4,className:`${K3.headerBlock} ${s}`,children:[!!t&&p.jsx(v.Paragraph,{children:t}),p.jsx(v.Heading,{children:r})]}),p.jsx(_,{className:`${K3.contentBlock} ${s}`,children:p.jsx(_,{children:a})}),p.jsx(_,{className:`${K3.buttonBlock} ${s}`,children:p.jsx(_,{horizontal:!0,gap:12,children:l})})]})}Object.defineProperty(z,"Badge",{enumerable:!0,get:()=>v.Badge}),Object.defineProperty(z,"BadgePosition",{enumerable:!0,get:()=>v.BadgePosition}),Object.defineProperty(z,"Breadcrumbs",{enumerable:!0,get:()=>v.Breadcrumbs}),Object.defineProperty(z,"BreadcrumbsItem",{enumerable:!0,get:()=>v.BreadcrumbsItem}),Object.defineProperty(z,"BreadcrumbsLink",{enumerable:!0,get:()=>v.BreadcrumbsLink}),Object.defineProperty(z,"BreadcrumbsList",{enumerable:!0,get:()=>v.BreadcrumbsList}),Object.defineProperty(z,"Card",{enumerable:!0,get:()=>v.Card}),Object.defineProperty(z,"CardBlock",{enumerable:!0,get:()=>v.CardBlock}),Object.defineProperty(z,"Checkbox",{enumerable:!0,get:()=>v.Checkbox}),Object.defineProperty(z,"Chip",{enumerable:!0,get:()=>v.Chip}),Object.defineProperty(z,"ChipButton",{enumerable:!0,get:()=>v.ChipButton}),Object.defineProperty(z,"ChipCheckbox",{enumerable:!0,get:()=>v.ChipCheckbox}),Object.defineProperty(z,"ChipRadio",{enumerable:!0,get:()=>v.ChipRadio}),Object.defineProperty(z,"ChipRemovable",{enumerable:!0,get:()=>v.ChipRemovable}),Object.defineProperty(z,"Combobox",{enumerable:!0,get:()=>v.Combobox}),Object.defineProperty(z,"ComboboxEmpty",{enumerable:!0,get:()=>v.ComboboxEmpty}),Object.defineProperty(z,"ComboboxOption",{enumerable:!0,get:()=>v.ComboboxOption}),Object.defineProperty(z,"Details",{enumerable:!0,get:()=>v.Details}),Object.defineProperty(z,"DetailsContent",{enumerable:!0,get:()=>v.DetailsContent}),Object.defineProperty(z,"DetailsSummary",{enumerable:!0,get:()=>v.DetailsSummary}),Object.defineProperty(z,"Dialog",{enumerable:!0,get:()=>v.Dialog}),Object.defineProperty(z,"DialogBlock",{enumerable:!0,get:()=>v.DialogBlock}),Object.defineProperty(z,"DialogTrigger",{enumerable:!0,get:()=>v.DialogTrigger}),Object.defineProperty(z,"DialogTriggerContext",{enumerable:!0,get:()=>v.DialogTriggerContext}),Object.defineProperty(z,"Divider",{enumerable:!0,get:()=>v.Divider}),Object.defineProperty(z,"Dropdown",{enumerable:!0,get:()=>v.Dropdown}),Object.defineProperty(z,"DropdownButton",{enumerable:!0,get:()=>v.DropdownButton}),Object.defineProperty(z,"DropdownHeading",{enumerable:!0,get:()=>v.DropdownHeading}),Object.defineProperty(z,"DropdownItem",{enumerable:!0,get:()=>v.DropdownItem}),Object.defineProperty(z,"DropdownList",{enumerable:!0,get:()=>v.DropdownList}),Object.defineProperty(z,"DropdownTrigger",{enumerable:!0,get:()=>v.DropdownTrigger}),Object.defineProperty(z,"DropdownTriggerContext",{enumerable:!0,get:()=>v.DropdownTriggerContext}),Object.defineProperty(z,"EXPERIMENTAL_Suggestion",{enumerable:!0,get:()=>v.EXPERIMENTAL_Suggestion}),Object.defineProperty(z,"EXPERIMENTAL_SuggestionClear",{enumerable:!0,get:()=>v.EXPERIMENTAL_SuggestionClear}),Object.defineProperty(z,"EXPERIMENTAL_SuggestionEmpty",{enumerable:!0,get:()=>v.EXPERIMENTAL_SuggestionEmpty}),Object.defineProperty(z,"EXPERIMENTAL_SuggestionInput",{enumerable:!0,get:()=>v.EXPERIMENTAL_SuggestionInput}),Object.defineProperty(z,"EXPERIMENTAL_SuggestionList",{enumerable:!0,get:()=>v.EXPERIMENTAL_SuggestionList}),Object.defineProperty(z,"EXPERIMENTAL_SuggestionOption",{enumerable:!0,get:()=>v.EXPERIMENTAL_SuggestionOption}),Object.defineProperty(z,"ErrorSummary",{enumerable:!0,get:()=>v.ErrorSummary}),Object.defineProperty(z,"ErrorSummaryHeading",{enumerable:!0,get:()=>v.ErrorSummaryHeading}),Object.defineProperty(z,"ErrorSummaryItem",{enumerable:!0,get:()=>v.ErrorSummaryItem}),Object.defineProperty(z,"ErrorSummaryLink",{enumerable:!0,get:()=>v.ErrorSummaryLink}),Object.defineProperty(z,"ErrorSummaryList",{enumerable:!0,get:()=>v.ErrorSummaryList}),Object.defineProperty(z,"Field",{enumerable:!0,get:()=>v.Field}),Object.defineProperty(z,"FieldAffix",{enumerable:!0,get:()=>v.FieldAffix}),Object.defineProperty(z,"FieldAffixes",{enumerable:!0,get:()=>v.FieldAffixes}),Object.defineProperty(z,"FieldCounter",{enumerable:!0,get:()=>v.FieldCounter}),Object.defineProperty(z,"FieldDescription",{enumerable:!0,get:()=>v.FieldDescription}),Object.defineProperty(z,"Fieldset",{enumerable:!0,get:()=>v.Fieldset}),Object.defineProperty(z,"FieldsetDescription",{enumerable:!0,get:()=>v.FieldsetDescription}),Object.defineProperty(z,"FieldsetLegend",{enumerable:!0,get:()=>v.FieldsetLegend}),Object.defineProperty(z,"Heading",{enumerable:!0,get:()=>v.Heading}),Object.defineProperty(z,"Input",{enumerable:!0,get:()=>v.Input}),Object.defineProperty(z,"Label",{enumerable:!0,get:()=>v.Label}),Object.defineProperty(z,"List",{enumerable:!0,get:()=>v.List}),Object.defineProperty(z,"ListItem",{enumerable:!0,get:()=>v.ListItem}),Object.defineProperty(z,"ListOrdered",{enumerable:!0,get:()=>v.ListOrdered}),Object.defineProperty(z,"ListUnordered",{enumerable:!0,get:()=>v.ListUnordered}),Object.defineProperty(z,"Pagination",{enumerable:!0,get:()=>v.Pagination}),Object.defineProperty(z,"PaginationButton",{enumerable:!0,get:()=>v.PaginationButton}),Object.defineProperty(z,"PaginationItem",{enumerable:!0,get:()=>v.PaginationItem}),Object.defineProperty(z,"PaginationList",{enumerable:!0,get:()=>v.PaginationList}),Object.defineProperty(z,"Paragraph",{enumerable:!0,get:()=>v.Paragraph}),Object.defineProperty(z,"Popover",{enumerable:!0,get:()=>v.Popover}),Object.defineProperty(z,"PopoverTrigger",{enumerable:!0,get:()=>v.PopoverTrigger}),Object.defineProperty(z,"PopoverTriggerContext",{enumerable:!0,get:()=>v.PopoverTriggerContext}),Object.defineProperty(z,"Radio",{enumerable:!0,get:()=>v.Radio}),Object.defineProperty(z,"RovingFocusItem",{enumerable:!0,get:()=>v.RovingFocusItem}),Object.defineProperty(z,"RovingFocusRoot",{enumerable:!0,get:()=>v.RovingFocusRoot}),Object.defineProperty(z,"Search",{enumerable:!0,get:()=>v.Search}),Object.defineProperty(z,"SearchButton",{enumerable:!0,get:()=>v.SearchButton}),Object.defineProperty(z,"SearchClear",{enumerable:!0,get:()=>v.SearchClear}),Object.defineProperty(z,"SearchInput",{enumerable:!0,get:()=>v.SearchInput}),Object.defineProperty(z,"SelectOptgroup",{enumerable:!0,get:()=>v.SelectOptgroup}),Object.defineProperty(z,"Skeleton",{enumerable:!0,get:()=>v.Skeleton}),Object.defineProperty(z,"SkipLink",{enumerable:!0,get:()=>v.SkipLink}),Object.defineProperty(z,"Spinner",{enumerable:!0,get:()=>v.Spinner}),Object.defineProperty(z,"Suggestion",{enumerable:!0,get:()=>v.EXPERIMENTAL_Suggestion}),Object.defineProperty(z,"Switch",{enumerable:!0,get:()=>v.Switch}),Object.defineProperty(z,"TableBody",{enumerable:!0,get:()=>v.TableBody}),Object.defineProperty(z,"TableCell",{enumerable:!0,get:()=>v.TableCell}),Object.defineProperty(z,"TableFoot",{enumerable:!0,get:()=>v.TableFoot}),Object.defineProperty(z,"TableHead",{enumerable:!0,get:()=>v.TableHead}),Object.defineProperty(z,"TableHeaderCell",{enumerable:!0,get:()=>v.TableHeaderCell}),Object.defineProperty(z,"TableRow",{enumerable:!0,get:()=>v.TableRow}),Object.defineProperty(z,"TabsList",{enumerable:!0,get:()=>v.TabsList}),Object.defineProperty(z,"TabsPanel",{enumerable:!0,get:()=>v.TabsPanel}),Object.defineProperty(z,"TabsTab",{enumerable:!0,get:()=>v.TabsTab}),Object.defineProperty(z,"Textarea",{enumerable:!0,get:()=>v.Textarea}),Object.defineProperty(z,"Textfield",{enumerable:!0,get:()=>v.Textfield}),Object.defineProperty(z,"ToggleGroup",{enumerable:!0,get:()=>v.ToggleGroup}),Object.defineProperty(z,"ToggleGroupItem",{enumerable:!0,get:()=>v.ToggleGroupItem}),Object.defineProperty(z,"Tooltip",{enumerable:!0,get:()=>v.Tooltip}),Object.defineProperty(z,"ValidationMessage",{enumerable:!0,get:()=>v.ValidationMessage}),Object.defineProperty(z,"omit",{enumerable:!0,get:()=>v.omit}),Object.defineProperty(z,"useCheckboxGroup",{enumerable:!0,get:()=>v.useCheckboxGroup}),Object.defineProperty(z,"useDebounceCallback",{enumerable:!0,get:()=>v.useDebounceCallback}),Object.defineProperty(z,"useIsomorphicLayoutEffect",{enumerable:!0,get:()=>v.useIsomorphicLayoutEffect}),Object.defineProperty(z,"useMediaQuery",{enumerable:!0,get:()=>v.useMediaQuery}),Object.defineProperty(z,"usePagination",{enumerable:!0,get:()=>v.usePagination}),Object.defineProperty(z,"useRadioGroup",{enumerable:!0,get:()=>v.useRadioGroup}),Object.defineProperty(z,"useSynchronizedAnimation",{enumerable:!0,get:()=>v.useSynchronizedAnimation}),z.Accent=J5,z.Alert=bA,z.Avatar=jl,z.Body=At,z.BorderedRadioGroup=xd,z.BorderedToggleGroup=Zd,z.Box=_,z.Button=R2,z.CardTitle=jE,z.DateTimePicker=NC,z.Datepicker=FC,z.DeprecatedCard=wl,z.DeprecatedDetails=oA,z.DeprecatedErrorLabel=lA,z.DeprecatedInputLabel=aA,z.FilePreviewer=X5,z.FileUploader=KE,z.FileUploaderContext=po,z.Footer=Xd,z.Header=Jd,z.Icon=l2,z.IdProvider=Yy,z.ImageAisSat=Zf,z.ImageArcticInfo=Bf,z.ImageAvgiftskalkulator=Uf,z.ImageBaatfartMarine=Yf,z.ImageBestilleLos=Vf,z.ImageBoelgevarsel=Of,z.ImageBwArcticinfo=Cd,z.ImageBwBoelgevarsel=Id,z.ImageBwNais=pd,z.ImageBwOhoi=md,z.ImageDatakatalog=xf,z.ImageDigitaleFyrbesoek=nd,z.ImageDigitaleReferanseruter=Kf,z.ImageEDialog=qf,z.ImageFarledsbevis=jf,z.ImageFarvannsskiltOgNavinnretninger=Ed,z.ImageFarvannsskiltOgNavinnretningerFarget=Md,z.ImageForespoerselSendt=hd,z.ImageHais=Rf,z.ImageHavbase=Wf,z.ImageHavnOgFarvannsloven=Pf,z.ImageHavnOgFarvannslovenFarget=Xf,z.ImageIsmelding=Gf,z.ImageIsmeldingFarget=Hf,z.ImageKikkert=Jf,z.ImageKystdatahuset=Ff,z.ImageKystinfoKart=wf,z.ImageKystreise=ad,z.ImageKystvaer=dd,z.ImageLavutslipp=Nf,z.ImageMarU=id,z.ImageMegafon=od,z.ImageNais=fd,z.ImageNavarea=ld,z.ImageNavigasjonsvarsler=Df,z.ImageNavigasjonsvarslerFarget=Lf,z.ImageOhoi=_f,z.ImageRegistrerteSeilaser=$f,z.ImageSafeSeaNet=sd,z.ImageSeLosbestilling=ed,z.ImageSelvbetjening=cd,z.ImageSelvbetjeningRso=ud,z.ImageSelvbetjeningRsoFarget=Ad,z.ImageSkadePaaInfrastruktur=vd,z.ImageSkadePaaInfrastrukturFarget=gd,z.ImageSkipsrapportering=td,z.ImageSlukkedeFyrlys=rd,z.ImageSoeknadOmFarledsbevis=Tf,z.ImageTilskuddTilFiskerihavn=zd,z.ImageTilskuddTilFiskerihavnFarget=Qd,z.ImageUtfordringIFarvannet=bd,z.ImageUtfordringIFarvannetFarget=Sd,z.KyvDivider=zA,z.LabelContent=Ne,z.Link=ql,z.Logo=w5,z.NumberInput=PE,z.PageHeading=QA,z.RichTextArea=xy,z.Select=By,z.Skillingsbuoye=yd,z.SlotDialog=Oy,z.Stepper=YA,z.Summary=Kd,z.Table=V0,z.Tabs=q5,z.Tag=fn,z.TextArea=XE,z.TextInput=TE,z.Typography=Rd,z.svgImageColors=yf,z.useIdProvider=Vy,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kystverket/styrbord",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {
@@ -54,5 +54,8 @@
54
54
  "react-datepicker": "^8.4.0",
55
55
  "react-dom": "^19.0.0",
56
56
  "uuid": "^11.1.0"
57
+ },
58
+ "peerDependencies": {
59
+ "@kystverket/sprak-react": "^0.0.14"
57
60
  }
58
61
  }