playhtml 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +4 -2
- package/dist/playhtml.es.js +2926 -5809
- package/dist/playhtml.umd.js +6 -7
- package/package.json +2 -2
package/dist/playhtml.umd.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
(function(_,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(_=typeof globalThis<"u"?globalThis:_||self,y(_.playhtml={}))})(this,function(_){var ye,di;"use strict";var Ka=Object.defineProperty;var Ya=(_,y,x)=>y in _?Ka(_,y,{enumerable:!0,configurable:!0,writable:!0,value:x}):_[y]=x;var b=(_,y,x)=>(Ya(_,typeof y!="symbol"?y+"":y,x),x),fi=(_,y,x)=>{if(!y.has(_))throw TypeError("Cannot "+x)};var Ct=(_,y,x)=>(fi(_,y,"read from private field"),x?x.call(_):y.get(_)),gi=(_,y,x)=>{if(y.has(_))throw TypeError("Cannot add the same private member more than once");y instanceof WeakSet?y.add(_):y.set(_,x)},pi=(_,y,x,Me)=>(fi(_,y,"write to private field"),Me?Me.call(_,x):y.set(_,x),x);var y=1e6,x="y-pk-batch",Me=!1,ki=(s,e)=>{if(s.byteLength<=y){e(s);return}Me||(console.warn("[y-partykit]","The Y.js update size exceeds 1MB, which is the maximum size for an individual update. The update will be split into chunks. This is an experimental feature.",`Message size: ${(s.byteLength/1e3/1e3).toFixed(1)}MB`),Me=!0);const t=(Date.now()+Math.random()).toString(36).substring(10),n=Math.ceil(s.byteLength/y);e(Ds({id:t,type:"start",size:s.byteLength,count:n}));let i=0,r=0;for(let o=0;o<n;o++){const a=s.slice(y*o,y*(o+1));e(a),r+=1,i+=a.byteLength}e(Ds({id:t,type:"end",size:i,count:r}))};function Ds(s){return`${x}#${JSON.stringify(s)}`}const B=()=>new Map,vt=s=>{const e=B();return s.forEach((t,n)=>{e.set(n,t)}),e},Y=(s,e,t)=>{let n=s.get(e);return n===void 0&&s.set(e,n=t()),n},mi=(s,e)=>{const t=[];for(const[n,i]of s)t.push(e(i,n));return t},bi=(s,e)=>{for(const[t,n]of s)if(e(n,t))return!0;return!1},ae=()=>new Set,At=s=>s[s.length-1],wi=(s,e)=>{for(let t=0;t<e.length;t++)s.push(e[t])},te=Array.from,yi=Array.isArray;class Ze{constructor(){this._observers=B()}on(e,t){Y(this._observers,e,ae).add(t)}once(e,t){const n=(...i)=>{this.off(e,n),t(...i)};this.on(e,n)}off(e,t){const n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return te((this._observers.get(e)||B()).values()).forEach(n=>n(...t))}destroy(){this._observers=B()}}const X=Math.floor,Qe=Math.abs,xt=(s,e)=>s<e?s:e,ce=(s,e)=>s>e?s:e,Si=Math.pow,Es=s=>s!==0?s<0:1/s<0,_i=String.fromCharCode,Di=s=>s.toLowerCase(),Ei=/^\s*/g,Ci=s=>s.replace(Ei,""),vi=/([A-Z])/g,Cs=(s,e)=>Ci(s.replace(vi,t=>`${e}${Di(t)}`)),Ai=s=>{const e=unescape(encodeURIComponent(s)),t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.codePointAt(i);return n},ze=typeof TextEncoder<"u"?new TextEncoder:null,xi=ze?s=>ze.encode(s):Ai;let Te=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Te&&Te.decode(new Uint8Array).length===1&&(Te=null);const vs=s=>s===void 0?null:s;class Li{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let As=new Li,Lt=!0;try{typeof localStorage<"u"&&(As=localStorage,Lt=!1)}catch{}const xs=As,Ii=s=>Lt||addEventListener("storage",s),ji=s=>Lt||removeEventListener("storage",s),Mi=Object.assign,zi=Object.keys,Ti=(s,e)=>{for(const t in s)e(s[t],t)},Ui=(s,e)=>{const t=[];for(const n in s)t.push(e(s[n],n));return t},et=s=>zi(s).length,Oi=s=>{for(const e in s)return!1;return!0},Ri=(s,e)=>{for(const t in s)if(!e(s[t],t))return!1;return!0},Ls=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),Bi=(s,e)=>s===e||et(s)===et(e)&&Ri(s,(t,n)=>(t!==void 0||Ls(e,n))&&e[n]===t),It=(s,e,t=0)=>{try{for(;t<s.length;t++)s[t](...e)}finally{t<s.length&&It(s,e,t+1)}},Ni=s=>s,Fi=(s,e)=>s===e,Ue=(s,e)=>{if(s==null||e==null)return Fi(s,e);if(s.constructor!==e.constructor)return!1;if(s===e)return!0;switch(s.constructor){case ArrayBuffer:s=new Uint8Array(s),e=new Uint8Array(e);case Uint8Array:{if(s.byteLength!==e.byteLength)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;break}case Set:{if(s.size!==e.size)return!1;for(const t of s)if(!e.has(t))return!1;break}case Map:{if(s.size!==e.size)return!1;for(const t of s.keys())if(!e.has(t)||!Ue(s.get(t),e.get(t)))return!1;break}case Object:if(et(s)!==et(e))return!1;for(const t in s)if(!Ls(s,t)||!Ue(s[t],e[t]))return!1;break;case Array:if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Ue(s[t],e[t]))return!1;break;default:return!1}return!0},Hi=(s,e)=>e.includes(s),Se=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Is=typeof window<"u"&&typeof document<"u"&&!Se;let N;const Vi=()=>{if(N===void 0)if(Se){N=B();const s=process.argv;let e=null;for(let t=0;t<s.length;t++){const n=s[t];n[0]==="-"?(e!==null&&N.set(e,""),e=n):e!==null&&(N.set(e,n),e=null)}e!==null&&N.set(e,"")}else typeof location=="object"?(N=B(),(location.search||"?").slice(1).split("&").forEach(s=>{if(s.length!==0){const[e,t]=s.split("=");N.set(`--${Cs(e,"-")}`,t),N.set(`-${Cs(e,"-")}`,t)}})):N=B();return N},jt=s=>Vi().has(s),Mt=s=>vs(Se?process.env[s.toUpperCase()]:xs.getItem(s));(s=>jt("--"+s)||Mt(s)!==null)("production");const js=Se&&Hi(process.env.FORCE_COLOR,["true","1","2"]),$i=!jt("no-colors")&&(!Se||process.stdout.isTTY||js)&&(!Se||jt("color")||js||Mt("COLORTERM")!==null||(Mt("TERM")||"").includes("color")),Ms=1,zs=2,zt=4,Tt=8,Oe=32,J=64,T=128,tt=31,Ut=63,le=127,qi=2147483647,Ts=Number.MAX_SAFE_INTEGER,Ki=Number.isInteger||(s=>typeof s=="number"&&isFinite(s)&&X(s)===s),W=s=>new Error(s),F=()=>{throw W("Method unimplemented")},H=()=>{throw W("Unexpected case")},Us=W("Unexpected end of array"),Os=W("Integer out of Range");class st{constructor(e){this.arr=e,this.pos=0}}const se=s=>new st(s),Yi=s=>s.pos!==s.arr.length,Xi=(s,e)=>{const t=Nt(s.arr.buffer,s.pos+s.arr.byteOffset,e);return s.pos+=e,t},M=s=>Xi(s,k(s)),_e=s=>s.arr[s.pos++],k=s=>{let e=0,t=1;const n=s.arr.length;for(;s.pos<n;){const i=s.arr[s.pos++];if(e=e+(i&le)*t,t*=128,i<T)return e;if(e>Ts)throw Os}throw Us},Ot=s=>{let e=s.arr[s.pos++],t=e&Ut,n=64;const i=(e&J)>0?-1:1;if(!(e&T))return i*t;const r=s.arr.length;for(;s.pos<r;){if(e=s.arr[s.pos++],t=t+(e&le)*n,n*=128,e<T)return i*t;if(t>Ts)throw Os}throw Us},ne=Te?s=>Te.decode(M(s)):s=>{let e=k(s);if(e===0)return"";{let t=String.fromCodePoint(_e(s));if(--e<100)for(;e--;)t+=String.fromCodePoint(_e(s));else for(;e>0;){const n=e<1e4?e:1e4,i=s.arr.subarray(s.pos,s.pos+n);s.pos+=n,t+=String.fromCodePoint.apply(null,i),e-=n}return decodeURIComponent(escape(t))}},Rt=(s,e)=>{const t=new DataView(s.arr.buffer,s.arr.byteOffset+s.pos,e);return s.pos+=e,t},Ji=[s=>{},s=>null,Ot,s=>Rt(s,4).getFloat32(0,!1),s=>Rt(s,8).getFloat64(0,!1),s=>Rt(s,8).getBigInt64(0,!1),s=>!1,s=>!0,ne,s=>{const e=k(s),t={};for(let n=0;n<e;n++){const i=ne(s);t[i]=Re(s)}return t},s=>{const e=k(s),t=[];for(let n=0;n<e;n++)t.push(Re(s));return t},M],Re=s=>Ji[127-_e(s)](s);class Rs extends st{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Yi(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class nt extends st{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ot(this);const e=Es(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class Bt extends st{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Ot(this),t=e&1;this.diff=X(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Wi{constructor(e){this.decoder=new nt(e),this.str=ne(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Bs=s=>new Uint8Array(s),Nt=(s,e,t)=>new Uint8Array(s,e,t),Gi=s=>new Uint8Array(s),Pi=s=>{let e="";for(let t=0;t<s.byteLength;t++)e+=_i(s[t]);return btoa(e)},Zi=s=>Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("base64"),Qi=s=>{const e=atob(s),t=Bs(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},er=s=>{const e=Buffer.from(s,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},tr=Is?Pi:Zi,sr=Is?Qi:er,nr=s=>{const e=Bs(s.byteLength);return e.set(s),e};class Be{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const z=()=>new Be,Ft=s=>{let e=s.cpos;for(let t=0;t<s.bufs.length;t++)e+=s.bufs[t].length;return e},D=s=>{const e=new Uint8Array(Ft(s));let t=0;for(let n=0;n<s.bufs.length;n++){const i=s.bufs[n];e.set(i,t),t+=i.length}return e.set(Nt(s.cbuf.buffer,0,s.cpos),t),e},ir=(s,e)=>{const t=s.cbuf.length;t-s.cpos<e&&(s.bufs.push(Nt(s.cbuf.buffer,0,s.cpos)),s.cbuf=new Uint8Array(ce(t,e)*2),s.cpos=0)},L=(s,e)=>{const t=s.cbuf.length;s.cpos===t&&(s.bufs.push(s.cbuf),s.cbuf=new Uint8Array(t*2),s.cpos=0),s.cbuf[s.cpos++]=e},Ht=L,p=(s,e)=>{for(;e>le;)L(s,T|le&e),e=X(e/128);L(s,le&e)},Vt=(s,e)=>{const t=Es(e);for(t&&(e=-e),L(s,(e>Ut?T:0)|(t?J:0)|Ut&e),e=X(e/64);e>0;)L(s,(e>le?T:0)|le&e),e=X(e/128)},$t=new Uint8Array(3e4),rr=$t.length/3,or=(s,e)=>{if(e.length<rr){const t=ze.encodeInto(e,$t).written||0;p(s,t);for(let n=0;n<t;n++)L(s,$t[n])}else C(s,xi(e))},ar=(s,e)=>{const t=unescape(encodeURIComponent(e)),n=t.length;p(s,n);for(let i=0;i<n;i++)L(s,t.codePointAt(i))},he=ze&&ze.encodeInto?or:ar,it=(s,e)=>{const t=s.cbuf.length,n=s.cpos,i=xt(t-n,e.length),r=e.length-i;s.cbuf.set(e.subarray(0,i),n),s.cpos+=i,r>0&&(s.bufs.push(s.cbuf),s.cbuf=new Uint8Array(ce(t*2,r)),s.cbuf.set(e.subarray(i)),s.cpos=r)},C=(s,e)=>{p(s,e.byteLength),it(s,e)},qt=(s,e)=>{ir(s,e);const t=new DataView(s.cbuf.buffer,s.cpos,e);return s.cpos+=e,t},cr=(s,e)=>qt(s,4).setFloat32(0,e,!1),lr=(s,e)=>qt(s,8).setFloat64(0,e,!1),hr=(s,e)=>qt(s,8).setBigInt64(0,e,!1),Ns=new DataView(new ArrayBuffer(4)),ur=s=>(Ns.setFloat32(0,s),Ns.getFloat32(0)===s),Ne=(s,e)=>{switch(typeof e){case"string":L(s,119),he(s,e);break;case"number":Ki(e)&&Qe(e)<=qi?(L(s,125),Vt(s,e)):ur(e)?(L(s,124),cr(s,e)):(L(s,123),lr(s,e));break;case"bigint":L(s,122),hr(s,e);break;case"object":if(e===null)L(s,126);else if(yi(e)){L(s,117),p(s,e.length);for(let t=0;t<e.length;t++)Ne(s,e[t])}else if(e instanceof Uint8Array)L(s,116),C(s,e);else{L(s,118);const t=Object.keys(e);p(s,t.length);for(let n=0;n<t.length;n++){const i=t[n];he(s,i),Ne(s,e[i])}}break;case"boolean":L(s,e?120:121);break;default:L(s,127)}};class Fs extends Be{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&p(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Hs=s=>{s.count>0&&(Vt(s.encoder,s.count===1?s.s:-s.s),s.count>1&&p(s.encoder,s.count-2))};class rt{constructor(){this.encoder=new Be,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Hs(this),this.count=1,this.s=e)}toUint8Array(){return Hs(this),D(this.encoder)}}const Vs=s=>{if(s.count>0){const e=s.diff*2+(s.count===1?0:1);Vt(s.encoder,e),s.count>1&&p(s.encoder,s.count-2)}};class Kt{constructor(){this.encoder=new Be,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Vs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Vs(this),D(this.encoder)}}class dr{constructor(){this.sarr=[],this.s="",this.lensE=new rt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Be;return this.sarr.push(this.s),this.s="",he(e,this.sarr.join("")),it(e,this.lensE.toUint8Array()),D(e)}}const fr=crypto.getRandomValues.bind(crypto),$s=()=>fr(new Uint32Array(1))[0],gr=[1e7]+-1e3+-4e3+-8e3+-1e11,pr=()=>gr.replace(/[018]/g,s=>(s^$s()&15>>s/4).toString(16)),ue=Date.now,De=s=>new Promise(s);Promise.all.bind(Promise);class kr{constructor(e,t){this.left=e,this.right=t}}const G=(s,e)=>new kr(s,e);typeof DOMParser<"u"&&new DOMParser;const mr=s=>mi(s,(e,t)=>`${t}:${e};`).join(""),P=Symbol,qs=P(),Ks=P(),br=P(),wr=P(),yr=P(),Ys=P(),Sr=P(),Xs=P(),_r=P(),Dr=s=>{const e=[];let t=0;for(;t<s.length;t++){const n=s[t];n.constructor===String||n.constructor===Number||n.constructor===Object&&e.push(JSON.stringify(n))}return e},Er={[qs]:G("font-weight","bold"),[Ks]:G("font-weight","normal"),[br]:G("color","blue"),[yr]:G("color","green"),[wr]:G("color","grey"),[Ys]:G("color","red"),[Sr]:G("color","purple"),[Xs]:G("color","orange"),[_r]:G("color","black")},Cr=$i?s=>{const e=[],t=[],n=B();let i=[],r=0;for(;r<s.length;r++){const o=s[r],a=Er[o];if(a!==void 0)n.set(a.left,a.right);else if(o.constructor===String||o.constructor===Number){const c=mr(n);r>0||c.length>0?(e.push("%c"+o),t.push(c)):e.push(o)}else break}for(r>0&&(i=t,i.unshift(e.join("")));r<s.length;r++){const o=s[r];o instanceof Symbol||i.push(o)}return i}:Dr,vr=(...s)=>{console.log(...Cr(s)),Ar.forEach(e=>e.print(s))},Ar=ae(),Js=s=>({[Symbol.iterator](){return this},next:s}),xr=(s,e)=>Js(()=>{let t;do t=s.next();while(!t.done&&!e(t.value));return t}),Yt=(s,e)=>Js(()=>{const{done:t,value:n}=s.next();return{done:t,value:t?void 0:e(n)}});class Xt{constructor(e,t){this.clock=e,this.len=t}}class Fe{constructor(){this.clients=new Map}}const Ws=(s,e,t)=>e.clients.forEach((n,i)=>{const r=s.doc.store.clients.get(i);for(let o=0;o<n.length;o++){const a=n[o];pn(s,r,a.clock,a.len,t)}}),Lr=(s,e)=>{let t=0,n=s.length-1;for(;t<=n;){const i=X((t+n)/2),r=s[i],o=r.clock;if(o<=e){if(e<o+r.len)return i;t=i+1}else n=i-1}return null},Gs=(s,e)=>{const t=s.clients.get(e.client);return t!==void 0&&Lr(t,e.clock)!==null},Jt=s=>{s.clients.forEach(e=>{e.sort((i,r)=>i.clock-r.clock);let t,n;for(t=1,n=1;t<e.length;t++){const i=e[n-1],r=e[t];i.clock+i.len>=r.clock?i.len=ce(i.len,r.clock+r.len-i.clock):(n<t&&(e[n]=r),n++)}e.length=n})},Ir=s=>{const e=new Fe;for(let t=0;t<s.length;t++)s[t].clients.forEach((n,i)=>{if(!e.clients.has(i)){const r=n.slice();for(let o=t+1;o<s.length;o++)wi(r,s[o].clients.get(i)||[]);e.clients.set(i,r)}});return Jt(e),e},ot=(s,e,t,n)=>{Y(s.clients,e,()=>[]).push(new Xt(t,n))},jr=()=>new Fe,Mr=s=>{const e=jr();return s.clients.forEach((t,n)=>{const i=[];for(let r=0;r<t.length;r++){const o=t[r];if(o.deleted){const a=o.id.clock;let c=o.length;if(r+1<t.length)for(let l=t[r+1];r+1<t.length&&l.deleted;l=t[++r+1])c+=l.length;i.push(new Xt(a,c))}}i.length>0&&e.clients.set(n,i)}),e},Ee=(s,e)=>{p(s.restEncoder,e.clients.size),te(e.clients.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{s.resetDsCurVal(),p(s.restEncoder,t);const i=n.length;p(s.restEncoder,i);for(let r=0;r<i;r++){const o=n[r];s.writeDsClock(o.clock),s.writeDsLen(o.len)}})},Wt=s=>{const e=new Fe,t=k(s.restDecoder);for(let n=0;n<t;n++){s.resetDsCurVal();const i=k(s.restDecoder),r=k(s.restDecoder);if(r>0){const o=Y(e.clients,i,()=>[]);for(let a=0;a<r;a++)o.push(new Xt(s.readDsClock(),s.readDsLen()))}}return e},Ps=(s,e,t)=>{const n=new Fe,i=k(s.restDecoder);for(let r=0;r<i;r++){s.resetDsCurVal();const o=k(s.restDecoder),a=k(s.restDecoder),c=t.clients.get(o)||[],l=I(t,o);for(let h=0;h<a;h++){const u=s.readDsClock(),d=u+s.readDsLen();if(u<l){l<d&&ot(n,o,l,d-l);let f=V(c,u),g=c[f];for(!g.deleted&&g.id.clock<u&&(c.splice(f+1,0,St(e,g,u-g.id.clock)),f++);f<c.length&&(g=c[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&c.splice(f,0,St(e,g,d-g.id.clock)),g.delete(e))}else ot(n,o,u,d-u)}}if(n.clients.size>0){const r=new fe;return p(r.restEncoder,0),Ee(r,n),r.toUint8Array()}return null},Zs=$s;class de extends Ze{constructor({guid:e=pr(),collectionid:t=null,gc:n=!0,gcFilter:i=()=>!0,meta:r=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=n,this.gcFilter=i,this.clientID=Zs(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new dn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=De(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const c=()=>De(l=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),l())};this.on("sync",h)});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=l===void 0||l===!0,this.isLoaded||this.emit("load",[])}),this.whenSynced=c()}load(){const e=this._item;e!==null&&!this.shouldLoad&&S(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(te(this.subdocs).map(e=>e.guid))}transact(e,t=null){return S(this,e,t)}get(e,t=j){const n=Y(this.share,e,()=>{const r=new t;return r._integrate(this,null),r}),i=n.constructor;if(t!==j&&i!==t)if(i===j){const r=new t;r._map=n._map,n._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=r}),r._start=n._start;for(let o=r._start;o!==null;o=o.right)o.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,Ae)}getText(e=""){return this.get(e,Le)}getMap(e=""){return this.get(e,ge)}getXmlFragment(e=""){return this.get(e,pe)}toJSON(){const e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){te(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new de({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,S(e.parent.doc,n=>{const i=t.doc;e.deleted||n.subdocsAdded.add(i),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(e,t){super.on(e,t)}off(e,t){super.off(e,t)}}class Qs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class en extends Qs{readLeftID(){return w(k(this.restDecoder),k(this.restDecoder))}readRightID(){return w(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return _e(this.restDecoder)}readString(){return ne(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Re(this.restDecoder)}readBuf(){return nr(M(this.restDecoder))}readJSON(){return JSON.parse(ne(this.restDecoder))}readKey(){return ne(this.restDecoder)}}class zr{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){const e=k(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ce extends zr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Bt(M(e)),this.clientDecoder=new nt(M(e)),this.leftClockDecoder=new Bt(M(e)),this.rightClockDecoder=new Bt(M(e)),this.infoDecoder=new Rs(M(e),_e),this.stringDecoder=new Wi(M(e)),this.parentInfoDecoder=new Rs(M(e),_e),this.typeRefDecoder=new nt(M(e)),this.lenDecoder=new nt(M(e))}readLeftID(){return new ve(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ve(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 Re(this.restDecoder)}readBuf(){return M(this.restDecoder)}readJSON(){return Re(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class tn{constructor(){this.restEncoder=z()}toUint8Array(){return D(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class He extends tn{writeLeftID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeRightID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeClient(e){p(this.restEncoder,e)}writeInfo(e){Ht(this.restEncoder,e)}writeString(e){he(this.restEncoder,e)}writeParentInfo(e){p(this.restEncoder,e?1:0)}writeTypeRef(e){p(this.restEncoder,e)}writeLen(e){p(this.restEncoder,e)}writeAny(e){Ne(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,JSON.stringify(e))}writeKey(e){he(this.restEncoder,e)}}class sn{constructor(){this.restEncoder=z(),this.dsCurrVal=0}toUint8Array(){return D(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,t)}writeDsLen(e){e===0&&H(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class fe extends sn{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Kt,this.clientEncoder=new rt,this.leftClockEncoder=new Kt,this.rightClockEncoder=new Kt,this.infoEncoder=new Fs(Ht),this.stringEncoder=new dr,this.parentInfoEncoder=new Fs(Ht),this.typeRefEncoder=new rt,this.lenEncoder=new rt}toUint8Array(){const e=z();return p(e,0),C(e,this.keyClockEncoder.toUint8Array()),C(e,this.clientEncoder.toUint8Array()),C(e,this.leftClockEncoder.toUint8Array()),C(e,this.rightClockEncoder.toUint8Array()),C(e,D(this.infoEncoder)),C(e,this.stringEncoder.toUint8Array()),C(e,D(this.parentInfoEncoder)),C(e,this.typeRefEncoder.toUint8Array()),C(e,this.lenEncoder.toUint8Array()),it(e,D(this.restEncoder)),D(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ne(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){Ne(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Tr=(s,e,t,n)=>{n=ce(n,e[0].id.clock);const i=V(e,n);p(s.restEncoder,e.length-i),s.writeClient(t),p(s.restEncoder,n);const r=e[i];r.write(s,n-r.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(s,0)},Gt=(s,e,t)=>{const n=new Map;t.forEach((i,r)=>{I(e,r)>i&&n.set(r,i)}),ct(e).forEach((i,r)=>{t.has(r)||n.set(r,0)}),p(s.restEncoder,n.size),te(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{Tr(s,e.clients.get(i),i,r)})},Ur=(s,e)=>{const t=B(),n=k(s.restDecoder);for(let i=0;i<n;i++){const r=k(s.restDecoder),o=new Array(r),a=s.readClient();let c=k(s.restDecoder);t.set(a,{i:0,refs:o});for(let l=0;l<r;l++){const h=s.readInfo();switch(tt&h){case 0:{const u=s.readLen();o[l]=new O(w(a,c),u),c+=u;break}case 10:{const u=k(s.restDecoder);o[l]=new R(w(a,c),u),c+=u;break}default:{const u=(h&(J|T))===0,d=new A(w(a,c),null,(h&T)===T?s.readLeftID():null,null,(h&J)===J?s.readRightID():null,u?s.readParentInfo()?e.get(s.readString()):s.readLeftID():null,u&&(h&Oe)===Oe?s.readString():null,Fn(s,h));o[l]=d,c+=d.length}}}}return t},Or=(s,e,t)=>{const n=[];let i=te(t.keys()).sort((f,g)=>f-g);if(i.length===0)return null;const r=()=>{if(i.length===0)return null;let f=t.get(i[i.length-1]);for(;f.refs.length===f.i;)if(i.pop(),i.length>0)f=t.get(i[i.length-1]);else return null;return f};let o=r();if(o===null&&n.length===0)return null;const a=new dn,c=new Map,l=(f,g)=>{const m=c.get(f);(m==null||m>g)&&c.set(f,g)};let h=o.refs[o.i++];const u=new Map,d=()=>{for(const f of n){const g=f.id.client,m=t.get(g);m?(m.i--,a.clients.set(g,m.refs.slice(m.i)),t.delete(g),m.i=0,m.refs=[]):a.clients.set(g,[f]),i=i.filter(E=>E!==g)}n.length=0};for(;;){if(h.constructor!==R){const g=Y(u,h.id.client,()=>I(e,h.id.client))-h.id.clock;if(g<0)n.push(h),l(h.id.client,h.id.clock-1),d();else{const m=h.getMissing(s,e);if(m!==null){n.push(h);const E=t.get(m)||{refs:[],i:0};if(E.refs.length===E.i)l(m,I(e,m)),d();else{h=E.refs[E.i++];continue}}else(g===0||g<h.length)&&(h.integrate(s,g),u.set(h.id.client,h.id.clock+h.length))}}if(n.length>0)h=n.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=r(),o===null)break;h=o.refs[o.i++]}}if(a.clients.size>0){const f=new fe;return Gt(f,a,new Map),p(f.restEncoder,0),{missing:c,update:f.toUint8Array()}}return null},Rr=(s,e)=>Gt(s,e.doc.store,e.beforeState),Br=(s,e,t,n=new Ce(s))=>S(e,i=>{i.local=!1;let r=!1;const o=i.doc,a=o.store,c=Ur(n,o),l=Or(i,a,c),h=a.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<I(a,d)){r=!0;break}if(l){for(const[d,f]of l.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=ht([h.update,l.update])}}else a.pendingStructs=l;const u=Ps(n,i,a);if(a.pendingDs){const d=new Ce(se(a.pendingDs));k(d.restDecoder);const f=Ps(d,i,a);u&&f?a.pendingDs=ht([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(r){const d=a.pendingStructs.update;a.pendingStructs=null,nn(i.doc,d)}},t,!1),nn=(s,e,t,n=Ce)=>{const i=se(e);Br(i,s,t,new n(i))},rn=(s,e,t)=>nn(s,e,t,en),Nr=(s,e,t=new Map)=>{Gt(s,e.store,t),Ee(s,Mr(e.store))},Fr=(s,e=new Uint8Array([0]),t=new fe)=>{const n=on(e);Nr(t,s,n);const i=[t.toUint8Array()];if(s.store.pendingDs&&i.push(s.store.pendingDs),s.store.pendingStructs&&i.push(eo(s.store.pendingStructs.update,e)),i.length>1){if(t.constructor===He)return Zr(i.map((r,o)=>o===0?r:so(r)));if(t.constructor===fe)return ht(i)}return i[0]},Pt=(s,e)=>Fr(s,e,new He),Hr=s=>{const e=new Map,t=k(s.restDecoder);for(let n=0;n<t;n++){const i=k(s.restDecoder),r=k(s.restDecoder);e.set(i,r)}return e},on=s=>Hr(new Qs(se(s))),an=(s,e)=>(p(s.restEncoder,e.size),te(e.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{p(s.restEncoder,t),p(s.restEncoder,n)}),s),Vr=(s,e)=>an(s,ct(e.store)),$r=(s,e=new sn)=>(s instanceof Map?an(e,s):Vr(e,s),e.toUint8Array()),qr=s=>$r(s,new tn);class Kr{constructor(){this.l=[]}}const cn=()=>new Kr,ln=(s,e)=>s.l.push(e),hn=(s,e)=>{const t=s.l,n=t.length;s.l=t.filter(i=>e!==i),n===s.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},un=(s,e,t)=>It(s.l,[e,t]);class ve{constructor(e,t){this.client=e,this.clock=t}}const at=(s,e)=>s===e||s!==null&&e!==null&&s.client===e.client&&s.clock===e.clock,w=(s,e)=>new ve(s,e),Yr=s=>{for(const[e,t]of s.doc.share.entries())if(t===s)return e;throw H()},Ve=(s,e)=>e===void 0?!s.deleted:e.sv.has(s.id.client)&&(e.sv.get(s.id.client)||0)>s.id.clock&&!Gs(e.ds,s.id),Zt=(s,e)=>{const t=Y(s.meta,Zt,ae),n=s.doc.store;t.has(e)||(e.sv.forEach((i,r)=>{i<I(n,r)&&ie(s,w(r,i))}),Ws(s,e.ds,i=>{}),t.add(e))};class dn{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ct=s=>{const e=new Map;return s.clients.forEach((t,n)=>{const i=t[t.length-1];e.set(n,i.id.clock+i.length)}),e},I=(s,e)=>{const t=s.clients.get(e);if(t===void 0)return 0;const n=t[t.length-1];return n.id.clock+n.length},fn=(s,e)=>{let t=s.clients.get(e.id.client);if(t===void 0)t=[],s.clients.set(e.id.client,t);else{const n=t[t.length-1];if(n.id.clock+n.length!==e.id.clock)throw H()}t.push(e)},V=(s,e)=>{let t=0,n=s.length-1,i=s[n],r=i.id.clock;if(r===e)return n;let o=X(e/(r+i.length-1)*n);for(;t<=n;){if(i=s[o],r=i.id.clock,r<=e){if(e<r+i.length)return o;t=o+1}else n=o-1;o=X((t+n)/2)}throw H()},Qt=(s,e)=>{const t=s.clients.get(e.client);return t[V(t,e.clock)]},es=(s,e,t)=>{const n=V(e,t),i=e[n];return i.id.clock<t&&i instanceof A?(e.splice(n+1,0,St(s,i,t-i.id.clock)),n+1):n},ie=(s,e)=>{const t=s.doc.store.clients.get(e.client);return t[es(s,t,e.clock)]},gn=(s,e,t)=>{const n=e.clients.get(t.client),i=V(n,t.clock),r=n[i];return t.clock!==r.id.clock+r.length-1&&r.constructor!==O&&n.splice(i+1,0,St(s,r,t.clock-r.id.clock+1)),r},Xr=(s,e,t)=>{const n=s.clients.get(e.id.client);n[V(n,e.id.clock)]=t},pn=(s,e,t,n,i)=>{if(n===0)return;const r=t+n;let o=es(s,e,t),a;do a=e[o++],r<a.id.clock+a.length&&es(s,e,r),i(a);while(o<e.length&&e[o].id.clock<r)};class Jr{constructor(e,t,n){this.doc=e,this.deleteSet=new Fe,this.beforeState=ct(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const kn=(s,e)=>e.deleteSet.clients.size===0&&!bi(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:(Jt(e.deleteSet),Rr(s,e),Ee(s,e.deleteSet),!0),mn=(s,e,t)=>{const n=e._item;(n===null||n.id.clock<(s.beforeState.get(n.id.client)||0)&&!n.deleted)&&Y(s.changed,e,ae).add(t)},lt=(s,e)=>{let t=s[e],n=s[e-1],i=e;for(;i>0;t=n,n=s[--i-1]){if(n.deleted===t.deleted&&n.constructor===t.constructor&&n.mergeWith(t)){t instanceof A&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,n);continue}break}const r=e-i;return r&&s.splice(e+1-r,r),r},Wr=(s,e,t)=>{for(const[n,i]of s.clients.entries()){const r=e.clients.get(n);for(let o=i.length-1;o>=0;o--){const a=i[o],c=a.clock+a.len;for(let l=V(r,a.clock),h=r[l];l<r.length&&h.id.clock<c;h=r[++l]){const u=r[l];if(a.clock+a.len<=u.id.clock)break;u instanceof A&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Gr=(s,e)=>{s.clients.forEach((t,n)=>{const i=e.clients.get(n);for(let r=t.length-1;r>=0;r--){const o=t[r],a=xt(i.length-1,1+V(i,o.clock+o.len-1));for(let c=a,l=i[c];c>0&&l.id.clock>=o.clock;l=i[c])c-=1+lt(i,c)}})},bn=(s,e)=>{if(e<s.length){const t=s[e],n=t.doc,i=n.store,r=t.deleteSet,o=t._mergeStructs;try{Jt(r),t.afterState=ct(t.doc.store),n.emit("beforeObserverCalls",[t,n]);const a=[];t.changed.forEach((c,l)=>a.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(t,c)})),a.push(()=>{t.changedParentTypes.forEach((c,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(c=c.filter(h=>h.target._item===null||!h.target._item.deleted),c.forEach(h=>{h.currentTarget=l,h._path=null}),c.sort((h,u)=>h.path.length-u.path.length),un(l._dEH,c,t))})}),a.push(()=>n.emit("afterTransaction",[t,n])),It(a,[]),t._needFormattingCleanup&&ko(t)}finally{n.gc&&Wr(r,i,n.gcFilter),Gr(r,i),t.afterState.forEach((h,u)=>{const d=t.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ce(V(f,d),1);for(let m=f.length-1;m>=g;)m-=1+lt(f,m)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:d}=o[h].id,f=i.clients.get(u),g=V(f,d);g+1<f.length&<(f,g+1)>1||g>0&<(f,g)}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(vr(Xs,qs,"[yjs] ",Ks,Ys,"Changed the client-id because another client seems to be using it."),n.clientID=Zs()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){const h=new He;kn(h,t)&&n.emit("update",[h.toUint8Array(),t.origin,n,t])}if(n._observers.has("updateV2")){const h=new fe;kn(h,t)&&n.emit("updateV2",[h.toUint8Array(),t.origin,n,t])}const{subdocsAdded:a,subdocsLoaded:c,subdocsRemoved:l}=t;(a.size>0||l.size>0||c.size>0)&&(a.forEach(h=>{h.clientID=n.clientID,h.collectionid==null&&(h.collectionid=n.collectionid),n.subdocs.add(h)}),l.forEach(h=>n.subdocs.delete(h)),n.emit("subdocs",[{loaded:c,added:a,removed:l},n,t]),l.forEach(h=>h.destroy())),s.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,s])):bn(s,e+1)}}},S=(s,e,t=null,n=!0)=>{const i=s._transactionCleanups;let r=!1,o=null;s._transaction===null&&(r=!0,s._transaction=new Jr(s,t,n),i.push(s._transaction),i.length===1&&s.emit("beforeAllTransactions",[s]),s.emit("beforeTransaction",[s._transaction,s]));try{o=e(s._transaction)}finally{if(r){const a=s._transaction===i[0];s._transaction=null,a&&bn(i,0)}}return o};function*Pr(s){const e=k(s.restDecoder);for(let t=0;t<e;t++){const n=k(s.restDecoder),i=s.readClient();let r=k(s.restDecoder);for(let o=0;o<n;o++){const a=s.readInfo();if(a===10){const c=k(s.restDecoder);yield new R(w(i,r),c),r+=c}else if(tt&a){const c=(a&(J|T))===0,l=new A(w(i,r),null,(a&T)===T?s.readLeftID():null,null,(a&J)===J?s.readRightID():null,c?s.readParentInfo()?s.readString():s.readLeftID():null,c&&(a&Oe)===Oe?s.readString():null,Fn(s,a));yield l,r+=l.length}else{const c=s.readLen();yield new O(w(i,r),c),r+=c}}}}class ts{constructor(e,t){this.gen=Pr(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===R);return this.curr}}class ss{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Zr=s=>ht(s,en,He),Qr=(s,e)=>{if(s.constructor===O){const{client:t,clock:n}=s.id;return new O(w(t,n+e),s.length-e)}else if(s.constructor===R){const{client:t,clock:n}=s.id;return new R(w(t,n+e),s.length-e)}else{const t=s,{client:n,clock:i}=t.id;return new A(w(n,i+e),null,w(n,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},ht=(s,e=Ce,t=fe)=>{if(s.length===1)return s[0];const n=s.map(h=>new e(se(h)));let i=n.map(h=>new ts(h,!0)),r=null;const o=new t,a=new ss(o);for(;i=i.filter(d=>d.curr!==null),i.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){const g=d.curr.id.clock-f.curr.id.clock;return g===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===R?1:-1:g}else return f.curr.id.client-d.curr.id.client}),i.length!==0;){const h=i[0],u=h.curr.id.client;if(r!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=r.struct.id.clock+r.struct.length&&d.id.client>=r.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>r.struct.id.clock+r.struct.length)continue;if(u!==r.struct.id.client)re(a,r.struct,r.offset),r={struct:d,offset:0},h.next();else if(r.struct.id.clock+r.struct.length<d.id.clock)if(r.struct.constructor===R)r.struct.length=d.id.clock+d.length-r.struct.id.clock;else{re(a,r.struct,r.offset);const g=d.id.clock-r.struct.id.clock-r.struct.length;r={struct:new R(w(u,r.struct.id.clock+r.struct.length),g),offset:0}}else{const g=r.struct.id.clock+r.struct.length-d.id.clock;g>0&&(r.struct.constructor===R?r.struct.length-=g:d=Qr(d,g)),r.struct.mergeWith(d)||(re(a,r.struct,r.offset),r={struct:d,offset:0},h.next())}}else r={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===r.struct.id.clock+r.struct.length&&d.constructor!==R;d=h.next())re(a,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(re(a,r.struct,r.offset),r=null),ns(a);const c=n.map(h=>Wt(h)),l=Ir(c);return Ee(o,l),o.toUint8Array()},eo=(s,e,t=Ce,n=fe)=>{const i=on(e),r=new n,o=new ss(r),a=new t(se(s)),c=new ts(a,!1);for(;c.curr;){const h=c.curr,u=h.id.client,d=i.get(u)||0;if(c.curr.constructor===R){c.next();continue}if(h.id.clock+h.length>d)for(re(o,h,ce(d-h.id.clock,0)),c.next();c.curr&&c.curr.id.client===u;)re(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===u&&c.curr.id.clock+c.curr.length<=d;)c.next()}ns(o);const l=Wt(a);return Ee(r,l),r.toUint8Array()},wn=s=>{s.written>0&&(s.clientStructs.push({written:s.written,restEncoder:D(s.encoder.restEncoder)}),s.encoder.restEncoder=z(),s.written=0)},re=(s,e,t)=>{s.written>0&&s.currClient!==e.id.client&&wn(s),s.written===0&&(s.currClient=e.id.client,s.encoder.writeClient(e.id.client),p(s.encoder.restEncoder,e.id.clock+t)),e.write(s.encoder,t),s.written++},ns=s=>{wn(s);const e=s.encoder.restEncoder;p(e,s.clientStructs.length);for(let t=0;t<s.clientStructs.length;t++){const n=s.clientStructs[t];p(e,n.written),it(e,n.restEncoder)}},to=(s,e,t,n)=>{const i=new t(se(s)),r=new ts(i,!1),o=new n,a=new ss(o);for(let l=r.curr;l!==null;l=r.next())re(a,e(l),0);ns(a);const c=Wt(i);return Ee(o,c),o.toUint8Array()},so=s=>to(s,Ni,Ce,He),yn="You must not compute changes after the event-handler fired.";class ut{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=no(this.currentTarget,this.target))}deletes(e){return Gs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw W(yn);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const r=t._map.get(i);let o,a;if(this.adds(r)){let c=r.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(r))if(c!==null&&this.deletes(c))o="delete",a=At(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",a=At(c.content.getContent())):(o="add",a=void 0)}else if(this.deletes(r))o="delete",a=At(r.content.getContent());else return;e.set(i,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw W(yn);const t=this.target,n=ae(),i=ae(),r=[];if(e={added:n,deleted:i,delta:r,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const c=()=>{a&&r.push(a)};for(let l=t._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((a===null||a.delete===void 0)&&(c(),a={delete:0}),a.delete+=l.length,i.add(l)):this.adds(l)?((a===null||a.insert===void 0)&&(c(),a={insert:[]}),a.insert=a.insert.concat(l.content.getContent()),n.add(l)):((a===null||a.retain===void 0)&&(c(),a={retain:0}),a.retain+=l.length);a!==null&&a.retain===void 0&&c()}this._changes=e}return e}}const no=(s,e)=>{const t=[];for(;e._item!==null&&e!==s;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let n=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)i.deleted||n++,i=i.right;t.unshift(n)}e=e._item.parent}return t},Sn=80;let is=0;class io{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=is++}}const ro=s=>{s.timestamp=is++},_n=(s,e,t)=>{s.p.marker=!1,s.p=e,e.marker=!0,s.index=t,s.timestamp=is++},oo=(s,e,t)=>{if(s.length>=Sn){const n=s.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return _n(n,e,t),n}else{const n=new io(e,t);return s.push(n),n}},dt=(s,e)=>{if(s._start===null||e===0||s._searchMarker===null)return null;const t=s._searchMarker.length===0?null:s._searchMarker.reduce((r,o)=>Qe(e-r.index)<Qe(e-o.index)?r:o);let n=s._start,i=0;for(t!==null&&(n=t.p,i=t.index,ro(t));n.right!==null&&i<e;){if(!n.deleted&&n.countable){if(e<i+n.length)break;i+=n.length}n=n.right}for(;n.left!==null&&i>e;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);return t!==null&&Qe(t.index-i)<n.parent.length/Sn?(_n(t,n,i),t):oo(s._searchMarker,n,i)},$e=(s,e,t)=>{for(let n=s.length-1;n>=0;n--){const i=s[n];if(t>0){let r=i.p;for(r.marker=!1;r&&(r.deleted||!r.countable);)r=r.left,r&&!r.deleted&&r.countable&&(i.index-=r.length);if(r===null||r.marker===!0){s.splice(n,1);continue}i.p=r,r.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=ce(e,i.index+t))}},ft=(s,e,t)=>{const n=s,i=e.changedParentTypes;for(;Y(i,s,()=>[]).push(t),s._item!==null;)s=s._item.parent;un(n._eH,t,e)};class j{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=cn(),this._dEH=cn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw F()}clone(){throw F()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ln(this._eH,e)}observeDeep(e){ln(this._dEH,e)}unobserve(e){hn(this._eH,e)}unobserveDeep(e){hn(this._dEH,e)}toJSON(){}}const Dn=(s,e,t)=>{e<0&&(e=s._length+e),t<0&&(t=s._length+t);let n=t-e;const i=[];let r=s._start;for(;r!==null&&n>0;){if(r.countable&&!r.deleted){const o=r.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&n>0;a++)i.push(o[a]),n--;e=0}}r=r.right}return i},En=s=>{const e=[];let t=s._start;for(;t!==null;){if(t.countable&&!t.deleted){const n=t.content.getContent();for(let i=0;i<n.length;i++)e.push(n[i])}t=t.right}return e},qe=(s,e)=>{let t=0,n=s._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let r=0;r<i.length;r++)e(i[r],t++,s)}n=n.right}},Cn=(s,e)=>{const t=[];return qe(s,(n,i)=>{t.push(e(n,i,s))}),t},ao=s=>{let e=s._start,t=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),n=0,e=e.right}const i=t[n++];return t.length<=n&&(t=null),{done:!1,value:i}}}},vn=(s,e)=>{const t=dt(s,e);let n=s._start;for(t!==null&&(n=t.p,e-=t.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length}},gt=(s,e,t,n)=>{let i=t;const r=s.doc,o=r.clientID,a=r.store,c=t===null?e._start:t.right;let l=[];const h=()=>{l.length>0&&(i=new A(w(o,I(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new me(l)),i.integrate(s,0),l=[])};n.forEach(u=>{if(u===null)l.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:i=new A(w(o,I(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Ye(new Uint8Array(u))),i.integrate(s,0);break;case de:i=new A(w(o,I(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Je(u)),i.integrate(s,0);break;default:if(u instanceof j)i=new A(w(o,I(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Z(u)),i.integrate(s,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},An=()=>W("Length exceeded!"),xn=(s,e,t,n)=>{if(t>e._length)throw An();if(t===0)return e._searchMarker&&$e(e._searchMarker,t,n.length),gt(s,e,null,n);const i=t,r=dt(e,t);let o=e._start;for(r!==null&&(o=r.p,t-=r.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&ie(s,w(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&$e(e._searchMarker,i,n.length),gt(s,e,o,n)},co=(s,e,t)=>{let i=(e._searchMarker||[]).reduce((r,o)=>o.index>r.index?o:r,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return gt(s,e,i,t)},Ln=(s,e,t,n)=>{if(n===0)return;const i=t,r=n,o=dt(e,t);let a=e._start;for(o!==null&&(a=o.p,t-=o.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&ie(s,w(a.id.client,a.id.clock+t)),t-=a.length);for(;n>0&&a!==null;)a.deleted||(n<a.length&&ie(s,w(a.id.client,a.id.clock+n)),a.delete(s),n-=a.length),a=a.right;if(n>0)throw An();e._searchMarker&&$e(e._searchMarker,i,-r+n)},pt=(s,e,t)=>{const n=e._map.get(t);n!==void 0&&n.delete(s)},rs=(s,e,t,n)=>{const i=e._map.get(t)||null,r=s.doc,o=r.clientID;let a;if(n==null)a=new me([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:a=new me([n]);break;case Uint8Array:a=new Ye(n);break;case de:a=new Je(n);break;default:if(n instanceof j)a=new Z(n);else throw new Error("Unexpected content type")}new A(w(o,I(r.store,o)),i,i&&i.lastId,null,null,e,t,a).integrate(s,0)},os=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},In=s=>{const e={};return s._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},jn=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted},kt=s=>xr(s.entries(),e=>!e[1].deleted);class lo extends ut{constructor(e,t){super(e,t),this._transaction=t}}class Ae extends j{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Ae;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ae}clone(){const e=new Ae;return e.insert(0,this.toArray().map(t=>t instanceof j?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),ft(this,e,new lo(this,e))}insert(e,t){this.doc!==null?S(this.doc,n=>{xn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?S(this.doc,t=>{co(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?S(this.doc,n=>{Ln(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return vn(this,e)}toArray(){return En(this)}slice(e=0,t=this.length){return Dn(this,e,t)}toJSON(){return this.map(e=>e instanceof j?e.toJSON():e)}map(e){return Cn(this,e)}forEach(e){qe(this,e)}[Symbol.iterator](){return ao(this)}_write(e){e.writeTypeRef(To)}}const ho=s=>new Ae;class uo extends ut{constructor(e,t,n){super(e,t),this.keysChanged=n}}class ge extends j{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((n,i)=>{this.set(i,n)}),this._prelimContent=null}_copy(){return new ge}clone(){const e=new ge;return this.forEach((t,n)=>{e.set(n,t instanceof j?t.clone():t)}),e}_callObserver(e,t){ft(this,e,new uo(this,e,t))}toJSON(){const e={};return this._map.forEach((t,n)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[n]=i instanceof j?i.toJSON():i}}),e}get size(){return[...kt(this._map)].length}keys(){return Yt(kt(this._map),e=>e[0])}values(){return Yt(kt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Yt(kt(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?S(this.doc,t=>{pt(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?S(this.doc,n=>{rs(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return os(this,e)}has(e){return jn(this,e)}clear(){this.doc!==null?S(this.doc,e=>{this.forEach(function(t,n,i){pt(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Uo)}}const fo=s=>new ge,oe=(s,e)=>s===e||typeof s=="object"&&typeof e=="object"&&s&&e&&Bi(s,e);class as{constructor(e,t,n,i){this.left=e,this.right=t,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&H(),this.right.content.constructor){case v:this.right.deleted||xe(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Mn=(s,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case v:e.right.deleted||xe(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&ie(s,w(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},mt=(s,e,t)=>{const n=new Map,i=dt(e,t);if(i){const r=new as(i.p.left,i.p,i.index,n);return Mn(s,r,t-i.index)}else{const r=new as(null,e._start,0,n);return Mn(s,r,t)}},zn=(s,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===v&&oe(n.get(t.right.content.key),t.right.content.value));)t.right.deleted||n.delete(t.right.content.key),t.forward();const i=s.doc,r=i.clientID;n.forEach((o,a)=>{const c=t.left,l=t.right,h=new A(w(r,I(i.store,r)),c,c&&c.lastId,l,l&&l.id,e,null,new v(a,o));h.integrate(s,0),t.right=h,t.forward()})},xe=(s,e)=>{const{key:t,value:n}=e;n===null?s.delete(t):s.set(t,n)},Tn=(s,e)=>{for(;s.right!==null;){if(!(s.right.deleted||s.right.content.constructor===v&&oe(e[s.right.content.key]||null,s.right.content.value)))break;s.forward()}},Un=(s,e,t,n)=>{const i=s.doc,r=i.clientID,o=new Map;for(const a in n){const c=n[a],l=t.currentAttributes.get(a)||null;if(!oe(l,c)){o.set(a,l);const{left:h,right:u}=t;t.right=new A(w(r,I(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new v(a,c)),t.right.integrate(s,0),t.forward()}}return o},cs=(s,e,t,n,i)=>{t.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=s.doc,o=r.clientID;Tn(t,i);const a=Un(s,e,t,i),c=n.constructor===String?new $(n):n instanceof j?new Z(n):new ke(n);let{left:l,right:h,index:u}=t;e._searchMarker&&$e(e._searchMarker,t.index,c.getLength()),h=new A(w(o,I(r.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,c),h.integrate(s,0),t.right=h,t.index=u,t.forward(),zn(s,e,t,a)},On=(s,e,t,n,i)=>{const r=s.doc,o=r.clientID;Tn(t,i);const a=Un(s,e,t,i);e:for(;t.right!==null&&(n>0||a.size>0&&(t.right.deleted||t.right.content.constructor===v));){if(!t.right.deleted)switch(t.right.content.constructor){case v:{const{key:c,value:l}=t.right.content,h=i[c];if(h!==void 0){if(oe(h,l))a.delete(c);else{if(n===0)break e;a.set(c,l)}t.right.delete(s)}else t.currentAttributes.set(c,l);break}default:n<t.right.length&&ie(s,w(t.right.id.client,t.right.id.clock+n)),n-=t.right.length;break}t.forward()}if(n>0){let c="";for(;n>0;n--)c+=`
|
|
2
|
-
`;
|
|
3
|
-
`?o.insert.slice(0,-1):o.insert;(typeof a!="string"||a.length>0)&&cs(n,this,i,a,o.attributes||{})}else o.retain!==void 0?On(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Bn(n,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){const i=[],r=new Map,o=this.doc;let a="",c=this._start;function l(){if(a.length>0){const u={};let d=!1;r.forEach((g,m)=>{d=!0,u[m]=g});const f={insert:a};d&&(f.attributes=u),i.push(f),a=""}}const h=()=>{for(;c!==null;){if(Ve(c,e)||t!==void 0&&Ve(c,t))switch(c.content.constructor){case $:{const u=r.get("ychange");e!==void 0&&!Ve(c,e)?(u===void 0||u.user!==c.id.client||u.type!=="removed")&&(l(),r.set("ychange",n?n("removed",c.id):{type:"removed"})):t!==void 0&&!Ve(c,t)?(u===void 0||u.user!==c.id.client||u.type!=="added")&&(l(),r.set("ychange",n?n("added",c.id):{type:"added"})):u!==void 0&&(l(),r.delete("ychange")),a+=c.content.str;break}case Z:case ke:{l();const u={insert:c.content.getContent()[0]};if(r.size>0){const d={};u.attributes=d,r.forEach((f,g)=>{d[g]=f})}i.push(u);break}case v:Ve(c,e)&&(l(),xe(r,c.content));break}c=c.right}l()};return e||t?S(o,u=>{e&&Zt(u,e),t&&Zt(u,t),h()},"cleanup"):h(),i}insert(e,t,n){if(t.length<=0)return;const i=this.doc;i!==null?S(i,r=>{const o=mt(r,this,e);n||(n={},o.currentAttributes.forEach((a,c)=>{n[c]=a})),cs(r,this,o,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n={}){const i=this.doc;i!==null?S(i,r=>{const o=mt(r,this,e);cs(r,this,o,t,n)}):this._pending.push(()=>this.insertEmbed(e,t,n))}delete(e,t){if(t===0)return;const n=this.doc;n!==null?S(n,i=>{Bn(i,mt(i,this,e),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,n){if(t===0)return;const i=this.doc;i!==null?S(i,r=>{const o=mt(r,this,e);o.right!==null&&On(r,this,o,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){this.doc!==null?S(this.doc,t=>{pt(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?S(this.doc,n=>{rs(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return os(this,e)}getAttributes(){return In(this)}_write(e){e.writeTypeRef(Oo)}}const bo=s=>new Le;class ls{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ke||t.constructor===pe)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class pe extends j{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new pe}clone(){const e=new pe;return e.insert(0,this.toArray().map(t=>t instanceof j?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ls(this,e)}querySelector(e){e=e.toUpperCase();const n=new ls(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),te(new ls(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ft(this,e,new So(this,t,e))}toString(){return Cn(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){const i=e.createDocumentFragment();return n!==void 0&&n._createAssociation(i,this),qe(this,r=>{i.insertBefore(r.toDOM(e,t,n),null)}),i}insert(e,t){this.doc!==null?S(this.doc,n=>{xn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)S(this.doc,n=>{const i=e&&e instanceof j?e._item:e;gt(n,this,i,t)});else{const n=this._prelimContent,i=e===null?0:n.findIndex(r=>r===e)+1;if(i===0&&e!==null)throw W("Reference item not found");n.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?S(this.doc,n=>{Ln(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return En(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return vn(this,e)}slice(e=0,t=this.length){return Dn(this,e,t)}forEach(e){qe(this,e)}_write(e){e.writeTypeRef(Bo)}}const wo=s=>new pe;class Ke extends pe{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((n,i)=>{this.setAttribute(i,n)}),this._prelimAttrs=null}_copy(){return new Ke(this.nodeName)}clone(){const e=new Ke(this.nodeName),t=this.getAttributes();return Ti(t,(n,i)=>{typeof n=="string"&&e.setAttribute(i,n)}),e.insert(0,this.toArray().map(n=>n instanceof j?n.clone():n)),e}toString(){const e=this.getAttributes(),t=[],n=[];for(const a in e)n.push(a);n.sort();const i=n.length;for(let a=0;a<i;a++){const c=n[a];t.push(c+'="'+e[c]+'"')}const r=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${r}${o}>${super.toString()}</${r}>`}removeAttribute(e){this.doc!==null?S(this.doc,t=>{pt(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?S(this.doc,n=>{rs(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return os(this,e)}hasAttribute(e){return jn(this,e)}getAttributes(){return In(this)}toDOM(e=document,t={},n){const i=e.createElement(this.nodeName),r=this.getAttributes();for(const o in r){const a=r[o];typeof a=="string"&&i.setAttribute(o,a)}return qe(this,o=>{i.appendChild(o.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Ro),e.writeKey(this.nodeName)}}const yo=s=>new Ke(s.readKey());class So extends ut{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class bt extends ge{constructor(e){super(),this.hookName=e}_copy(){return new bt(this.hookName)}clone(){const e=new bt(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(e=document,t={},n){const i=t[this.hookName];let r;return i!==void 0?r=i.createDom(this):r=document.createElement(this.hookName),r.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(No),e.writeKey(this.hookName)}}const _o=s=>new bt(s.readKey());class wt extends Le{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new wt}clone(){const e=new wt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){const i=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const r=[];for(const o in e.attributes[i])r.push({key:o,value:e.attributes[i][o]});r.sort((o,a)=>o.key<a.key?-1:1),t.push({nodeName:i,attrs:r})}t.sort((i,r)=>i.nodeName<r.nodeName?-1:1);let n="";for(let i=0;i<t.length;i++){const r=t[i];n+=`<${r.nodeName}`;for(let o=0;o<r.attrs.length;o++){const a=r.attrs[o];n+=` ${a.key}="${a.value}"`}n+=">"}n+=e.insert;for(let i=t.length-1;i>=0;i--)n+=`</${t[i].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Fo)}}const Do=s=>new wt;class hs{constructor(e,t){this.id=e,this.length=t}get deleted(){throw F()}mergeWith(e){return!1}write(e,t,n){throw F()}integrate(e,t){throw F()}}const Eo=0;class O extends hs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),fn(e.doc.store,this)}write(e,t){e.writeInfo(Eo),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Ye{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ye(this.content)}splice(e){throw F()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const Co=s=>new Ye(s.readBuf());class Xe{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Xe(this.len)}splice(e){const t=new Xe(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){ot(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const vo=s=>new Xe(s.readLen()),Nn=(s,e)=>new de({guid:s,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Je{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Je(Nn(this.doc.guid,this.opts))}splice(e){throw F()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const Ao=s=>new Je(Nn(s.readString(),s.readAny()));class ke{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ke(this.embed)}splice(e){throw F()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const xo=s=>new ke(s.readJSON());class v{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new v(this.key,this.value)}splice(e){throw F()}mergeWith(e){return!1}integrate(e,t){const n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const Lo=s=>new v(s.readKey(),s.readJSON());class yt{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new yt(this.arr)}splice(e){const t=new yt(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let i=t;i<n;i++){const r=this.arr[i];e.writeString(r===void 0?"undefined":JSON.stringify(r))}}getRef(){return 2}}const Io=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++){const i=s.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new yt(t)};class me{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new me(this.arr)}splice(e){const t=new me(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let i=t;i<n;i++){const r=this.arr[i];e.writeAny(r)}}getRef(){return 8}}const jo=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++)t.push(s.readAny());return new me(t)};class ${constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new $(this.str)}splice(e){const t=new $(this.str.slice(e));this.str=this.str.slice(0,e);const n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const Mo=s=>new $(s.readString()),zo=[ho,fo,bo,yo,wo,_o,Do],To=0,Uo=1,Oo=2,Ro=3,Bo=4,No=5,Fo=6;class Z{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Z(this.type._copy())}splice(e){throw F()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const Ho=s=>new Z(zo[s.readTypeRef()](s)),St=(s,e,t)=>{const{client:n,clock:i}=e.id,r=new A(w(n,i+t),e,w(n,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&r.markDeleted(),e.keep&&(r.keep=!0),e.redone!==null&&(r.redone=w(e.redone.client,e.redone.clock+t)),e.right=r,r.right!==null&&(r.right.left=r),s._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),e.length=t,r};class A extends hs{constructor(e,t,n,i,r,o,a,c){super(e,c.getLength()),this.origin=n,this.left=t,this.right=i,this.rightOrigin=r,this.parent=o,this.parentSub=a,this.redone=null,this.content=c,this.info=this.content.isCountable()?zs:0}set marker(e){(this.info&Tt)>0!==e&&(this.info^=Tt)}get marker(){return(this.info&Tt)>0}get keep(){return(this.info&Ms)>0}set keep(e){this.keep!==e&&(this.info^=Ms)}get countable(){return(this.info&zs)>0}get deleted(){return(this.info&zt)>0}set deleted(e){this.deleted!==e&&(this.info^=zt)}markDeleted(){this.info|=zt}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ve&&this.id.client!==this.parent.client&&this.parent.clock>=I(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=gn(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ie(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===O||this.right&&this.right.constructor===O)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===A&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===A&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ve){const n=Qt(t,this.parent);n.constructor===O?this.parent=null:this.parent=n.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=gn(e,e.doc.store,w(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,i;if(n!==null)i=n.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const r=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),r.add(i),at(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(at(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Qt(e.doc.store,i.origin)))r.has(Qt(e.doc.store,i.origin))||(n=i,r.clear());else break;i=i.right}this.left=n}if(this.left!==null){const n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),fn(e.doc.store,this),this.content.integrate(e,this),mn(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new O(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:w(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&at(e.origin,this.lastId)&&this.right===e&&at(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),ot(e.deleteSet,this.id.client,this.id.clock,this.length),mn(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw H();this.content.gc(e),t?Xr(e,this,new O(this.id,this.length)):this.content=new Xe(this.length)}write(e,t){const n=t>0?w(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,r=this.parentSub,o=this.content.getRef()&tt|(n===null?0:T)|(i===null?0:J)|(r===null?0:Oe);if(e.writeInfo(o),n!==null&&e.writeLeftID(n),i!==null&&e.writeRightID(i),n===null&&i===null){const a=this.parent;if(a._item!==void 0){const c=a._item;if(c===null){const l=Yr(a);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===ve?(e.writeParentInfo(!1),e.writeLeftID(a)):H();r!==null&&e.writeString(r)}this.content.write(e,t)}}const Fn=(s,e)=>Vo[e&tt](s),Vo=[()=>{H()},vo,Io,Co,Mo,xo,Lo,Ho,jo,Ao,()=>{H()}],$o=10;class R extends hs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){H()}write(e,t){e.writeInfo($o),p(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const Hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vn="__ $YJS$ __";Hn[Vn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Hn[Vn]=!0;const $n=new Map;class qo{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:sr(t.newValue||"")}),Ii(this._onChange)}postMessage(e){xs.setItem(this.room,tr(Gi(e)))}close(){ji(this._onChange)}}const Ko=typeof BroadcastChannel>"u"?qo:BroadcastChannel,us=s=>Y($n,s,()=>{const e=ae(),t=new Ko(s);return t.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:t,subs:e}}),Yo=(s,e)=>(us(s).subs.add(e),e),Xo=(s,e)=>{const t=us(s),n=t.subs.delete(e);return n&&t.subs.size===0&&(t.bc.close(),$n.delete(s)),n},Ie=(s,e,t=null)=>{const n=us(s);n.bc.postMessage(e),n.subs.forEach(i=>i(e,t))},qn=0,ds=1,Kn=2,fs=(s,e)=>{p(s,qn);const t=qr(e);C(s,t)},Yn=(s,e,t)=>{p(s,ds),C(s,Pt(e,t))},Jo=(s,e,t)=>Yn(e,t,M(s)),Xn=(s,e,t)=>{try{rn(e,M(s),t)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Wo=(s,e)=>{p(s,Kn),C(s,e)},Go=Xn,Po=(s,e,t,n)=>{const i=k(s);switch(i){case qn:Jo(s,e,t);break;case ds:Xn(s,t,n);break;case Kn:Go(s,t,n);break;default:throw new Error("Unknown message type")}return i},Zo=0,Qo=(s,e,t)=>{switch(k(s)){case Zo:t(e,ne(s))}},gs=3e4;class ea extends Ze{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=ue();this.getLocalState()!==null&&gs/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&gs<=t-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&ps(this,n,"timeout")},X(gs/10)),e.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(e){const t=this.clientID,n=this.meta.get(t),i=n===void 0?0:n.clock+1,r=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:ue()});const o=[],a=[],c=[],l=[];e===null?l.push(t):r==null?e!=null&&o.push(t):(a.push(t),Ue(r,e)||c.push(t)),(o.length>0||c.length>0||l.length>0)&&this.emit("change",[{added:o,updated:c,removed:l},"local"]),this.emit("update",[{added:o,updated:a,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}const ps=(s,e,t)=>{const n=[];for(let i=0;i<e.length;i++){const r=e[i];if(s.states.has(r)){if(s.states.delete(r),r===s.clientID){const o=s.meta.get(r);s.meta.set(r,{clock:o.clock+1,lastUpdated:ue()})}n.push(r)}}n.length>0&&(s.emit("change",[{added:[],updated:[],removed:n},t]),s.emit("update",[{added:[],updated:[],removed:n},t]))},We=(s,e,t=s.states)=>{const n=e.length,i=z();p(i,n);for(let r=0;r<n;r++){const o=e[r],a=t.get(o)||null,c=s.meta.get(o).clock;p(i,o),p(i,c),he(i,JSON.stringify(a))}return D(i)},ta=(s,e,t)=>{const n=se(e),i=ue(),r=[],o=[],a=[],c=[],l=k(n);for(let h=0;h<l;h++){const u=k(n);let d=k(n);const f=JSON.parse(ne(n)),g=s.meta.get(u),m=s.states.get(u),E=g===void 0?0:g.clock;(E<d||E===d&&f===null&&s.states.has(u))&&(f===null?u===s.clientID&&s.getLocalState()!=null?d++:s.states.delete(u):s.states.set(u,f),s.meta.set(u,{clock:d,lastUpdated:i}),g===void 0&&f!==null?r.push(u):g!==void 0&&f===null?c.push(u):f!==null&&(Ue(f,m)||a.push(u),o.push(u)))}(r.length>0||a.length>0||c.length>0)&&s.emit("change",[{added:r,updated:a,removed:c},t]),(r.length>0||o.length>0||c.length>0)&&s.emit("update",[{added:r,updated:o,removed:c},t])},sa=s=>Ui(s,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var be=0,Jn=3,je=1,na=2,ia=typeof window>"u";function ra(s,e){if(!s)throw new Error(e)}var Ge=[];Ge[be]=(s,e,t,n,i)=>{p(s,be);const r=Po(e,s,t.doc,t);n&&r===ds&&!t.synced&&(t.synced=!0)},Ge[Jn]=(s,e,t,n,i)=>{p(s,je),C(s,We(t.awareness,Array.from(t.awareness.getStates().keys())))},Ge[je]=(s,e,t,n,i)=>{ta(t.awareness,M(e),t)},Ge[na]=(s,e,t,n,i)=>{Qo(e,t.doc,(r,o)=>oa(t,o))};var Wn=3e4;function oa(s,e){console.warn(`Permission denied to access ${s.url}.
|
|
4
|
-
${e}`)}function Gn(s,e,t){const n=se(e),i=z(),r=k(n),o=s.messageHandlers[r];return o?o(i,n,s,t,r):console.error("Unable to compute message"),i}function Pn(s){if(s.shouldConnect&&s.ws===null){const e=new s._WS(s.url);e.binaryType="arraybuffer",s.ws=e,s.wsconnecting=!0,s.wsconnected=!1,s.synced=!1,e.onmessage=t=>{if(typeof t.data=="string")return;s.wsLastMessageReceived=ue();const n=Gn(s,new Uint8Array(t.data),!0);Ft(n)>1&&e.send(D(n))},e.onerror=t=>{s.emit("connection-error",[t,s])},e.onclose=t=>{s.emit("connection-close",[t,s]),s.ws=null,s.wsconnecting=!1,s.wsconnected?(s.wsconnected=!1,s.synced=!1,ps(s.awareness,Array.from(s.awareness.getStates().keys()).filter(n=>n!==s.doc.clientID),s),s.emit("status",[{status:"disconnected"}])):s.wsUnsuccessfulReconnects++,setTimeout(Pn,xt(Si(2,s.wsUnsuccessfulReconnects)*100,s.maxBackoffTime),s)},e.onopen=()=>{s.wsLastMessageReceived=ue(),s.wsconnecting=!1,s.wsconnected=!0,s.wsUnsuccessfulReconnects=0,s.emit("status",[{status:"connected"}]);const t=z();if(p(t,be),fs(t,s.doc),e.send(D(t)),s.awareness.getLocalState()!==null){const n=z();p(n,je),C(n,We(s.awareness,[s.doc.clientID])),e.send(D(n))}},s.emit("status",[{status:"connecting"}])}}function ks(s,e){const t=s.ws;s.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),s.bcconnected&&Ie(s.bcChannel,e,s)}var aa=class extends Ze{constructor(e,t,n,{connect:i=!0,awareness:r=new ea(n),params:o={},WebSocketPolyfill:a=WebSocket,resyncInterval:c=-1,maxBackoffTime:l=2500,disableBc:h=ia}={}){super();b(this,"maxBackoffTime");b(this,"bcChannel");b(this,"url");b(this,"roomname");b(this,"doc");b(this,"_WS");b(this,"awareness");b(this,"wsconnected");b(this,"wsconnecting");b(this,"bcconnected");b(this,"disableBc");b(this,"wsUnsuccessfulReconnects");b(this,"messageHandlers");b(this,"_synced");b(this,"ws");b(this,"wsLastMessageReceived");b(this,"shouldConnect");b(this,"_resyncInterval");b(this,"_bcSubscriber");b(this,"_updateHandler");b(this,"_awarenessUpdateHandler");b(this,"_unloadHandler");b(this,"_checkInterval");for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);const u=sa(o);this.maxBackoffTime=l,this.bcChannel=e+"/"+t,this.url=e+"/"+t+(u.length===0?"":"?"+u),this.roomname=t,this.doc=n,this._WS=a,this.awareness=r,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Ge.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=z();p(d,be),fs(d,n),this.ws.send(D(d))}},c)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Gn(this,new Uint8Array(d),!1);Ft(g)>1&&Ie(this.bcChannel,D(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=z();p(g,be),Wo(g,d),ks(this,D(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const E=d.concat(f).concat(g),ee=z();p(ee,je),C(ee,We(r,E)),ks(this,D(ee))},this._unloadHandler=()=>{ps(this.awareness,[n.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),r.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Wn<ue()-this.wsLastMessageReceived&&(ra(this.ws!==null,"ws must not be null"),this.ws.close())},Wn/10),i&&this.connect()}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Yo(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=z();p(e,be),fs(e,this.doc),Ie(this.bcChannel,D(e),this);const t=z();p(t,be),Yn(t,this.doc),Ie(this.bcChannel,D(t),this);const n=z();p(n,Jn),Ie(this.bcChannel,D(n),this);const i=z();p(i,je),C(i,We(this.awareness,[this.doc.clientID])),Ie(this.bcChannel,D(i),this)}disconnectBc(){const e=z();p(e,je),C(e,We(this.awareness,[this.doc.clientID],new Map)),ks(this,D(e)),this.bcconnected&&(Xo(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Pn(this),this.connectBc())}};function ca(){if(crypto.randomUUID)return crypto.randomUUID();let s=new Date().getTime(),e=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let n=Math.random()*16;return s>0?(n=(s+n)%16|0,s=Math.floor(s/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),(t==="x"?n:n&3|8).toString(16)})}function Zn(s,e,t){if(typeof s!==t)throw new Error(`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${t}, received: ${s}`)}var la=class extends WebSocket{send(s){typeof s!="string"&&ki(s,e=>super.send(e))}},ha=(di=class extends aa{constructor(e,t,n,i={}){Zn(e,"host","string"),Zn(t,"room","string"),e=e.replace(/^(http|https|ws|wss):\/\//,""),e.endsWith("/")&&e.slice(0,-1);const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}${i.party?`/parties/${i.party}`:"/party"}`,o=i.connectionId??ca(),{params:a,connect:c=!0,...l}=i,h={...l,connect:!1,WebSocketPolyfill:la};super(r,t,n??new de,h);b(this,"id");gi(this,ye,void 0);this.id=o,pi(this,ye,a),c&&this.connect()}connect(){Promise.resolve(typeof Ct(this,ye)=="function"?Ct(this,ye).call(this):Ct(this,ye)).then(e=>{const t=new URLSearchParams([["_pk",this.id]]);if(e)for(const[i,r]of Object.entries(e))r!=null&&t.append(i,r);const n=new URL(this.url);n.search=t.toString(),this.url=n.toString(),super.connect()}).catch(e=>{throw console.error("Failed to open connecton to PartyKit",e),new Error(e)})}},ye=new WeakMap,di);const we=s=>De((e,t)=>{s.onerror=n=>t(new Error(n.target.error)),s.onsuccess=n=>e(n.target.result)}),ua=(s,e)=>De((t,n)=>{const i=indexedDB.open(s);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(W(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),t(o)}}),da=s=>we(indexedDB.deleteDatabase(s)),fa=(s,e)=>e.forEach(t=>s.createObjectStore.apply(s,t)),Pe=(s,e,t="readwrite")=>{const n=s.transaction(e,t);return e.map(i=>Sa(n,i))},Qn=(s,e)=>we(s.count(e)),ga=(s,e)=>we(s.get(e)),ei=(s,e)=>we(s.delete(e)),pa=(s,e,t)=>we(s.put(e,t)),ms=(s,e)=>we(s.add(e)),ka=(s,e,t)=>we(s.getAll(e,t)),ma=(s,e,t)=>{let n=null;return ya(s,e,i=>(n=i,!1),t).then(()=>n)},ba=(s,e=null)=>ma(s,e,"prev"),wa=(s,e)=>De((t,n)=>{s.onerror=n,s.onsuccess=async i=>{const r=i.target.result;if(r===null||await e(r)===!1)return t();r.continue()}}),ya=(s,e,t,n="next")=>wa(s.openKeyCursor(e,n),i=>t(i.key)),Sa=(s,e)=>s.objectStore(e),_a=(s,e)=>IDBKeyRange.upperBound(s,e),Da=(s,e)=>IDBKeyRange.lowerBound(s,e),bs="custom",ti="updates",si=500,ni=(s,e=()=>{},t=()=>{})=>{const[n]=Pe(s.db,[ti]);return ka(n,Da(s._dbref,!1)).then(i=>{s._destroyed||(e(n),S(s.doc,()=>{i.forEach(r=>rn(s.doc,r))},s,!1),t(n))}).then(()=>ba(n).then(i=>{s._dbref=i+1})).then(()=>Qn(n).then(i=>{s._dbsize=i})).then(()=>n)},Ea=(s,e=!0)=>ni(s).then(t=>{(e||s._dbsize>=si)&&ms(t,Pt(s.doc)).then(()=>ei(t,_a(s._dbref,!0))).then(()=>Qn(t).then(n=>{s._dbsize=n}))});class Ca extends Ze{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=ua(e,n=>fa(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=De(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,ni(this,o=>ms(o,Pt(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(n,i)=>{if(this.db&&i!==this){const[r]=Pe(this.db,[ti]);ms(r,n),++this._dbsize>=si&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Ea(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{da(this.name)})}get(e){return this._db.then(t=>{const[n]=Pe(t,[bs],"readonly");return ga(n,e)})}set(e,t){return this._db.then(n=>{const[i]=Pe(n,[bs]);return pa(i,t,e)})}del(e){return this._db.then(t=>{const[n]=Pe(t,[bs]);return ei(n,e)})}}const sc="";function va(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Aa=["2 girls 1 cup","2g1c","4r5e","5h1t","5hit","5ht","666","@$$","a s s","a s shole","a55","a55hole","a_s_s","abbo","abeed","abuse","acrotomophilia","aeolus","africoon","ahole","alabama hot pocket","alaskan pipeline","alligator bait","alligatorbait","amcik","anal","analannie","analprobe","analsex","andskota","anilingus","anus","apeshit","ar5e","arabush","arabushs","areola","areole","argie","armo","armos","aroused","arrse","arschloch","arse","arsehole","aryan","ash0le","ash0les","asholes","ass monkey","ass","ass-fucker","ass-hat","ass-pirate","assbag","assbagger","assbandit","assbang","assbanged","assbanger","assbangs","assbite","assblaster","assclown","asscock","asscowboy","asscracker","asses","assface","assfuck","assfucker","assfukka","assgoblin","assh0le","assh0lez","asshat","asshead","assho1e","asshole","assholes","assholz","asshopper","asshore","assjacker","assjockey","asskiss","asskisser","assklown","asslick","asslicker","asslover","assman","assmaster","assmonkey","assmunch","assmuncher","assnigger","asspacker","asspirate","asspuppies","assrammer","assranger","assshit","assshole","asssucker","asswad","asswhole","asswhore","asswipe","asswipes","auto erotic","autoerotic","ayir","azazel","azz","azzhole","b a s t a r d","b i t c h","b o o b","b!+ch","b!tch","b!tchin","b*tch","b00b","b00bies","b00biez","b00bs","b00bz","b17ch","b1tch","b7ch","babeland","babes","baby batter","baby juice","backdoor","backdoorman","badfuck","bagging","ball gag","ball gravy","ball kicking","ball licking","ball sack","ball sucking","ballbag","balllicker","ballsack","bampot","bangbro","bangbros","bangbus","banger","banging","bareback","barely legal","barelylegal","barenaked","barf","barface","barfface","bassterd","bassterds","bastard","bastardo","bastards","bastardz","basterds","basterdz","bastinado","bawdy","bazongas","bazooms","bbw","bdsm","beaner","beaners","beaney","beaneys","beardedclam","beastality","beastial","beastiality","beastility","beatch","beatoff","beatyourmeat","beaver cleaver","beaver lips","beef curtains","beeyotch","bellend","beotch","bestial","bestiality","bi curious","bi+ch","bi7ch","biatch","bicurious","big black","big breasts","big knockers","big tits","bigass","bigbastard","bigbreasts","bigbutt","bigtits","bimbo","bimbos","bint","birdlock","bitch","bitchass","bitched","bitcher","bitchers","bitches","bitchez","bitchin","bitching","bitchslap","bitchtit","bitchy","biteme","bitties","black cock","blackcock","blackman","blackout","blacks","blonde action","blonde on blonde action","blonde on blonde","bloodclaat","bloody","blow j","blow job","blow your l","blow your load","blowjob","blowjobs","blue waffle","bluegum","bluegums","blumpkin","bo ob","bo obs","boang","boche","boches","bodily","boffing","bogan","bohunk","boink","boiolas","bollick","bollock","bollocks","bollok","bollox","bombers","bombing","bomd","bondage","boned","boner","boners","bong","bookie","boong","boonga","boongas","boongs","boonie","boonies","booobs","boooobs","booooobs","booooooobs","bootee","bootlip","bootlips","boozer","boozy","bosch","bosche","bosches","boschs","bosomy","bounty bar","bounty bars","bountybar","brea5t","breastjob","breastlover","breastman","brown shower","brown showers","brunette action","btch","buceta","buddhahead","buddhaheads","buffies","bugger","buggered","buggery","bukake","bukkake","bullcrap","bulldike","bulldyke","bullet vibe","bullshit","bullshits","bullshitted","bullturds","bumblefuck","bumfuck","bung hole","bung","bunga","bungas","bunghole","bunny fucker","burr head","burr heads","burrhead","burrheads","butchbabes","butchdike","butchdyke","butt plug","butt-pirate","buttbang","buttcheeks","buttface","buttfuck","buttfucker","buttfuckers","butthead","butthole","buttman","buttmuch","buttmunch","buttmuncher","buttpirate","buttplug","buttstain","buttwipe","byatch","c u n t","c-0-c-k","c-o-c-k","c-u-n-t","c.0.c.k","c.o.c.k.","c.u.n.t","c0ck","c0cks","c0cksucker","c0k","cabron","caca","cacker","cahone","camel jockey","camel jockeys","camel toe","cameljockey","cameltoe","camgirl","camslut","camwhore","carpet muncher","carpetmuncher","carruth","cawk","cawks","cazzo","cervix","chav","cheese eating surrender monkey","cheese eating surrender monkies","cheeseeating surrender monkey","cheeseeating surrender monkies","cheesehead","cheeseheads","cherrypopper","chickslick","china swede","china swedes","chinaman","chinamen","chinaswede","chinaswedes","chinc","chincs","ching chong","ching chongs","chinga","chingchong","chingchongs","chink","chinks","chinky","choad","chocolate rosebuds","chode","chodes","chonkies","chonky","chonkys","chraa","christ killer","christ killers","chug","chugs","chuj","chunger","chungers","chunkies","chunkys","chute","cipa","circlejerk","cl1t","clamdigger","clamdiver","clamps","clansman","clansmen","clanswoman","clanswomen","cleveland steamer","clit","clitface","clitfuck","clitoris","clitorus","clits","clitty","clogwog","clover clamps","clusterfuck","cnts","cntz","cnut","cocain","cocaine","cock","cock-head","cock-sucker","cockbite","cockblock","cockblocker","cockburger","cockcowboy","cockface","cockfight","cockfucker","cockhead","cockholster","cockjockey","cockknob","cockknocker","cockknoker","cocklicker","cocklover","cockmaster","cockmongler","cockmongruel","cockmonkey","cockmunch","cockmuncher","cocknob","cocknose","cocknugget","cockqueen","cockrider","cocks","cockshit","cocksman","cocksmith","cocksmoker","cocksucer","cocksuck","cocksucked","cocksucker","cocksucking","cocksucks","cocksuka","cocksukka","cocktease","cocky","cohee","coital","coitus","cok","cokmuncher","coksucka","commie","condom","coochie","coochy","coolie","coolies","cooly","coon ass","coon asses","coonass","coonasses","coondog","coons","cooter","coprolagnia","coprophilia","copulate","corksucker","cornhole","cra5h","crabs","crackcocain","cracker","crackpipe","crackwhore","crap","crapola","crapper","crappy","creampie","crotch","crotchjockey","crotchmonkey","crotchrot","cuck","cum face","cum licker","cum","cumbubble","cumdumpster","cumfest","cumguzzler","cuming","cumjockey","cumlickr","cumm","cummer","cummin","cumming","cumquat","cumqueen","cums","cumshot","cumshots","cumslut","cumstain","cumsucker","cumtart","cunilingus","cunillingus","cunn","cunnie","cunnilingus","cunntt","cunny","cunt","cunteyed","cuntface","cuntfuck","cuntfucker","cunthole","cunthunter","cuntlick","cuntlicker","cuntlicking","cuntrag","cunts","cuntslut","cuntsucker","cuntz","curry muncher","curry munchers","currymuncher","currymunchers","cushi","cushis","cyalis","cyberfuc","cyberfuck","cyberfucked","cyberfucker","cyberfuckers","cyberfucking","cybersex","cyberslimer","d0ng","d0uch3","d0uche","d1ck","d1ld0","d1ldo","d4mn","dago","dagos","dahmer","damm","dammit","damn","damnation","damned","damnit","darkey","darkeys","darkie","darkies","darky","date rape","daterape","datnigga","dawgie style","dawgie-style","daygo","deapthroat","deep throat","deep throating","deepaction","deepthroat","deepthroating","defecate","deggo","dego","degos","demon","dendrophilia","destroyyourpussy","deth","diaper daddy","diaper head","diaper heads","diaperdaddy","diaperhead","diaperheads","dick pic","dick","dick-ish","dickbag","dickbeater","dickbeaters","dickbrain","dickdipper","dickface","dickflipper","dickforbrains","dickfuck","dickhead","dickheads","dickhole","dickish","dickjuice","dickless","dicklick","dicklicker","dickman","dickmilk","dickmonger","dickpic","dickripper","dicks","dicksipper","dickslap","dickslicker","dicksucker","dickwad","dickweasel","dickweed","dickwhipper","dickwod","dickzipper","diddle","dike","dild0","dild0s","dildo","dildos","dilf","diligaf","dilld0","dilld0s","dillweed","dimwit","dingle","dingleberries","dingleberry","dink","dinks","dipship","dipshit","dipstick","dirsa","dirty pillows","dirty sanchez","dix","dixiedike","dixiedyke","dlck","dog style","dog-fucker","doggie style","doggie","doggie-style","doggiestyle","doggin","dogging","doggy style","doggy-style","doggystyle","dolcett","domination","dominatricks","dominatrics","dominatrix","dommes","dong","donkey punch","donkeypunch","donkeyribber","doochbag","doodoo","doofus","dookie","doosh","dot head","dot heads","dothead","dotheads","double dong","double penetration","doubledong","doublepenetration","douch3","douche bag","douche","douche-fag","douchebag","douchebags","douchewaffle","douchey","dp action","dp","dpaction","dragqueen","dragqween","dripdick","dry hump","dryhump","duche","dudette","dumass","dumb ass","dumbass","dumbasses","dumbbitch","dumbfuck","dumbshit","dumshit","dune coon","dune coons","dupa","dvda","dyefly","dyke","dykes","dziwka","earotics","easyslut","eat my ass","eat my","eatadick","eatballs","eathairpie","eatme","eatmyass","eatpussy","ecchi","ejackulate","ejakulate","ekrem","ekto","enculer","enema","enlargement","erect","erection","ero","erotic","erotism","escort","esqua","essohbee","ethical slut","evl","excrement","exkwew","extacy","extasy","f u c k e r","f u c k e","f u c k","f u k","f*ck","f-u-c-k","f.u.c.k","f4nny","f_u_c_k","facefucker","fack","faeces","faen","fag","fag1t","fagbag","faget","fagfucker","fagg","fagg1t","fagged","fagging","faggit","faggitt","faggot","faggotcock","faggs","fagit","fagot","fagots","fags","fagt","fagtard","fagz","faig","faigs","faigt","fanculo","fannybandit","fannyflaps","fannyfucker","fanyy","fartknocker","fastfuck","fatah","fatfuck","fatfucker","fatso","fck","fckcum","fckd","fcuk","fcuker","fcuking","fecal","feck","fecker","feg","felatio","felch","felcher","felching","fellate","fellatio","feltch","feltcher","feltching","female squirting","femalesquirtin","femalesquirting","femdom","fetish","ficken","figging","fingerbang","fingerfood","fingerfuck","fingerfucked","fingerfucker","fingerfuckers","fingerfucking","fingerfucks","fingering","fisted","fister","fistfuck","fistfucked","fistfucker","fistfuckers","fistfucking","fistfuckings","fistfucks","fisting","fisty","fitt","flamer","flange","flasher","flikker","flipping the bird","flogthelog","floo","floozy","flydie","flydye","foad","fok","fondle","foobar","fook","fooker","foot fetish","footaction","footfetish","footfuck","footfucker","footjob","footlicker","footstar","foreskin","forni","fornicate","fotze","foursome","fourtwenty","freakfuck","freakyfucker","freefuck","freex","frigg","frigga","frigger","frotting","fucck","fuck","fuck-tard","fucka","fuckable","fuckass","fuckbag","fuckbitch","fuckbook","fuckboy","fuckbrain","fuckbuddy","fuckbutt","fuckd","fucked","fuckedup","fucker","fuckers","fuckersucker","fuckface","fuckfest","fuckfreak","fuckfriend","fuckhead","fuckheads","fuckher","fuckhole","fuckin","fuckina","fucking","fuckingbitch","fuckings","fuckingshitmotherfucker","fuckinnuts","fuckinright","fuckit","fuckknob","fuckme","fuckmeat","fuckmehard","fuckmonkey","fuckn","fucknugget","fucknut","fucknuts","fucknutt","fucknutz","fuckoff","fuckpig","fuckpuppet","fuckr","fucks","fuckstick","fucktard","fucktards","fucktoy","fucktrophy","fuckup","fuckwad","fuckwhit","fuckwhore","fuckwit","fuckwitt","fuckyomama","fuckyou","fudge packer","fudgepacker","fugly","fuk","fukah","fuken","fuker","fukin","fuking","fukk","fukkah","fukken","fukker","fukkin","fukking","fuks","fuktard","fuktards","fukwhit","fukwit","funfuck","fungus","futanari","futanary","futkretzn","fuuck","fux","fux0r","fuxor","fvck","fvk","fxck","g-spot","g00k","gae","gai","gang bang","gangbang","gangbanged","gangbanger","gangbangs","gangsta","ganja","gassyass","gator bait","gatorbait","gay sex","gayass","gaybob","gayboy","gaydo","gaygirl","gaylord","gaymuthafuckinwhore","gays","gaysex","gaytard","gaywad","gayz","geezer","geni","genital","genitals","getiton","gey","gfy","ghay","ghey","giant cock","gigolo","ginzo","ginzos","gipp","gippo","gippos","gipps","girl on top","girl on","girls gone wild","givehead","glans","glazeddonut","goatcx","goatse","gob","god dammit","god damn","god damnit","god-dam","god-damned","godam","godammit","godamn","godamnit","goddam","goddamit","goddamm","goddammit","goddamn","goddamned","goddamnes","goddamnit","goddamnmuthafucker","godsdamn","gokkun","golden shower","goldenshower","golliwog","golliwogs","gonad","gonads","gonorrehea","gonzagas","goo girl","gooch","goodpoop","gook eye","gook eyes","gook","gookeye","gookeyes","gookies","gooks","gooky","gora","goras","goregasm","gotohell","goy","goyim","greaseball","greaseballs","groe","groid","groids","grope","grostulation","group sex","gspot","gstring","gtfo","gub","gubba","gubbas","gubs","guido","guiena","guineas","guizi","gummer","guro","gwailo","gwailos","gweilo","gweilos","gyopo","gyopos","gyp","gyped","gypo","gypos","gypp","gypped","gyppie","gyppies","gyppo","gyppos","gyppy","gyppys","gypsys","h e l l","h o m","h00r","h0ar","h0m0","h0mo","h0r","h0re","h4x0r","hadji","hadjis","hairyback","hairybacks","haji","hajis","hajji","hajjis","half breed","half caste","halfbreed","halfcaste","hamas","hamflap","hand job","handjob","haole","haoles","hapa","hard core","hardcore","hardcoresex","hardon","harem","he11","headfuck","hebe","hebes","heeb","heebs","hell","hells","helvete","hentai","heroin","herp","herpes","herpy","heshe","hijacker","hijacking","hillbillies","hillbilly","hindoo","hiscock","hitler","hitlerism","hitlerist","hoar","hoare","hobag","hodgie","hoe","hoer","hoes","holestuffer","hom0","homey","homo","homobangers","homodumbshit","homoey","honger","honkers","honkey","honkeys","honkie","honkies","honky","hooch","hooker","hookers","hoor","hoore","hootch","hooter","hooters","hore","hori","horis","hork","horndawg","horndog","horney","horniest","horny","horseshit","hosejob","hoser","hot carl","hot chick","hotcarl","hotdamn","hotpussy","hotsex","hottotrot","how to kill","how to murder","howtokill","howtomurdep","huevon","huge fat","hugefat","hui","hummer","humped","humper","humpher","humphim","humpin","humping","hussy","hustler","hymen","hymie","hymies","iblowu","ike","ikes","ikey","ikeymo","ikeymos","ikwe","illegal","illegals","inbred","incest","indon","indons","injun","injuns","insest","intercourse","interracial","intheass","inthebuff","israels","j3rk0ff","jack off","jack-off","jackass","jackhole","jackoff","jackshit","jacktheripper","jail bait","jailbait","jap","japcrap","japie","japies","japs","jebus","jelly donut","jerk off","jerk","jerk-off","jerk0ff","jerked","jerkoff","jerries","jerry","jewboy","jewed","jewess","jiga","jigaboo","jigaboos","jigarooni","jigaroonis","jigg","jigga","jiggabo","jiggaboo","jiggabos","jiggas","jigger","jiggerboo","jiggers","jiggs","jiggy","jigs","jihad","jijjiboo","jijjiboos","jimfish","jisim","jism","jiss","jiz","jizim","jizin","jizjuice","jizm","jizn","jizz","jizzd","jizzed","jizzim","jizzin","jizzn","jizzum","jugg","juggs","jugs","jungle bunnies","jungle bunny","junglebunny","junkie","junky","kacap","kacapas","kacaps","kaffer","kaffir","kaffre","kafir","kanake","kanker","katsap","katsaps","kawk","khokhol","khokhols","kicking","kigger","kike","kikes","kimchis","kinbaku","kink","kinkster","kinky","kinkyJesus","kissass","kiunt","kkk","klan","klansman","klansmen","klanswoman","klanswomen","klootzak","knobbing","knobead","knobed","knobend","knobhead","knobjocky","knobjokey","knobz","knockers","knulle","kock","kondum","kondums","kooch","kooches","koon","kootch","krap","krappy","kraut","krauts","kuffar","kuk","kuksuger","kum","kumbubble","kumbullbe","kumer","kummer","kumming","kumquat","kums","kunilingus","kunnilingus","kunt","kunts","kuntz","kurac","kurwa","kushi","kushis","kusi","kwa","kwai lo","kwai los","kwif","kyke","kykes","kyopo","kyopos","kyrpa","l3i+ch","l3i\\+ch","l3itch","labia","lapdance","leather restraint","leather straight","leatherrestraint","lebos","lech","lemon party","lemonparty","leper","lesbain","lesbayn","lesbin","lesbo","lesbos","lez","lezbe","lezbefriends","lezbian","lezbians","lezbo","lezbos","lezz","lezzian","lezzie","lezzies","lezzo","lezzy","libido","licker","licking","lickme","lilniglet","limey","limpdick","limy","lingerie","lipshits","lipshitz","livesex","loadedgun","loin","loins","lolita","lovebone","lovegoo","lovegun","lovejuice","lovemaking","lovemuscle","lovepistol","loverocket","lowlife","lsd","lubejob","lubra","lucifer","luckycammeltoe","lugan","lugans","lust","lusting","lusty","lynch","m-fucking","m0f0","m0fo","m45terbate","ma5terb8","ma5terbate","mabuno","mabunos","macaca","macacas","mafugly","magicwand","mahbuno","mahbunos","make me come","makemecome","makemecum","male squirting","mamhoon","mams","manhater","manpaste","maricon","maricón","marijuana","masochist","masokist","massa","massterbait","masstrbait","masstrbate","mastabate","mastabater","master-bate","masterb8","masterbaiter","masterbat","masterbat3","masterbate","masterbates","masterbating","masterbation","masterbations","masterblaster","mastrabator","masturbat","masturbate","masturbating","masturbation","mattressprincess","mau mau","mau maus","maumau","maumaus","mcfagget","meatbeatter","meatrack","menage","merd","mgger","mggor","mibun","mick","mickeyfinn","mideast","mierda","milf","minge","minger","mo-fo","mockey","mockie","mocky","mof0","mofo","moky","molest","molestation","molester","molestor","moneyshot","mong","monkleigh","moolie","moon cricket","moon crickets","mooncricket","mooncrickets","mormon","moron","moskal","moskals","moslem","mosshead","motha fucker","motha fuker","motha fukkah","motha fukker","mothafuck","mothafucka","mothafuckas","mothafuckaz","mothafucked","mothafucker","mothafuckers","mothafuckin","mothafucking","mothafuckings","mothafucks","mother fucker","mother fukah","mother fuker","mother fukkah","mother fukker","mother-fucker","motherfuck","motherfucka","motherfucked","motherfucker","motherfuckers","motherfuckin","motherfucking","motherfuckings","motherfuckka","motherfucks","motherfvcker","motherlovebone","mothrfucker","mouliewop","mound of venus","moundofvenus","mr hands","mrhands","mtherfucker","mthrfuck","mthrfucker","mthrfucking","mtrfck","mtrfuck","mtrfucker","muff diver","muff","muffdive","muffdiver","muffdiving","muffindiver","mufflikcer","muffpuff","muie","mulatto","mulkku","muncher","mung","munging","munt","munter","muschi","mutha fucker","mutha fukah","mutha fuker","mutha fukkah","mutha fukker","muthafecker","muthafuckaz","muthafucker","muthafuckker","muther","mutherfucker","mutherfucking","muthrfucking","mzungu","mzungus","n1gga","n1gger","n1gr","nad","nads","naked","nambla","nappy","nastt","nasty","nastybitch","nastyho","nastyslut","nastywhore","nawashi","nazi","nazis","nazism","necked","necro","needthedick","negres","negress","negro","negroes","negroid","negros","neonazi","nepesaurio","nig nog","nig","niga","nigar","nigars","nigas","nigers","nigette","nigettes","nigg","nigg3r","nigg4h","nigga","niggah","niggahs","niggar","niggaracci","niggard","niggarded","niggarding","niggardliness","niggardlinesss","niggardly","niggards","niggars","niggas","niggaz","nigger","niggerhead","niggerhole","niggers","niggle","niggled","niggles","niggling","nigglings","niggor","niggress","niggresses","nigguh","nigguhs","niggur","niggurs","niglet","nignog","nigor","nigors","nigr","nigra","nigras","nigre","nigres","nigress","nigs","nigur","niiger","niigr","nimphomania","nimrod","ninny","nip","nipple","nipplering","nipples","nips","nittit","nlgger","nlggor","nob jokey","nob","nobhead","nobjocky","nobjokey","nofuckingway","nog","nookey","nookie","nooky","noonan","nooner","nsfw images","nsfw","nudger","nudie","nudies","numbnuts","nut sack","nutbutter","nutfucker","nutsack","nutten","nymph","nympho","nymphomania","o c k","octopussy","omorashi","one cup two girls","one guy one jar","one guy","one jar","ontherag","orafis","orally","orga","orgasim","orgasim;","orgasims","orgasm","orgasmic","orgasms","orgasum","orgies","orgy","oriface","orifice","orifiss","orospu","osama","ovum","ovums","p e n i s","p i s","p u s s y","p.u.s.s.y.","p0rn","packi","packie","packy","paddy","paedophile","paki","pakie","pakis","paky","palesimian","pancake face","pancake faces","panooch","pansies","pansy","panti","pantie","panties","panty","paska","pastie","pasty","payo","pcp","pearlnecklace","pecker","peckerhead","peckerwood","pedo","pedobear","pedophile","pedophilia","pedophiliac","peeenus","peeenusss","peehole","peenus","peepee","peepshow","peepshpw","pegging","peinus","pen1s","penas","pendejo","pendy","penetrate","penetration","peni5","penial","penile","penis","penis-breath","penises","penisfucker","penisland","penislick","penislicker","penispuffer","penthouse","penus","penuus","perse","perv","perversion","peyote","phalli","phallic","phone sex","phonesex","phuc","phuck","phuk","phuked","phuker","phuking","phukked","phukker","phukking","phuks","phungky","phuq","pi55","picaninny","piccaninny","picka","pickaninnies","pickaninny","piece of shit","pieceofshit","piefke","piefkes","pierdol","pigfucker","piker","pikey","piky","pillowbiter","pillu","pimmel","pimp","pimped","pimper","pimpis","pimpjuic","pimpjuice","pimpsimp","pindick","pinko","pis","pises","pisin","pising","pisof","piss pig","piss","piss-off","pissed","pisser","pissers","pisses","pissflap","pissflaps","pisshead","pissin","pissing","pissoff","pisspig","pistol","pizda","playboy","playgirl","pleasure chest","pleasurechest","pocha","pochas","pocho","pochos","pocketpool","pohm","pohms","polac","polack","polacks","polak","pole smoker","polesmoker","pollock","pollocks","pommie grant","pommie grants","pommy","ponyplay","poof","poon","poonani","poonany","poontang","poontsee","poop chute","poopchute","pooper","pooperscooper","pooping","poorwhitetrash","popimp","porch monkey","porch monkies","porchmonkey","porn","pornflick","pornking","porno","pornography","pornos","pornprincess","pound town","poundtown","pplicker","pr0n","pr1c","pr1ck","pr1k","prairie nigger","prairie niggers","premature","preteen","pric","prickhead","pricks","prig","prince albert piercing","pron","prostitute","pthc","pu55i","pu55y","pube","pubes","pubic","pubiclice","pubis","pud","pudboy","pudd","puddboy","puke","pula","pule","punani","punanny","punany","punkass","punky","punta","puntang","purinapricness","pusies","puss","pusse","pussee","pussi","pussie","pussies","pussy","pussycat","pussydestroyer","pussyeater","pussyfart","pussyfucker","pussylicker","pussylicking","pussylips","pussylover","pussypalace","pussypounder","pussys","pusy","puta","puto","puuke","puuker","qahbeh","quashie","queaf","queef","queerhole","queero","queers","queerz","quickie","quicky","quiff","quim","qweers","qweerz","qweir","r-tard","r-tards","r5e","ra8s","raghead","ragheads","rape","raped","raper","raping","rapist","rautenberg","rearend","rearentry","recktum","rectal","rectum","rectus","redleg","redlegs","redlight","redneck","rednecks","redskin","redskins","reefer","reestie","reetard","reich","renob","rentafuck","rere","retard","retarded","retards","retardz","reverse cowgirl","reversecowgirl","rigger","rimjaw","rimjob","rimming","ritard","rosebuds","rosy palm and her 5 sisters","rosy palm","rosypalm","rosypalmandher5sisters","rosypalmandherefivesisters","round eyes","roundeye","rtard","rtards","rumprammer","ruski","russki","russkie","rusty trombone","rustytrombone","s h i t","s hit","s&m","s-h-1-t","s-h-i-t","s-o-b","s.h.i.t.","s.o.b.","s0b","s_h_i_t","sac","sadis","sadism","sadist","sadom","sambo","sambos","samckdaddy","sanchez","sand nigger","sand niggers","sandm","sandnigger","santorum","sausagequeen","scag","scallywag","scank","scantily","scat","schaffer","scheiss","schizo","schlampe","schlong","schmuck","schvartse","schvartsen","schwartze","schwartzen","scissoring","screwed","screwing","screwyou","scroat","scrog","scrote","scrotum","scrud","seduce","semen","seppo","seppos","septics","sex","sexcam","sexed","sexfarm","sexhound","sexhouse","sexi","sexing","sexkitten","sexo","sexpot","sexslave","sextogo","sextoy","sextoys","sexual","sexually","sexwhore","sexx","sexxi","sexxx","sexxxi","sexxxy","sexxy","sexy","sexymoma","sexyslim","sh!+","sh!t","sh1t","sh1ter","sh1ts","sh1tter","sh1tz","shag","shagger","shaggin","shagging","shamedame","sharmuta","sharmute","shat","shav","shaved beaver","shaved pussy","shavedbeaver","shavedpussy","shawtypimp","sheeney","shemale","shhit","shi+","shibari","shibary","shinola","shipal","shit ass","shit","shit-ass","shit-bag","shit-bagger","shit-brain","shit-breath","shit-cunt","shit-dick","shit-eating","shit-face","shit-faced","shit-fit","shit-head","shit-heel","shit-hole","shit-house","shit-load","shit-pot","shit-spitter","shit-stain","shitass","shitbag","shitbagger","shitblimp","shitbrain","shitbreath","shitcan","shitcunt","shitdick","shite","shiteater","shiteating","shited","shitey","shitface","shitfaced","shitfit","shitforbrains","shitfuck","shitfucker","shitfull","shithapens","shithappens","shithead","shitheel","shithole","shithouse","shiting","shitings","shitlist","shitload","shitola","shitoutofluck","shitpot","shits","shitspitter","shitstain","shitt","shitted","shitter","shitters","shittiest","shitting","shittings","shitty","shity","shitz","shiz","shiznit","shortfuck","shota","shrimping","shylock","shylocks","shyt","shyte","shytty","shyty","simp","sissy","sixsixsix","sixtynine","sixtyniner","skag","skanck","skank","skankbitch","skankee","skankey","skankfuck","skanks","skankwhore","skanky","skankybitch","skankywhore","skeet","skinflute","skribz","skullfuck","skum","skumbag","skurwysyn","skwa","skwe","slag","slanteye","slanty","slapper","sleezeball","slideitin","slimeball","slimebucket","slopehead","slopeheads","sloper","slopers","slopes","slopey","slopeys","slopies","slopy","slut","slutbag","slutbucket","slutdumper","slutkiss","sluts","slutt","slutting","slutty","slutwear","slutwhore","slutz","smack","smackthemonkey","smeg","smegma","smoker","smut","smutty","snatchpatch","snigger","sniggered","sniggering","sniggers","snowback","snowballing","snownigger","snuff","socksucker","sodom","sodomise","sodomite","sodomize","sodomy","son of a bitch","son of a whore","son-of-a-bitch","son-of-a-whore","sonofabitch","sonofbitch","sooties","sooty","souse","soused","soyboy","spac","spade","spades","spaghettibender","spaghettinigger","spank","spankthemonkey","spastic","spearchucker","spearchuckers","sperm","spermacide","spermbag","spermhearder","spermherder","sphencter","spic","spick","spicks","spics","spierdalaj","spig","spigotty","spik","spiks","spitter","splittail","splooge","spludge","spooge","spread legs","spreadeagle","spunk","spunky","sqeh","squa","squarehead","squareheads","squaw","squinty","squirting","stagg","steamy","stfu","stiffy","stoned","stoner","strap on","strapon","strappado","stringer","strip club","stripclub","stroke","stroking","stuinties","stupidfuck","stupidfucker","style doggy","suckdick","sucked","sucker","sucking","suckme","suckmyass","suckmydick","suckmytit","suckoff","sucks","suicide girl","suicide girls","suicidegirl","suicidegirls","suka","sultrywoman","sultrywomen","sumofabiatch","swallower","swalow","swamp guinea","swamp guineas","swastika","syphilis","t i t","t i ts","t1t","t1tt1e5","t1tties","taboo","tacohead","tacoheads","taff","take off your","tar babies","tar baby","tarbaby","tard","taste my","tastemy","tawdry","tea bagging","teabagging","teat","teets","teez","terd","terror","terrorist","teste","testee","testes","testical","testicle","testicles","testis","thicklip","thicklips","thirdeye","thirdleg","threesome","threeway","throating","thumbzilla","thundercunt","tied up","tig ol bitties","tig old bitties","tight white","timber nigger","timber niggers","timbernigger","tinkle","tit","titbitnipply","titfuck","titfucker","titfuckin","titi","titjob","titlicker","titlover","tits","titt","tittie","tittie5","tittiefucker","titties","tittis","titty","tittyfuck","tittyfucker","tittys","tittywank","titwank","tity","to murder","toke","tongethruster","tongue in a","tongueina","tonguethrust","tonguetramp","toots","topless","tortur","torture","tosser","towel head","towel heads","towelhead","trailertrash","tramp","trannie","tranny","transsexual","transvestite","trashy","tribadism","triplex","trisexual","trois","trojan","trots","tub girl","tubgirl","tuckahoe","tunneloflove","turd burgler","turnon","tush","tushy","tw4t","twat","twathead","twatlips","twats","twatty","twatwaffle","twink","twinkie","two girls one cup","twobitwhore","twunt","twunter","udge packer","ukrop","unclefucker","undressing","unfuckable","upskirt","uptheass","upthebutt","urethra play","urethraplay","urophilia","usama","ussys","uzi","v a g i n a","v14gra","v1gra","v4gra","va-j-j","va1jina","vag","vag1na","vagiina","vaj1na","vajina","valium","venus mound","vgra","vibr","vibrater","vibrator","vigra","violet wand","virgin","virginbreaker","vittu","vixen","vjayjay","vodka","vomit","vorarephilia","voyeurweb","voyuer","vullva","vulva","w00se","w0p","wab","wad","wang","wank","wanker","wanking","wanky","waysted","wazoo","weenie","weewee","weiner","welcher","wench","wet dream","wetb","wetback","wetbacks","wetdream","wetspot","wh00r","wh0re","wh0reface","whacker","whash","whigger","whiggers","whiskeydick","whiskydick","whit","white power","white trash","whitenigger","whitepower","whites","whitetrash","whitey","whiteys","whities","whoar","whop","whoralicious","whore","whorealicious","whorebag","whored","whoreface","whorefucker","whorehopper","whorehouse","whores","whoring","wichser","wigga","wiggas","wigger","wiggers","willie","willies","williewanker","willy","wn","wog","wogs","woose","wop","worldsex","wrapping men","wrinkled starfish","wtf","wuss","wuzzie","x-rated","x-rated2g1c","xkwe","xrated","xtc","xx","xxx","xxxxxx","yank","yaoi","yarpie","yarpies","yeasty","yed","yellow showers","yellowman","yellowshowers","yid","yids","yiffy","yobbo","yourboobs","yourpenis","yourtits","yury","zabourah","zigabo","zigabos","zipperhead","zipperheads","zoophile","zoophilia","🖕"];const xa=va(Aa),La={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},Ia="can-duplicate-to";var U=(s=>(s.CanPlay="can-play",s.CanMove="can-move",s.CanSpin="can-spin",s.CanGrow="can-grow",s.CanToggle="can-toggle",s.CanDuplicate="can-duplicate",s.CanPost="can-post",s))(U||{});function ja(s){return s.id}function ii(s){return document.getElementById(s)}const ri=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
|
|
1
|
+
(function(S,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(S=typeof globalThis<"u"?globalThis:S||self,k(S.playhtml={}))})(this,function(S){var bt,dr;"use strict";var Kl=Object.defineProperty;var zl=(S,k,I)=>k in S?Kl(S,k,{enumerable:!0,configurable:!0,writable:!0,value:I}):S[k]=I;var y=(S,k,I)=>(zl(S,typeof k!="symbol"?k+"":k,I),I),fr=(S,k,I)=>{if(!k.has(S))throw TypeError("Cannot "+I)};var Ce=(S,k,I)=>(fr(S,k,"read from private field"),I?I.call(S):k.get(S)),gr=(S,k,I)=>{if(k.has(S))throw TypeError("Cannot add the same private member more than once");k instanceof WeakSet?k.add(S):k.set(S,I)},pr=(S,k,I,xt)=>(fr(S,k,"write to private field"),xt?xt.call(S,I):k.set(S,I),I);var k=1e6,I="y-pk-batch",xt=!1,wr=(n,t)=>{if(n.byteLength<=k){t(n);return}xt||(console.warn("[y-partykit]","The Y.js update size exceeds 1MB, which is the maximum size for an individual update. The update will be split into chunks. This is an experimental feature.",`Message size: ${(n.byteLength/1e3/1e3).toFixed(1)}MB`),xt=!0);const e=(Date.now()+Math.random()).toString(36).substring(10),s=Math.ceil(n.byteLength/k);t(An({id:e,type:"start",size:n.byteLength,count:s}));let r=0,i=0;for(let o=0;o<s;o++){const l=n.slice(k*o,k*(o+1));t(l),i+=1,r+=l.byteLength}t(An({id:e,type:"end",size:r,count:i}))};function An(n){return`${I}#${JSON.stringify(n)}`}const N=()=>new Map,Ae=n=>{const t=N();return n.forEach((e,s)=>{t.set(s,e)}),t},Y=(n,t,e)=>{let s=n.get(t);return s===void 0&&n.set(t,s=e()),s},mr=(n,t)=>{const e=[];for(const[s,r]of n)e.push(t(r,s));return e},yr=(n,t)=>{for(const[e,s]of n)if(t(s,e))return!0;return!1},ot=()=>new Set,Le=n=>n[n.length-1],br=(n,t)=>{for(let e=0;e<t.length;e++)n.push(t[e])},tt=Array.from,kr=Array.isArray;class Zt{constructor(){this._observers=N()}on(t,e){Y(this._observers,t,ot).add(e)}once(t,e){const s=(...r)=>{this.off(t,s),e(...r)};this.on(t,s)}off(t,e){const s=this._observers.get(t);s!==void 0&&(s.delete(e),s.size===0&&this._observers.delete(t))}emit(t,e){return tt((this._observers.get(t)||N()).values()).forEach(s=>s(...e))}destroy(){this._observers=N()}}const X=Math.floor,Qt=Math.abs,Ie=(n,t)=>n<t?n:t,lt=(n,t)=>n>t?n:t,_r=Math.pow,Ln=n=>n!==0?n<0:1/n<0,Sr=String.fromCharCode,Dr=n=>n.toLowerCase(),Er=/^\s*/g,Cr=n=>n.replace(Er,""),Ar=/([A-Z])/g,In=(n,t)=>Cr(n.replace(Ar,e=>`${t}${Dr(e)}`)),Lr=n=>{const t=unescape(encodeURIComponent(n)),e=t.length,s=new Uint8Array(e);for(let r=0;r<e;r++)s[r]=t.codePointAt(r);return s},Tt=typeof TextEncoder<"u"?new TextEncoder:null,Ir=Tt?n=>Tt.encode(n):Lr;let Ut=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ut&&Ut.decode(new Uint8Array).length===1&&(Ut=null);const vn=n=>n===void 0?null:n;class vr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}let Mn=new vr,ve=!0;try{typeof localStorage<"u"&&(Mn=localStorage,ve=!1)}catch{}const xn=Mn,Mr=n=>ve||addEventListener("storage",n),xr=n=>ve||removeEventListener("storage",n),Tr=Object.assign,Ur=Object.keys,Or=(n,t)=>{for(const e in n)t(n[e],e)},Rr=(n,t)=>{const e=[];for(const s in n)e.push(t(n[s],s));return e},te=n=>Ur(n).length,Br=n=>{for(const t in n)return!1;return!0},Nr=(n,t)=>{for(const e in n)if(!t(n[e],e))return!1;return!0},Tn=(n,t)=>Object.prototype.hasOwnProperty.call(n,t),Fr=(n,t)=>n===t||te(n)===te(t)&&Nr(n,(e,s)=>(e!==void 0||Tn(t,s))&&t[s]===e),Me=(n,t,e=0)=>{try{for(;e<n.length;e++)n[e](...t)}finally{e<n.length&&Me(n,t,e+1)}},Vr=n=>n,Hr=(n,t)=>n===t,Ot=(n,t)=>{if(n==null||t==null)return Hr(n,t);if(n.constructor!==t.constructor)return!1;if(n===t)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),t=new Uint8Array(t);case Uint8Array:{if(n.byteLength!==t.byteLength)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;break}case Set:{if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;break}case Map:{if(n.size!==t.size)return!1;for(const e of n.keys())if(!t.has(e)||!Ot(n.get(e),t.get(e)))return!1;break}case Object:if(te(n)!==te(t))return!1;for(const e in n)if(!Tn(n,e)||!Ot(n[e],t[e]))return!1;break;case Array:if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(!Ot(n[e],t[e]))return!1;break;default:return!1}return!0},$r=(n,t)=>t.includes(n),kt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Un=typeof window<"u"&&typeof document<"u"&&!kt;let F;const jr=()=>{if(F===void 0)if(kt){F=N();const n=process.argv;let t=null;for(let e=0;e<n.length;e++){const s=n[e];s[0]==="-"?(t!==null&&F.set(t,""),t=s):t!==null&&(F.set(t,s),t=null)}t!==null&&F.set(t,"")}else typeof location=="object"?(F=N(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[t,e]=n.split("=");F.set(`--${In(t,"-")}`,e),F.set(`-${In(t,"-")}`,e)}})):F=N();return F},xe=n=>jr().has(n),Te=n=>vn(kt?process.env[n.toUpperCase()]:xn.getItem(n));(n=>xe("--"+n)||Te(n)!==null)("production");const On=kt&&$r(process.env.FORCE_COLOR,["true","1","2"]),Kr=!xe("no-colors")&&(!kt||process.stdout.isTTY||On)&&(!kt||xe("color")||On||Te("COLORTERM")!==null||(Te("TERM")||"").includes("color")),Rn=1,Bn=2,Ue=4,Oe=8,Rt=32,J=64,O=128,ee=31,Re=63,ct=127,zr=2147483647,Nn=Number.MAX_SAFE_INTEGER,Yr=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&X(n)===n),W=n=>new Error(n),V=()=>{throw W("Method unimplemented")},H=()=>{throw W("Unexpected case")},Fn=W("Unexpected end of array"),Vn=W("Integer out of Range");class ne{constructor(t){this.arr=t,this.pos=0}}const et=n=>new ne(n),Xr=n=>n.pos!==n.arr.length,Jr=(n,t)=>{const e=Ve(n.arr.buffer,n.pos+n.arr.byteOffset,t);return n.pos+=t,e},T=n=>Jr(n,w(n)),_t=n=>n.arr[n.pos++],w=n=>{let t=0,e=1;const s=n.arr.length;for(;n.pos<s;){const r=n.arr[n.pos++];if(t=t+(r&ct)*e,e*=128,r<O)return t;if(t>Nn)throw Vn}throw Fn},Be=n=>{let t=n.arr[n.pos++],e=t&Re,s=64;const r=(t&J)>0?-1:1;if(!(t&O))return r*e;const i=n.arr.length;for(;n.pos<i;){if(t=n.arr[n.pos++],e=e+(t&ct)*s,s*=128,t<O)return r*e;if(e>Nn)throw Vn}throw Fn},nt=Ut?n=>Ut.decode(T(n)):n=>{let t=w(n);if(t===0)return"";{let e=String.fromCodePoint(_t(n));if(--t<100)for(;t--;)e+=String.fromCodePoint(_t(n));else for(;t>0;){const s=t<1e4?t:1e4,r=n.arr.subarray(n.pos,n.pos+s);n.pos+=s,e+=String.fromCodePoint.apply(null,r),t-=s}return decodeURIComponent(escape(e))}},Ne=(n,t)=>{const e=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,t);return n.pos+=t,e},Wr=[n=>{},n=>null,Be,n=>Ne(n,4).getFloat32(0,!1),n=>Ne(n,8).getFloat64(0,!1),n=>Ne(n,8).getBigInt64(0,!1),n=>!1,n=>!0,nt,n=>{const t=w(n),e={};for(let s=0;s<t;s++){const r=nt(n);e[r]=Bt(n)}return e},n=>{const t=w(n),e=[];for(let s=0;s<t;s++)e.push(Bt(n));return e},T],Bt=n=>Wr[127-_t(n)](n);class Hn extends ne{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Xr(this)?this.count=w(this)+1:this.count=-1),this.count--,this.s}}class se extends ne{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Be(this);const t=Ln(this.s);this.count=1,t&&(this.s=-this.s,this.count=w(this)+2)}return this.count--,this.s}}class Fe extends ne{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=Be(this),e=t&1;this.diff=X(t/2),this.count=1,e&&(this.count=w(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Gr{constructor(t){this.decoder=new se(t),this.str=nt(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}const $n=n=>new Uint8Array(n),Ve=(n,t,e)=>new Uint8Array(n,t,e),Pr=n=>new Uint8Array(n),qr=n=>{let t="";for(let e=0;e<n.byteLength;e++)t+=Sr(n[e]);return btoa(t)},Zr=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),Qr=n=>{const t=atob(n),e=$n(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e},ti=n=>{const t=Buffer.from(n,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)},ei=Un?qr:Zr,ni=Un?Qr:ti,si=n=>{const t=$n(n.byteLength);return t.set(n),t};class Nt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const U=()=>new Nt,He=n=>{let t=n.cpos;for(let e=0;e<n.bufs.length;e++)t+=n.bufs[e].length;return t},D=n=>{const t=new Uint8Array(He(n));let e=0;for(let s=0;s<n.bufs.length;s++){const r=n.bufs[s];t.set(r,e),e+=r.length}return t.set(Ve(n.cbuf.buffer,0,n.cpos),e),t},ri=(n,t)=>{const e=n.cbuf.length;e-n.cpos<t&&(n.bufs.push(Ve(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(lt(e,t)*2),n.cpos=0)},v=(n,t)=>{const e=n.cbuf.length;n.cpos===e&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(e*2),n.cpos=0),n.cbuf[n.cpos++]=t},$e=v,p=(n,t)=>{for(;t>ct;)v(n,O|ct&t),t=X(t/128);v(n,ct&t)},je=(n,t)=>{const e=Ln(t);for(e&&(t=-t),v(n,(t>Re?O:0)|(e?J:0)|Re&t),t=X(t/64);t>0;)v(n,(t>ct?O:0)|ct&t),t=X(t/128)},Ke=new Uint8Array(3e4),ii=Ke.length/3,oi=(n,t)=>{if(t.length<ii){const e=Tt.encodeInto(t,Ke).written||0;p(n,e);for(let s=0;s<e;s++)v(n,Ke[s])}else C(n,Ir(t))},li=(n,t)=>{const e=unescape(encodeURIComponent(t)),s=e.length;p(n,s);for(let r=0;r<s;r++)v(n,e.codePointAt(r))},at=Tt&&Tt.encodeInto?oi:li,re=(n,t)=>{const e=n.cbuf.length,s=n.cpos,r=Ie(e-s,t.length),i=t.length-r;n.cbuf.set(t.subarray(0,r),s),n.cpos+=r,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(lt(e*2,i)),n.cbuf.set(t.subarray(r)),n.cpos=i)},C=(n,t)=>{p(n,t.byteLength),re(n,t)},ze=(n,t)=>{ri(n,t);const e=new DataView(n.cbuf.buffer,n.cpos,t);return n.cpos+=t,e},ci=(n,t)=>ze(n,4).setFloat32(0,t,!1),ai=(n,t)=>ze(n,8).setFloat64(0,t,!1),hi=(n,t)=>ze(n,8).setBigInt64(0,t,!1),jn=new DataView(new ArrayBuffer(4)),ui=n=>(jn.setFloat32(0,n),jn.getFloat32(0)===n),Ft=(n,t)=>{switch(typeof t){case"string":v(n,119),at(n,t);break;case"number":Yr(t)&&Qt(t)<=zr?(v(n,125),je(n,t)):ui(t)?(v(n,124),ci(n,t)):(v(n,123),ai(n,t));break;case"bigint":v(n,122),hi(n,t);break;case"object":if(t===null)v(n,126);else if(kr(t)){v(n,117),p(n,t.length);for(let e=0;e<t.length;e++)Ft(n,t[e])}else if(t instanceof Uint8Array)v(n,116),C(n,t);else{v(n,118);const e=Object.keys(t);p(n,e.length);for(let s=0;s<e.length;s++){const r=e[s];at(n,r),Ft(n,t[r])}}break;case"boolean":v(n,t?120:121);break;default:v(n,127)}};class Kn extends Nt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&p(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const zn=n=>{n.count>0&&(je(n.encoder,n.count===1?n.s:-n.s),n.count>1&&p(n.encoder,n.count-2))};class ie{constructor(){this.encoder=new Nt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(zn(this),this.count=1,this.s=t)}toUint8Array(){return zn(this),D(this.encoder)}}const Yn=n=>{if(n.count>0){const t=n.diff*2+(n.count===1?0:1);je(n.encoder,t),n.count>1&&p(n.encoder,n.count-2)}};class Ye{constructor(){this.encoder=new Nt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Yn(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Yn(this),D(this.encoder)}}class di{constructor(){this.sarr=[],this.s="",this.lensE=new ie}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new Nt;return this.sarr.push(this.s),this.s="",at(t,this.sarr.join("")),re(t,this.lensE.toUint8Array()),D(t)}}const fi=crypto.getRandomValues.bind(crypto),Xn=()=>fi(new Uint32Array(1))[0],gi=[1e7]+-1e3+-4e3+-8e3+-1e11,pi=()=>gi.replace(/[018]/g,n=>(n^Xn()&15>>n/4).toString(16)),ht=Date.now,St=n=>new Promise(n);Promise.all.bind(Promise);class wi{constructor(t,e){this.left=t,this.right=e}}const G=(n,t)=>new wi(n,t);typeof DOMParser<"u"&&new DOMParser;const mi=n=>mr(n,(t,e)=>`${e}:${t};`).join(""),P=Symbol,Jn=P(),Wn=P(),yi=P(),bi=P(),ki=P(),Gn=P(),_i=P(),Pn=P(),Si=P(),Di=n=>{const t=[];let e=0;for(;e<n.length;e++){const s=n[e];s.constructor===String||s.constructor===Number||s.constructor===Object&&t.push(JSON.stringify(s))}return t},Ei={[Jn]:G("font-weight","bold"),[Wn]:G("font-weight","normal"),[yi]:G("color","blue"),[ki]:G("color","green"),[bi]:G("color","grey"),[Gn]:G("color","red"),[_i]:G("color","purple"),[Pn]:G("color","orange"),[Si]:G("color","black")},Ci=Kr?n=>{const t=[],e=[],s=N();let r=[],i=0;for(;i<n.length;i++){const o=n[i],l=Ei[o];if(l!==void 0)s.set(l.left,l.right);else if(o.constructor===String||o.constructor===Number){const c=mi(s);i>0||c.length>0?(t.push("%c"+o),e.push(c)):t.push(o)}else break}for(i>0&&(r=e,r.unshift(t.join("")));i<n.length;i++){const o=n[i];o instanceof Symbol||r.push(o)}return r}:Di,Ai=(...n)=>{console.log(...Ci(n)),Li.forEach(t=>t.print(n))},Li=ot(),qn=n=>({[Symbol.iterator](){return this},next:n}),Ii=(n,t)=>qn(()=>{let e;do e=n.next();while(!e.done&&!t(e.value));return e}),Xe=(n,t)=>qn(()=>{const{done:e,value:s}=n.next();return{done:e,value:e?void 0:t(s)}});class Je{constructor(t,e){this.clock=t,this.len=e}}class Vt{constructor(){this.clients=new Map}}const Zn=(n,t,e)=>t.clients.forEach((s,r)=>{const i=n.doc.store.clients.get(r);for(let o=0;o<s.length;o++){const l=s[o];ms(n,i,l.clock,l.len,e)}}),vi=(n,t)=>{let e=0,s=n.length-1;for(;e<=s;){const r=X((e+s)/2),i=n[r],o=i.clock;if(o<=t){if(t<o+i.len)return r;e=r+1}else s=r-1}return null},Qn=(n,t)=>{const e=n.clients.get(t.client);return e!==void 0&&vi(e,t.clock)!==null},We=n=>{n.clients.forEach(t=>{t.sort((r,i)=>r.clock-i.clock);let e,s;for(e=1,s=1;e<t.length;e++){const r=t[s-1],i=t[e];r.clock+r.len>=i.clock?r.len=lt(r.len,i.clock+i.len-r.clock):(s<e&&(t[s]=i),s++)}t.length=s})},Mi=n=>{const t=new Vt;for(let e=0;e<n.length;e++)n[e].clients.forEach((s,r)=>{if(!t.clients.has(r)){const i=s.slice();for(let o=e+1;o<n.length;o++)br(i,n[o].clients.get(r)||[]);t.clients.set(r,i)}});return We(t),t},oe=(n,t,e,s)=>{Y(n.clients,t,()=>[]).push(new Je(e,s))},xi=()=>new Vt,Ti=n=>{const t=xi();return n.clients.forEach((e,s)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(o.deleted){const l=o.id.clock;let c=o.length;if(i+1<e.length)for(let a=e[i+1];i+1<e.length&&a.deleted;a=e[++i+1])c+=a.length;r.push(new Je(l,c))}}r.length>0&&t.clients.set(s,r)}),t},Dt=(n,t)=>{p(n.restEncoder,t.clients.size),tt(t.clients.entries()).sort((e,s)=>s[0]-e[0]).forEach(([e,s])=>{n.resetDsCurVal(),p(n.restEncoder,e);const r=s.length;p(n.restEncoder,r);for(let i=0;i<r;i++){const o=s[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Ge=n=>{const t=new Vt,e=w(n.restDecoder);for(let s=0;s<e;s++){n.resetDsCurVal();const r=w(n.restDecoder),i=w(n.restDecoder);if(i>0){const o=Y(t.clients,r,()=>[]);for(let l=0;l<i;l++)o.push(new Je(n.readDsClock(),n.readDsLen()))}}return t},ts=(n,t,e)=>{const s=new Vt,r=w(n.restDecoder);for(let i=0;i<r;i++){n.resetDsCurVal();const o=w(n.restDecoder),l=w(n.restDecoder),c=e.clients.get(o)||[],a=M(e,o);for(let h=0;h<l;h++){const d=n.readDsClock(),u=d+n.readDsLen();if(d<a){a<u&&oe(s,o,a,u-a);let f=$(c,d),g=c[f];for(!g.deleted&&g.id.clock<d&&(c.splice(f+1,0,_e(t,g,d-g.id.clock)),f++);f<c.length&&(g=c[f++],g.id.clock<u);)g.deleted||(u<g.id.clock+g.length&&c.splice(f,0,_e(t,g,u-g.id.clock)),g.delete(t))}else oe(s,o,d,u-d)}}if(s.clients.size>0){const i=new dt;return p(i.restEncoder,0),Dt(i,s),i.toUint8Array()}return null},es=Xn;class ut extends Zt{constructor({guid:t=pi(),collectionid:e=null,gc:s=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=s,this.gcFilter=r,this.clientID=es(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new gs,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=St(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const c=()=>St(a=>{const h=d=>{(d===void 0||d===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isLoaded||this.emit("load",[])}),this.whenSynced=c()}load(){const t=this._item;t!==null&&!this.shouldLoad&&_(t.parent.doc,e=>{e.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,e=null){return _(this,t,e)}get(t,e=x){const s=Y(this.share,t,()=>{const i=new e;return i._integrate(this,null),i}),r=s.constructor;if(e!==x&&r!==e)if(r===x){const i=new e;i._map=s._map,s._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=s._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=s._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return s}getArray(t=""){return this.get(t,At)}getText(t=""){return this.get(t,It)}getMap(t=""){return this.get(t,ft)}getXmlFragment(t=""){return this.get(t,gt)}toJSON(){const t={};return this.share.forEach((e,s)=>{t[s]=e.toJSON()}),t}destroy(){tt(this.subdocs).forEach(e=>e.destroy());const t=this._item;if(t!==null){this._item=null;const e=t.content;e.doc=new ut({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,_(t.parent.doc,s=>{const r=e.doc;t.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(t,e){super.on(t,e)}off(t,e){super.off(t,e)}}class ns{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return w(this.restDecoder)}readDsLen(){return w(this.restDecoder)}}class ss extends ns{readLeftID(){return b(w(this.restDecoder),w(this.restDecoder))}readRightID(){return b(w(this.restDecoder),w(this.restDecoder))}readClient(){return w(this.restDecoder)}readInfo(){return _t(this.restDecoder)}readString(){return nt(this.restDecoder)}readParentInfo(){return w(this.restDecoder)===1}readTypeRef(){return w(this.restDecoder)}readLen(){return w(this.restDecoder)}readAny(){return Bt(this.restDecoder)}readBuf(){return si(T(this.restDecoder))}readJSON(){return JSON.parse(nt(this.restDecoder))}readKey(){return nt(this.restDecoder)}}class Ui{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=w(this.restDecoder),this.dsCurrVal}readDsLen(){const t=w(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class Et extends Ui{constructor(t){super(t),this.keys=[],w(t),this.keyClockDecoder=new Fe(T(t)),this.clientDecoder=new se(T(t)),this.leftClockDecoder=new Fe(T(t)),this.rightClockDecoder=new Fe(T(t)),this.infoDecoder=new Hn(T(t),_t),this.stringDecoder=new Gr(T(t)),this.parentInfoDecoder=new Hn(T(t),_t),this.typeRefDecoder=new se(T(t)),this.lenDecoder=new se(T(t))}readLeftID(){return new Ct(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ct(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 Bt(this.restDecoder)}readBuf(){return T(this.restDecoder)}readJSON(){return Bt(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const e=this.stringDecoder.read();return this.keys.push(e),e}}}class rs{constructor(){this.restEncoder=U()}toUint8Array(){return D(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){p(this.restEncoder,t)}writeDsLen(t){p(this.restEncoder,t)}}class Ht extends rs{writeLeftID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeRightID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeClient(t){p(this.restEncoder,t)}writeInfo(t){$e(this.restEncoder,t)}writeString(t){at(this.restEncoder,t)}writeParentInfo(t){p(this.restEncoder,t?1:0)}writeTypeRef(t){p(this.restEncoder,t)}writeLen(t){p(this.restEncoder,t)}writeAny(t){Ft(this.restEncoder,t)}writeBuf(t){C(this.restEncoder,t)}writeJSON(t){at(this.restEncoder,JSON.stringify(t))}writeKey(t){at(this.restEncoder,t)}}class is{constructor(){this.restEncoder=U(),this.dsCurrVal=0}toUint8Array(){return D(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,p(this.restEncoder,e)}writeDsLen(t){t===0&&H(),p(this.restEncoder,t-1),this.dsCurrVal+=t}}class dt extends is{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ye,this.clientEncoder=new ie,this.leftClockEncoder=new Ye,this.rightClockEncoder=new Ye,this.infoEncoder=new Kn($e),this.stringEncoder=new di,this.parentInfoEncoder=new Kn($e),this.typeRefEncoder=new ie,this.lenEncoder=new ie}toUint8Array(){const t=U();return p(t,0),C(t,this.keyClockEncoder.toUint8Array()),C(t,this.clientEncoder.toUint8Array()),C(t,this.leftClockEncoder.toUint8Array()),C(t,this.rightClockEncoder.toUint8Array()),C(t,D(this.infoEncoder)),C(t,this.stringEncoder.toUint8Array()),C(t,D(this.parentInfoEncoder)),C(t,this.typeRefEncoder.toUint8Array()),C(t,this.lenEncoder.toUint8Array()),re(t,D(this.restEncoder)),D(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){Ft(this.restEncoder,t)}writeBuf(t){C(this.restEncoder,t)}writeJSON(t){Ft(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);e===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}}const Oi=(n,t,e,s)=>{s=lt(s,t[0].id.clock);const r=$(t,s);p(n.restEncoder,t.length-r),n.writeClient(e),p(n.restEncoder,s);const i=t[r];i.write(n,s-i.id.clock);for(let o=r+1;o<t.length;o++)t[o].write(n,0)},Pe=(n,t,e)=>{const s=new Map;e.forEach((r,i)=>{M(t,i)>r&&s.set(i,r)}),ce(t).forEach((r,i)=>{e.has(i)||s.set(i,0)}),p(n.restEncoder,s.size),tt(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{Oi(n,t.clients.get(r),r,i)})},Ri=(n,t)=>{const e=N(),s=w(n.restDecoder);for(let r=0;r<s;r++){const i=w(n.restDecoder),o=new Array(i),l=n.readClient();let c=w(n.restDecoder);e.set(l,{i:0,refs:o});for(let a=0;a<i;a++){const h=n.readInfo();switch(ee&h){case 0:{const d=n.readLen();o[a]=new R(b(l,c),d),c+=d;break}case 10:{const d=w(n.restDecoder);o[a]=new B(b(l,c),d),c+=d;break}default:{const d=(h&(J|O))===0,u=new L(b(l,c),null,(h&O)===O?n.readLeftID():null,null,(h&J)===J?n.readRightID():null,d?n.readParentInfo()?t.get(n.readString()):n.readLeftID():null,d&&(h&Rt)===Rt?n.readString():null,js(n,h));o[a]=u,c+=u.length}}}}return e},Bi=(n,t,e)=>{const s=[];let r=tt(e.keys()).sort((f,g)=>f-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let f=e.get(r[r.length-1]);for(;f.refs.length===f.i;)if(r.pop(),r.length>0)f=e.get(r[r.length-1]);else return null;return f};let o=i();if(o===null&&s.length===0)return null;const l=new gs,c=new Map,a=(f,g)=>{const m=c.get(f);(m==null||m>g)&&c.set(f,g)};let h=o.refs[o.i++];const d=new Map,u=()=>{for(const f of s){const g=f.id.client,m=e.get(g);m?(m.i--,l.clients.set(g,m.refs.slice(m.i)),e.delete(g),m.i=0,m.refs=[]):l.clients.set(g,[f]),r=r.filter(E=>E!==g)}s.length=0};for(;;){if(h.constructor!==B){const g=Y(d,h.id.client,()=>M(t,h.id.client))-h.id.clock;if(g<0)s.push(h),a(h.id.client,h.id.clock-1),u();else{const m=h.getMissing(n,t);if(m!==null){s.push(h);const E=e.get(m)||{refs:[],i:0};if(E.refs.length===E.i)a(m,M(t,m)),u();else{h=E.refs[E.i++];continue}}else(g===0||g<h.length)&&(h.integrate(n,g),d.set(h.id.client,h.id.clock+h.length))}}if(s.length>0)h=s.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=i(),o===null)break;h=o.refs[o.i++]}}if(l.clients.size>0){const f=new dt;return Pe(f,l,new Map),p(f.restEncoder,0),{missing:c,update:f.toUint8Array()}}return null},Ni=(n,t)=>Pe(n,t.doc.store,t.beforeState),Fi=(n,t,e,s=new Et(n))=>_(t,r=>{r.local=!1;let i=!1;const o=r.doc,l=o.store,c=Ri(s,o),a=Bi(r,l,c),h=l.pendingStructs;if(h){for(const[u,f]of h.missing)if(f<M(l,u)){i=!0;break}if(a){for(const[u,f]of a.missing){const g=h.missing.get(u);(g==null||g>f)&&h.missing.set(u,f)}h.update=he([h.update,a.update])}}else l.pendingStructs=a;const d=ts(s,r,l);if(l.pendingDs){const u=new Et(et(l.pendingDs));w(u.restDecoder);const f=ts(u,r,l);d&&f?l.pendingDs=he([d,f]):l.pendingDs=d||f}else l.pendingDs=d;if(i){const u=l.pendingStructs.update;l.pendingStructs=null,os(r.doc,u)}},e,!1),os=(n,t,e,s=Et)=>{const r=et(t);Fi(r,n,e,new s(r))},ls=(n,t,e)=>os(n,t,e,ss),Vi=(n,t,e=new Map)=>{Pe(n,t.store,e),Dt(n,Ti(t.store))},Hi=(n,t=new Uint8Array([0]),e=new dt)=>{const s=cs(t);Vi(e,n,s);const r=[e.toUint8Array()];if(n.store.pendingDs&&r.push(n.store.pendingDs),n.store.pendingStructs&&r.push(to(n.store.pendingStructs.update,t)),r.length>1){if(e.constructor===Ht)return Zi(r.map((i,o)=>o===0?i:no(i)));if(e.constructor===dt)return he(r)}return r[0]},qe=(n,t)=>Hi(n,t,new Ht),$i=n=>{const t=new Map,e=w(n.restDecoder);for(let s=0;s<e;s++){const r=w(n.restDecoder),i=w(n.restDecoder);t.set(r,i)}return t},cs=n=>$i(new ns(et(n))),as=(n,t)=>(p(n.restEncoder,t.size),tt(t.entries()).sort((e,s)=>s[0]-e[0]).forEach(([e,s])=>{p(n.restEncoder,e),p(n.restEncoder,s)}),n),ji=(n,t)=>as(n,ce(t.store)),Ki=(n,t=new is)=>(n instanceof Map?as(t,n):ji(t,n),t.toUint8Array()),zi=n=>Ki(n,new rs);class Yi{constructor(){this.l=[]}}const hs=()=>new Yi,us=(n,t)=>n.l.push(t),ds=(n,t)=>{const e=n.l,s=e.length;n.l=e.filter(r=>t!==r),s===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},fs=(n,t,e)=>Me(n.l,[t,e]);class Ct{constructor(t,e){this.client=t,this.clock=e}}const le=(n,t)=>n===t||n!==null&&t!==null&&n.client===t.client&&n.clock===t.clock,b=(n,t)=>new Ct(n,t),Xi=n=>{for(const[t,e]of n.doc.share.entries())if(e===n)return t;throw H()},$t=(n,t)=>t===void 0?!n.deleted:t.sv.has(n.id.client)&&(t.sv.get(n.id.client)||0)>n.id.clock&&!Qn(t.ds,n.id),Ze=(n,t)=>{const e=Y(n.meta,Ze,ot),s=n.doc.store;e.has(t)||(t.sv.forEach((r,i)=>{r<M(s,i)&&st(n,b(i,r))}),Zn(n,t.ds,r=>{}),e.add(t))};class gs{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ce=n=>{const t=new Map;return n.clients.forEach((e,s)=>{const r=e[e.length-1];t.set(s,r.id.clock+r.length)}),t},M=(n,t)=>{const e=n.clients.get(t);if(e===void 0)return 0;const s=e[e.length-1];return s.id.clock+s.length},ps=(n,t)=>{let e=n.clients.get(t.id.client);if(e===void 0)e=[],n.clients.set(t.id.client,e);else{const s=e[e.length-1];if(s.id.clock+s.length!==t.id.clock)throw H()}e.push(t)},$=(n,t)=>{let e=0,s=n.length-1,r=n[s],i=r.id.clock;if(i===t)return s;let o=X(t/(i+r.length-1)*s);for(;e<=s;){if(r=n[o],i=r.id.clock,i<=t){if(t<i+r.length)return o;e=o+1}else s=o-1;o=X((e+s)/2)}throw H()},Qe=(n,t)=>{const e=n.clients.get(t.client);return e[$(e,t.clock)]},tn=(n,t,e)=>{const s=$(t,e),r=t[s];return r.id.clock<e&&r instanceof L?(t.splice(s+1,0,_e(n,r,e-r.id.clock)),s+1):s},st=(n,t)=>{const e=n.doc.store.clients.get(t.client);return e[tn(n,e,t.clock)]},ws=(n,t,e)=>{const s=t.clients.get(e.client),r=$(s,e.clock),i=s[r];return e.clock!==i.id.clock+i.length-1&&i.constructor!==R&&s.splice(r+1,0,_e(n,i,e.clock-i.id.clock+1)),i},Ji=(n,t,e)=>{const s=n.clients.get(t.id.client);s[$(s,t.id.clock)]=e},ms=(n,t,e,s,r)=>{if(s===0)return;const i=e+s;let o=tn(n,t,e),l;do l=t[o++],i<l.id.clock+l.length&&tn(n,t,i),r(l);while(o<t.length&&t[o].id.clock<i)};class Wi{constructor(t,e,s){this.doc=t,this.deleteSet=new Vt,this.beforeState=ce(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=s,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const ys=(n,t)=>t.deleteSet.clients.size===0&&!yr(t.afterState,(e,s)=>t.beforeState.get(s)!==e)?!1:(We(t.deleteSet),Ni(n,t),Dt(n,t.deleteSet),!0),bs=(n,t,e)=>{const s=t._item;(s===null||s.id.clock<(n.beforeState.get(s.id.client)||0)&&!s.deleted)&&Y(n.changed,t,ot).add(e)},ae=(n,t)=>{let e=n[t],s=n[t-1],r=t;for(;r>0;e=s,s=n[--r-1]){if(s.deleted===e.deleted&&s.constructor===e.constructor&&s.mergeWith(e)){e instanceof L&&e.parentSub!==null&&e.parent._map.get(e.parentSub)===e&&e.parent._map.set(e.parentSub,s);continue}break}const i=t-r;return i&&n.splice(t+1-i,i),i},Gi=(n,t,e)=>{for(const[s,r]of n.clients.entries()){const i=t.clients.get(s);for(let o=r.length-1;o>=0;o--){const l=r[o],c=l.clock+l.len;for(let a=$(i,l.clock),h=i[a];a<i.length&&h.id.clock<c;h=i[++a]){const d=i[a];if(l.clock+l.len<=d.id.clock)break;d instanceof L&&d.deleted&&!d.keep&&e(d)&&d.gc(t,!1)}}}},Pi=(n,t)=>{n.clients.forEach((e,s)=>{const r=t.clients.get(s);for(let i=e.length-1;i>=0;i--){const o=e[i],l=Ie(r.length-1,1+$(r,o.clock+o.len-1));for(let c=l,a=r[c];c>0&&a.id.clock>=o.clock;a=r[c])c-=1+ae(r,c)}})},ks=(n,t)=>{if(t<n.length){const e=n[t],s=e.doc,r=s.store,i=e.deleteSet,o=e._mergeStructs;try{We(i),e.afterState=ce(e.doc.store),s.emit("beforeObserverCalls",[e,s]);const l=[];e.changed.forEach((c,a)=>l.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(e,c)})),l.push(()=>{e.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(h=>h.target._item===null||!h.target._item.deleted),c.forEach(h=>{h.currentTarget=a,h._path=null}),c.sort((h,d)=>h.path.length-d.path.length),fs(a._dEH,c,e))})}),l.push(()=>s.emit("afterTransaction",[e,s])),Me(l,[]),e._needFormattingCleanup&&wo(e)}finally{s.gc&&Gi(i,r,s.gcFilter),Pi(i,r),e.afterState.forEach((h,d)=>{const u=e.beforeState.get(d)||0;if(u!==h){const f=r.clients.get(d),g=lt($(f,u),1);for(let m=f.length-1;m>=g;)m-=1+ae(f,m)}});for(let h=o.length-1;h>=0;h--){const{client:d,clock:u}=o[h].id,f=r.clients.get(d),g=$(f,u);g+1<f.length&&ae(f,g+1)>1||g>0&&ae(f,g)}if(!e.local&&e.afterState.get(s.clientID)!==e.beforeState.get(s.clientID)&&(Ai(Pn,Jn,"[yjs] ",Wn,Gn,"Changed the client-id because another client seems to be using it."),s.clientID=es()),s.emit("afterTransactionCleanup",[e,s]),s._observers.has("update")){const h=new Ht;ys(h,e)&&s.emit("update",[h.toUint8Array(),e.origin,s,e])}if(s._observers.has("updateV2")){const h=new dt;ys(h,e)&&s.emit("updateV2",[h.toUint8Array(),e.origin,s,e])}const{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=e;(l.size>0||a.size>0||c.size>0)&&(l.forEach(h=>{h.clientID=s.clientID,h.collectionid==null&&(h.collectionid=s.collectionid),s.subdocs.add(h)}),a.forEach(h=>s.subdocs.delete(h)),s.emit("subdocs",[{loaded:c,added:l,removed:a},s,e]),a.forEach(h=>h.destroy())),n.length<=t+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,n])):ks(n,t+1)}}},_=(n,t,e=null,s=!0)=>{const r=n._transactionCleanups;let i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new Wi(n,e,s),r.push(n._transaction),r.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=t(n._transaction)}finally{if(i){const l=n._transaction===r[0];n._transaction=null,l&&ks(r,0)}}return o};function*qi(n){const t=w(n.restDecoder);for(let e=0;e<t;e++){const s=w(n.restDecoder),r=n.readClient();let i=w(n.restDecoder);for(let o=0;o<s;o++){const l=n.readInfo();if(l===10){const c=w(n.restDecoder);yield new B(b(r,i),c),i+=c}else if(ee&l){const c=(l&(J|O))===0,a=new L(b(r,i),null,(l&O)===O?n.readLeftID():null,null,(l&J)===J?n.readRightID():null,c?n.readParentInfo()?n.readString():n.readLeftID():null,c&&(l&Rt)===Rt?n.readString():null,js(n,l));yield a,i+=a.length}else{const c=n.readLen();yield new R(b(r,i),c),i+=c}}}}class en{constructor(t,e){this.gen=qi(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===B);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const Zi=n=>he(n,ss,Ht),Qi=(n,t)=>{if(n.constructor===R){const{client:e,clock:s}=n.id;return new R(b(e,s+t),n.length-t)}else if(n.constructor===B){const{client:e,clock:s}=n.id;return new B(b(e,s+t),n.length-t)}else{const e=n,{client:s,clock:r}=e.id;return new L(b(s,r+t),null,b(s,r+t-1),null,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t))}},he=(n,t=Et,e=dt)=>{if(n.length===1)return n[0];const s=n.map(h=>new t(et(h)));let r=s.map(h=>new en(h,!0)),i=null;const o=new e,l=new nn(o);for(;r=r.filter(u=>u.curr!==null),r.sort((u,f)=>{if(u.curr.id.client===f.curr.id.client){const g=u.curr.id.clock-f.curr.id.clock;return g===0?u.curr.constructor===f.curr.constructor?0:u.curr.constructor===B?1:-1:g}else return f.curr.id.client-u.curr.id.client}),r.length!==0;){const h=r[0],d=h.curr.id.client;if(i!==null){let u=h.curr,f=!1;for(;u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client;)u=h.next(),f=!0;if(u===null||u.id.client!==d||f&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)rt(l,i.struct,i.offset),i={struct:u,offset:0},h.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===B)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{rt(l,i.struct,i.offset);const g=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new B(b(d,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-u.id.clock;g>0&&(i.struct.constructor===B?i.struct.length-=g:u=Qi(u,g)),i.struct.mergeWith(u)||(rt(l,i.struct,i.offset),i={struct:u,offset:0},h.next())}}else i={struct:h.curr,offset:0},h.next();for(let u=h.curr;u!==null&&u.id.client===d&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==B;u=h.next())rt(l,i.struct,i.offset),i={struct:u,offset:0}}i!==null&&(rt(l,i.struct,i.offset),i=null),sn(l);const c=s.map(h=>Ge(h)),a=Mi(c);return Dt(o,a),o.toUint8Array()},to=(n,t,e=Et,s=dt)=>{const r=cs(t),i=new s,o=new nn(i),l=new e(et(n)),c=new en(l,!1);for(;c.curr;){const h=c.curr,d=h.id.client,u=r.get(d)||0;if(c.curr.constructor===B){c.next();continue}if(h.id.clock+h.length>u)for(rt(o,h,lt(u-h.id.clock,0)),c.next();c.curr&&c.curr.id.client===d;)rt(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===d&&c.curr.id.clock+c.curr.length<=u;)c.next()}sn(o);const a=Ge(l);return Dt(i,a),i.toUint8Array()},_s=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:D(n.encoder.restEncoder)}),n.encoder.restEncoder=U(),n.written=0)},rt=(n,t,e)=>{n.written>0&&n.currClient!==t.id.client&&_s(n),n.written===0&&(n.currClient=t.id.client,n.encoder.writeClient(t.id.client),p(n.encoder.restEncoder,t.id.clock+e)),t.write(n.encoder,e),n.written++},sn=n=>{_s(n);const t=n.encoder.restEncoder;p(t,n.clientStructs.length);for(let e=0;e<n.clientStructs.length;e++){const s=n.clientStructs[e];p(t,s.written),re(t,s.restEncoder)}},eo=(n,t,e,s)=>{const r=new e(et(n)),i=new en(r,!1),o=new s,l=new nn(o);for(let a=i.curr;a!==null;a=i.next())rt(l,t(a),0);sn(l);const c=Ge(r);return Dt(o,c),o.toUint8Array()},no=n=>eo(n,Vr,Et,Ht),Ss="You must not compute changes after the event-handler fired.";class ue{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=so(this.currentTarget,this.target))}deletes(t){return Qn(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw W(Ss);const t=new Map,e=this.target;this.transaction.changed.get(e).forEach(r=>{if(r!==null){const i=e._map.get(r);let o,l;if(this.adds(i)){let c=i.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(i))if(c!==null&&this.deletes(c))o="delete",l=Le(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",l=Le(c.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=Le(i.content.getContent());else return;t.set(r,{action:o,oldValue:l})}}),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 W(Ss);const e=this.target,s=ot(),r=ot(),i=[];if(t={added:s,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let l=null;const c=()=>{l&&i.push(l)};for(let a=e._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((l===null||l.delete===void 0)&&(c(),l={delete:0}),l.delete+=a.length,r.add(a)):this.adds(a)?((l===null||l.insert===void 0)&&(c(),l={insert:[]}),l.insert=l.insert.concat(a.content.getContent()),s.add(a)):((l===null||l.retain===void 0)&&(c(),l={retain:0}),l.retain+=a.length);l!==null&&l.retain===void 0&&c()}this._changes=t}return t}}const so=(n,t)=>{const e=[];for(;t._item!==null&&t!==n;){if(t._item.parentSub!==null)e.unshift(t._item.parentSub);else{let s=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)r.deleted||s++,r=r.right;e.unshift(s)}t=t._item.parent}return e},Ds=80;let rn=0;class ro{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=rn++}}const io=n=>{n.timestamp=rn++},Es=(n,t,e)=>{n.p.marker=!1,n.p=t,t.marker=!0,n.index=e,n.timestamp=rn++},oo=(n,t,e)=>{if(n.length>=Ds){const s=n.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Es(s,t,e),s}else{const s=new ro(t,e);return n.push(s),s}},de=(n,t)=>{if(n._start===null||t===0||n._searchMarker===null)return null;const e=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>Qt(t-i.index)<Qt(t-o.index)?i:o);let s=n._start,r=0;for(e!==null&&(s=e.p,r=e.index,io(e));s.right!==null&&r<t;){if(!s.deleted&&s.countable){if(t<r+s.length)break;r+=s.length}s=s.right}for(;s.left!==null&&r>t;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);for(;s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);return e!==null&&Qt(e.index-r)<s.parent.length/Ds?(Es(e,s,r),e):oo(n._searchMarker,s,r)},jt=(n,t,e)=>{for(let s=n.length-1;s>=0;s--){const r=n[s];if(e>0){let i=r.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(r.index-=i.length);if(i===null||i.marker===!0){n.splice(s,1);continue}r.p=i,i.marker=!0}(t<r.index||e>0&&t===r.index)&&(r.index=lt(t,r.index+e))}},fe=(n,t,e)=>{const s=n,r=t.changedParentTypes;for(;Y(r,n,()=>[]).push(e),n._item!==null;)n=n._item.parent;fs(s._eH,e,t)};class x{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=hs(),this._dEH=hs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw V()}clone(){throw V()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){us(this._eH,t)}observeDeep(t){us(this._dEH,t)}unobserve(t){ds(this._eH,t)}unobserveDeep(t){ds(this._dEH,t)}toJSON(){}}const Cs=(n,t,e)=>{t<0&&(t=n._length+t),e<0&&(e=n._length+e);let s=e-t;const r=[];let i=n._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let l=t;l<o.length&&s>0;l++)r.push(o[l]),s--;t=0}}i=i.right}return r},As=n=>{const t=[];let e=n._start;for(;e!==null;){if(e.countable&&!e.deleted){const s=e.content.getContent();for(let r=0;r<s.length;r++)t.push(s[r])}e=e.right}return t},Kt=(n,t)=>{let e=0,s=n._start;for(;s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)t(r[i],e++,n)}s=s.right}},Ls=(n,t)=>{const e=[];return Kt(n,(s,r)=>{e.push(t(s,r,n))}),e},lo=n=>{let t=n._start,e=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(e===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};e=t.content.getContent(),s=0,t=t.right}const r=e[s++];return e.length<=s&&(e=null),{done:!1,value:r}}}},Is=(n,t)=>{const e=de(n,t);let s=n._start;for(e!==null&&(s=e.p,t-=e.index);s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<s.length)return s.content.getContent()[t];t-=s.length}},ge=(n,t,e,s)=>{let r=e;const i=n.doc,o=i.clientID,l=i.store,c=e===null?t._start:e.right;let a=[];const h=()=>{a.length>0&&(r=new L(b(o,M(l,o)),r,r&&r.lastId,c,c&&c.id,t,null,new wt(a)),r.integrate(n,0),a=[])};s.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(h(),d.constructor){case Uint8Array:case ArrayBuffer:r=new L(b(o,M(l,o)),r,r&&r.lastId,c,c&&c.id,t,null,new Yt(new Uint8Array(d))),r.integrate(n,0);break;case ut:r=new L(b(o,M(l,o)),r,r&&r.lastId,c,c&&c.id,t,null,new Jt(d)),r.integrate(n,0);break;default:if(d instanceof x)r=new L(b(o,M(l,o)),r,r&&r.lastId,c,c&&c.id,t,null,new q(d)),r.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},vs=()=>W("Length exceeded!"),Ms=(n,t,e,s)=>{if(e>t._length)throw vs();if(e===0)return t._searchMarker&&jt(t._searchMarker,e,s.length),ge(n,t,null,s);const r=e,i=de(t,e);let o=t._start;for(i!==null&&(o=i.p,e-=i.index,e===0&&(o=o.prev,e+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(e<=o.length){e<o.length&&st(n,b(o.id.client,o.id.clock+e));break}e-=o.length}return t._searchMarker&&jt(t._searchMarker,r,s.length),ge(n,t,o,s)},co=(n,t,e)=>{let r=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return ge(n,t,r,e)},xs=(n,t,e,s)=>{if(s===0)return;const r=e,i=s,o=de(t,e);let l=t._start;for(o!==null&&(l=o.p,e-=o.index);l!==null&&e>0;l=l.right)!l.deleted&&l.countable&&(e<l.length&&st(n,b(l.id.client,l.id.clock+e)),e-=l.length);for(;s>0&&l!==null;)l.deleted||(s<l.length&&st(n,b(l.id.client,l.id.clock+s)),l.delete(n),s-=l.length),l=l.right;if(s>0)throw vs();t._searchMarker&&jt(t._searchMarker,r,-i+s)},pe=(n,t,e)=>{const s=t._map.get(e);s!==void 0&&s.delete(n)},on=(n,t,e,s)=>{const r=t._map.get(e)||null,i=n.doc,o=i.clientID;let l;if(s==null)l=new wt([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:l=new wt([s]);break;case Uint8Array:l=new Yt(s);break;case ut:l=new Jt(s);break;default:if(s instanceof x)l=new q(s);else throw new Error("Unexpected content type")}new L(b(o,M(i.store,o)),r,r&&r.lastId,null,null,t,e,l).integrate(n,0)},ln=(n,t)=>{const e=n._map.get(t);return e!==void 0&&!e.deleted?e.content.getContent()[e.length-1]:void 0},Ts=n=>{const t={};return n._map.forEach((e,s)=>{e.deleted||(t[s]=e.content.getContent()[e.length-1])}),t},Us=(n,t)=>{const e=n._map.get(t);return e!==void 0&&!e.deleted},we=n=>Ii(n.entries(),t=>!t[1].deleted);class ao extends ue{constructor(t,e){super(t,e),this._transaction=e}}class At extends x{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const e=new At;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new At}clone(){const t=new At;return t.insert(0,this.toArray().map(e=>e instanceof x?e.clone():e)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(t,e){super._callObserver(t,e),fe(this,t,new ao(this,t))}insert(t,e){this.doc!==null?_(this.doc,s=>{Ms(s,this,t,e)}):this._prelimContent.splice(t,0,...e)}push(t){this.doc!==null?_(this.doc,e=>{co(e,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){this.doc!==null?_(this.doc,s=>{xs(s,this,t,e)}):this._prelimContent.splice(t,e)}get(t){return Is(this,t)}toArray(){return As(this)}slice(t=0,e=this.length){return Cs(this,t,e)}toJSON(){return this.map(t=>t instanceof x?t.toJSON():t)}map(t){return Ls(this,t)}forEach(t){Kt(this,t)}[Symbol.iterator](){return lo(this)}_write(t){t.writeTypeRef(Oo)}}const ho=n=>new At;class uo extends ue{constructor(t,e,s){super(t,e),this.keysChanged=s}}class ft extends x{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((s,r)=>{this.set(r,s)}),this._prelimContent=null}_copy(){return new ft}clone(){const t=new ft;return this.forEach((e,s)=>{t.set(s,e instanceof x?e.clone():e)}),t}_callObserver(t,e){fe(this,t,new uo(this,t,e))}toJSON(){const t={};return this._map.forEach((e,s)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[s]=r instanceof x?r.toJSON():r}}),t}get size(){return[...we(this._map)].length}keys(){return Xe(we(this._map),t=>t[0])}values(){return Xe(we(this._map),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Xe(we(this._map),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this._map.forEach((e,s)=>{e.deleted||t(e.content.getContent()[e.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?_(this.doc,e=>{pe(e,this,t)}):this._prelimContent.delete(t)}set(t,e){return this.doc!==null?_(this.doc,s=>{on(s,this,t,e)}):this._prelimContent.set(t,e),e}get(t){return ln(this,t)}has(t){return Us(this,t)}clear(){this.doc!==null?_(this.doc,t=>{this.forEach(function(e,s,r){pe(t,r,s)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Ro)}}const fo=n=>new ft,it=(n,t)=>n===t||typeof n=="object"&&typeof t=="object"&&n&&t&&Fr(n,t);class cn{constructor(t,e,s,r){this.left=t,this.right=e,this.index=s,this.currentAttributes=r}forward(){switch(this.right===null&&H(),this.right.content.constructor){case A:this.right.deleted||Lt(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Os=(n,t,e)=>{for(;t.right!==null&&e>0;){switch(t.right.content.constructor){case A:t.right.deleted||Lt(t.currentAttributes,t.right.content);break;default:t.right.deleted||(e<t.right.length&&st(n,b(t.right.id.client,t.right.id.clock+e)),t.index+=t.right.length,e-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},me=(n,t,e)=>{const s=new Map,r=de(t,e);if(r){const i=new cn(r.p.left,r.p,r.index,s);return Os(n,i,e-r.index)}else{const i=new cn(null,t._start,0,s);return Os(n,i,e)}},Rs=(n,t,e,s)=>{for(;e.right!==null&&(e.right.deleted===!0||e.right.content.constructor===A&&it(s.get(e.right.content.key),e.right.content.value));)e.right.deleted||s.delete(e.right.content.key),e.forward();const r=n.doc,i=r.clientID;s.forEach((o,l)=>{const c=e.left,a=e.right,h=new L(b(i,M(r.store,i)),c,c&&c.lastId,a,a&&a.id,t,null,new A(l,o));h.integrate(n,0),e.right=h,e.forward()})},Lt=(n,t)=>{const{key:e,value:s}=t;s===null?n.delete(e):n.set(e,s)},Bs=(n,t)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===A&&it(t[n.right.content.key]||null,n.right.content.value)))break;n.forward()}},Ns=(n,t,e,s)=>{const r=n.doc,i=r.clientID,o=new Map;for(const l in s){const c=s[l],a=e.currentAttributes.get(l)||null;if(!it(a,c)){o.set(l,a);const{left:h,right:d}=e;e.right=new L(b(i,M(r.store,i)),h,h&&h.lastId,d,d&&d.id,t,null,new A(l,c)),e.right.integrate(n,0),e.forward()}}return o},an=(n,t,e,s,r)=>{e.currentAttributes.forEach((u,f)=>{r[f]===void 0&&(r[f]=null)});const i=n.doc,o=i.clientID;Bs(e,r);const l=Ns(n,t,e,r),c=s.constructor===String?new j(s):s instanceof x?new q(s):new pt(s);let{left:a,right:h,index:d}=e;t._searchMarker&&jt(t._searchMarker,e.index,c.getLength()),h=new L(b(o,M(i.store,o)),a,a&&a.lastId,h,h&&h.id,t,null,c),h.integrate(n,0),e.right=h,e.index=d,e.forward(),Rs(n,t,e,l)},Fs=(n,t,e,s,r)=>{const i=n.doc,o=i.clientID;Bs(e,r);const l=Ns(n,t,e,r);t:for(;e.right!==null&&(s>0||l.size>0&&(e.right.deleted||e.right.content.constructor===A));){if(!e.right.deleted)switch(e.right.content.constructor){case A:{const{key:c,value:a}=e.right.content,h=r[c];if(h!==void 0){if(it(h,a))l.delete(c);else{if(s===0)break t;l.set(c,a)}e.right.delete(n)}else e.currentAttributes.set(c,a);break}default:s<e.right.length&&st(n,b(e.right.id.client,e.right.id.clock+s)),s-=e.right.length;break}e.forward()}if(s>0){let c="";for(;s>0;s--)c+=`
|
|
2
|
+
`;e.right=new L(b(o,M(i.store,o)),e.left,e.left&&e.left.lastId,e.right,e.right&&e.right.id,t,null,new j(c)),e.right.integrate(n,0),e.forward()}Rs(n,t,e,l)},Vs=(n,t,e,s,r)=>{let i=t;const o=N();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===A){const a=i.content;o.set(a.key,a)}i=i.right}let l=0,c=!1;for(;t!==i;){if(e===t&&(c=!0),!t.deleted){const a=t.content;switch(a.constructor){case A:{const{key:h,value:d}=a,u=s.get(h)||null;(o.get(h)!==a||u===d)&&(t.delete(n),l++,!c&&(r.get(h)||null)===d&&u!==d&&(u===null?r.delete(h):r.set(h,u))),!c&&!t.deleted&&Lt(r,a);break}}}t=t.right}return l},go=(n,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const e=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===A){const s=t.content.key;e.has(s)?t.delete(n):e.add(s)}t=t.left}},po=n=>{let t=0;return _(n.doc,e=>{let s=n._start,r=n._start,i=N();const o=Ae(i);for(;r;){if(r.deleted===!1)switch(r.content.constructor){case A:Lt(o,r.content);break;default:t+=Vs(e,s,r,i,o),i=Ae(o),s=r;break}r=r.right}}),t},wo=n=>{const t=new Set,e=n.doc;for(const[s,r]of n.afterState.entries()){const i=n.beforeState.get(s)||0;r!==i&&ms(n,e.store.clients.get(s),i,r,o=>{!o.deleted&&o.content.constructor===A&&o.constructor!==R&&t.add(o.parent)})}_(e,s=>{Zn(n,n.deleteSet,r=>{if(r instanceof R||!r.parent._hasFormatting||t.has(r.parent))return;const i=r.parent;r.content.constructor===A?t.add(i):go(s,r)});for(const r of t)po(r)})},Hs=(n,t,e)=>{const s=e,r=Ae(t.currentAttributes),i=t.right;for(;e>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case pt:case j:e<t.right.length&&st(n,b(t.right.id.client,t.right.id.clock+e)),e-=t.right.length,t.right.delete(n);break}t.forward()}i&&Vs(n,i,t.right,r,t.currentAttributes);const o=(t.left||t.right).parent;return o._searchMarker&&jt(o._searchMarker,t.index,-s+e),t};class mo extends ue{constructor(t,e,s){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const 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){const t=this.target.doc,e=[];_(t,s=>{const r=new Map,i=new Map;let o=this.target._start,l=null;const c={};let a="",h=0,d=0;const u=()=>{if(l!==null){let f=null;switch(l){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof a=="object"||a.length>0)&&(f={insert:a},r.size>0&&(f.attributes={},r.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),a="";break;case"retain":h>0&&(f={retain:h},Br(c)||(f.attributes=Tr({},c))),h=0;break}f&&e.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case q:case pt:this.adds(o)?this.deletes(o)||(u(),l="insert",a=o.content.getContent()[0],u()):this.deletes(o)?(l!=="delete"&&(u(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(u(),l="retain"),h+=1);break;case j:this.adds(o)?this.deletes(o)||(l!=="insert"&&(u(),l="insert"),a+=o.content.str):this.deletes(o)?(l!=="delete"&&(u(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(u(),l="retain"),h+=o.length);break;case A:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=r.get(f)||null;it(m,g)?g!==null&&o.delete(s):(l==="retain"&&u(),it(g,i.get(f)||null)?delete c[f]:c[f]=g)}}else if(this.deletes(o)){i.set(f,g);const m=r.get(f)||null;it(m,g)||(l==="retain"&&u(),c[f]=m)}else if(!o.deleted){i.set(f,g);const m=c[f];m!==void 0&&(it(m,g)?m!==null&&o.delete(s):(l==="retain"&&u(),g===null?delete c[f]:c[f]=g))}o.deleted||(l==="insert"&&u(),Lt(r,o.content));break}}o=o.right}for(u();e.length>0;){const f=e[e.length-1];if(f.retain!==void 0&&f.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class It extends x{constructor(t){super(),this._pending=t!==void 0?[()=>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(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new It}clone(){const t=new It;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);const s=new mo(this,t,e);fe(this,t,s),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){let t="",e=this._start;for(;e!==null;)!e.deleted&&e.countable&&e.content.constructor===j&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){this.doc!==null?_(this.doc,s=>{const r=new cn(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const o=t[i];if(o.insert!==void 0){const l=!e&&typeof o.insert=="string"&&i===t.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
3
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&an(s,this,r,l,o.attributes||{})}else o.retain!==void 0?Fs(s,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&Hs(s,r,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,s){const r=[],i=new Map,o=this.doc;let l="",c=this._start;function a(){if(l.length>0){const d={};let u=!1;i.forEach((g,m)=>{u=!0,d[m]=g});const f={insert:l};u&&(f.attributes=d),r.push(f),l=""}}const h=()=>{for(;c!==null;){if($t(c,t)||e!==void 0&&$t(c,e))switch(c.content.constructor){case j:{const d=i.get("ychange");t!==void 0&&!$t(c,t)?(d===void 0||d.user!==c.id.client||d.type!=="removed")&&(a(),i.set("ychange",s?s("removed",c.id):{type:"removed"})):e!==void 0&&!$t(c,e)?(d===void 0||d.user!==c.id.client||d.type!=="added")&&(a(),i.set("ychange",s?s("added",c.id):{type:"added"})):d!==void 0&&(a(),i.delete("ychange")),l+=c.content.str;break}case q:case pt:{a();const d={insert:c.content.getContent()[0]};if(i.size>0){const u={};d.attributes=u,i.forEach((f,g)=>{u[g]=f})}r.push(d);break}case A:$t(c,t)&&(a(),Lt(i,c.content));break}c=c.right}a()};return t||e?_(o,d=>{t&&Ze(d,t),e&&Ze(d,e),h()},"cleanup"):h(),r}insert(t,e,s){if(e.length<=0)return;const r=this.doc;r!==null?_(r,i=>{const o=me(i,this,t);s||(s={},o.currentAttributes.forEach((l,c)=>{s[c]=l})),an(i,this,o,e,s)}):this._pending.push(()=>this.insert(t,e,s))}insertEmbed(t,e,s={}){const r=this.doc;r!==null?_(r,i=>{const o=me(i,this,t);an(i,this,o,e,s)}):this._pending.push(()=>this.insertEmbed(t,e,s))}delete(t,e){if(e===0)return;const s=this.doc;s!==null?_(s,r=>{Hs(r,me(r,this,t),e)}):this._pending.push(()=>this.delete(t,e))}format(t,e,s){if(e===0)return;const r=this.doc;r!==null?_(r,i=>{const o=me(i,this,t);o.right!==null&&Fs(i,this,o,e,s)}):this._pending.push(()=>this.format(t,e,s))}removeAttribute(t){this.doc!==null?_(this.doc,e=>{pe(e,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){this.doc!==null?_(this.doc,s=>{on(s,this,t,e)}):this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return ln(this,t)}getAttributes(){return Ts(this)}_write(t){t.writeTypeRef(Bo)}}const yo=n=>new It;class hn{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(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===zt||e.constructor===gt)&&e._start!==null)t=e._start;else for(;t!==null;)if(t.right!==null){t=t.right;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})}}class gt extends x{constructor(){super(),this._prelimContent=[]}get firstChild(){const 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 gt}clone(){const t=new gt;return t.insert(0,this.toArray().map(e=>e instanceof x?e.clone():e)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new hn(this,t)}querySelector(t){t=t.toUpperCase();const s=new hn(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),tt(new hn(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){fe(this,t,new _o(this,e,t))}toString(){return Ls(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},s){const r=t.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),Kt(this,i=>{r.insertBefore(i.toDOM(t,e,s),null)}),r}insert(t,e){this.doc!==null?_(this.doc,s=>{Ms(s,this,t,e)}):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)_(this.doc,s=>{const r=t&&t instanceof x?t._item:t;ge(s,this,r,e)});else{const s=this._prelimContent,r=t===null?0:s.findIndex(i=>i===t)+1;if(r===0&&t!==null)throw W("Reference item not found");s.splice(r,0,...e)}}delete(t,e=1){this.doc!==null?_(this.doc,s=>{xs(s,this,t,e)}):this._prelimContent.splice(t,e)}toArray(){return As(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Is(this,t)}slice(t=0,e=this.length){return Cs(this,t,e)}forEach(t){Kt(this,t)}_write(t){t.writeTypeRef(Fo)}}const bo=n=>new gt;class zt extends gt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new zt(this.nodeName)}clone(){const t=new zt(this.nodeName),e=this.getAttributes();return Or(e,(s,r)=>{typeof s=="string"&&t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof x?s.clone():s)),t}toString(){const t=this.getAttributes(),e=[],s=[];for(const l in t)s.push(l);s.sort();const r=s.length;for(let l=0;l<r;l++){const c=s[l];e.push(c+'="'+t[c]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?_(this.doc,e=>{pe(e,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,e){this.doc!==null?_(this.doc,s=>{on(s,this,t,e)}):this._prelimAttrs.set(t,e)}getAttribute(t){return ln(this,t)}hasAttribute(t){return Us(this,t)}getAttributes(){return Ts(this)}toDOM(t=document,e={},s){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&r.setAttribute(o,l)}return Kt(this,o=>{r.appendChild(o.toDOM(t,e,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(No),t.writeKey(this.nodeName)}}const ko=n=>new zt(n.readKey());class _o extends ue{constructor(t,e,s){super(t,s),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class ye extends ft{constructor(t){super(),this.hookName=t}_copy(){return new ye(this.hookName)}clone(){const t=new ye(this.hookName);return this.forEach((e,s)=>{t.set(s,e)}),t}toDOM(t=document,e={},s){const r=e[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(t){t.writeTypeRef(Vo),t.writeKey(this.hookName)}}const So=n=>new ye(n.readKey());class be extends It{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new be}clone(){const t=new be;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,s){const r=t.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const e=[];for(const r in t.attributes){const i=[];for(const o in t.attributes[r])i.push({key:o,value:t.attributes[r][o]});i.sort((o,l)=>o.key<l.key?-1:1),e.push({nodeName:r,attrs:i})}e.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<e.length;r++){const i=e[r];s+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];s+=` ${l.key}="${l.value}"`}s+=">"}s+=t.insert;for(let r=e.length-1;r>=0;r--)s+=`</${e[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Ho)}}const Do=n=>new be;class un{constructor(t,e){this.id=t,this.length=e}get deleted(){throw V()}mergeWith(t){return!1}write(t,e,s){throw V()}integrate(t,e){throw V()}}const Eo=0;class R extends un{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),ps(t.doc.store,this)}write(t,e){t.writeInfo(Eo),t.writeLen(this.length-e)}getMissing(t,e){return null}}class Yt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Yt(this.content)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}const Co=n=>new Yt(n.readBuf());class Xt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Xt(this.len)}splice(t){const e=new Xt(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){oe(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}}const Ao=n=>new Xt(n.readLen()),$s=(n,t)=>new ut({guid:n,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Jt{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;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),t.meta!==null&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Jt($s(this.doc.guid,this.opts))}splice(t){throw V()}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}}const Lo=n=>new Jt($s(n.readString(),n.readAny()));class pt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new pt(this.embed)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}const Io=n=>new pt(n.readJSON());class A{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new A(this.key,this.value)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,e){const s=e.parent;s._searchMarker=null,s._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const vo=n=>new A(n.readKey(),n.readJSON());class ke{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ke(this.arr)}splice(t){const e=new ke(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){const s=this.arr.length;t.writeLen(s-e);for(let r=e;r<s;r++){const i=this.arr[r];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const Mo=n=>{const t=n.readLen(),e=[];for(let s=0;s<t;s++){const r=n.readString();r==="undefined"?e.push(void 0):e.push(JSON.parse(r))}return new ke(e)};class wt{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new wt(this.arr)}splice(t){const e=new wt(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){const s=this.arr.length;t.writeLen(s-e);for(let r=e;r<s;r++){const i=this.arr[r];t.writeAny(i)}}getRef(){return 8}}const xo=n=>{const t=n.readLen(),e=[];for(let s=0;s<t;s++)e.push(n.readAny());return new wt(e)};class j{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new j(this.str)}splice(t){const e=new j(this.str.slice(t));this.str=this.str.slice(0,t);const s=this.str.charCodeAt(t-1);return s>=55296&&s<=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(e===0?this.str:this.str.slice(e))}getRef(){return 4}}const To=n=>new j(n.readString()),Uo=[ho,fo,yo,ko,bo,So,Do],Oo=0,Ro=1,Bo=2,No=3,Fo=4,Vo=5,Ho=6;class q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new q(this.type._copy())}splice(t){throw V()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;e!==null;)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(s=>{s.deleted?s.id.clock<(t.beforeState.get(s.id.client)||0)&&t._mergeStructs.push(s):s.delete(t)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;e!==null;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(t,!0),s=s.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const $o=n=>new q(Uo[n.readTypeRef()](n)),_e=(n,t,e)=>{const{client:s,clock:r}=t.id,i=new L(b(s,r+e),t,b(s,r+e-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=b(t.redone.client,t.redone.clock+e)),t.right=i,i.right!==null&&(i.right.left=i),n._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=e,i};class L extends un{constructor(t,e,s,r,i,o,l,c){super(t,c.getLength()),this.origin=s,this.left=e,this.right=r,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=c,this.info=this.content.isCountable()?Bn:0}set marker(t){(this.info&Oe)>0!==t&&(this.info^=Oe)}get marker(){return(this.info&Oe)>0}get keep(){return(this.info&Rn)>0}set keep(t){this.keep!==t&&(this.info^=Rn)}get countable(){return(this.info&Bn)>0}get deleted(){return(this.info&Ue)>0}set deleted(t){this.deleted!==t&&(this.info^=Ue)}markDeleted(){this.info|=Ue}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=M(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=M(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ct&&this.id.client!==this.parent.client&&this.parent.clock>=M(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ws(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=st(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===R||this.right&&this.right.constructor===R)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===L&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===L&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ct){const s=Qe(e,this.parent);s.constructor===R?this.parent=null:this.parent=s.content.type}return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=ws(t,t.doc.store,b(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||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else 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;const i=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),i.add(r),le(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(le(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Qe(t.doc.store,r.origin)))i.has(Qe(t.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;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,this.parent._start=this;this.right=s}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),ps(t.doc.store,this),this.content.integrate(t,this),bs(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new R(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&&le(t.origin,this.lastId)&&this.right===t&&le(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)){const e=this.parent._searchMarker;return e&&e.forEach(s=>{s.p===t&&(s.p=this,!this.deleted&&this.countable&&(s.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){const e=this.parent;this.countable&&this.parentSub===null&&(e._length-=this.length),this.markDeleted(),oe(t.deleteSet,this.id.client,this.id.clock,this.length),bs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw H();this.content.gc(t),e?Ji(t,this,new R(this.id,this.length)):this.content=new Xt(this.length)}write(t,e){const s=e>0?b(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&ee|(s===null?0:O)|(r===null?0:J)|(i===null?0:Rt);if(t.writeInfo(o),s!==null&&t.writeLeftID(s),r!==null&&t.writeRightID(r),s===null&&r===null){const l=this.parent;if(l._item!==void 0){const c=l._item;if(c===null){const a=Xi(l);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else l.constructor===String?(t.writeParentInfo(!0),t.writeString(l)):l.constructor===Ct?(t.writeParentInfo(!1),t.writeLeftID(l)):H();i!==null&&t.writeString(i)}this.content.write(t,e)}}const js=(n,t)=>jo[t&ee](n),jo=[()=>{H()},Ao,Mo,Co,To,Io,vo,$o,xo,Lo,()=>{H()}],Ko=10;class B extends un{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){H()}write(t,e){t.writeInfo(Ko),p(t.restEncoder,this.length-e)}getMissing(t,e){return null}}const Ks=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},zs="__ $YJS$ __";Ks[zs]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ks[zs]=!0;const Ys=new Map;class zo{constructor(t){this.room=t,this.onmessage=null,this._onChange=e=>e.key===t&&this.onmessage!==null&&this.onmessage({data:ni(e.newValue||"")}),Mr(this._onChange)}postMessage(t){xn.setItem(this.room,ei(Pr(t)))}close(){xr(this._onChange)}}const Yo=typeof BroadcastChannel>"u"?zo:BroadcastChannel,dn=n=>Y(Ys,n,()=>{const t=ot(),e=new Yo(n);return e.onmessage=s=>t.forEach(r=>r(s.data,"broadcastchannel")),{bc:e,subs:t}}),Xo=(n,t)=>(dn(n).subs.add(t),t),Jo=(n,t)=>{const e=dn(n),s=e.subs.delete(t);return s&&e.subs.size===0&&(e.bc.close(),Ys.delete(n)),s},vt=(n,t,e=null)=>{const s=dn(n);s.bc.postMessage(t),s.subs.forEach(r=>r(t,e))},Xs=0,fn=1,Js=2,gn=(n,t)=>{p(n,Xs);const e=zi(t);C(n,e)},Ws=(n,t,e)=>{p(n,fn),C(n,qe(t,e))},Wo=(n,t,e)=>Ws(t,e,T(n)),Gs=(n,t,e)=>{try{ls(t,T(n),e)}catch(s){console.error("Caught error while handling a Yjs update",s)}},Go=(n,t)=>{p(n,Js),C(n,t)},Po=Gs,qo=(n,t,e,s)=>{const r=w(n);switch(r){case Xs:Wo(n,t,e);break;case fn:Gs(n,e,s);break;case Js:Po(n,e,s);break;default:throw new Error("Unknown message type")}return r},Zo=0,Qo=(n,t,e)=>{switch(w(n)){case Zo:e(t,nt(n))}},pn=3e4;class tl extends Zt{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const e=ht();this.getLocalState()!==null&&pn/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&pn<=e-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&wn(this,s,"timeout")},X(pn/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){const e=this.clientID,s=this.meta.get(e),r=s===void 0?0:s.clock+1,i=this.states.get(e);t===null?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:r,lastUpdated:ht()});const o=[],l=[],c=[],a=[];t===null?a.push(e):i==null?t!=null&&o.push(e):(l.push(e),Ot(i,t)||c.push(e)),(o.length>0||c.length>0||a.length>0)&&this.emit("change",[{added:o,updated:c,removed:a},"local"]),this.emit("update",[{added:o,updated:l,removed:a},"local"])}setLocalStateField(t,e){const s=this.getLocalState();s!==null&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const wn=(n,t,e)=>{const s=[];for(let r=0;r<t.length;r++){const i=t[r];if(n.states.has(i)){if(n.states.delete(i),i===n.clientID){const o=n.meta.get(i);n.meta.set(i,{clock:o.clock+1,lastUpdated:ht()})}s.push(i)}}s.length>0&&(n.emit("change",[{added:[],updated:[],removed:s},e]),n.emit("update",[{added:[],updated:[],removed:s},e]))},Wt=(n,t,e=n.states)=>{const s=t.length,r=U();p(r,s);for(let i=0;i<s;i++){const o=t[i],l=e.get(o)||null,c=n.meta.get(o).clock;p(r,o),p(r,c),at(r,JSON.stringify(l))}return D(r)},el=(n,t,e)=>{const s=et(t),r=ht(),i=[],o=[],l=[],c=[],a=w(s);for(let h=0;h<a;h++){const d=w(s);let u=w(s);const f=JSON.parse(nt(s)),g=n.meta.get(d),m=n.states.get(d),E=g===void 0?0:g.clock;(E<u||E===u&&f===null&&n.states.has(d))&&(f===null?d===n.clientID&&n.getLocalState()!=null?u++:n.states.delete(d):n.states.set(d,f),n.meta.set(d,{clock:u,lastUpdated:r}),g===void 0&&f!==null?i.push(d):g!==void 0&&f===null?c.push(d):f!==null&&(Ot(f,m)||l.push(d),o.push(d)))}(i.length>0||l.length>0||c.length>0)&&n.emit("change",[{added:i,updated:l,removed:c},e]),(i.length>0||o.length>0||c.length>0)&&n.emit("update",[{added:i,updated:o,removed:c},e])},nl=n=>Rr(n,(t,e)=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");var mt=0,Ps=3,Mt=1,sl=2,rl=typeof window>"u";function il(n,t){if(!n)throw new Error(t)}var Gt=[];Gt[mt]=(n,t,e,s,r)=>{p(n,mt);const i=qo(t,n,e.doc,e);s&&i===fn&&!e.synced&&(e.synced=!0)},Gt[Ps]=(n,t,e,s,r)=>{p(n,Mt),C(n,Wt(e.awareness,Array.from(e.awareness.getStates().keys())))},Gt[Mt]=(n,t,e,s,r)=>{el(e.awareness,T(t),e)},Gt[sl]=(n,t,e,s,r)=>{Qo(t,e.doc,(i,o)=>ol(e,o))};var qs=3e4;function ol(n,t){console.warn(`Permission denied to access ${n.url}.
|
|
4
|
+
${t}`)}function Zs(n,t,e){const s=et(t),r=U(),i=w(s),o=n.messageHandlers[i];return o?o(r,s,n,e,i):console.error("Unable to compute message"),r}function Qs(n){if(n.shouldConnect&&n.ws===null){const t=new n._WS(n.url);t.binaryType="arraybuffer",n.ws=t,n.wsconnecting=!0,n.wsconnected=!1,n.synced=!1,t.onmessage=e=>{if(typeof e.data=="string")return;n.wsLastMessageReceived=ht();const s=Zs(n,new Uint8Array(e.data),!0);He(s)>1&&t.send(D(s))},t.onerror=e=>{n.emit("connection-error",[e,n])},t.onclose=e=>{n.emit("connection-close",[e,n]),n.ws=null,n.wsconnecting=!1,n.wsconnected?(n.wsconnected=!1,n.synced=!1,wn(n.awareness,Array.from(n.awareness.getStates().keys()).filter(s=>s!==n.doc.clientID),n),n.emit("status",[{status:"disconnected"}])):n.wsUnsuccessfulReconnects++,setTimeout(Qs,Ie(_r(2,n.wsUnsuccessfulReconnects)*100,n.maxBackoffTime),n)},t.onopen=()=>{n.wsLastMessageReceived=ht(),n.wsconnecting=!1,n.wsconnected=!0,n.wsUnsuccessfulReconnects=0,n.emit("status",[{status:"connected"}]);const e=U();if(p(e,mt),gn(e,n.doc),t.send(D(e)),n.awareness.getLocalState()!==null){const s=U();p(s,Mt),C(s,Wt(n.awareness,[n.doc.clientID])),t.send(D(s))}},n.emit("status",[{status:"connecting"}])}}function mn(n,t){const e=n.ws;n.wsconnected&&e&&e.readyState===e.OPEN&&e.send(t),n.bcconnected&&vt(n.bcChannel,t,n)}var ll=class extends Zt{constructor(t,e,s,{connect:r=!0,awareness:i=new tl(s),params:o={},WebSocketPolyfill:l=WebSocket,resyncInterval:c=-1,maxBackoffTime:a=2500,disableBc:h=rl}={}){super();y(this,"maxBackoffTime");y(this,"bcChannel");y(this,"url");y(this,"roomname");y(this,"doc");y(this,"_WS");y(this,"awareness");y(this,"wsconnected");y(this,"wsconnecting");y(this,"bcconnected");y(this,"disableBc");y(this,"wsUnsuccessfulReconnects");y(this,"messageHandlers");y(this,"_synced");y(this,"ws");y(this,"wsLastMessageReceived");y(this,"shouldConnect");y(this,"_resyncInterval");y(this,"_bcSubscriber");y(this,"_updateHandler");y(this,"_awarenessUpdateHandler");y(this,"_unloadHandler");y(this,"_checkInterval");for(;t[t.length-1]==="/";)t=t.slice(0,t.length-1);const d=nl(o);this.maxBackoffTime=a,this.bcChannel=t+"/"+e,this.url=t+"/"+e+(d.length===0?"":"?"+d),this.roomname=e,this.doc=s,this._WS=l,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Gt.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const u=U();p(u,mt),gn(u,s),this.ws.send(D(u))}},c)),this._bcSubscriber=(u,f)=>{if(f!==this){const g=Zs(this,new Uint8Array(u),!1);He(g)>1&&vt(this.bcChannel,D(g),this)}},this._updateHandler=(u,f)=>{if(f!==this){const g=U();p(g,mt),Go(g,u),mn(this,D(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:u,updated:f,removed:g},m)=>{const E=u.concat(f).concat(g),Q=U();p(Q,Mt),C(Q,Wt(i,E)),mn(this,D(Q))},this._unloadHandler=()=>{wn(this.awareness,[s.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&qs<ht()-this.wsLastMessageReceived&&(il(this.ws!==null,"ws must not be null"),this.ws.close())},qs/10),r&&this.connect()}get synced(){return this._synced}set synced(t){this._synced!==t&&(this._synced=t,this.emit("synced",[t]),this.emit("sync",[t]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Xo(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const t=U();p(t,mt),gn(t,this.doc),vt(this.bcChannel,D(t),this);const e=U();p(e,mt),Ws(e,this.doc),vt(this.bcChannel,D(e),this);const s=U();p(s,Ps),vt(this.bcChannel,D(s),this);const r=U();p(r,Mt),C(r,Wt(this.awareness,[this.doc.clientID])),vt(this.bcChannel,D(r),this)}disconnectBc(){const t=U();p(t,Mt),C(t,Wt(this.awareness,[this.doc.clientID],new Map)),mn(this,D(t)),this.bcconnected&&(Jo(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Qs(this),this.connectBc())}};function cl(){if(crypto.randomUUID)return crypto.randomUUID();let n=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let s=Math.random()*16;return n>0?(s=(n+s)%16|0,n=Math.floor(n/16)):(s=(t+s)%16|0,t=Math.floor(t/16)),(e==="x"?s:s&3|8).toString(16)})}function tr(n,t,e){if(typeof n!==e)throw new Error(`Invalid "${t}" parameter provided to YPartyKitProvider. Expected: ${e}, received: ${n}`)}var al=class extends WebSocket{send(n){typeof n!="string"&&wr(n,t=>super.send(t))}},hl=(dr=class extends ll{constructor(t,e,s,r={}){tr(t,"host","string"),tr(e,"room","string"),t=t.replace(/^(http|https|ws|wss):\/\//,""),t.endsWith("/")&&t.slice(0,-1);const i=`${t.startsWith("localhost:")||t.startsWith("127.0.0.1:")?"ws":"wss"}://${t}${r.party?`/parties/${r.party}`:"/party"}`,o=r.connectionId??cl(),{params:l,connect:c=!0,...a}=r,h={...a,connect:!1,WebSocketPolyfill:al};super(i,e,s??new ut,h);y(this,"id");gr(this,bt,void 0);this.id=o,pr(this,bt,l),c&&this.connect()}connect(){Promise.resolve(typeof Ce(this,bt)=="function"?Ce(this,bt).call(this):Ce(this,bt)).then(t=>{const e=new URLSearchParams([["_pk",this.id]]);if(t)for(const[r,i]of Object.entries(t))i!=null&&e.append(r,i);const s=new URL(this.url);s.search=e.toString(),this.url=s.toString(),super.connect()}).catch(t=>{throw console.error("Failed to open connecton to PartyKit",t),new Error(t)})}},bt=new WeakMap,dr);const yt=n=>St((t,e)=>{n.onerror=s=>e(new Error(s.target.error)),n.onsuccess=s=>t(s.target.result)}),ul=(n,t)=>St((e,s)=>{const r=indexedDB.open(n);r.onupgradeneeded=i=>t(i.target.result),r.onerror=i=>s(W(i.target.error)),r.onsuccess=i=>{const o=i.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),e(o)}}),dl=n=>yt(indexedDB.deleteDatabase(n)),fl=(n,t)=>t.forEach(e=>n.createObjectStore.apply(n,e)),Pt=(n,t,e="readwrite")=>{const s=n.transaction(t,e);return t.map(r=>_l(s,r))},er=(n,t)=>yt(n.count(t)),gl=(n,t)=>yt(n.get(t)),nr=(n,t)=>yt(n.delete(t)),pl=(n,t,e)=>yt(n.put(t,e)),yn=(n,t)=>yt(n.add(t)),wl=(n,t,e)=>yt(n.getAll(t,e)),ml=(n,t,e)=>{let s=null;return kl(n,t,r=>(s=r,!1),e).then(()=>s)},yl=(n,t=null)=>ml(n,t,"prev"),bl=(n,t)=>St((e,s)=>{n.onerror=s,n.onsuccess=async r=>{const i=r.target.result;if(i===null||await t(i)===!1)return e();i.continue()}}),kl=(n,t,e,s="next")=>bl(n.openKeyCursor(t,s),r=>e(r.key)),_l=(n,t)=>n.objectStore(t),Sl=(n,t)=>IDBKeyRange.upperBound(n,t),Dl=(n,t)=>IDBKeyRange.lowerBound(n,t),bn="custom",sr="updates",rr=500,ir=(n,t=()=>{},e=()=>{})=>{const[s]=Pt(n.db,[sr]);return wl(s,Dl(n._dbref,!1)).then(r=>{n._destroyed||(t(s),_(n.doc,()=>{r.forEach(i=>ls(n.doc,i))},n,!1),e(s))}).then(()=>yl(s).then(r=>{n._dbref=r+1})).then(()=>er(s).then(r=>{n._dbsize=r})).then(()=>s)},El=(n,t=!0)=>ir(n).then(e=>{(t||n._dbsize>=rr)&&yn(e,qe(n.doc)).then(()=>nr(e,Sl(n._dbref,!0))).then(()=>er(e).then(s=>{n._dbsize=s}))});class Cl extends Zt{constructor(t,e){super(),this.doc=e,this.name=t,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=ul(t,s=>fl(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=St(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,ir(this,o=>yn(o,qe(e)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(s,r)=>{if(this.db&&r!==this){const[i]=Pt(this.db,[sr]);yn(i,s),++this._dbsize>=rr&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{El(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},e.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),e.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(t=>{t.close()})}clearData(){return this.destroy().then(()=>{dl(this.name)})}get(t){return this._db.then(e=>{const[s]=Pt(e,[bn],"readonly");return gl(s,t)})}set(t,e){return this._db.then(s=>{const[r]=Pt(s,[bn]);return pl(r,e,t)})}del(t){return this._db.then(e=>{const[s]=Pt(e,[bn]);return nr(s,t)})}}const tc="",Al={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},Ll="can-duplicate-to";var kn=(n=>(n.CanPlay="can-play",n.CanMove="can-move",n.CanSpin="can-spin",n.CanGrow="can-grow",n.CanToggle="can-toggle",n.CanDuplicate="can-duplicate",n))(kn||{});function Il(n){return n.id}const or=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
|
|
5
5
|
16 0,
|
|
6
|
-
auto`,
|
|
7
|
-
<span class="guestbook-entry-timestamp">${h} at ${c}</span><span class="guestbook-entry-name"></span> <span class="guestbook-entry-message"></span>`,i.prepend(o),o.querySelector(".guestbook-entry-name")&&(o.querySelector(".guestbook-entry-name").innerText=r.name),o.querySelector(".guestbook-entry-message")&&(o.querySelector(".guestbook-entry-message").innerText=r.message),e.add(r.id)}),t({addedEntries:e})},additionalSetup:({getElement:s,getData:e,setData:t})=>{const n=s();n.addEventListener("submit",i=>{i.preventDefault(),i.stopImmediatePropagation();const r=e(),o=new FormData(i.target);function a(){const u=n.querySelector('input[name="message"]');u&&(u.value="")}const c=Object.fromEntries(o.entries());if(!c.name)return a(),!1;if(xa.some(u=>{const d=new RegExp(`\\b${u}\\b`,"gi");return d.test(c.message)||d.test(c.name)}))return alert("now why would you try to do something like that?"),a(),!1;const l=Date.now(),h={name:"someone",message:"something",...c,timestamp:l,id:`${l}-${c.name}`};return t([...r,h]),a(),!1})}},["can-duplicate"]:{defaultData:[],defaultLocalData:[],updateElement:({data:s,localData:e,setLocalData:t,element:n})=>{var i;const r=n.getAttribute("can-duplicate"),o=document.getElementById(r);let a=document.getElementById((i=e.slice(-1))==null?void 0:i[0])??null;if(!o){console.error(`Element with id ${r} not found. Cannot duplicate.`);return}const c=n.getAttribute(Ia);function l(u){if(c){const d=document.getElementById(c)||document.querySelector(c);if(d){d.appendChild(u);return}}o.parentNode.insertBefore(u,(a||o).nextSibling)}const h=new Set(e);for(const u of s){if(h.has(u))continue;const d=o.cloneNode(!0);Object.assign(d,{...o}),d.id=u,l(d),e.push(u),window.playhtml.setupPlayElement(d),a=d}t(e)},onClick:(s,{data:e,element:t,setData:n})=>{const i=t.getAttribute("can-duplicate")+"-"+Math.random().toString(36).substr(2,9);n([...e,i])}}},ci=(s,e=300)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>s.apply(this,n),e)}};class za{constructor(e){b(this,"defaultData");b(this,"localData");b(this,"awareness",[]);b(this,"selfAwareness");b(this,"element");b(this,"_data");b(this,"onChange");b(this,"onAwarenessChange");b(this,"debouncedOnChange");b(this,"resetShortcut");b(this,"updateElement");b(this,"updateElementAwareness");b(this,"triggerAwarenessUpdate");b(this,"onClick");b(this,"onDrag");b(this,"onDragStart");const{element:t,onChange:n,onAwarenessChange:i,defaultData:r,defaultLocalData:o,myDefaultAwareness:a,data:c,awareness:l,updateElement:h,updateElementAwareness:u,additionalSetup:d,debounceMs:f,triggerAwarenessUpdate:g}=e;this.element=t,this.defaultData=r instanceof Function?r(t):r,this.localData=o instanceof Function?o(t):o,this.triggerAwarenessUpdate=g,this.onChange=n,this.debouncedOnChange=ci(this.onChange,f),this.onAwarenessChange=i,this.updateElement=h,this.updateElementAwareness=u;const m=c===void 0?this.defaultData:c;l!==void 0&&(this.__awareness=l);const E=a instanceof Function?a(t):a;E!==void 0&&this.setLocalAwareness(E),this._data=m,this.__data=m,this.reinitializeElementData(e),d&&d(this.getSetupData())}reinitializeElementData({element:e,onChange:t,onAwarenessChange:n,updateElement:i,updateElementAwareness:r,onClick:o,onDrag:a,onDragStart:c,resetShortcut:l,debounceMs:h,triggerAwarenessUpdate:u}){this.triggerAwarenessUpdate=u,this.onChange=t,this.resetShortcut=l,this.debouncedOnChange=ci(this.onChange,h),this.onAwarenessChange=n,this.updateElement=i,this.updateElementAwareness=r,o&&!this.onClick&&e.addEventListener("click",d=>{var f;(f=this.onClick)==null||f.call(this,d,this.getEventHandlerData())}),this.onClick=o,a&&!this.onDrag&&(e.addEventListener("touchstart",d=>{var m;d.preventDefault(),(m=this.onDragStart)==null||m.call(this,d,this.getEventHandlerData());const f=E=>{var ee;E.preventDefault(),(ee=this.onDrag)==null||ee.call(this,E,this.getEventHandlerData())},g=E=>{document.removeEventListener("touchmove",f),document.removeEventListener("touchend",g)};document.addEventListener("touchmove",f),document.addEventListener("touchend",g)}),e.addEventListener("mousedown",d=>{var m;(m=this.onDragStart)==null||m.call(this,d,this.getEventHandlerData());const f=E=>{var ee;E.preventDefault(),(ee=this.onDrag)==null||ee.call(this,E,this.getEventHandlerData())},g=E=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",g)})),this.onDrag=a,this.onDragStart=c,l&&!this.resetShortcut&&(e.title||(e.title=`Hold down the ${La[l]} key while clicking to reset.`),e.reset=this.reset,e.addEventListener("click",d=>{switch(this.resetShortcut){case"ctrlKey":if(!d.ctrlKey)return;break;case"altKey":if(!d.altKey)return;break;case"shiftKey":if(!d.shiftKey)return;break;case"metaKey":if(!d.metaKey)return;break;default:return}this.reset(),d.preventDefault(),d.stopPropagation()})),this.resetShortcut=l}get data(){return this._data}setLocalData(e){this.localData=e}set __data(e){this._data=e,this.updateElement(this.getEventHandlerData())}set __awareness(e){console.log("updating awareness"),this.updateElementAwareness&&(console.log("updating awareness [2]"),this.awareness=e,this.updateElementAwareness(this.getAwarenessEventHandlerData()))}getEventHandlerData(){return{element:this.element,data:this.data,localData:this.localData,awareness:this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}getAwarenessEventHandlerData(){return{...this.getEventHandlerData(),myAwareness:this.selfAwareness}}getSetupData(){return{getElement:()=>this.element,getData:()=>this.data,getLocalData:()=>this.localData,getAwareness:()=>this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}setData(e){this.onChange(e)}setLocalAwareness(e){var t;e!==this.selfAwareness&&(this.selfAwareness=e,this.onAwarenessChange(e),(t=this.triggerAwarenessUpdate)==null||t.call(this))}setDataDebounced(e){this.debouncedOnChange(e)}reset(){this.setData(this.defaultData)}}const Ta="playhtml.spencerc99.partykit.dev",ws=new de;function Ua(){return window.location.pathname+window.location.search}let Q,q,K;const li=new Map;let ys=!1,Ss=!0;function hi({room:s=Ua(),host:e=Ta}={}){if(!Ss){console.error("playhtml already set up!");return}const t=encodeURIComponent(window.location.hostname+"-"+s),n=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
|
|
6
|
+
auto`,vl=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function lr(n,{getData:t,getElement:e,getLocalData:s,setLocalData:r}){const i=t(),o=s(),l=e();if(o.isHovering=!0,n.altKey){if(i.scale<=.5){l.style.cursor="not-allowed";return}l.style.cursor=vl}else{if(i.scale>=i.maxScale){l.style.cursor="not-allowed";return}l.style.cursor=or}r(o)}function Se(n){if("touches"in n){const{clientX:t,clientY:e}=n.touches[0];return{clientX:t,clientY:e}}return{clientX:n.clientX,clientY:n.clientY}}const Ml={["can-move"]:{defaultData:{x:0,y:0},defaultLocalData:{startMouseX:0,startMouseY:0},updateElement:({element:n,data:t})=>{n.style.transform=`translate(${t.x}px, ${t.y}px)`},onDragStart:(n,{setLocalData:t})=>{const{clientX:e,clientY:s}=Se(n);t({startMouseX:e,startMouseY:s})},onDrag:(n,{data:t,localData:e,setData:s,setLocalData:r,element:i})=>{const{clientX:o,clientY:l}=Se(n),{top:c,left:a,bottom:h,right:d}=i.getBoundingClientRect();d>window.outerWidth&&o>e.startMouseX||h>window.innerHeight&&l>e.startMouseY||a<0&&o<e.startMouseX||c<0&&l<e.startMouseY||(s({x:t.x+o-e.startMouseX,y:t.y+l-e.startMouseY}),r({startMouseX:o,startMouseY:l}))},resetShortcut:"shiftKey"},["can-spin"]:{defaultData:{rotation:0},defaultLocalData:{startMouseX:0},updateElement:({element:n,data:t})=>{n.style.transform=`rotate(${t.rotation}deg)`},onDragStart:(n,{setLocalData:t})=>{const{clientX:e}=Se(n);t({startMouseX:e})},onDrag:(n,{data:t,localData:e,setData:s,setLocalData:r})=>{const{clientX:i}=Se(n);let o=Math.abs(i-e.startMouseX)*2,l=t.rotation;i>e.startMouseX?l+=o:i<e.startMouseX&&(l-=o),s({rotation:l}),r({startMouseX:i})},resetShortcut:"shiftKey"},["can-toggle"]:{defaultData:!1,updateElement:({element:n,data:t})=>{n.classList.toggle("clicked",t)},onClick:(n,{data:t,setData:e})=>{e(!t)},resetShortcut:"shiftKey"},["can-grow"]:{defaultData:{scale:1},defaultLocalData:{maxScale:2,isHovering:!1},updateElement:({element:n,data:t})=>{n.style.transform=`scale(${t.scale})`},onClick:(n,{data:t,element:e,setData:s,localData:r})=>{let{scale:i}=t;if(n.altKey){if(t.scale<=.5)return;i-=.1}else{if(e.style.cursor=or,t.scale>=r.maxScale)return;i+=.1}s({...t,scale:i})},additionalSetup:n=>{n.getElement().addEventListener("mouseenter",t=>{lr(t,n);const e=s=>lr(s,n);document.addEventListener("keydown",e),document.addEventListener("keyup",e),n.getElement().addEventListener("mouseleave",s=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",e)})})},resetShortcut:"shiftKey"},["can-duplicate"]:{defaultData:[],defaultLocalData:[],updateElement:({data:n,localData:t,setLocalData:e,element:s})=>{var r;const i=s.getAttribute("can-duplicate"),o=document.getElementById(i);let l=document.getElementById((r=t.slice(-1))==null?void 0:r[0])??null;if(!o){console.error(`Element with id ${i} not found. Cannot duplicate.`);return}const c=s.getAttribute(Ll);function a(d){if(c){const u=document.getElementById(c)||document.querySelector(c);if(u){u.appendChild(d);return}}o.parentNode.insertBefore(d,(l||o).nextSibling)}const h=new Set(t);for(const d of n){if(h.has(d))continue;const u=o.cloneNode(!0);Object.assign(u,{...o}),u.id=d,a(u),t.push(d),window.playhtml.setupPlayElement(u),l=u}e(t)},onClick:(n,{data:t,element:e,setData:s})=>{const r=e.getAttribute("can-duplicate")+"-"+Math.random().toString(36).substr(2,9);s([...t,r])},isValidElementForTag:n=>{const t=n.getAttribute("can-duplicate");return t?(document.getElementById(t)||console.warn(`can-duplicate element (${n.id}) duplicate element ("${t}") not found.`),!0):!1}}},cr=(n,t=300)=>{let e;return function(...s){clearTimeout(e),e=setTimeout(()=>n.apply(this,s),t)}};class xl{constructor(t){y(this,"defaultData");y(this,"localData");y(this,"awareness",[]);y(this,"selfAwareness");y(this,"element");y(this,"_data");y(this,"onChange");y(this,"onAwarenessChange");y(this,"debouncedOnChange");y(this,"resetShortcut");y(this,"updateElement");y(this,"updateElementAwareness");y(this,"triggerAwarenessUpdate");y(this,"onClick");y(this,"onDrag");y(this,"onDragStart");const{element:e,onChange:s,onAwarenessChange:r,defaultData:i,defaultLocalData:o,myDefaultAwareness:l,data:c,awareness:a,updateElement:h,updateElementAwareness:d,additionalSetup:u,debounceMs:f,triggerAwarenessUpdate:g}=t;this.element=e,this.defaultData=i instanceof Function?i(e):i,this.localData=o instanceof Function?o(e):o,this.triggerAwarenessUpdate=g,this.onChange=s,this.debouncedOnChange=cr(this.onChange,f),this.onAwarenessChange=r,this.updateElement=h,this.updateElementAwareness=d;const m=c===void 0?this.defaultData:c;a!==void 0&&(this.__awareness=a);const E=l instanceof Function?l(e):l;E!==void 0&&this.setLocalAwareness(E),this._data=m,this.__data=m,this.reinitializeElementData(t),u&&u(this.getSetupData())}reinitializeElementData({element:t,onChange:e,onAwarenessChange:s,updateElement:r,updateElementAwareness:i,onClick:o,onDrag:l,onDragStart:c,resetShortcut:a,debounceMs:h,triggerAwarenessUpdate:d}){this.triggerAwarenessUpdate=d,this.onChange=e,this.debouncedOnChange=cr(this.onChange,h),this.onAwarenessChange=s,this.updateElement=r,this.updateElementAwareness=i,o&&!this.onClick&&t.addEventListener("click",u=>{var f;(f=this.onClick)==null||f.call(this,u,this.getEventHandlerData())}),this.onClick=o,l&&!this.onDrag&&(t.addEventListener("touchstart",u=>{var m;u.preventDefault(),(m=this.onDragStart)==null||m.call(this,u,this.getEventHandlerData());const f=E=>{var Q;E.preventDefault(),(Q=this.onDrag)==null||Q.call(this,E,this.getEventHandlerData())},g=E=>{document.removeEventListener("touchmove",f),document.removeEventListener("touchend",g)};document.addEventListener("touchmove",f),document.addEventListener("touchend",g)}),t.addEventListener("mousedown",u=>{var m;(m=this.onDragStart)==null||m.call(this,u,this.getEventHandlerData());const f=E=>{var Q;E.preventDefault(),(Q=this.onDrag)==null||Q.call(this,E,this.getEventHandlerData())},g=E=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",g)})),this.onDrag=l,this.onDragStart=c,a&&!this.resetShortcut&&(t.title||(t.title=`Hold down the ${Al[a]} key while clicking to reset.`),t.reset=this.reset,t.addEventListener("click",u=>{switch(this.resetShortcut){case"ctrlKey":if(!u.ctrlKey)return;break;case"altKey":if(!u.altKey)return;break;case"shiftKey":if(!u.shiftKey)return;break;case"metaKey":if(!u.metaKey)return;break;default:return}this.reset(),u.preventDefault(),u.stopPropagation()})),this.resetShortcut=a}get data(){return this._data}setLocalData(t){this.localData=t}set __data(t){this._data=t,this.updateElement(this.getEventHandlerData())}set __awareness(t){this.updateElementAwareness&&(this.awareness=t,this.updateElementAwareness(this.getAwarenessEventHandlerData()))}getEventHandlerData(){return{element:this.element,data:this.data,localData:this.localData,awareness:this.awareness,setData:t=>this.setData(t),setLocalData:t=>this.setLocalData(t),setLocalAwareness:t=>this.setLocalAwareness(t)}}getAwarenessEventHandlerData(){return{...this.getEventHandlerData(),myAwareness:this.selfAwareness}}getSetupData(){return{getElement:()=>this.element,getData:()=>this.data,getLocalData:()=>this.localData,getAwareness:()=>this.awareness,setData:t=>this.setData(t),setLocalData:t=>this.setLocalData(t),setLocalAwareness:t=>this.setLocalAwareness(t)}}setData(t){this.onChange(t)}setLocalAwareness(t){var e;t!==this.selfAwareness&&(this.selfAwareness=t,this.onAwarenessChange(t),(e=this.triggerAwarenessUpdate)==null||e.call(this))}setDataDebounced(t){this.debouncedOnChange(t)}reset(){this.setData(this.defaultData)}}const Tl="playhtml.spencerc99.partykit.dev",_n=new ut;function Ul(){return window.location.pathname+window.location.search}let Z,K,z;const ar=new Map;let qt=Ml;function Sn(){return Object.keys(qt)}let Dn=!1,En=!0;function hr({room:n=Ul(),host:t=Tl,extraCapabilities:e}={}){if(!En){console.error("playhtml already set up!");return}const s=encodeURIComponent(window.location.hostname+"-"+n),r=t;if(console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
|
|
8
7
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
9
8
|
࿂࿂࿂࿂ booting up playhtml... ࿂࿂࿂࿂
|
|
10
9
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
11
10
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
12
|
-
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),
|
|
11
|
+
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),Z=new hl(r,s,_n),K=_n.getMap("playhtml-global"),z=new Map,new Cl(s,_n),De.globalData=K,De.elementHandlers=z,e)for(const[i,o]of Object.entries(e))qt[i]=o;return Z.on("sync",i=>{i||console.error("Issue connecting to yjs..."),Dn=!0,Fl()}),Z}setTimeout(()=>{Z||(console.error("You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."),hr())},3e3);function Ol(n,t){const e=Z.awareness.getLocalState();return((e==null?void 0:e[n])??{})[t]}function Cn(n){return n instanceof HTMLElement}function Rl(n,t,e,s){const r=K.get(t);return{...e,data:r.get(s)??e.defaultData,awareness:Ol(t,s)??e.myDefaultAwareness!==void 0?[e.myDefaultAwareness]:void 0,element:n,onChange:o=>{r.get(s)!==o&&r.set(s,o)},onAwarenessChange:o=>{var c;const l=((c=Z.awareness.getLocalState())==null?void 0:c[t])||{};l[s]!==o&&(l[s]=o,Z.awareness.setLocalStateField(t,l))},triggerAwarenessUpdate:()=>{ur()}}}function Bl(n){return n.defaultData!==void 0&&n.updateElement!==void 0}function Nl(n,t){if(n===kn.CanPlay){const e=t;return{defaultData:e.defaultData,defaultLocalData:e.defaultLocalData,myDefaultAwareness:e.myDefaultAwareness,updateElement:e.updateElement,updateElementAwareness:e.updateElementAwareness,onDrag:e.onDrag,onDragStart:e.onDragStart,onClick:e.onClick,additionalSetup:e.additionalSetup,resetShortcut:e.resetShortcut,debounceMs:e.debounceMs,isValidElementForTag:e.isValidElementForTag}}return qt[n]}function ur(){const n=new Map;function t(e,s,r,i){n.has(e)||n.set(e,new Map);const o=n.get(e);o.has(s)||o.set(s,new Map),o.get(s).set(r,i)}Z.awareness.getStates().forEach((e,s)=>{var r;for(const[i,o]of Object.entries(e)){const l=z.get(i);if(l)for(const[c,a]of l){if(!(c in o))continue;const h=o[c];t(i,c,s,h)}}for(const[i,o]of n){const l=z.get(i);if(l)for(const[c,a]of l){const h=(r=o.get(c))==null?void 0:r.values();if(!h)continue;let d=Array.from(h);a.__awareness=d}}})}function Fl(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝"),console.log(Sn());for(const n of Sn()){const t=Array.from(document.querySelectorAll(`[${n}]`)).filter(Cn);if(t.length)for(let e=0;e<t.length;e++){const s=t[e];Ee(s,n)}}En&&(K.observe(n=>{n.changes.keys.forEach((t,e)=>{t.action==="add"&&K.set(e,K.get(e))})}),Z.awareness.on("change",()=>ur()),En=!1)}const De={init:hr,setupPlayElement:$l,removePlayElement:jl,setupPlayElementForTag:Ee,globalData:void 0,elementHandlers:void 0};window.playhtml=De;function Vl(n){if(z.has(n)||!Dn)return;z.set(n,new Map),n!==kn.CanPlay&&qt[n],K.get(n)||K.set(n,new ft);const t=K.get(n);t.observe(e=>{e.changes.keys.forEach((s,r)=>{const i=z.get(n);if(s.action==="add"){const o=document.getElementById(r);if(!Cn(o)){console.log(`Element ${r} not an HTML element. Ignoring.`);return}Ee(o,n)}else if(s.action==="update"){const o=i.get(r);o.__data=t.get(r)}else s.action==="delete"?i.delete(r):console.log(`Unhandled action: ${s.action}`)})})}function Hl(n,t){var e,s;return((s=(e=qt[t])==null?void 0:e.isValidElementForTag)==null?void 0:s.call(e,n))??!0}function Ee(n,t){var l;if(!Hl(n,t)||!Dn)return;if(!n.id){const c=n.getAttribute("selector-id");if(c){const a=ar.get(c)??0;n.id=btoa(`${t}-${c}-${a}`),ar.set(c,a+1)}else n.id=btoa(`${t}-${n.innerHTML}}`)}const e=Il(n);if(!e){console.error(`Element ${n} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}Vl(t);const s=z.get(t),r=Nl(t,n);if(!Bl(r)){console.error(`Element ${e} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`);return}const i=K.get(t),o=Rl(n,t,r,e);if(s.has(e)){s.get(e).reinitializeElementData(o);return}else s.set(e,new xl(o));i.get(e)===void 0&&r.defaultData!==void 0&&i.set(e,r.defaultData),(l=o.triggerAwarenessUpdate)==null||l.call(o),n.classList.add("__playhtml-element"),n.classList.add(`__playhtml-${t}`),n.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function $l(n){if(!Cn(n)){console.log(`Element ${n.id} not an HTML element. Ignoring.`);return}for(const t of Sn())n.hasAttribute(t)&&Ee(n,t)}function jl(n){if(!(!n||!n.id))for(const t of Object.keys(z)){const e=z.get(t);e.has(n.id)&&e.delete(n.id)}}S.playhtml=De,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|