dsh-artifact-studio 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +3 -2
- package/assets/canvas.engine.js +1 -1
- package/client.canvas.js +1 -1
- package/client.doc.js +79 -67
- package/dist/host/lib/rpc.js +0 -11
- package/dist/host/lib/service.js +0 -19
- package/dist/host/lib/skill.js +10 -2
- package/dist/host/lib/store.js +0 -48
- package/dist/host/lib/tools.js +2 -17
- package/package.json +3 -1
- package/dist/host/lib/editor-leases.js +0 -63
package/client.doc.js
CHANGED
|
@@ -4,39 +4,39 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
factory(require) {
|
|
5
5
|
var module = { exports: {} };
|
|
6
6
|
var exports = module.exports;
|
|
7
|
-
"use strict";var Ai=Object.defineProperty;var Ip=Object.getOwnPropertyDescriptor;var Dp=Object.getOwnPropertyNames;var Lp=Object.prototype.hasOwnProperty;var Pp=(t,e)=>{for(var n in e)Ai(t,n,{get:e[n],enumerable:!0})},zp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Dp(e))!Lp.call(t,s)&&s!==n&&Ai(t,s,{get:()=>e[s],enumerable:!(r=Ip(e,s))||r.enumerable});return t};var $p=t=>zp(Ai({},"__esModule",{value:!0}),t);var rS={};Pp(rS,{mountDocEditor:()=>nS});module.exports=$p(rS);var Ca=Object.defineProperty,va=(t,e)=>{let n={};for(var r in t)Ca(n,r,{get:t[r],enumerable:!0});return e||Ca(n,Symbol.toStringTag,{value:"Module"}),n};function le(t){this.content=t}le.prototype={constructor:le,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new le(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new le(n)},addToStart:function(t,e){return new le([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new le(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new le(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=le.from(t),t.size?new le(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=le.from(t),t.size?new le(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=le.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};le.from=function(t){if(t instanceof le)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new le(e)};var Ei=le;function za(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,a=0;for(;o[a]==l[a];a++)n++;return a&&a<o.length&&a<l.length&&Ha(o.charCodeAt(a-1))&&Ba(o.charCodeAt(a))&&n--,n}if(s.content.size||i.content.size){let o=za(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function $a(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&Ha(c.charCodeAt(d-1))&&Ba(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let c=$a(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Ba(t){return t>=56320&&t<57344}function Ha(t){return t>=55296&&t<56320}var w=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new t(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new t(r,s)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new t(s,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return za(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return $a(this,e,n,r)}findIndex(e){if(e==0)return Or(0,e);if(e==this.size)return Or(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Or(n+1,i):Or(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};w.empty=new w([],0);var Ri={index:0,offset:0};function Or(t,e){return Ri.index=t,Ri.offset=e,Ri}function Lr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Lr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Lr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var F=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Lr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};F.none=[];var ut=class extends Error{},v=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ja(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(Fa(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(w.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new t(e,r,s)}};v.empty=new v(w.empty,0,0);function Fa(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Fa(i.content,e-s-1,n-s-1)))}function ja(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=ja(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function Bp(t,e,n){if(n.openStart>t.depth)throw new ut("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ut("Inconsistent open depths");return _a(t,e,n,0)}function _a(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=_a(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Et(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Hp(n,t);return Et(i,Va(t,o,l,e,r))}else return Et(i,Pr(t,e,r))}function Wa(t,e){if(!e.type.compatibleContent(t.type))throw new ut("Cannot join "+e.type.name+" onto "+t.type.name)}function Ni(t,e,n){let r=t.node(n);return Wa(r,e.node(n)),r}function At(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function zn(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(At(t.nodeAfter,r),i++));for(let l=i;l<o;l++)At(s.child(l),r);e&&e.depth==n&&e.textOffset&&At(e.nodeBefore,r)}function Et(t,e){if(!t.type.validContent(e))throw new ut("Invalid content for node "+t.type.name);return t.copy(e)}function Va(t,e,n,r,s){let i=t.depth>s&&Ni(t,e,s+1),o=r.depth>s&&Ni(n,r,s+1),l=[];return zn(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(Wa(i,o),At(Et(i,Va(t,e,n,r,s+1)),l)):(i&&At(Et(i,Pr(t,e,s+1)),l),zn(e,n,s,l),o&&At(Et(o,Pr(n,r,s+1)),l)),zn(r,null,s,l),new w(l)}function Pr(t,e,n){let r=[];if(zn(null,t,n,r),t.depth>n){let s=Ni(t,e,n+1);At(Et(s,Pr(t,e,n+1)),r)}return zn(e,null,n,r),new w(r)}function Hp(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(w.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}var zr=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Rt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=Ma.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Ma.set(e,r=new Oi);let s=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%Fp,s}},Oi=class{constructor(){this.elts=[],this.i=0}},Fp=12,Ma=new WeakMap,Rt=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},jp=Object.create(null),De=class t{constructor(e,n,r,s=F.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||w.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Lr(this.attrs,n||e.defaultAttrs||jp)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return v.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new v(c,s.depth-o,i.depth-o)}replace(e,n,r){return Bp(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return zr.resolveCached(this,e)}resolveNoCache(e){return zr.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ka(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=w.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Aa(this.type.attrs,this.attrs,"node",this.type.name);let e=F.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Aa(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=w.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,s,r)}};De.prototype.text=void 0;var Ta=(()=>{let{stack:t}=new Error("/");if(!t||!/\n\s*at\s/.test(t))return n=>n;let e=Object.create(null);return n=>(e[n],n)})(),Ii=class t extends De{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ka(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return Ta(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(Ta(this.text.slice(e,n)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ka(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Aa(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}var Nt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Di(e,n);if(r.next==null)return t.empty;let s=Ua(r);r.next&&r.err("Unexpected trailing text");let i=Jp(qp(s));return Gp(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return w.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
8
|
-
`)}};Nt.empty=new Nt(!0);var Di=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Ua(t){let e=[];do e.push(_p(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function _p(t){let e=[];do e.push(Wp(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Wp(t){let e=Up(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Vp(t,e);else break;return e}function Ea(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Vp(t,e){let n=Ea(t),r=n;return t.eat(",")&&(t.next!="}"?r=Ea(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Kp(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function Up(t){if(t.eat("(")){let e=Ua(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Kp(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function qp(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function qa(t,e){return e-t}function Ra(t,e){let n=[];return r(e),n.sort(qa);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function Jp(t){let e=Object.create(null);return n(Ra(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Ra(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Nt(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(qa);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function Gp(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ja(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Ga(t,e){let n=Object.create(null);for(let r in t){let s=t[r],i=e&&e[r];if(i===void 0)if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r);else s.validate&&s.validate(i);n[r]=i}return n}function Xa(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Li(t,r,e[r]);return n}var rn=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Xa(e,r.attrs),this.defaultAttrs=Ja(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Nt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ga(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new De(this,this.computeAttrs(e),w.from(n),F.setFrom(r))}createChecked(e=null,n,r){return n=w.from(n),this.checkContent(n),new De(this,this.computeAttrs(e),n,F.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=w.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(w.empty,!0);return i?new De(this,e,n.append(i),F.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:F.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new t(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Xp(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var Li=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Xp(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Bn=class t{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=Xa(e,s.attrs),this.excluded=null;let i=Ja(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Ga(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new t(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},Ot=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Ei.from(e.nodes),n.marks=Ei.from(e.marks||{}),this.nodes=rn.compile(this.spec.nodes,this),this.marks=Bn.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Nt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Na(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Na(this,o.split(" "))}this.nodeFromJSON=s=>De.fromJSON(this,s),this.markFromJSON=s=>F.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof rn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Ii(r,r.defaultAttrs,e,F.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Na(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Yp(t){return t.tag!=null}function Qp(t){return t.style!=null}var Fe=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Yp(s))this.tags.push(s);else if(Qp(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new $r(this,n,!1);return r.addAll(e,F.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new $r(this,n,!0);return r.addAll(e,F.none,n.from,n.to),v.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(tm(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ia(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ia(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},Ya={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Zp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qa={ol:!0,ul:!0},Hn=1,Pi=2,$n=4;function Oa(t,e,n){return e!=null?(e?Hn:0)|(e==="full"?Pi:0):t&&t.whitespace=="pre"?Hn|Pi:n&~$n}var nn=class{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=F.none,this.match=i||(o&$n?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(w.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Hn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=w.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ya.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},$r=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Oa(null,n.preserveWhitespace,0)|(r?$n:0);s?i=new nn(s.type,s.attrs,F.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new nn(null,null,F.none,!0,null,o):i=new nn(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Pi?"full":this.localPreserveWS||(s.options&Hn)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
9
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;
|
|
10
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=F.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Da(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Oa(e,i,o.options);o.options&$n&&o.content.length==0&&(l|=$n);let a=F.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Da(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new nn(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Hn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function em(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Qa.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function tm(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ia(t){let e={};for(let n in t)e[n]=t[n];return e}function Da(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}var Ge=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ir(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Ir(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Dr(Ir(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Dr(Ir(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Dr(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=La(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return La(e.marks)}};function La(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ir(t){return t.document||window.document}var Pa=new WeakMap;function nm(t){let e=Pa.get(t);return e===void 0&&Pa.set(t,e=rm(t)),e}function rm(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Dr(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=nm(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=Dr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var rc=65535,sc=Math.pow(2,16);function sm(t,e){return t+e*sc}function Za(t){return t&rc}function im(t){return(t-(t&rc))/sc}var ic=1,oc=2,Br=4,lc=8,_n=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&lc)>0}get deletedBefore(){return(this.delInfo&(ic|Br))>0}get deletedAfter(){return(this.delInfo&(oc|Br))>0}get deletedAcross(){return(this.delInfo&Br)>0}},Xe=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Za(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+im(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+s+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:sm(l/3,e-a),m=0;return c&&(m|=e==a?oc:e==d?ic:Br,(n<0?e!=a:e!=d)&&(m|=lc)),new _n(h,m,p)}s+=u-c}return r?e+s:new _n(e+s,0,null)}touches(e,n){let r=0,s=Za(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Xe.empty=new Xe([]);var Wn=class t{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new _n(e,s,null)}},zi=Object.create(null),X=class{getMap(){return Xe.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=zi[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in zi)throw new RangeError("Duplicate use of step JSON ID "+e);return zi[e]=n,n.prototype.jsonID=e,n}},re=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,s){try{return t.ok(e.replace(n,r,s))}catch(i){if(i instanceof ut)return t.fail(i.message);throw i}}};function Fi(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Fi(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return w.fromArray(r)}var Vn=class t extends X{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new v(Fi(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return re.fromReplace(e,this.from,this.to,i)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!F.sameSet(i,r.marks)){let o=Math.max(this.from,s),l=Math.min(this.to,s+r.nodeSize);Hr(dt,o,l,this.mark,n);for(let a of r.marks)a.isInSet(i)||Hr(t,o,l,a,n)}}}),n.length==1?n[0]:new Kn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};X.jsonID("addMark",Vn);var dt=class t extends X{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new v(Fi(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return re.fromReplace(e,this.from,this.to,r)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Hr(Vn,Math.max(this.from,s),Math.min(this.to,s+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new Kn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};X.jsonID("removeMark",dt);function Hr(t,e,n,r,s){let i=s.length?s[s.length-1]:null;i&&i instanceof t&&i.to==e&&i.mark.eq(r)?s[s.length-1]=new t(i.from,n,r):s.push(new t(e,n,r))}var Kn=class t extends X{constructor(e){super(),this.steps=e}apply(e){for(let n of this.steps){let r=n.apply(e);if(!r.doc)return r;e=r.doc}return new re(e,null)}invert(e){return new t(this.steps.map(n=>n.invert(e)))}map(e){let n=[];for(let r of this.steps){let s=r.map(e);s&&n.push(s)}return n.length?new t(n):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,n){if(!Array.isArray(n.steps)||!n.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new t(n.steps.map(r=>X.fromJSON(e,r)))}};X.jsonID("markSet",Kn);var Un=class t extends X{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new t(this.pos,n.marks[s]);return new t(this.pos,this.mark)}}return new sn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};X.jsonID("addNodeMark",Un);var sn=class t extends X{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Un(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};X.jsonID("removeNodeMark",sn);var Y=class t extends X{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Bi(e,this.from,this.to)?re.fail("Structure replace would overwrite content"):re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?v.empty:new v(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?v.empty:new v(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,v.fromJSON(e,n.slice),!!n.structure)}};Y.MAP_BIAS=1;X.jsonID("replace",Y);var Q=class t extends X{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Bi(e,this.from,this.gapFrom)||Bi(e,this.gapTo,this.to)))return re.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return re.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?re.fromReplace(e,this.from,this.to,r):re.fail("Content does not fit in gap")}getMap(){return new Xe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos||s>i?null:new t(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,v.fromJSON(e,n.slice),n.insert,!!n.structure)}};X.jsonID("replaceAround",Q);function Bi(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function om(t,e,n,r){let s=[];t.doc.nodesBetween(e,n,(i,o,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(o,e),u=Math.min(o+i.nodeSize,n);Hr(Vn,c,u,r,s)}}),s.forEach(i=>t.step(i))}function lm(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline||!o.isAtom)return;i++;let a=null;if(r instanceof Bn){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new dt(o.from,o.to,o.style)))}function ji(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Y(l,u,v.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new dt(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new v(w.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Y(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(w.empty,!0);t.replace(l,l,new v(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function am(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ye(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!am(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function cm(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=w.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=w.from(r.node(p).copy(u)),d++):a--;let f=w.empty,h=0;for(let p=i,m=!1;p>n;p--)m||s.after(p+1)<s.end(p)?(m=!0,f=w.from(s.node(p).copy(f)),h++):c++;t.step(new Q(a,c,o,l,new v(u.append(f),d,h),u.size-d,!0))}function ln(t,e,n=null,r=t){let s=um(t,e),i=s&&dm(r,e);return i?s.map(ec).concat({type:e,attrs:n}).concat(i.map(ec)):null}function ec(t){return{type:t,attrs:null}}function um(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function dm(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function fm(t,e,n){let r=w.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=w.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Q(s,i,s,i,new v(r,0,0),n.length,!0))}function hm(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&pm(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&cc(t,o,l,i),ji(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return t.step(new Q(d,f,d+1,f-1,new v(w.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&ac(t,o,l,i),!1}})}function ac(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function cc(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
11
|
-
`))}})}function pm(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function mm(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Q(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new v(w.from(o),0,0),1,!0))}function Ae(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function gm(t,e,n=1,r){let s=t.doc.resolve(e),i=w.empty,o=w.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=w.from(s.node(l).copy(i));let u=r&&r[c];o=w.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Y(e,e,new v(i.append(o),n,n),!0))}function Le(t,e){let n=t.resolve(e),r=n.index();return uc(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function ym(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function uc(t,e){return!!(t&&e&&!t.isLeaf&&ym(t,e))}function an(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&uc(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function km(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);cc(t,u.node(),u.before(),l)}o.inlineContent&&ji(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Y(c,a.map(e+n,-1),v.empty,!0)),r===!0){let u=t.doc.resolve(c);ac(t,u.node(),u.before(),t.steps.length)}return t}function bm(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function _r(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function qn(t,e,n=e,r=v.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return dc(s,i,r)?new Y(e,n,r):new Hi(s,i,r).fit()}function dc(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Hi=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=w.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=w.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new v(i,o,l);return e>-1?new Q(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Y(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=tc(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(w.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return nc(e,-1)<=n?!1:(this.unplaced.size>1&&nc(e,1)>r&&r++,this.unplaced=new v(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=tc(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new v(Fn(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new v(Fn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(s){for(let m=0;m<s.childCount;m++)u.push(s.child(m));d=d.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(fc(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=jn(this.placed,n,w.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<h;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=p?e==0?v.empty:new v(Fn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new v(Fn(o.content,e,c),e,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!$i(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=$i(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=$i(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=jn(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=jn(this.placed,this.depth,w.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(w.empty,!0);n.childCount&&(this.placed=jn(this.placed,this.frontier.length,n))}};function Fn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Fn(t.firstChild.content,e-1,n)))}function jn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(jn(t.lastChild.content,e-1,n)))}function tc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function fc(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,fc(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(w.empty,!0)))),t.copy(r)}function $i(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!wm(n,i.content,o)?l:null}function wm(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function xm(t){return t.spec.defining||t.spec.definingForContent}function nc(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function Sm(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(dc(s,i,r))return t.step(new Y(e,n,r));let o=pc(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=xm(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let k=s.node(g-1),b=s.index(g-1);if(k.canReplaceWith(b,b,p.type,p.marks))return t.replace(s.before(g),y?i.after(g):n,new v(hc(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=s.before(h),n=i.after(h))}}function hc(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(hc(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(w.empty,!0))}return t}function Cm(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=bm(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new v(w.from(r),0,0))}function vm(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&n==s.start(a);a--)n=s.before(a);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=pc(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function pc(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}var Fr=class t extends X{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(s),0,n.isLeaf?0:1))}getMap(){return Xe.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};X.jsonID("attr",Fr);var jr=class t extends X{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return re.ok(r)}getMap(){return Xe.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};X.jsonID("docAttr",jr);var on=class extends Error{};on=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};on.prototype=Object.create(Error.prototype);on.prototype.constructor=on;on.prototype.name="TransformError";var ft=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Wn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new on(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=v.empty){let s=qn(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new v(w.from(r),0,0))}delete(e,n){return this.replace(e,n,v.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Sm(this,e,n,r),this}replaceRangeWith(e,n,r){return Cm(this,e,n,r),this}deleteRange(e,n){return vm(this,e,n),this}lift(e,n){return cm(this,e,n),this}join(e,n=1){return km(this,e,n),this}wrap(e,n){return fm(this,e,n),this}setBlockType(e,n=e,r,s=null){return hm(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return mm(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Fr(e,n,r)),this}setDocAttribute(e,n){return this.step(new jr(e,n)),this}addNodeMark(e,n){return this.step(new Un(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof F)n.isInSet(r.marks)&&this.step(new sn(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new sn(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return gm(this,e,n,r),this}addMark(e,n,r){return om(this,e,n,r),this}removeMark(e,n,r){return lm(this,e,n,r),this}clearIncompatible(e,n,r){return ji(this,e,n,r),this}};var _i=Object.create(null),R=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new un(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=v.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?v.empty:n),l==0&&yc(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),yc(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new M(e):cn(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?cn(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):cn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new me(e.node(0))}static atStart(e){return cn(e,e,0,0,1)||new me(e)}static atEnd(e){return cn(e,e,e.content.size,e.childCount,-1)||new me(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=_i[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in _i)throw new RangeError("Duplicate use of selection JSON ID "+e);return _i[e]=n,n.prototype.jsonID=e,n}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};R.prototype.visible=!0;var un=class{constructor(e,n){this.$from=e,this.$to=n}},mc=!1;function gc(t){!mc&&!t.parent.inlineContent&&(mc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var M=class t extends R{constructor(e,n=e){gc(e),gc(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return R.near(r);let s=e.resolve(n.map(this.anchor));return new t(s.parent.inlineContent?s:r,r)}replace(e,n=v.empty){if(super.replace(e,n),n==v.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=R.findFrom(n,r,!0)||R.findFrom(n,-r,!0);if(i)n=i.$head;else return R.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new t(e,n)}};R.jsonID("text",M);var Vr=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},N=class t extends R{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?R.near(i):new t(i)}content(){return new v(w.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Vi(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};N.prototype.visible=!1;R.jsonID("node",N);var Vi=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Vr(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&N.isSelectable(r)?new N(n):R.near(n)}},me=class t extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=v.empty){if(n==v.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Mm}};R.jsonID("all",me);var Mm={map(){return this},resolve(t){return new me(t)}};function cn(t,e,n,r,s,i=!1){if(e.inlineContent)return M.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(t,n-(s<0?l.nodeSize:0))}else{let a=cn(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function yc(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Y||s instanceof Q))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(R.near(t.doc.resolve(o),n))}var kc=1,Wr=2,bc=4,Ki=class extends ft{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|kc)&~Wr,this.storedMarks=null,this}get selectionSet(){return(this.updated&kc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Wr,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Wr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Wr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=bc,this}get scrolledIntoView(){return(this.updated&bc)>0}};function wc(t,e){return!e||!t?t:t.bind(e)}var It=class{constructor(e,n,r){this.name=e,this.init=wc(n.init,r),this.apply=wc(n.apply,r)}},Tm=[new It("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new It("selection",{init(t,e){return t.selection||R.atStart(e.doc)},apply(t){return t.selection}}),new It("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new It("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Jn=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tm.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new It(r.key,r.spec.state,r))})}},Dt=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Ki(this)}static create(e){let n=new Jn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Jn(this.schema,e.plugins),r=n.fields,s=new t(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Jn(e.schema,e.plugins),i=new t(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=De.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=R.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}};function xc(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=xc(s,e,{})),n[r]=s}return n}var L=class{constructor(e){this.spec=e,this.props={},e.props&&xc(e.props,this,this.props),this.key=e.key?e.key.key:Sc("plugin")}getState(e){return e[this.key]}},Wi=Object.create(null);function Sc(t){return t in Wi?t+"$"+ ++Wi[t]:(Wi[t]=0,t+"$")}var j=class{constructor(e="key"){this.key=Sc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var vc=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Mc(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var qi=(t,e,n)=>{let r=Mc(t,n);if(!r)return!1;let s=Gi(r);if(!s){let o=r.blockRange(),l=o&&Ye(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Ic(t,s,e,-1))return!0;if(r.parent.content.size==0&&(dn(i,"end")||N.isSelectable(i)))for(let o=r.depth;;o--){let l=qn(t.doc,r.before(o),r.after(o),v.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(dn(i,"end")?R.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):N.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Kr=(t,e,n)=>{let r=Mc(t,n);if(!r)return!1;let s=Gi(r);return s?Tc(t,s,e):!1},Ur=(t,e,n)=>{let r=Ac(t,n);if(!r)return!1;let s=Qi(r);return s?Tc(t,s,e):!1};function Tc(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=qn(t.doc,i,a,v.empty);if(!c||c.from!=i||c instanceof Y&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(M.create(u.doc,i)),n(u.scrollIntoView())}return!0}function dn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ji=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Gi(r)}let o=i&&i.nodeBefore;return!o||!N.isSelectable(o)?!1:(e&&e(t.tr.setSelection(N.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Gi(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ac(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var Xi=(t,e,n)=>{let r=Ac(t,n);if(!r)return!1;let s=Qi(r);if(!s)return!1;let i=s.nodeAfter;if(Ic(t,s,e,1))return!0;if(r.parent.content.size==0&&(dn(i,"start")||N.isSelectable(i))){let o=qn(t.doc,r.before(),r.after(),v.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(dn(i,"start")?R.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):N.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Yi=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Qi(r)}let o=i&&i.nodeAfter;return!o||!N.isSelectable(o)?!1:(e&&e(t.tr.setSelection(N.create(t.doc,i.pos)).scrollIntoView()),!0)};function Qi(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}var Ec=(t,e)=>{let n=t.selection,r=n instanceof N,s;if(r){if(n.node.isTextblock||!Le(t.doc,n.from))return!1;s=n.from}else if(s=an(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(N.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Rc=(t,e)=>{let n=t.selection,r;if(n instanceof N){if(n.node.isTextblock||!Le(t.doc,n.to))return!1;r=n.to}else if(r=an(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Nc=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Ye(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Zi=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
12
|
-
`).scrollIntoView()),!0)};function eo(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var to=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=eo(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},no=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof me||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=eo(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(M.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},ro=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ae(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Ye(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Am(t){return(e,n)=>{if(e.selection instanceof N&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Ae(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof me)&&r.deleteSelection();let{$from:s}=r.selection,i=r.steps.length,o=[],l,a,c=!1,u=!1;for(let h=s.depth;;h--)if(s.node(h).isBlock){c=s.end(h)==s.pos+(s.depth-h),u=s.start(h)==s.pos-(s.depth-h),a=eo(s.node(h-1).contentMatchAt(s.indexAfter(h-1)));let m=t&&t(s.parent,c,s);o.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;o.unshift(null)}let d=s.pos,f=Ae(r.doc,d,o.length,o);if(f||(o[0]=a?{type:a}:null,f=Ae(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!c&&u&&s.node(l).type!=a){let h=r.mapping.slice(i),p=h.map(s.before(l)),m=r.doc.resolve(p);a&&s.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(s.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Em=Am();var Oc=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(N.create(t.doc,s))),!0)},Rm=(t,e)=>(e&&e(t.tr.setSelection(new me(t.doc))),!0);function Nm(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Le(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ic(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Nm(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(s.copy(p));let m=t.tr.step(new Q(e.pos-1,h,e.pos,h,new v(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Le(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ye(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&dn(i,"start",!0)&&dn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=w.empty;for(let b=p.length-1;b>=0;b--)y=w.from(p[b].copy(y));let k=t.tr.step(new Q(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new v(y,p.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Dc(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(M.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}var so=Dc(-1),io=Dc(1);function Lc(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&ln(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function oo(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function lo(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}var Ui=lo(vc,qi,Ji),Cc=lo(vc,Xi,Yi),ht={Enter:lo(Zi,no,ro,Em),"Mod-Enter":to,Backspace:Ui,"Mod-Backspace":Ui,"Shift-Backspace":Ui,Delete:Cc,"Mod-Delete":Cc,"Mod-a":Rm},Om={"Ctrl-h":ht.Backspace,"Alt-Backspace":ht["Mod-Backspace"],"Ctrl-d":ht.Delete,"Ctrl-Alt-Backspace":ht["Mod-Delete"],"Alt-Delete":ht["Mod-Delete"],"Alt-d":ht["Mod-Delete"],"Ctrl-a":so,"Ctrl-e":io};for(let t in ht)Om[t]=ht[t];var wS=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Pc(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return Im(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Im(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new Rt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Rt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=ln(i,n,r,e);return l?(t&&Dm(t,e,l,s,n),!0):!1}function Dm(t,e,n,r,s){let i=w.empty;for(let u=n.length-1;u>=0;u--)i=w.from(n[u].type.create(n[u].attrs,i));t.step(new Q(e.start-(r?2:0),e.end,e.start,e.end,new v(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&Ae(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function qr(t,e){return t instanceof rn?e==t:t.indexOf(e)>-1}function zc(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&qr(t,o.firstChild.type));return i?n?qr(t,r.node(i.depth-1).type)?Lm(e,n,i):Pm(e,n,i):!0:!1}}function Lm(t,e,n){let r=t.tr,s=n.end,i=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;s<i&&(r.step(new Q(s-1,i,s,i,new v(w.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new Rt(r.doc.resolve(n.$from.pos),r.doc.resolve(i),n.depth));let l=Ye(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(s,-1)-1);return Le(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Pm(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?w.empty:w.from(s))))return!1;let d=i.pos,f=d+o.nodeSize;return r.step(new Q(d-(l?1:0),f+(a?1:0),d+1,f-1,new v((l?w.empty:w.from(s.copy(w.empty))).append(a?w.empty:w.from(s.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function $c(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&qr(t,c.firstChild.type));if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(!qr(t,a.type))return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=w.from(c?a.lastChild.lastChild.type.create():null),d=new v(w.from(a.type.create(null,w.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new Q(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var se=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},mn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},ho=null,Ze=function(t,e,n){let r=ho||(ho=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},zm=function(){ho=null},Ft=function(t,e,n,r){return n&&(Bc(t,e,n,r,-1)||Bc(t,e,n,r,1))},$m=/^(img|br|input|textarea|hr)$/i;function Bc(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ce(t))){let o=t.parentNode;if(!o||!O(o)||sr(t)||$m.test(t.nodeName)||t.contentEditable=="false")return!1;e=se(t)+(s<0?0:1),t=o}else if(O(t)){let o=t.childNodes[e+(s<0?-1:0)];if(O(o)&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?ce(t):0}else return!1}}function ce(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function O(t){return t.nodeType==1}function te(t){return t.nodeType==3}function jt(t,e){return e?t.contains(O(e)?e:e.parentNode):!1}function Bm(t,e){for(;;){if(te(t)&&e)return t;if(O(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ce(t)}else if(t.parentNode&&!sr(t))e=se(t),t=t.parentNode;else return null}}function Hm(t,e){for(;;){if(te(t)&&e<t.nodeValue.length)return t;if(O(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!sr(t))e=se(t)+1,t=t.parentNode;else return null}}function Fm(t,e,n){for(let r=e==0,s=e==ce(t);r||s;){if(t==n)return!0;let i=se(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ce(t)}}function sr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var ss=function(t){return t.focusNode&&Ft(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function jm(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _m(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Wm(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ce(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ce(r.startContainer),r.startOffset)}}}var je=typeof navigator<"u"?navigator:null,Hc=typeof document<"u"?document:null,bt=je&&je.userAgent||"",po=/Edge\/(\d+)/.exec(bt),pu=/MSIE \d/.exec(bt),mo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bt),we=!!(pu||mo||po),yt=pu?document.documentMode:mo?+mo[1]:po?+po[1]:0,Se=!we&&/gecko\/(\d+)/i.test(bt);Se&&+(/Firefox\/(\d+)/.exec(bt)||[0,0])[1];var go=!we&&/Chrome\/(\d+)/.exec(bt),ie=!!go,mu=go?+go[1]:0,ue=!we&&!!je&&/Apple Computer/.test(je.vendor),gn=ue&&(/Mobile\/\w+/.test(bt)||!!je&&je.maxTouchPoints>2),Ee=gn||(je?/Mac/.test(je.platform):!1),gu=je?/Win/.test(je.platform):!1,et=/Android \d/.test(bt),is=!!Hc&&"webkitFontSmoothing"in Hc.documentElement.style,Vm=is?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Km(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qe(t,e){return typeof t=="number"?t:t[e]}function Um(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Fc(t,e,n){if(!yo(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(!O(o)){o=mn(o);continue}let l=o==i.body,a=l?Km(i):Um(o),c=0,u=0;if(e.top<a.top+Qe(r,"top")?u=-(a.top-e.top+Qe(s,"top")):e.bottom>a.bottom-Qe(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Qe(s,"top")-a.top:e.bottom-a.bottom+Qe(s,"bottom")),e.left<a.left+Qe(r,"left")?c=-(a.left-e.left+Qe(s,"left")):e.right>a.right-Qe(r,"right")&&(c=e.right-a.right+Qe(s,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),c&&(o.scrollLeft+=c);let p=o.scrollLeft-f,m=o.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:mn(o)}}function qm(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:yu(t.dom)}}function yu(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=mn(r));return e}function Jm({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ku(n,r==0?0:r-e)}function ku(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var fn=null;function Gm(t){if(t.setActive)return t.setActive();if(fn)return t.focus(fn);let e=yu(t);t.focus(fn==null?{get preventScroll(){return fn={preventScroll:!0},!0}}:void 0),fn||(fn=!1,ku(e,0))}function bu(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(O(u))f=u.getClientRects();else if(te(u))f=Ze(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,s=m&&te(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,O(u)&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&te(n)?Xm(n,s):!n||r?{node:t,offset:i}:bu(n,s)}function Xm(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=pt(r,1);if(o.top!=o.bottom&&Do(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Do(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ym(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Qm(t,e,n){let{node:r,offset:s}=bu(e,n),i=-1;if(O(r)&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function Zm(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(O(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function wu(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(O(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Do(e,c))return wu(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function eg(t,e){let n=t.dom.ownerDocument,r,s=0,i=Wm(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o)){let c=t.dom.getBoundingClientRect();if(!Do(e,c)||(o=wu(t.dom,e,c),!o))return null}if(ue)for(let c=o;r&&c;c=mn(c))c.draggable&&(r=void 0);if(o=Ym(o,e),r){if(Se&&O(r)&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;is&&s&&O(r)&&O(c=r.childNodes[s-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&O(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||!O(r)||r.childNodes[s-1].nodeName!="BR")&&(l=Zm(t,r,s,e))}l==null&&(l=Qm(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function yo(t){return t.top<t.bottom||t.left<t.right}function pt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(yo(r))return r}return Array.prototype.find.call(n,yo)||t.getBoundingClientRect()}var tg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function xu(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=is||Se;if(te(r))if(o&&(tg.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=pt(Ze(r,s,s),n);if(Se&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=pt(Ze(r,s-1,s-1),-1);if(c.top==a.top){let u=pt(Ze(r,s,s+1),-1);if(u.top!=a.top)return Gn(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Gn(pt(Ze(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==ce(r))){let a=r.childNodes[s-1];if(O(a))return ao(a.getBoundingClientRect(),!1)}if(i==null&&s<ce(r)){let a=r.childNodes[s];if(O(a))return ao(a.getBoundingClientRect(),!0)}return ao(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==ce(r))){let a=r.childNodes[s-1],c=te(a)?Ze(a,ce(a)-(o?0:1)):O(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Gn(pt(c,1),!1)}if(i==null&&s<ce(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?te(a)?Ze(a,0,o?0:1):O(a)?a:null:null;if(c)return Gn(pt(c,-1),!0)}return Gn(pt(te(r)?Ze(r):r,-n),n>=0)}function Gn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ao(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Su(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function ng(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Su(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=xu(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(O(l))a=l.getClientRects();else if(te(l))a=Ze(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var rg=/[\u0590-\u08ac]/;function sg(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!rg.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:Su(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!jt(h,p)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var jc=null,_c=null,Wc=!1;function ig(t,e,n){return jc==e&&_c==n?Wc:(jc=e,_c=n,Wc=n=="up"||n=="down"?ng(t,e,n):sg(t,e,n))}var Re=0,Vc=1,Lt=2,Pe=3,_t=class{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Re,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&jt(this.contentDOM,e))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>se(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?s=n>Array.from(e.childNodes).findIndex(o=>o.contains(this.contentDOM)):s=!(i&4)}else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(O(o)?jt(o,e):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Xr||i instanceof Jr&&i.side>=0))break}if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?se(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?se(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=se(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=se(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!O(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Se||ue)&&e==n){let{node:h,offset:p}=l;if(te(h)){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
13
|
-
`),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:se(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Se&&u.focusNode&&u.focusNode!=a.node&&O(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&ue)&&Ft(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Ft(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Se)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Lt:Vc,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Pe:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Lt:Pe}r=o}this.dirty=Lt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lt:Vc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Jr=class extends _t{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=O(o)?o:document.createElement("span");l!=o&&(l.appendChild(o),o=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Re&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ko=class extends _t{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},zt=class t extends _t{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Ge.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Pe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Re){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Re}}slice(e,n,r){let s=t.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=So(i,n,o,r)),e>0&&(i=So(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},kt=class t extends _t{constructor(e,n,r,s,i,o,l){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!te(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ge.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Mu(u,r,n),c?a=new bo(e,n,r,s,u,d||null,f,c):n.isText?new Gr(e,n,r,s,u,f):new t(e,n,r,s,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>O(s)&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>w.empty}}return n}matchesNode(e,n,r){return this.dirty==Re&&e.eq(this.node)&&Yr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new xo(this,o&&o.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;cg(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?F.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,s)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,h,m,e)||a.updateNextNode(d,f,h,e,p,s)||a.addNode(d,f,h,e,s),s+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Lt)&&(o&&this.protectLocalComposition(e,o),Cu(this.contentDOM,this.children,e),gn&&ug(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof M)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=dg(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new ko(this,i,n,s);e.input.compositionNodes.push(o),this.children=So(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Pe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Re}updateOuterDeco(e){if(Yr(e,this.outerDeco))return;let n=!O(this.nodeDOM),r=this.dom;this.dom=vu(this.dom,this.nodeDOM,wo(this.outerDeco,this.node,n),wo(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Kc(t,e,n,r,s){Mu(r,e,t);let i=new kt(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(s,0),i}var Gr=class t extends kt{constructor(e,n,r,s,i,o){super(e,n,r,s,i,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Pe||this.dirty!=Re&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Re||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Re,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new t(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Pe)}get domAtom(){return!1}isText(e){return this.node.text==e}},Xr=class extends _t{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Re&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},bo=class extends kt{constructor(e,n,r,s,i,o,l,a){super(e,n,r,s,i,o,l),this.spec=a}update(e,n,r,s){if(this.dirty==Pe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Cu(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Uc(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof zt){let a=r?r.previousSibling:t.lastChild;Cu(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Uc(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}var Yn=function(t){t&&(this.nodeName=t)};Yn.prototype=Object.create(null);var Pt=[new Yn];function wo(t,e,n){if(t.length==0)return Pt;let r=n?Pt[0]:new Yn,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Yn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Yn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function vu(t,e,n,r){if(n==Pt&&r==Pt)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Pt[0]),s=a}og(s,l||Pt[0],o)}return s}function og(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Mu(t,e,n){return vu(t,t,Pt,wo(e,n,!O(t)))}function Yr(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Uc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var xo=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=lg(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Re,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof zt&&u.dirty!=Pe&&u.mark.type==e[o].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[o])&&(u.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=zt.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Pe&&o.dom==o.contentDOM&&(o.dirty=Lt),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof kt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Pe&&Yr(n,a.outerDeco));if(!f&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Lt,d.updateChildren(s,o+1),d.dirty=Re),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Yr(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=kt.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=kt.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Jr(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof zt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Gr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Xr(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||O(e)&&e.contains(this.lock.parentNode))}};function lg(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof zt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function ag(t,e){return t.type.side-e.type.side}function cg(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(ag);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function ug(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function dg(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function So(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Lo(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(ss(n)){for(a=o;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&N.isSelectable(s.node)&&s.parent&&!(s.node.isInline&&Fm(n.focusNode,n.focusOffset,s.dom))){let d=s.posBefore;c=new N(o==d?l:r.resolve(d))}else if(Se&&e=="key"&&o>t.state.selection.to&&O(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&s&&s.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=R.findFrom(r.resolve(s.posAtStart),1);break}if(d==s.dom||d.nextSibling||!d.parentNode||!O(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,f=o;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Po(t,u,l,d)}return c}function Tu(t){return t.editable?t.hasFocus():Eu(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nt(t,e=!1){let n=t.state.selection;if(Au(t,n),!Tu(t))return;let r=t.input.mouseDown;if(!e&&ie&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&Ft(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)hg(t);else{let{anchor:s,head:i}=n,o,l;qc&&!(n instanceof M)&&(n.$from.parent.inlineContent||(o=Jc(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Jc(t,n.to))),t.docView.setSelection(s,i,t,e),qc&&(o&&Gc(o),l&&Gc(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fg(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var qc=ue||ie&&mu<63;function Jc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ue&&s&&s.contentEditable=="false")return co(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return co(s);if(i)return co(i)}}function co(t){return t.contentEditable="true",ue&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Gc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function fg(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Tu(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function hg(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,se(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&we&&yt<=11&&(n.disabled=!0,n.disabled=!1)}function Au(t,e){if(e instanceof N){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Xc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Xc(t)}function Xc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Po(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||M.between(e,n,r)}function Yc(t){return t.editable&&!t.hasFocus()?!1:Eu(t)}function Eu(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return jt(t.dom,e.anchorNode)&&(t.editable||jt(t.dom,e.focusNode))}catch{return!1}}function pg(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ft(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Co(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&R.findFrom(i,e)}function mt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Qc(t,e,n){let r=t.state.selection;if(r instanceof M)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return mt(t,new M(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Co(t.state,e);return s&&s instanceof N?mt(t,s):!1}else if(!Ee||n.indexOf("m")<0){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?N.isSelectable(i)?mt(t,new N(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):mt(t,new M(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof N&&r.node.isInline)return mt(t,new M(e>0?r.$to:r.$from));{let s=Co(t.state,e);return s?mt(t,s):!1}}}function Qn(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):O(t)&&t.contentEditable=="false"}function hn(t,e){return e<0?mg(t):gg(t)}function mg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Se&&O(n)&&r<ce(n)&&Qn(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!O(n))break;let l=n.childNodes[r-1];if(Qn(l,-1))s=n,i=--r;else if(te(l))n=l,r=n.nodeValue.length;else break}else{if(Ru(n))break;{let l=n.previousSibling;for(;l&&Qn(l,-1);)s=n.parentNode,i=se(l),l=l.previousSibling;if(l)n=l,r=ce(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?vo(t,n,r):s&&vo(t,s,i)}function gg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=ce(n),i,o;for(;;)if(r<s){if(!O(n))break;let l=n.childNodes[r];if(Qn(l,1))i=n,o=++r;else break}else{if(Ru(n))break;{let l=n.nextSibling;for(;l&&Qn(l,1);)i=l.parentNode,o=se(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=ce(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&vo(t,i,o)}function Ru(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function yg(t,e){for(;t&&e==t.childNodes.length&&!sr(t);)e=se(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(te(n))return n;if(O(n)&&n.contentEditable=="false")break;t=n,e=0}}function kg(t,e){for(;t&&!e&&!sr(t);)e=se(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(te(n))return n;if(O(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function vo(t,e,n){if(!te(e)){let o,l;(l=yg(e,n))?(e=l,n=0):(o=kg(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection(),s=t.domSelectionRange();if(!r)return;ss(s)?r.collapse(e,n):r.extend&&(r.collapse(s.anchorNode,s.anchorOffset),r.extend(e,n)),t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&nt(t)},50)}function Zc(t,e){let n=t.state.doc.resolve(e);if(!(ie||gu)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),l=(o.top+o.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}let r=t.dom;for(let i=n.depth;i>0;i--)if(n.node(i).isBlock){r=t.nodeDOM(n.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function eu(t,e,n){let r=t.state.selection;if(r instanceof M&&!r.empty||n.indexOf("s")>-1||Ee&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Co(t.state,e);if(o&&o instanceof N)return mt(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof me?R.near(o,e):R.findFrom(o,e);return l?mt(t,l):!1}return!1}function tu(t,e){if(!(t.state.selection instanceof M))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function nu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function bg(t){if(!ue||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&O(e)&&n==0&&e.firstChild&&O(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;nu(t,r,"true"),setTimeout(()=>nu(t,r,"false"),20)}return!1}function wg(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function xg(t,e){let n=e.keyCode,r=wg(e);if(n==8||Ee&&n==72&&r=="c")return tu(t,-1)||hn(t,-1);if(n==46&&!e.shiftKey||Ee&&n==68&&r=="c")return tu(t,1)||hn(t,1);if(n==13||n==27)return!0;if(n==37||Ee&&n==66&&r=="c"){let s=n==37?Zc(t,t.state.selection.from)=="ltr"?-1:1:-1;return Qc(t,s,r)||hn(t,s)}else if(n==39||Ee&&n==70&&r=="c"){let s=n==39?Zc(t,t.state.selection.from)=="ltr"?1:-1:1;return Qc(t,s,r)||hn(t,s)}else{if(n==38||Ee&&n==80&&r=="c")return eu(t,-1,r)||hn(t,-1);if(n==40||Ee&&n==78&&r=="c")return bg(t)||eu(t,1,r)||hn(t,1);if(r==(Ee?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function zo(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Ge.fromSchema(t.state.schema),l=Pu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&O(c)&&(u=Lu[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&O(c)&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
14
|
-
|
|
15
|
-
`);return{dom:a,text:f,slice:e}}function
|
|
16
|
-
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)l=d;else{let f=s.marks(),{schema:h}=t.state,p=Ge.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=Mg(n),is&&Tg(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&!O(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Fe.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Sg.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ag(ru(l,+u[1],+u[2]),u[4]);else if(l=v.maxOpen(Cg(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=ru(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}var Sg=/^(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 Cg(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Iu(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Du(o[o.length-1],i.length));let u=Ou(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return w.from(o)}return t}function Ou(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,w.from(t));return t}function Iu(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Iu(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(w.from(Ou(n,t,s+1))))}}function Du(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Du(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(w.empty,!0);return t.copy(n.append(r))}function Mo(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Mo(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(w.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function ru(t,e,n){return e<t.openStart&&(t=new v(Mo(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new v(Mo(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Lu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Pu(){return document.implementation.createHTMLDocument("title")}var Xn=null;function vg(t){let e=window.trustedTypes;if(!e)return t;if(!Xn){if(Xn=e.defaultPolicy)try{return Xn.createHTML(t)}catch{}Xn=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Xn.createHTML(t)}function Mg(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Pu(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&Lu[s[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=vg(t),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[o])||r;for(let o=0;o<n.styleSheets.length;o++){let l=n.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Tg(t){let e=t.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Ag(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{s=w.from(a.create(r[l+1],s))}catch{break}i++,o++}return new v(s,i,o)}var ge={},ye={},Eg={touchstart:!0,touchmove:!0},To=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 Rg(t){for(let e in ge){let n=ge[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Og(t,r)&&!$o(t,r)&&(t.editable||!(r.type in ye))&&n(t,r)},Eg[e]?{passive:!0}:void 0)}ue&&t.dom.addEventListener("input",()=>null),Ao(t)}function tt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ng(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ao(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>$o(t,r))})}function $o(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Og(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Ig(t,e){!$o(t,e)&&ge[e.type]&&(t.editable||!(e.type in ye))&&ge[e.type](t,e)}function gt(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=jm(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}ye.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Bu(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(et&&ie&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),gn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(gt(t,"Enter"),t.input.lastIOSEnter=0)},200)}else gt(t,n)||xg(t,n)?n.preventDefault():tt(t,"key")};ye.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ye.keypress=(t,e)=>{let n=e;if(Bu(t)||!n.charCode||n.ctrlKey&&!n.altKey||Ee&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function ir(t){return{left:t.clientX,top:t.clientY}}function Dg(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Bo(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function or(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Lg(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&N.isSelectable(r)?(or(t,new N(n)),!0):!1}function Pg(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof N&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(N.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(or(t,N.create(t.state.doc,s)),!0):!1}function zg(t,e,n,r,s){return Bo(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Pg(t,n):Lg(t,n))}function $g(t,e,n,r){return Bo(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Bg(t,e,n,r){return Bo(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Hg(t,n,r)}function Hg(t,e,n){if(n.button!=0)return!1;let r=zu(t,e,!0),s=t.state.doc;return r?(or(t,r),r instanceof M&&s.eq(t.state.doc)&&(t.input.mouseDown=new Ro(t,r)),!0):!1}function zu(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?M.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return M.create(r,l+1,l+1+o.content.size);if(n&&N.isSelectable(o))return N.create(r,l)}return null}function Ho(t){return Zr(t)}var $u=Ee?"metaKey":"ctrlKey";ge.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ho(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Dg(n,t.input.lastClick)&&!n[$u]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(ir(n));o&&(i=="singleClick"?t.input.mouseDown=new Eo(t,o,n,!!r):(i=="doubleClick"?$g:Bg)(t,o.pos,o.inside,n)?n.preventDefault():tt(t,"pointer"))};var Qr=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Eo=class extends Qr{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[$u],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}let l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&O(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Se&&!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()),tt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||nt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ir(e))),this.updateAllowDefault(e),this.allowDefault||!n?tt(this.view,"pointer"):zg(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(or(this.view,R.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),tt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ro=class extends Qr{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),tt(this.view,"pointer");let n=this.view.posAtCoords(ir(e)),r=n&&zu(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];or(this.view,M.create(s,o,l))}};ge.touchstart=t=>{t.input.lastTouch=Date.now(),Ho(t),tt(t,"pointer")};ge.touchmove=t=>{t.input.lastTouch=Date.now(),tt(t,"pointer")};ge.contextmenu=t=>Ho(t);function Bu(t,e){return t.composing?!0:ue&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Fg=et?5e3:-1;ye.compositionstart=ye.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ie&&gu&&jg(t)))t.markCursor=t.state.storedMarks||n.marks(),Zr(t,!0),t.markCursor=null;else if(Zr(t,!e.selection.empty),Se&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&O(s)&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(te(o)){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Hu(t,Fg)};function jg(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!O(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return O(r)&&r.contentEditable=="false"}ye.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Hu(t,20))};function Hu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Zr(t),e))}function Fu(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function _g(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Bm(e.focusNode,e.focusOffset),r=Hm(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Zr(t,e=!1){if(!(et&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Fu(t),e||t.docView&&t.docView.dirty){let n=Lo(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Wg(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Zn=we&&yt<15||gn&&Vm<604;ge.copy=ye.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Zn?null:n.clipboardData,o=r.content(),{dom:l,text:a}=zo(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Wg(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vg(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Kg(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?er(t,r.value,null,s,e):er(t,r.textContent,r.innerHTML,s,e)},50)}function er(t,e,n,r,s){let i=Nu(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||v.empty)))return!0;if(!i)return!1;let o=Vg(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ju(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ye.paste=(t,e)=>{let n=e;if(t.composing&&!et)return;let r=Zn?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&er(t,ju(r),r.getData("text/html"),s,n)?n.preventDefault():Kg(t,n)};var es=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Ug=Ee?"altKey":"ctrlKey";function _u(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[Ug]}ge.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(ir(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof N?s.to-1:s.to))){if(r&&r.mightDrag)o=N.create(t.state.doc,r.mightDrag.pos);else if(n.target&&O(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=N.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=zo(t,l);(!n.dataTransfer.files.length||!ie||mu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Zn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Zn||n.dataTransfer.setData("text/plain",c),t.dragging=new es(u,_u(t,n),o)};ge.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ye.dragover=ye.dragenter=(t,e)=>e.preventDefault();ye.drop=(t,e)=>{try{qg(t,e,t.dragging)}finally{t.dragging=null}};function qg(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(ir(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Nu(t,ju(e.dataTransfer),Zn?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&_u(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||v.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?_r(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&N.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new N(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(Po(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}ge.focus=t=>{if(t.input.lastFocus=Date.now(),!t.focused){t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0;let e=t.domSelectionRange();if(!t.domObserver.currentSelection.eq(e)){let{focusNode:n,focusOffset:r}=e;setTimeout(()=>{let s=t.domSelectionRange();s.focusNode==n&&s.focusOffset==r&&t.docView&&t.hasFocus()&&nt(t)},20)}}};ge.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ge.beforeinput=(t,e)=>{if(et&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||t.domObserver.pendingRecords().length||(t.dom.blur(),t.focus(),gt(t,"Backspace")))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in ye)ge[t]=ye[t];function tr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var nr=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let n=this.frag.child(this.index);if(this.off==e)return n;this.off+=n.nodeSize,this.index++}return null}},ts=class t{constructor(e,n){this.toDOM=e,this.spec=n||Bt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new ne(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&tr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},$t=class t{constructor(e,n){this.attrs=e,this.spec=n||Bt}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new ne(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&tr(this.attrs,e.attrs)&&tr(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},No=class t{constructor(e,n){this.attrs=e,this.spec=n||Bt}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new ne(i.pos-r,o.pos-r,this)}valid(e,n,r){let s=r.nodeAt(n.from);return!!s&&!s.isText&&n.from+s.nodeSize==n.to}eq(e){return this==e||e instanceof t&&tr(this.attrs,e.attrs)&&tr(this.spec,e.spec)}destroy(){}},ne=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new ts(n,r))}static inline(e,n,r,s){return new t(e,n,new $t(r,s))}static node(e,n,r,s){return new t(e,n,new No(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof ts}},pn=[],Bt={},_=class t{constructor(e,n){this.local=e.length?e:pn,this.children=n.length?n:pn}static create(e,n){return n.length?rs(n,e,0,Bt):ae}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Bt)}mapInner(e,n,r,s,i){let o;if(this.local.length){let l=new nr(n.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,s);c&&c.type.valid(n,c,l)?(o||(o=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Jg(this.children,o||[],e,n,r,s,i):o?new t(o.sort(Ht),pn):ae}add(e,n){return n.length?this==ae?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Vu(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,rs(u,l,c+1,Bt)),i+=3}});let o=Wu(i?Ku(n):n,-r);if(o.length){let l=new nr(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||o.splice(a--,1)}return new t(o.length?this.local.concat(o).sort(Ht):this.local,s||this.children)}remove(e){return e.length==0||this==ae?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ae?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new t(s,r):ae}forChild(e,n){if(this==ae)return this;if(n.isLeaf)return t.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof $t){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new t(s.sort(Ht),pn);return r?new ns([l,r]):l}return r||ae}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Fo(this.localsInner(e))}localsInner(e){if(this==ae)return pn;if(e.inlineContent||!this.local.some($t.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||n.push(this.local[r]);return n}forEachSet(e){e(this)}};_.empty=new _([],[]);_.removeOverlap=Fo;var ae=_.empty,ns=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(s=>s.map(e,n,Bt));return t.from(r)}forChild(e,n){if(n.isLeaf)return _.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ae&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Fo(r?n:n.sort(Ht)):pn}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new t(e.every(n=>n instanceof _)?e:e.reduce((n,r)=>n.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function Jg(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let k=l[y+1];if(k<0||f>k+u-d)continue;let b=l[y]+u-d;h>=b?l[y+1]=f<=b?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,u+1,t[c]+i+1,o);y!=ae?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Gg(l,t,e,n,s,i,o),u=rs(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new _(e.sort(Ht),l)}function Wu(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new ne(s.from+e,s.to+e,s.type))}return n}function Gg(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Vu(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Ku(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function rs(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Vu(t,l,a+n);if(c){i=!0;let u=rs(c,l,n+a+1,r);u!=ae&&s.push(a,a+l.nodeSize,u)}});let o=Wu(i?Ku(t):t,-n).sort(Ht);if(o.length){let l=new nr(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1))}return o.length||s.length?new _(o,s):ae}function Ht(t,e){return t.from-e.from||t.to-e.to}function Fo(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),su(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),su(e,s,r.copy(i.from,r.to)));break}}}return e}function su(t,e,n){for(;e<t.length&&Ht(n,t[e])>0;)e++;t.splice(e,0,n)}function uo(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ae&&e.push(r)}),t.cursorWrapper&&e.push(_.create(t.state.doc,[t.cursorWrapper.deco])),ns.from(e)}var Xg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Yg=we&&yt<=11,Oo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Io=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Oo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);we&&yt<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ue&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Yg&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Xg)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Yc(this.view)){if(this.suppressingSelectionUpdates)return nt(this.view);if(we&&yt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ft(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=mn(i))n.add(i);for(let i=e.anchorNode;i;i=mn(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:te(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r,s=!1;!this.suppressingSelectionUpdates&&Yc(e)&&(r=e.domSelectionRange(),s=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ie&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&O(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Se&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||e0(e,d)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ss(r)&&(c=Lo(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nt(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Qg(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,t0(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&nt(e),r&&this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),te(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(we&&yt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?se(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?se(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},iu=new WeakMap,ou=!1;function Qg(t){if(!iu.has(t)&&(iu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Se,ou)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."),ou=!0}}function lu(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Ft(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Zg(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return lu(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?lu(t,n):null}function e0(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function t0(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!O(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function n0(t,e,n,r){let{node:s,fromOffset:i,toOffset:o,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&jt(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],ss(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ie&&t.input.lastKeyCode===8)for(let y=o;y>i;y--){let k=s.childNodes[y-1],b=k.pmViewDesc;if(k.nodeName=="BR"&&!b){o=y;break}if(!b||b.size)break}let f=t.state.doc,h=t.someProp("domParser")||Fe.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=h.parse(s,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:r0(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:a}}var r0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ue&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ue&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},s0=/^(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 i0(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=Lo(t,T);if(D&&!t.state.selection.eq(D)){if(ie&&et&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&>(t,"Enter"))return;let I=t.state.tr.setSelection(D);T=="pointer"?I.setMeta("pointer",!0):T=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=n0(t,e,n,s),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=c0(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(gn&&t.input.lastIOSEnter>Date.now()-225||et)&&s.some(T=>O(T)&&!s0.test(T.nodeName))&&(!p||p.endA>=p.endB)&>(t,"Enter")){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof M&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=au(t,t.state.doc,c.sel);if(T&&!T.eq(t.state.selection)){let D=t.state.tr.setSelection(T);i&&D.setMeta("composition",i),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof M&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),we&&yt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((gn&&t.input.lastIOSEnter>Date.now()-225&&(!k||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!k&&a0(c.doc,m.pos,g.pos))&>(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&(k?p.endA>p.start&&p.endB==p.start:l0(u,p.start,p.endA,m,g))&>(t,"Backspace")){et&&ie&&t.domObserver.suppressSelectionUpdates();return}ie&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),et&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>gt(t,"Enter"),20));let b=p.start,x=p.endA,E=T=>{let D=T||t.state.tr.replace(b,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let I=au(t,D.doc,c.sel);I&&!(ie&&t.composing&&I.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(I.head==b||I.head==D.mapping.map(x)-1)||we&&I.empty&&I.head==b)&&D.setSelection(I)}return i&&D.setMeta("composition",i),D.scrollIntoView()},C;if(k)if(m.pos==g.pos){we&&yt<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>nt(t),20));let T=E(t.state.tr.delete(b,x)),D=u.resolve(p.start).marksAcross(u.resolve(p.endA));D&&T.ensureMarks(D),t.dispatch(T)}else if(p.endA==p.endB&&(C=o0(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=E(t.state.tr);C.type=="add"?T.addMark(b,x,C.mark):T.removeMark(b,x,C.mark),t.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>E(t.state.tr.insertText(T,b,x));t.someProp("handleTextInput",I=>I(t,b,x,T,D))||t.dispatch(D())}else t.dispatch(E());else t.dispatch(E())}function au(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Po(t,e.resolve(n.anchor),e.resolve(n.head))}function o0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(w.from(c).eq(t))return{mark:l,type:o}}function l0(t,e,n,r,s){if(n-e<=s.pos-r.pos||fo(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(fo(i,!0,!0));return!o.parent.isTextblock||o.pos>n||fo(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function a0(t,e,n){let r=0,s=0;return t.nodesBetween(e,n,(i,o)=>{i.isTextblock&&o>=e&&o<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-o),Math.min(i.nodeSize,n-o))):i.isLeaf)&&s++}),s==0&&r==1}function fo(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function c0(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,o,l);if(s=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&o<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var rr=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new To,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(hu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=du(this),uu(this),this.nodeViews=fu(this),this.docView=Kc(this.state.doc,cu(this),uo(this),this.dom,this),this.domObserver=new Io(this,(r,s,i,o)=>i0(this,r,s,i,o)),this.domObserver.start(),Rg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ao(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(hu),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Fu(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=fu(this);d0(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ao(this),this.editable=du(this),uu(this);let a=uo(this),c=cu(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&qm(this);if(o){this.domObserver.stop();let h=d&&(we||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&u0(s.selection,e.selection);if(d){let m=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_g(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Kc(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&pg(this)&&p.delaySelUpdate())?nt(this,h):(Au(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Jm(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!jt(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof N){let n=this.docView.domAfterPos(this.state.selection.from);O(n)&&Fc(this,n.getBoundingClientRect(),e)}else Fc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new es(e.slice,e.move,s<0?void 0:N.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(we){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Gm(this.dom),nt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return eg(this,e)}coordsAtPos(e,n=1){return xu(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return ig(this,n||this.state,e)}pasteHTML(e,n){return er(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return er(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return zo(this,e)}destroy(){this.docView&&(Ng(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],uo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ig(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ue&&this.root.nodeType===11&&_m(this.dom.ownerDocument)==this.dom&&Zg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};rr.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function cu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[ne.node(0,t.state.doc.content.size,e)]}function uu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:ne.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function du(t){return!t.someProp("editable",e=>e(t.state)===!1)}function u0(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function fu(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function d0(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function hu(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var rt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},as={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f0=typeof navigator<"u"&&/Mac/.test(navigator.platform),h0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Z=0;Z<10;Z++)rt[48+Z]=rt[96+Z]=String(Z);var Z;for(Z=1;Z<=24;Z++)rt[Z+111]="F"+Z;var Z;for(Z=65;Z<=90;Z++)rt[Z]=String.fromCharCode(Z+32),as[Z]=String.fromCharCode(Z);var Z;for(ls in rt)as.hasOwnProperty(ls)||(as[ls]=rt[ls]);var ls;function Uu(t){var e=f0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||h0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?as:rt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var p0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),m0=typeof navigator<"u"&&/Win/.test(navigator.platform);function g0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))p0?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function y0(t){let e=Object.create(null);for(let n in t)e[g0(n)]=t[n];return e}function jo(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function qu(t){return new L({props:{handleKeyDown:lr(t)}})}function lr(t){let e=y0(t);return function(n,r){let s=Uu(r),i,o=e[jo(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[jo(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(m0&&r.ctrlKey&&r.altKey)&&(i=rt[r.keyCode])&&i!=s){let l=e[jo(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var cs=200,oe=function(){};oe.prototype.append=function(e){return e.length?(e=oe.from(e),!this.length&&e||e.length<cs&&this.leafAppend(e)||this.length<cs&&e.leafPrepend(this)||this.appendInner(e)):this};oe.prototype.prepend=function(e){return e.length?oe.from(e).append(this):this};oe.prototype.appendInner=function(e){return new k0(this,e)};oe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?oe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};oe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};oe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};oe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};oe.from=function(e){return e instanceof oe?e:e&&e.length?new Ju(e):oe.empty};var Ju=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=cs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=cs)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(oe);oe.empty=new Ju([]);var k0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(oe),_o=oe;var b0=500,Wt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new _e(d.map));let h=d.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new _e(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new _e(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(o++,n=void 0),s||(a=f)}let c=o-r.depth;return c>x0&&(l=w0(l,c),o-=c),new t(l.append(i),o)}remapping(e,n){let r=new Wn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new _e(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],s=this.items.length-n,i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new _e(p,m,g))}else r.push(new _e(p))},s);let c=[];for(let f=n;f<o;f++)c.push(new _e(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new t(u,l);return d.emptyItemCount()>b0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new _e(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new t(_o.from(s.reverse()),i)}};Wt.empty=new Wt(_o.empty,0);function w0(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}var _e=class t{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},We=class{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}},x0=20;function S0(t,e,n,r){let s=n.getMeta(wt),i;if(s)return s.historyState;n.getMeta(Qu)&&(t=new We(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(wt))return o.getMeta(wt).redo?new We(t.done.addTransform(n,void 0,r,us(e)),t.undone,Gu(n.mapping.maps),t.prevTime,t.prevComposition):new We(t.done,t.undone.addTransform(n,void 0,r,us(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!C0(n,t.prevRanges)),c=o?Wo(t.prevRanges,n.mapping):Gu(n.mapping.maps);return new We(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,us(e)),Wt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new We(t.done.rebased(n,i),t.undone.rebased(n,i),Wo(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new We(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Wo(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function C0(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function Gu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Wo(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function v0(t,e,n){let r=us(e),s=wt.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new We(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(wt,{redo:n,historyState:a})}var Vo=!1,Xu=null;function us(t){let e=t.plugins;if(Xu!=e){Vo=!1,Xu=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Vo=!0;break}}return Vo}function Yu(t){return t.setMeta(Qu,!0)}var wt=new j("history"),Qu=new j("closeHistory");function Zu(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new L({key:wt,state:{init(){return new We(Wt.empty,Wt.empty,null,0,-1)},apply(e,n,r){return S0(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Ko:r=="historyRedo"?Uo:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function ds(t,e){return(n,r)=>{let s=wt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=v0(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var Ko=ds(!1,!0),Uo=ds(!0,!0),GS=ds(!1,!1),XS=ds(!0,!1);function ed(t){return t.getMeta(wt)!=null}function bs(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var xn=class Cd{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:s}=n,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}static createFallbackCan(){let e=Cd.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:bs({state:i,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},M0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),T0=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),A0=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{ranges:r}=n;if(!e)return!0;let s=t.mapping.maps.length;return r.forEach(({$from:i,$to:o})=>{let l=i.pos,a=o.pos,c=t.mapping.slice(s),u=1;t.doc.nodesBetween(c.map(l),c.map(a),(d,f)=>{u=Math.max(u,t.doc.resolve(f).depth+1)});for(let d=0;d<u;d+=1){let f=t.doc,h=t.mapping.maps.length,p=t.mapping.slice(s),m=h,g=t.mapping.slice(h),y=p.map(l),k=p.map(a);if(f.nodesBetween(y,k,(b,x)=>{if(b.type.isText)return;t.mapping.maps.length!==m&&(m=t.mapping.maps.length,g=t.mapping.slice(h));let E=t.doc.resolve(g.map(x)),C=t.doc.resolve(g.map(x+b.nodeSize)),T=E.blockRange(C);if(!T)return;let D=Ye(T);if(b.type.isTextblock){let{defaultType:I}=E.parent.contentMatchAt(E.index()),$=t.doc.nodeAt(T.start);I&&$&&!$.hasMarkup(I)&&I.validContent($.content)&&t.setNodeMarkup(T.start,I)}(D||D===0)&&t.lift(T,D)}),t.doc.eq(f))break}}),!0},E0=t=>e=>t(e),R0=()=>({state:t,dispatch:e})=>no(t,e),N0=(t,e)=>({editor:n,tr:r})=>{let{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new M(r.doc.resolve(Math.max(o-1,0)))),!0},O0=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){let o=s.before(i),l=s.after(i);t.delete(o,l).scrollIntoView()}return!0}return!1};function ee(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var I0=t=>({tr:e,state:n,dispatch:r})=>{let s=ee(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){let l=i.before(o),a=i.after(o);e.delete(l,a).scrollIntoView()}return!0}return!1},D0=t=>({tr:e,dispatch:n})=>{let{from:r,to:s}=t;return n&&e.delete(r,s),!0},L0=t=>t.content?/^text(\*|\+)/.test(t.content):!1,td=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return L0(r)?n==="left"?t.start()-1:t.end()+1:t.pos},P0=(t,e,n)=>({from:td(t,n,"left"),to:td(e,n,"right")}),z0=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,s=t.selection instanceof M?t.selection.$from.marksAcross(t.selection.$to):null,i=n.steps.length;r.forEach(o=>{let l=n.mapping.slice(i),a=n.doc.resolve(l.map(o.$from.pos)),c=n.doc.resolve(l.map(o.$to.pos)),{from:u,to:d}=P0(a,c,t.schema);n.deleteRange(u,d)}),n.selection.empty||n.setSelection(M.near(n.doc.resolve(n.selection.from))),s&&n.ensureMarks(s),n.scrollIntoView(),e(n)}return!0},$0=()=>({commands:t})=>t.keyboardShortcut("Enter"),B0=()=>({state:t,dispatch:e})=>to(t,e);function Yo(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ys(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Yo(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function vd(t,e,n={}){return t.find(r=>r.type===e&&ys(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function nd(t,e,n={}){return!!vd(t,e,n)}function Qo(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!vd([...r.node.marks],e,n))return;let s=r.index,i=t.start()+r.offset,o=s+1,l=i+r.node.nodeSize;for(;s>0&&nd([...t.parent.child(s-1).marks],e,n);)s-=1,i-=t.parent.child(s).nodeSize;for(;o<t.parent.childCount&&nd([...t.parent.child(o).marks],e,n);)l+=t.parent.child(o).nodeSize,o+=1;return{from:i,to:l}}function st(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var H0=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=st(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){let d=Qo(a,i,e);if(d&&d.from<=c&&d.to>=u){let f=M.create(o,d.from,d.to);n.setSelection(f)}}return!0},F0=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Md(t){return t instanceof M}function Vt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function qo(t,e=null){if(!e)return null;let n=R.atStart(t),r=R.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let s=n.from,i=r.to;return e==="all"?M.create(t,Vt(0,s,i),Vt(t.content.size,s,i)):M.create(t,Vt(e,s,i),Vt(e,s,i))}function rd(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function ks(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function j0(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var _0=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};let o=()=>{(ks()||rd())&&r.dom.focus(),j0()&&!ks()&&!rd()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Md(n.state.selection))return o(),!0;let l=qo(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},W0=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),V0=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Td=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Td(r)}return t};function cr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Td(n)}function Ad(t){return typeof t?.nodesBetween=="function"}function Sn(t,e,n){if(Ad(t))return t;let r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};let s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return w.fromArray(t.map(o=>e.nodeFromJSON(o)));let i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Sn("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="",a=new Ot({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Fe.fromSchema(a).parseSlice(cr(t),n.parseOptions):Fe.fromSchema(a).parse(cr(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Fe.fromSchema(e);return n.slice?i.parseSlice(cr(t),n.parseOptions).content:i.parse(cr(t),n.parseOptions)}return Sn("",e,n)}function Ed(t){return!("type"in t)}function Rd(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Y||s instanceof Q))return;let i=t.mapping.maps[r],o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(R.near(t.doc.resolve(o),n))}var K0=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Sn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var o;l=Sn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=Ed(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||"").join(""):Ad(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=w.from(p);let g=r.doc.resolve(u),y=g.node(),k=g.parentOffset===0,b=y.isText||y.isTextblock,x=y.content.size>0;k&&b&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}n.updateSelection&&Rd(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0};function Nd(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var U0=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:s,attrs:i,content:o,updateSelection:l=!0}=t,a;typeof s=="number"?a=e.doc.resolve(s):s?a=s:a=e.selection.$from;let c=Nd(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([h])=>u.includes(h))):{},f;if(o){let h=Sn(o,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(a.pos,f),l&&Rd(e,e.steps.length-1,-1)),!0):!1},q0=()=>({state:t,dispatch:e})=>Ec(t,e),J0=()=>({state:t,dispatch:e})=>Rc(t,e),G0=()=>({state:t,dispatch:e})=>qi(t,e),X0=()=>({state:t,dispatch:e})=>Xi(t,e),Od=(t,e)=>{let n=t.resolve(e),r=n.nodeBefore,s=n.nodeAfter;return!r||!s?!1:!r.type.spec.isolating&&!s.type.spec.isolating},Y0=()=>({state:t,dispatch:e,tr:n})=>{try{let r=an(t.doc,t.selection.$from.pos,-1);return r==null||!Od(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Q0=()=>({state:t,dispatch:e,tr:n})=>{try{let r=an(t.doc,t.selection.$from.pos,1);return r==null||!Od(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Z0=()=>({state:t,dispatch:e})=>Kr(t,e),ey=()=>({state:t,dispatch:e})=>Ur(t,e);function Id(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ty(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))ks()||Id()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var ny=t=>({editor:e,view:n,tr:r,dispatch:s})=>{let i=ty(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Ve(t,e,n={}){let{from:r,to:s,empty:i}=t.selection,o=e?ee(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(s,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ys(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var ry=(t,e={})=>({state:n,dispatch:r})=>Ve(n,ee(t,n.schema),e)?Nc(n,r):!1,sy=()=>({state:t,dispatch:e})=>ro(t,e),iy=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return zc(r)(e,n)},oy=()=>({state:t,dispatch:e})=>Zi(t,e);function ws(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function sd(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ly=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,l=ws(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ee(t,r.schema)),l==="mark"&&(o=st(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,sd(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create(sd(f.attrs,e))))})})}),a},ay=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),cy=()=>({tr:t,dispatch:e})=>{if(e){let n=new me(t.doc);t.setSelection(n)}return!0},uy=()=>({state:t,dispatch:e})=>Ji(t,e),dy=()=>({state:t,dispatch:e})=>Yi(t,e),fy=()=>({state:t,dispatch:e})=>Oc(t,e),hy=()=>({state:t,dispatch:e})=>io(t,e),py=()=>({state:t,dispatch:e})=>so(t,e);function Jo(t,e,n={},r={}){return Sn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var my=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=Jo(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});if(o){let u=Ed(c)?c.content:[c];i.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Dd(t,e){let n=st(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Zo(t,e){let n=new ft(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function Ld(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Mn(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function xs(t){return e=>Mn(e.$from,t)}function A(t,e,n){return t.config[e]===void 0&&t.parent?A(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?A(t.parent,e,n):null}):t.config[e]}function dr(t){return t.map(e=>{let n=A(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...dr(n())]:e}).flat(10)}function el(t,e){let n=Ge.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Pd(t,e){let n=new Map;for(let s of t){var r;let i=(r=n.get(s.type))!==null&&r!==void 0?r:new Map;i.set(s.name,s),n.set(s.type,i)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(s=>{var i;return Object.entries((i=s.spec.attrs)!==null&&i!==void 0?i:{}).map(([o,l])=>{var a;let c=(a=n.get(s.name))===null||a===void 0?void 0:a.get(o),u=Object.hasOwn(l,"default");return{type:s.name,name:o,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var gy={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},yy={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function ky(t,e,n){return Object.fromEntries(Object.entries(e).flatMap(([r,s])=>{let i=t[r];if(i===void 0)return[];if(!(typeof s=="string"?typeof i===s:typeof i=="string"&&s.includes(i)))throw new RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,i]]}))}function id(t,e,n,r){return{...Object.fromEntries(Object.entries(e).filter(([s])=>s!=="attrs"&&!Object.hasOwn(r,s))),...ky(n,r,t),attrs:n.attrs}}function od(t,e,n){for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw new RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function by(t,e){od(t.nodes,e.nodes,"node"),od(t.marks,e.marks,"mark");let n=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((s,i)=>{n=n.update(s,id(s,t.nodes[s],i,gy))}),e.spec.marks.forEach((s,i)=>{r=r.update(s,id(s,t.marks[s],i,yy))}),{topNode:e.topNodeType.name,nodes:n,marks:r}}function zd(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Cn(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function tl(t){let e=[],{nodeExtensions:n,markExtensions:r}=Cn(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{let u=A(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:s});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=o:d.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),s.forEach(c=>{let u=A(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...i,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function Go(t){return typeof t=="function"}function B(t,e=void 0,...n){return Go(t)?e?t.bind(e)(...n):t(...n):t}function wy(t={}){return Object.keys(t).length===0&&t.constructor===Object}function xy(t){let e=[],n="",r=!1,s=!1,i=0,o=t.length;for(let l=0;l<o;l+=1){let a=t[l];if(a==="'"&&!s){r=!r,n+=a;continue}if(a==='"'&&!r){s=!s,n+=a;continue}if(!r&&!s){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function ld(t){let e=[],n=xy(t||""),r=n.length;for(let s=0;s<r;s+=1){let i=n[s],o=i.indexOf(":");if(o===-1)continue;let l=i.slice(0,o).trim(),a=i.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function z(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([s,i])=>{if(s==="__proto__"){Object.defineProperty(r,s,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[s]){r[s]=i;return}if(s==="class"){let o=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],a=o.filter(c=>!l.includes(c));r[s]=[...l,...a].join(" ")}else if(s==="style"){let o=new Map([...ld(r[s]),...ld(i)]);r[s]=Array.from(o.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[s]=i}),r},{})}function vn(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>z(n,r),{})}function Sy(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ad(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let s=e.reduce((i,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(n):Sy(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function cd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&wy(n)?!1:n!=null))}function ud(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function dd(t,e,n=tl(t)){var r;let{nodeExtensions:s,markExtensions:i}=Cn(t);return{topNode:(r=s.find(o=>A(o,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(s.map(o=>{let l=n.filter(h=>h.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=cd({...t.reduce((h,p)=>{let m=A(p,"extendNodeSchema",a);return{...h,...m?m(o):{}}},{}),content:B(A(o,"content",a)),marks:B(A(o,"marks",a)),group:B(A(o,"group",a)),inline:B(A(o,"inline",a)),atom:B(A(o,"atom",a)),selectable:B(A(o,"selectable",a)),draggable:B(A(o,"draggable",a)),code:B(A(o,"code",a)),whitespace:B(A(o,"whitespace",a)),linebreakReplacement:B(A(o,"linebreakReplacement",a)),defining:B(A(o,"defining",a)),isolating:B(A(o,"isolating",a)),attrs:Object.fromEntries(l.map(ud))}),u=B(A(o,"parseHTML",a));u&&(c.parseDOM=u.map(h=>ad(h,l)));let d=A(o,"renderHTML",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:vn(h,l)}));let f=A(o,"renderText",a);return f&&(c.toText=f),[o.name,c]})),marks:Object.fromEntries(i.map(o=>{let l=n.filter(f=>f.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=cd({...t.reduce((f,h)=>{let p=A(h,"extendMarkSchema",a);return{...f,...p?p(o):{}}},{}),inclusive:B(A(o,"inclusive",a)),excludes:B(A(o,"excludes",a)),group:B(A(o,"group",a)),spanning:B(A(o,"spanning",a)),code:B(A(o,"code",a)),attrs:Object.fromEntries(l.map(ud))}),u=B(A(o,"parseHTML",a));u&&(c.parseDOM=u.map(f=>ad(f,l)));let d=A(o,"renderHTML",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:vn(f,l)})),[o.name,c]}))}}function $d(t,e,n){if(n===void 0)return new Ot(dd(t,e));let r=zd(t.filter(o=>o.type!=="extension").map(o=>o.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(", ")}`);let s=new Ot(n),i=dd(t,e,Pd(tl(t),s));return new Ot(by(i,s))}function Kt(t){return t.sort((n,r)=>{let s=A(n,"priority")||100,i=A(r,"priority")||100;return s>i?-1:s<i?1:0})}function nl(t){let e=Kt(dr(t)),n=zd(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Ss(t,e){return $d(nl(t),e)}function Bd(t,e){let n=Ss(e),r=cr(t);return Fe.fromSchema(n).parse(r).toJSON()}function Hd(t,e,n){let{from:r,to:s}=e,{blockSeparator:i=`
|
|
17
|
-
|
|
18
|
-
`,textSerializers:o={}}=n||{},l="";return t.nodesBetween(r,s,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=i);let f=o?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c)}}),l}function Cy(t,e){return Hd(t,{from:0,to:t.content.size},e)}function Fd(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function vy(t,e){let n=ee(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});let o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function rl(t,e){let n=ws(typeof e=="string"?e:e.name,t.schema);return n==="node"?vy(t,e):n==="mark"?Dd(t,e):{}}function My(t,e=JSON.stringify){let n={};return t.filter(r=>{let s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Ty(t){let e=My(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Tn(t){let{mapping:e,steps:n}=t,r=[],s=e.invert();return e.maps.forEach((i,o)=>{let l=[];if(i.ranges.length)i.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=n[o];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(o);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=s.map(d,-1),p=s.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Ty(r)}function fr(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(s=>{let i=Qo(n.resolve(t),s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var jd=(t,e,n,r=20)=>{let s=t.doc.resolve(n),i=r,o=null;for(;i>0&&o===null;){let l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]},_d=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function yn(t,e){return e.nodes[t]||e.marks[t]||null}function gs(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var Ay=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;let u=((a=(c=s.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Xo(t,e,n={}){let{empty:r,ranges:s}=t.selection,i=e?st(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>ys(u.attrs,n,{strict:!1}));let o=0,l=[];if(s.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(p,m)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),k=y-g;o+=k,l.push(...p.marks.map(b=>({mark:b,from:g,to:y})))})}),o===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>ys(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function Ey(t,e,n={}){if(!e)return Ve(t,null,n)||Xo(t,null,n);let r=ws(e,t.schema);return r==="node"?Ve(t,e,n):r==="mark"?Xo(t,e,n):!1}var Wd=(t,e)=>{let{$from:n,$to:r,$anchor:s}=t.selection;if(e){let i=xs(l=>l.type.name===e)(t.selection);if(!i)return!1;let o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Vd=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function fd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function ar(t,e){let{nodeExtensions:n}=Cn(e),r=n.find(i=>i.name===t);if(!r)return!1;let s=B(A(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof s!="string"?!1:s.split(" ").includes("list")}function An(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(An(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Cs(t){return t instanceof N}function Ry(t){if(t===null||typeof t!="object")return!1;let e=t;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function Ny(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ry(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="replace")}var Kd=class Ud{constructor(e){this.position=e}static fromJSON(e){return new Ud(e.position)}toJSON(){return{position:this.position}}};function Oy(t,e){let n=e.mapping.mapResult(t.position);return{position:new Kd(n.pos),mapResult:n}}function Iy(t){return new Kd(t)}function Dy(t,e,n){let{selection:r}=e,s=null;if(Md(r)&&(s=r.$cursor),s){var i;let l=(i=t.storedMarks)!==null&&i!==void 0?i:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var Ly=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let{selection:i}=n,{empty:o,ranges:l}=i,a=st(t,r.schema);if(s)if(o){let c=Dd(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&n.addMark(p,m,a.create({...g.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Dy(r,n,a)},Py=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zy=(t,e={})=>({state:n,dispatch:r,chain:s})=>{let i=ee(t,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>oo(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>oo(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},$y=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,s=Vt(t,0,r.content.size),i=N.create(r,s);e.setSelection(i)}return!0},By=(t,e)=>({tr:n,state:r,dispatch:s})=>{let{selection:i}=r,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Hy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=M.atStart(r).from,l=M.atEnd(r).to,a=Vt(s,o,l),c=Vt(i,o,l),u=M.create(r,a,c);e.setSelection(u)}return!0},Fy=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return $c(r)(e,n)};function hd(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var jy=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{let{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=gs(c,l.node().type.name,l.node().attrs);if(i instanceof N&&i.node.isBlock)return!l.parentOffset||!Ae(o,l.pos)?!1:(r&&(t&&hd(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Nd(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=i instanceof M&&!i.empty?Dt.create({doc:e.doc,selection:i}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=Ae(m,g,1,h);if(!h&&!y&&Ae(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let k=e.steps.length;if(i instanceof M&&e.deleteSelection(),e.split(e.mapping.slice(k).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let b=e.mapping.slice(k).map(l.before()),x=e.doc.resolve(b);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(k).map(l.before()),f)}}t&&hd(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return y},_y=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{let o=ee(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==o)return!1;let d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){var f;let x=w.empty,E=l.index(-1)?1:l.index(-2)?2:3;for(let Te=l.depth-E;Te>=l.depth-3;Te-=1)x=w.from(l.node(Te).copy(x));let C=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...gs(d,l.node().type.name,l.node().attrs),...e},D=((f=o.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(T))||void 0;x=x.append(w.from(o.createAndFill(null,D)||void 0));let I=l.before(l.depth-(E-1));n.replace(I,l.after(-C),new v(x,4-E,0));let $=-1;n.doc.nodesBetween(I,n.doc.content.size,(Te,Mt)=>{if($>-1)return!1;Te.isTextblock&&Te.content.size===0&&($=Mt+1)}),$>-1&&n.setSelection(M.near(n.doc.resolve($))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...gs(d,u.type.name,u.attrs),...e},m={...gs(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);n.delete(l.pos,a.pos);let k=g?u.attrs:p,b=h?[{type:o,attrs:k},{type:h,attrs:m}]:[{type:o,attrs:k}];if(!Ae(n.doc,l.pos,2))return!1;if(s){let{selection:x,storedMarks:E}=r,{splittableMarks:C}=i.extensionManager,T=E||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),g&&n.setNodeMarkup(y,void 0,p),!T||!s)return!0;let D=T.filter(I=>C.includes(I.type.name));n.ensureMarks(D)}return!0};function qd(t,e,n){if(!t.validContent(e))return null;try{return t.create(n,e)}catch{return null}}function sl(t,e){if(t.pendingContent.length===0)return!0;let n=qd(e,w.from(t.pendingContent));return n?(t.items.push(n),t.pendingContent=[],!0):!1}function Wy(t,e,n){return n.validContent(w.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!sl(e,n)||!n.validContent(w.from(t))?!1:(e.pendingContent.push(t),!0)}function Vy(t,e,n,r){let s=r(t,n);if(!s)return!1;let i=qd(n.listType,w.from(s),t.attrs);return i?n.itemType.validContent(w.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):sl(e,n.itemType)?(e.items.push(...s),!0):!1:!1}function Ky(t,e,n){let r={items:[],pendingContent:[]};for(let s=0;s<t.childCount;s+=1){let i=t.child(s);if(!(e.isListNode(i)?Vy(i,r,e,n):Wy(i,r,e.itemType)))return null}return sl(r,e.itemType)?r.items:null}function Jd(t,e){let n=[];for(let r=0;r<t.childCount;r+=1){let s=Ky(t.child(r),e,Jd);if(!s)return null;n.push(...s)}return n}function pd(t,e){let n=null;return t.descendants((r,s)=>r!==e?!0:(n=s,!1)),n}function md(t){return!t||t==="1"?null:t}function Gd(t,e){return md(t)===md(e)}var fs=(t,e)=>{let n=xs(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&Le(t.doc,n.pos))||!Gd(n.node.attrs.type,s?.attrs.type)||t.join(n.pos),!0},hs=(t,e)=>{let n=xs(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&Le(t.doc,r))||!Gd(n.node.attrs.type,s?.attrs.type)||t.join(r),!0};function Uy(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),s=e.resolve(n.nodeSize-1);return M.between(r,s)}var qy=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=s.extensionManager,h=ee(t,o.schema),p=ee(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:k}=m,b=y.blockRange(k),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;let E=xs(he=>ar(he.type.name,d))(m),C=m.from===0&&m.to===o.doc.content.size,T=o.doc.content.content,D=T.length===1?T[0]:null,I=C&&D&&ar(D.type.name,d)?{node:D,pos:0,depth:0}:null,$=E??I,Te=!!E&&b.depth>=1&&b.depth-E.depth<=1,Mt=!!I;if((Te||Mt)&&$){if($.node.type===h)return C&&Mt?a().command(({tr:he,dispatch:be})=>{let pe=Uy(he);return pe?(he.setSelection(pe),be&&be(he),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(ar($.node.type.name,d)&&h.validContent($.node.content))return a().command(()=>(i.setNodeMarkup($.pos,h),!0)).command(()=>fs(i,h)).command(()=>hs(i,h)).run();if(ar($.node.type.name,d)){var Tt;let he=(Tt=$.node.firstChild)===null||Tt===void 0?void 0:Tt.type;if(he&&he!==p){let be=Jd($.node,{listType:h,itemType:p,isListNode:Rr=>ar(Rr.type.name,d)}),pe=be?w.from(be):null;return!pe||!h.validContent(pe)?!1:a().command(()=>{let{$anchor:Rr,$head:ka}=i.selection,ba=Rr.parent,wa=ka.parent,Ep=Rr.parentOffset,Rp=ka.parentOffset,Nr;try{Nr=h.create(r,pe)}catch{return!1}if(i.replaceWith($.pos,$.pos+$.node.nodeSize,Nr),ba.inlineContent&&wa.inlineContent){let xa=pd(Nr,ba),Sa=pd(Nr,wa);if(xa!==null&&Sa!==null){let Np=$.pos+xa+2+Ep,Op=$.pos+Sa+2+Rp;i.setSelection(M.create(i.doc,Np,Op))}}return!0}).command(()=>fs(i,h)).command(()=>hs(i,h)).run()}}}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>fs(i,h)).command(()=>hs(i,h)).run():a().command(()=>{let he=u().wrapInList(h,r),be=x.filter(pe=>f.includes(pe.type.name));return i.ensureMarks(be),he?!0:c.clearNodes()}).wrapInList(h,r).command(()=>fs(i,h)).command(()=>hs(i,h)).run()},Jy=(t,e={},n={})=>({state:r,commands:s})=>{let{extendEmptyMarkRange:i=!1}=n,o=st(t,r.schema);return Xo(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Gy=(t,e,n={})=>({state:r,commands:s})=>{let i=ee(t,r.schema),o=ee(e,r.schema),l=Ve(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},Xy=(t,e={})=>({state:n,commands:r})=>{let s=ee(t,n.schema);return Ve(n,s,e)?r.lift(s):r.wrapIn(s,e)},Yy=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let s=n[r],i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){let o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},Qy=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>s||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},Zy=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:o}=n,l=st(t,r.schema),{$from:a,empty:c,ranges:u}=o;if(!s)return!0;if(c&&i){var d;let{from:f,to:h}=o,p=Qo(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},ek=t=>({tr:e,state:n,dispatch:r})=>{let{selection:s}=n,i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},tk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,l=ws(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ee(t,r.schema)),l==="mark"&&(o=st(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(i&&i===g.type&&(a=!0,s&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(k=>{if(o===k.type&&(a=!0,s)){let b=Math.max(y,u),x=Math.min(y+g.nodeSize,d);n.addMark(b,x,o.create({...k.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&s&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},bn=new j("__tiptap_decorations__"),nk=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(bn,{type:"force",name:t}),!0),rk=(t,e={})=>({state:n,dispatch:r})=>{let s=ee(t,n.schema);return Lc(s,e)(n,r)},sk=(t,e={})=>({state:n,dispatch:r})=>{let s=ee(t,n.schema);return Pc(s,e)(n,r)},ze=va({blur:()=>M0,clearContent:()=>T0,clearNodes:()=>A0,command:()=>E0,createParagraphNear:()=>R0,cut:()=>N0,deleteCurrentNode:()=>O0,deleteNode:()=>I0,deleteRange:()=>D0,deleteSelection:()=>z0,enter:()=>$0,exitCode:()=>B0,extendMarkRange:()=>H0,first:()=>F0,focus:()=>_0,forEach:()=>W0,insertContent:()=>V0,insertContentAt:()=>K0,insertDefaultBlock:()=>U0,joinBackward:()=>G0,joinDown:()=>J0,joinForward:()=>X0,joinItemBackward:()=>Y0,joinItemForward:()=>Q0,joinTextblockBackward:()=>Z0,joinTextblockForward:()=>ey,joinUp:()=>q0,keyboardShortcut:()=>ny,lift:()=>ry,liftEmptyBlock:()=>sy,liftListItem:()=>iy,newlineInCode:()=>oy,resetAttributes:()=>ly,scrollIntoView:()=>ay,selectAll:()=>cy,selectNodeBackward:()=>uy,selectNodeForward:()=>dy,selectParentNode:()=>fy,selectTextblockEnd:()=>hy,selectTextblockStart:()=>py,setContent:()=>my,setMark:()=>Ly,setMeta:()=>Py,setNode:()=>zy,setNodeSelection:()=>$y,setTextDirection:()=>By,setTextSelection:()=>Hy,sinkListItem:()=>Fy,splitBlock:()=>jy,splitListItem:()=>_y,toggleList:()=>qy,toggleMark:()=>Jy,toggleNode:()=>Gy,toggleWrap:()=>Xy,undoInputRule:()=>Yy,unsetAllMarks:()=>Qy,unsetMark:()=>Zy,unsetTextDirection:()=>ek,updateAttributes:()=>tk,updateDecorations:()=>nk,wrapIn:()=>rk,wrapInList:()=>sk}),wn=new WeakMap;function ik(t,e){var n;wn.set(t,((n=wn.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let s=((r=wn.get(t))!==null&&r!==void 0?r:1)-1;s>0?wn.set(t,s):wn.delete(t)}}function ok(t){return wn.has(t)}var lk=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Xd=typeof process<"u"&&!1;function ak(t){return t.kind==="widget"}function Yd(t,e){let n=[],r=new Set;for(let s of t)s.kind==="widget"&&ak(s)&&r.add(s.key),n.push(s.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function ck(t,e,n){let{decorations:r,widgetKeys:s}=Yd(e,n);return{set:_.create(t,r),widgetKeys:s}}function Qd({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function uk({decorations:t,from:e,to:n,docSize:r,extensionName:s,warnedExtensions:i}){return t.filter(o=>Qd({position:o.anchor,from:e,to:n,docSize:r})?!0:(o.anchor===n||i.has(s)||(i.add(s),console.warn(`[tiptap warn]: Extension "${s}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function Zd(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function dk(t){let e=new Map,n=new Map;for(let o of t.find()){var r,s,i;let l=Zd(o);if(!l)continue;let a=(r=o.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(s=e.get(l))!==null&&s!==void 0?s:new Set;c.add(a),e.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([o,l])=>({key:o,extensions:l})).filter(({key:o})=>{var l;return((l=n.get(o))!==null&&l!==void 0?l:0)>1})}function ef(t){return t.jsonID==="attr"}function fk(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||ef(t))return!0;let n=t;return typeof n.from=="number"&&typeof n.to=="number"}function hk(t,e){let n=null,r=0,s=0;for(let i=0;i<t.childCount&&!(s>e.to);i+=1){let o=s+t.child(i).nodeSize;o>=e.from&&(n===null&&(n=s),r=o),s=o}return n===null?null:{from:n,to:r}}function pk(t,e){if(t.steps.some(i=>!fk(i)))return{type:"full"};let n=Tn(t).map(({newRange:i})=>i);t.steps.forEach((i,o)=>{if(!ef(i))return;let l=t.mapping.slice(o);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let o=hk(e,i);o&&r.push(o)}r.sort((i,o)=>i.from-o.from);let s=[];for(let i of r){let o=s[s.length-1];o&&i.from<=o.to?o.to=Math.max(o.to,i.to):s.push({...i})}return{type:"ranges",ranges:s}}function tf(t,e,n,r){return t.map(e,n,{onRemove:s=>{let i=s?.key;typeof i=="string"&&r.delete(i)}})}function mk(t,e,n){var r,s;let i=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:_.empty,o=new Set((s=e.widgetKeysByExtension[t])!==null&&s!==void 0?s:[]);return{set:tf(i,n.mapping,n.doc,o),widgetKeys:o}}function gd(t,e){let n=Object.values(e).flatMap(r=>r.find());return _.create(t,n)}function yd(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function gk(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function yk(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var kk=new Set;var bk=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=bn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>gk(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=bn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:kk}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let s=r();s&&e.push({name:n,spec:s})}return e}createPlugin(){let{editor:t,entries:e}=this;return new L({key:bn,state:{init:(n,r)=>{let s={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);s[l]=c,i[l]=u}let o={decorationSetsByExtension:s,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,s),widgetKeys:yd(i)};return this.warnDuplicateWidgetKeys(o),o},apply:(n,r,s,i)=>{let o=n.getMeta(bn),l=o?.type==="force"&&!o.name,a=o?.type==="force"?o.name:void 0,c={},u={},d=new Set;return ik(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(yk(h,{editor:t,tr:n,oldState:s,newState:i},p))if(h.update==="changedRanges"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,i);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,i);c[f]=m,u[f]=g,d.add(f)}else{let m=mk(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:yd(u)}}},props:{decorations(n){var r,s;return(r=(s=bn.getState(n))===null||s===void 0?void 0:s.mergedDecorationSet)!==null&&r!==void 0?r:_.empty}}})}applyChangedRangesRecompute(t,e,n,r,s){let i=pk(r,s.doc);return i.type==="full"?this.buildFullSet(t,e,s):this.rebuildRanges(t,e,n,r,s,i.ranges)}rebuildRanges(t,e,n,r,s,i){var o,l;let a=(o=n.decorationSetsByExtension[t])!==null&&o!==void 0?o:_.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),u=tf(a,r.mapping,r.doc,c),d=s.doc.content.size;for(let{from:f,to:h}of i){let p=u.find(f,h).filter(y=>Qd({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let k=Zd(y);k&&c.delete(k)}u=u.remove(p);let{decorations:m,widgetKeys:g}=Yd(uk({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:s,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(s.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return ck(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!Xd)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=dk(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:s}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(s).map(o=>`"${o}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${s.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:gd(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:s}){return t.length===1?r[t[0].name]:s.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):gd(n.doc,r)}};function Ut(t,e){if(t===e)return!0;if(!t||!e)return!1;let n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(s=>Object.prototype.hasOwnProperty.call(e,s)&&Object.is(t[s],e[s]))}function nf(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof N){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){let i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function wk(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var xk={lt:"<",gt:">",quot:'"',amp:"&"};function il(t){return t.replace(/&(?:#(\d{1,7})|#[xX]([0-9a-fA-F]{1,6})|(lt|gt|quot|amp));/g,(e,n,r,s)=>n!==void 0?kd(Number(n)):r!==void 0?kd(parseInt(r,16)):xk[s])}var Sk=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function kd(t){var e;return t===0||t>1114111||t>=55296&&t<=57343?"\uFFFD":String.fromCodePoint((e=Sk.get(t))!==null&&e!==void 0?e:t)}function rf(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ck(t){return typeof t=="number"}function vk(t){return Object.prototype.toString.call(t).slice(8,-1)}function ps(t){return vk(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function sf(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function Mk(t,e){return t.replace(/^[ \t]*/,n=>{let s=0;for(let i of n)s+=i===" "?4-s%4:1;return" ".repeat(Math.max(0,s-e))})}function Tk(t,e){let n=`text
|
|
7
|
+
"use strict";var Hi=Object.defineProperty;var rm=Object.getOwnPropertyDescriptor;var sm=Object.getOwnPropertyNames;var im=Object.prototype.hasOwnProperty;var om=(t,e)=>{for(var n in e)Hi(t,n,{get:e[n],enumerable:!0})},lm=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of sm(e))!im.call(t,s)&&s!==n&&Hi(t,s,{get:()=>e[s],enumerable:!(r=rm(e,s))||r.enumerable});return t};var am=t=>lm(Hi({},"__esModule",{value:!0}),t);var mC={};om(mC,{mountDocEditor:()=>pC});module.exports=am(mC);var $a=Object.defineProperty,za=(t,e)=>{let n={};for(var r in t)$a(n,r,{get:t[r],enumerable:!0});return e||$a(n,Symbol.toStringTag,{value:"Module"}),n};function le(t){this.content=t}le.prototype={constructor:le,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new le(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new le(n)},addToStart:function(t,e){return new le([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new le(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new le(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=le.from(t),t.size?new le(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=le.from(t),t.size?new le(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=le.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};le.from=function(t){if(t instanceof le)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new le(e)};var Fi=le;function Ga(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,a=0;for(;o[a]==l[a];a++)n++;return a&&a<o.length&&a<l.length&&Qa(o.charCodeAt(a-1))&&Ya(o.charCodeAt(a))&&n--,n}if(s.content.size||i.content.size){let o=Ga(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function Xa(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&Qa(c.charCodeAt(d-1))&&Ya(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let c=Xa(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Ya(t){return t>=56320&&t<57344}function Qa(t){return t>=55296&&t<56320}var w=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new t(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new t(r,s)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new t(s,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Ga(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Xa(this,e,n,r)}findIndex(e){if(e==0)return $r(0,e);if(e==this.size)return $r(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?$r(n+1,i):$r(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};w.empty=new w([],0);var _i={index:0,offset:0};function $r(t,e){return _i.index=t,_i.offset=e,_i}function Hr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Hr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Hr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var F=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Hr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};F.none=[];var dt=class extends Error{},v=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ec(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(Za(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(w.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new t(e,r,s)}};v.empty=new v(w.empty,0,0);function Za(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Za(i.content,e-s-1,n-s-1)))}function ec(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=ec(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function cm(t,e,n){if(n.openStart>t.depth)throw new dt("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new dt("Inconsistent open depths");return tc(t,e,n,0)}function tc(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=tc(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Rt(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=um(n,t);return Rt(i,rc(t,o,l,e,r))}else return Rt(i,Fr(t,e,r))}function nc(t,e){if(!e.type.compatibleContent(t.type))throw new dt("Cannot join "+e.type.name+" onto "+t.type.name)}function ji(t,e,n){let r=t.node(n);return nc(r,e.node(n)),r}function Et(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function _n(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Et(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Et(s.child(l),r);e&&e.depth==n&&e.textOffset&&Et(e.nodeBefore,r)}function Rt(t,e){if(!t.type.validContent(e))throw new dt("Invalid content for node "+t.type.name);return t.copy(e)}function rc(t,e,n,r,s){let i=t.depth>s&&ji(t,e,s+1),o=r.depth>s&&ji(n,r,s+1),l=[];return _n(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(nc(i,o),Et(Rt(i,rc(t,e,n,r,s+1)),l)):(i&&Et(Rt(i,Fr(t,e,s+1)),l),_n(e,n,s,l),o&&Et(Rt(o,Fr(n,r,s+1)),l)),_n(r,null,s,l),new w(l)}function Fr(t,e,n){let r=[];if(_n(null,t,n,r),t.depth>n){let s=ji(t,e,n+1);Et(Rt(s,Fr(t,e,n+1)),r)}return _n(e,null,n,r),new w(r)}function um(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(w.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}var _r=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Nt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=Ba.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Ba.set(e,r=new Wi);let s=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%dm,s}},Wi=class{constructor(){this.elts=[],this.i=0}},dm=12,Ba=new WeakMap,Nt=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},fm=Object.create(null),Pe=class t{constructor(e,n,r,s=F.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||w.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Hr(this.attrs,n||e.defaultAttrs||fm)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return v.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new v(c,s.depth-o,i.depth-o)}replace(e,n,r){return cm(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return _r.resolveCached(this,e)}resolveNoCache(e){return _r.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),sc(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=w.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Fa(this.type.attrs,this.attrs,"node",this.type.name);let e=F.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Fa(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=w.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,s,r)}};Pe.prototype.text=void 0;var Ha=(()=>{let{stack:t}=new Error("/");if(!t||!/\n\s*at\s/.test(t))return n=>n;let e=Object.create(null);return n=>(e[n],n)})(),Vi=class t extends Pe{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):sc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return Ha(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(Ha(this.text.slice(e,n)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function sc(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Fa(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}var Ot=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ki(e,n);if(r.next==null)return t.empty;let s=ic(r);r.next&&r.err("Unexpected trailing text");let i=bm(km(s));return wm(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return w.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
8
|
+
`)}};Ot.empty=new Ot(!0);var Ki=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ic(t){let e=[];do e.push(hm(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function hm(t){let e=[];do e.push(pm(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function pm(t){let e=ym(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=mm(t,e);else break;return e}function _a(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function mm(t,e){let n=_a(t),r=n;return t.eat(",")&&(t.next!="}"?r=_a(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function gm(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function ym(t){if(t.eat("(")){let e=ic(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=gm(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function km(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function oc(t,e){return e-t}function ja(t,e){let n=[];return r(e),n.sort(oc);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function bm(t){let e=Object.create(null);return n(ja(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);ja(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Ot(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(oc);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function wm(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function lc(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function ac(t,e){let n=Object.create(null);for(let r in t){let s=t[r],i=e&&e[r];if(i===void 0)if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r);else s.validate&&s.validate(i);n[r]=i}return n}function cc(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Ui(t,r,e[r]);return n}var sn=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=cc(e,r.attrs),this.defaultAttrs=lc(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ot.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ac(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Pe(this,this.computeAttrs(e),w.from(n),F.setFrom(r))}createChecked(e=null,n,r){return n=w.from(n),this.checkContent(n),new Pe(this,this.computeAttrs(e),n,F.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=w.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(w.empty,!0);return i?new Pe(this,e,n.append(i),F.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:F.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new t(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function xm(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var Ui=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?xm(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Wn=class t{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=cc(e,s.attrs),this.excluded=null;let i=lc(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,ac(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new t(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},It=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Fi.from(e.nodes),n.marks=Fi.from(e.marks||{}),this.nodes=sn.compile(this.spec.nodes,this),this.marks=Wn.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Ot.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Wa(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Wa(this,o.split(" "))}this.nodeFromJSON=s=>Pe.fromJSON(this,s),this.markFromJSON=s=>F.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof sn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Vi(r,r.defaultAttrs,e,F.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Wa(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Sm(t){return t.tag!=null}function Cm(t){return t.style!=null}var je=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Sm(s))this.tags.push(s);else if(Cm(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new jr(this,n,!1);return r.addAll(e,F.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new jr(this,n,!0);return r.addAll(e,F.none,n.from,n.to),v.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Tm(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ka(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ka(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},uc={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},vm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dc={ol:!0,ul:!0},Vn=1,qi=2,jn=4;function Va(t,e,n){return e!=null?(e?Vn:0)|(e==="full"?qi:0):t&&t.whitespace=="pre"?Vn|qi:n&~jn}var rn=class{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=F.none,this.match=i||(o&jn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(w.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=w.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!uc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},jr=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Va(null,n.preserveWhitespace,0)|(r?jn:0);s?i=new rn(s.type,s.attrs,F.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new rn(null,null,F.none,!0,null,o):i=new rn(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&qi?"full":this.localPreserveWS||(s.options&Vn)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
9
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;dc.hasOwnProperty(o)&&this.parser.normalizeLists&&Mm(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:vm.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(uc.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
10
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=F.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Ua(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Va(e,i,o.options);o.options&jn&&o.content.length==0&&(l|=jn);let a=F.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Ua(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new rn(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Vn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function Mm(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dc.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Tm(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ka(t){let e={};for(let n in t)e[n]=t[n];return e}function Ua(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}var Xe=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=zr(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return zr(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Br(zr(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Br(zr(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Br(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=qa(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return qa(e.marks)}};function qa(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zr(t){return t.document||window.document}var Ja=new WeakMap;function Am(t){let e=Ja.get(t);return e===void 0&&Ja.set(t,e=Em(t)),e}function Em(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Br(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Am(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=Br(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var gc=65535,yc=Math.pow(2,16);function Rm(t,e){return t+e*yc}function fc(t){return t&gc}function Nm(t){return(t-(t&gc))/yc}var kc=1,bc=2,Wr=4,wc=8,qn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&wc)>0}get deletedBefore(){return(this.delInfo&(kc|Wr))>0}get deletedAfter(){return(this.delInfo&(bc|Wr))>0}get deletedAcross(){return(this.delInfo&Wr)>0}},Ye=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=fc(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Nm(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+s+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:Rm(l/3,e-a),m=0;return c&&(m|=e==a?bc:e==d?kc:Wr,(n<0?e!=a:e!=d)&&(m|=wc)),new qn(h,m,p)}s+=u-c}return r?e+s:new qn(e+s,0,null)}touches(e,n){let r=0,s=fc(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Ye.empty=new Ye([]);var Jn=class t{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new qn(e,s,null)}},Ji=Object.create(null),Y=class{getMap(){return Ye.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ji[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ji)throw new RangeError("Duplicate use of step JSON ID "+e);return Ji[e]=n,n.prototype.jsonID=e,n}},re=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,s){try{return t.ok(e.replace(n,r,s))}catch(i){if(i instanceof dt)return t.fail(i.message);throw i}}};function Qi(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Qi(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return w.fromArray(r)}var Gn=class t extends Y{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new v(Qi(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return re.fromReplace(e,this.from,this.to,i)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!F.sameSet(i,r.marks)){let o=Math.max(this.from,s),l=Math.min(this.to,s+r.nodeSize);Vr(ft,o,l,this.mark,n);for(let a of r.marks)a.isInSet(i)||Vr(t,o,l,a,n)}}}),n.length==1?n[0]:new Xn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Y.jsonID("addMark",Gn);var ft=class t extends Y{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new v(Qi(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return re.fromReplace(e,this.from,this.to,r)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Vr(Gn,Math.max(this.from,s),Math.min(this.to,s+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new Xn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Y.jsonID("removeMark",ft);function Vr(t,e,n,r,s){let i=s.length?s[s.length-1]:null;i&&i instanceof t&&i.to==e&&i.mark.eq(r)?s[s.length-1]=new t(i.from,n,r):s.push(new t(e,n,r))}var Xn=class t extends Y{constructor(e){super(),this.steps=e}apply(e){for(let n of this.steps){let r=n.apply(e);if(!r.doc)return r;e=r.doc}return new re(e,null)}invert(e){return new t(this.steps.map(n=>n.invert(e)))}map(e){let n=[];for(let r of this.steps){let s=r.map(e);s&&n.push(s)}return n.length?new t(n):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,n){if(!Array.isArray(n.steps)||!n.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new t(n.steps.map(r=>Y.fromJSON(e,r)))}};Y.jsonID("markSet",Xn);var Yn=class t extends Y{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new t(this.pos,n.marks[s]);return new t(this.pos,this.mark)}}return new on(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Y.jsonID("addNodeMark",Yn);var on=class t extends Y{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Y.jsonID("removeNodeMark",on);var Q=class t extends Y{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Xi(e,this.from,this.to)?re.fail("Structure replace would overwrite content"):re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ye([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?v.empty:new v(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?v.empty:new v(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,v.fromJSON(e,n.slice),!!n.structure)}};Q.MAP_BIAS=1;Y.jsonID("replace",Q);var Z=class t extends Y{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Xi(e,this.from,this.gapFrom)||Xi(e,this.gapTo,this.to)))return re.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return re.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?re.fromReplace(e,this.from,this.to,r):re.fail("Content does not fit in gap")}getMap(){return new Ye([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos||s>i?null:new t(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,v.fromJSON(e,n.slice),n.insert,!!n.structure)}};Y.jsonID("replaceAround",Z);function Xi(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function Om(t,e,n,r){let s=[];t.doc.nodesBetween(e,n,(i,o,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(o,e),u=Math.min(o+i.nodeSize,n);Vr(Gn,c,u,r,s)}}),s.forEach(i=>t.step(i))}function Im(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline||!o.isAtom)return;i++;let a=null;if(r instanceof Wn){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new ft(o.from,o.to,o.style)))}function Zi(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Q(l,u,v.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new ft(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new v(w.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Q(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(w.empty,!0);t.replace(l,l,new v(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function Lm(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Qe(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!Lm(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function Dm(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=w.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=w.from(r.node(p).copy(u)),d++):a--;let f=w.empty,h=0;for(let p=i,m=!1;p>n;p--)m||s.after(p+1)<s.end(p)?(m=!0,f=w.from(s.node(p).copy(f)),h++):c++;t.step(new Z(a,c,o,l,new v(u.append(f),d,h),u.size-d,!0))}function an(t,e,n=null,r=t){let s=Pm(t,e),i=s&&$m(r,e);return i?s.map(hc).concat({type:e,attrs:n}).concat(i.map(hc)):null}function hc(t){return{type:t,attrs:null}}function Pm(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function $m(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function zm(t,e,n){let r=w.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=w.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Z(s,i,s,i,new v(r,0,0),n.length,!0))}function Bm(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Hm(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Sc(t,o,l,i),Zi(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return t.step(new Z(d,f,d+1,f-1,new v(w.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&xc(t,o,l,i),!1}})}function xc(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Sc(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
11
|
+
`))}})}function Hm(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function Fm(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Z(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new v(w.from(o),0,0),1,!0))}function Re(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function _m(t,e,n=1,r){let s=t.doc.resolve(e),i=w.empty,o=w.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=w.from(s.node(l).copy(i));let u=r&&r[c];o=w.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Q(e,e,new v(i.append(o),n,n),!0))}function $e(t,e){let n=t.resolve(e),r=n.index();return Cc(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function jm(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Cc(t,e){return!!(t&&e&&!t.isLeaf&&jm(t,e))}function cn(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Cc(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function Wm(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Sc(t,u.node(),u.before(),l)}o.inlineContent&&Zi(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Q(c,a.map(e+n,-1),v.empty,!0)),r===!0){let u=t.doc.resolve(c);xc(t,u.node(),u.before(),t.steps.length)}return t}function Vm(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function qr(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Qn(t,e,n=e,r=v.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return vc(s,i,r)?new Q(e,n,r):new Yi(s,i,r).fit()}function vc(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Yi=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=w.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=w.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new v(i,o,l);return e>-1?new Z(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Q(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=pc(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(w.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return mc(e,-1)<=n?!1:(this.unplaced.size>1&&mc(e,1)>r&&r++,this.unplaced=new v(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=pc(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new v(Kn(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new v(Kn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(s){for(let m=0;m<s.childCount;m++)u.push(s.child(m));d=d.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Mc(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Un(this.placed,n,w.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<h;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=p?e==0?v.empty:new v(Kn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new v(Kn(o.content,e,c),e,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Gi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Gi(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Gi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Un(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Un(this.placed,this.depth,w.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(w.empty,!0);n.childCount&&(this.placed=Un(this.placed,this.frontier.length,n))}};function Kn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Kn(t.firstChild.content,e-1,n)))}function Un(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Un(t.lastChild.content,e-1,n)))}function pc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Mc(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Mc(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(w.empty,!0)))),t.copy(r)}function Gi(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Km(n,i.content,o)?l:null}function Km(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Um(t){return t.spec.defining||t.spec.definingForContent}function mc(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function qm(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(vc(s,i,r))return t.step(new Q(e,n,r));let o=Ac(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Um(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let k=s.node(g-1),b=s.index(g-1);if(k.canReplaceWith(b,b,p.type,p.marks))return t.replace(s.before(g),y?i.after(g):n,new v(Tc(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=s.before(h),n=i.after(h))}}function Tc(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Tc(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(w.empty,!0))}return t}function Jm(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Vm(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new v(w.from(r),0,0))}function Gm(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&n==s.start(a);a--)n=s.before(a);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=Ac(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Ac(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}var Kr=class t extends Y{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return re.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return re.fromReplace(e,this.pos,this.pos+1,new v(w.from(s),0,n.isLeaf?0:1))}getMap(){return Ye.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};Y.jsonID("attr",Kr);var Ur=class t extends Y{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return re.ok(r)}getMap(){return Ye.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};Y.jsonID("docAttr",Ur);var ln=class extends Error{};ln=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ln.prototype=Object.create(Error.prototype);ln.prototype.constructor=ln;ln.prototype.name="TransformError";var ht=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ln(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=v.empty){let s=Qn(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new v(w.from(r),0,0))}delete(e,n){return this.replace(e,n,v.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return qm(this,e,n,r),this}replaceRangeWith(e,n,r){return Jm(this,e,n,r),this}deleteRange(e,n){return Gm(this,e,n),this}lift(e,n){return Dm(this,e,n),this}join(e,n=1){return Wm(this,e,n),this}wrap(e,n){return zm(this,e,n),this}setBlockType(e,n=e,r,s=null){return Bm(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return Fm(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Kr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ur(e,n)),this}addNodeMark(e,n){return this.step(new Yn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof F)n.isInSet(r.marks)&&this.step(new on(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new on(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return _m(this,e,n,r),this}addMark(e,n,r){return Om(this,e,n,r),this}removeMark(e,n,r){return Im(this,e,n,r),this}clearIncompatible(e,n,r){return Zi(this,e,n,r),this}};var eo=Object.create(null),R=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new dn(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=v.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?v.empty:n),l==0&&Nc(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Nc(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new M(e):un(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?un(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):un(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new me(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new me(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new me(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=eo[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in eo)throw new RangeError("Duplicate use of selection JSON ID "+e);return eo[e]=n,n.prototype.jsonID=e,n}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};R.prototype.visible=!0;var dn=class{constructor(e,n){this.$from=e,this.$to=n}},Ec=!1;function Rc(t){!Ec&&!t.parent.inlineContent&&(Ec=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var M=class t extends R{constructor(e,n=e){Rc(e),Rc(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return R.near(r);let s=e.resolve(n.map(this.anchor));return new t(s.parent.inlineContent?s:r,r)}replace(e,n=v.empty){if(super.replace(e,n),n==v.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=R.findFrom(n,r,!0)||R.findFrom(n,-r,!0);if(i)n=i.$head;else return R.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new t(e,n)}};R.jsonID("text",M);var Gr=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},N=class t extends R{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?R.near(i):new t(i)}content(){return new v(w.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new no(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};N.prototype.visible=!1;R.jsonID("node",N);var no=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Gr(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&N.isSelectable(r)?new N(n):R.near(n)}},me=class t extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=v.empty){if(n==v.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Xm}};R.jsonID("all",me);var Xm={map(){return this},resolve(t){return new me(t)}};function un(t,e,n,r,s,i=!1){if(e.inlineContent)return M.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(t,n-(s<0?l.nodeSize:0))}else{let a=un(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function Nc(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Q||s instanceof Z))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(R.near(t.doc.resolve(o),n))}var Oc=1,Jr=2,Ic=4,ro=class extends ht{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Oc)&~Jr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Oc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Jr,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Jr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Jr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ic,this}get scrolledIntoView(){return(this.updated&Ic)>0}};function Lc(t,e){return!e||!t?t:t.bind(e)}var Lt=class{constructor(e,n,r){this.name=e,this.init=Lc(n.init,r),this.apply=Lc(n.apply,r)}},Ym=[new Lt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Lt("selection",{init(t,e){return t.selection||R.atStart(e.doc)},apply(t){return t.selection}}),new Lt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Lt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Zn=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ym.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Lt(r.key,r.spec.state,r))})}},Dt=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new ro(this)}static create(e){let n=new Zn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Zn(this.schema,e.plugins),r=n.fields,s=new t(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Zn(e.schema,e.plugins),i=new t(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Pe.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=R.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}};function Dc(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Dc(s,e,{})),n[r]=s}return n}var P=class{constructor(e){this.spec=e,this.props={},e.props&&Dc(e.props,this,this.props),this.key=e.key?e.key.key:Pc("plugin")}getState(e){return e[this.key]}},to=Object.create(null);function Pc(t){return t in to?t+"$"+ ++to[t]:(to[t]=0,t+"$")}var _=class{constructor(e="key"){this.key=Pc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var zc=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Bc(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var io=(t,e,n)=>{let r=Bc(t,n);if(!r)return!1;let s=lo(r);if(!s){let o=r.blockRange(),l=o&&Qe(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Kc(t,s,e,-1))return!0;if(r.parent.content.size==0&&(fn(i,"end")||N.isSelectable(i)))for(let o=r.depth;;o--){let l=Qn(t.doc,r.before(o),r.after(o),v.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(fn(i,"end")?R.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):N.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},hn=(t,e,n)=>{let r=Bc(t,n);if(!r)return!1;let s=lo(r);return s?Hc(t,s,e):!1},pn=(t,e,n)=>{let r=Fc(t,n);if(!r)return!1;let s=uo(r);return s?Hc(t,s,e):!1};function Hc(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Qn(t.doc,i,a,v.empty);if(!c||c.from!=i||c instanceof Q&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(M.create(u.doc,i)),n(u.scrollIntoView())}return!0}function fn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var oo=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=lo(r)}let o=i&&i.nodeBefore;return!o||!N.isSelectable(o)?!1:(e&&e(t.tr.setSelection(N.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function lo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Fc(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var ao=(t,e,n)=>{let r=Fc(t,n);if(!r)return!1;let s=uo(r);if(!s)return!1;let i=s.nodeAfter;if(Kc(t,s,e,1))return!0;if(r.parent.content.size==0&&(fn(i,"start")||N.isSelectable(i))){let o=Qn(t.doc,r.before(),r.after(),v.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(fn(i,"start")?R.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):N.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},co=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=uo(r)}let o=i&&i.nodeAfter;return!o||!N.isSelectable(o)?!1:(e&&e(t.tr.setSelection(N.create(t.doc,i.pos)).scrollIntoView()),!0)};function uo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}var _c=(t,e)=>{let n=t.selection,r=n instanceof N,s;if(r){if(n.node.isTextblock||!$e(t.doc,n.from))return!1;s=n.from}else if(s=cn(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(N.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},jc=(t,e)=>{let n=t.selection,r;if(n instanceof N){if(n.node.isTextblock||!$e(t.doc,n.to))return!1;r=n.to}else if(r=cn(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Wc=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Qe(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},fo=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
12
|
+
`).scrollIntoView()),!0)};function ho(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var po=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=ho(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},mo=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof me||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=ho(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(M.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},go=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Re(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Qe(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Qm(t){return(e,n)=>{if(e.selection instanceof N&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Re(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof me)&&r.deleteSelection();let{$from:s}=r.selection,i=r.steps.length,o=[],l,a,c=!1,u=!1;for(let h=s.depth;;h--)if(s.node(h).isBlock){c=s.end(h)==s.pos+(s.depth-h),u=s.start(h)==s.pos-(s.depth-h),a=ho(s.node(h-1).contentMatchAt(s.indexAfter(h-1)));let m=t&&t(s.parent,c,s);o.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;o.unshift(null)}let d=s.pos,f=Re(r.doc,d,o.length,o);if(f||(o[0]=a?{type:a}:null,f=Re(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!c&&u&&s.node(l).type!=a){let h=r.mapping.slice(i),p=h.map(s.before(l)),m=r.doc.resolve(p);a&&s.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(s.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Zm=Qm();var Vc=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(N.create(t.doc,s))),!0)},eg=(t,e)=>(e&&e(t.tr.setSelection(new me(t.doc))),!0);function tg(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||$e(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Kc(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&tg(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(s.copy(p));let m=t.tr.step(new Z(e.pos-1,h,e.pos,h,new v(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&$e(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Qe(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&fn(i,"start",!0)&&fn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=w.empty;for(let b=p.length-1;b>=0;b--)y=w.from(p[b].copy(y));let k=t.tr.step(new Z(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new v(y,p.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Uc(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(M.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}var yo=Uc(-1),ko=Uc(1);function qc(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&an(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function bo(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function wo(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}var so=wo(zc,io,oo),$c=wo(zc,ao,co),pt={Enter:wo(fo,mo,go,Zm),"Mod-Enter":po,Backspace:so,"Mod-Backspace":so,"Shift-Backspace":so,Delete:$c,"Mod-Delete":$c,"Mod-a":eg},ng={"Ctrl-h":pt.Backspace,"Alt-Backspace":pt["Mod-Backspace"],"Ctrl-d":pt.Delete,"Ctrl-Alt-Backspace":pt["Mod-Delete"],"Alt-Delete":pt["Mod-Delete"],"Alt-d":pt["Mod-Delete"],"Ctrl-a":yo,"Ctrl-e":ko};for(let t in pt)ng[t]=pt[t];var IC=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Jc(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return rg(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function rg(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new Nt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Nt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=an(i,n,r,e);return l?(t&&sg(t,e,l,s,n),!0):!1}function sg(t,e,n,r,s){let i=w.empty;for(let u=n.length-1;u>=0;u--)i=w.from(n[u].type.create(n[u].attrs,i));t.step(new Z(e.start-(r?2:0),e.end,e.start,e.end,new v(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&Re(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function Xr(t,e){return t instanceof sn?e==t:t.indexOf(e)>-1}function Gc(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&Xr(t,o.firstChild.type));return i?n?Xr(t,r.node(i.depth-1).type)?ig(e,n,i):og(e,n,i):!0:!1}}function ig(t,e,n){let r=t.tr,s=n.end,i=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;s<i&&(r.step(new Z(s-1,i,s,i,new v(w.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new Nt(r.doc.resolve(n.$from.pos),r.doc.resolve(i),n.depth));let l=Qe(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(s,-1)-1);return $e(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function og(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?w.empty:w.from(s))))return!1;let d=i.pos,f=d+o.nodeSize;return r.step(new Z(d-(l?1:0),f+(a?1:0),d+1,f-1,new v((l?w.empty:w.from(s.copy(w.empty))).append(a?w.empty:w.from(s.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Xc(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&Xr(t,c.firstChild.type));if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(!Xr(t,a.type))return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=w.from(c?a.lastChild.lastChild.type.create():null),d=new v(w.from(a.type.create(null,w.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new Z(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var se=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},kn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Mo=null,et=function(t,e,n){let r=Mo||(Mo=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},lg=function(){Mo=null},_t=function(t,e,n,r){return n&&(Yc(t,e,n,r,-1)||Yc(t,e,n,r,1))},ag=/^(img|br|input|textarea|hr)$/i;function Yc(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ce(t))){let o=t.parentNode;if(!o||!O(o)||cr(t)||ag.test(t.nodeName)||t.contentEditable=="false")return!1;e=se(t)+(s<0?0:1),t=o}else if(O(t)){let o=t.childNodes[e+(s<0?-1:0)];if(O(o)&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?ce(t):0}else return!1}}function ce(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function O(t){return t.nodeType==1}function te(t){return t.nodeType==3}function jt(t,e){return e?t.contains(O(e)?e:e.parentNode):!1}function cg(t,e){for(;;){if(te(t)&&e)return t;if(O(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ce(t)}else if(t.parentNode&&!cr(t))e=se(t),t=t.parentNode;else return null}}function ug(t,e){for(;;){if(te(t)&&e<t.nodeValue.length)return t;if(O(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!cr(t))e=se(t)+1,t=t.parentNode;else return null}}function dg(t,e,n){for(let r=e==0,s=e==ce(t);r||s;){if(t==n)return!0;let i=se(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ce(t)}}function cr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var as=function(t){return t.focusNode&&_t(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function fg(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function hg(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pg(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ce(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ce(r.startContainer),r.startOffset)}}}var We=typeof navigator<"u"?navigator:null,Qc=typeof document<"u"?document:null,wt=We&&We.userAgent||"",To=/Edge\/(\d+)/.exec(wt),Au=/MSIE \d/.exec(wt),Ao=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wt),xe=!!(Au||Ao||To),kt=Au?document.documentMode:Ao?+Ao[1]:To?+To[1]:0,ve=!xe&&/gecko\/(\d+)/i.test(wt);ve&&+(/Firefox\/(\d+)/.exec(wt)||[0,0])[1];var Eo=!xe&&/Chrome\/(\d+)/.exec(wt),ie=!!Eo,Eu=Eo?+Eo[1]:0,ue=!xe&&!!We&&/Apple Computer/.test(We.vendor),bn=ue&&(/Mobile\/\w+/.test(wt)||!!We&&We.maxTouchPoints>2),Ne=bn||(We?/Mac/.test(We.platform):!1),Ru=We?/Win/.test(We.platform):!1,tt=/Android \d/.test(wt),cs=!!Qc&&"webkitFontSmoothing"in Qc.documentElement.style,mg=cs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gg(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ze(t,e){return typeof t=="number"?t:t[e]}function yg(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Zc(t,e,n){if(!Ro(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(!O(o)){o=kn(o);continue}let l=o==i.body,a=l?gg(i):yg(o),c=0,u=0;if(e.top<a.top+Ze(r,"top")?u=-(a.top-e.top+Ze(s,"top")):e.bottom>a.bottom-Ze(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Ze(s,"top")-a.top:e.bottom-a.bottom+Ze(s,"bottom")),e.left<a.left+Ze(r,"left")?c=-(a.left-e.left+Ze(s,"left")):e.right>a.right-Ze(r,"right")&&(c=e.right-a.right+Ze(s,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),c&&(o.scrollLeft+=c);let p=o.scrollLeft-f,m=o.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:kn(o)}}function kg(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Nu(t.dom)}}function Nu(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=kn(r));return e}function bg({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ou(n,r==0?0:r-e)}function Ou(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var mn=null;function wg(t){if(t.setActive)return t.setActive();if(mn)return t.focus(mn);let e=Nu(t);t.focus(mn==null?{get preventScroll(){return mn={preventScroll:!0},!0}}:void 0),mn||(mn=!1,Ou(e,0))}function Iu(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(O(u))f=u.getClientRects();else if(te(u))f=et(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,s=m&&te(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,O(u)&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&te(n)?xg(n,s):!n||r?{node:t,offset:i}:Iu(n,s)}function xg(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=mt(r,1);if(o.top!=o.bottom&&Ko(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Ko(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Sg(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Cg(t,e,n){let{node:r,offset:s}=Iu(e,n),i=-1;if(O(r)&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function vg(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(O(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function Lu(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(O(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ko(e,c))return Lu(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function Mg(t,e){let n=t.dom.ownerDocument,r,s=0,i=pg(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o)){let c=t.dom.getBoundingClientRect();if(!Ko(e,c)||(o=Lu(t.dom,e,c),!o))return null}if(ue)for(let c=o;r&&c;c=kn(c))c.draggable&&(r=void 0);if(o=Sg(o,e),r){if(ve&&O(r)&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;cs&&s&&O(r)&&O(c=r.childNodes[s-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&O(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||!O(r)||r.childNodes[s-1].nodeName!="BR")&&(l=vg(t,r,s,e))}l==null&&(l=Cg(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ro(t){return t.top<t.bottom||t.left<t.right}function mt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Ro(r))return r}return Array.prototype.find.call(n,Ro)||t.getBoundingClientRect()}var Tg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Du(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=cs||ve;if(te(r))if(o&&(Tg.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=mt(et(r,s,s),n);if(ve&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=mt(et(r,s-1,s-1),-1);if(c.top==a.top){let u=mt(et(r,s,s+1),-1);if(u.top!=a.top)return er(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,er(mt(et(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==ce(r))){let a=r.childNodes[s-1];if(O(a))return xo(a.getBoundingClientRect(),!1)}if(i==null&&s<ce(r)){let a=r.childNodes[s];if(O(a))return xo(a.getBoundingClientRect(),!0)}return xo(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==ce(r))){let a=r.childNodes[s-1],c=te(a)?et(a,ce(a)-(o?0:1)):O(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return er(mt(c,1),!1)}if(i==null&&s<ce(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?te(a)?et(a,0,o?0:1):O(a)?a:null:null;if(c)return er(mt(c,-1),!0)}return er(mt(te(r)?et(r):r,-n),n>=0)}function er(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function xo(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Pu(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Ag(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Pu(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=Du(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(O(l))a=l.getClientRects();else if(te(l))a=et(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var Eg=/[\u0590-\u08ac]/;function Rg(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!Eg.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:Pu(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!jt(h,p)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var eu=null,tu=null,nu=!1;function Ng(t,e,n){return eu==e&&tu==n?nu:(eu=e,tu=n,nu=n=="up"||n=="down"?Ag(t,e,n):Rg(t,e,n))}var Oe=0,ru=1,Pt=2,ze=3,Wt=class{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Oe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&jt(this.contentDOM,e))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>se(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?s=n>Array.from(e.childNodes).findIndex(o=>o.contains(this.contentDOM)):s=!(i&4)}else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(O(o)?jt(o,e):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Zr||i instanceof Yr&&i.side>=0))break}if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?se(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?se(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=se(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=se(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!O(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((ve||ue)&&e==n){let{node:h,offset:p}=l;if(te(h)){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
13
|
+
`),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:se(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ve&&u.focusNode&&u.focusNode!=a.node&&O(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&ue)&&_t(l.node,l.offset,u.anchorNode,u.anchorOffset)&&_t(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&ve)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Pt:ru,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ze:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Pt:ze}r=o}this.dirty=Pt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Pt:ru;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Yr=class extends Wt{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=O(o)?o:document.createElement("span");l!=o&&(l.appendChild(o),o=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Oe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},No=class extends Wt{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},zt=class t extends Wt{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Xe.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ze&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Oe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Oe}}slice(e,n,r){let s=t.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Do(i,n,o,r)),e>0&&(i=Do(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},bt=class t extends Wt{constructor(e,n,r,s,i,o,l){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!te(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Xe.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Bu(u,r,n),c?a=new Oo(e,n,r,s,u,d||null,f,c):n.isText?new Qr(e,n,r,s,u,f):new t(e,n,r,s,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>O(s)&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>w.empty}}return n}matchesNode(e,n,r){return this.dirty==Oe&&e.eq(this.node)&&es(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Lo(this,o&&o.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Dg(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?F.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,s)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,h,m,e)||a.updateNextNode(d,f,h,e,p,s)||a.addNode(d,f,h,e,s),s+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Pt)&&(o&&this.protectLocalComposition(e,o),$u(this.contentDOM,this.children,e),bn&&Pg(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof M)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=$g(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new No(this,i,n,s);e.input.compositionNodes.push(o),this.children=Do(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Oe}updateOuterDeco(e){if(es(e,this.outerDeco))return;let n=!O(this.nodeDOM),r=this.dom;this.dom=zu(this.dom,this.nodeDOM,Io(this.outerDeco,this.node,n),Io(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function su(t,e,n,r,s){Bu(r,e,t);let i=new bt(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(s,0),i}var Qr=class t extends bt{constructor(e,n,r,s,i,o){super(e,n,r,s,i,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==ze||this.dirty!=Oe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Oe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Oe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new t(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ze)}get domAtom(){return!1}isText(e){return this.node.text==e}},Zr=class extends Wt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Oe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Oo=class extends bt{constructor(e,n,r,s,i,o,l,a){super(e,n,r,s,i,o,l),this.spec=a}update(e,n,r,s){if(this.dirty==ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function $u(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=iu(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof zt){let a=r?r.previousSibling:t.lastChild;$u(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=iu(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}var nr=function(t){t&&(this.nodeName=t)};nr.prototype=Object.create(null);var $t=[new nr];function Io(t,e,n){if(t.length==0)return $t;let r=n?$t[0]:new nr,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new nr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new nr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function zu(t,e,n,r){if(n==$t&&r==$t)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=$t[0]),s=a}Og(s,l||$t[0],o)}return s}function Og(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Bu(t,e,n){return zu(t,t,$t,Io(e,n,!O(t)))}function es(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function iu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Lo=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ig(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Oe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof zt&&u.dirty!=ze&&u.mark.type==e[o].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[o])&&(u.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=zt.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==ze&&o.dom==o.contentDOM&&(o.dirty=Pt),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof bt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ze&&es(n,a.outerDeco));if(!f&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Pt,d.updateChildren(s,o+1),d.dirty=Oe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!es(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=bt.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=bt.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Yr(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof zt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Qr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Zr(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||O(e)&&e.contains(this.lock.parentNode))}};function Ig(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof zt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function Lg(t,e){return t.type.side-e.type.side}function Dg(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(Lg);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function Pg(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function $g(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Do(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Uo(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(as(n)){for(a=o;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&N.isSelectable(s.node)&&s.parent&&!(s.node.isInline&&dg(n.focusNode,n.focusOffset,s.dom))){let d=s.posBefore;c=new N(o==d?l:r.resolve(d))}else if(ve&&e=="key"&&o>t.state.selection.to&&O(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&s&&s.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=R.findFrom(r.resolve(s.posAtStart),1);break}if(d==s.dom||d.nextSibling||!d.parentNode||!O(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,f=o;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=qo(t,u,l,d)}return c}function Hu(t){return t.editable?t.hasFocus():_u(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function rt(t,e=!1){let n=t.state.selection;if(Fu(t,n),!Hu(t))return;let r=t.input.mouseDown;if(!e&&ie&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&_t(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Bg(t);else{let{anchor:s,head:i}=n,o,l;ou&&!(n instanceof M)&&(n.$from.parent.inlineContent||(o=lu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=lu(t,n.to))),t.docView.setSelection(s,i,t,e),ou&&(o&&au(o),l&&au(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&zg(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var ou=ue||ie&&Eu<63;function lu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ue&&s&&s.contentEditable=="false")return So(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return So(s);if(i)return So(i)}}function So(t){return t.contentEditable="true",ue&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function au(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function zg(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Hu(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Bg(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,se(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&xe&&kt<=11&&(n.disabled=!0,n.disabled=!1)}function Fu(t,e){if(e instanceof N){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(cu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else cu(t)}function cu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function qo(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||M.between(e,n,r)}function uu(t){return t.editable&&!t.hasFocus()?!1:_u(t)}function _u(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return jt(t.dom,e.anchorNode)&&(t.editable||jt(t.dom,e.focusNode))}catch{return!1}}function Hg(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return _t(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Po(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&R.findFrom(i,e)}function gt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function du(t,e,n){let r=t.state.selection;if(r instanceof M)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return gt(t,new M(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Po(t.state,e);return s&&s instanceof N?gt(t,s):!1}else if(!Ne||n.indexOf("m")<0){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?N.isSelectable(i)?gt(t,new N(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):gt(t,new M(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof N&&r.node.isInline)return gt(t,new M(e>0?r.$to:r.$from));{let s=Po(t.state,e);return s?gt(t,s):!1}}}function rr(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):O(t)&&t.contentEditable=="false"}function gn(t,e){return e<0?Fg(t):_g(t)}function Fg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(ve&&O(n)&&r<ce(n)&&rr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!O(n))break;let l=n.childNodes[r-1];if(rr(l,-1))s=n,i=--r;else if(te(l))n=l,r=n.nodeValue.length;else break}else{if(ju(n))break;{let l=n.previousSibling;for(;l&&rr(l,-1);)s=n.parentNode,i=se(l),l=l.previousSibling;if(l)n=l,r=ce(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?$o(t,n,r):s&&$o(t,s,i)}function _g(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=ce(n),i,o;for(;;)if(r<s){if(!O(n))break;let l=n.childNodes[r];if(rr(l,1))i=n,o=++r;else break}else{if(ju(n))break;{let l=n.nextSibling;for(;l&&rr(l,1);)i=l.parentNode,o=se(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=ce(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&$o(t,i,o)}function ju(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function jg(t,e){for(;t&&e==t.childNodes.length&&!cr(t);)e=se(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(te(n))return n;if(O(n)&&n.contentEditable=="false")break;t=n,e=0}}function Wg(t,e){for(;t&&!e&&!cr(t);)e=se(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(te(n))return n;if(O(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function $o(t,e,n){if(!te(e)){let o,l;(l=jg(e,n))?(e=l,n=0):(o=Wg(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection(),s=t.domSelectionRange();if(!r)return;as(s)?r.collapse(e,n):r.extend&&(r.collapse(s.anchorNode,s.anchorOffset),r.extend(e,n)),t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&rt(t)},50)}function fu(t,e){let n=t.state.doc.resolve(e);if(!(ie||Ru)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),l=(o.top+o.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}let r=t.dom;for(let i=n.depth;i>0;i--)if(n.node(i).isBlock){r=t.nodeDOM(n.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function hu(t,e,n){let r=t.state.selection;if(r instanceof M&&!r.empty||n.indexOf("s")>-1||Ne&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Po(t.state,e);if(o&&o instanceof N)return gt(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof me?R.near(o,e):R.findFrom(o,e);return l?gt(t,l):!1}return!1}function pu(t,e){if(!(t.state.selection instanceof M))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function mu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Vg(t){if(!ue||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&O(e)&&n==0&&e.firstChild&&O(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;mu(t,r,"true"),setTimeout(()=>mu(t,r,"false"),20)}return!1}function Kg(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Ug(t,e){let n=e.keyCode,r=Kg(e);if(n==8||Ne&&n==72&&r=="c")return pu(t,-1)||gn(t,-1);if(n==46&&!e.shiftKey||Ne&&n==68&&r=="c")return pu(t,1)||gn(t,1);if(n==13||n==27)return!0;if(n==37||Ne&&n==66&&r=="c"){let s=n==37?fu(t,t.state.selection.from)=="ltr"?-1:1:-1;return du(t,s,r)||gn(t,s)}else if(n==39||Ne&&n==70&&r=="c"){let s=n==39?fu(t,t.state.selection.from)=="ltr"?1:-1:1;return du(t,s,r)||gn(t,s)}else{if(n==38||Ne&&n==80&&r=="c")return hu(t,-1,r)||gn(t,-1);if(n==40||Ne&&n==78&&r=="c")return Vg(t)||hu(t,1,r)||gn(t,1);if(r==(Ne?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Jo(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Xe.fromSchema(t.state.schema),l=Ju(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&O(c)&&(u=qu[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&O(c)&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
14
|
+
|
|
15
|
+
`);return{dom:a,text:f,slice:e}}function Wu(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return l=new v(w.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
16
|
+
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)l=d;else{let f=s.marks(),{schema:h}=t.state,p=Xe.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=Xg(n),cs&&Yg(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&!O(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||je.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!qg.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Qg(gu(l,+u[1],+u[2]),u[4]);else if(l=v.maxOpen(Jg(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=gu(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}var qg=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Jg(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Ku(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Uu(o[o.length-1],i.length));let u=Vu(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return w.from(o)}return t}function Vu(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,w.from(t));return t}function Ku(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Ku(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(w.from(Vu(n,t,s+1))))}}function Uu(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Uu(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(w.empty,!0);return t.copy(n.append(r))}function zo(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=zo(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(w.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function gu(t,e,n){return e<t.openStart&&(t=new v(zo(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new v(zo(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var qu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Ju(){return document.implementation.createHTMLDocument("title")}var tr=null;function Gg(t){let e=window.trustedTypes;if(!e)return t;if(!tr){if(tr=e.defaultPolicy)try{return tr.createHTML(t)}catch{}tr=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return tr.createHTML(t)}function Xg(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Ju(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&qu[s[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=Gg(t),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[o])||r;for(let o=0;o<n.styleSheets.length;o++){let l=n.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Yg(t){let e=t.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Qg(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{s=w.from(a.create(r[l+1],s))}catch{break}i++,o++}return new v(s,i,o)}var ge={},ye={},Zg={touchstart:!0,touchmove:!0},Bo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 e0(t){for(let e in ge){let n=ge[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{n0(t,r)&&!Go(t,r)&&(t.editable||!(r.type in ye))&&n(t,r)},Zg[e]?{passive:!0}:void 0)}ue&&t.dom.addEventListener("input",()=>null),Ho(t)}function nt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function t0(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ho(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Go(t,r))})}function Go(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function n0(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function r0(t,e){!Go(t,e)&&ge[e.type]&&(t.editable||!(e.type in ye))&&ge[e.type](t,e)}function yt(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=fg(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}ye.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Yu(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(tt&&ie&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),bn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(yt(t,"Enter"),t.input.lastIOSEnter=0)},200)}else yt(t,n)||Ug(t,n)?n.preventDefault():nt(t,"key")};ye.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ye.keypress=(t,e)=>{let n=e;if(Yu(t)||!n.charCode||n.ctrlKey&&!n.altKey||Ne&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function ur(t){return{left:t.clientX,top:t.clientY}}function s0(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Xo(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function dr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function i0(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&N.isSelectable(r)?(dr(t,new N(n)),!0):!1}function o0(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof N&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(N.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(dr(t,N.create(t.state.doc,s)),!0):!1}function l0(t,e,n,r,s){return Xo(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?o0(t,n):i0(t,n))}function a0(t,e,n,r){return Xo(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function c0(t,e,n,r){return Xo(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||u0(t,n,r)}function u0(t,e,n){if(n.button!=0)return!1;let r=Gu(t,e,!0),s=t.state.doc;return r?(dr(t,r),r instanceof M&&s.eq(t.state.doc)&&(t.input.mouseDown=new _o(t,r)),!0):!1}function Gu(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?M.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return M.create(r,l+1,l+1+o.content.size);if(n&&N.isSelectable(o))return N.create(r,l)}return null}function Yo(t){return ns(t)}var Xu=Ne?"metaKey":"ctrlKey";ge.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Yo(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&s0(n,t.input.lastClick)&&!n[Xu]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(ur(n));o&&(i=="singleClick"?t.input.mouseDown=new Fo(t,o,n,!!r):(i=="doubleClick"?a0:c0)(t,o.pos,o.inside,n)?n.preventDefault():nt(t,"pointer"))};var ts=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Fo=class extends ts{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Xu],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}let l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&O(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ve&&!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()),nt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||rt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ur(e))),this.updateAllowDefault(e),this.allowDefault||!n?nt(this.view,"pointer"):l0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(dr(this.view,R.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):nt(this.view,"pointer")}move(e){this.updateAllowDefault(e),nt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},_o=class extends ts{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),nt(this.view,"pointer");let n=this.view.posAtCoords(ur(e)),r=n&&Gu(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];dr(this.view,M.create(s,o,l))}};ge.touchstart=t=>{t.input.lastTouch=Date.now(),Yo(t),nt(t,"pointer")};ge.touchmove=t=>{t.input.lastTouch=Date.now(),nt(t,"pointer")};ge.contextmenu=t=>Yo(t);function Yu(t,e){return t.composing?!0:ue&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var d0=tt?5e3:-1;ye.compositionstart=ye.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ie&&Ru&&f0(t)))t.markCursor=t.state.storedMarks||n.marks(),ns(t,!0),t.markCursor=null;else if(ns(t,!e.selection.empty),ve&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&O(s)&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(te(o)){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Qu(t,d0)};function f0(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!O(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return O(r)&&r.contentEditable=="false"}ye.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Qu(t,20))};function Qu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ns(t),e))}function Zu(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function h0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=cg(e.focusNode,e.focusOffset),r=ug(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function ns(t,e=!1){if(!(tt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Zu(t),e||t.docView&&t.docView.dirty){let n=Uo(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function p0(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var sr=xe&&kt<15||bn&&mg<604;ge.copy=ye.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=sr?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Jo(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):p0(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function m0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function g0(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ir(t,r.value,null,s,e):ir(t,r.textContent,r.innerHTML,s,e)},50)}function ir(t,e,n,r,s){let i=Wu(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||v.empty)))return!0;if(!i)return!1;let o=m0(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ed(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ye.paste=(t,e)=>{let n=e;if(t.composing&&!tt)return;let r=sr?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ir(t,ed(r),r.getData("text/html"),s,n)?n.preventDefault():g0(t,n)};var rs=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},y0=Ne?"altKey":"ctrlKey";function td(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[y0]}ge.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(ur(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof N?s.to-1:s.to))){if(r&&r.mightDrag)o=N.create(t.state.doc,r.mightDrag.pos);else if(n.target&&O(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=N.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=Jo(t,l);(!n.dataTransfer.files.length||!ie||Eu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(sr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",sr||n.dataTransfer.setData("text/plain",c),t.dragging=new rs(u,td(t,n),o)};ge.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ye.dragover=ye.dragenter=(t,e)=>e.preventDefault();ye.drop=(t,e)=>{try{k0(t,e,t.dragging)}finally{t.dragging=null}};function k0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(ur(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Wu(t,ed(e.dataTransfer),sr?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&td(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||v.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?qr(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&N.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new N(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(qo(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}ge.focus=t=>{if(t.input.lastFocus=Date.now(),!t.focused){t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0;let e=t.domSelectionRange();if(!t.domObserver.currentSelection.eq(e)){let{focusNode:n,focusOffset:r}=e;setTimeout(()=>{let s=t.domSelectionRange();s.focusNode==n&&s.focusOffset==r&&t.docView&&t.hasFocus()&&rt(t)},20)}}};ge.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ge.beforeinput=(t,e)=>{if(tt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||t.domObserver.pendingRecords().length||(t.dom.blur(),t.focus(),yt(t,"Backspace")))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in ye)ge[t]=ye[t];function or(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var lr=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let n=this.frag.child(this.index);if(this.off==e)return n;this.off+=n.nodeSize,this.index++}return null}},ss=class t{constructor(e,n){this.toDOM=e,this.spec=n||Ht,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new ne(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&or(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Bt=class t{constructor(e,n){this.attrs=e,this.spec=n||Ht}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new ne(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&or(this.attrs,e.attrs)&&or(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},jo=class t{constructor(e,n){this.attrs=e,this.spec=n||Ht}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new ne(i.pos-r,o.pos-r,this)}valid(e,n,r){let s=r.nodeAt(n.from);return!!s&&!s.isText&&n.from+s.nodeSize==n.to}eq(e){return this==e||e instanceof t&&or(this.attrs,e.attrs)&&or(this.spec,e.spec)}destroy(){}},ne=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new ss(n,r))}static inline(e,n,r,s){return new t(e,n,new Bt(r,s))}static node(e,n,r,s){return new t(e,n,new jo(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Bt}get widget(){return this.type instanceof ss}},yn=[],Ht={},V=class t{constructor(e,n){this.local=e.length?e:yn,this.children=n.length?n:yn}static create(e,n){return n.length?ls(n,e,0,Ht):ae}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ht)}mapInner(e,n,r,s,i){let o;if(this.local.length){let l=new lr(n.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,s);c&&c.type.valid(n,c,l)?(o||(o=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?b0(this.children,o||[],e,n,r,s,i):o?new t(o.sort(Ft),yn):ae}add(e,n){return n.length?this==ae?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=rd(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,ls(u,l,c+1,Ht)),i+=3}});let o=nd(i?sd(n):n,-r);if(o.length){let l=new lr(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||o.splice(a--,1)}return new t(o.length?this.local.concat(o).sort(Ft):this.local,s||this.children)}remove(e){return e.length==0||this==ae?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ae?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new t(s,r):ae}forChild(e,n){if(this==ae)return this;if(n.isLeaf)return t.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof Bt){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new t(s.sort(Ft),yn);return r?new is([l,r]):l}return r||ae}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Qo(this.localsInner(e))}localsInner(e){if(this==ae)return yn;if(e.inlineContent||!this.local.some(Bt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Bt||n.push(this.local[r]);return n}forEachSet(e){e(this)}};V.empty=new V([],[]);V.removeOverlap=Qo;var ae=V.empty,is=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(s=>s.map(e,n,Ht));return t.from(r)}forChild(e,n){if(n.isLeaf)return V.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ae&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Qo(r?n:n.sort(Ft)):yn}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new t(e.every(n=>n instanceof V)?e:e.reduce((n,r)=>n.concat(r instanceof V?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function b0(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let k=l[y+1];if(k<0||f>k+u-d)continue;let b=l[y]+u-d;h>=b?l[y+1]=f<=b?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,u+1,t[c]+i+1,o);y!=ae?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=w0(l,t,e,n,s,i,o),u=ls(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new V(e.sort(Ft),l)}function nd(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new ne(s.from+e,s.to+e,s.type))}return n}function w0(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function rd(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function sd(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ls(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=rd(t,l,a+n);if(c){i=!0;let u=ls(c,l,n+a+1,r);u!=ae&&s.push(a,a+l.nodeSize,u)}});let o=nd(i?sd(t):t,-n).sort(Ft);if(o.length){let l=new lr(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1))}return o.length||s.length?new V(o,s):ae}function Ft(t,e){return t.from-e.from||t.to-e.to}function Qo(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),yu(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),yu(e,s,r.copy(i.from,r.to)));break}}}return e}function yu(t,e,n){for(;e<t.length&&Ft(n,t[e])>0;)e++;t.splice(e,0,n)}function Co(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ae&&e.push(r)}),t.cursorWrapper&&e.push(V.create(t.state.doc,[t.cursorWrapper.deco])),is.from(e)}var x0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},S0=xe&&kt<=11,Wo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Vo=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Wo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);xe&&kt<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ue&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),S0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,x0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(uu(this.view)){if(this.suppressingSelectionUpdates)return rt(this.view);if(xe&&kt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&_t(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=kn(i))n.add(i);for(let i=e.anchorNode;i;i=kn(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:te(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r,s=!1;!this.suppressingSelectionUpdates&&uu(e)&&(r=e.domSelectionRange(),s=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ie&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&O(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(ve&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||M0(e,d)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&as(r)&&(c=Uo(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,rt(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),C0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,T0(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&rt(e),r&&this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),te(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(xe&&kt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?se(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?se(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ku=new WeakMap,bu=!1;function C0(t){if(!ku.has(t)&&(ku.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ve,bu)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."),bu=!0}}function wu(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return _t(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function v0(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return wu(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?wu(t,n):null}function M0(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function T0(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!O(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function A0(t,e,n,r){let{node:s,fromOffset:i,toOffset:o,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&jt(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],as(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ie&&t.input.lastKeyCode===8)for(let y=o;y>i;y--){let k=s.childNodes[y-1],b=k.pmViewDesc;if(k.nodeName=="BR"&&!b){o=y;break}if(!b||b.size)break}let f=t.state.doc,h=t.someProp("domParser")||je.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=h.parse(s,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:E0(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:a}}var E0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ue&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ue&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},R0=/^(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 N0(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,L=Uo(t,T);if(L&&!t.state.selection.eq(L)){if(ie&&tt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&yt(t,"Enter"))return;let I=t.state.tr.setSelection(L);T=="pointer"?I.setMeta("pointer",!0):T=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=A0(t,e,n,s),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=D0(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(bn&&t.input.lastIOSEnter>Date.now()-225||tt)&&s.some(T=>O(T)&&!R0.test(T.nodeName))&&(!p||p.endA>=p.endB)&&yt(t,"Enter")){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof M&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=xu(t,t.state.doc,c.sel);if(T&&!T.eq(t.state.selection)){let L=t.state.tr.setSelection(T);i&&L.setMeta("composition",i),t.dispatch(L)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof M&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),xe&&kt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((bn&&t.input.lastIOSEnter>Date.now()-225&&(!k||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!k&&L0(c.doc,m.pos,g.pos))&&yt(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&(k?p.endA>p.start&&p.endB==p.start:I0(u,p.start,p.endA,m,g))&&yt(t,"Backspace")){tt&&ie&&t.domObserver.suppressSelectionUpdates();return}ie&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),tt&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>yt(t,"Enter"),20));let b=p.start,x=p.endA,E=T=>{let L=T||t.state.tr.replace(b,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let I=xu(t,L.doc,c.sel);I&&!(ie&&t.composing&&I.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(I.head==b||I.head==L.mapping.map(x)-1)||xe&&I.empty&&I.head==b)&&L.setSelection(I)}return i&&L.setMeta("composition",i),L.scrollIntoView()},C;if(k)if(m.pos==g.pos){xe&&kt<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>rt(t),20));let T=E(t.state.tr.delete(b,x)),L=u.resolve(p.start).marksAcross(u.resolve(p.endA));L&&T.ensureMarks(L),t.dispatch(T)}else if(p.endA==p.endB&&(C=O0(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=E(t.state.tr);C.type=="add"?T.addMark(b,x,C.mark):T.removeMark(b,x,C.mark),t.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset),L=()=>E(t.state.tr.insertText(T,b,x));t.someProp("handleTextInput",I=>I(t,b,x,T,L))||t.dispatch(L())}else t.dispatch(E());else t.dispatch(E())}function xu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:qo(t,e.resolve(n.anchor),e.resolve(n.head))}function O0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(w.from(c).eq(t))return{mark:l,type:o}}function I0(t,e,n,r,s){if(n-e<=s.pos-r.pos||vo(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(vo(i,!0,!0));return!o.parent.isTextblock||o.pos>n||vo(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function L0(t,e,n){let r=0,s=0;return t.nodesBetween(e,n,(i,o)=>{i.isTextblock&&o>=e&&o<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-o),Math.min(i.nodeSize,n-o))):i.isLeaf)&&s++}),s==0&&r==1}function vo(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function D0(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,o,l);if(s=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&o<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var ar=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Bo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Tu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=vu(this),Cu(this),this.nodeViews=Mu(this),this.docView=su(this.state.doc,Su(this),Co(this),this.dom,this),this.domObserver=new Vo(this,(r,s,i,o)=>N0(this,r,s,i,o)),this.domObserver.start(),e0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ho(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tu),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Zu(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Mu(this);$0(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ho(this),this.editable=vu(this),Cu(this);let a=Co(this),c=Su(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&kg(this);if(o){this.domObserver.stop();let h=d&&(xe||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&P0(s.selection,e.selection);if(d){let m=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=h0(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=su(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hg(this)&&p.delaySelUpdate())?rt(this,h):(Fu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&bg(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!jt(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof N){let n=this.docView.domAfterPos(this.state.selection.from);O(n)&&Zc(this,n.getBoundingClientRect(),e)}else Zc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new rs(e.slice,e.move,s<0?void 0:N.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(xe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&wg(this.dom),rt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Mg(this,e)}coordsAtPos(e,n=1){return Du(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Ng(this,n||this.state,e)}pasteHTML(e,n){return ir(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ir(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Jo(this,e)}destroy(){this.docView&&(t0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Co(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,lg())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return r0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ue&&this.root.nodeType===11&&hg(this.dom.ownerDocument)==this.dom&&v0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ar.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Su(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[ne.node(0,t.state.doc.content.size,e)]}function Cu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:ne.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function vu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function P0(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Mu(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function $0(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Tu(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var st={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ds={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},z0=typeof navigator<"u"&&/Mac/.test(navigator.platform),B0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ee=0;ee<10;ee++)st[48+ee]=st[96+ee]=String(ee);var ee;for(ee=1;ee<=24;ee++)st[ee+111]="F"+ee;var ee;for(ee=65;ee<=90;ee++)st[ee]=String.fromCharCode(ee+32),ds[ee]=String.fromCharCode(ee);var ee;for(us in st)ds.hasOwnProperty(us)||(ds[us]=st[us]);var us;function id(t){var e=z0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||B0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ds:st)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var H0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),F0=typeof navigator<"u"&&/Win/.test(navigator.platform);function _0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))H0?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function j0(t){let e=Object.create(null);for(let n in t)e[_0(n)]=t[n];return e}function Zo(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function od(t){return new P({props:{handleKeyDown:fr(t)}})}function fr(t){let e=j0(t);return function(n,r){let s=id(r),i,o=e[Zo(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Zo(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(F0&&r.ctrlKey&&r.altKey)&&(i=st[r.keyCode])&&i!=s){let l=e[Zo(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var fs=200,oe=function(){};oe.prototype.append=function(e){return e.length?(e=oe.from(e),!this.length&&e||e.length<fs&&this.leafAppend(e)||this.length<fs&&e.leafPrepend(this)||this.appendInner(e)):this};oe.prototype.prepend=function(e){return e.length?oe.from(e).append(this):this};oe.prototype.appendInner=function(e){return new W0(this,e)};oe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?oe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};oe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};oe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};oe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};oe.from=function(e){return e instanceof oe?e:e&&e.length?new ld(e):oe.empty};var ld=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=fs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=fs)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(oe);oe.empty=new ld([]);var W0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(oe),el=oe;var V0=500,Vt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new Ve(d.map));let h=d.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ve(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Ve(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(o++,n=void 0),s||(a=f)}let c=o-r.depth;return c>U0&&(l=K0(l,c),o-=c),new t(l.append(i),o)}remapping(e,n){let r=new Jn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new Ve(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],s=this.items.length-n,i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Ve(p,m,g))}else r.push(new Ve(p))},s);let c=[];for(let f=n;f<o;f++)c.push(new Ve(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new t(u,l);return d.emptyItemCount()>V0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new Ve(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new t(el.from(s.reverse()),i)}};Vt.empty=new Vt(el.empty,0);function K0(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}var Ve=class t{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Ke=class{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}},U0=20;function q0(t,e,n,r){let s=n.getMeta(xt),i;if(s)return s.historyState;n.getMeta(dd)&&(t=new Ke(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(xt))return o.getMeta(xt).redo?new Ke(t.done.addTransform(n,void 0,r,hs(e)),t.undone,ad(n.mapping.maps),t.prevTime,t.prevComposition):new Ke(t.done,t.undone.addTransform(n,void 0,r,hs(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!J0(n,t.prevRanges)),c=o?tl(t.prevRanges,n.mapping):ad(n.mapping.maps);return new Ke(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,hs(e)),Vt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ke(t.done.rebased(n,i),t.undone.rebased(n,i),tl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ke(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),tl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function J0(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function ad(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function tl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function G0(t,e,n){let r=hs(e),s=xt.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Ke(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(xt,{redo:n,historyState:a})}var nl=!1,cd=null;function hs(t){let e=t.plugins;if(cd!=e){nl=!1,cd=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){nl=!0;break}}return nl}function ud(t){return t.setMeta(dd,!0)}var xt=new _("history"),dd=new _("closeHistory");function fd(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new P({key:xt,state:{init(){return new Ke(Vt.empty,Vt.empty,null,0,-1)},apply(e,n,r){return q0(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?rl:r=="historyRedo"?sl:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function ps(t,e){return(n,r)=>{let s=xt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=G0(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var rl=ps(!1,!0),sl=ps(!0,!0),lv=ps(!1,!1),av=ps(!0,!1);function hd(t){return t.getMeta(xt)!=null}function Ss(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var vn=class $d{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:s}=n,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}static createFallbackCan(){let e=$d.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:Ss({state:i,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},X0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Y0=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Q0=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{ranges:r}=n;if(!e)return!0;let s=t.mapping.maps.length;return r.forEach(({$from:i,$to:o})=>{let l=i.pos,a=o.pos,c=t.mapping.slice(s),u=1;t.doc.nodesBetween(c.map(l),c.map(a),(d,f)=>{u=Math.max(u,t.doc.resolve(f).depth+1)});for(let d=0;d<u;d+=1){let f=t.doc,h=t.mapping.maps.length,p=t.mapping.slice(s),m=h,g=t.mapping.slice(h),y=p.map(l),k=p.map(a);if(f.nodesBetween(y,k,(b,x)=>{if(b.type.isText)return;t.mapping.maps.length!==m&&(m=t.mapping.maps.length,g=t.mapping.slice(h));let E=t.doc.resolve(g.map(x)),C=t.doc.resolve(g.map(x+b.nodeSize)),T=E.blockRange(C);if(!T)return;let L=Qe(T);if(b.type.isTextblock){let{defaultType:I}=E.parent.contentMatchAt(E.index()),z=t.doc.nodeAt(T.start);I&&z&&!z.hasMarkup(I)&&I.validContent(z.content)&&t.setNodeMarkup(T.start,I)}(L||L===0)&&t.lift(T,L)}),t.doc.eq(f))break}}),!0},Z0=t=>e=>t(e),ey=()=>({state:t,dispatch:e})=>mo(t,e),ty=(t,e)=>({editor:n,tr:r})=>{let{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new M(r.doc.resolve(Math.max(o-1,0)))),!0},ny=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){let o=s.before(i),l=s.after(i);t.delete(o,l).scrollIntoView()}return!0}return!1};function J(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ry=t=>({tr:e,state:n,dispatch:r})=>{let s=J(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){let l=i.before(o),a=i.after(o);e.delete(l,a).scrollIntoView()}return!0}return!1},sy=t=>({tr:e,dispatch:n})=>{let{from:r,to:s}=t;return n&&e.delete(r,s),!0},iy=t=>t.content?/^text(\*|\+)/.test(t.content):!1,pd=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return iy(r)?n==="left"?t.start()-1:t.end()+1:t.pos},oy=(t,e,n)=>({from:pd(t,n,"left"),to:pd(e,n,"right")}),ly=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,s=t.selection instanceof M?t.selection.$from.marksAcross(t.selection.$to):null,i=n.steps.length;r.forEach(o=>{let l=n.mapping.slice(i),a=n.doc.resolve(l.map(o.$from.pos)),c=n.doc.resolve(l.map(o.$to.pos)),{from:u,to:d}=oy(a,c,t.schema);n.deleteRange(u,d)}),n.selection.empty||n.setSelection(M.near(n.doc.resolve(n.selection.from))),s&&n.ensureMarks(s),n.scrollIntoView(),e(n)}return!0},ay=()=>({commands:t})=>t.keyboardShortcut("Enter"),cy=()=>({state:t,dispatch:e})=>po(t,e);function cl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ws(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:cl(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function zd(t,e,n={}){return t.find(r=>r.type===e&&ws(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function md(t,e,n={}){return!!zd(t,e,n)}function ul(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!zd([...r.node.marks],e,n))return;let s=r.index,i=t.start()+r.offset,o=s+1,l=i+r.node.nodeSize;for(;s>0&&md([...t.parent.child(s-1).marks],e,n);)s-=1,i-=t.parent.child(s).nodeSize;for(;o<t.parent.childCount&&md([...t.parent.child(o).marks],e,n);)l+=t.parent.child(o).nodeSize,o+=1;return{from:i,to:l}}function it(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var uy=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=it(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){let d=ul(a,i,e);if(d&&d.from<=c&&d.to>=u){let f=M.create(o,d.from,d.to);n.setSelection(f)}}return!0},dy=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Bd(t){return t instanceof M}function Kt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function il(t,e=null){if(!e)return null;let n=R.atStart(t),r=R.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let s=n.from,i=r.to;return e==="all"?M.create(t,Kt(0,s,i),Kt(t.content.size,s,i)):M.create(t,Kt(e,s,i),Kt(e,s,i))}function gd(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function xs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function fy(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var hy=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};let o=()=>{(xs()||gd())&&r.dom.focus(),fy()&&!xs()&&!gd()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Bd(n.state.selection))return o(),!0;let l=il(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},py=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),my=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Hd=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Hd(r)}return t};function pr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Hd(n)}function Fd(t){return typeof t?.nodesBetween=="function"}function Mn(t,e,n){if(Fd(t))return t;let r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};let s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return w.fromArray(t.map(o=>e.nodeFromJSON(o)));let i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Mn("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="",a=new It({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?je.fromSchema(a).parseSlice(pr(t),n.parseOptions):je.fromSchema(a).parse(pr(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=je.fromSchema(e);return n.slice?i.parseSlice(pr(t),n.parseOptions).content:i.parse(pr(t),n.parseOptions)}return Mn("",e,n)}function _d(t){return!("type"in t)}function jd(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Q||s instanceof Z))return;let i=t.mapping.maps[r],o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(R.near(t.doc.resolve(o),n))}var gy=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Mn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var o;l=Mn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=_d(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||"").join(""):Fd(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=w.from(p);let g=r.doc.resolve(u),y=g.node(),k=g.parentOffset===0,b=y.isText||y.isTextblock,x=y.content.size>0;k&&b&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}n.updateSelection&&jd(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0};function Wd(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var yy=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:s,attrs:i,content:o,updateSelection:l=!0}=t,a;typeof s=="number"?a=e.doc.resolve(s):s?a=s:a=e.selection.$from;let c=Wd(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([h])=>u.includes(h))):{},f;if(o){let h=Mn(o,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(a.pos,f),l&&jd(e,e.steps.length-1,-1)),!0):!1},ky=()=>({state:t,dispatch:e})=>_c(t,e),by=()=>({state:t,dispatch:e})=>jc(t,e),wy=()=>({state:t,dispatch:e})=>io(t,e),xy=()=>({state:t,dispatch:e})=>ao(t,e),Vd=(t,e)=>{let n=t.resolve(e),r=n.nodeBefore,s=n.nodeAfter;return!r||!s?!1:!r.type.spec.isolating&&!s.type.spec.isolating},Sy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=cn(t.doc,t.selection.$from.pos,-1);return r==null||!Vd(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Cy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=cn(t.doc,t.selection.$from.pos,1);return r==null||!Vd(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},vy=()=>({state:t,dispatch:e})=>hn(t,e),My=()=>({state:t,dispatch:e})=>pn(t,e);function Kd(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ty(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))xs()||Kd()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Ay=t=>({editor:e,view:n,tr:r,dispatch:s})=>{let i=Ty(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function ke(t,e,n={}){let{from:r,to:s,empty:i}=t.selection,o=e?J(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(s,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ws(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Ey=(t,e={})=>({state:n,dispatch:r})=>ke(n,J(t,n.schema),e)?Wc(n,r):!1,Ry=()=>({state:t,dispatch:e})=>go(t,e),Ny=t=>({state:e,dispatch:n})=>{let r=J(t,e.schema);return Gc(r)(e,n)},Oy=()=>({state:t,dispatch:e})=>fo(t,e);function Cs(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function yd(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var Iy=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,l=Cs(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=J(t,r.schema)),l==="mark"&&(o=it(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,yd(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create(yd(f.attrs,e))))})})}),a},Ly=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Dy=()=>({tr:t,dispatch:e})=>{if(e){let n=new me(t.doc);t.setSelection(n)}return!0},Py=()=>({state:t,dispatch:e})=>oo(t,e),$y=()=>({state:t,dispatch:e})=>co(t,e),zy=()=>({state:t,dispatch:e})=>Vc(t,e),By=()=>({state:t,dispatch:e})=>ko(t,e),Hy=()=>({state:t,dispatch:e})=>yo(t,e);function ol(t,e,n={},r={}){return Mn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Fy=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=ol(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});if(o){let u=_d(c)?c.content:[c];i.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Ud(t,e){let n=it(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function dl(t,e){let n=new ht(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function qd(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function An(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function vs(t){return e=>An(e.$from,t)}function A(t,e,n){return t.config[e]===void 0&&t.parent?A(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?A(t.parent,e,n):null}):t.config[e]}function gr(t){return t.map(e=>{let n=A(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...gr(n())]:e}).flat(10)}function fl(t,e){let n=Xe.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Jd(t,e){let n=new Map;for(let s of t){var r;let i=(r=n.get(s.type))!==null&&r!==void 0?r:new Map;i.set(s.name,s),n.set(s.type,i)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(s=>{var i;return Object.entries((i=s.spec.attrs)!==null&&i!==void 0?i:{}).map(([o,l])=>{var a;let c=(a=n.get(s.name))===null||a===void 0?void 0:a.get(o),u=Object.hasOwn(l,"default");return{type:s.name,name:o,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var _y={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},jy={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function Wy(t,e,n){return Object.fromEntries(Object.entries(e).flatMap(([r,s])=>{let i=t[r];if(i===void 0)return[];if(!(typeof s=="string"?typeof i===s:typeof i=="string"&&s.includes(i)))throw new RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,i]]}))}function kd(t,e,n,r){return{...Object.fromEntries(Object.entries(e).filter(([s])=>s!=="attrs"&&!Object.hasOwn(r,s))),...Wy(n,r,t),attrs:n.attrs}}function bd(t,e,n){for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw new RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function Vy(t,e){bd(t.nodes,e.nodes,"node"),bd(t.marks,e.marks,"mark");let n=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((s,i)=>{n=n.update(s,kd(s,t.nodes[s],i,_y))}),e.spec.marks.forEach((s,i)=>{r=r.update(s,kd(s,t.marks[s],i,jy))}),{topNode:e.topNodeType.name,nodes:n,marks:r}}function Gd(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Tn(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function hl(t){let e=[],{nodeExtensions:n,markExtensions:r}=Tn(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{let u=A(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:s});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=o:d.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),s.forEach(c=>{let u=A(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...i,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function ll(t){return typeof t=="function"}function B(t,e=void 0,...n){return ll(t)?e?t.bind(e)(...n):t(...n):t}function Ky(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Uy(t){let e=[],n="",r=!1,s=!1,i=0,o=t.length;for(let l=0;l<o;l+=1){let a=t[l];if(a==="'"&&!s){r=!r,n+=a;continue}if(a==='"'&&!r){s=!s,n+=a;continue}if(!r&&!s){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function wd(t){let e=[],n=Uy(t||""),r=n.length;for(let s=0;s<r;s+=1){let i=n[s],o=i.indexOf(":");if(o===-1)continue;let l=i.slice(0,o).trim(),a=i.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function D(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([s,i])=>{if(s==="__proto__"){Object.defineProperty(r,s,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[s]){r[s]=i;return}if(s==="class"){let o=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],a=o.filter(c=>!l.includes(c));r[s]=[...l,...a].join(" ")}else if(s==="style"){let o=new Map([...wd(r[s]),...wd(i)]);r[s]=Array.from(o.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[s]=i}),r},{})}function St(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>D(n,r),{})}function qy(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function xd(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let s=e.reduce((i,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(n):qy(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Sd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Ky(n)?!1:n!=null))}function Cd(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function vd(t,e,n=hl(t)){var r;let{nodeExtensions:s,markExtensions:i}=Tn(t);return{topNode:(r=s.find(o=>A(o,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(s.map(o=>{let l=n.filter(h=>h.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=Sd({...t.reduce((h,p)=>{let m=A(p,"extendNodeSchema",a);return{...h,...m?m(o):{}}},{}),content:B(A(o,"content",a)),marks:B(A(o,"marks",a)),group:B(A(o,"group",a)),inline:B(A(o,"inline",a)),atom:B(A(o,"atom",a)),selectable:B(A(o,"selectable",a)),draggable:B(A(o,"draggable",a)),code:B(A(o,"code",a)),whitespace:B(A(o,"whitespace",a)),linebreakReplacement:B(A(o,"linebreakReplacement",a)),defining:B(A(o,"defining",a)),isolating:B(A(o,"isolating",a)),attrs:Object.fromEntries(l.map(Cd))}),u=B(A(o,"parseHTML",a));u&&(c.parseDOM=u.map(h=>xd(h,l)));let d=A(o,"renderHTML",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:St(h,l)}));let f=A(o,"renderText",a);return f&&(c.toText=f),[o.name,c]})),marks:Object.fromEntries(i.map(o=>{let l=n.filter(f=>f.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=Sd({...t.reduce((f,h)=>{let p=A(h,"extendMarkSchema",a);return{...f,...p?p(o):{}}},{}),inclusive:B(A(o,"inclusive",a)),excludes:B(A(o,"excludes",a)),group:B(A(o,"group",a)),spanning:B(A(o,"spanning",a)),code:B(A(o,"code",a)),attrs:Object.fromEntries(l.map(Cd))}),u=B(A(o,"parseHTML",a));u&&(c.parseDOM=u.map(f=>xd(f,l)));let d=A(o,"renderHTML",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:St(f,l)})),[o.name,c]}))}}function Xd(t,e,n){if(n===void 0)return new It(vd(t,e));let r=Gd(t.filter(o=>o.type!=="extension").map(o=>o.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(", ")}`);let s=new It(n),i=vd(t,e,Jd(hl(t),s));return new It(Vy(i,s))}function Ut(t){return t.sort((n,r)=>{let s=A(n,"priority")||100,i=A(r,"priority")||100;return s>i?-1:s<i?1:0})}function pl(t){let e=Ut(gr(t)),n=Gd(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Ms(t,e){return Xd(pl(t),e)}function Yd(t,e){let n=Ms(e),r=pr(t);return je.fromSchema(n).parse(r).toJSON()}function Qd(t,e,n){let{from:r,to:s}=e,{blockSeparator:i=`
|
|
17
|
+
|
|
18
|
+
`,textSerializers:o={}}=n||{},l="";return t.nodesBetween(r,s,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=i);let f=o?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c)}}),l}function Jy(t,e){return Qd(t,{from:0,to:t.content.size},e)}function Zd(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Gy(t,e){let n=J(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});let o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function ml(t,e){let n=Cs(typeof e=="string"?e:e.name,t.schema);return n==="node"?Gy(t,e):n==="mark"?Ud(t,e):{}}function Xy(t,e=JSON.stringify){let n={};return t.filter(r=>{let s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Yy(t){let e=Xy(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function En(t){let{mapping:e,steps:n}=t,r=[],s=e.invert();return e.maps.forEach((i,o)=>{let l=[];if(i.ranges.length)i.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=n[o];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(o);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=s.map(d,-1),p=s.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Yy(r)}function yr(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(s=>{let i=ul(n.resolve(t),s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var Ts=(t,e,n,r=20)=>{let s=t.doc.resolve(n),i=r,o=null;for(;i>0&&o===null;){let l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]},As=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function wn(t,e){return e.nodes[t]||e.marks[t]||null}function bs(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var Qy=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;let u=((a=(c=s.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function al(t,e,n={}){let{empty:r,ranges:s}=t.selection,i=e?it(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>ws(u.attrs,n,{strict:!1}));let o=0,l=[];if(s.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(p,m)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),k=y-g;o+=k,l.push(...p.marks.map(b=>({mark:b,from:g,to:y})))})}),o===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>ws(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function Zy(t,e,n={}){if(!e)return ke(t,null,n)||al(t,null,n);let r=Cs(e,t.schema);return r==="node"?ke(t,e,n):r==="mark"?al(t,e,n):!1}var Es=(t,e)=>{let{$from:n,$to:r,$anchor:s}=t.selection;if(e){let i=vs(l=>l.type.name===e)(t.selection);if(!i)return!1;let o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Rs=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Md(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function hr(t,e){let{nodeExtensions:n}=Tn(e),r=n.find(i=>i.name===t);if(!r)return!1;let s=B(A(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof s!="string"?!1:s.split(" ").includes("list")}function Rn(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Rn(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Ns(t){return t instanceof N}function ek(t){if(t===null||typeof t!="object")return!1;let e=t;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function tk(t){if(t===null||typeof t!="object")return!1;let e=t;if(!ek(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="replace")}var ef=class tf{constructor(e){this.position=e}static fromJSON(e){return new tf(e.position)}toJSON(){return{position:this.position}}};function nk(t,e){let n=e.mapping.mapResult(t.position);return{position:new ef(n.pos),mapResult:n}}function rk(t){return new ef(t)}function sk(t,e,n){let{selection:r}=e,s=null;if(Bd(r)&&(s=r.$cursor),s){var i;let l=(i=t.storedMarks)!==null&&i!==void 0?i:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var ik=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let{selection:i}=n,{empty:o,ranges:l}=i,a=it(t,r.schema);if(s)if(o){let c=Ud(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&n.addMark(p,m,a.create({...g.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return sk(r,n,a)},ok=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),lk=(t,e={})=>({state:n,dispatch:r,chain:s})=>{let i=J(t,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>bo(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>bo(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ak=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,s=Kt(t,0,r.content.size),i=N.create(r,s);e.setSelection(i)}return!0},ck=(t,e)=>({tr:n,state:r,dispatch:s})=>{let{selection:i}=r,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},uk=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=M.atStart(r).from,l=M.atEnd(r).to,a=Kt(s,o,l),c=Kt(i,o,l),u=M.create(r,a,c);e.setSelection(u)}return!0},dk=t=>({state:e,dispatch:n})=>{let r=J(t,e.schema);return Xc(r)(e,n)};function Td(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var fk=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{let{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=bs(c,l.node().type.name,l.node().attrs);if(i instanceof N&&i.node.isBlock)return!l.parentOffset||!Re(o,l.pos)?!1:(r&&(t&&Td(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Wd(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=i instanceof M&&!i.empty?Dt.create({doc:e.doc,selection:i}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=Re(m,g,1,h);if(!h&&!y&&Re(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let k=e.steps.length;if(i instanceof M&&e.deleteSelection(),e.split(e.mapping.slice(k).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let b=e.mapping.slice(k).map(l.before()),x=e.doc.resolve(b);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(k).map(l.before()),f)}}t&&Td(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return y},hk=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{let o=J(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==o)return!1;let d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){var f;let x=w.empty,E=l.index(-1)?1:l.index(-2)?2:3;for(let Ee=l.depth-E;Ee>=l.depth-3;Ee-=1)x=w.from(l.node(Ee).copy(x));let C=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...bs(d,l.node().type.name,l.node().attrs),...e},L=((f=o.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(T))||void 0;x=x.append(w.from(o.createAndFill(null,L)||void 0));let I=l.before(l.depth-(E-1));n.replace(I,l.after(-C),new v(x,4-E,0));let z=-1;n.doc.nodesBetween(I,n.doc.content.size,(Ee,Tt)=>{if(z>-1)return!1;Ee.isTextblock&&Ee.content.size===0&&(z=Tt+1)}),z>-1&&n.setSelection(M.near(n.doc.resolve(z))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...bs(d,u.type.name,u.attrs),...e},m={...bs(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);n.delete(l.pos,a.pos);let k=g?u.attrs:p,b=h?[{type:o,attrs:k},{type:h,attrs:m}]:[{type:o,attrs:k}];if(!Re(n.doc,l.pos,2))return!1;if(s){let{selection:x,storedMarks:E}=r,{splittableMarks:C}=i.extensionManager,T=E||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),g&&n.setNodeMarkup(y,void 0,p),!T||!s)return!0;let L=T.filter(I=>C.includes(I.type.name));n.ensureMarks(L)}return!0};function nf(t,e,n){if(!t.validContent(e))return null;try{return t.create(n,e)}catch{return null}}function gl(t,e){if(t.pendingContent.length===0)return!0;let n=nf(e,w.from(t.pendingContent));return n?(t.items.push(n),t.pendingContent=[],!0):!1}function pk(t,e,n){return n.validContent(w.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!gl(e,n)||!n.validContent(w.from(t))?!1:(e.pendingContent.push(t),!0)}function mk(t,e,n,r){let s=r(t,n);if(!s)return!1;let i=nf(n.listType,w.from(s),t.attrs);return i?n.itemType.validContent(w.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):gl(e,n.itemType)?(e.items.push(...s),!0):!1:!1}function gk(t,e,n){let r={items:[],pendingContent:[]};for(let s=0;s<t.childCount;s+=1){let i=t.child(s);if(!(e.isListNode(i)?mk(i,r,e,n):pk(i,r,e.itemType)))return null}return gl(r,e.itemType)?r.items:null}function rf(t,e){let n=[];for(let r=0;r<t.childCount;r+=1){let s=gk(t.child(r),e,rf);if(!s)return null;n.push(...s)}return n}function Ad(t,e){let n=null;return t.descendants((r,s)=>r!==e?!0:(n=s,!1)),n}function Ed(t){return!t||t==="1"?null:t}function sf(t,e){return Ed(t)===Ed(e)}var ms=(t,e)=>{let n=vs(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&$e(t.doc,n.pos))||!sf(n.node.attrs.type,s?.attrs.type)||t.join(n.pos),!0},gs=(t,e)=>{let n=vs(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&$e(t.doc,r))||!sf(n.node.attrs.type,s?.attrs.type)||t.join(r),!0};function yk(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),s=e.resolve(n.nodeSize-1);return M.between(r,s)}var kk=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=s.extensionManager,h=J(t,o.schema),p=J(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:k}=m,b=y.blockRange(k),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;let E=vs(he=>hr(he.type.name,d))(m),C=m.from===0&&m.to===o.doc.content.size,T=o.doc.content.content,L=T.length===1?T[0]:null,I=C&&L&&hr(L.type.name,d)?{node:L,pos:0,depth:0}:null,z=E??I,Ee=!!E&&b.depth>=1&&b.depth-E.depth<=1,Tt=!!I;if((Ee||Tt)&&z){if(z.node.type===h)return C&&Tt?a().command(({tr:he,dispatch:we})=>{let pe=yk(he);return pe?(he.setSelection(pe),we&&we(he),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(hr(z.node.type.name,d)&&h.validContent(z.node.content))return a().command(()=>(i.setNodeMarkup(z.pos,h),!0)).command(()=>ms(i,h)).command(()=>gs(i,h)).run();if(hr(z.node.type.name,d)){var At;let he=(At=z.node.firstChild)===null||At===void 0?void 0:At.type;if(he&&he!==p){let we=rf(z.node,{listType:h,itemType:p,isListNode:Dr=>hr(Dr.type.name,d)}),pe=we?w.from(we):null;return!pe||!h.validContent(pe)?!1:a().command(()=>{let{$anchor:Dr,$head:Oa}=i.selection,Ia=Dr.parent,La=Oa.parent,Zp=Dr.parentOffset,em=Oa.parentOffset,Pr;try{Pr=h.create(r,pe)}catch{return!1}if(i.replaceWith(z.pos,z.pos+z.node.nodeSize,Pr),Ia.inlineContent&&La.inlineContent){let Da=Ad(Pr,Ia),Pa=Ad(Pr,La);if(Da!==null&&Pa!==null){let tm=z.pos+Da+2+Zp,nm=z.pos+Pa+2+em;i.setSelection(M.create(i.doc,tm,nm))}}return!0}).command(()=>ms(i,h)).command(()=>gs(i,h)).run()}}}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ms(i,h)).command(()=>gs(i,h)).run():a().command(()=>{let he=u().wrapInList(h,r),we=x.filter(pe=>f.includes(pe.type.name));return i.ensureMarks(we),he?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ms(i,h)).command(()=>gs(i,h)).run()},bk=(t,e={},n={})=>({state:r,commands:s})=>{let{extendEmptyMarkRange:i=!1}=n,o=it(t,r.schema);return al(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},wk=(t,e,n={})=>({state:r,commands:s})=>{let i=J(t,r.schema),o=J(e,r.schema),l=ke(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},xk=(t,e={})=>({state:n,commands:r})=>{let s=J(t,n.schema);return ke(n,s,e)?r.lift(s):r.wrapIn(s,e)},Sk=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let s=n[r],i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){let o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},Ck=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>s||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},vk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:o}=n,l=it(t,r.schema),{$from:a,empty:c,ranges:u}=o;if(!s)return!0;if(c&&i){var d;let{from:f,to:h}=o,p=ul(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},Mk=t=>({tr:e,state:n,dispatch:r})=>{let{selection:s}=n,i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Tk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,l=Cs(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=J(t,r.schema)),l==="mark"&&(o=it(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(i&&i===g.type&&(a=!0,s&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(k=>{if(o===k.type&&(a=!0,s)){let b=Math.max(y,u),x=Math.min(y+g.nodeSize,d);n.addMark(b,x,o.create({...k.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&s&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Sn=new _("__tiptap_decorations__"),Ak=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(Sn,{type:"force",name:t}),!0),Ek=(t,e={})=>({state:n,dispatch:r})=>{let s=J(t,n.schema);return qc(s,e)(n,r)},Rk=(t,e={})=>({state:n,dispatch:r})=>{let s=J(t,n.schema);return Jc(s,e)(n,r)},Be=za({blur:()=>X0,clearContent:()=>Y0,clearNodes:()=>Q0,command:()=>Z0,createParagraphNear:()=>ey,cut:()=>ty,deleteCurrentNode:()=>ny,deleteNode:()=>ry,deleteRange:()=>sy,deleteSelection:()=>ly,enter:()=>ay,exitCode:()=>cy,extendMarkRange:()=>uy,first:()=>dy,focus:()=>hy,forEach:()=>py,insertContent:()=>my,insertContentAt:()=>gy,insertDefaultBlock:()=>yy,joinBackward:()=>wy,joinDown:()=>by,joinForward:()=>xy,joinItemBackward:()=>Sy,joinItemForward:()=>Cy,joinTextblockBackward:()=>vy,joinTextblockForward:()=>My,joinUp:()=>ky,keyboardShortcut:()=>Ay,lift:()=>Ey,liftEmptyBlock:()=>Ry,liftListItem:()=>Ny,newlineInCode:()=>Oy,resetAttributes:()=>Iy,scrollIntoView:()=>Ly,selectAll:()=>Dy,selectNodeBackward:()=>Py,selectNodeForward:()=>$y,selectParentNode:()=>zy,selectTextblockEnd:()=>By,selectTextblockStart:()=>Hy,setContent:()=>Fy,setMark:()=>ik,setMeta:()=>ok,setNode:()=>lk,setNodeSelection:()=>ak,setTextDirection:()=>ck,setTextSelection:()=>uk,sinkListItem:()=>dk,splitBlock:()=>fk,splitListItem:()=>hk,toggleList:()=>kk,toggleMark:()=>bk,toggleNode:()=>wk,toggleWrap:()=>xk,undoInputRule:()=>Sk,unsetAllMarks:()=>Ck,unsetMark:()=>vk,unsetTextDirection:()=>Mk,updateAttributes:()=>Tk,updateDecorations:()=>Ak,wrapIn:()=>Ek,wrapInList:()=>Rk}),Cn=new WeakMap;function Nk(t,e){var n;Cn.set(t,((n=Cn.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let s=((r=Cn.get(t))!==null&&r!==void 0?r:1)-1;s>0?Cn.set(t,s):Cn.delete(t)}}function Ok(t){return Cn.has(t)}var Ik=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},of=typeof process<"u"&&!1;function Lk(t){return t.kind==="widget"}function lf(t,e){let n=[],r=new Set;for(let s of t)s.kind==="widget"&&Lk(s)&&r.add(s.key),n.push(s.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function Dk(t,e,n){let{decorations:r,widgetKeys:s}=lf(e,n);return{set:V.create(t,r),widgetKeys:s}}function af({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function Pk({decorations:t,from:e,to:n,docSize:r,extensionName:s,warnedExtensions:i}){return t.filter(o=>af({position:o.anchor,from:e,to:n,docSize:r})?!0:(o.anchor===n||i.has(s)||(i.add(s),console.warn(`[tiptap warn]: Extension "${s}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function cf(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function $k(t){let e=new Map,n=new Map;for(let o of t.find()){var r,s,i;let l=cf(o);if(!l)continue;let a=(r=o.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(s=e.get(l))!==null&&s!==void 0?s:new Set;c.add(a),e.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([o,l])=>({key:o,extensions:l})).filter(({key:o})=>{var l;return((l=n.get(o))!==null&&l!==void 0?l:0)>1})}function uf(t){return t.jsonID==="attr"}function zk(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||uf(t))return!0;let n=t;return typeof n.from=="number"&&typeof n.to=="number"}function Bk(t,e){let n=null,r=0,s=0;for(let i=0;i<t.childCount&&!(s>e.to);i+=1){let o=s+t.child(i).nodeSize;o>=e.from&&(n===null&&(n=s),r=o),s=o}return n===null?null:{from:n,to:r}}function Hk(t,e){if(t.steps.some(i=>!zk(i)))return{type:"full"};let n=En(t).map(({newRange:i})=>i);t.steps.forEach((i,o)=>{if(!uf(i))return;let l=t.mapping.slice(o);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let o=Bk(e,i);o&&r.push(o)}r.sort((i,o)=>i.from-o.from);let s=[];for(let i of r){let o=s[s.length-1];o&&i.from<=o.to?o.to=Math.max(o.to,i.to):s.push({...i})}return{type:"ranges",ranges:s}}function df(t,e,n,r){return t.map(e,n,{onRemove:s=>{let i=s?.key;typeof i=="string"&&r.delete(i)}})}function Fk(t,e,n){var r,s;let i=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:V.empty,o=new Set((s=e.widgetKeysByExtension[t])!==null&&s!==void 0?s:[]);return{set:df(i,n.mapping,n.doc,o),widgetKeys:o}}function Rd(t,e){let n=Object.values(e).flatMap(r=>r.find());return V.create(t,n)}function Nd(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function _k(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function jk(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var Wk=new Set;var Vk=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=Sn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>_k(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=Sn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:Wk}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let s=r();s&&e.push({name:n,spec:s})}return e}createPlugin(){let{editor:t,entries:e}=this;return new P({key:Sn,state:{init:(n,r)=>{let s={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);s[l]=c,i[l]=u}let o={decorationSetsByExtension:s,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,s),widgetKeys:Nd(i)};return this.warnDuplicateWidgetKeys(o),o},apply:(n,r,s,i)=>{let o=n.getMeta(Sn),l=o?.type==="force"&&!o.name,a=o?.type==="force"?o.name:void 0,c={},u={},d=new Set;return Nk(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(jk(h,{editor:t,tr:n,oldState:s,newState:i},p))if(h.update==="changedRanges"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,i);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,i);c[f]=m,u[f]=g,d.add(f)}else{let m=Fk(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:Nd(u)}}},props:{decorations(n){var r,s;return(r=(s=Sn.getState(n))===null||s===void 0?void 0:s.mergedDecorationSet)!==null&&r!==void 0?r:V.empty}}})}applyChangedRangesRecompute(t,e,n,r,s){let i=Hk(r,s.doc);return i.type==="full"?this.buildFullSet(t,e,s):this.rebuildRanges(t,e,n,r,s,i.ranges)}rebuildRanges(t,e,n,r,s,i){var o,l;let a=(o=n.decorationSetsByExtension[t])!==null&&o!==void 0?o:V.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),u=df(a,r.mapping,r.doc,c),d=s.doc.content.size;for(let{from:f,to:h}of i){let p=u.find(f,h).filter(y=>af({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let k=cf(y);k&&c.delete(k)}u=u.remove(p);let{decorations:m,widgetKeys:g}=lf(Pk({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:s,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(s.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return Dk(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!of)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=$k(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:s}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(s).map(o=>`"${o}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${s.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:Rd(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:s}){return t.length===1?r[t[0].name]:s.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):Rd(n.doc,r)}};function qt(t,e){if(t===e)return!0;if(!t||!e)return!1;let n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(s=>Object.prototype.hasOwnProperty.call(e,s)&&Object.is(t[s],e[s]))}function ff(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof N){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){let i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function Kk(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var Uk={lt:"<",gt:">",quot:'"',amp:"&"};function yl(t){return t.replace(/&(?:#(\d{1,7})|#[xX]([0-9a-fA-F]{1,6})|(lt|gt|quot|amp));/g,(e,n,r,s)=>n!==void 0?Od(Number(n)):r!==void 0?Od(parseInt(r,16)):Uk[s])}var qk=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function Od(t){var e;return t===0||t>1114111||t>=55296&&t<=57343?"\uFFFD":String.fromCodePoint((e=qk.get(t))!==null&&e!==void 0?e:t)}function hf(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Jk(t){return typeof t=="number"}function Gk(t){return Object.prototype.toString.call(t).slice(8,-1)}function ys(t){return Gk(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function pf(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function Xk(t,e){return t.replace(/^[ \t]*/,n=>{let s=0;for(let i of n)s+=i===" "?4-s%4:1;return" ".repeat(Math.max(0,s-e))})}function Yk(t,e){let n=`text
|
|
19
19
|
${t}
|
|
20
|
-
`,r=e(n)[0];return(r?.type==="paragraph"||r?.type==="text")&&r.raw===n}function
|
|
21
|
-
`),i=(r=n.isParagraphContinuation)!==null&&r!==void 0?r:(l=>
|
|
20
|
+
`,r=e(n)[0];return(r?.type==="paragraph"||r?.type==="text")&&r.raw===n}function Qk(t,e,n){var r;let s=e.split(`
|
|
21
|
+
`),i=(r=n.isParagraphContinuation)!==null&&r!==void 0?r:(l=>Yk(l,n.blockTokens)),o=0;for(let l of s){if(!l.trim()||!i(l))break;o+=1}return{mainContent:[t,...s.slice(0,o).map(l=>l.trimStart())].join(`
|
|
22
22
|
`),nestedContent:s.slice(o).join(`
|
|
23
|
-
`)}}function
|
|
23
|
+
`)}}function Nn(t,e,n){let r=t.split(`
|
|
24
24
|
`),s=[],i="",o=0,l=e.baseIndentSize||2;for(;o<r.length;){let u=r[o],d=u.match(e.itemPattern);if(!d){if(s.length>0)break;if(u.trim()===""){o+=1,i=`${i}${u}
|
|
25
25
|
`;continue}else return}let f=e.extractItemData(d),{indentLevel:h,mainContent:p}=f;i=`${i}${u}
|
|
26
26
|
`;let m=[p];for(o+=1;o<r.length;){var a;let b=r[o];if(b.trim()===""){var c;let x=r.slice(o+1).findIndex(E=>E.trim()!=="");if(x===-1)break;if((((c=r[o+1+x].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(b),i=`${i}${b}
|
|
27
27
|
`,o+=1;continue}else break}if((((a=b.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(b),i=`${i}${b}
|
|
28
|
-
`,o+=1;else break}let g,y=m.slice(1);if(y.length>0){let b=
|
|
29
|
-
`),n);f.mainContent=b.mainContent;let x=b.nestedContent;x.trim()&&(e.customNestedParser?g=e.customNestedParser(x):g=n.blockTokens(x))}let k=e.createToken(f,g);s.push(k)}if(s.length!==0)return{items:s,raw:i.slice(0,t.length)}}var
|
|
28
|
+
`,o+=1;else break}let g,y=m.slice(1);if(y.length>0){let b=Qk(p,y.map(E=>Xk(E,h+l)).join(`
|
|
29
|
+
`),n);f.mainContent=b.mainContent;let x=b.nestedContent;x.trim()&&(e.customNestedParser?g=e.customNestedParser(x):g=n.blockTokens(x))}let k=e.createToken(f,g);s.push(k)}if(s.length!==0)return{items:s,raw:i.slice(0,t.length)}}var Id=4;function Ld(t){let e=0;for(let n of t)e=n===" "?e+Id-e%Id:e+1;return e}function On(t,e,n,r,s){if(!t||!Array.isArray(t.content))return"";let i=typeof n=="function"?n(r):n,[o,...l]=t.content,a=e.renderChildren([o]),c=`${i}${s?.indentMainContent?a.split(`
|
|
30
30
|
`).map((u,d)=>d===0?u:e.indent(u)).join(`
|
|
31
|
-
`):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!s?.alignNestedToPrefix)return e.indent(y);let k=e.indent(""),b=
|
|
31
|
+
`):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!s?.alignNestedToPrefix)return e.indent(y);let k=e.indent(""),b=Ld(i);return(Ld(k)>=b?k:" ".repeat(b))+y},g=p.split(`
|
|
32
32
|
`).map(y=>m(y||"")).join(`
|
|
33
33
|
`);c+=u.type==="paragraph"?`
|
|
34
34
|
|
|
35
35
|
${g}`:`
|
|
36
|
-
${g}`}}),c}function
|
|
37
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var
|
|
36
|
+
${g}`}}),c}function Dd(t){return typeof t.type=="string"?t.type:t.type.name}function mf(t,e){if(t.length!==e.length)return!1;let n=Array.from({length:e.length},()=>!1);return t.every(r=>{let s=Dd(r),i=e.findIndex((o,l)=>!n[l]&&s===Dd(o)&&qt(r.attrs,o.attrs));return i===-1?!1:(n[i]=!0,!0)})}function gf(t,e){let n={...t};return ys(t)&&ys(e)&&Object.keys(e).forEach(r=>{ys(e[r])&&ys(t[r])?n[r]=gf(t[r],e[r]):n[r]=e[r]}),n}function Zk(t,e,n={}){let{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{let c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var In=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},eb=(t,e)=>{if(cl(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function tb(t){let{editor:e,from:n,to:r,text:s,insertText:i}=t;if(!i)return{inputTransaction:null,tr:e.view.state.tr};let o=e.view.state.tr.insertText(s,n,r);return{inputTransaction:o,tr:Dt.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function nb(t){let{editor:e,from:n,to:r,text:s,rule:i,match:o,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=tb({editor:e,from:n,to:r,text:s,insertText:a}),f=u?n+s.length:r,h=Ss({state:c.state,transaction:d}),p={from:n-(o[0].length-s.length),to:f},{commands:m,chain:g,can:y}=new vn({editor:e,state:h});return i.handler({state:h,range:p,match:o,commands:m,chain:g,can:y})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(ud(d),d.setMeta("inputRule",!0),i.undoable&&d.setMeta(l,{transform:d,from:n,to:f,text:s}),c.dispatch(d)),!0)}function rb(t,e,n){let r=e[0].length-n.length;if(r<=0)return!0;let s=t.parentOffset-r;return s>=0&&t.parent.textBetween(s,t.parentOffset)===e[0].slice(0,r)}function ks(t){var e;let{editor:n,from:r,to:s,text:i,rules:o,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=Qy(u)+i;for(let f of o){let h=eb(d,f.find);if(!(!h||!rb(u,h,i))&&nb({editor:n,from:r,to:s,text:i,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function sb(t){let{editor:e,rules:n}=t,r=new P({state:{init(){return null},apply(s,i,o){let l=s.getMeta(r);if(l)return l;let a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=fl(w.from(c),o.schema);let{from:u}=a,d=u+c.length;ks({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ks({editor:e,from:i,to:o,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{let{$cursor:i}=s.state.selection;i&&ks({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;let{$cursor:o}=s.state.selection;return o?ks({editor:e,from:o.pos,to:o.pos,text:`
|
|
37
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var kl=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...B(A(this,"addOptions",{name:this.name}))}}get storage(){return{...B(A(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>gf(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Me=class yf extends kl{constructor(...e){super(...e),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new yf(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){let i=s.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let o=i.find(l=>l?.type.name===n.name);return o&&r.removeStoredMark(o),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},bl=class{constructor(t){this.find=t.find,this.handler=t.handler}},ib=(t,e,n)=>{if(cl(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(s=>{let i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function ob(t){let{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new vn({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let k=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,b=Math.max(r,h),x=Math.min(s,h+k);if(b>=x)return;let E=f.isText?f.text||"":f.textBetween(b-h,x-h,void 0,"\uFFFC");ib(E,i.find,o).forEach(C=>{if(C.index===void 0)return;let T=b+C.index+1,L=T+C[0].length,I={from:n.tr.mapping.map(T),to:n.tr.mapping.map(L)},z=i.handler({state:n,range:I,match:C,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(z)})}),d.every(f=>f!==null)}var xn=null,lb=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function ab(t){let{editor:e,rules:n}=t,r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=Ss({state:c,transaction:p});if(!(!ob({editor:e,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return e.on("destroy",()=>{xn===e&&(xn=null)}),n.map(c=>new P({view(u){let d=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null,r&&(xn=e)},f=()=>{xn&&(xn=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(i=r===u.dom.parentElement,l=d,!i){let f=xn;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=d,s=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta("uiEvent")==="paste"&&!s,m=h.getMeta("uiEvent")==="drop"&&!i,g=h.getMeta("applyPasteRules"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:x}=g;typeof x=="string"?x=x:x=fl(w.from(x),f.schema);let{from:E}=g,C=E+x.length,T=lb(x);return a({rule:c,state:f,from:E,to:{b:C},pasteEvt:T})}let k=d.doc.content.findDiffStart(f.doc.content),b=d.doc.content.findDiffEnd(f.doc.content);if(!(!Jk(k)||!b||k===b.b))return a({rule:c,state:f,from:k,to:b,pasteEvt:o})}}))}var Os=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=pl(t),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=Xd(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n=A(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:wn(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){let{editor:t}=this,e=Ut([...this.extensions].reverse()).flatMap(r=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:wn(r.name,this.schema)},i=[],o=A(r,"addKeyboardShortcuts",s),l={};if(r.type==="mark"&&A(r,"exitable",s)&&(l.ArrowRight=()=>Me.handleExit({editor:t,mark:r})),o){let f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=od(l);i.push(a);let c=A(r,"addInputRules",s);if(Md(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=sb({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let u=A(r,"addPasteRules",s);if(Md(r,t.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=ab({editor:t,rules:f});i.push(...h)}}let d=A(r,"addProseMirrorPlugins",s);if(d){let f=d();i.push(...f)}return i}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;let{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();let n=[];return this.extensions.forEach(r=>{let s=A(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:wn(r.name,this.schema)});s&&n.push({name:r.name,addDecorations:s})}),this.decorationManager=new Vk({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){let t=hl(this.extensions);return this.hasSchemaSpec?Jd(t,this.schema):t}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=Tn(this.extensions);return Object.fromEntries(e.filter(n=>!!A(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),s=A(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:J(n.name,this.schema)});if(!s)return[];let i=s();if(!i)return[];let o=(l,a,c,u,d)=>{let f=St(l,r);return i({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,o]}))}dispatchTransaction(t){let{editor:e}=this;return Ut([...this.extensions].reverse()).reduceRight((n,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:wn(r.name,this.schema)},i=A(r,"dispatchTransaction",s);return i?o=>{i.call(s,{transaction:o,next:n})}:n},t)}transformPastedHTML(t){let{editor:e}=this;return Ut([...this.extensions]).reduce((n,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:wn(r.name,this.schema)},i=A(r,"transformPastedHTML",s);return i?(o,l)=>{let a=n(o,l);return i.call(s,a)}:n},t||(n=>n))}get markViews(){let{editor:t}=this,{markExtensions:e}=Tn(this.extensions);return Object.fromEntries(e.filter(n=>!!A(n,"addMarkView")).map(n=>{let r=this.attributes.filter(o=>o.type===n.name),s=A(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:it(n.name,this.schema)});if(!s)return[];let i=(o,l,a)=>{let c=St(o,r);return s()({mark:o,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{Zk(o,t,u)}})};return[n.name,i]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:wn(e.name,this.schema)};if(e.type==="mark"){var r,s;(!((r=B(A(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((s=B(A(e,"clearable",n)))!==null&&s!==void 0)||s||this.nonClearableMarks.push(e.name)}let i=A(e,"onBeforeCreate",n),o=A(e,"onCreate",n),l=A(e,"onUpdate",n),a=A(e,"onSelectionUpdate",n),c=A(e,"onTransaction",n),u=A(e,"onFocus",n),d=A(e,"onBlur",n),f=A(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};Os.resolve=pl;Os.sort=Ut;Os.flatten=gr;var j=class kf extends kl{constructor(...e){super(...e),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new kf(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},cb=j.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new P({key:new _("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,i=Zd(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:i};return[...s.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>Qd(r,{from:a.pos,to:c.pos},l)).join(o??`
|
|
38
38
|
|
|
39
|
-
`)}}})]}}),
|
|
39
|
+
`)}}})]}}),ub=j.create({name:"commands",addCommands(){return{...Be}}}),db=j.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;let s=()=>{var i,o,l;if((i=(o=this.editor.options.coreExtensionOptions)===null||o===void 0||(o=o.delete)===null||o===void 0||(l=o.filterTransaction)===null||l===void 0?void 0:l.call(o,t))!==null&&i!==void 0?i:t.getMeta("y-sync$"))return;let a=dl(t.before,[t,...e]);En(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:t,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof ft){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),y=c.invert().map(m),k=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(x=>x.eq(u.mark)):!1,b=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(x=>x.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(b||k),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(s,0):s()}}),fb=j.create({name:"drop",addProseMirrorPlugins(){return[new P({key:new _("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),hb=j.create({name:"editable",addProseMirrorPlugins(){return[new P({key:new _("editable"),props:{editable:()=>this.editor.options.editable}})]}}),pb=new _("focusEvents"),mb=j.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new P({key:pb,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}});function gb(t){let{empty:e,from:n,to:r}=t.selection;return e?!1:n===R.atStart(t.doc).from&&r===R.atEnd(t.doc).to}var yb=j.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:R.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xs()||Kd()?i:s},addProseMirrorPlugins(){return[new P({key:new _("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(a=>a.getMeta("composition")))return;let r=t.some(a=>a.docChanged)&&!e.doc.eq(n.doc),s=t.some(a=>a.getMeta("preventClearDocument"));if(!r||s||!gb(e)||!Rn(n.doc))return;let i=n.tr,o=Ss({state:n,transaction:i}),{commands:l}=new vn({editor:this.editor,state:o});if(l.clearNodes(),!(!i.steps.length&&!n.storedMarks))return i.setStoredMarks(null)}})]}}),kb=j.create({name:"paste",addProseMirrorPlugins(){return[new P({key:new _("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),bb=j.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new P({key:new _("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),wb=j.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=Tn(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new P({key:new _("textDirection"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}});var Pd=!1;function xb(t){if(Pd)return;Pd=!0;let e;try{let n=Q.fromJSON(t,{from:0,to:0});if(!tk(n))return;e=n.slice.content}catch{return}e instanceof w||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Sb=class mr{get name(){return this.node.type.name}constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new mr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new mr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new mr(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!s&&!o&&a.depth<=this.depth)return;let c=new mr(a,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){let i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){let a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;let i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>n[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Cb=`.ProseMirror {
|
|
40
40
|
position: relative;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -106,41 +106,41 @@ img.ProseMirror-separator {
|
|
|
106
106
|
|
|
107
107
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
108
108
|
display: block;
|
|
109
|
-
}`,
|
|
109
|
+
}`,bf=class extends Ik{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:nk,createMappablePosition:rk},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=il(e,this.options.autofocus);this.editorState=Dt.create({doc:e,schema:this.schema,selection:n||void 0})}xb(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():vn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():vn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Kk(Cb,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return of&&!this.hasWarnedStaleDecorationRead&&Ok(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=ll(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(s=>{let i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[hb,cb.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),ub,mb,yb,bb.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),fb,kb,db,wb.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Os(n,this)}createCommandManager(){this.commandManager=new vn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=ol(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let n=ol(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Dt.create({doc:n,schema:this.schema,selection:il(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;let e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return ll(e)?n=>({role:"textbox",...e(n)}):{role:"textbox",...e}}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new ar(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:s,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ml(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Zy(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return fl(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`
|
|
110
110
|
|
|
111
|
-
`,textSerializers:n={}}=t||{};return
|
|
112
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Zk,this.editor.getAttributes(hf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=xt({find:pf,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=xt({find:pf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(hf),editor:this.editor})),[t]}}),eb=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let h=s.depth;h>0;h-=1)if(s.node(h).type.name===e){i=h;break}if(i<0)return null;let o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;let a=o.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:s.after(),insertPos:s.after(i),items:f}},tb=(t,e,n,r)=>{let s=eb(t,n,r);if(!s)return!1;let{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=s,u=t.tr;u.delete(l,l+o.nodeSize);let d=u.mapping.map(a);return u.insert(d,w.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},nb=(t,e,n)=>tb(t.state,t.view.dispatch,e,n),Cf=(t,e)=>V.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>nb(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),vf=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ms="abcdefghijklmnopqrstuvwxyz",Mf=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Es(t){let e=t,n="";for(let[r,s]of vf)for(;e>=r;)n+=s,e-=r;return n}function dl(t){return Es(t).toUpperCase()}function Tf(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let s=!1;for(let[i,o]of vf)if(e.startsWith(o,n)){r+=i,n+=o.length,s=!0;break}if(!s)return 0}return r}function rb(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Tf(t);return e<=0?!1:(t===t.toLowerCase()?Es(e):dl(e))===t}function sb(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Ts(t){if(t<=26)return Ms[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Ms[n]:Ms[e]+Ms[n]}function Rs(t){if(!(!t||/^\d+$/.test(t))){if(rb(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function fl(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=Rs(t);if(e==="i"||e==="I")return Tf(t);if(e==="a"||e==="A"){let r=sb(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function ib(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Ts(e);case"A":return Ts(e).toUpperCase();case"i":return Es(e);case"I":return dl(e);default:return String(e)}}function ob(t){var e;if(t.length===0)return!1;let n=(e=Rs(t[0]))!==null&&e!==void 0?e:"numeric",r=fl(t[0]);if(r<1)return!1;for(let s=0;s<t.length;s++){let i=ib(n,r+s);if(t[s]!==i)return!1}return!0}function lb(t){return{type:Rs(t),start:fl(t)}}function ab(t){let{type:e,start:n}=lb(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function cb(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Ts(r)}${n}`;case"A":return`${Ts(r).toUpperCase()}${n}`;case"i":return`${Es(r)}${n}`;case"I":return`${dl(r)}${n}`;default:return`${r}${n}`}}function ub(t){return!t[0]||t[0].type==="paragraph"?t:[{type:"paragraph",content:[]},...t]}function db(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var fb=" ",mf=1,hb=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:mf)>mf};function pb(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function mb(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var hl=K.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,s=[];if(t.tokens&&t.tokens.length>0){if(pb(t))return{type:"listItem",content:[{type:"paragraph",content:mb(t.text||"",e)}]};let[o,...l]=t.tokens;if(o.type==="heading"){var i;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((i=o.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type==="paragraph"))s=r(t.tokens);else if(o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));s.push(...a)}}else s=r(t.tokens)}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:ub(s)}},renderMarkdown:(t,e,n)=>{let r=o=>{if(o.parentType==="bulletList")return"- ";if(o.parentType==="orderedList"){var l,a;let c=((l=o.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return cb((a=o.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(o.index||0),". ")}return"- "},s=ll(t,e,r,n,{alignNestedToPrefix:n?.parentType==="orderedList"});if(!db(t)||!hb(n))return s;let i=r(n);return`${i}${fb}${s.slice(i.length)}`},addExtensions(){return[Cf(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),pl=(t,e)=>{let{$from:n}=e.selection,r=ee(t,e.schema),s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Af=(t,e)=>{let n=pl(t,e);if(!n)return!1;let[,r]=jd(e,t,n.$pos.pos+4);return r},gb=(t,e,n)=>{let{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},gf=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ve(t.state,e)&&gb(t.state,e,n)){let{$anchor:i}=t.state.selection,o=t.state.doc.resolve(i.before()-1),l=[];o.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(o.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(i.before(),i.after()).insert(d,i.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(Kr(u,d),!0)).run()}if(!Ve(t.state,e)||!Vd(t.state))return!1;let{$from:r}=t.state.selection,s=r.depth-1;return r.node(s).type!==t.schema.nodes[e]||r.index(s)!==0?!1:t.chain().liftListItem(e).run()},yb=(t,e)=>{let n=Af(t,e),r=pl(t,e);return!r||!n?!1:n>r.depth},kb=(t,e)=>{let n=Af(t,e),r=pl(t,e);return!r||!n?!1:n<r.depth},yf=(t,e)=>!Ve(t.state,e)||!Wd(t.state,e)||!t.state.selection.empty?!1:yb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():kb(e,t.state)?t.commands.command(({state:n,dispatch:r})=>Ur(n,r)):t.commands.joinItemForward(),bb=(t,e,n)=>{let{state:r}=t,{selection:s}=r;if(!s.empty)return!1;let{$from:i}=s;if(i.parentOffset!==0||!i.parent.isTextblock||Ve(r,e))return!1;let o=_d(i);if(!o||!n.includes(o.type.name))return!1;let l=o.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,w.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,w.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var ml=V.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&yf(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&yf(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&gf(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&gf(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&bb(t,e,n))return!0;return!1}}}}),As=new RegExp(`^(\\s*)(${Mf})([.)])\\s+(.*)$`),wb=/^\s/,Rn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function xb(t){return As.test(t.trimStart())}function Sb(t){let e=t.trimStart();return Rn.bulletItem.test(e)||xb(e)||Rn.heading.test(e)||Rn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Rn.codeFence.test(e)||Rn.blockMath.test(e)}function Cb(t){return Object.values(Rn).some(e=>e.test(t))}function vb(t){let e=[],n=[],r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&Sb(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function kf(t){let e=[],n=0,r=0;for(;n<t.length;){let s=t[n],i=s.match(As);if(!i)break;let[,o,l,a,c]=i,u=o.length,d=parseInt(l,10),f=isNaN(d)?Rs(l):void 0,h=isNaN(d)?fl(l):d,p=[c],m=n+1,g=[s],y=!1;for(;m<t.length;){let k=t[m];if(k.match(As))break;if(k.trim()==="")g.push(k),p.push(""),y=!0,m+=1;else if(k.match(wb)){let b=k.length-k.trimStart().length,x=u+l.length+1;g.push(k),p.push(k.slice(Math.min(b,x))),m+=1}else{if(y||Cb(k))break;g.push(k),p.push(k),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
|
|
111
|
+
`,textSerializers:n={}}=t||{};return Jy(this.state.doc,{blockSeparator:e,textSerializers:{...Zd(this.schema),...n}})}get isEmpty(){return Rn(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new Sb(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Ie(t){return new In({find:t.find,handler:({state:e,range:n,match:r})=>{let s=B(t.getAttributes,void 0,r);if(s===!1||s===null)return null;let{tr:i}=e,o=r[r.length-1],l=r[0];if(o){let a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(yr(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let d=n.from+a+o.length;i.addMark(n.from+a,d,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function wf(t){return new In({find:t.find,handler:({state:e,range:n,match:r})=>{let s=B(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from,l=n.to,a=t.type.create(s);if(r[1]){let c=o+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function kr(t){return new In({find:t.find,handler:({state:e,range:n,match:r})=>{let s=e.doc.resolve(n.from),i=B(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Se(t){return new In({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{let i=B(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),a=l&&an(l,t.type,i);if(!a)return null;if(o.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));o.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}let c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&$e(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&o.join(n.from-1)},undoable:t.undoable})}var W=class xf extends kl{constructor(...e){super(...e),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new xf(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Te(t){return new bl({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{let i=B(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;let{tr:o}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(yr(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&o.delete(f,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}var vb="listItem",Sf="textStyle",Cf=/^\s*([-+*])\s$/,Mb=W.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
112
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vb,this.editor.getAttributes(Sf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Se({find:Cf,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Se({find:Cf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Sf),editor:this.editor})),[t]}}),Tb=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let h=s.depth;h>0;h-=1)if(s.node(h).type.name===e){i=h;break}if(i<0)return null;let o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;let a=o.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:s.after(),insertPos:s.after(i),items:f}},Ab=(t,e,n,r)=>{let s=Tb(t,n,r);if(!s)return!1;let{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=s,u=t.tr;u.delete(l,l+o.nodeSize);let d=u.mapping.map(a);return u.insert(d,w.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},Eb=(t,e,n)=>Ab(t.state,t.view.dispatch,e,n),If=(t,e)=>j.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Eb(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Lf=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Is="abcdefghijklmnopqrstuvwxyz",Df=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Ps(t){let e=t,n="";for(let[r,s]of Lf)for(;e>=r;)n+=s,e-=r;return n}function wl(t){return Ps(t).toUpperCase()}function Pf(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let s=!1;for(let[i,o]of Lf)if(e.startsWith(o,n)){r+=i,n+=o.length,s=!0;break}if(!s)return 0}return r}function Rb(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Pf(t);return e<=0?!1:(t===t.toLowerCase()?Ps(e):wl(e))===t}function Nb(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Ls(t){if(t<=26)return Is[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Is[n]:Is[e]+Is[n]}function $s(t){if(!(!t||/^\d+$/.test(t))){if(Rb(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function xl(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=$s(t);if(e==="i"||e==="I")return Pf(t);if(e==="a"||e==="A"){let r=Nb(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function Ob(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Ls(e);case"A":return Ls(e).toUpperCase();case"i":return Ps(e);case"I":return wl(e);default:return String(e)}}function Ib(t){var e;if(t.length===0)return!1;let n=(e=$s(t[0]))!==null&&e!==void 0?e:"numeric",r=xl(t[0]);if(r<1)return!1;for(let s=0;s<t.length;s++){let i=Ob(n,r+s);if(t[s]!==i)return!1}return!0}function Lb(t){return{type:$s(t),start:xl(t)}}function Db(t){let{type:e,start:n}=Lb(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function Pb(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Ls(r)}${n}`;case"A":return`${Ls(r).toUpperCase()}${n}`;case"i":return`${Ps(r)}${n}`;case"I":return`${wl(r)}${n}`;default:return`${r}${n}`}}function $b(t){return!t[0]||t[0].type==="paragraph"?t:[{type:"paragraph",content:[]},...t]}function zb(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var Bb=" ",vf=1,Hb=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:vf)>vf};function Fb(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function _b(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var jb=W.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,s=[];if(t.tokens&&t.tokens.length>0){if(Fb(t))return{type:"listItem",content:[{type:"paragraph",content:_b(t.text||"",e)}]};let[o,...l]=t.tokens;if(o.type==="heading"){var i;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((i=o.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type==="paragraph"))s=r(t.tokens);else if(o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));s.push(...a)}}else s=r(t.tokens)}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:$b(s)}},renderMarkdown:(t,e,n)=>{let r=o=>{if(o.parentType==="bulletList")return"- ";if(o.parentType==="orderedList"){var l,a;let c=((l=o.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Pb((a=o.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(o.index||0),". ")}return"- "},s=On(t,e,r,n,{alignNestedToPrefix:n?.parentType==="orderedList"});if(!zb(t)||!Hb(n))return s;let i=r(n);return`${i}${Bb}${s.slice(i.length)}`},addExtensions(){return[If(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Sl=(t,e)=>{let{$from:n}=e.selection,r=J(t,e.schema),s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},$f=(t,e)=>{let n=Sl(t,e);if(!n)return!1;let[,r]=Ts(e,t,n.$pos.pos+4);return r},Wb=(t,e,n)=>{let{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},Mf=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ke(t.state,e)&&Wb(t.state,e,n)){let{$anchor:i}=t.state.selection,o=t.state.doc.resolve(i.before()-1),l=[];o.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(o.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(i.before(),i.after()).insert(d,i.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(hn(u,d),!0)).run()}if(!ke(t.state,e)||!Rs(t.state))return!1;let{$from:r}=t.state.selection,s=r.depth-1;return r.node(s).type!==t.schema.nodes[e]||r.index(s)!==0?!1:t.chain().liftListItem(e).run()},Vb=(t,e)=>{let n=$f(t,e),r=Sl(t,e);return!r||!n?!1:n>r.depth},Kb=(t,e)=>{let n=$f(t,e),r=Sl(t,e);return!r||!n?!1:n<r.depth},Tf=(t,e)=>!ke(t.state,e)||!Es(t.state,e)||!t.state.selection.empty?!1:Vb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Kb(e,t.state)?t.commands.command(({state:n,dispatch:r})=>pn(n,r)):t.commands.joinItemForward(),Ub=(t,e,n)=>{let{state:r}=t,{selection:s}=r;if(!s.empty)return!1;let{$from:i}=s;if(i.parentOffset!==0||!i.parent.isTextblock||ke(r,e))return!1;let o=As(i);if(!o||!n.includes(o.type.name))return!1;let l=o.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,w.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,w.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var qb=j.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Tf(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Tf(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Mf(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Mf(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&Ub(t,e,n))return!0;return!1}}}}),Ds=new RegExp(`^(\\s*)(${Df})([.)])\\s+(.*)$`),Jb=/^\s/,Ln={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Gb(t){return Ds.test(t.trimStart())}function Xb(t){let e=t.trimStart();return Ln.bulletItem.test(e)||Gb(e)||Ln.heading.test(e)||Ln.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Ln.codeFence.test(e)||Ln.blockMath.test(e)}function Yb(t){return Object.values(Ln).some(e=>e.test(t))}function Qb(t){let e=[],n=[],r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&Xb(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function Af(t){let e=[],n=0,r=0;for(;n<t.length;){let s=t[n],i=s.match(Ds);if(!i)break;let[,o,l,a,c]=i,u=o.length,d=parseInt(l,10),f=isNaN(d)?$s(l):void 0,h=isNaN(d)?xl(l):d,p=[c],m=n+1,g=[s],y=!1;for(;m<t.length;){let k=t[m];if(k.match(Ds))break;if(k.trim()==="")g.push(k),p.push(""),y=!0,m+=1;else if(k.match(Jb)){let b=k.length-k.trimStart().length,x=u+l.length+1;g.push(k),p.push(k.slice(Math.min(b,x))),m+=1}else{if(y||Yb(k))break;g.push(k),p.push(k),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
|
|
113
113
|
`).trim(),contentLines:p,raw:g.join(`
|
|
114
|
-
`)}),r=m,n=m}return[e,r]}var
|
|
115
|
-
`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let s=r.trim().match(
|
|
114
|
+
`)}),r=m,n=m}return[e,r]}var Zb=new RegExp(`^(${Df})([.)])\\s+(.+)$`);function ew(t){let e=t.split(`
|
|
115
|
+
`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let s=r.trim().match(Zb);if(!s)return null;n.push({marker:s[1],content:s[3]})}return Ib(n.map(r=>r.marker))?{type:"orderedList",attrs:Db(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function zf(t,e,n){let r=[],s=0;for(;s<t.length;){let i=t[s];if(i.indent===e){let{paragraphLines:o,blockLines:l}=Qb(i.contentLines),a=o.join(`
|
|
116
116
|
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`
|
|
117
|
-
`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=s+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=
|
|
118
|
-
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function
|
|
119
|
-
`,r);if(s===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,s)),r=s+1}return n}function
|
|
120
|
-
`),n=e===-1?t:t.slice(0,e);if(!
|
|
121
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,s;let[i,o,l]=
|
|
122
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
123
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let o=ol(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(o){let l={type:"taskList",raw:o.raw,items:o.items},a=i.slice(o.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},s=ol(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),vC=V.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(ul.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(hl.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(ml.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(gl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(yl.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(kl.configure(this.options.taskList)),t}});var wl,xl;if(typeof WeakMap<"u"){let t=new WeakMap;wl=e=>t.get(e),xl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;wl=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},xl=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var J=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,s=e/this.width|0,i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){let{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){let i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){let i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width,l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return wl(t)||xl(t,Lb(t))}};function Lb(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=Pb(t),n=t.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:k}=m.attrs;for(let b=0;b<y;b++){if(b+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-b});break}let x=s+b*e;for(let E=0;E<g;E++){r[x+E]==0?r[x+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-E});let C=k&&k[E];if(C){let T=(x+E)%e*2,D=o[T];D==null||D!=C&&o[T+1]==1?(o[T]=C,o[T+1]=1):D==C&&o[T+1]++}}}s+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new J(e,n,r,i),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&zb(l,o,t),l}function Pb(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let s=t.child(r),i=0;if(n)for(let o=0;o<r;o++){let l=t.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zb(t,e,n){t.problems||(t.problems=[]);let r={};for(let s=0;s<t.map.length;s++){let i=t.map[s];if(r[i])continue;r[i]=!0;let o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=o.attrs;for(let c=0;c<a.colspan;c++){let u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=$b(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function $b(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function de(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var St=new j("selectingCells");function qt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Bb(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function $e(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ps(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=qt(e.$head)||Hb(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Hb(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Sl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Fb(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ml(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Bf(t,e,n){let r=t.node(-1),s=J.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Jt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function Hf(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function jb(t,e,n){let r=de(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var U=class it extends R{constructor(e,n=e){let r=e.node(-1),s=J.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new un(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Sl(r)&&Sl(s)&&Ml(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?it.rowSelection(r,s):i&&this.isColSelection()?it.colSelection(r,s):new it(r,s)}return M.between(r,s)}content(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){let c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Jt(y,0,m)),g>0&&(y=Jt(y,y.colspan-g,g)),h.left<s.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(a).copy(w.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:o;return new v(w.from(l),1,1)}replace(e,n=v.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?v.empty:n)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new v(w.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=J.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),s=J.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new it(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;let o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof it&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),s=J.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new it(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new it(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new it(e.resolve(n),e.resolve(r))}getBookmark(){return new _b(this.$anchorCell.pos,this.$headCell.pos)}};U.prototype.visible=!1;R.jsonID("cell",U);var _b=class Ff{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ff(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ml(n,r)?new U(n,r):R.near(r,1)}};function Wb(t){if(!(t.selection instanceof U))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ne.node(r,r+n.nodeSize,{class:"selectedCell"}))}),_.create(t.doc,e)}function Vb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function Kb({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){let i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function Ub(t,e,n){let r=(e||t).selection,s=(e||t).doc,i,o;if(r instanceof N&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=U.create(s,r.from);else if(o=="row"){let l=s.resolve(r.from+1);i=U.rowSelection(l,l)}else if(!n){let l=J.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=U.create(s,a+1,c)}}else r instanceof M&&Vb(r)?i=M.create(s,r.from):r instanceof M&&Kb(r)&&(i=M.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var qb=new j("fix-tables");function jf(t,e,n,r){let s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){let a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?jf(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Tl(t,e){let n,r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=Jb(t,s,i,n))};return e?e.doc!=t.doc&&jf(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Jb(t,e,n,r){let s=J.get(e);if(!s.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){let c=s.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Jt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=de(t.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(qb,{fixTables:!0})}function Ke(t){let e=t.selection,n=Ps(t),r=n.node(-1),s=n.start(-1),i=J.get(r);return{...e instanceof U?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function _f(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;jb(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,Hf(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=i==null?de(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function Wf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t);e(_f(t.tr,n,n.left))}return!0}function Vf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t);e(_f(t.tr,n,n.right))}return!0}function Gb(t,{map:e,table:n,tableStart:r},s){let i=t.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Jt(u,s-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function Kf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;Gb(r,n,s),s!=n.left;s--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=J.get(i)}e(r)}return!0}function Xb(t,e,n){var r;let s=de(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function Uf(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;let o=[],l=s>0?-1:0;Xb(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?de(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&o.push(f)}return t.insert(i,de(r.type.schema).row.create(null,o)),t}function qf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t);e(Uf(t.tr,n,n.top))}return!0}function Jf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t);e(Uf(t.tr,n,n.bottom))}return!0}function Yb(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;let o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);let a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function Gf(t,e){if(!$e(t))return!1;if(e){let n=Ke(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;Yb(r,n,s),s!=n.top;s--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=J.get(n.table)}e(r)}return!0}function Rf(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Qb({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Al(t,e){let n=t.selection;if(!(n instanceof U)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Ke(t),{map:s}=r;if(Qb(s,r))return!1;if(e){let i=t.tr,o={},l=w.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=s.map[u*s.width+d],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{Rf(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Hf(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Rf(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new U(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function El(t,e){let n=de(t.schema);return Zb(({node:r})=>n[r.type.spec.tableRole])(t,e)}function Zb(t){return(e,n)=>{let r=e.selection,s,i;if(r instanceof U){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=Bb(r.$from),!s)return!1;i=(o=qt(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=Ke(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:s,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof U&&d.setSelection(new U(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Xf(t,e){return function(n,r){if(!$e(n))return!1;let s=Ps(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof U?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function ew(t){return function(e,n){if(!$e(e))return!1;if(n){let r=de(e.schema),s=Ke(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Nf(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){let i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Nn(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ew(t):function(n,r){if(!$e(n))return!1;if(r){let s=de(n.schema),i=Ke(n),o=n.tr,l=Nf("row",i,s),a=Nf("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,d,p.attrs)}),r(o)}return!0}}var OC=Nn("row",{useDeprecatedLogic:!0}),IC=Nn("column",{useDeprecatedLogic:!0}),Yf=Nn("cell",{useDeprecatedLogic:!0});function tw(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){let i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Rl(t){return function(e,n){if(!$e(e))return!1;let r=tw(Ps(e),t);if(r==null)return!1;if(n){let s=e.doc.resolve(r);n(e.tr.setSelection(M.between(s,Fb(s))).scrollIntoView())}return!0}}function Qf(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Ns(t,e){let n=t.selection;if(!(n instanceof U))return!1;if(e){let r=t.tr,s=de(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new v(s,0,0))}),r.docChanged&&e(r)}return!0}function nw(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Cl(de(o).row,new v(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Cl(de(o).row,new v(e,n,r)).content:e);else return null;return rw(o,l)}function rw(t,e){let n=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(w.empty),n[s]<r){let i=de(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(w.from(o))}return{height:e.length,width:r,rows:e}}function Cl(t,e){let n=t.createAndFill();return new ft(n).replace(0,n.content.size,e).doc}function sw({width:t,height:e,rows:n},r,s){if(t!=r){let i=[],o=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Jt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(w.from(c))}n=o,t=r}if(e!=s){let i=[];for(let o=0,l=0;o<s;o++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(w.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function iw(t,e,n,r,s,i,o){let l=t.doc.type.schema,a=de(l),c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,w.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||u)}function Of(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:o-h}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function If(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Jt(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Jt(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Df(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=J.get(i),{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=J.get(i),f=d.mapping.maps.length}iw(d,o,i,n,c,u,f)&&h(),Of(d,o,i,n,a,c,l,f)&&h(),Of(d,o,i,n,a,c,u,f)&&h(),If(d,o,i,n,l,u,a,f)&&h(),If(d,o,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=o.positionAt(p,a,i),g=o.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+n),d.mapping.slice(f).map(g+n),new v(s.rows[p-l],0,0))}h(),d.setSelection(new U(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}var ow=lr({ArrowLeft:Os("horiz",-1),ArrowRight:Os("horiz",1),ArrowUp:Os("vert",-1),ArrowDown:Os("vert",1),"Shift-ArrowLeft":Is("horiz",-1),"Shift-ArrowRight":Is("horiz",1),"Shift-ArrowUp":Is("vert",-1),"Shift-ArrowDown":Is("vert",1),Backspace:Ns,"Mod-Backspace":Ns,Delete:Ns,"Mod-Delete":Ns});function Ds(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Os(t,e){return(n,r,s)=>{if(!s)return!1;let i=n.selection;if(i instanceof U)return Ds(n,r,R.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let o=Zf(s,t,e);if(o==null)return!1;if(t=="horiz")return Ds(n,r,R.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(o),a=Bf(l,t,e),c;return a?c=R.near(a,1):e<0?c=R.near(n.doc.resolve(l.before(-1)),-1):c=R.near(n.doc.resolve(l.after(-1)),1),Ds(n,r,c)}}}function Is(t,e){return(n,r,s)=>{if(!s)return!1;let i=n.selection,o;if(i instanceof U)o=i;else{let a=Zf(s,t,e);if(a==null)return!1;o=new U(n.doc.resolve(a))}let l=Bf(o.$headCell,t,e);return l?Ds(n,r,new U(o.$anchorCell,l)):!1}}function lw(t,e){let n=t.state.doc,r=qt(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new U(r))),!0):!1}function aw(t,e,n){if(!$e(t.state))return!1;let r=nw(n),s=t.state.selection;if(s instanceof U){r||(r={width:1,height:1,rows:[w.from(Cl(de(t.state.schema).cell,n))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=J.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=sw(r,l.right-l.left,l.bottom-l.top),Df(t.state,t.dispatch,o,l,r),!0}else if(r){let i=Ps(t.state),o=i.start(-1);return Df(t.state,t.dispatch,o,J.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function cw(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Lf(t,e.target),s;if(e.shiftKey&&t.state.selection instanceof U)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=qt(t.state.selection.$anchor))!=null&&((n=bl(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=bl(t,c),d=St.getState(t.state)==null;if(!u||!Ml(a,u))if(d)u=a;else return;let f=new U(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(St,a.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),St.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(St,-1))}function l(a){let c=a,u=St.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Lf(t,c.target)!=r&&(d=bl(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Zf(t,e,n){if(!(t.state.selection instanceof M))return null;let{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function Lf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function bl(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&qt(t.state.doc.resolve(r))||qt(t.state.doc.resolve(s))}var uw=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),vl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,vl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function vl(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m++,f++){let g=s==f?i:p&&p[m],y=g?g+"px":"";if(o+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}var Me=new j("tableColumnResizing");function eh({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=uw,lastColumnResizable:s=!0}={}){let i=new L({key:Me,state:{init(o,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=de(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new dw(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{let l=Me.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{fw(o,l,t,s)},mouseleave:o=>{hw(o)},mousedown:(o,l)=>{pw(o,l,e,n)}},decorations:o=>{let l=Me.getState(o);if(l&&l.activeHandle>-1)return bw(o,l.activeHandle)},nodeViews:{}}});return i}var dw=class Ls{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Me);if(r&&r.setHandle!=null)return new Ls(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ls(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Sl(e.doc.resolve(s))||(s=-1),new Ls(s,n.dragging)}return n}};function fw(t,e,n,r){if(!t.editable)return;let s=Me.getState(t.state);if(s&&!s.dragging){let i=gw(e.target),o=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Pf(t,e,"left",n):a-e.clientX<=n&&(o=Pf(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){let l=t.state.doc.resolve(o),a=l.node(-1),c=J.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}th(t,o)}}}function hw(t){if(!t.editable)return;let e=Me.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&th(t,-1)}function pw(t,e,n,r){var s;if(!t.editable)return!1;let i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Me.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;let l=t.state.doc.nodeAt(o.activeHandle),a=mw(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Me,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=Me.getState(t.state);f?.dragging&&(yw(t,f.activeHandle,zf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Me,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Me.getState(t.state);if(f&&f.dragging){let h=zf(f.dragging,d,n);$f(t,f.activeHandle,h,r)}}return $f(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function mw(t,e,{colspan:n,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=t.domAtPos(e),o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function gw(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Pf(t,e,n,r){let s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;let{pos:o}=i,l=qt(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;let a=J.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function zf(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function th(t,e){t.dispatch(t.state.tr.setMeta(Me,{setHandle:e}))}function yw(t,e,n){let r=t.state.doc.resolve(e),s=r.node(-1),i=J.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=s.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():kw(f.colspan);p[h]=n,a.setNodeMarkup(o+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function $f(t,e,n,r){let s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=J.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&vl(i,a.firstChild,a,r,l,n)}function kw(t){return Array(t).fill(0)}function bw(t,e){let n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return _.empty;let i=J.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=o+d+s.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Me.getState(t))===null||a===void 0)&&a.dragging&&n.push(ne.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(ne.widget(f,h))}}return _.create(t.doc,n)}function nh({allowTableNodeSelection:t=!1}={}){return new L({key:St,state:{init(){return null},apply(e,n){let r=e.getMeta(St);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:Wb,handleDOMEvents:{mousedown:cw},createSelectionBetween(e){return St.getState(e.state)!=null?e.state.selection:null},handleTripleClick:lw,handleKeyDown:ow,handlePaste:aw},appendTransaction(e,n,r){return Ub(r,Tl(r,n),t)}})}function pr(t){return t==="left"||t==="right"||t==="center"?t:null}function ww(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return pr(e||n)}function xw(t){return pr(t?.align)}function lh(){return{default:null,parseHTML:t=>ww(t),renderHTML:t=>{let e=pr(t.align);return sf(e)?{style:`text-align: ${e}`}:{}}}}function Sw(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let s=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[s])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function ah(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):Sw(t)}var Cw=/[ \t\r\n\f]+/g;function ch(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(Cw,"")===""}function uh(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}function $s(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r==="1"||r===null||r===void 0)&&delete t[n]}var vw=K.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:ah},align:lh()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>ch(t)?{}:!1,getContent:(t,e)=>uh(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){let e=z(this.options.HTMLAttributes,t);return $s(e,t,"colspan"),$s(e,t,"rowspan"),["td",e,0]}}),Mw=K.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:ah},align:lh()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>ch(t)?{}:!1,getContent:(t,e)=>uh(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){let e=z(this.options.HTMLAttributes,t);return $s(e,t,"colspan"),$s(e,t,"rowspan"),["th",e,0]}}),Tw=K.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",z(this.options.HTMLAttributes,t),0]}});function Nl(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function rh(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=s===h?i:m&&m[g],k=y?`${y}px`:"";if(o+=y||r,y||(l=!1),a){if(a.style.width!==k){let[b,x]=Nl(r,y);a.style.setProperty(b,x)}a=a.nextSibling}else{let b=document.createElement("col"),[x,E]=Nl(r,y);b.style.setProperty(x,E),e.appendChild(b)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${o}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${o}px`)}var Aw=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),rh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.sameMarkup(this.node)?(this.node=t,rh(t,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Ew(t,e,n,r){let s=0,i=!0,o=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let m=n===d?r:h&&h[p];s+=m||e,m||(i=!1);let[g,y]=Nl(e,m);o.push(["col",{style:`${g}: ${y}`}])}}let a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function sh(t,e){return e?t.createChecked(null,e):t.createAndFill()}function Rw(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Nw(t,e,n,r,s){let i=Rw(t),o=[],l=[];for(let c=0;c<n;c+=1){let u=sh(i.cell,s);if(u&&l.push(u),r){let d=sh(i.header_cell,s);d&&o.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function dh(t){return t instanceof U}var zs=({editor:t})=>{let{selection:e}=t.state;if(!dh(e))return!1;let n=0,r=Mn(e.ranges[0].$from,s=>s.type.name==="table");return r?.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function ih(t,e){let n=t.mapping.map(e),r=Mn(t.selection.$from,o=>o.type.name==="table");if(r?.pos===n)return;let s=t.doc.nodeAt(n);if(!s)return;let i=n+s.nodeSize-1;t.setSelection(M.near(t.doc.resolve(i),-1))}function Ow(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let s=n+r,i=!1;for(;s<t.length;){if(t[s]!=="`"){s+=1;continue}let o=0;for(;s+o<t.length&&t[s+o]==="`";)o+=1;if(o===r){let l=t.slice(n+r,s);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(s,s+r),n=s+r,i=!0;break}s+=o}i||(e+=t.slice(n,n+r),n+=r)}return e}function Iw(t){return t.split(`
|
|
124
|
-
`).map(e=>!e.includes("|")||!e.includes("`")?e:
|
|
125
|
-
`)}function
|
|
126
|
-
`):t}function
|
|
127
|
-
`):m=
|
|
117
|
+
`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=s+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=zf(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
|
|
118
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function tw(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){let i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var nw=64;function Ef(t,e){let n=[],r=0;for(;n.length<e;){let s=t.indexOf(`
|
|
119
|
+
`,r);if(s===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,s)),r=s+1}return n}function rw(t){let e=t.indexOf(`
|
|
120
|
+
`),n=e===-1?t:t.slice(0,e);if(!Ds.test(n))return[[],0,[]];let r=nw,s=Ef(t,r),i=Af(s);for(;i[1]===s.length&&s.length===r;)r*=2,s=Ef(t,r),i=Af(s);return[i[0],i[1],s]}var sw="listItem",Rf="textStyle",Nf=/^(\d+)\.\s$/;function Of(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var iw=W.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let s=Of(n);if(s)return s}let r=t.querySelector("li");if(r){let s=r.getAttribute("style");if(s){let i=Of(s);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,s=D(this.options.HTMLAttributes,r);return e!==1&&(s.start=e),n&&n!=="1"&&(s.type=n),["ol",s,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,s=t.items?tw(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
121
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,s;let[i,o,l]=rw(t);if(i.length===0)return;let a=zf(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(s=i[0])===null||s===void 0?void 0:s.type,items:a,raw:l.slice(0,o).join(`
|
|
122
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sw,this.editor.getAttributes(Rf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new P({props:{handlePaste:(t,e)=>{var n,r;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(s?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let o=ew(i);if(!o)return!1;try{let l=t.state.schema.nodeFromJSON(o),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=Se({find:Nf,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Se({find:Nf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Rf)}),joinPredicate:t,editor:this.editor})),[e]}}),ow=/^\s*(\[([( |x])?\])\s$/,lw="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",aw=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},Cl=W.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",D(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return On(t,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[If(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=lw;let c=d=>{let f=aw(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=St(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?s.setAttribute(g,m[g]):s.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?s.setAttribute(g,m[g]):s.removeAttribute(g):s.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[Se({find:ow,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),vl=W.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",D(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
123
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let o=Nn(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(o){let l={type:"taskList",raw:o.raw,items:o.items},a=i.slice(o.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},s=Nn(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),$v=j.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Mb.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(jb.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(iw.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Cl.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(vl.configure(this.options.taskList)),t}});var Tl,Al;if(typeof WeakMap<"u"){let t=new WeakMap;Tl=e=>t.get(e),Al=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Tl=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Al=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var G=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,s=e/this.width|0,i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){let{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){let i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){let i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width,l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return Tl(t)||Al(t,cw(t))}};function cw(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=uw(t),n=t.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:k}=m.attrs;for(let b=0;b<y;b++){if(b+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-b});break}let x=s+b*e;for(let E=0;E<g;E++){r[x+E]==0?r[x+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-E});let C=k&&k[E];if(C){let T=(x+E)%e*2,L=o[T];L==null||L!=C&&o[T+1]==1?(o[T]=C,o[T+1]=1):L==C&&o[T+1]++}}}s+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new G(e,n,r,i),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&dw(l,o,t),l}function uw(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let s=t.child(r),i=0;if(n)for(let o=0;o<r;o++){let l=t.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function dw(t,e,n){t.problems||(t.problems=[]);let r={};for(let s=0;s<t.map.length;s++){let i=t.map[s];if(r[i])continue;r[i]=!0;let o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=o.attrs;for(let c=0;c<a.colspan;c++){let u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=fw(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function fw(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function de(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var Ct=new _("selectingCells");function Jt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function hw(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function He(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function js(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=Jt(e.$head)||pw(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function pw(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function El(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function mw(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ol(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function qf(t,e,n){let r=t.node(-1),s=G.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Gt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function Jf(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function gw(t,e,n){let r=de(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var U=class ot extends R{constructor(e,n=e){let r=e.node(-1),s=G.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new dn(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(El(r)&&El(s)&&Ol(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ot.rowSelection(r,s):i&&this.isColSelection()?ot.colSelection(r,s):new ot(r,s)}return M.between(r,s)}content(){let e=this.$anchorCell.node(-1),n=G.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){let c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Gt(y,0,m)),g>0&&(y=Gt(y,y.colspan-g,g)),h.left<s.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(a).copy(w.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:o;return new v(w.from(l),1,1)}replace(e,n=v.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?v.empty:n)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new v(w.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=G.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),s=G.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new ot(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=G.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;let o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),s=G.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new ot(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new ot(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new ot(e.resolve(n),e.resolve(r))}getBookmark(){return new yw(this.$anchorCell.pos,this.$headCell.pos)}};U.prototype.visible=!1;R.jsonID("cell",U);var yw=class Gf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Gf(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ol(n,r)?new U(n,r):R.near(r,1)}};function kw(t){if(!(t.selection instanceof U))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ne.node(r,r+n.nodeSize,{class:"selectedCell"}))}),V.create(t.doc,e)}function bw({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function ww({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){let i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function xw(t,e,n){let r=(e||t).selection,s=(e||t).doc,i,o;if(r instanceof N&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=U.create(s,r.from);else if(o=="row"){let l=s.resolve(r.from+1);i=U.rowSelection(l,l)}else if(!n){let l=G.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=U.create(s,a+1,c)}}else r instanceof M&&bw(r)?i=M.create(s,r.from):r instanceof M&&ww(r)&&(i=M.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var Sw=new _("fix-tables");function Xf(t,e,n,r){let s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){let a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?Xf(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Il(t,e){let n,r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=Cw(t,s,i,n))};return e?e.doc!=t.doc&&Xf(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Cw(t,e,n,r){let s=G.get(e);if(!s.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){let c=s.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Gt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=de(t.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(Sw,{fixTables:!0})}function Ue(t){let e=t.selection,n=js(t),r=n.node(-1),s=n.start(-1),i=G.get(r);return{...e instanceof U?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function Yf(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;gw(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,Jf(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=i==null?de(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function Qf(t,e){if(!He(t))return!1;if(e){let n=Ue(t);e(Yf(t.tr,n,n.left))}return!0}function Zf(t,e){if(!He(t))return!1;if(e){let n=Ue(t);e(Yf(t.tr,n,n.right))}return!0}function vw(t,{map:e,table:n,tableStart:r},s){let i=t.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Gt(u,s-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function eh(t,e){if(!He(t))return!1;if(e){let n=Ue(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;vw(r,n,s),s!=n.left;s--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=G.get(i)}e(r)}return!0}function Mw(t,e,n){var r;let s=de(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function th(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;let o=[],l=s>0?-1:0;Mw(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?de(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&o.push(f)}return t.insert(i,de(r.type.schema).row.create(null,o)),t}function nh(t,e){if(!He(t))return!1;if(e){let n=Ue(t);e(th(t.tr,n,n.top))}return!0}function rh(t,e){if(!He(t))return!1;if(e){let n=Ue(t);e(th(t.tr,n,n.bottom))}return!0}function Tw(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;let o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);let a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function sh(t,e){if(!He(t))return!1;if(e){let n=Ue(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;Tw(r,n,s),s!=n.top;s--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=G.get(n.table)}e(r)}return!0}function Bf(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Aw({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Ll(t,e){let n=t.selection;if(!(n instanceof U)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Ue(t),{map:s}=r;if(Aw(s,r))return!1;if(e){let i=t.tr,o={},l=w.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=s.map[u*s.width+d],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{Bf(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Jf(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Bf(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new U(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Dl(t,e){let n=de(t.schema);return Ew(({node:r})=>n[r.type.spec.tableRole])(t,e)}function Ew(t){return(e,n)=>{let r=e.selection,s,i;if(r instanceof U){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=hw(r.$from),!s)return!1;i=(o=Jt(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=Ue(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:s,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof U&&d.setSelection(new U(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function ih(t,e){return function(n,r){if(!He(n))return!1;let s=js(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof U?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function Rw(t){return function(e,n){if(!He(e))return!1;if(n){let r=de(e.schema),s=Ue(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Hf(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){let i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Dn(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Rw(t):function(n,r){if(!He(n))return!1;if(r){let s=de(n.schema),i=Ue(n),o=n.tr,l=Hf("row",i,s),a=Hf("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,d,p.attrs)}),r(o)}return!0}}var Wv=Dn("row",{useDeprecatedLogic:!0}),Vv=Dn("column",{useDeprecatedLogic:!0}),oh=Dn("cell",{useDeprecatedLogic:!0});function Nw(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){let i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Pl(t){return function(e,n){if(!He(e))return!1;let r=Nw(js(e),t);if(r==null)return!1;if(n){let s=e.doc.resolve(r);n(e.tr.setSelection(M.between(s,mw(s))).scrollIntoView())}return!0}}function lh(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function zs(t,e){let n=t.selection;if(!(n instanceof U))return!1;if(e){let r=t.tr,s=de(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new v(s,0,0))}),r.docChanged&&e(r)}return!0}function Ow(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Rl(de(o).row,new v(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Rl(de(o).row,new v(e,n,r)).content:e);else return null;return Iw(o,l)}function Iw(t,e){let n=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(w.empty),n[s]<r){let i=de(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(w.from(o))}return{height:e.length,width:r,rows:e}}function Rl(t,e){let n=t.createAndFill();return new ht(n).replace(0,n.content.size,e).doc}function Lw({width:t,height:e,rows:n},r,s){if(t!=r){let i=[],o=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Gt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(w.from(c))}n=o,t=r}if(e!=s){let i=[];for(let o=0,l=0;o<s;o++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(w.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function Dw(t,e,n,r,s,i,o){let l=t.doc.type.schema,a=de(l),c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,w.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||u)}function Ff(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:o-h}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function _f(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Gt(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Gt(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function jf(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=G.get(i),{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=G.get(i),f=d.mapping.maps.length}Dw(d,o,i,n,c,u,f)&&h(),Ff(d,o,i,n,a,c,l,f)&&h(),Ff(d,o,i,n,a,c,u,f)&&h(),_f(d,o,i,n,l,u,a,f)&&h(),_f(d,o,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=o.positionAt(p,a,i),g=o.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+n),d.mapping.slice(f).map(g+n),new v(s.rows[p-l],0,0))}h(),d.setSelection(new U(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}var Pw=fr({ArrowLeft:Bs("horiz",-1),ArrowRight:Bs("horiz",1),ArrowUp:Bs("vert",-1),ArrowDown:Bs("vert",1),"Shift-ArrowLeft":Hs("horiz",-1),"Shift-ArrowRight":Hs("horiz",1),"Shift-ArrowUp":Hs("vert",-1),"Shift-ArrowDown":Hs("vert",1),Backspace:zs,"Mod-Backspace":zs,Delete:zs,"Mod-Delete":zs});function Fs(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Bs(t,e){return(n,r,s)=>{if(!s)return!1;let i=n.selection;if(i instanceof U)return Fs(n,r,R.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let o=ah(s,t,e);if(o==null)return!1;if(t=="horiz")return Fs(n,r,R.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(o),a=qf(l,t,e),c;return a?c=R.near(a,1):e<0?c=R.near(n.doc.resolve(l.before(-1)),-1):c=R.near(n.doc.resolve(l.after(-1)),1),Fs(n,r,c)}}}function Hs(t,e){return(n,r,s)=>{if(!s)return!1;let i=n.selection,o;if(i instanceof U)o=i;else{let a=ah(s,t,e);if(a==null)return!1;o=new U(n.doc.resolve(a))}let l=qf(o.$headCell,t,e);return l?Fs(n,r,new U(o.$anchorCell,l)):!1}}function $w(t,e){let n=t.state.doc,r=Jt(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new U(r))),!0):!1}function zw(t,e,n){if(!He(t.state))return!1;let r=Ow(n),s=t.state.selection;if(s instanceof U){r||(r={width:1,height:1,rows:[w.from(Rl(de(t.state.schema).cell,n))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=G.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=Lw(r,l.right-l.left,l.bottom-l.top),jf(t.state,t.dispatch,o,l,r),!0}else if(r){let i=js(t.state),o=i.start(-1);return jf(t.state,t.dispatch,o,G.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function Bw(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Wf(t,e.target),s;if(e.shiftKey&&t.state.selection instanceof U)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Jt(t.state.selection.$anchor))!=null&&((n=Ml(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Ml(t,c),d=Ct.getState(t.state)==null;if(!u||!Ol(a,u))if(d)u=a;else return;let f=new U(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(Ct,a.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),Ct.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ct,-1))}function l(a){let c=a,u=Ct.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Wf(t,c.target)!=r&&(d=Ml(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function ah(t,e,n){if(!(t.state.selection instanceof M))return null;let{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function Wf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ml(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Jt(t.state.doc.resolve(r))||Jt(t.state.doc.resolve(s))}var Hw=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Nl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Nl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Nl(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m++,f++){let g=s==f?i:p&&p[m],y=g?g+"px":"";if(o+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}var Ae=new _("tableColumnResizing");function ch({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=Hw,lastColumnResizable:s=!0}={}){let i=new P({key:Ae,state:{init(o,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=de(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new Fw(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{let l=Ae.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{_w(o,l,t,s)},mouseleave:o=>{jw(o)},mousedown:(o,l)=>{Ww(o,l,e,n)}},decorations:o=>{let l=Ae.getState(o);if(l&&l.activeHandle>-1)return Jw(o,l.activeHandle)},nodeViews:{}}});return i}var Fw=class _s{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Ae);if(r&&r.setHandle!=null)return new _s(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new _s(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return El(e.doc.resolve(s))||(s=-1),new _s(s,n.dragging)}return n}};function _w(t,e,n,r){if(!t.editable)return;let s=Ae.getState(t.state);if(s&&!s.dragging){let i=Kw(e.target),o=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Vf(t,e,"left",n):a-e.clientX<=n&&(o=Vf(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){let l=t.state.doc.resolve(o),a=l.node(-1),c=G.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}uh(t,o)}}}function jw(t){if(!t.editable)return;let e=Ae.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&uh(t,-1)}function Ww(t,e,n,r){var s;if(!t.editable)return!1;let i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Ae.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;let l=t.state.doc.nodeAt(o.activeHandle),a=Vw(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ae,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=Ae.getState(t.state);f?.dragging&&(Uw(t,f.activeHandle,Kf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Ae,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Ae.getState(t.state);if(f&&f.dragging){let h=Kf(f.dragging,d,n);Uf(t,f.activeHandle,h,r)}}return Uf(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function Vw(t,e,{colspan:n,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=t.domAtPos(e),o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function Kw(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Vf(t,e,n,r){let s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;let{pos:o}=i,l=Jt(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;let a=G.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Kf(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function uh(t,e){t.dispatch(t.state.tr.setMeta(Ae,{setHandle:e}))}function Uw(t,e,n){let r=t.state.doc.resolve(e),s=r.node(-1),i=G.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=s.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():qw(f.colspan);p[h]=n,a.setNodeMarkup(o+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function Uf(t,e,n,r){let s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=G.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Nl(i,a.firstChild,a,r,l,n)}function qw(t){return Array(t).fill(0)}function Jw(t,e){let n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return V.empty;let i=G.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=o+d+s.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Ae.getState(t))===null||a===void 0)&&a.dragging&&n.push(ne.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(ne.widget(f,h))}}return V.create(t.doc,n)}function dh({allowTableNodeSelection:t=!1}={}){return new P({key:Ct,state:{init(){return null},apply(e,n){let r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:kw,handleDOMEvents:{mousedown:Bw},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:$w,handleKeyDown:Pw,handlePaste:zw},appendTransaction(e,n,r){return xw(r,Il(r,n),t)}})}function br(t){return t==="left"||t==="right"||t==="center"?t:null}function Gw(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return br(e||n)}function Xw(t){return br(t?.align)}function gh(){return{default:null,parseHTML:t=>Gw(t),renderHTML:t=>{let e=br(t.align);return pf(e)?{style:`text-align: ${e}`}:{}}}}function Yw(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let s=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[s])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function yh(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):Yw(t)}var Qw=/[ \t\r\n\f]+/g;function kh(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(Qw,"")===""}function bh(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}function Vs(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r==="1"||r===null||r===void 0)&&delete t[n]}var Zw=W.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:yh},align:gh()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>kh(t)?{}:!1,getContent:(t,e)=>bh(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){let e=D(this.options.HTMLAttributes,t);return Vs(e,t,"colspan"),Vs(e,t,"rowspan"),["td",e,0]}}),ex=W.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:yh},align:gh()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>kh(t)?{}:!1,getContent:(t,e)=>bh(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){let e=D(this.options.HTMLAttributes,t);return Vs(e,t,"colspan"),Vs(e,t,"rowspan"),["th",e,0]}}),tx=W.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",D(this.options.HTMLAttributes,t),0]}});function $l(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function fh(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=s===h?i:m&&m[g],k=y?`${y}px`:"";if(o+=y||r,y||(l=!1),a){if(a.style.width!==k){let[b,x]=$l(r,y);a.style.setProperty(b,x)}a=a.nextSibling}else{let b=document.createElement("col"),[x,E]=$l(r,y);b.style.setProperty(x,E),e.appendChild(b)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${o}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${o}px`)}var nx=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),fh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.sameMarkup(this.node)?(this.node=t,fh(t,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function rx(t,e,n,r){let s=0,i=!0,o=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let m=n===d?r:h&&h[p];s+=m||e,m||(i=!1);let[g,y]=$l(e,m);o.push(["col",{style:`${g}: ${y}`}])}}let a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function hh(t,e){return e?t.createChecked(null,e):t.createAndFill()}function sx(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function ix(t,e,n,r,s){let i=sx(t),o=[],l=[];for(let c=0;c<n;c+=1){let u=hh(i.cell,s);if(u&&l.push(u),r){let d=hh(i.header_cell,s);d&&o.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function wh(t){return t instanceof U}var Ws=({editor:t})=>{let{selection:e}=t.state;if(!wh(e))return!1;let n=0,r=An(e.ranges[0].$from,s=>s.type.name==="table");return r?.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function ph(t,e){let n=t.mapping.map(e),r=An(t.selection.$from,o=>o.type.name==="table");if(r?.pos===n)return;let s=t.doc.nodeAt(n);if(!s)return;let i=n+s.nodeSize-1;t.setSelection(M.near(t.doc.resolve(i),-1))}function ox(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let s=n+r,i=!1;for(;s<t.length;){if(t[s]!=="`"){s+=1;continue}let o=0;for(;s+o<t.length&&t[s+o]==="`";)o+=1;if(o===r){let l=t.slice(n+r,s);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(s,s+r),n=s+r,i=!0;break}s+=o}i||(e+=t.slice(n,n+r),n+=r)}return e}function lx(t){return t.split(`
|
|
124
|
+
`).map(e=>!e.includes("|")||!e.includes("`")?e:ox(e)).join(`
|
|
125
|
+
`)}function ax(t){return(t||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function mh(t,e){return e?t.split(e).join(`
|
|
126
|
+
`):t}function cx(t){return t.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function ux(t,e,n={}){if(!t||!t.content||t.content.length===0)return"";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let m="";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(b=>mh(e.renderChildren(b),n.cellLineSeparator)).join(`
|
|
127
|
+
`):m=mh(p.content?e.renderChildren(p.content):"",n.cellLineSeparator);let g=cx(ax(m.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),y=p.type==="tableHeader",k=Xw(p.attrs);h.push({text:g,isHeader:y,align:k})}),r.push(h)});let s=r.reduce((f,h)=>Math.max(f,h.length),0);if(s===0)return"";let i=Array.from({length:s}).fill(0);r.forEach(f=>{for(let p=0;p<s;p+=1){var h;let m=(((h=f[p])===null||h===void 0?void 0:h.text)||"").length;m>i[p]&&(i[p]=m),i[p]<3&&(i[p]=3)}});let o=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:s}).fill(null);r.forEach(f=>{for(let p=0;p<s;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`
|
|
128
128
|
`,d=Array.from({length:s}).map((f,h)=>a&&l[h]&&l[h].text||"");return u+=`| ${d.map((f,h)=>o(f,i[h])).join(" | ")} |
|
|
129
129
|
`,u+=`| ${i.map((f,h)=>{let p=Math.max(3,f),m=c[h];return m==="left"?`:${"-".repeat(p)}`:m==="right"?`${"-".repeat(p)}:`:m==="center"?`:${"-".repeat(p)}:`:"-".repeat(p)}).join(" | ")} |
|
|
130
130
|
`,(a?r.slice(1):r).forEach(f=>{u+=`| ${Array.from({length:s}).fill(0).map((h,p)=>o(f[p]&&f[p].text||"",i[p])).join(" | ")} |
|
|
131
|
-
`}),u}var
|
|
131
|
+
`}),u}var dx=new _("preserveCellSelectionOnContextMenu");function fx(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function hx(t,e){let n=!1;return t.forEachCell((r,s)=>{e>=s&&e<s+r.nodeSize&&(n=!0)}),n}function px(){return new P({key:dx,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!wh(n)||n.ranges.length<2)return!1;let r=fx(t,e);return r==null||!hx(n,r)?!1:(e.preventDefault(),!0)}}}})}var mx=W.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:nx,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:s}=rx(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}let l=["table",D(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let s=[];t.header.forEach((i,o)=>{var l;let a=br((l=r[o])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};s.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{let i=[];s.forEach((o,l)=>{var a;let c=br((a=r[l])!==null&&a!==void 0?a:o.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>ux(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{let e=t.split(`
|
|
132
132
|
`);if(e.length<2)return-1;let n=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(t,e,n){let r=t.indexOf(`
|
|
133
133
|
|
|
134
134
|
`),s=r>=0?t.slice(0,r):t,i=s.split(`
|
|
135
|
-
`);if(i.length<2)return;let o=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;let l=
|
|
135
|
+
`);if(i.length<2)return;let o=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;let l=lx(s);if(l===s)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
|
|
136
136
|
`).length,u=t.split(`
|
|
137
137
|
`).slice(0,c).join(`
|
|
138
|
-
`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{let o=
|
|
139
|
-
]`).replace("lheading",
|
|
138
|
+
`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{let o=ix(i.schema,t,e,n);if(s){let l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qf(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Zf(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=An(t.selection.$from,r=>r.type.name==="table");return eh(t,e&&(r=>{n&&ph(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>nh(t,e),addRowAfter:()=>({state:t,dispatch:e})=>rh(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=An(t.selection.$from,r=>r.type.name==="table");return sh(t,e&&(r=>{n&&ph(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>lh(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ll(t,e),splitCell:()=>({state:t,dispatch:e})=>Dl(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Dn("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Dn("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>oh(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ll(t,e)?!0:Dl(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>ih(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Pl(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Pl(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Il(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=U.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ws,"Mod-Backspace":Ws,Delete:Ws,"Mod-Delete":Ws}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ch({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],dh({allowTableNodeSelection:this.options.allowTableNodeSelection}),px()]},addNodeView(){let t=this.options.View;return t?({node:e,view:n,HTMLAttributes:r})=>{let s=D(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,s)}:null},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:B(A(t,"tableRole",e))}}}),xh=j.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(mx.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Zw.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(ex.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(tx.configure(this.options.tableRow)),t}});function Fl(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Qt=Fl();function Eh(t){Qt=t}var Xt={exec:()=>null};function H(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(be.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var gx=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),be={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},yx=/^(?:[ \t]*(?:\n|$))+/,kx=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bx=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Cr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,wx=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_l=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Rh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Nh=H(Rh).replace(/bull/g,_l).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),xx=H(Rh).replace(/bull/g,_l).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),jl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Sx=/^[^\n]+/,Wl=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Cx=H(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),vx=H(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_l).getRegex(),Gs="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vl=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Mx=H("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vl).replace("tag",Gs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Oh=H(jl).replace("hr",Cr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),Tx=H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Oh).getRegex(),Kl={blockquote:Tx,code:kx,def:Cx,fences:bx,heading:wx,hr:Cr,html:Mx,lheading:Nh,list:vx,newline:yx,paragraph:Oh,table:Xt,text:Sx},Sh=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Cr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),Ax={...Kl,lheading:xx,table:Sh,paragraph:H(jl).replace("hr",Cr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Sh).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex()},Ex={...Kl,html:H(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vl).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Xt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H(jl).replace("hr",Cr).replace("heading",` *#{1,6} *[^
|
|
139
|
+
]`).replace("lheading",Nh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Rx=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nx=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ih=/^( {2,}|\\)\n(?!\s*$)/,Ox=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pn=/[\p{P}\p{S}]/u,Xs=/[\s\p{P}\p{S}]/u,Ul=/[^\s\p{P}\p{S}]/u,Ix=H(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xs).getRegex(),Lh=/(?!~)[\p{P}\p{S}]/u,Lx=/(?!~)[\s\p{P}\p{S}]/u,Dx=/(?:[^\s\p{P}\p{S}]|~)/u,Px=H(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",gx?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Dh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$x=H(Dh,"u").replace(/punct/g,Pn).getRegex(),zx=H(Dh,"u").replace(/punct/g,Lh).getRegex(),Ph="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Bx=H(Ph,"gu").replace(/notPunctSpace/g,Ul).replace(/punctSpace/g,Xs).replace(/punct/g,Pn).getRegex(),Hx=H(Ph,"gu").replace(/notPunctSpace/g,Dx).replace(/punctSpace/g,Lx).replace(/punct/g,Lh).getRegex(),Fx=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ul).replace(/punctSpace/g,Xs).replace(/punct/g,Pn).getRegex(),_x=H(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Pn).getRegex(),jx="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Wx=H(jx,"gu").replace(/notPunctSpace/g,Ul).replace(/punctSpace/g,Xs).replace(/punct/g,Pn).getRegex(),Vx=H(/\\(punct)/,"gu").replace(/punct/g,Pn).getRegex(),Kx=H(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ux=H(Vl).replace("(?:-->|$)","-->").getRegex(),qx=H("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ux).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Us=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Jx=H(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Us).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),$h=H(/^!?\[(label)\]\[(ref)\]/).replace("label",Us).replace("ref",Wl).getRegex(),zh=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wl).getRegex(),Gx=H("reflink|nolink(?!\\()","g").replace("reflink",$h).replace("nolink",zh).getRegex(),Ch=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ql={_backpedal:Xt,anyPunctuation:Vx,autolink:Kx,blockSkip:Px,br:Ih,code:Nx,del:Xt,delLDelim:Xt,delRDelim:Xt,emStrongLDelim:$x,emStrongRDelimAst:Bx,emStrongRDelimUnd:Fx,escape:Rx,link:Jx,nolink:zh,punctuation:Ix,reflink:$h,reflinkSearch:Gx,tag:qx,text:Ox,url:Xt},Xx={...ql,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",Us).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Us).getRegex()},zl={...ql,emStrongRDelimAst:Hx,emStrongLDelim:zx,delLDelim:_x,delRDelim:Wx,url:H(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ch).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:H(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ch).getRegex()},Yx={...zl,br:H(Ih).replace("{2,}","*").getRegex(),text:H(zl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ks={normal:Kl,gfm:Ax,pedantic:Ex},wr={normal:ql,gfm:zl,breaks:Yx,pedantic:Xx},Qx={"&":"&","<":"<",">":">",'"':""","'":"'"},vh=t=>Qx[t];function qe(t,e){if(e){if(be.escapeTest.test(t))return t.replace(be.escapeReplace,vh)}else if(be.escapeTestNoEncode.test(t))return t.replace(be.escapeReplaceNoEncode,vh);return t}function Mh(t){try{t=encodeURI(t).replace(be.percentDecode,"%")}catch{return null}return t}function Th(t,e){let n=t.replace(be.findPipe,(i,o,l)=>{let a=!1,c=o;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),r=n.split(be.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(be.slashPipe,"|");return r}function xr(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r;){let i=t.charAt(r-s-1);if(i===e&&!n)s++;else if(i!==e&&n)s++;else break}return t.slice(0,r-s)}function Zx(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function e1(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function Ah(t,e,n,r,s){let i=e.href,o=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,a}function t1(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
140
140
|
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[l]=o;return l.length>=s.length?i.slice(s.length):i}).join(`
|
|
141
|
-
`)}var
|
|
142
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=
|
|
143
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
141
|
+
`)}var qs=class{options;rules;lexer;constructor(t){this.options=t||Qt}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:xr(n,`
|
|
142
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=t1(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=xr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:xr(e[0],`
|
|
143
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=xr(e[0],`
|
|
144
144
|
`).split(`
|
|
145
145
|
`),r="",s="",i=[];for(;n.length>0;){let o=!1,l=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),o=!0;else if(!o)l.push(n[a]);else break;n=n.slice(a);let c=l.join(`
|
|
146
146
|
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -151,17 +151,17 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
151
151
|
`),m=this.blockquote(p);i[i.length-1]=m,r=r.substring(0,r.length-h.raw.length)+m.raw,s=s.substring(0,s.length-h.text.length)+m.text;break}else if(f?.type==="list"){let h=f,p=h.raw+`
|
|
152
152
|
`+n.join(`
|
|
153
153
|
`),m=this.list(p);i[i.length-1]=m,r=r.substring(0,r.length-f.raw.length)+m.raw,s=s.substring(0,s.length-h.raw.length)+m.raw,n=p.substring(i.at(-1).raw.length).split(`
|
|
154
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;t;){let a=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=
|
|
154
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;t;){let a=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=e1(e[2].split(`
|
|
155
155
|
`,1)[0],e[1].length),f=t.split(`
|
|
156
156
|
`,1)[0],h=!d.trim(),p=0;if(this.options.pedantic?(p=2,u=d.trimStart()):h?p=e[1].length+1:(p=d.search(this.rules.other.nonSpaceChar),p=p>4?1:p,u=d.slice(p),p+=e[1].length),h&&this.rules.other.blankLine.test(f)&&(c+=f+`
|
|
157
157
|
`,t=t.substring(f.length+1),a=!0),!a){let m=this.rules.other.nextBulletRegex(p),g=this.rules.other.hrRegex(p),y=this.rules.other.fencesBeginRegex(p),k=this.rules.other.headingBeginRegex(p),b=this.rules.other.htmlBeginRegex(p),x=this.rules.other.blockquoteBeginRegex(p);for(;t;){let E=t.split(`
|
|
158
158
|
`,1)[0],C;if(f=E,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),C=f):C=f.replace(this.rules.other.tabCharGlobal," "),y.test(f)||k.test(f)||b.test(f)||x.test(f)||m.test(f)||g.test(f))break;if(C.search(this.rules.other.nonSpaceChar)>=p||!f.trim())u+=`
|
|
159
159
|
`+C.slice(p);else{if(h||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(d)||k.test(d)||g.test(d))break;u+=`
|
|
160
160
|
`+f}h=!f.trim(),c+=E+`
|
|
161
|
-
`,t=t.substring(E.length+1),d=C.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),s.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),s.raw+=c}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let a of s.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,s.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!s.loose){let c=a.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=u}}if(s.loose)for(let a of s.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=
|
|
162
|
-
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of s)i.rows.push(
|
|
163
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=
|
|
164
|
-
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(
|
|
161
|
+
`,t=t.substring(E.length+1),d=C.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),s.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),s.raw+=c}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let a of s.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,s.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!s.loose){let c=a.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=u}}if(s.loose)for(let a of s.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Th(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
162
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of s)i.rows.push(Th(o,i.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[a]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
163
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=xr(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Zx(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Ah(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Ah(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,l=s,a=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){l+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){a+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+a);let u=[...r[0]][0].length,d=t.slice(0,s+r.index+u+o);if(Math.min(s,o)%2){let h=d.slice(1,-1);return{type:"em",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}let f=d.slice(2,-2);return{type:"strong",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,l=s,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*t.length+s);(r=a.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let c=[...r[0]][0].length,u=t.slice(0,s+r.index+c+o),d=u.slice(s,-s);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Fe=class Bl{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Qt,this.options.tokenizer=this.options.tokenizer||new qs,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:be,block:Ks.normal,inline:wr.normal};this.options.pedantic?(n.block=Ks.pedantic,n.inline=wr.pedantic):this.options.gfm&&(n.block=Ks.gfm,this.options.breaks?n.inline=wr.breaks:n.inline=wr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ks,inline:wr}}static lex(e,n){return new Bl(n).lex(e)}static lexInline(e,n){return new Bl(n).inlineTokens(e)}lex(e){e=e.replace(be.carriageReturn,`
|
|
164
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(be.tabCharGlobal," ").replace(be.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(o=>(s=o.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let o=n.at(-1);s.raw.length===1&&o!==void 0?o.raw+=`
|
|
165
165
|
`:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
166
166
|
`)?"":`
|
|
167
167
|
`)+s.raw,o.text+=`
|
|
@@ -174,9 +174,9 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
174
174
|
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
175
175
|
`)?"":`
|
|
176
176
|
`)+s.raw,o.text+=`
|
|
177
|
-
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,l="";for(;e;){o||(l=""),o=!1;let a;if(this.options.extensions?.inline?.some(u=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let u=n.at(-1);a.type==="text"&&u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,d=e.slice(1),f;this.options.extensions.startInline.forEach(h=>{f=h.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),o=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},
|
|
178
|
-
`;return r?'<pre><code class="language-'+
|
|
179
|
-
`:"<pre><code>"+(n?s:
|
|
177
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,l="";for(;e;){o||(l=""),o=!1;let a;if(this.options.extensions?.inline?.some(u=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let u=n.at(-1);a.type==="text"&&u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,d=e.slice(1),f;this.options.extensions.startInline.forEach(h=>{f=h.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),o=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},Js=class{options;parser;constructor(t){this.options=t||Qt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(be.notSpaceStart)?.[0],s=t.replace(be.endingNewline,"")+`
|
|
178
|
+
`;return r?'<pre><code class="language-'+qe(r)+'">'+(n?s:qe(s,!0))+`</code></pre>
|
|
179
|
+
`:"<pre><code>"+(n?s:qe(s,!0))+`</code></pre>
|
|
180
180
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
181
181
|
${this.parser.parse(t)}</blockquote>
|
|
182
182
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -192,29 +192,29 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
192
192
|
`}tablerow({text:t}){return`<tr>
|
|
193
193
|
${t}</tr>
|
|
194
194
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
195
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${
|
|
196
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+
|
|
195
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${qe(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=Mh(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+qe(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=Mh(t);if(s===null)return qe(n);t=s;let i=`<img src="${t}" alt="${qe(n)}"`;return e&&(i+=` title="${qe(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:qe(t.text)}},Jl=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},_e=class Hl{options;renderer;textRenderer;constructor(e){this.options=e||Qt,this.options.renderer=this.options.renderer||new Js,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jl}static parse(e,n){return new Hl(n).parse(e)}static parseInline(e,n){return new Hl(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let o=s,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let i=s;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=l||"";continue}}let o=i;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},Sr=class{options;block;constructor(t){this.options=t||Qt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Fe.lex:Fe.lexInline}provideParser(t=this.block){return t?_e.parse:_e.parseInline}},n1=class{defaults=Fl();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=_e;Renderer=Js;TextRenderer=Jl;Lexer=Fe;Tokenizer=qs;Hooks=Sr;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let o=s[i].flat(1/0);n=n.concat(this.walkTokens(o,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new Js(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=n.renderer[o],a=s[o];s[o]=(...c)=>{let u=l.apply(s,c);return u===!1&&(u=a.apply(s,c)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new qs(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=n.tokenizer[o],a=s[o];s[o]=(...c)=>{let u=l.apply(s,c);return u===!1&&(u=a.apply(s,c)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Sr;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=n.hooks[o],a=s[o];Sr.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&Sr.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await l.call(s,c);return a.call(s,d)})();let u=l.call(s,c);return a.call(s,u)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await l.apply(s,c);return d===!1&&(d=await a.apply(s,c)),d})();let u=l.apply(s,c);return u===!1&&(u=a.apply(s,c)),u}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Fe.lex(t,e??this.defaults)}parser(t,e){return _e.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,l=await(s.hooks?await s.hooks.provideLexer(t):t?Fe.lex:Fe.lexInline)(o,s),a=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(a,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser(t):t?_e.parse:_e.parseInline)(a,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer(t):t?Fe.lex:Fe.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let l=(s.hooks?s.hooks.provideParser(t):t?_e.parse:_e.parseInline)(o,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
196
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+qe(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Yt=new n1;function K(t,e){return Yt.parse(t,e)}K.options=K.setOptions=function(t){return Yt.setOptions(t),K.defaults=Yt.defaults,Eh(K.defaults),K};K.getDefaults=Fl;K.defaults=Qt;K.use=function(...t){return Yt.use(...t),K.defaults=Yt.defaults,Eh(K.defaults),K};K.walkTokens=function(t,e){return Yt.walkTokens(t,e)};K.parseInline=Yt.parseInline;K.Parser=_e;K.parser=_e.parse;K.Renderer=Js;K.TextRenderer=Jl;K.Lexer=Fe;K.lexer=Fe.lex;K.Tokenizer=qs;K.Hooks=Sr;K.parse=K;var tM=K.options,nM=K.setOptions,rM=K.use,sM=K.walkTokens,iM=K.parseInline;var oM=_e.parse,lM=Fe.lex;var r1=/\n[^\S\n]*(?:\n[^\S\n]*)+$/;function s1(t){return t.flatMap((e,n)=>{var r;if(e.type==="space"||((r=t[n+1])===null||r===void 0?void 0:r.type)==="space")return[e];let s=(e.raw||"").match(r1);return s?[{...e,raw:(e.raw||"").slice(0,-s[0].length)},{type:"space",raw:s[0]}]:[e]})}function i1(t,e){let n=e.split(`
|
|
197
197
|
`).flatMap(r=>[r,""]).map(r=>`${t}${r}`).join(`
|
|
198
|
-
`);return n.slice(0,n.length-1)}function
|
|
198
|
+
`);return n.slice(0,n.length-1)}function Bh(t,e){let n=[];return Array.from(t.entries()).forEach(([r,s])=>{if(!e){n.push(r);return}(e.marks||[]).find(i=>i.type===r&&qt(i.attrs,s.attrs))||n.push(r)}),n}function o1(t,e){let n=[];return Array.from(e.entries()).forEach(([r,s])=>{let i=t.get(r);(!i||!qt(i.attrs,s.attrs))&&n.push({type:r,mark:s})}),n}function l1(t,e,n,r){let s=!n,i=n&&(!n.marks||n.marks.length===0),o=n&&n.marks&&!r(e,new Map(n.marks.map(a=>[a.type,a]))),l=[];return(s||i||o)&&(n&&n.marks?Array.from(t.entries()).reverse().forEach(([a,c])=>{n.marks.find(u=>u.type===a&&qt(u.attrs,c.attrs))||l.push(a)}):(s||i)&&l.push(...Array.from(t.keys()).reverse())),l}function a1(t,e){let n="";return Array.from(t.keys()).reverse().forEach(r=>{let s=e(r,t.get(r));s&&(n=s+n)}),t.clear(),n}function c1(t,e,n){let r="";return Array.from(t.entries()).forEach(([s,i])=>{let o=n(s,i);o&&(r+=o),e.set(s,i)}),r}function Gl(t){let e=(t.raw||t.text||"").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return e?{isTask:!0,checked:e[2].toLowerCase()==="x",indentLevel:e[1].length}:{isTask:!1,indentLevel:0}}function Ys(t,e){return typeof t!="string"?"json":e}function u1(t){let e=t.map(()=>new Map),n=new Map,r=s=>{let i=n.get(s);i&&(i.indexes.forEach(o=>e[o].set(s,i.text)),n.delete(s))};return t.forEach((s,i)=>{if(s.type!=="text"){Array.from(n.keys()).forEach(r);return}let o=new Set((s.marks||[]).map(l=>l.type));Array.from(n.keys()).filter(l=>!o.has(l)).forEach(r),o.forEach(l=>{let a=n.get(l)||{indexes:[],text:""};a.indexes.push(i),a.text+=s.text||"",n.set(l,a)})}),Array.from(n.keys()).forEach(r),e}var d1=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","mask","path","polygon","polyline","radialgradient","rect","stop","switch","symbol","textpath","tspan","use","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),f1=/<\/?([a-zA-Z][\w-]*)/g;function h1(t){let e=[],n;for(;(n=f1.exec(t))!==null;)e.push(n[1].toLowerCase());return e}function p1(t){let e=t.toLowerCase();return e.includes("-")?!1:!d1.has(e)}function m1(t,e){return h1(t).some(n=>p1(n)?!e.has(n):!1)}var Hh=class{constructor(t){var e,n,r,s,i;this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.schemaParseDomTagsCache=null,this.inlineNodeTypesCache=null,this.lastParseResult=null,this.markedInstance=(e=t?.marked)!==null&&e!==void 0?e:K,this.indentStyle=(n=t==null||(r=t.indentation)===null||r===void 0?void 0:r.style)!==null&&n!==void 0?n:"space",this.indentSize=(s=t==null||(i=t.indentation)===null||i===void 0?void 0:i.size)!==null&&s!==void 0?s:2,this.baseExtensions=t?.extensions||[],t?.markedOptions&&typeof this.markedInstance.setOptions=="function"&&this.markedInstance.setOptions(t.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,t?.extensions&&(this.baseExtensions=t.extensions,Ut(gr(t.extensions)).forEach(o=>this.registerExtension(o)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":" "}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(t){var e,n;this.extensions.push(t);let r=B(A(t,"code")),s=t.name,i={name:s,options:t.options,storage:t.storage};r&&this.codeTypes.add(s),this.extensionRanks.has(s)||this.extensionRanks.set(s,this.extensionRanks.size);let o=A(t,"markdownTokenName",i)||s,l=A(t,"parseMarkdown",i),a=A(t,"renderMarkdown",i),c=A(t,"markdownTokenizer",i),u=(e=A(t,"markdownOptions",i))!==null&&e!==void 0?e:null,d={tokenName:o,nodeName:s,parseMarkdown:l,renderMarkdown:a,isIndenting:(n=u?.indentsContent)!==null&&n!==void 0?n:!1,htmlReopen:u?.htmlReopen,tokenizer:c};if(o&&l){let f=this.registry.get(o)||[];f.push(d),this.registry.set(o,f)}if(a){let f=this.nodeTypeRegistry.get(s)||[];f.push(d),this.nodeTypeRegistry.set(s,f)}c&&this.hasMarked()&&this.registerTokenizer(c)}createLexer(){return new this.markedInstance.Lexer(this.markedInstance.defaults)}createTokenizerHelpers(t){return{inlineTokens:e=>t.inlineTokens(e),blockTokens:e=>{let n=t.state.top;try{return t.blockTokens(e)}finally{t.state.top=n}},isParagraphContinuation:e=>{var n,r;let s=new this.markedInstance.Lexer({...this.markedInstance.defaults,extensions:void 0,tokenizer:void 0}),i=`text
|
|
199
199
|
${e}
|
|
200
200
|
`,o=s.blockTokens(i)[0];if(o?.type!=="paragraph"||o.raw!==i)return!1;let l=this.createLexer();l.state.top=t.state.top;let a=this.markedInstance.defaults.extensions;return!(a==null||(n=a.startBlock)===null||n===void 0)&&n.some(c=>{let u=c.call({lexer:l},e);return typeof u=="number"&&u>=0})?!1:!(!(a==null||(r=a.block)===null||r===void 0)&&r.some(c=>c.call({lexer:l},`${e}
|
|
201
|
-
`,[])))}}}tokenizeInline(t){var e;return((e=this.activeParseLexer)!==null&&e!==void 0?e:this.createLexer()).inlineTokens(t)}registerTokenizer(t){if(!this.hasMarked())return;let{name:e,start:n,level:r="inline",tokenize:s}=t,i=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this),l;n?l=typeof n=="function"?n:c=>c.indexOf(n):l=c=>{let u=s(c,[],this.createTokenizerHelpers(this.createLexer()));return u&&u.raw?c.indexOf(u.raw):-1};let a={name:e,level:r,start:l,tokenizer(c,u){let d=this.lexer?i(this.lexer):i(o()),f=s(c,u,d);if(f&&f.type)return{...f,type:f.type||e,raw:f.raw||"",tokens:f.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[a]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){let e=this.getHandlersForToken(t);if(e.length>0)return e[0];let n=this.getHandlersForNodeType(t);return n.length>0?n[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t)return"";let e=this.renderNodes(t,t);return this.isEmptyOutput(e)?"":e}isEmptyOutput(t){return!t||t.trim()===""?!0:t.replace(/ /g,"").replace(/\u00A0/g,"").trim()===""}parse(t){if(!this.hasMarked())throw new Error("No marked instance available for parsing");let e=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{let r=n.lex(t);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=e}}parseTokens(t,e=!1){let n=e?
|
|
202
|
-
`).match(/\n\n/g)||[]).length}parseToken(t,e=!1){if(!t.type)return null;if(t.type==="list")return this.parseListToken(t);let n=this.getHandlersForToken(t.type),r=this.createParseHelpers();if(n.find(s=>{if(!s.parseMarkdown)return!1;let i=s.parseMarkdown(t,r),o=this.normalizeParseResult(i);return o&&(!Array.isArray(o)||o.length>0)?(this.lastParseResult=o,!0):!1})&&this.lastParseResult){let s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(t,e)}parseListToken(t){if(!t.items||t.items.length===0)return this.parseTokenWithHandlers(t);let e=t.items.some(l=>
|
|
201
|
+
`,[])))}}}tokenizeInline(t){var e;return((e=this.activeParseLexer)!==null&&e!==void 0?e:this.createLexer()).inlineTokens(t)}registerTokenizer(t){if(!this.hasMarked())return;let{name:e,start:n,level:r="inline",tokenize:s}=t,i=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this),l;n?l=typeof n=="function"?n:c=>c.indexOf(n):l=c=>{let u=s(c,[],this.createTokenizerHelpers(this.createLexer()));return u&&u.raw?c.indexOf(u.raw):-1};let a={name:e,level:r,start:l,tokenizer(c,u){let d=this.lexer?i(this.lexer):i(o()),f=s(c,u,d);if(f&&f.type)return{...f,type:f.type||e,raw:f.raw||"",tokens:f.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[a]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){let e=this.getHandlersForToken(t);if(e.length>0)return e[0];let n=this.getHandlersForNodeType(t);return n.length>0?n[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t)return"";let e=this.renderNodes(t,t);return this.isEmptyOutput(e)?"":e}isEmptyOutput(t){return!t||t.trim()===""?!0:t.replace(/ /g,"").replace(/\u00A0/g,"").trim()===""}parse(t){if(!this.hasMarked())throw new Error("No marked instance available for parsing");let e=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{let r=n.lex(t);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=e}}parseTokens(t,e=!1){let n=e?s1(t):t,r=n.reduce((o,l,a)=>(l.type!=="space"&&o.push(a),o),[]),s=-1,i=0;return n.flatMap((o,l)=>{for(;i<r.length&&r[i]<l;)s=r[i],i+=1;if(e&&o.type==="space"){var a;let u=(a=r[i])!==null&&a!==void 0?a:-1;return this.createImplicitEmptyParagraphsFromSpace(o,s,u)}let c=this.parseToken(o,e);return c===null?[]:Array.isArray(c)?c:[c]})}createImplicitEmptyParagraphsFromSpace(t,e,n){let r=this.countParagraphSeparators(t.raw||"");if(r===0)return[];let s=Math.max(r-(e===-1||n===-1?0:1),0);return Array.from({length:s},()=>({type:"paragraph",content:[]}))}countParagraphSeparators(t){return(t.replace(/\r\n/g,`
|
|
202
|
+
`).match(/\n\n/g)||[]).length}parseToken(t,e=!1){if(!t.type)return null;if(t.type==="list")return this.parseListToken(t);let n=this.getHandlersForToken(t.type),r=this.createParseHelpers();if(n.find(s=>{if(!s.parseMarkdown)return!1;let i=s.parseMarkdown(t,r),o=this.normalizeParseResult(i);return o&&(!Array.isArray(o)||o.length>0)?(this.lastParseResult=o,!0):!1})&&this.lastParseResult){let s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(t,e)}parseListToken(t){if(!t.items||t.items.length===0)return this.parseTokenWithHandlers(t);let e=t.items.some(l=>Gl(l).isTask),n=t.items.some(l=>!Gl(l).isTask);if(!e||!n||this.getHandlersForToken("taskList").length===0)return this.parseTokenWithHandlers(t);let r=[],s=[],i=null;for(let l=0;l<t.items.length;l+=1){let a=t.items[l],{isTask:c,checked:u,indentLevel:d}=Gl(a),f=a;if(c){let p=(a.raw||a.text||"").split(`
|
|
203
203
|
`),m=p[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),g=m?m[2]:"",y=[];if(p.length>1&&p.slice(1).join(`
|
|
204
204
|
`).trim()){let k=p.slice(1),b=k.filter(x=>x.trim());if(b.length>0){let x=Math.min(...b.map(C=>C.length-C.trimStart().length)),E=k.map(C=>C.trim()?C.slice(x):"").join(`
|
|
205
205
|
`).trim();E&&(y=this.markedInstance.lexer(`${E}
|
|
206
|
-
`))}}f={type:"taskItem",raw:"",mainContent:g,indentLevel:d,checked:u??!1,text:g,tokens:this.tokenizeInline(g),nestedTokens:y}}let h=c?"taskList":"list";i!==h?(s.length>0&&r.push({type:i,items:s}),s=[f],i=h):s.push(f)}s.length>0&&r.push({type:i,items:s});let o=[];for(let l=0;l<r.length;l+=1){let a=r[l],c={...t,type:a.type,items:a.items},u=this.parseToken(c);u&&(Array.isArray(u)?o.push(...u):o.push(u))}return o.length>0?o:null}parseTokenWithHandlers(t){if(!t.type)return null;let e=this.getHandlersForToken(t.type),n=this.createParseHelpers();if(e.find(r=>{if(!r.parseMarkdown)return!1;let s=r.parseMarkdown(t,n),i=this.normalizeParseResult(s);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let r=this.lastParseResult;return this.lastParseResult=null,r}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),tokenizeInline:t=>this.tokenizeInline(t),parseChildren:t=>this.parseTokens(t),parseBlockChildren:t=>this.parseTokens(t,!0),createTextNode:(t,e)=>({type:"text",text:t,marks:e||void 0}),createNode:(t,e,n)=>{let r={type:t,attrs:e||void 0,content:n||void 0};return(!e||Object.keys(e).length===0)&&delete r.attrs,r},applyMark:(t,e,n)=>({mark:t,content:e,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(t){let e=[];for(let o=0;o<t.length;o+=1){let l=t[o];if(l.type==="text")e.push({type:"text",text:il(l.text||"")});else if(l.type==="escape")e.push({type:"text",text:l.text||""});else if(l.type==="html"){var n,r;let a=((n=(r=l.raw)!==null&&r!==void 0?r:l.text)!==null&&n!==void 0?n:"").toString(),c=/^<\/[\s]*[\w-]+/i.test(a),u=a.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!c&&u&&!/\/>$/.test(a)){let f=u[1],h=this.escapeRegex(f),p=new RegExp(`^<\\/\\s*${h}\\b`,"i"),m=-1,g=[a];for(let y=o+1;y<t.length;y+=1){var s,i;let k=t[y],b=((s=(i=k.raw)!==null&&i!==void 0?i:k.text)!==null&&s!==void 0?s:"").toString();if(g.push(b),k.type==="html"&&p.test(b)){m=y;break}}if(m!==-1){let y=g.join(""),k={type:"html",raw:y,text:y,block:!1},b=this.parseHTMLToken(k);if(b){let x=this.normalizeParseResult(b);Array.isArray(x)?e.push(...x):x&&e.push(x)}o=m;continue}}let d=this.parseHTMLToken(l);if(d){let f=this.normalizeParseResult(d);Array.isArray(f)?e.push(...f):f&&e.push(f)}}else if(l.type){let a=this.getHandlerForToken(l.type);if(a&&a.parseMarkdown){let c=this.createParseHelpers(),u=a.parseMarkdown(l,c);if(this.isMarkResult(u)){let d=this.applyMarkToContent(u.mark,u.content,u.attrs);e.push(...d)}else{let d=this.normalizeParseResult(u);Array.isArray(d)?e.push(...d):d&&e.push(d)}}else l.tokens&&e.push(...this.parseInlineTokens(l.tokens))}}for(let o=e.length-1;o>0;o-=1){let l=e[o],a=e[o-1];if(l.type==="text"&&a.type==="text"){let c=l.marks||[],u=a.marks||[];of(c,u)&&(a.text=(a.text||"")+(l.text||""),e.splice(o,1))}}return e}applyMarkToContent(t,e,n){return e.map(r=>{if(r.type==="text"){let s=r.marks||[],i=n?{type:t,attrs:n}:{type:t};return{...r,marks:[...s,i]}}return{...r,content:r.content?this.applyMarkToContent(t,r.content,n):void 0}})}isMarkResult(t){return t&&typeof t=="object"&&"mark"in t}normalizeParseResult(t){return t?this.isMarkResult(t)?t.content:t:null}parseFallbackToken(t,e=!1){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:il(t.text||"")};case"html":return this.parseHTMLToken(t);case"escape":return{type:"text",text:t.text||""};case"space":return null;default:return t.tokens?this.parseTokens(t.tokens,e):null}}parseHTMLToken(t){let e=t.text||t.raw||"";if(!e.trim())return null;if(this.isUnrecognizedHtml(e))return this.htmlAsLiteralText(e,!!t.block);if(typeof window>"u"||typeof window.DOMParser>"u")return this.htmlAsLiteralText(e,!!t.block);try{let n=Bd(e,this.baseExtensions);if(n.type==="doc"&&n.content){if(t.block)return n.content;let r=this.toInlineContent(n.content);return r.length>0?r:null}return n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}toInlineContent(t){let e=this.getInlineNodeTypes();return t.flatMap(n=>n.type&&e.has(n.type)?[n]:n.content?this.toInlineContent(n.content):[])}getInlineNodeTypes(){if(this.inlineNodeTypesCache)return this.inlineNodeTypesCache;let t=new Set(["text"]);try{let e=Ss(this.baseExtensions);Object.values(e.nodes).forEach(n=>{n.isInline&&t.add(n.name)})}catch{}return this.inlineNodeTypesCache=t,t}isUnrecognizedHtml(t){return Fx(t,this.getSchemaParseDomTags())}getSchemaParseDomTags(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;let t=new Set;try{let e=Ss(this.baseExtensions),n=r=>{let s=r?.parseDOM;Array.isArray(s)&&s.forEach(i=>{if(typeof i?.tag=="string"){let o=i.tag.match(/^[a-zA-Z][\w-]*/);o&&t.add(o[0].toLowerCase())}})};Object.values(e.nodes).forEach(r=>n(r.spec)),Object.values(e.marks).forEach(r=>n(r.spec))}catch{}return this.schemaParseDomTagsCache=t,t}htmlAsLiteralText(t,e){let n=t.replace(/\s+$/,"");return n?e?{type:"paragraph",content:[{type:"text",text:n}]}:{type:"text",text:n}:null}encodeTextForMarkdown(t,e,n){return n?.type!=null&&this.codeTypes.has(n.type)||(e.marks||[]).some(r=>this.codeTypes.has(typeof r=="string"?r:r.type))?t:this.escapeMarkdownSyntax(rf(t))}escapeMarkdownSyntax(t){return t.replace(/([\\`*_[\]~])/g,"\\$1")}renderNodeToMarkdown(t,e,n=0,r=0,s={}){var i;if(t.type==="text")return this.encodeTextForMarkdown(t.text||"",t,e);if(!t.type)return"";let o=this.getHandlerForToken(t.type);if(!o)return"";let l=Array.isArray(e?.content)&&n>0?e.content[n-1]:void 0,a={renderChildren:(u,d)=>{let f=o.isIndenting?r+1:r;return!Array.isArray(u)&&u.content?this.renderNodes(u.content,t,d||"",n,f):this.renderNodes(u,t,d||"",n,f)},renderChild:(u,d)=>{let f=o.isIndenting?r+1:r;return this.renderNodeToMarkdown(u,t,d,f)},indent:u=>this.indentString+u,wrapInBlock:Nx},c={index:n,level:r,parentType:e?.type,previousNode:l,meta:{parentAttrs:e?.attrs,...s}};return((i=o.renderMarkdown)===null||i===void 0?void 0:i.call(o,t,a,c))||""}renderNodes(t,e,n="",r=0,s=0){return Array.isArray(t)?this.renderNodesWithMarkBoundaries(t,e,n,s):t.type?this.renderNodeToMarkdown(t,e,r,s):""}renderNodesWithMarkBoundaries(t,e,n="",r=0){let s=[],i=new Map,o=new Set,l=new Map,a=Px(t);if(t.forEach((c,u)=>{let d=u<t.length-1?t[u+1]:null;if(c.type)if(c.type==="text"){let f=this.encodeTextForMarkdown(c.text||"",c,e),h=new Map((c.marks||[]).map(C=>[C.type,C])),p=this.getMarksToOpenForSerialization(i,h,d),m=Rh(h,d);if(f.length>0&&f.trim().length===0&&h.size>0){let C=new Set(m.filter(T=>!i.has(T)));C.size>0&&(h=new Map(Array.from(h).filter(([T])=>!C.has(T))),p=this.getMarksToOpenForSerialization(i,h,d),m=Rh(h,d))}let g=m.filter(C=>i.has(C)),y=g.length>0&&p.length>0,k="";if(m.length>0&&!y){let C=f.match(/(\s+)$/);C&&(k=C[1],f=f.slice(0,-k.length))}y||m.slice().reverse().forEach(C=>{var T;if(!i.has(C))return;let D=h.get(C),I=this.getMarkClosing(C,D,l.get(C),(T=a[u])===null||T===void 0?void 0:T.get(C));I&&(f+=I),i.has(C)&&(i.delete(C),l.delete(C))});let b="";if(p.length>0){let C=f.match(/^(\s+)/);C&&(b=C[1],f=f.slice(b.length))}p.forEach(({type:C,mark:T})=>{var D;let I=o.has(C)?"html":"markdown",$=this.getMarkOpening(C,T,I,(D=a[u])===null||D===void 0?void 0:D.get(C));$&&(f=$+f),l.set(C,I),o.delete(C)}),y||p.slice().reverse().forEach(({type:C,mark:T})=>{i.set(C,T)}),f=b+f;let x;if(y){let C=new Set((d?.marks||[]).map(I=>I.type));p.forEach(({type:I})=>{C.has(I)&&this.getHtmlReopenTags(I)&&o.add(I)});let T=Array.from(i.keys()),D=g.slice().sort((I,$)=>T.indexOf($)-T.indexOf(I));x=[...p.map(I=>I.type),...D]}else x=Ix(i,h,d,this.markSetsEqual.bind(this));let E="";if(x.length>0){let C=f.match(/(\s+)$/);C&&(E=C[1],f=f.slice(0,-E.length))}x.forEach(C=>{var T,D;let I=(T=i.get(C))!==null&&T!==void 0?T:h.get(C),$=this.getMarkClosing(C,I,l.get(C),(D=a[u])===null||D===void 0?void 0:D.get(C));$&&(f+=$),i.delete(C),l.delete(C)}),f+=E,f+=k,s.push(f)}else{let f=new Set((c.marks||[]).map(k=>k.type)),h=new Map,p=new Map;i.forEach((k,b)=>{if(f.has(b)){var x;h.set(b,k),p.set(b,(x=l.get(b))!==null&&x!==void 0?x:"markdown")}});let m=Dx(i,(k,b)=>{var x;return this.getMarkClosing(k,b,l.get(k),(x=a[u-1])===null||x===void 0?void 0:x.get(k))});l.clear();let g=this.renderNodeToMarkdown(c,e,u,r),y=c.type==="hardBreak"?"":Lx(h,i,(k,b)=>{var x,E;let C=(x=p.get(k))!==null&&x!==void 0?x:"markdown";return l.set(k,C),this.getMarkOpening(k,b,C,(E=a[u+1])===null||E===void 0?void 0:E.get(k))});s.push(m+g+y)}}),n===""){let c=-1;s.forEach((u,d)=>{if(u){if(c>=0&&u.startsWith("[")){let f=/(\\*)!$/.exec(s[c]);f&&f[1].length%2===0&&(s[c]=`${s[c].slice(0,-1)}\\!`)}c=d}})}return s.join(n)}getMarkOpening(t,e,n="markdown",r){if(n==="html"){var s;return((s=this.getHtmlReopenTags(t))===null||s===void 0?void 0:s.open)||""}let i=this.getHandlersForNodeType(t),o=i.length>0?i[0]:void 0;if(!o||!o.renderMarkdown)return"";let l="\uE000__TIPTAP_MARKDOWN_PLACEHOLDER__\uE001",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:l}]};try{let c=o.renderMarkdown(a,{renderChildren:()=>l,renderChild:()=>l,indent:d=>d,wrapInBlock:(d,f)=>d+f},{index:0,level:0,parentType:"text",meta:{markText:r}}),u=c.indexOf(l);return u>=0?c.substring(0,u):""}catch(c){throw new Error(`Failed to get mark opening for ${t}: ${c}`)}}getMarkClosing(t,e,n="markdown",r){if(n==="html"){var s;return((s=this.getHtmlReopenTags(t))===null||s===void 0?void 0:s.close)||""}let i=this.getHandlersForNodeType(t),o=i.length>0?i[0]:void 0;if(!o||!o.renderMarkdown)return"";let l="\uE000__TIPTAP_MARKDOWN_PLACEHOLDER__\uE001",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:l}]};try{let c=o.renderMarkdown(a,{renderChildren:()=>l,renderChild:()=>l,indent:f=>f,wrapInBlock:(f,h)=>f+h},{index:0,level:0,parentType:"text",meta:{markText:r}}),u=c.indexOf(l),d=u+33;return u>=0?c.substring(d):""}catch(c){throw new Error(`Failed to get mark closing for ${t}: ${c}`)}}getHtmlReopenTags(t){let e=this.getHandlersForNodeType(t),n=e.length>0?e[0]:void 0;return n?.htmlReopen}markSetsEqual(t,e){return t.size!==e.size?!1:Array.from(t.entries()).every(([n,r])=>{let s=e.get(n);return s&&Ut(r.attrs,s.attrs)})}getMarksToOpenForSerialization(t,e,n){let r=Ox(t,e);if(r.length<=1)return r;let s=n?.marks||[],i=(c,u)=>s.some(d=>d.type===c&&Ut(d.attrs,u)),o=(c,u)=>{var d,f;let h=(d=this.extensionRanks.get(c.type))!==null&&d!==void 0?d:Number.MAX_SAFE_INTEGER,p=(f=this.extensionRanks.get(u.type))!==null&&f!==void 0?f:Number.MAX_SAFE_INTEGER;return h!==p?p-h:c.type.localeCompare(u.type)},l=r.filter(c=>!i(c.type,c.mark.attrs)).sort(o),a=r.filter(c=>i(c.type,c.mark.attrs)).sort(o);return[...l,...a]}},Oh=V.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!e?.contentType)return ze.setContent(t,e);if(Vs(t,e?.contentType)!=="markdown"||!this.editor.markdown)return ze.setContent(t,e);let n=this.editor.markdown.parse(t);return ze.setContent(n,e)},insertContent:(t,e)=>{if(!e?.contentType)return ze.insertContent(t,e);if(Vs(t,e?.contentType)!=="markdown"||!this.editor.markdown)return ze.insertContent(t,e);let n=this.editor.markdown.parse(t);return ze.insertContent(n,e)},insertContentAt:(t,e,n)=>{if(!n?.contentType)return ze.insertContentAt(t,e,n);if(Vs(e,n?.contentType)!=="markdown"||!this.editor.markdown)return ze.insertContentAt(t,e,n);let r=this.editor.markdown.parse(e);return ze.insertContentAt(t,r,n)}}},addStorage(){return{manager:new Nh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var t;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new Nh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||Vs(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');let e=this.editor.markdown.parse(this.editor.options.content);!((t=e.content)===null||t===void 0)&&t.length&&(this.editor.options.content=e)}});var Ih=new WeakSet,Dh=new WeakSet;function Qt(t){let e=t;return Ih.add(e),e}function Vl(t){return Array.isArray(t)&&Ih.has(t)}function Lh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Dh.has(e)&&!Vl(e)?Lh(e):[e])}function jx(t,e){if(t==="slot")return 0;if(t instanceof Function){let s=t(e);return Array.isArray(s)&&!Vl(s)&&!Dh.has(s)?Qt(s):s}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Vl(n))return Qt([t,r,n]);if(n.length===0)return Qt([t,r]);let s=Lh(n);return s.length===0?Qt([t,r]):Qt([t,r,...s])}return n!=null?Qt([t,r,n]):Qt([t,r])}var In=(t,e)=>jx(t,e);var _x=(t,e)=>{var n;let{state:r}=t,{selection:s}=r;if(!s.empty)return!1;let{$from:i}=s;if(i.parentOffset!==0)return!1;let o=i.depth-1;if(o<0)return!1;let l=i.node(o),a=i.index(o);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=i.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new v(h,0,0);return d.replace(u,i.after(),p),d.setSelection(M.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},Wx=/^\s*>\s$/,Ph=K.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return In("blockquote",{...z(this.options.HTMLAttributes,t),children:In("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((s,i)=>{var o,l;let a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,s,i))!==null&&o!==void 0?o:e.renderChildren([s])).split(`
|
|
206
|
+
`))}}f={type:"taskItem",raw:"",mainContent:g,indentLevel:d,checked:u??!1,text:g,tokens:this.tokenizeInline(g),nestedTokens:y}}let h=c?"taskList":"list";i!==h?(s.length>0&&r.push({type:i,items:s}),s=[f],i=h):s.push(f)}s.length>0&&r.push({type:i,items:s});let o=[];for(let l=0;l<r.length;l+=1){let a=r[l],c={...t,type:a.type,items:a.items},u=this.parseToken(c);u&&(Array.isArray(u)?o.push(...u):o.push(u))}return o.length>0?o:null}parseTokenWithHandlers(t){if(!t.type)return null;let e=this.getHandlersForToken(t.type),n=this.createParseHelpers();if(e.find(r=>{if(!r.parseMarkdown)return!1;let s=r.parseMarkdown(t,n),i=this.normalizeParseResult(s);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let r=this.lastParseResult;return this.lastParseResult=null,r}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),tokenizeInline:t=>this.tokenizeInline(t),parseChildren:t=>this.parseTokens(t),parseBlockChildren:t=>this.parseTokens(t,!0),createTextNode:(t,e)=>({type:"text",text:t,marks:e||void 0}),createNode:(t,e,n)=>{let r={type:t,attrs:e||void 0,content:n||void 0};return(!e||Object.keys(e).length===0)&&delete r.attrs,r},applyMark:(t,e,n)=>({mark:t,content:e,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(t){let e=[];for(let o=0;o<t.length;o+=1){let l=t[o];if(l.type==="text")e.push({type:"text",text:yl(l.text||"")});else if(l.type==="escape")e.push({type:"text",text:l.text||""});else if(l.type==="html"){var n,r;let a=((n=(r=l.raw)!==null&&r!==void 0?r:l.text)!==null&&n!==void 0?n:"").toString(),c=/^<\/[\s]*[\w-]+/i.test(a),u=a.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!c&&u&&!/\/>$/.test(a)){let f=u[1],h=this.escapeRegex(f),p=new RegExp(`^<\\/\\s*${h}\\b`,"i"),m=-1,g=[a];for(let y=o+1;y<t.length;y+=1){var s,i;let k=t[y],b=((s=(i=k.raw)!==null&&i!==void 0?i:k.text)!==null&&s!==void 0?s:"").toString();if(g.push(b),k.type==="html"&&p.test(b)){m=y;break}}if(m!==-1){let y=g.join(""),k={type:"html",raw:y,text:y,block:!1},b=this.parseHTMLToken(k);if(b){let x=this.normalizeParseResult(b);Array.isArray(x)?e.push(...x):x&&e.push(x)}o=m;continue}}let d=this.parseHTMLToken(l);if(d){let f=this.normalizeParseResult(d);Array.isArray(f)?e.push(...f):f&&e.push(f)}}else if(l.type){let a=this.getHandlerForToken(l.type);if(a&&a.parseMarkdown){let c=this.createParseHelpers(),u=a.parseMarkdown(l,c);if(this.isMarkResult(u)){let d=this.applyMarkToContent(u.mark,u.content,u.attrs);e.push(...d)}else{let d=this.normalizeParseResult(u);Array.isArray(d)?e.push(...d):d&&e.push(d)}}else l.tokens&&e.push(...this.parseInlineTokens(l.tokens))}}for(let o=e.length-1;o>0;o-=1){let l=e[o],a=e[o-1];if(l.type==="text"&&a.type==="text"){let c=l.marks||[],u=a.marks||[];mf(c,u)&&(a.text=(a.text||"")+(l.text||""),e.splice(o,1))}}return e}applyMarkToContent(t,e,n){return e.map(r=>{if(r.type==="text"){let s=r.marks||[],i=n?{type:t,attrs:n}:{type:t};return{...r,marks:[...s,i]}}return{...r,content:r.content?this.applyMarkToContent(t,r.content,n):void 0}})}isMarkResult(t){return t&&typeof t=="object"&&"mark"in t}normalizeParseResult(t){return t?this.isMarkResult(t)?t.content:t:null}parseFallbackToken(t,e=!1){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:yl(t.text||"")};case"html":return this.parseHTMLToken(t);case"escape":return{type:"text",text:t.text||""};case"space":return null;default:return t.tokens?this.parseTokens(t.tokens,e):null}}parseHTMLToken(t){let e=t.text||t.raw||"";if(!e.trim())return null;if(this.isUnrecognizedHtml(e))return this.htmlAsLiteralText(e,!!t.block);if(typeof window>"u"||typeof window.DOMParser>"u")return this.htmlAsLiteralText(e,!!t.block);try{let n=Yd(e,this.baseExtensions);if(n.type==="doc"&&n.content){if(t.block)return n.content;let r=this.toInlineContent(n.content);return r.length>0?r:null}return n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}toInlineContent(t){let e=this.getInlineNodeTypes();return t.flatMap(n=>n.type&&e.has(n.type)?[n]:n.content?this.toInlineContent(n.content):[])}getInlineNodeTypes(){if(this.inlineNodeTypesCache)return this.inlineNodeTypesCache;let t=new Set(["text"]);try{let e=Ms(this.baseExtensions);Object.values(e.nodes).forEach(n=>{n.isInline&&t.add(n.name)})}catch{}return this.inlineNodeTypesCache=t,t}isUnrecognizedHtml(t){return m1(t,this.getSchemaParseDomTags())}getSchemaParseDomTags(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;let t=new Set;try{let e=Ms(this.baseExtensions),n=r=>{let s=r?.parseDOM;Array.isArray(s)&&s.forEach(i=>{if(typeof i?.tag=="string"){let o=i.tag.match(/^[a-zA-Z][\w-]*/);o&&t.add(o[0].toLowerCase())}})};Object.values(e.nodes).forEach(r=>n(r.spec)),Object.values(e.marks).forEach(r=>n(r.spec))}catch{}return this.schemaParseDomTagsCache=t,t}htmlAsLiteralText(t,e){let n=t.replace(/\s+$/,"");return n?e?{type:"paragraph",content:[{type:"text",text:n}]}:{type:"text",text:n}:null}encodeTextForMarkdown(t,e,n){return n?.type!=null&&this.codeTypes.has(n.type)||(e.marks||[]).some(r=>this.codeTypes.has(typeof r=="string"?r:r.type))?t:this.escapeMarkdownSyntax(hf(t))}escapeMarkdownSyntax(t){return t.replace(/([\\`*_[\]~])/g,"\\$1")}renderNodeToMarkdown(t,e,n=0,r=0,s={}){var i;if(t.type==="text")return this.encodeTextForMarkdown(t.text||"",t,e);if(!t.type)return"";let o=this.getHandlerForToken(t.type);if(!o)return"";let l=Array.isArray(e?.content)&&n>0?e.content[n-1]:void 0,a={renderChildren:(u,d)=>{let f=o.isIndenting?r+1:r;return!Array.isArray(u)&&u.content?this.renderNodes(u.content,t,d||"",n,f):this.renderNodes(u,t,d||"",n,f)},renderChild:(u,d)=>{let f=o.isIndenting?r+1:r;return this.renderNodeToMarkdown(u,t,d,f)},indent:u=>this.indentString+u,wrapInBlock:i1},c={index:n,level:r,parentType:e?.type,previousNode:l,meta:{parentAttrs:e?.attrs,...s}};return((i=o.renderMarkdown)===null||i===void 0?void 0:i.call(o,t,a,c))||""}renderNodes(t,e,n="",r=0,s=0){return Array.isArray(t)?this.renderNodesWithMarkBoundaries(t,e,n,s):t.type?this.renderNodeToMarkdown(t,e,r,s):""}renderNodesWithMarkBoundaries(t,e,n="",r=0){let s=[],i=new Map,o=new Set,l=new Map,a=u1(t);if(t.forEach((c,u)=>{let d=u<t.length-1?t[u+1]:null;if(c.type)if(c.type==="text"){let f=this.encodeTextForMarkdown(c.text||"",c,e),h=new Map((c.marks||[]).map(C=>[C.type,C])),p=this.getMarksToOpenForSerialization(i,h,d),m=Bh(h,d);if(f.length>0&&f.trim().length===0&&h.size>0){let C=new Set(m.filter(T=>!i.has(T)));C.size>0&&(h=new Map(Array.from(h).filter(([T])=>!C.has(T))),p=this.getMarksToOpenForSerialization(i,h,d),m=Bh(h,d))}let g=m.filter(C=>i.has(C)),y=g.length>0&&p.length>0,k="";if(m.length>0&&!y){let C=f.match(/(\s+)$/);C&&(k=C[1],f=f.slice(0,-k.length))}y||m.slice().reverse().forEach(C=>{var T;if(!i.has(C))return;let L=h.get(C),I=this.getMarkClosing(C,L,l.get(C),(T=a[u])===null||T===void 0?void 0:T.get(C));I&&(f+=I),i.has(C)&&(i.delete(C),l.delete(C))});let b="";if(p.length>0){let C=f.match(/^(\s+)/);C&&(b=C[1],f=f.slice(b.length))}p.forEach(({type:C,mark:T})=>{var L;let I=o.has(C)?"html":"markdown",z=this.getMarkOpening(C,T,I,(L=a[u])===null||L===void 0?void 0:L.get(C));z&&(f=z+f),l.set(C,I),o.delete(C)}),y||p.slice().reverse().forEach(({type:C,mark:T})=>{i.set(C,T)}),f=b+f;let x;if(y){let C=new Set((d?.marks||[]).map(I=>I.type));p.forEach(({type:I})=>{C.has(I)&&this.getHtmlReopenTags(I)&&o.add(I)});let T=Array.from(i.keys()),L=g.slice().sort((I,z)=>T.indexOf(z)-T.indexOf(I));x=[...p.map(I=>I.type),...L]}else x=l1(i,h,d,this.markSetsEqual.bind(this));let E="";if(x.length>0){let C=f.match(/(\s+)$/);C&&(E=C[1],f=f.slice(0,-E.length))}x.forEach(C=>{var T,L;let I=(T=i.get(C))!==null&&T!==void 0?T:h.get(C),z=this.getMarkClosing(C,I,l.get(C),(L=a[u])===null||L===void 0?void 0:L.get(C));z&&(f+=z),i.delete(C),l.delete(C)}),f+=E,f+=k,s.push(f)}else{let f=new Set((c.marks||[]).map(k=>k.type)),h=new Map,p=new Map;i.forEach((k,b)=>{if(f.has(b)){var x;h.set(b,k),p.set(b,(x=l.get(b))!==null&&x!==void 0?x:"markdown")}});let m=a1(i,(k,b)=>{var x;return this.getMarkClosing(k,b,l.get(k),(x=a[u-1])===null||x===void 0?void 0:x.get(k))});l.clear();let g=this.renderNodeToMarkdown(c,e,u,r),y=c.type==="hardBreak"?"":c1(h,i,(k,b)=>{var x,E;let C=(x=p.get(k))!==null&&x!==void 0?x:"markdown";return l.set(k,C),this.getMarkOpening(k,b,C,(E=a[u+1])===null||E===void 0?void 0:E.get(k))});s.push(m+g+y)}}),n===""){let c=-1;s.forEach((u,d)=>{if(u){if(c>=0&&u.startsWith("[")){let f=/(\\*)!$/.exec(s[c]);f&&f[1].length%2===0&&(s[c]=`${s[c].slice(0,-1)}\\!`)}c=d}})}return s.join(n)}getMarkOpening(t,e,n="markdown",r){if(n==="html"){var s;return((s=this.getHtmlReopenTags(t))===null||s===void 0?void 0:s.open)||""}let i=this.getHandlersForNodeType(t),o=i.length>0?i[0]:void 0;if(!o||!o.renderMarkdown)return"";let l="\uE000__TIPTAP_MARKDOWN_PLACEHOLDER__\uE001",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:l}]};try{let c=o.renderMarkdown(a,{renderChildren:()=>l,renderChild:()=>l,indent:d=>d,wrapInBlock:(d,f)=>d+f},{index:0,level:0,parentType:"text",meta:{markText:r}}),u=c.indexOf(l);return u>=0?c.substring(0,u):""}catch(c){throw new Error(`Failed to get mark opening for ${t}: ${c}`)}}getMarkClosing(t,e,n="markdown",r){if(n==="html"){var s;return((s=this.getHtmlReopenTags(t))===null||s===void 0?void 0:s.close)||""}let i=this.getHandlersForNodeType(t),o=i.length>0?i[0]:void 0;if(!o||!o.renderMarkdown)return"";let l="\uE000__TIPTAP_MARKDOWN_PLACEHOLDER__\uE001",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:l}]};try{let c=o.renderMarkdown(a,{renderChildren:()=>l,renderChild:()=>l,indent:f=>f,wrapInBlock:(f,h)=>f+h},{index:0,level:0,parentType:"text",meta:{markText:r}}),u=c.indexOf(l),d=u+33;return u>=0?c.substring(d):""}catch(c){throw new Error(`Failed to get mark closing for ${t}: ${c}`)}}getHtmlReopenTags(t){let e=this.getHandlersForNodeType(t),n=e.length>0?e[0]:void 0;return n?.htmlReopen}markSetsEqual(t,e){return t.size!==e.size?!1:Array.from(t.entries()).every(([n,r])=>{let s=e.get(n);return s&&qt(r.attrs,s.attrs)})}getMarksToOpenForSerialization(t,e,n){let r=o1(t,e);if(r.length<=1)return r;let s=n?.marks||[],i=(c,u)=>s.some(d=>d.type===c&&qt(d.attrs,u)),o=(c,u)=>{var d,f;let h=(d=this.extensionRanks.get(c.type))!==null&&d!==void 0?d:Number.MAX_SAFE_INTEGER,p=(f=this.extensionRanks.get(u.type))!==null&&f!==void 0?f:Number.MAX_SAFE_INTEGER;return h!==p?p-h:c.type.localeCompare(u.type)},l=r.filter(c=>!i(c.type,c.mark.attrs)).sort(o),a=r.filter(c=>i(c.type,c.mark.attrs)).sort(o);return[...l,...a]}},Fh=j.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!e?.contentType)return Be.setContent(t,e);if(Ys(t,e?.contentType)!=="markdown"||!this.editor.markdown)return Be.setContent(t,e);let n=this.editor.markdown.parse(t);return Be.setContent(n,e)},insertContent:(t,e)=>{if(!e?.contentType)return Be.insertContent(t,e);if(Ys(t,e?.contentType)!=="markdown"||!this.editor.markdown)return Be.insertContent(t,e);let n=this.editor.markdown.parse(t);return Be.insertContent(n,e)},insertContentAt:(t,e,n)=>{if(!n?.contentType)return Be.insertContentAt(t,e,n);if(Ys(e,n?.contentType)!=="markdown"||!this.editor.markdown)return Be.insertContentAt(t,e,n);let r=this.editor.markdown.parse(e);return Be.insertContentAt(t,r,n)}}},addStorage(){return{manager:new Hh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var t;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new Hh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||Ys(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');let e=this.editor.markdown.parse(this.editor.options.content);!((t=e.content)===null||t===void 0)&&t.length&&(this.editor.options.content=e)}});var _h=new WeakSet,jh=new WeakSet;function Zt(t){let e=t;return _h.add(e),e}function Xl(t){return Array.isArray(t)&&_h.has(t)}function Wh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&jh.has(e)&&!Xl(e)?Wh(e):[e])}function g1(t,e){if(t==="slot")return 0;if(t instanceof Function){let s=t(e);return Array.isArray(s)&&!Xl(s)&&!jh.has(s)?Zt(s):s}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Xl(n))return Zt([t,r,n]);if(n.length===0)return Zt([t,r]);let s=Wh(n);return s.length===0?Zt([t,r]):Zt([t,r,...s])}return n!=null?Zt([t,r,n]):Zt([t,r])}var $n=(t,e)=>g1(t,e);var y1=(t,e)=>{var n;let{state:r}=t,{selection:s}=r;if(!s.empty)return!1;let{$from:i}=s;if(i.parentOffset!==0)return!1;let o=i.depth-1;if(o<0)return!1;let l=i.node(o),a=i.index(o);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=i.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new v(h,0,0);return d.replace(u,i.after(),p),d.setSelection(M.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},k1=/^\s*>\s$/,Vh=W.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return $n("blockquote",{...D(this.options.HTMLAttributes,t),children:$n("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((s,i)=>{var o,l;let a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,s,i))!==null&&o!==void 0?o:e.renderChildren([s])).split(`
|
|
207
207
|
`).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
|
|
208
208
|
`))}),r.join(`
|
|
209
209
|
${n}
|
|
210
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
210
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>y1(this.editor,this.type)}},addInputRules(){return[Se({find:k1,type:this.type})]}});var b1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,w1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,x1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,S1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Kh=Me.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return $n("strong",{...D(this.options.HTMLAttributes,t),children:$n("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ie({find:b1,type:this.type}),Ie({find:x1,type:this.type})]},addPasteRules(){return[Te({find:w1,type:this.type}),Te({find:S1,type:this.type})]}});var C1=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},v1=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function M1(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var Uh=Me.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";let s=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",i="`".repeat(M1(s)),o=s.startsWith("`")||s.endsWith("`")?" ":"";return`${i}${o}${e.renderChildren(t.content)}${o}${i}`},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ie({find:C1,type:this.type})]},addPasteRules(){return[Te({find:v1,type:this.type})]}});var Yl=4,T1=/^```([a-z]+)?[\s\n]$/,A1=/^~~~([a-z]+)?[\s\n]$/,qh=W.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Yl,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",D(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",s=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
211
211
|
`):r=`\`\`\`${s}
|
|
212
212
|
|
|
213
|
-
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:
|
|
213
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:Yl,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:u}=s,d=r.doc.textBetween(c,u,`
|
|
214
214
|
`,`
|
|
215
215
|
`).split(`
|
|
216
216
|
`).map(f=>l+f).join(`
|
|
217
|
-
`);return a.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:
|
|
217
|
+
`);return a.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:Yl,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;let{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`
|
|
218
218
|
`,`
|
|
219
219
|
`).split(`
|
|
220
220
|
`),h=0,p=0,m=c-u;for(let b=0;b<f.length;b+=1){if(p+f[b].length>=m){h=b;break}p+=f[b].length+1}let g=((a=f[h].match(/^ */))===null||a===void 0?void 0:a[0])||"",y=Math.min(g.length,n);if(y===0)return!0;let k=u;for(let b=0;b<h;b+=1)k+=f[b].length+1;return l.delete(k,k+y),c-k<=y&&l.setSelection(M.create(l.doc,k)),!0}):t.commands.command(({tr:l})=>{let{from:a,to:c}=s,u=r.doc.textBetween(a,c,`
|
|
@@ -223,16 +223,28 @@ ${n}
|
|
|
223
223
|
`).map(d=>{var f;let h=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||"",p=Math.min(h.length,n);return d.slice(p)}).join(`
|
|
224
224
|
`);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
225
225
|
|
|
226
|
-
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||s.parentOffset!==s.parent.nodeSize-2)return!1;let o=s.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:l})=>(l.setSelection(R.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[
|
|
227
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(M.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}});var
|
|
226
|
+
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||s.parentOffset!==s.parent.nodeSize-2)return!1;let o=s.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:l})=>(l.setSelection(R.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[kr({find:T1,type:this.type,getAttributes:t=>({language:t[1]})}),kr({find:A1,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new P({key:new _("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;let{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
|
|
227
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(M.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}});var Jh=W.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
228
228
|
|
|
229
|
-
`):""});var
|
|
229
|
+
`):""});var Gh=W.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",D(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
230
230
|
`},renderMarkdown:()=>`
|
|
231
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jh=K.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,z(this.options.HTMLAttributes,e),0]},parseMarkdown(t,e){let n=t.depth||1;return this.options.levels.includes(n)?e.createNode("heading",{level:n},e.parseInline(t.tokens||[])):e.createNode("paragraph",void 0,e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>hr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var _h=K.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",z(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!nf(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,s=t();return Cs(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){let{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(M.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(N.create(o.doc,a.pos)):o.setSelection(M.create(o.doc,a.pos));else{let u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(M.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[df({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Zx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,e1=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,t1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,n1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Wh=Ce.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",z(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ne({find:Zx,type:this.type}),Ne({find:t1,type:this.type})]},addPasteRules(){return[ve({find:e1,type:this.type}),ve({find:n1,type:this.type})]}});var r1="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",s1="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Yl="numeric",Ql="ascii",Zl="alpha",wr="asciinumeric",br="alphanumeric",ea="domain",Gh="emoji",i1="scheme",o1="slashscheme",Ul="whitespace";function l1(t,e){return t in e||(e[t]=[]),e[t]}function en(t,e,n){e[Yl]&&(e[wr]=!0,e[br]=!0),e[Ql]&&(e[wr]=!0,e[Zl]=!0),e[wr]&&(e[br]=!0),e[Zl]&&(e[br]=!0),e[br]&&(e[ea]=!0),e[Gh]&&(e[ea]=!0);for(let r in e){let s=l1(r,n);s.indexOf(t)<0&&s.push(t)}}function a1(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function xe(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xe.groups={};xe.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||xe.groups;let s;return e&&e.j?s=e:(s=new xe(e),n&&r&&en(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this,i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||xe.groups;let s=this;if(e&&e.j)return s.j[t]=e,e;let i=e,o,l=s.go(t);if(l?(o=new xe,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new xe,i){if(r)if(o.t&&typeof o.t=="string"){let a=Object.assign(a1(o.t,r),n);en(i,a,r)}else n&&en(i,n,r);o.t=i}return s.j[t]=o,o}};var P=(t,e,n,r,s)=>t.ta(e,n,r,s),G=(t,e,n,r,s)=>t.tr(e,n,r,s),Vh=(t,e,n,r,s)=>t.ts(e,n,r,s),S=(t,e,n,r,s)=>t.tt(e,n,r,s),at="WORD",ta="UWORD",Xh="ASCIINUMERICAL",Yh="ALPHANUMERICAL",Mr="LOCALHOST",na="TLD",ra="UTLD",Js="SCHEME",Dn="SLASH_SCHEME",ia="NUM",sa="WS",oa="NL",xr="OPENBRACE",Sr="CLOSEBRACE",Xs="OPENBRACKET",Ys="CLOSEBRACKET",Qs="OPENPAREN",Zs="CLOSEPAREN",ei="OPENANGLEBRACKET",ti="CLOSEANGLEBRACKET",ni="FULLWIDTHLEFTPAREN",ri="FULLWIDTHRIGHTPAREN",si="LEFTCORNERBRACKET",ii="RIGHTCORNERBRACKET",oi="LEFTWHITECORNERBRACKET",li="RIGHTWHITECORNERBRACKET",ai="FULLWIDTHLESSTHAN",ci="FULLWIDTHGREATERTHAN",ui="AMPERSAND",di="APOSTROPHE",fi="ASTERISK",vt="AT",hi="BACKSLASH",pi="BACKTICK",mi="CARET",tn="COLON",la="COMMA",gi="DOLLAR",qe="DOT",yi="EQUALS",aa="EXCLAMATION",Ie="HYPHEN",Cr="PERCENT",ki="PIPE",bi="PLUS",Pn="POUND",Zt="QUERY",ca="QUOTE",Qh="FULLWIDTHMIDDLEDOT",ua="SEMI",Je="SLASH",vr="TILDE",wi="UNDERSCORE",Zh="EMOJI",xi="SYM",ep=Object.freeze({__proto__:null,ALPHANUMERICAL:Yh,AMPERSAND:ui,APOSTROPHE:di,ASCIINUMERICAL:Xh,ASTERISK:fi,AT:vt,BACKSLASH:hi,BACKTICK:pi,CARET:mi,CLOSEANGLEBRACKET:ti,CLOSEBRACE:Sr,CLOSEBRACKET:Ys,CLOSEPAREN:Zs,COLON:tn,COMMA:la,DOLLAR:gi,DOT:qe,EMOJI:Zh,EQUALS:yi,EXCLAMATION:aa,FULLWIDTHGREATERTHAN:ci,FULLWIDTHLEFTPAREN:ni,FULLWIDTHLESSTHAN:ai,FULLWIDTHMIDDLEDOT:Qh,FULLWIDTHRIGHTPAREN:ri,HYPHEN:Ie,LEFTCORNERBRACKET:si,LEFTWHITECORNERBRACKET:oi,LOCALHOST:Mr,NL:oa,NUM:ia,OPENANGLEBRACKET:ei,OPENBRACE:xr,OPENBRACKET:Xs,OPENPAREN:Qs,PERCENT:Cr,PIPE:ki,PLUS:bi,POUND:Pn,QUERY:Zt,QUOTE:ca,RIGHTCORNERBRACKET:ii,RIGHTWHITECORNERBRACKET:li,SCHEME:Js,SEMI:ua,SLASH:Je,SLASH_SCHEME:Dn,SYM:xi,TILDE:vr,TLD:na,UNDERSCORE:wi,UTLD:ra,UWORD:ta,WORD:at,WS:sa}),ot=/[a-z]/,Ln=/[a-z]/i,Gs=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{Ln=new RegExp("\\p{L}","u"),Gs=new RegExp("\\p{Emoji}","u")}catch{}var lt=/\d/,ql=/\s/;var Kh="\r",Jl=`
|
|
232
|
-
`,
|
|
231
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Xh=W.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,D(this.options.HTMLAttributes,e),0]},parseMarkdown(t,e){let n=t.depth||1;return this.options.levels.includes(n)?e.createNode("heading",{level:n},e.parseInline(t.tokens||[])):e.createNode("paragraph",void 0,e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>kr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Yh=W.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",D(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!ff(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,s=t();return Ns(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){let{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(M.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(N.create(o.doc,a.pos)):o.setSelection(M.create(o.doc,a.pos));else{let u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(M.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[wf({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var E1=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,R1=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,N1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,O1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Qh=Me.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",D(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ie({find:E1,type:this.type}),Ie({find:N1,type:this.type})]},addPasteRules(){return[Te({find:R1,type:this.type}),Te({find:O1,type:this.type})]}});var I1="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",L1="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",ra="numeric",sa="ascii",ia="alpha",Mr="asciinumeric",vr="alphanumeric",oa="domain",sp="emoji",D1="scheme",P1="slashscheme",Ql="whitespace";function $1(t,e){return t in e||(e[t]=[]),e[t]}function tn(t,e,n){e[ra]&&(e[Mr]=!0,e[vr]=!0),e[sa]&&(e[Mr]=!0,e[ia]=!0),e[Mr]&&(e[vr]=!0),e[ia]&&(e[vr]=!0),e[vr]&&(e[oa]=!0),e[sp]&&(e[oa]=!0);for(let r in e){let s=$1(r,n);s.indexOf(t)<0&&s.push(t)}}function z1(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ce(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ce.groups={};Ce.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Ce.groups;let s;return e&&e.j?s=e:(s=new Ce(e),n&&r&&tn(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this,i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Ce.groups;let s=this;if(e&&e.j)return s.j[t]=e,e;let i=e,o,l=s.go(t);if(l?(o=new Ce,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Ce,i){if(r)if(o.t&&typeof o.t=="string"){let a=Object.assign(z1(o.t,r),n);tn(i,a,r)}else n&&tn(i,n,r);o.t=i}return s.j[t]=o,o}};var $=(t,e,n,r,s)=>t.ta(e,n,r,s),X=(t,e,n,r,s)=>t.tr(e,n,r,s),Zh=(t,e,n,r,s)=>t.ts(e,n,r,s),S=(t,e,n,r,s)=>t.tt(e,n,r,s),ct="WORD",la="UWORD",ip="ASCIINUMERICAL",op="ALPHANUMERICAL",Nr="LOCALHOST",aa="TLD",ca="UTLD",ti="SCHEME",zn="SLASH_SCHEME",da="NUM",ua="WS",fa="NL",Tr="OPENBRACE",Ar="CLOSEBRACE",ri="OPENBRACKET",si="CLOSEBRACKET",ii="OPENPAREN",oi="CLOSEPAREN",li="OPENANGLEBRACKET",ai="CLOSEANGLEBRACKET",ci="FULLWIDTHLEFTPAREN",ui="FULLWIDTHRIGHTPAREN",di="LEFTCORNERBRACKET",fi="RIGHTCORNERBRACKET",hi="LEFTWHITECORNERBRACKET",pi="RIGHTWHITECORNERBRACKET",mi="FULLWIDTHLESSTHAN",gi="FULLWIDTHGREATERTHAN",yi="AMPERSAND",ki="APOSTROPHE",bi="ASTERISK",Mt="AT",wi="BACKSLASH",xi="BACKTICK",Si="CARET",nn="COLON",ha="COMMA",Ci="DOLLAR",Je="DOT",vi="EQUALS",pa="EXCLAMATION",De="HYPHEN",Er="PERCENT",Mi="PIPE",Ti="PLUS",Hn="POUND",en="QUERY",ma="QUOTE",lp="FULLWIDTHMIDDLEDOT",ga="SEMI",Ge="SLASH",Rr="TILDE",Ai="UNDERSCORE",ap="EMOJI",Ei="SYM",cp=Object.freeze({__proto__:null,ALPHANUMERICAL:op,AMPERSAND:yi,APOSTROPHE:ki,ASCIINUMERICAL:ip,ASTERISK:bi,AT:Mt,BACKSLASH:wi,BACKTICK:xi,CARET:Si,CLOSEANGLEBRACKET:ai,CLOSEBRACE:Ar,CLOSEBRACKET:si,CLOSEPAREN:oi,COLON:nn,COMMA:ha,DOLLAR:Ci,DOT:Je,EMOJI:ap,EQUALS:vi,EXCLAMATION:pa,FULLWIDTHGREATERTHAN:gi,FULLWIDTHLEFTPAREN:ci,FULLWIDTHLESSTHAN:mi,FULLWIDTHMIDDLEDOT:lp,FULLWIDTHRIGHTPAREN:ui,HYPHEN:De,LEFTCORNERBRACKET:di,LEFTWHITECORNERBRACKET:hi,LOCALHOST:Nr,NL:fa,NUM:da,OPENANGLEBRACKET:li,OPENBRACE:Tr,OPENBRACKET:ri,OPENPAREN:ii,PERCENT:Er,PIPE:Mi,PLUS:Ti,POUND:Hn,QUERY:en,QUOTE:ma,RIGHTCORNERBRACKET:fi,RIGHTWHITECORNERBRACKET:pi,SCHEME:ti,SEMI:ga,SLASH:Ge,SLASH_SCHEME:zn,SYM:Ei,TILDE:Rr,TLD:aa,UNDERSCORE:Ai,UTLD:ca,UWORD:la,WORD:ct,WS:ua}),lt=/[a-z]/,Bn=/[a-z]/i,ni=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{Bn=new RegExp("\\p{L}","u"),ni=new RegExp("\\p{Emoji}","u")}catch{}var at=/\d/,Zl=/\s/;var ep="\r",ea=`
|
|
232
|
+
`,B1="\uFE0F",H1="\u200D",ta="\uFFFC",Qs=null,Zs=null;function F1(t=[]){let e={};Ce.groups=e;let n=new Ce;Qs==null&&(Qs=tp(I1)),Zs==null&&(Zs=tp(L1)),S(n,"'",ki),S(n,"{",Tr),S(n,"}",Ar),S(n,"[",ri),S(n,"]",si),S(n,"(",ii),S(n,")",oi),S(n,"<",li),S(n,">",ai),S(n,"\uFF08",ci),S(n,"\uFF09",ui),S(n,"\u300C",di),S(n,"\u300D",fi),S(n,"\u300E",hi),S(n,"\u300F",pi),S(n,"\uFF1C",mi),S(n,"\uFF1E",gi),S(n,"&",yi),S(n,"*",bi),S(n,"@",Mt),S(n,"`",xi),S(n,"^",Si),S(n,":",nn),S(n,",",ha),S(n,"$",Ci),S(n,".",Je),S(n,"=",vi),S(n,"!",pa),S(n,"-",De),S(n,"%",Er),S(n,"|",Mi),S(n,"+",Ti),S(n,"#",Hn),S(n,"?",en),S(n,'"',ma),S(n,"/",Ge),S(n,";",ga),S(n,"~",Rr),S(n,"_",Ai),S(n,"\\",wi),S(n,"\u30FB",lp);let r=X(n,at,da,{[ra]:!0});X(r,at,r);let s=X(r,lt,ip,{[Mr]:!0}),i=X(r,Bn,op,{[vr]:!0}),o=X(n,lt,ct,{[sa]:!0});X(o,at,s),X(o,lt,o),X(s,at,s),X(s,lt,s);let l=X(n,Bn,la,{[ia]:!0});X(l,lt),X(l,at,i),X(l,Bn,l),X(i,at,i),X(i,lt),X(i,Bn,i);let a=S(n,ea,fa,{[Ql]:!0}),c=S(n,ep,ua,{[Ql]:!0}),u=X(n,Zl,ua,{[Ql]:!0});S(n,ta,u),S(c,ea,a),S(c,ta,u),X(c,Zl,u),S(u,ep),S(u,ea),X(u,Zl,u),S(u,ta,u);let d=X(n,ni,ap,{[sp]:!0});S(d,"#"),X(d,ni,d),S(d,B1,d);let f=S(d,H1);S(f,"#"),X(f,ni,d);let h=[[lt,o],[at,s]],p=[[lt,null],[Bn,l],[at,i]];for(let m=0;m<Qs.length;m++)vt(n,Qs[m],aa,ct,h);for(let m=0;m<Zs.length;m++)vt(n,Zs[m],ca,la,p);tn(aa,{tld:!0,ascii:!0},e),tn(ca,{utld:!0,alpha:!0},e),vt(n,"file",ti,ct,h),vt(n,"mailto",ti,ct,h),vt(n,"http",zn,ct,h),vt(n,"https",zn,ct,h),vt(n,"ftp",zn,ct,h),vt(n,"ftps",zn,ct,h),tn(ti,{scheme:!0,ascii:!0},e),tn(zn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){let g=t[m][0],k=t[m][1]?{[D1]:!0}:{[P1]:!0};g.indexOf("-")>=0?k[oa]=!0:lt.test(g)?at.test(g)?k[Mr]=!0:k[sa]=!0:k[ra]=!0,Zh(n,g,g,k)}return Zh(n,"localhost",Nr,{ascii:!0}),n.jd=new Ce(Ei),{start:n,tokens:Object.assign({groups:e},cp)}}function up(t,e){let n=_1(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[],i=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[o].length,f++),c+=n[o].length,i+=n[o].length,o++;i-=d,o-=f,c-=d,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function _1(t){let e=[],n=t.length,r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function vt(t,e,n,r,s){let i,o=e.length;for(let l=0;l<o-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new Ce(r),i.jr=s.slice(),t.j[a]=i),t=i}return i=new Ce(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function tp(t){let e=[],n=[],r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}var Or={defaultProtocol:"http",events:null,format:np,formatHref:np,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function ya(t,e=null){let n=Object.assign({},Or);t&&(n=Object.assign(n,t instanceof ya?t.o:t));let r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s,this.ignoreClasses=n.ignoreClasses.slice()}ya.prototype={o:Or,ignoreTags:[],ignoreClasses:[],isIgnoredClass(t){if(typeof t!="string"||this.ignoreClasses.length===0)return!1;let e=t.split(/\s+/);for(let n=0;n<e.length;n++)if(this.ignoreClasses.indexOf(e[n])>=0)return!0;return!1},defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){let r=e!=null,s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Or[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function np(t){return t}function dp(t,e){this.t="token",this.v=t,this.tk=e}dp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Or.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:d}}};function Ri(t,e){class n extends dp{constructor(s,i){super(s,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var j1=Ri("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),rp=Ri("text"),W1=Ri("nl"),ei=Ri("url",{isLink:!0,toHref(t=Or.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==Nr&&t[1].t===nn}});var Le=t=>new Ce(t);function V1({groups:t}){let e=t.domain.concat([yi,bi,Mt,wi,xi,Si,Ci,vi,De,da,Er,Mi,Ti,Hn,Ge,Ei,Rr,Ai]),n=[ki,nn,ha,Je,pa,Er,en,ma,ga,li,ai,Tr,Ar,si,ri,ii,oi,ci,ui,di,fi,hi,pi,mi,gi],r=[yi,ki,bi,wi,xi,Si,Ci,vi,De,Tr,Ar,Er,Mi,Ti,Hn,en,Ge,Ei,Rr,Ai],s=Le(),i=S(s,Rr);$(i,r,i),$(i,t.domain,i);let o=Le(),l=Le(),a=Le();$(s,t.domain,o),$(s,t.scheme,l),$(s,t.slashscheme,a),$(o,r,i),$(o,t.domain,o);let c=S(o,Mt);S(i,Mt,c),S(l,Mt,c),S(a,Mt,c);let u=S(i,Je);$(u,r,i),$(u,t.domain,i);let d=Le();$(c,t.domain,d),$(d,t.domain,d);let f=S(d,Je);$(f,t.domain,d);let h=Le(j1);$(f,t.tld,h),$(f,t.utld,h),S(c,Nr,h);let p=S(d,De);S(p,De,p),$(p,t.domain,d),$(h,t.domain,d),S(h,Je,f),S(h,De,p);let m=S(o,De),g=S(o,Je);S(m,De,m),$(m,t.domain,o),$(g,r,i),$(g,t.domain,o);let y=Le(ei);$(g,t.tld,y),$(g,t.utld,y),$(y,t.domain,o),$(y,r,i),S(y,Je,g),S(y,De,m),S(y,Mt,c);let k=S(y,nn),b=Le(ei);$(k,t.numeric,b);let x=Le(ei),E=Le();$(x,e,x),$(x,n,E),$(E,e,x),$(E,n,E),S(y,Ge,x),S(b,Ge,x),S(y,en,E),S(y,Hn,x),S(b,en,E),S(b,Hn,x);let C=S(l,nn),T=S(a,nn),L=S(T,Ge),I=S(L,Ge);$(l,t.domain,o),S(l,Je,g),S(l,De,m),$(a,t.domain,o),S(a,Je,g),S(a,De,m),$(C,t.domain,x),S(C,Ge,x),S(C,en,x),$(I,t.domain,x),$(I,e,x),S(I,Ge,x);let z=[[Tr,Ar],[ri,si],[ii,oi],[li,ai],[ci,ui],[di,fi],[hi,pi],[mi,gi]];for(let Ee=0;Ee<z.length;Ee++){let[Tt,At]=z[Ee],he=S(x,Tt);S(E,Tt,he);let we=Le(ei);$(he,e,we);let pe=Le();$(he,n,pe),S(he,At,x),$(we,e,we),$(we,n,pe),$(pe,e,we),$(pe,n,pe),S(we,At,x),S(pe,At,x)}return S(s,Nr,y),S(s,fa,W1),{start:s,tokens:cp}}function K1(t,e,n){let r=n.length,s=0,i=[],o=[],l=[];for(;s<r;){let a=t,c=null,u=null,d=0,f=null,h=-1,p=[];for(;s<r&&!(c=a.go(n[s].t));)o.push(n[s++]);for(;s<r&&(u=c||a.go(n[s].t));)if(c=null,a=u,s++,d++,a.accepts())h=0,f=a,p=[];else if(h>=0&&h++,p.push(a),l[s]&&l[s].has(a))break;for(let m=0,g=s-p.length+1;m<p.length;m++,g++)(l[g]||(l[g]=new Set)).add(p[m]);if(h<0)s-=d,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(na(rp,e,o)),o=[]),s-=h,d-=h;let m=f.t,g=n.slice(s-d,s);i.push(na(m,e,g))}}return o.length>0&&i.push(na(rp,e,o)),i}function na(t,e,n){let r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}var U1=typeof console<"u"&&console&&console.warn||(()=>{}),q1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function fp(){return Ce.groups={},q.scanner=null,q.parser=null,q.tokenQueue=[],q.pluginQueue=[],q.customSchemes=[],q.initialized=!1,q}function ka(t,e=!1){if(q.initialized&&U1(`linkifyjs: already initialized - will not register custom scheme "${t}" ${q1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
233
233
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
234
234
|
2. Cannot start or end with "-"
|
|
235
|
-
3. "-" cannot repeat`);q.customSchemes.push([t,e])}function b1(){q.scanner=d1(q.customSchemes);for(let t=0;t<q.tokenQueue.length;t++)q.tokenQueue[t][1]({scanner:q.scanner});q.parser=m1(q.scanner.tokens);for(let t=0;t<q.pluginQueue.length;t++)q.pluginQueue[t][1]({scanner:q.scanner,parser:q.parser});return q.initialized=!0,q}function Ci(t){return q.initialized||b1(),g1(q.parser.start,t,tp(q.scanner.start,t))}Ci.scan=tp;function ha(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new da(n),s=Ci(t),i=[];for(let o=0;o<s.length;o++){let l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var vi="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",w1=new RegExp(vi),x1=new RegExp(`${vi}$`),S1=new RegExp(`${vi}+$`),C1=new RegExp(vi,"g");function v1(t,e,n){var r,s;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let o=(s=t.doc.textBetween(e.from,e.to,"\uFFFC","\uFFFC").match(S1))===null||s===void 0?void 0:s[0];if(!o)return;let l=e.to-o.length,a=fr(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function M1(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function T1(t){return new L({key:new j("autolink"),appendTransaction:(e,n,r)=>{let s=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta("preventAutolink"));if(!s||i)return;let{tr:o}=r,l=Zo(n.doc,[...e]);if(!e.some(ed)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof Y)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>v1(o,c,t.type))}if(Tn(l).forEach(({newRange:a})=>{let c=Ld(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!x1.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){let f=d.split(w1).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let m=Ci(h).map(g=>g.toObject(t.defaultProtocol));if(!M1(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{fr(g.from,g.to,r.doc).some(y=>y.mark.type===t.type)||o.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function A1(t){return new L({key:new j("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;s=a.closest("a"),s&&!c.contains(s)&&(s=null)}if(!s)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var o,l;let a=rl(e.state,t.type.name),c=(o=s.href)!==null&&o!==void 0?o:a.href,u=(l=s.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var E1=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,R1=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function sp(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function N1(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&sp(t,r)){r+=1;continue}let s=0;for(;r<e&&t[r]==="`";)s+=1,r+=1;n===0?n=s:s===n&&(n=0)}return n>0}function ip(t,e,n){var r,s;let[,i,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||sp(t,(r=e.index)!==null&&r!==void 0?r:0)||N1(t,(s=e.index)!==null&&s!==void 0?s:0)?!1:!!i.trim()&&n(o)}function op(t){var e,n;let[r,s,i,,o,l,a]=t,c=(e=o??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:s,data:{href:i,title:c||null,markdown:!0}}}function O1(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function lp(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function I1(t){let e=Ne({find:n=>{let r=E1.exec(n);return!r||!ip(n,r,t.isAllowedHref)?null:op(r)},type:t.type,getAttributes:lp});return new En({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function D1(t){let e=ve({find:n=>{var r,s;let i=[];for(let l of n.matchAll(R1))ip(n,l,t.isAllowedHref)&&i.push(op(l));let o=((r=(s=t.findPlainUrls)===null||s===void 0?void 0:s.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>O1(a,l)));return[...i,...o]},type:t.type,getAttributes:lp});return new cl({find:e.find,handler:n=>{var r;let s=e.handler(n);return s!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),s}})}function L1(t){return new L({key:new j("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=ha(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function ct(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(C1,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var ap=Ce.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){fa(t);return}fa(t.scheme,t.optionalSlashes)})},onDestroy(){rp()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!ct(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!ct(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",z(this.options.HTMLAttributes,t),0]:["a",z(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;let o=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(s=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&s!==void 0?s:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!ct(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!ct(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[I1({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:s}=this.options;ha(e,{defaultProtocol:s}).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!ct(o,r),protocols:r,defaultProtocol:s})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[D1({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!ct(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[ve({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(T1({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!ct(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(A1({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(L1({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Mi=" ",pa="\xA0",cp=K.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",z(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Mi||n[0].text===Mi||n[0].raw===pa||n[0].text===pa)&&r.length===1&&r[0].type==="text"&&(r[0].text===Mi||r[0].text===pa)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var s,i;let o=Array.isArray(n==null||(s=n.previousNode)===null||s===void 0?void 0:s.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&o.length===0?Mi:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var P1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,z1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,up=Ce.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ne({find:P1,type:this.type})]},addPasteRules(){return[ve({find:z1,type:this.type})]}});var dp=K.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var fp=Ce.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",z(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`<u>${e.renderChildren(t)}</u>`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.toLowerCase().indexOf("<u>")},tokenize(t,e,n){if(!/^<u>/i.test(t))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let s=r.exec(t);for(;s;){if(s[0].startsWith("`")){let i=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(t.slice(s.index));i&&(r.lastIndex=s.index+i[0].length)}else if(!s[0].startsWith("\\")){let i=t.slice(3,s.index);return i?{type:"underline",raw:t.slice(0,r.lastIndex),text:i,tokens:n.inlineTokens(i)}:void 0}s=r.exec(t)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function hp(t={}){return new L({view(e){return new ma(e,t)}})}var ma=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(!n||i)return null;let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=_r(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var fe=class t extends R{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):R.near(r)}content(){return v.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new ga(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!$1(e)||!B1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(t.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!N.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(t.valid(l))return l}return null}}};fe.prototype.visible=!1;fe.findFrom=fe.findGapCursorFrom;R.jsonID("gapcursor",fe);var ga=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fe.valid(n)?new fe(n):R.near(n)}};function pp(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||pp(s.type))return!0;if(s.inlineContent)return!1}}return!0}function B1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||pp(s.type))return!0;if(s.inlineContent)return!1}}return!0}function mp(){return new L({props:{decorations:_1,createSelectionBetween(t,e,n){return e.pos==n.pos&&fe.valid(n)?new fe(n):null},handleClick:F1,handleKeyDown:H1,handleDOMEvents:{beforeinput:j1}}})}var H1=lr({ArrowLeft:Ti("horiz",-1),ArrowRight:Ti("horiz",1),ArrowUp:Ti("vert",-1),ArrowDown:Ti("vert",1)});function Ti(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new fe(c))),!0):!1}}function F1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fe.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&N.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fe(r))),!0)}function j1(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=w.empty;for(let o=r.length-1;o>=0;o--)s=w.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new v(s,0,0));return i.setSelection(M.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function _1(t){if(!(t.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",_.create(t.doc,[ne.widget(t.selection.head,e,{key:"gapcursor"})])}var uM=V.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new L({key:new j("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}let o=this.storage.characters({node:r.doc});if(o>s){let l=o-s,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;let o=e.selection.$head.pos,l=o-(i-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),kp=V.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[hp(this.options)]}}),dM=V.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new L({key:new j("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return _.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(ne.node(c,c+a.nodeSize,{class:this.options.className}))}),_.create(t,i)}}})]}}),bp=V.create({name:"gapCursor",addProseMirrorPlugins(){return[mp()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=B(A(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),wp="placeholder",gp=new j("tiptap__placeholder");function xp(t){let{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),ne.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function Sp(t,e){return typeof t=="function"?t(e):t}function Cp({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:i,to:o}){let{anchor:l}=s,a=[],c=t.isEmpty;return r.nodesBetween(i,o,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&An(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(xp({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Sp(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function vp({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=s,o=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&An(c)){let d=i>=u&&i<=u+c.nodeSize;o.push(xp({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Sp(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else o.push(...Cp({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:0,to:r.content.size}));return _.create(r,o)}function Ar(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let o=n.nodeAfter?e:e-i.nodeSize;return{from:o,to:o+i.nodeSize}}let s=n.before(1);return{from:s,to:s+n.node(1).nodeSize}}function Er(t,e){return{from:Math.max(0,e.from),to:Math.min(t.content.size,e.to)}}function W1(t,e,n){let r=[];return t.forEach((s,i)=>{let o=i,l=o+s.nodeSize,a=o+1,c=l+1;a<n&&c>e&&r.push({from:o,to:l})}),r}function V1(t){if(t.length===0)return[];let e=[...t].sort((r,s)=>r.from-s.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let s=n[n.length-1],i=e[r];i.from<=s.to?s.to=Math.max(s.to,i.to):n.push({...i})}return n}function K1(t,e){let n=W1(t,e.from,e.to);return n.push(Er(t,Ar(t,e.from))),e.to>e.from?n.push(Er(t,Ar(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Er(t,Ar(t,Math.min(e.from+1,t.content.size)))),n}function U1(t,e,n){let r=[];if(t.docChanged){let s=Tn(t);for(let i of s)r.push(...K1(n.doc,i.newRange))}return t.selectionSet&&(r.push(Er(n.doc,Ar(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Er(n.doc,Ar(n.doc,n.selection.anchor)))),V1(r)}function q1(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function J1({decorations:t,ranges:e,editor:n,options:r,dataAttribute:s,doc:i,selection:o}){let l=t;for(let a of e){let{from:c,to:u}=q1(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=Cp({editor:n,options:r,dataAttribute:s,doc:i,selection:o,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function G1({editor:t,options:e,dataAttribute:n}){return{init(r,s){let i=vp({editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection});return i??_.empty},apply(r,s,i,o){return!r.docChanged&&!r.selectionSet?s:J1({decorations:s.map(r.mapping,r.doc),ranges:U1(r,i,o),editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function X1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Y1({editor:t,options:e}){let n=e.dataAttribute?`data-${X1(e.dataAttribute)}`:`data-${wp}`,r=e.showOnlyCurrent&&!e.includeChildren;return new L({key:gp,...r?{}:{state:G1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:s,selection:i})=>vp({editor:t,options:e,dataAttribute:n,doc:s,selection:i}):s=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?_.empty:(i=gp.getState(s))!==null&&i!==void 0?i:_.empty}}})}var fM=V.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:wp,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Y1({editor:this.editor,options:this.options})]}});function ya(t,e){return!t.selection.empty&&!Cs(t.selection)&&e.isEditable}function Q1(t,e){return ya(t,e)&&!e.isFocused&&!e.view.dragging}function Z1(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function eS(t){t.focus()}var hM=V.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new L({key:new j("selection"),props:{decorations(n){return Q1(n,t)?_.create(n.doc,[ne.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return ya(n.state,t)&&Z1(),!1},focus(n){return ya(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&eS(n)}),!1}}}})]}});function yp({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Mp=V.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new j(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new L({key:e,appendTransaction:(s,i,o)=>{let{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[n];if(!s.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(s,i)=>{let o=i.tr.doc.lastChild;return!yp({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;let o=s.doc.lastChild;return!yp({node:o,types:r})}}})]}}),Tp=V.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Ko(t,e),redo:()=>({state:t,dispatch:e})=>Uo(t,e)}},addProseMirrorPlugins(){return[Zu(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var tS=V.create({name:"starterKit",addExtensions(){let t=[];if(this.options.bold!==!1&&t.push(zh.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(Ph.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(ul.configure(this.options.bulletList)),this.options.code!==!1&&t.push($h.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(Bh.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Hh.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(kp.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(bp.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Fh.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(jh.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(Tp.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(_h.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Wh.configure(this.options.italic)),this.options.listItem!==!1&&t.push(hl.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(ml.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(ap.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(gl.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(cp.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(up.configure(this.options.strike)),this.options.text!==!1&&t.push(dp.configure(this.options.text)),this.options.underline!==!1){var r;t.push(fp.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var s;t.push(Mp.configure((s=this.options)===null||s===void 0?void 0:s.trailingNode))}return t}}),Ap=tS;function nS(t){let e=!1,n=new uf({element:t.element,extensions:[Ap.configure({link:{openOnClick:!1,autolink:!0}}),kl,yl.configure({nested:!0}),fh.configure({table:{resizable:!1}}),Oh],content:t.markdown,contentType:"markdown",editable:t.editable,editorProps:{attributes:{class:"art-prose","aria-label":t.label,role:"textbox","aria-multiline":"true"}},onTransaction:({editor:r})=>{let s=["heading","bold","italic","bulletList","orderedList","codeBlock"];t.onSelectionChange?.(s.filter(i=>i==="heading"?r.isActive("heading",{level:2}):r.isActive(i)))},onSelectionUpdate:({editor:r})=>{let{from:s,to:i,empty:o}=r.state.selection;t.onSelectionText?.(o?"":r.state.doc.textBetween(s,i,`
|
|
235
|
+
3. "-" cannot repeat`);q.customSchemes.push([t,e])}function J1(){q.scanner=F1(q.customSchemes);for(let t=0;t<q.tokenQueue.length;t++)q.tokenQueue[t][1]({scanner:q.scanner});q.parser=V1(q.scanner.tokens);for(let t=0;t<q.pluginQueue.length;t++)q.pluginQueue[t][1]({scanner:q.scanner,parser:q.parser});return q.initialized=!0,q}function Ni(t){return q.initialized||J1(),K1(q.parser.start,t,up(q.scanner.start,t))}Ni.scan=up;function ba(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new ya(n),s=Ni(t),i=[];for(let o=0;o<s.length;o++){let l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Oi="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",G1=new RegExp(Oi),X1=new RegExp(`${Oi}$`),Y1=new RegExp(`${Oi}+$`),Q1=new RegExp(Oi,"g");function Z1(t,e,n){var r,s;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let o=(s=t.doc.textBetween(e.from,e.to,"\uFFFC","\uFFFC").match(Y1))===null||s===void 0?void 0:s[0];if(!o)return;let l=e.to-o.length,a=yr(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function eS(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function tS(t){return new P({key:new _("autolink"),appendTransaction:(e,n,r)=>{let s=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta("preventAutolink"));if(!s||i)return;let{tr:o}=r,l=dl(n.doc,[...e]);if(!e.some(hd)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof Q)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Z1(o,c,t.type))}if(En(l).forEach(({newRange:a})=>{let c=qd(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!X1.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){let f=d.split(G1).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let m=Ni(h).map(g=>g.toObject(t.defaultProtocol));if(!eS(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{yr(g.from,g.to,r.doc).some(y=>y.mark.type===t.type)||o.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function nS(t){return new P({key:new _("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;s=a.closest("a"),s&&!c.contains(s)&&(s=null)}if(!s)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var o,l;let a=ml(e.state,t.type.name),c=(o=s.href)!==null&&o!==void 0?o:a.href,u=(l=s.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var rS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,sS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function hp(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function iS(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&hp(t,r)){r+=1;continue}let s=0;for(;r<e&&t[r]==="`";)s+=1,r+=1;n===0?n=s:s===n&&(n=0)}return n>0}function pp(t,e,n){var r,s;let[,i,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||hp(t,(r=e.index)!==null&&r!==void 0?r:0)||iS(t,(s=e.index)!==null&&s!==void 0?s:0)?!1:!!i.trim()&&n(o)}function mp(t){var e,n;let[r,s,i,,o,l,a]=t,c=(e=o??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:s,data:{href:i,title:c||null,markdown:!0}}}function oS(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function gp(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function lS(t){let e=Ie({find:n=>{let r=rS.exec(n);return!r||!pp(n,r,t.isAllowedHref)?null:mp(r)},type:t.type,getAttributes:gp});return new In({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function aS(t){let e=Te({find:n=>{var r,s;let i=[];for(let l of n.matchAll(sS))pp(n,l,t.isAllowedHref)&&i.push(mp(l));let o=((r=(s=t.findPlainUrls)===null||s===void 0?void 0:s.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>oS(a,l)));return[...i,...o]},type:t.type,getAttributes:gp});return new bl({find:e.find,handler:n=>{var r;let s=e.handler(n);return s!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),s}})}function cS(t){return new P({key:new _("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=ba(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function ut(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(Q1,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var yp=Me.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){ka(t);return}ka(t.scheme,t.optionalSlashes)})},onDestroy(){fp()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!ut(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!ut(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!ut(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",D(this.options.HTMLAttributes,t),0]:["a",D(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;let o=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(s=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&s!==void 0?s:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[lS({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!ut(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:s}=this.options;ba(e,{defaultProtocol:s}).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!ut(o,r),protocols:r,defaultProtocol:s})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[aS({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!ut(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Te({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(tS({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!ut(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(nS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(cS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var uS="listItem",kp="textStyle",bp=/^\s*([-+*])\s$/,wa=W.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
236
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uS,this.editor.getAttributes(kp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Se({find:bp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Se({find:bp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kp),editor:this.editor})),[t]}}),dS=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let h=s.depth;h>0;h-=1)if(s.node(h).type.name===e){i=h;break}if(i<0)return null;let o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;let a=o.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:s.after(),insertPos:s.after(i),items:f}},fS=(t,e,n,r)=>{let s=dS(t,n,r);if(!s)return!1;let{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=s,u=t.tr;u.delete(l,l+o.nodeSize);let d=u.mapping.map(a);return u.insert(d,w.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},hS=(t,e,n)=>fS(t.state,t.view.dispatch,e,n),Ep=(t,e)=>j.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>hS(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Rp=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ii="abcdefghijklmnopqrstuvwxyz",Np=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Pi(t){let e=t,n="";for(let[r,s]of Rp)for(;e>=r;)n+=s,e-=r;return n}function xa(t){return Pi(t).toUpperCase()}function Op(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let s=!1;for(let[i,o]of Rp)if(e.startsWith(o,n)){r+=i,n+=o.length,s=!0;break}if(!s)return 0}return r}function pS(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Op(t);return e<=0?!1:(t===t.toLowerCase()?Pi(e):xa(e))===t}function mS(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Li(t){if(t<=26)return Ii[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Ii[n]:Ii[e]+Ii[n]}function $i(t){if(!(!t||/^\d+$/.test(t))){if(pS(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function Sa(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=$i(t);if(e==="i"||e==="I")return Op(t);if(e==="a"||e==="A"){let r=mS(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function gS(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Li(e);case"A":return Li(e).toUpperCase();case"i":return Pi(e);case"I":return xa(e);default:return String(e)}}function yS(t){var e;if(t.length===0)return!1;let n=(e=$i(t[0]))!==null&&e!==void 0?e:"numeric",r=Sa(t[0]);if(r<1)return!1;for(let s=0;s<t.length;s++){let i=gS(n,r+s);if(t[s]!==i)return!1}return!0}function kS(t){return{type:$i(t),start:Sa(t)}}function bS(t){let{type:e,start:n}=kS(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function wS(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Li(r)}${n}`;case"A":return`${Li(r).toUpperCase()}${n}`;case"i":return`${Pi(r)}${n}`;case"I":return`${xa(r)}${n}`;default:return`${r}${n}`}}function xS(t){return!t[0]||t[0].type==="paragraph"?t:[{type:"paragraph",content:[]},...t]}function SS(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var CS=" ",wp=1,vS=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:wp)>wp};function MS(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function TS(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var Ca=W.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,s=[];if(t.tokens&&t.tokens.length>0){if(MS(t))return{type:"listItem",content:[{type:"paragraph",content:TS(t.text||"",e)}]};let[o,...l]=t.tokens;if(o.type==="heading"){var i;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((i=o.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type==="paragraph"))s=r(t.tokens);else if(o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));s.push(...a)}}else s=r(t.tokens)}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:xS(s)}},renderMarkdown:(t,e,n)=>{let r=o=>{if(o.parentType==="bulletList")return"- ";if(o.parentType==="orderedList"){var l,a;let c=((l=o.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return wS((a=o.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(o.index||0),". ")}return"- "},s=On(t,e,r,n,{alignNestedToPrefix:n?.parentType==="orderedList"});if(!SS(t)||!vS(n))return s;let i=r(n);return`${i}${CS}${s.slice(i.length)}`},addExtensions(){return[Ep(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),va=(t,e)=>{let{$from:n}=e.selection,r=J(t,e.schema),s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Ip=(t,e)=>{let n=va(t,e);if(!n)return!1;let[,r]=Ts(e,t,n.$pos.pos+4);return r},AS=(t,e,n)=>{let{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},xp=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ke(t.state,e)&&AS(t.state,e,n)){let{$anchor:i}=t.state.selection,o=t.state.doc.resolve(i.before()-1),l=[];o.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(o.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(i.before(),i.after()).insert(d,i.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(hn(u,d),!0)).run()}if(!ke(t.state,e)||!Rs(t.state))return!1;let{$from:r}=t.state.selection,s=r.depth-1;return r.node(s).type!==t.schema.nodes[e]||r.index(s)!==0?!1:t.chain().liftListItem(e).run()},ES=(t,e)=>{let n=Ip(t,e),r=va(t,e);return!r||!n?!1:n>r.depth},RS=(t,e)=>{let n=Ip(t,e),r=va(t,e);return!r||!n?!1:n<r.depth},Sp=(t,e)=>!ke(t.state,e)||!Es(t.state,e)||!t.state.selection.empty?!1:ES(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():RS(e,t.state)?t.commands.command(({state:n,dispatch:r})=>pn(n,r)):t.commands.joinItemForward(),NS=(t,e,n)=>{let{state:r}=t,{selection:s}=r;if(!s.empty)return!1;let{$from:i}=s;if(i.parentOffset!==0||!i.parent.isTextblock||ke(r,e))return!1;let o=As(i);if(!o||!n.includes(o.type.name))return!1;let l=o.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,w.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,w.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Ma=j.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Sp(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Sp(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xp(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xp(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&NS(t,e,n))return!0;return!1}}}}),Di=new RegExp(`^(\\s*)(${Np})([.)])\\s+(.*)$`),OS=/^\s/,Fn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function IS(t){return Di.test(t.trimStart())}function LS(t){let e=t.trimStart();return Fn.bulletItem.test(e)||IS(e)||Fn.heading.test(e)||Fn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Fn.codeFence.test(e)||Fn.blockMath.test(e)}function DS(t){return Object.values(Fn).some(e=>e.test(t))}function PS(t){let e=[],n=[],r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&LS(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function Cp(t){let e=[],n=0,r=0;for(;n<t.length;){let s=t[n],i=s.match(Di);if(!i)break;let[,o,l,a,c]=i,u=o.length,d=parseInt(l,10),f=isNaN(d)?$i(l):void 0,h=isNaN(d)?Sa(l):d,p=[c],m=n+1,g=[s],y=!1;for(;m<t.length;){let k=t[m];if(k.match(Di))break;if(k.trim()==="")g.push(k),p.push(""),y=!0,m+=1;else if(k.match(OS)){let b=k.length-k.trimStart().length,x=u+l.length+1;g.push(k),p.push(k.slice(Math.min(b,x))),m+=1}else{if(y||DS(k))break;g.push(k),p.push(k),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
|
|
237
|
+
`).trim(),contentLines:p,raw:g.join(`
|
|
238
|
+
`)}),r=m,n=m}return[e,r]}var $S=new RegExp(`^(${Np})([.)])\\s+(.+)$`);function zS(t){let e=t.split(`
|
|
239
|
+
`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let s=r.trim().match($S);if(!s)return null;n.push({marker:s[1],content:s[3]})}return yS(n.map(r=>r.marker))?{type:"orderedList",attrs:bS(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function Lp(t,e,n){let r=[],s=0;for(;s<t.length;){let i=t[s];if(i.indent===e){let{paragraphLines:o,blockLines:l}=PS(i.contentLines),a=o.join(`
|
|
240
|
+
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`
|
|
241
|
+
`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=s+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=Lp(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
|
|
242
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function BS(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){let i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var HS=64;function vp(t,e){let n=[],r=0;for(;n.length<e;){let s=t.indexOf(`
|
|
243
|
+
`,r);if(s===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,s)),r=s+1}return n}function FS(t){let e=t.indexOf(`
|
|
244
|
+
`),n=e===-1?t:t.slice(0,e);if(!Di.test(n))return[[],0,[]];let r=HS,s=vp(t,r),i=Cp(s);for(;i[1]===s.length&&s.length===r;)r*=2,s=vp(t,r),i=Cp(s);return[i[0],i[1],s]}var _S="listItem",Mp="textStyle",Tp=/^(\d+)\.\s$/;function Ap(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Ta=W.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let s=Ap(n);if(s)return s}let r=t.querySelector("li");if(r){let s=r.getAttribute("style");if(s){let i=Ap(s);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,s=D(this.options.HTMLAttributes,r);return e!==1&&(s.start=e),n&&n!=="1"&&(s.type=n),["ol",s,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,s=t.items?BS(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
245
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,s;let[i,o,l]=FS(t);if(i.length===0)return;let a=Lp(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(s=i[0])===null||s===void 0?void 0:s.type,items:a,raw:l.slice(0,o).join(`
|
|
246
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_S,this.editor.getAttributes(Mp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new P({props:{handlePaste:(t,e)=>{var n,r;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(s?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let o=zS(i);if(!o)return!1;try{let l=t.state.schema.nodeFromJSON(o),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=Se({find:Tp,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Se({find:Tp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Mp)}),joinPredicate:t,editor:this.editor})),[e]}}),jS=/^\s*(\[([( |x])?\])\s$/,WS="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",VS=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},KS=W.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",D(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return On(t,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[Ep(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=WS;let c=d=>{let f=VS(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=St(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?s.setAttribute(g,m[g]):s.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?s.setAttribute(g,m[g]):s.removeAttribute(g):s.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[Se({find:jS,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),US=W.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",D(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
247
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let o=Nn(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(o){let l={type:"taskList",raw:o.raw,items:o.items},a=i.slice(o.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},s=Nn(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),rT=j.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(wa.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Ca.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ma.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Ta.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(KS.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(US.configure(this.options.taskList)),t}});var zi=" ",Aa="\xA0",Dp=W.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",D(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===zi||n[0].text===zi||n[0].raw===Aa||n[0].text===Aa)&&r.length===1&&r[0].type==="text"&&(r[0].text===zi||r[0].text===Aa)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var s,i;let o=Array.isArray(n==null||(s=n.previousNode)===null||s===void 0?void 0:s.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&o.length===0?zi:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var qS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,JS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Pp=Me.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",D(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ie({find:qS,type:this.type})]},addPasteRules(){return[Te({find:JS,type:this.type})]}});var $p=W.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var zp=Me.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",D(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`<u>${e.renderChildren(t)}</u>`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.toLowerCase().indexOf("<u>")},tokenize(t,e,n){if(!/^<u>/i.test(t))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let s=r.exec(t);for(;s;){if(s[0].startsWith("`")){let i=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(t.slice(s.index));i&&(r.lastIndex=s.index+i[0].length)}else if(!s[0].startsWith("\\")){let i=t.slice(3,s.index);return i?{type:"underline",raw:t.slice(0,r.lastIndex),text:i,tokens:n.inlineTokens(i)}:void 0}s=r.exec(t)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Bp(t={}){return new P({view(e){return new Ea(e,t)}})}var Ea=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(!n||i)return null;let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=qr(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var fe=class t extends R{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):R.near(r)}content(){return v.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Ra(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!GS(e)||!XS(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(t.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!N.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(t.valid(l))return l}return null}}};fe.prototype.visible=!1;fe.findFrom=fe.findGapCursorFrom;R.jsonID("gapcursor",fe);var Ra=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fe.valid(n)?new fe(n):R.near(n)}};function Hp(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function GS(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Hp(s.type))return!0;if(s.inlineContent)return!1}}return!0}function XS(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Hp(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Fp(){return new P({props:{decorations:eC,createSelectionBetween(t,e,n){return e.pos==n.pos&&fe.valid(n)?new fe(n):null},handleClick:QS,handleKeyDown:YS,handleDOMEvents:{beforeinput:ZS}}})}var YS=fr({ArrowLeft:Bi("horiz",-1),ArrowRight:Bi("horiz",1),ArrowUp:Bi("vert",-1),ArrowDown:Bi("vert",1)});function Bi(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new fe(c))),!0):!1}}function QS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fe.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&N.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fe(r))),!0)}function ZS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=w.empty;for(let o=r.length-1;o>=0;o--)s=w.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new v(s,0,0));return i.setSelection(M.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function eC(t){if(!(t.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",V.create(t.doc,[ne.widget(t.selection.head,e,{key:"gapcursor"})])}var OT=j.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new P({key:new _("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}let o=this.storage.characters({node:r.doc});if(o>s){let l=o-s,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;let o=e.selection.$head.pos,l=o-(i-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),Wp=j.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bp(this.options)]}}),IT=j.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new P({key:new _("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return V.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(ne.node(c,c+a.nodeSize,{class:this.options.className}))}),V.create(t,i)}}})]}}),Vp=j.create({name:"gapCursor",addProseMirrorPlugins(){return[Fp()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=B(A(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Kp="placeholder",_p=new _("tiptap__placeholder");function Up(t){let{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),ne.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function qp(t,e){return typeof t=="function"?t(e):t}function Jp({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:i,to:o}){let{anchor:l}=s,a=[],c=t.isEmpty;return r.nodesBetween(i,o,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&Rn(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(Up({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:qp(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function Gp({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=s,o=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&Rn(c)){let d=i>=u&&i<=u+c.nodeSize;o.push(Up({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:qp(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else o.push(...Jp({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:0,to:r.content.size}));return V.create(r,o)}function Ir(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let o=n.nodeAfter?e:e-i.nodeSize;return{from:o,to:o+i.nodeSize}}let s=n.before(1);return{from:s,to:s+n.node(1).nodeSize}}function Lr(t,e){return{from:Math.max(0,e.from),to:Math.min(t.content.size,e.to)}}function tC(t,e,n){let r=[];return t.forEach((s,i)=>{let o=i,l=o+s.nodeSize,a=o+1,c=l+1;a<n&&c>e&&r.push({from:o,to:l})}),r}function nC(t){if(t.length===0)return[];let e=[...t].sort((r,s)=>r.from-s.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let s=n[n.length-1],i=e[r];i.from<=s.to?s.to=Math.max(s.to,i.to):n.push({...i})}return n}function rC(t,e){let n=tC(t,e.from,e.to);return n.push(Lr(t,Ir(t,e.from))),e.to>e.from?n.push(Lr(t,Ir(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Lr(t,Ir(t,Math.min(e.from+1,t.content.size)))),n}function sC(t,e,n){let r=[];if(t.docChanged){let s=En(t);for(let i of s)r.push(...rC(n.doc,i.newRange))}return t.selectionSet&&(r.push(Lr(n.doc,Ir(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Lr(n.doc,Ir(n.doc,n.selection.anchor)))),nC(r)}function iC(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function oC({decorations:t,ranges:e,editor:n,options:r,dataAttribute:s,doc:i,selection:o}){let l=t;for(let a of e){let{from:c,to:u}=iC(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=Jp({editor:n,options:r,dataAttribute:s,doc:i,selection:o,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function lC({editor:t,options:e,dataAttribute:n}){return{init(r,s){let i=Gp({editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection});return i??V.empty},apply(r,s,i,o){return!r.docChanged&&!r.selectionSet?s:oC({decorations:s.map(r.mapping,r.doc),ranges:sC(r,i,o),editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function aC(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function cC({editor:t,options:e}){let n=e.dataAttribute?`data-${aC(e.dataAttribute)}`:`data-${Kp}`,r=e.showOnlyCurrent&&!e.includeChildren;return new P({key:_p,...r?{}:{state:lC({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:s,selection:i})=>Gp({editor:t,options:e,dataAttribute:n,doc:s,selection:i}):s=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?V.empty:(i=_p.getState(s))!==null&&i!==void 0?i:V.empty}}})}var LT=j.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Kp,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[cC({editor:this.editor,options:this.options})]}});function Na(t,e){return!t.selection.empty&&!Ns(t.selection)&&e.isEditable}function uC(t,e){return Na(t,e)&&!e.isFocused&&!e.view.dragging}function dC(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function fC(t){t.focus()}var DT=j.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new P({key:new _("selection"),props:{decorations(n){return uC(n,t)?V.create(n.doc,[ne.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Na(n.state,t)&&dC(),!1},focus(n){return Na(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&fC(n)}),!1}}}})]}});function jp({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Xp=j.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new _(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new P({key:e,appendTransaction:(s,i,o)=>{let{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[n];if(!s.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(s,i)=>{let o=i.tr.doc.lastChild;return!jp({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;let o=s.doc.lastChild;return!jp({node:o,types:r})}}})]}}),Yp=j.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>rl(t,e),redo:()=>({state:t,dispatch:e})=>sl(t,e)}},addProseMirrorPlugins(){return[fd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var hC=j.create({name:"starterKit",addExtensions(){let t=[];if(this.options.bold!==!1&&t.push(Kh.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(Vh.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(wa.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Uh.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(qh.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Jh.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Wp.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(Vp.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Gh.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(Xh.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(Yp.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(Yh.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Qh.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Ca.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(Ma.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(yp.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(Ta.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Dp.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Pp.configure(this.options.strike)),this.options.text!==!1&&t.push($p.configure(this.options.text)),this.options.underline!==!1){var r;t.push(zp.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var s;t.push(Xp.configure((s=this.options)===null||s===void 0?void 0:s.trailingNode))}return t}}),Qp=hC;function pC(t){let e=!1,n=new bf({element:t.element,extensions:[Qp.configure({link:{openOnClick:!1,autolink:!0}}),vl,Cl.configure({nested:!0}),xh.configure({table:{resizable:!1}}),Fh],content:t.markdown,contentType:"markdown",editable:t.editable,editorProps:{attributes:{class:"art-prose","aria-label":t.label,role:"textbox","aria-multiline":"true"}},onTransaction:({editor:r})=>{let s=["heading","bold","italic","bulletList","orderedList","codeBlock"];t.onSelectionChange?.(s.filter(i=>i==="heading"?r.isActive("heading",{level:2}):r.isActive(i)))},onSelectionUpdate:({editor:r})=>{let{from:s,to:i,empty:o}=r.state.selection;t.onSelectionText?.(o?"":r.state.doc.textBetween(s,i,`
|
|
236
248
|
`))},onUpdate:({editor:r})=>{e||t.onChange(r.getMarkdown())}});return{getMarkdown:()=>n.getMarkdown(),getSelectionText:()=>{let{from:r,to:s,empty:i}=n.state.selection;return i?"":n.state.doc.textBetween(r,s,`
|
|
237
249
|
`)},setMarkdown(r){e=!0;try{n.commands.setContent(r,{contentType:"markdown",emitUpdate:!1})}finally{e=!1}},setEditable:r=>n.setEditable(r,!1),format(r){if(!n.isEditable)return;let s=n.chain().focus();switch(r){case"heading":s.toggleHeading({level:2}).run();break;case"bold":s.toggleBold().run();break;case"italic":s.toggleItalic().run();break;case"bulletList":s.toggleBulletList().run();break;case"orderedList":s.toggleOrderedList().run();break;case"codeBlock":s.toggleCodeBlock().run();break;default:{let i=r;throw new Error(String(i))}}},destroy:()=>n.destroy()}}
|
|
238
250
|
|