oficina / docs Public
File too large to show in full — download it above (showing a truncated preview below).
| 1 | var tp=Object.defineProperty;var np=(n,e,t)=>e in n?tp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var xi=(n,e,t)=>np(n,typeof e!="symbol"?e+"":e,t);var le=()=>new Map,bi=n=>{let e=le();return n.forEach((t,r)=>{e.set(r,t)}),e},Te=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},Xc=(n,e)=>{let t=[];for(let[r,i]of n)t.push(e(i,r));return t},Zc=(n,e)=>{for(let[t,r]of n)if(e(r,t))return!0;return!1};var Re=()=>new Set;var ki=n=>n[n.length-1];var Qc=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},Ye=Array.from,Si=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},or=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1};var ea=(n,e)=>{let t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t};var Ge=Array.isArray;var cr=class{constructor(){this._observers=le()}on(e,t){return Te(this._observers,e,Re).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 Ye((this._observers.get(e)||le()).values()).forEach(r=>r(...t))}destroy(){this._observers=le()}};var X=Math.floor;var Nt=Math.abs;var Xe=(n,e)=>n<e?n:e,ve=(n,e)=>n>e?n:e,Vb=Number.isNaN;var Ci=n=>n!==0?n<0:1/n<0;var pn=Number.MAX_SAFE_INTEGER,fo=Number.MIN_SAFE_INTEGER,Lb=1<<31;var ta=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&X(n)===n),Fb=Number.isNaN,Pb=Number.parseInt;var ar=String.fromCharCode,rp=String.fromCodePoint,zb=ar(65535),ip=n=>n.toLowerCase(),sp=/^\s*/g,op=n=>n.replace(sp,""),lp=/([A-Z])/g,ho=(n,e)=>op(n.replace(lp,t=>`${e}${ip(t)}`));var cp=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},gn=typeof TextEncoder<"u"?new TextEncoder:null,ap=n=>gn.encode(n),na=gn?ap:cp;var mn=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});mn&&mn.decode(new Uint8Array).length===1&&(mn=null);var ra=(n,e)=>ea(e,()=>n).join("");var _t=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},bn=()=>new _t,ca=n=>{let e=bn();return n(e),Ee(e)},fp=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e};var Ee=n=>{let e=new Uint8Array(fp(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},up=(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(ve(t,e)*2),n.cpos=0)},j=(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 Ei=j;var O=(n,e)=>{for(;e>127;)j(n,128|127&e),e=X(e/128);j(n,127&e)},Ai=(n,e)=>{let t=Ci(e);for(t&&(e=-e),j(n,(e>63?128:0)|(t?64:0)|63&e),e=X(e/64);e>0;)j(n,(e>127?128:0)|127&e),e=X(e/128)},po=new Uint8Array(3e4),hp=po.length/3,dp=(n,e)=>{if(e.length<hp){let t=gn.encodeInto(e,po).written||0;O(n,t);for(let r=0;r<t;r++)j(n,po[r])}else de(n,na(e))},pp=(n,e)=>{let t=unescape(encodeURIComponent(e)),r=t.length;O(n,r);for(let i=0;i<r;i++)j(n,t.codePointAt(i))},Rt=gn&&gn.encodeInto?dp:pp;var hr=(n,e)=>{let t=n.cbuf.length,r=n.cpos,i=Xe(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(ve(t*2,s)),n.cbuf.set(e.subarray(i)),n.cpos=s)},de=(n,e)=>{O(n,e.byteLength),hr(n,e)},mo=(n,e)=>{up(n,e);let t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},mp=(n,e)=>mo(n,4).setFloat32(0,e,!1),gp=(n,e)=>mo(n,8).setFloat64(0,e,!1),yp=(n,e)=>mo(n,8).setBigInt64(0,e,!1);var sa=new DataView(new ArrayBuffer(4)),xp=n=>(sa.setFloat32(0,n),sa.getFloat32(0)===n),ht=(n,e)=>{switch(typeof e){case"string":j(n,119),Rt(n,e);break;case"number":ta(e)&&Nt(e)<=2147483647?(j(n,125),Ai(n,e)):xp(e)?(j(n,124),mp(n,e)):(j(n,123),gp(n,e));break;case"bigint":j(n,122),yp(n,e);break;case"object":if(e===null)j(n,126);else if(Ge(e)){j(n,117),O(n,e.length);for(let t=0;t<e.length;t++)ht(n,e[t])}else if(e instanceof Uint8Array)j(n,116),de(n,e);else{j(n,118);let t=Object.keys(e);O(n,t.length);for(let r=0;r<t.length;r++){let i=t[r];Rt(n,i),ht(n,e[i])}}break;case"boolean":j(n,e?120:121);break;default:j(n,127)}},ur=class extends _t{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&O(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};var oa=n=>{n.count>0&&(Ai(n.encoder,n.count===1?n.s:-n.s),n.count>1&&O(n.encoder,n.count-2))},vt=class{constructor(){this.encoder=new _t,this.s=0,this.count=0}write(e){this.s===e?this.count++:(oa(this),this.count=1,this.s=e)}toUint8Array(){return oa(this),Ee(this.encoder)}};var la=n=>{if(n.count>0){let e=n.diff*2+(n.count===1?0:1);Ai(n.encoder,e),n.count>1&&O(n.encoder,n.count-2)}},xn=class{constructor(){this.encoder=new _t,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(la(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return la(this),Ee(this.encoder)}},Ti=class{constructor(){this.sarr=[],this.s="",this.lensE=new vt}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 _t;return this.sarr.push(this.s),this.s="",Rt(e,this.sarr.join("")),hr(e,this.lensE.toUint8Array()),Ee(e)}};var ke=n=>new Error(n),ce=()=>{throw ke("Method unimplemented")},J=()=>{throw ke("Unexpected case")};var fa=ke("Unexpected end of array"),ua=ke("Integer out of Range"),wn=class{constructor(e){this.arr=e,this.pos=0}},Cn=n=>new wn(n),Oi=n=>n.pos!==n.arr.length;var bp=(n,e)=>{let t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},pe=n=>bp(n,A(n));var Bt=n=>n.arr[n.pos++];var A=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>pn)throw ua}throw fa},Di=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>pn)throw ua}throw fa};var wp=n=>{let e=A(n);if(e===0)return"";{let t=String.fromCodePoint(Bt(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(Bt(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))}},kp=n=>mn.decode(pe(n)),Ut=mn?kp:wp;var go=(n,e)=>{let t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},Sp=n=>go(n,4).getFloat32(0,!1),Cp=n=>go(n,8).getFloat64(0,!1),Tp=n=>go(n,8).getBigInt64(0,!1);var Ep=[n=>{},n=>null,Di,Sp,Cp,Tp,n=>!1,n=>!0,Ut,n=>{let e=A(n),t={};for(let r=0;r<e;r++){let i=Ut(n);t[i]=kn(n)}return t},n=>{let e=A(n),t=[];for(let r=0;r<e;r++)t.push(kn(n));return t},pe],kn=n=>Ep[127-Bt(n)](n),pr=class extends wn{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Oi(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}};var Vt=class extends wn{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Di(this);let e=Ci(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}};var Sn=class extends wn{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Di(this),t=e&1;this.diff=X(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Mi=class{constructor(e){this.decoder=new Vt(e),this.str=Ut(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 Jb=crypto.subtle,da=crypto.getRandomValues.bind(crypto);var Ap=Math.random,yo=()=>da(new Uint32Array(1))[0];var pa=n=>n[X(Ap()*n.length)],Mp="10000000-1000-4000-8000"+-1e11,ma=()=>Mp.replace(/[018]/g,n=>(n^yo()&15>>n/4).toString(16));var Ni=Date.now;var xo=n=>new Promise(n);var Kb=Promise.all.bind(Promise);var bo=n=>n===void 0?null:n;var wo=class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},xa=new wo,Np=!0;try{typeof localStorage<"u"&&localStorage&&(xa=localStorage,Np=!1)}catch{}var ba=xa;var Lt=Symbol("Equality"),Ii=(n,e)=>n===e||!!n?.[Lt]?.(e)||!1;var wa=n=>typeof n=="object",ka=Object.assign,So=Object.keys;var Sa=(n,e)=>{for(let t in n)e(n[t],t)};var mr=n=>So(n).length;var Ca=n=>{for(let e in n)return!1;return!0},pt=(n,e)=>{for(let t in n)if(!e(n[t],t))return!1;return!0},gr=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),Co=(n,e)=>n===e||mr(n)===mr(e)&&pt(n,(t,r)=>(t!==void 0||gr(e,r))&&Ii(e[r],t)),_p=Object.freeze,To=n=>{for(let e in n){let t=n[e];(typeof t=="object"||typeof t=="function")&&To(n[e])}return _p(n)};var xr=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&xr(n,e,t+1)}};var yr=(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[Lt]!=null)return n[Lt](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)||!yr(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(mr(n)!==mr(e))return!1;for(let t in n)if(!gr(n,t)||!yr(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(!yr(n[t],e[t]))return!1;break;default:return!1}return!0},Ta=(n,e)=>e.includes(n);var Tn=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",wr=typeof window<"u"&&typeof document<"u"&&!Tn,Hb=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Le,Rp=[],vp=()=>{if(Le===void 0)if(Tn){Le=le();let n=process.argv,e=null;for(let t=0;t<n.length;t++){let r=n[t];r[0]==="-"?(e!==null&&Le.set(e,""),e=r):e!==null?(Le.set(e,r),e=null):Rp.push(r)}e!==null&&Le.set(e,"")}else typeof location=="object"?(Le=le(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){let[e,t]=n.split("=");Le.set(`--${ho(e,"-")}`,t),Le.set(`-${ho(e,"-")}`,t)}})):Le=le();return Le},Ao=n=>vp().has(n);var br=n=>Tn?bo(process.env[n.toUpperCase().replaceAll("-","_")]):bo(ba.getItem(n));var Ea=n=>Ao("--"+n)||br(n)!==null,Aa=Ea("production"),Bp=Tn&&Ta(process.env.FORCE_COLOR,["true","1","2"]),Ma=Bp||!Ao("--no-colors")&&!Ea("no-color")&&(!Tn||process.stdout.isTTY)&&(!Tn||Ao("--color")||br("COLORTERM")!==null||(br("TERM")||"").includes("color"));var Up=n=>new Uint8Array(n);var Vp=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=ar(n[t]);return btoa(e)},Lp=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64");var Oa=wr?Vp:Lp;var Da=n=>{let e=Up(n.byteLength);return e.set(n),e},Na=n=>ca(e=>ht(e,n));var Mo=class{constructor(e,t){this.left=e,this.right=t}},Fe=(n,e)=>new Mo(n,e);var Oo=n=>n.next()>=.5,Ri=(n,e,t)=>X(n.next()*(t+1-e)+e);var Do=(n,e,t)=>X(n.next()*(t+1-e)+e);var No=(n,e,t)=>Do(n,e,t);var Pp=n=>ar(No(n,97,122)),_a=(n,e=0,t=20)=>{let r=No(n,e,t),i="";for(let s=0;s<r;s++)i+=Pp(n);return i};var vi=(n,e)=>e[No(n,0,e.length-1)];var $p=Symbol("0schema"),Io=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(ra(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(` |
| 2 | `)}},_o=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[Lt]?Ii(n,e):Ge(n)?Si(n,t=>or(e,r=>_o(t,r))):wa(n)?pt(n,(t,r)=>_o(t,e[r])):!1,K=class{extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),_o(t,r)}equals(e){return this.constructor===e.constructor&&yr(this.shape,e.shape)}[$p](){return!0}[Lt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ce()}get nullable(){return Nn(this,Ki)}get optional(){return new Bi(this)}cast(e){return Ra(e,this),e}expect(e){return Ra(e,this),e}};xi(K,"_dilutes",!1);var Sr=class extends K{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}},z=(n,e=null)=>new Sr(n,e),Gb=z(Sr),Cr=class extends K{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}},W=n=>new Cr(n),Xb=z(Cr),On=class extends K{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}},Wi=(...n)=>new On(n),va=z(On),qp=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Ba=n=>{if(Dn.check(n))return[qp(n)];if(va.check(n))return n.shape.map(e=>e+"");if(Pa.check(n))return["[+-]?\\d+.?\\d*"];if(za.check(n))return[".*"];if($i.check(n))return n.shape.map(Ba).flat(1);J()},Ro=class extends K{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Ba).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 Zb=z(Ro),Jp=Symbol("optional"),Bi=class extends K{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[Jp](){return!0}},Wp=z(Bi),Ui=class extends K{check(e,t){return t?.extend(null,"never",typeof e),!1}},Qb=new Ui,ew=z(Ui),Ji=class Ji extends K{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}get partial(){return new Ji(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,"object","null"),!1):pt(this.shape,(r,i)=>{let s=this._isPartial&&!gr(e,i)||r.check(e[i],t);return!s&&t?.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match"),s})}};xi(Ji,"_dilutes",!0);var Vi=Ji,jp=n=>new Vi(n),Kp=z(Vi),Hp=W(n=>n!=null&&(n.constructor===Object||n.constructor==null)),Li=class extends K{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&pt(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)})}},Ua=(n,e)=>new Li(n,e),Yp=z(Li),Fi=class extends K{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&pt(this.shape,(r,i)=>{let s=r.check(e[i],t);return!s&&t?.extend(i.toString(),"Tuple",typeof r),s})}},Gp=(...n)=>new Fi(n),tw=z(Fi),Pi=class extends K{constructor(e){super(),this.shape=e.length===1?e[0]:new An(e)}check(e,t){let r=Ge(e)&&Si(e,i=>this.shape.check(i));return!r&&t?.extend(null,"Array",""),r}},Va=(...n)=>new Pi(n),Xp=z(Pi),Zp=W(n=>Ge(n)),zi=class extends K{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}},Qp=(n,e=null)=>new zi(n,e),nw=z(zi),em=Qp(K),vo=class extends K{constructor(e){super(),this.len=e.length-1,this.args=Gp(...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 tm=z(vo),nm=W(n=>typeof n=="function"),Bo=class extends K{constructor(e){super(),this.shape=e}check(e,t){let r=Si(this.shape,i=>i.check(e,t));return!r&&t?.extend(null,"Intersectinon",typeof e),r}};var rw=z(Bo,n=>n.shape.length>0),An=class extends K{constructor(e){super(),this.shape=e}check(e,t){let r=or(this.shape,i=>i.check(e,t));return t?.extend(null,"Union",typeof e),r}};xi(An,"_dilutes",!0);var Nn=(...n)=>n.findIndex(e=>$i.check(e))>=0?Nn(...n.map(e=>Tr(e)).map(e=>$i.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new An(n),$i=z(An),La=()=>!0,qi=W(La),rm=z(Cr,n=>n.shape===La),Vo=W(n=>typeof n=="bigint"),im=W(n=>n===Vo),Fa=W(n=>typeof n=="symbol"),iw=W(n=>n===Fa),Mn=W(n=>typeof n=="number"),Pa=W(n=>n===Mn),Dn=W(n=>typeof n=="string"),za=W(n=>n===Dn),ji=W(n=>typeof n=="boolean"),sm=W(n=>n===ji),$a=Wi(void 0),sw=z(On,n=>n.shape.length===1&&n.shape[0]===void 0),ow=Wi(void 0);var Ki=Wi(null),om=z(On,n=>n.shape.length===1&&n.shape[0]===null),lw=z(Uint8Array),cw=z(Sr,n=>n.shape===Uint8Array),lm=Nn(Mn,Dn,Ki,$a,Vo,ji,Fa),aw=(()=>{let n=Va(qi),e=Ua(Dn,qi),t=Nn(Mn,Dn,Ki,ji,n,e);return n.shape=t,e.shape.values=t,t})(),Tr=n=>{if(em.check(n))return n;if(Hp.check(n)){let e={};for(let t in n)e[t]=Tr(n[t]);return jp(e)}else{if(Zp.check(n))return Nn(...n.map(Tr));if(lm.check(n))return Wi(n);if(nm.check(n))return z(n)}J()},Ra=Aa?()=>{}:(n,e)=>{let t=new Io;if(!e.check(n,t))throw ke(`Expected value to be of type ${e.constructor.name}. |
| 3 | ${t.toString()}`)},Uo=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Tr(e),h:t}),this}else(e){return this.if(qi,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 ke("Unhandled pattern")}}},cm=n=>new Uo(n),qa=cm(qi).if(Pa,(n,e)=>Ri(e,fo,pn)).if(za,(n,e)=>_a(e)).if(sm,(n,e)=>Oo(e)).if(im,(n,e)=>BigInt(Ri(e,fo,pn))).if($i,(n,e)=>En(e,vi(e,n.shape))).if(Kp,(n,e)=>{let t={};for(let r in n.shape){let i=n.shape[r];if(Wp.check(i)){if(Oo(e))continue;i=i.shape}t[r]=qa(i,e)}return t}).if(Xp,(n,e)=>{let t=[],r=Do(e,0,42);for(let i=0;i<r;i++)t.push(En(e,n.shape));return t}).if(va,(n,e)=>vi(e,n.shape)).if(om,(n,e)=>null).if(tm,(n,e)=>{let t=En(e,n.res);return()=>t}).if(rm,(n,e)=>En(e,vi(e,[Mn,Dn,Ki,$a,Vo,ji,Va(Mn),Ua(Nn("a","b","c"),Mn)]))).if(Yp,(n,e)=>{let t={},r=Ri(e,0,3);for(let i=0;i<r;i++){let s=En(e,n.shape.keys),o=En(e,n.shape.values);t[s]=o}return t}).done(),En=(n,e)=>qa(Tr(e),n);var Ze=typeof document<"u"?document:{};var uw=W(n=>n.nodeType===dm);var hw=typeof DOMParser<"u"?new DOMParser:null;var dw=W(n=>n.nodeType===fm);var pw=W(n=>n.nodeType===um);var Ja=n=>Xc(n,(e,t)=>`${t}:${e};`).join("");var fm=Ze.ELEMENT_NODE,um=Ze.TEXT_NODE,mw=Ze.CDATA_SECTION_NODE,gw=Ze.COMMENT_NODE,hm=Ze.DOCUMENT_NODE,yw=Ze.DOCUMENT_TYPE_NODE,dm=Ze.DOCUMENT_FRAGMENT_NODE,xw=W(n=>n.nodeType===hm);var Hi=n=>class{constructor(t){this._=t}destroy(){n(this._)}},pm=Hi(clearTimeout),Lo=(n,e)=>new pm(setTimeout(e,n)),ww=Hi(clearInterval);var kw=Hi(n=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(n));var Sw=Hi(n=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(n));var Pe=Symbol;var Er=Pe(),Ar=Pe(),Fo=Pe(),Po=Pe(),zo=Pe(),Mr=Pe(),$o=Pe(),In=Pe(),qo=Pe(),ja=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 Cw=Ni();var xm={[Er]:Fe("font-weight","bold"),[Ar]:Fe("font-weight","normal"),[Fo]:Fe("color","blue"),[zo]:Fe("color","green"),[Po]:Fe("color","grey"),[Mr]:Fe("color","red"),[$o]:Fe("color","purple"),[In]:Fe("color","orange"),[qo]:Fe("color","black")},bm=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let e=[],t=[],r=le(),i=[],s=0;for(;s<n.length;s++){let o=n[s],l=xm[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=Ja(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},Ka=Ma?bm:ja,Ha=(...n)=>{console.log(...Ka(n)),Ya.forEach(e=>e.print(n))},Jo=(...n)=>{console.warn(...Ka(n)),n.unshift(In),Ya.forEach(e=>e.print(n))};var Ya=Re();var Ga=n=>({[Symbol.iterator](){return this},next:n}),Xa=(n,e)=>Ga(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),Yi=(n,e)=>Ga(()=>{let{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});var Nr=class{constructor(e,t){this.clock=e,this.len=t}},yt=class{constructor(){this.clients=new Map}},Qe=(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])Sf(n,s,a.clock,a.len,t)}}),Tm=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){let i=X((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},qt=(n,e)=>{let t=n.clients.get(e.client);return t!==void 0&&Tm(t,e.clock)!==null},ml=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=ve(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++)}e.length=r})},jo=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++)Qc(s,n[o].clients.get(i)||[]);e.clients.set(i,s)}});return ml(e),e},Ir=(n,e,t,r)=>{Te(n.clients,e,()=>[]).push(new Nr(t,r))},us=()=>new yt,Em=n=>{let e=us();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 Nr(l,c))}}i.length>0&&e.clients.set(r,i)}),e},gl=(n,e)=>{O(n.restEncoder,e.clients.size),Ye(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),O(n.restEncoder,t);let i=r.length;O(n.restEncoder,i);for(let s=0;s<i;s++){let o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Am=n=>{let e=new yt,t=A(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();let i=A(n.restDecoder),s=A(n.restDecoder);if(s>0){let o=Te(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new Nr(n.readDsClock(),n.readDsLen()))}}return e},ef=(n,e,t)=>{let r=new yt,i=A(n.restDecoder);for(let s=0;s<i;s++){n.resetDsCurVal();let o=A(n.restDecoder),l=A(n.restDecoder),c=t.clients.get(o)||[],a=L(t,o);for(let f=0;f<l;f++){let u=n.readDsClock(),h=u+n.readDsLen();if(u<a){a<h&&Ir(r,o,a,h-a);let d=Me(c,u),p=c[d];for(!p.deleted&&p.id.clock<u&&(c.splice(d+1,0,fs(e,p,u-p.id.clock)),d++);d<c.length&&(p=c[d++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&c.splice(d,0,fs(e,p,h-p.id.clock)),p.delete(e))}else Ir(r,o,u,h-u)}}if(r.clients.size>0){let s=new vn;return O(s.restEncoder,0),gl(s,r),s.toUint8Array()}return null};var mf=yo,Ae=class n extends cr{constructor({guid:e=ma(),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=mf(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new is,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=xo(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>xo(a=>{let f=u=>{(u===void 0||u===!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&&v(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ye(this.subdocs).map(e=>e.guid))}transact(e,t=null){return v(this,e,t)}get(e,t=$){let r=Te(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==$&&i!==t)if(i===$){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,cs)}getText(e=""){return this.get(e,et)}getMap(e=""){return this.get(e,vr)}getXmlElement(e=""){return this.get(e,Z)}getXmlFragment(e=""){return this.get(e,zt)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Ye(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,v(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()}},Ko=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return A(this.restDecoder)}readDsLen(){return A(this.restDecoder)}},ns=class extends Ko{readLeftID(){return S(A(this.restDecoder),A(this.restDecoder))}readRightID(){return S(A(this.restDecoder),A(this.restDecoder))}readClient(){return A(this.restDecoder)}readInfo(){return Bt(this.restDecoder)}readString(){return Ut(this.restDecoder)}readParentInfo(){return A(this.restDecoder)===1}readTypeRef(){return A(this.restDecoder)}readLen(){return A(this.restDecoder)}readAny(){return kn(this.restDecoder)}readBuf(){return Da(pe(this.restDecoder))}readJSON(){return JSON.parse(Ut(this.restDecoder))}readKey(){return Ut(this.restDecoder)}},Ho=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=A(this.restDecoder),this.dsCurrVal}readDsLen(){let e=A(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Rn=class extends Ho{constructor(e){super(e),this.keys=[],A(e),this.keyClockDecoder=new Sn(pe(e)),this.clientDecoder=new Vt(pe(e)),this.leftClockDecoder=new Sn(pe(e)),this.rightClockDecoder=new Sn(pe(e)),this.infoDecoder=new pr(pe(e),Bt),this.stringDecoder=new Mi(pe(e)),this.parentInfoDecoder=new pr(pe(e),Bt),this.typeRefDecoder=new Vt(pe(e)),this.lenDecoder=new Vt(pe(e))}readLeftID(){return new gt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new gt(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 kn(this.restDecoder)}readBuf(){return pe(this.restDecoder)}readJSON(){return kn(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}}},Yo=class{constructor(){this.restEncoder=bn()}toUint8Array(){return Ee(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){O(this.restEncoder,e)}writeDsLen(e){O(this.restEncoder,e)}},rs=class extends Yo{writeLeftID(e){O(this.restEncoder,e.client),O(this.restEncoder,e.clock)}writeRightID(e){O(this.restEncoder,e.client),O(this.restEncoder,e.clock)}writeClient(e){O(this.restEncoder,e)}writeInfo(e){Ei(this.restEncoder,e)}writeString(e){Rt(this.restEncoder,e)}writeParentInfo(e){O(this.restEncoder,e?1:0)}writeTypeRef(e){O(this.restEncoder,e)}writeLen(e){O(this.restEncoder,e)}writeAny(e){ht(this.restEncoder,e)}writeBuf(e){de(this.restEncoder,e)}writeJSON(e){Rt(this.restEncoder,JSON.stringify(e))}writeKey(e){Rt(this.restEncoder,e)}},Go=class{constructor(){this.restEncoder=bn(),this.dsCurrVal=0}toUint8Array(){return Ee(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,O(this.restEncoder,t)}writeDsLen(e){e===0&&J(),O(this.restEncoder,e-1),this.dsCurrVal+=e}},vn=class extends Go{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new xn,this.clientEncoder=new vt,this.leftClockEncoder=new xn,this.rightClockEncoder=new xn,this.infoEncoder=new ur(Ei),this.stringEncoder=new Ti,this.parentInfoEncoder=new ur(Ei),this.typeRefEncoder=new vt,this.lenEncoder=new vt}toUint8Array(){let e=bn();return O(e,0),de(e,this.keyClockEncoder.toUint8Array()),de(e,this.clientEncoder.toUint8Array()),de(e,this.leftClockEncoder.toUint8Array()),de(e,this.rightClockEncoder.toUint8Array()),de(e,Ee(this.infoEncoder)),de(e,this.stringEncoder.toUint8Array()),de(e,Ee(this.parentInfoEncoder)),de(e,this.typeRefEncoder.toUint8Array()),de(e,this.lenEncoder.toUint8Array()),hr(e,Ee(this.restEncoder)),Ee(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){ht(this.restEncoder,e)}writeBuf(e){de(this.restEncoder,e)}writeJSON(e){ht(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)}},Mm=(n,e,t,r)=>{r=ve(r,e[0].id.clock);let i=Me(e,r);O(n.restEncoder,e.length-i),n.writeClient(t),O(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)},gf=(n,e,t)=>{let r=new Map;t.forEach((i,s)=>{L(e,s)>i&&r.set(s,i)}),gs(e).forEach((i,s)=>{t.has(s)||r.set(s,0)}),O(n.restEncoder,r.size),Ye(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Mm(n,e.clients.get(i),i,s)})},Om=(n,e)=>{let t=le(),r=A(n.restDecoder);for(let i=0;i<r;i++){let s=A(n.restDecoder),o=new Array(s),l=n.readClient(),c=A(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 u=n.readLen();o[a]=new ge(S(l,c),u),c+=u;break}case 10:{let u=A(n.restDecoder);o[a]=new Se(S(l,c),u),c+=u;break}default:{let u=(f&192)===0,h=new R(S(l,c),null,(f&128)===128?n.readLeftID():null,null,(f&64)===64?n.readRightID():null,u?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,u&&(f&32)===32?n.readString():null,qf(n,f));o[a]=h,c+=h.length}}}}return t},Dm=(n,e,t)=>{let r=[],i=Ye(t.keys()).sort((d,p)=>d-p);if(i.length===0)return null;let s=()=>{if(i.length===0)return null;let d=t.get(i[i.length-1]);for(;d.refs.length===d.i;)if(i.pop(),i.length>0)d=t.get(i[i.length-1]);else return null;return d},o=s();if(o===null)return null;let l=new is,c=new Map,a=(d,p)=>{let m=c.get(d);(m==null||m>p)&&c.set(d,p)},f=o.refs[o.i++],u=new Map,h=()=>{for(let d of r){let p=d.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,[d]),i=i.filter(g=>g!==p)}r.length=0};for(;;){if(f.constructor!==Se){let p=Te(u,f.id.client,()=>L(e,f.id.client))-f.id.clock;if(p<0)r.push(f),a(f.id.client,f.id.clock-1),h();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,L(e,m)),h();else{f=g.refs[g.i++];continue}}else(p===0||p<f.length)&&(f.integrate(n,p),u.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 d=new vn;return gf(d,l,new Map),O(d.restEncoder,0),{missing:c,update:d.toUint8Array()}}return null},Nm=(n,e)=>gf(n,e.doc.store,e.beforeState),yf=(n,e,t,r=new Rn(n))=>v(e,i=>{i.local=!1;let s=!1,o=i.doc,l=o.store,c=Om(r,o),a=Dm(i,l,c),f=l.pendingStructs;if(f){for(let[h,d]of f.missing)if(d<L(l,h)){s=!0;break}if(a){for(let[h,d]of a.missing){let p=f.missing.get(h);(p==null||p>d)&&f.missing.set(h,d)}f.update=sl([f.update,a.update])}}else l.pendingStructs=a;let u=ef(r,i,l);if(l.pendingDs){let h=new Rn(Cn(l.pendingDs));A(h.restDecoder);let d=ef(h,i,l);u&&d?l.pendingDs=sl([u,d]):l.pendingDs=u||d}else l.pendingDs=u;if(s){let h=l.pendingStructs.update;l.pendingStructs=null,hs(i.doc,h)}},t,!1),xf=(n,e,t)=>yf(n,e,t,new ns(n)),hs=(n,e,t,r=Rn)=>{let i=Cn(e);yf(i,n,t,new r(i))};var Xo=class{constructor(){this.l=[]}},tf=()=>new Xo,nf=(n,e)=>n.l.push(e),rf=(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.")},bf=(n,e,t)=>xr(n.l,[e,t]),gt=class{constructor(e,t){this.client=e,this.clock=t}},Gi=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,S=(n,e)=>new gt(n,e);var Pn=n=>{for(let[e,t]of n.doc.share.entries())if(t===n)return e;throw J()},Bn=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};var Pt=class{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}};var Zo=class{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}},Im=(n,e,t=0)=>new Zo(n,e,t),Xi=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Pn(n):r=S(n._item.id.client,n._item.id.clock),new Pt(r,i,e,t)},ds=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Xi(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Xi(n,S(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Xi(n,r.lastId,t);r=r.right}return Xi(n,null,t)};var _m=(n,e)=>{let t=_n(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},wf=(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(L(r,i.client)<=i.clock)return null;let f=t?dl(r,i):_m(r,i),u=f.item;if(!(u instanceof R))return null;if(c=u.parent,c._item===null||!c._item.deleted){a=u.deleted||!u.countable?0:f.diff+(l>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(a+=h.length),h=h.left}}else{if(o!==null)c=e.get(o);else if(s!==null){if(L(r,s.client)<=s.clock)return null;let{item:f}=t?dl(r,s):{item:_n(r,s)};if(f instanceof R&&f.content instanceof Oe)c=f.content.type;else return null}else throw J();l>=0?a=c._length:a=0}return Im(c,a,n.assoc)};var Un=class{constructor(e,t){this.ds=e,this.sv=t}};var ps=(n,e)=>new Un(n,e),vw=ps(us(),new Map),ms=n=>ps(Em(n.store),gs(n.store)),Ft=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!qt(e.ds,n.id),Qo=(n,e)=>{let t=Te(n.meta,Qo,Re),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<L(r,s)&&me(n,S(s,i))}),Qe(n,e.ds,i=>{}),t.add(e))};var is=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},gs=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},L=(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},kf=(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 J()}t.push(e)},Me=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=X(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=X((t+r)/2)}throw J()},Rm=(n,e)=>{let t=n.clients.get(e.client);return t[Me(t,e.clock)]},_n=Rm,el=(n,e,t)=>{let r=Me(e,t),i=e[r];return i.id.clock<t&&i instanceof R?(e.splice(r+1,0,fs(n,i,t-i.id.clock)),r+1):r},me=(n,e)=>{let t=n.doc.store.clients.get(e.client);return t[el(n,t,e.clock)]},sf=(n,e,t)=>{let r=e.clients.get(t.client),i=Me(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==ge&&r.splice(i+1,0,fs(n,s,t.clock-s.id.clock+1)),s},vm=(n,e,t)=>{let r=n.clients.get(e.id.client);r[Me(r,e.id.clock)]=t},Sf=(n,e,t,r,i)=>{if(r===0)return;let s=t+r,o=el(n,e,t),l;do l=e[o++],s<l.id.clock+l.length&&el(n,e,s),i(l);while(o<e.length&&e[o].id.clock<s)},tl=class{constructor(e,t,r){this.doc=e,this.deleteSet=new yt,this.beforeState=gs(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}},of=(n,e)=>e.deleteSet.clients.size===0&&!Zc(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(ml(e.deleteSet),Nm(n,e),gl(n,e.deleteSet),!0),lf=(n,e,t)=>{let r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Te(n.changed,e,Re).add(t)},es=(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 R&&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},Bm=(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=Me(s,l.clock),f=s[a];a<s.length&&f.id.clock<c;f=s[++a]){let u=s[a];if(l.clock+l.len<=u.id.clock)break;u instanceof R&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Um=(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=Xe(i.length-1,1+Me(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+es(i,c)}})};var Cf=(n,e)=>{if(e<n.length){let t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{ml(s),t.afterState=gs(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,u)=>f.path.length-u.path.length),bf(a._dEH,c,t))})}),l.push(()=>r.emit("afterTransaction",[t,r])),xr(l,[]),t._needFormattingCleanup&&Gm(t)}finally{r.gc&&Bm(s,i,r.gcFilter),Um(s,i),t.afterState.forEach((f,u)=>{let h=t.beforeState.get(u)||0;if(h!==f){let d=i.clients.get(u),p=ve(Me(d,h),1);for(let m=d.length-1;m>=p;)m-=1+es(d,m)}});for(let f=o.length-1;f>=0;f--){let{client:u,clock:h}=o[f].id,d=i.clients.get(u),p=Me(d,h);p+1<d.length&&es(d,p+1)>1||p>0&&es(d,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(Ha(In,Er,"[yjs] ",Ar,Mr,"Changed the client-id because another client seems to be using it."),r.clientID=mf()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){let f=new rs;of(f,t)&&r.emit("update",[f.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){let f=new vn;of(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])):Cf(n,e+1)}}},v=(n,e,t=null,r=!0)=>{let i=n._transactionCleanups,s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new tl(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&&Cf(i,0)}}return o},nl=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},cf=(n,e,t)=>{Qe(n,t.deletions,r=>{r instanceof R&&e.scope.some(i=>i===n.doc||Bn(i,r))&&kl(r,!1)})},af=(n,e,t)=>{let r=null,i=n.doc,s=n.scope;v(i,l=>{for(;e.length>0&&n.currStackItem===null;){let c=i.store,a=e.pop(),f=new Set,u=[],h=!1;Qe(l,a.insertions,d=>{if(d instanceof R){if(d.redone!==null){let{item:p,diff:m}=dl(c,d.id);m>0&&(p=me(l,S(p.id.client,p.id.clock+m))),d=p}!d.deleted&&s.some(p=>p===l.doc||Bn(p,d))&&u.push(d)}}),Qe(l,a.deletions,d=>{d instanceof R&&s.some(p=>p===l.doc||Bn(p,d))&&!qt(a.insertions,d.id)&&f.add(d)}),f.forEach(d=>{h=$f(l,d,f,a.insertions,n.ignoreRemoteMapChanges,n)!==null||h});for(let d=u.length-1;d>=0;d--){let p=u[d];n.deleteFilter(p)&&(p.delete(l),h=!0)}n.currStackItem=h?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},Vn=class extends cr{constructor(e,{captureTimeout:t=500,captureTransaction:r=c=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Ge(e)?e[0].doc:e instanceof Ae?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,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():f||this.clear(!1,!0);let h=new yt;c.afterState.forEach((g,y)=>{let T=c.beforeState.get(y)||0,k=g-T;k>0&&Ir(h,y,T,k)});let d=Ni(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!f){let g=u[u.length-1];g.deletions=jo([g.deletions,c.deleteSet]),g.insertions=jo([g.insertions,h])}else u.push(new nl(c.deleteSet,h)),p=!0;!a&&!f&&(this.lastChange=d),Qe(c,c.deleteSet,g=>{g instanceof R&&this.scope.some(y=>y===c.doc||Bn(y,g))&&kl(g,!0)});let m=[{stackItem:u[u.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=Ge(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof $?r.doc!==this.doc:r!==this.doc)&&Jo("[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=>cf(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>cf(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=af(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=af(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*Vm(n){let e=A(n.restDecoder);for(let t=0;t<e;t++){let r=A(n.restDecoder),i=n.readClient(),s=A(n.restDecoder);for(let o=0;o<r;o++){let l=n.readInfo();if(l===10){let c=A(n.restDecoder);yield new Se(S(i,s),c),s+=c}else if((31&l)!==0){let c=(l&192)===0,a=new R(S(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,qf(n,l));yield a,s+=a.length}else{let c=n.readLen();yield new ge(S(i,s),c),s+=c}}}}var rl=class{constructor(e,t){this.gen=Vm(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===Se);return this.curr}};var il=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Tf=n=>sl(n,ns,rs);var Lm=(n,e)=>{if(n.constructor===ge){let{client:t,clock:r}=n.id;return new ge(S(t,r+e),n.length-e)}else if(n.constructor===Se){let{client:t,clock:r}=n.id;return new Se(S(t,r+e),n.length-e)}else{let t=n,{client:r,clock:i}=t.id;return new R(S(r,i+e),null,S(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},sl=(n,e=Rn,t=vn)=>{if(n.length===1)return n[0];let r=n.map(f=>new e(Cn(f))),i=r.map(f=>new rl(f,!0)),s=null,o=new t,l=new il(o);for(;i=i.filter(h=>h.curr!==null),i.sort((h,d)=>{if(h.curr.id.client===d.curr.id.client){let p=h.curr.id.clock-d.curr.id.clock;return p===0?h.curr.constructor===d.curr.constructor?0:h.curr.constructor===Se?1:-1:p}else return d.curr.id.client-h.curr.id.client}),i.length!==0;){let f=i[0],u=f.curr.id.client;if(s!==null){let h=f.curr,d=!1;for(;h!==null&&h.id.clock+h.length<=s.struct.id.clock+s.struct.length&&h.id.client>=s.struct.id.client;)h=f.next(),d=!0;if(h===null||h.id.client!==u||d&&h.id.clock>s.struct.id.clock+s.struct.length)continue;if(u!==s.struct.id.client)Or(l,s.struct,s.offset),s={struct:h,offset:0},f.next();else if(s.struct.id.clock+s.struct.length<h.id.clock)if(s.struct.constructor===Se)s.struct.length=h.id.clock+h.length-s.struct.id.clock;else{Or(l,s.struct,s.offset);let p=h.id.clock-s.struct.id.clock-s.struct.length;s={struct:new Se(S(u,s.struct.id.clock+s.struct.length),p),offset:0}}else{let p=s.struct.id.clock+s.struct.length-h.id.clock;p>0&&(s.struct.constructor===Se?s.struct.length-=p:h=Lm(h,p)),s.struct.mergeWith(h)||(Or(l,s.struct,s.offset),s={struct:h,offset:0},f.next())}}else s={struct:f.curr,offset:0},f.next();for(let h=f.curr;h!==null&&h.id.client===u&&h.id.clock===s.struct.id.clock+s.struct.length&&h.constructor!==Se;h=f.next())Or(l,s.struct,s.offset),s={struct:h,offset:0}}s!==null&&(Or(l,s.struct,s.offset),s=null),Fm(l);let c=r.map(f=>Am(f)),a=jo(c);return gl(o,a),o.toUint8Array()};var Ef=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Ee(n.encoder.restEncoder)}),n.encoder.restEncoder=bn(),n.written=0)},Or=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&Ef(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),O(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},Fm=n=>{Ef(n);let e=n.encoder.restEncoder;O(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){let r=n.clientStructs[t];O(e,r.written),hr(e,r.restEncoder)}};var ff="You must not compute changes after the event-handler fired.",Ln=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=Pm(this.currentTarget,this.target))}deletes(e){return qt(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ke(ff);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=ki(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",l=ki(c.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=ki(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 ke(ff);let t=this.target,r=Re(),i=Re(),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}},Pm=(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},ne=()=>{Jo("Invalid access: Add Yjs type to a document before reading data.")},Af=80,yl=0,ol=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=yl++}},zm=n=>{n.timestamp=yl++},Mf=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=yl++},$m=(n,e,t)=>{if(n.length>=Af){let r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return Mf(r,e,t),r}else{let r=new ol(e,t);return n.push(r),r}},ys=(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)=>Nt(e-s.index)<Nt(e-o.index)?s:o),r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,zm(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&&Nt(t.index-i)<r.parent.length/Af?(Mf(t,r,i),t):$m(n._searchMarker,r,i)},_r=(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=ve(e,i.index+t))}};var xs=(n,e,t)=>{let r=n,i=e.changedParentTypes;for(;Te(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;bf(r._eH,t,e)},$=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=tf(),this._dEH=tf(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw ce()}clone(){throw ce()}_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){nf(this._eH,e)}observeDeep(e){nf(this._dEH,e)}unobserve(e){rf(this._eH,e)}unobserveDeep(e){rf(this._dEH,e)}toJSON(){}},Of=(n,e,t)=>{n.doc??ne(),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},Df=n=>{n.doc??ne();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},xl=(n,e)=>{let t=[],r=n._start;for(;r!==null;){if(r.countable&&Ft(r,e)){let i=r.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}r=r.right}return t},Rr=(n,e)=>{let t=0,r=n._start;for(n.doc??ne();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}},Nf=(n,e)=>{let t=[];return Rr(n,(r,i)=>{t.push(e(r,i,n))}),t},qm=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}}}},If=(n,e)=>{n.doc??ne();let t=ys(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}},ss=(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 R(S(o,L(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Fn(a)),i.integrate(n,0),a=[])};r.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(f(),u.constructor){case Uint8Array:case ArrayBuffer:i=new R(S(o,L(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Vr(new Uint8Array(u))),i.integrate(n,0);break;case Ae:i=new R(S(o,L(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Lr(u)),i.integrate(n,0);break;default:if(u instanceof $)i=new R(S(o,L(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Oe(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},_f=()=>ke("Length exceeded!"),Rf=(n,e,t,r)=>{if(t>e._length)throw _f();if(t===0)return e._searchMarker&&_r(e._searchMarker,t,r.length),ss(n,e,null,r);let i=t,s=ys(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&&me(n,S(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&_r(e._searchMarker,i,r.length),ss(n,e,o,r)},Jm=(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 ss(n,e,i,t)},vf=(n,e,t,r)=>{if(r===0)return;let i=t,s=r,o=ys(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&&me(n,S(l.id.client,l.id.clock+t)),t-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&me(n,S(l.id.client,l.id.clock+r)),l.delete(n),r-=l.length),l=l.right;if(r>0)throw _f();e._searchMarker&&_r(e._searchMarker,i,-s+r)},ls=(n,e,t)=>{let r=e._map.get(t);r!==void 0&&r.delete(n)},bl=(n,e,t,r)=>{let i=e._map.get(t)||null,s=n.doc,o=s.clientID,l;if(r==null)l=new Fn([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Fn([r]);break;case Uint8Array:l=new Vr(r);break;case Ae:l=new Lr(r);break;default:if(r instanceof $)l=new Oe(r);else throw new Error("Unexpected content type")}new R(S(o,L(s.store,o)),i,i&&i.lastId,null,null,e,t,l).integrate(n,0)},wl=(n,e)=>{n.doc??ne();let t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},Bf=n=>{let e={};return n.doc??ne(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},Uf=(n,e)=>{n.doc??ne();let t=n._map.get(e);return t!==void 0&&!t.deleted};var Wm=(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&&Ft(s,e)&&(t[i]=s.content.getContent()[s.length-1])}),t},Zi=n=>(n.doc??ne(),Xa(n._map.entries(),e=>!e[1].deleted)),ll=class extends Ln{},cs=class n extends ${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 $?t.clone():t)),e}get length(){return this.doc??ne(),this._length}_callObserver(e,t){super._callObserver(e,t),xs(this,e,new ll(this,e))}insert(e,t){this.doc!==null?v(this.doc,r=>{Rf(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?v(this.doc,t=>{Jm(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?v(this.doc,r=>{vf(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return If(this,e)}toArray(){return Df(this)}slice(e=0,t=this.length){return Of(this,e,t)}toJSON(){return this.map(e=>e instanceof $?e.toJSON():e)}map(e){return Nf(this,e)}forEach(e){Rr(this,e)}[Symbol.iterator](){return qm(this)}_write(e){e.writeTypeRef(dg)}},jm=n=>new cs,cl=class extends Ln{constructor(e,t,r){super(e,t),this.keysChanged=r}},vr=class n extends ${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 $?t.clone():t)}),e}_callObserver(e,t){xs(this,e,new cl(this,e,t))}toJSON(){this.doc??ne();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let i=t.content.getContent()[t.length-1];e[r]=i instanceof $?i.toJSON():i}}),e}get size(){return[...Zi(this)].length}keys(){return Yi(Zi(this),e=>e[0])}values(){return Yi(Zi(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Yi(Zi(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ne(),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?v(this.doc,t=>{ls(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?v(this.doc,r=>{bl(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return wl(this,e)}has(e){return Uf(this,e)}clear(){this.doc!==null?v(this.doc,e=>{this.forEach(function(t,r,i){ls(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(pg)}},Km=n=>new vr,mt=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&Co(n,e),Br=class{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){this.right===null&&J(),this.right.content.constructor===F?this.right.deleted||zn(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},uf=(n,e,t)=>{for(;e.right!==null&&t>0;)e.right.content.constructor===F?e.right.deleted||zn(e.currentAttributes,e.right.content):e.right.deleted||(t<e.right.length&&me(n,S(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},Qi=(n,e,t,r)=>{let i=new Map,s=r?ys(e,t):null;if(s){let o=new Br(s.p.left,s.p,s.index,i);return uf(n,o,t-s.index)}else{let o=new Br(null,e._start,0,i);return uf(n,o,t)}},Vf=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===F&&mt(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 R(S(s,L(i.store,s)),c,c&&c.lastId,a,a&&a.id,e,null,new F(l,o));f.integrate(n,0),t.right=f,t.forward()})},zn=(n,e)=>{let{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},Lf=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===F&&mt(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},Ff=(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(!mt(a,c)){o.set(l,a);let{left:f,right:u}=t;t.right=new R(S(s,L(i.store,s)),f,f&&f.lastId,u,u&&u.id,e,null,new F(l,c)),t.right.integrate(n,0),t.forward()}}return o},Wo=(n,e,t,r,i)=>{t.currentAttributes.forEach((h,d)=>{i[d]===void 0&&(i[d]=null)});let s=n.doc,o=s.clientID;Lf(t,i);let l=Ff(n,e,t,i),c=r.constructor===String?new Be(r):r instanceof $?new Oe(r):new $t(r),{left:a,right:f,index:u}=t;e._searchMarker&&_r(e._searchMarker,t.index,c.getLength()),f=new R(S(o,L(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,c),f.integrate(n,0),t.right=f,t.index=u,t.forward(),Vf(n,e,t,l)},hf=(n,e,t,r,i)=>{let s=n.doc,o=s.clientID;Lf(t,i);let l=Ff(n,e,t,i);e:for(;t.right!==null&&(r>0||l.size>0&&(t.right.deleted||t.right.content.constructor===F));){if(!t.right.deleted)switch(t.right.content.constructor){case F:{let{key:c,value:a}=t.right.content,f=i[c];if(f!==void 0){if(mt(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&&me(n,S(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 R(S(o,L(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Be(c)),t.right.integrate(n,0),t.forward()}Vf(n,e,t,l)},Pf=(n,e,t,r,i)=>{let s=e,o=le();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===F){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===F){let{key:f,value:u}=a,h=r.get(f)??null;(o.get(f)!==a||h===u)&&(e.delete(n),l++,!c&&(i.get(f)??null)===u&&h!==u&&(h===null?i.delete(f):i.set(f,h))),!c&&!e.deleted&&zn(i,a)}}e=e.right}return l},Hm=(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===F){let r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},Ym=n=>{let e=0;return v(n.doc,t=>{let r=n._start,i=n._start,s=le(),o=bi(s);for(;i;)i.deleted===!1&&(i.content.constructor===F?zn(o,i.content):(e+=Pf(t,r,i,s,o),s=bi(o),r=i)),i=i.right}),e},Gm=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&&Sf(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===F&&o.constructor!==ge&&e.add(o.parent)})}v(t,r=>{Qe(n,n.deleteSet,i=>{if(i instanceof ge||!i.parent._hasFormatting||e.has(i.parent))return;let s=i.parent;i.content.constructor===F?e.add(s):Hm(r,i)});for(let i of e)Ym(i)})},df=(n,e,t)=>{let r=t,i=bi(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Oe:case $t:case Be:t<e.right.length&&me(n,S(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&Pf(n,s,e.right,i,e.currentAttributes);let o=(e.left||e.right).parent;return o._searchMarker&&_r(o._searchMarker,e.index,-r+t),e},al=class extends Ln{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=[];v(e,r=>{let i=new Map,s=new Map,o=this.target._start,l=null,c={},a="",f=0,u=0,h=()=>{if(l!==null){let d=null;switch(l){case"delete":u>0&&(d={delete:u}),u=0;break;case"insert":(typeof a=="object"||a.length>0)&&(d={insert:a},i.size>0&&(d.attributes={},i.forEach((p,m)=>{p!==null&&(d.attributes[m]=p)}))),a="";break;case"retain":f>0&&(d={retain:f},Ca(c)||(d.attributes=ka({},c))),f=0;break}d&&t.push(d),l=null}};for(;o!==null;){switch(o.content.constructor){case Oe:case $t:this.adds(o)?this.deletes(o)||(h(),l="insert",a=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),f+=1);break;case Be:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),a+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),f+=o.length);break;case F:{let{key:d,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let m=i.get(d)??null;mt(m,p)?p!==null&&o.delete(r):(l==="retain"&&h(),mt(p,s.get(d)??null)?delete c[d]:c[d]=p)}}else if(this.deletes(o)){s.set(d,p);let m=i.get(d)??null;mt(m,p)||(l==="retain"&&h(),c[d]=m)}else if(!o.deleted){s.set(d,p);let m=c[d];m!==void 0&&(mt(m,p)?m!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete c[d]:c[d]=p))}o.deleted||(l==="insert"&&h(),zn(i,o.content));break}}o=o.right}for(h();t.length>0;){let d=t[t.length-1];if(d.retain!==void 0&&d.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},et=class n extends ${constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ne(),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 al(this,e,t);xs(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ne();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Be&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?v(this.doc,r=>{let i=new Br(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)&&Wo(r,this,i,l,o.attributes||{})}else o.retain!==void 0?hf(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&df(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??ne();let i=[],s=new Map,o=this.doc,l="",c=this._start;function a(){if(l.length>0){let u={},h=!1;s.forEach((p,m)=>{h=!0,u[m]=p});let d={insert:l};h&&(d.attributes=u),i.push(d),l=""}}let f=()=>{for(;c!==null;){if(Ft(c,e)||t!==void 0&&Ft(c,t))switch(c.content.constructor){case Be:{let u=s.get("ychange");e!==void 0&&!Ft(c,e)?(u===void 0||u.user!==c.id.client||u.type!=="removed")&&(a(),s.set("ychange",r?r("removed",c.id):{type:"removed"})):t!==void 0&&!Ft(c,t)?(u===void 0||u.user!==c.id.client||u.type!=="added")&&(a(),s.set("ychange",r?r("added",c.id):{type:"added"})):u!==void 0&&(a(),s.delete("ychange")),l+=c.content.str;break}case Oe:case $t:{a();let u={insert:c.content.getContent()[0]};if(s.size>0){let h={};u.attributes=h,s.forEach((d,p)=>{h[p]=d})}i.push(u);break}case F:Ft(c,e)&&(a(),zn(s,c.content));break}c=c.right}a()};return e||t?v(o,u=>{e&&Qo(u,e),t&&Qo(u,t),f()},"cleanup"):f(),i}insert(e,t,r){if(t.length<=0)return;let i=this.doc;i!==null?v(i,s=>{let o=Qi(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,c)=>{r[c]=l})),Wo(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let i=this.doc;i!==null?v(i,s=>{let o=Qi(s,this,e,!r);Wo(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?v(r,i=>{df(i,Qi(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?v(i,s=>{let o=Qi(s,this,e,!1);o.right!==null&&hf(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?v(this.doc,t=>{ls(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?v(this.doc,r=>{bl(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return wl(this,e)}getAttributes(){return Bf(this)}_write(e){e.writeTypeRef(mg)}},Xm=n=>new et,Dr=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ne()}[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===Z||t.constructor===zt)&&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})}},zt=class n extends ${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 $?t.clone():t)),e}get length(){return this.doc??ne(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Dr(this,e)}querySelector(e){e=e.toUpperCase();let r=new Dr(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Ye(new Dr(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){xs(this,e,new fl(this,t,e))}toString(){return Nf(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),Rr(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?v(this.doc,r=>{Rf(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)v(this.doc,r=>{let i=e&&e instanceof $?e._item:e;ss(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 ke("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?v(this.doc,r=>{vf(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Df(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return If(this,e)}slice(e=0,t=this.length){return Of(this,e,t)}forEach(e){Rr(this,e)}_write(e){e.writeTypeRef(yg)}},Zm=n=>new zt,Z=class n extends zt{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 Sa(t,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof $?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?v(this.doc,t=>{ls(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?v(this.doc,r=>{bl(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return wl(this,e)}hasAttribute(e){return Uf(this,e)}getAttributes(e){return e?Wm(this,e):Bf(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 Rr(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(gg),e.writeKey(this.nodeName)}},Qm=n=>new Z(n.readKey()),fl=class extends Ln{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)})}},ul=class n extends vr{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(xg),e.writeKey(this.hookName)}},eg=n=>new ul(n.readKey()),ye=class n extends et{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(bg)}},tg=n=>new ye,Ur=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ce()}mergeWith(e){return!1}write(e,t,r){throw ce()}integrate(e,t){throw ce()}},ng=0,ge=class extends Ur{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),kf(e.doc.store,this)}write(e,t){e.writeInfo(ng),e.writeLen(this.length-t)}getMissing(e,t){return null}},Vr=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 ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},rg=n=>new Vr(n.readBuf()),as=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){Ir(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}},ig=n=>new as(n.readLen()),zf=(n,e)=>new Ae({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),Lr=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(zf(this.doc.guid,this.opts))}splice(e){throw ce()}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}},sg=n=>new Lr(zf(n.readString(),n.readAny())),$t=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 ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},og=n=>new $t(n.readJSON()),F=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 ce()}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}},lg=n=>new F(n.readKey(),n.readJSON()),hl=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}},cg=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 hl(t)},ag=br("node_env")==="development",Fn=class n{constructor(e){this.arr=e,ag&&To(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}},fg=n=>{let e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Fn(t)},Be=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}},ug=n=>new Be(n.readString()),hg=[jm,Km,Xm,Qm,Zm,eg,tg],dg=0,pg=1,mg=2,gg=3,yg=4,xg=5,bg=6,Oe=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 ce()}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}},wg=n=>new Oe(hg[n.readTypeRef()](n)),dl=(n,e)=>{let t=e,r=0,i;do r>0&&(t=S(t.client,t.clock+r)),i=_n(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof R);return{item:i,diff:r}},kl=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},fs=(n,e,t)=>{let{client:r,clock:i}=e.id,s=new R(S(r,i+t),e,S(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=S(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},pf=(n,e)=>or(n,t=>qt(t.deletions,e)),$f=(n,e,t,r,i,s)=>{let o=n.doc,l=o.store,c=o.clientID,a=e.redone;if(a!==null)return me(n,a);let f=e.parent._item,u=null,h;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!t.has(f)||$f(n,f,t,r,i,s)===null))return null;for(;f.redone!==null;)f=me(n,f.redone)}let d=f===null?e.parent:f.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let y=u;for(;y!==null&&y.parent._item!==f;)y=y.redone===null?null:me(n,y.redone);if(y!==null&&y.parent._item===f){u=y;break}u=u.left}for(;h!==null;){let y=h;for(;y!==null&&y.parent._item!==f;)y=y.redone===null?null:me(n,y.redone);if(y!==null&&y.parent._item===f){h=y;break}h=h.right}}else if(h=null,e.right&&!i){for(u=e;u!==null&&u.right!==null&&(u.right.redone||qt(r,u.right.id)||pf(s.undoStack,u.right.id)||pf(s.redoStack,u.right.id));)for(u=u.right;u.redone;)u=me(n,u.redone);if(u&&u.right!==null)return null}else u=d._map.get(e.parentSub)||null;let p=L(l,c),m=S(c,p),g=new R(m,u,u&&u.lastId,h,h&&h.id,d,e.parentSub,e.content.copy());return e.redone=m,kl(g,!0),g.integrate(n,0),g},R=class n extends Ur{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>=L(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=L(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===gt&&this.id.client!==this.parent.client&&this.parent.clock>=L(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=sf(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=me(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ge||this.right&&this.right.constructor===ge)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===gt){let r=_n(t,this.parent);r.constructor===ge?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=sf(e,e.doc.store,S(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),Gi(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(Gi(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(_n(e.doc.store,i.origin)))s.has(_n(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),kf(e.doc.store,this),this.content.integrate(e,this),lf(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new ge(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:S(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Gi(e.origin,this.lastId)&&this.right===e&&Gi(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(),Ir(e.deleteSet,this.id.client,this.id.clock,this.length),lf(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw J();this.content.gc(e),t?vm(e,this,new ge(this.id,this.length)):this.content=new as(this.length)}write(e,t){let r=t>0?S(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=Pn(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===gt?(e.writeParentInfo(!1),e.writeLeftID(l)):J();s!==null&&e.writeString(s)}this.content.write(e,t)}},qf=(n,e)=>kg[e&31](n),kg=[()=>{J()},ig,cg,rg,ug,og,lg,wg,fg,sg,()=>{J()}],Sg=10,Se=class extends Ur{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){J()}write(e,t){e.writeInfo(Sg),O(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Jf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Wf="__ $YJS$ __";Jf[Wf]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Jf[Wf]=!0;function re(n){this.content=n}re.prototype={constructor:re,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 re(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 re(t)},addToStart:function(n,e){return new re([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new re(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 re(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=re.from(n),n.size?new re(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=re.from(n),n.size?new re(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=re.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}};re.from=function(n){if(n instanceof re)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new re(e)};var Cl=re;function tu(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&&iu(o.charCodeAt(c-1))&&ru(o.charCodeAt(c))&&t--,t}if(i.content.size||s.content.size){let o=tu(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function nu(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,u=a.length,h=f.length;for(;u>0&&h>0&&a[u-1]==f[h-1];)u--,h--,t--,r--;return u&&h&&u<a.length&&iu(a.charCodeAt(u-1))&&ru(a.charCodeAt(u))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let a=nu(o.content,l.content,t-1,r-1);if(a)return a}t-=c,r-=c}}function ru(n){return n>=56320&&n<57344}function iu(n){return n>=55296&&n<56320}var x=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 tu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return nu(this,e,t,r)}findIndex(e){if(e==0)return bs(0,e);if(e==this.size)return bs(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?bs(t+1,s):bs(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)":""))}};x.empty=new x([],0);var Tl={index:0,offset:0};function bs(n,e){return Tl.index=n,Tl.offset=e,Tl}function Ss(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(!Ss(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Ss(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var N=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&&Ss(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}};N.none=[];var xt=class extends Error{},b=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=ou(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(su(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(x.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)}};b.empty=new b(x.empty,0,0);function su(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(su(s.content,e-i-1,t-i-1)))}function ou(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=ou(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 Cg(n,e,t){if(t.openStart>n.depth)throw new xt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new xt("Inconsistent open depths");return lu(n,e,t,0)}function lu(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=lu(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 Wt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Tg(t,n);return Wt(s,au(n,o,l,e,r))}else return Wt(s,Cs(n,e,r))}function cu(n,e){if(!e.type.compatibleContent(n.type))throw new xt("Cannot join "+e.type.name+" onto "+n.type.name)}function El(n,e,t){let r=n.node(t);return cu(r,e.node(t)),r}function Jt(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 Fr(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&&(Jt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Jt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Jt(e.nodeBefore,r)}function Wt(n,e){if(!n.type.validContent(e))throw new xt("Invalid content for node "+n.type.name);return n.copy(e)}function au(n,e,t,r,i){let s=n.depth>i&&El(n,e,i+1),o=r.depth>i&&El(t,r,i+1),l=[];return Fr(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(cu(s,o),Jt(Wt(s,au(n,e,t,r,i+1)),l)):(s&&Jt(Wt(s,Cs(n,e,i+1)),l),Fr(e,t,i,l),o&&Jt(Wt(o,Cs(t,r,i+1)),l)),Fr(r,null,i,l),new x(l)}function Cs(n,e,t){let r=[];if(Fr(null,n,t,r),n.depth>t){let i=El(n,e,t+1);Jt(Wt(i,Cs(n,e,t+1)),r)}return Fr(e,null,t,r),new x(r)}function Tg(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(x.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Ts=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 N.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 jt(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=jf.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 jf.set(e,r=new Al);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Eg,i}},Al=class{constructor(){this.elts=[],this.i=0}},Eg=12,jf=new WeakMap,jt=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)}},Ag=Object.create(null),ze=class n{constructor(e,t,r,i=N.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,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&&Ss(this.attrs,t||e.defaultAttrs||Ag)&&N.sameSet(this.marks,r||N.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 b.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 b(a,i.depth-o,s.depth-o)}replace(e,t,r){return Cg(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 Ts.resolveCached(this,e)}resolveNoCache(e){return Ts.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()+")"),fu(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=x.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=N.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(!N.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=x.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};ze.prototype.text=void 0;var Ml=class n extends ze{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):fu(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 fu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Kt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ol(e,t);if(r.next==null)return n.empty;let i=uu(r);r.next&&r.err("Unexpected trailing text");let s=Rg(_g(i));return vg(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 x.from(l.map(a=>a.createAndFill()));for(let a=0;a<o.next.length;a++){let{type:f,next:u}=o.next[a];if(!(f.isText||f.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let h=s(u,l.concat(f));if(h)return h}}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 | `)}};Kt.empty=new Kt(!0);var Ol=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 uu(n){let e=[];do e.push(Mg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Mg(n){let e=[];do e.push(Og(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Og(n){let e=Ig(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=Dg(n,e);else break;return e}function Kf(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Dg(n,e){let t=Kf(n),r=t;return n.eat(",")&&(n.next!="}"?r=Kf(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ng(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 Ig(n){if(n.eat("(")){let e=uu(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=Ng(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function _g(n){let e=[[]];return i(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 hu(n,e){return e-n}function Hf(n,e){let t=[];return r(e),t.sort(hu);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 Rg(n){let e=Object.create(null);return t(Hf(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]);Hf(n,c).forEach(f=>{a||i.push([l,a=[]]),a.indexOf(f)==-1&&a.push(f)})})});let s=e[r.join(",")]=new Kt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(hu);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function vg(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 du(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 pu(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 mu(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 gu(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Dl(n,r,e[r]);return t}var Es=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=gu(e,r.attrs),this.defaultAttrs=du(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==Kt.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:pu(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),x.from(t),N.setFrom(r))}createChecked(e=null,t,r){return t=x.from(t),this.checkContent(t),new ze(this,this.computeAttrs(e),t,N.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=x.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(x.empty,!0);return s?new ze(this,e,t.append(s),N.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){mu(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:N.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 Bg(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 Dl=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Bg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},zr=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=gu(e,i.attrs),this.excluded=null;let s=du(this.attrs);this.instance=s?new N(this,s):null}create(e=null){return!e&&this.instance?this.instance:new N(this,pu(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){mu(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},qn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Cl.from(e.nodes),t.marks=Cl.from(e.marks||{}),this.nodes=Es.compile(this.spec.nodes,this),this.marks=zr.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]=Kt.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?Yf(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==""?[]:Yf(this,o.split(" "))}this.nodeFromJSON=i=>ze.fromJSON(this,i),this.markFromJSON=i=>N.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 Es){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Ml(r,r.defaultAttrs,e,N.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 Yf(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 Ug(n){return n.tag!=null}function Vg(n){return n.style!=null}var $r=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Ug(i))this.tags.push(i);else if(Vg(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 As(this,t,!1);return r.addAll(e,N.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new As(this,t,!0);return r.addAll(e,N.none,t.from,t.to),b.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(Pg(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=Xf(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=Xf(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)))}},yu={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},Lg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},xu={ol:!0,ul:!0},qr=1,Nl=2,Pr=4;function Gf(n,e,t){return e!=null?(e?qr:0)|(e==="full"?Nl:0):n&&n.whitespace=="pre"?qr|Nl:t&~Pr}var $n=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=N.none,this.match=s||(o&Pr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.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&qr)){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=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!yu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},As=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=Gf(null,t.preserveWhitespace,0)|(r?Pr:0);i?s=new $n(i.type,i.attrs,N.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new $n(null,null,N.none,!0,null,o):s=new $n(e.schema.topNodeType,null,N.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&Nl?"full":this.localPreserveWS||(i.options&qr)>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;xu.hasOwnProperty(o)&&this.parser.normalizeLists&&Fg(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:Lg.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(yu.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 u=c&&c.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),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=N.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Zf(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=Gf(e,s,o.options);o.options&Pr&&o.content.length==0&&(l|=Pr);let c=N.none;return r=r.filter(a=>(o.type?o.type.allowsMarkType(a.type):Zf(a.type,e))?(c=a.addToSet(c),!1):!0),this.nodes.push(new $n(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|=qr)}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 Fg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&xu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Pg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Xf(n){let e={};for(let t in n)e[t]=n[t];return e}function Zf(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 Ht=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ws(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 ws(t).createTextNode(e.text);let{dom:r,contentDOM:i}=ks(ws(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&&ks(ws(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:ks(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=Qf(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Qf(e.marks)}};function Qf(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ws(n){return n.document||window.document}var eu=new WeakMap;function zg(n){let e=eu.get(n);return e===void 0&&eu.set(n,e=$g(n)),e}function $g(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 ks(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=zg(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 u in a)if(a[u]!=null){let h=u.indexOf(" ");h>0?c.setAttributeNS(u.slice(0,h),u.slice(h+1),a[u]):u=="style"&&c.style?c.style.cssText=a[u]:c.setAttribute(u,a[u])}}for(let u=f;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof h=="string")c.appendChild(n.createTextNode(h));else{let{dom:d,contentDOM:p}=ks(n,h,t,r);if(c.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:c,contentDOM:l}}var ku=65535,Su=Math.pow(2,16);function Jg(n,e){return n+e*Su}function bu(n){return n&ku}function Wg(n){return(n-(n&ku))/Su}var Cu=1,Tu=2,Ms=4,Eu=8,jr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Eu)>0}get deletedBefore(){return(this.delInfo&(Cu|Ms))>0}get deletedAfter(){return(this.delInfo&(Tu|Ms))>0}get deletedAcross(){return(this.delInfo&Ms)>0}},tt=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=bu(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+Wg(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],u=c+a;if(e<=u){let h=a?e==c?-1:e==u?1:t:t,d=c+i+(h<0?0:f);if(r)return d;let p=e==(t<0?c:u)?null:Jg(l/3,e-c),m=e==c?Tu:e==u?Cu:Ms;return(t<0?e!=c:e!=u)&&(m|=Eu),new jr(d,m,p)}i+=f-a}return r?e+i:new jr(e+i,0,null)}touches(e,t){let r=0,i=bu(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])}};tt.empty=new tt([]);var vl=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 jr(e,i,null)}},Il=Object.create(null),H=class{getMap(){return tt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Il[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 Il)throw new RangeError("Duplicate use of step JSON ID "+e);return Il[e]=t,t.prototype.jsonID=e,t}},Q=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 xt)return n.fail(s.message);throw s}}};function Vl(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Vl(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return x.fromArray(r)}var Kr=class n extends H{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 b(Vl(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 Q.fromReplace(e,this.from,this.to,s)}invert(){return new Yt(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))}};H.jsonID("addMark",Kr);var Yt=class n extends H{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 b(Vl(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Q.fromReplace(e,this.from,this.to,r)}invert(){return new Kr(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))}};H.jsonID("removeMark",Yt);var Hr=class n extends H{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Q.fromReplace(e,this.pos,this.pos+1,new b(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Jn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};H.jsonID("addNodeMark",Hr);var Jn=class n extends H{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Q.fromReplace(e,this.pos,this.pos+1,new b(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Hr(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))}};H.jsonID("removeNodeMark",Jn);var xe=class n extends H{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Bl(e,this.from,this.to)?Q.fail("Structure replace would overwrite content"):Q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tt([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?b.empty:new b(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?b.empty:new b(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,b.fromJSON(e,t.slice),!!t.structure)}};xe.MAP_BIAS=1;H.jsonID("replace",xe);var Y=class n extends H{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&&(Bl(e,this.from,this.gapFrom)||Bl(e,this.gapTo,this.to)))return Q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Q.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Q.fromReplace(e,this.from,this.to,r):Q.fail("Content does not fit in gap")}getMap(){return new tt([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,b.fromJSON(e,t.slice),t.insert,!!t.structure)}};H.jsonID("replaceAround",Y);function Bl(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 jg(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(c,a,f)=>{if(!c.isInline)return;let u=c.marks;if(!r.isInSet(u)&&f.type.allowsMarkType(r.type)){let h=Math.max(a,e),d=Math.min(a+c.nodeSize,t),p=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==h&&o.mark.eq(u[m])?o.to=d:i.push(o=new Yt(h,d,u[m])));l&&l.to==h?l.to=d:s.push(l=new Kr(h,d,r))}}),i.forEach(c=>n.step(c)),s.forEach(c=>n.step(c))}function Kg(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 zr){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 u=c[f],h;for(let d=0;d<i.length;d++){let p=i[d];p.step==s-1&&u.eq(i[d].style)&&(h=p)}h?(h.to=a,h.step=s):i.push({style:u,from:Math.max(l,e),to:a,step:s})}}}),i.forEach(o=>n.step(new Yt(o.from,o.to,o.style)))}function Ll(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,u=r.matchType(a.type);if(!u)o.push(new xe(l,f,b.empty));else{r=u;for(let h=0;h<a.marks.length;h++)t.allowsMarkType(a.marks[h].type)||n.step(new Yt(l,f,a.marks[h]));if(i&&a.isText&&t.whitespace!="pre"){let h,d=/\r?\n|\r/g,p;for(;h=d.exec(a.text);)p||(p=new b(x.from(t.schema.text(" ",t.allowedMarks(a.marks))),0,0)),o.push(new xe(l+h.index,l+h.index+h[0].length,p))}}l=f}if(!r.validEnd){let c=r.fillBefore(x.empty,!0);n.replace(l,l,new b(c,0,0))}for(let c=o.length-1;c>=0;c--)n.step(o[c])}function Hg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Gt(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||!Hg(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function Yg(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=x.empty,u=0;for(let p=s,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,f=x.from(r.node(p).copy(f)),u++):c--;let h=x.empty,d=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,h=x.from(i.node(p).copy(h)),d++):a++;n.step(new Y(c,a,o,l,new b(f.append(h),u,d),f.size-u,!0))}function jn(n,e,t=null,r=n){let i=Gg(n,e),s=i&&Xg(r,e);return s?i.map(wu).concat({type:e,attrs:t}).concat(s.map(wu)):null}function wu(n){return{type:n,attrs:null}}function Gg(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Xg(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let a=r;c&&a<i;a++)c=c.matchType(t.child(a).type);return!c||!c.validEnd?null:o}function Zg(n,e,t){let r=x.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=x.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Y(i,s,i,s,new b(r,0,0),t.length,!0))}function Qg(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)&&ey(n.doc,n.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let d=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);d&&!p?a=!1:!d&&p&&(a=!0)}a===!1&&Mu(n,o,l,s),Ll(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let f=n.mapping.slice(s),u=f.map(l,1),h=f.map(l+o.nodeSize,1);return n.step(new Y(u,h,u+1,h-1,new b(x.from(r.create(c,null,o.marks)),0,0),1,!0)),a===!0&&Au(n,o,l,s),!1}})}function Au(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 Mu(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 ey(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function ty(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 Y(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new b(x.from(o),0,0),1,!0))}function bt(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 u=i.node(a),h=i.index(a);if(u.type.spec.isolating)return!1;let d=u.content.cutByIndex(h,u.childCount),p=r&&r[f+1];p&&(d=d.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[f]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(d))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 ny(n,e,t=1,r){let i=n.doc.resolve(e),s=x.empty,o=x.empty;for(let l=i.depth,c=i.depth-t,a=t-1;l>c;l--,a--){s=x.from(i.node(l).copy(s));let f=r&&r[a];o=x.from(f?f.type.create(f.attrs,o):i.node(l).copy(o))}n.step(new xe(e,e,new b(s.append(o),t,t),!0))}function Xt(n,e){let t=n.resolve(e),r=t.index();return iy(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function ry(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 iy(n,e){return!!(n&&e&&!n.isLeaf&&ry(n,e))}function sy(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",u=!!o.contentMatch.matchType(i);f&&!u?r=!1:!f&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let f=n.doc.resolve(e+t);Mu(n,f.node(),f.before(),l)}o.inlineContent&&Ll(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 xe(a,c.map(e+t,-1),b.empty,!0)),r===!0){let f=n.doc.resolve(a);Au(n,f.node(),f.before(),n.steps.length)}return n}function oy(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 Ou(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 u=a.contentMatchAt(c).findWrapping(i.firstChild.type);f=u&&a.canReplaceWith(c,c,u[0])}if(f)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Is(n,e,t=e,r=b.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Du(i,s,r)?new xe(e,t,r):new Ul(i,s,r).fit()}function Du(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Ul=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.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=x.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 b(s,o,l);return e>-1?new Y(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new xe(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=_l(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,u=null;if(t==1&&(o?a.matchType(o.type)||(u=a.fillBefore(x.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:u};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,i=_l(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new b(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=_l(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new b(Jr(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new b(Jr(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:u,type:h}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));u=u.matchFragment(i)}let d=l.size+e-(o.content.size-o.openEnd);for(;a<l.childCount;){let m=l.child(a),g=u.matchType(m.type);if(!g)break;a++,(a>1||c==0||m.content.size)&&(u=g,f.push(Nu(m.mark(h.allowedMarks(m.marks)),a==1?c:0,a==l.childCount?d:-1)))}let p=a==l.childCount;p||(d=-1),this.placed=Wr(this.placed,t,x.from(f)),this.frontier[t].match=u,p&&d<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<d;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?b.empty:new b(Jr(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new b(Jr(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||!Rl(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=Rl(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:c,type:a}=this.frontier[l],f=Rl(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=Wr(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=Wr(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Wr(this.placed,this.frontier.length,t))}};function Jr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Jr(n.firstChild.content,e-1,t)))}function Wr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Wr(n.lastChild.content,e-1,t)))}function _l(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Nu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Nu(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(x.empty,!0)))),n.copy(r)}function Rl(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&&!ly(t,s.content,o)?l:null}function ly(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function cy(n){return n.spec.defining||n.spec.definingForContent}function ay(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Du(i,s,r))return n.step(new xe(e,t,r));let o=_u(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let h=i.depth,d=i.pos-1;h>0;h--,d--){let p=i.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:i.before(h)==d&&o.splice(1,0,-h)}let c=o.indexOf(l),a=[],f=r.openStart;for(let h=r.content,d=0;;d++){let p=h.firstChild;if(a.push(p),d==r.openStart)break;h=p.content}for(let h=f-1;h>=0;h--){let d=a[h],p=cy(d.type);if(p&&!d.sameMarkup(i.node(Math.abs(l)-1)))f=h;else if(p||!d.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let d=(h+f+1)%(r.openStart+1),p=a[d];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 T=i.node(g-1),k=i.index(g-1);if(T.canReplaceWith(k,k,p.type,p.marks))return n.replace(i.before(g),y?s.after(g):t,new b(Iu(r.content,0,r.openStart,d),d,r.openEnd))}}let u=n.steps.length;for(let h=o.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let d=o[h];d<0||(e=i.before(d),t=s.after(d))}}function Iu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Iu(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(x.empty,!0))}return n}function fy(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=oy(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new b(x.from(r),0,0))}function uy(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=_u(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 _u(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 Os=class n extends H{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 Q.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 Q.fromReplace(e,this.pos,this.pos+1,new b(x.from(i),0,t.isLeaf?0:1))}getMap(){return tt.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)}};H.jsonID("attr",Os);var Ds=class n extends H{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 Q.ok(r)}getMap(){return tt.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)}};H.jsonID("docAttr",Ds);var Wn=class extends Error{};Wn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Wn.prototype=Object.create(Error.prototype);Wn.prototype.constructor=Wn;Wn.prototype.name="TransformError";var Ns=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Wn(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=b.empty){let i=Is(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new b(x.from(r),0,0))}delete(e,t){return this.replace(e,t,b.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ay(this,e,t,r),this}replaceRangeWith(e,t,r){return fy(this,e,t,r),this}deleteRange(e,t){return uy(this,e,t),this}lift(e,t){return Yg(this,e,t),this}join(e,t=1){return sy(this,e,t),this}wrap(e,t){return Zg(this,e,t),this}setBlockType(e,t=e,r,i=null){return Qg(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return ty(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Os(e,t,r)),this}setDocAttribute(e,t){return this.step(new Ds(e,t)),this}addNodeMark(e,t){return this.step(new Hr(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 N)t.isInSet(r.marks)&&this.step(new Jn(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Jn(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 ny(this,e,t,r),this}addMark(e,t,r){return jg(this,e,t,r),this}removeMark(e,t,r){return Kg(this,e,t,r),this}clearIncompatible(e,t,r){return Ll(this,e,t,r),this}};var Fl=Object.create(null),E=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Hn(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=b.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?b.empty:t),l==0&&Bu(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),Bu(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new I(e):Kn(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?Kn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Kn(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 Kn(e,e,0,0,1)||new ae(e)}static atEnd(e){return Kn(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=Fl[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 Fl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};E.prototype.visible=!0;var Hn=class{constructor(e,t){this.$from=e,this.$to=t}},Ru=!1;function vu(n){!Ru&&!n.parent.inlineContent&&(Ru=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var I=class n extends E{constructor(e,t=e){vu(e),vu(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 E.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=b.empty){if(super.replace(e,t),t==b.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 Rs(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=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(s)t=s.$head;else return E.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};E.jsonID("text",I);var Rs=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 I.between(e.resolve(this.anchor),e.resolve(this.head))}},w=class n extends E{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?E.near(s):new n(s)}content(){return new b(x.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 zl(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}};w.prototype.visible=!1;E.jsonID("node",w);var zl=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Rs(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&w.isSelectable(r)?new w(t):E.near(t)}},ae=class n extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=b.empty){if(t==b.empty){e.delete(0,e.doc.content.size);let r=E.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 hy}};E.jsonID("all",ae);var hy={map(){return this},resolve(n){return new ae(n)}};function Kn(n,e,t,r,i,s=!1){if(e.inlineContent)return I.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&&w.isSelectable(l))return w.create(n,t-(i<0?l.nodeSize:0))}else{let c=Kn(n,l,t+i,i<0?l.childCount:0,i,s);if(c)return c}t+=l.nodeSize*i}return null}function Bu(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof xe||i instanceof Y))return;let s=n.mapping.maps[r],o;s.forEach((l,c,a,f)=>{o==null&&(o=f)}),n.setSelection(E.near(n.doc.resolve(o),t))}var Uu=1,_s=2,Vu=4,$l=class extends Ns{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|Uu)&~_s,this.storedMarks=null,this}get selectionSet(){return(this.updated&Uu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_s,this}ensureMarks(e){return N.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&_s)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~_s,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)||N.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(E.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|=Vu,this}get scrolledIntoView(){return(this.updated&Vu)>0}};function Lu(n,e){return!e||!n?n:n.bind(e)}var Zt=class{constructor(e,t,r){this.name=e,this.init=Lu(t.init,r),this.apply=Lu(t.apply,r)}},dy=[new Zt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Zt("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new Zt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Zt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Yr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dy.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 Zt(r.key,r.spec.state,r))})}},vs=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 u=0;u<this.config.plugins.length;u++)i.push(u<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 $l(this)}static create(e){let t=new Yr(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 Yr(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 Yr(e.schema,e.plugins),s=new n(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=ze.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=E.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 Fu(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Fu(i,e,{})),t[r]=i}return t}var be=class{constructor(e){this.spec=e,this.props={},e.props&&Fu(e.props,this,this.props),this.key=e.key?e.key.key:Pu("plugin")}getState(e){return e[this.key]}},Pl=Object.create(null);function Pu(n){return n in Pl?n+"$"+ ++Pl[n]:(Pl[n]=0,n+"$")}var wt=class{constructor(e="key"){this.key=Pu(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Zn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Kl=null,rt=function(n,e,t){let r=Kl||(Kl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},py=function(){Kl=null},ln=function(n,e,t,r){return t&&(zu(n,e,t,r,-1)||zu(n,e,t,r,1))},my=/^(img|br|input|textarea|hr)$/i;function zu(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ne(n))){let o=n.parentNode;if(!o||o.nodeType!=1||ii(n)||my.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(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?Ne(n):0}else return!1}}function Ne(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function gy(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=Ne(n)}else if(n.parentNode&&!ii(n))e=ee(n),n=n.parentNode;else return null}}function yy(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&&!ii(n))e=ee(n)+1,n=n.parentNode;else return null}}function xy(n,e,t){for(let r=e==0,i=e==Ne(n);r||i;){if(n==t)return!0;let s=ee(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Ne(n)}}function ii(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 js=function(n){return n.focusNode&&ln(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Qt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function by(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function wy(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ne(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ne(r.startContainer),r.startOffset)}}}var $e=typeof navigator<"u"?navigator:null,$u=typeof document<"u"?document:null,Et=$e&&$e.userAgent||"",Hl=/Edge\/(\d+)/.exec(Et),yh=/MSIE \d/.exec(Et),Yl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Et),we=!!(yh||Yl||Hl),Ct=yh?document.documentMode:Yl?+Yl[1]:Hl?+Hl[1]:0,Ie=!we&&/gecko\/(\d+)/i.test(Et);Ie&&+(/Firefox\/(\d+)/.exec(Et)||[0,0])[1];var Gl=!we&&/Chrome\/(\d+)/.exec(Et),te=!!Gl,xh=Gl?+Gl[1]:0,oe=!we&&!!$e&&/Apple Computer/.test($e.vendor),Qn=oe&&(/Mobile\/\w+/.test(Et)||!!$e&&$e.maxTouchPoints>2),De=Qn||($e?/Mac/.test($e.platform):!1),bh=$e?/Win/.test($e.platform):!1,it=/Android \d/.test(Et),si=!!$u&&"webkitFontSmoothing"in $u.documentElement.style,ky=si?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Sy(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 Cy(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 qu(n,e,t){if(!Xl(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=Zn(o);continue}let l=o,c=l==s.body,a=c?Sy(s):Cy(l),f=0,u=0;if(e.top<a.top+nt(r,"top")?u=-(a.top-e.top+nt(i,"top")):e.bottom>a.bottom-nt(r,"bottom")&&(u=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||u)if(c)s.defaultView.scrollBy(f,u);else{let d=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),f&&(l.scrollLeft+=f);let m=l.scrollLeft-d,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Zn(o)}}function Ty(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:wh(n.dom)}}function wh(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Zn(r));return e}function Ey({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;kh(t,r==0?0:r-e)}function kh(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 Yn=null;function Ay(n){if(n.setActive)return n.setActive();if(Yn)return n.focus(Yn);let e=wh(n);n.focus(Yn==null?{get preventScroll(){return Yn={preventScroll:!0},!0}}:void 0),Yn||(Yn=!1,kh(e,0))}function Sh(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,c,a;for(let f=n.firstChild,u=0;f;f=f.nextSibling,u++){let h;if(f.nodeType==1)h=f.getClientRects();else if(f.nodeType==3)h=rt(f).getClientRects();else continue;for(let d=0;d<h.length;d++){let p=h[d];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=u+(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=u+1)}}return!t&&c&&(t=c,i=a,r=0),t&&t.nodeType==3?My(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Sh(t,i)}function My(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=kt(r,1);if(o.top!=o.bottom&&dc(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 dc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Oy(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Dy(n,e,t){let{node:r,offset:i}=Sh(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 Ny(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 Ch(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(dc(e,a))return Ch(o,e,a)}}if((s=(s+1)%r)==i)break}return n}function Iy(n,e){let t=n.dom.ownerDocument,r,i=0,s=wy(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(!dc(e,a)||(o=Ch(n.dom,e,a),!o))return null}if(oe)for(let a=o;r&&a;a=Zn(a))a.draggable&&(r=void 0);if(o=Oy(o,e),r){if(Ie&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let f=r.childNodes[i],u;f.nodeName=="IMG"&&(u=f.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let a;si&&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=Ny(n,r,i,e))}l==null&&(l=Dy(n,o,e));let c=n.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Xl(n){return n.top<n.bottom||n.left<n.right}function kt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Xl(r))return r}return Array.prototype.find.call(t,Xl)||n.getBoundingClientRect()}var _y=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Th(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=si||Ie;if(r.nodeType==3)if(o&&(_y.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let c=kt(rt(r,i,i),t);if(Ie&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let a=kt(rt(r,i-1,i-1),-1);if(a.top==c.top){let f=kt(rt(r,i,i+1),-1);if(f.top!=c.top)return Gr(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++,Gr(kt(rt(r,c,a),f),f<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Ne(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return ql(c.getBoundingClientRect(),!1)}if(s==null&&i<Ne(r)){let c=r.childNodes[i];if(c.nodeType==1)return ql(c.getBoundingClientRect(),!0)}return ql(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Ne(r))){let c=r.childNodes[i-1],a=c.nodeType==3?rt(c,Ne(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(a)return Gr(kt(a,1),!1)}if(s==null&&i<Ne(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let a=c?c.nodeType==3?rt(c,0,o?0:1):c.nodeType==1?c:null:null;if(a)return Gr(kt(a,-1),!0)}return Gr(kt(r.nodeType==3?rt(r):r,-t),t>=0)}function Gr(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 ql(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 Eh(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 Ry(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Eh(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=Th(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=rt(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 vy=/[\u0590-\u08ac]/;function By(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?!vy.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Eh(n,e,()=>{let{focusNode:c,focusOffset:a,anchorNode:f,anchorOffset:u}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let d=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!d.contains(p.nodeType==1?p:p.parentNode)||c==p&&a==m;try{l.collapse(f,u),c&&(c!=f||a!=u)&&l.extend&&l.extend(c,a)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}var Ju=null,Wu=null,ju=!1;function Uy(n,e,t){return Ju==e&&Wu==t?ju:(Ju=e,Wu=t,ju=t=="up"||t=="down"?Ry(n,e,t):By(n,e,t))}var _e=0,Ku=1,en=2,Ue=3,cn=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=_e,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>ee(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 Vs){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 Bs&&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?ee(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?ee(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 u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=ee(h.dom)+1;break}e-=h.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 u=this.children[f];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=ee(u.dom);break}t+=u.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 d=0,p=0;d<this.children.length;d++){let m=this.children[d],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(),u=!1;if((Ie||oe)&&e==t){let{node:d,offset:p}=l;if(d.nodeType==3){if(u=!!(p&&d.nodeValue[p-1]==` |
| 10 | `),u&&p==d.nodeValue.length)for(let m=d,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=c={node:g.parentNode,offset:ee(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=d.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ie&&f.focusNode&&f.focusNode!=c.node&&f.focusNode.nodeType==1){let d=f.focusNode.childNodes[f.focusOffset];d&&d.contentEditable=="false"&&(i=!0)}if(!(i||u&&oe)&&ln(l.node,l.offset,f.anchorNode,f.anchorOffset)&&ln(c.node,c.offset,f.focusNode,f.focusOffset))return;let h=!1;if((a.extend||e==t)&&!(u&&Ie)){a.collapse(l.node,l.offset);try{e!=t&&a.extend(c.node,c.offset),h=!0}catch{}}if(!h){if(e>t){let p=l;l=c,c=p}let d=document.createRange();d.setEnd(c.node,c.offset),d.setStart(l.node,l.offset),a.removeAllRanges(),a.addRange(d)}}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?en:Ku,e==l&&t==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Ue:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?en:Ue}r=o}this.dirty=en}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?en:Ku;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Bs=class extends cn{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==_e&&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}},Zl=class extends cn{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 cn{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=Ht.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&Ue||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ue&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=_e){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=_e}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=nc(s,t,o,r)),e>0&&(s=nc(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()}},Tt=class n extends cn{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,u=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:u}=Ht.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let h=f;return f=Oh(f,r,t),a?c=new Ql(e,t,r,i,f,u||null,h,a):t.isText?new Us(e,t,r,i,f,h):new n(e,t,r,i,f,u||null,h)}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=()=>x.empty}}return t}matchesNode(e,t,r){return this.dirty==_e&&e.eq(this.node)&&Ls(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 tc(this,o&&o.node,e);Py(this.node,this.innerDeco,(a,f,u)=>{a.spec.marks?c.syncToMarks(a.spec.marks,r,e,f):a.type.side>=0&&!u&&c.syncToMarks(f==this.node.childCount?N.none:this.node.child(f).marks,r,e,f),c.placeWidget(a,e,i)},(a,f,u,h)=>{c.syncToMarks(a.marks,r,e,h);let d;c.findNodeMatch(a,f,u,h)||l&&e.state.selection.from>i&&e.state.selection.to<i+a.nodeSize&&(d=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(a,f,u,d,e)||c.updateNextNode(a,f,u,e,h,i)||c.addNode(a,f,u,e,i),i+=a.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==en)&&(o&&this.protectLocalComposition(e,o),Ah(this.contentDOM,this.children,e),Qn&&zy(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof I)||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=$y(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 Zl(this,s,t,i);e.input.compositionNodes.push(o),this.children=nc(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Ue||!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=_e}updateOuterDeco(e){if(Ls(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Mh(this.dom,this.nodeDOM,ec(this.outerDeco,this.node,t),ec(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 Hu(n,e,t,r,i){Oh(r,e,n);let s=new Tt(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}var Us=class n extends Tt{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==Ue||this.dirty!=_e&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=_e||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=_e,!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=Ue)}get domAtom(){return!1}isText(e){return this.node.text==e}},Vs=class extends cn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==_e&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Ql=class extends Tt{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==Ue)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 Ah(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=Yu(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof nn){let c=r?r.previousSibling:n.lastChild;Ah(o.contentDOM,o.children,t),r=c?c.nextSibling:n.firstChild}}for(;r;)r=Yu(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var Zr=function(n){n&&(this.nodeName=n)};Zr.prototype=Object.create(null);var tn=[new Zr];function ec(n,e,t){if(n.length==0)return tn;let r=t?tn[0]:new Zr,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new Zr(o.nodeName));for(let l in o){let c=o[l];c!=null&&(t&&i.length==1&&i.push(r=new Zr(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 Mh(n,e,t,r){if(t==tn&&r==tn)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=tn[0]),i=c}Vy(i,l||tn[0],o)}return i}function Vy(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 Oh(n,e,t){return Mh(n,n,tn,ec(e,t,n.nodeType!=1))}function Ls(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 Yu(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var tc=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ly(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=_e,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 u=this.top.children[f];if(u.matchesMark(e[o])&&!this.isLocked(u.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!=Ue&&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==Ue&&o.dom==o.contentDOM&&(o.dirty=en),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 Tt){let a=this.preMatch.matched.get(c);if(a!=null&&a!=s)return!1;let f=c.dom,u,h=this.isLocked(f)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Ue&&Ls(t,c.outerDeco));if(!h&&c.update(e,t,r,i))return this.destroyBetween(this.index,l),c.dom!=f&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(c,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=en,u.updateChildren(i,o+1),u.dirty=_e),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)||!Ls(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Tt.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=Tt.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 Bs(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 Us)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((oe||te)&&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 Vs(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 Ly(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 Fy(n,e){return n.type.side-e.type.side}function Py(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,u;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(f?(u||(u=[f])).push(g):f=g)}if(f)if(u){u.sort(Fy);for(let g=0;g<u.length;g++)t(u[g],a,!!c)}else t(f,a,!!c);let h,d;if(c)d=-1,h=c,c=null;else if(a<n.childCount)d=a,h=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+h.nodeSize;if(h.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=h.cut(g-s),h=h.cut(0,g-s),p=g,d=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();r(h,m,e.forChild(s,h),d),s=p}}function zy(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 $y(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 nc(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 pc(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(js(t)){for(c=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&w.isSelectable(u)&&i.parent&&!(u.isInline&&xy(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;a=new w(o==h?l:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,h=o;for(let d=0;d<t.rangeCount;d++){let p=t.getRangeAt(d);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[c,o]=h==n.state.selection.anchor?[h,u]:[u,h],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 u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;a=mc(n,f,l,u)}return a}function Dh(n){return n.editable?n.hasFocus():Ih(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ot(n,e=!1){let t=n.state.selection;if(Nh(n,t),!Dh(n))return;let r=n.input.mouseDown;if(!e&&te&&r){let i=n.domSelectionRange(),s=n.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&ln(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Jy(n);else{let{anchor:i,head:s}=t,o,l;Gu&&!(t instanceof I)&&(t.$from.parent.inlineContent||(o=Xu(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=Xu(n,t.to))),n.docView.setSelection(i,s,n,e),Gu&&(o&&Zu(o),l&&Zu(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&qy(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var Gu=oe||te&&xh<63;function Xu(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(oe&&i&&i.contentEditable=="false")return Jl(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Jl(i);if(s)return Jl(s)}}function Jl(n){return n.contentEditable="true",oe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Zu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function qy(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(()=>{(!Dh(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Jy(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ee(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&we&&Ct<=11&&(t.disabled=!0,t.disabled=!1)}function Nh(n,e){if(e instanceof w){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qu(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qu(n)}function Qu(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function mc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||I.between(e,t,r)}function eh(n){return n.editable&&!n.hasFocus()?!1:Ih(n)}function Ih(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 Wy(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return ln(e.node,e.offset,t.anchorNode,t.anchorOffset)}function rc(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&&E.findFrom(s,e)}function St(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function th(n,e,t){let r=n.state.selection;if(r instanceof I)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 St(n,new I(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=rc(n.state,e);return i&&i instanceof w?St(n,i):!1}else if(!(De&&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?w.isSelectable(s)?St(n,new w(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):si?St(n,new I(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof w&&r.node.isInline)return St(n,new I(e>0?r.$to:r.$from));{let i=rc(n.state,e);return i?St(n,i):!1}}}function Fs(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qr(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Gn(n,e){return e<0?jy(n):Ky(n)}function jy(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ie&&t.nodeType==1&&r<Fs(t)&&Qr(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Qr(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(_h(t))break;{let l=t.previousSibling;for(;l&&Qr(l,-1);)i=t.parentNode,s=ee(l),l=l.previousSibling;if(l)t=l,r=Fs(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?ic(n,t,r):i&&ic(n,i,s)}function Ky(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Fs(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Qr(l,1))s=t,o=++r;else break}else{if(_h(t))break;{let l=t.nextSibling;for(;l&&Qr(l,1);)s=l.parentNode,o=ee(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Fs(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&ic(n,s,o)}function _h(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Hy(n,e){for(;n&&e==n.childNodes.length&&!ii(n);)e=ee(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 Yy(n,e){for(;n&&!e&&!ii(n);)e=ee(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 ic(n,e,t){if(e.nodeType!=3){let s,o;(o=Hy(e,t))?(e=o,t=0):(s=Yy(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(js(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&&ot(n)},50)}function nh(n,e){let t=n.state.doc.resolve(e);if(!(te||bh)&&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 rh(n,e,t){let r=n.state.selection;if(r instanceof I&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=rc(n.state,e);if(o&&o instanceof w)return St(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof ae?E.near(o,e):E.findFrom(o,e);return l?St(n,l):!1}return!1}function ih(n,e){if(!(n.state.selection instanceof I))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 sh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Gy(n){if(!oe||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;sh(n,r,"true"),setTimeout(()=>sh(n,r,"false"),20)}return!1}function Xy(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Zy(n,e){let t=e.keyCode,r=Xy(e);if(t==8||De&&t==72&&r=="c")return ih(n,-1)||Gn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return ih(n,1)||Gn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let i=t==37?nh(n,n.state.selection.from)=="ltr"?-1:1:-1;return th(n,i,r)||Gn(n,i)}else if(t==39||De&&t==70&&r=="c"){let i=t==39?nh(n,n.state.selection.from)=="ltr"?1:-1:1;return th(n,i,r)||Gn(n,i)}else{if(t==38||De&&t==80&&r=="c")return rh(n,-1,r)||Gn(n,-1);if(t==40||De&&t==78&&r=="c")return Gy(n)||rh(n,1,r)||Gn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function gc(n,e){n.someProp("transformCopied",d=>{e=d(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 d=r.firstChild;t.push(d.type.name,d.attrs!=d.type.defaultAttrs?d.attrs:null),r=d.content}let o=n.someProp("clipboardSerializer")||Ht.fromSchema(n.state.schema),l=Lh(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let a=c.firstChild,f,u=0;for(;a&&a.nodeType==1&&(f=Vh[a.nodeName.toLowerCase()]);){for(let d=f.length-1;d>=0;d--){let p=l.createElement(f[d]);for(;c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p),u++}a=c.firstChild}a&&a.nodeType==1&&a.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",d=>d(e,n))||e.content.textBetween(0,e.content.size,` |
| 11 | |
| 12 | `);return{dom:c,text:h,slice:e}}function Rh(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",h=>{e=h(e,s||r,n)}),s)return l=new b(x.from(n.state.schema.text(e.replace(/\r\n?/g,` |
| 13 | `))),0,0),n.someProp("transformPasted",h=>{l=h(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(u)l=u;else{let h=i.marks(),{schema:d}=n.state,p=Ht.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=n0(t),si&&r0(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 u=+f[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||$r.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||f),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Qy.test(h.parentNode.nodeName)?{ignore:!0}:null}})),f)l=i0(oh(l,+f[1],+f[2]),f[4]);else if(l=b.maxOpen(e0(l.content,i),!0),l.openStart||l.openEnd){let u=0,h=0;for(let d=l.content.firstChild;u<l.openStart&&!d.type.spec.isolating;u++,d=d.firstChild);for(let d=l.content.lastChild;h<l.openEnd&&!d.type.spec.isolating;h++,d=d.lastChild);l=oh(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n,c)}),l}var Qy=/^(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 e0(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&&Bh(c,s,l,o[o.length-1],0))o[o.length-1]=a;else{o.length&&(o[o.length-1]=Uh(o[o.length-1],s.length));let f=vh(l,c);o.push(f),i=i.matchType(f.type),s=c}}),o)return x.from(o)}return n}function vh(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Bh(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Bh(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(x.from(vh(t,n,i+1))))}}function Uh(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Uh(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function sc(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=sc(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(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function oh(n,e,t){return e<n.openStart&&(n=new b(sc(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new b(sc(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Vh={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 Lh(){return document.implementation.createHTMLDocument("title")}var Xr=null;function t0(n){let e=window.trustedTypes;if(!e)return n;if(!Xr){if(Xr=e.defaultPolicy)try{return Xr.createHTML(n)}catch{}Xr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Xr.createHTML(n)}function n0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Lh(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&Vh[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=t0(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 u=0;u<f.length;u++)f[u].style.cssText+=a.style.cssText}}}return r}function r0(n){let e=n.querySelectorAll(te?"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 i0(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=x.from(c.create(r[l+1],i)),s++,o++}return new b(i,s,o)}var fe={},ue={},s0={touchstart:!0,touchmove:!0},oc=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 o0(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{c0(n,r)&&!yc(n,r)&&(n.editable||!(r.type in ue))&&t(n,r)},s0[e]?{passive:!0}:void 0)}oe&&n.dom.addEventListener("input",()=>null),lc(n)}function st(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function l0(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 lc(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>yc(n,r))})}function yc(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function c0(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 a0(n,e){!yc(n,e)&&fe[e.type]&&(n.editable||!(e.type in ue))&&fe[e.type](n,e)}ue.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!zh(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(it&&te&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Qn&&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,Qt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Zy(n,t)?t.preventDefault():st(n,"key")};ue.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ue.keypress=(n,e)=>{let t=e;if(zh(n)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!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 oi(n){return{left:n.clientX,top:n.clientY}}function f0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function xc(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 li(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 u0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&w.isSelectable(r)?(li(n,new w(t),"pointer"),!0):!1}function h0(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof w&&(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(w.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?(li(n,w.create(n.state.doc,i),"pointer"),!0):!1}function d0(n,e,t,r,i){return xc(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?h0(n,t):u0(n,t))}function p0(n,e,t,r){return xc(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function m0(n,e,t,r){return xc(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||g0(n,t,r)}function g0(n,e,t){if(t.button!=0)return!1;let r=Fh(n,e,!0),i=n.state.doc;return r?(li(n,r,"pointer"),r instanceof I&&i.eq(n.state.doc)&&(n.input.mouseDown=new ac(n,r)),!0):!1}function Fh(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?I.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 I.create(r,l+1,l+1+o.content.size);if(t&&w.isSelectable(o))return w.create(r,l)}return null}function bc(n){return zs(n)}var Ph=De?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=bc(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&f0(t,n.input.lastClick)&&!t[Ph]&&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(oi(t));o&&(s=="singleClick"?n.input.mouseDown=new cc(n,o,t,!!r):(s=="doubleClick"?p0:m0)(n,o.pos,o.inside,t)?t.preventDefault():st(n,"pointer"))};var Ps=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}},cc=class extends Ps{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[Ph],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 w&&a.from<=o&&a.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!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()),st(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||ot(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(oi(e))),this.updateAllowDefault(e),this.allowDefault||!t?st(this.view,"pointer"):d0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||oe&&this.mightDrag&&!this.mightDrag.node.isAtom||te&&!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)?(li(this.view,E.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):st(this.view,"pointer")}move(e){this.updateAllowDefault(e),st(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}},ac=class extends Ps{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(),st(this.view,"pointer");let t=this.view.posAtCoords(oi(e)),r=t&&Fh(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];li(this.view,I.create(i,o,l),"pointer")}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),bc(n),st(n,"pointer")};fe.touchmove=n=>{n.input.lastTouch=Date.now(),st(n,"pointer")};fe.contextmenu=n=>bc(n);function zh(n,e){return n.composing?!0:oe&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var y0=it?5e3:-1;ue.compositionstart=ue.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||te&&bh&&x0(n)))n.markCursor=n.state.storedMarks||t.marks(),zs(n,!0),n.markCursor=null;else if(zs(n,!e.selection.empty),Ie&&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}$h(n,y0)};function x0(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"}ue.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++,$h(n,20))};function $h(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>zs(n),e))}function qh(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function b0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=gy(e.focusNode,e.focusOffset),r=yy(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 zs(n,e=!1){if(!(it&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),qh(n),e||n.docView&&n.docView.dirty){let t=pc(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 w0(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 ei=we&&Ct<15||Qn&&ky<604;fe.copy=ue.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=ei?null:t.clipboardData,o=r.content(),{dom:l,text:c}=gc(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):w0(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function k0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function S0(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?ti(n,r.value,null,i,e):ti(n,r.textContent,r.innerHTML,i,e)},50)}function ti(n,e,t,r,i){let s=Rh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,s||b.empty)))return!0;if(!s)return!1;let o=k0(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 Jh(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," "):""}ue.paste=(n,e)=>{let t=e;if(n.composing&&!it)return;let r=ei?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ti(n,Jh(r),r.getData("text/html"),i,t)?t.preventDefault():S0(n,t)};var $s=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},C0=De?"altKey":"ctrlKey";function Wh(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[C0]}fe.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(oi(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof w?i.to-1:i.to))){if(r&&r.mightDrag)o=w.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=w.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:a,slice:f}=gc(n,l);(!t.dataTransfer.files.length||!te||xh>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ei?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",ei||t.dataTransfer.setData("text/plain",a),n.dragging=new $s(f,Wh(n,t),o)};fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ue.dragover=ue.dragenter=(n,e)=>e.preventDefault();ue.drop=(n,e)=>{try{T0(n,e,n.dragging)}finally{n.dragging=null}};function T0(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(oi(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",d=>{s=d(s,n,!1)}):s=Rh(n,Jh(e.dataTransfer),ei?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Wh(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||b.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Ou(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(o){let{node:d}=t;d?d.replace(c):c.deleteSelection()}let a=c.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=c.doc;if(f?c.replaceRangeWith(a,a,s.content.firstChild):c.replaceRange(a,a,s),c.doc.eq(u))return;let h=c.doc.resolve(a);if(f&&w.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new w(h));else{let d=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),c.setSelection(mc(n,h,c.doc.resolve(d)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}fe.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())&&ot(n)},20))};fe.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)};fe.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,Qt(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 ue)fe[n]=ue[n];function ni(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 qs=class n{constructor(e,t){this.toDOM=e,this.spec=t||sn,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 qe(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&&ni(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},rn=class n{constructor(e,t){this.attrs=e,this.spec=t||sn}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 qe(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&ni(this.attrs,e.attrs)&&ni(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},fc=class n{constructor(e,t){this.attrs=e,this.spec=t||sn}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 qe(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&&ni(this.attrs,e.attrs)&&ni(this.spec,e.spec)}destroy(){}},qe=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 qs(t,r))}static inline(e,t,r,i){return new n(e,t,new rn(r,i))}static node(e,t,r,i){return new n(e,t,new fc(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof rn}get widget(){return this.type instanceof qs}},Xn=[],sn={},se=class n{constructor(e,t){this.local=e.length?e:Xn,this.children=t.length?t:Xn}static create(e,t){return t.length?Ws(t,e,0,sn):ie}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==ie||e.maps.length==0?this:this.mapInner(e,t,0,0,r||sn)}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?E0(this.children,o||[],e,t,r,i,s):o?new n(o.sort(on),Xn):ie}add(e,t){return t.length?this==ie?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=Kh(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,Ws(f,l,a+1,sn)),s+=3}});let o=jh(s?Hh(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(on):this.local,i||this.children)}remove(e){return e.length==0||this==ie?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,u;f<e.length;f++)(u=e[f])&&u.from>l&&u.to<c&&(e[f]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let a=r[s+2].removeInner(o,l+1);a!=ie?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):ie}forChild(e,t){if(this==ie)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 rn){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(on),Xn);return r?new Js([l,r]):l}return r||ie}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 wc(this.localsInner(e))}localsInner(e){if(this==ie)return Xn;if(e.inlineContent||!this.local.some(rn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof rn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};se.empty=new se([],[]);se.removeOverlap=wc;var ie=se.empty,Js=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,sn));return n.from(r)}forChild(e,t){if(t.isLeaf)return se.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ie&&(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?wc(r?t:t.sort(on)):Xn}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new n(e.every(t=>t instanceof se)?e:e.reduce((t,r)=>t.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function E0(n,e,t,r,i,s,o){let l=n.slice();for(let a=0,f=s;a<t.maps.length;a++){let u=0;t.maps[a].forEach((h,d,p,m)=>{let g=m-p-(d-h);for(let y=0;y<l.length;y+=3){let T=l[y+1];if(T<0||h>T+f-u)continue;let k=l[y]+f-u;d>=k?l[y+1]=h<=k?-2:-1:h>=f&&g&&(l[y]+=g,l[y+1]+=g)}u+=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),u=f-i;if(u<0||u>=r.content.size){c=!0;continue}let h=t.map(n[a+1]+s,-1),d=h-i,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==d){let y=l[a+2].mapInner(t,g,f+1,n[a]+s+1,o);y!=ie?(l[a]=u,l[a+1]=d,l[a+2]=y):(l[a+1]=-2,c=!0)}else c=!0}if(c){let a=A0(l,n,e,t,i,s,o),f=Ws(a,r,0,o);e=f.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<f.children.length;u+=3){let d=f.children[u];for(;h<l.length&&l[h]<d;)h+=3;l.splice(h,0,f.children[u],f.children[u+1],f.children[u+2])}}return new se(e.sort(on),l)}function jh(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 qe(i.from+e,i.to+e,i.type))}return t}function A0(n,e,t,r,i,s,o){function l(c,a){for(let f=0;f<c.local.length;f++){let u=c.local[f].map(r,i,a);u?t.push(u):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 Kh(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 Hh(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ws(n,e,t,r){let i=[],s=!1;e.forEach((l,c)=>{let a=Kh(n,l,c+t);if(a){s=!0;let f=Ws(a,l,t+c+1,r);f!=ie&&i.push(c,c+l.nodeSize,f)}});let o=jh(s?Hh(n):n,-t).sort(on);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 se(o,i):ie}function on(n,e){return n.from-e.from||n.to-e.to}function wc(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),lh(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),lh(e,i,r.copy(s.from,r.to)));break}}}return e}function lh(n,e,t){for(;e<n.length&&on(t,n[e])>0;)e++;n.splice(e,0,t)}function Wl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ie&&e.push(r)}),n.cursorWrapper&&e.push(se.create(n.state.doc,[n.cursorWrapper.deco])),Js.from(e)}var M0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},O0=we&&Ct<=11,uc=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}},hc=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new uc,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]);we&&Ct<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():oe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),O0&&(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,M0)),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(eh(this.view)){if(this.suppressingSelectionUpdates)return ot(this.view);if(we&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ln(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=Zn(s))t.add(s);for(let s=e.anchorNode;s;s=Zn(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)&&eh(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let f=0;f<t.length;f++){let u=this.registerMutation(t[f],c);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(c.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||te&&(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 u=f.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){f.parentNode.removeChild(f);break}u=u.firstChild}}}else if(Ie&&c.length){let f=c.filter(u=>u.nodeName=="BR");if(f.length==2){let[u,h]=f;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of f){let d=h.parentNode;d&&d.nodeName=="LI"&&(!u||I0(e,u)!=d)&&h.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&&js(r)&&(a=pc(e))&&a.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ot(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),D0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,_0(e,c)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ot(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 u=e.addedNodes[f];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}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(we&&Ct<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:u,nextSibling:h}=e.addedNodes[f];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let o=i&&i.parentNode==e.target?ee(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?ee(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})}},ch=new WeakMap,ah=!1;function D0(n){if(!ch.has(n)&&(ch.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,ah)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."),ah=!0}}function fh(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return ln(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function N0(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return fh(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?fh(n,t):null}function I0(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 _0(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 R0(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:c}=n.docView.parseRange(e,t),a=n.domSelectionRange(),f,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(f=[{node:u,offset:a.anchorOffset}],js(a)||f.push({node:a.focusNode,offset:a.focusOffset})),te&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let T=i.childNodes[y-1],k=T.pmViewDesc;if(T.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let h=n.state.doc,d=n.someProp("domParser")||$r.fromSchema(n.state.schema),p=h.resolve(l),m=null,g=d.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:v0(r),context:p});if(f&&f[0].pos!=null){let y=f[0].pos,T=f[1]&&f[1].pos;T==null&&(T=y),m={anchor:y+l,head:T+l}}return{doc:g,sel:m,from:l,to:c}}var v0=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(oe&&/^(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||oe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},B0=/^(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 U0(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,V=pc(n,M);if(V&&!n.state.selection.eq(V)){if(te&&it&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",ir=>ir(n,Qt(13,"Enter"))))return;let G=n.state.tr.setSelection(V);M=="pointer"?G.setMeta("pointer",!0):M=="key"&&G.scrollIntoView(),s&&G.setMeta("composition",s),n.dispatch(G)}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=R0(n,e,t,i),f=n.state.doc,u=f.slice(a.from,a.to),h,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,d="end"):(h=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=F0(u.content,a.doc.content,a.from,h,d);if(p&&n.input.domChangeCount++,(Qn&&n.input.lastIOSEnter>Date.now()-225||it)&&i.some(M=>M.nodeType==1&&!B0.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,Qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&c instanceof I&&!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 M=uh(n,n.state.doc,a.sel);if(M&&!M.eq(n.state.selection)){let V=n.state.tr.setSelection(M);s&&V.setMeta("composition",s),n.dispatch(V)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof I&&(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)),we&&Ct<=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),T=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Qn&&n.input.lastIOSEnter>Date.now()-225&&(!T||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!T&&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",M=>M(n,Qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&L0(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Qt(8,"Backspace")))){it&&te&&n.domObserver.suppressSelectionUpdates();return}te&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),it&&!T&&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(M){return M(n,Qt(13,"Enter"))})},20));let k=p.start,_=p.endA,U=M=>{let V=M||n.state.tr.replace(k,_,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let G=uh(n,V.doc,a.sel);G&&!(te&&n.composing&&G.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(G.head==k||G.head==V.mapping.map(_)-1)||we&&G.empty&&G.head==k)&&V.setSelection(G)}return s&&V.setMeta("composition",s),V.scrollIntoView()},Ot;if(T)if(m.pos==g.pos){we&&Ct<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ot(n),20));let M=U(n.state.tr.delete(k,_)),V=f.resolve(p.start).marksAcross(f.resolve(p.endA));V&&M.ensureMarks(V),n.dispatch(M)}else if(p.endA==p.endB&&(Ot=V0(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let M=U(n.state.tr);Ot.type=="add"?M.addMark(k,_,Ot.mark):M.removeMark(k,_,Ot.ma |