"use strict";(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[9978,4922,861,9574],{86552:(t,e,r)=>{r.d(e,{HT:()=>s,HV:()=>n,S2:()=>i,cy:()=>c,t8:()=>o,zN:()=>l});let n=t=>t[t.length-1],i=(t,e)=>{for(let r=0;r{for(let r=0;r{let r=Array(t);for(let n=0;n{r.d(e,{CW:()=>w,D1:()=>s,D7:()=>c,Dk:()=>n,KD:()=>i,KJ:()=>o,P1:()=>u,V7:()=>a,WD:()=>g,WY:()=>d,vZ:()=>p,wn:()=>l,wt:()=>h,yK:()=>f});let n=1,i=2,s=4,l=8,o=32,c=64,h=128,a=536870912,d=31,u=63,g=127,f=2097151,p=2147483647,w=4294967295},3531:(t,e,r)=>{r.d(e,{HR:()=>c,nk:()=>o});var n=r(66816),i=r(36645);let s=t=>new Uint8Array(t),l=(t,e,r)=>new Uint8Array(t,e,r),o=i.Bd?t=>{let e="";for(let r=0;rBuffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");i.Bd||(t=>{let e=Buffer.from(t,"base64");return l(e.buffer,e.byteOffset,e.byteLength)});let c=t=>{let e=s(t.byteLength);return e.set(t),e}},86348:(t,e,r)=>{r.d(e,{$C:()=>d,Ib:()=>D,Jg:()=>k,VQ:()=>S,bo:()=>f,cQ:()=>v,cw:()=>w,ov:()=>u,pT:()=>_,t3:()=>y,xK:()=>A,xh:()=>p});var n=r(98376),i=r(70655),s=r(72692),l=r(66816),o=r(27211);let c=o.vt("Unexpected end of array"),h=o.vt("Integer out of Range");class a{constructor(t){this.arr=t,this.pos=0}}let d=t=>new a(t),u=t=>t.pos!==t.arr.length,g=(t,e)=>{let r=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,r},f=t=>g(t,w(t)),p=t=>t.arr[t.pos++],w=t=>{let e=0,r=1,i=t.arr.length;for(;t.poss.Is)throw h}throw c},_=t=>{let e=t.arr[t.pos++],r=e&n.P1,i=64,l=(e&n.D7)>0?-1:1;if((e&n.wt)==0)return l*r;let o=t.arr.length;for(;t.poss.Is)throw h}throw c},y=l.tv?t=>l.tv.decode(f(t)):t=>{let e=w(t);if(0===e)return"";{let r=String.fromCodePoint(p(t));if(--e<100)for(;e--;)r+=String.fromCodePoint(p(t));else for(;e>0;){let n=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+n);t.pos+=n,r+=String.fromCodePoint.apply(null,i),e-=n}return decodeURIComponent(escape(r))}},b=(t,e)=>{let r=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,r},m=[t=>void 0,t=>null,_,t=>b(t,4).getFloat32(0,!1),t=>b(t,8).getFloat64(0,!1),t=>b(t,8).getBigInt64(0,!1),t=>!1,t=>!0,y,t=>{let e=w(t),r={};for(let n=0;n{let e=w(t),r=[];for(let n=0;nm[127-p(t)](t);class v extends a{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return 0===this.count&&(this.s=this.reader(this),u(this)?this.count=w(this)+1:this.count=-1),this.count--,this.s}}class S extends a{constructor(t){super(t),this.s=0,this.count=0}read(){if(0===this.count){this.s=_(this);let t=i.sj(this.s);this.count=1,t&&(this.s=-this.s,this.count=w(this)+2)}return this.count--,this.s}}class A extends a{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){let t=_(this);this.diff=i.RI(t/2),this.count=1,1&t&&(this.count=w(this)+2)}return this.s+=this.diff,this.count--,this.s}}class D{constructor(t){this.decoder=new S(t),this.str=y(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}},57632:(t,e,r)=>{r.d(e,{D$:()=>T,FA:()=>N,Fo:()=>d,Gu:()=>v,IO:()=>O,LH:()=>k,QJ:()=>f,Qj:()=>b,Sj:()=>w,Sw:()=>L,Vp:()=>m,cq:()=>x,xv:()=>h,zd:()=>p});var n=r(70655),i=r(72692),s=r(98376),l=r(66816),o=r(86552);class c{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}let h=()=>new c,a=t=>{let e=t.cpos;for(let r=0;r{let e=new Uint8Array(a(t)),r=0;for(let n=0;n{let r=t.cbuf.length;r-t.cpos{let r=t.cbuf.length;t.cpos===r&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*r),t.cpos=0),t.cbuf[t.cpos++]=e},f=g,p=(t,e)=>{for(;e>s.WD;)g(t,s.wt|s.WD&e),e=n.RI(e/128);g(t,s.WD&e)},w=(t,e)=>{let r=n.sj(e);for(r&&(e=-e),g(t,(e>s.P1?s.wt:0)|(r?s.D7:0)|s.P1&e),e=n.RI(e/64);e>0;)g(t,(e>s.WD?s.wt:0)|s.WD&e),e=n.RI(e/128)},_=new Uint8Array(3e4),y=_.length/3,b=l.db&&l.db.encodeInto?(t,e)=>{if(e.length{let r=unescape(encodeURIComponent(e)),n=r.length;p(t,n);for(let e=0;ek(t,d(e)),k=(t,e)=>{let r=t.cbuf.length,i=t.cpos,s=n.jk(r-i,e.length),l=e.length-s;t.cbuf.set(e.subarray(0,s),i),t.cpos+=s,l>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n.T9(2*r,l)),t.cbuf.set(e.subarray(s)),t.cpos=l)},v=(t,e)=>{p(t,e.byteLength),k(t,e)},S=(t,e)=>{u(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},A=(t,e)=>S(t,4).setFloat32(0,e,!1),D=(t,e)=>S(t,8).setFloat64(0,e,!1),C=(t,e)=>S(t,8).setBigInt64(0,e,!1),E=new DataView(new ArrayBuffer(4)),I=t=>(E.setFloat32(0,t),E.getFloat32(0)===t),O=(t,e)=>{switch(typeof e){case"string":g(t,119),b(t,e);break;case"number":i.Fq(e)&&n.tn(e)<=s.vZ?(g(t,125),w(t,e)):I(e)?(g(t,124),A(t,e)):(g(t,123),D(t,e));break;case"bigint":g(t,122),C(t,e);break;case"object":if(null===e)g(t,126);else if(o.cy(e)){g(t,117),p(t,e.length);for(let r=0;r0&&p(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}let M=t=>{t.count>0&&(w(t.encoder,1===t.count?t.s:-t.s),t.count>1&&p(t.encoder,t.count-2))};class T{constructor(){this.encoder=new c,this.s=0,this.count=0}write(t){this.s===t?this.count++:(M(this),this.count=1,this.s=t)}toUint8Array(){return M(this),d(this.encoder)}}let U=t=>{if(t.count>0){let e=2*t.diff+(1===t.count?0:1);w(t.encoder,e),t.count>1&&p(t.encoder,t.count-2)}};class N{constructor(){this.encoder=new c,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(U(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return U(this),d(this.encoder)}}class L{constructor(){this.sarr=[],this.s="",this.lensE=new T}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 c;return this.sarr.push(this.s),this.s="",b(t,this.sarr.join("")),k(t,this.lensE.toUint8Array()),d(t)}}},36645:(t,e,r)=>{let n;r.d(e,{Bd:()=>d,WI:()=>_});var i=r(17915),s=r(66816);let l=t=>void 0===t?null:t,o=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}};try{"undefined"!=typeof localStorage&&localStorage&&(o=localStorage)}catch(t){}let c=o;var h=r(86761);let a="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),d="undefined"!=typeof window&&"undefined"!=typeof document&&!a;"undefined"!=typeof navigator&&/Mac/.test(navigator.platform);let u=[],g=()=>{if(void 0===n){if(a){n=i.vt();let t=process.argv,e=null;for(let r=0;r{if(0!==t.length){let[e,r]=t.split("=");n.set(`--${s.jN(e,"-")}`,r),n.set(`-${s.jN(e,"-")}`,r)}})):n=i.vt()}return n},f=t=>g().has(t),p=t=>a?l(process.env[t.toUpperCase().replaceAll("-","_")]):l(c.getItem(t)),w=t=>f("--"+t)||null!==p(t);w("production");let _=a&&h.EK(process.env.FORCE_COLOR,["true","1","2"])||!f("--no-colors")&&!w("no-color")&&(!a||process.stdout.isTTY)&&(!a||f("--color")||null!==p("COLORTERM")||(p("TERM")||"").includes("color"))},27211:(t,e,r)=>{r.d(e,{Mq:()=>s,bD:()=>i,vt:()=>n});let n=t=>Error(t),i=()=>{throw n("Method unimplemented")},s=()=>{throw n("Unexpected case")}},86761:(t,e,r)=>{r.d(e,{EK:()=>h,OK:()=>s,id:()=>l,vo:()=>c});var n=r(86552),i=r(58674);let s=(t,e,r=0)=>{try{for(;rt,o=(t,e)=>t===e,c=(t,e)=>{if(null==t||null==e)return o(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let r=0;re.includes(t);n.cy},30827:(t,e,r)=>{r.d(e,{b:()=>u});var n=r(98376);let i=(t,e)=>t>>>e|t<<32-e,s=t=>i(t,2)^i(t,13)^i(t,22),l=t=>i(t,6)^i(t,11)^i(t,25),o=t=>i(t,7)^i(t,18)^t>>>3,c=t=>i(t,17)^i(t,19)^t>>>10,h=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class d{constructor(){let t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(a),this._W=new Uint32Array(t,64,64)}_updateHash(){let t=this._H,e=this._W;for(let t=16;t<64;t++)e[t]=c(e[t-2])+e[t-7]+o(e[t-15])+e[t-16];let r=t[0],n=t[1],i=t[2],a=t[3],d=t[4],u=t[5],g=t[6],f=t[7];for(let t=0,o,c;t<64;t++)o=f+l(d)+(d&u^~d&g)+h[t]+e[t]>>>0,c=s(r)+(r&n^r&i^n&i)>>>0,f=g,g=u,u=d,d=a+o>>>0,a=i,i=n,n=r,r=o+c>>>0;t[0]+=r,t[1]+=n,t[2]+=i,t[3]+=a,t[4]+=d,t[5]+=u,t[6]+=g,t[7]+=f}digest(t){let e=0;for(;e+56<=t.length;){let r=0;for(;r<16&&e+3=0&&e>>(3-e)*8;return s}}let u=t=>new d().digest(t)},20847:(t,e,r)=>{r.d(e,{$5:()=>i,n:()=>s});let n=t=>({[Symbol.iterator](){return this},next:t}),i=(t,e)=>n(()=>{let r;do r=t.next();while(!r.done&&!e(r.value))return r}),s=(t,e)=>n(()=>{let{done:r,value:n}=t.next();return{done:r,value:r?void 0:e(n)}})},94368:(t,e,r)=>{r.d(e,{ft:()=>o,Y:()=>s,AV:()=>h,Qu:()=>c,hN:()=>u,hr:()=>d,UH:()=>a,Ny:()=>l,Tx:()=>g,ET:()=>f});let n=Symbol;var i=r(9800);let s=n(),l=n(),o=n(),c=n(),h=n(),a=n(),d=n(),u=n(),g=n(),f=t=>{1===t.length&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=0;for(;n0&&r.push(e.join(""));n{r.d(e,{yy:()=>g,R8:()=>f});var n=r(36645),i=r(74357);class s{constructor(t,e){this.left=t,this.right=e}}let l=(t,e)=>new s(t,e);var o=r(17915);let c="undefined"!=typeof document?document:{};"undefined"!=typeof DOMParser&&new DOMParser;let h=t=>o.Tj(t,(t,e)=>`${e}:${t};`).join("");c.ELEMENT_NODE,c.TEXT_NODE,c.CDATA_SECTION_NODE,c.COMMENT_NODE,c.DOCUMENT_NODE,c.DOCUMENT_TYPE_NODE,c.DOCUMENT_FRAGMENT_NODE;var a=r(94368);let d={[a.Y]:l("font-weight","bold"),[a.Ny]:l("font-weight","normal"),[a.ft]:l("color","blue"),[a.AV]:l("color","green"),[a.Qu]:l("color","grey"),[a.UH]:l("color","red"),[a.hr]:l("color","purple"),[a.hN]:l("color","orange"),[a.Tx]:l("color","black")},u=n.WI?t=>{1===t.length&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=o.vt(),i=[],s=0;for(;s0||t.length>0?(e.push("%c"+i),r.push(t)):e.push(i)}else break}}for(s>0&&(i=r).unshift(e.join(""));s{console.log(...u(t)),p.forEach(e=>e.print(t))},f=(...t)=>{console.warn(...u(t)),t.unshift(a.hN),p.forEach(e=>e.print(t))},p=i.vt()},17915:(t,e,r)=>{r.d(e,{C:()=>i,Tj:()=>l,_4:()=>s,bz:()=>o,vt:()=>n});let n=()=>new Map,i=t=>{let e=n();return t.forEach((t,r)=>{e.set(r,t)}),e},s=(t,e,r)=>{let n=t.get(e);return void 0===n&&t.set(e,n=r()),n},l=(t,e)=>{let r=[];for(let[n,i]of t)r.push(e(i,n));return r},o=(t,e)=>{for(let[r,n]of t)if(e(n,r))return!0;return!1}},70655:(t,e,r)=>{r.d(e,{RI:()=>n,T9:()=>l,jk:()=>s,sj:()=>o,tn:()=>i});let n=Math.floor,i=Math.abs,s=(t,e)=>tt>e?t:e,o=t=>0!==t?t<0:1/t<0},72692:(t,e,r)=>{r.d(e,{Fq:()=>l,Is:()=>s});var n=r(70655),i=r(98376);let s=Number.MAX_SAFE_INTEGER;Number.MIN_SAFE_INTEGER,i.vZ,i.CW;let l=Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&n.RI(t)===t);Number.parseInt},58674:(t,e,r)=>{r.d(e,{Bw:()=>l,Im:()=>c,SQ:()=>d,i5:()=>a,jJ:()=>s,kp:()=>n});let n=Object.assign,i=Object.keys,s=(t,e)=>{for(let r in t)e(t[r],r)},l=t=>i(t).length,o=t=>i(t).length,c=t=>{for(let e in t)return!1;return!0},h=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},a=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),d=(t,e)=>t===e||o(t)===o(e)&&h(t,(t,r)=>(void 0!==t||a(e,r))&&e[r]===t)},79296:(t,e,r)=>{r.d(e,{W:()=>l,c:()=>o});var n=r(17915),i=r(74357),s=r(86552);class l{constructor(){this._observers=n.vt()}on(t,e){return n._4(this._observers,t,i.vt).add(e),e}once(t,e){let r=(...n)=>{this.off(t,r),e(...n)};this.on(t,r)}off(t,e){let r=this._observers.get(t);void 0!==r&&(r.delete(e),0===r.size&&this._observers.delete(t))}emit(t,e){return s.HT((this._observers.get(t)||n.vt()).values()).forEach(t=>t(...e))}destroy(){this._observers=n.vt()}}class o{constructor(){this._observers=n.vt()}on(t,e){n._4(this._observers,t,i.vt).add(e)}once(t,e){let r=(...n)=>{this.off(t,r),e(...n)};this.on(t,r)}off(t,e){let r=this._observers.get(t);void 0!==r&&(r.delete(e),0===r.size&&this._observers.delete(t))}emit(t,e){return s.HT((this._observers.get(t)||n.vt()).values()).forEach(t=>t(...e))}destroy(){this._observers=n.vt()}}},61632:(t,e,r)=>{r.d(e,{vt:()=>n});let n=t=>new Promise(t);Promise.all.bind(Promise)},47754:(t,e,r)=>{r.d(e,{r5:()=>l,gZ:()=>o});var n=r(98376);crypto.subtle;let i=crypto.getRandomValues.bind(crypto),s=()=>i(new Uint32Array(1))[0],l=()=>{let t=i(new Uint32Array(8));return(t[0]&n.yK)*(n.CW+1)+(t[1]>>>0)},o=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^s()&15>>t/4).toString(16))},74357:(t,e,r)=>{r.d(e,{vt:()=>n});let n=()=>new Set},66816:(t,e,r)=>{r.d(e,{Af:()=>d,QV:()=>i,db:()=>a,jN:()=>h,tv:()=>u,ux:()=>g});var n=r(86552);let i=String.fromCharCode;String.fromCodePoint,i(65535);let s=t=>t.toLowerCase(),l=/^\s*/g,o=t=>t.replace(l,""),c=/([A-Z])/g,h=(t,e)=>o(t.replace(c,t=>`${e}${s(t)}`)),a="undefined"!=typeof TextEncoder?new TextEncoder:null,d=a?t=>a.encode(t):t=>{let e=unescape(encodeURIComponent(t)),r=e.length,n=new Uint8Array(r);for(let t=0;tn.t8(e,()=>t).join("")},9800:(t,e,r)=>{r.d(e,{_g:()=>n});let n=Date.now},9169:(t,e,r)=>{r.d(e,{A:()=>o});var n=r(196);let i=function(t,e){for(var r=t.length;r--;)if((0,n.A)(t[r][0],e))return r;return -1};var s=Array.prototype.splice;function l(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e-1},l.prototype.set=function(t,e){var r=this.__data__,n=i(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};let o=l},71331:(t,e,r)=>{r.d(e,{A:()=>s});var n=r(80326),i=r(25801);let s=(0,n.A)(i.A,"Map")},81910:(t,e,r)=>{r.d(e,{A:()=>u});var n=(0,r(80326).A)(Object,"create"),i=Object.prototype.hasOwnProperty,s=Object.prototype.hasOwnProperty;function l(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e{r.d(e,{A:()=>s});var n=r(81910);function i(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new n.A;++e{r.d(e,{A:()=>n});let n=r(25801).A.Symbol},59693:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}},77184:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r{r.d(e,{A:()=>n});let n=function(t,e){for(var r=-1,n=e.length,i=t.length;++r{r.d(e,{A:()=>h});var n=r(55940),i=r(39229),s=r(28643),l=r(74637),o=i.A?i.A.isConcatSpreadable:void 0;let c=function(t){return(0,l.A)(t)||(0,s.A)(t)||!!(o&&t&&t[o])},h=function t(e,r,i,s,l){var o=-1,h=e.length;for(i||(i=c),l||(l=[]);++o0&&i(a)?r>1?t(a,r-1,i,s,l):(0,n.A)(l,a):s||(l[l.length]=a)}return l}},31835:(t,e,r)=>{r.d(e,{A:()=>d});var n=r(39229),i=Object.prototype,s=i.hasOwnProperty,l=i.toString,o=n.A?n.A.toStringTag:void 0;let c=function(t){var e=s.call(t,o),r=t[o];try{t[o]=void 0;var n=!0}catch(t){}var i=l.call(t);return n&&(e?t[o]=r:delete t[o]),i};var h=Object.prototype.toString,a=n.A?n.A.toStringTag:void 0;let d=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":a&&a in Object(t)?c(t):h.call(t)}},89698:(t,e,r)=>{r.d(e,{A:()=>l});var n=r(63708),i=r(21185),s=r(18198);let l=function(t,e){return(0,s.A)((0,i.A)(t,e,n.A),t+"")}},16105:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t){return function(e){return t(e)}}},95199:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t,e){return t.has(e)}},66831:(t,e,r)=>{r.d(e,{A:()=>i});var n=r(80326);let i=function(){try{var t=(0,n.A)(Object,"defineProperty");return t({},"",{}),t}catch(t){}}()},42692:(t,e,r)=>{r.d(e,{A:()=>n});let n="object"==typeof global&&global&&global.Object===Object&&global},80326:(t,e,r)=>{r.d(e,{A:()=>g});var n=r(54750),i=r(25801).A["__core-js_shared__"],s=function(){var t=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),l=r(40345),o=r(7837),c=/^\[object .+?Constructor\]$/,h=Object.prototype,a=Function.prototype.toString,d=h.hasOwnProperty,u=RegExp("^"+a.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");let g=function(t,e){var r,i=null==t?void 0:t[e];return(r=i,(0,l.A)(r)&&(!s||!(s in r))&&((0,n.A)(r)?u:c).test((0,o.A)(r)))?i:void 0}},21185:(t,e,r)=>{r.d(e,{A:()=>s});var n=r(59693),i=Math.max;let s=function(t,e,r){return e=i(void 0===e?t.length-1:e,0),function(){for(var s=arguments,l=-1,o=i(s.length-e,0),c=Array(o);++l{r.d(e,{A:()=>s});var n=r(42692),i="object"==typeof self&&self&&self.Object===Object&&self;let s=n.A||i||Function("return this")()},18198:(t,e,r)=>{r.d(e,{A:()=>o});var n=r(66831),i=r(63708),s=n.A?function(t,e){return(0,n.A)(t,"toString",{configurable:!0,enumerable:!1,value:function(){return e},writable:!0})}:i.A,l=Date.now;let o=function(t){var e=0,r=0;return function(){var n=l(),i=16-(n-r);if(r=n,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(s)},7837:(t,e,r)=>{r.d(e,{A:()=>i});var n=Function.prototype.toString;let i=function(t){if(null!=t){try{return n.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},20593:(t,e,r)=>{r.d(e,{A:()=>w});var n=r(70488);let i=function(t,e,r,n){for(var i=t.length,s=r+(n?1:-1);n?s--:++s-1},c=function(t,e,r){for(var n=-1,i=null==t?0:t.length;++n=200&&(l=d.A,u=!1,e=new n.A(e));t:for(;++s{r.d(e,{A:()=>n});let n=function(t,e){return t===e||t!=t&&e!=e}},63708:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t){return t}},28643:(t,e,r)=>{r.d(e,{A:()=>h});var n=r(31835),i=r(43046);let s=function(t){return(0,i.A)(t)&&"[object Arguments]"==(0,n.A)(t)};var l=Object.prototype,o=l.hasOwnProperty,c=l.propertyIsEnumerable;let h=s(function(){return arguments}())?s:function(t){return(0,i.A)(t)&&o.call(t,"callee")&&!c.call(t,"callee")}},74637:(t,e,r)=>{r.d(e,{A:()=>n});let n=Array.isArray},41578:(t,e,r)=>{r.d(e,{A:()=>s});var n=r(54750),i=r(81605);let s=function(t){return null!=t&&(0,i.A)(t.length)&&!(0,n.A)(t)}},31937:(t,e,r)=>{r.d(e,{A:()=>s});var n=r(41578),i=r(43046);let s=function(t){return(0,i.A)(t)&&(0,n.A)(t)}},54750:(t,e,r)=>{r.d(e,{A:()=>s});var n=r(31835),i=r(40345);let s=function(t){if(!(0,i.A)(t))return!1;var e=(0,n.A)(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},81605:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},40345:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},43046:(t,e,r)=>{r.d(e,{A:()=>n});let n=function(t){return null!=t&&"object"==typeof t}},16820:(t,e,r)=>{r.r(e),r.d(e,{AbsolutePosition:()=>tI,AbstractConnector:()=>v,AbstractStruct:()=>rT,AbstractType:()=>eq,Array:()=>rl,ContentAny:()=>rP,ContentBinary:()=>rN,ContentDeleted:()=>rL,ContentDoc:()=>rR,ContentEmbed:()=>rj,ContentFormat:()=>rV,ContentJSON:()=>rF,ContentString:()=>rW,ContentType:()=>rY,Doc:()=>j,GC:()=>rU,ID:()=>tw,Item:()=>r8,Map:()=>rc,PermanentUserData:()=>tA,RelativePosition:()=>tD,Skip:()=>r4,Snapshot:()=>tj,Text:()=>rD,Transaction:()=>t9,UndoManager:()=>ed,UpdateDecoderV1:()=>F,UpdateDecoderV2:()=>W,UpdateEncoderV1:()=>J,UpdateEncoderV2:()=>K,XmlElement:()=>rI,XmlFragment:()=>rE,XmlHook:()=>rx,XmlText:()=>rM,YArrayEvent:()=>rs,YEvent:()=>eR,YMapEvent:()=>ro,YTextEvent:()=>rA,YXmlEvent:()=>rO,applyUpdate:()=>te,applyUpdateV2:()=>tt,cleanupYTextFormatting:()=>rk,compareIDs:()=>t_,compareRelativePositions:()=>tR,convertUpdateFormatV1ToV2:()=>eN,convertUpdateFormatV2ToV1:()=>eL,createAbsolutePositionFromRelativePosition:()=>tz,createDeleteSet:()=>M,createDeleteSetFromStructStore:()=>T,createDocFromSnapshot:()=>tQ,createID:()=>ty,createRelativePositionFromJSON:()=>tE,createRelativePositionFromTypeIndex:()=>tM,createSnapshot:()=>tJ,decodeRelativePosition:()=>tL,decodeSnapshot:()=>t$,decodeSnapshotV2:()=>tW,decodeStateVector:()=>tl,decodeUpdate:()=>ep,decodeUpdateV2:()=>ew,diffUpdate:()=>eC,diffUpdateV2:()=>eD,emptySnapshot:()=>tH,encodeRelativePosition:()=>tU,encodeSnapshot:()=>tP,encodeSnapshotV2:()=>tF,encodeStateAsUpdate:()=>ti,encodeStateAsUpdateV2:()=>tn,encodeStateVector:()=>ta,encodeStateVectorFromUpdate:()=>em,encodeStateVectorFromUpdateV2:()=>eb,equalDeleteSets:()=>z,equalSnapshots:()=>tV,findIndexSS:()=>t2,findRootTypeKey:()=>tk,getItem:()=>t8,getState:()=>t0,getTypeChildren:()=>eK,isDeleted:()=>E,isParentOf:()=>tv,iterateDeletedStructs:()=>D,logType:()=>tS,logUpdate:()=>eg,logUpdateV2:()=>ef,mergeDeleteSets:()=>O,mergeUpdates:()=>ey,mergeUpdatesV2:()=>eA,obfuscateUpdate:()=>eT,obfuscateUpdateV2:()=>eU,parseUpdateMeta:()=>ev,parseUpdateMetaV2:()=>ek,readUpdate:()=>Z,readUpdateV2:()=>X,relativePositionToJSON:()=>tC,snapshot:()=>tK,snapshotContainsUpdate:()=>tY,transact:()=>eo,tryGc:()=>es,typeListToArraySnapshot:()=>eY,typeMapGetAllSnapshot:()=>rn,typeMapGetSnapshot:()=>rr});var n=r(79296),i=r(86552),s=r(70655),l=r(17915),o=r(57632),c=r(86348),h=r(47754),a=r(61632),d=r(3531),u=r(27211),g=r(98376),f=r(86761),p=r(74357),w=r(39601),_=r(94368),y=r(9800),b=r(66816),m=r(20847),k=r(58674);class v extends n.W{constructor(t,e){super(),this.doc=t,this.awareness=e}}class S{constructor(t,e){this.clock=t,this.len=e}}class A{constructor(){this.clients=new Map}}let D=(t,e,r)=>e.clients.forEach((e,n)=>{let i=t.doc.store.clients.get(n);for(let n=0;n{let r=0,n=t.length-1;for(;r<=n;){let i=s.RI((r+n)/2),l=t[i],o=l.clock;if(o<=e){if(e{let r=t.clients.get(e.client);return void 0!==r&&null!==C(r,e.clock)},I=t=>{t.clients.forEach(t=>{let e,r;for(t.sort((t,e)=>t.clock-e.clock),e=1,r=1;e=i.clock?n.len=s.T9(n.len,i.clock+i.len-n.clock):(r{let e=new A;for(let r=0;r{if(!e.clients.has(s)){let l=n.slice();for(let e=r+1;e{l._4(t.clients,e,()=>[]).push(new S(r,n))},M=()=>new A,T=t=>{let e=M();return t.clients.forEach((t,r)=>{let n=[];for(let e=0;e0&&e.clients.set(r,n)}),e},U=(t,e)=>{o.zd(t.restEncoder,e.clients.size),i.HT(e.clients.entries()).sort((t,e)=>e[0]-t[0]).forEach(([e,r])=>{t.resetDsCurVal(),o.zd(t.restEncoder,e);let n=r.length;o.zd(t.restEncoder,n);for(let e=0;e{let e=new A,r=c.cw(t.restDecoder);for(let n=0;n0){let i=l._4(e.clients,r,()=>[]);for(let e=0;e{let n=new A,i=c.cw(t.restDecoder);for(let s=0;s0){let t=new K;return o.zd(t.restEncoder,0),U(t,n),t.toUint8Array()}return null},z=(t,e)=>{if(t.clients.size!==e.clients.size)return!1;for(let[r,n]of t.clients.entries()){let t=e.clients.get(r);if(void 0===t||n.length!==t.length)return!1;for(let e=0;e!0,meta:i=null,autoLoad:s=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=n,this.clientID=R(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new tX,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=a.vt(t=>{this.on("load",()=>{this.isLoaded=!0,t(this)})});let o=()=>a.vt(t=>{let e=r=>{(void 0===r||!0===r)&&(this.off("sync",e),t())};this.on("sync",e)});this.on("sync",t=>{!1===t&&this.isSynced&&(this.whenSynced=o()),this.isSynced=void 0===t||!0===t,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=o()}load(){let t=this._item;null===t||this.shouldLoad||eo(t.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(i.HT(this.subdocs).map(t=>t.guid))}transact(t,e=null){return eo(this,t,e)}get(t,e=eq){let r=l._4(this.share,t,()=>{let t=new e;return t._integrate(this,null),t}),n=r.constructor;if(e!==eq&&n!==e){if(n===eq){let n=new e;n._map=r._map,r._map.forEach(t=>{for(;null!==t;t=t.left)t.parent=n}),n._start=r._start;for(let t=n._start;null!==t;t=t.right)t.parent=n;return n._length=r._length,this.share.set(t,n),n._integrate(this,null),n}throw Error(`Type with the name ${t} has already been defined with a different constructor`)}return r}getArray(t=""){return this.get(t,rl)}getText(t=""){return this.get(t,rD)}getMap(t=""){return this.get(t,rc)}getXmlElement(t=""){return this.get(t,rI)}getXmlFragment(t=""){return this.get(t,rE)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){i.HT(this.subdocs).forEach(t=>t.destroy());let t=this._item;if(null!==t){this._item=null;let e=t.content;e.doc=new j({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,eo(t.parent.doc,r=>{let n=e.doc;t.deleted||r.subdocsAdded.add(n),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class V{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return c.cw(this.restDecoder)}readDsLen(){return c.cw(this.restDecoder)}}class F extends V{readLeftID(){return ty(c.cw(this.restDecoder),c.cw(this.restDecoder))}readRightID(){return ty(c.cw(this.restDecoder),c.cw(this.restDecoder))}readClient(){return c.cw(this.restDecoder)}readInfo(){return c.xh(this.restDecoder)}readString(){return c.t3(this.restDecoder)}readParentInfo(){return 1===c.cw(this.restDecoder)}readTypeRef(){return c.cw(this.restDecoder)}readLen(){return c.cw(this.restDecoder)}readAny(){return c.Jg(this.restDecoder)}readBuf(){return d.HR(c.bo(this.restDecoder))}readJSON(){return JSON.parse(c.t3(this.restDecoder))}readKey(){return c.t3(this.restDecoder)}}class P{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=c.cw(this.restDecoder),this.dsCurrVal}readDsLen(){let t=c.cw(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class W extends P{constructor(t){super(t),this.keys=[],c.cw(t),this.keyClockDecoder=new c.xK(c.bo(t)),this.clientDecoder=new c.VQ(c.bo(t)),this.leftClockDecoder=new c.xK(c.bo(t)),this.rightClockDecoder=new c.xK(c.bo(t)),this.infoDecoder=new c.cQ(c.bo(t),c.xh),this.stringDecoder=new c.Ib(c.bo(t)),this.parentInfoDecoder=new c.cQ(c.bo(t),c.xh),this.typeRefDecoder=new c.VQ(c.bo(t)),this.lenDecoder=new c.VQ(c.bo(t))}readLeftID(){return new tw(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new tw(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return c.Jg(this.restDecoder)}readBuf(){return c.bo(this.restDecoder)}readJSON(){return c.Jg(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t{n=s.T9(n,e[0].id.clock);let i=t2(e,n);o.zd(t.restEncoder,e.length-i),t.writeClient(r),o.zd(t.restEncoder,n);let l=e[i];l.write(t,n-l.id.clock);for(let r=i+1;r{let n=new Map;r.forEach((t,r)=>{t0(e,r)>t&&n.set(r,t)}),tZ(e).forEach((t,e)=>{r.has(e)||n.set(e,0)}),o.zd(t.restEncoder,n.size),i.HT(n.entries()).sort((t,e)=>e[0]-t[0]).forEach(([r,n])=>{B(t,e.clients.get(r),r,n)})},Q=(t,e)=>{let r=l.vt(),n=c.cw(t.restDecoder);for(let i=0;i{let n=[],s=i.HT(r.keys()).sort((t,e)=>t-e);if(0===s.length)return null;let c=()=>{if(0===s.length)return null;let t=r.get(s[s.length-1]);for(;t.refs.length===t.i;){if(s.pop(),!(s.length>0))return null;t=r.get(s[s.length-1])}return t},h=c();if(null===h)return null;let a=new tX,d=new Map,u=(t,e)=>{let r=d.get(t);(null==r||r>e)&&d.set(t,e)},g=h.refs[h.i++],f=new Map,p=()=>{for(let t of n){let e=t.id.client,n=r.get(e);n?(n.i--,a.clients.set(e,n.refs.slice(n.i)),r.delete(e),n.i=0,n.refs=[]):a.clients.set(e,[t]),s=s.filter(t=>t!==e)}n.length=0};for(;;){if(g.constructor!==r4){let i=l._4(f,g.id.client,()=>t0(e,g.id.client))-g.id.clock;if(i<0)n.push(g),u(g.id.client,g.id.clock-1),p();else{let s=g.getMissing(t,e);if(null!==s){n.push(g);let t=r.get(s)||{refs:[],i:0};if(t.refs.length===t.i)u(s,t0(e,s)),p();else{g=t.refs[t.i++];continue}}else(0===i||i0)g=n.pop();else if(null!==h&&h.i0){let t=new K;return q(t,a,new Map),o.zd(t.restEncoder,0),{missing:d,update:t.toUint8Array()}}return null},Y=(t,e)=>q(t,e.doc.store,e.beforeState),X=(t,e,r,n=new W(t))=>eo(e,t=>{t.local=!1;let e=!1,r=t.doc,i=r.store,s=G(t,i,Q(n,r)),l=i.pendingStructs;if(l){for(let[t,r]of l.missing)if(re)&&l.missing.set(t,e)}l.update=eA([l.update,s.update])}}else i.pendingStructs=s;let o=L(n,t,i);if(i.pendingDs){let e=new W(c.$C(i.pendingDs));c.cw(e.restDecoder);let r=L(e,t,i);o&&r?i.pendingDs=eA([o,r]):i.pendingDs=o||r}else i.pendingDs=o;if(e){let e=i.pendingStructs.update;i.pendingStructs=null,tt(t.doc,e)}},r,!1),Z=(t,e,r)=>X(t,e,r,new F(t)),tt=(t,e,r,n=W)=>{let i=c.$C(e);X(i,t,r,new n(i))},te=(t,e,r)=>tt(t,e,r,F),tr=(t,e,r=new Map)=>{q(t,e.store,r),U(t,T(e.store))},tn=(t,e=new Uint8Array([0]),r=new K)=>{tr(r,t,tl(e));let n=[r.toUint8Array()];if(t.store.pendingDs&&n.push(t.store.pendingDs),t.store.pendingStructs&&n.push(eD(t.store.pendingStructs.update,e)),n.length>1){if(r.constructor===J)return ey(n.map((t,e)=>0===e?t:eL(t)));if(r.constructor===K)return eA(n)}return n[0]},ti=(t,e)=>tn(t,e,new J),ts=t=>{let e=new Map,r=c.cw(t.restDecoder);for(let n=0;nts(new V(c.$C(t))),to=(t,e)=>(o.zd(t.restEncoder,e.size),i.HT(e.entries()).sort((t,e)=>e[0]-t[0]).forEach(([e,r])=>{o.zd(t.restEncoder,e),o.zd(t.restEncoder,r)}),t),tc=(t,e)=>to(t,tZ(e.store)),th=(t,e=new H)=>(t instanceof Map?to(e,t):tc(e,t),e.toUint8Array()),ta=t=>th(t,new $);class td{constructor(){this.l=[]}}let tu=()=>new td,tg=(t,e)=>t.l.push(e),tf=(t,e)=>{let r=t.l,n=r.length;t.l=r.filter(t=>e!==t),n===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},tp=(t,e,r)=>f.OK(t.l,[e,r]);class tw{constructor(t,e){this.client=t,this.clock=e}}let t_=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,ty=(t,e)=>new tw(t,e),tb=(t,e)=>{o.zd(t,e.client),o.zd(t,e.clock)},tm=t=>ty(c.cw(t),c.cw(t)),tk=t=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw u.Mq()},tv=(t,e)=>{for(;null!==e;){if(e.parent===t)return!0;e=e.parent._item}return!1},tS=t=>{let e=[],r=t._start;for(;r;)e.push(r),r=r.right;console.log("Children: ",e),console.log("Children content: ",e.filter(t=>!t.deleted).map(t=>t.content))};class tA{constructor(t,e=t.getMap("users")){let r=new Map;this.yusers=e,this.doc=t,this.clients=new Map,this.dss=r;let n=(t,e)=>{let r=t.get("ds"),n=t.get("ids"),i=t=>this.clients.set(t,e);r.observe(t=>{t.changes.added.forEach(t=>{t.content.getContent().forEach(t=>{t instanceof Uint8Array&&this.dss.set(e,O([this.dss.get(e)||M(),N(new V(c.$C(t)))]))})})}),this.dss.set(e,O(r.map(t=>N(new V(c.$C(t)))))),n.observe(t=>t.changes.added.forEach(t=>t.content.getContent().forEach(i))),n.forEach(i)};e.observe(t=>{t.keysChanged.forEach(t=>n(e.get(t),t))}),e.forEach(n)}setUserMapping(t,e,r,{filter:n=()=>!0}={}){let i=this.yusers,s=i.get(r);s||((s=new rc).set("ids",new rl),s.set("ds",new rl),i.set(r,s)),s.get("ids").push([e]),i.observe(t=>{setTimeout(()=>{let t=i.get(r);if(t!==s){s=t,this.clients.forEach((t,e)=>{r===t&&s.get("ids").push([e])});let e=new $,n=this.dss.get(r);n&&(U(e,n),s.get("ds").push([e.toUint8Array()]))}},0)}),t.on("afterTransaction",t=>{setTimeout(()=>{let e=s.get("ds"),r=t.deleteSet;if(t.local&&r.clients.size>0&&n(t,r)){let t=new $;U(t,r),e.push([t.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[e,r]of this.dss.entries())if(E(r,t))return e;return null}}class tD{constructor(t,e,r,n=0){this.type=t,this.tname=e,this.item=r,this.assoc=n}}let tC=t=>{let e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),null!=t.assoc&&(e.assoc=t.assoc),e},tE=t=>new tD(null==t.type?null:ty(t.type.client,t.type.clock),t.tname??null,null==t.item?null:ty(t.item.client,t.item.clock),null==t.assoc?0:t.assoc);class tI{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}let tO=(t,e,r=0)=>new tI(t,e,r),tx=(t,e,r)=>{let n=null,i=null;return null===t._item?i=tk(t):n=ty(t._item.id.client,t._item.id.clock),new tD(n,i,e,r)},tM=(t,e,r=0)=>{let n=t._start;if(r<0){if(0===e)return tx(t,null,r);e--}for(;null!==n;){if(!n.deleted&&n.countable){if(n.length>e)return tx(t,ty(n.id.client,n.id.clock+e),r);e-=n.length}if(null===n.right&&r<0)return tx(t,n.lastId,r);n=n.right}return tx(t,null,r)},tT=(t,e)=>{let{type:r,tname:n,item:i,assoc:s}=e;if(null!==i)o.zd(t,0),tb(t,i);else if(null!==n)o.QJ(t,1),o.Qj(t,n);else if(null!==r)o.QJ(t,2),tb(t,r);else throw u.Mq();return o.Sj(t,s),t},tU=t=>{let e=o.xv();return tT(e,t),o.Fo(e)},tN=t=>{let e=null,r=null,n=null;switch(c.cw(t)){case 0:n=tm(t);break;case 1:r=c.t3(t);break;case 2:e=tm(t)}return new tD(e,r,n,c.ov(t)?c.pT(t):0)},tL=t=>tN(c.$C(t)),tz=(t,e,r=!0)=>{let n=e.store,i=t.item,s=t.type,l=t.tname,o=t.assoc,c=null,h=0;if(null!==i){if(t0(n,i.client)<=i.clock)return null;let t=r?rX(n,i):{item:t8(n,i),diff:0},e=t.item;if(!(e instanceof r8))return null;if(null===(c=e.parent)._item||!c._item.deleted){h=e.deleted||!e.countable?0:t.diff+(o>=0?0:1);let r=e.left;for(;null!==r;)!r.deleted&&r.countable&&(h+=r.length),r=r.left}}else{if(null!==l)c=e.get(l);else if(null!==s){if(t0(n,s.client)<=s.clock)return null;let{item:t}=r?rX(n,s):{item:t8(n,s)};if(!(t instanceof r8)||!(t.content instanceof rY))return null;c=t.content.type}else throw u.Mq();h=o>=0?c._length:0}return tO(c,h,t.assoc)},tR=(t,e)=>t===e||null!==t&&null!==e&&t.tname===e.tname&&t_(t.item,e.item)&&t_(t.type,e.type)&&t.assoc===e.assoc;class tj{constructor(t,e){this.ds=t,this.sv=e}}let tV=(t,e)=>{let r=t.ds.clients,n=e.ds.clients,i=t.sv,s=e.sv;if(i.size!==s.size||r.size!==n.size)return!1;for(let[t,e]of i.entries())if(s.get(t)!==e)return!1;for(let[t,e]of r.entries()){let r=n.get(t)||[];if(e.length!==r.length)return!1;for(let t=0;t(U(e,t.ds),to(e,t.sv),e.toUint8Array()),tP=t=>tF(t,new $),tW=(t,e=new P(c.$C(t)))=>new tj(N(e),ts(e)),t$=t=>tW(t,new V(c.$C(t))),tJ=(t,e)=>new tj(t,e),tH=tJ(M(),new Map),tK=t=>tJ(T(t.store),tZ(t.store)),tB=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!E(e.ds,t.id),tq=(t,e)=>{let r=l._4(t.meta,tq,p.vt),n=t.doc.store;r.has(e)||(e.sv.forEach((e,r)=>{e{}),r.add(e))},tQ=(t,e,r=new j)=>{if(t.gc)throw Error("Garbage-collection must be disabled in `originDoc`!");let{sv:n,ds:i}=e,s=new K;return t.transact(e=>{let r=0;for(let[i,l]of(n.forEach(t=>{t>0&&r++}),o.zd(s.restEncoder,r),n)){if(0===l)continue;l{let n=new r(c.$C(e)),i=new eu(n,!1);for(let e=i.curr;null!==e;e=i.next())if((t.sv.get(e.id.client)||0)tG(t,e,F);class tX{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}let tZ=t=>{let e=new Map;return t.clients.forEach((t,r)=>{let n=t[t.length-1];e.set(r,n.id.clock+n.length)}),e},t0=(t,e)=>{let r=t.clients.get(e);if(void 0===r)return 0;let n=r[r.length-1];return n.id.clock+n.length},t1=(t,e)=>{let r=t.clients.get(e.id.client);if(void 0===r)r=[],t.clients.set(e.id.client,r);else{let t=r[r.length-1];if(t.id.clock+t.length!==e.id.clock)throw u.Mq()}r.push(e)},t2=(t,e)=>{let r=0,n=t.length-1,i=t[n],l=i.id.clock;if(l===e)return n;let o=s.RI(e/(l+i.length-1)*n);for(;r<=n;){if((l=(i=t[o]).id.clock)<=e){if(e{let r=t.clients.get(e.client);return r[t2(r,e.clock)]},t3=(t,e,r)=>{let n=t2(e,r),i=e[n];return i.id.clock{let r=t.doc.store.clients.get(e.client);return r[t3(t,r,e.clock)]},t4=(t,e,r)=>{let n=e.clients.get(r.client),i=t2(n,r.clock),s=n[i];return r.clock!==s.id.clock+s.length-1&&s.constructor!==rU&&n.splice(i+1,0,r0(t,s,r.clock-s.id.clock+1)),s},t7=(t,e,r)=>{let n=t.clients.get(e.id.client);n[t2(n,e.id.clock)]=r},t5=(t,e,r,n,i)=>{let s;if(0===n)return;let l=r+n,o=t3(t,e,r);do l<(s=e[o++]).id.clock+s.length&&t3(t,e,l),i(s);while(o!!(0!==e.deleteSet.clients.size||l.bz(e.afterState,(t,r)=>e.beforeState.get(r)!==t))&&(I(e.deleteSet),Y(t,e),U(t,e.deleteSet),!0),ee=(t,e,r)=>{let n=e._item;(null===n||n.id.clock<(t.beforeState.get(n.id.client)||0)&&!n.deleted)&&l._4(t.changed,e,p.vt).add(r)},er=(t,e)=>{let r=t[e],n=t[e-1],i=e;for(;i>0;r=n,n=t[--i-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor&&n.mergeWith(r)){r instanceof r8&&null!==r.parentSub&&r.parent._map.get(r.parentSub)===r&&r.parent._map.set(r.parentSub,n);continue}break}let s=e-i;return s&&t.splice(e+1-s,s),s},en=(t,e,r)=>{for(let[n,i]of t.clients.entries()){let t=e.clients.get(n);for(let n=i.length-1;n>=0;n--){let s=i[n],l=s.clock+s.len;for(let n=t2(t,s.clock),i=t[n];n{t.clients.forEach((t,r)=>{let n=e.clients.get(r);for(let e=t.length-1;e>=0;e--){let r=t[e],i=s.jk(n.length-1,1+t2(n,r.clock+r.len-1));for(let t=i,e=n[t];t>0&&e.id.clock>=r.clock;e=n[t])t-=1+er(n,t)}})},es=(t,e,r)=>{en(t,e,r),ei(t,e)},el=(t,e)=>{if(et.push(()=>{null!==n._item&&n._item.deleted||n._callObserver(r,e)})),t.push(()=>{r.changedParentTypes.forEach((t,e)=>{e._dEH.l.length>0&&(null===e._item||!e._item.deleted)&&((t=t.filter(t=>null===t.target._item||!t.target._item.deleted)).forEach(t=>{t.currentTarget=e,t._path=null}),t.sort((t,e)=>t.path.length-e.path.length),tp(e._dEH,t,r))})}),t.push(()=>n.emit("afterTransaction",[r,n])),(0,f.OK)(t,[]),r._needFormattingCleanup&&rv(r)}finally{n.gc&&en(l,i,n.gcFilter),ei(l,i),r.afterState.forEach((t,e)=>{let n=r.beforeState.get(e)||0;if(n!==t){let t=i.clients.get(e),r=s.T9(t2(t,n),1);for(let e=t.length-1;e>=r;)e-=1+er(t,e)}});for(let t=o.length-1;t>=0;t--){let{client:e,clock:r}=o[t].id,n=i.clients.get(e),s=t2(n,r);!(s+11)&&s>0&&er(n,s)}if(r.local||r.afterState.get(n.clientID)===r.beforeState.get(n.clientID)||(w.yy(_.hN,_.Y,"[yjs] ",_.Ny,_.UH,"Changed the client-id because another client seems to be using it."),n.clientID=R()),n.emit("afterTransactionCleanup",[r,n]),n._observers.has("update")){let t=new J;et(t,r)&&n.emit("update",[t.toUint8Array(),r.origin,n,r])}if(n._observers.has("updateV2")){let t=new K;et(t,r)&&n.emit("updateV2",[t.toUint8Array(),r.origin,n,r])}let{subdocsAdded:c,subdocsLoaded:h,subdocsRemoved:a}=r;(c.size>0||a.size>0||h.size>0)&&(c.forEach(t=>{t.clientID=n.clientID,null==t.collectionid&&(t.collectionid=n.collectionid),n.subdocs.add(t)}),a.forEach(t=>n.subdocs.delete(t)),n.emit("subdocs",[{loaded:h,added:c,removed:a},n,r]),a.forEach(t=>t.destroy())),t.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,t])):el(t,e+1)}}},eo=(t,e,r=null,n=!0)=>{let i=t._transactionCleanups,s=!1,l=null;null===t._transaction&&(s=!0,t._transaction=new t9(t,r,n),i.push(t._transaction),1===i.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(s){let e=t._transaction===i[0];t._transaction=null,e&&el(i,0)}}return l};class ec{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}let eh=(t,e,r)=>{D(t,r.deletions,t=>{t instanceof r8&&e.scope.some(e=>tv(e,t))&&rZ(t,!1)})},ea=(t,e,r)=>{let n=null,i=t.doc,s=t.scope;eo(i,r=>{for(;e.length>0&&null===t.currStackItem;){let n=i.store,l=e.pop(),o=new Set,c=[],h=!1;D(r,l.insertions,t=>{if(t instanceof r8){if(null!==t.redone){let{item:e,diff:i}=rX(n,t.id);i>0&&(e=t6(r,ty(e.id.client,e.id.clock+i))),t=e}!t.deleted&&s.some(e=>tv(e,t))&&c.push(t)}}),D(r,l.deletions,t=>{t instanceof r8&&s.some(e=>tv(e,t))&&!E(l.insertions,t.id)&&o.add(t)}),o.forEach(e=>{h=null!==r2(r,e,o,l.insertions,t.ignoreRemoteMapChanges,t)||h});for(let e=c.length-1;e>=0;e--){let n=c[e];t.deleteFilter(n)&&(n.delete(r),h=!0)}t.currStackItem=h?l:null}r.changed.forEach((t,e)=>{t.has(null)&&e._searchMarker&&(e._searchMarker.length=0)}),n=r},t);let l=t.currStackItem;if(null!=l){let e=n.changedParentTypes;t.emit("stack-item-popped",[{stackItem:l,type:r,changedParentTypes:e,origin:t},t]),t.currStackItem=null}return l};class ed extends n.W{constructor(t,{captureTimeout:e=500,captureTransaction:r=t=>!0,deleteFilter:n=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:l=!1,doc:o=i.cy(t)?t[0].doc:t.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=n,s.add(this),this.trackedOrigins=s,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=l,this.captureTimeout=e,this.afterTransactionHandler=t=>{if(!this.captureTransaction(t)||!this.scope.some(e=>t.changedParentTypes.has(e))||!this.trackedOrigins.has(t.origin)&&(!t.origin||!this.trackedOrigins.has(t.origin.constructor)))return;let e=this.undoing,r=this.redoing,n=e?this.redoStack:this.undoStack;e?this.stopCapturing():r||this.clear(!1,!0);let i=new A;t.afterState.forEach((e,r)=>{let n=t.beforeState.get(r)||0,s=e-n;s>0&&x(i,r,n,s)});let s=y._g(),l=!1;if(this.lastChange>0&&s-this.lastChange0&&!e&&!r){let e=n[n.length-1];e.deletions=O([e.deletions,t.deleteSet]),e.insertions=O([e.insertions,i])}else n.push(new ec(t.deleteSet,i)),l=!0;e||r||(this.lastChange=s),D(t,t.deleteSet,t=>{t instanceof r8&&this.scope.some(e=>tv(e,t))&&rZ(t,!0)});let o=[{stackItem:n[n.length-1],origin:t.origin,type:e?"redo":"undo",changedParentTypes:t.changedParentTypes},this];l?this.emit("stack-item-added",o):this.emit("stack-item-updated",o)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){(t=i.cy(t)?t:[t]).forEach(t=>{this.scope.every(e=>e!==t)&&(t.doc!==this.doc&&w.R8("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(t=>eh(r,this,t)),this.undoStack=[]),e&&(this.redoStack.forEach(t=>eh(r,this,t)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){let t;this.undoing=!0;try{t=ea(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){let t;this.redoing=!0;try{t=ea(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()}}class eu{constructor(t,e){this.gen=function*(t){let e=c.cw(t.restDecoder);for(let r=0;ref(t,F),ef=(t,e=W)=>{let r=[],n=new e(c.$C(t)),i=new eu(n,!1);for(let t=i.curr;null!==t;t=i.next())r.push(t);w.yy("Structs: ",r);let s=N(n);w.yy("DeleteSet: ",s)},ep=t=>ew(t,F),ew=(t,e=W)=>{let r=[],n=new e(c.$C(t)),i=new eu(n,!1);for(let t=i.curr;null!==t;t=i.next())r.push(t);return{structs:r,ds:N(n)}};class e_{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}let ey=t=>eA(t,F,J),eb=(t,e=H,r=W)=>{let n=new e,i=new eu(new r(c.$C(t)),!1),s=i.curr;if(null===s)return o.zd(n.restEncoder,0),n.toUint8Array();{let t=0,e=s.id.client,r=0!==s.id.clock,l=r?0:s.id.clock+s.length;for(;null!==s;s=i.next())e!==s.id.client&&(0!==l&&(t++,o.zd(n.restEncoder,e),o.zd(n.restEncoder,l)),e=s.id.client,l=0,r=0!==s.id.clock),s.constructor===r4&&(r=!0),r||(l=s.id.clock+s.length);0!==l&&(t++,o.zd(n.restEncoder,e),o.zd(n.restEncoder,l));let c=o.xv();return o.zd(c,t),o.Vp(c,n.restEncoder),n.restEncoder=c,n.toUint8Array()}},em=t=>eb(t,$,F),ek=(t,e=W)=>{let r=new Map,n=new Map,i=new eu(new e(c.$C(t)),!1),s=i.curr;if(null!==s){let t=s.id.client,e=s.id.clock;for(r.set(t,e);null!==s;s=i.next())t!==s.id.client&&(n.set(t,e),r.set(s.id.client,s.id.clock),t=s.id.client),e=s.id.clock+s.length;n.set(t,e)}return{from:r,to:n}},ev=t=>ek(t,F),eS=(t,e)=>{if(t.constructor===rU){let{client:r,clock:n}=t.id;return new rU(ty(r,n+e),t.length-e)}if(t.constructor===r4){let{client:r,clock:n}=t.id;return new r4(ty(r,n+e),t.length-e)}{let{client:r,clock:n}=t.id;return new r8(ty(r,n+e),null,ty(r,n+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},eA=(t,e=W,r=K)=>{if(1===t.length)return t[0];let n=t.map(t=>new e(c.$C(t))),i=n.map(t=>new eu(t,!0)),s=null,l=new r,o=new e_(l);for(;(i=i.filter(t=>null!==t.curr)).sort((t,e)=>{if(t.curr.id.client!==e.curr.id.client)return e.curr.id.client-t.curr.id.client;{let r=t.curr.id.clock-e.curr.id.clock;return 0===r?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===r4?1:-1:r}}),0!==i.length;){let t=i[0],e=t.curr.id.client;if(null!==s){let r=t.curr,n=!1;for(;null!==r&&r.id.clock+r.length<=s.struct.id.clock+s.struct.length&&r.id.client>=s.struct.id.client;)r=t.next(),n=!0;if(null===r||r.id.client!==e||n&&r.id.clock>s.struct.id.clock+s.struct.length)continue;if(e!==s.struct.id.client)eI(o,s.struct,s.offset),s={struct:r,offset:0},t.next();else if(s.struct.id.clock+s.struct.length0&&(s.struct.constructor===r4?s.struct.length-=e:r=eS(r,e)),s.struct.mergeWith(r)||(eI(o,s.struct,s.offset),s={struct:r,offset:0},t.next())}}else s={struct:t.curr,offset:0},t.next();for(let r=t.curr;null!==r&&r.id.client===e&&r.id.clock===s.struct.id.clock+s.struct.length&&r.constructor!==r4;r=t.next())eI(o,s.struct,s.offset),s={struct:r,offset:0}}return null!==s&&(eI(o,s.struct,s.offset),s=null),eO(o),U(l,O(n.map(t=>N(t)))),l.toUint8Array()},eD=(t,e,r=W,n=K)=>{let i=tl(e),l=new n,o=new e_(l),h=new r(c.$C(t)),a=new eu(h,!1);for(;a.curr;){let t=a.curr,e=t.id.client,r=i.get(e)||0;if(a.curr.constructor===r4){a.next();continue}if(t.id.clock+t.length>r)for(eI(o,t,s.T9(r-t.id.clock,0)),a.next();a.curr&&a.curr.id.client===e;)eI(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===e&&a.curr.id.clock+a.curr.length<=r;)a.next()}return eO(o),U(l,N(h)),l.toUint8Array()},eC=(t,e)=>eD(t,e,F,J),eE=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:o.Fo(t.encoder.restEncoder)}),t.encoder.restEncoder=o.xv(),t.written=0)},eI=(t,e,r)=>{t.written>0&&t.currClient!==e.id.client&&eE(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),o.zd(t.encoder.restEncoder,e.id.clock+r)),e.write(t.encoder,r),t.written++},eO=t=>{eE(t);let e=t.encoder.restEncoder;o.zd(e,t.clientStructs.length);for(let r=0;r{let i=new r(c.$C(t)),s=new eu(i,!1),l=new n,o=new e_(l);for(let t=s.curr;null!==t;t=s.next())eI(o,e(t),0);return eO(o),U(l,N(i)),l.toUint8Array()},eM=({formatting:t=!0,subdocs:e=!0,yxml:r=!0}={})=>{let n=0,i=l.vt(),s=l.vt(),o=l.vt(),c=l.vt();return c.set(null,null),h=>{switch(h.constructor){case rU:case r4:return h;case r8:{let a=h.content;switch(a.constructor){case rL:break;case rY:if(r){let t=a.type;t instanceof rI&&(t.nodeName=l._4(s,t.nodeName,()=>"node-"+n)),t instanceof rx&&(t.hookName=l._4(s,t.hookName,()=>"hook-"+n))}break;case rP:a.arr=a.arr.map(()=>n);break;case rN:a.content=new Uint8Array([n]);break;case rR:e&&(a.opts={},a.doc.guid=n+"");break;case rj:a.embed={};break;case rV:t&&(a.key=l._4(o,a.key,()=>n+""),a.value=l._4(c,a.value,()=>({i:n})));break;case rF:a.arr=a.arr.map(()=>n);break;case rW:a.str=b.ux(n%10+"",a.str.length);break;default:u.Mq()}return h.parentSub&&(h.parentSub=l._4(i,h.parentSub,()=>n+"")),n++,h}default:u.Mq()}}},eT=(t,e)=>ex(t,eM(e),F,J),eU=(t,e)=>ex(t,eM(e),W,K),eN=t=>ex(t,f.id,F,K),eL=t=>ex(t,f.id,W,J),ez="You must not compute changes after the event-handler fired.";class eR{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=ej(this.currentTarget,this.target))}deletes(t){return E(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw u.vt(ez);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach(r=>{if(null!==r){let n,s;let l=e._map.get(r);if(this.adds(l)){let t=l.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(l)){if(!(null!==t&&this.deletes(t)))return;n="delete",s=i.HV(t.content.getContent())}else null!==t&&this.deletes(t)?(n="update",s=i.HV(t.content.getContent())):(n="add",s=void 0)}else{if(!this.deletes(l))return;n="delete",s=i.HV(l.content.getContent())}t.set(r,{action:n,oldValue:s})}}),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(null===t){if(0===this.transaction.doc._transactionCleanups.length)throw u.vt(ez);let e=this.target,r=p.vt(),n=p.vt(),i=[];if(t={added:r,deleted:n,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let t=null,s=()=>{t&&i.push(t)};for(let i=e._start;null!==i;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((null===t||void 0===t.delete)&&(s(),t={delete:0}),t.delete+=i.length,n.add(i)):this.adds(i)?((null===t||void 0===t.insert)&&(s(),t={insert:[]}),t.insert=t.insert.concat(i.content.getContent()),r.add(i)):((null===t||void 0===t.retain)&&(s(),t={retain:0}),t.retain+=i.length);null!==t&&void 0===t.retain&&s()}this._changes=t}return t}}let ej=(t,e)=>{let r=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)r.unshift(e._item.parentSub);else{let t=0,n=e._item.parent._start;for(;n!==e._item&&null!==n;)!n.deleted&&n.countable&&(t+=n.length),n=n.right;r.unshift(t)}e=e._item.parent}return r},eV=0;class eF{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=eV++}}let eP=t=>{t.timestamp=eV++},eW=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=eV++},e$=(t,e,r)=>{if(t.length>=80){let n=t.reduce((t,e)=>t.timestamp{if(null===t._start||0===e||null===t._searchMarker)return null;let r=0===t._searchMarker.length?null:t._searchMarker.reduce((t,r)=>s.tn(e-t.index)e;)!(n=n.left).deleted&&n.countable&&(i-=n.length);for(;null!==n.left&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)!(n=n.left).deleted&&n.countable&&(i-=n.length);return null!==r&&s.tn(r.index-i){for(let n=t.length-1;n>=0;n--){let i=t[n];if(r>0){let e=i.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)(e=e.left)&&!e.deleted&&e.countable&&(i.index-=e.length);if(null===e||!0===e.marker){t.splice(n,1);continue}i.p=e,e.marker=!0}(e0&&e===i.index)&&(i.index=s.T9(e,i.index+r))}},eK=t=>{let e=t._start,r=[];for(;e;)r.push(e),e=e.right;return r},eB=(t,e,r)=>{let n=t,i=e.changedParentTypes;for(;l._4(i,t,()=>[]).push(r),null!==t._item;)t=t._item.parent;tp(n._eH,r,e)};class eq{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=tu(),this._dEH=tu(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw u.bD()}clone(){throw u.bD()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){tg(this._eH,t)}observeDeep(t){tg(this._dEH,t)}unobserve(t){tf(this._eH,t)}unobserveDeep(t){tf(this._dEH,t)}toJSON(){}}let eQ=(t,e,r)=>{e<0&&(e=t._length+e),r<0&&(r=t._length+r);let n=r-e,i=[],s=t._start;for(;null!==s&&n>0;){if(s.countable&&!s.deleted){let t=s.content.getContent();if(t.length<=e)e-=t.length;else{for(let r=e;r0;r++)i.push(t[r]),n--;e=0}}s=s.right}return i},eG=t=>{let e=[],r=t._start;for(;null!==r;){if(r.countable&&!r.deleted){let t=r.content.getContent();for(let r=0;r{let r=[],n=t._start;for(;null!==n;){if(n.countable&&tB(n,e)){let t=n.content.getContent();for(let e=0;e{let r=0,n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){let i=n.content.getContent();for(let n=0;n{let r=[];return eX(t,(n,i)=>{r.push(e(n,i,t))}),r},e0=t=>{let e=t._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(null===r){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};r=e.content.getContent(),n=0,e=e.right}let t=r[n++];return r.length<=n&&(r=null),{done:!1,value:t}}}},e1=(t,e)=>{let r=eJ(t,e),n=t._start;for(null!==r&&(n=r.p,e-=r.index);null!==n;n=n.right)if(!n.deleted&&n.countable){if(e{let i=r,s=t.doc,l=s.clientID,o=s.store,c=null===r?e._start:r.right,h=[],a=()=>{h.length>0&&((i=new r8(ty(l,t0(o,l)),i,i&&i.lastId,c,c&&c.id,e,null,new rP(h))).integrate(t,0),h=[])};n.forEach(r=>{if(null===r)h.push(r);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(r);break;default:switch(a(),r.constructor){case Uint8Array:case ArrayBuffer:(i=new r8(ty(l,t0(o,l)),i,i&&i.lastId,c,c&&c.id,e,null,new rN(new Uint8Array(r)))).integrate(t,0);break;case j:(i=new r8(ty(l,t0(o,l)),i,i&&i.lastId,c,c&&c.id,e,null,new rR(r))).integrate(t,0);break;default:if(r instanceof eq)(i=new r8(ty(l,t0(o,l)),i,i&&i.lastId,c,c&&c.id,e,null,new rY(r))).integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},e8=()=>u.vt("Length exceeded!"),e3=(t,e,r,n)=>{if(r>e._length)throw e8();if(0===r)return e._searchMarker&&eH(e._searchMarker,r,n.length),e2(t,e,null,n);let i=r,s=eJ(e,r),l=e._start;for(null!==s&&(l=s.p,0==(r-=s.index)&&(r+=(l=l.prev)&&l.countable&&!l.deleted?l.length:0));null!==l;l=l.right)if(!l.deleted&&l.countable){if(r<=l.length){r{let n=(e._searchMarker||[]).reduce((t,e)=>e.index>t.index?e:t,{index:0,p:e._start}).p;if(n)for(;n.right;)n=n.right;return e2(t,e,n,r)},e4=(t,e,r,n)=>{if(0===n)return;let i=r,s=n,l=eJ(e,r),o=e._start;for(null!==l&&(o=l.p,r-=l.index);null!==o&&r>0;o=o.right)!o.deleted&&o.countable&&(r0&&null!==o;)o.deleted||(n0)throw e8();e._searchMarker&&eH(e._searchMarker,i,-s+n)},e7=(t,e,r)=>{let n=e._map.get(r);void 0!==n&&n.delete(t)},e5=(t,e,r,n)=>{let i;let s=e._map.get(r)||null,l=t.doc,o=l.clientID;if(null==n)i=new rP([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:i=new rP([n]);break;case Uint8Array:i=new rN(n);break;case j:i=new rR(n);break;default:if(n instanceof eq)i=new rY(n);else throw Error("Unexpected content type")}new r8(ty(o,t0(l.store,o)),s,s&&s.lastId,null,null,e,r,i).integrate(t,0)},e9=(t,e)=>{let r=t._map.get(e);return void 0===r||r.deleted?void 0:r.content.getContent()[r.length-1]},rt=t=>{let e={};return t._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},re=(t,e)=>{let r=t._map.get(e);return void 0!==r&&!r.deleted},rr=(t,e,r)=>{let n=t._map.get(e)||null;for(;null!==n&&(!r.sv.has(n.id.client)||n.id.clock>=(r.sv.get(n.id.client)||0));)n=n.left;return null!==n&&tB(n,r)?n.content.getContent()[n.length-1]:void 0},rn=(t,e)=>{let r={};return t._map.forEach((t,n)=>{let i=t;for(;null!==i&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;null!==i&&tB(i,e)&&(r[n]=i.content.getContent()[i.length-1])}),r},ri=t=>m.$5(t.entries(),t=>!t[1].deleted);class rs extends eR{}class rl extends eq{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new rl;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new rl}clone(){let t=new rl;return t.insert(0,this.toArray().map(t=>t instanceof eq?t.clone():t)),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}_callObserver(t,e){super._callObserver(t,e),eB(this,t,new rs(this,t))}insert(t,e){null!==this.doc?eo(this.doc,r=>{e3(r,this,t,e)}):this._prelimContent.splice(t,0,...e)}push(t){null!==this.doc?eo(this.doc,e=>{e6(e,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?eo(this.doc,r=>{e4(r,this,t,e)}):this._prelimContent.splice(t,e)}get(t){return e1(this,t)}toArray(){return eG(this)}slice(t=0,e=this.length){return eQ(this,t,e)}toJSON(){return this.map(t=>t instanceof eq?t.toJSON():t)}map(t){return eZ(this,t)}forEach(t){eX(this,t)}[Symbol.iterator](){return e0(this)}_write(t){t.writeTypeRef(rJ)}}class ro extends eR{constructor(t,e,r){super(t,e),this.keysChanged=r}}class rc extends eq{constructor(t){super(),this._prelimContent=null,void 0===t?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((t,e)=>{this.set(e,t)}),this._prelimContent=null}_copy(){return new rc}clone(){let t=new rc;return this.forEach((e,r)=>{t.set(r,e instanceof eq?e.clone():e)}),t}_callObserver(t,e){eB(this,t,new ro(this,t,e))}toJSON(){let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let n=e.content.getContent()[e.length-1];t[r]=n instanceof eq?n.toJSON():n}}),t}get size(){return[...ri(this._map)].length}keys(){return m.n(ri(this._map),t=>t[0])}values(){return m.n(ri(this._map),t=>t[1].content.getContent()[t[1].length-1])}entries(){return m.n(ri(this._map),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this._map.forEach((e,r)=>{e.deleted||t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?eo(this.doc,e=>{e7(e,this,t)}):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?eo(this.doc,r=>{e5(r,this,t,e)}):this._prelimContent.set(t,e),e}get(t){return e9(this,t)}has(t){return re(this,t)}clear(){null!==this.doc?eo(this.doc,t=>{this.forEach(function(e,r,n){e7(t,n,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(rH)}}let rh=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&k.SQ(t,e);class ra{constructor(t,e,r,n){this.left=t,this.right=e,this.index=r,this.currentAttributes=n}forward(){(null===this.right&&u.Mq(),this.right.content.constructor===rV)?this.right.deleted||rf(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}let rd=(t,e,r)=>{for(;null!==e.right&&r>0;)e.right.content.constructor===rV?e.right.deleted||rf(e.currentAttributes,e.right.content):e.right.deleted||(r{let i=new Map,s=n?eJ(e,r):null;return s?rd(t,new ra(s.p.left,s.p,s.index,i),r-s.index):rd(t,new ra(null,e._start,0,i),r)},rg=(t,e,r,n)=>{for(;null!==r.right&&(!0===r.right.deleted||r.right.content.constructor===rV&&rh(n.get(r.right.content.key),r.right.content.value));)r.right.deleted||n.delete(r.right.content.key),r.forward();let i=t.doc,s=i.clientID;n.forEach((n,l)=>{let o=r.left,c=r.right,h=new r8(ty(s,t0(i.store,s)),o,o&&o.lastId,c,c&&c.id,e,null,new rV(l,n));h.integrate(t,0),r.right=h,r.forward()})},rf=(t,e)=>{let{key:r,value:n}=e;null===n?t.delete(r):t.set(r,n)},rp=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===rV&&rh(e[t.right.content.key]??null,t.right.content.value));)t.forward()},rw=(t,e,r,n)=>{let i=t.doc,s=i.clientID,l=new Map;for(let o in n){let c=n[o],h=r.currentAttributes.get(o)??null;if(!rh(h,c)){l.set(o,h);let{left:n,right:a}=r;r.right=new r8(ty(s,t0(i.store,s)),n,n&&n.lastId,a,a&&a.id,e,null,new rV(o,c)),r.right.integrate(t,0),r.forward()}}return l},r_=(t,e,r,n,i)=>{r.currentAttributes.forEach((t,e)=>{void 0===i[e]&&(i[e]=null)});let s=t.doc,l=s.clientID;rp(r,i);let o=rw(t,e,r,i),c=n.constructor===String?new rW(n):n instanceof eq?new rY(n):new rj(n),{left:h,right:a,index:d}=r;e._searchMarker&&eH(e._searchMarker,r.index,c.getLength()),(a=new r8(ty(l,t0(s.store,l)),h,h&&h.lastId,a,a&&a.id,e,null,c)).integrate(t,0),r.right=a,r.index=d,r.forward(),rg(t,e,r,o)},ry=(t,e,r,n,i)=>{let s=t.doc,l=s.clientID;rp(r,i);let o=rw(t,e,r,i);for(;null!==r.right&&(n>0||o.size>0&&(r.right.deleted||r.right.content.constructor===rV));){if(!r.right.deleted){if(r.right.content.constructor===rV){let{key:e,value:s}=r.right.content,l=i[e];if(void 0!==l){if(rh(l,s))o.delete(e);else{if(0===n)break;o.set(e,s)}r.right.delete(t)}else r.currentAttributes.set(e,s)}else n0){let i="";for(;n>0;n--)i+="\n";r.right=new r8(ty(l,t0(s.store,l)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new rW(i)),r.right.integrate(t,0),r.forward()}rg(t,e,r,o)},rb=(t,e,r,n,i)=>{let s=e,o=l.vt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===rV){let t=s.content;o.set(t.key,t)}s=s.right}let c=0,h=!1;for(;e!==s;){if(r===e&&(h=!0),!e.deleted){let r=e.content;if(r.constructor===rV){let{key:s,value:l}=r,a=n.get(s)??null;o.get(s)===r&&a!==l||(e.delete(t),c++,h||(i.get(s)??null)!==l||a===l||(null===a?i.delete(s):i.set(s,a))),h||e.deleted||rf(i,r)}}e=e.right}return c},rm=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let r=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===rV){let n=e.content.key;r.has(n)?e.delete(t):r.add(n)}e=e.left}},rk=t=>{let e=0;return eo(t.doc,r=>{let n=t._start,i=t._start,s=l.vt(),o=l.C(s);for(;i;)!1===i.deleted&&(i.content.constructor===rV?rf(o,i.content):(e+=rb(r,n,i,s,o),s=l.C(o),n=i)),i=i.right}),e},rv=t=>{let e=new Set,r=t.doc;for(let[n,i]of t.afterState.entries()){let s=t.beforeState.get(n)||0;i!==s&&t5(t,r.store.clients.get(n),s,i,t=>{t.deleted||t.content.constructor!==rV||t.constructor===rU||e.add(t.parent)})}eo(r,r=>{for(let n of(D(t,t.deleteSet,t=>{if(t instanceof rU||!t.parent._hasFormatting||e.has(t.parent))return;let n=t.parent;t.content.constructor===rV?e.add(n):rm(r,t)}),e))rk(n)})},rS=(t,e,r)=>{let n=r,i=l.C(e.currentAttributes),s=e.right;for(;r>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case rY:case rj:case rW:r{null===t?this.childListChanged=!0:this.keysChanged.add(t)})}get changes(){if(null===this._changes){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){let t=this.target.doc,e=[];eo(t,t=>{let r=new Map,n=new Map,i=this.target._start,s=null,l={},o="",c=0,h=0,a=()=>{if(null!==s){let t=null;switch(s){case"delete":h>0&&(t={delete:h}),h=0;break;case"insert":("object"==typeof o||o.length>0)&&(t={insert:o},r.size>0&&(t.attributes={},r.forEach((e,r)=>{null!==e&&(t.attributes[r]=e)}))),o="";break;case"retain":c>0&&(t={retain:c},k.Im(l)||(t.attributes=k.kp({},l))),c=0}t&&e.push(t),s=null}};for(;null!==i;){switch(i.content.constructor){case rY:case rj:this.adds(i)?this.deletes(i)||(a(),s="insert",o=i.content.getContent()[0],a()):this.deletes(i)?("delete"!==s&&(a(),s="delete"),h+=1):i.deleted||("retain"!==s&&(a(),s="retain"),c+=1);break;case rW:this.adds(i)?this.deletes(i)||("insert"!==s&&(a(),s="insert"),o+=i.content.str):this.deletes(i)?("delete"!==s&&(a(),s="delete"),h+=i.length):i.deleted||("retain"!==s&&(a(),s="retain"),c+=i.length);break;case rV:{let{key:e,value:o}=i.content;if(this.adds(i))this.deletes(i)||(rh(r.get(e)??null,o)?null!==o&&i.delete(t):("retain"===s&&a(),rh(o,n.get(e)??null)?delete l[e]:l[e]=o));else if(this.deletes(i)){n.set(e,o);let t=r.get(e)??null;rh(t,o)||("retain"===s&&a(),l[e]=t)}else if(!i.deleted){n.set(e,o);let r=l[e];void 0!==r&&(rh(r,o)?null!==r&&i.delete(t):("retain"===s&&a(),null===o?delete l[e]:l[e]=o))}i.deleted||("insert"===s&&a(),rf(r,i.content))}}i=i.right}for(a();e.length>0;){let t=e[e.length-1];if(void 0!==t.retain&&void 0===t.attributes)e.pop();else break}}),this._delta=e}return this._delta}}class rD extends eq{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach(t=>t())}catch(t){console.error(t)}this._pending=null}_copy(){return new rD}clone(){let t=new rD;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new rA(this,t,e);eB(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===rW&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?eo(this.doc,r=>{let n=new ra(null,this._start,0,new Map);for(let i=0;i0)&&r_(r,this,n,l,s.attributes||{})}else void 0!==s.retain?ry(r,this,n,s.retain,s.attributes||{}):void 0!==s.delete&&rS(r,n,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){let n=[],i=new Map,s=this.doc,l="",o=this._start;function c(){if(l.length>0){let t={},e=!1;i.forEach((r,n)=>{e=!0,t[n]=r});let r={insert:l};e&&(r.attributes=t),n.push(r),l=""}}let h=()=>{for(;null!==o;){if(tB(o,t)||void 0!==e&&tB(o,e))switch(o.content.constructor){case rW:{let n=i.get("ychange");void 0===t||tB(o,t)?void 0===e||tB(o,e)?void 0!==n&&(c(),i.delete("ychange")):(void 0===n||n.user!==o.id.client||"added"!==n.type)&&(c(),i.set("ychange",r?r("added",o.id):{type:"added"})):(void 0===n||n.user!==o.id.client||"removed"!==n.type)&&(c(),i.set("ychange",r?r("removed",o.id):{type:"removed"})),l+=o.content.str;break}case rY:case rj:{c();let t={insert:o.content.getContent()[0]};if(i.size>0){let e={};t.attributes=e,i.forEach((t,r)=>{e[r]=t})}n.push(t);break}case rV:tB(o,t)&&(c(),rf(i,o.content))}o=o.right}c()};return t||e?eo(s,r=>{t&&tq(r,t),e&&tq(r,e),h()},"cleanup"):h(),n}insert(t,e,r){if(e.length<=0)return;let n=this.doc;null!==n?eo(n,n=>{let i=ru(n,this,t,!r);r||(r={},i.currentAttributes.forEach((t,e)=>{r[e]=t})),r_(n,this,i,e,r)}):this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let n=this.doc;null!==n?eo(n,n=>{let i=ru(n,this,t,!r);r_(n,this,i,e,r||{})}):this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(0===e)return;let r=this.doc;null!==r?eo(r,r=>{rS(r,ru(r,this,t,!0),e)}):this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(0===e)return;let n=this.doc;null!==n?eo(n,n=>{let i=ru(n,this,t,!1);null!==i.right&&ry(n,this,i,e,r)}):this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){null!==this.doc?eo(this.doc,e=>{e7(e,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){null!==this.doc?eo(this.doc,r=>{e5(r,this,t,e)}):this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return e9(this,t)}getAttributes(){return rt(this)}_write(t){t.writeTypeRef(rK)}}class rC{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,t.deleted||e.constructor!==rI&&e.constructor!==rE||null===e._start)for(;null!==t;){if(null!==t.right){t=t.right;break}t=t.parent===this._root?null:t.parent._item}else t=e._start;while(null!==t&&(t.deleted||!this._filter(t.content.type)))return(this._firstCall=!1,null===t)?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class rE extends eq{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new rE}clone(){let t=new rE;return t.insert(0,this.toArray().map(t=>t instanceof eq?t.clone():t)),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new rC(this,t)}querySelector(t){t=t.toUpperCase();let e=new rC(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),i.HT(new rC(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){eB(this,t,new rO(this,e,t))}toString(){return eZ(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let n=t.createDocumentFragment();return void 0!==r&&r._createAssociation(n,this),eX(this,i=>{n.insertBefore(i.toDOM(t,e,r),null)}),n}insert(t,e){null!==this.doc?eo(this.doc,r=>{e3(r,this,t,e)}):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)eo(this.doc,r=>{e2(r,this,t&&t instanceof eq?t._item:t,e)});else{let r=this._prelimContent,n=null===t?0:r.findIndex(e=>e===t)+1;if(0===n&&null!==t)throw u.vt("Reference item not found");r.splice(n,0,...e)}}delete(t,e=1){null!==this.doc?eo(this.doc,r=>{e4(r,this,t,e)}):this._prelimContent.splice(t,e)}toArray(){return eG(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return e1(this,t)}slice(t=0,e=this.length){return eQ(this,t,e)}forEach(t){eX(this,t)}_write(t){t.writeTypeRef(rq)}}class rI extends rE{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,e){super._integrate(t,e),this._prelimAttrs.forEach((t,e)=>{this.setAttribute(e,t)}),this._prelimAttrs=null}_copy(){return new rI(this.nodeName)}clone(){let t=new rI(this.nodeName),e=this.getAttributes();return k.jJ(e,(e,r)=>{"string"==typeof e&&t.setAttribute(r,e)}),t.insert(0,this.toArray().map(t=>t instanceof eq?t.clone():t)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let e in t)r.push(e);r.sort();let n=r.length;for(let i=0;i0?" "+e.join(" "):"";return`<${i}${s}>${super.toString()}`}removeAttribute(t){null!==this.doc?eo(this.doc,e=>{e7(e,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?eo(this.doc,r=>{e5(r,this,t,e)}):this._prelimAttrs.set(t,e)}getAttribute(t){return e9(this,t)}hasAttribute(t){return re(this,t)}getAttributes(t){return t?rn(this,t):rt(this)}toDOM(t=document,e={},r){let n=t.createElement(this.nodeName),i=this.getAttributes();for(let t in i){let e=i[t];"string"==typeof e&&n.setAttribute(t,e)}return eX(this,i=>{n.appendChild(i.toDOM(t,e,r))}),void 0!==r&&r._createAssociation(n,this),n}_write(t){t.writeTypeRef(rB),t.writeKey(this.nodeName)}}class rO extends eR{constructor(t,e,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)})}}class rx extends rc{constructor(t){super(),this.hookName=t}_copy(){return new rx(this.hookName)}clone(){let t=new rx(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let n;let i=e[this.hookName];return(n=void 0!==i?i.createDom(this):document.createElement(this.hookName)).setAttribute("data-yjs-hook",this.hookName),void 0!==r&&r._createAssociation(n,this),n}_write(t){t.writeTypeRef(rQ),t.writeKey(this.hookName)}}class rM extends rD{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 rM}clone(){let t=new rM;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let n=t.createTextNode(this.toString());return void 0!==r&&r._createAssociation(n,this),n}toString(){return this.toDelta().map(t=>{let e=[];for(let r in t.attributes){let n=[];for(let e in t.attributes[r])n.push({key:e,value:t.attributes[r][e]});n.sort((t,e)=>t.keyt.nodeName=0;t--)r+=``;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(rG)}}class rT{constructor(t,e){this.id=t,this.length=e}get deleted(){throw u.bD()}mergeWith(t){return!1}write(t,e,r){throw u.bD()}integrate(t,e){throw u.bD()}}class rU extends rT{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),t1(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}}class rN{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new rN(this.content)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}class rL{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new rL(this.len)}splice(t){let e=new rL(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){x(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}let rz=(t,e)=>new j({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class rR{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 e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new rR(rz(this.doc.guid,this.opts))}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,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,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class rj{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new rj(this.embed)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}class rV{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new rV(this.key,this.value)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}class rF{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new rF(this.arr)}splice(t){let e=new rF(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let n=e;n=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}}let r$=[t=>new rl,t=>new rc,t=>new rD,t=>new rI(t.readKey()),t=>new rE,t=>new rx(t.readKey()),t=>new rM],rJ=0,rH=1,rK=2,rB=3,rq=4,rQ=5,rG=6;class rY{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new rY(this.type._copy())}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach(e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach(e=>{for(;null!==e;)e.gc(t,!0),e=e.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}let rX=(t,e)=>{let r,n=e,i=0;do i>0&&(n=ty(n.client,n.clock+i)),r=t8(t,n),i=n.clock-r.id.clock,n=r.redone;while(null!==n&&r instanceof r8)return{item:r,diff:i}},rZ=(t,e)=>{for(;null!==t&&t.keep!==e;)t.keep=e,t=t.parent._item},r0=(t,e,r)=>{let{client:n,clock:i}=e.id,s=new r8(ty(n,i+r),e,ty(n,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),null!==e.redone&&(s.redone=ty(e.redone.client,e.redone.clock+r)),e.right=s,null!==s.right&&(s.right.left=s),t._mergeStructs.push(s),null!==s.parentSub&&null===s.right&&s.parent._map.set(s.parentSub,s),e.length=r,s},r1=(t,e)=>i.zN(t,t=>E(t.deletions,e)),r2=(t,e,r,n,i,s)=>{let l;let o=t.doc,c=o.store,h=o.clientID,a=e.redone;if(null!==a)return t6(t,a);let d=e.parent._item,u=null;if(null!==d&&!0===d.deleted){if(null===d.redone&&(!r.has(d)||null===r2(t,d,r,n,i,s)))return null;for(;null!==d.redone;)d=t6(t,d.redone)}let g=null===d?e.parent:d.content.type;if(null===e.parentSub){for(u=e.left,l=e;null!==u;){let e=u;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:t6(t,e.redone);if(null!==e&&e.parent._item===d){u=e;break}u=u.left}for(;null!==l;){let e=l;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:t6(t,e.redone);if(null!==e&&e.parent._item===d){l=e;break}l=l.right}}else if(l=null,e.right&&!i){for(u=e;null!==u&&null!==u.right&&(u.right.redone||E(n,u.right.id)||r1(s.undoStack,u.right.id)||r1(s.redoStack,u.right.id));)for(u=u.right;u.redone;)u=t6(t,u.redone);if(u&&null!==u.right)return null}else u=g._map.get(e.parentSub)||null;let f=t0(c,h),p=ty(h,f),w=new r8(p,u,u&&u.lastId,l,l&&l.id,g,e.parentSub,e.content.copy());return e.redone=p,rZ(w,!0),w.integrate(t,0),w};class r8 extends rT{constructor(t,e,r,n,i,s,l,o){super(t,o.getLength()),this.origin=r,this.left=e,this.right=n,this.rightOrigin=i,this.parent=s,this.parentSub=l,this.redone=null,this.content=o,this.info=this.content.isCountable()?g.KD:0}set marker(t){(this.info&g.wn)>0!==t&&(this.info^=g.wn)}get marker(){return(this.info&g.wn)>0}get keep(){return(this.info&g.Dk)>0}set keep(t){this.keep!==t&&(this.info^=g.Dk)}get countable(){return(this.info&g.KD)>0}get deleted(){return(this.info&g.D1)>0}set deleted(t){this.deleted!==t&&(this.info^=g.D1)}markDeleted(){this.info|=g.D1}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=t0(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=t0(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===tw&&this.id.client!==this.parent.client&&this.parent.clock>=t0(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=t4(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=t6(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===rU||this.right&&this.right.constructor===rU)this.parent=null;else if(this.parent){if(this.parent.constructor===tw){let t=t8(e,this.parent);t.constructor===rU?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===r8&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===r8&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=t4(t,t.doc.store,ty(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,r=this.left;if(null!==r)e=r.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;let n=new Set,i=new Set;for(;null!==e&&e!==this.right;){if(i.add(e),n.add(e),t_(this.origin,e.origin)){if(e.id.client{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),x(t.deleteSet,this.id.client,this.id.clock,this.length),ee(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw u.Mq();this.content.gc(t),e?t7(t,this,new rU(this.id,this.length)):this.content=new rL(this.length)}write(t,e){let r=e>0?ty(this.id.client,this.id.clock+e-1):this.origin,n=this.rightOrigin,i=this.parentSub,s=this.content.getRef()&g.WY|(null===r?0:g.wt)|(null===n?0:g.D7)|(null===i?0:g.KJ);if(t.writeInfo(s),null!==r&&t.writeLeftID(r),null!==n&&t.writeRightID(n),null===r&&null===n){let e=this.parent;if(void 0!==e._item){let r=e._item;if(null===r){let r=tk(e);t.writeParentInfo(!0),t.writeString(r)}else t.writeParentInfo(!1),t.writeLeftID(r.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===tw?(t.writeParentInfo(!1),t.writeLeftID(e)):u.Mq();null!==i&&t.writeString(i)}this.content.write(t,e)}}let r3=(t,e)=>r6[e&g.WY](t),r6=[()=>{u.Mq()},t=>new rL(t.readLen()),t=>{let e=t.readLen(),r=[];for(let n=0;nnew rN(t.readBuf()),t=>new rW(t.readString()),t=>new rj(t.readJSON()),t=>new rV(t.readKey(),t.readJSON()),t=>new rY(r$[t.readTypeRef()](t)),t=>{let e=t.readLen(),r=[];for(let n=0;nnew rR(rz(t.readString(),t.readAny())),()=>{u.Mq()}];class r4 extends rT{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){u.Mq()}write(t,e){t.writeInfo(10),o.zd(t.restEncoder,this.length-e)}getMissing(t,e){return null}}let r7="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},r5="__ $YJS$ __";!0===r7[r5]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),r7[r5]=!0}}]); //# sourceMappingURL=9978.7afe3c8f.js.map