@richscripts/richtexteditor 2.6.3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/angular/component.ts +16 -3
- package/integrations/shared.js +27 -0
- package/package.json +2 -2
- package/react/index.d.ts +7 -0
- package/react/index.js +25 -3
- package/richtexteditor/CHANGELOG.md +87 -0
- package/richtexteditor/all_plugins.js +721 -53
- package/richtexteditor/all_plugins.min.js +59 -59
- package/richtexteditor/lang/rte-lang-de.js +96 -0
- package/richtexteditor/lang/rte-lang-zh-Hans.js +181 -0
- package/richtexteditor/lang/rte-lang-zh-Hant.js +181 -0
- package/richtexteditor/plugins/all_plugins.js +721 -53
- package/richtexteditor/plugins/all_plugins.min.js +59 -59
- package/richtexteditor/plugins/comments.js +11 -1
- package/richtexteditor/plugins/crdt-engine.js +244 -17
- package/richtexteditor/plugins/crdt-engine.min.js +5 -5
- package/richtexteditor/plugins/documentimport.js +31 -13
- package/richtexteditor/plugins/docxexport.js +31 -0
- package/richtexteditor/plugins/inlinecode.js +270 -0
- package/richtexteditor/plugins/insertcode.js +2 -2
- package/richtexteditor/plugins/pdfexport.js +25 -2
- package/richtexteditor/plugins/readabilitystats.js +6 -11
- package/richtexteditor/plugins/sanitizer.js +136 -10
- package/richtexteditor/plugins/shadowdom.js +11 -1
- package/richtexteditor/plugins/slashcommand.js +78 -7
- package/richtexteditor/plugins/wordexport.js +3 -1
- package/richtexteditor/plugins/yjscollab.js +116 -5
- package/richtexteditor/rte-webcomponent.js +15 -0
- package/richtexteditor/rte.js +15 -3
- package/richtexteditor/rte_theme_default.css +13 -4
- package/richtexteditor/rte_theme_default.min.css +1 -1
- package/vue/index.js +12 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";(()=>{var Us=Object.defineProperty;var qi=(e,t,n)=>t in e?Us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ds=(e,t)=>{for(var n in t)Us(e,n,{get:t[n],enumerable:!0})};var rn=(e,t,n)=>qi(e,typeof t!="symbol"?t+"":t,n);var Cs={};Ds(Cs,{BLOCK_TAGS:()=>xs,INLINE_MARK_TAGS:()=>bs,LEAF_TAGS:()=>ks,LOCAL_ORIGIN:()=>at,SUPPORTED_MARKS:()=>Ci,attachAwareness:()=>Pi,attachCollab:()=>Xi,attachCrdtBinding:()=>rr,attachUndoManager:()=>$i,captureSelection:()=>er,classify:()=>Tt,htmlToYFragment:()=>Gi,renderFragmentToHost:()=>nn,renderYNodeToDom:()=>tr,restoreSelection:()=>nr});var at=Symbol.for("rte.crdt.local");var Jt={};Ds(Jt,{AbsolutePosition:()=>Fn,AbstractConnector:()=>Xr,AbstractStruct:()=>ke,AbstractType:()=>_,Array:()=>Pt,ContentAny:()=>Ct,ContentBinary:()=>Gt,ContentDeleted:()=>Se,ContentDoc:()=>qt,ContentEmbed:()=>gt,ContentFormat:()=>C,ContentJSON:()=>tn,ContentString:()=>et,ContentType:()=>Q,Doc:()=>At,GC:()=>$,ID:()=>ht,Item:()=>S,Map:()=>Xt,PermanentUserData:()=>qr,RelativePosition:()=>xe,Skip:()=>R,Snapshot:()=>Ge,Text:()=>be,Transaction:()=>Yn,UndoManager:()=>qe,UpdateDecoderV1:()=>X,UpdateDecoderV2:()=>j,UpdateEncoderV1:()=>ct,UpdateEncoderV2:()=>J,XmlElement:()=>O,XmlFragment:()=>pt,XmlHook:()=>Qe,XmlText:()=>K,YArrayEvent:()=>Pn,YEvent:()=>Ht,YMapEvent:()=>Xn,YTextEvent:()=>Gn,YXmlEvent:()=>qn,applyUpdate:()=>Sl,applyUpdateV2:()=>Kn,cleanupYTextFormatting:()=>bi,compareIDs:()=>Bt,compareRelativePositions:()=>Ml,convertUpdateFormatV1ToV2:()=>na,convertUpdateFormatV2ToV1:()=>ri,createAbsolutePositionFromRelativePosition:()=>ds,createDeleteSet:()=>Jn,createDeleteSetFromStructStore:()=>ns,createDocFromSnapshot:()=>Yl,createID:()=>x,createRelativePositionFromJSON:()=>Il,createRelativePositionFromTypeIndex:()=>ls,createSnapshot:()=>hs,decodeRelativePosition:()=>us,decodeSnapshot:()=>Bl,decodeSnapshotV2:()=>Po,decodeStateVector:()=>os,decodeUpdate:()=>Jl,decodeUpdateV2:()=>Wo,diffUpdate:()=>Ql,diffUpdateV2:()=>fs,emptySnapshot:()=>Fl,encodeRelativePosition:()=>as,encodeSnapshot:()=>Vl,encodeSnapshotV2:()=>Ho,encodeStateAsUpdate:()=>Al,encodeStateAsUpdateV2:()=>$o,encodeStateVector:()=>Tl,encodeStateVectorFromUpdate:()=>Kl,encodeStateVectorFromUpdateV2:()=>Qo,equalDeleteSets:()=>Bo,equalSnapshots:()=>Rl,findIndexSS:()=>Z,findRootTypeKey:()=>cs,getItem:()=>Ft,getItemCleanEnd:()=>Kr,getItemCleanStart:()=>F,getState:()=>E,getTypeChildren:()=>ia,isDeleted:()=>zt,isParentOf:()=>Xe,iterateDeletedStructs:()=>$t,logType:()=>Ul,logUpdate:()=>zl,logUpdateV2:()=>Ko,mergeDeleteSets:()=>Yt,mergeUpdates:()=>Zo,mergeUpdatesV2:()=>Je,obfuscateUpdate:()=>ta,obfuscateUpdateV2:()=>ea,parseUpdateMeta:()=>Wl,parseUpdateMetaV2:()=>ti,readUpdate:()=>kl,readUpdateV2:()=>ss,relativePositionToJSON:()=>Dl,snapshot:()=>$l,snapshotContainsUpdate:()=>Hl,transact:()=>k,tryGc:()=>Gl,typeListToArraySnapshot:()=>ca,typeMapGetAllSnapshot:()=>gi,typeMapGetSnapshot:()=>ua});var A=()=>new Map,sn=e=>{let t=A();return e.forEach((n,r)=>{t.set(r,n)}),t},B=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Is=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},Ns=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var nt=()=>new Set;var on=e=>e[e.length-1];var vs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},tt=Array.from,cn=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},_e=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var Os=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var ut=Array.isArray;var Kt=class{constructor(){this._observers=A()}on(t,n){return B(this._observers,t,nt).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return tt((this._observers.get(t)||A()).values()).forEach(r=>r(...n))}destroy(){this._observers=A()}},ln=class{constructor(){this._observers=A()}on(t,n){B(this._observers,t,nt).add(n)}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return tt((this._observers.get(t)||A()).values()).forEach(r=>r(...n))}destroy(){this._observers=A()}};var L=Math.floor;var Dt=Math.abs;var an=(e,t)=>e<t?e:t,dt=(e,t)=>e>t?e:t,fu=Number.isNaN;var un=e=>e!==0?e<0:1/e<0;var Zt=Number.MAX_SAFE_INTEGER,ir=Number.MIN_SAFE_INTEGER,pu=1<<31;var Ls=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&L(e)===e),gu=Number.isNaN,mu=Number.parseInt;var lr=String.fromCharCode,zi=String.fromCodePoint,wu=lr(65535),Ji=e=>e.toLowerCase(),Ki=/^\s*/g,Wi=e=>e.replace(Ki,""),Zi=/([A-Z])/g,ar=(e,t)=>Wi(e.replace(Zi,n=>`${t}${Ji(n)}`));var Qi=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},te=typeof TextEncoder!="undefined"?new TextEncoder:null,tc=e=>te.encode(e),Ms=te?tc:Qi;var Qt=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Qt&&Qt.decode(new Uint8Array).length===1&&(Qt=null);var dn=(e,t)=>Os(t,()=>e).join("");var It=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},vt=()=>new It;var ec=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var G=e=>{let t=new Uint8Array(ec(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},nc=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(dt(n,t)*2),e.cpos=0)},I=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var se=I;var m=(e,t)=>{for(;t>127;)I(e,128|127&t),t=L(t/128);I(e,127&t)},De=(e,t)=>{let n=un(t);for(n&&(t=-t),I(e,(t>63?128:0)|(n?64:0)|63&t),t=L(t/64);t>0;)I(e,(t>127?128:0)|127&t),t=L(t/128)},ur=new Uint8Array(3e4),rc=ur.length/3,sc=(e,t)=>{if(t.length<rc){let n=te.encodeInto(t,ur).written||0;m(e,n);for(let r=0;r<n;r++)I(e,ur[r])}else H(e,Ms(t))},oc=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;m(e,r);for(let s=0;s<r;s++)I(e,n.codePointAt(s))},mt=te&&te.encodeInto?sc:oc;var $s=(e,t)=>oe(e,G(t)),oe=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=an(n-r,t.length),o=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,o>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(dt(n*2,o)),e.cbuf.set(t.subarray(s)),e.cpos=o)},H=(e,t)=>{m(e,t.byteLength),oe(e,t)},dr=(e,t)=>{nc(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ic=(e,t)=>dr(e,4).setFloat32(0,t,!1),cc=(e,t)=>dr(e,8).setFloat64(0,t,!1),lc=(e,t)=>dr(e,8).setBigInt64(0,t,!1);var Vs=new DataView(new ArrayBuffer(4)),ac=e=>(Vs.setFloat32(0,e),Vs.getFloat32(0)===e),ne=(e,t)=>{switch(typeof t){case"string":I(e,119),mt(e,t);break;case"number":Ls(t)&&Dt(t)<=2147483647?(I(e,125),De(e,t)):ac(t)?(I(e,124),ic(e,t)):(I(e,123),cc(e,t));break;case"bigint":I(e,122),lc(e,t);break;case"object":if(t===null)I(e,126);else if(ut(t)){I(e,117),m(e,t.length);for(let n=0;n<t.length;n++)ne(e,t[n])}else if(t instanceof Uint8Array)I(e,116),H(e,t);else{I(e,118);let n=Object.keys(t);m(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];mt(e,s),ne(e,t[s])}}break;case"boolean":I(e,t?120:121);break;default:I(e,127)}},Ue=class extends It{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&m(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var Bs=e=>{e.count>0&&(De(e.encoder,e.count===1?e.s:-e.s),e.count>1&&m(e.encoder,e.count-2))},Nt=class{constructor(){this.encoder=new It,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Bs(this),this.count=1,this.s=t)}toUint8Array(){return Bs(this),G(this.encoder)}};var Fs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);De(e.encoder,t),e.count>1&&m(e.encoder,e.count-2)}},re=class{constructor(){this.encoder=new It,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Fs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Fs(this),G(this.encoder)}},hn=class{constructor(){this.sarr=[],this.s="",this.lensE=new Nt}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new It;return this.sarr.push(this.s),this.s="",mt(t,this.sarr.join("")),oe(t,this.lensE.toUint8Array()),G(t)}};var q=e=>new Error(e),z=()=>{throw q("Method unimplemented")},N=()=>{throw q("Unexpected case")};var Ys=q("Unexpected end of array"),js=q("Integer out of Range"),ie=class{constructor(t){this.arr=t,this.pos=0}},M=e=>new ie(e),fr=e=>e.pos!==e.arr.length;var dc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},P=e=>dc(e,b(e));var Ot=e=>e.arr[e.pos++];var b=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>Zt)throw js}throw Ys},Ne=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*n;let o=e.arr.length;for(;e.pos<o;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>Zt)throw js}throw Ys};var hc=e=>{let t=b(e);if(t===0)return"";{let n=String.fromCodePoint(Ot(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ot(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},fc=e=>Qt.decode(P(e)),yt=Qt?fc:hc;var pr=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},pc=e=>pr(e,4).getFloat32(0,!1),gc=e=>pr(e,8).getFloat64(0,!1),mc=e=>pr(e,8).getBigInt64(0,!1);var wc=[e=>{},e=>null,Ne,pc,gc,mc,e=>!1,e=>!0,yt,e=>{let t=b(e),n={};for(let r=0;r<t;r++){let s=yt(e);n[s]=ce(e)}return n},e=>{let t=b(e),n=[];for(let r=0;r<t;r++)n.push(ce(e));return n},P],ce=e=>wc[127-Ot(e)](e),Ie=class extends ie{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),fr(this)?this.count=b(this)+1:this.count=-1),this.count--,this.s}};var Lt=class extends ie{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ne(this);let t=un(this.s);this.count=1,t&&(this.s=-this.s,this.count=b(this)+2)}return this.count--,this.s}};var le=class extends ie{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Ne(this),n=t&1;this.diff=L(t/2),this.count=1,n&&(this.count=b(this)+2)}return this.s+=this.diff,this.count--,this.s}},fn=class{constructor(t){this.decoder=new Lt(t),this.str=yt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var bu=crypto.subtle,Hs=crypto.getRandomValues.bind(crypto);var gr=()=>Hs(new Uint32Array(1))[0];var xc="10000000-1000-4000-8000"+-1e11,Ps=()=>xc.replace(/[018]/g,e=>(e^gr()&15>>e/4).toString(16));var xt=Date.now;var wr=e=>new Promise(e);var Eu=Promise.all.bind(Promise);var yr=e=>e===void 0?null:e;var xr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},Xs=new xr,Ec=!0;try{typeof localStorage!="undefined"&&localStorage&&(Xs=localStorage,Ec=!1)}catch(e){}var Gs=Xs;var Mt=Symbol("Equality"),pn=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[Mt])!=null&&n.call(e,t))||!1};var qs=e=>typeof e=="object",zs=Object.assign,_c=Object.keys;var Js=(e,t)=>{for(let n in e)t(e[n],n)};var ve=e=>_c(e).length;var Ks=e=>{for(let t in e)return!1;return!0},ae=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Oe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),kr=(e,t)=>e===t||ve(e)===ve(t)&&ae(e,(n,r)=>(n!==void 0||Oe(t,r))&&pn(t[r],n)),Cc=Object.freeze,Sr=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&Sr(e[t])}return Cc(e)};var Le=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Le(e,t,n+1)}};var Ar=e=>e;var Rt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Mt]!=null)return e[Mt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Rt(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(ve(e)!==ve(t))return!1;for(let n in e)if(!Oe(e,n)||!Rt(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Rt(e[n],t[n]))return!1;break;default:return!1}return!0},Ws=(e,t)=>t.includes(e);var Me=typeof process!="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var Au=typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1,rt,Tc=[],Uc=()=>{if(rt===void 0)if(Me){rt=A();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&rt.set(t,""),t=r):t!==null?(rt.set(t,r),t=null):Tc.push(r)}t!==null&&rt.set(t,"")}else typeof location=="object"?(rt=A(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");rt.set(`--${ar(t,"-")}`,n),rt.set(`-${ar(t,"-")}`,n)}})):rt=A();return rt},_r=e=>Uc().has(e);var Re=e=>Me?yr(process.env[e.toUpperCase().replaceAll("-","_")]):yr(Gs.getItem(e));var Zs=e=>_r("--"+e)||Re(e)!==null,Qs=Zs("production"),Dc=Me&&Ws(process.env.FORCE_COLOR,["true","1","2"]),to=Dc||!_r("--no-colors")&&!Zs("no-color")&&(!Me||process.stdout.isTTY)&&(!Me||_r("--color")||Re("COLORTERM")!==null||(Re("TERM")||"").includes("color"));var Ic=e=>new Uint8Array(e);var eo=e=>{let t=Ic(e.byteLength);return t.set(e),t};var Tr=class{constructor(t,n){this.left=t,this.right=n}},st=(e,t)=>new Tr(e,t);var Ur=e=>e.next()>=.5,mn=(e,t,n)=>L(e.next()*(n+1-t)+t);var Dr=(e,t,n)=>L(e.next()*(n+1-t)+t);var Ir=(e,t,n)=>Dr(e,t,n);var Oc=e=>lr(Ir(e,97,122)),no=(e,t=0,n=20)=>{let r=Ir(e,t,n),s="";for(let o=0;o<r;o++)s+=Oc(e);return s};var wn=(e,t)=>t[Ir(e,0,t.length-1)];var Mc=Symbol("0schema"),Nr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(dn(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
-
`)}},
|
|
3
|
-
${n.toString()}`)},Rr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Fe(t),h:n}),this}else(t){return this.if(Cn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw q("Unhandled pattern")}}},el=e=>new Rr(e),po=el(Cn).if(uo,(e,t)=>mn(t,ir,Zt)).if(ho,(e,t)=>no(t)).if(Zc,(e,t)=>Ur(t)).if(Wc,(e,t)=>BigInt(mn(t,ir,Zt))).if(_n,(e,t)=>ue(t,wn(t,e.shape))).if($c,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Bc.check(s)){if(Ur(t))continue;s=s.shape}n[r]=po(s,t)}return n}).if(Pc,(e,t)=>{let n=[],r=Dr(t,0,42);for(let s=0;s<r;s++)n.push(ue(t,e.shape));return n}).if(so,(e,t)=>wn(t,e.shape)).if(Qc,(e,t)=>null).if(zc,(e,t)=>{let n=ue(t,e.res);return()=>n}).if(Kc,(e,t)=>ue(t,wn(t,[he,pe,In,fo,Vr,Dn,co(he),io(ge("a","b","c"),he)]))).if(jc,(e,t)=>{let n={},r=mn(t,0,3);for(let s=0;s<r;s++){let o=ue(t,e.shape.keys),i=ue(t,e.shape.values);n[o]=i}return n}).done(),ue=(e,t)=>po(Fe(t),e);var Vt=typeof document!="undefined"?document:{};var Yu=D(e=>e.nodeType===il);var ju=typeof DOMParser!="undefined"?new DOMParser:null;var Hu=D(e=>e.nodeType===rl);var Pu=D(e=>e.nodeType===sl);var go=e=>Is(e,(t,n)=>`${n}:${t};`).join("");var rl=Vt.ELEMENT_NODE,sl=Vt.TEXT_NODE,Xu=Vt.CDATA_SECTION_NODE,Gu=Vt.COMMENT_NODE,ol=Vt.DOCUMENT_NODE,qu=Vt.DOCUMENT_TYPE_NODE,il=Vt.DOCUMENT_FRAGMENT_NODE,zu=D(e=>e.nodeType===ol);var ot=Symbol;var $e=ot(),Ye=ot(),Br=ot(),Fr=ot(),$r=ot(),je=ot(),Yr=ot(),me=ot(),jr=ot(),mo=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let o=e[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let o=e[r];o instanceof Symbol||n.push(o)}return n};var Ju=xt();var ul={[$e]:st("font-weight","bold"),[Ye]:st("font-weight","normal"),[Br]:st("color","blue"),[$r]:st("color","green"),[Fr]:st("color","grey"),[je]:st("color","red"),[Yr]:st("color","purple"),[me]:st("color","orange"),[jr]:st("color","black")},dl=e=>{var i;e.length===1&&((i=e[0])==null?void 0:i.constructor)===Function&&(e=e[0]());let t=[],n=[],r=A(),s=[],o=0;for(;o<e.length;o++){let c=e[o],l=ul[c];if(l!==void 0)r.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let a=go(r);o>0||a.length>0?(t.push("%c"+c),n.push(a)):t.push(c)}else break}}for(o>0&&(s=n,s.unshift(t.join("")));o<e.length;o++){let c=e[o];c instanceof Symbol||s.push(c)}return s},wo=to?dl:mo,Nn=(...e)=>{console.log(...wo(e)),yo.forEach(t=>t.print(e))},Hr=(...e)=>{console.warn(...wo(e)),e.unshift(me),yo.forEach(t=>t.print(e))};var yo=nt();var xo=e=>({[Symbol.iterator](){return this},next:e}),bo=(e,t)=>xo(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),vn=(e,t)=>xo(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Xr=class extends Kt{constructor(t,n){super(),this.doc=t,this.awareness=n}},we=class{constructor(t,n){this.clock=t,this.len=n}},Et=class{constructor(){this.clients=new Map}},$t=(e,t,n)=>t.clients.forEach((r,s)=>{let o=e.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let l=0,a=r[l];l<r.length&&a.clock<c;a=r[++l])Go(e,o,a.clock,a.len,n)}}),ml=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=L((n+r)/2),o=e[s],i=o.clock;if(i<=t){if(t<i+o.len)return s;n=s+1}else r=s-1}return null},zt=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&ml(n,t.clock)!==null},es=e=>{e.clients.forEach(t=>{t.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],o=t[n];s.clock+s.len>=o.clock?t[r-1]=new we(s.clock,dt(s.len,o.clock+o.len-s.clock)):(r<n&&(t[r]=o),r++)}t.length=r})},Yt=e=>{let t=new Et;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let o=r.slice();for(let i=n+1;i<e.length;i++)vs(o,e[i].clients.get(s)||[]);t.clients.set(s,o)}});return es(t),t},Pe=(e,t,n,r)=>{B(e.clients,t,()=>[]).push(new we(n,r))},Jn=()=>new Et,ns=e=>{let t=Jn();return e.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,l=i.length;if(o+1<n.length)for(let a=n[o+1];o+1<n.length&&a.deleted;a=n[++o+1])l+=a.length;s.push(new we(c,l))}}s.length>0&&t.clients.set(r,s)}),t},it=(e,t)=>{m(e.restEncoder,t.clients.size),tt(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),m(e.restEncoder,n);let s=r.length;m(e.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},ft=e=>{let t=new Et,n=b(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=b(e.restDecoder),o=b(e.restDecoder);if(o>0){let i=B(t.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new we(e.readDsClock(),e.readDsLen()))}}return t},Eo=(e,t,n)=>{let r=new Et,s=b(e.restDecoder);for(let o=0;o<s;o++){e.resetDsCurVal();let i=b(e.restDecoder),c=b(e.restDecoder),l=n.clients.get(i)||[],a=E(n,i);for(let u=0;u<c;u++){let d=e.readDsClock(),h=d+e.readDsLen();if(d<a){a<h&&Pe(r,i,a,h-a);let f=Z(l,d),p=l[f];for(!p.deleted&&p.id.clock<d&&(l.splice(f+1,0,zn(t,p,d-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&l.splice(f,0,zn(t,p,h-p.id.clock)),p.delete(t))}else Pe(r,i,d,h-d)}}if(r.clients.size>0){let o=new J;return m(o.restEncoder,0),it(o,r),o.toUint8Array()}return null},Bo=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let o=0;o<r.length;o++){let i=r[o],c=s[o];if(i.clock!==c.clock||i.len!==c.len)return!1}}return!0},Fo=gr,At=class e extends Kt{constructor({guid:t=Ps(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:o=null,autoLoad:i=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=Fo(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new $n,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=i,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=wr(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let l=()=>wr(a=>{let u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),a())};this.on("sync",u)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&k(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(tt(this.subdocs).map(t=>t.guid))}transact(t,n=null){return k(this,t,n)}get(t,n=_){let r=B(this.share,t,()=>{let o=new n;return o._integrate(this,null),o}),s=r.constructor;if(n!==_&&s!==n)if(s===_){let o=new n;o._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=o}),o._start=r._start;for(let i=o._start;i!==null;i=i.right)i.parent=o;return o._length=r._length,this.share.set(t,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,Pt)}getText(t=""){return this.get(t,be)}getMap(t=""){return this.get(t,Xt)}getXmlElement(t=""){return this.get(t,O)}getXmlFragment(t=""){return this.get(t,pt)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,tt(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,k(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},jt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return b(this.restDecoder)}readDsLen(){return b(this.restDecoder)}},X=class extends jt{readLeftID(){return x(b(this.restDecoder),b(this.restDecoder))}readRightID(){return x(b(this.restDecoder),b(this.restDecoder))}readClient(){return b(this.restDecoder)}readInfo(){return Ot(this.restDecoder)}readString(){return yt(this.restDecoder)}readParentInfo(){return b(this.restDecoder)===1}readTypeRef(){return b(this.restDecoder)}readLen(){return b(this.restDecoder)}readAny(){return ce(this.restDecoder)}readBuf(){return eo(P(this.restDecoder))}readJSON(){return JSON.parse(yt(this.restDecoder))}readKey(){return yt(this.restDecoder)}},Bn=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=b(this.restDecoder),this.dsCurrVal}readDsLen(){let t=b(this.restDecoder)+1;return this.dsCurrVal+=t,t}},j=class extends Bn{constructor(t){super(t),this.keys=[],b(t),this.keyClockDecoder=new le(P(t)),this.clientDecoder=new Lt(P(t)),this.leftClockDecoder=new le(P(t)),this.rightClockDecoder=new le(P(t)),this.infoDecoder=new Ie(P(t),Ot),this.stringDecoder=new fn(P(t)),this.parentInfoDecoder=new Ie(P(t),Ot),this.typeRefDecoder=new Lt(P(t)),this.lenDecoder=new Lt(P(t))}readLeftID(){return new ht(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ht(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 ce(this.restDecoder)}readBuf(){return P(this.restDecoder)}readJSON(){return ce(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},_t=class{constructor(){this.restEncoder=vt()}toUint8Array(){return G(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){m(this.restEncoder,t)}writeDsLen(t){m(this.restEncoder,t)}},ct=class extends _t{writeLeftID(t){m(this.restEncoder,t.client),m(this.restEncoder,t.clock)}writeRightID(t){m(this.restEncoder,t.client),m(this.restEncoder,t.clock)}writeClient(t){m(this.restEncoder,t)}writeInfo(t){se(this.restEncoder,t)}writeString(t){mt(this.restEncoder,t)}writeParentInfo(t){m(this.restEncoder,t?1:0)}writeTypeRef(t){m(this.restEncoder,t)}writeLen(t){m(this.restEncoder,t)}writeAny(t){ne(this.restEncoder,t)}writeBuf(t){H(this.restEncoder,t)}writeJSON(t){mt(this.restEncoder,JSON.stringify(t))}writeKey(t){mt(this.restEncoder,t)}},ye=class{constructor(){this.restEncoder=vt(),this.dsCurrVal=0}toUint8Array(){return G(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,m(this.restEncoder,n)}writeDsLen(t){t===0&&N(),m(this.restEncoder,t-1),this.dsCurrVal+=t}},J=class extends ye{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new re,this.clientEncoder=new Nt,this.leftClockEncoder=new re,this.rightClockEncoder=new re,this.infoEncoder=new Ue(se),this.stringEncoder=new hn,this.parentInfoEncoder=new Ue(se),this.typeRefEncoder=new Nt,this.lenEncoder=new Nt}toUint8Array(){let t=vt();return m(t,0),H(t,this.keyClockEncoder.toUint8Array()),H(t,this.clientEncoder.toUint8Array()),H(t,this.leftClockEncoder.toUint8Array()),H(t,this.rightClockEncoder.toUint8Array()),H(t,G(this.infoEncoder)),H(t,this.stringEncoder.toUint8Array()),H(t,G(this.parentInfoEncoder)),H(t,this.typeRefEncoder.toUint8Array()),H(t,this.lenEncoder.toUint8Array()),oe(t,G(this.restEncoder)),G(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){ne(this.restEncoder,t)}writeBuf(t){H(this.restEncoder,t)}writeJSON(t){ne(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},wl=(e,t,n,r)=>{r=dt(r,t[0].id.clock);let s=Z(t,r);m(e.restEncoder,t.length-s),e.writeClient(n),m(e.restEncoder,r);let o=t[s];o.write(e,r-o.id.clock);for(let i=s+1;i<t.length;i++)t[i].write(e,0)},rs=(e,t,n)=>{let r=new Map;n.forEach((s,o)=>{E(t,o)>s&&r.set(o,s)}),en(t).forEach((s,o)=>{n.has(o)||r.set(o,0)}),m(e.restEncoder,r.size),tt(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wl(e,t.clients.get(s),s,o)})},yl=(e,t)=>{let n=A(),r=b(e.restDecoder);for(let s=0;s<r;s++){let o=b(e.restDecoder),i=new Array(o),c=e.readClient(),l=b(e.restDecoder);n.set(c,{i:0,refs:i});for(let a=0;a<o;a++){let u=e.readInfo();switch(31&u){case 0:{let d=e.readLen();i[a]=new $(x(c,l),d),l+=d;break}case 10:{let d=b(e.restDecoder);i[a]=new R(x(c,l),d),l+=d;break}default:{let d=(u&192)===0,h=new S(x(c,l),null,(u&128)===128?e.readLeftID():null,null,(u&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(u&32)===32?e.readString():null,Ei(e,u));i[a]=h,l+=h.length}}}}return n},xl=(e,t,n)=>{let r=[],s=tt(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},i=o();if(i===null)return null;let c=new $n,l=new Map,a=(f,p)=>{let y=l.get(f);(y==null||y>p)&&l.set(f,p)},u=i.refs[i.i++],d=new Map,h=()=>{for(let f of r){let p=f.id.client,y=n.get(p);y?(y.i--,c.clients.set(p,y.refs.slice(y.i)),n.delete(p),y.i=0,y.refs=[]):c.clients.set(p,[f]),s=s.filter(g=>g!==p)}r.length=0};for(;;){if(u.constructor!==R){let p=B(d,u.id.client,()=>E(t,u.id.client))-u.id.clock;if(p<0)r.push(u),a(u.id.client,u.id.clock-1),h();else{let y=u.getMissing(e,t);if(y!==null){r.push(u);let g=n.get(y)||{refs:[],i:0};if(g.refs.length===g.i)a(y,E(t,y)),h();else{u=g.refs[g.i++];continue}}else(p===0||p<u.length)&&(u.integrate(e,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else{if(i=o(),i===null)break;u=i.refs[i.i++]}}if(c.clients.size>0){let f=new J;return rs(f,c,new Map),m(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},bl=(e,t)=>rs(e,t.doc.store,t.beforeState),ss=(e,t,n,r=new j(e))=>k(t,s=>{s.local=!1;let o=!1,i=s.doc,c=i.store,l=yl(r,i),a=xl(s,c,l),u=c.pendingStructs;if(u){for(let[h,f]of u.missing)if(f<E(c,h)){o=!0;break}if(a){for(let[h,f]of a.missing){let p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=Je([u.update,a.update])}}else c.pendingStructs=a;let d=Eo(r,s,c);if(c.pendingDs){let h=new j(M(c.pendingDs));b(h.restDecoder);let f=Eo(h,s,c);d&&f?c.pendingDs=Je([d,f]):c.pendingDs=d||f}else c.pendingDs=d;if(o){let h=c.pendingStructs.update;c.pendingStructs=null,Kn(s.doc,h)}},n,!1),kl=(e,t,n)=>ss(e,t,n,new X(e)),Kn=(e,t,n,r=j)=>{let s=M(t);ss(s,e,n,new r(s))},Sl=(e,t,n)=>Kn(e,t,n,X),El=(e,t,n=new Map)=>{rs(e,t.store,n),it(e,ns(t.store))},$o=(e,t=new Uint8Array([0]),n=new J)=>{let r=os(t);El(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(fs(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===ct)return Zo(s.map((o,i)=>i===0?o:ri(o)));if(n.constructor===J)return Je(s)}return s[0]},Al=(e,t)=>$o(e,t,new ct),Yo=e=>{let t=new Map,n=b(e.restDecoder);for(let r=0;r<n;r++){let s=b(e.restDecoder),o=b(e.restDecoder);t.set(s,o)}return t},os=e=>Yo(new jt(M(e))),is=(e,t)=>(m(e.restEncoder,t.size),tt(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{m(e.restEncoder,n),m(e.restEncoder,r)}),e),_l=(e,t)=>is(e,en(t.store)),Cl=(e,t=new ye)=>(e instanceof Map?is(t,e):_l(t,e),t.toUint8Array()),Tl=e=>Cl(e,new _t),Gr=class{constructor(){this.l=[]}},Ao=()=>new Gr,_o=(e,t)=>e.l.push(t),Co=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},jo=(e,t,n)=>Le(e.l,[t,n]),ht=class{constructor(t,n){this.client=t,this.clock=n}},Bt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,x=(e,t)=>new ht(e,t),To=(e,t)=>{m(e,t.client),m(e,t.clock)},Uo=e=>x(b(e),b(e)),cs=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw N()},Xe=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Ul=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},qr=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(o,i)=>{let c=o.get("ds"),l=o.get("ids"),a=u=>this.clients.set(u,i);c.observe(u=>{u.changes.added.forEach(d=>{d.content.getContent().forEach(h=>{h instanceof Uint8Array&&this.dss.set(i,Yt([this.dss.get(i)||Jn(),ft(new jt(M(h)))]))})})}),this.dss.set(i,Yt(c.map(u=>ft(new jt(M(u)))))),l.observe(u=>u.changes.added.forEach(d=>d.content.getContent().forEach(a))),l.forEach(a)};n.observe(o=>{o.keysChanged.forEach(i=>s(n.get(i),i))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let o=this.yusers,i=o.get(r);i||(i=new Xt,i.set("ids",new Pt),i.set("ds",new Pt),o.set(r,i)),i.get("ids").push([n]),o.observe(c=>{setTimeout(()=>{let l=o.get(r);if(l!==i){i=l,this.clients.forEach((d,h)=>{r===d&&i.get("ids").push([h])});let a=new _t,u=this.dss.get(r);u&&(it(a,u),i.get("ds").push([a.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=i.get("ds"),a=c.deleteSet;if(c.local&&a.clients.size>0&&s(c,a)){let u=new _t;it(u,a),l.push([u.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(zt(r,t))return n;return null}},xe=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},Dl=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Il=e=>{var t;return new xe(e.type==null?null:x(e.type.client,e.type.clock),(t=e.tname)!=null?t:null,e.item==null?null:x(e.item.client,e.item.clock),e.assoc==null?0:e.assoc)},Fn=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},Nl=(e,t,n=0)=>new Fn(e,t,n),On=(e,t,n)=>{let r=null,s=null;return e._item===null?s=cs(e):r=x(e._item.id.client,e._item.id.clock),new xe(r,s,t,n)},ls=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return On(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return On(e,x(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return On(e,r.lastId,n);r=r.right}return On(e,null,n)},vl=(e,t)=>{let{type:n,tname:r,item:s,assoc:o}=t;if(s!==null)m(e,0),To(e,s);else if(r!==null)se(e,1),mt(e,r);else if(n!==null)se(e,2),To(e,n);else throw N();return De(e,o),e},as=e=>{let t=vt();return vl(t,e),G(t)},Ol=e=>{let t=null,n=null,r=null;switch(b(e)){case 0:r=Uo(e);break;case 1:n=yt(e);break;case 2:t=Uo(e)}let s=fr(e)?Ne(e):0;return new xe(t,n,r,s)},us=e=>Ol(M(e)),Ll=(e,t)=>{let n=Ft(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},ds=(e,t,n=!0)=>{let r=t.store,s=e.item,o=e.type,i=e.tname,c=e.assoc,l=null,a=0;if(s!==null){if(E(r,s.client)<=s.clock)return null;let u=n?Qr(r,s):Ll(r,s),d=u.item;if(!(d instanceof S))return null;if(l=d.parent,l._item===null||!l._item.deleted){a=d.deleted||!d.countable?0:u.diff+(c>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(a+=h.length),h=h.left}}else{if(i!==null)l=t.get(i);else if(o!==null){if(E(r,o.client)<=o.clock)return null;let{item:u}=n?Qr(r,o):{item:Ft(r,o)};if(u instanceof S&&u.content instanceof Q)l=u.content.type;else return null}else throw N();c>=0?a=l._length:a=0}return Nl(l,a,e.assoc)},Ml=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Bt(e.item,t.item)&&Bt(e.type,t.type)&&e.assoc===t.assoc,Ge=class{constructor(t,n){this.ds=t,this.sv=n}},Rl=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,o=t.sv;if(s.size!==o.size||n.size!==r.size)return!1;for(let[i,c]of s.entries())if(o.get(i)!==c)return!1;for(let[i,c]of n.entries()){let l=r.get(i)||[];if(c.length!==l.length)return!1;for(let a=0;a<c.length;a++){let u=c[a],d=l[a];if(u.clock!==d.clock||u.len!==d.len)return!1}}return!0},Ho=(e,t=new ye)=>(it(t,e.ds),is(t,e.sv),t.toUint8Array()),Vl=e=>Ho(e,new _t),Po=(e,t=new Bn(M(e)))=>new Ge(ft(t),Yo(t)),Bl=e=>Po(e,new jt(M(e))),hs=(e,t)=>new Ge(e,t),Fl=hs(Jn(),new Map),$l=e=>hs(ns(e.store),en(e.store)),bt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!zt(t.ds,e.id),zr=(e,t)=>{let n=B(e.meta,zr,nt),r=e.doc.store;n.has(t)||(t.sv.forEach((s,o)=>{s<E(r,o)&&F(e,x(o,s))}),$t(e,t.ds,s=>{}),n.add(t))},Yl=(e,t,n=new At)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,o=new J;return e.transact(i=>{let c=0;r.forEach(l=>{l>0&&c++}),m(o.restEncoder,c);for(let[l,a]of r){if(a===0)continue;a<E(e.store,l)&&F(i,x(l,a));let u=e.store.clients.get(l)||[],d=Z(u,a-1);m(o.restEncoder,d+1),o.writeClient(l),m(o.restEncoder,0);for(let h=0;h<=d;h++)u[h].write(o,0)}it(o,s)}),Kn(n,o.toUint8Array(),"snapshot"),n},jl=(e,t,n=j)=>{let r=new n(M(t)),s=new lt(r,!1);for(let i=s.curr;i!==null;i=s.next())if((e.sv.get(i.id.client)||0)<i.id.clock+i.length)return!1;let o=Yt([e.ds,ft(r)]);return Bo(e.ds,o)},Hl=(e,t)=>jl(e,t,X),$n=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},en=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},E=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Xo=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw N()}n.push(t)},Z=(e,t)=>{let n=0,r=e.length-1,s=e[r],o=s.id.clock;if(o===t)return r;let i=L(t/(o+s.length-1)*r);for(;n<=r;){if(s=e[i],o=s.id.clock,o<=t){if(t<o+s.length)return i;n=i+1}else r=i-1;i=L((n+r)/2)}throw N()},Pl=(e,t)=>{let n=e.clients.get(t.client);return n[Z(n,t.clock)]},Ft=Pl,Jr=(e,t,n)=>{let r=Z(t,n),s=t[r];return s.id.clock<n&&s instanceof S?(t.splice(r+1,0,zn(e,s,n-s.id.clock)),r+1):r},F=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Jr(e,n,t.clock)]},Kr=(e,t,n)=>{let r=t.clients.get(n.client),s=Z(r,n.clock),o=r[s];return n.clock!==o.id.clock+o.length-1&&o.constructor!==$&&r.splice(s+1,0,zn(e,o,n.clock-o.id.clock+1)),o},Xl=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Z(r,t.id.clock)]=n},Go=(e,t,n,r,s)=>{if(r===0)return;let o=n+r,i=Jr(e,t,n),c;do c=t[i++],o<c.id.clock+c.length&&Jr(e,t,o),s(c);while(i<t.length&&t[i].id.clock<o)},Yn=class{constructor(t,n,r){this.doc=t,this.deleteSet=new Et,this.beforeState=en(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Do=(e,t)=>t.deleteSet.clients.size===0&&!Ns(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(es(t.deleteSet),bl(e,t),it(e,t.deleteSet),!0),Io=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&B(e.changed,t,nt).add(n)},Rn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof S&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let o=t-s;return o&&e.splice(t+1-o,o),o},qo=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let o=t.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],l=c.clock+c.len;for(let a=Z(o,c.clock),u=o[a];a<o.length&&u.id.clock<l;u=o[++a]){let d=o[a];if(c.clock+c.len<=d.id.clock)break;d instanceof S&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},zo=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=an(s.length-1,1+Z(s,i.clock+i.len-1));for(let l=c,a=s[l];l>0&&a.id.clock>=i.clock;a=s[l])l-=1+Rn(s,l)}})},Gl=(e,t,n)=>{qo(e,t,n),zo(e,t)},Jo=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,o=n.deleteSet,i=n._mergeStructs;try{es(o),n.afterState=en(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=a,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),c.push(()=>{jo(a._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&pa(n)})}),Le(c,[])}finally{r.gc&&qo(o,s,r.gcFilter),zo(o,s),n.afterState.forEach((u,d)=>{let h=n.beforeState.get(d)||0;if(h!==u){let f=s.clients.get(d),p=dt(Z(f,h),1);for(let y=f.length-1;y>=p;)y-=1+Rn(f,y)}});for(let u=i.length-1;u>=0;u--){let{client:d,clock:h}=i[u].id,f=s.clients.get(d),p=Z(f,h);p+1<f.length&&Rn(f,p+1)>1||p>0&&Rn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Nn(me,$e,"[yjs] ",Ye,je,"Changed the client-id because another client seems to be using it."),r.clientID=Fo()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let u=new ct;Do(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let u=new J;Do(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=n;(c.size>0||a.size>0||l.size>0)&&(c.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),a.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:c,removed:a},r,n]),a.forEach(u=>u.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Jo(e,t+1)}}},k=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,o=!1,i=null;e._transaction===null&&(o=!0,e._transaction=new Yn(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{i=t(e._transaction)}finally{if(o){let c=e._transaction===s[0];e._transaction=null,c&&Jo(s,0)}}return i},Wr=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},No=(e,t,n)=>{$t(e,n.deletions,r=>{r instanceof S&&t.scope.some(s=>s===e.doc||Xe(s,r))&&ys(r,!1)})},vo=(e,t,n)=>{let r=null,s=e.doc,o=e.scope;k(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,a=t.pop(),u=new Set,d=[],h=!1;$t(c,a.insertions,f=>{if(f instanceof S){if(f.redone!==null){let{item:p,diff:y}=Qr(l,f.id);y>0&&(p=F(c,x(p.id.client,p.id.clock+y))),f=p}!f.deleted&&o.some(p=>p===c.doc||Xe(p,f))&&d.push(f)}}),$t(c,a.deletions,f=>{f instanceof S&&o.some(p=>p===c.doc||Xe(p,f))&&!zt(a.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Si(c,f,u,a.insertions,e.ignoreRemoteMapChanges,e)!==null||h});for(let f=d.length-1;f>=0;f--){let p=d[f];e.deleteFilter(p)&&(p.delete(c),h=!0)}e.currStackItem=h?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=c},e);let i=e.currStackItem;if(i!=null){let c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return i},qe=class extends Kt{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:c=ut(t)?t[0].doc:t instanceof At?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let a=this.undoing,u=this.redoing,d=a?this.redoStack:this.undoStack;a?this.stopCapturing():u||this.clear(!1,!0);let h=new Et;l.afterState.forEach((g,w)=>{let U=l.beforeState.get(w)||0,Ut=g-U;Ut>0&&Pe(h,w,U,Ut)});let f=xt(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!a&&!u){let g=d[d.length-1];g.deletions=Yt([g.deletions,l.deleteSet]),g.insertions=Yt([g.insertions,h])}else d.push(new Wr(l.deleteSet,h)),p=!0;!a&&!u&&(this.lastChange=f),$t(l,l.deleteSet,g=>{g instanceof S&&this.scope.some(w=>w===l.doc||Xe(w,g))&&ys(g,!0)});let y=[{stackItem:d[d.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",y):this.emit("stack-item-updated",y)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let n=new Set(this.scope);t=ut(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof _?r.doc!==this.doc:r!==this.doc)&&Hr("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>No(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>No(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=vo(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=vo(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}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*ql(e){let t=b(e.restDecoder);for(let n=0;n<t;n++){let r=b(e.restDecoder),s=e.readClient(),o=b(e.restDecoder);for(let i=0;i<r;i++){let c=e.readInfo();if(c===10){let l=b(e.restDecoder);yield new R(x(s,o),l),o+=l}else if((31&c)!==0){let l=(c&192)===0,a=new S(x(s,o),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,Ei(e,c));yield a,o+=a.length}else{let l=e.readLen();yield new $(x(s,o),l),o+=l}}}}var lt=class{constructor(t,n){this.gen=ql(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===R);return this.curr}},zl=e=>Ko(e,X),Ko=(e,t=j)=>{let n=[],r=new t(M(e)),s=new lt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);Nn("Structs: ",n);let o=ft(r);Nn("DeleteSet: ",o)},Jl=e=>Wo(e,X),Wo=(e,t=j)=>{let n=[],r=new t(M(e)),s=new lt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);return{structs:n,ds:ft(r)}},ze=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Zo=e=>Je(e,X,ct),Qo=(e,t=ye,n=j)=>{let r=new t,s=new lt(new n(M(e)),!1),o=s.curr;if(o!==null){let i=0,c=o.id.client,l=o.id.clock!==0,a=l?0:o.id.clock+o.length;for(;o!==null;o=s.next())c!==o.id.client&&(a!==0&&(i++,m(r.restEncoder,c),m(r.restEncoder,a)),c=o.id.client,a=0,l=o.id.clock!==0),o.constructor===R&&(l=!0),l||(a=o.id.clock+o.length);a!==0&&(i++,m(r.restEncoder,c),m(r.restEncoder,a));let u=vt();return m(u,i),$s(u,r.restEncoder),r.restEncoder=u,r.toUint8Array()}else return m(r.restEncoder,0),r.toUint8Array()},Kl=e=>Qo(e,_t,X),ti=(e,t=j)=>{let n=new Map,r=new Map,s=new lt(new t(M(e)),!1),o=s.curr;if(o!==null){let i=o.id.client,c=o.id.clock;for(n.set(i,c);o!==null;o=s.next())i!==o.id.client&&(r.set(i,c),n.set(o.id.client,o.id.clock),i=o.id.client),c=o.id.clock+o.length;r.set(i,c)}return{from:n,to:r}},Wl=e=>ti(e,X),Zl=(e,t)=>{if(e.constructor===$){let{client:n,clock:r}=e.id;return new $(x(n,r+t),e.length-t)}else if(e.constructor===R){let{client:n,clock:r}=e.id;return new R(x(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new S(x(r,s+t),null,x(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Je=(e,t=j,n=J)=>{if(e.length===1)return e[0];let r=e.map(u=>new t(M(u))),s=r.map(u=>new lt(u,!0)),o=null,i=new n,c=new ze(i);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){let p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===R?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){let u=s[0],d=u.curr.id.client;if(o!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(d!==o.struct.id.client)kt(c,o.struct,o.offset),o={struct:h,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===R)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{kt(c,o.struct,o.offset);let p=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new R(x(d,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-h.id.clock;p>0&&(o.struct.constructor===R?o.struct.length-=p:h=Zl(h,p)),o.struct.mergeWith(h)||(kt(c,o.struct,o.offset),o={struct:h,offset:0},u.next())}}else o={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==R;h=u.next())kt(c,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(kt(c,o.struct,o.offset),o=null),ps(c);let l=r.map(u=>ft(u)),a=Yt(l);return it(i,a),i.toUint8Array()},fs=(e,t,n=j,r=J)=>{let s=os(t),o=new r,i=new ze(o),c=new n(M(e)),l=new lt(c,!1);for(;l.curr;){let u=l.curr,d=u.id.client,h=s.get(d)||0;if(l.curr.constructor===R){l.next();continue}if(u.id.clock+u.length>h)for(kt(i,u,dt(h-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===d;)kt(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===d&&l.curr.id.clock+l.curr.length<=h;)l.next()}ps(i);let a=ft(c);return it(o,a),o.toUint8Array()},Ql=(e,t)=>fs(e,t,X,ct),ei=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:G(e.encoder.restEncoder)}),e.encoder.restEncoder=vt(),e.written=0)},kt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&ei(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),m(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},ps=e=>{ei(e);let t=e.encoder.restEncoder;m(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];m(t,r.written),oe(t,r.restEncoder)}},Wn=(e,t,n,r)=>{let s=new n(M(e)),o=new lt(s,!1),i=new r,c=new ze(i);for(let a=o.curr;a!==null;a=o.next())kt(c,t(a),0);ps(c);let l=ft(s);return it(i,l),i.toUint8Array()},ni=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=A(),o=A(),i=A(),c=A();return c.set(null,null),l=>{switch(l.constructor){case $:case R:return l;case S:{let a=l,u=a.content;switch(u.constructor){case Se:break;case Q:{if(n){let d=u.type;d instanceof O&&(d.nodeName=B(o,d.nodeName,()=>"node-"+r)),d instanceof Qe&&(d.hookName=B(o,d.hookName,()=>"hook-"+r))}break}case Ct:{let d=u;d.arr=d.arr.map(()=>r);break}case Gt:{let d=u;d.content=new Uint8Array([r]);break}case qt:{let d=u;t&&(d.opts={},d.doc.guid=r+"");break}case gt:{let d=u;d.embed={};break}case C:{let d=u;e&&(d.key=B(i,d.key,()=>r+""),d.value=B(c,d.value,()=>({i:r})));break}case tn:{let d=u;d.arr=d.arr.map(()=>r);break}case et:{let d=u;d.str=dn(r%10+"",d.str.length);break}default:N()}return a.parentSub&&(a.parentSub=B(s,a.parentSub,()=>r+"")),r++,l}default:N()}}},ta=(e,t)=>Wn(e,ni(t),X,ct),ea=(e,t)=>Wn(e,ni(t),j,J),na=e=>Wn(e,Ar,X,J),ri=e=>Wn(e,Ar,j,ct),Oo="You must not compute changes after the event-handler fired.",Ht=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=ra(this.currentTarget,this.target))}deletes(t){return zt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw q(Oo);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let o=n._map.get(s),i,c;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))i="delete",c=on(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",c=on(l.content.getContent())):(i="add",c=void 0)}else if(this.deletes(o))i="delete",c=on(o.content.getContent());else return;t.set(s,{action:i,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw q(Oo);let n=this.target,r=nt(),s=nt(),o=[];if(t={added:r,deleted:s,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&o.push(c)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,s.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),r.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},ra=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}t=t._item.parent}return n},V=()=>{Hr("Invalid access: Add Yjs type to a document before reading data.")},si=80,gs=0,Zr=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=gs++}},sa=e=>{e.timestamp=gs++},oi=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=gs++},oa=(e,t,n)=>{if(e.length>=si){let r=e.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return oi(r,t,n),r}else{let r=new Zr(t,n);return e.push(r),r}},Zn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,i)=>Dt(t-o.index)<Dt(t-i.index)?o:i),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,sa(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=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&&(s-=r.length);return n!==null&&Dt(n.index-s)<r.parent.length/si?(oi(n,r,s),n):oa(e._searchMarker,r,s)},Ke=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let o=s.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(s.index-=o.length);if(o===null||o.marker===!0){e.splice(r,1);continue}s.p=o,o.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=dt(t,s.index+n))}},ia=e=>{var r;(r=e.doc)!=null||V();let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},Qn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;B(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;jo(r._eH,n,t)},_=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ao(),this._dEH=Ao(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw z()}clone(){throw z()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){_o(this._eH,t)}observeDeep(t){_o(this._dEH,t)}unobserve(t){Co(this._eH,t)}unobserveDeep(t){Co(this._dEH,t)}toJSON(){}},ii=(e,t,n)=>{var i;(i=e.doc)!=null||V(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],o=e._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=t)t-=c.length;else{for(let l=t;l<c.length&&r>0;l++)s.push(c[l]),r--;t=0}}o=o.right}return s},ci=e=>{var r;(r=e.doc)!=null||V();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let s=n.content.getContent();for(let o=0;o<s.length;o++)t.push(s[o])}n=n.right}return t},ca=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&bt(r,t)){let s=r.content.getContent();for(let o=0;o<s.length;o++)n.push(s[o])}r=r.right}return n},We=(e,t)=>{var s;let n=0,r=e._start;for((s=e.doc)!=null||V();r!==null;){if(r.countable&&!r.deleted){let o=r.content.getContent();for(let i=0;i<o.length;i++)t(o[i],n++,e)}r=r.right}},li=(e,t)=>{let n=[];return We(e,(r,s)=>{n.push(t(r,s,e))}),n},la=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},ai=(e,t)=>{var s;(s=e.doc)!=null||V();let n=Zn(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},jn=(e,t,n,r)=>{let s=n,o=e.doc,i=o.clientID,c=o.store,l=n===null?t._start:n.right,a=[],u=()=>{a.length>0&&(s=new S(x(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Ct(a)),s.integrate(e,0),a=[])};r.forEach(d=>{if(d===null)a.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new S(x(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Gt(new Uint8Array(d))),s.integrate(e,0);break;case At:s=new S(x(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new qt(d)),s.integrate(e,0);break;default:if(d instanceof _)s=new S(x(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Q(d)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},ui=()=>q("Length exceeded!"),di=(e,t,n,r)=>{if(n>t._length)throw ui();if(n===0)return t._searchMarker&&Ke(t._searchMarker,n,r.length),jn(e,t,null,r);let s=n,o=Zn(t,n),i=t._start;for(o!==null&&(i=o.p,n-=o.index,n===0&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&F(e,x(i.id.client,i.id.clock+n));break}n-=i.length}return t._searchMarker&&Ke(t._searchMarker,s,r.length),jn(e,t,i,r)},aa=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return jn(e,t,s,n)},hi=(e,t,n,r)=>{if(r===0)return;let s=n,o=r,i=Zn(t,n),c=t._start;for(i!==null&&(c=i.p,n-=i.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&F(e,x(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&F(e,x(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw ui();t._searchMarker&&Ke(t._searchMarker,s,-o+r)},Hn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},ms=(e,t,n,r)=>{let s=t._map.get(n)||null,o=e.doc,i=o.clientID,c;if(r==null)c=new Ct([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Ct([r]);break;case Uint8Array:c=new Gt(r);break;case At:c=new qt(r);break;default:if(r instanceof _)c=new Q(r);else throw new Error("Unexpected content type")}new S(x(i,E(o.store,i)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},ws=(e,t)=>{var r;(r=e.doc)!=null||V();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},fi=e=>{var n;let t={};return(n=e.doc)!=null||V(),e._map.forEach((r,s)=>{r.deleted||(t[s]=r.content.getContent()[r.length-1])}),t},pi=(e,t)=>{var r;(r=e.doc)!=null||V();let n=e._map.get(t);return n!==void 0&&!n.deleted},ua=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&bt(r,n)?r.content.getContent()[r.length-1]:void 0},gi=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let o=r;for(;o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;o!==null&&bt(o,t)&&(n[s]=o.content.getContent()[o.length-1])}),n},Ln=e=>{var t;return(t=e.doc)!=null||V(),bo(e._map.entries(),n=>!n[1].deleted)},Pn=class extends Ht{},Pt=class e extends _{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof _?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||V(),this._length}_callObserver(t,n){super._callObserver(t,n),Qn(this,t,new Pn(this,t))}insert(t,n){this.doc!==null?k(this.doc,r=>{di(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?k(this.doc,n=>{aa(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?k(this.doc,r=>{hi(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return ai(this,t)}toArray(){return ci(this)}slice(t=0,n=this.length){return ii(this,t,n)}toJSON(){return this.map(t=>t instanceof _?t.toJSON():t)}map(t){return li(this,t)}forEach(t){We(this,t)}[Symbol.iterator](){return la(this)}_write(t){t.writeTypeRef(Na)}},da=e=>new Pt,Xn=class extends Ht{constructor(t,n,r){super(t,n),this.keysChanged=r}},Xt=class e extends _{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof _?n.clone():n)}),t}_callObserver(t,n){Qn(this,t,new Xn(this,t,n))}toJSON(){var n;(n=this.doc)!=null||V();let t={};return this._map.forEach((r,s)=>{if(!r.deleted){let o=r.content.getContent()[r.length-1];t[s]=o instanceof _?o.toJSON():o}}),t}get size(){return[...Ln(this)].length}keys(){return vn(Ln(this),t=>t[0])}values(){return vn(Ln(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return vn(Ln(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){var n;(n=this.doc)!=null||V(),this._map.forEach((r,s)=>{r.deleted||t(r.content.getContent()[r.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?k(this.doc,n=>{Hn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?k(this.doc,r=>{ms(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return ws(this,t)}has(t){return pi(this,t)}clear(){this.doc!==null?k(this.doc,t=>{this.forEach(function(n,r,s){Hn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(va)}},ha=e=>new Xt,St=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&kr(e,t),Ze=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&N(),this.right.content.constructor===C?this.right.deleted||Ee(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Lo=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===C?t.right.deleted||Ee(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&F(e,x(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},Mn=(e,t,n,r)=>{let s=new Map,o=r?Zn(t,n):null;if(o){let i=new Ze(o.p.left,o.p,o.index,s);return Lo(e,i,n-o.index)}else{let i=new Ze(null,t._start,0,s);return Lo(e,i,n)}},mi=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===C&&St(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,o=s.clientID;r.forEach((i,c)=>{let l=n.left,a=n.right,u=new S(x(o,E(s.store,o)),l,l&&l.lastId,a,a&&a.id,t,null,new C(c,i));u.integrate(e,0),n.right=u,n.forward()})},Ee=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},wi=(e,t)=>{var n;for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===C&&St((n=t[e.right.content.key])!=null?n:null,e.right.content.value)))break;e.forward()}},yi=(e,t,n,r)=>{var c;let s=e.doc,o=s.clientID,i=new Map;for(let l in r){let a=r[l],u=(c=n.currentAttributes.get(l))!=null?c:null;if(!St(u,a)){i.set(l,u);let{left:d,right:h}=n;n.right=new S(x(o,E(s.store,o)),d,d&&d.lastId,h,h&&h.id,t,null,new C(l,a)),n.right.integrate(e,0),n.forward()}}return i},Pr=(e,t,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});let o=e.doc,i=o.clientID;wi(n,s);let c=yi(e,t,n,s),l=r.constructor===String?new et(r):r instanceof _?new Q(r):new gt(r),{left:a,right:u,index:d}=n;t._searchMarker&&Ke(t._searchMarker,n.index,l.getLength()),u=new S(x(i,E(o.store,i)),a,a&&a.lastId,u,u&&u.id,t,null,l),u.integrate(e,0),n.right=u,n.index=d,n.forward(),mi(e,t,n,c)},Mo=(e,t,n,r,s)=>{let o=e.doc,i=o.clientID;wi(n,s);let c=yi(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===C));){if(!n.right.deleted)switch(n.right.content.constructor){case C:{let{key:l,value:a}=n.right.content,u=s[l];if(u!==void 0){if(St(u,a))c.delete(l);else{if(r===0)break t;c.set(l,a)}n.right.delete(e)}else n.currentAttributes.set(l,a);break}default:r<n.right.length&&F(e,x(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
-
`;n.right=new S(
|
|
5
|
-
`?i.insert.slice(0,-1):i.insert;(typeof c!="string"||c.length>0)&&Pr(r,this,s,c,i.attributes||{})}else i.retain!==void 0?Mo(r,this,s,i.retain,i.attributes||{}):i.delete!==void 0&&Ro(r,s,i.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){var d;(d=this.doc)!=null||V();let s=[],o=new Map,i=this.doc,c="",l=this._start;function a(){if(c.length>0){let h={},f=!1;o.forEach((y,g)=>{f=!0,h[g]=y});let p={insert:c};f&&(p.attributes=h),s.push(p),c=""}}let u=()=>{for(;l!==null;){if(bt(l,t)||n!==void 0&&bt(l,n))switch(l.content.constructor){case et:{let h=o.get("ychange");t!==void 0&&!bt(l,t)?(h===void 0||h.user!==l.id.client||h.type!=="removed")&&(a(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!bt(l,n)?(h===void 0||h.user!==l.id.client||h.type!=="added")&&(a(),o.set("ychange",r?r("added",l.id):{type:"added"})):h!==void 0&&(a(),o.delete("ychange")),c+=l.content.str;break}case Q:case gt:{a();let h={insert:l.content.getContent()[0]};if(o.size>0){let f={};h.attributes=f,o.forEach((p,y)=>{f[y]=p})}s.push(h);break}case C:bt(l,t)&&(a(),Ee(o,l.content));break}l=l.right}a()};return t||n?k(i,h=>{t&&zr(h,t),n&&zr(h,n),u()},"cleanup"):u(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?k(s,o=>{let i=Mn(o,this,t,!r);r||(r={},i.currentAttributes.forEach((c,l)=>{r[l]=c})),Pr(o,this,i,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?k(s,o=>{let i=Mn(o,this,t,!r);Pr(o,this,i,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?k(r,s=>{Ro(s,Mn(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?k(s,o=>{let i=Mn(o,this,t,!1);i.right!==null&&Mo(o,this,i,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?k(this.doc,n=>{Hn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{ms(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return ws(this,t)}getAttributes(){return fi(this)}_write(t){t.writeTypeRef(Oa)}},ga=e=>new be,He=class{constructor(t,n=()=>!0){var r;this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,(r=t.doc)!=null||V()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===O||n.constructor===pt)&&n._start!==null)t=n._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},pt=class e extends _{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof _?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||V(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new He(this,t)}querySelector(t){t=t.toUpperCase();let r=new He(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),tt(new He(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Qn(this,t,new qn(this,n,t))}toString(){return li(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),We(this,o=>{s.insertBefore(o.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?k(this.doc,r=>{di(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)k(this.doc,r=>{let s=t&&t instanceof _?t._item:t;jn(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(o=>o===t)+1;if(s===0&&t!==null)throw q("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?k(this.doc,r=>{hi(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return ci(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ai(this,t)}slice(t=0,n=this.length){return ii(this,t,n)}forEach(t){We(this,t)}_write(t){t.writeTypeRef(Ma)}},ma=e=>new pt,O=class e extends pt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return Js(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof _?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let o=this.nodeName.toLocaleLowerCase(),i=n.length>0?" "+n.join(" "):"";return`<${o}${i}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?k(this.doc,n=>{Hn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{ms(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return ws(this,t)}hasAttribute(t){return pi(this,t)}getAttributes(t){return t?gi(this,t):fi(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),o=this.getAttributes();for(let i in o){let c=o[i];typeof c=="string"&&s.setAttribute(i,c)}return We(this,i=>{s.appendChild(i.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(La),t.writeKey(this.nodeName)}},wa=e=>new O(e.readKey()),qn=class extends Ht{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},Qe=class e extends Xt{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){let s=n[this.hookName],o;return s!==void 0?o=s.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(Ra),t.writeKey(this.hookName)}},ya=e=>new Qe(e.readKey()),K=class e extends be{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let o=[];for(let i in t.attributes[s])o.push({key:i,value:t.attributes[s][i]});o.sort((i,c)=>i.key<c.key?-1:1),n.push({nodeName:s,attrs:o})}n.sort((s,o)=>s.nodeName<o.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let o=n[s];r+=`<${o.nodeName}`;for(let i=0;i<o.attrs.length;i++){let c=o.attrs[i];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Va)}},xa=e=>new K,ke=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw z()}mergeWith(t){return!1}write(t,n,r){throw z()}integrate(t,n){throw z()}},ba=0,$=class extends ke{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Xo(t.doc.store,this)}write(t,n){t.writeInfo(ba),t.writeLen(this.length-n)}getMissing(t,n){return null}},Gt=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},ka=e=>new Gt(e.readBuf()),Se=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Pe(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},Sa=e=>new Se(e.readLen()),ki=(e,t)=>new At({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),qt=class e{constructor(t){t._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=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(ki(this.doc.guid,this.opts))}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},Ea=e=>new qt(ki(e.readString(),e.readAny())),gt=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},Aa=e=>new gt(e.readJSON()),C=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},_a=e=>new C(e.readKey(),e.readJSON()),tn=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let o=this.arr[s];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},Ca=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new tn(n)},Ta=Re("node_env")==="development",Ct=class e{constructor(t){this.arr=t,Ta&&Sr(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let o=this.arr[s];t.writeAny(o)}}getRef(){return 8}},Ua=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Ct(n)},et=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},Da=e=>new et(e.readString()),Ia=[da,ha,ga,wa,ma,ya,xa],Na=0,va=1,Oa=2,La=3,Ma=4,Ra=5,Va=6,Q=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},Ba=e=>new Q(Ia[e.readTypeRef()](e)),Qr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=x(n.client,n.clock+r)),s=Ft(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof S);return{item:s,diff:r}},ys=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},zn=(e,t,n)=>{let{client:r,clock:s}=t.id,o=new S(x(r,s+n),t,x(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=x(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},Vo=(e,t)=>_e(e,n=>zt(n.deletions,t)),Si=(e,t,n,r,s,o)=>{let i=e.doc,c=i.store,l=i.clientID,a=t.redone;if(a!==null)return F(e,a);let u=t.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Si(e,u,n,r,s,o)===null))return null;for(;u.redone!==null;)u=F(e,u.redone)}let f=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,h=t;d!==null;){let w=d;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:F(e,w.redone);if(w!==null&&w.parent._item===u){d=w;break}d=d.left}for(;h!==null;){let w=h;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:F(e,w.redone);if(w!==null&&w.parent._item===u){h=w;break}h=h.right}}else if(h=null,t.right&&!s){for(d=t;d!==null&&d.right!==null&&(d.right.redone||zt(r,d.right.id)||Vo(o.undoStack,d.right.id)||Vo(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=F(e,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(t.parentSub)||null;let p=E(c,l),y=x(l,p),g=new S(y,d,d&&d.lastId,h,h&&h.id,f,t.parentSub,t.content.copy());return t.redone=y,ys(g,!0),g.integrate(e,0),g},S=class e extends ke{constructor(t,n,r,s,o,i,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=o,this.parent=i,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ht&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Kr(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=F(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===$||this.right&&this.right.constructor===$)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ht){let r=Ft(n,this.parent);r.constructor===$?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Kr(t,t.doc.store,x(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let o=new Set,i=new Set;for(;s!==null&&s!==this.right;){if(i.add(s),o.add(s),Bt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,o.clear();else if(Bt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&i.has(Ft(t.doc.store,s.origin)))o.has(Ft(t.doc.store,s.origin))||(r=s,o.clear());else break;s=s.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(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Xo(t.doc.store,this),this.content.integrate(t,this),Io(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new $(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:x(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Bt(t.origin,this.lastId)&&this.right===t&&Bt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Pe(t.deleteSet,this.id.client,this.id.clock,this.length),Io(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw N();this.content.gc(t),n?Xl(t,this,new $(this.id,this.length)):this.content=new Se(this.length)}write(t,n){let r=n>0?x(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,o=this.parentSub,i=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(o===null?0:32);if(t.writeInfo(i),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let a=cs(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===ht?(t.writeParentInfo(!1),t.writeLeftID(c)):N();o!==null&&t.writeString(o)}this.content.write(t,n)}},Ei=(e,t)=>Fa[t&31](e),Fa=[()=>{N()},Sa,Ca,ka,Da,Aa,_a,Ba,Ua,Ea,()=>{N()}],$a=10,R=class extends ke{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){N()}write(t,n){t.writeInfo($a),m(t.restEncoder,this.length-n)}getMissing(t,n){return null}},Ai=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:{},_i="__ $YJS$ __";Ai[_i]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ai[_i]=!0;var xs=new Set(["p","div","section","article","header","footer","main","aside","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","table","thead","tbody","tfoot","tr","td","th","figure","figcaption"]),bs=new Set(["strong","b","em","i","u","s","strike","del","ins","mark","small","sub","sup","code","kbd","samp","var","span","font","a"]),ks=new Set(["br","hr","img","video","audio","source","iframe","embed","object"]);function Tt(e){let t=e.toLowerCase();return xs.has(t)?"block":ks.has(t)?"leaf":bs.has(t)?"mark":"unknown"}var Ci=["bold","italic","underline","strikethrough","subscript","superscript","color","backcolor","fontFamily","fontSize","link","code"];var Y="http://www.w3.org/1999/xhtml";function nn(e,t){for(;t.firstChild;)t.removeChild(t.firstChild);let n=t.ownerDocument;if(!n)throw new Error("renderFragmentToHost: editable host has no ownerDocument");for(let r=0;r<e.length;r++){let s=e.get(r),o=tr(s,n);o&&t.appendChild(o)}t.childNodes.length===0&&t.appendChild(n.createElementNS(Y,"p"))}function tr(e,t){return e instanceof K?ja(e,t):e instanceof O?Ya(e,t):null}function Ya(e,t){let n=e.nodeName.toLowerCase(),r=Tt(n);if(r==="unknown"){let o=t.createElementNS(Y,"span");return o.setAttribute("data-rte-unknown",n),Ui(e,o),Ti(e,o,t),o}let s=t.createElementNS(Y,n);return Ui(e,s),r==="leaf"||Ti(e,s,t),s}function Ti(e,t,n){let r=e.length;for(let s=0;s<r;s++){let o=e.get(s),i=tr(o,n);i&&t.appendChild(i)}}function Ui(e,t){let n=e.getAttributes();for(let[r,s]of Object.entries(n))s!=null&&t.setAttribute(r,String(s))}function ja(e,t){var s;let n=t.createDocumentFragment(),r=e.toDelta();for(let o of r){if(typeof o.insert!="string"||o.insert.length===0)continue;let i=Pa(o.attributes),c=t.createTextNode(o.insert);for(let l=i.length-1;l>=0;l--){let a=Xa(i[l],(s=o.attributes)!=null?s:{},t);a.appendChild(c),c=a}n.appendChild(c)}return n}var Ha=["link","color","backcolor","fontFamily","fontSize","code","underline","strikethrough","subscript","superscript","italic","bold"];function Pa(e){if(!e)return[];let t=[];for(let n of Ha)n in e&&e[n]!=null&&e[n]!==!1&&t.push(n);return t}function Xa(e,t,n){switch(e){case"bold":return n.createElementNS(Y,"strong");case"italic":return n.createElementNS(Y,"em");case"underline":return n.createElementNS(Y,"u");case"strikethrough":return n.createElementNS(Y,"s");case"subscript":return n.createElementNS(Y,"sub");case"superscript":return n.createElementNS(Y,"sup");case"code":return n.createElementNS(Y,"code");case"link":{let r=n.createElementNS(Y,"a"),s=t.link;return typeof s=="string"&&r.setAttribute("href",s),r}case"color":{let r=n.createElementNS(Y,"span");return r.setAttribute("style",`color:${t.color}`),r}case"backcolor":{let r=n.createElementNS(Y,"span");return r.setAttribute("style",`background-color:${t.backcolor}`),r}case"fontFamily":{let r=n.createElementNS(Y,"span");return r.setAttribute("style",`font-family:${t.fontFamily}`),r}case"fontSize":{let r=n.createElementNS(Y,"span");return r.setAttribute("style",`font-size:${t.fontSize}`),r}default:return n.createElementNS(Y,"span")}}function er(e){var o;let t=(o=e.ownerDocument)==null?void 0:o.defaultView,n=t==null?void 0:t.getSelection(),r={insideHost:!1,anchorPath:[],anchorOffset:0,focusPath:[],focusOffset:0};if(!n||n.rangeCount===0)return r;let s=n.getRangeAt(0);return!e.contains(s.startContainer)||!e.contains(s.endContainer)?r:{insideHost:!0,anchorPath:Di(e,s.startContainer),anchorOffset:s.startOffset,focusPath:Di(e,s.endContainer),focusOffset:s.endOffset}}function nr(e,t){if(!t.insideHost)return;let n=e.ownerDocument,r=n==null?void 0:n.defaultView;if(!n||!r)return;let s=r.getSelection();if(!s)return;let o=Ii(e,t.anchorPath,t.anchorOffset),i=t.anchorPath===t.focusPath?o:Ii(e,t.focusPath,t.focusOffset);try{let c=n.createRange();c.setStart(o.node,o.offset),c.setEnd(i.node,i.offset),s.removeAllRanges(),s.addRange(c)}catch(c){}}function Di(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}function Ii(e,t,n){let r=e;for(let o of t){let i=r.childNodes.item(o);if(!i)return{node:r,offset:0};r=i}let s=Ga(r,n);return{node:r,offset:s}}function Ga(e,t){if(e.nodeType===3){let r=e.data.length;return Math.max(0,Math.min(t,r))}let n=e.childNodes.length;return Math.max(0,Math.min(t,n))}function Ni(e){var s,o;let t=(s=e.editable.ownerDocument)==null?void 0:s.defaultView;if(!t)return{disconnect:()=>{},drainPending:()=>{}};let n=(o=t.MutationObserver)!=null?o:globalThis.MutationObserver;if(!n)return{disconnect:()=>{},drainPending:()=>{}};let r=new n(i=>{var c;e.isApplyingRemote()||(c=e.fragment.doc)==null||c.transact(()=>{for(let l of i)qa(l,e)},at)});return r.observe(e.editable,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0}),{disconnect:()=>r.disconnect(),drainPending:()=>{r.takeRecords()}}}function qa(e,t){switch(e.type){case"characterData":za(e,t);break;case"childList":Ja(e,t);break;case"attributes":Wa(e,t);break}}function za(e,t){let n=e.target;if(n.nodeType!==3)return;let r=Za(n,t);if(!r)return;let s=n.data;r.toString()!==s&&(r.delete(0,r.length),r.insert(0,s))}function Ja(e,t){if(e.target===t.editable){Li(t);return}e.target.nodeType===1&&Ka(e.target,t)}function Ka(e,t){let n=vi(e,t);if(!n){Qa(t);return}n.delete(0,n.length);let r=Vi(Array.from(e.childNodes));r.children.length>0&&(n.insert(0,r.children),Es(r.marked))}function Wa(e,t){if(e.target.nodeType!==1)return;let n=e.target,r=vi(n,t);if(!r||e.attributeName===null)return;let s=n.getAttribute(e.attributeName);s===null?r.removeAttribute(e.attributeName):r.getAttribute(e.attributeName)!==s&&r.setAttribute(e.attributeName,s)}function Za(e,t){let n=Oi(t.editable,e);if(n.length===0)return null;let r=t.fragment;for(let o=0;o<n.length-1;o++){let i=n[o],c=r.get(i);if(!(c instanceof O))return null;r=c}let s=r.get(n[n.length-1]);return s instanceof K?s:null}function vi(e,t){let n=Oi(t.editable,e);if(n.length===0)return null;let r=t.fragment;for(let s of n){let o=r.get(s);if(!(o instanceof O))return null;r=o}return r instanceof O?r:null}function Oi(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}var Ss=new WeakSet;function Qa(e){Ss.has(e.fragment)||(Ss.add(e.fragment),queueMicrotask(()=>{var t;Ss.delete(e.fragment),(t=e.fragment.doc)==null||t.transact(()=>Li(e),at)}))}function Li(e){e.fragment.delete(0,e.fragment.length);let t=Mi(e.editable);t.children.length>0&&(e.fragment.insert(0,t.children),Es(t.marked))}function Mi(e){let t={children:[],marked:[]};for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes.item(n),s=Ri(r);if(s){s.node&&t.children.push(s.node);for(let o of s.marked)t.marked.push(o)}}return t}function Ri(e){if(e.nodeType===3)return{node:new K(e.data),marked:[]};if(e.nodeType!==1)return null;let t=e,n=t.tagName.toLowerCase(),r=Tt(n);if(r==="mark")return null;let s=new O(n);for(let i of Array.from(t.attributes))s.setAttribute(i.name,i.value);if(r==="leaf")return{node:s,marked:[]};let o=Vi(Array.from(t.childNodes));for(let i of o.children)s.insert(s.length,[i]);return{node:s,marked:o.marked}}function tu(){return{str:"",ranges:[]}}function Vi(e){let t={marked:[],children:[]},n=null,r=()=>{if(n&&n.str.length>0){let o=new K(n.str);t.children.push(o),n.ranges.length>0&&t.marked.push({text:o,ranges:n.ranges})}n=null},s=()=>(n||(n=tu()),n);for(let o of e){if(o.nodeType===3){let a=o.data;if(a.length===0)continue;let u=s();u.str+=a;continue}if(o.nodeType!==1)continue;let i=o,c=i.tagName.toLowerCase(),l=Tt(c);if(l==="mark"){let a=s(),u=Fi(i);Bi(i,a,u);continue}if(r(),l==="leaf"){let a=new O(c);for(let u of Array.from(i.attributes))a.setAttribute(u.name,u.value);t.children.push(a)}else{let a=Ri(i);if(a&&a.node){t.children.push(a.node);for(let u of a.marked)t.marked.push(u)}}}return r(),t}function Bi(e,t,n){for(let r of Array.from(e.childNodes)){if(r.nodeType===3){let i=r.data;if(i.length===0)continue;let c=t.str.length;t.str+=i;let l=t.str.length;Object.keys(n).length>0&&t.ranges.push({start:c,end:l,marks:n});continue}if(r.nodeType!==1)continue;let s=r;if(Tt(s.tagName.toLowerCase())==="mark"){let i={...n,...Fi(s)};Bi(s,t,i)}}}function Es(e){for(let t of e)for(let n of t.ranges){let r=n.end-n.start;r<=0||t.text.format(n.start,r,n.marks)}}var As={buildYNodesFromDom:Mi,applyDeferredMarks:Es};function Fi(e){switch(e.tagName.toLowerCase()){case"strong":case"b":return{bold:!0};case"em":case"i":return{italic:!0};case"u":return{underline:!0};case"s":case"strike":case"del":return{strikethrough:!0};case"sub":return{subscript:!0};case"sup":return{superscript:!0};case"code":case"kbd":case"samp":return{code:!0};case"a":{let n=e.getAttribute("href");return n?{link:n}:{}}case"span":case"font":return eu(e);default:return{}}}function eu(e){var r;let t={},n=(r=e.getAttribute("style"))!=null?r:"";for(let s of n.split(";")){let[o,...i]=s.split(":");if(!o||i.length===0)continue;let c=o.trim().toLowerCase(),l=i.join(":").trim();if(l)switch(c){case"color":t.color=l;break;case"background-color":case"background":t.backcolor=l;break;case"font-family":t.fontFamily=l;break;case"font-size":t.fontSize=l;break}}if(e.tagName.toLowerCase()==="font"){let s=e.getAttribute("color");s&&(t.color=s);let o=e.getAttribute("face");o&&(t.fontFamily=o)}return t}function rr(e){var d,h,f;let t=(d=e.fragmentName)!=null?d:"default",n=e.ydoc.getXmlFragment(t),r=(f=e.awareness)!=null?f:(h=e.provider)==null?void 0:h.awareness,s=!1,o=Ni({editable:e.editable,fragment:n,isApplyingRemote:()=>s});s=!0;try{nn(n,e.editable)}finally{o.drainPending(),s=!1}let i=(p,y)=>{if(y===at)return;let g=er(e.editable);s=!0;try{nn(n,e.editable)}finally{o.drainPending(),s=!1}nr(e.editable,g)};e.ydoc.on("update",i);let c=()=>{e.ydoc.off("update",i)},l=()=>o.disconnect(),a=nu(r,e.initialAwareness),u=[c,l,a];return{ydoc:e.ydoc,fragment:n,dispose(){for(let p of u)try{p()}catch(y){console.error("[crdt-engine] dispose cleanup error:",y)}u=[]}}}function nu(e,t){return e?(t&&e.setLocalState(t),()=>e.setLocalState(null)):()=>{}}function $i(e){var n;let t=new Set([at]);if(e.extraTrackedOrigins)for(let r of e.extraTrackedOrigins)t.add(r);return new qe(e.fragment,{trackedOrigins:t,captureTimeout:(n=e.captureTimeoutMs)!=null?n:500})}var ru=32;function Pi(e){var u,d;let t=(u=e.editable.ownerDocument)==null?void 0:u.defaultView,n=e.editable.ownerDocument,r=(d=e.throttleMs)!=null?d:ru,s=null,o=null,i=null,c=()=>{var w;if(!n)return;let h=t==null?void 0:t.getSelection();if(!h||h.rangeCount===0){e.awareness.setLocalStateField("cursor",null);return}let f=h.getRangeAt(0);if(!e.editable.contains(f.startContainer)||!e.editable.contains(f.endContainer)){e.awareness.setLocalStateField("cursor",null);return}let p=Yi(e.fragment,e.editable,f.startContainer,f.startOffset),y=h.isCollapsed?p:Yi(e.fragment,e.editable,f.endContainer,f.endOffset);if(!p||!y){e.awareness.setLocalStateField("cursor",null);return}if(s&&o&&Hi(s,p)&&Hi(o,y))return;s=p,o=y;let g={...e.user?{user:e.user}:{},cursor:{anchor:{encoded:p},head:{encoded:y}}};e.awareness.setLocalState({...(w=e.awareness.getStates().get(e.awareness.clientID))!=null?w:{},...g,active:Date.now()})},l=()=>{i==null&&(i=setTimeout(()=>{i=null,c()},r))},a=()=>l();return n&&n.addEventListener("selectionchange",a),{dispose(){i!=null&&clearTimeout(i),n&&n.removeEventListener("selectionchange",a),e.awareness.setLocalStateField("cursor",null)},publishNow(){i!=null&&(clearTimeout(i),i=null),c()},snapshotPeers(){var f,p;let h=[];for(let[y,g]of e.awareness.getStates()){if(y===e.awareness.clientID)continue;let w=g;if(!w.cursor)continue;let U=ji(e.fragment,e.editable,w.cursor.anchor.encoded),Ut=w.cursor.head===w.cursor.anchor?U:ji(e.fragment,e.editable,w.cursor.head.encoded);h.push({clientID:y,user:(f=w.user)!=null?f:{},anchor:U,head:Ut,isCollapsed:U!==null&&Ut!==null&&U.node===Ut.node&&U.offset===Ut.offset,activeAt:(p=w.active)!=null?p:0})}return h}}}function Yi(e,t,n,r){let s=su(e,t,n,r);if(!s)return null;try{let o=ls(s.parent,s.index);return as(o)}catch(o){return null}}function ji(e,t,n){if(!e.doc)return null;try{let r=us(n),s=ds(r,e.doc);return s?ou(t,s.type,s.index):null}catch(r){return null}}function su(e,t,n,r){var u;let s=[],o=r,i=n;if(i.nodeType===3)for(;i&&i!==t;){let d=i.parentNode;if(!d)break;let h=0,f=d.firstChild;for(;f&&f!==i;)h+=_s(f),f=f.nextSibling;if(o+=h,d===t||cu(d)){i=d;break}i=d}else if(i.nodeType===1){let d=0;for(let h=0;h<r&&h<i.childNodes.length;h++)d+=_s(i.childNodes.item(h));o=d}if(i===t){let d=(u=lu(t,n===t?t:n).at(0))!=null?u:0;return{parent:e,index:d}}let c=i;for(;c&&c!==t;){let d=c.parentNode;if(!d)return null;let h=0,f=d.firstChild;for(;f&&f!==c;)h++,f=f.nextSibling;s.unshift(h),c=d}let l=e;for(let d of s){let h=l.get(d);if(!(h instanceof O))return null;l=h}let a=l.get(0);return a instanceof K?{parent:a,index:o}:{parent:l,index:0}}function ou(e,t,n){let r=[],s=t,o=!0;for(;s;){let l=s._item;if(!l)break;let a=l.parent;if(!a)break;let u=0,d=!1;if(a instanceof pt||a instanceof O){for(let h=0;h<a.length;h++)if(a.get(h)===s){u=h,d=!0;break}}if(!d)break;o&&t instanceof K||r.unshift(u),o=!1,s=a}let i=e;for(let l of r){let a=i.childNodes.item(l);if(!a)return null;i=a}return iu(i,n)}function iu(e,t){let n=t,r=[];for(let s=e.childNodes.length-1;s>=0;s--)r.push(e.childNodes.item(s));for(;r.length>0;){let s=r.pop();if(s.nodeType===3){let o=s.data.length;if(n<=o)return{node:s,offset:n};n-=o;continue}if(s.nodeType===1)for(let o=s.childNodes.length-1;o>=0;o--)r.push(s.childNodes.item(o))}return{node:e,offset:e.childNodes.length}}function _s(e){if(e.nodeType===3)return e.data.length;let t=0;for(let n=0;n<e.childNodes.length;n++)t+=_s(e.childNodes.item(n));return t}function cu(e){if(e.nodeType!==1)return!1;let t=e.tagName.toLowerCase();return!["strong","b","em","i","u","s","strike","del","ins","mark","small","sub","sup","code","kbd","samp","var","span","font","a"].includes(t)}function lu(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}function Hi(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Xi(e){var r,s;let t=(r=e.textSync)!=null?r:!1;if(t==="crdt")return rr(e);if(t===!0){if(!e.legacySnapshotAttach)throw new Error("[crdt-engine] textSync: true requires `legacySnapshotAttach` to be provided by the host. See M5.1 in the sprint README for the back-compat contract.");return e.legacySnapshotAttach(e)}let n=e.ydoc.getXmlFragment((s=e.fragmentName)!=null?s:"default");return{ydoc:e.ydoc,fragment:n,dispose(){}}}function Gi(e){var c;let t=(c=e.fragmentName)!=null?c:"default",n=e.ydoc.getXmlFragment(t),r=e.parserDocument.createElement("div");r.innerHTML=e.html;let s=r,o=r.querySelector("body");o&&(s=o);let i=As.buildYNodesFromDom(s);return e.replace!==!1&&n.length>0&&n.delete(0,n.length),i.children.length>0&&(n.insert(n.length,i.children),As.applyDeferredMarks(i.marked)),n}var Ts=3e4,sr=class extends ln{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let n=xt();this.getLocalState()!==null&&Ts/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((s,o)=>{o!==this.clientID&&Ts<=n-s.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&au(this,r,"timeout")},L(Ts/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){let n=this.clientID,r=this.meta.get(n),s=r===void 0?0:r.clock+1,o=this.states.get(n);t===null?this.states.delete(n):this.states.set(n,t),this.meta.set(n,{clock:s,lastUpdated:xt()});let i=[],c=[],l=[],a=[];t===null?a.push(n):o==null?t!=null&&i.push(n):(c.push(n),Rt(o,t)||l.push(n)),(i.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:i,updated:l,removed:a},"local"]),this.emit("update",[{added:i,updated:c,removed:a},"local"])}setLocalStateField(t,n){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[t]:n})}getStates(){return this.states}},au=(e,t,n)=>{let r=[];for(let s=0;s<t.length;s++){let o=t[s];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){let i=e.meta.get(o);e.meta.set(o,{clock:i.clock+1,lastUpdated:xt()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))};typeof window!="undefined"&&(window.RichTextEditorCrdt=Object.assign({},Cs,{Y:Jt,Awareness:sr}));})();
|
|
1
|
+
"use strict";(()=>{var Ys=Object.defineProperty;var lc=(e,t,n)=>t in e?Ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var js=(e,t)=>{for(var n in t)Ys(e,n,{get:t[n],enumerable:!0})};var pn=(e,t,n)=>lc(e,typeof t!="symbol"?t+"":t,n);var Ms={};js(Ms,{BLOCK_TAGS:()=>_s,INLINE_MARK_TAGS:()=>Us,LEAF_TAGS:()=>Ds,LOCAL_ORIGIN:()=>it,SUPPORTED_MARKS:()=>hn,attachAwareness:()=>oc,attachCollab:()=>ic,attachCrdtBinding:()=>fr,attachUndoManager:()=>ec,captureSelection:()=>dr,classify:()=>Rt,htmlToYFragment:()=>cc,renderFragmentToHost:()=>fn,renderYNodeToDom:()=>ur,restoreSelection:()=>hr});var Mt={};js(Mt,{AbsolutePosition:()=>Jn,AbstractConnector:()=>es,AbstractStruct:()=>Ue,AbstractType:()=>T,Array:()=>Zt,ContentAny:()=>Lt,ContentBinary:()=>te,ContentDeleted:()=>De,ContentDoc:()=>ee,ContentEmbed:()=>Et,ContentFormat:()=>_,ContentJSON:()=>un,ContentString:()=>ot,ContentType:()=>rt,Doc:()=>Nt,GC:()=>P,ID:()=>xt,Item:()=>S,Map:()=>Qt,PermanentUserData:()=>rs,RelativePosition:()=>Te,Skip:()=>V,Snapshot:()=>en,Text:()=>_e,Transaction:()=>Wn,UndoManager:()=>nn,UpdateDecoderV1:()=>J,UpdateDecoderV2:()=>X,UpdateEncoderV1:()=>pt,UpdateEncoderV2:()=>tt,XmlElement:()=>L,XmlFragment:()=>St,XmlHook:()=>an,XmlText:()=>G,YArrayEvent:()=>tr,YEvent:()=>Wt,YMapEvent:()=>er,YTextEvent:()=>nr,YXmlEvent:()=>rr,applyUpdate:()=>Vl,applyUpdateV2:()=>ir,cleanupYTextFormatting:()=>Oi,compareIDs:()=>Gt,compareRelativePositions:()=>Kl,convertUpdateFormatV1ToV2:()=>wa,convertUpdateFormatV2ToV1:()=>mi,createAbsolutePositionFromRelativePosition:()=>Ie,createDeleteSet:()=>or,createDeleteSetFromStructStore:()=>hs,createDocFromSnapshot:()=>na,createID:()=>b,createRelativePositionFromJSON:()=>Xl,createRelativePositionFromTypeIndex:()=>ve,createSnapshot:()=>xs,decodeRelativePosition:()=>bs,decodeSnapshot:()=>Ql,decodeSnapshotV2:()=>ri,decodeStateVector:()=>gs,decodeUpdate:()=>ua,decodeUpdateV2:()=>ui,diffUpdate:()=>pa,diffUpdateV2:()=>ks,emptySnapshot:()=>ta,encodeRelativePosition:()=>ys,encodeSnapshot:()=>Zl,encodeSnapshotV2:()=>ni,encodeStateAsUpdate:()=>Fl,encodeStateAsUpdateV2:()=>Qo,encodeStateVector:()=>jl,encodeStateVectorFromUpdate:()=>da,encodeStateVectorFromUpdateV2:()=>hi,equalDeleteSets:()=>Wo,equalSnapshots:()=>Wl,findIndexSS:()=>nt,findRootTypeKey:()=>ws,getItem:()=>qt,getItemCleanEnd:()=>is,getItemCleanStart:()=>j,getState:()=>E,getTypeChildren:()=>ka,isDeleted:()=>ne,isParentOf:()=>tn,iterateDeletedStructs:()=>zt,logType:()=>Pl,logUpdate:()=>aa,logUpdateV2:()=>ai,mergeDeleteSets:()=>Jt,mergeUpdates:()=>di,mergeUpdatesV2:()=>sn,obfuscateUpdate:()=>ga,obfuscateUpdateV2:()=>ma,parseUpdateMeta:()=>ha,parseUpdateMetaV2:()=>fi,readUpdate:()=>Rl,readUpdateV2:()=>ps,relativePositionToJSON:()=>Hl,snapshot:()=>ea,snapshotContainsUpdate:()=>sa,transact:()=>k,tryGc:()=>ca,typeListToArraySnapshot:()=>Sa,typeMapGetAllSnapshot:()=>Ui,typeMapGetSnapshot:()=>Ca});var A=()=>new Map,gn=e=>{let t=A();return e.forEach((n,r)=>{t.set(r,n)}),t},Y=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ps=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},Hs=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var at=()=>new Set;var mn=e=>e[e.length-1];var Xs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},st=Array.from,wn=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Le=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var Gs=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var yt=Array.isArray;var re=class{constructor(){this._observers=A()}on(t,n){return Y(this._observers,t,at).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return st((this._observers.get(t)||A()).values()).forEach(r=>r(...n))}destroy(){this._observers=A()}},yn=class{constructor(){this._observers=A()}on(t,n){Y(this._observers,t,at).add(n)}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return st((this._observers.get(t)||A()).values()).forEach(r=>r(...n))}destroy(){this._observers=A()}};var M=Math.floor;var Vt=Math.abs;var bn=(e,t)=>e<t?e:t,bt=(e,t)=>e>t?e:t,Cu=Number.isNaN;var xn=e=>e!==0?e<0:1/e<0;var oe=Number.MAX_SAFE_INTEGER,mr=Number.MIN_SAFE_INTEGER,Tu=1<<31;var qs=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&M(e)===e),_u=Number.isNaN,Uu=Number.parseInt;var yr=String.fromCharCode,ac=String.fromCodePoint,Du=yr(65535),uc=e=>e.toLowerCase(),dc=/^\s*/g,hc=e=>e.replace(dc,""),fc=/([A-Z])/g,br=(e,t)=>hc(e.replace(fc,n=>`${t}${uc(n)}`));var pc=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},ce=typeof TextEncoder!="undefined"?new TextEncoder:null,gc=e=>ce.encode(e),zs=ce?gc:pc;var ie=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ie&&ie.decode(new Uint8Array).length===1&&(ie=null);var kn=(e,t)=>Gs(t,()=>e).join("");var Bt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},$t=()=>new Bt;var mc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var W=e=>{let t=new Uint8Array(mc(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},wc=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(bt(n,t)*2),e.cpos=0)},I=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var de=I;var y=(e,t)=>{for(;t>127;)I(e,128|127&t),t=M(t/128);I(e,127&t)},Be=(e,t)=>{let n=xn(t);for(n&&(t=-t),I(e,(t>63?128:0)|(n?64:0)|63&t),t=M(t/64);t>0;)I(e,(t>127?128:0)|127&t),t=M(t/128)},xr=new Uint8Array(3e4),yc=xr.length/3,bc=(e,t)=>{if(t.length<yc){let n=ce.encodeInto(t,xr).written||0;y(e,n);for(let r=0;r<n;r++)I(e,xr[r])}else q(e,zs(t))},xc=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;y(e,r);for(let s=0;s<r;s++)I(e,n.codePointAt(s))},At=ce&&ce.encodeInto?bc:xc;var Qs=(e,t)=>he(e,W(t)),he=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=bn(n-r,t.length),o=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,o>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(bt(n*2,o)),e.cbuf.set(t.subarray(s)),e.cpos=o)},q=(e,t)=>{y(e,t.byteLength),he(e,t)},kr=(e,t)=>{wc(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},kc=(e,t)=>kr(e,4).setFloat32(0,t,!1),Sc=(e,t)=>kr(e,8).setFloat64(0,t,!1),Ec=(e,t)=>kr(e,8).setBigInt64(0,t,!1);var Ks=new DataView(new ArrayBuffer(4)),Ac=e=>(Ks.setFloat32(0,e),Ks.getFloat32(0)===e),ae=(e,t)=>{switch(typeof t){case"string":I(e,119),At(e,t);break;case"number":qs(t)&&Vt(t)<=2147483647?(I(e,125),Be(e,t)):Ac(t)?(I(e,124),kc(e,t)):(I(e,123),Sc(e,t));break;case"bigint":I(e,122),Ec(e,t);break;case"object":if(t===null)I(e,126);else if(yt(t)){I(e,117),y(e,t.length);for(let n=0;n<t.length;n++)ae(e,t[n])}else if(t instanceof Uint8Array)I(e,116),q(e,t);else{I(e,118);let n=Object.keys(t);y(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];At(e,s),ae(e,t[s])}}break;case"boolean":I(e,t?120:121);break;default:I(e,127)}},Ve=class extends Bt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&y(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var Ws=e=>{e.count>0&&(Be(e.encoder,e.count===1?e.s:-e.s),e.count>1&&y(e.encoder,e.count-2))},Ft=class{constructor(){this.encoder=new Bt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Ws(this),this.count=1,this.s=t)}toUint8Array(){return Ws(this),W(this.encoder)}};var Zs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Be(e.encoder,t),e.count>1&&y(e.encoder,e.count-2)}},ue=class{constructor(){this.encoder=new Bt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Zs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Zs(this),W(this.encoder)}},Sn=class{constructor(){this.sarr=[],this.s="",this.lensE=new Ft}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new Bt;return this.sarr.push(this.s),this.s="",At(t,this.sarr.join("")),he(t,this.lensE.toUint8Array()),W(t)}};var Z=e=>new Error(e),Q=()=>{throw Z("Method unimplemented")},N=()=>{throw Z("Unexpected case")};var to=Z("Unexpected end of array"),eo=Z("Integer out of Range"),fe=class{constructor(t){this.arr=t,this.pos=0}},R=e=>new fe(e),Er=e=>e.pos!==e.arr.length;var Tc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},z=e=>Tc(e,x(e));var Yt=e=>e.arr[e.pos++];var x=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>oe)throw eo}throw to},$e=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*n;let o=e.arr.length;for(;e.pos<o;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>oe)throw eo}throw to};var _c=e=>{let t=x(e);if(t===0)return"";{let n=String.fromCodePoint(Yt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Yt(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},Uc=e=>ie.decode(z(e)),Tt=ie?Uc:_c;var Ar=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Dc=e=>Ar(e,4).getFloat32(0,!1),vc=e=>Ar(e,8).getFloat64(0,!1),Ic=e=>Ar(e,8).getBigInt64(0,!1);var Nc=[e=>{},e=>null,$e,Dc,vc,Ic,e=>!1,e=>!0,Tt,e=>{let t=x(e),n={};for(let r=0;r<t;r++){let s=Tt(e);n[s]=pe(e)}return n},e=>{let t=x(e),n=[];for(let r=0;r<t;r++)n.push(pe(e));return n},z],pe=e=>Nc[127-Yt(e)](e),Fe=class extends fe{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Er(this)?this.count=x(this)+1:this.count=-1),this.count--,this.s}};var jt=class extends fe{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=$e(this);let t=xn(this.s);this.count=1,t&&(this.s=-this.s,this.count=x(this)+2)}return this.count--,this.s}};var ge=class extends fe{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=$e(this),n=t&1;this.diff=M(t/2),this.count=1,n&&(this.count=x(this)+2)}return this.s+=this.diff,this.count--,this.s}},En=class{constructor(t){this.decoder=new jt(t),this.str=Tt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var Nu=crypto.subtle,no=crypto.getRandomValues.bind(crypto);var Cr=()=>no(new Uint32Array(1))[0];var Lc="10000000-1000-4000-8000"+-1e11,ro=()=>Lc.replace(/[018]/g,e=>(e^Cr()&15>>e/4).toString(16));var _t=Date.now;var _r=e=>new Promise(e);var Mu=Promise.all.bind(Promise);var Ur=e=>e===void 0?null:e;var Dr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},so=new Dr,Bc=!0;try{typeof localStorage!="undefined"&&localStorage&&(so=localStorage,Bc=!1)}catch(e){}var oo=so;var Pt=Symbol("Equality"),An=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[Pt])!=null&&n.call(e,t))||!1};var io=e=>typeof e=="object",co=Object.assign,$c=Object.keys;var lo=(e,t)=>{for(let n in e)t(e[n],n)};var Ye=e=>$c(e).length;var ao=e=>{for(let t in e)return!1;return!0},me=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},je=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ir=(e,t)=>e===t||Ye(e)===Ye(t)&&me(e,(n,r)=>(n!==void 0||je(t,r))&&An(t[r],n)),Yc=Object.freeze,Nr=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&Nr(e[t])}return Yc(e)};var Pe=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Pe(e,t,n+1)}};var Lr=e=>e;var Ht=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Pt]!=null)return e[Pt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Ht(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(Ye(e)!==Ye(t))return!1;for(let n in e)if(!je(e,n)||!Ht(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ht(e[n],t[n]))return!1;break;default:return!1}return!0},uo=(e,t)=>t.includes(e);var He=typeof process!="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var Ru=typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1,ut,jc=[],Pc=()=>{if(ut===void 0)if(He){ut=A();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&ut.set(t,""),t=r):t!==null?(ut.set(t,r),t=null):jc.push(r)}t!==null&&ut.set(t,"")}else typeof location=="object"?(ut=A(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");ut.set(`--${br(t,"-")}`,n),ut.set(`-${br(t,"-")}`,n)}})):ut=A();return ut},Mr=e=>Pc().has(e);var Xe=e=>He?Ur(process.env[e.toUpperCase().replaceAll("-","_")]):Ur(oo.getItem(e));var ho=e=>Mr("--"+e)||Xe(e)!==null,fo=ho("production"),Hc=He&&uo(process.env.FORCE_COLOR,["true","1","2"]),po=Hc||!Mr("--no-colors")&&!ho("no-color")&&(!He||process.stdout.isTTY)&&(!He||Mr("--color")||Xe("COLORTERM")!==null||(Xe("TERM")||"").includes("color"));var Xc=e=>new Uint8Array(e);var go=e=>{let t=Xc(e.byteLength);return t.set(e),t};var Vr=class{constructor(t,n){this.left=t,this.right=n}},dt=(e,t)=>new Vr(e,t);var Br=e=>e.next()>=.5,Tn=(e,t,n)=>M(e.next()*(n+1-t)+t);var Fr=(e,t,n)=>M(e.next()*(n+1-t)+t);var $r=(e,t,n)=>Fr(e,t,n);var zc=e=>yr($r(e,97,122)),mo=(e,t=0,n=20)=>{let r=$r(e,t,n),s="";for(let o=0;o<r;o++)s+=zc(e);return s};var _n=(e,t)=>t[$r(e,0,t.length-1)];var Kc=Symbol("0schema"),Yr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(kn(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
+
`)}},jr=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Pt]?An(e,t):yt(e)?wn(e,n=>Le(t,r=>jr(n,r))):io(e)?me(e,(n,r)=>jr(n,t[r])):!1,O=class{extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),jr(n,r)}equals(t){return this.constructor===t.constructor&&Ht(this.shape,t.shape)}[Kc](){return!0}[Pt](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){Q()}get nullable(){return Se(this,$n)}get optional(){return new Un(this)}cast(t){return wo(t,this),t}expect(t){return wo(t,this),t}};pn(O,"_dilutes",!1);var Ge=class extends O{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=(t==null?void 0:t.constructor)===this.shape&&(this._c==null||this._c(t));return!r&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name,(t==null?void 0:t.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}},D=(e,t=null)=>new Ge(e,t),Bu=D(Ge),qe=class extends O{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&(n==null||n.extend(null,"custom prop",t==null?void 0:t.constructor.name,"failed to check custom prop")),r}},v=e=>new qe(e),Fu=D(qe),xe=class extends O{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&(n==null||n.extend(null,this.shape.join(" | "),t.toString())),r}},Bn=(...e)=>new xe(e),yo=D(xe),Wc=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),bo=e=>{if(ke.check(e))return[Wc(e)];if(yo.check(e))return e.shape.map(t=>t+"");if(Ao.check(e))return["[+-]?\\d+.?\\d*"];if(Co.check(e))return[".*"];if(Mn.check(e))return e.shape.map(bo).flat(1);N()},Pr=class extends O{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(bo).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),t.toString(),"String doesn't match string template.")),r}};var $u=D(Pr),Zc=Symbol("optional"),Un=class extends O{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[Zc](){return!0}},Qc=D(Un),Dn=class extends O{check(t,n){return n==null||n.extend(null,"never",typeof t),!1}},Yu=new Dn,ju=D(Dn),Vn=class Vn extends O{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new Vn(this.shape,!0)}check(t,n){return t==null?(n==null||n.extend(null,"object","null"),!1):me(this.shape,(r,s)=>{let o=this._isPartial&&!je(t,s)||r.check(t[s],n);return!o&&(n==null||n.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match")),o})}};pn(Vn,"_dilutes",!0);var vn=Vn,tl=e=>new vn(e),el=D(vn),nl=v(e=>e!=null&&(e.constructor===Object||e.constructor==null)),In=class extends O{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&me(t,(r,s)=>{let o=this.shape.keys.check(s,n);return!o&&(n==null||n.extend(s+"","Record",typeof t,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,n)})}},xo=(e,t)=>new In(e,t),rl=D(In),Nn=class extends O{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&me(this.shape,(r,s)=>{let o=r.check(t[s],n);return!o&&(n==null||n.extend(s.toString(),"Tuple",typeof r)),o})}},sl=(...e)=>new Nn(e),Pu=D(Nn),On=class extends O{constructor(t){super(),this.shape=t.length===1?t[0]:new ye(t)}check(t,n){let r=yt(t)&&wn(t,s=>this.shape.check(s));return!r&&(n==null||n.extend(null,"Array","")),r}},ko=(...e)=>new On(e),ol=D(On),il=v(e=>yt(e)),Ln=class extends O{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name)),r}},cl=(e,t=null)=>new Ln(e,t),Hu=D(Ln),ll=cl(O),Hr=class extends O{constructor(t){super(),this.len=t.length-1,this.args=sl(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof t)),r}};var al=D(Hr),ul=v(e=>typeof e=="function"),Xr=class extends O{constructor(t){super(),this.shape=t}check(t,n){let r=wn(this.shape,s=>s.check(t,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof t)),r}};var Xu=D(Xr,e=>e.shape.length>0),ye=class extends O{constructor(t){super(),this.shape=t}check(t,n){let r=Le(this.shape,s=>s.check(t,n));return n==null||n.extend(null,"Union",typeof t),r}};pn(ye,"_dilutes",!0);var Se=(...e)=>e.findIndex(t=>Mn.check(t))>=0?Se(...e.map(t=>ze(t)).map(t=>Mn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new ye(e),Mn=D(ye),So=()=>!0,Rn=v(So),dl=D(qe,e=>e.shape===So),qr=v(e=>typeof e=="bigint"),hl=v(e=>e===qr),Eo=v(e=>typeof e=="symbol"),Gu=v(e=>e===Eo),be=v(e=>typeof e=="number"),Ao=v(e=>e===be),ke=v(e=>typeof e=="string"),Co=v(e=>e===ke),Fn=v(e=>typeof e=="boolean"),fl=v(e=>e===Fn),To=Bn(void 0),qu=D(xe,e=>e.shape.length===1&&e.shape[0]===void 0),zu=Bn(void 0);var $n=Bn(null),pl=D(xe,e=>e.shape.length===1&&e.shape[0]===null),Ju=D(Uint8Array),Ku=D(Ge,e=>e.shape===Uint8Array),gl=Se(be,ke,$n,To,qr,Fn,Eo),Wu=(()=>{let e=ko(Rn),t=xo(ke,Rn),n=Se(be,ke,$n,Fn,e,t);return e.shape=n,t.shape.values=n,n})(),ze=e=>{if(ll.check(e))return e;if(nl.check(e)){let t={};for(let n in e)t[n]=ze(e[n]);return tl(t)}else{if(il.check(e))return Se(...e.map(ze));if(gl.check(e))return Bn(e);if(ul.check(e))return D(e)}N()},wo=fo?()=>{}:(e,t)=>{let n=new Yr;if(!t.check(e,n))throw Z(`Expected value to be of type ${t.constructor.name}.
|
|
3
|
+
${n.toString()}`)},Gr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:ze(t),h:n}),this}else(t){return this.if(Rn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw Z("Unhandled pattern")}}},ml=e=>new Gr(e),_o=ml(Rn).if(Ao,(e,t)=>Tn(t,mr,oe)).if(Co,(e,t)=>mo(t)).if(fl,(e,t)=>Br(t)).if(hl,(e,t)=>BigInt(Tn(t,mr,oe))).if(Mn,(e,t)=>we(t,_n(t,e.shape))).if(el,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Qc.check(s)){if(Br(t))continue;s=s.shape}n[r]=_o(s,t)}return n}).if(ol,(e,t)=>{let n=[],r=Fr(t,0,42);for(let s=0;s<r;s++)n.push(we(t,e.shape));return n}).if(yo,(e,t)=>_n(t,e.shape)).if(pl,(e,t)=>null).if(al,(e,t)=>{let n=we(t,e.res);return()=>n}).if(dl,(e,t)=>we(t,_n(t,[be,ke,$n,To,qr,Fn,ko(be),xo(Se("a","b","c"),be)]))).if(rl,(e,t)=>{let n={},r=Tn(t,0,3);for(let s=0;s<r;s++){let o=we(t,e.shape.keys),i=we(t,e.shape.values);n[o]=i}return n}).done(),we=(e,t)=>_o(ze(t),e);var Xt=typeof document!="undefined"?document:{};var Qu=v(e=>e.nodeType===kl);var td=typeof DOMParser!="undefined"?new DOMParser:null;var ed=v(e=>e.nodeType===yl);var nd=v(e=>e.nodeType===bl);var Uo=e=>Ps(e,(t,n)=>`${n}:${t};`).join("");var yl=Xt.ELEMENT_NODE,bl=Xt.TEXT_NODE,rd=Xt.CDATA_SECTION_NODE,sd=Xt.COMMENT_NODE,xl=Xt.DOCUMENT_NODE,od=Xt.DOCUMENT_TYPE_NODE,kl=Xt.DOCUMENT_FRAGMENT_NODE,id=v(e=>e.nodeType===xl);var ht=Symbol;var Je=ht(),Ke=ht(),zr=ht(),Jr=ht(),Kr=ht(),We=ht(),Wr=ht(),Ee=ht(),Zr=ht(),Do=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let o=e[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let o=e[r];o instanceof Symbol||n.push(o)}return n};var cd=_t();var Cl={[Je]:dt("font-weight","bold"),[Ke]:dt("font-weight","normal"),[zr]:dt("color","blue"),[Kr]:dt("color","green"),[Jr]:dt("color","grey"),[We]:dt("color","red"),[Wr]:dt("color","purple"),[Ee]:dt("color","orange"),[Zr]:dt("color","black")},Tl=e=>{var i;e.length===1&&((i=e[0])==null?void 0:i.constructor)===Function&&(e=e[0]());let t=[],n=[],r=A(),s=[],o=0;for(;o<e.length;o++){let c=e[o],l=Cl[c];if(l!==void 0)r.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let a=Uo(r);o>0||a.length>0?(t.push("%c"+c),n.push(a)):t.push(c)}else break}}for(o>0&&(s=n,s.unshift(t.join("")));o<e.length;o++){let c=e[o];c instanceof Symbol||s.push(c)}return s},vo=po?Tl:Do,Yn=(...e)=>{console.log(...vo(e)),Io.forEach(t=>t.print(e))},Qr=(...e)=>{console.warn(...vo(e)),e.unshift(Ee),Io.forEach(t=>t.print(e))};var Io=at();var No=e=>({[Symbol.iterator](){return this},next:e}),Oo=(e,t)=>No(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),jn=(e,t)=>No(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var es=class extends re{constructor(t,n){super(),this.doc=t,this.awareness=n}},Ae=class{constructor(t,n){this.clock=t,this.len=n}},It=class{constructor(){this.clients=new Map}},zt=(e,t,n)=>t.clients.forEach((r,s)=>{let o=e.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let l=0,a=r[l];l<r.length&&a.clock<c;a=r[++l])oi(e,o,a.clock,a.len,n)}}),Il=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=M((n+r)/2),o=e[s],i=o.clock;if(i<=t){if(t<i+o.len)return s;n=s+1}else r=s-1}return null},ne=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Il(n,t.clock)!==null},ds=e=>{e.clients.forEach(t=>{t.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],o=t[n];s.clock+s.len>=o.clock?t[r-1]=new Ae(s.clock,bt(s.len,o.clock+o.len-s.clock)):(r<n&&(t[r]=o),r++)}t.length=r})},Jt=e=>{let t=new It;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let o=r.slice();for(let i=n+1;i<e.length;i++)Xs(o,e[i].clients.get(s)||[]);t.clients.set(s,o)}});return ds(t),t},Qe=(e,t,n,r)=>{Y(e.clients,t,()=>[]).push(new Ae(n,r))},or=()=>new It,hs=e=>{let t=or();return e.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,l=i.length;if(o+1<n.length)for(let a=n[o+1];o+1<n.length&&a.deleted;a=n[++o+1])l+=a.length;s.push(new Ae(c,l))}}s.length>0&&t.clients.set(r,s)}),t},ft=(e,t)=>{y(e.restEncoder,t.clients.size),st(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),y(e.restEncoder,n);let s=r.length;y(e.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},kt=e=>{let t=new It,n=x(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=x(e.restDecoder),o=x(e.restDecoder);if(o>0){let i=Y(t.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new Ae(e.readDsClock(),e.readDsLen()))}}return t},Ro=(e,t,n)=>{let r=new It,s=x(e.restDecoder);for(let o=0;o<s;o++){e.resetDsCurVal();let i=x(e.restDecoder),c=x(e.restDecoder),l=n.clients.get(i)||[],a=E(n,i);for(let u=0;u<c;u++){let d=e.readDsClock(),h=d+e.readDsLen();if(d<a){a<h&&Qe(r,i,a,h-a);let f=nt(l,d),p=l[f];for(!p.deleted&&p.id.clock<d&&(l.splice(f+1,0,sr(t,p,d-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&l.splice(f,0,sr(t,p,h-p.id.clock)),p.delete(t))}else Qe(r,i,d,h-d)}}if(r.clients.size>0){let o=new tt;return y(o.restEncoder,0),ft(o,r),o.toUint8Array()}return null},Wo=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let o=0;o<r.length;o++){let i=r[o],c=s[o];if(i.clock!==c.clock||i.len!==c.len)return!1}}return!0},Zo=Cr,Nt=class e extends re{constructor({guid:t=ro(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:o=null,autoLoad:i=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=Zo(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Kn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=i,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_r(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let l=()=>_r(a=>{let u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),a())};this.on("sync",u)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&k(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(st(this.subdocs).map(t=>t.guid))}transact(t,n=null){return k(this,t,n)}get(t,n=T){let r=Y(this.share,t,()=>{let o=new n;return o._integrate(this,null),o}),s=r.constructor;if(n!==T&&s!==n)if(s===T){let o=new n;o._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=o}),o._start=r._start;for(let i=o._start;i!==null;i=i.right)i.parent=o;return o._length=r._length,this.share.set(t,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,Zt)}getText(t=""){return this.get(t,_e)}getMap(t=""){return this.get(t,Qt)}getXmlElement(t=""){return this.get(t,L)}getXmlFragment(t=""){return this.get(t,St)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,st(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,k(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Kt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}},J=class extends Kt{readLeftID(){return b(x(this.restDecoder),x(this.restDecoder))}readRightID(){return b(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return Yt(this.restDecoder)}readString(){return Tt(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return pe(this.restDecoder)}readBuf(){return go(z(this.restDecoder))}readJSON(){return JSON.parse(Tt(this.restDecoder))}readKey(){return Tt(this.restDecoder)}},zn=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}},X=class extends zn{constructor(t){super(t),this.keys=[],x(t),this.keyClockDecoder=new ge(z(t)),this.clientDecoder=new jt(z(t)),this.leftClockDecoder=new ge(z(t)),this.rightClockDecoder=new ge(z(t)),this.infoDecoder=new Fe(z(t),Yt),this.stringDecoder=new En(z(t)),this.parentInfoDecoder=new Fe(z(t),Yt),this.typeRefDecoder=new jt(z(t)),this.lenDecoder=new jt(z(t))}readLeftID(){return new xt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new xt(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 pe(this.restDecoder)}readBuf(){return z(this.restDecoder)}readJSON(){return pe(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},Ot=class{constructor(){this.restEncoder=$t()}toUint8Array(){return W(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){y(this.restEncoder,t)}writeDsLen(t){y(this.restEncoder,t)}},pt=class extends Ot{writeLeftID(t){y(this.restEncoder,t.client),y(this.restEncoder,t.clock)}writeRightID(t){y(this.restEncoder,t.client),y(this.restEncoder,t.clock)}writeClient(t){y(this.restEncoder,t)}writeInfo(t){de(this.restEncoder,t)}writeString(t){At(this.restEncoder,t)}writeParentInfo(t){y(this.restEncoder,t?1:0)}writeTypeRef(t){y(this.restEncoder,t)}writeLen(t){y(this.restEncoder,t)}writeAny(t){ae(this.restEncoder,t)}writeBuf(t){q(this.restEncoder,t)}writeJSON(t){At(this.restEncoder,JSON.stringify(t))}writeKey(t){At(this.restEncoder,t)}},Ce=class{constructor(){this.restEncoder=$t(),this.dsCurrVal=0}toUint8Array(){return W(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,y(this.restEncoder,n)}writeDsLen(t){t===0&&N(),y(this.restEncoder,t-1),this.dsCurrVal+=t}},tt=class extends Ce{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ue,this.clientEncoder=new Ft,this.leftClockEncoder=new ue,this.rightClockEncoder=new ue,this.infoEncoder=new Ve(de),this.stringEncoder=new Sn,this.parentInfoEncoder=new Ve(de),this.typeRefEncoder=new Ft,this.lenEncoder=new Ft}toUint8Array(){let t=$t();return y(t,0),q(t,this.keyClockEncoder.toUint8Array()),q(t,this.clientEncoder.toUint8Array()),q(t,this.leftClockEncoder.toUint8Array()),q(t,this.rightClockEncoder.toUint8Array()),q(t,W(this.infoEncoder)),q(t,this.stringEncoder.toUint8Array()),q(t,W(this.parentInfoEncoder)),q(t,this.typeRefEncoder.toUint8Array()),q(t,this.lenEncoder.toUint8Array()),he(t,W(this.restEncoder)),W(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){ae(this.restEncoder,t)}writeBuf(t){q(this.restEncoder,t)}writeJSON(t){ae(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},Nl=(e,t,n,r)=>{r=bt(r,t[0].id.clock);let s=nt(t,r);y(e.restEncoder,t.length-s),e.writeClient(n),y(e.restEncoder,r);let o=t[s];o.write(e,r-o.id.clock);for(let i=s+1;i<t.length;i++)t[i].write(e,0)},fs=(e,t,n)=>{let r=new Map;n.forEach((s,o)=>{E(t,o)>s&&r.set(o,s)}),dn(t).forEach((s,o)=>{n.has(o)||r.set(o,0)}),y(e.restEncoder,r.size),st(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{Nl(e,t.clients.get(s),s,o)})},Ol=(e,t)=>{let n=A(),r=x(e.restDecoder);for(let s=0;s<r;s++){let o=x(e.restDecoder),i=new Array(o),c=e.readClient(),l=x(e.restDecoder);n.set(c,{i:0,refs:i});for(let a=0;a<o;a++){let u=e.readInfo();switch(31&u){case 0:{let d=e.readLen();i[a]=new P(b(c,l),d),l+=d;break}case 10:{let d=x(e.restDecoder);i[a]=new V(b(c,l),d),l+=d;break}default:{let d=(u&192)===0,h=new S(b(c,l),null,(u&128)===128?e.readLeftID():null,null,(u&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(u&32)===32?e.readString():null,Ri(e,u));i[a]=h,l+=h.length}}}}return n},Ll=(e,t,n)=>{let r=[],s=st(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},i=o();if(i===null)return null;let c=new Kn,l=new Map,a=(f,p)=>{let g=l.get(f);(g==null||g>p)&&l.set(f,p)},u=i.refs[i.i++],d=new Map,h=()=>{for(let f of r){let p=f.id.client,g=n.get(p);g?(g.i--,c.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):c.clients.set(p,[f]),s=s.filter(m=>m!==p)}r.length=0};for(;;){if(u.constructor!==V){let p=Y(d,u.id.client,()=>E(t,u.id.client))-u.id.clock;if(p<0)r.push(u),a(u.id.client,u.id.clock-1),h();else{let g=u.getMissing(e,t);if(g!==null){r.push(u);let m=n.get(g)||{refs:[],i:0};if(m.refs.length===m.i)a(g,E(t,g)),h();else{u=m.refs[m.i++];continue}}else(p===0||p<u.length)&&(u.integrate(e,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else{if(i=o(),i===null)break;u=i.refs[i.i++]}}if(c.clients.size>0){let f=new tt;return fs(f,c,new Map),y(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},Ml=(e,t)=>fs(e,t.doc.store,t.beforeState),ps=(e,t,n,r=new X(e))=>k(t,s=>{s.local=!1;let o=!1,i=s.doc,c=i.store,l=Ol(r,i),a=Ll(s,c,l),u=c.pendingStructs;if(u){for(let[h,f]of u.missing)if(f<E(c,h)){o=!0;break}if(a){for(let[h,f]of a.missing){let p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=sn([u.update,a.update])}}else c.pendingStructs=a;let d=Ro(r,s,c);if(c.pendingDs){let h=new X(R(c.pendingDs));x(h.restDecoder);let f=Ro(h,s,c);d&&f?c.pendingDs=sn([d,f]):c.pendingDs=d||f}else c.pendingDs=d;if(o){let h=c.pendingStructs.update;c.pendingStructs=null,ir(s.doc,h)}},n,!1),Rl=(e,t,n)=>ps(e,t,n,new J(e)),ir=(e,t,n,r=X)=>{let s=R(t);ps(s,e,n,new r(s))},Vl=(e,t,n)=>ir(e,t,n,J),Bl=(e,t,n=new Map)=>{fs(e,t.store,n),ft(e,hs(t.store))},Qo=(e,t=new Uint8Array([0]),n=new tt)=>{let r=gs(t);Bl(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(ks(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===pt)return di(s.map((o,i)=>i===0?o:mi(o)));if(n.constructor===tt)return sn(s)}return s[0]},Fl=(e,t)=>Qo(e,t,new pt),ti=e=>{let t=new Map,n=x(e.restDecoder);for(let r=0;r<n;r++){let s=x(e.restDecoder),o=x(e.restDecoder);t.set(s,o)}return t},gs=e=>ti(new Kt(R(e))),ms=(e,t)=>(y(e.restEncoder,t.size),st(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{y(e.restEncoder,n),y(e.restEncoder,r)}),e),$l=(e,t)=>ms(e,dn(t.store)),Yl=(e,t=new Ce)=>(e instanceof Map?ms(t,e):$l(t,e),t.toUint8Array()),jl=e=>Yl(e,new Ot),ns=class{constructor(){this.l=[]}},Vo=()=>new ns,Bo=(e,t)=>e.l.push(t),Fo=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ei=(e,t,n)=>Pe(e.l,[t,n]),xt=class{constructor(t,n){this.client=t,this.clock=n}},Gt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,b=(e,t)=>new xt(e,t),$o=(e,t)=>{y(e,t.client),y(e,t.clock)},Yo=e=>b(x(e),x(e)),ws=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw N()},tn=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Pl=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},rs=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(o,i)=>{let c=o.get("ds"),l=o.get("ids"),a=u=>this.clients.set(u,i);c.observe(u=>{u.changes.added.forEach(d=>{d.content.getContent().forEach(h=>{h instanceof Uint8Array&&this.dss.set(i,Jt([this.dss.get(i)||or(),kt(new Kt(R(h)))]))})})}),this.dss.set(i,Jt(c.map(u=>kt(new Kt(R(u)))))),l.observe(u=>u.changes.added.forEach(d=>d.content.getContent().forEach(a))),l.forEach(a)};n.observe(o=>{o.keysChanged.forEach(i=>s(n.get(i),i))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let o=this.yusers,i=o.get(r);i||(i=new Qt,i.set("ids",new Zt),i.set("ds",new Zt),o.set(r,i)),i.get("ids").push([n]),o.observe(c=>{setTimeout(()=>{let l=o.get(r);if(l!==i){i=l,this.clients.forEach((d,h)=>{r===d&&i.get("ids").push([h])});let a=new Ot,u=this.dss.get(r);u&&(ft(a,u),i.get("ds").push([a.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=i.get("ds"),a=c.deleteSet;if(c.local&&a.clients.size>0&&s(c,a)){let u=new Ot;ft(u,a),l.push([u.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(ne(r,t))return n;return null}},Te=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},Hl=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Xl=e=>{var t;return new Te(e.type==null?null:b(e.type.client,e.type.clock),(t=e.tname)!=null?t:null,e.item==null?null:b(e.item.client,e.item.clock),e.assoc==null?0:e.assoc)},Jn=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},Gl=(e,t,n=0)=>new Jn(e,t,n),Pn=(e,t,n)=>{let r=null,s=null;return e._item===null?s=ws(e):r=b(e._item.id.client,e._item.id.clock),new Te(r,s,t,n)},ve=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Pn(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Pn(e,b(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Pn(e,r.lastId,n);r=r.right}return Pn(e,null,n)},ql=(e,t)=>{let{type:n,tname:r,item:s,assoc:o}=t;if(s!==null)y(e,0),$o(e,s);else if(r!==null)de(e,1),At(e,r);else if(n!==null)de(e,2),$o(e,n);else throw N();return Be(e,o),e},ys=e=>{let t=$t();return ql(t,e),W(t)},zl=e=>{let t=null,n=null,r=null;switch(x(e)){case 0:r=Yo(e);break;case 1:n=Tt(e);break;case 2:t=Yo(e)}let s=Er(e)?$e(e):0;return new Te(t,n,r,s)},bs=e=>zl(R(e)),Jl=(e,t)=>{let n=qt(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},Ie=(e,t,n=!0)=>{let r=t.store,s=e.item,o=e.type,i=e.tname,c=e.assoc,l=null,a=0;if(s!==null){if(E(r,s.client)<=s.clock)return null;let u=n?as(r,s):Jl(r,s),d=u.item;if(!(d instanceof S))return null;if(l=d.parent,l._item===null||!l._item.deleted){a=d.deleted||!d.countable?0:u.diff+(c>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(a+=h.length),h=h.left}}else{if(i!==null)l=t.get(i);else if(o!==null){if(E(r,o.client)<=o.clock)return null;let{item:u}=n?as(r,o):{item:qt(r,o)};if(u instanceof S&&u.content instanceof rt)l=u.content.type;else return null}else throw N();c>=0?a=l._length:a=0}return Gl(l,a,e.assoc)},Kl=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Gt(e.item,t.item)&&Gt(e.type,t.type)&&e.assoc===t.assoc,en=class{constructor(t,n){this.ds=t,this.sv=n}},Wl=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,o=t.sv;if(s.size!==o.size||n.size!==r.size)return!1;for(let[i,c]of s.entries())if(o.get(i)!==c)return!1;for(let[i,c]of n.entries()){let l=r.get(i)||[];if(c.length!==l.length)return!1;for(let a=0;a<c.length;a++){let u=c[a],d=l[a];if(u.clock!==d.clock||u.len!==d.len)return!1}}return!0},ni=(e,t=new Ce)=>(ft(t,e.ds),ms(t,e.sv),t.toUint8Array()),Zl=e=>ni(e,new Ot),ri=(e,t=new zn(R(e)))=>new en(kt(t),ti(t)),Ql=e=>ri(e,new Kt(R(e))),xs=(e,t)=>new en(e,t),ta=xs(or(),new Map),ea=e=>xs(hs(e.store),dn(e.store)),Ut=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!ne(t.ds,e.id),ss=(e,t)=>{let n=Y(e.meta,ss,at),r=e.doc.store;n.has(t)||(t.sv.forEach((s,o)=>{s<E(r,o)&&j(e,b(o,s))}),zt(e,t.ds,s=>{}),n.add(t))},na=(e,t,n=new Nt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,o=new tt;return e.transact(i=>{let c=0;r.forEach(l=>{l>0&&c++}),y(o.restEncoder,c);for(let[l,a]of r){if(a===0)continue;a<E(e.store,l)&&j(i,b(l,a));let u=e.store.clients.get(l)||[],d=nt(u,a-1);y(o.restEncoder,d+1),o.writeClient(l),y(o.restEncoder,0);for(let h=0;h<=d;h++)u[h].write(o,0)}ft(o,s)}),ir(n,o.toUint8Array(),"snapshot"),n},ra=(e,t,n=X)=>{let r=new n(R(t)),s=new gt(r,!1);for(let i=s.curr;i!==null;i=s.next())if((e.sv.get(i.id.client)||0)<i.id.clock+i.length)return!1;let o=Jt([e.ds,kt(r)]);return Wo(e.ds,o)},sa=(e,t)=>ra(e,t,J),Kn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},dn=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},E=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},si=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw N()}n.push(t)},nt=(e,t)=>{let n=0,r=e.length-1,s=e[r],o=s.id.clock;if(o===t)return r;let i=M(t/(o+s.length-1)*r);for(;n<=r;){if(s=e[i],o=s.id.clock,o<=t){if(t<o+s.length)return i;n=i+1}else r=i-1;i=M((n+r)/2)}throw N()},oa=(e,t)=>{let n=e.clients.get(t.client);return n[nt(n,t.clock)]},qt=oa,os=(e,t,n)=>{let r=nt(t,n),s=t[r];return s.id.clock<n&&s instanceof S?(t.splice(r+1,0,sr(e,s,n-s.id.clock)),r+1):r},j=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[os(e,n,t.clock)]},is=(e,t,n)=>{let r=t.clients.get(n.client),s=nt(r,n.clock),o=r[s];return n.clock!==o.id.clock+o.length-1&&o.constructor!==P&&r.splice(s+1,0,sr(e,o,n.clock-o.id.clock+1)),o},ia=(e,t,n)=>{let r=e.clients.get(t.id.client);r[nt(r,t.id.clock)]=n},oi=(e,t,n,r,s)=>{if(r===0)return;let o=n+r,i=os(e,t,n),c;do c=t[i++],o<c.id.clock+c.length&&os(e,t,o),s(c);while(i<t.length&&t[i].id.clock<o)},Wn=class{constructor(t,n,r){this.doc=t,this.deleteSet=new It,this.beforeState=dn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},jo=(e,t)=>t.deleteSet.clients.size===0&&!Hs(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(ds(t.deleteSet),Ml(e,t),ft(e,t.deleteSet),!0),Po=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Y(e.changed,t,at).add(n)},Gn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof S&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let o=t-s;return o&&e.splice(t+1-o,o),o},ii=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let o=t.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],l=c.clock+c.len;for(let a=nt(o,c.clock),u=o[a];a<o.length&&u.id.clock<l;u=o[++a]){let d=o[a];if(c.clock+c.len<=d.id.clock)break;d instanceof S&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},ci=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=bn(s.length-1,1+nt(s,i.clock+i.len-1));for(let l=c,a=s[l];l>0&&a.id.clock>=i.clock;a=s[l])l-=1+Gn(s,l)}})},ca=(e,t,n)=>{ii(e,t,n),ci(e,t)},li=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,o=n.deleteSet,i=n._mergeStructs;try{ds(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=a,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),c.push(()=>{ei(a._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&Da(n)})}),Pe(c,[])}finally{r.gc&&ii(o,s,r.gcFilter),ci(o,s),n.afterState.forEach((u,d)=>{let h=n.beforeState.get(d)||0;if(h!==u){let f=s.clients.get(d),p=bt(nt(f,h),1);for(let g=f.length-1;g>=p;)g-=1+Gn(f,g)}});for(let u=i.length-1;u>=0;u--){let{client:d,clock:h}=i[u].id,f=s.clients.get(d),p=nt(f,h);p+1<f.length&&Gn(f,p+1)>1||p>0&&Gn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Yn(Ee,Je,"[yjs] ",Ke,We,"Changed the client-id because another client seems to be using it."),r.clientID=Zo()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let u=new pt;jo(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let u=new tt;jo(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=n;(c.size>0||a.size>0||l.size>0)&&(c.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),a.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:c,removed:a},r,n]),a.forEach(u=>u.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):li(e,t+1)}}},k=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,o=!1,i=null;e._transaction===null&&(o=!0,e._transaction=new Wn(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{i=t(e._transaction)}finally{if(o){let c=e._transaction===s[0];e._transaction=null,c&&li(s,0)}}return i},cs=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},Ho=(e,t,n)=>{zt(e,n.deletions,r=>{r instanceof S&&t.scope.some(s=>s===e.doc||tn(s,r))&&Ts(r,!1)})},Xo=(e,t,n)=>{let r=null,s=e.doc,o=e.scope;k(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,a=t.pop(),u=new Set,d=[],h=!1;zt(c,a.insertions,f=>{if(f instanceof S){if(f.redone!==null){let{item:p,diff:g}=as(l,f.id);g>0&&(p=j(c,b(p.id.client,p.id.clock+g))),f=p}!f.deleted&&o.some(p=>p===c.doc||tn(p,f))&&d.push(f)}}),zt(c,a.deletions,f=>{f instanceof S&&o.some(p=>p===c.doc||tn(p,f))&&!ne(a.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Mi(c,f,u,a.insertions,e.ignoreRemoteMapChanges,e)!==null||h});for(let f=d.length-1;f>=0;f--){let p=d[f];e.deleteFilter(p)&&(p.delete(c),h=!0)}e.currStackItem=h?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=c},e);let i=e.currStackItem;if(i!=null){let c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return i},nn=class extends re{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:c=yt(t)?t[0].doc:t instanceof Nt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(m=>l.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let a=this.undoing,u=this.redoing,d=a?this.redoStack:this.undoStack;a?this.stopCapturing():u||this.clear(!1,!0);let h=new It;l.afterState.forEach((m,w)=>{let C=l.beforeState.get(w)||0,ct=m-C;ct>0&&Qe(h,w,C,ct)});let f=_t(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!a&&!u){let m=d[d.length-1];m.deletions=Jt([m.deletions,l.deleteSet]),m.insertions=Jt([m.insertions,h])}else d.push(new cs(l.deleteSet,h)),p=!0;!a&&!u&&(this.lastChange=f),zt(l,l.deleteSet,m=>{m instanceof S&&this.scope.some(w=>w===l.doc||tn(w,m))&&Ts(m,!0)});let g=[{stackItem:d[d.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let n=new Set(this.scope);t=yt(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof T?r.doc!==this.doc:r!==this.doc)&&Qr("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>Ho(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Ho(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Xo(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Xo(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}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*la(e){let t=x(e.restDecoder);for(let n=0;n<t;n++){let r=x(e.restDecoder),s=e.readClient(),o=x(e.restDecoder);for(let i=0;i<r;i++){let c=e.readInfo();if(c===10){let l=x(e.restDecoder);yield new V(b(s,o),l),o+=l}else if((31&c)!==0){let l=(c&192)===0,a=new S(b(s,o),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,Ri(e,c));yield a,o+=a.length}else{let l=e.readLen();yield new P(b(s,o),l),o+=l}}}}var gt=class{constructor(t,n){this.gen=la(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===V);return this.curr}},aa=e=>ai(e,J),ai=(e,t=X)=>{let n=[],r=new t(R(e)),s=new gt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);Yn("Structs: ",n);let o=kt(r);Yn("DeleteSet: ",o)},ua=e=>ui(e,J),ui=(e,t=X)=>{let n=[],r=new t(R(e)),s=new gt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);return{structs:n,ds:kt(r)}},rn=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},di=e=>sn(e,J,pt),hi=(e,t=Ce,n=X)=>{let r=new t,s=new gt(new n(R(e)),!1),o=s.curr;if(o!==null){let i=0,c=o.id.client,l=o.id.clock!==0,a=l?0:o.id.clock+o.length;for(;o!==null;o=s.next())c!==o.id.client&&(a!==0&&(i++,y(r.restEncoder,c),y(r.restEncoder,a)),c=o.id.client,a=0,l=o.id.clock!==0),o.constructor===V&&(l=!0),l||(a=o.id.clock+o.length);a!==0&&(i++,y(r.restEncoder,c),y(r.restEncoder,a));let u=$t();return y(u,i),Qs(u,r.restEncoder),r.restEncoder=u,r.toUint8Array()}else return y(r.restEncoder,0),r.toUint8Array()},da=e=>hi(e,Ot,J),fi=(e,t=X)=>{let n=new Map,r=new Map,s=new gt(new t(R(e)),!1),o=s.curr;if(o!==null){let i=o.id.client,c=o.id.clock;for(n.set(i,c);o!==null;o=s.next())i!==o.id.client&&(r.set(i,c),n.set(o.id.client,o.id.clock),i=o.id.client),c=o.id.clock+o.length;r.set(i,c)}return{from:n,to:r}},ha=e=>fi(e,J),fa=(e,t)=>{if(e.constructor===P){let{client:n,clock:r}=e.id;return new P(b(n,r+t),e.length-t)}else if(e.constructor===V){let{client:n,clock:r}=e.id;return new V(b(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new S(b(r,s+t),null,b(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},sn=(e,t=X,n=tt)=>{if(e.length===1)return e[0];let r=e.map(u=>new t(R(u))),s=r.map(u=>new gt(u,!0)),o=null,i=new n,c=new rn(i);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){let p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===V?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){let u=s[0],d=u.curr.id.client;if(o!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(d!==o.struct.id.client)Dt(c,o.struct,o.offset),o={struct:h,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===V)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{Dt(c,o.struct,o.offset);let p=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new V(b(d,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-h.id.clock;p>0&&(o.struct.constructor===V?o.struct.length-=p:h=fa(h,p)),o.struct.mergeWith(h)||(Dt(c,o.struct,o.offset),o={struct:h,offset:0},u.next())}}else o={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==V;h=u.next())Dt(c,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(Dt(c,o.struct,o.offset),o=null),Ss(c);let l=r.map(u=>kt(u)),a=Jt(l);return ft(i,a),i.toUint8Array()},ks=(e,t,n=X,r=tt)=>{let s=gs(t),o=new r,i=new rn(o),c=new n(R(e)),l=new gt(c,!1);for(;l.curr;){let u=l.curr,d=u.id.client,h=s.get(d)||0;if(l.curr.constructor===V){l.next();continue}if(u.id.clock+u.length>h)for(Dt(i,u,bt(h-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===d;)Dt(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===d&&l.curr.id.clock+l.curr.length<=h;)l.next()}Ss(i);let a=kt(c);return ft(o,a),o.toUint8Array()},pa=(e,t)=>ks(e,t,J,pt),pi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:W(e.encoder.restEncoder)}),e.encoder.restEncoder=$t(),e.written=0)},Dt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&pi(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),y(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Ss=e=>{pi(e);let t=e.encoder.restEncoder;y(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];y(t,r.written),he(t,r.restEncoder)}},cr=(e,t,n,r)=>{let s=new n(R(e)),o=new gt(s,!1),i=new r,c=new rn(i);for(let a=o.curr;a!==null;a=o.next())Dt(c,t(a),0);Ss(c);let l=kt(s);return ft(i,l),i.toUint8Array()},gi=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=A(),o=A(),i=A(),c=A();return c.set(null,null),l=>{switch(l.constructor){case P:case V:return l;case S:{let a=l,u=a.content;switch(u.constructor){case De:break;case rt:{if(n){let d=u.type;d instanceof L&&(d.nodeName=Y(o,d.nodeName,()=>"node-"+r)),d instanceof an&&(d.hookName=Y(o,d.hookName,()=>"hook-"+r))}break}case Lt:{let d=u;d.arr=d.arr.map(()=>r);break}case te:{let d=u;d.content=new Uint8Array([r]);break}case ee:{let d=u;t&&(d.opts={},d.doc.guid=r+"");break}case Et:{let d=u;d.embed={};break}case _:{let d=u;e&&(d.key=Y(i,d.key,()=>r+""),d.value=Y(c,d.value,()=>({i:r})));break}case un:{let d=u;d.arr=d.arr.map(()=>r);break}case ot:{let d=u;d.str=kn(r%10+"",d.str.length);break}default:N()}return a.parentSub&&(a.parentSub=Y(s,a.parentSub,()=>r+"")),r++,l}default:N()}}},ga=(e,t)=>cr(e,gi(t),J,pt),ma=(e,t)=>cr(e,gi(t),X,tt),wa=e=>cr(e,Lr,J,tt),mi=e=>cr(e,Lr,X,pt),Go="You must not compute changes after the event-handler fired.",Wt=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=ya(this.currentTarget,this.target))}deletes(t){return ne(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Z(Go);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let o=n._map.get(s),i,c;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))i="delete",c=mn(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",c=mn(l.content.getContent())):(i="add",c=void 0)}else if(this.deletes(o))i="delete",c=mn(o.content.getContent());else return;t.set(s,{action:i,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw Z(Go);let n=this.target,r=at(),s=at(),o=[];if(t={added:r,deleted:s,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&o.push(c)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,s.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),r.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},ya=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}t=t._item.parent}return n},B=()=>{Qr("Invalid access: Add Yjs type to a document before reading data.")},wi=80,Es=0,ls=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Es++}},ba=e=>{e.timestamp=Es++},yi=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Es++},xa=(e,t,n)=>{if(e.length>=wi){let r=e.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return yi(r,t,n),r}else{let r=new ls(t,n);return e.push(r),r}},lr=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,i)=>Vt(t-o.index)<Vt(t-i.index)?o:i),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,ba(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=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&&(s-=r.length);return n!==null&&Vt(n.index-s)<r.parent.length/wi?(yi(n,r,s),n):xa(e._searchMarker,r,s)},on=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let o=s.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(s.index-=o.length);if(o===null||o.marker===!0){e.splice(r,1);continue}s.p=o,o.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=bt(t,s.index+n))}},ka=e=>{var r;(r=e.doc)!=null||B();let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},ar=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;Y(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ei(r._eH,n,t)},T=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Vo(),this._dEH=Vo(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw Q()}clone(){throw Q()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Bo(this._eH,t)}observeDeep(t){Bo(this._dEH,t)}unobserve(t){Fo(this._eH,t)}unobserveDeep(t){Fo(this._dEH,t)}toJSON(){}},bi=(e,t,n)=>{var i;(i=e.doc)!=null||B(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],o=e._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=t)t-=c.length;else{for(let l=t;l<c.length&&r>0;l++)s.push(c[l]),r--;t=0}}o=o.right}return s},xi=e=>{var r;(r=e.doc)!=null||B();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let s=n.content.getContent();for(let o=0;o<s.length;o++)t.push(s[o])}n=n.right}return t},Sa=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ut(r,t)){let s=r.content.getContent();for(let o=0;o<s.length;o++)n.push(s[o])}r=r.right}return n},cn=(e,t)=>{var s;let n=0,r=e._start;for((s=e.doc)!=null||B();r!==null;){if(r.countable&&!r.deleted){let o=r.content.getContent();for(let i=0;i<o.length;i++)t(o[i],n++,e)}r=r.right}},ki=(e,t)=>{let n=[];return cn(e,(r,s)=>{n.push(t(r,s,e))}),n},Ea=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Si=(e,t)=>{var s;(s=e.doc)!=null||B();let n=lr(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Zn=(e,t,n,r)=>{let s=n,o=e.doc,i=o.clientID,c=o.store,l=n===null?t._start:n.right,a=[],u=()=>{a.length>0&&(s=new S(b(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Lt(a)),s.integrate(e,0),a=[])};r.forEach(d=>{if(d===null)a.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new S(b(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new te(new Uint8Array(d))),s.integrate(e,0);break;case Nt:s=new S(b(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new ee(d)),s.integrate(e,0);break;default:if(d instanceof T)s=new S(b(i,E(c,i)),s,s&&s.lastId,l,l&&l.id,t,null,new rt(d)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Ei=()=>Z("Length exceeded!"),Ai=(e,t,n,r)=>{if(n>t._length)throw Ei();if(n===0)return t._searchMarker&&on(t._searchMarker,n,r.length),Zn(e,t,null,r);let s=n,o=lr(t,n),i=t._start;for(o!==null&&(i=o.p,n-=o.index,n===0&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&j(e,b(i.id.client,i.id.clock+n));break}n-=i.length}return t._searchMarker&&on(t._searchMarker,s,r.length),Zn(e,t,i,r)},Aa=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return Zn(e,t,s,n)},Ci=(e,t,n,r)=>{if(r===0)return;let s=n,o=r,i=lr(t,n),c=t._start;for(i!==null&&(c=i.p,n-=i.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&j(e,b(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&j(e,b(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw Ei();t._searchMarker&&on(t._searchMarker,s,-o+r)},Qn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},As=(e,t,n,r)=>{let s=t._map.get(n)||null,o=e.doc,i=o.clientID,c;if(r==null)c=new Lt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Lt([r]);break;case Uint8Array:c=new te(r);break;case Nt:c=new ee(r);break;default:if(r instanceof T)c=new rt(r);else throw new Error("Unexpected content type")}new S(b(i,E(o.store,i)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},Cs=(e,t)=>{var r;(r=e.doc)!=null||B();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ti=e=>{var n;let t={};return(n=e.doc)!=null||B(),e._map.forEach((r,s)=>{r.deleted||(t[s]=r.content.getContent()[r.length-1])}),t},_i=(e,t)=>{var r;(r=e.doc)!=null||B();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ca=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&Ut(r,n)?r.content.getContent()[r.length-1]:void 0},Ui=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let o=r;for(;o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;o!==null&&Ut(o,t)&&(n[s]=o.content.getContent()[o.length-1])}),n},Hn=e=>{var t;return(t=e.doc)!=null||B(),Oo(e._map.entries(),n=>!n[1].deleted)},tr=class extends Wt{},Zt=class e extends T{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof T?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||B(),this._length}_callObserver(t,n){super._callObserver(t,n),ar(this,t,new tr(this,t))}insert(t,n){this.doc!==null?k(this.doc,r=>{Ai(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?k(this.doc,n=>{Aa(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?k(this.doc,r=>{Ci(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Si(this,t)}toArray(){return xi(this)}slice(t=0,n=this.length){return bi(this,t,n)}toJSON(){return this.map(t=>t instanceof T?t.toJSON():t)}map(t){return ki(this,t)}forEach(t){cn(this,t)}[Symbol.iterator](){return Ea(this)}_write(t){t.writeTypeRef(Ga)}},Ta=e=>new Zt,er=class extends Wt{constructor(t,n,r){super(t,n),this.keysChanged=r}},Qt=class e extends T{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof T?n.clone():n)}),t}_callObserver(t,n){ar(this,t,new er(this,t,n))}toJSON(){var n;(n=this.doc)!=null||B();let t={};return this._map.forEach((r,s)=>{if(!r.deleted){let o=r.content.getContent()[r.length-1];t[s]=o instanceof T?o.toJSON():o}}),t}get size(){return[...Hn(this)].length}keys(){return jn(Hn(this),t=>t[0])}values(){return jn(Hn(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return jn(Hn(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){var n;(n=this.doc)!=null||B(),this._map.forEach((r,s)=>{r.deleted||t(r.content.getContent()[r.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?k(this.doc,n=>{Qn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?k(this.doc,r=>{As(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Cs(this,t)}has(t){return _i(this,t)}clear(){this.doc!==null?k(this.doc,t=>{this.forEach(function(n,r,s){Qn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(qa)}},_a=e=>new Qt,vt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&Ir(e,t),ln=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&N(),this.right.content.constructor===_?this.right.deleted||Ne(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},qo=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===_?t.right.deleted||Ne(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&j(e,b(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},Xn=(e,t,n,r)=>{let s=new Map,o=r?lr(t,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return qo(e,i,n-o.index)}else{let i=new ln(null,t._start,0,s);return qo(e,i,n)}},Di=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===_&&vt(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,o=s.clientID;r.forEach((i,c)=>{let l=n.left,a=n.right,u=new S(b(o,E(s.store,o)),l,l&&l.lastId,a,a&&a.id,t,null,new _(c,i));u.integrate(e,0),n.right=u,n.forward()})},Ne=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},vi=(e,t)=>{var n;for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===_&&vt((n=t[e.right.content.key])!=null?n:null,e.right.content.value)))break;e.forward()}},Ii=(e,t,n,r)=>{var c;let s=e.doc,o=s.clientID,i=new Map;for(let l in r){let a=r[l],u=(c=n.currentAttributes.get(l))!=null?c:null;if(!vt(u,a)){i.set(l,u);let{left:d,right:h}=n;n.right=new S(b(o,E(s.store,o)),d,d&&d.lastId,h,h&&h.id,t,null,new _(l,a)),n.right.integrate(e,0),n.forward()}}return i},ts=(e,t,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});let o=e.doc,i=o.clientID;vi(n,s);let c=Ii(e,t,n,s),l=r.constructor===String?new ot(r):r instanceof T?new rt(r):new Et(r),{left:a,right:u,index:d}=n;t._searchMarker&&on(t._searchMarker,n.index,l.getLength()),u=new S(b(i,E(o.store,i)),a,a&&a.lastId,u,u&&u.id,t,null,l),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Di(e,t,n,c)},zo=(e,t,n,r,s)=>{let o=e.doc,i=o.clientID;vi(n,s);let c=Ii(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===_));){if(!n.right.deleted)switch(n.right.content.constructor){case _:{let{key:l,value:a}=n.right.content,u=s[l];if(u!==void 0){if(vt(u,a))c.delete(l);else{if(r===0)break t;c.set(l,a)}n.right.delete(e)}else n.currentAttributes.set(l,a);break}default:r<n.right.length&&j(e,b(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
+
`;n.right=new S(b(i,E(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new ot(l)),n.right.integrate(e,0),n.forward()}Di(e,t,n,c)},Ni=(e,t,n,r,s)=>{var a,u;let o=t,i=A();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===_){let d=o.content;i.set(d.key,d)}o=o.right}let c=0,l=!1;for(;t!==o;){if(n===t&&(l=!0),!t.deleted){let d=t.content;if(d.constructor===_){let{key:h,value:f}=d,p=(a=r.get(h))!=null?a:null;(i.get(h)!==d||p===f)&&(t.delete(e),c++,!l&&((u=s.get(h))!=null?u:null)===f&&p!==f&&(p===null?s.delete(h):s.set(h,p))),!l&&!t.deleted&&Ne(s,d)}}t=t.right}return c},Ua=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===_){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Oi=e=>{let t=0;return k(e.doc,n=>{let r=e._start,s=e._start,o=A(),i=gn(o);for(;s;)s.deleted===!1&&(s.content.constructor===_?Ne(i,s.content):(t+=Ni(n,r,s,o,i),o=gn(i),r=s)),s=s.right}),t},Da=e=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let o=e.beforeState.get(r)||0;s!==o&&oi(e,n.store.clients.get(r),o,s,i=>{!i.deleted&&i.content.constructor===_&&i.constructor!==P&&t.add(i.parent)})}k(n,r=>{zt(e,e.deleteSet,s=>{if(s instanceof P||!s.parent._hasFormatting||t.has(s.parent))return;let o=s.parent;s.content.constructor===_?t.add(o):Ua(r,s)});for(let s of t)Oi(s)})},Jo=(e,t,n)=>{let r=n,s=gn(t.currentAttributes),o=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case rt:case Et:case ot:n<t.right.length&&j(e,b(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}o&&Ni(e,o,t.right,s,t.currentAttributes);let i=(t.left||t.right).parent;return i._searchMarker&&on(i._searchMarker,t.index,-r+n),t},nr=class extends Wt{constructor(t,n,r){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,n=[];k(t,r=>{var f,p,g;let s=new Map,o=new Map,i=this.target._start,c=null,l={},a="",u=0,d=0,h=()=>{if(c!==null){let m=null;switch(c){case"delete":d>0&&(m={delete:d}),d=0;break;case"insert":(typeof a=="object"||a.length>0)&&(m={insert:a},s.size>0&&(m.attributes={},s.forEach((w,C)=>{w!==null&&(m.attributes[C]=w)}))),a="";break;case"retain":u>0&&(m={retain:u},ao(l)||(m.attributes=co({},l))),u=0;break}m&&n.push(m),c=null}};for(;i!==null;){switch(i.content.constructor){case rt:case Et:this.adds(i)?this.deletes(i)||(h(),c="insert",a=i.content.getContent()[0],h()):this.deletes(i)?(c!=="delete"&&(h(),c="delete"),d+=1):i.deleted||(c!=="retain"&&(h(),c="retain"),u+=1);break;case ot:this.adds(i)?this.deletes(i)||(c!=="insert"&&(h(),c="insert"),a+=i.content.str):this.deletes(i)?(c!=="delete"&&(h(),c="delete"),d+=i.length):i.deleted||(c!=="retain"&&(h(),c="retain"),u+=i.length);break;case _:{let{key:m,value:w}=i.content;if(this.adds(i)){if(!this.deletes(i)){let C=(f=s.get(m))!=null?f:null;vt(C,w)?w!==null&&i.delete(r):(c==="retain"&&h(),vt(w,(p=o.get(m))!=null?p:null)?delete l[m]:l[m]=w)}}else if(this.deletes(i)){o.set(m,w);let C=(g=s.get(m))!=null?g:null;vt(C,w)||(c==="retain"&&h(),l[m]=C)}else if(!i.deleted){o.set(m,w);let C=l[m];C!==void 0&&(vt(C,w)?C!==null&&i.delete(r):(c==="retain"&&h(),w===null?delete l[m]:l[m]=w))}i.deleted||(c==="insert"&&h(),Ne(s,i.content));break}}i=i.right}for(h();n.length>0;){let m=n[n.length-1];if(m.retain!==void 0&&m.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},_e=class e extends T{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){var t;return(t=this.doc)!=null||B(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);let r=new nr(this,t,n);ar(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){var r;(r=this.doc)!=null||B();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===ot&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?k(this.doc,r=>{let s=new ln(null,this._start,0,new Map);for(let o=0;o<t.length;o++){let i=t[o];if(i.insert!==void 0){let c=!n&&typeof i.insert=="string"&&o===t.length-1&&s.right===null&&i.insert.slice(-1)===`
|
|
5
|
+
`?i.insert.slice(0,-1):i.insert;(typeof c!="string"||c.length>0)&&ts(r,this,s,c,i.attributes||{})}else i.retain!==void 0?zo(r,this,s,i.retain,i.attributes||{}):i.delete!==void 0&&Jo(r,s,i.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){var d;(d=this.doc)!=null||B();let s=[],o=new Map,i=this.doc,c="",l=this._start;function a(){if(c.length>0){let h={},f=!1;o.forEach((g,m)=>{f=!0,h[m]=g});let p={insert:c};f&&(p.attributes=h),s.push(p),c=""}}let u=()=>{for(;l!==null;){if(Ut(l,t)||n!==void 0&&Ut(l,n))switch(l.content.constructor){case ot:{let h=o.get("ychange");t!==void 0&&!Ut(l,t)?(h===void 0||h.user!==l.id.client||h.type!=="removed")&&(a(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Ut(l,n)?(h===void 0||h.user!==l.id.client||h.type!=="added")&&(a(),o.set("ychange",r?r("added",l.id):{type:"added"})):h!==void 0&&(a(),o.delete("ychange")),c+=l.content.str;break}case rt:case Et:{a();let h={insert:l.content.getContent()[0]};if(o.size>0){let f={};h.attributes=f,o.forEach((p,g)=>{f[g]=p})}s.push(h);break}case _:Ut(l,t)&&(a(),Ne(o,l.content));break}l=l.right}a()};return t||n?k(i,h=>{t&&ss(h,t),n&&ss(h,n),u()},"cleanup"):u(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?k(s,o=>{let i=Xn(o,this,t,!r);r||(r={},i.currentAttributes.forEach((c,l)=>{r[l]=c})),ts(o,this,i,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?k(s,o=>{let i=Xn(o,this,t,!r);ts(o,this,i,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?k(r,s=>{Jo(s,Xn(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?k(s,o=>{let i=Xn(o,this,t,!1);i.right!==null&&zo(o,this,i,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?k(this.doc,n=>{Qn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{As(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Cs(this,t)}getAttributes(){return Ti(this)}_write(t){t.writeTypeRef(za)}},va=e=>new _e,Ze=class{constructor(t,n=()=>!0){var r;this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,(r=t.doc)!=null||B()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===L||n.constructor===St)&&n._start!==null)t=n._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},St=class e extends T{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof T?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||B(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new Ze(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),st(new Ze(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){ar(this,t,new rr(this,n,t))}toString(){return ki(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),cn(this,o=>{s.insertBefore(o.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?k(this.doc,r=>{Ai(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)k(this.doc,r=>{let s=t&&t instanceof T?t._item:t;Zn(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(o=>o===t)+1;if(s===0&&t!==null)throw Z("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?k(this.doc,r=>{Ci(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return xi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Si(this,t)}slice(t=0,n=this.length){return bi(this,t,n)}forEach(t){cn(this,t)}_write(t){t.writeTypeRef(Ka)}},Ia=e=>new St,L=class e extends St{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return lo(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof T?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let o=this.nodeName.toLocaleLowerCase(),i=n.length>0?" "+n.join(" "):"";return`<${o}${i}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?k(this.doc,n=>{Qn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{As(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Cs(this,t)}hasAttribute(t){return _i(this,t)}getAttributes(t){return t?Ui(this,t):Ti(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),o=this.getAttributes();for(let i in o){let c=o[i];typeof c=="string"&&s.setAttribute(i,c)}return cn(this,i=>{s.appendChild(i.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(Ja),t.writeKey(this.nodeName)}},Na=e=>new L(e.readKey()),rr=class extends Wt{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},an=class e extends Qt{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){let s=n[this.hookName],o;return s!==void 0?o=s.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(Wa),t.writeKey(this.hookName)}},Oa=e=>new an(e.readKey()),G=class e extends _e{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let o=[];for(let i in t.attributes[s])o.push({key:i,value:t.attributes[s][i]});o.sort((i,c)=>i.key<c.key?-1:1),n.push({nodeName:s,attrs:o})}n.sort((s,o)=>s.nodeName<o.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let o=n[s];r+=`<${o.nodeName}`;for(let i=0;i<o.attrs.length;i++){let c=o.attrs[i];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Za)}},La=e=>new G,Ue=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw Q()}mergeWith(t){return!1}write(t,n,r){throw Q()}integrate(t,n){throw Q()}},Ma=0,P=class extends Ue{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),si(t.doc.store,this)}write(t,n){t.writeInfo(Ma),t.writeLen(this.length-n)}getMissing(t,n){return null}},te=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw Q()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},Ra=e=>new te(e.readBuf()),De=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Qe(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},Va=e=>new De(e.readLen()),Li=(e,t)=>new Nt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),ee=class e{constructor(t){t._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=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Li(this.doc.guid,this.opts))}splice(t){throw Q()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},Ba=e=>new ee(Li(e.readString(),e.readAny())),Et=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw Q()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},Fa=e=>new Et(e.readJSON()),_=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw Q()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},$a=e=>new _(e.readKey(),e.readJSON()),un=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let o=this.arr[s];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},Ya=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new un(n)},ja=Xe("node_env")==="development",Lt=class e{constructor(t){this.arr=t,ja&&Nr(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let o=this.arr[s];t.writeAny(o)}}getRef(){return 8}},Pa=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Lt(n)},ot=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},Ha=e=>new ot(e.readString()),Xa=[Ta,_a,va,Na,Ia,Oa,La],Ga=0,qa=1,za=2,Ja=3,Ka=4,Wa=5,Za=6,rt=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw Q()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},Qa=e=>new rt(Xa[e.readTypeRef()](e)),as=(e,t)=>{let n=t,r=0,s;do r>0&&(n=b(n.client,n.clock+r)),s=qt(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof S);return{item:s,diff:r}},Ts=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},sr=(e,t,n)=>{let{client:r,clock:s}=t.id,o=new S(b(r,s+n),t,b(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=b(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},Ko=(e,t)=>Le(e,n=>ne(n.deletions,t)),Mi=(e,t,n,r,s,o)=>{let i=e.doc,c=i.store,l=i.clientID,a=t.redone;if(a!==null)return j(e,a);let u=t.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Mi(e,u,n,r,s,o)===null))return null;for(;u.redone!==null;)u=j(e,u.redone)}let f=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,h=t;d!==null;){let w=d;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:j(e,w.redone);if(w!==null&&w.parent._item===u){d=w;break}d=d.left}for(;h!==null;){let w=h;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:j(e,w.redone);if(w!==null&&w.parent._item===u){h=w;break}h=h.right}}else if(h=null,t.right&&!s){for(d=t;d!==null&&d.right!==null&&(d.right.redone||ne(r,d.right.id)||Ko(o.undoStack,d.right.id)||Ko(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=j(e,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(t.parentSub)||null;let p=E(c,l),g=b(l,p),m=new S(g,d,d&&d.lastId,h,h&&h.id,f,t.parentSub,t.content.copy());return t.redone=g,Ts(m,!0),m.integrate(e,0),m},S=class e extends Ue{constructor(t,n,r,s,o,i,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=o,this.parent=i,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===xt&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=is(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=j(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===P||this.right&&this.right.constructor===P)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===xt){let r=qt(n,this.parent);r.constructor===P?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=is(t,t.doc.store,b(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let o=new Set,i=new Set;for(;s!==null&&s!==this.right;){if(i.add(s),o.add(s),Gt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,o.clear();else if(Gt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&i.has(qt(t.doc.store,s.origin)))o.has(qt(t.doc.store,s.origin))||(r=s,o.clear());else break;s=s.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(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),si(t.doc.store,this),this.content.integrate(t,this),Po(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new P(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:b(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Gt(t.origin,this.lastId)&&this.right===t&&Gt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Qe(t.deleteSet,this.id.client,this.id.clock,this.length),Po(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw N();this.content.gc(t),n?ia(t,this,new P(this.id,this.length)):this.content=new De(this.length)}write(t,n){let r=n>0?b(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,o=this.parentSub,i=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(o===null?0:32);if(t.writeInfo(i),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let a=ws(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===xt?(t.writeParentInfo(!1),t.writeLeftID(c)):N();o!==null&&t.writeString(o)}this.content.write(t,n)}},Ri=(e,t)=>tu[t&31](e),tu=[()=>{N()},Va,Ya,Ra,Ha,Fa,$a,Qa,Pa,Ba,()=>{N()}],eu=10,V=class extends Ue{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){N()}write(t,n){t.writeInfo(eu),y(t.restEncoder,this.length-n)}getMissing(t,n){return null}},Vi=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:{},Bi="__ $YJS$ __";Vi[Bi]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Vi[Bi]=!0;var it=Symbol.for("rte.crdt.local");var _s=new Set(["p","div","section","article","header","footer","main","aside","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","table","thead","tbody","tfoot","tr","td","th","figure","figcaption"]),Us=new Set(["strong","b","em","i","u","s","strike","del","ins","mark","small","sub","sup","code","kbd","samp","var","span","font","a"]),Ds=new Set(["br","hr","img","video","audio","source","iframe","embed","object"]);function Rt(e){let t=e.toLowerCase();return _s.has(t)?"block":Ds.has(t)?"leaf":Us.has(t)?"mark":"unknown"}var hn=["bold","italic","underline","strikethrough","subscript","superscript","color","backcolor","fontFamily","fontSize","link","code","inline"];var F="http://www.w3.org/1999/xhtml";function fn(e,t){for(;t.firstChild;)t.removeChild(t.firstChild);let n=t.ownerDocument;if(!n)throw new Error("renderFragmentToHost: editable host has no ownerDocument");for(let r=0;r<e.length;r++){let s=e.get(r),o=ur(s,n);o&&t.appendChild(o)}t.childNodes.length===0&&t.appendChild(n.createElementNS(F,"p"))}function ur(e,t){return e instanceof G?ru(e,t):e instanceof L?nu(e,t):null}function nu(e,t){let n=e.nodeName.toLowerCase(),r=Rt(n);if(r==="unknown"){let o=t.createElementNS(F,"span");return o.setAttribute("data-rte-unknown",n),$i(e,o),Fi(e,o,t),o}let s=t.createElementNS(F,n);return $i(e,s),r==="leaf"||Fi(e,s,t),s}function Fi(e,t,n){let r=e.length;for(let s=0;s<r;s++){let o=e.get(s),i=ur(o,n);i&&t.appendChild(i)}}function $i(e,t){let n=e.getAttributes();for(let[r,s]of Object.entries(n))s!=null&&t.setAttribute(r,String(s))}function ru(e,t){var o;let n=t.createDocumentFragment(),r=e.toDelta(),s=null;for(let i of r){if(typeof i.insert!="string"||i.insert.length===0)continue;let c=(o=i.attributes)!=null?o:{},l=ou(c),a=typeof c.inline=="string"?c.inline:"",u=t.createTextNode(i.insert);for(let d=l.length-1;d>=0;d--){if(l[d]==="inline")continue;let h=Yi(l[d],c,t);h.appendChild(u),u=h}a?((!s||s.key!==a)&&(s={key:a,el:Yi("inline",c,t)},n.appendChild(s.el)),s.el.appendChild(u)):(s=null,n.appendChild(u))}return n}var su=["inline","link","color","backcolor","fontFamily","fontSize","code","underline","strikethrough","subscript","superscript","italic","bold"];function ou(e){var r;if(!e)return[];let t=[],n="";if(typeof e.inline=="string")try{n=String((r=JSON.parse(e.inline).tag)!=null?r:"").toLowerCase()}catch(s){n=""}for(let s of su)!(s in e)||e[s]==null||e[s]===!1||s==="superscript"&&n==="sup"||s==="subscript"&&n==="sub"||t.push(s);return t}function Yi(e,t,n){switch(e){case"inline":{let r="span",s={};try{let i=JSON.parse(String(t.inline));i.tag&&(r=i.tag),i.attrs&&(s=i.attrs)}catch(i){}/^[a-z][a-z0-9-]*$/.test(r)||(r="span");let o=n.createElementNS(F,r);for(let i of Object.keys(s))/^on/i.test(i)||i==="style"||o.setAttribute(i,s[i]);return o}case"bold":return n.createElementNS(F,"strong");case"italic":return n.createElementNS(F,"em");case"underline":return n.createElementNS(F,"u");case"strikethrough":return n.createElementNS(F,"s");case"subscript":return n.createElementNS(F,"sub");case"superscript":return n.createElementNS(F,"sup");case"code":return n.createElementNS(F,"code");case"link":{let r=n.createElementNS(F,"a"),s=t.link;return typeof s=="string"&&r.setAttribute("href",s),r}case"color":{let r=n.createElementNS(F,"span");return r.setAttribute("style",`color:${t.color}`),r}case"backcolor":{let r=n.createElementNS(F,"span");return r.setAttribute("style",`background-color:${t.backcolor}`),r}case"fontFamily":{let r=n.createElementNS(F,"span");return r.setAttribute("style",`font-family:${t.fontFamily}`),r}case"fontSize":{let r=n.createElementNS(F,"span");return r.setAttribute("style",`font-size:${t.fontSize}`),r}default:return n.createElementNS(F,"span")}}function dr(e){var o;let t=(o=e.ownerDocument)==null?void 0:o.defaultView,n=t==null?void 0:t.getSelection(),r={insideHost:!1,anchorPath:[],anchorOffset:0,focusPath:[],focusOffset:0};if(!n||n.rangeCount===0)return r;let s=n.getRangeAt(0);return!e.contains(s.startContainer)||!e.contains(s.endContainer)?r:{insideHost:!0,anchorPath:ji(e,s.startContainer),anchorOffset:s.startOffset,focusPath:ji(e,s.endContainer),focusOffset:s.endOffset}}function hr(e,t){if(!t.insideHost)return;let n=e.ownerDocument,r=n==null?void 0:n.defaultView;if(!n||!r)return;let s=r.getSelection();if(!s)return;let o=Pi(e,t.anchorPath,t.anchorOffset),i=t.anchorPath===t.focusPath?o:Pi(e,t.focusPath,t.focusOffset);try{let c=n.createRange();c.setStart(o.node,o.offset),c.setEnd(i.node,i.offset),s.removeAllRanges(),s.addRange(c)}catch(c){}}function ji(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}function Pi(e,t,n){let r=e;for(let o of t){let i=r.childNodes.item(o);if(!i)return{node:r,offset:0};r=i}let s=iu(r,n);return{node:r,offset:s}}function iu(e,t){if(e.nodeType===3){let r=e.data.length;return Math.max(0,Math.min(t,r))}let n=e.childNodes.length;return Math.max(0,Math.min(t,n))}function Xi(e){var o,i;let t=(o=e.editable.ownerDocument)==null?void 0:o.defaultView;if(!t)return{disconnect:()=>{},drainPending:()=>{},flushPending:()=>{}};let n=(i=t.MutationObserver)!=null?i:globalThis.MutationObserver;if(!n)return{disconnect:()=>{},drainPending:()=>{},flushPending:()=>{}};let r=new n(c=>{var l;e.isApplyingRemote()||(l=e.fragment.doc)==null||l.transact(()=>{for(let a of c)Hi(a,e)},it)});r.observe(e.editable,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0});let s=c=>{var l;!c.length||e.isApplyingRemote()||(l=e.fragment.doc)==null||l.transact(()=>{for(let a of c)Hi(a,e)},it)};return{disconnect:()=>r.disconnect(),drainPending:()=>{r.takeRecords()},flushPending:()=>{s(r.takeRecords())}}}function Hi(e,t){switch(e.type){case"characterData":cu(e,t);break;case"childList":lu(e,t);break;case"attributes":uu(e,t);break}}function cu(e,t){let n=e.target;if(n.nodeType!==3)return;let r=Is(n,t);if(!r)return;let s=n.data;Gi(r,s)}function Gi(e,t){let n=e.toString();if(n===t)return;let r=0,s=Math.min(n.length,t.length);for(;r<s&&n.charCodeAt(r)===t.charCodeAt(r);)r++;let o=0,i=Math.min(n.length,t.length)-r;for(;o<i&&n.charCodeAt(n.length-1-o)===t.charCodeAt(t.length-1-o);)o++;let c=n.length-r-o,l=t.slice(r,t.length-o);if(c>0&&e.delete(r,c),l.length>0){let a;try{let u=e.toDelta(),d=0;for(let h of u){let f=typeof h.insert=="string"?h.insert.length:1;if(r>d&&r<=d+f){a=h.attributes;break}d+=f}}catch(u){a=void 0}e.insert(r,l,a)}}function lu(e,t){if(e.target===t.editable){Ji(t);return}e.target.nodeType===1&&au(e.target,t)}function au(e,t){var s;let n=qi(e,t);if(!n){du(t);return}let r=Zi(Array.from(e.childNodes));if(n.length===1&&r.children.length===1){let o=n.get(0),i=r.children[0];if(o instanceof G&&i instanceof G){let c=r.marked.find(a=>a.text===i),l=(s=e.textContent)!=null?s:"";if(Gi(o,l),c){let a=o.length;if(a>0){let u={};for(let g of hn)u[g]=null;let d=c.ranges.map(g=>JSON.stringify([g.start,g.end,g.marks])).join("|"),h=o.toDelta(),f=0,p=[];for(let g of h){let m=typeof g.insert=="string"?g.insert.length:1;g.attributes&&Object.keys(g.attributes).length&&p.push(JSON.stringify([f,f+m,g.attributes])),f+=m}if(p.join("|")!==d){o.format(0,a,u);for(let g of c.ranges)o.format(g.start,g.end-g.start,g.marks)}}}else if(o.length>0&&o.toDelta().some(u=>u.attributes&&Object.keys(u.attributes).length)){let u={};for(let d of hn)u[d]=null;o.format(0,o.length,u)}return}}n.delete(0,n.length),r.children.length>0&&(n.insert(0,r.children),Ns(r.marked))}function uu(e,t){if(e.target.nodeType!==1)return;let n=e.target,r=qi(n,t);if(!r||e.attributeName===null)return;let s=n.getAttribute(e.attributeName);s===null?r.removeAttribute(e.attributeName):r.getAttribute(e.attributeName)!==s&&r.setAttribute(e.attributeName,s)}function Is(e,t){let n=zi(t.editable,e);if(n.length===0)return null;let r=t.fragment;for(let o=0;o<n.length-1;o++){let i=n[o],c=r.get(i);if(!(c instanceof L))return null;r=c}let s=r.get(n[n.length-1]);return s instanceof G?s:null}function qi(e,t){let n=zi(t.editable,e);if(n.length===0)return null;let r=t.fragment;for(let s of n){let o=r.get(s);if(!(o instanceof L))return null;r=o}return r instanceof L?r:null}function zi(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}var vs=new WeakSet;function du(e){vs.has(e.fragment)||(vs.add(e.fragment),queueMicrotask(()=>{var t;vs.delete(e.fragment),(t=e.fragment.doc)==null||t.transact(()=>Ji(e),it)}))}function Ji(e){e.fragment.delete(0,e.fragment.length);let t=Ki(e.editable);t.children.length>0&&(e.fragment.insert(0,t.children),Ns(t.marked))}function Ki(e){let t={children:[],marked:[]};for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes.item(n),s=Wi(r);if(s){s.node&&t.children.push(s.node);for(let o of s.marked)t.marked.push(o)}}return t}function Wi(e){if(e.nodeType===3)return{node:new G(e.data),marked:[]};if(e.nodeType!==1)return null;let t=e,n=t.tagName.toLowerCase(),r=Rt(n);if(r==="mark")return null;let s=new L(n);for(let i of Array.from(t.attributes))s.setAttribute(i.name,i.value);if(r==="leaf")return{node:s,marked:[]};let o=Zi(Array.from(t.childNodes));for(let i of o.children)s.insert(s.length,[i]);return{node:s,marked:o.marked}}function hu(){return{str:"",ranges:[]}}function Zi(e){let t={marked:[],children:[]},n=null,r=()=>{if(n&&n.str.length>0){let o=new G(n.str);t.children.push(o),n.ranges.length>0&&t.marked.push({text:o,ranges:n.ranges})}n=null},s=()=>(n||(n=hu()),n);for(let o of e){if(o.nodeType===3){let a=o.data;if(a.length===0)continue;let u=s();u.str+=a;continue}if(o.nodeType!==1)continue;let i=o,c=i.tagName.toLowerCase(),l=Rt(c);if(l==="mark"){let a=s(),u=tc(i);Qi(i,a,u);continue}if(r(),l==="leaf"){let a=new L(c);for(let u of Array.from(i.attributes))a.setAttribute(u.name,u.value);t.children.push(a)}else{let a=Wi(i);if(a&&a.node){t.children.push(a.node);for(let u of a.marked)t.marked.push(u)}}}return r(),t}function Qi(e,t,n){for(let r of Array.from(e.childNodes)){if(r.nodeType===3){let i=r.data;if(i.length===0)continue;let c=t.str.length;t.str+=i;let l=t.str.length;Object.keys(n).length>0&&t.ranges.push({start:c,end:l,marks:n});continue}if(r.nodeType!==1)continue;let s=r;if(Rt(s.tagName.toLowerCase())==="mark"){let i={...n,...tc(s)};Qi(s,t,i)}}}function Ns(e){for(let t of e)for(let n of t.ranges){let r=n.end-n.start;r<=0||t.text.format(n.start,r,n.marks)}}var Os={buildYNodesFromDom:Ki,applyDeferredMarks:Ns};function tc(e){let t=fu(e),n=e.tagName.toLowerCase();if(n==="a")return t;let r={},s=!1;for(let o of Array.from(e.attributes))o.name!=="style"&&(r[o.name]=o.value,s=!0);return s&&(t.inline=JSON.stringify({tag:n,attrs:r})),t}function fu(e){switch(e.tagName.toLowerCase()){case"strong":case"b":return{bold:!0};case"em":case"i":return{italic:!0};case"u":return{underline:!0};case"s":case"strike":case"del":return{strikethrough:!0};case"sub":return{subscript:!0};case"sup":return{superscript:!0};case"code":case"kbd":case"samp":return{code:!0};case"a":{let n=e.getAttribute("href");return n?{link:n}:{}}case"span":case"font":return pu(e);default:return{}}}function pu(e){var r;let t={},n=(r=e.getAttribute("style"))!=null?r:"";for(let s of n.split(";")){let[o,...i]=s.split(":");if(!o||i.length===0)continue;let c=o.trim().toLowerCase(),l=i.join(":").trim();if(l)switch(c){case"color":t.color=l;break;case"background-color":case"background":t.backcolor=l;break;case"font-family":t.fontFamily=l;break;case"font-size":t.fontSize=l;break}}if(e.tagName.toLowerCase()==="font"){let s=e.getAttribute("color");s&&(t.color=s);let o=e.getAttribute("face");o&&(t.fontFamily=o)}return t}function fr(e){var Vs,Bs,Fs;let t=(Vs=e.fragmentName)!=null?Vs:"default",n=e.ydoc.getXmlFragment(t),r=(Fs=e.awareness)!=null?Fs:(Bs=e.provider)==null?void 0:Bs.awareness,s=!1,o=!1,i=Xi({editable:e.editable,fragment:n,isApplyingRemote:()=>s||o});s=!0;try{fn(n,e.editable)}finally{i.drainPending(),s=!1}let c=()=>{i.flushPending();let $=dr(e.editable);s=!0;try{fn(n,e.editable)}finally{i.drainPending(),s=!1}hr(e.editable,$)},l=!1,a=null,u={editable:e.editable,fragment:n,isApplyingRemote:()=>s},d=($,U)=>{if($.nodeType===3)return{node:$,offset:U};if($.nodeType!==1)return null;let mt=$.childNodes,K=U>0?mt[U-1]:null;if(K&&K.nodeType===3){let lt=K;return{node:lt,offset:lt.data.length}}let H=mt[U];return H&&H.nodeType===3?{node:H,offset:0}:null},h=()=>{var $;a=null;try{let U=e.editable.ownerDocument,mt=($=U==null?void 0:U.defaultView)==null?void 0:$.getSelection(),K=mt&&mt.rangeCount?mt.getRangeAt(0):null,H=K?d(K.startContainer,K.startOffset):null,lt=K?d(K.endContainer,K.endOffset):null;if(H&<&&H.node===lt.node){let wt=Is(H.node,u);wt&&(a={yText:wt,start:ve(wt,H.offset),end:ve(wt,lt.offset)})}}catch(U){a=null}o=a!==null},f=$=>{var K;if(!o)return;o=!1;let U=a;a=null;let mt=(K=$==null?void 0:$.data)!=null?K:"";i.drainPending();try{if(U){let H=Ie(U.start,e.ydoc),lt=Ie(U.end,e.ydoc);if(H&<&&H.type===U.yText){let wt=Math.min(H.index,lt.index),$s=Math.max(H.index,lt.index);e.ydoc.transact(()=>{$s>wt&&U.yText.delete(wt,$s-wt),mt&&U.yText.insert(wt,mt)},it)}}}catch(H){console.error("[crdt-engine] composition commit failed:",H)}l=!1,c()};e.editable.addEventListener("compositionstart",h),e.editable.addEventListener("compositionend",f),e.editable.addEventListener("blur",f);let p=()=>{e.editable.removeEventListener("compositionstart",h),e.editable.removeEventListener("compositionend",f),e.editable.removeEventListener("blur",f)},g=($,U)=>{if(U!==it){if(o){l=!0;return}c()}};e.ydoc.on("update",g);let m=()=>{e.ydoc.off("update",g)},w=()=>i.disconnect(),C=gu(r,e.initialAwareness),ct=[m,w,C,p];return{ydoc:e.ydoc,fragment:n,dispose(){for(let $ of ct)try{$()}catch(U){console.error("[crdt-engine] dispose cleanup error:",U)}ct=[]}}}function gu(e,t){return e?(t&&e.setLocalState(t),()=>e.setLocalState(null)):()=>{}}function ec(e){var n;let t=new Set([it]);if(e.extraTrackedOrigins)for(let r of e.extraTrackedOrigins)t.add(r);return new nn(e.fragment,{trackedOrigins:t,captureTimeout:(n=e.captureTimeoutMs)!=null?n:500})}var mu=32;function oc(e){var u,d;let t=(u=e.editable.ownerDocument)==null?void 0:u.defaultView,n=e.editable.ownerDocument,r=(d=e.throttleMs)!=null?d:mu,s=null,o=null,i=null,c=()=>{var w;if(!n)return;let h=t==null?void 0:t.getSelection();if(!h||h.rangeCount===0){e.awareness.setLocalStateField("cursor",null);return}let f=h.getRangeAt(0);if(!e.editable.contains(f.startContainer)||!e.editable.contains(f.endContainer)){e.awareness.setLocalStateField("cursor",null);return}let p=nc(e.fragment,e.editable,f.startContainer,f.startOffset),g=h.isCollapsed?p:nc(e.fragment,e.editable,f.endContainer,f.endOffset);if(!p||!g){e.awareness.setLocalStateField("cursor",null);return}if(s&&o&&sc(s,p)&&sc(o,g))return;s=p,o=g;let m={...e.user?{user:e.user}:{},cursor:{anchor:{encoded:p},head:{encoded:g}}};e.awareness.setLocalState({...(w=e.awareness.getStates().get(e.awareness.clientID))!=null?w:{},...m,active:Date.now()})},l=()=>{i==null&&(i=setTimeout(()=>{i=null,c()},r))},a=()=>l();return n&&n.addEventListener("selectionchange",a),{dispose(){i!=null&&clearTimeout(i),n&&n.removeEventListener("selectionchange",a),e.awareness.setLocalStateField("cursor",null)},publishNow(){i!=null&&(clearTimeout(i),i=null),c()},snapshotPeers(){var f,p;let h=[];for(let[g,m]of e.awareness.getStates()){if(g===e.awareness.clientID)continue;let w=m;if(!w.cursor)continue;let C=rc(e.fragment,e.editable,w.cursor.anchor.encoded),ct=w.cursor.head===w.cursor.anchor?C:rc(e.fragment,e.editable,w.cursor.head.encoded);h.push({clientID:g,user:(f=w.user)!=null?f:{},anchor:C,head:ct,isCollapsed:C!==null&&ct!==null&&C.node===ct.node&&C.offset===ct.offset,activeAt:(p=w.active)!=null?p:0})}return h}}}function nc(e,t,n,r){let s=wu(e,t,n,r);if(!s)return null;try{let o=ve(s.parent,s.index);return ys(o)}catch(o){return null}}function rc(e,t,n){if(!e.doc)return null;try{let r=bs(n),s=Ie(r,e.doc);return s?yu(t,s.type,s.index):null}catch(r){return null}}function wu(e,t,n,r){var u;let s=[],o=r,i=n;if(i.nodeType===3)for(;i&&i!==t;){let d=i.parentNode;if(!d)break;let h=0,f=d.firstChild;for(;f&&f!==i;)h+=Ls(f),f=f.nextSibling;if(o+=h,d===t||xu(d)){i=d;break}i=d}else if(i.nodeType===1){let d=0;for(let h=0;h<r&&h<i.childNodes.length;h++)d+=Ls(i.childNodes.item(h));o=d}if(i===t){let d=(u=ku(t,n===t?t:n).at(0))!=null?u:0;return{parent:e,index:d}}let c=i;for(;c&&c!==t;){let d=c.parentNode;if(!d)return null;let h=0,f=d.firstChild;for(;f&&f!==c;)h++,f=f.nextSibling;s.unshift(h),c=d}let l=e;for(let d of s){let h=l.get(d);if(!(h instanceof L))return null;l=h}let a=l.get(0);return a instanceof G?{parent:a,index:o}:{parent:l,index:0}}function yu(e,t,n){let r=[],s=t,o=!0;for(;s;){let l=s._item;if(!l)break;let a=l.parent;if(!a)break;let u=0,d=!1;if(a instanceof St||a instanceof L){for(let h=0;h<a.length;h++)if(a.get(h)===s){u=h,d=!0;break}}if(!d)break;o&&t instanceof G||r.unshift(u),o=!1,s=a}let i=e;for(let l of r){let a=i.childNodes.item(l);if(!a)return null;i=a}return bu(i,n)}function bu(e,t){let n=t,r=[];for(let s=e.childNodes.length-1;s>=0;s--)r.push(e.childNodes.item(s));for(;r.length>0;){let s=r.pop();if(s.nodeType===3){let o=s.data.length;if(n<=o)return{node:s,offset:n};n-=o;continue}if(s.nodeType===1)for(let o=s.childNodes.length-1;o>=0;o--)r.push(s.childNodes.item(o))}return{node:e,offset:e.childNodes.length}}function Ls(e){if(e.nodeType===3)return e.data.length;let t=0;for(let n=0;n<e.childNodes.length;n++)t+=Ls(e.childNodes.item(n));return t}function xu(e){if(e.nodeType!==1)return!1;let t=e.tagName.toLowerCase();return!["strong","b","em","i","u","s","strike","del","ins","mark","small","sub","sup","code","kbd","samp","var","span","font","a"].includes(t)}function ku(e,t){let n=[],r=t;for(;r&&r!==e;){let s=r.parentNode;if(!s)break;let o=0,i=s.firstChild;for(;i&&i!==r;)o++,i=i.nextSibling;n.unshift(o),r=s}return n}function sc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ic(e){var r,s;let t=(r=e.textSync)!=null?r:!1;if(t==="crdt")return fr(e);if(t===!0){if(!e.legacySnapshotAttach)throw new Error("[crdt-engine] textSync: true requires `legacySnapshotAttach` to be provided by the host. See M5.1 in the sprint README for the back-compat contract.");return e.legacySnapshotAttach(e)}let n=e.ydoc.getXmlFragment((s=e.fragmentName)!=null?s:"default");return{ydoc:e.ydoc,fragment:n,dispose(){}}}function cc(e){var c;let t=(c=e.fragmentName)!=null?c:"default",n=e.ydoc.getXmlFragment(t),r=e.parserDocument.createElement("div");r.innerHTML=e.html;let s=r,o=r.querySelector("body");o&&(s=o);let i=Os.buildYNodesFromDom(s);return e.replace!==!1&&n.length>0&&n.delete(0,n.length),i.children.length>0&&(n.insert(n.length,i.children),Os.applyDeferredMarks(i.marked)),n}var Rs=3e4,pr=class extends yn{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let n=_t();this.getLocalState()!==null&&Rs/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((s,o)=>{o!==this.clientID&&Rs<=n-s.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Su(this,r,"timeout")},M(Rs/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){let n=this.clientID,r=this.meta.get(n),s=r===void 0?0:r.clock+1,o=this.states.get(n);t===null?this.states.delete(n):this.states.set(n,t),this.meta.set(n,{clock:s,lastUpdated:_t()});let i=[],c=[],l=[],a=[];t===null?a.push(n):o==null?t!=null&&i.push(n):(c.push(n),Ht(o,t)||l.push(n)),(i.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:i,updated:l,removed:a},"local"]),this.emit("update",[{added:i,updated:c,removed:a},"local"])}setLocalStateField(t,n){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[t]:n})}getStates(){return this.states}},Su=(e,t,n)=>{let r=[];for(let s=0;s<t.length;s++){let o=t[s];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){let i=e.meta.get(o);e.meta.set(o,{clock:i.clock+1,lastUpdated:_t()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))};typeof window!="undefined"&&(window.RichTextEditorCrdt=Object.assign({},Ms,{Y:Mt,Awareness:pr}));})();
|