@tempots/beatui 0.61.2 → 0.61.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ar-CZ-UB9pc.cjs → ar-CefikVG3.cjs} +1 -1
- package/dist/{ar-TEVFGyor.js → ar-aMLQTGVh.js} +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +4 -4
- package/dist/{de-DAzM31i4.js → de-DBFOC44R.js} +1 -1
- package/dist/{de-IZSle3Nd.cjs → de-ZRnkggf5.cjs} +1 -1
- package/dist/{es-C7Gx9dqG.js → es-C4xOThaT.js} +1 -1
- package/dist/{es-DYe8rpsj.cjs → es-IkNtVSp2.cjs} +1 -1
- package/dist/{fa-CEbnfFly.cjs → fa-B-byOhgU.cjs} +1 -1
- package/dist/{fa-DKX_zJDi.js → fa-B7X_xydY.js} +1 -1
- package/dist/{fr-BRfNV0Yj.js → fr-AmjzbxN_.js} +1 -1
- package/dist/{fr-CrG0l5HN.cjs → fr-F0ZegdR2.cjs} +1 -1
- package/dist/{he-D6hsIiTH.cjs → he-BcEFNuYz.cjs} +1 -1
- package/dist/{he-DRAV97MO.js → he-DY-9yiOC.js} +1 -1
- package/dist/{hi-DyS6BNlk.cjs → hi-CarXvOJD.cjs} +1 -1
- package/dist/{hi-BaZyjzct.js → hi-Clkyp5Fu.js} +1 -1
- package/dist/{index-nqoZcPdT.js → index-CGoK9M1f.js} +3 -3
- package/dist/{index-Bu4A7nbp.js → index-D4U7cDIP.js} +1 -1
- package/dist/{index-BJxozmss.cjs → index-DJ6AuTd_.cjs} +2 -2
- package/dist/{index-Ch-e3nx4.cjs → index-J7CsYy0-.cjs} +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +10 -10
- package/dist/{it-TCCyUGRc.js → it-BC32WmGF.js} +1 -1
- package/dist/{it-5c_IK4cL.cjs → it-ops3Czzi.cjs} +1 -1
- package/dist/{ja-VrfuPGN3.cjs → ja-2dzONSkh.cjs} +1 -1
- package/dist/{ja-Bpc6MfYs.js → ja-JNSZS_Hv.js} +1 -1
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +3 -3
- package/dist/{ko-BBN3tai6.js → ko-B8l0TJp0.js} +1 -1
- package/dist/{ko-BKSVpY_x.cjs → ko-uVJEhtyQ.cjs} +1 -1
- package/dist/{modal-DA0OKusk.cjs → modal-BdeAM_B7.cjs} +1 -1
- package/dist/{modal-DJDeFIxV.js → modal-DX4x-JE5.js} +2 -2
- package/dist/{nl-CwXW1x3G.js → nl-BpYESHP8.js} +1 -1
- package/dist/{nl-Bry6kgvp.cjs → nl-DXnbYulJ.cjs} +1 -1
- package/dist/{notice-Cpso9PgQ.js → notice-BCio7XSW.js} +1 -1
- package/dist/{notice-BIcHmVnn.cjs → notice-CkABNiTZ.cjs} +1 -1
- package/dist/{pl-CI2JMYK3.cjs → pl-RbiIBA3C.cjs} +1 -1
- package/dist/{pl-utONv5st.js → pl-_sWhGdrs.js} +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/{pt-pg3nMUQB.cjs → pt-BAecyAv-.cjs} +1 -1
- package/dist/{pt-BKZlur2O.js → pt-BmiQvHUz.js} +1 -1
- package/dist/{ru-DcagJ4uT.cjs → ru-DZ4gJ6yr.cjs} +1 -1
- package/dist/{ru-B6HTgTqQ.js → ru-DacnqexG.js} +1 -1
- package/dist/{toolbar-_yJ-dm-Z.js → toolbar-Bk5-22ln.js} +1 -1
- package/dist/{toolbar-CC22Z53U.cjs → toolbar-wEm8iNet.cjs} +1 -1
- package/dist/{tr-BabBuwqd.cjs → tr-7jGF_acJ.cjs} +1 -1
- package/dist/{tr-DhELxnEm.js → tr-BSS5b_v6.js} +1 -1
- package/dist/{translations-g3qGTkzw.js → translations-BUTBIDsS.js} +36 -36
- package/dist/{translations-BRRDPpLp.cjs → translations-C7HVMcOQ.cjs} +1 -1
- package/dist/translations-hMQlZmD4.cjs +1 -0
- package/dist/{translations-ConAsIH1.js → translations-zGwuSQWQ.js} +1 -1
- package/dist/{ur-CT09S1x5.js → ur-C6Ky6OCl.js} +1 -1
- package/dist/{ur-BVE5ZRyR.cjs → ur-ZT6fZFId.cjs} +1 -1
- package/dist/{utils-B25pniId.cjs → utils-BjJCDm_6.cjs} +1 -1
- package/dist/{utils-BRzdi3Gx.js → utils-jsPYqpvC.js} +2 -2
- package/dist/{vi-BsZzI9Fa.js → vi-Bx2gx2S0.js} +1 -1
- package/dist/{vi-DvU7fKay.cjs → vi-tNs62pgs.cjs} +1 -1
- package/dist/{zh-CijYgDFA.cjs → zh-CBnP8_Lf.cjs} +1 -1
- package/dist/{zh-BeCkrv4q.js → zh-eixtg-Ce.js} +1 -1
- package/package.json +1 -1
- package/dist/translations-DM5R5VZ0.cjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";const A=require("@tempots/dom"),It=require("./toolbar-CC22Z53U.cjs"),Rr=require("./translations-DM5R5VZ0.cjs"),No=require("./link-portal-_tiDFZqh.cjs"),Io=require("@tempots/ui"),Ro=require("./theme-Dt6lCAvY.cjs");function q(t){this.content=t}q.prototype={constructor:q,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,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new q(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 q(n)},addToStart:function(t,e){return new q([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new q(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new q(u)},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=q.from(t),t.size?new q(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=q.from(t),t.size?new q(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=q.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}};q.from=function(t){if(t instanceof q)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new q(e)};function Fi(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Fi(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Ni(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Ni(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class x{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,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new x(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new x(r,u)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new x(u,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(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 u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Fi(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ni(this,e,n,r)}findIndex(e){if(e==0)return tn(0,e);if(e==this.size)return tn(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 u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?tn(n+1,i):tn(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 x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new x(n||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Pn={index:0,offset:0};function tn(t,e){return Pn.index=t,Pn.offset=e,Pn}function hn(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(!hn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class w{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),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&&hn(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`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}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 w.none;if(e instanceof w)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}w.none=[];class pn extends Error{}class C{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=Ri(this.content,e+this.openStart,n);return r&&new C(r,this.openStart,this.openEnd)}removeBetween(e,n){return new C(Ii(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 C.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new C(x.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=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)u++;return new C(e,r,u)}}C.empty=new C(x.empty,0,0);function Ii(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ii(i.content,e-u-1,n-u-1)))}function Ri(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Ri(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function Bo(t,e,n){if(n.openStart>t.depth)throw new pn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pn("Inconsistent open depths");return Bi(t,e,n,0)}function Bi(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=Bi(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ge(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=vo(n,t);return Ge(i,zi(t,s,o,e,r))}else return Ge(i,mn(t,e,r))}function vi(t,e){if(!e.type.compatibleContent(t.type))throw new pn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return vi(r,e.node(n)),r}function Ze(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 wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ze(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ze(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ze(e.nodeBefore,r)}function Ge(t,e){return t.type.checkContent(e),t.copy(e)}function zi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(vi(i,s),Ze(Ge(i,zi(t,e,n,r,u+1)),o)):(i&&Ze(Ge(i,mn(t,e,u+1)),o),wt(e,n,u,o),s&&Ze(Ge(s,mn(n,r,u+1)),o)),wt(r,null,u,o),new x(o)}function mn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ze(Ge(u,mn(t,e,n+1)),r)}return wt(e,null,n,r),new x(r)}function vo(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(x.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{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],u=e.child(n);return r?e.child(n).cut(r):u}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],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return w.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.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 Pi(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=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=ou.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else ou.set(e,r=new zo);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%Po,u}}class zo{constructor(){this.elts=[],this.i=0}}const Po=12,ou=new WeakMap;class Pi{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)}}const Lo=Object.create(null);class xe{constructor(e,n,r,u=w.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||x.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,u=0){this.content.nodesBetween(e,n,r,u,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,u){return this.content.textBetween(e,n,r,u)}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&&hn(this.attrs,n||e.defaultAttrs||Lo)&&w.sameSet(this.marks,r||w.none)}copy(e=null){return e==this.content?this:new xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xe(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 C.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new C(a,u.depth-s,i.depth-s)}replace(e,n,r){return Bo(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+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 u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}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()+")"),Li(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=x.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=w.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!w.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 u=x.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}xe.prototype.text=void 0;class gn extends xe{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Li(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(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 Li(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class et{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new qo(e,n);if(r.next==null)return et.empty;let u=qi(r);r.next&&r.err("Unexpected trailing text");let i=Uo(jo(u));return Ko(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 u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}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 u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return x.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}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 u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.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 u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
1
|
+
"use strict";const A=require("@tempots/dom"),It=require("./toolbar-wEm8iNet.cjs"),Rr=require("./translations-hMQlZmD4.cjs"),No=require("./link-portal-_tiDFZqh.cjs"),Io=require("@tempots/ui"),Ro=require("./theme-Dt6lCAvY.cjs");function q(t){this.content=t}q.prototype={constructor:q,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,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new q(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 q(n)},addToStart:function(t,e){return new q([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new q(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new q(u)},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=q.from(t),t.size?new q(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=q.from(t),t.size?new q(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=q.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}};q.from=function(t){if(t instanceof q)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new q(e)};function Fi(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Fi(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Ni(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Ni(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class x{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,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new x(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new x(r,u)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new x(u,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(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 u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Fi(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ni(this,e,n,r)}findIndex(e){if(e==0)return tn(0,e);if(e==this.size)return tn(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 u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?tn(n+1,i):tn(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 x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new x(n||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Pn={index:0,offset:0};function tn(t,e){return Pn.index=t,Pn.offset=e,Pn}function hn(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(!hn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class w{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),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&&hn(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`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}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 w.none;if(e instanceof w)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}w.none=[];class pn extends Error{}class C{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=Ri(this.content,e+this.openStart,n);return r&&new C(r,this.openStart,this.openEnd)}removeBetween(e,n){return new C(Ii(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 C.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new C(x.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=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)u++;return new C(e,r,u)}}C.empty=new C(x.empty,0,0);function Ii(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ii(i.content,e-u-1,n-u-1)))}function Ri(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Ri(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function Bo(t,e,n){if(n.openStart>t.depth)throw new pn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pn("Inconsistent open depths");return Bi(t,e,n,0)}function Bi(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=Bi(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ge(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=vo(n,t);return Ge(i,zi(t,s,o,e,r))}else return Ge(i,mn(t,e,r))}function vi(t,e){if(!e.type.compatibleContent(t.type))throw new pn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return vi(r,e.node(n)),r}function Ze(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 wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ze(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ze(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ze(e.nodeBefore,r)}function Ge(t,e){return t.type.checkContent(e),t.copy(e)}function zi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(vi(i,s),Ze(Ge(i,zi(t,e,n,r,u+1)),o)):(i&&Ze(Ge(i,mn(t,e,u+1)),o),wt(e,n,u,o),s&&Ze(Ge(s,mn(n,r,u+1)),o)),wt(r,null,u,o),new x(o)}function mn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ze(Ge(u,mn(t,e,n+1)),r)}return wt(e,null,n,r),new x(r)}function vo(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(x.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{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],u=e.child(n);return r?e.child(n).cut(r):u}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],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return w.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.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 Pi(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=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=ou.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else ou.set(e,r=new zo);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%Po,u}}class zo{constructor(){this.elts=[],this.i=0}}const Po=12,ou=new WeakMap;class Pi{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)}}const Lo=Object.create(null);class xe{constructor(e,n,r,u=w.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||x.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,u=0){this.content.nodesBetween(e,n,r,u,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,u){return this.content.textBetween(e,n,r,u)}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&&hn(this.attrs,n||e.defaultAttrs||Lo)&&w.sameSet(this.marks,r||w.none)}copy(e=null){return e==this.content?this:new xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xe(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 C.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new C(a,u.depth-s,i.depth-s)}replace(e,n,r){return Bo(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+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 u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}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()+")"),Li(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=x.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=w.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!w.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 u=x.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}xe.prototype.text=void 0;class gn extends xe{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Li(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(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 Li(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class et{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new qo(e,n);if(r.next==null)return et.empty;let u=qi(r);r.next&&r.err("Unexpected trailing text");let i=Uo(jo(u));return Ko(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 u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}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 u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return x.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}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 u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.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 u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
2
2
|
`)}}et.empty=new et(!0);class qo{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 qi(t){let e=[];do e.push(Vo(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vo(t){let e=[];do e.push($o(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $o(t){let e=Jo(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=Wo(t,e);else break;return e}function lu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wo(t,e){let n=lu(t),r=n;return t.eat(",")&&(t.next!="}"?r=lu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Ho(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let u=[];for(let i in n){let s=n[i];s.isInGroup(e)&&u.push(s)}return u.length==0&&t.err("No node type or group '"+e+"' found"),u}function Jo(t){if(t.eat("(")){let e=qi(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=Ho(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 jo(t){let e=[[]];return u(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let a={term:l,to:o};return e[s].push(a),a}function u(s,o){s.forEach(l=>l.to=o)}function i(s,o){if(s.type=="choice")return s.exprs.reduce((l,a)=>l.concat(i(a,o)),[]);if(s.type=="seq")for(let l=0;;l++){let a=i(s.exprs[l],o);if(l==s.exprs.length-1)return a;u(a,o=n())}else if(s.type=="star"){let l=n();return r(o,l),u(i(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return u(i(s.expr,o),l),u(i(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(i(s.expr,o));if(s.type=="range"){let l=o;for(let a=0;a<s.min;a++){let c=n();u(i(s.expr,l),c),l=c}if(s.max==-1)u(i(s.expr,l),l);else for(let a=s.min;a<s.max;a++){let c=n();r(l,c),u(i(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Vi(t,e){return e-t}function au(t,e){let n=[];return r(e),n.sort(Vi);function r(u){let i=t[u];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(u);for(let s=0;s<i.length;s++){let{term:o,to:l}=i[s];!o&&n.indexOf(l)==-1&&r(l)}}}function Uo(t){let e=Object.create(null);return n(au(t,0));function n(r){let u=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let a;for(let c=0;c<u.length;c++)u[c][0]==o&&(a=u[c][1]);au(t,l).forEach(c=>{a||u.push([o,a=[]]),a.indexOf(c)==-1&&a.push(c)})})});let i=e[r.join(",")]=new et(r.indexOf(t.length-1)>-1);for(let s=0;s<u.length;s++){let o=u[s][1].sort(Vi);i.next.push({type:u[s][0],next:e[o.join(",")]||n(o)})}return i}}function Ko(t,e){for(let n=0,r=[t];n<r.length;n++){let u=r[n],i=!u.validEnd,s=[];for(let o=0;o<u.next.length;o++){let{type:l,next:a}=u.next[o];s.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(a)==-1&&r.push(a)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function $i(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 Wi(t,e){let n=Object.create(null);for(let r in t){let u=e&&e[r];if(u===void 0){let i=t[r];if(i.hasDefault)u=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=u}return n}function Hi(t,e,n,r){for(let u in e)if(!(u in t))throw new RangeError(`Unsupported attribute ${u} for ${n} of type ${u}`);for(let u in t){let i=t[u];i.validate&&i.validate(e[u])}}function Ji(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Go(t,r,e[r]);return n}let cu=class ji{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=Ji(e,r.attrs),this.defaultAttrs=$i(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==et.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:Wi(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xe(this,this.computeAttrs(e),x.from(n),w.setFrom(r))}createChecked(e=null,n,r){return n=x.from(n),this.checkContent(n),new xe(this,this.computeAttrs(e),n,w.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=x.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let u=this.contentMatch.matchFragment(n),i=u&&u.fillBefore(x.empty,!0);return i?new xe(this,e,n.append(i),w.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){Hi(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let 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:w.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new ji(i,n,s));let u=n.spec.topNode||"doc";if(!r[u])throw new RangeError("Schema is missing its top node type ('"+u+"')");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 Zo(t,e,n){let r=n.split("|");return u=>{let i=u===null?"null":typeof u;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class Go{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Zo(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Mn{constructor(e,n,r,u){this.name=e,this.rank=n,this.schema=r,this.spec=u,this.attrs=Ji(e,u.attrs),this.excluded=null;let i=$i(this.attrs);this.instance=i?new w(this,i):null}create(e=null){return!e&&this.instance?this.instance:new w(this,Wi(this.attrs,e))}static compile(e,n){let r=Object.create(null),u=0;return e.forEach((i,s)=>r[i]=new Mn(i,u++,n,s)),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]}checkAttrs(e){Hi(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Br{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let u in e)n[u]=e[u];n.nodes=q.from(e.nodes),n.marks=q.from(e.marks||{}),this.nodes=cu.compile(this.spec.nodes,this),this.marks=Mn.compile(this.spec.marks,this);let r=Object.create(null);for(let u in this.nodes){if(u in this.marks)throw new RangeError(u+" can not be both a node and a mark");let i=this.nodes[u],s=i.spec.content||"",o=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=et.parse(s,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=o=="_"?null:o?fu(this,o.split(" ")):o==""||!i.inlineContent?[]:null}for(let u in this.marks){let i=this.marks[u],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:fu(this,s.split(" "))}this.nodeFromJSON=u=>xe.fromJSON(this,u),this.markFromJSON=u=>w.fromJSON(this,u),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,u){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof cu){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,u)}text(e,n){let r=this.nodes.text;return new gn(r,r.defaultAttrs,e,w.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 fu(t,e){let n=[];for(let r=0;r<e.length;r++){let u=e[r],i=t.marks[u],s=i;if(i)n.push(i);else for(let o in t.marks){let l=t.marks[o];(u=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(u)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Yo(t){return t.tag!=null}function Xo(t){return t.style!=null}class Bt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(u=>{if(Yo(u))this.tags.push(u);else if(Xo(u)){let i=/[^=]*/.exec(u.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(u)}}),this.normalizeLists=!this.tags.some(u=>{if(!/^(ul|ol)\b/.test(u.tag)||!u.node)return!1;let i=e.nodes[u.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new hu(this,n,!1);return r.addAll(e,w.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new hu(this,n,!0);return r.addAll(e,w.none,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let u=r?this.tags.indexOf(r)+1:0;u<this.tags.length;u++){let i=this.tags[u];if(tl(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,u){for(let i=u?this.styles.indexOf(u)+1:0;i<this.styles.length;i++){let s=this.styles[i],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(u){let i=u.priority==null?50:u.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<i)break}n.splice(s,0,u)}for(let u in e.marks){let i=e.marks[u].spec.parseDOM;i&&i.forEach(s=>{r(s=pu(s)),s.mark||s.ignore||s.clearMark||(s.mark=u)})}for(let u in e.nodes){let i=e.nodes[u].spec.parseDOM;i&&i.forEach(s=>{r(s=pu(s)),s.node||s.ignore||s.mark||(s.node=u)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Ui={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Qo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ki={ol:!0,ul:!0},vt=1,mr=2,Tt=4;function du(t,e,n){return e!=null?(e?vt:0)|(e==="full"?mr:0):t&&t.whitespace=="pre"?vt|mr:n&~Tt}class nn{constructor(e,n,r,u,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=u,this.options=s,this.content=[],this.activeMarks=w.none,this.match=i||(s&Tt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(x.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,u;return(u=r.findWrapping(e.type))?(this.match=r,u):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&vt)){let r=this.content[this.content.length-1],u;if(r&&r.isText&&(u=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==u[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-u[0].length))}}let n=x.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(x.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&&!Ui.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class hu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let u=n.topNode,i,s=du(null,n.preserveWhitespace,0)|(r?Tt:0);u?i=new nn(u.type,u.attrs,w.none,!0,n.topMatch||u.type.contentMatch,s):r?i=new nn(null,null,w.none,!0,null,s):i=new nn(e.schema.topNodeType,null,w.none,!0,null,s),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,u=this.top,i=u.options&mr?"full":this.localPreserveWS||(u.options&vt)>0,{schema:s}=this.parser;if(i==="full"||u.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));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 o=u.content[u.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let u=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;Ki.hasOwnProperty(s)&&this.parser.normalizeLists&&el(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Qo.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let a,c=this.needsBlock;if(Ui.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),a&&this.sync(i),this.needsBlock=c}else{let a=this.readStyles(e,n);a&&this.addElementByRule(e,l,a,l.consuming===!1?o:void 0)}this.localPreserveWS=u}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),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 u=0;u<this.parser.matchedStyles.length;u++){let i=this.parser.matchedStyles[u],s=r.getPropertyValue(i);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(i,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(a=>!l.clearMark(a)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,u){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(u)this.addElement(e,r,u);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(o)&&this.open--}addAll(e,n,r,u){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=u==null?null:e.childNodes[u];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let u,i;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(e);if(a&&(!u||u.length>a.length+o)&&(u=a,i=l,!a.length))break;if(l.solid){if(r)break;o+=2}}if(!u)return null;this.sync(i);for(let s=0;s<u.length;s++)n=this.enterInner(u[s],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 u=this.findPlace(e,n,r);if(u){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=w.none;for(let o of u.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):mu(o.type,e.type))&&(s=o.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,u){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,u)),i}enterInner(e,n,r,u=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=du(e,i,s.options);s.options&Tt&&s.content.length==0&&(o|=Tt);let l=w.none;return r=r.filter(a=>(s.type?s.type.allowsMarkType(a.type):mu(a.type,e))?(l=a.addToSet(l),!1):!0),this.nodes.push(new nn(e,n,l,u,null,o)),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|=vt)}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 u=r.length-1;u>=0;u--)e+=r[u].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 u=0;u<this.find.length;u++)this.find[u].pos==null&&e.nodeType==1&&e.contains(this.find[u].node)&&n.compareDocumentPosition(this.find[u].node)&(r?2:4)&&(this.find[u].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,u=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(u?0:1),s=(o,l)=>{for(;o>=0;o--){let a=n[o];if(a==""){if(o==n.length-1||o==0)continue;for(;l>=i;l--)if(s(o-1,l))return!0;return!1}else{let c=l>0||l==0&&u?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!c||c.name!=a&&!c.isInGroup(a))return!1;l--}}return!0};return s(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 el(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ki.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function tl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function pu(t){let e={};for(let n in t)e[n]=t[n];return e}function mu(t,e){let n=e.schema.nodes;for(let r in n){let u=n[r];if(!u.allowsMarkType(t))continue;let i=[],s=o=>{i.push(o);for(let l=0;l<o.edgeCount;l++){let{type:a,next:c}=o.edge(l);if(a==e||i.indexOf(c)<0&&s(c))return!0}};if(s(u.contentMatch))return!0}}class xt{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ln(n).createDocumentFragment());let u=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let o=0,l=0;for(;o<i.length&&l<s.marks.length;){let a=s.marks[l];if(!this.marks[a.type.name]){l++;continue}if(!a.eq(i[o][0])||a.type.spec.spanning===!1)break;o++,l++}for(;o<i.length;)u=i.pop()[1];for(;l<s.marks.length;){let a=s.marks[l++],c=this.serializeMark(a,s.isInline,n);c&&(i.push([a,u]),u.appendChild(c.dom),u=c.contentDOM||c.dom)}}u.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:u}=ln(Ln(n),this.nodes[e.type.name](e),null,e.attrs);if(u){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,u)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let u=e.marks.length-1;u>=0;u--){let i=this.serializeMark(e.marks[u],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let u=this.marks[e.type.name];return u&&ln(Ln(r),u(e,n),null,e.attrs)}static renderSpec(e,n,r=null,u){return ln(e,n,r,u)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new xt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=gu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return gu(e.marks)}}function gu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ln(t){return t.document||window.document}const bu=new WeakMap;function nl(t){let e=bu.get(t);return e===void 0&&bu.set(t,e=rl(t)),e}function rl(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 u=0;u<r.length;u++)n(r[u]);else for(let u in r)n(r[u])}return n(t),e}function ln(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let u=e[0],i;if(typeof u!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=nl(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 s=u.indexOf(" ");s>0&&(n=u.slice(0,s),u=u.slice(s+1));let o,l=n?t.createElementNS(n,u):t.createElement(u),a=e[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let f in a)if(a[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),a[f]):f=="style"&&l.style?l.style.cssText=a[f]:l.setAttribute(f,a[f])}}for(let f=c;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:d}=ln(t,p,n,r);if(l.appendChild(h),d){if(o)throw new RangeError("Multiple content holes");o=d}}}return{dom:l,contentDOM:o}}const Zi=65535,Gi=Math.pow(2,16);function ul(t,e){return t+e*Gi}function xu(t){return t&Zi}function il(t){return(t-(t&Zi))/Gi}const Yi=1,Xi=2,an=4,Qi=8;class gr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Qi)>0}get deletedBefore(){return(this.delInfo&(Yi|an))>0}get deletedAfter(){return(this.delInfo&(Xi|an))>0}get deletedAcross(){return(this.delInfo&an)>0}}class Q{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Q.empty)return Q.empty}recover(e){let n=0,r=xu(e);if(!this.inverted)for(let u=0;u<r;u++)n+=this.ranges[u*3+2]-this.ranges[u*3+1];return this.ranges[r*3]+n+il(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 u=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?u:0);if(l>e)break;let a=this.ranges[o+i],c=this.ranges[o+s],f=l+a;if(e<=f){let p=a?e==l?-1:e==f?1:n:n,h=l+u+(p<0?0:c);if(r)return h;let d=e==(n<0?l:f)?null:ul(o/3,e-l),m=e==l?Xi:e==f?Yi:an;return(n<0?e!=l:e!=f)&&(m|=Qi),new gr(h,m,d)}u+=c-a}return r?e+u:new gr(e+u,0,null)}touches(e,n){let r=0,u=xu(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[o+i],c=l+a;if(e<=c&&o==u*3)return!0;r+=this.ranges[o+s]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let u=0,i=0;u<this.ranges.length;u+=3){let s=this.ranges[u],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),a=this.ranges[u+n],c=this.ranges[u+r];e(o,o+a,l,l+c),i+=c-a}}invert(){return new Q(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Q.empty:new Q(e<0?[0,-e,0]:[0,0,e])}}Q.empty=new Q([]);class zt{constructor(e,n,r=0,u=e?e.length:0){this.mirror=n,this.from=r,this.to=u,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new zt(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 u=e.getMirror(n);this.appendMap(e._maps[n],u!=null&&u<n?r+u: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 u=e.getMirror(n);this.appendMap(e._maps[n].invert(),u!=null&&u>n?r-u-1:void 0)}}invert(){let e=new zt;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 u=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(o.recover);continue}}u|=o.delInfo,e=o.pos}return r?e:new gr(e,u,null)}}const qn=Object.create(null);class j{getMap(){return Q.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=qn[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 qn)throw new RangeError("Duplicate use of step JSON ID "+e);return qn[e]=n,n.prototype.jsonID=e,n}}class B{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,n,r,u){try{return B.ok(e.replace(n,r,u))}catch(i){if(i instanceof pn)return B.fail(i.message);throw i}}}function vr(t,e,n){let r=[];for(let u=0;u<t.childCount;u++){let i=t.child(u);i.content.size&&(i=i.copy(vr(i.content,e,i))),i.isInline&&(i=e(i,n,u)),r.push(i)}return x.fromArray(r)}class Be extends j{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),u=r.node(r.sharedDepth(this.to)),i=new C(vr(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),u),n.openStart,n.openEnd);return B.fromReplace(e,this.from,this.to,i)}invert(){return new me(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Be(n.pos,r.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(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 Be(n.from,n.to,e.markFromJSON(n.mark))}}j.jsonID("addMark",Be);class me extends j{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 C(vr(n.content,u=>u.mark(this.mark.removeFromSet(u.marks)),e),n.openStart,n.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Be(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new me(n.pos,r.pos,this.mark)}merge(e){return e instanceof me&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new me(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 me(n.from,n.to,e.markFromJSON(n.mark))}}j.jsonID("removeMark",me);class ve extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return B.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return B.fromReplace(e,this.pos,this.pos+1,new C(x.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 u=0;u<n.marks.length;u++)if(!n.marks[u].isInSet(r))return new ve(this.pos,n.marks[u]);return new ve(this.pos,this.mark)}}return new tt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ve(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 ve(n.pos,e.markFromJSON(n.mark))}}j.jsonID("addNodeMark",ve);class tt extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return B.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return B.fromReplace(e,this.pos,this.pos+1,new C(x.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ve(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new tt(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 tt(n.pos,e.markFromJSON(n.mark))}}j.jsonID("removeNodeMark",tt);class H extends j{constructor(e,n,r,u=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=u}apply(e){return this.structure&&br(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Q([this.from,this.to-this.from,this.slice.size])}invert(e){return new H(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new H(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof H)||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?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new H(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?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new H(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 H(n.from,n.to,C.fromJSON(e,n.slice),!!n.structure)}}j.jsonID("replace",H);class G extends j{constructor(e,n,r,u,i,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=u,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(br(e,this.from,this.gapFrom)||br(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return B.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?B.fromReplace(e,this.from,this.to,r):B.fail("Content does not fit in gap")}getMap(){return new Q([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 G(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),u=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||u<n.pos||i>r.pos?null:new G(n.pos,r.pos,u,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 G(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}}j.jsonID("replaceAround",G);function br(t,e,n){let r=t.resolve(e),u=n-e,i=r.depth;for(;u>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,u--;if(u>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;u>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,u--}}return!1}function sl(t,e,n,r){let u=[],i=[],s,o;t.doc.nodesBetween(e,n,(l,a,c)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let p=Math.max(a,e),h=Math.min(a+l.nodeSize,n),d=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(d)||(s&&s.to==p&&s.mark.eq(f[m])?s.to=h:u.push(s=new me(p,h,f[m])));o&&o.to==p?o.to=h:i.push(o=new Be(p,h,r))}}),u.forEach(l=>t.step(l)),i.forEach(l=>t.step(l))}function ol(t,e,n,r){let u=[],i=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;i++;let l=null;if(r instanceof Mn){let a=s.marks,c;for(;c=r.isInSet(a);)(l||(l=[])).push(c),a=c.removeFromSet(a)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let a=Math.min(o+s.nodeSize,n);for(let c=0;c<l.length;c++){let f=l[c],p;for(let h=0;h<u.length;h++){let d=u[h];d.step==i-1&&f.eq(u[h].style)&&(p=d)}p?(p.to=a,p.step=i):u.push({style:f,from:Math.max(o,e),to:a,step:i})}}}),u.forEach(s=>t.step(new me(s.from,s.to,s.style)))}function zr(t,e,n,r=n.contentMatch,u=!0){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<i.childCount;l++){let a=i.child(l),c=o+a.nodeSize,f=r.matchType(a.type);if(!f)s.push(new H(o,c,C.empty));else{r=f;for(let p=0;p<a.marks.length;p++)n.allowsMarkType(a.marks[p].type)||t.step(new me(o,c,a.marks[p]));if(u&&a.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,d;for(;p=h.exec(a.text);)d||(d=new C(x.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new H(o+p.index,o+p.index+p[0].length,d))}}o=c}if(!r.validEnd){let l=r.fillBefore(x.empty,!0);t.replace(o,o,new C(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function ll(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let u=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&u.canReplace(i,s,n))return r;if(r==0||u.type.spec.isolating||!ll(u,i,s))break}return null}function al(t,e,n){let{$from:r,$to:u,depth:i}=e,s=r.before(i+1),o=u.after(i+1),l=s,a=o,c=x.empty,f=0;for(let d=i,m=!1;d>n;d--)m||r.index(d)>0?(m=!0,c=x.from(r.node(d).copy(c)),f++):l--;let p=x.empty,h=0;for(let d=i,m=!1;d>n;d--)m||u.after(d+1)<u.end(d)?(m=!0,p=x.from(u.node(d).copy(p)),h++):a++;t.step(new G(l,a,s,o,new C(c.append(p),f,h),c.size-f,!0))}function es(t,e,n=null,r=t){let u=cl(t,e),i=u&&fl(r,e);return i?u.map(ku).concat({type:e,attrs:n}).concat(i.map(ku)):null}function ku(t){return{type:t,attrs:null}}function cl(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,u,s)?i:null}function fl(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let a=r;l&&a<u;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:s}function dl(t,e,n){let r=x.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(n[s].type.create(n[s].attrs,r))}let u=e.start,i=e.end;t.step(new G(u,i,u,i,new C(r,0,0),n.length,!0))}function hl(t,e,n,r,u){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof u=="function"?u(s):u;if(s.isTextblock&&!s.hasMarkup(r,l)&&pl(t.doc,t.mapping.slice(i).map(o),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",d=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!d?a=!1:!h&&d&&(a=!0)}a===!1&&ns(t,s,o,i),zr(t,t.mapping.slice(i).map(o,1),r,void 0,a===null);let c=t.mapping.slice(i),f=c.map(o,1),p=c.map(o+s.nodeSize,1);return t.step(new G(f,p,f+1,p-1,new C(x.from(r.create(l,null,s.marks)),0,0),1,!0)),a===!0&&ts(t,s,o,i),!1}})}function ts(t,e,n,r){e.forEach((u,i)=>{if(u.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(u.text);){let l=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function ns(t,e,n,r){e.forEach((u,i)=>{if(u.type==u.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
|
|
5
5
|
`))}})}function pl(t,e,n){let r=t.resolve(e),u=r.index();return r.parent.canReplaceWith(u,u+1,n)}function ml(t,e,n,r,u){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,u||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new G(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new C(x.from(s),0,0),1,!0))}function Ot(t,e,n=1,r){let u=t.resolve(e),i=u.depth-n,s=r&&r[r.length-1]||u.parent;if(i<0||u.parent.type.spec.isolating||!u.parent.canReplace(u.index(),u.parent.childCount)||!s.type.validContent(u.parent.content.cutByIndex(u.index(),u.parent.childCount)))return!1;for(let a=u.depth-1,c=n-2;a>i;a--,c--){let f=u.node(a),p=u.index(a);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(p,f.childCount),d=r&&r[c+1];d&&(h=h.replaceChild(0,d.type.create(d.attrs)));let m=r&&r[c]||f;if(!f.canReplace(p+1,f.childCount)||!m.type.validContent(h))return!1}let o=u.indexAfter(i),l=r&&r[0];return u.node(i).canReplaceWith(o,o,l?l.type:u.node(i+1).type)}function gl(t,e,n=1,r){let u=t.doc.resolve(e),i=x.empty,s=x.empty;for(let o=u.depth,l=u.depth-n,a=n-1;o>l;o--,a--){i=x.from(u.node(o).copy(i));let c=r&&r[a];s=x.from(c?c.type.create(c.attrs,s):u.node(o).copy(s))}t.step(new H(e,e,new C(i.append(s),n,n),!0))}function Pr(t,e){let n=t.resolve(e),r=n.index();return xl(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bl(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let u=0;u<e.childCount;u++){let i=e.child(u),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function xl(t,e){return!!(t&&e&&!t.isLeaf&&bl(t,e))}function kl(t,e,n){let r=null,{linebreakReplacement:u}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(u&&s.inlineContent){let c=s.whitespace=="pre",f=!!s.contentMatch.matchType(u);c&&!f?r=!1:!c&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let c=t.doc.resolve(e+n);ns(t,c.node(),c.before(),o)}s.inlineContent&&zr(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let l=t.mapping.slice(o),a=l.map(e-n);if(t.step(new H(a,l.map(e+n,-1),C.empty,!0)),r===!0){let c=t.doc.resolve(a);ts(t,c.node(),c.before(),t.steps.length)}return t}function yl(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 u=r.depth-1;u>=0;u--){let i=r.index(u);if(r.node(u).canReplaceWith(i,i,n))return r.before(u+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let u=r.depth-1;u>=0;u--){let i=r.indexAfter(u);if(r.node(u).canReplaceWith(i,i,n))return r.after(u+1);if(i<r.node(u).childCount)return null}return null}function Cl(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let u=n.content;for(let i=0;i<n.openStart;i++)u=u.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(o>0?1:0),a=r.node(s),c=!1;if(i==1)c=a.canReplace(l,l,u);else{let f=a.contentMatchAt(l).findWrapping(u.firstChild.type);c=f&&a.canReplaceWith(l,l,f[0])}if(c)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function Lr(t,e,n=e,r=C.empty){if(e==n&&!r.size)return null;let u=t.resolve(e),i=t.resolve(n);return rs(u,i,r)?new H(e,n,r):new Dl(u,i,r).fit()}function rs(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Dl{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let u=0;u<=e.depth;u++){let i=e.node(u);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(u))})}for(let u=e.depth;u>0;u--)this.placed=x.from(e.node(u).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,u=this.close(e<0?this.$to:r.doc.resolve(e));if(!u)return null;let i=this.placed,s=r.depth,o=u.depth;for(;s&&o&&i.childCount==1;)i=i.firstChild.content,s--,o--;let l=new C(i,s,o);return e>-1?new G(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new H(r.pos,u.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,u=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(u=0),i.type.spec.isolating&&u<=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 u,i=null;r?(i=Vn(this.unplaced.content,r-1).firstChild,u=i.content):u=this.unplaced.content;let s=u.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:a}=this.frontier[o],c,f=null;if(n==1&&(s?a.matchType(s.type)||(f=a.fillBefore(x.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:o,parent:i,inject:f};if(n==2&&s&&(c=a.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:i,wrap:c};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,u=Vn(e,n);return!u.childCount||u.firstChild.isLeaf?!1:(this.unplaced=new C(e,n+1,Math.max(r,u.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,u=Vn(e,n);if(u.childCount<=1&&n>0){let i=e.size-n<=n+u.size;this.unplaced=new C(St(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new C(St(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:u,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-e,a=0,c=[],{match:f,type:p}=this.frontier[n];if(u){for(let m=0;m<u.childCount;m++)c.push(u.child(m));f=f.matchFragment(u)}let h=o.size+e-(s.content.size-s.openEnd);for(;a<o.childCount;){let m=o.child(a),g=f.matchType(m.type);if(!g)break;a++,(a>1||l==0||m.content.size)&&(f=g,c.push(us(m.mark(p.allowedMarks(m.marks)),a==1?l:0,a==o.childCount?h:-1)))}let d=a==o.childCount;d||(h=-1),this.placed=At(this.placed,n,x.from(c)),this.frontier[n].match=f,d&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=o;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=d?e==0?C.empty:new C(St(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new C(St(s.content,e,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!$n(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,u=this.$to.after(r);for(;r>1&&u==this.$to.end(--r);)++u;return u}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:u}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=$n(e,n,u,r,i);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:a}=this.frontier[o],c=$n(e,o,a,l,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,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=At(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let u=e.node(r),i=u.type.contentMatch.fillBefore(u.content,!0,e.index(r));this.openFrontierNode(u.type,u.attrs,i)}return e}openFrontierNode(e,n=null,r){let u=this.frontier[this.depth];u.match=u.match.matchType(e),this.placed=At(this.placed,this.depth,x.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(x.empty,!0);n.childCount&&(this.placed=At(this.placed,this.frontier.length,n))}}function St(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(St(t.firstChild.content,e-1,n)))}function At(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(At(t.lastChild.content,e-1,n)))}function Vn(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function us(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,us(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(x.empty,!0)))),t.copy(r)}function $n(t,e,n,r,u){let i=t.node(e),s=u?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let o=r.fillBefore(i.content,!0,s);return o&&!_l(n,i.content,s)?o:null}function _l(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function El(t){return t.spec.defining||t.spec.definingForContent}function Sl(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let u=t.doc.resolve(e),i=t.doc.resolve(n);if(rs(u,i,r))return t.step(new H(e,n,r));let s=ss(u,t.doc.resolve(n));s[s.length-1]==0&&s.pop();let o=-(u.depth+1);s.unshift(o);for(let p=u.depth,h=u.pos-1;p>0;p--,h--){let d=u.node(p).type.spec;if(d.defining||d.definingAsContext||d.isolating)break;s.indexOf(p)>-1?o=p:u.before(p)==h&&s.splice(1,0,-p)}let l=s.indexOf(o),a=[],c=r.openStart;for(let p=r.content,h=0;;h++){let d=p.firstChild;if(a.push(d),h==r.openStart)break;p=d.content}for(let p=c-1;p>=0;p--){let h=a[p],d=El(h.type);if(d&&!h.sameMarkup(u.node(Math.abs(o)-1)))c=p;else if(d||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+c+1)%(r.openStart+1),d=a[h];if(d)for(let m=0;m<s.length;m++){let g=s[(m+l)%s.length],b=!0;g<0&&(b=!1,g=-g);let k=u.node(g-1),y=u.index(g-1);if(k.canReplaceWith(y,y,d.type,d.marks))return t.replace(u.before(g),b?i.after(g):n,new C(is(r.content,0,r.openStart,h),h,r.openEnd))}}let f=t.steps.length;for(let p=s.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let h=s[p];h<0||(e=u.before(h),n=i.after(h))}}function is(t,e,n,r,u){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(is(i.content,e+1,n,r,i)))}if(e>r){let i=u.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(x.empty,!0))}return t}function Al(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let u=yl(t.doc,e,r.type);u!=null&&(e=n=u)}t.replaceRange(e,n,new C(x.from(r),0,0))}function Ml(t,e,n){let r=t.doc.resolve(e),u=t.doc.resolve(n),i=ss(r,u);for(let s=0;s<i.length;s++){let o=i[s],l=s==i.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),u.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),u.indexAfter(o-1))))return t.delete(r.before(o),u.after(o))}for(let s=1;s<=r.depth&&s<=u.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&u.end(s)-n!=u.depth-s&&r.start(s-1)==u.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),u.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ss(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let u=r;u>=0;u--){let i=t.start(u);if(i<t.pos-(t.depth-u)||e.end(u)>e.pos+(e.depth-u)||t.node(u).type.spec.isolating||e.node(u).type.spec.isolating)break;(i==e.start(u)||u==t.depth&&u==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&u&&e.start(u-1)==i-1)&&n.push(u)}return n}class at extends j{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 B.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 u=n.type.create(r,null,n.marks);return B.fromReplace(e,this.pos,this.pos+1,new C(x.from(u),0,n.isLeaf?0:1))}getMap(){return Q.empty}invert(e){return new at(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 at(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 at(n.pos,n.attr,n.value)}}j.jsonID("attr",at);class Pt extends j{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let u in e.attrs)n[u]=e.attrs[u];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return B.ok(r)}getMap(){return Q.empty}invert(e){return new Pt(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 Pt(n.attr,n.value)}}j.jsonID("docAttr",Pt);let dt=class extends Error{};dt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};dt.prototype=Object.create(Error.prototype);dt.prototype.constructor=dt;dt.prototype.name="TransformError";class wl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new zt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new dt(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}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=C.empty){let u=Lr(this.doc,e,n,r);return u&&this.step(u),this}replaceWith(e,n,r){return this.replace(e,n,new C(x.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Sl(this,e,n,r),this}replaceRangeWith(e,n,r){return Al(this,e,n,r),this}deleteRange(e,n){return Ml(this,e,n),this}lift(e,n){return al(this,e,n),this}join(e,n=1){return kl(this,e,n),this}wrap(e,n){return dl(this,e,n),this}setBlockType(e,n=e,r,u=null){return hl(this,e,n,r,u),this}setNodeMarkup(e,n,r=null,u){return ml(this,e,n,r,u),this}setNodeAttribute(e,n,r){return this.step(new at(e,n,r)),this}setDocAttribute(e,n){return this.step(new Pt(e,n)),this}addNodeMark(e,n){return this.step(new ve(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 w)n.isInSet(r.marks)&&this.step(new tt(e,n));else{let u=r.marks,i,s=[];for(;i=n.isInSet(u);)s.push(new tt(e,i)),u=i.removeFromSet(u);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return gl(this,e,n,r),this}addMark(e,n,r){return sl(this,e,n,r),this}removeMark(e,n,r){return ol(this,e,n,r),this}clearIncompatible(e,n,r){return zr(this,e,n,r),this}}const Wn=Object.create(null);class F{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Tl(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=C.empty){let r=n.content.lastChild,u=null;for(let o=0;o<n.openEnd;o++)u=r,r=r.lastChild;let i=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(i);e.replaceRange(c.map(l.pos),c.map(a.pos),o?C.empty:n),o==0&&Du(e,i,(r?r.isInline:u&&u.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,u=this.ranges;for(let i=0;i<u.length;i++){let{$from:s,$to:o}=u[i],l=e.mapping.slice(r),a=l.map(s.pos),c=l.map(o.pos);i?e.deleteRange(a,c):(e.replaceRangeWith(a,c,n),Du(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let u=e.parent.inlineContent?new N(e):ot(e.node(0),e.parent,e.pos,e.index(),n,r);if(u)return u;for(let i=e.depth-1;i>=0;i--){let s=n<0?ot(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ot(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ee(e.node(0))}static atStart(e){return ot(e,e,0,0,1)||new ee(e)}static atEnd(e){return ot(e,e,e.content.size,e.childCount,-1)||new ee(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Wn[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 Wn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}F.prototype.visible=!0;class Tl{constructor(e,n){this.$from=e,this.$to=n}}let yu=!1;function Cu(t){!yu&&!t.parent.inlineContent&&(yu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class N extends F{constructor(e,n=e){Cu(e),Cu(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 F.near(r);let u=e.resolve(n.map(this.anchor));return new N(u.parent.inlineContent?u:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new wn(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 N(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let u=e.resolve(n);return new this(u,r==n?u:e.resolve(r))}static between(e,n,r){let u=e.pos-n.pos;if((!r||u)&&(r=u>=0?1:-1),!n.parent.inlineContent){let i=F.findFrom(n,r,!0)||F.findFrom(n,-r,!0);if(i)n=i.$head;else return F.near(n,r)}return e.parent.inlineContent||(u==0?e=n:(e=(F.findFrom(e,-r,!0)||F.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=u<0&&(e=n))),new N(e,n)}}F.jsonID("text",N);class wn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new wn(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class M extends F{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:u}=n.mapResult(this.anchor),i=e.resolve(u);return r?F.near(i):new M(i)}content(){return new C(x.from(this.node),0,0)}eq(e){return e instanceof M&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new qr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new M(e.resolve(n.anchor))}static create(e,n){return new M(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}M.prototype.visible=!1;F.jsonID("node",M);class qr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new wn(r,r):new qr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&M.isSelectable(r)?new M(n):F.near(n)}}class ee extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=C.empty){if(n==C.empty){e.delete(0,e.doc.content.size);let r=F.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ee(e)}map(e){return new ee(e)}eq(e){return e instanceof ee}getBookmark(){return Ol}}F.jsonID("all",ee);const Ol={map(){return this},resolve(t){return new ee(t)}};function ot(t,e,n,r,u,i=!1){if(e.inlineContent)return N.create(t,n);for(let s=r-(u>0?0:1);u>0?s<e.childCount:s>=0;s+=u){let o=e.child(s);if(o.isAtom){if(!i&&M.isSelectable(o))return M.create(t,n-(u<0?o.nodeSize:0))}else{let l=ot(t,o,n+u,u<0?o.childCount:0,u,i);if(l)return l}n+=o.nodeSize*u}return null}function Du(t,e,n){let r=t.steps.length-1;if(r<e)return;let u=t.steps[r];if(!(u instanceof H||u instanceof G))return;let i=t.mapping.maps[r],s;i.forEach((o,l,a,c)=>{s==null&&(s=c)}),t.setSelection(F.near(t.doc.resolve(s),n))}const _u=1,rn=2,Eu=4;class Fl extends wl{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|_u)&~rn,this.storedMarks=null,this}get selectionSet(){return(this.updated&_u)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=rn,this}ensureMarks(e){return w.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&rn)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~rn,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)||w.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let u=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(u.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,u.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(F.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|=Eu,this}get scrolledIntoView(){return(this.updated&Eu)>0}}function Su(t,e){return!e||!t?t:t.bind(e)}class Mt{constructor(e,n,r){this.name=e,this.init=Su(n.init,r),this.apply=Su(n.apply,r)}}const Nl=[new Mt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mt("selection",{init(t,e){return t.selection||F.atStart(e.doc)},apply(t){return t.selection}}),new Mt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hn{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Nl.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 Mt(r.key,r.spec.state,r))})}}class je{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 u=this.config.plugins[r];if(u.spec.filterTransaction&&!u.spec.filterTransaction.call(u,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),u=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=u?u[s].n:0,a=u?u[s].state:this,c=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,a,r);if(c&&r.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!u){u=[];for(let f=0;f<this.config.plugins.length;f++)u.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(c),r=r.applyInner(c),i=!0}u&&(u[s]={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 je(this.config),r=this.config.fields;for(let u=0;u<r.length;u++){let i=r[u];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Fl(this)}static create(e){let n=new Hn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new je(n);for(let u=0;u<n.fields.length;u++)r[n.fields[u].name]=n.fields[u].init(e,r);return r}reconfigure(e){let n=new Hn(this.schema,e.plugins),r=n.fields,u=new je(n);for(let i=0;i<r.length;i++){let s=r[i].name;u[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,u)}return u}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 u=e[r],i=u.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(u,this[u.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 u=new Hn(e.schema,e.plugins),i=new je(u);return u.fields.forEach(s=>{if(s.name=="doc")i.doc=xe.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=F.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],a=l.spec.state;if(l.key==s.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){i[s.name]=a.fromJSON.call(l,e,n[o],i);return}}i[s.name]=s.init(e,i)}}),i}}function ls(t,e,n){for(let r in t){let u=t[r];u instanceof Function?u=u.bind(e):r=="handleDOMEvents"&&(u=ls(u,e,{})),n[r]=u}return n}class Vr{constructor(e){this.spec=e,this.props={},e.props&&ls(e.props,this,this.props),this.key=e.key?e.key.key:as("plugin")}getState(e){return e[this.key]}}const Jn=Object.create(null);function as(t){return t in Jn?t+"$"+ ++Jn[t]:(Jn[t]=0,t+"$")}class cs{constructor(e="key"){this.key=as(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const fs=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Il(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Rl=(t,e,n)=>{let r=Il(t,n);if(!r)return!1;let u=ds(r);if(!u){let s=r.blockRange(),o=s&&jt(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let i=u.nodeBefore;if(ps(t,u,e,-1))return!0;if(r.parent.content.size==0&&(ht(i,"end")||M.isSelectable(i)))for(let s=r.depth;;s--){let o=Lr(t.doc,r.before(s),r.after(s),C.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(ht(i,"end")?F.findFrom(l.doc.resolve(l.mapping.map(u.pos,-1)),-1):M.create(l.doc,u.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&u.depth==r.depth-1?(e&&e(t.tr.delete(u.pos-i.nodeSize,u.pos).scrollIntoView()),!0):!1};function ht(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}const Bl=(t,e,n)=>{let{$head:r,empty:u}=t.selection,i=r;if(!u)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=ds(r)}let s=i&&i.nodeBefore;return!s||!M.isSelectable(s)?!1:(e&&e(t.tr.setSelection(M.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function ds(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 vl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const zl=(t,e,n)=>{let r=vl(t,n);if(!r)return!1;let u=hs(r);if(!u)return!1;let i=u.nodeAfter;if(ps(t,u,e,1))return!0;if(r.parent.content.size==0&&(ht(i,"start")||M.isSelectable(i))){let s=Lr(t.doc,r.before(),r.after(),C.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(ht(i,"start")?F.findFrom(o.doc.resolve(o.mapping.map(u.pos)),1):M.create(o.doc,o.mapping.map(u.pos))),e(o.scrollIntoView())}return!0}}return i.isAtom&&u.depth==r.depth-1?(e&&e(t.tr.delete(u.pos,u.pos+i.nodeSize).scrollIntoView()),!0):!1},Pl=(t,e,n)=>{let{$head:r,empty:u}=t.selection,i=r;if(!u)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=hs(r)}let s=i&&i.nodeAfter;return!s||!M.isSelectable(s)?!1:(e&&e(t.tr.setSelection(M.create(t.doc,i.pos)).scrollIntoView()),!0)};function hs(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}const Ll=(t,e)=>{let{$from:n,$to:r}=t.selection,u=n.blockRange(r),i=u&&jt(u);return i==null?!1:(e&&e(t.tr.lift(u,i).scrollIntoView()),!0)},ql=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
6
|
-
`).scrollIntoView()),!0)};function $r(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Vl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let u=n.node(-1),i=n.indexAfter(-1),s=$r(u.contentMatchAt(i));if(!s||!u.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(F.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},$l=(t,e)=>{let n=t.selection,{$from:r,$to:u}=n;if(n instanceof ee||r.parent.inlineContent||u.parent.inlineContent)return!1;let i=$r(u.parent.contentMatchAt(u.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&u.index()<u.parent.childCount?r:u).pos,o=t.tr.insert(s,i.createAndFill());o.setSelection(N.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},Wl=(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(Ot(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),u=r&&jt(r);return u==null?!1:(e&&e(t.tr.lift(r,u).scrollIntoView()),!0)};function Hl(t){return(e,n)=>{let{$from:r,$to:u}=e.selection;if(e.selection instanceof M&&e.selection.node.isBlock)return!r.parentOffset||!Ot(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,o,l=!1,a=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),a=r.start(h)==r.pos-(r.depth-h),o=$r(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(l&&o?{type:o}:null),s=h;break}else{if(h==1)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof N||e.selection instanceof ee)&&c.deleteSelection();let f=c.mapping.map(r.pos),p=Ot(c.doc,f,i.length,i);if(p||(i[0]=o?{type:o}:null,p=Ot(c.doc,f,i.length,i)),!p)return!1;if(c.split(f,i.length,i),!l&&a&&r.node(s).type!=o){let h=c.mapping.map(r.before(s)),d=c.doc.resolve(h);o&&r.node(s-1).canReplaceWith(d.index(),d.index()+1,o)&&c.setNodeMarkup(c.mapping.map(r.before(s)),o)}return n&&n(c.scrollIntoView()),!0}}const Jl=Hl(),jl=(t,e)=>(e&&e(t.tr.setSelection(new ee(t.doc))),!0);function Ul(t,e,n){let r=e.nodeBefore,u=e.nodeAfter,i=e.index();return!r||!u||!r.type.compatibleContent(u.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)||!(u.isTextblock||Pr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ps(t,e,n,r){let u=e.nodeBefore,i=e.nodeAfter,s,o,l=u.type.spec.isolating||i.type.spec.isolating;if(!l&&Ul(t,e,n))return!0;let a=!l&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=u.contentMatchAt(u.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,d=x.empty;for(let b=s.length-1;b>=0;b--)d=x.from(s[b].create(null,d));d=x.from(u.copy(d));let m=t.tr.step(new G(e.pos-1,h,e.pos,h,new C(d,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==u.type&&Pr(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&l?null:F.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),p=f&&jt(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(a&&ht(i,"start",!0)&&ht(u,"end")){let h=u,d=[];for(;d.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 b=x.empty;for(let y=d.length-1;y>=0;y--)b=x.from(d[y].copy(b));let k=t.tr.step(new G(e.pos-d.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new C(b,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function ms(t){return function(e,n){let r=e.selection,u=t<0?r.$from:r.$to,i=u.depth;for(;u.node(i).isInline;){if(!i)return!1;i--}return u.node(i).isTextblock?(n&&n(e.tr.setSelection(N.create(e.doc,t<0?u.start(i):u.end(i)))),!0):!1}}const Kl=ms(-1),Zl=ms(1);function Gl(t,e=null){return function(n,r){let{$from:u,$to:i}=n.selection,s=u.blockRange(i),o=s&&es(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function xr(t,e=null){return function(n,r){let u=!1;for(let i=0;i<n.selection.ranges.length&&!u;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(s,o,(l,a)=>{if(u)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)u=!0;else{let c=n.doc.resolve(a),f=c.index();u=c.parent.canReplaceWith(f,f+1,t)}})}if(!u)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];i.setBlockType(o,l,t,e)}r(i.scrollIntoView())}return!0}}function Yl(t,e,n,r){for(let u=0;u<e.length;u++){let{$from:i,$to:s}=e[u],o=i.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(i.pos,s.pos,(l,a)=>{if(o)return!1;o=l.inlineContent&&l.type.allowsMarkType(n)}),o)return!0}return!1}function cn(t,e=null,n){return function(r,u){let{empty:i,$cursor:s,ranges:o}=r.selection;if(i&&!s||!Yl(r.doc,o,t))return!1;if(u)if(s)t.isInSet(r.storedMarks||s.marks())?u(r.tr.removeStoredMark(t)):u(r.tr.addStoredMark(t.create(e)));else{let l,a=r.tr;l=!o.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,t));for(let c=0;c<o.length;c++){let{$from:f,$to:p}=o[c];if(!l)a.removeMark(f.pos,p.pos,t);else{let h=f.pos,d=p.pos,m=f.nodeAfter,g=p.nodeBefore,b=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,k=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;h+b<d&&(h+=b,d-=k),a.addMark(h,d,t.create(e))}}u(a.scrollIntoView())}return!0}}function Wr(...t){return function(e,n,r){for(let u=0;u<t.length;u++)if(t[u](e,n,r))return!0;return!1}}let jn=Wr(fs,Rl,Bl),Au=Wr(fs,zl,Pl);const Se={Enter:Wr(ql,$l,Wl,Jl),"Mod-Enter":Vl,Backspace:jn,"Mod-Backspace":jn,"Shift-Backspace":jn,Delete:Au,"Mod-Delete":Au,"Mod-a":jl},gs={"Ctrl-h":Se.Backspace,"Alt-Backspace":Se["Mod-Backspace"],"Ctrl-d":Se.Delete,"Ctrl-Alt-Backspace":Se["Mod-Delete"],"Alt-Delete":Se["Mod-Delete"],"Alt-d":Se["Mod-Delete"],"Ctrl-a":Kl,"Ctrl-e":Zl};for(let t in Se)gs[t]=Se[t];const Xl=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ql=Xl?gs:Se;function bs(t,e){return xs(t,e)!=null}function xs(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function fn(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return bs(r.state,u)})}function ea(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?ea(u.state,i,r):!1})}function he({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return A.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},A.attr.title(u),Rr.Icon({icon:i,size:s})))}function ta(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function ks(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!ys(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function na(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=ks(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function ra(t){const e=t.state.schema.marks.link;if(e==null)return;const n=ks(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function ys(t){return bs(t,t.schema.marks.link)}function ua({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=A.prop(null);s.on(l=>{l!=null&&na(e.value,l)});const o=t.on(()=>{const l=xs(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return A.Fragment(A.OnDispose(o),It.ToolbarGroup(he({display:A.signal(!0),active:fn(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;if(ys(l))ra(e.value),s.set(null);else{const a="";ta(e.value,a),s.set(a)}}}),A.Ensure(s,l=>Rr.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),A.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function un({display:t},...e){return A.When(A.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function Cs({view:t,stateUpdate:e,features:n,readOnly:r=A.signal(!1),size:u="sm"}){return A.Ensure(t,i=>A.Use(Rr.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(un({display:[n.$.bold,n.$.italic,n.$.code]},he({active:fn(e,l,"strong"),display:n.$.bold,onClick:()=>Un(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),he({active:fn(e,l,"em"),display:n.$.italic,onClick:()=>Un(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),he({active:fn(e,l,"code"),display:n.$.code,onClick:()=>Un(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),un({display:[n.$.headings]},A.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>he({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>ia(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),un({display:[n.$.bulletList,n.$.orderedList]},he({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>Mu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),he({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>Mu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),un({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},he({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>sa(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),he({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>oa(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),he({active:A.signal(!1),display:n.$.horizontalRule,onClick:()=>la(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),A.When(n.$.links,()=>ua({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}function Un(t,e){const n=t.state.schema.marks[e];n!=null&&(cn(n)(t.state,t.dispatch),t.focus())}function ia(t,e){const n=t.state.schema.nodes.heading;n!=null&&(xr(n,{level:e})(t.state,t.dispatch),t.focus())}async function Mu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-Ch-e3nx4.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}function sa(t){const e=t.state.schema.nodes.blockquote;if(e==null)return;const{state:n}=t,{$from:r}=n.selection;let u=!1;for(let i=r.depth;i>0;i--)if(r.node(i).type.name==="blockquote"){u=!0;break}u?Ll(n,t.dispatch):Gl(e)(n,t.dispatch),t.focus()}function oa(t){const e=t.state.schema.nodes.code_block,n=t.state.schema.nodes.paragraph;if(e==null||n==null)return;const{state:r}=t,{$from:u}=r.selection;let i=!1;for(let s=u.depth;s>0;s--)if(u.node(s).type.name==="code_block"){i=!0;break}i?xr(n)(r,t.dispatch):xr(e)(r,t.dispatch),t.focus()}function la(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}const V=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},pt=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let kr=null;const Ee=function(t,e,n){let r=kr||(kr=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},aa=function(){kr=null},nt=function(t,e,n,r){return n&&(wu(t,e,n,r,-1)||wu(t,e,n,r,1))},ca=/^(img|br|input|textarea|hr)$/i;function wu(t,e,n,r,u){for(var i;;){if(t==n&&e==r)return!0;if(e==(u<0?0:re(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Ut(t)||ca.test(t.nodeName)||t.contentEditable=="false")return!1;e=V(t)+(u<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(u<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=u;else return!1;else t=s,e=u<0?re(t):0}else return!1}}function re(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function fa(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=re(t)}else if(t.parentNode&&!Ut(t))e=V(t),t=t.parentNode;else return null}}function da(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ut(t))e=V(t)+1,t=t.parentNode;else return null}}function ha(t,e,n){for(let r=e==0,u=e==re(t);r||u;){if(t==n)return!0;let i=V(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,u=u&&i==re(t)}}function Ut(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)}const Tn=function(t){return t.focusNode&&nt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Je(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function pa(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ma(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(re(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(re(r.startContainer),r.startOffset)}}}const ke=typeof navigator<"u"?navigator:null,Tu=typeof document<"u"?document:null,He=ke&&ke.userAgent||"",yr=/Edge\/(\d+)/.exec(He),Ds=/MSIE \d/.exec(He),Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Y=!!(Ds||Cr||yr),Le=Ds?document.documentMode:Cr?+Cr[1]:yr?+yr[1]:0,ue=!Y&&/gecko\/(\d+)/i.test(He);ue&&+(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Dr=!Y&&/Chrome\/(\d+)/.exec(He),J=!!Dr,_s=Dr?+Dr[1]:0,U=!Y&&!!ke&&/Apple Computer/.test(ke.vendor),mt=U&&(/Mobile\/\w+/.test(He)||!!ke&&ke.maxTouchPoints>2),ne=mt||(ke?/Mac/.test(ke.platform):!1),ga=ke?/Win/.test(ke.platform):!1,Ae=/Android \d/.test(He),Kt=!!Tu&&"webkitFontSmoothing"in Tu.documentElement.style,ba=Kt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xa(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 _e(t,e){return typeof t=="number"?t:t[e]}function ka(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 Ou(t,e,n){let r=t.someProp("scrollThreshold")||0,u=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=pt(s);continue}let o=s,l=o==i.body,a=l?xa(i):ka(o),c=0,f=0;if(e.top<a.top+_e(r,"top")?f=-(a.top-e.top+_e(u,"top")):e.bottom>a.bottom-_e(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+_e(u,"top")-a.top:e.bottom-a.bottom+_e(u,"bottom")),e.left<a.left+_e(r,"left")?c=-(a.left-e.left+_e(u,"left")):e.right>a.right-_e(r,"right")&&(c=e.right-a.right+_e(u,"right")),c||f)if(l)i.defaultView.scrollBy(c,f);else{let h=o.scrollLeft,d=o.scrollTop;f&&(o.scrollTop+=f),c&&(o.scrollLeft+=c);let m=o.scrollLeft-h,g=o.scrollTop-d;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:pt(s)}}function ya(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,u;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,u=l.top;break}}return{refDOM:r,refTop:u,stack:Es(t.dom)}}function Es(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=pt(r));return e}function Ca({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ss(n,r==0?0:r-e)}function Ss(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:u,left:i}=t[n];r.scrollTop!=u+e&&(r.scrollTop=u+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ut=null;function Da(t){if(t.setActive)return t.setActive();if(ut)return t.focus(ut);let e=Es(t);t.focus(ut==null?{get preventScroll(){return ut={preventScroll:!0},!0}}:void 0),ut||(ut=!1,Ss(e,0))}function As(t,e){let n,r=2e8,u,i=0,s=e.top,o=e.top,l,a;for(let c=t.firstChild,f=0;c;c=c.nextSibling,f++){let p;if(c.nodeType==1)p=c.getClientRects();else if(c.nodeType==3)p=Ee(c).getClientRects();else continue;for(let h=0;h<p.length;h++){let d=p[h];if(d.top<=s&&d.bottom>=o){s=Math.max(d.bottom,s),o=Math.min(d.top,o);let m=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(m<r){n=c,r=m,u=m&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,c.nodeType==1&&m&&(i=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!l&&d.left<=e.left&&d.right>=e.left&&(l=c,a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(i=f+1)}}return!n&&l&&(n=l,u=a,r=0),n&&n.nodeType==3?_a(n,u):!n||r&&n.nodeType==1?{node:t,offset:i}:As(n,u)}function _a(t,e){let n=t.nodeValue.length,r=document.createRange();for(let u=0;u<n;u++){r.setEnd(t,u+1),r.setStart(t,u);let i=Te(r,1);if(i.top!=i.bottom&&Hr(e,i))return{node:t,offset:u+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Hr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ea(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Sa(t,e,n){let{node:r,offset:u}=As(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,u,i)}function Aa(t,e,n,r){let u=-1;for(let i=e,s=!1;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?u=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(u=o.posAfter),s=!0),!o.contentDOM&&u<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;i=o.dom.parentNode}return u>-1?u:t.docView.posFromDOM(e,n,-1)}function Ms(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let u=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=u;;){let s=t.childNodes[i];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(Hr(e,a))return Ms(s,e,a)}}if((i=(i+1)%r)==u)break}return t}function Ma(t,e){let n=t.dom.ownerDocument,r,u=0,i=ma(n,e.left,e.top);i&&({node:r,offset:u}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let a=t.dom.getBoundingClientRect();if(!Hr(e,a)||(s=Ms(t.dom,e,a),!s))return null}if(U)for(let a=s;r&&a;a=pt(a))a.draggable&&(r=void 0);if(s=Ea(s,e),r){if(ue&&r.nodeType==1&&(u=Math.min(u,r.childNodes.length),u<r.childNodes.length)){let c=r.childNodes[u],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&u++}let a;Kt&&u&&r.nodeType==1&&(a=r.childNodes[u-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&u--,r==t.dom&&u==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(u==0||r.nodeType!=1||r.childNodes[u-1].nodeName!="BR")&&(o=Aa(t,r,u,e))}o==null&&(o=Sa(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function Fu(t){return t.top<t.bottom||t.left<t.right}function Te(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Fu(r))return r}return Array.prototype.find.call(n,Fu)||t.getBoundingClientRect()}const wa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ws(t,e,n){let{node:r,offset:u,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Kt||ue;if(r.nodeType==3)if(s&&(wa.test(r.nodeValue)||(n<0?!u:u==r.nodeValue.length))){let l=Te(Ee(r,u,u),n);if(ue&&u&&/\s/.test(r.nodeValue[u-1])&&u<r.nodeValue.length){let a=Te(Ee(r,u-1,u-1),-1);if(a.top==l.top){let c=Te(Ee(r,u,u+1),-1);if(c.top!=l.top)return _t(c,c.left<a.left)}}return l}else{let l=u,a=u,c=n<0?1:-1;return n<0&&!u?(a++,c=-1):n>=0&&u==r.nodeValue.length?(l--,c=1):n<0?l--:a++,_t(Te(Ee(r,l,a),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&u&&(n<0||u==re(r))){let l=r.childNodes[u-1];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!1)}if(i==null&&u<re(r)){let l=r.childNodes[u];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!0)}return Kn(r.getBoundingClientRect(),n>=0)}if(i==null&&u&&(n<0||u==re(r))){let l=r.childNodes[u-1],a=l.nodeType==3?Ee(l,re(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return _t(Te(a,1),!1)}if(i==null&&u<re(r)){let l=r.childNodes[u];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?l.nodeType==3?Ee(l,0,s?0:1):l.nodeType==1?l:null:null;if(a)return _t(Te(a,-1),!0)}return _t(Te(r.nodeType==3?Ee(r):r,-n),n>=0)}function _t(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 Kn(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 Ts(t,e,n){let r=t.state,u=t.root.activeElement;r!=e&&t.updateState(e),u!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),u!=t.dom&&u&&u.focus()}}function Ta(t,e,n){let r=e.selection,u=n=="up"?r.$from:r.$to;return Ts(t,e,()=>{let{node:i}=t.docView.domFromPos(u.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(i,!0);if(!o)break;if(o.node.isBlock){i=o.contentDOM||o.dom;break}i=o.dom.parentNode}let s=ws(t,u.pos,1);for(let o=i.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Ee(o,0,o.nodeValue.length).getClientRects();else continue;for(let a=0;a<l.length;a++){let c=l[a];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Oa=/[\u0590-\u08ac]/;function Fa(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let u=r.parentOffset,i=!u,s=u==r.parent.content.size,o=t.domSelection();return o?!Oa.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?i:s:Ts(t,e,()=>{let{focusNode:l,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),p=o.caretBidiLevel;o.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:m}=t.domSelectionRange(),g=d&&!h.contains(d.nodeType==1?d:d.parentNode)||l==d&&a==m;try{o.collapse(c,f),l&&(l!=c||a!=f)&&o.extend&&o.extend(l,a)}catch{}return p!=null&&(o.caretBidiLevel=p),g}):r.pos==r.start()||r.pos==r.end()}let Nu=null,Iu=null,Ru=!1;function Na(t,e,n){return Nu==e&&Iu==n?Ru:(Nu=e,Iu=n,Ru=n=="up"||n=="down"?Ta(t,e,n):Fa(t,e,n))}const ie=0,Bu=1,Ue=2,ye=3;class Zt{constructor(e,n,r,u){this.parent=e,this.children=n,this.dom=r,this.contentDOM=u,this.dirty=ie,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){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 u=this.children[n];if(u==e)return r;r+=u.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&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let u;if(e==this.dom&&this.contentDOM)u=n>V(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))u=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!1;break}if(i.previousSibling)break}if(u==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!0;break}if(i.nextSibling)break}}return u??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,u=e;u;u=u.parentNode){let i=this.getDesc(u),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==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 u=e;u;u=u.parentNode){let i=this.getDesc(u);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let u=this.children[n],i=r+u.size;if(r==e&&i!=r){for(;!u.border&&u.children.length;)for(let s=0;s<u.children.length;s++){let o=u.children[s];if(o.size){u=o;break}}return u}if(e<i)return u.descAt(e-r-u.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,u=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(o>e||s instanceof Fs){u=e-i;break}i=o}if(u)return this.children[r].domFromPos(u-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Os&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?V(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?V(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 u=-1,i=-1;for(let s=r,o=0;;o++){let l=this.children[o],a=s+l.size;if(u==-1&&e<=a){let c=s+l.border;if(e>=c&&n<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=s;for(let f=o;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){u=V(p.dom)+1;break}e-=p.size}u==-1&&(u=0)}if(u>-1&&(a>n||o==this.children.length-1)){n=a;for(let c=o+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=V(f.dom);break}n+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:n,fromOffset:u,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(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,u=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,d=0;h<this.children.length;h++){let m=this.children[h],g=d+m.size;if(i>d&&s<g)return m.setSelection(e-d-m.border,n-d-m.border,r,u);d=g}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),a=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((ue||U)&&e==n){let{node:h,offset:d}=o;if(h.nodeType==3){if(f=!!(d&&h.nodeValue[d-1]==`
|
|
6
|
+
`).scrollIntoView()),!0)};function $r(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Vl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let u=n.node(-1),i=n.indexAfter(-1),s=$r(u.contentMatchAt(i));if(!s||!u.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(F.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},$l=(t,e)=>{let n=t.selection,{$from:r,$to:u}=n;if(n instanceof ee||r.parent.inlineContent||u.parent.inlineContent)return!1;let i=$r(u.parent.contentMatchAt(u.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&u.index()<u.parent.childCount?r:u).pos,o=t.tr.insert(s,i.createAndFill());o.setSelection(N.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},Wl=(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(Ot(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),u=r&&jt(r);return u==null?!1:(e&&e(t.tr.lift(r,u).scrollIntoView()),!0)};function Hl(t){return(e,n)=>{let{$from:r,$to:u}=e.selection;if(e.selection instanceof M&&e.selection.node.isBlock)return!r.parentOffset||!Ot(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,o,l=!1,a=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),a=r.start(h)==r.pos-(r.depth-h),o=$r(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(l&&o?{type:o}:null),s=h;break}else{if(h==1)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof N||e.selection instanceof ee)&&c.deleteSelection();let f=c.mapping.map(r.pos),p=Ot(c.doc,f,i.length,i);if(p||(i[0]=o?{type:o}:null,p=Ot(c.doc,f,i.length,i)),!p)return!1;if(c.split(f,i.length,i),!l&&a&&r.node(s).type!=o){let h=c.mapping.map(r.before(s)),d=c.doc.resolve(h);o&&r.node(s-1).canReplaceWith(d.index(),d.index()+1,o)&&c.setNodeMarkup(c.mapping.map(r.before(s)),o)}return n&&n(c.scrollIntoView()),!0}}const Jl=Hl(),jl=(t,e)=>(e&&e(t.tr.setSelection(new ee(t.doc))),!0);function Ul(t,e,n){let r=e.nodeBefore,u=e.nodeAfter,i=e.index();return!r||!u||!r.type.compatibleContent(u.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)||!(u.isTextblock||Pr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ps(t,e,n,r){let u=e.nodeBefore,i=e.nodeAfter,s,o,l=u.type.spec.isolating||i.type.spec.isolating;if(!l&&Ul(t,e,n))return!0;let a=!l&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=u.contentMatchAt(u.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,d=x.empty;for(let b=s.length-1;b>=0;b--)d=x.from(s[b].create(null,d));d=x.from(u.copy(d));let m=t.tr.step(new G(e.pos-1,h,e.pos,h,new C(d,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==u.type&&Pr(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&l?null:F.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),p=f&&jt(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(a&&ht(i,"start",!0)&&ht(u,"end")){let h=u,d=[];for(;d.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 b=x.empty;for(let y=d.length-1;y>=0;y--)b=x.from(d[y].copy(b));let k=t.tr.step(new G(e.pos-d.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new C(b,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function ms(t){return function(e,n){let r=e.selection,u=t<0?r.$from:r.$to,i=u.depth;for(;u.node(i).isInline;){if(!i)return!1;i--}return u.node(i).isTextblock?(n&&n(e.tr.setSelection(N.create(e.doc,t<0?u.start(i):u.end(i)))),!0):!1}}const Kl=ms(-1),Zl=ms(1);function Gl(t,e=null){return function(n,r){let{$from:u,$to:i}=n.selection,s=u.blockRange(i),o=s&&es(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function xr(t,e=null){return function(n,r){let u=!1;for(let i=0;i<n.selection.ranges.length&&!u;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(s,o,(l,a)=>{if(u)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)u=!0;else{let c=n.doc.resolve(a),f=c.index();u=c.parent.canReplaceWith(f,f+1,t)}})}if(!u)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];i.setBlockType(o,l,t,e)}r(i.scrollIntoView())}return!0}}function Yl(t,e,n,r){for(let u=0;u<e.length;u++){let{$from:i,$to:s}=e[u],o=i.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(i.pos,s.pos,(l,a)=>{if(o)return!1;o=l.inlineContent&&l.type.allowsMarkType(n)}),o)return!0}return!1}function cn(t,e=null,n){return function(r,u){let{empty:i,$cursor:s,ranges:o}=r.selection;if(i&&!s||!Yl(r.doc,o,t))return!1;if(u)if(s)t.isInSet(r.storedMarks||s.marks())?u(r.tr.removeStoredMark(t)):u(r.tr.addStoredMark(t.create(e)));else{let l,a=r.tr;l=!o.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,t));for(let c=0;c<o.length;c++){let{$from:f,$to:p}=o[c];if(!l)a.removeMark(f.pos,p.pos,t);else{let h=f.pos,d=p.pos,m=f.nodeAfter,g=p.nodeBefore,b=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,k=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;h+b<d&&(h+=b,d-=k),a.addMark(h,d,t.create(e))}}u(a.scrollIntoView())}return!0}}function Wr(...t){return function(e,n,r){for(let u=0;u<t.length;u++)if(t[u](e,n,r))return!0;return!1}}let jn=Wr(fs,Rl,Bl),Au=Wr(fs,zl,Pl);const Se={Enter:Wr(ql,$l,Wl,Jl),"Mod-Enter":Vl,Backspace:jn,"Mod-Backspace":jn,"Shift-Backspace":jn,Delete:Au,"Mod-Delete":Au,"Mod-a":jl},gs={"Ctrl-h":Se.Backspace,"Alt-Backspace":Se["Mod-Backspace"],"Ctrl-d":Se.Delete,"Ctrl-Alt-Backspace":Se["Mod-Delete"],"Alt-Delete":Se["Mod-Delete"],"Alt-d":Se["Mod-Delete"],"Ctrl-a":Kl,"Ctrl-e":Zl};for(let t in Se)gs[t]=Se[t];const Xl=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ql=Xl?gs:Se;function bs(t,e){return xs(t,e)!=null}function xs(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function fn(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return bs(r.state,u)})}function ea(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?ea(u.state,i,r):!1})}function he({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return A.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},A.attr.title(u),Rr.Icon({icon:i,size:s})))}function ta(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function ks(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!ys(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function na(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=ks(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function ra(t){const e=t.state.schema.marks.link;if(e==null)return;const n=ks(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function ys(t){return bs(t,t.schema.marks.link)}function ua({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=A.prop(null);s.on(l=>{l!=null&&na(e.value,l)});const o=t.on(()=>{const l=xs(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return A.Fragment(A.OnDispose(o),It.ToolbarGroup(he({display:A.signal(!0),active:fn(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;if(ys(l))ra(e.value),s.set(null);else{const a="";ta(e.value,a),s.set(a)}}}),A.Ensure(s,l=>Rr.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),A.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function un({display:t},...e){return A.When(A.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function Cs({view:t,stateUpdate:e,features:n,readOnly:r=A.signal(!1),size:u="sm"}){return A.Ensure(t,i=>A.Use(Rr.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(un({display:[n.$.bold,n.$.italic,n.$.code]},he({active:fn(e,l,"strong"),display:n.$.bold,onClick:()=>Un(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),he({active:fn(e,l,"em"),display:n.$.italic,onClick:()=>Un(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),he({active:fn(e,l,"code"),display:n.$.code,onClick:()=>Un(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),un({display:[n.$.headings]},A.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>he({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>ia(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),un({display:[n.$.bulletList,n.$.orderedList]},he({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>Mu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),he({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>Mu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),un({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},he({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>sa(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),he({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>oa(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),he({active:A.signal(!1),display:n.$.horizontalRule,onClick:()=>la(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),A.When(n.$.links,()=>ua({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}function Un(t,e){const n=t.state.schema.marks[e];n!=null&&(cn(n)(t.state,t.dispatch),t.focus())}function ia(t,e){const n=t.state.schema.nodes.heading;n!=null&&(xr(n,{level:e})(t.state,t.dispatch),t.focus())}async function Mu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-J7CsYy0-.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}function sa(t){const e=t.state.schema.nodes.blockquote;if(e==null)return;const{state:n}=t,{$from:r}=n.selection;let u=!1;for(let i=r.depth;i>0;i--)if(r.node(i).type.name==="blockquote"){u=!0;break}u?Ll(n,t.dispatch):Gl(e)(n,t.dispatch),t.focus()}function oa(t){const e=t.state.schema.nodes.code_block,n=t.state.schema.nodes.paragraph;if(e==null||n==null)return;const{state:r}=t,{$from:u}=r.selection;let i=!1;for(let s=u.depth;s>0;s--)if(u.node(s).type.name==="code_block"){i=!0;break}i?xr(n)(r,t.dispatch):xr(e)(r,t.dispatch),t.focus()}function la(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}const V=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},pt=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let kr=null;const Ee=function(t,e,n){let r=kr||(kr=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},aa=function(){kr=null},nt=function(t,e,n,r){return n&&(wu(t,e,n,r,-1)||wu(t,e,n,r,1))},ca=/^(img|br|input|textarea|hr)$/i;function wu(t,e,n,r,u){for(var i;;){if(t==n&&e==r)return!0;if(e==(u<0?0:re(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Ut(t)||ca.test(t.nodeName)||t.contentEditable=="false")return!1;e=V(t)+(u<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(u<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=u;else return!1;else t=s,e=u<0?re(t):0}else return!1}}function re(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function fa(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=re(t)}else if(t.parentNode&&!Ut(t))e=V(t),t=t.parentNode;else return null}}function da(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ut(t))e=V(t)+1,t=t.parentNode;else return null}}function ha(t,e,n){for(let r=e==0,u=e==re(t);r||u;){if(t==n)return!0;let i=V(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,u=u&&i==re(t)}}function Ut(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)}const Tn=function(t){return t.focusNode&&nt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Je(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function pa(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ma(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(re(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(re(r.startContainer),r.startOffset)}}}const ke=typeof navigator<"u"?navigator:null,Tu=typeof document<"u"?document:null,He=ke&&ke.userAgent||"",yr=/Edge\/(\d+)/.exec(He),Ds=/MSIE \d/.exec(He),Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Y=!!(Ds||Cr||yr),Le=Ds?document.documentMode:Cr?+Cr[1]:yr?+yr[1]:0,ue=!Y&&/gecko\/(\d+)/i.test(He);ue&&+(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Dr=!Y&&/Chrome\/(\d+)/.exec(He),J=!!Dr,_s=Dr?+Dr[1]:0,U=!Y&&!!ke&&/Apple Computer/.test(ke.vendor),mt=U&&(/Mobile\/\w+/.test(He)||!!ke&&ke.maxTouchPoints>2),ne=mt||(ke?/Mac/.test(ke.platform):!1),ga=ke?/Win/.test(ke.platform):!1,Ae=/Android \d/.test(He),Kt=!!Tu&&"webkitFontSmoothing"in Tu.documentElement.style,ba=Kt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xa(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 _e(t,e){return typeof t=="number"?t:t[e]}function ka(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 Ou(t,e,n){let r=t.someProp("scrollThreshold")||0,u=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=pt(s);continue}let o=s,l=o==i.body,a=l?xa(i):ka(o),c=0,f=0;if(e.top<a.top+_e(r,"top")?f=-(a.top-e.top+_e(u,"top")):e.bottom>a.bottom-_e(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+_e(u,"top")-a.top:e.bottom-a.bottom+_e(u,"bottom")),e.left<a.left+_e(r,"left")?c=-(a.left-e.left+_e(u,"left")):e.right>a.right-_e(r,"right")&&(c=e.right-a.right+_e(u,"right")),c||f)if(l)i.defaultView.scrollBy(c,f);else{let h=o.scrollLeft,d=o.scrollTop;f&&(o.scrollTop+=f),c&&(o.scrollLeft+=c);let m=o.scrollLeft-h,g=o.scrollTop-d;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:pt(s)}}function ya(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,u;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,u=l.top;break}}return{refDOM:r,refTop:u,stack:Es(t.dom)}}function Es(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=pt(r));return e}function Ca({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ss(n,r==0?0:r-e)}function Ss(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:u,left:i}=t[n];r.scrollTop!=u+e&&(r.scrollTop=u+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ut=null;function Da(t){if(t.setActive)return t.setActive();if(ut)return t.focus(ut);let e=Es(t);t.focus(ut==null?{get preventScroll(){return ut={preventScroll:!0},!0}}:void 0),ut||(ut=!1,Ss(e,0))}function As(t,e){let n,r=2e8,u,i=0,s=e.top,o=e.top,l,a;for(let c=t.firstChild,f=0;c;c=c.nextSibling,f++){let p;if(c.nodeType==1)p=c.getClientRects();else if(c.nodeType==3)p=Ee(c).getClientRects();else continue;for(let h=0;h<p.length;h++){let d=p[h];if(d.top<=s&&d.bottom>=o){s=Math.max(d.bottom,s),o=Math.min(d.top,o);let m=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(m<r){n=c,r=m,u=m&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,c.nodeType==1&&m&&(i=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!l&&d.left<=e.left&&d.right>=e.left&&(l=c,a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(i=f+1)}}return!n&&l&&(n=l,u=a,r=0),n&&n.nodeType==3?_a(n,u):!n||r&&n.nodeType==1?{node:t,offset:i}:As(n,u)}function _a(t,e){let n=t.nodeValue.length,r=document.createRange();for(let u=0;u<n;u++){r.setEnd(t,u+1),r.setStart(t,u);let i=Te(r,1);if(i.top!=i.bottom&&Hr(e,i))return{node:t,offset:u+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Hr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ea(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Sa(t,e,n){let{node:r,offset:u}=As(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,u,i)}function Aa(t,e,n,r){let u=-1;for(let i=e,s=!1;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?u=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(u=o.posAfter),s=!0),!o.contentDOM&&u<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;i=o.dom.parentNode}return u>-1?u:t.docView.posFromDOM(e,n,-1)}function Ms(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let u=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=u;;){let s=t.childNodes[i];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(Hr(e,a))return Ms(s,e,a)}}if((i=(i+1)%r)==u)break}return t}function Ma(t,e){let n=t.dom.ownerDocument,r,u=0,i=ma(n,e.left,e.top);i&&({node:r,offset:u}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let a=t.dom.getBoundingClientRect();if(!Hr(e,a)||(s=Ms(t.dom,e,a),!s))return null}if(U)for(let a=s;r&&a;a=pt(a))a.draggable&&(r=void 0);if(s=Ea(s,e),r){if(ue&&r.nodeType==1&&(u=Math.min(u,r.childNodes.length),u<r.childNodes.length)){let c=r.childNodes[u],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&u++}let a;Kt&&u&&r.nodeType==1&&(a=r.childNodes[u-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&u--,r==t.dom&&u==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(u==0||r.nodeType!=1||r.childNodes[u-1].nodeName!="BR")&&(o=Aa(t,r,u,e))}o==null&&(o=Sa(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function Fu(t){return t.top<t.bottom||t.left<t.right}function Te(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Fu(r))return r}return Array.prototype.find.call(n,Fu)||t.getBoundingClientRect()}const wa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ws(t,e,n){let{node:r,offset:u,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Kt||ue;if(r.nodeType==3)if(s&&(wa.test(r.nodeValue)||(n<0?!u:u==r.nodeValue.length))){let l=Te(Ee(r,u,u),n);if(ue&&u&&/\s/.test(r.nodeValue[u-1])&&u<r.nodeValue.length){let a=Te(Ee(r,u-1,u-1),-1);if(a.top==l.top){let c=Te(Ee(r,u,u+1),-1);if(c.top!=l.top)return _t(c,c.left<a.left)}}return l}else{let l=u,a=u,c=n<0?1:-1;return n<0&&!u?(a++,c=-1):n>=0&&u==r.nodeValue.length?(l--,c=1):n<0?l--:a++,_t(Te(Ee(r,l,a),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&u&&(n<0||u==re(r))){let l=r.childNodes[u-1];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!1)}if(i==null&&u<re(r)){let l=r.childNodes[u];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!0)}return Kn(r.getBoundingClientRect(),n>=0)}if(i==null&&u&&(n<0||u==re(r))){let l=r.childNodes[u-1],a=l.nodeType==3?Ee(l,re(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return _t(Te(a,1),!1)}if(i==null&&u<re(r)){let l=r.childNodes[u];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?l.nodeType==3?Ee(l,0,s?0:1):l.nodeType==1?l:null:null;if(a)return _t(Te(a,-1),!0)}return _t(Te(r.nodeType==3?Ee(r):r,-n),n>=0)}function _t(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 Kn(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 Ts(t,e,n){let r=t.state,u=t.root.activeElement;r!=e&&t.updateState(e),u!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),u!=t.dom&&u&&u.focus()}}function Ta(t,e,n){let r=e.selection,u=n=="up"?r.$from:r.$to;return Ts(t,e,()=>{let{node:i}=t.docView.domFromPos(u.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(i,!0);if(!o)break;if(o.node.isBlock){i=o.contentDOM||o.dom;break}i=o.dom.parentNode}let s=ws(t,u.pos,1);for(let o=i.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Ee(o,0,o.nodeValue.length).getClientRects();else continue;for(let a=0;a<l.length;a++){let c=l[a];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Oa=/[\u0590-\u08ac]/;function Fa(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let u=r.parentOffset,i=!u,s=u==r.parent.content.size,o=t.domSelection();return o?!Oa.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?i:s:Ts(t,e,()=>{let{focusNode:l,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),p=o.caretBidiLevel;o.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:m}=t.domSelectionRange(),g=d&&!h.contains(d.nodeType==1?d:d.parentNode)||l==d&&a==m;try{o.collapse(c,f),l&&(l!=c||a!=f)&&o.extend&&o.extend(l,a)}catch{}return p!=null&&(o.caretBidiLevel=p),g}):r.pos==r.start()||r.pos==r.end()}let Nu=null,Iu=null,Ru=!1;function Na(t,e,n){return Nu==e&&Iu==n?Ru:(Nu=e,Iu=n,Ru=n=="up"||n=="down"?Ta(t,e,n):Fa(t,e,n))}const ie=0,Bu=1,Ue=2,ye=3;class Zt{constructor(e,n,r,u){this.parent=e,this.children=n,this.dom=r,this.contentDOM=u,this.dirty=ie,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){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 u=this.children[n];if(u==e)return r;r+=u.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&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let u;if(e==this.dom&&this.contentDOM)u=n>V(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))u=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!1;break}if(i.previousSibling)break}if(u==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!0;break}if(i.nextSibling)break}}return u??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,u=e;u;u=u.parentNode){let i=this.getDesc(u),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==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 u=e;u;u=u.parentNode){let i=this.getDesc(u);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let u=this.children[n],i=r+u.size;if(r==e&&i!=r){for(;!u.border&&u.children.length;)for(let s=0;s<u.children.length;s++){let o=u.children[s];if(o.size){u=o;break}}return u}if(e<i)return u.descAt(e-r-u.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,u=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(o>e||s instanceof Fs){u=e-i;break}i=o}if(u)return this.children[r].domFromPos(u-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Os&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?V(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?V(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 u=-1,i=-1;for(let s=r,o=0;;o++){let l=this.children[o],a=s+l.size;if(u==-1&&e<=a){let c=s+l.border;if(e>=c&&n<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=s;for(let f=o;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){u=V(p.dom)+1;break}e-=p.size}u==-1&&(u=0)}if(u>-1&&(a>n||o==this.children.length-1)){n=a;for(let c=o+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=V(f.dom);break}n+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:n,fromOffset:u,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(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,u=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,d=0;h<this.children.length;h++){let m=this.children[h],g=d+m.size;if(i>d&&s<g)return m.setSelection(e-d-m.border,n-d-m.border,r,u);d=g}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),a=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((ue||U)&&e==n){let{node:h,offset:d}=o;if(h.nodeType==3){if(f=!!(d&&h.nodeValue[d-1]==`
|
|
7
7
|
`),f&&d==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(o=l={node:g.parentNode,offset:V(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[d-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ue&&c.focusNode&&c.focusNode!=l.node&&c.focusNode.nodeType==1){let h=c.focusNode.childNodes[c.focusOffset];h&&h.contentEditable=="false"&&(u=!0)}if(!(u||f&&U)&&nt(o.node,o.offset,c.anchorNode,c.anchorOffset)&&nt(l.node,l.offset,c.focusNode,c.focusOffset))return;let p=!1;if((a.extend||e==n)&&!(f&&ue)){a.collapse(o.node,o.offset);try{e!=n&&a.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>n){let d=o;o=l,l=d}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(o.node,o.offset),a.removeAllRanges(),a.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,u=0;u<this.children.length;u++){let i=this.children[u],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+i.border,l=s-i.border;if(e>=o&&n<=l){this.dirty=e==r||n==s?Ue:Bu,e==o&&n==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ye:i.markDirty(e-o,n-o);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ue:ye}r=s}this.dirty=Ue}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ue:Bu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Os extends Zt{constructor(e,n,r,u){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return u;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==ie&&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}}class Ia extends Zt{constructor(e,n,r,u){super(e,[],n,null),this.textDOM=r,this.text=u}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}}class rt extends Zt{constructor(e,n,r,u,i){super(e,[],r,u),this.mark=n,this.spec=i}static create(e,n,r,u){let i=u.nodeViews[n.type.name],s=i&&i(n,u,r);return(!s||!s.dom)&&(s=xt.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new rt(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ye||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ye&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ie){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ie}}slice(e,n,r){let u=rt.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Er(i,n,s,r)),e>0&&(i=Er(i,0,e,r));for(let o=0;o<i.length;o++)i[o].parent=u;return u.children=i,u}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qe extends Zt{constructor(e,n,r,u,i,s,o,l,a){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=u,this.nodeDOM=o}static create(e,n,r,u,i,s){let o=i.nodeViews[n.type.name],l,a=o&&o(n,i,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,u),c=a&&a.dom,f=a&&a.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=xt.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let p=c;return c=Rs(c,r,n),a?l=new Ra(e,n,r,u,c,f||null,p,a,i,s+1):n.isText?new On(e,n,r,u,c,p,i):new qe(e,n,r,u,c,f||null,p,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,n,r){return this.dirty==ie&&e.eq(this.node)&&bn(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,u=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,l=new va(this,s&&s.node,e);La(this.node,this.innerDeco,(a,c,f)=>{a.spec.marks?l.syncToMarks(a.spec.marks,r,e):a.type.side>=0&&!f&&l.syncToMarks(c==this.node.childCount?w.none:this.node.child(c).marks,r,e),l.placeWidget(a,e,u)},(a,c,f,p)=>{l.syncToMarks(a.marks,r,e);let h;l.findNodeMatch(a,c,f,p)||o&&e.state.selection.from>u&&e.state.selection.to<u+a.nodeSize&&(h=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(a,c,f,h,e)||l.updateNextNode(a,c,f,e,p,u)||l.addNode(a,c,f,e,u),u+=a.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Ue)&&(s&&this.protectLocalComposition(e,s),Ns(this.contentDOM,this.children,e),mt&&qa(this.dom))}localCompositionInfo(e,n){let{from:r,to:u}=e.state.selection;if(!(e.state.selection instanceof N)||r<n||u>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 s=i.nodeValue,o=Va(this.node.content,s,r-n,u-n);return o<0?null:{node:i,pos:o,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:u}){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 s=new Ia(this,i,n,u);e.input.compositionNodes.push(s),this.children=Er(this.children,r,r+u.length,e,s)}update(e,n,r,u){return this.dirty==ye||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,u),!0)}updateInner(e,n,r,u){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(u,this.posAtStart),this.dirty=ie}updateOuterDeco(e){if(bn(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Is(this.dom,this.nodeDOM,_r(this.outerDeco,this.node,n),_r(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function vu(t,e,n,r,u){Rs(r,e,t);let i=new qe(void 0,t,e,n,r,r,r,u,0);return i.contentDOM&&i.updateChildren(u,0),i}class On extends qe{constructor(e,n,r,u,i,s,o){super(e,n,r,u,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,u){return this.dirty==ye||this.dirty!=ie&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ie||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,u.trackWrites==this.nodeDOM&&(u.trackWrites=null)),this.node=e,this.dirty=ie,!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 u=this.node.cut(e,n),i=document.createTextNode(u.text);return new On(this.parent,u,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ye)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Fs extends Zt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ie&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ra extends qe{constructor(e,n,r,u,i,s,o,l,a,c){super(e,n,r,u,i,s,o,a,c),this.spec=l}update(e,n,r,u){if(this.dirty==ye)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,u),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,u)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,u){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,u)}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 Ns(t,e,n){let r=t.firstChild,u=!1;for(let i=0;i<e.length;i++){let s=e[i],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=zu(r),u=!0;r=r.nextSibling}else u=!0,t.insertBefore(o,r);if(s instanceof rt){let l=r?r.previousSibling:t.lastChild;Ns(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=zu(r),u=!0;u&&n.trackWrites==t&&(n.trackWrites=null)}const Ft=function(t){t&&(this.nodeName=t)};Ft.prototype=Object.create(null);const Ke=[new Ft];function _r(t,e,n){if(t.length==0)return Ke;let r=n?Ke[0]:new Ft,u=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&u.push(r=new Ft(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&u.length==1&&u.push(r=new Ft(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return u}function Is(t,e,n,r){if(n==Ke&&r==Ke)return e;let u=e;for(let i=0;i<r.length;i++){let s=r[i],o=n[i];if(i){let l;o&&o.nodeName==s.nodeName&&u!=t&&(l=u.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(u),o=Ke[0]),u=l}Ba(u,o||Ke[0],s)}return u}function Ba(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):[],u=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)u.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<u.length;i++)r.indexOf(u[i])==-1&&t.classList.add(u[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,u;for(;u=r.exec(e.style);)t.style.removeProperty(u[1])}n.style&&(t.style.cssText+=n.style)}}function Rs(t,e,n){return Is(t,t,Ke,_r(e,n,t.nodeType!=1))}function bn(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 zu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class va{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=za(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){let u=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;u<s&&(u==i-1?this.top:this.stack[u+1<<1]).matchesMark(e[u])&&e[u].type.spec.spanning!==!1;)u++;for(;u<i;)this.destroyRest(),this.top.dirty=ie,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let a=this.top.children[l];if(a.matchesMark(e[i])&&!this.isLocked(a.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=rt.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,u){let i=-1,s;if(u>=this.preMatch.index&&(s=this.preMatch.matches[u-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let a=this.top.children[o];if(a.matchesNode(e,n,r)&&!this.preMatch.matched.has(a)){i=o;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,u,i){let s=this.top.children[u];return s.dirty==ye&&s.dom==s.contentDOM&&(s.dirty=Ue),s.update(e,n,r,i)?(this.destroyBetween(this.index,u),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 u=this.index;u<this.top.children.length;u++)if(this.top.children[u]==r)return u}return-1}e=n}}updateNextNode(e,n,r,u,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof qe){let a=this.preMatch.matched.get(l);if(a!=null&&a!=i)return!1;let c=l.dom,f,p=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ye&&bn(n,l.outerDeco));if(!p&&l.update(e,n,r,u))return this.destroyBetween(this.index,o),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(l,e,n,r,u,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Ue,f.updateChildren(u,s+1),f.dirty=ie),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,u,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!bn(r,e.outerDeco)||!u.eq(e.innerDeco))return null;let o=qe.create(this.top,n,r,u,i,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,u,i){let s=qe.create(this.top,e,n,r,u,i);s.contentDOM&&s.updateChildren(u,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let u=this.index<this.top.children.length?this.top.children[this.index]:null;if(u&&u.matchesWidget(e)&&(e==u.widget||!u.widget.type.toDOM.parentNode))this.index++;else{let i=new Os(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 rt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof On)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((U||J)&&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 u=new Fs(this.top,[],r,null);n!=this.top?n.children.push(u):n.children.splice(this.index++,0,u),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function za(t,e){let n=e,r=n.children.length,u=t.childCount,i=new Map,s=[];e:for(;u>0;){let o;for(;;)if(r){let a=n.children[r-1];if(a instanceof rt)n=a,r=a.children.length;else{o=a,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(u-1))break;--u,i.set(o,u),s.push(o)}}return{index:u,matched:i,matches:s.reverse()}}function Pa(t,e){return t.type.side-e.type.side}function La(t,e,n,r){let u=e.locals(t),i=0;if(u.length==0){for(let a=0;a<t.childCount;a++){let c=t.child(a);r(c,u,e.forChild(i,c),a),i+=c.nodeSize}return}let s=0,o=[],l=null;for(let a=0;;){let c,f;for(;s<u.length&&u[s].to==i;){let g=u[s++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(Pa);for(let g=0;g<f.length;g++)n(f[g],a,!!l)}else n(c,a,!!l);let p,h;if(l)h=-1,p=l,l=null;else if(a<t.childCount)h=a,p=t.child(a++);else break;for(let g=0;g<o.length;g++)o[g].to<=i&&o.splice(g--,1);for(;s<u.length&&u[s].from<=i&&u[s].to>i;)o.push(u[s++]);let d=i+p.nodeSize;if(p.isText){let g=d;s<u.length&&u[s].from<g&&(g=u[s].from);for(let b=0;b<o.length;b++)o[b].to<g&&(g=o[b].to);g<d&&(l=p.cut(g-i),p=p.cut(0,g-i),d=g,h=-1)}else for(;s<u.length&&u[s].to<d;)s++;let m=p.isInline&&!p.isLeaf?o.filter(g=>!g.inline):o.slice();r(p,m,e.forChild(i,p),h),i=d}}function qa(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 Va(t,e,n,r){for(let u=0,i=0;u<t.childCount&&i<=r;){let s=t.child(u++),o=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;u<t.childCount;){let a=t.child(u++);if(i+=a.nodeSize,!a.isText)break;l+=a.text}if(i>=n){if(i>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let a=o<r?l.lastIndexOf(e,r-o-1):-1;if(a>=0&&a+e.length+o>=n)return o+a;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function Er(t,e,n,r,u){let i=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],a=o,c=o+=l.size;a>=n||c<=e?i.push(l):(a<e&&i.push(l.slice(0,e-a,r)),u&&(i.push(u),u=void 0),c>n&&i.push(l.slice(n-a,l.size,r)))}return i}function Jr(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let u=t.docView.nearestDesc(n.focusNode),i=u&&u.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),l,a;if(Tn(n)){for(l=s;u&&!u.node;)u=u.parent;let f=u.node;if(u&&f.isAtom&&M.isSelectable(f)&&u.parent&&!(f.isInline&&ha(n.focusNode,n.focusOffset,u.dom))){let p=u.posBefore;a=new M(s==p?o:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,p=s;for(let h=0;h<n.rangeCount;h++){let d=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(d.startContainer,d.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(d.endContainer,d.endOffset,-1))}if(f<0)return null;[l,s]=p==t.state.selection.anchor?[p,f]:[f,p],o=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let c=r.resolve(l);if(!a){let f=e=="pointer"||t.state.selection.head<o.pos&&!i?1:-1;a=jr(t,c,o,f)}return a}function Bs(t){return t.editable?t.hasFocus():zs(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Me(t,e=!1){let n=t.state.selection;if(vs(t,n),!!Bs(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&J){let r=t.domSelectionRange(),u=t.domObserver.currentSelection;if(r.anchorNode&&u.anchorNode&&nt(r.anchorNode,r.anchorOffset,u.anchorNode,u.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Wa(t);else{let{anchor:r,head:u}=n,i,s;Pu&&!(n instanceof N)&&(n.$from.parent.inlineContent||(i=Lu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=Lu(t,n.to))),t.docView.setSelection(r,u,t,e),Pu&&(i&&qu(i),s&&qu(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&$a(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Pu=U||J&&_s<63;function Lu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),u=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(U&&u&&u.contentEditable=="false")return Zn(u);if((!u||u.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(u)return Zn(u);if(i)return Zn(i)}}function Zn(t){return t.contentEditable="true",U&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function qu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function $a(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,u=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=u)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Bs(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Wa(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,V(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Y&&Le<=11&&(n.disabled=!0,n.disabled=!1)}function vs(t,e){if(e instanceof M){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Vu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Vu(t)}function Vu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function jr(t,e,n,r){return t.someProp("createSelectionBetween",u=>u(t,e,n))||N.between(e,n,r)}function $u(t){return t.editable&&!t.hasFocus()?!1:zs(t)}function zs(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ha(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return nt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Sr(t,e){let{$anchor:n,$head:r}=t.selection,u=e>0?n.max(r):n.min(r),i=u.parent.inlineContent?u.depth?t.doc.resolve(e>0?u.after():u.before()):null:u;return i&&F.findFrom(i,e)}function Oe(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Wu(t,e,n){let r=t.state.selection;if(r instanceof N)if(n.indexOf("s")>-1){let{$head:u}=r,i=u.textOffset?null:e<0?u.nodeBefore:u.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(u.pos+i.nodeSize*(e<0?-1:1));return Oe(t,new N(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let u=Sr(t.state,e);return u&&u instanceof M?Oe(t,u):!1}else if(!(ne&&n.indexOf("m")>-1)){let u=r.$head,i=u.textOffset?null:e<0?u.nodeBefore:u.nodeAfter,s;if(!i||i.isText)return!1;let o=e<0?u.pos-i.nodeSize:u.pos;return i.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?M.isSelectable(i)?Oe(t,new M(e<0?t.state.doc.resolve(u.pos-i.nodeSize):u)):Kt?Oe(t,new N(t.state.doc.resolve(e<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof M&&r.node.isInline)return Oe(t,new N(e>0?r.$to:r.$from));{let u=Sr(t.state,e);return u?Oe(t,u):!1}}}function xn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nt(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function it(t,e){return e<0?Ja(t):ja(t)}function Ja(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let u,i,s=!1;for(ue&&n.nodeType==1&&r<xn(n)&&Nt(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Nt(o,-1))u=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(Ps(n))break;{let o=n.previousSibling;for(;o&&Nt(o,-1);)u=n.parentNode,i=V(o),o=o.previousSibling;if(o)n=o,r=xn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Ar(t,n,r):u&&Ar(t,u,i)}function ja(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let u=xn(n),i,s;for(;;)if(r<u){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Nt(o,1))i=n,s=++r;else break}else{if(Ps(n))break;{let o=n.nextSibling;for(;o&&Nt(o,1);)i=o.parentNode,s=V(o)+1,o=o.nextSibling;if(o)n=o,r=0,u=xn(n);else{if(n=n.parentNode,n==t.dom)break;r=u=0}}}i&&Ar(t,i,s)}function Ps(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ua(t,e){for(;t&&e==t.childNodes.length&&!Ut(t);)e=V(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Ka(t,e){for(;t&&!e&&!Ut(t);)e=V(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Ar(t,e,n){if(e.nodeType!=3){let i,s;(s=Ua(e,n))?(e=s,n=0):(i=Ka(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Tn(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:u}=t;setTimeout(()=>{t.state==u&&Me(t)},50)}function Hu(t,e){let n=t.state.doc.resolve(e);if(!(J||ga)&&n.parent.inlineContent){let u=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>u.top&&s<u.bottom&&Math.abs(i.left-u.left)>1)return i.left<u.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>u.top&&s<u.bottom&&Math.abs(i.left-u.left)>1)return i.left>u.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ju(t,e,n){let r=t.state.selection;if(r instanceof N&&!r.empty||n.indexOf("s")>-1||ne&&n.indexOf("m")>-1)return!1;let{$from:u,$to:i}=r;if(!u.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Sr(t.state,e);if(s&&s instanceof M)return Oe(t,s)}if(!u.parent.inlineContent){let s=e<0?u:i,o=r instanceof ee?F.near(s,e):F.findFrom(s,e);return o?Oe(t,o):!1}return!1}function ju(t,e){if(!(t.state.selection instanceof N))return!0;let{$head:n,$anchor:r,empty:u}=t.state.selection;if(!n.sameParent(r))return!0;if(!u)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 s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Uu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Za(t){if(!U||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Uu(t,r,"true"),setTimeout(()=>Uu(t,r,"false"),20)}return!1}function Ga(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Ya(t,e){let n=e.keyCode,r=Ga(e);if(n==8||ne&&n==72&&r=="c")return ju(t,-1)||it(t,-1);if(n==46&&!e.shiftKey||ne&&n==68&&r=="c")return ju(t,1)||it(t,1);if(n==13||n==27)return!0;if(n==37||ne&&n==66&&r=="c"){let u=n==37?Hu(t,t.state.selection.from)=="ltr"?-1:1:-1;return Wu(t,u,r)||it(t,u)}else if(n==39||ne&&n==70&&r=="c"){let u=n==39?Hu(t,t.state.selection.from)=="ltr"?1:-1:1;return Wu(t,u,r)||it(t,u)}else{if(n==38||ne&&n==80&&r=="c")return Ju(t,-1,r)||it(t,-1);if(n==40||ne&&n==78&&r=="c")return Za(t)||Ju(t,1,r)||it(t,1);if(r==(ne?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ur(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:u,openEnd:i}=e;for(;u>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){u--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||xt.fromSchema(t.state.schema),o=Hs(),l=o.createElement("div");l.appendChild(s.serializeFragment(r,{document:o}));let a=l.firstChild,c,f=0;for(;a&&a.nodeType==1&&(c=Ws[a.nodeName.toLowerCase()]);){for(let h=c.length-1;h>=0;h--){let d=o.createElement(c[h]);for(;l.firstChild;)d.appendChild(l.firstChild);l.appendChild(d),f++}a=l.firstChild}a&&a.nodeType==1&&a.setAttribute("data-pm-slice",`${u} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
8
8
|
|
|
9
9
|
`);return{dom:l,text:p,slice:e}}function Ls(t,e,n,r,u){let i=u.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return o=new C(x.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-DJ6AuTd_.cjs");function S(f,t=null){return function(e,n){let{$from:o,$to:l}=e.selection,i=o.blockRange(l);if(!i)return!1;let d=n?e.tr:null;return h(d,i,f,t)?(n&&n(d.scrollIntoView()),!0):!1}}function h(f,t,e,n=null){let o=!1,l=t,i=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(e)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let u=i.resolve(t.start-2);l=new r.NodeRange(u,u,t.depth),t.endIndex<t.parent.childCount&&(t=new r.NodeRange(t.$from,i.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let d=r.findWrapping(l,e,n,t);return d?(f&&$(f,t,d,o,e),!0):!1}function $(f,t,e,n,o){let l=r.Fragment.empty;for(let p=e.length-1;p>=0;p--)l=r.Fragment.from(e[p].type.create(e[p].attrs,l));f.step(new r.ReplaceAroundStep(t.start-(n?2:0),t.end,t.start,t.end,new r.Slice(l,0,0),e.length,!0));let i=0;for(let p=0;p<e.length;p++)e[p].type==o&&(i=p+1);let d=e.length-i,u=t.start+e.length-(n?2:0),m=t.parent;for(let p=t.startIndex,s=t.endIndex,c=!0;p<s;p++,c=!1)!c&&r.canSplit(f.doc,u,d)&&(f.split(u,d),u+=2*d),u+=m.child(p).nodeSize;return f}function R(f){return function(t,e){let{$from:n,$to:o}=t.selection,l=n.blockRange(o,i=>i.childCount>0&&i.firstChild.type==f);return l?e?n.node(l.depth-1).type==f?x(t,e,f,l):F(t,e,l):!0:!1}}function x(f,t,e,n){let o=f.tr,l=n.end,i=n.$to.end(n.depth);l<i&&(o.step(new r.ReplaceAroundStep(l-1,i,l,i,new r.Slice(r.Fragment.from(e.create(null,n.parent.copy())),1,0),1,!0)),n=new r.NodeRange(o.doc.resolve(n.$from.pos),o.doc.resolve(i),n.depth));const d=r.liftTarget(n);if(d==null)return!1;o.lift(n,d);let u=o.doc.resolve(o.mapping.map(l,-1)-1);return r.canJoin(o.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&o.join(u.pos),t(o.scrollIntoView()),!0}function F(f,t,e){let n=f.tr,o=e.parent;for(let a=e.end,I=e.endIndex-1,y=e.startIndex;I>y;I--)a-=o.child(I).nodeSize,n.delete(a-1,a+1);let l=n.doc.resolve(e.start),i=l.nodeAfter;if(n.mapping.map(e.end)!=e.start+l.nodeAfter.nodeSize)return!1;let d=e.startIndex==0,u=e.endIndex==o.childCount,m=l.node(-1),p=l.index(-1);if(!m.canReplace(p+(d?0:1),p+1,i.content.append(u?r.Fragment.empty:r.Fragment.from(o))))return!1;let s=l.pos,c=s+i.nodeSize;return n.step(new r.ReplaceAroundStep(s-(d?1:0),c+(u?1:0),s+1,c-1,new r.Slice((d?r.Fragment.empty:r.Fragment.from(o.copy(r.Fragment.empty))).append(u?r.Fragment.empty:r.Fragment.from(o.copy(r.Fragment.empty))),d?0:1,u?0:1),d?0:1)),t(n.scrollIntoView()),!0}exports.liftListItem=R;exports.wrapInList=S;exports.wrapRangeInList=h;
|