oficina / slides Public
File too large to show in full — download it above (showing a truncated preview below).
| 1 | var Cg=Object.defineProperty;var Tg=(n,e,t)=>e in n?Cg(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var fs=(n,e,t)=>Tg(n,typeof e!="symbol"?e+"":e,t);var Te=()=>new Map,ds=n=>{let e=Te();return n.forEach((t,r)=>{e.set(r,t)}),e},Je=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},bf=(n,e)=>{let t=[];for(let[r,i]of n)t.push(e(i,r));return t},wf=(n,e)=>{for(let[t,r]of n)if(e(r,t))return!0;return!1};var nt=()=>new Set;var hs=n=>n[n.length-1];var kf=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},St=Array.from,ps=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},Pr=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1};var Sf=(n,e)=>{let t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t};var Ct=Array.isArray;var $r=class{constructor(){this._observers=Te()}on(e,t){return Je(this._observers,e,nt).add(t),t}once(e,t){let r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){let r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return St((this._observers.get(e)||Te()).values()).forEach(r=>r(...t))}destroy(){this._observers=Te()}};var de=Math.floor;var ln=Math.abs;var Tt=(n,e)=>n<e?n:e,rt=(n,e)=>n>e?n:e,HS=Number.isNaN;var ms=n=>n!==0?n<0:1/n<0;var Hn=Number.MAX_SAFE_INTEGER,yl=Number.MIN_SAFE_INTEGER,KS=1<<31;var Cf=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&de(n)===n),XS=Number.isNaN,GS=Number.parseInt;var qr=String.fromCharCode,Eg=String.fromCodePoint,ZS=qr(65535),Ag=n=>n.toLowerCase(),Og=/^\s*/g,Mg=n=>n.replace(Og,""),Ng=/([A-Z])/g,bl=(n,e)=>Mg(n.replace(Ng,t=>`${e}${Ag(t)}`));var Dg=n=>{let e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Xn=typeof TextEncoder<"u"?new TextEncoder:null,Ig=n=>Xn.encode(n),Tf=Xn?Ig:Dg;var Kn=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Kn&&Kn.decode(new Uint8Array).length===1&&(Kn=null);var Ef=(n,e)=>Sf(e,()=>n).join("");var an=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Qn=()=>new an,Df=n=>{let e=Qn();return n(e),Ye(e)},_g=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e};var Ye=n=>{let e=new Uint8Array(_g(n)),t=0;for(let r=0;r<n.bufs.length;r++){let i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},Rg=(n,e)=>{let t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(rt(t,e)*2),n.cpos=0)},ie=(n,e)=>{let t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e};var ys=ie;var V=(n,e)=>{for(;e>127;)ie(n,128|127&e),e=de(e/128);ie(n,127&e)},xs=(n,e)=>{let t=ms(e);for(t&&(e=-e),ie(n,(e>63?128:0)|(t?64:0)|63&e),e=de(e/64);e>0;)ie(n,(e>127?128:0)|127&e),e=de(e/128)},wl=new Uint8Array(3e4),vg=wl.length/3,Bg=(n,e)=>{if(e.length<vg){let t=Xn.encodeInto(e,wl).written||0;V(n,t);for(let r=0;r<t;r++)ie(n,wl[r])}else _e(n,Tf(e))},Ug=(n,e)=>{let t=unescape(encodeURIComponent(e)),r=t.length;V(n,r);for(let i=0;i<r;i++)ie(n,t.codePointAt(i))},fn=Xn&&Xn.encodeInto?Bg:Ug;var jr=(n,e)=>{let t=n.cbuf.length,r=n.cpos,i=Tt(t-r,e.length),s=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,s>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(rt(t*2,s)),n.cbuf.set(e.subarray(i)),n.cpos=s)},_e=(n,e)=>{V(n,e.byteLength),jr(n,e)},kl=(n,e)=>{Rg(n,e);let t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},Vg=(n,e)=>kl(n,4).setFloat32(0,e,!1),Lg=(n,e)=>kl(n,8).setFloat64(0,e,!1),Fg=(n,e)=>kl(n,8).setBigInt64(0,e,!1);var Of=new DataView(new ArrayBuffer(4)),Pg=n=>(Of.setFloat32(0,n),Of.getFloat32(0)===n),Pt=(n,e)=>{switch(typeof e){case"string":ie(n,119),fn(n,e);break;case"number":Cf(e)&&ln(e)<=2147483647?(ie(n,125),xs(n,e)):Pg(e)?(ie(n,124),Vg(n,e)):(ie(n,123),Lg(n,e));break;case"bigint":ie(n,122),Fg(n,e);break;case"object":if(e===null)ie(n,126);else if(Ct(e)){ie(n,117),V(n,e.length);for(let t=0;t<e.length;t++)Pt(n,e[t])}else if(e instanceof Uint8Array)ie(n,116),_e(n,e);else{ie(n,118);let t=Object.keys(e);V(n,t.length);for(let r=0;r<t.length;r++){let i=t[r];fn(n,i),Pt(n,e[i])}}break;case"boolean":ie(n,e?120:121);break;default:ie(n,127)}},Yr=class extends an{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&V(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};var Mf=n=>{n.count>0&&(xs(n.encoder,n.count===1?n.s:-n.s),n.count>1&&V(n.encoder,n.count-2))},dn=class{constructor(){this.encoder=new an,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Mf(this),this.count=1,this.s=e)}toUint8Array(){return Mf(this),Ye(this.encoder)}};var Nf=n=>{if(n.count>0){let e=n.diff*2+(n.count===1?0:1);xs(n.encoder,e),n.count>1&&V(n.encoder,n.count-2)}},Zn=class{constructor(){this.encoder=new an,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Nf(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Nf(this),Ye(this.encoder)}},gs=class{constructor(){this.sarr=[],this.s="",this.lensE=new dn}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){let e=new an;return this.sarr.push(this.s),this.s="",fn(e,this.sarr.join("")),jr(e,this.lensE.toUint8Array()),Ye(e)}};var Le=n=>new Error(n),Ee=()=>{throw Le("Method unimplemented")},ne=()=>{throw Le("Unexpected case")};var _f=Le("Unexpected end of array"),Rf=Le("Integer out of Range"),er=class{constructor(e){this.arr=e,this.pos=0}},ws=n=>new er(n),vf=n=>n.pos!==n.arr.length;var zg=(n,e)=>{let t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Re=n=>zg(n,U(n));var un=n=>n.arr[n.pos++];var U=n=>{let e=0,t=1,r=n.arr.length;for(;n.pos<r;){let i=n.arr[n.pos++];if(e=e+(i&127)*t,t*=128,i<128)return e;if(e>Hn)throw Rf}throw _f},ks=n=>{let e=n.arr[n.pos++],t=e&63,r=64,i=(e&64)>0?-1:1;if((e&128)===0)return i*t;let s=n.arr.length;for(;n.pos<s;){if(e=n.arr[n.pos++],t=t+(e&127)*r,r*=128,e<128)return i*t;if(t>Hn)throw Rf}throw _f};var $g=n=>{let e=U(n);if(e===0)return"";{let t=String.fromCodePoint(un(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(un(n));else for(;e>0;){let r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},qg=n=>Kn.decode(Re(n)),hn=Kn?qg:$g;var Sl=(n,e)=>{let t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},Jg=n=>Sl(n,4).getFloat32(0,!1),Yg=n=>Sl(n,8).getFloat64(0,!1),jg=n=>Sl(n,8).getBigInt64(0,!1);var Wg=[n=>{},n=>null,ks,Jg,Yg,jg,n=>!1,n=>!0,hn,n=>{let e=U(n),t={};for(let r=0;r<e;r++){let i=hn(n);t[i]=tr(n)}return t},n=>{let e=U(n),t=[];for(let r=0;r<e;r++)t.push(tr(n));return t},Re],tr=n=>Wg[127-un(n)](n),Hr=class extends er{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),vf(this)?this.count=U(this)+1:this.count=-1),this.count--,this.s}};var pn=class extends er{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=ks(this);let e=ms(this.s);this.count=1,e&&(this.s=-this.s,this.count=U(this)+2)}return this.count--,this.s}};var nr=class extends er{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=ks(this),t=e&1;this.diff=de(e/2),this.count=1,t&&(this.count=U(this)+2)}return this.s+=this.diff,this.count--,this.s}},bs=class{constructor(e){this.decoder=new pn(e),this.str=hn(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};var t1=crypto.subtle,Bf=crypto.getRandomValues.bind(crypto);var Kg=Math.random,Cl=()=>Bf(new Uint32Array(1))[0];var Uf=n=>n[de(Kg()*n.length)],Xg="10000000-1000-4000-8000"+-1e11,Vf=()=>Xg.replace(/[018]/g,n=>(n^Cl()&15>>n/4).toString(16));var Ss=Date.now;var Tl=n=>new Promise(n);var i1=Promise.all.bind(Promise);var El=n=>n===void 0?null:n;var Al=class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},Pf=new Al,Qg=!0;try{typeof localStorage<"u"&&localStorage&&(Pf=localStorage,Qg=!1)}catch{}var zf=Pf;var mn=Symbol("Equality"),Cs=(n,e)=>n===e||!!n?.[mn]?.(e)||!1;var $f=n=>typeof n=="object",qf=Object.assign,Ml=Object.keys;var Jf=(n,e)=>{for(let t in n)e(n[t],t)};var Kr=n=>Ml(n).length;var Yf=n=>{for(let e in n)return!1;return!0},$t=(n,e)=>{for(let t in n)if(!e(n[t],t))return!1;return!0},Xr=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),Nl=(n,e)=>n===e||Kr(n)===Kr(e)&&$t(n,(t,r)=>(t!==void 0||Xr(e,r))&&Cs(e[r],t)),ty=Object.freeze,Dl=n=>{for(let e in n){let t=n[e];(typeof t=="object"||typeof t=="function")&&Dl(n[e])}return ty(n)};var Zr=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&Zr(n,e,t+1)}};var Gr=(n,e)=>{if(n===e)return!0;if(n==null||e==null||n.constructor!==e.constructor&&(n.constructor||Object)!==(e.constructor||Object))return!1;if(n[mn]!=null)return n[mn](e);switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(let t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(let t of n.keys())if(!e.has(t)||!Gr(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Kr(n)!==Kr(e))return!1;for(let t in n)if(!Xr(n,t)||!Gr(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Gr(n[t],e[t]))return!1;break;default:return!1}return!0},jf=(n,e)=>e.includes(n);var rr=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",ei=typeof window<"u"&&typeof document<"u"&&!rr,s1=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,dt,ny=[],ry=()=>{if(dt===void 0)if(rr){dt=Te();let n=process.argv,e=null;for(let t=0;t<n.length;t++){let r=n[t];r[0]==="-"?(e!==null&&dt.set(e,""),e=r):e!==null?(dt.set(e,r),e=null):ny.push(r)}e!==null&&dt.set(e,"")}else typeof location=="object"?(dt=Te(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){let[e,t]=n.split("=");dt.set(`--${bl(e,"-")}`,t),dt.set(`-${bl(e,"-")}`,t)}})):dt=Te();return dt},_l=n=>ry().has(n);var Qr=n=>rr?El(process.env[n.toUpperCase().replaceAll("-","_")]):El(zf.getItem(n));var Wf=n=>_l("--"+n)||Qr(n)!==null,Hf=Wf("production"),iy=rr&&jf(process.env.FORCE_COLOR,["true","1","2"]),Kf=iy||!_l("--no-colors")&&!Wf("no-color")&&(!rr||process.stdout.isTTY)&&(!rr||_l("--color")||Qr("COLORTERM")!==null||(Qr("TERM")||"").includes("color"));var sy=n=>new Uint8Array(n);var oy=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=qr(n[t]);return btoa(e)},ly=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64");var Xf=ei?oy:ly;var Gf=n=>{let e=sy(n.byteLength);return e.set(n),e},Zf=n=>Df(e=>Pt(e,n));var Rl=class{constructor(e,t){this.left=e,this.right=t}},ut=(n,e)=>new Rl(n,e);var vl=n=>n.next()>=.5,Es=(n,e,t)=>de(n.next()*(t+1-e)+e);var Bl=(n,e,t)=>de(n.next()*(t+1-e)+e);var Ul=(n,e,t)=>Bl(n,e,t);var ay=n=>qr(Ul(n,97,122)),ed=(n,e=0,t=20)=>{let r=Ul(n,e,t),i="";for(let s=0;s<r;s++)i+=ay(n);return i};var As=(n,e)=>e[Ul(n,0,e.length-1)];var dy=Symbol("0schema"),Vl=class{constructor(){this._rerrs=[]}extend(e,t,r,i=null){this._rerrs.push({path:e,expected:t,has:r,message:i})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let r=this._rerrs[t];e.push(Ef(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(` |
| 2 | `)}},Ll=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[mn]?Cs(n,e):Ct(n)?ps(n,t=>Pr(e,r=>Ll(t,r))):$f(n)?$t(n,(t,r)=>Ll(t,e[r])):!1,se=class{extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),Ll(t,r)}equals(e){return this.constructor===e.constructor&&Gr(this.shape,e.shape)}[dy](){return!0}[mn](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ee()}get nullable(){return ar(this,Fs)}get optional(){return new Os(this)}cast(e){return td(e,this),e}expect(e){return td(e,this),e}};fs(se,"_dilutes",!1);var ni=class extends se{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},ee=(n,e=null)=>new ni(n,e),l1=ee(ni),ri=class extends se{constructor(e){super(),this.shape=e}check(e,t){let r=this.shape(e);return!r&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}},re=n=>new ri(n),c1=ee(ri),lr=class extends se{constructor(e){super(),this.shape=e}check(e,t){let r=this.shape.some(i=>i===e);return!r&&t?.extend(null,this.shape.join(" | "),e.toString()),r}},Vs=(...n)=>new lr(n),nd=ee(lr),uy=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),rd=n=>{if(cr.check(n))return[uy(n)];if(nd.check(n))return n.shape.map(e=>e+"");if(cd.check(n))return["[+-]?\\d+.?\\d*"];if(ad.check(n))return[".*"];if(vs.check(n))return n.shape.map(rd).flat(1);ne()},Fl=class extends se{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(rd).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){let r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}};var a1=ee(Fl),hy=Symbol("optional"),Os=class extends se{constructor(e){super(),this.shape=e}check(e,t){let r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,"undefined (optional)","()"),r}get[hy](){return!0}},py=ee(Os),Ms=class extends se{check(e,t){return t?.extend(null,"never",typeof e),!1}},f1=new Ms,d1=ee(Ms),Us=class Us extends se{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}get partial(){return new Us(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,"object","null"),!1):$t(this.shape,(r,i)=>{let s=this._isPartial&&!Xr(e,i)||r.check(e[i],t);return!s&&t?.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match"),s})}};fs(Us,"_dilutes",!0);var Ns=Us,my=n=>new Ns(n),gy=ee(Ns),yy=re(n=>n!=null&&(n.constructor===Object||n.constructor==null)),Ds=class extends se{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&$t(e,(r,i)=>{let s=this.shape.keys.check(i,t);return!s&&t?.extend(i+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(r,t)})}},id=(n,e)=>new Ds(n,e),xy=ee(Ds),Is=class extends se{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&$t(this.shape,(r,i)=>{let s=r.check(e[i],t);return!s&&t?.extend(i.toString(),"Tuple",typeof r),s})}},by=(...n)=>new Is(n),u1=ee(Is),_s=class extends se{constructor(e){super(),this.shape=e.length===1?e[0]:new sr(e)}check(e,t){let r=Ct(e)&&ps(e,i=>this.shape.check(i));return!r&&t?.extend(null,"Array",""),r}},sd=(...n)=>new _s(n),wy=ee(_s),ky=re(n=>Ct(n)),Rs=class extends se{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}},Sy=(n,e=null)=>new Rs(n,e),h1=ee(Rs),Cy=Sy(se),Pl=class extends se{constructor(e){super(),this.len=e.length-1,this.args=by(...e.slice(-1)),this.res=e[this.len]}check(e,t){let r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,"function",typeof e),r}};var Ty=ee(Pl),Ey=re(n=>typeof n=="function"),zl=class extends se{constructor(e){super(),this.shape=e}check(e,t){let r=ps(this.shape,i=>i.check(e,t));return!r&&t?.extend(null,"Intersectinon",typeof e),r}};var p1=ee(zl,n=>n.shape.length>0),sr=class extends se{constructor(e){super(),this.shape=e}check(e,t){let r=Pr(this.shape,i=>i.check(e,t));return t?.extend(null,"Union",typeof e),r}};fs(sr,"_dilutes",!0);var ar=(...n)=>n.findIndex(e=>vs.check(e))>=0?ar(...n.map(e=>ii(e)).map(e=>vs.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new sr(n),vs=ee(sr),od=()=>!0,Bs=re(od),Ay=ee(ri,n=>n.shape===od),ql=re(n=>typeof n=="bigint"),Oy=re(n=>n===ql),ld=re(n=>typeof n=="symbol"),m1=re(n=>n===ld),or=re(n=>typeof n=="number"),cd=re(n=>n===or),cr=re(n=>typeof n=="string"),ad=re(n=>n===cr),Ls=re(n=>typeof n=="boolean"),My=re(n=>n===Ls),fd=Vs(void 0),g1=ee(lr,n=>n.shape.length===1&&n.shape[0]===void 0),y1=Vs(void 0);var Fs=Vs(null),Ny=ee(lr,n=>n.shape.length===1&&n.shape[0]===null),x1=ee(Uint8Array),b1=ee(ni,n=>n.shape===Uint8Array),Dy=ar(or,cr,Fs,fd,ql,Ls,ld),w1=(()=>{let n=sd(Bs),e=id(cr,Bs),t=ar(or,cr,Fs,Ls,n,e);return n.shape=t,e.shape.values=t,t})(),ii=n=>{if(Cy.check(n))return n;if(yy.check(n)){let e={};for(let t in n)e[t]=ii(n[t]);return my(e)}else{if(ky.check(n))return ar(...n.map(ii));if(Dy.check(n))return Vs(n);if(Ey.check(n))return ee(n)}ne()},td=Hf?()=>{}:(n,e)=>{let t=new Vl;if(!e.check(n,t))throw Le(`Expected value to be of type ${e.constructor.name}. |
| 3 | ${t.toString()}`)},$l=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:ii(e),h:t}),this}else(e){return this.if(Bs,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){let i=this.patterns[r];if(i.if.check(e))return i.h(e,t)}throw Le("Unhandled pattern")}}},Iy=n=>new $l(n),dd=Iy(Bs).if(cd,(n,e)=>Es(e,yl,Hn)).if(ad,(n,e)=>ed(e)).if(My,(n,e)=>vl(e)).if(Oy,(n,e)=>BigInt(Es(e,yl,Hn))).if(vs,(n,e)=>ir(e,As(e,n.shape))).if(gy,(n,e)=>{let t={};for(let r in n.shape){let i=n.shape[r];if(py.check(i)){if(vl(e))continue;i=i.shape}t[r]=dd(i,e)}return t}).if(wy,(n,e)=>{let t=[],r=Bl(e,0,42);for(let i=0;i<r;i++)t.push(ir(e,n.shape));return t}).if(nd,(n,e)=>As(e,n.shape)).if(Ny,(n,e)=>null).if(Ty,(n,e)=>{let t=ir(e,n.res);return()=>t}).if(Ay,(n,e)=>ir(e,As(e,[or,cr,Fs,fd,ql,Ls,sd(or),id(ar("a","b","c"),or)]))).if(xy,(n,e)=>{let t={},r=Es(e,0,3);for(let i=0;i<r;i++){let s=ir(e,n.shape.keys),o=ir(e,n.shape.values);t[s]=o}return t}).done(),ir=(n,e)=>dd(ii(e),n);var Et=typeof document<"u"?document:{};var S1=re(n=>n.nodeType===Uy);var C1=typeof DOMParser<"u"?new DOMParser:null;var T1=re(n=>n.nodeType===Ry);var E1=re(n=>n.nodeType===vy);var ud=n=>bf(n,(e,t)=>`${t}:${e};`).join("");var Ry=Et.ELEMENT_NODE,vy=Et.TEXT_NODE,A1=Et.CDATA_SECTION_NODE,O1=Et.COMMENT_NODE,By=Et.DOCUMENT_NODE,M1=Et.DOCUMENT_TYPE_NODE,Uy=Et.DOCUMENT_FRAGMENT_NODE,N1=re(n=>n.nodeType===By);var Ps=n=>class{constructor(t){this._=t}destroy(){n(this._)}},Vy=Ps(clearTimeout),Jl=(n,e)=>new Vy(setTimeout(e,n)),I1=Ps(clearInterval);var _1=Ps(n=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(n));var R1=Ps(n=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(n));var ht=Symbol;var si=ht(),oi=ht(),Yl=ht(),jl=ht(),Wl=ht(),li=ht(),Hl=ht(),fr=ht(),Kl=ht(),pd=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let e=[],t=[],r=0;for(;r<n.length;r++){let i=n[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&t.push(e.join(""));r<n.length;r++){let i=n[r];i instanceof Symbol||t.push(i)}return t};var v1=Ss();var zy={[si]:ut("font-weight","bold"),[oi]:ut("font-weight","normal"),[Yl]:ut("color","blue"),[Wl]:ut("color","green"),[jl]:ut("color","grey"),[li]:ut("color","red"),[Hl]:ut("color","purple"),[fr]:ut("color","orange"),[Kl]:ut("color","black")},$y=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let e=[],t=[],r=Te(),i=[],s=0;for(;s<n.length;s++){let o=n[s],l=zy[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let c=ud(r);s>0||c.length>0?(e.push("%c"+o),t.push(c)):e.push(o)}else break}}for(s>0&&(i=t,i.unshift(e.join("")));s<n.length;s++){let o=n[s];o instanceof Symbol||i.push(o)}return i},md=Kf?$y:pd,gd=(...n)=>{console.log(...md(n)),yd.forEach(e=>e.print(n))},Xl=(...n)=>{console.warn(...md(n)),n.unshift(fr),yd.forEach(e=>e.print(n))};var yd=nt();var xd=n=>({[Symbol.iterator](){return this},next:n}),bd=(n,e)=>xd(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),zs=(n,e)=>xd(()=>{let{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});var fi=class{constructor(e,t){this.clock=e,this.len=t}},Yt=class{constructor(){this.clients=new Map}},At=(n,e,t)=>e.clients.forEach((r,i)=>{let s=n.doc.store.clients.get(i);if(s!=null){let o=s[s.length-1],l=o.id.clock+o.length;for(let c=0,a=r[c];c<r.length&&a.clock<l;a=r[++c])zd(n,s,a.clock,a.len,t)}}),Wy=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){let i=de((t+r)/2),s=n[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;t=i+1}else r=i-1}return null},bn=(n,e)=>{let t=n.clients.get(e.client);return t!==void 0&&Wy(t,e.clock)!==null},kc=n=>{n.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){let i=e[r-1],s=e[t];i.clock+i.len>=s.clock?i.len=rt(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++)}e.length=r})},Zl=n=>{let e=new Yt;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,i)=>{if(!e.clients.has(i)){let s=r.slice();for(let o=t+1;o<n.length;o++)kf(s,n[o].clients.get(i)||[]);e.clients.set(i,s)}});return kc(e),e},di=(n,e,t,r)=>{Je(n.clients,e,()=>[]).push(new fi(t,r))},to=()=>new Yt,Hy=n=>{let e=to();return n.clients.forEach((t,r)=>{let i=[];for(let s=0;s<t.length;s++){let o=t[s];if(o.deleted){let l=o.id.clock,c=o.length;if(s+1<t.length)for(let a=t[s+1];s+1<t.length&&a.deleted;a=t[++s+1])c+=a.length;i.push(new fi(l,c))}}i.length>0&&e.clients.set(r,i)}),e},Sc=(n,e)=>{V(n.restEncoder,e.clients.size),St(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),V(n.restEncoder,t);let i=r.length;V(n.restEncoder,i);for(let s=0;s<i;s++){let o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Ky=n=>{let e=new Yt,t=U(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();let i=U(n.restDecoder),s=U(n.restDecoder);if(s>0){let o=Je(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new fi(n.readDsClock(),n.readDsLen()))}}return e},Sd=(n,e,t)=>{let r=new Yt,i=U(n.restDecoder);for(let s=0;s<i;s++){n.resetDsCurVal();let o=U(n.restDecoder),l=U(n.restDecoder),c=t.clients.get(o)||[],a=G(t,o);for(let f=0;f<l;f++){let d=n.readDsClock(),u=d+n.readDsLen();if(d<a){a<u&&di(r,o,a,u-a);let h=je(c,d),p=c[h];for(!p.deleted&&p.id.clock<d&&(c.splice(h+1,0,eo(e,p,d-p.id.clock)),h++);h<c.length&&(p=c[h++],p.id.clock<u);)p.deleted||(u<p.id.clock+p.length&&c.splice(h,0,eo(e,p,u-p.id.clock)),p.delete(e))}else di(r,o,d,u-d)}}if(r.clients.size>0){let s=new hr;return V(s.restEncoder,0),Sc(s,r),s.toUint8Array()}return null};var Ud=Cl,it=class n extends $r{constructor({guid:e=Vf(),collectionid:t=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=Ud(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Xs,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Tl(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>Tl(a=>{let f=d=>{(d===void 0||d===!0)&&(this.off("sync",f),a())};this.on("sync",f)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;e!==null&&!this.shouldLoad&&q(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(St(this.subdocs).map(e=>e.guid))}transact(e,t=null){return q(this,e,t)}get(e,t=H){let r=Je(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==H&&i!==t)if(i===H){let s=new t;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Pe)}getText(e=""){return this.get(e,Ot)}getMap(e=""){return this.get(e,ge)}getXmlElement(e=""){return this.get(e,J)}getXmlFragment(e=""){return this.get(e,W)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,St(this.subdocs).forEach(t=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new n({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,q(e.parent.doc,r=>{let i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Ql=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return U(this.restDecoder)}readDsLen(){return U(this.restDecoder)}},Hs=class extends Ql{readLeftID(){return _(U(this.restDecoder),U(this.restDecoder))}readRightID(){return _(U(this.restDecoder),U(this.restDecoder))}readClient(){return U(this.restDecoder)}readInfo(){return un(this.restDecoder)}readString(){return hn(this.restDecoder)}readParentInfo(){return U(this.restDecoder)===1}readTypeRef(){return U(this.restDecoder)}readLen(){return U(this.restDecoder)}readAny(){return tr(this.restDecoder)}readBuf(){return Gf(Re(this.restDecoder))}readJSON(){return JSON.parse(hn(this.restDecoder))}readKey(){return hn(this.restDecoder)}},ec=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=U(this.restDecoder),this.dsCurrVal}readDsLen(){let e=U(this.restDecoder)+1;return this.dsCurrVal+=e,e}},ur=class extends ec{constructor(e){super(e),this.keys=[],U(e),this.keyClockDecoder=new nr(Re(e)),this.clientDecoder=new pn(Re(e)),this.leftClockDecoder=new nr(Re(e)),this.rightClockDecoder=new nr(Re(e)),this.infoDecoder=new Hr(Re(e),un),this.stringDecoder=new bs(Re(e)),this.parentInfoDecoder=new Hr(Re(e),un),this.typeRefDecoder=new pn(Re(e)),this.lenDecoder=new pn(Re(e))}readLeftID(){return new Jt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Jt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return tr(this.restDecoder)}readBuf(){return Re(this.restDecoder)}readJSON(){return tr(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let t=this.stringDecoder.read();return this.keys.push(t),t}}},tc=class{constructor(){this.restEncoder=Qn()}toUint8Array(){return Ye(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){V(this.restEncoder,e)}writeDsLen(e){V(this.restEncoder,e)}},Ks=class extends tc{writeLeftID(e){V(this.restEncoder,e.client),V(this.restEncoder,e.clock)}writeRightID(e){V(this.restEncoder,e.client),V(this.restEncoder,e.clock)}writeClient(e){V(this.restEncoder,e)}writeInfo(e){ys(this.restEncoder,e)}writeString(e){fn(this.restEncoder,e)}writeParentInfo(e){V(this.restEncoder,e?1:0)}writeTypeRef(e){V(this.restEncoder,e)}writeLen(e){V(this.restEncoder,e)}writeAny(e){Pt(this.restEncoder,e)}writeBuf(e){_e(this.restEncoder,e)}writeJSON(e){fn(this.restEncoder,JSON.stringify(e))}writeKey(e){fn(this.restEncoder,e)}},nc=class{constructor(){this.restEncoder=Qn(),this.dsCurrVal=0}toUint8Array(){return Ye(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,V(this.restEncoder,t)}writeDsLen(e){e===0&&ne(),V(this.restEncoder,e-1),this.dsCurrVal+=e}},hr=class extends nc{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Zn,this.clientEncoder=new dn,this.leftClockEncoder=new Zn,this.rightClockEncoder=new Zn,this.infoEncoder=new Yr(ys),this.stringEncoder=new gs,this.parentInfoEncoder=new Yr(ys),this.typeRefEncoder=new dn,this.lenEncoder=new dn}toUint8Array(){let e=Qn();return V(e,0),_e(e,this.keyClockEncoder.toUint8Array()),_e(e,this.clientEncoder.toUint8Array()),_e(e,this.leftClockEncoder.toUint8Array()),_e(e,this.rightClockEncoder.toUint8Array()),_e(e,Ye(this.infoEncoder)),_e(e,this.stringEncoder.toUint8Array()),_e(e,Ye(this.parentInfoEncoder)),_e(e,this.typeRefEncoder.toUint8Array()),_e(e,this.lenEncoder.toUint8Array()),jr(e,Ye(this.restEncoder)),Ye(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Pt(this.restEncoder,e)}writeBuf(e){_e(this.restEncoder,e)}writeJSON(e){Pt(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Xy=(n,e,t,r)=>{r=rt(r,e[0].id.clock);let i=je(e,r);V(n.restEncoder,e.length-i),n.writeClient(t),V(n.restEncoder,r);let s=e[i];s.write(n,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(n,0)},Vd=(n,e,t)=>{let r=new Map;t.forEach((i,s)=>{G(e,s)>i&&r.set(s,i)}),so(e).forEach((i,s)=>{t.has(s)||r.set(s,0)}),V(n.restEncoder,r.size),St(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Xy(n,e.clients.get(i),i,s)})},Gy=(n,e)=>{let t=Te(),r=U(n.restDecoder);for(let i=0;i<r;i++){let s=U(n.restDecoder),o=new Array(s),l=n.readClient(),c=U(n.restDecoder);t.set(l,{i:0,refs:o});for(let a=0;a<s;a++){let f=n.readInfo();switch(31&f){case 0:{let d=n.readLen();o[a]=new Be(_(l,c),d),c+=d;break}case 10:{let d=U(n.restDecoder);o[a]=new Fe(_(l,c),d),c+=d;break}default:{let d=(f&192)===0,u=new z(_(l,c),null,(f&128)===128?n.readLeftID():null,null,(f&64)===64?n.readRightID():null,d?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,d&&(f&32)===32?n.readString():null,cu(n,f));o[a]=u,c+=u.length}}}}return t},Zy=(n,e,t)=>{let r=[],i=St(t.keys()).sort((h,p)=>h-p);if(i.length===0)return null;let s=()=>{if(i.length===0)return null;let h=t.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=t.get(i[i.length-1]);else return null;return h},o=s();if(o===null)return null;let l=new Xs,c=new Map,a=(h,p)=>{let m=c.get(h);(m==null||m>p)&&c.set(h,p)},f=o.refs[o.i++],d=new Map,u=()=>{for(let h of r){let p=h.id.client,m=t.get(p);m?(m.i--,l.clients.set(p,m.refs.slice(m.i)),t.delete(p),m.i=0,m.refs=[]):l.clients.set(p,[h]),i=i.filter(g=>g!==p)}r.length=0};for(;;){if(f.constructor!==Fe){let p=Je(d,f.id.client,()=>G(e,f.id.client))-f.id.clock;if(p<0)r.push(f),a(f.id.client,f.id.clock-1),u();else{let m=f.getMissing(n,e);if(m!==null){r.push(f);let g=t.get(m)||{refs:[],i:0};if(g.refs.length===g.i)a(m,G(e,m)),u();else{f=g.refs[g.i++];continue}}else(p===0||p<f.length)&&(f.integrate(n,p),d.set(f.id.client,f.id.clock+f.length))}}if(r.length>0)f=r.pop();else if(o!==null&&o.i<o.refs.length)f=o.refs[o.i++];else{if(o=s(),o===null)break;f=o.refs[o.i++]}}if(l.clients.size>0){let h=new hr;return Vd(h,l,new Map),V(h.restEncoder,0),{missing:c,update:h.toUint8Array()}}return null},Qy=(n,e)=>Vd(n,e.doc.store,e.beforeState),ex=(n,e,t,r=new ur(n))=>q(e,i=>{i.local=!1;let s=!1,o=i.doc,l=o.store,c=Gy(r,o),a=Zy(i,l,c),f=l.pendingStructs;if(f){for(let[u,h]of f.missing)if(h<G(l,u)){s=!0;break}if(a){for(let[u,h]of a.missing){let p=f.missing.get(u);(p==null||p>h)&&f.missing.set(u,h)}f.update=dc([f.update,a.update])}}else l.pendingStructs=a;let d=Sd(r,i,l);if(l.pendingDs){let u=new ur(ws(l.pendingDs));U(u.restDecoder);let h=Sd(u,i,l);d&&h?l.pendingDs=dc([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(s){let u=l.pendingStructs.update;l.pendingStructs=null,xi(i.doc,u)}},t,!1);var xi=(n,e,t,r=ur)=>{let i=ws(e);ex(i,n,t,new r(i))},Cc=(n,e,t)=>xi(n,e,t,Hs);var rc=class{constructor(){this.l=[]}},Cd=()=>new rc,Td=(n,e)=>n.l.push(e),Ed=(n,e)=>{let t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ld=(n,e,t)=>Zr(n.l,[e,t]),Jt=class{constructor(e,t){this.client=e,this.clock=t}},$s=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,_=(n,e)=>new Jt(n,e);var br=n=>{for(let[e,t]of n.doc.share.entries())if(t===n)return e;throw ne()},pr=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};var yn=class{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}};var ic=class{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}},tx=(n,e,t=0)=>new ic(n,e,t),qs=(n,e,t)=>{let r=null,i=null;return n._item===null?i=br(n):r=_(n._item.id.client,n._item.id.clock),new yn(r,i,e,t)},no=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return qs(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return qs(n,_(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return qs(n,r.lastId,t);r=r.right}return qs(n,null,t)};var nx=(n,e)=>{let t=dr(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},Fd=(n,e,t=!0)=>{let r=e.store,i=n.item,s=n.type,o=n.tname,l=n.assoc,c=null,a=0;if(i!==null){if(G(r,i.client)<=i.clock)return null;let f=t?bc(r,i):nx(r,i),d=f.item;if(!(d instanceof z))return null;if(c=d.parent,c._item===null||!c._item.deleted){a=d.deleted||!d.countable?0:f.diff+(l>=0?0:1);let u=d.left;for(;u!==null;)!u.deleted&&u.countable&&(a+=u.length),u=u.left}}else{if(o!==null)c=e.get(o);else if(s!==null){if(G(r,s.client)<=s.clock)return null;let{item:f}=t?bc(r,s):{item:dr(r,s)};if(f instanceof z&&f.content instanceof pt)c=f.content.type;else return null}else throw ne();l>=0?a=c._length:a=0}return tx(c,a,n.assoc)};var mr=class{constructor(e,t){this.ds=e,this.sv=t}};var ro=(n,e)=>new mr(n,e),Y1=ro(to(),new Map),io=n=>ro(Hy(n.store),so(n.store)),gn=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!bn(e.ds,n.id),sc=(n,e)=>{let t=Je(n.meta,sc,nt),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<G(r,s)&&ve(n,_(s,i))}),At(n,e.ds,i=>{}),t.add(e))};var Xs=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},so=n=>{let e=new Map;return n.clients.forEach((t,r)=>{let i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},G=(n,e)=>{let t=n.clients.get(e);if(t===void 0)return 0;let r=t[t.length-1];return r.id.clock+r.length},Pd=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{let r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw ne()}t.push(e)},je=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=de(e/(s+i.length-1)*r);for(;t<=r;){if(i=n[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;t=o+1}else r=o-1;o=de((t+r)/2)}throw ne()},rx=(n,e)=>{let t=n.clients.get(e.client);return t[je(t,e.clock)]},dr=rx,oc=(n,e,t)=>{let r=je(e,t),i=e[r];return i.id.clock<t&&i instanceof z?(e.splice(r+1,0,eo(n,i,t-i.id.clock)),r+1):r},ve=(n,e)=>{let t=n.doc.store.clients.get(e.client);return t[oc(n,t,e.clock)]},Ad=(n,e,t)=>{let r=e.clients.get(t.client),i=je(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==Be&&r.splice(i+1,0,eo(n,s,t.clock-s.id.clock+1)),s},ix=(n,e,t)=>{let r=n.clients.get(e.id.client);r[je(r,e.id.clock)]=t},zd=(n,e,t,r,i)=>{if(r===0)return;let s=t+r,o=oc(n,e,t),l;do l=e[o++],s<l.id.clock+l.length&&oc(n,e,s),i(l);while(o<e.length&&e[o].id.clock<s)},lc=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Yt,this.beforeState=so(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Od=(n,e)=>e.deleteSet.clients.size===0&&!wf(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(kc(e.deleteSet),Qy(n,e),Sc(n,e.deleteSet),!0),Md=(n,e,t)=>{let r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Je(n.changed,e,nt).add(t)},js=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof z&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}let s=e-i;return s&&n.splice(e+1-s,s),s},sx=(n,e,t)=>{for(let[r,i]of n.clients.entries()){let s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){let l=i[o],c=l.clock+l.len;for(let a=je(s,l.clock),f=s[a];a<s.length&&f.id.clock<c;f=s[++a]){let d=s[a];if(l.clock+l.len<=d.id.clock)break;d instanceof z&&d.deleted&&!d.keep&&t(d)&&d.gc(e,!1)}}}},ox=(n,e)=>{n.clients.forEach((t,r)=>{let i=e.clients.get(r);for(let s=t.length-1;s>=0;s--){let o=t[s],l=Tt(i.length-1,1+je(i,o.clock+o.len-1));for(let c=l,a=i[c];c>0&&a.id.clock>=o.clock;a=i[c])c-=1+js(i,c)}})};var $d=(n,e)=>{if(e<n.length){let t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{kc(s),t.afterState=so(t.doc.store),r.emit("beforeObserverCalls",[t,r]);let l=[];t.changed.forEach((c,a)=>l.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(t,c)})),l.push(()=>{t.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(f=>f.target._item===null||!f.target._item.deleted),c.forEach(f=>{f.currentTarget=a,f._path=null}),c.sort((f,d)=>f.path.length-d.path.length),Ld(a._dEH,c,t))})}),l.push(()=>r.emit("afterTransaction",[t,r])),Zr(l,[]),t._needFormattingCleanup&&wx(t)}finally{r.gc&&sx(s,i,r.gcFilter),ox(s,i),t.afterState.forEach((f,d)=>{let u=t.beforeState.get(d)||0;if(u!==f){let h=i.clients.get(d),p=rt(je(h,u),1);for(let m=h.length-1;m>=p;)m-=1+js(h,m)}});for(let f=o.length-1;f>=0;f--){let{client:d,clock:u}=o[f].id,h=i.clients.get(d),p=je(h,u);p+1<h.length&&js(h,p+1)>1||p>0&&js(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(gd(fr,si,"[yjs] ",oi,li,"Changed the client-id because another client seems to be using it."),r.clientID=Ud()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){let f=new Ks;Od(f,t)&&r.emit("update",[f.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){let f=new hr;Od(f,t)&&r.emit("updateV2",[f.toUint8Array(),t.origin,r,t])}let{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=t;(l.size>0||a.size>0||c.size>0)&&(l.forEach(f=>{f.clientID=r.clientID,f.collectionid==null&&(f.collectionid=r.collectionid),r.subdocs.add(f)}),a.forEach(f=>r.subdocs.delete(f)),r.emit("subdocs",[{loaded:c,added:l,removed:a},r,t]),a.forEach(f=>f.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):$d(n,e+1)}}},q=(n,e,t=null,r=!0)=>{let i=n._transactionCleanups,s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new lc(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(s){let l=n._transaction===i[0];n._transaction=null,l&&$d(i,0)}}return o},cc=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Nd=(n,e,t)=>{At(n,t.deletions,r=>{r instanceof z&&e.scope.some(i=>i===n.doc||pr(i,r))&&Mc(r,!1)})},Dd=(n,e,t)=>{let r=null,i=n.doc,s=n.scope;q(i,l=>{for(;e.length>0&&n.currStackItem===null;){let c=i.store,a=e.pop(),f=new Set,d=[],u=!1;At(l,a.insertions,h=>{if(h instanceof z){if(h.redone!==null){let{item:p,diff:m}=bc(c,h.id);m>0&&(p=ve(l,_(p.id.client,p.id.clock+m))),h=p}!h.deleted&&s.some(p=>p===l.doc||pr(p,h))&&d.push(h)}}),At(l,a.deletions,h=>{h instanceof z&&s.some(p=>p===l.doc||pr(p,h))&&!bn(a.insertions,h.id)&&f.add(h)}),f.forEach(h=>{u=lu(l,h,f,a.insertions,n.ignoreRemoteMapChanges,n)!==null||u});for(let h=d.length-1;h>=0;h--){let p=d[h];n.deleteFilter(p)&&(p.delete(l),u=!0)}n.currStackItem=u?a:null}l.changed.forEach((c,a)=>{c.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=l},n);let o=n.currStackItem;if(o!=null){let l=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:o,type:t,changedParentTypes:l,origin:n},n]),n.currStackItem=null}return o},gr=class extends $r{constructor(e,{captureTimeout:t=500,captureTransaction:r=c=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Ct(e)?e[0].doc:e instanceof it?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=i,s.add(this),this.trackedOrigins=s,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=c=>{if(!this.captureTransaction(c)||!this.scope.some(g=>c.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,d=a?this.redoStack:this.undoStack;a?this.stopCapturing():f||this.clear(!1,!0);let u=new Yt;c.afterState.forEach((g,y)=>{let k=c.beforeState.get(y)||0,x=g-k;x>0&&di(u,y,k,x)});let h=Ss(),p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!a&&!f){let g=d[d.length-1];g.deletions=Zl([g.deletions,c.deleteSet]),g.insertions=Zl([g.insertions,u])}else d.push(new cc(c.deleteSet,u)),p=!0;!a&&!f&&(this.lastChange=h),At(c,c.deleteSet,g=>{g instanceof z&&this.scope.some(y=>y===c.doc||pr(y,g))&&Mc(g,!0)});let m=[{stackItem:d[d.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=Ct(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof H?r.doc!==this.doc:r!==this.doc)&&Xl("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>Nd(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>Nd(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Dd(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Dd(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*lx(n){let e=U(n.restDecoder);for(let t=0;t<e;t++){let r=U(n.restDecoder),i=n.readClient(),s=U(n.restDecoder);for(let o=0;o<r;o++){let l=n.readInfo();if(l===10){let c=U(n.restDecoder);yield new Fe(_(i,s),c),s+=c}else if((31&l)!==0){let c=(l&192)===0,a=new z(_(i,s),null,(l&128)===128?n.readLeftID():null,null,(l&64)===64?n.readRightID():null,c?n.readParentInfo()?n.readString():n.readLeftID():null,c&&(l&32)===32?n.readString():null,cu(n,l));yield a,s+=a.length}else{let c=n.readLen();yield new Be(_(i,s),c),s+=c}}}}var ac=class{constructor(e,t){this.gen=lx(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Fe);return this.curr}};var fc=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},qd=n=>dc(n,Hs,Ks);var cx=(n,e)=>{if(n.constructor===Be){let{client:t,clock:r}=n.id;return new Be(_(t,r+e),n.length-e)}else if(n.constructor===Fe){let{client:t,clock:r}=n.id;return new Fe(_(t,r+e),n.length-e)}else{let t=n,{client:r,clock:i}=t.id;return new z(_(r,i+e),null,_(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},dc=(n,e=ur,t=hr)=>{if(n.length===1)return n[0];let r=n.map(f=>new e(ws(f))),i=r.map(f=>new ac(f,!0)),s=null,o=new t,l=new fc(o);for(;i=i.filter(u=>u.curr!==null),i.sort((u,h)=>{if(u.curr.id.client===h.curr.id.client){let p=u.curr.id.clock-h.curr.id.clock;return p===0?u.curr.constructor===h.curr.constructor?0:u.curr.constructor===Fe?1:-1:p}else return h.curr.id.client-u.curr.id.client}),i.length!==0;){let f=i[0],d=f.curr.id.client;if(s!==null){let u=f.curr,h=!1;for(;u!==null&&u.id.clock+u.length<=s.struct.id.clock+s.struct.length&&u.id.client>=s.struct.id.client;)u=f.next(),h=!0;if(u===null||u.id.client!==d||h&&u.id.clock>s.struct.id.clock+s.struct.length)continue;if(d!==s.struct.id.client)ci(l,s.struct,s.offset),s={struct:u,offset:0},f.next();else if(s.struct.id.clock+s.struct.length<u.id.clock)if(s.struct.constructor===Fe)s.struct.length=u.id.clock+u.length-s.struct.id.clock;else{ci(l,s.struct,s.offset);let p=u.id.clock-s.struct.id.clock-s.struct.length;s={struct:new Fe(_(d,s.struct.id.clock+s.struct.length),p),offset:0}}else{let p=s.struct.id.clock+s.struct.length-u.id.clock;p>0&&(s.struct.constructor===Fe?s.struct.length-=p:u=cx(u,p)),s.struct.mergeWith(u)||(ci(l,s.struct,s.offset),s={struct:u,offset:0},f.next())}}else s={struct:f.curr,offset:0},f.next();for(let u=f.curr;u!==null&&u.id.client===d&&u.id.clock===s.struct.id.clock+s.struct.length&&u.constructor!==Fe;u=f.next())ci(l,s.struct,s.offset),s={struct:u,offset:0}}s!==null&&(ci(l,s.struct,s.offset),s=null),ax(l);let c=r.map(f=>Ky(f)),a=Zl(c);return Sc(o,a),o.toUint8Array()};var Jd=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Ye(n.encoder.restEncoder)}),n.encoder.restEncoder=Qn(),n.written=0)},ci=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&Jd(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),V(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},ax=n=>{Jd(n);let e=n.encoder.restEncoder;V(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){let r=n.clientStructs[t];V(e,r.written),jr(e,r.restEncoder)}};var Id="You must not compute changes after the event-handler fired.",yr=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=fx(this.currentTarget,this.target))}deletes(e){return bn(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Le(Id);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){let s=t._map.get(i),o,l;if(this.adds(s)){let c=s.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",l=hs(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",l=hs(c.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=hs(s.content.getContent());else return;e.set(i,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Le(Id);let t=this.target,r=nt(),i=nt(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null,c=()=>{l&&s.push(l)};for(let a=t._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((l===null||l.delete===void 0)&&(c(),l={delete:0}),l.delete+=a.length,i.add(a)):this.adds(a)?((l===null||l.insert===void 0)&&(c(),l={insert:[]}),l.insert=l.insert.concat(a.content.getContent()),r.add(a)):((l===null||l.retain===void 0)&&(c(),l={retain:0}),l.retain+=a.length);l!==null&&l.retain===void 0&&c()}this._changes=e}return e}},fx=(n,e)=>{let t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;t.unshift(r)}e=e._item.parent}return t},me=()=>{Xl("Invalid access: Add Yjs type to a document before reading data.")},Yd=80,Tc=0,uc=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Tc++}},dx=n=>{n.timestamp=Tc++},jd=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Tc++},ux=(n,e,t)=>{if(n.length>=Yd){let r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return jd(r,e,t),r}else{let r=new uc(e,t);return n.push(r),r}},oo=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;let t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,o)=>ln(e-s.index)<ln(e-o.index)?s:o),r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,dx(t));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return t!==null&&ln(t.index-i)<r.parent.length/Yd?(jd(t,r,i),t):ux(n._searchMarker,r,i)},ui=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){let i=n[r];if(t>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){n.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=rt(e,i.index+t))}};var lo=(n,e,t)=>{let r=n,i=e.changedParentTypes;for(;Je(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Ld(r._eH,t,e)},H=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Cd(),this._dEH=Cd(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ee()}clone(){throw Ee()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Td(this._eH,e)}observeDeep(e){Td(this._dEH,e)}unobserve(e){Ed(this._eH,e)}unobserveDeep(e){Ed(this._dEH,e)}toJSON(){}},Wd=(n,e,t)=>{n.doc??me(),e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e,i=[],s=n._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){let o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)i.push(o[l]),r--;e=0}}s=s.right}return i},Hd=n=>{n.doc??me();let e=[],t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){let r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},Ec=(n,e)=>{let t=[],r=n._start;for(;r!==null;){if(r.countable&&gn(r,e)){let i=r.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}r=r.right}return t},hi=(n,e)=>{let t=0,r=n._start;for(n.doc??me();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let s=0;s<i.length;s++)e(i[s],t++,n)}r=r.right}},Kd=(n,e)=>{let t=[];return hi(n,(r,i)=>{t.push(e(r,i,n))}),t},hx=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}let i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Xd=(n,e)=>{n.doc??me();let t=oo(n,e),r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Gs=(n,e,t,r)=>{let i=t,s=n.doc,o=s.clientID,l=s.store,c=t===null?e._start:t.right,a=[],f=()=>{a.length>0&&(i=new z(_(o,G(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new xr(a)),i.integrate(n,0),a=[])};r.forEach(d=>{if(d===null)a.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(d);break;default:switch(f(),d.constructor){case Uint8Array:case ArrayBuffer:i=new z(_(o,G(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new gi(new Uint8Array(d))),i.integrate(n,0);break;case it:i=new z(_(o,G(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new yi(d)),i.integrate(n,0);break;default:if(d instanceof H)i=new z(_(o,G(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new pt(d)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},Gd=()=>Le("Length exceeded!"),Zd=(n,e,t,r)=>{if(t>e._length)throw Gd();if(t===0)return e._searchMarker&&ui(e._searchMarker,t,r.length),Gs(n,e,null,r);let i=t,s=oo(e,t),o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&ve(n,_(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&ui(e._searchMarker,i,r.length),Gs(n,e,o,r)},px=(n,e,t)=>{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return Gs(n,e,i,t)},Qd=(n,e,t,r)=>{if(r===0)return;let i=t,s=r,o=oo(e,t),l=e._start;for(o!==null&&(l=o.p,t-=o.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&ve(n,_(l.id.client,l.id.clock+t)),t-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&ve(n,_(l.id.client,l.id.clock+r)),l.delete(n),r-=l.length),l=l.right;if(r>0)throw Gd();e._searchMarker&&ui(e._searchMarker,i,-s+r)},Zs=(n,e,t)=>{let r=e._map.get(t);r!==void 0&&r.delete(n)},Ac=(n,e,t,r)=>{let i=e._map.get(t)||null,s=n.doc,o=s.clientID,l;if(r==null)l=new xr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new xr([r]);break;case Uint8Array:l=new gi(r);break;case it:l=new yi(r);break;default:if(r instanceof H)l=new pt(r);else throw new Error("Unexpected content type")}new z(_(o,G(s.store,o)),i,i&&i.lastId,null,null,e,t,l).integrate(n,0)},Oc=(n,e)=>{n.doc??me();let t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},eu=n=>{let e={};return n.doc??me(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},tu=(n,e)=>{n.doc??me();let t=n._map.get(e);return t!==void 0&&!t.deleted};var mx=(n,e)=>{let t={};return n._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&gn(s,e)&&(t[i]=s.content.getContent()[s.length-1])}),t},Js=n=>(n.doc??me(),bd(n._map.entries(),e=>!e[1].deleted)),hc=class extends yr{},Pe=class n extends H{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new n;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof H?t.clone():t)),e}get length(){return this.doc??me(),this._length}_callObserver(e,t){super._callObserver(e,t),lo(this,e,new hc(this,e))}insert(e,t){this.doc!==null?q(this.doc,r=>{Zd(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?q(this.doc,t=>{px(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?q(this.doc,r=>{Qd(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Xd(this,e)}toArray(){return Hd(this)}slice(e=0,t=this.length){return Wd(this,e,t)}toJSON(){return this.map(e=>e instanceof H?e.toJSON():e)}map(e){return Kd(this,e)}forEach(e){hi(this,e)}[Symbol.iterator](){return hx(this)}_write(e){e.writeTypeRef(Vx)}},gx=n=>new Pe,pc=class extends yr{constructor(e,t,r){super(e,t),this.keysChanged=r}},ge=class n extends H{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return this.forEach((t,r)=>{e.set(r,t instanceof H?t.clone():t)}),e}_callObserver(e,t){lo(this,e,new pc(this,e,t))}toJSON(){this.doc??me();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let i=t.content.getContent()[t.length-1];e[r]=i instanceof H?i.toJSON():i}}),e}get size(){return[...Js(this)].length}keys(){return zs(Js(this),e=>e[0])}values(){return zs(Js(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return zs(Js(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??me(),this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?q(this.doc,t=>{Zs(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?q(this.doc,r=>{Ac(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Oc(this,e)}has(e){return tu(this,e)}clear(){this.doc!==null?q(this.doc,e=>{this.forEach(function(t,r,i){Zs(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Lx)}},yx=n=>new ge,qt=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&Nl(n,e),pi=class{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){this.right===null&&ne(),this.right.content.constructor===Z?this.right.deleted||wr(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},_d=(n,e,t)=>{for(;e.right!==null&&t>0;)e.right.content.constructor===Z?e.right.deleted||wr(e.currentAttributes,e.right.content):e.right.deleted||(t<e.right.length&&ve(n,_(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Ys=(n,e,t,r)=>{let i=new Map,s=r?oo(e,t):null;if(s){let o=new pi(s.p.left,s.p,s.index,i);return _d(n,o,t-s.index)}else{let o=new pi(null,e._start,0,i);return _d(n,o,t)}},nu=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Z&&qt(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();let i=n.doc,s=i.clientID;r.forEach((o,l)=>{let c=t.left,a=t.right,f=new z(_(s,G(i.store,s)),c,c&&c.lastId,a,a&&a.id,e,null,new Z(l,o));f.integrate(n,0),t.right=f,t.forward()})},wr=(n,e)=>{let{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},ru=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Z&&qt(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},iu=(n,e,t,r)=>{let i=n.doc,s=i.clientID,o=new Map;for(let l in r){let c=r[l],a=t.currentAttributes.get(l)??null;if(!qt(a,c)){o.set(l,a);let{left:f,right:d}=t;t.right=new z(_(s,G(i.store,s)),f,f&&f.lastId,d,d&&d.id,e,null,new Z(l,c)),t.right.integrate(n,0),t.forward()}}return o},Gl=(n,e,t,r,i)=>{t.currentAttributes.forEach((u,h)=>{i[h]===void 0&&(i[h]=null)});let s=n.doc,o=s.clientID;ru(t,i);let l=iu(n,e,t,i),c=r.constructor===String?new st(r):r instanceof H?new pt(r):new xn(r),{left:a,right:f,index:d}=t;e._searchMarker&&ui(e._searchMarker,t.index,c.getLength()),f=new z(_(o,G(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,c),f.integrate(n,0),t.right=f,t.index=d,t.forward(),nu(n,e,t,l)},Rd=(n,e,t,r,i)=>{let s=n.doc,o=s.clientID;ru(t,i);let l=iu(n,e,t,i);e:for(;t.right!==null&&(r>0||l.size>0&&(t.right.deleted||t.right.content.constructor===Z));){if(!t.right.deleted)switch(t.right.content.constructor){case Z:{let{key:c,value:a}=t.right.content,f=i[c];if(f!==void 0){if(qt(f,a))l.delete(c);else{if(r===0)break e;l.set(c,a)}t.right.delete(n)}else t.currentAttributes.set(c,a);break}default:r<t.right.length&&ve(n,_(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let c="";for(;r>0;r--)c+=` |
| 4 | `;t.right=new z(_(o,G(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new st(c)),t.right.integrate(n,0),t.forward()}nu(n,e,t,l)},su=(n,e,t,r,i)=>{let s=e,o=Te();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Z){let a=s.content;o.set(a.key,a)}s=s.right}let l=0,c=!1;for(;e!==s;){if(t===e&&(c=!0),!e.deleted){let a=e.content;if(a.constructor===Z){let{key:f,value:d}=a,u=r.get(f)??null;(o.get(f)!==a||u===d)&&(e.delete(n),l++,!c&&(i.get(f)??null)===d&&u!==d&&(u===null?i.delete(f):i.set(f,u))),!c&&!e.deleted&&wr(i,a)}}e=e.right}return l},xx=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Z){let r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},bx=n=>{let e=0;return q(n.doc,t=>{let r=n._start,i=n._start,s=Te(),o=ds(s);for(;i;)i.deleted===!1&&(i.content.constructor===Z?wr(o,i.content):(e+=su(t,r,i,s,o),s=ds(o),r=i)),i=i.right}),e},wx=n=>{let e=new Set,t=n.doc;for(let[r,i]of n.afterState.entries()){let s=n.beforeState.get(r)||0;i!==s&&zd(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===Z&&o.constructor!==Be&&e.add(o.parent)})}q(t,r=>{At(n,n.deleteSet,i=>{if(i instanceof Be||!i.parent._hasFormatting||e.has(i.parent))return;let s=i.parent;i.content.constructor===Z?e.add(s):xx(r,i)});for(let i of e)bx(i)})},vd=(n,e,t)=>{let r=t,i=ds(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case pt:case xn:case st:t<e.right.length&&ve(n,_(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&su(n,s,e.right,i,e.currentAttributes);let o=(e.left||e.right).parent;return o._searchMarker&&ui(o._searchMarker,e.index,-r+t),e},mc=class extends yr{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];q(e,r=>{let i=new Map,s=new Map,o=this.target._start,l=null,c={},a="",f=0,d=0,u=()=>{if(l!==null){let h=null;switch(l){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof a=="object"||a.length>0)&&(h={insert:a},i.size>0&&(h.attributes={},i.forEach((p,m)=>{p!==null&&(h.attributes[m]=p)}))),a="";break;case"retain":f>0&&(h={retain:f},Yf(c)||(h.attributes=qf({},c))),f=0;break}h&&t.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case pt:case xn:this.adds(o)?this.deletes(o)||(u(),l="insert",a=o.content.getContent()[0],u()):this.deletes(o)?(l!=="delete"&&(u(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(u(),l="retain"),f+=1);break;case st:this.adds(o)?this.deletes(o)||(l!=="insert"&&(u(),l="insert"),a+=o.content.str):this.deletes(o)?(l!=="delete"&&(u(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(u(),l="retain"),f+=o.length);break;case Z:{let{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let m=i.get(h)??null;qt(m,p)?p!==null&&o.delete(r):(l==="retain"&&u(),qt(p,s.get(h)??null)?delete c[h]:c[h]=p)}}else if(this.deletes(o)){s.set(h,p);let m=i.get(h)??null;qt(m,p)||(l==="retain"&&u(),c[h]=m)}else if(!o.deleted){s.set(h,p);let m=c[h];m!==void 0&&(qt(m,p)?m!==null&&o.delete(r):(l==="retain"&&u(),p===null?delete c[h]:c[h]=p))}o.deleted||(l==="insert"&&u(),wr(i,o.content));break}}o=o.right}for(u();t.length>0;){let h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Ot=class n extends H{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??me(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new n}clone(){let e=new n;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new mc(this,e,t);lo(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??me();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===st&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?q(this.doc,r=>{let i=new pi(null,this._start,0,new Map);for(let s=0;s<e.length;s++){let o=e[s];if(o.insert!==void 0){let l=!t&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===` |
| 5 | `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Gl(r,this,i,l,o.attributes||{})}else o.retain!==void 0?Rd(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&vd(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??me();let i=[],s=new Map,o=this.doc,l="",c=this._start;function a(){if(l.length>0){let d={},u=!1;s.forEach((p,m)=>{u=!0,d[m]=p});let h={insert:l};u&&(h.attributes=d),i.push(h),l=""}}let f=()=>{for(;c!==null;){if(gn(c,e)||t!==void 0&&gn(c,t))switch(c.content.constructor){case st:{let d=s.get("ychange");e!==void 0&&!gn(c,e)?(d===void 0||d.user!==c.id.client||d.type!=="removed")&&(a(),s.set("ychange",r?r("removed",c.id):{type:"removed"})):t!==void 0&&!gn(c,t)?(d===void 0||d.user!==c.id.client||d.type!=="added")&&(a(),s.set("ychange",r?r("added",c.id):{type:"added"})):d!==void 0&&(a(),s.delete("ychange")),l+=c.content.str;break}case pt:case xn:{a();let d={insert:c.content.getContent()[0]};if(s.size>0){let u={};d.attributes=u,s.forEach((h,p)=>{u[p]=h})}i.push(d);break}case Z:gn(c,e)&&(a(),wr(s,c.content));break}c=c.right}a()};return e||t?q(o,d=>{e&&sc(d,e),t&&sc(d,t),f()},"cleanup"):f(),i}insert(e,t,r){if(t.length<=0)return;let i=this.doc;i!==null?q(i,s=>{let o=Ys(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,c)=>{r[c]=l})),Gl(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let i=this.doc;i!==null?q(i,s=>{let o=Ys(s,this,e,!r);Gl(s,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;r!==null?q(r,i=>{vd(i,Ys(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let i=this.doc;i!==null?q(i,s=>{let o=Ys(s,this,e,!1);o.right!==null&&Rd(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?q(this.doc,t=>{Zs(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?q(this.doc,r=>{Ac(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Oc(this,e)}getAttributes(){return eu(this)}_write(e){e.writeTypeRef(Fx)}},kx=n=>new Ot,ai=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??me()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===J||t.constructor===W)&&t._start!==null)e=t._start;else for(;e!==null;){let r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},W=class n extends H{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof H?t.clone():t)),e}get length(){return this.doc??me(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ai(this,e)}querySelector(e){e=e.toUpperCase();let r=new ai(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),St(new ai(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){lo(this,e,new gc(this,t,e))}toString(){return Kd(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),hi(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?q(this.doc,r=>{Zd(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)q(this.doc,r=>{let i=e&&e instanceof H?e._item:e;Gs(r,this,i,t)});else{let r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw Le("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?q(this.doc,r=>{Qd(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Hd(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Xd(this,e)}slice(e=0,t=this.length){return Wd(this,e,t)}forEach(e){hi(this,e)}_write(e){e.writeTypeRef(zx)}},Sx=n=>new W,J=class n extends W{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new n(this.nodeName)}clone(){let e=new n(this.nodeName),t=this.getAttributes();return Jf(t,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof H?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let l in e)r.push(l);r.sort();let i=r.length;for(let l=0;l<i;l++){let c=r[l];t.push(c+'="'+e[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?q(this.doc,t=>{Zs(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?q(this.doc,r=>{Ac(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Oc(this,e)}hasAttribute(e){return tu(this,e)}getAttributes(e){return e?mx(this,e):eu(this)}toDOM(e=document,t={},r){let i=e.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let l=s[o];typeof l=="string"&&i.setAttribute(o,l)}return hi(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(Px),e.writeKey(this.nodeName)}},Cx=n=>new J(n.readKey()),gc=class extends yr{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}},yc=class n extends ge{constructor(e){super(),this.hookName=e}_copy(){return new n(this.hookName)}clone(){let e=new n(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let i=t[this.hookName],s;return i!==void 0?s=i.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef($x),e.writeKey(this.hookName)}},Tx=n=>new yc(n.readKey()),K=class n extends Ot{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new n}clone(){let e=new n;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{let t=[];for(let i in e.attributes){let s=[];for(let o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,l)=>o.key<l.key?-1:1),t.push({nodeName:i,attrs:s})}t.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){let s=t[i];r+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let l=s.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let i=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(qx)}},Ex=n=>new K,mi=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ee()}mergeWith(e){return!1}write(e,t,r){throw Ee()}integrate(e,t){throw Ee()}},Ax=0,Be=class extends mi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Pd(e.doc.store,this)}write(e,t){e.writeInfo(Ax),e.writeLen(this.length-t)}getMissing(e,t){return null}},gi=class n{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new n(this.content)}splice(e){throw Ee()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Ox=n=>new gi(n.readBuf()),Qs=class n{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.len)}splice(e){let t=new n(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){di(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},Mx=n=>new Qs(n.readLen()),ou=(n,e)=>new it({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),yi=class n{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new n(ou(this.doc.guid,this.opts))}splice(e){throw Ee()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Nx=n=>new yi(ou(n.readString(),n.readAny())),xn=class n{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new n(this.embed)}splice(e){throw Ee()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Dx=n=>new xn(n.readJSON()),Z=class n{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.key,this.value)}splice(e){throw Ee()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Ix=n=>new Z(n.readKey(),n.readJSON()),xc=class n{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(e){let t=new n(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){let s=this.arr[i];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}},_x=n=>{let e=n.readLen(),t=[];for(let r=0;r<e;r++){let i=n.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new xc(t)},Rx=Qr("node_env")==="development",xr=class n{constructor(e){this.arr=e,Rx&&Dl(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(e){let t=new n(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){let s=this.arr[i];e.writeAny(s)}}getRef(){return 8}},vx=n=>{let e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new xr(t)},st=class n{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new n(this.str)}splice(e){let t=new n(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",t.str="\uFFFD"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Bx=n=>new st(n.readString()),Ux=[gx,yx,kx,Cx,Sx,Tx,Ex],Vx=0,Lx=1,Fx=2,Px=3,zx=4,$x=5,qx=6,pt=class n{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new n(this.type._copy())}splice(e){throw Ee()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Jx=n=>new pt(Ux[n.readTypeRef()](n)),bc=(n,e)=>{let t=e,r=0,i;do r>0&&(t=_(t.client,t.clock+r)),i=dr(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof z);return{item:i,diff:r}},Mc=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},eo=(n,e,t)=>{let{client:r,clock:i}=e.id,s=new z(_(r,i+t),e,_(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=_(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s},Bd=(n,e)=>Pr(n,t=>bn(t.deletions,e)),lu=(n,e,t,r,i,s)=>{let o=n.doc,l=o.store,c=o.clientID,a=e.redone;if(a!==null)return ve(n,a);let f=e.parent._item,d=null,u;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!t.has(f)||lu(n,f,t,r,i,s)===null))return null;for(;f.redone!==null;)f=ve(n,f.redone)}let h=f===null?e.parent:f.content.type;if(e.parentSub===null){for(d=e.left,u=e;d!==null;){let y=d;for(;y!==null&&y.parent._item!==f;)y=y.redone===null?null:ve(n,y.redone);if(y!==null&&y.parent._item===f){d=y;break}d=d.left}for(;u!==null;){let y=u;for(;y!==null&&y.parent._item!==f;)y=y.redone===null?null:ve(n,y.redone);if(y!==null&&y.parent._item===f){u=y;break}u=u.right}}else if(u=null,e.right&&!i){for(d=e;d!==null&&d.right!==null&&(d.right.redone||bn(r,d.right.id)||Bd(s.undoStack,d.right.id)||Bd(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=ve(n,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;let p=G(l,c),m=_(c,p),g=new z(m,d,d&&d.lastId,u,u&&u.id,h,e.parentSub,e.content.copy());return e.redone=m,Mc(g,!0),g.integrate(n,0),g},z=class n extends mi{constructor(e,t,r,i,s,o,l,c){super(e,c.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=G(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=G(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Jt&&this.id.client!==this.parent.client&&this.parent.clock>=G(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Ad(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ve(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Be||this.right&&this.right.constructor===Be)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===n?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===n&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Jt){let r=dr(t,this.parent);r.constructor===Be?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Ad(e,e.doc.store,_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;let s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),$s(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if($s(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(dr(e.doc.store,i.origin)))s.has(dr(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Pd(e.doc.store,this),this.content.integrate(e,this),Md(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Be(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:_(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&$s(e.origin,this.lastId)&&this.right===e&&$s(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),di(e.deleteSet,this.id.client,this.id.clock,this.length),Md(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw ne();this.content.gc(e),t?ix(e,this,new Be(this.id,this.length)):this.content=new Qs(this.length)}write(e,t){let r=t>0?_(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(s===null?0:32);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){let l=this.parent;if(l._item!==void 0){let c=l._item;if(c===null){let a=br(l);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===Jt?(e.writeParentInfo(!1),e.writeLeftID(l)):ne();s!==null&&e.writeString(s)}this.content.write(e,t)}},cu=(n,e)=>Yx[e&31](n),Yx=[()=>{ne()},Mx,_x,Ox,Bx,Dx,Ix,Jx,vx,Nx,()=>{ne()}],jx=10,Fe=class extends mi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){ne()}write(e,t){e.writeInfo(jx),V(e.restEncoder,this.length-t)}getMissing(e,t){return null}},au=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},fu="__ $YJS$ __";au[fu]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");au[fu]=!0;function ye(n){this.content=n}ye.prototype={constructor:ye,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ye(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ye(t)},addToStart:function(n,e){return new ye([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ye(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ye(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ye.from(n),n.size?new ye(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ye.from(n),n.size?new ye(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ye.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ye.from=function(n){if(n instanceof ye)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ye(e)};var Nc=ye;function wu(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,c=0;for(;o[c]==l[c];c++)t++;return c&&c<o.length&&c<l.length&&Cu(o.charCodeAt(c-1))&&Su(o.charCodeAt(c))&&t--,t}if(i.content.size||s.content.size){let o=wu(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function ku(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),c=o.nodeSize;if(o==l){t-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let a=o.text,f=l.text,d=a.length,u=f.length;for(;d>0&&u>0&&a[d-1]==f[u-1];)d--,u--,t--,r--;return d&&u&&d<a.length&&Cu(a.charCodeAt(d-1))&&Su(a.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let a=ku(o.content,l.content,t-1,r-1);if(a)return a}t-=c,r-=c}}function Su(n){return n>=56320&&n<57344}function Cu(n){return n>=55296&&n<56320}var T=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let c=this.content[o],a=l+c.nodeSize;if(a>e&&r(c,i+l,s||null,o)!==!1&&c.content.size){let f=l+1;c.nodesBetween(Math.max(0,e-f),Math.min(c.content.size,t-f),r,i+f)}l=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,c)=>{let a=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&a||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=a},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new n(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=c}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,s)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return wu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return ku(this,e,t,r)}findIndex(e){if(e==0)return co(0,e);if(e==this.size)return co(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?co(t+1,s):co(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};T.empty=new T([],0);var Dc={index:0,offset:0};function co(n,e){return Dc.index=n,Dc.offset=e,Dc}function uo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!uo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!uo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var F=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&uo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};F.none=[];var jt=class extends Error{},A=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Eu(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Tu(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(T.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new n(e,r,i)}};A.empty=new A(T.empty,0,0);function Tu(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Tu(s.content,e-i-1,t-i-1)))}function Eu(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),c=n.maybeChild(o);if(l==e||c.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Eu(c.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,c);return a&&n.replaceChild(o,c.copy(a))}function Wx(n,e,t){if(t.openStart>n.depth)throw new jt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new jt("Inconsistent open depths");return Au(n,e,t,0)}function Au(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Au(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return kn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Hx(t,n);return kn(s,Mu(n,o,l,e,r))}else return kn(s,ho(n,e,r))}function Ou(n,e){if(!e.type.compatibleContent(n.type))throw new jt("Cannot join "+e.type.name+" onto "+n.type.name)}function Ic(n,e,t){let r=n.node(t);return Ou(r,e.node(t)),r}function wn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function bi(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(wn(n.nodeAfter,r),s++));for(let l=s;l<o;l++)wn(i.child(l),r);e&&e.depth==t&&e.textOffset&&wn(e.nodeBefore,r)}function kn(n,e){if(!n.type.validContent(e))throw new jt("Invalid content for node "+n.type.name);return n.copy(e)}function Mu(n,e,t,r,i){let s=n.depth>i&&Ic(n,e,i+1),o=r.depth>i&&Ic(t,r,i+1),l=[];return bi(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Ou(s,o),wn(kn(s,Mu(n,e,t,r,i+1)),l)):(s&&wn(kn(s,ho(n,e,i+1)),l),bi(e,t,i,l),o&&wn(kn(o,ho(t,r,i+1)),l)),bi(r,null,i,l),new T(l)}function ho(n,e,t){let r=[];if(bi(null,n,t,r),n.depth>t){let i=Ic(n,e,t+1);wn(kn(i,ho(n,e,t+1)),r)}return bi(e,null,t,r),new T(r)}function Hx(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(T.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var po=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Rc(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(s),a=s-c;if(r.push(o,l,i+c),!a||(o=o.child(l),o.isText))break;s=a-1,i+=c+1}return new n(t,r,s)}static resolveCached(e,t){let r=du.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else du.set(e,r=new _c);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Kx,i}},_c=class{constructor(){this.elts=[],this.i=0}},Kx=12,du=new WeakMap,Rc=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Xx=Object.create(null),mt=class n{constructor(e,t,r,i=F.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&uo(this.attrs,t||e.defaultAttrs||Xx)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return A.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),a=i.node(o).content.cut(i.pos-l,s.pos-l);return new A(a,i.depth-o,s.depth-o)}replace(e,t,r){return Wx(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return po.resolveCached(this,e)}resolveNoCache(e){return po.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Nu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;c<s;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=T.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};mt.prototype.text=void 0;var vc=class n extends mt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Nu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Nu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Sn=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Bc(e,t);if(r.next==null)return n.empty;let i=Du(r);r.next&&r.err("Unexpected trailing text");let s=rb(nb(i));return ib(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let c=o.matchFragment(e,r);if(c&&(!t||c.validEnd))return T.from(l.map(a=>a.createAndFill()));for(let a=0;a<o.next.length;a++){let{type:f,next:d}=o.next[a];if(!(f.isText||f.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let u=s(d,l.concat(f));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:c}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(` |
| 6 | `)}};Sn.empty=new Sn(!0);var Bc=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Du(n){let e=[];do e.push(Gx(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Gx(n){let e=[];do e.push(Zx(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Zx(n){let e=tb(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Qx(n,e);else break;return e}function uu(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Qx(n,e){let t=uu(n),r=t;return n.eat(",")&&(n.next!="}"?r=uu(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function eb(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function tb(n){if(n.eat("(")){let e=Du(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=eb(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nb(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,c){let a={term:c,to:l};return e[o].push(a),a}function i(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,a)=>c.concat(s(a,l)),[]);if(o.type=="seq")for(let c=0;;c++){let a=s(o.exprs[c],l);if(c==o.exprs.length-1)return a;i(a,l=t())}else if(o.type=="star"){let c=t();return r(l,c),i(s(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=t();return i(s(o.expr,l),c),i(s(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let a=0;a<o.min;a++){let f=t();i(s(o.expr,c),f),c=f}if(o.max==-1)i(s(o.expr,c),c);else for(let a=o.min;a<o.max;a++){let f=t();r(c,f),i(s(o.expr,c),f),c=f}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Iu(n,e){return e-n}function hu(n,e){let t=[];return r(e),t.sort(Iu);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&t.indexOf(c)==-1&&r(c)}}}function rb(n){let e=Object.create(null);return t(hu(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:c})=>{if(!l)return;let a;for(let f=0;f<i.length;f++)i[f][0]==l&&(a=i[f][1]);hu(n,c).forEach(f=>{a||i.push([l,a=[]]),a.indexOf(f)==-1&&a.push(f)})})});let s=e[r.join(",")]=new Sn(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Iu);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function ib(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:a}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(a)==-1&&r.push(a)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function _u(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ru(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function vu(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function Bu(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Uc(n,r,e[r]);return t}var mo=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Bu(e,r.attrs),this.defaultAttrs=_u(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==Sn.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:Ru(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new mt(this,this.computeAttrs(e),T.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new mt(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(T.empty,!0);return s?new mt(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){vu(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new n(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function sb(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}var Uc=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?sb(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},ki=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Bu(e,i.attrs),this.excluded=null;let s=_u(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Ru(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new n(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){vu(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},go=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Nc.from(e.nodes),t.marks=Nc.from(e.marks||{}),this.nodes=mo.compile(this.spec.nodes,this),this.marks=ki.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Sn.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?pu(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:pu(this,o.split(" "))}this.nodeFromJSON=i=>mt.fromJSON(this,i),this.markFromJSON=i=>F.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof mo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new vc(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function pu(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let c=n.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ob(n){return n.tag!=null}function lb(n){return n.style!=null}var Si=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(ob(i))this.tags.push(i);else if(lb(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new yo(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new yo(this,t,!0);return r.addAll(e,F.none,t.from,t.to),A.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(fb(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let c=o.getAttrs(t);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=gu(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=gu(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Uu={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},cb={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vu={ol:!0,ul:!0},Ci=1,Vc=2,wi=4;function mu(n,e,t){return e!=null?(e?Ci:0)|(e==="full"?Vc:0):n&&n.whitespace=="pre"?Ci|Vc:t&~wi}var kr=class{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=F.none,this.match=s||(o&wi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ci)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Uu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},yo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=mu(null,t.preserveWhitespace,0)|(r?wi:0);i?s=new kr(i.type,i.attrs,F.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new kr(null,null,F.none,!0,null,o):s=new kr(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Vc?"full":this.localPreserveWS||(i.options&Ci)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,` |
| 7 | `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(o.text(l[c]),t,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Vu.hasOwnProperty(o)&&this.parser.normalizeLists&&ab(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:cb.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let a,f=this.needsBlock;if(Uu.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),a=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=c&&c.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),a&&this.sync(s),this.needsBlock=f}else{let a=this.readStyles(e,t);a&&this.addElementByRule(e,c,a,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` |
| 8 | `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(a=>!c.clearMark(a)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,t.attrs||null,r,t.preserveWhitespace);c&&(s=!0,r=c)}else{let c=this.parser.schema.marks[t.mark];r=r.concat(c.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],a=c.findWrapping(e);if(a&&(!i||i.length>a.length+l)&&(i=a,s=c,!a.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=F.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):yu(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=mu(e,s,o.options);o.options&wi&&o.content.length==0&&(l|=wi);let c=F.none;return r=r.filter(a=>(o.type?o.type.allowsMarkType(a.type):yu(a.type,e))?(c=a.addToSet(c),!1):!0),this.nodes.push(new kr(e,t,c,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Ci)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let a=t[l];if(a==""){if(l==t.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let f=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!f||f.name!=a&&!f.isInGroup(a))return!1;c--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function ab(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Vu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function fb(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function gu(n){let e={};for(let t in n)e[t]=n[t];return e}function yu(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:a,next:f}=l.edge(c);if(a==e||s.indexOf(f)<0&&o(f))return!0}};if(o(i.contentMatch))return!0}}var Cn=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ao(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let a=o.marks[c];if(!this.marks[a.type.name]){c++;continue}if(!a.eq(s[l][0])||a.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let a=o.marks[c++],f=this.serializeMark(a,o.isInline,t);f&&(s.push([a,i]),i.appendChild(f.dom),i=f.contentDOM||f.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){if(e.isText)return ao(t).createTextNode(e.text);let{dom:r,contentDOM:i}=fo(ao(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&fo(ao(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:fo(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xu(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return xu(e.marks)}};function xu(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ao(n){return n.document||window.document}var bu=new WeakMap;function db(n){let e=bu.get(n);return e===void 0&&bu.set(n,e=ub(n)),e}function ub(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function fo(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=db(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,c=t?n.createElementNS(t,i):n.createElement(i),a=e[1],f=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){f=2;for(let d in a)if(a[d]!=null){let u=d.indexOf(" ");u>0?c.setAttributeNS(d.slice(0,u),d.slice(u+1),a[d]):d=="style"&&c.style?c.style.cssText=a[d]:c.setAttribute(d,a[d])}}for(let d=f;d<e.length;d++){let u=e[d];if(u===0){if(d<e.length-1||d>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof u=="string")c.appendChild(n.createTextNode(u));else{let{dom:h,contentDOM:p}=fo(n,u,t,r);if(c.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:c,contentDOM:l}}var zu=65535,$u=Math.pow(2,16);function pb(n,e){return n+e*$u}function Lu(n){return n&zu}function mb(n){return(n-(n&zu))/$u}var qu=1,Ju=2,xo=4,Yu=8,Ai=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Yu)>0}get deletedBefore(){return(this.delInfo&(qu|xo))>0}get deletedAfter(){return(this.delInfo&(Ju|xo))>0}get deletedAcross(){return(this.delInfo&xo)>0}},Mt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Lu(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+mb(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let a=this.ranges[l+s],f=this.ranges[l+o],d=c+a;if(e<=d){let u=a?e==c?-1:e==d?1:t:t,h=c+i+(u<0?0:f);if(r)return h;let p=e==(t<0?c:d)?null:pb(l/3,e-c),m=e==c?Ju:e==d?qu:xo;return(t<0?e!=c:e!=d)&&(m|=Yu),new Ai(h,m,p)}i+=f-a}return r?e+i:new Ai(e+i,0,null)}touches(e,t){let r=0,i=Lu(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let a=this.ranges[l+s],f=c+a;if(e<=f&&l==i*3)return!0;r+=this.ranges[l+o]-a}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),a=this.ranges[i+t],f=this.ranges[i+r];e(l,l+a,c,c+f),s+=f-a}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};Mt.empty=new Mt([]);var Pc=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Ai(e,i,null)}},Lc=Object.create(null),oe=class{getMap(){return Mt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Lc[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Lc)throw new RangeError("Duplicate use of step JSON ID "+e);return Lc[e]=t,t.prototype.jsonID=e,t}},ue=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(s){if(s instanceof jt)return n.fail(s.message);throw s}}};function qc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(qc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return T.fromArray(r)}var Oi=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new A(qc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,s)}invert(){return new Tn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Oi);var Tn=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new A(qc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,r)}invert(){return new Oi(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",Tn);var Mi=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new A(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Sr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("addNodeMark",Mi);var Sr=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new A(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Mi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("removeNodeMark",Sr);var Ue=class n extends oe{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&zc(e,this.from,this.to)?ue.fail("Structure replace would overwrite content"):ue.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Mt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}};Ue.MAP_BIAS=1;oe.jsonID("replace",Ue);var ze=class n extends oe{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(zc(e,this.from,this.gapFrom)||zc(e,this.gapTo,this.to)))return ue.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ue.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ue.fromReplace(e,this.from,this.to,r):ue.fail("Content does not fit in gap")}getMap(){return new Mt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new n(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",ze);function zc(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function gb(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(c,a,f)=>{if(!c.isInline)return;let d=c.marks;if(!r.isInSet(d)&&f.type.allowsMarkType(r.type)){let u=Math.max(a,e),h=Math.min(a+c.nodeSize,t),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==u&&o.mark.eq(d[m])?o.to=h:i.push(o=new Tn(u,h,d[m])));l&&l.to==u?l.to=h:s.push(l=new Oi(u,h,r))}}),i.forEach(c=>n.step(c)),s.forEach(c=>n.step(c))}function yb(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(r instanceof ki){let a=o.marks,f;for(;f=r.isInSet(a);)(c||(c=[])).push(f),a=f.removeFromSet(a)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let a=Math.min(l+o.nodeSize,t);for(let f=0;f<c.length;f++){let d=c[f],u;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(u=p)}u?(u.to=a,u.step=s):i.push({style:d,from:Math.max(l,e),to:a,step:s})}}}),i.forEach(o=>n.step(new Tn(o.from,o.to,o.style)))}function Jc(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let a=s.child(c),f=l+a.nodeSize,d=r.matchType(a.type);if(!d)o.push(new Ue(l,f,A.empty));else{r=d;for(let u=0;u<a.marks.length;u++)t.allowsMarkType(a.marks[u].type)||n.step(new Tn(l,f,a.marks[u]));if(i&&a.isText&&t.whitespace!="pre"){let u,h=/\r?\n|\r/g,p;for(;u=h.exec(a.text);)p||(p=new A(T.from(t.schema.text(" ",t.allowedMarks(a.marks))),0,0)),o.push(new Ue(l+u.index,l+u.index+u[0].length,p))}}l=f}if(!r.validEnd){let c=r.fillBefore(T.empty,!0);n.replace(l,l,new A(c,0,0))}for(let c=o.length-1;c>=0;c--)n.step(o[c])}function xb(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function So(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,c=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,c,t))return r;if(r==0||o.type.spec.isolating||!xb(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function bb(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,a=l,f=T.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,f=T.from(r.node(p).copy(f)),d++):c--;let u=T.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,u=T.from(i.node(p).copy(u)),h++):a++;n.step(new ze(c,a,o,l,new A(f.append(u),d,h),f.size-d,!0))}function wb(n,e,t){let r=T.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=T.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new ze(i,s,i,s,new A(r,0,0),t.length,!0))}function kb(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&Sb(n.doc,n.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?a=!1:!h&&p&&(a=!0)}a===!1&&Wu(n,o,l,s),Jc(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let f=n.mapping.slice(s),d=f.map(l,1),u=f.map(l+o.nodeSize,1);return n.step(new ze(d,u,d+1,u-1,new A(T.from(r.create(c,null,o.marks)),0,0),1,!0)),a===!0&&ju(n,o,l,s),!1}})}function ju(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Wu(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(` |
| 9 | `))}})}function Sb(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Cb(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ze(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new A(T.from(o),0,0),1,!0))}function Ni(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let a=i.depth-1,f=t-2;a>s;a--,f--){let d=i.node(a),u=i.index(a);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(u,d.childCount),p=r&&r[f+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[f]||d;if(!d.canReplace(u+1,d.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function Tb(n,e,t=1,r){let i=n.doc.resolve(e),s=T.empty,o=T.empty;for(let l=i.depth,c=i.depth-t,a=t-1;l>c;l--,a--){s=T.from(i.node(l).copy(s));let f=r&&r[a];o=T.from(f?f.type.create(f.attrs,o):i.node(l).copy(o))}n.step(new Ue(e,e,new A(s.append(o),t,t),!0))}function Yc(n,e){let t=n.resolve(e),r=t.index();return Ab(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Eb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ab(n,e){return!!(n&&e&&!n.isLeaf&&Eb(n,e))}function Ob(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);f&&!d?r=!1:!f&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let f=n.doc.resolve(e+t);Wu(n,f.node(),f.before(),l)}o.inlineContent&&Jc(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let c=n.mapping.slice(l),a=c.map(e-t);if(n.step(new Ue(a,c.map(e+t,-1),A.empty,!0)),r===!0){let f=n.doc.resolve(a);ju(n,f.node(),f.before(),n.steps.length)}return n}function Mb(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Hu(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),a=r.node(o),f=!1;if(s==1)f=a.canReplace(c,c,i);else{let d=a.contentMatchAt(c).findWrapping(i.firstChild.type);f=d&&a.canReplaceWith(c,c,d[0])}if(f)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Co(n,e,t=e,r=A.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Ku(i,s,r)?new Ue(e,t,r):new $c(i,s,r).fit()}function Ku(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var $c=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=T.from(e.node(i).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(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new A(s,o,l);return e>-1?new ze(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new Ue(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Fu(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:a}=this.frontier[l],f,d=null;if(t==1&&(o?a.matchType(o.type)||(d=a.fillBefore(T.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(f=a.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:f};if(s&&a.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return Pu(e,-1)<=t?!1:(this.unplaced.size>1&&Pu(e,1)>r&&r++,this.unplaced=new A(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Fu(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new A(Ti(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new A(Ti(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,a=0,f=[],{match:d,type:u}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;a<l.childCount;){let m=l.child(a),g=d.matchType(m.type);if(!g)break;a++,(a>1||c==0||m.content.size)&&(d=g,f.push(Xu(m.mark(u.allowedMarks(m.marks)),a==1?c:0,a==l.childCount?h:-1)))}let p=a==l.childCount;p||(h=-1),this.placed=Ei(this.placed,t,T.from(f)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?A.empty:new A(Ti(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new A(Ti(o.content,e,a),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Fc(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Fc(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:c,type:a}=this.frontier[l],f=Fc(e,l,a,c,!0);if(!f||f.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ei(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ei(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=Ei(this.placed,this.frontier.length,t))}};function Ti(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ti(n.firstChild.content,e-1,t)))}function Ei(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ei(n.lastChild.content,e-1,t)))}function Fu(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Xu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Xu(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function Fc(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Nb(t,s.content,o)?l:null}function Nb(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Db(n){return n.spec.defining||n.spec.definingForContent}function Pu(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Ib(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Ku(i,s,r))return n.step(new Ue(e,t,r));let o=Zu(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let u=i.depth,h=i.pos-1;u>0;u--,h--){let p=i.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(u)>-1?l=u:i.before(u)==h&&o.splice(1,0,-u)}let c=o.indexOf(l),a=[],f=r.openStart;for(let u=r.content,h=0;;h++){let p=u.firstChild;if(a.push(p),h==r.openStart)break;u=p.content}for(let u=f-1;u>=0;u--){let h=a[u],p=Db(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))f=u;else if(p||!h.type.isTextblock)break}for(let u=r.openStart;u>=0;u--){let h=(u+f+1)%(r.openStart+1),p=a[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+c)%o.length],y=!0;g<0&&(y=!1,g=-g);let k=i.node(g-1),x=i.index(g-1);if(k.canReplaceWith(x,x,p.type,p.marks))return n.replace(i.before(g),y?s.after(g):t,new A(Gu(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let u=o.length-1;u>=0&&(n.replace(e,t,r),!(n.steps.length>d));u--){let h=o[u];h<0||(e=i.before(h),t=s.after(h))}}function Gu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Gu(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(T.empty,!0))}return n}function _b(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Mb(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new A(T.from(r),0,0))}function Rb(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let c=r.depth;c>o;c--)r.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>o;c--)i.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=r.depth;c>0&&e==r.start(c);c--)e=r.before(c);for(let c=i.depth;c>0&&t==i.start(c);c--)t=i.before(c);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=Zu(r,i);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Zu(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}var bo=class n extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ue.fromReplace(e,this.pos,this.pos+1,new A(T.from(i),0,t.isLeaf?0:1))}getMap(){return Mt.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};oe.jsonID("attr",bo);var wo=class n extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ue.ok(r)}getMap(){return Mt.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};oe.jsonID("docAttr",wo);var Cr=class extends Error{};Cr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Cr.prototype=Object.create(Error.prototype);Cr.prototype.constructor=Cr;Cr.prototype.name="TransformError";var ko=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Pc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Cr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,c)=>{e=Math.min(e,l),t=Math.max(t,c)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=A.empty){let i=Co(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new A(T.from(r),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ib(this,e,t,r),this}replaceRangeWith(e,t,r){return _b(this,e,t,r),this}deleteRange(e,t){return Rb(this,e,t),this}lift(e,t){return bb(this,e,t),this}join(e,t=1){return Ob(this,e,t),this}wrap(e,t){return wb(this,e,t),this}setBlockType(e,t=e,r,i=null){return kb(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Cb(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new bo(e,t,r)),this}setDocAttribute(e,t){return this.step(new wo(e,t)),this}addNodeMark(e,t){return this.step(new Mi(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new Sr(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Sr(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Tb(this,e,t,r),this}addMark(e,t,r){return gb(this,e,t,r),this}removeMark(e,t,r){return yb(this,e,t,r),this}clearIncompatible(e,t,r){return Jc(this,e,t,r),this}};var jc=Object.create(null),L=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Er(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=A.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:a}=o[l],f=e.mapping.slice(s);e.replaceRange(f.map(c.pos),f.map(a.pos),l?A.empty:t),l==0&&th(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],c=e.mapping.slice(r),a=c.map(o.pos),f=c.map(l.pos);s?e.deleteRange(a,f):(e.replaceRangeWith(a,f,t),th(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new P(e):Tr(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Tr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Tr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ae(e.node(0))}static atStart(e){return Tr(e,e,0,0,1)||new Ae(e)}static atEnd(e){return Tr(e,e,e.content.size,e.childCount,-1)||new Ae(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=jc[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in jc)throw new RangeError("Duplicate use of selection JSON ID "+e);return jc[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};L.prototype.visible=!0;var Er=class{constructor(e,t){this.$from=e,this.$to=t}},Qu=!1;function eh(n){!Qu&&!n.parent.inlineContent&&(Qu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var P=class n extends L{constructor(e,t=e){eh(e),eh(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return L.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=A.empty){if(super.replace(e,t),t==A.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 Eo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=L.findFrom(t,r,!0)||L.findFrom(t,-r,!0);if(s)t=s.$head;else return L.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(L.findFrom(e,-r,!0)||L.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};L.jsonID("text",P);var Eo=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}},D=class n extends L{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?L.near(s):new n(s)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Hc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};D.prototype.visible=!1;L.jsonID("node",D);var Hc=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Eo(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&D.isSelectable(r)?new D(t):L.near(t)}},Ae=class n extends L{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let r=L.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return vb}};L.jsonID("all",Ae);var vb={map(){return this},resolve(n){return new Ae(n)}};function Tr(n,e,t,r,i,s=!1){if(e.inlineContent)return P.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&D.isSelectable(l))return D.create(n,t-(i<0?l.nodeSize:0))}else{let c=Tr(n,l,t+i,i<0?l.childCount:0,i,s);if(c)return c}t+=l.nodeSize*i}return null}function th(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Ue||i instanceof ze))return;let s=n.mapping.maps[r],o;s.forEach((l,c,a,f)=>{o==null&&(o=f)}),n.setSelection(L.near(n.doc.resolve(o),t))}var nh=1,To=2,rh=4,Kc=class extends ko{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|nh)&~To,this.storedMarks=null,this}get selectionSet(){return(this.updated&nh)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=To,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&To)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~To,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(L.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=rh,this}get scrolledIntoView(){return(this.updated&rh)>0}};function ih(n,e){return!e||!n?n:n.bind(e)}var En=class{constructor(e,t,r){this.name=e,this.init=ih(t.init,r),this.apply=ih(t.apply,r)}},Bb=[new En("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new En("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new En("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new En("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Di=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bb.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new En(r.key,r.spec.state,r))})}},Ao=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,a=i?i[o].state:this,f=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,a,r);if(f&&r.filterTransaction(f,o)){if(f.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:t.length}:{state:this,n:0})}t.push(f),r=r.applyInner(f),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Kc(this)}static create(e){let t=new Di(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Di(this.schema,e.plugins),r=t.fields,i=new n(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Di(e.schema,e.plugins),s=new n(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=mt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=L.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],a=c.spec.state;if(c.key==o.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=a.fromJSON.call(c,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function sh(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=sh(i,e,{})),t[r]=i}return t}var Ar=class{constructor(e){this.spec=e,this.props={},e.props&&sh(e.props,this,this.props),this.key=e.key?e.key.key:oh("plugin")}getState(e){return e[this.key]}},Wc=Object.create(null);function oh(n){return n in Wc?n+"$"+ ++Wc[n]:(Wc[n]=0,n+"$")}var Or=class{constructor(e="key"){this.key=oh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var he=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ir=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ea=null,Dt=function(n,e,t){let r=ea||(ea=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ub=function(){ea=null},Rn=function(n,e,t,r){return t&&(lh(n,e,t,r,-1)||lh(n,e,t,r,1))},Vb=/^(img|br|input|textarea|hr)$/i;function lh(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:He(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Fi(n)||Vb.test(n.nodeName)||n.contentEditable=="false")return!1;e=he(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?He(n):0}else return!1}}function He(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Lb(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=He(n)}else if(n.parentNode&&!Fi(n))e=he(n),n=n.parentNode;else return null}}function Fb(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Fi(n))e=he(n)+1,n=n.parentNode;else return null}}function Pb(n,e,t){for(let r=e==0,i=e==He(n);r||i;){if(n==t)return!0;let s=he(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==He(n)}}function Fi(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}var Lo=function(n){return n.focusNode&&Rn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function An(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function zb(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function $b(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(He(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(He(r.startContainer),r.startOffset)}}}var gt=typeof navigator<"u"?navigator:null,ch=typeof document<"u"?document:null,Zt=gt&>.userAgent||"",ta=/Edge\/(\d+)/.exec(Zt),Vh=/MSIE \d/.exec(Zt),na=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zt),Ve=!!(Vh||na||ta),Kt=Vh?document.documentMode:na?+na[1]:ta?+ta[1]:0,Ke=!Ve&&/gecko\/(\d+)/i.test(Zt);Ke&&+(/Firefox\/(\d+)/.exec(Zt)||[0,0])[1];var ra=!Ve&&/Chrome\/(\d+)/.exec(Zt),pe=!!ra,Lh=ra?+ra[1]:0,be=!Ve&&!!gt&&/Apple Computer/.test(gt.vendor),_r=be&&(/Mobile\/\w+/.test(Zt)||!!gt&>.maxTouchPoints>2),We=_r||(gt?/Mac/.test(gt.platform):!1),Fh=gt?/Win/.test(gt.platform):!1,It=/Android \d/.test(Zt),Pi=!!ch&&"webkitFontSmoothing"in ch.documentElement.style,qb=Pi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Nt(n,e){return typeof n=="number"?n:n[e]}function Yb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ah(n,e,t){if(!ia(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Ir(o);continue}let l=o,c=l==s.body,a=c?Jb(s):Yb(l),f=0,d=0;if(e.top<a.top+Nt(r,"top")?d=-(a.top-e.top+Nt(i,"top")):e.bottom>a.bottom-Nt(r,"bottom")&&(d=e.bottom-e.top>a.bottom-a.top?e.top+Nt(i,"top")-a.top:e.bottom-a.bottom+Nt(i,"bottom")),e.left<a.left+Nt(r,"left")?f=-(a.left-e.left+Nt(i,"left")):e.right>a.right-Nt(r,"right")&&(f=e.right-a.right+Nt(i,"right")),f||d)if(c)s.defaultView.scrollBy(f,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),f&&(l.scrollLeft+=f);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let u=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u=="absolute"?o.offsetParent:Ir(o)}}function jb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:Ph(n.dom)}}function Ph(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ir(r));return e}function Wb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;zh(t,r==0?0:r-e)}function zh(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}var Mr=null;function Hb(n){if(n.setActive)return n.setActive();if(Mr)return n.focus(Mr);let e=Ph(n);n.focus(Mr==null?{get preventScroll(){return Mr={preventScroll:!0},!0}}:void 0),Mr||(Mr=!1,zh(e,0))}function $h(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,c,a;for(let f=n.firstChild,d=0;f;f=f.nextSibling,d++){let u;if(f.nodeType==1)u=f.getClientRects();else if(f.nodeType==3)u=Dt(f).getClientRects();else continue;for(let h=0;h<u.length;h++){let p=u[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=f,r=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,f.nodeType==1&&m&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!c&&p.left<=e.left&&p.right>=e.left&&(c=f,a={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&c&&(t=c,i=a,r=0),t&&t.nodeType==3?Kb(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:$h(t,i)}function Kb(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let o=Wt(r,1);if(o.top!=o.bottom&&wa(e,o)){i={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function wa(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Xb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Gb(n,e,t){let{node:r,offset:i}=$h(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Zb(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function qh(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let a=l[c];if(wa(e,a))return qh(o,e,a)}}if((s=(s+1)%r)==i)break}return n}function Qb(n,e){let t=n.dom.ownerDocument,r,i=0,s=$b(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let a=n.dom.getBoundingClientRect();if(!wa(e,a)||(o=qh(n.dom,e,a),!o))return null}if(be)for(let a=o;r&&a;a=Ir(a))a.draggable&&(r=void 0);if(o=Xb(o,e),r){if(Ke&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let f=r.childNodes[i],d;f.nodeName=="IMG"&&(d=f.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let a;Pi&&i&&r.nodeType==1&&(a=r.childNodes[i-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Zb(n,r,i,e))}l==null&&(l=Gb(n,o,e));let c=n.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function ia(n){return n.top<n.bottom||n.left<n.right}function Wt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(ia(r))return r}return Array.prototype.find.call(t,ia)||n.getBoundingClientRect()}var e0=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Jh(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Pi||Ke;if(r.nodeType==3)if(o&&(e0.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let c=Wt(Dt(r,i,i),t);if(Ke&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let a=Wt(Dt(r,i-1,i-1),-1);if(a.top==c.top){let f=Wt(Dt(r,i,i+1),-1);if(f.top!=c.top)return Ii(f,f.left<a.left)}}return c}else{let c=i,a=i,f=t<0?1:-1;return t<0&&!i?(a++,f=-1):t>=0&&i==r.nodeValue.length?(c--,f=1):t<0?c--:a++,Ii(Wt(Dt(r,c,a),f),f<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==He(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Xc(c.getBoundingClientRect(),!1)}if(s==null&&i<He(r)){let c=r.childNodes[i];if(c.nodeType==1)return Xc(c.getBoundingClientRect(),!0)}return Xc(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==He(r))){let c=r.childNodes[i-1],a=c.nodeType==3?Dt(c,He(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(a)return Ii(Wt(a,1),!1)}if(s==null&&i<He(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let a=c?c.nodeType==3?Dt(c,0,o?0:1):c.nodeType==1?c:null:null;if(a)return Ii(Wt(a,-1),!0)}return Ii(Wt(r.nodeType==3?Dt(r):r,-t),t>=0)}function Ii(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Xc(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Yh(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function t0(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Yh(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Jh(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Dt(l,0,l.nodeValue.length).getClientRects();else continue;for(let a=0;a<c.length;a++){let f=c[a];if(f.bottom>f.top+1&&(t=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}var n0=/[\u0590-\u08ac]/;function r0(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!n0.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Yh(n,e,()=>{let{focusNode:c,focusOffset:a,anchorNode:f,anchorOffset:d}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||c==p&&a==m;try{l.collapse(f,d),c&&(c!=f||a!=d)&&l.extend&&l.extend(c,a)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):r.pos==r.start()||r.pos==r.end()}var fh=null,dh=null,uh=!1;function i0(n,e,t){return fh==e&&dh==t?uh:(fh=e,dh=t,uh=t=="up"||t=="down"?t0(n,e,t):r0(n,e,t))}var Xe=0,hh=1,On=2,lt=3,vn=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>he(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof No){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Oo&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?he(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?he(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let c=this.children[l],a=o+c.size;if(i==-1&&e<=a){let f=o+c.border;if(e>=f&&t<=a-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,f);e=o;for(let d=l;d>0;d--){let u=this.children[d-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){i=he(u.dom)+1;break}e-=u.size}i==-1&&(i=0)}if(i>-1&&(a>t||l==this.children.length-1)){t=a;for(let f=l+1;f<this.children.length;f++){let d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=he(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=g}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),a=r.root.getSelection(),f=r.domSelectionRange(),d=!1;if((Ke||be)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==` |
| 10 | `),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=c={node:g.parentNode,offset:he(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ke&&f.focusNode&&f.focusNode!=c.node&&f.focusNode.nodeType==1){let h=f.focusNode.childNodes[f.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&be)&&Rn(l.node,l.offset,f.anchorNode,f.anchorOffset)&&Rn(c.node,c.offset,f.focusNode,f.focusOffset))return;let u=!1;if((a.extend||e==t)&&!(d&&Ke)){a.collapse(l.node,l.offset);try{e!=t&&a.extend(c.node,c.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=c,c=p}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.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,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,c=o-s.border;if(e>=l&&t<=c){this.dirty=e==r||t==o?On:hh,e==l&&t==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=lt:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?On:lt}r=o}this.dirty=On}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?On:hh;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Oo=class extends vn{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.hasAttribute("contenteditable")||(o.contentEditable="false"),o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},sa=class extends vn{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Nn=class n extends vn{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Cn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty<||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=lt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=aa(s,t,o,r)),e>0&&(s=aa(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Xt=class n extends vn{constructor(e,t,r,i,s,o,l){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],c,a=l&&l(t,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),f=a&&a.dom,d=a&&a.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:d}=Cn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let u=f;return f=Hh(f,r,t),a?c=new oa(e,t,r,i,f,d||null,u,a):t.isText?new Mo(e,t,r,i,f,u):new n(e,t,r,i,f,d||null,u)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?t.contentElement=r:t.getContent=()=>T.empty}}return t}matchesNode(e,t,r){return this.dirty==Xe&&e.eq(this.node)&&Do(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new ca(this,o&&o.node,e);c0(this.node,this.innerDeco,(a,f,d)=>{a.spec.marks?c.syncToMarks(a.spec.marks,r,e,f):a.type.side>=0&&!d&&c.syncToMarks(f==this.node.childCount?F.none:this.node.child(f).marks,r,e,f),c.placeWidget(a,e,i)},(a,f,d,u)=>{c.syncToMarks(a.marks,r,e,u);let h;c.findNodeMatch(a,f,d,u)||l&&e.state.selection.from>i&&e.state.selection.to<i+a.nodeSize&&(h=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(a,f,d,h,e)||c.updateNextNode(a,f,d,e,u,i)||c.addNode(a,f,d,e,i),i+=a.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==On)&&(o&&this.protectLocalComposition(e,o),jh(this.contentDOM,this.children,e),_r&&a0(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof P)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=f0(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new sa(this,s,t,i);e.input.compositionNodes.push(o),this.children=aa(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==lt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(Do(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Wh(this.dom,this.nodeDOM,la(this.outerDeco,this.node,t),la(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function ph(n,e,t,r,i){Hh(r,e,n);let s=new Xt(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}var Mo=class n extends Xt{constructor(e,t,r,i,s,o){super(e,t,r,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==lt||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=lt)}get domAtom(){return!1}isText(e){return this.node.text==e}},No=class extends vn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},oa=class extends Xt{constructor(e,t,r,i,s,o,l,c){super(e,t,r,i,s,o,l),this.spec=c}update(e,t,r,i){if(this.dirty==lt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function jh(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=mh(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof Nn){let c=r?r.previousSibling:n.lastChild;jh(o.contentDOM,o.children,t),r=c?c.nextSibling:n.firstChild}}for(;r;)r=mh(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var Ri=function(n){n&&(this.nodeName=n)};Ri.prototype=Object.create(null);var Mn=[new Ri];function la(n,e,t){if(n.length==0)return Mn;let r=t?Mn[0]:new Ri,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new Ri(o.nodeName));for(let l in o){let c=o[l];c!=null&&(t&&i.length==1&&i.push(r=new Ri(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function Wh(n,e,t,r){if(t==Mn&&r==Mn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let c;l&&l.nodeName==o.nodeName&&i!=n&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Mn[0]),i=c}s0(i,l||Mn[0],o)}return i}function s0(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Hh(n,e,t){return Wh(n,n,Mn,la(e,t,n.nodeType!=1))}function Do(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function mh(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var ca=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=o0(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,a=this.top.children.length;i<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let f=this.index;f<a;f++){let d=this.top.children[f];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){c=f;break}}if(c<0&&this.index<this.top.children.length){let f=this.top.children[this.index];f instanceof Nn&&f.dirty!=lt&&f.mark.type==e[o].type&&f.spec.update&&!this.isLocked(f.dom)&&f.spec.update(e[o])&&(f.mark=e[o],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let f=Nn.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let a=this.top.children[l];if(a.matchesNode(e,t,r)&&!this.preMatch.matched.has(a)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==lt&&o.dom==o.contentDOM&&(o.dirty=On),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Xt){let a=this.preMatch.matched.get(c);if(a!=null&&a!=s)return!1;let f=c.dom,d,u=this.isLocked(f)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=lt&&Do(t,c.outerDeco));if(!u&&c.update(e,t,r,i))return this.destroyBetween(this.index,l),c.dom!=f&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(c,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=On,d.updateChildren(i,o+1),d.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Do(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Xt.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=Xt.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Oo(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Nn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Mo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((be||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new No(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function o0(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let a=t.children[r-1];if(a instanceof Nn)t=a,r=a.children.length;else{l=a,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function l0(n,e){return n.type.side-e.type.side}function c0(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let a=0;a<n.childCount;a++){let f=n.child(a);r(f,i,e.forChild(s,f),a),s+=f.nodeSize}return}let o=0,l=[],c=null;for(let a=0;;){let f,d;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(f?(d||(d=[f])).push(g):f=g)}if(f)if(d){d.sort(l0);for(let g=0;g<d.length;g++)t(d[g],a,!!c)}else t(f,a,!!c);let u,h;if(c)h=-1,u=c,c=null;else if(a<n.childCount)h=a,u=n.child(a++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+u.nodeSize;if(u.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(c=u.cut(g-s),u=u.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();r(u,m,e.forChild(s,u),h),s=p}}function a0(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function f0(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<n.childCount;){let a=n.child(i++);if(s+=a.nodeSize,!a.isText)break;c+=a.text}if(s>=t){if(s>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let a=l<r?c.lastIndexOf(e,r-l-1):-1;if(a>=0&&a+e.length+l>=t)return l+a;if(t==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function aa(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let c=n[o],a=l,f=l+=c.size;a>=t||f<=e?s.push(c):(a<e&&s.push(c.slice(0,e-a,r)),i&&(s.push(i),i=void 0),f>t&&s.push(c.slice(t-a,c.size,r)))}return s}function ka(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,a;if(Lo(t)){for(c=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&D.isSelectable(d)&&i.parent&&!(d.isInline&&Pb(t.focusNode,t.focusOffset,i.dom))){let u=i.posBefore;a=new D(o==u?l:r.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,u=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[c,o]=u==n.state.selection.anchor?[u,d]:[d,u],l=r.resolve(o)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let f=r.resolve(c);if(!a){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;a=Sa(n,f,l,d)}return a}function Kh(n){return n.editable?n.hasFocus():Gh(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Rt(n,e=!1){let t=n.state.selection;if(Xh(n,t),!Kh(n))return;let r=n.input.mouseDown;if(!e&&pe&&r){let i=n.domSelectionRange(),s=n.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Rn(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)u0(n);else{let{anchor:i,head:s}=t,o,l;gh&&!(t instanceof P)&&(t.$from.parent.inlineContent||(o=yh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=yh(n,t.to))),n.docView.setSelection(i,s,n,e),gh&&(o&&xh(o),l&&xh(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&d0(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var gh=be||pe&&Lh<63;function yh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(be&&i&&i.contentEditable=="false")return Gc(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Gc(i);if(s)return Gc(s)}}function Gc(n){return n.contentEditable="true",be&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function xh(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function d0(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Kh(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function u0(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,he(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Ve&&Kt<=11&&(t.disabled=!0,t.disabled=!1)}function Xh(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(bh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else bh(n)}function bh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Sa(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,r)}function wh(n){return n.editable&&!n.hasFocus()?!1:Gh(n)}function Gh(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function h0(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Rn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function fa(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&L.findFrom(s,e)}function Ht(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function kh(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ht(n,new P(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=fa(n.state,e);return i&&i instanceof D?Ht(n,i):!1}else if(!(We&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?D.isSelectable(s)?Ht(n,new D(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Pi?Ht(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return Ht(n,new P(e>0?r.$to:r.$from));{let i=fa(n.state,e);return i?Ht(n,i):!1}}}function Io(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function vi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Nr(n,e){return e<0?p0(n):m0(n)}function p0(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ke&&t.nodeType==1&&r<Io(t)&&vi(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(vi(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Zh(t))break;{let l=t.previousSibling;for(;l&&vi(l,-1);)i=t.parentNode,s=he(l),l=l.previousSibling;if(l)t=l,r=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?da(n,t,r):i&&da(n,i,s)}function m0(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Io(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(vi(l,1))s=t,o=++r;else break}else{if(Zh(t))break;{let l=t.nextSibling;for(;l&&vi(l,1);)s=l.parentNode,o=he(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&da(n,s,o)}function Zh(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function g0(n,e){for(;n&&e==n.childNodes.length&&!Fi(n);)e=he(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function y0(n,e){for(;n&&!e&&!Fi(n);)e=he(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function da(n,e,t){if(e.nodeType!=3){let s,o;(o=g0(e,t))?(e=o,t=0):(s=y0(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Lo(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Rt(n)},50)}function Sh(n,e){let t=n.state.doc.resolve(e);if(!(pe||Fh)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ch(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||We&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=fa(n.state,e);if(o&&o instanceof D)return Ht(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Ae?L.near(o,e):L.findFrom(o,e);return l?Ht(n,l):!1}return!1}function Th(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Eh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function x0(n){if(!be||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Eh(n,r,"true"),setTimeout(()=>Eh(n,r,"false"),20)}return!1}function b0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function w0(n,e){let t=e.keyCode,r=b0(e);if(t==8||We&&t==72&&r=="c")return Th(n,-1)||Nr(n,-1);if(t==46&&!e.shiftKey||We&&t==68&&r=="c")return Th(n,1)||Nr(n,1);if(t==13||t==27)return!0;if(t==37||We&&t==66&&r=="c"){let i=t==37?Sh(n,n.state.selection.from)=="ltr"?-1:1:-1;return kh(n,i,r)||Nr(n,i)}else if(t==39||We&&t==70&&r=="c"){let i=t==39?Sh(n,n.state.selection.from)=="ltr"?1:-1:1;return kh(n,i,r)||Nr(n,i)}else{if(t==38||We&&t==80&&r=="c")return Ch(n,-1,r)||Nr(n,-1);if(t==40||We&&t==78&&r=="c")return x0(n)||Ch(n,1,r)||Nr(n,1);if(r==(We?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ca(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Cn.fromSchema(n.state.schema),l=ip(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let a=c.firstChild,f,d=0;for(;a&&a.nodeType==1&&(f=rp[a.nodeName.toLowerCase()]);){for(let h=f.length-1;h>=0;h--){let p=l.createElement(f[h]);for(;c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p),d++}a=c.firstChild}a&&a.nodeType==1&&a.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` |
| 11 | |
| 12 | `);return{dom:c,text:u,slice:e}}function Qh(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let c=!!e&&(r||s||!t);if(c){if(n.someProp("transformPastedText",u=>{e=u(e,s||r,n)}),s)return l=new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,` |
| 13 | `))),0,0),n.someProp("transformPasted",u=>{l=u(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",u=>u(e,i,r,n));if(d)l=d;else{let u=i.marks(),{schema:h}=n.state,p=Cn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=T0(t),Pi&&E0(o);let a=o&&o.querySelector("[data-pm-slice]"),f=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let d=+f[3];d>0;d--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Si.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||f),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!k0.test(u.parentNode.nodeName)?{ignore:!0}:null}})),f)l=A0(Ah(l,+f[1],+f[2]),f[4]);else if(l=A.maxOpen(S0(l.content,i),!0),l.openStart||l.openEnd){let d=0,u=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=Ah(l,d,u)}return n.someProp("transformPasted",d=>{l=d(l,n,c)}),l}var k0=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function S0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),a;if(!c)return o=null;if(a=o.length&&s.length&&tp(c,s,l,o[o.length-1],0))o[o.length-1]=a;else{o.length&&(o[o.length-1]=np(o[o.length-1],s.length));let f=ep(l,c);o.push(f),i=i.matchType(f.type),s=c}}),o)return T.from(o)}return n}function ep(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function tp(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=tp(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(T.from(ep(t,n,i+1))))}}function np(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,np(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function ua(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=ua(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ah(n,e,t){return e<n.openStart&&(n=new A(ua(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(ua(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var rp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ip(){return document.implementation.createHTMLDocument("title")}var _i=null;function C0(n){let e=window.trustedTypes;if(!e)return n;if(!_i){if(_i=e.defaultPolicy)try{return _i.createHTML(n)}catch{}_i=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return _i.createHTML(n)}function T0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ip(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&rp[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=C0(n),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let c=0;c<l.rules.length;c++){let a=l.rules[c];if(a instanceof CSSStyleRule){let f=r.querySelectorAll(a.selectorText);for(let d=0;d<f.length;d++)f[d].style.cssText+=a.style.cssText}}}return r}function E0(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function A0(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let c=t.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;try{c.checkAttrs(r[l+1])}catch{break}i=T.from(c.create(r[l+1],i)),s++,o++}return new A(i,s,o)}var Oe={},Me={},O0={touchstart:!0,touchmove:!0},ha=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function M0(n){for(let e in Oe){let t=Oe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{D0(n,r)&&!Ta(n,r)&&(n.editable||!(r.type in Me))&&t(n,r)},O0[e]?{passive:!0}:void 0)}be&&n.dom.addEventListener("input",()=>null),pa(n)}function _t(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function N0(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function pa(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ta(n,r))})}function Ta(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function D0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function I0(n,e){!Ta(n,e)&&Oe[e.type]&&(n.editable||!(e.type in Me))&&Oe[e.type](n,e)}Me.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!lp(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(It&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_r&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,An(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||w0(n,t)?t.preventDefault():_t(n,"key")};Me.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Me.keypress=(n,e)=>{let t=e;if(lp(n)||!t.charCode||t.ctrlKey&&!t.altKey||We&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function zi(n){return{left:n.clientX,top:n.clientY}}function _0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ea(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function $i(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function R0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?($i(n,new D(t),"pointer"),!0):!1}function v0(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(D.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?($i(n,D.create(n.state.doc,i),"pointer"),!0):!1}function B0(n,e,t,r,i){return Ea(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?v0(n,t):R0(n,t))}function U0(n,e,t,r){return Ea(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function V0(n,e,t,r){return Ea(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||L0(n,t,r)}function L0(n,e,t){if(t.button!=0)return!1;let r=sp(n,e,!0),i=n.state.doc;return r?($i(n,r,"pointer"),r instanceof P&&i.eq(n.state.doc)&&(n.input.mouseDown=new ga(n,r)),!0):!1}function sp(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?P.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return P.create(r,l+1,l+1+o.content.size);if(t&&D.isSelectable(o))return D.create(r,l)}return null}function Aa(n){return Ro(n)}var op=We?"metaKey":"ctrlKey";Oe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Aa(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&_0(t,n.input.lastClick)&&!t[op]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(zi(t));o&&(s=="singleClick"?n.input.mouseDown=new ma(n,o,t,!!r):(s=="doubleClick"?U0:V0)(n,o.pos,o.inside,t)?t.preventDefault():_t(n,"pointer"))};var _o=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},ma=class extends _o{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[op],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}let l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:a}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||a instanceof D&&a.from<=o&&a.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ke&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),_t(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Rt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(zi(e))),this.updateAllowDefault(e),this.allowDefault||!t?_t(this.view,"pointer"):B0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||be&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?($i(this.view,L.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):_t(this.view,"pointer")}move(e){this.updateAllowDefault(e),_t(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},ga=class extends _o{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),_t(this.view,"pointer");let t=this.view.posAtCoords(zi(e)),r=t&&sp(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];$i(this.view,P.create(i,o,l),"pointer")}};Oe.touchstart=n=>{n.input.lastTouch=Date.now(),Aa(n),_t(n,"pointer")};Oe.touchmove=n=>{n.input.lastTouch=Date.now(),_t(n,"pointer")};Oe.contextmenu=n=>Aa(n);function lp(n,e){return n.composing?!0:be&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var F0=It?5e3:-1;Me.compositionstart=Me.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&Fh&&P0(n)))n.markCursor=n.state.storedMarks||t.marks(),Ro(n,!0),n.markCursor=null;else if(Ro(n,!e.selection.empty),Ke&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}cp(n,F0)};function P0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Me.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,cp(n,20))};function cp(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ro(n),e))}function ap(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function z0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Lb(e.focusNode,e.focusOffset),r=Fb(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Ro(n,e=!1){if(!(It&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ap(n),e||n.docView&&n.docView.dirty){let t=ka(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function $0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Bi=Ve&&Kt<15||_r&&qb<604;Oe.copy=Me.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Bi?null:t.clipboardData,o=r.content(),{dom:l,text:c}=Ca(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):$0(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function q0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function J0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ui(n,r.value,null,i,e):Ui(n,r.textContent,r.innerHTML,i,e)},50)}function Ui(n,e,t,r,i){let s=Qh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,s||A.empty)))return!0;if(!s)return!1;let o=q0(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function fp(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Me.paste=(n,e)=>{let t=e;if(n.composing&&!It)return;let r=Bi?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ui(n,fp(r),r.getData("text/html"),i,t)?t.preventDefault():J0(n,t)};var vo=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Y0=We?"altKey":"ctrlKey";function dp(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Y0]}Oe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(zi(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof D?i.to-1:i.to))){if(r&&r.mightDrag)o=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=D.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:a,slice:f}=Ca(n,l);(!t.dataTransfer.files.length||!pe||Lh>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Bi?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",Bi||t.dataTransfer.setData("text/plain",a),n.dragging=new vo(f,dp(n,t),o)};Oe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Me.dragover=Me.dragenter=(n,e)=>e.preventDefault();Me.drop=(n,e)=>{try{j0(n,e,n.dragging)}finally{n.dragging=null}};function j0(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(zi(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=Qh(n,fp(e.dataTransfer),Bi?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&dp(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||A.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Hu(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(o){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let a=c.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(a,a,s.content.firstChild):c.replaceRange(a,a,s),c.doc.eq(d))return;let u=c.doc.resolve(a);if(f&&D.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new D(u));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),c.setSelection(Sa(n,u,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}Oe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Rt(n)},20))};Oe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Oe.beforeinput=(n,e)=>{if(It&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,An(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Me)Oe[n]=Me[n];function Vi(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Bo=class n{constructor(e,t){this.toDOM=e,this.spec=t||In,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Gt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Dn=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Gt(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Vi(this.attrs,e.attrs)&&Vi(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},ya=class n{constructor(e,t){this.attrs=e,this.spec=t||In}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Gt(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Vi(this.attrs,e.attrs)&&Vi(this.spec,e.spec)}destroy(){}},Gt=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Bo(t,r))}static inline(e,t,r,i){return new n(e,t,new Dn(r,i))}static node(e,t,r,i){return new n(e,t,new ya(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Dn}get widget(){return this.type instanceof Bo}},Dr=[],In={},Ge=class n{constructor(e,t){this.local=e.length?e:Dr,this.children=t.length?t:Dr}static create(e,t){return t.length?Vo(t,e,0,In):xe}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||In)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(t,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?W0(this.children,o||[],e,t,r,i,s):o?new n(o.sort(_n),Dr):xe}add(e,t){return t.length?this==xe?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,c)=>{let a=c+r,f;if(f=hp(t,l,a)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,f,a+1):i.splice(s,0,c,c+l.nodeSize,Vo(f,l,a+1,In)),s+=3}});let o=up(s?pp(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new n(o.length?this.local.concat(o).sort(_n):this.local,i||this.children)}remove(e){return e.length==0||this==xe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,c=r[s+1]+t;for(let f=0,d;f<e.length;f++)(d=e[f])&&d.from>l&&d.to<c&&(e[f]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let a=r[s+2].removeInner(o,l+1);a!=xe?r[s+2]=a:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):xe}forChild(e,t){if(this==xe)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof Dn){let a=Math.max(s,c.from)-s,f=Math.min(o,c.to)-s;a<f&&(i||(i=[])).push(c.copy(a,f))}}if(i){let l=new n(i.sort(_n),Dr);return r?new Uo([l,r]):l}return r||xe}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Oa(this.localsInner(e))}localsInner(e){if(this==xe)return Dr;if(e.inlineContent||!this.local.some(Dn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Dn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Ge.empty=new Ge([],[]);Ge.removeOverlap=Oa;var xe=Ge.empty,Uo=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,In));return n.from(r)}forChild(e,t){if(t.isLeaf)return Ge.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=xe&&(s instanceof n?r=r.concat(s.members):r.push(s))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Oa(r?t:t.sort(_n)):Dr}static from(e){switch(e.length){case 0:return xe;case 1:return e[0];default:return new n(e.every(t=>t instanceof Ge)?e:e.reduce((t,r)=>t.concat(r instanceof Ge?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function W0(n,e,t,r,i,s,o){let l=n.slice();for(let a=0,f=s;a<t.maps.length;a++){let d=0;t.maps[a].forEach((u,h,p,m)=>{let g=m-p-(h-u);for(let y=0;y<l.length;y+=3){let k=l[y+1];if(k<0||u>k+f-d)continue;let x=l[y]+f-d;h>=x?l[y+1]=u<=x?-2:-1:u>=f&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),f=t.maps[a].map(f,-1)}let c=!1;for(let a=0;a<l.length;a+=3)if(l[a+1]<0){if(l[a+1]==-2){c=!0,l[a+1]=-1;continue}let f=t.map(n[a]+s),d=f-i;if(d<0||d>=r.content.size){c=!0;continue}let u=t.map(n[a+1]+s,-1),h=u-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[a+2].mapInner(t,g,f+1,n[a]+s+1,o);y!=xe?(l[a]=d,l[a+1]=h,l[a+2]=y):(l[a+1]=-2,c=!0)}else c=!0}if(c){let a=H0(l,n,e,t,i,s,o),f=Vo(a,r,0,o);e=f.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,u=0;d<f.children.length;d+=3){let h=f.children[d];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,f.children[d],f.children[d+1],f.children[d+2])}}return new Ge(e.sort(_n),l)}function up(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Gt(i.from+e,i.to+e,i.type))}return t}function H0(n,e,t,r,i,s,o){function l(c,a){for(let f=0;f<c.local.length;f++){let d=c.local[f].map(r,i,a);d?t.push(d):o.onRemove&&o.onRemove(c.local[f].spec)}for(let f=0;f<c.children.length;f+=3)l(c.children[f+2],c.children[f]+a+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+s+1);return t}function hp(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function pp(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Vo(n,e,t,r){let i=[],s=!1;e.forEach((l,c)=>{let a=hp(n,l,c+t);if(a){s=!0;let f=Vo(a,l,t+c+1,r);f!=xe&&i.push(c,c+l.nodeSize,f)}});let o=up(s?pp(n):n,-t).sort(_n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Ge(o,i):xe}function _n(n,e){return n.from-e.from||n.to-e.to}function Oa(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Oh(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Oh(e,i,r.copy(s.from,r.to)));break}}}return e}function Oh(n,e,t){for(;e<n.length&&_n(t,n[e])>0;)e++;n.splice(e,0,t)}function Zc(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(Ge.create(n.state.doc,[n.cursorWrapper.deco])),Uo.from(e)}var K0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},X0=Ve&&Kt<=11,xa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ba=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xa,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Ve&&Kt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():be&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),X0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,K0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(wh(this.view)){if(this.suppressingSelectionUpdates)return Rt(this.view);if(Ve&&Kt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Ir(s))t.add(s);for(let s=e.anchorNode;s;s=Ir(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&wh(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let f=0;f<t.length;f++){let d=this.registerMutation(t[f],c);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(c.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||pe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of c)if(f.nodeName=="BR"&&f.parentNode){let d=f.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){f.parentNode.removeChild(f);break}d=d.firstChild}}}else if(Ke&&c.length){let f=c.filter(d=>d.nodeName=="BR");if(f.length==2){let[d,u]=f;d.parentNode&&d.parentNode.parentNode==u.parentNode?u.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let u of f){let h=u.parentNode;h&&h.nodeName=="LI"&&(!d||Q0(e,d)!=h)&&u.remove()}}}let a=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Lo(r)&&(a=ka(e))&&a.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Rt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),G0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ew(e,c)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Rt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let d=e.addedNodes[f];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ve&&Kt<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:d,nextSibling:u}=e.addedNodes[f];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=i&&i.parentNode==e.target?he(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?he(s):e.target.childNodes.length,a=r.localPosFromDOM(e.target,c,1);return{from:l,to:a}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Mh=new WeakMap,Nh=!1;function G0(n){if(!Mh.has(n)&&(Mh.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ke,Nh)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Nh=!0}}function Dh(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Rn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Z0(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Dh(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Dh(n,t):null}function Q0(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function ew(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function tw(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:c}=n.docView.parseRange(e,t),a=n.domSelectionRange(),f,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(f=[{node:d,offset:a.anchorOffset}],Lo(a)||f.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let k=i.childNodes[y-1],x=k.pmViewDesc;if(k.nodeName=="BR"&&!x){o=y;break}if(!x||x.size)break}let u=n.state.doc,h=n.someProp("domParser")||Si.fromSchema(n.state.schema),p=u.resolve(l),m=null,g=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:nw(r),context:p});if(f&&f[0].pos!=null){let y=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:c}}var nw=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(be&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||be&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},rw=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function iw(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let S=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,C=ka(n,S);if(C&&!n.state.selection.eq(C)){if(pe&&It&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",B=>B(n,An(13,"Enter"))))return;let M=n.state.tr.setSelection(C);S=="pointer"?M.setMeta("pointer",!0):S=="key"&&M.scrollIntoView(),s&&M.setMeta("composition",s),n.dispatch(M)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,a=tw(n,e,t,i),f=n.state.doc,d=f.slice(a.from,a.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=lw(d.content,a.doc.content,a.from,u,h);if(p&&n.input.domChangeCount++,(_r&&n.input.lastIOSEnter>Date.now()-225||It)&&i.some(S=>S.nodeType==1&&!rw.test(S.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",S=>S(n,An(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&c instanceof P&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))p={start:c.from,endA:c.to,endB:c.to};else{if(a.sel){let S=Ih(n,n.state.doc,a.sel);if(S&&!S.eq(n.state.selection)){let C=n.state.tr.setSelection(S);s&&C.setMeta("composition",s),n.dispatch(C)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof P&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=a.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=a.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Ve&&Kt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=a.doc.resolveNoCache(p.start-a.from),g=a.doc.resolveNoCache(p.endB-a.from),y=f.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((_r&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!k&&m.pos<a.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(a.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",S=>S(n,An(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ow(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",S=>S(n,An(8,"Backspace")))){It&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),It&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==p.endA&&(p.endB-=2,g=a.doc.resolveNoCache(p.endB-a.from),setTimeout(()=>{n.someProp("handleKeyDown",function(S){return S(n,An(13,"Enter"))})},20));let x=p.start,b=p.endA,E=S=>{let C=S||n.state.tr.replace(x,b,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let M=Ih(n,C.doc,a.sel);M&&!(pe&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(M.head==x||M.head==C.mapping.map(b)-1)||Ve&&M.empty&&M.head==x)&&C.setSelection(M)}return s&&C.setMeta("composition",s),C.scrollIntoView()},R;if(k)if(m.pos==g.pos){Ve&&Kt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Rt(n),20));let S=E(n.state.tr.delete(x,b)),C=f.resolve(p.start).marksAcross(f.resolve(p.endA));C&&S.ensureMarks(C),n.dispatch(S)}else if(p.endA==p.endB&&(R=sw(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let S=E(n.state.tr);R.type=="add"?S.addMark(x,b,R.mark):S.removeMark(x,b,R.mark),n.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,g.parentOffset),C=()=>E(n.state.tr.insertText(S,x,b));n.someProp("handleTextInput",M=>M(n,x,b,S,C))||n.dispatch(C())}else n.dispatch(E());else n.dispatch(E())}function Ih(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Sa(n,e.resolv |