playhtml 2.0.6 → 2.0.7

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.
@@ -1,12 +1,12 @@
1
- (function(U,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(U=typeof globalThis<"u"?globalThis:U||self,S(U.playhtml={}))})(this,function(U){"use strict";var zc=Object.defineProperty;var Oc=(U,S,q)=>S in U?zc(U,S,{enumerable:!0,configurable:!0,writable:!0,value:q}):U[S]=q;var b=(U,S,q)=>(Oc(U,typeof S!="symbol"?S+"":S,q),q);const S=()=>new Map,q=s=>{const e=S();return s.forEach((t,n)=>{e.set(n,t)}),e},K=(s,e,t)=>{let n=s.get(e);return n===void 0&&s.set(e,n=t()),n},ai=(s,e)=>{const t=[];for(const[n,i]of s)t.push(e(i,n));return t},li=(s,e)=>{for(const[t,n]of s)if(e(n,t))return!0;return!1},ce=()=>new Set,Dt=s=>s[s.length-1],hi=(s,e)=>{for(let t=0;t<e.length;t++)s.push(e[t])},te=Array.from,ui=Array.isArray;class We{constructor(){this._observers=S()}on(e,t){K(this._observers,e,ce).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)||S()).values()).forEach(n=>n(...t))}destroy(){this._observers=S()}}const Y=Math.floor,Pe=Math.abs,Ct=(s,e)=>s<e?s:e,ae=(s,e)=>s>e?s:e,di=Math.pow,ws=s=>s!==0?s<0:1/s<0,fi=String.fromCharCode,gi=s=>s.toLowerCase(),pi=/^\s*/g,ki=s=>s.replace(pi,""),mi=/([A-Z])/g,ys=(s,e)=>ki(s.replace(mi,t=>`${e}${gi(t)}`)),bi=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},je=typeof TextEncoder<"u"?new TextEncoder:null,wi=je?s=>je.encode(s):bi;let Me=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Me&&Me.decode(new Uint8Array).length===1&&(Me=null);const Ss=s=>s===void 0?null:s;class yi{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let _s=new yi,Et=!0;try{typeof localStorage<"u"&&(_s=localStorage,Et=!1)}catch{}const Ds=_s,Si=s=>Et||addEventListener("storage",s),_i=s=>Et||removeEventListener("storage",s),Di=Object.assign,Ci=Object.keys,Ei=(s,e)=>{for(const t in s)e(s[t],t)},vi=(s,e)=>{const t=[];for(const n in s)t.push(e(s[n],n));return t},Qe=s=>Ci(s).length,Ai=s=>{for(const e in s)return!1;return!0},xi=(s,e)=>{for(const t in s)if(!e(s[t],t))return!1;return!0},Cs=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),Ii=(s,e)=>s===e||Qe(s)===Qe(e)&&xi(s,(t,n)=>(t!==void 0||Cs(e,n))&&e[n]===t),vt=(s,e,t=0)=>{try{for(;t<s.length;t++)s[t](...e)}finally{t<s.length&&vt(s,e,t+1)}},Li=s=>s,ji=(s,e)=>s===e,Te=(s,e)=>{if(s==null||e==null)return ji(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)||!Te(s.get(t),e.get(t)))return!1;break}case Object:if(Qe(s)!==Qe(e))return!1;for(const t in s)if(!Cs(s,t)||!Te(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(!Te(s[t],e[t]))return!1;break;default:return!1}return!0},Mi=(s,e)=>e.includes(s),ye=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Es=typeof window<"u"&&typeof document<"u"&&!ye;let R;const Ti=()=>{if(R===void 0)if(ye){R=S();const s=process.argv;let e=null;for(let t=0;t<s.length;t++){const n=s[t];n[0]==="-"?(e!==null&&R.set(e,""),e=n):e!==null&&(R.set(e,n),e=null)}e!==null&&R.set(e,"")}else typeof location=="object"?(R=S(),(location.search||"?").slice(1).split("&").forEach(s=>{if(s.length!==0){const[e,t]=s.split("=");R.set(`--${ys(e,"-")}`,t),R.set(`-${ys(e,"-")}`,t)}})):R=S();return R},At=s=>Ti().has(s),xt=s=>Ss(ye?process.env[s.toUpperCase()]:Ds.getItem(s));(s=>At("--"+s)||xt(s)!==null)("production");const vs=ye&&Mi(process.env.FORCE_COLOR,["true","1","2"]),Ui=!At("no-colors")&&(!ye||process.stdout.isTTY||vs)&&(!ye||At("color")||vs||xt("COLORTERM")!==null||(xt("TERM")||"").includes("color")),As=1,xs=2,It=4,Lt=8,Ue=32,J=64,M=128,Ze=31,jt=63,le=127,zi=2147483647,Is=Number.MAX_SAFE_INTEGER,Oi=Number.isInteger||(s=>typeof s=="number"&&isFinite(s)&&Y(s)===s),X=s=>new Error(s),N=()=>{throw X("Method unimplemented")},B=()=>{throw X("Unexpected case")},Ls=X("Unexpected end of array"),js=X("Integer out of Range");class et{constructor(e){this.arr=e,this.pos=0}}const se=s=>new et(s),Ri=s=>s.pos!==s.arr.length,Ni=(s,e)=>{const t=zt(s.arr.buffer,s.pos+s.arr.byteOffset,e);return s.pos+=e,t},L=s=>Ni(s,k(s)),Se=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<M)return e;if(e>Is)throw js}throw Ls},Mt=s=>{let e=s.arr[s.pos++],t=e&jt,n=64;const i=(e&J)>0?-1:1;if(!(e&M))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<M)return i*t;if(t>Is)throw js}throw Ls},ne=Me?s=>Me.decode(L(s)):s=>{let e=k(s);if(e===0)return"";{let t=String.fromCodePoint(Se(s));if(--e<100)for(;e--;)t+=String.fromCodePoint(Se(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))}},Tt=(s,e)=>{const t=new DataView(s.arr.buffer,s.arr.byteOffset+s.pos,e);return s.pos+=e,t},Bi=[s=>{},s=>null,Mt,s=>Tt(s,4).getFloat32(0,!1),s=>Tt(s,8).getFloat64(0,!1),s=>Tt(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]=ze(s)}return t},s=>{const e=k(s),t=[];for(let n=0;n<e;n++)t.push(ze(s));return t},L],ze=s=>Bi[127-Se(s)](s);class Ms extends et{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ri(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class tt extends et{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Mt(this);const e=ws(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class Ut extends et{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Mt(this),t=e&1;this.diff=Y(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Fi{constructor(e){this.decoder=new tt(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 Ts=s=>new Uint8Array(s),zt=(s,e,t)=>new Uint8Array(s,e,t),Hi=s=>new Uint8Array(s),Vi=s=>{let e="";for(let t=0;t<s.byteLength;t++)e+=fi(s[t]);return btoa(e)},$i=s=>Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("base64"),qi=s=>{const e=atob(s),t=Ts(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},Ki=s=>{const e=Buffer.from(s,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},Yi=Es?Vi:$i,Ji=Es?qi:Ki,Xi=s=>{const e=Ts(s.byteLength);return e.set(s),e};class Oe{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const j=()=>new Oe,Ot=s=>{let e=s.cpos;for(let t=0;t<s.bufs.length;t++)e+=s.bufs[t].length;return e},_=s=>{const e=new Uint8Array(Ot(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(zt(s.cbuf.buffer,0,s.cpos),t),e},Gi=(s,e)=>{const t=s.cbuf.length;t-s.cpos<e&&(s.bufs.push(zt(s.cbuf.buffer,0,s.cpos)),s.cbuf=new Uint8Array(ae(t,e)*2),s.cpos=0)},A=(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},Rt=A,p=(s,e)=>{for(;e>le;)A(s,M|le&e),e=Y(e/128);A(s,le&e)},Nt=(s,e)=>{const t=ws(e);for(t&&(e=-e),A(s,(e>jt?M:0)|(t?J:0)|jt&e),e=Y(e/64);e>0;)A(s,(e>le?M:0)|le&e),e=Y(e/128)},Bt=new Uint8Array(3e4),Wi=Bt.length/3,Pi=(s,e)=>{if(e.length<Wi){const t=je.encodeInto(e,Bt).written||0;p(s,t);for(let n=0;n<t;n++)A(s,Bt[n])}else C(s,wi(e))},Qi=(s,e)=>{const t=unescape(encodeURIComponent(e)),n=t.length;p(s,n);for(let i=0;i<n;i++)A(s,t.codePointAt(i))},he=je&&je.encodeInto?Pi:Qi,st=(s,e)=>{const t=s.cbuf.length,n=s.cpos,i=Ct(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(ae(t*2,r)),s.cbuf.set(e.subarray(i)),s.cpos=r)},C=(s,e)=>{p(s,e.byteLength),st(s,e)},Ft=(s,e)=>{Gi(s,e);const t=new DataView(s.cbuf.buffer,s.cpos,e);return s.cpos+=e,t},Zi=(s,e)=>Ft(s,4).setFloat32(0,e,!1),er=(s,e)=>Ft(s,8).setFloat64(0,e,!1),tr=(s,e)=>Ft(s,8).setBigInt64(0,e,!1),Us=new DataView(new ArrayBuffer(4)),sr=s=>(Us.setFloat32(0,s),Us.getFloat32(0)===s),Re=(s,e)=>{switch(typeof e){case"string":A(s,119),he(s,e);break;case"number":Oi(e)&&Pe(e)<=zi?(A(s,125),Nt(s,e)):sr(e)?(A(s,124),Zi(s,e)):(A(s,123),er(s,e));break;case"bigint":A(s,122),tr(s,e);break;case"object":if(e===null)A(s,126);else if(ui(e)){A(s,117),p(s,e.length);for(let t=0;t<e.length;t++)Re(s,e[t])}else if(e instanceof Uint8Array)A(s,116),C(s,e);else{A(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),Re(s,e[i])}}break;case"boolean":A(s,e?120:121);break;default:A(s,127)}};class zs extends Oe{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 Os=s=>{s.count>0&&(Nt(s.encoder,s.count===1?s.s:-s.s),s.count>1&&p(s.encoder,s.count-2))};class nt{constructor(){this.encoder=new Oe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Os(this),this.count=1,this.s=e)}toUint8Array(){return Os(this),_(this.encoder)}}const Rs=s=>{if(s.count>0){const e=s.diff*2+(s.count===1?0:1);Nt(s.encoder,e),s.count>1&&p(s.encoder,s.count-2)}};class Ht{constructor(){this.encoder=new Oe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Rs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Rs(this),_(this.encoder)}}class nr{constructor(){this.sarr=[],this.s="",this.lensE=new nt}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 Oe;return this.sarr.push(this.s),this.s="",he(e,this.sarr.join("")),st(e,this.lensE.toUint8Array()),_(e)}}const ir=crypto.getRandomValues.bind(crypto),Ns=()=>ir(new Uint32Array(1))[0],rr=[1e7]+-1e3+-4e3+-8e3+-1e11,or=()=>rr.replace(/[018]/g,s=>(s^Ns()&15>>s/4).toString(16)),ue=Date.now,_e=s=>new Promise(s);Promise.all.bind(Promise);class cr{constructor(e,t){this.left=e,this.right=t}}const G=(s,e)=>new cr(s,e);typeof DOMParser<"u"&&new DOMParser;const ar=s=>ai(s,(e,t)=>`${t}:${e};`).join(""),W=Symbol,Bs=W(),Fs=W(),lr=W(),hr=W(),ur=W(),Hs=W(),dr=W(),Vs=W(),fr=W(),gr=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},pr={[Bs]:G("font-weight","bold"),[Fs]:G("font-weight","normal"),[lr]:G("color","blue"),[ur]:G("color","green"),[hr]:G("color","grey"),[Hs]:G("color","red"),[dr]:G("color","purple"),[Vs]:G("color","orange"),[fr]:G("color","black")},kr=Ui?s=>{const e=[],t=[],n=S();let i=[],r=0;for(;r<s.length;r++){const o=s[r],c=pr[o];if(c!==void 0)n.set(c.left,c.right);else if(o.constructor===String||o.constructor===Number){const a=ar(n);r>0||a.length>0?(e.push("%c"+o),t.push(a)):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}:gr,mr=(...s)=>{console.log(...kr(s)),br.forEach(e=>e.print(s))},br=ce(),$s=s=>({[Symbol.iterator](){return this},next:s}),wr=(s,e)=>$s(()=>{let t;do t=s.next();while(!t.done&&!e(t.value));return t}),Vt=(s,e)=>$s(()=>{const{done:t,value:n}=s.next();return{done:t,value:t?void 0:e(n)}});class $t{constructor(e,t){this.clock=e,this.len=t}}class Ne{constructor(){this.clients=new Map}}const qs=(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 c=n[o];hn(s,r,c.clock,c.len,t)}}),yr=(s,e)=>{let t=0,n=s.length-1;for(;t<=n;){const i=Y((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},Ks=(s,e)=>{const t=s.clients.get(e.client);return t!==void 0&&yr(t,e.clock)!==null},qt=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=ae(i.len,r.clock+r.len-i.clock):(n<t&&(e[n]=r),n++)}e.length=n})},Sr=s=>{const e=new Ne;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++)hi(r,s[o].clients.get(i)||[]);e.clients.set(i,r)}});return qt(e),e},it=(s,e,t,n)=>{K(s.clients,e,()=>[]).push(new $t(t,n))},_r=()=>new Ne,Dr=s=>{const e=_r();return s.clients.forEach((t,n)=>{const i=[];for(let r=0;r<t.length;r++){const o=t[r];if(o.deleted){const c=o.id.clock;let a=o.length;if(r+1<t.length)for(let l=t[r+1];r+1<t.length&&l.deleted;l=t[++r+1])a+=l.length;i.push(new $t(c,a))}}i.length>0&&e.clients.set(n,i)}),e},De=(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)}})},Kt=s=>{const e=new Ne,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=K(e.clients,i,()=>[]);for(let c=0;c<r;c++)o.push(new $t(s.readDsClock(),s.readDsLen()))}}return e},Ys=(s,e,t)=>{const n=new Ne,i=k(s.restDecoder);for(let r=0;r<i;r++){s.resetDsCurVal();const o=k(s.restDecoder),c=k(s.restDecoder),a=t.clients.get(o)||[],l=x(t,o);for(let h=0;h<c;h++){const u=s.readDsClock(),d=u+s.readDsLen();if(u<l){l<d&&it(n,o,l,d-l);let f=F(a,u),g=a[f];for(!g.deleted&&g.id.clock<u&&(a.splice(f+1,0,wt(e,g,u-g.id.clock)),f++);f<a.length&&(g=a[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&a.splice(f,0,wt(e,g,d-g.id.clock)),g.delete(e))}else it(n,o,u,d-u)}}if(n.clients.size>0){const r=new fe;return p(r.restEncoder,0),De(r,n),r.toUint8Array()}return null},Js=Ns;class de extends We{constructor({guid:e=or(),collectionid:t=null,gc:n=!0,gcFilter:i=()=>!0,meta:r=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=n,this.gcFilter=i,this.clientID=Js(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new cn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=_e(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const a=()=>_e(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=a()),this.isSynced=l===void 0||l===!0,this.isLoaded||this.emit("load",[])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&y(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 y(this,e,t)}get(e,t=I){const n=K(this.share,e,()=>{const r=new t;return r._integrate(this,null),r}),i=n.constructor;if(t!==I&&i!==t)if(i===I){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,ve)}getText(e=""){return this.get(e,xe)}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,y(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 Xs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Gs extends Xs{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 Se(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 ze(this.restDecoder)}readBuf(){return Xi(L(this.restDecoder))}readJSON(){return JSON.parse(ne(this.restDecoder))}readKey(){return ne(this.restDecoder)}}class Cr{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 Cr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Ut(L(e)),this.clientDecoder=new tt(L(e)),this.leftClockDecoder=new Ut(L(e)),this.rightClockDecoder=new Ut(L(e)),this.infoDecoder=new Ms(L(e),Se),this.stringDecoder=new Fi(L(e)),this.parentInfoDecoder=new Ms(L(e),Se),this.typeRefDecoder=new tt(L(e)),this.lenDecoder=new tt(L(e))}readLeftID(){return new Ee(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ee(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 ze(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return ze(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 Ws{constructor(){this.restEncoder=j()}toUint8Array(){return _(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Be extends Ws{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){Rt(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){Re(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,JSON.stringify(e))}writeKey(e){he(this.restEncoder,e)}}class Ps{constructor(){this.restEncoder=j(),this.dsCurrVal=0}toUint8Array(){return _(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,t)}writeDsLen(e){e===0&&B(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class fe extends Ps{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ht,this.clientEncoder=new nt,this.leftClockEncoder=new Ht,this.rightClockEncoder=new Ht,this.infoEncoder=new zs(Rt),this.stringEncoder=new nr,this.parentInfoEncoder=new zs(Rt),this.typeRefEncoder=new nt,this.lenEncoder=new nt}toUint8Array(){const e=j();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,_(this.infoEncoder)),C(e,this.stringEncoder.toUint8Array()),C(e,_(this.parentInfoEncoder)),C(e,this.typeRefEncoder.toUint8Array()),C(e,this.lenEncoder.toUint8Array()),st(e,_(this.restEncoder)),_(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){Re(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){Re(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 Er=(s,e,t,n)=>{n=ae(n,e[0].id.clock);const i=F(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)},Yt=(s,e,t)=>{const n=new Map;t.forEach((i,r)=>{x(e,r)>i&&n.set(r,i)}),ot(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])=>{Er(s,e.clients.get(i),i,r)})},vr=(s,e)=>{const t=S(),n=k(s.restDecoder);for(let i=0;i<n;i++){const r=k(s.restDecoder),o=new Array(r),c=s.readClient();let a=k(s.restDecoder);t.set(c,{i:0,refs:o});for(let l=0;l<r;l++){const h=s.readInfo();switch(Ze&h){case 0:{const u=s.readLen();o[l]=new z(w(c,a),u),a+=u;break}case 10:{const u=k(s.restDecoder);o[l]=new O(w(c,a),u),a+=u;break}default:{const u=(h&(J|M))===0,d=new v(w(c,a),null,(h&M)===M?s.readLeftID():null,null,(h&J)===J?s.readRightID():null,u?s.readParentInfo()?e.get(s.readString()):s.readLeftID():null,u&&(h&Ue)===Ue?s.readString():null,zn(s,h));o[l]=d,a+=d.length}}}}return t},Ar=(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 c=new cn,a=new Map,l=(f,g)=>{const m=a.get(f);(m==null||m>g)&&a.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--,c.clients.set(g,m.refs.slice(m.i)),t.delete(g),m.i=0,m.refs=[]):c.clients.set(g,[f]),i=i.filter(D=>D!==g)}n.length=0};for(;;){if(h.constructor!==O){const g=K(u,h.id.client,()=>x(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 D=t.get(m)||{refs:[],i:0};if(D.refs.length===D.i)l(m,x(e,m)),d();else{h=D.refs[D.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(c.clients.size>0){const f=new fe;return Yt(f,c,new Map),p(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},xr=(s,e)=>Yt(s,e.doc.store,e.beforeState),Ir=(s,e,t,n=new Ce(s))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,c=o.store,a=vr(n,o),l=Ar(i,c,a),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<x(c,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=at([h.update,l.update])}}else c.pendingStructs=l;const u=Ys(n,i,c);if(c.pendingDs){const d=new Ce(se(c.pendingDs));k(d.restDecoder);const f=Ys(d,i,c);u&&f?c.pendingDs=at([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(r){const d=c.pendingStructs.update;c.pendingStructs=null,Qs(i.doc,d)}},t,!1),Qs=(s,e,t,n=Ce)=>{const i=se(e);Ir(i,s,t,new n(i))},Zs=(s,e,t)=>Qs(s,e,t,Gs),Lr=(s,e,t=new Map)=>{Yt(s,e.store,t),De(s,Dr(e.store))},jr=(s,e=new Uint8Array([0]),t=new fe)=>{const n=en(e);Lr(t,s,n);const i=[t.toUint8Array()];if(s.store.pendingDs&&i.push(s.store.pendingDs),s.store.pendingStructs&&i.push(Kr(s.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Be)return $r(i.map((r,o)=>o===0?r:Jr(r)));if(t.constructor===fe)return at(i)}return i[0]},Jt=(s,e)=>jr(s,e,new Be),Mr=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},en=s=>Mr(new Xs(se(s))),tn=(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),Tr=(s,e)=>tn(s,ot(e.store)),Ur=(s,e=new Ps)=>(s instanceof Map?tn(e,s):Tr(e,s),e.toUint8Array()),zr=s=>Ur(s,new Ws);class Or{constructor(){this.l=[]}}const sn=()=>new Or,nn=(s,e)=>s.l.push(e),rn=(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.")},on=(s,e,t)=>vt(s.l,[e,t]);class Ee{constructor(e,t){this.client=e,this.clock=t}}const rt=(s,e)=>s===e||s!==null&&e!==null&&s.client===e.client&&s.clock===e.clock,w=(s,e)=>new Ee(s,e),Rr=s=>{for(const[e,t]of s.doc.share.entries())if(t===s)return e;throw B()},Fe=(s,e)=>e===void 0?!s.deleted:e.sv.has(s.id.client)&&(e.sv.get(s.id.client)||0)>s.id.clock&&!Ks(e.ds,s.id),Xt=(s,e)=>{const t=K(s.meta,Xt,ce),n=s.doc.store;t.has(e)||(e.sv.forEach((i,r)=>{i<x(n,r)&&ie(s,w(r,i))}),qs(s,e.ds,i=>{}),t.add(e))};class cn{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ot=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},x=(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},an=(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 B()}t.push(e)},F=(s,e)=>{let t=0,n=s.length-1,i=s[n],r=i.id.clock;if(r===e)return n;let o=Y(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=Y((t+n)/2)}throw B()},Gt=(s,e)=>{const t=s.clients.get(e.client);return t[F(t,e.clock)]},Wt=(s,e,t)=>{const n=F(e,t),i=e[n];return i.id.clock<t&&i instanceof v?(e.splice(n+1,0,wt(s,i,t-i.id.clock)),n+1):n},ie=(s,e)=>{const t=s.doc.store.clients.get(e.client);return t[Wt(s,t,e.clock)]},ln=(s,e,t)=>{const n=e.clients.get(t.client),i=F(n,t.clock),r=n[i];return t.clock!==r.id.clock+r.length-1&&r.constructor!==z&&n.splice(i+1,0,wt(s,r,t.clock-r.id.clock+1)),r},Nr=(s,e,t)=>{const n=s.clients.get(e.id.client);n[F(n,e.id.clock)]=t},hn=(s,e,t,n,i)=>{if(n===0)return;const r=t+n;let o=Wt(s,e,t),c;do c=e[o++],r<c.id.clock+c.length&&Wt(s,e,r),i(c);while(o<e.length&&e[o].id.clock<r)};class Br{constructor(e,t,n){this.doc=e,this.deleteSet=new Ne,this.beforeState=ot(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 un=(s,e)=>e.deleteSet.clients.size===0&&!li(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:(qt(e.deleteSet),xr(s,e),De(s,e.deleteSet),!0),dn=(s,e,t)=>{const n=e._item;(n===null||n.id.clock<(s.beforeState.get(n.id.client)||0)&&!n.deleted)&&K(s.changed,e,ce).add(t)},ct=(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 v&&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},Fr=(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 c=i[o],a=c.clock+c.len;for(let l=F(r,c.clock),h=r[l];l<r.length&&h.id.clock<a;h=r[++l]){const u=r[l];if(c.clock+c.len<=u.id.clock)break;u instanceof v&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Hr=(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],c=Ct(i.length-1,1+F(i,o.clock+o.len-1));for(let a=c,l=i[a];a>0&&l.id.clock>=o.clock;l=i[a])a-=1+ct(i,a)}})},fn=(s,e)=>{if(e<s.length){const t=s[e],n=t.doc,i=n.store,r=t.deleteSet,o=t._mergeStructs;try{qt(r),t.afterState=ot(t.doc.store),n.emit("beforeObserverCalls",[t,n]);const c=[];t.changed.forEach((a,l)=>c.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(t,a)})),c.push(()=>{t.changedParentTypes.forEach((a,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(a=a.filter(h=>h.target._item===null||!h.target._item.deleted),a.forEach(h=>{h.currentTarget=l,h._path=null}),a.sort((h,u)=>h.path.length-u.path.length),on(l._dEH,a,t))})}),c.push(()=>n.emit("afterTransaction",[t,n])),vt(c,[]),t._needFormattingCleanup&&oo(t)}finally{n.gc&&Fr(r,i,n.gcFilter),Hr(r,i),t.afterState.forEach((h,u)=>{const d=t.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ae(F(f,d),1);for(let m=f.length-1;m>=g;)m-=1+ct(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=F(f,d);g+1<f.length&&ct(f,g+1)>1||g>0&&ct(f,g)}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(mr(Vs,Bs,"[yjs] ",Fs,Hs,"Changed the client-id because another client seems to be using it."),n.clientID=Js()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){const h=new Be;un(h,t)&&n.emit("update",[h.toUint8Array(),t.origin,n,t])}if(n._observers.has("updateV2")){const h=new fe;un(h,t)&&n.emit("updateV2",[h.toUint8Array(),t.origin,n,t])}const{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=t;(c.size>0||l.size>0||a.size>0)&&(c.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:a,added:c,removed:l},n,t]),l.forEach(h=>h.destroy())),s.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,s])):fn(s,e+1)}}},y=(s,e,t=null,n=!0)=>{const i=s._transactionCleanups;let r=!1,o=null;s._transaction===null&&(r=!0,s._transaction=new Br(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 c=s._transaction===i[0];s._transaction=null,c&&fn(i,0)}}return o};function*Vr(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 c=s.readInfo();if(c===10){const a=k(s.restDecoder);yield new O(w(i,r),a),r+=a}else if(Ze&c){const a=(c&(J|M))===0,l=new v(w(i,r),null,(c&M)===M?s.readLeftID():null,null,(c&J)===J?s.readRightID():null,a?s.readParentInfo()?s.readString():s.readLeftID():null,a&&(c&Ue)===Ue?s.readString():null,zn(s,c));yield l,r+=l.length}else{const a=s.readLen();yield new z(w(i,r),a),r+=a}}}}class Pt{constructor(e,t){this.gen=Vr(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===O);return this.curr}}class Qt{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const $r=s=>at(s,Gs,Be),qr=(s,e)=>{if(s.constructor===z){const{client:t,clock:n}=s.id;return new z(w(t,n+e),s.length-e)}else if(s.constructor===O){const{client:t,clock:n}=s.id;return new O(w(t,n+e),s.length-e)}else{const t=s,{client:n,clock:i}=t.id;return new v(w(n,i+e),null,w(n,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},at=(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 Pt(h,!0)),r=null;const o=new t,c=new Qt(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===O?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(c,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===O)r.struct.length=d.id.clock+d.length-r.struct.id.clock;else{re(c,r.struct,r.offset);const g=d.id.clock-r.struct.id.clock-r.struct.length;r={struct:new O(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===O?r.struct.length-=g:d=qr(d,g)),r.struct.mergeWith(d)||(re(c,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!==O;d=h.next())re(c,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(re(c,r.struct,r.offset),r=null),Zt(c);const a=n.map(h=>Kt(h)),l=Sr(a);return De(o,l),o.toUint8Array()},Kr=(s,e,t=Ce,n=fe)=>{const i=en(e),r=new n,o=new Qt(r),c=new t(se(s)),a=new Pt(c,!1);for(;a.curr;){const h=a.curr,u=h.id.client,d=i.get(u)||0;if(a.curr.constructor===O){a.next();continue}if(h.id.clock+h.length>d)for(re(o,h,ae(d-h.id.clock,0)),a.next();a.curr&&a.curr.id.client===u;)re(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===u&&a.curr.id.clock+a.curr.length<=d;)a.next()}Zt(o);const l=Kt(c);return De(r,l),r.toUint8Array()},gn=s=>{s.written>0&&(s.clientStructs.push({written:s.written,restEncoder:_(s.encoder.restEncoder)}),s.encoder.restEncoder=j(),s.written=0)},re=(s,e,t)=>{s.written>0&&s.currClient!==e.id.client&&gn(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++},Zt=s=>{gn(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),st(e,n.restEncoder)}},Yr=(s,e,t,n)=>{const i=new t(se(s)),r=new Pt(i,!1),o=new n,c=new Qt(o);for(let l=r.curr;l!==null;l=r.next())re(c,e(l),0);Zt(c);const a=Kt(i);return De(o,a),o.toUint8Array()},Jr=s=>Yr(s,Li,Ce,Be),pn="You must not compute changes after the event-handler fired.";class lt{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=Xr(this.currentTarget,this.target))}deletes(e){return Ks(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(pn);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,c;if(this.adds(r)){let a=r.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(r))if(a!==null&&this.deletes(a))o="delete",c=Dt(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=Dt(a.content.getContent())):(o="add",c=void 0)}else if(this.deletes(r))o="delete",c=Dt(r.content.getContent());else return;e.set(i,{action:o,oldValue:c})}}),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 X(pn);const t=this.target,n=ce(),i=ce(),r=[];if(e={added:n,deleted:i,delta:r,keys:this.keys},this.transaction.changed.get(t).has(null)){let c=null;const a=()=>{c&&r.push(c)};for(let l=t._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((c===null||c.delete===void 0)&&(a(),c={delete:0}),c.delete+=l.length,i.add(l)):this.adds(l)?((c===null||c.insert===void 0)&&(a(),c={insert:[]}),c.insert=c.insert.concat(l.content.getContent()),n.add(l)):((c===null||c.retain===void 0)&&(a(),c={retain:0}),c.retain+=l.length);c!==null&&c.retain===void 0&&a()}this._changes=e}return e}}const Xr=(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},kn=80;let es=0;class Gr{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=es++}}const Wr=s=>{s.timestamp=es++},mn=(s,e,t)=>{s.p.marker=!1,s.p=e,e.marker=!0,s.index=t,s.timestamp=es++},Pr=(s,e,t)=>{if(s.length>=kn){const n=s.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return mn(n,e,t),n}else{const n=new Gr(e,t);return s.push(n),n}},ht=(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)=>Pe(e-r.index)<Pe(e-o.index)?r:o);let n=s._start,i=0;for(t!==null&&(n=t.p,i=t.index,Wr(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&&Pe(t.index-i)<n.parent.length/kn?(mn(t,n,i),t):Pr(s._searchMarker,n,i)},He=(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=ae(e,i.index+t))}},ut=(s,e,t)=>{const n=s,i=e.changedParentTypes;for(;K(i,s,()=>[]).push(t),s._item!==null;)s=s._item.parent;on(n._eH,t,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=sn(),this._dEH=sn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw N()}clone(){throw N()}_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){nn(this._eH,e)}observeDeep(e){nn(this._dEH,e)}unobserve(e){rn(this._eH,e)}unobserveDeep(e){rn(this._dEH,e)}toJSON(){}}const bn=(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 c=e;c<o.length&&n>0;c++)i.push(o[c]),n--;e=0}}r=r.right}return i},wn=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},Ve=(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}},yn=(s,e)=>{const t=[];return Ve(s,(n,i)=>{t.push(e(n,i,s))}),t},Qr=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}}}},Sn=(s,e)=>{const t=ht(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}},dt=(s,e,t,n)=>{let i=t;const r=s.doc,o=r.clientID,c=r.store,a=t===null?e._start:t.right;let l=[];const h=()=>{l.length>0&&(i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.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 v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new qe(new Uint8Array(u))),i.integrate(s,0);break;case de:i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ye(u)),i.integrate(s,0);break;default:if(u instanceof I)i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new P(u)),i.integrate(s,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},_n=X("Length exceeded!"),Dn=(s,e,t,n)=>{if(t>e._length)throw _n;if(t===0)return e._searchMarker&&He(e._searchMarker,t,n.length),dt(s,e,null,n);const i=t,r=ht(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&&He(e._searchMarker,i,n.length),dt(s,e,o,n)},Zr=(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 dt(s,e,i,t)},Cn=(s,e,t,n)=>{if(n===0)return;const i=t,r=n,o=ht(e,t);let c=e._start;for(o!==null&&(c=o.p,t-=o.index);c!==null&&t>0;c=c.right)!c.deleted&&c.countable&&(t<c.length&&ie(s,w(c.id.client,c.id.clock+t)),t-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&ie(s,w(c.id.client,c.id.clock+n)),c.delete(s),n-=c.length),c=c.right;if(n>0)throw _n;e._searchMarker&&He(e._searchMarker,i,-r+n)},ft=(s,e,t)=>{const n=e._map.get(t);n!==void 0&&n.delete(s)},ts=(s,e,t,n)=>{const i=e._map.get(t)||null,r=s.doc,o=r.clientID;let c;if(n==null)c=new me([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c=new me([n]);break;case Uint8Array:c=new qe(n);break;case de:c=new Ye(n);break;default:if(n instanceof I)c=new P(n);else throw new Error("Unexpected content type")}new v(w(o,x(r.store,o)),i,i&&i.lastId,null,null,e,t,c).integrate(s,0)},ss=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},En=s=>{const e={};return s._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},vn=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted},gt=s=>wr(s.entries(),e=>!e[1].deleted);class eo extends lt{constructor(e,t){super(e,t),this._transaction=t}}class ve extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new ve;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ve}clone(){const e=new ve;return e.insert(0,this.toArray().map(t=>t instanceof I?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),ut(this,e,new eo(this,e))}insert(e,t){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?y(this.doc,t=>{Zr(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Cn(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Sn(this,e)}toArray(){return wn(this)}slice(e=0,t=this.length){return bn(this,e,t)}toJSON(){return this.map(e=>e instanceof I?e.toJSON():e)}map(e){return yn(this,e)}forEach(e){Ve(this,e)}[Symbol.iterator](){return Qr(this)}_write(e){e.writeTypeRef(Eo)}}const to=s=>new ve;class so extends lt{constructor(e,t,n){super(e,t),this.keysChanged=n}}class ge extends I{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 I?t.clone():t)}),e}_callObserver(e,t){ut(this,e,new so(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 I?i.toJSON():i}}),e}get size(){return[...gt(this._map)].length}keys(){return Vt(gt(this._map),e=>e[0])}values(){return Vt(gt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Vt(gt(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?y(this.doc,t=>{ft(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return ss(this,e)}has(e){return vn(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(t,n,i){ft(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(vo)}}const no=s=>new ge,oe=(s,e)=>s===e||typeof s=="object"&&typeof e=="object"&&s&&e&&Ii(s,e);class ns{constructor(e,t,n,i){this.left=e,this.right=t,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&B(),this.right.content.constructor){case E:this.right.deleted||Ae(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 An=(s,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case E:e.right.deleted||Ae(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},pt=(s,e,t)=>{const n=new Map,i=ht(e,t);if(i){const r=new ns(i.p.left,i.p,i.index,n);return An(s,r,t-i.index)}else{const r=new ns(null,e._start,0,n);return An(s,r,t)}},xn=(s,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===E&&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,c)=>{const a=t.left,l=t.right,h=new v(w(r,x(i.store,r)),a,a&&a.lastId,l,l&&l.id,e,null,new E(c,o));h.integrate(s,0),t.right=h,t.forward()})},Ae=(s,e)=>{const{key:t,value:n}=e;n===null?s.delete(t):s.set(t,n)},In=(s,e)=>{for(;s.right!==null;){if(!(s.right.deleted||s.right.content.constructor===E&&oe(e[s.right.content.key]||null,s.right.content.value)))break;s.forward()}},Ln=(s,e,t,n)=>{const i=s.doc,r=i.clientID,o=new Map;for(const c in n){const a=n[c],l=t.currentAttributes.get(c)||null;if(!oe(l,a)){o.set(c,l);const{left:h,right:u}=t;t.right=new v(w(r,x(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new E(c,a)),t.right.integrate(s,0),t.forward()}}return o},is=(s,e,t,n,i)=>{t.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=s.doc,o=r.clientID;In(t,i);const c=Ln(s,e,t,i),a=n.constructor===String?new H(n):n instanceof I?new P(n):new ke(n);let{left:l,right:h,index:u}=t;e._searchMarker&&He(e._searchMarker,t.index,a.getLength()),h=new v(w(o,x(r.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,a),h.integrate(s,0),t.right=h,t.index=u,t.forward(),xn(s,e,t,c)},jn=(s,e,t,n,i)=>{const r=s.doc,o=r.clientID;In(t,i);const c=Ln(s,e,t,i);e:for(;t.right!==null&&(n>0||c.size>0&&(t.right.deleted||t.right.content.constructor===E));){if(!t.right.deleted)switch(t.right.content.constructor){case E:{const{key:a,value:l}=t.right.content,h=i[a];if(h!==void 0){if(oe(h,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}t.right.delete(s)}else t.currentAttributes.set(a,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 a="";for(;n>0;n--)a+=`
2
- `;t.right=new v(w(o,x(r.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new H(a)),t.right.integrate(s,0),t.forward()}xn(s,e,t,c)},Mn=(s,e,t,n,i)=>{let r=e;const o=S();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===E){const l=r.content;o.set(l.key,l)}r=r.right}let c=0,a=!1;for(;e!==r;){if(t===e&&(a=!0),!e.deleted){const l=e.content;switch(l.constructor){case E:{const{key:h,value:u}=l,d=n.get(h)||null;(o.get(h)!==l||d===u)&&(e.delete(s),c++,!a&&(i.get(h)||null)===u&&d!==u&&(d===null?i.delete(h):i.set(h,d))),!a&&!e.deleted&&Ae(i,l);break}}}e=e.right}return c},io=(s,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===E){const n=e.content.key;t.has(n)?e.delete(s):t.add(n)}e=e.left}},ro=s=>{let e=0;return y(s.doc,t=>{let n=s._start,i=s._start,r=S();const o=q(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case E:Ae(o,i.content);break;default:e+=Mn(t,n,i,r,o),r=q(o),n=i;break}i=i.right}}),e},oo=s=>{const e=new Set,t=s.doc;for(const[n,i]of s.afterState.entries()){const r=s.beforeState.get(n)||0;i!==r&&hn(s,t.store.clients.get(n),r,i,o=>{!o.deleted&&o.content.constructor===E&&o.constructor!==z&&e.add(o.parent)})}y(t,n=>{qs(s,s.deleteSet,i=>{if(i instanceof z||!i.parent._hasFormatting||e.has(i.parent))return;const r=i.parent;i.content.constructor===E?e.add(r):io(n,i)});for(const i of e)ro(i)})},Tn=(s,e,t)=>{const n=t,i=q(e.currentAttributes),r=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case P:case ke:case H:t<e.right.length&&ie(s,w(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(s);break}e.forward()}r&&Mn(s,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&He(o._searchMarker,e.index,-n+t),e};class co extends lt{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];y(e,n=>{const i=new Map,r=new Map;let o=this.target._start,c=null;const a={};let l="",h=0,u=0;const d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},i.size>0&&(f.attributes={},i.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),l="";break;case"retain":h>0&&(f={retain:h},Ai(a)||(f.attributes=Di({},a))),h=0;break}f&&t.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case P:case ke:this.adds(o)?this.deletes(o)||(d(),c="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=1);break;case H:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),l+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=o.length);break;case E:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=i.get(f)||null;oe(m,g)?g!==null&&o.delete(n):(c==="retain"&&d(),oe(g,r.get(f)||null)?delete a[f]:a[f]=g)}}else if(this.deletes(o)){r.set(f,g);const m=i.get(f)||null;oe(m,g)||(c==="retain"&&d(),a[f]=m)}else if(!o.deleted){r.set(f,g);const m=a[f];m!==void 0&&(oe(m,g)?m!==null&&o.delete(n):(c==="retain"&&d(),g===null?delete a[f]:a[f]=g))}o.deleted||(c==="insert"&&d(),Ae(i,o.content));break}}o=o.right}for(d();t.length>0;){const f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class xe extends I{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new xe}clone(){const e=new xe;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new co(this,e,t);ut(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===H&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?y(this.doc,n=>{const i=new ns(null,this._start,0,new Map);for(let r=0;r<e.length;r++){const o=e[r];if(o.insert!==void 0){const c=!t&&typeof o.insert=="string"&&r===e.length-1&&i.right===null&&o.insert.slice(-1)===`
3
- `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&is(n,this,i,c,o.attributes||{})}else o.retain!==void 0?jn(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Tn(n,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){const i=[],r=new Map,o=this.doc;let c="",a=this._start;function l(){if(c.length>0){const u={};let d=!1;r.forEach((g,m)=>{d=!0,u[m]=g});const f={insert:c};d&&(f.attributes=u),i.push(f),c=""}}const h=()=>{for(;a!==null;){if(Fe(a,e)||t!==void 0&&Fe(a,t))switch(a.content.constructor){case H:{const u=r.get("ychange");e!==void 0&&!Fe(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(l(),r.set("ychange",n?n("removed",a.id):{type:"removed"})):t!==void 0&&!Fe(a,t)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(l(),r.set("ychange",n?n("added",a.id):{type:"added"})):u!==void 0&&(l(),r.delete("ychange")),c+=a.content.str;break}case P:case ke:{l();const u={insert:a.content.getContent()[0]};if(r.size>0){const d={};u.attributes=d,r.forEach((f,g)=>{d[g]=f})}i.push(u);break}case E:Fe(a,e)&&(l(),Ae(r,a.content));break}a=a.right}l()};return e||t?y(o,u=>{e&&Xt(u,e),t&&Xt(u,t),h()},"cleanup"):h(),i}insert(e,t,n){if(t.length<=0)return;const i=this.doc;i!==null?y(i,r=>{const o=pt(r,this,e);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c})),is(r,this,o,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n={}){const i=this.doc;i!==null?y(i,r=>{const o=pt(r,this,e);is(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?y(n,i=>{Tn(i,pt(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?y(i,r=>{const o=pt(r,this,e);o.right!==null&&jn(r,this,o,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){this.doc!==null?y(this.doc,t=>{ft(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ss(this,e)}getAttributes(){return En(this)}_write(e){e.writeTypeRef(Ao)}}const ao=s=>new xe;class rs{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===$e||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 I{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 I?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rs(this,e)}querySelector(e){e=e.toUpperCase();const n=new rs(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),te(new rs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ut(this,e,new uo(this,t,e))}toString(){return yn(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),Ve(this,r=>{i.insertBefore(r.toDOM(e,t,n),null)}),i}insert(e,t){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)y(this.doc,n=>{const i=e&&e instanceof I?e._item:e;dt(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 X("Reference item not found");n.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Cn(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return wn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Sn(this,e)}slice(e=0,t=this.length){return bn(this,e,t)}forEach(e){Ve(this,e)}_write(e){e.writeTypeRef(Io)}}const lo=s=>new pe;class $e 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 $e(this.nodeName)}clone(){const e=new $e(this.nodeName),t=this.getAttributes();return Ei(t,(n,i)=>{typeof n=="string"&&e.setAttribute(i,n)}),e.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),e}toString(){const e=this.getAttributes(),t=[],n=[];for(const c in e)n.push(c);n.sort();const i=n.length;for(let c=0;c<i;c++){const a=n[c];t.push(a+'="'+e[a]+'"')}const r=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${r}${o}>${super.toString()}</${r}>`}removeAttribute(e){this.doc!==null?y(this.doc,t=>{ft(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return ss(this,e)}hasAttribute(e){return vn(this,e)}getAttributes(){return En(this)}toDOM(e=document,t={},n){const i=e.createElement(this.nodeName),r=this.getAttributes();for(const o in r){const c=r[o];typeof c=="string"&&i.setAttribute(o,c)}return Ve(this,o=>{i.appendChild(o.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(xo),e.writeKey(this.nodeName)}}const ho=s=>new $e(s.readKey());class uo extends lt{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 kt extends ge{constructor(e){super(),this.hookName=e}_copy(){return new kt(this.hookName)}clone(){const e=new kt(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(Lo),e.writeKey(this.hookName)}}const fo=s=>new kt(s.readKey());class mt extends xe{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 mt}clone(){const e=new mt;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,c)=>o.key<c.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 c=r.attrs[o];n+=` ${c.key}="${c.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(jo)}}const go=s=>new mt;class os{constructor(e,t){this.id=e,this.length=t}get deleted(){throw N()}mergeWith(e){return!1}write(e,t,n){throw N()}integrate(e,t){throw N()}}const po=0;class z extends os{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),an(e.doc.store,this)}write(e,t){e.writeInfo(po),e.writeLen(this.length-t)}getMissing(e,t){return null}}class qe{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new qe(this.content)}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const ko=s=>new qe(s.readBuf());class Ke{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ke(this.len)}splice(e){const t=new Ke(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){it(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 mo=s=>new Ke(s.readLen()),Un=(s,e)=>new de({guid:s,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ye{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 Ye(Un(this.doc.guid,this.opts))}splice(e){throw N()}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 bo=s=>new Ye(Un(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 N()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const wo=s=>new ke(s.readJSON());class E{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new E(this.key,this.value)}splice(e){throw N()}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 yo=s=>new E(s.readKey(),s.readJSON());class bt{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new bt(this.arr)}splice(e){const t=new bt(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 So=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 bt(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 _o=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++)t.push(s.readAny());return new me(t)};class H{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(e){const t=new H(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 Do=s=>new H(s.readString()),Co=[to,no,ao,ho,lo,fo,go],Eo=0,vo=1,Ao=2,xo=3,Io=4,Lo=5,jo=6;class P{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new P(this.type._copy())}splice(e){throw N()}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 Mo=s=>new P(Co[s.readTypeRef()](s)),wt=(s,e,t)=>{const{client:n,clock:i}=e.id,r=new v(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 v extends os{constructor(e,t,n,i,r,o,c,a){super(e,a.getLength()),this.origin=n,this.left=t,this.right=i,this.rightOrigin=r,this.parent=o,this.parentSub=c,this.redone=null,this.content=a,this.info=this.content.isCountable()?xs:0}set marker(e){(this.info&Lt)>0!==e&&(this.info^=Lt)}get marker(){return(this.info&Lt)>0}get keep(){return(this.info&As)>0}set keep(e){this.keep!==e&&(this.info^=As)}get countable(){return(this.info&xs)>0}get deleted(){return(this.info&It)>0}set deleted(e){this.deleted!==e&&(this.info^=It)}markDeleted(){this.info|=It}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=x(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=x(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ee&&this.id.client!==this.parent.client&&this.parent.clock>=x(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ln(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===z||this.right&&this.right.constructor===z)&&(this.parent=null),!this.parent)this.left&&this.left.constructor===v&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===v&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ee){const n=Gt(t,this.parent);n.constructor===z?this.parent=null:this.parent=n.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ln(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),rt(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(rt(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Gt(e.doc.store,i.origin)))r.has(Gt(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),an(e.doc.store,this),this.content.integrate(e,this),dn(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new z(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&&rt(e.origin,this.lastId)&&this.right===e&&rt(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(),it(e.deleteSet,this.id.client,this.id.clock,this.length),dn(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw B();this.content.gc(e),t?Nr(e,this,new z(this.id,this.length)):this.content=new Ke(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()&Ze|(n===null?0:M)|(i===null?0:J)|(r===null?0:Ue);if(e.writeInfo(o),n!==null&&e.writeLeftID(n),i!==null&&e.writeRightID(i),n===null&&i===null){const c=this.parent;if(c._item!==void 0){const a=c._item;if(a===null){const l=Rr(c);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===Ee?(e.writeParentInfo(!1),e.writeLeftID(c)):B();r!==null&&e.writeString(r)}this.content.write(e,t)}}const zn=(s,e)=>To[e&Ze](s),To=[()=>{B()},mo,So,ko,Do,wo,yo,Mo,_o,bo,()=>{B()}],Uo=10;class O extends os{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){B()}write(e,t){e.writeInfo(Uo),p(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Rn="__ $YJS$ __";On[Rn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),On[Rn]=!0;const Nn=new Map;class zo{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:Ji(t.newValue||"")}),Si(this._onChange)}postMessage(e){Ds.setItem(this.room,Yi(Hi(e)))}close(){_i(this._onChange)}}const Oo=typeof BroadcastChannel>"u"?zo:BroadcastChannel,cs=s=>K(Nn,s,()=>{const e=ce(),t=new Oo(s);return t.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:t,subs:e}}),Ro=(s,e)=>(cs(s).subs.add(e),e),No=(s,e)=>{const t=cs(s),n=t.subs.delete(e);return n&&t.subs.size===0&&(t.bc.close(),Nn.delete(s)),n},Ie=(s,e,t=null)=>{const n=cs(s);n.bc.postMessage(e),n.subs.forEach(i=>i(e,t))},Bn=0,as=1,Fn=2,ls=(s,e)=>{p(s,Bn);const t=zr(e);C(s,t)},Hn=(s,e,t)=>{p(s,as),C(s,Jt(e,t))},Bo=(s,e,t)=>Hn(e,t,L(s)),Vn=(s,e,t)=>{try{Zs(e,L(s),t)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Fo=(s,e)=>{p(s,Fn),C(s,e)},Ho=Vn,Vo=(s,e,t,n)=>{const i=k(s);switch(i){case Bn:Bo(s,e,t);break;case as:Vn(s,t,n);break;case Fn:Ho(s,t,n);break;default:throw new Error("Unknown message type")}return i},$o=0,qo=(s,e,t)=>{switch(k(s)){case $o:t(e,ne(s))}},hs=3e4;class Ko extends We{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&&hs/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&hs<=t-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&us(this,n,"timeout")},Y(hs/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=[],c=[],a=[],l=[];e===null?l.push(t):r==null?e!=null&&o.push(t):(c.push(t),Te(r,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:c,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}const us=(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]))},Je=(s,e,t=s.states)=>{const n=e.length,i=j();p(i,n);for(let r=0;r<n;r++){const o=e[r],c=t.get(o)||null,a=s.meta.get(o).clock;p(i,o),p(i,a),he(i,JSON.stringify(c))}return _(i)},Yo=(s,e,t)=>{const n=se(e),i=ue(),r=[],o=[],c=[],a=[],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),D=g===void 0?0:g.clock;(D<d||D===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?a.push(u):f!==null&&(Te(f,m)||c.push(u),o.push(u)))}(r.length>0||c.length>0||a.length>0)&&s.emit("change",[{added:r,updated:c,removed:a},t]),(r.length>0||o.length>0||a.length>0)&&s.emit("update",[{added:r,updated:o,removed:a},t])},Jo=s=>vi(s,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var be=0,$n=3,Le=1,Xo=2,qn={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3};WebSocket.OPEN===void 0&&(Object.assign(WebSocket,qn),Object.assign(WebSocket.prototype,qn));var Go=typeof window>"u";function Wo(s,e){if(!s)throw new Error(e)}var Xe=[];Xe[be]=(s,e,t,n,i)=>{p(s,be);const r=Vo(e,s,t.doc,t);n&&r===as&&!t.synced&&(t.synced=!0)},Xe[$n]=(s,e,t,n,i)=>{p(s,Le),C(s,Je(t.awareness,Array.from(t.awareness.getStates().keys())))},Xe[Le]=(s,e,t,n,i)=>{Yo(t.awareness,L(e),t)},Xe[Xo]=(s,e,t,n,i)=>{qo(e,t.doc,(r,o)=>Po(t,o))};var Kn=3e4;function Po(s,e){console.warn(`Permission denied to access ${s.url}.
4
- ${e}`)}function Yn(s,e,t){const n=se(e),i=j(),r=k(n),o=s.messageHandlers[r];return o?o(i,n,s,t,r):console.error("Unable to compute message"),i}function Jn(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(t.data==="ping"){e.send("pong");return}s.wsLastMessageReceived=ue();const n=Yn(s,new Uint8Array(t.data),!0);Ot(n)>1&&e.send(_(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,us(s.awareness,Array.from(s.awareness.getStates().keys()).filter(n=>n!==s.doc.clientID),s),s.emit("status",[{status:"disconnected"}])):s.wsUnsuccessfulReconnects++,setTimeout(Jn,Ct(di(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=j();if(p(t,be),ls(t,s.doc),e.send(_(t)),s.awareness.getLocalState()!==null){const n=j();p(n,Le),C(n,Je(s.awareness,[s.doc.clientID])),e.send(_(n))}},s.emit("status",[{status:"connecting"}])}}function ds(s,e){const t=s.ws;s.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),s.bcconnected&&Ie(s.bcChannel,e,s)}var Qo=class extends We{constructor(e,t,n,{connect:i=!0,awareness:r=new Ko(n),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:a=-1,maxBackoffTime:l=2500,disableBc:h=Go}={}){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=Jo(o);this.maxBackoffTime=l,this.bcChannel=e+"/"+t,this.url=e+"/"+t+(u.length===0?"":"?"+u),this.roomname=t,this.doc=n,this._WS=c,this.awareness=r,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Xe.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,a>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=j();p(d,be),ls(d,n),this.ws.send(_(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Yn(this,new Uint8Array(d),!1);Ot(g)>1&&Ie(this.bcChannel,_(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=j();p(g,be),Fo(g,d),ds(this,_(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const D=d.concat(f).concat(g),ee=j();p(ee,Le),C(ee,Je(r,D)),ds(this,_(ee))},this._unloadHandler=()=>{us(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&&Kn<ue()-this.wsLastMessageReceived&&(Wo(this.ws!==null,"ws must not be null"),this.ws.close())},Kn/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||(Ro(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=j();p(e,be),ls(e,this.doc),Ie(this.bcChannel,_(e),this);const t=j();p(t,be),Hn(t,this.doc),Ie(this.bcChannel,_(t),this);const n=j();p(n,$n),Ie(this.bcChannel,_(n),this);const i=j();p(i,Le),C(i,Je(this.awareness,[this.doc.clientID])),Ie(this.bcChannel,_(i),this)}disconnectBc(){const e=j();p(e,Le),C(e,Je(this.awareness,[this.doc.clientID],new Map)),ds(this,_(e)),this.bcconnected&&(No(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&&(Jn(this),this.connectBc())}};function Zo(){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 Xn(s,e,t){if(typeof s!==t)throw new Error(`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${t}, received: ${s}`)}var ec=class extends Qo{constructor(e,t,n,i={}){Xn(e,"host","string"),Xn(t,"room","string"),e=e.replace(/^(http|https|ws|wss):\/\//,"");const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}${i.party?`/parties/${i.party}`:"/party"}`,o=Zo();i.params===void 0?i.params={_pk:o}:i.params._pk=o;super(r,t,n??new de,i);b(this,"id");this.id=o}};const we=s=>_e((e,t)=>{s.onerror=n=>t(new Error(n.target.error)),s.onsuccess=n=>e(n.target.result)}),tc=(s,e)=>_e((t,n)=>{const i=indexedDB.open(s);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(X(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),t(o)}}),sc=s=>we(indexedDB.deleteDatabase(s)),nc=(s,e)=>e.forEach(t=>s.createObjectStore.apply(s,t)),Ge=(s,e,t="readwrite")=>{const n=s.transaction(e,t);return e.map(i=>uc(n,i))},Gn=(s,e)=>we(s.count(e)),ic=(s,e)=>we(s.get(e)),Wn=(s,e)=>we(s.delete(e)),rc=(s,e,t)=>we(s.put(e,t)),fs=(s,e)=>we(s.add(e)),oc=(s,e,t)=>we(s.getAll(e,t)),cc=(s,e,t)=>{let n=null;return hc(s,e,i=>(n=i,!1),t).then(()=>n)},ac=(s,e=null)=>cc(s,e,"prev"),lc=(s,e)=>_e((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()}}),hc=(s,e,t,n="next")=>lc(s.openKeyCursor(e,n),i=>t(i.key)),uc=(s,e)=>s.objectStore(e),dc=(s,e)=>IDBKeyRange.upperBound(s,e),fc=(s,e)=>IDBKeyRange.lowerBound(s,e),gs="custom",Pn="updates",Qn=500,Zn=(s,e=()=>{},t=()=>{})=>{const[n]=Ge(s.db,[Pn]);return oc(n,fc(s._dbref,!1)).then(i=>{s._destroyed||(e(n),y(s.doc,()=>{i.forEach(r=>Zs(s.doc,r))},s,!1),t(n))}).then(()=>ac(n).then(i=>{s._dbref=i+1})).then(()=>Gn(n).then(i=>{s._dbsize=i})).then(()=>n)},gc=(s,e=!0)=>Zn(s).then(t=>{(e||s._dbsize>=Qn)&&fs(t,Jt(s.doc)).then(()=>Wn(t,dc(s._dbref,!0))).then(()=>Gn(t).then(n=>{s._dbsize=n}))});class pc extends We{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=tc(e,n=>nc(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=_e(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,Zn(this,o=>fs(o,Jt(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]=Ge(this.db,[Pn]);fs(r,n),++this._dbsize>=Qn&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{gc(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(()=>{sc(this.name)})}get(e){return this._db.then(t=>{const[n]=Ge(t,[gs],"readonly");return ic(n,e)})}set(e,t){return this._db.then(n=>{const[i]=Ge(n,[gs]);return rc(i,t,e)})}del(e){return this._db.then(t=>{const[n]=Ge(t,[gs]);return Wn(n,e)})}}const Yc="";var T=(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))(T||{});function kc(s){return s.id}function ei(s){return document.getElementById(s)}const mc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},bc="can-duplicate-to";var Q=(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))(Q||{});function wc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var yc=["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 Sc=wc(yc),ti=(s,e=300)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>s.apply(this,n),e)}},si=`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(U,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(U=typeof globalThis<"u"?globalThis:U||self,_(U.playhtml={}))})(this,function(U){"use strict";var Ta=Object.defineProperty;var Ua=(U,_,q)=>_ in U?Ta(U,_,{enumerable:!0,configurable:!0,writable:!0,value:q}):U[_]=q;var b=(U,_,q)=>(Ua(U,typeof _!="symbol"?_+"":_,q),q);const _=()=>new Map,q=s=>{const e=_();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},oi=(s,e)=>{const t=[];for(const[n,i]of s)t.push(e(i,n));return t},ai=(s,e)=>{for(const[t,n]of s)if(e(n,t))return!0;return!1},oe=()=>new Set,St=s=>s[s.length-1],ci=(s,e)=>{for(let t=0;t<e.length;t++)s.push(e[t])},ee=Array.from,li=Array.isArray;class Ge{constructor(){this._observers=_()}on(e,t){Y(this._observers,e,oe).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 ee((this._observers.get(e)||_()).values()).forEach(n=>n(...t))}destroy(){this._observers=_()}}const K=Math.floor,We=Math.abs,Dt=(s,e)=>s<e?s:e,ae=(s,e)=>s>e?s:e,hi=Math.pow,bs=s=>s!==0?s<0:1/s<0,ui=String.fromCharCode,di=s=>s.toLowerCase(),fi=/^\s*/g,gi=s=>s.replace(fi,""),pi=/([A-Z])/g,ws=(s,e)=>gi(s.replace(pi,t=>`${e}${di(t)}`)),ki=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},Ie=typeof TextEncoder<"u"?new TextEncoder:null,mi=Ie?s=>Ie.encode(s):ki;let je=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});je&&je.decode(new Uint8Array).length===1&&(je=null);const ys=s=>s===void 0?null:s;class bi{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let _s=new bi,Et=!0;try{typeof localStorage<"u"&&(_s=localStorage,Et=!1)}catch{}const Ss=_s,wi=s=>Et||addEventListener("storage",s),yi=s=>Et||removeEventListener("storage",s),_i=Object.assign,Si=Object.keys,Di=(s,e)=>{for(const t in s)e(s[t],t)},Ei=(s,e)=>{const t=[];for(const n in s)t.push(e(s[n],n));return t},Pe=s=>Si(s).length,Ci=s=>{for(const e in s)return!1;return!0},vi=(s,e)=>{for(const t in s)if(!e(s[t],t))return!1;return!0},Ds=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),Ai=(s,e)=>s===e||Pe(s)===Pe(e)&&vi(s,(t,n)=>(t!==void 0||Ds(e,n))&&e[n]===t),Ct=(s,e,t=0)=>{try{for(;t<s.length;t++)s[t](...e)}finally{t<s.length&&Ct(s,e,t+1)}},xi=s=>s,Li=(s,e)=>s===e,Me=(s,e)=>{if(s==null||e==null)return Li(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)||!Me(s.get(t),e.get(t)))return!1;break}case Object:if(Pe(s)!==Pe(e))return!1;for(const t in s)if(!Ds(s,t)||!Me(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(!Me(s[t],e[t]))return!1;break;default:return!1}return!0},Ii=(s,e)=>e.includes(s),we=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Es=typeof window<"u"&&typeof document<"u"&&!we;let R;const ji=()=>{if(R===void 0)if(we){R=_();const s=process.argv;let e=null;for(let t=0;t<s.length;t++){const n=s[t];n[0]==="-"?(e!==null&&R.set(e,""),e=n):e!==null&&(R.set(e,n),e=null)}e!==null&&R.set(e,"")}else typeof location=="object"?(R=_(),(location.search||"?").slice(1).split("&").forEach(s=>{if(s.length!==0){const[e,t]=s.split("=");R.set(`--${ws(e,"-")}`,t),R.set(`-${ws(e,"-")}`,t)}})):R=_();return R},vt=s=>ji().has(s),At=s=>ys(we?process.env[s.toUpperCase()]:Ss.getItem(s));(s=>vt("--"+s)||At(s)!==null)("production");const Cs=we&&Ii(process.env.FORCE_COLOR,["true","1","2"]),Mi=!vt("no-colors")&&(!we||process.stdout.isTTY||Cs)&&(!we||vt("color")||Cs||At("COLORTERM")!==null||(At("TERM")||"").includes("color")),vs=1,As=2,xt=4,Lt=8,Te=32,X=64,M=128,Qe=31,It=63,ce=127,Ti=2147483647,xs=Number.MAX_SAFE_INTEGER,Ui=Number.isInteger||(s=>typeof s=="number"&&isFinite(s)&&K(s)===s),J=s=>new Error(s),B=()=>{throw J("Method unimplemented")},N=()=>{throw J("Unexpected case")},Ls=J("Unexpected end of array"),Is=J("Integer out of Range");class Ze{constructor(e){this.arr=e,this.pos=0}}const te=s=>new Ze(s),zi=s=>s.pos!==s.arr.length,Oi=(s,e)=>{const t=Ut(s.arr.buffer,s.pos+s.arr.byteOffset,e);return s.pos+=e,t},I=s=>Oi(s,k(s)),ye=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&ce)*t,t*=128,i<M)return e;if(e>xs)throw Is}throw Ls},jt=s=>{let e=s.arr[s.pos++],t=e&It,n=64;const i=(e&X)>0?-1:1;if(!(e&M))return i*t;const r=s.arr.length;for(;s.pos<r;){if(e=s.arr[s.pos++],t=t+(e&ce)*n,n*=128,e<M)return i*t;if(t>xs)throw Is}throw Ls},se=je?s=>je.decode(I(s)):s=>{let e=k(s);if(e===0)return"";{let t=String.fromCodePoint(ye(s));if(--e<100)for(;e--;)t+=String.fromCodePoint(ye(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))}},Mt=(s,e)=>{const t=new DataView(s.arr.buffer,s.arr.byteOffset+s.pos,e);return s.pos+=e,t},Ri=[s=>{},s=>null,jt,s=>Mt(s,4).getFloat32(0,!1),s=>Mt(s,8).getFloat64(0,!1),s=>Mt(s,8).getBigInt64(0,!1),s=>!1,s=>!0,se,s=>{const e=k(s),t={};for(let n=0;n<e;n++){const i=se(s);t[i]=Ue(s)}return t},s=>{const e=k(s),t=[];for(let n=0;n<e;n++)t.push(Ue(s));return t},I],Ue=s=>Ri[127-ye(s)](s);class js extends Ze{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),zi(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class et extends Ze{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=jt(this);const e=bs(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class Tt extends Ze{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=jt(this),t=e&1;this.diff=K(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Bi{constructor(e){this.decoder=new et(e),this.str=se(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 Ms=s=>new Uint8Array(s),Ut=(s,e,t)=>new Uint8Array(s,e,t),Ni=s=>new Uint8Array(s),Fi=s=>{let e="";for(let t=0;t<s.byteLength;t++)e+=ui(s[t]);return btoa(e)},Vi=s=>Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("base64"),Hi=s=>{const e=atob(s),t=Ms(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},$i=s=>{const e=Buffer.from(s,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},qi=Es?Fi:Vi,Yi=Es?Hi:$i,Ki=s=>{const e=Ms(s.byteLength);return e.set(s),e};class ze{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const j=()=>new ze,zt=s=>{let e=s.cpos;for(let t=0;t<s.bufs.length;t++)e+=s.bufs[t].length;return e},S=s=>{const e=new Uint8Array(zt(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(Ut(s.cbuf.buffer,0,s.cpos),t),e},Xi=(s,e)=>{const t=s.cbuf.length;t-s.cpos<e&&(s.bufs.push(Ut(s.cbuf.buffer,0,s.cpos)),s.cbuf=new Uint8Array(ae(t,e)*2),s.cpos=0)},A=(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},Ot=A,p=(s,e)=>{for(;e>ce;)A(s,M|ce&e),e=K(e/128);A(s,ce&e)},Rt=(s,e)=>{const t=bs(e);for(t&&(e=-e),A(s,(e>It?M:0)|(t?X:0)|It&e),e=K(e/64);e>0;)A(s,(e>ce?M:0)|ce&e),e=K(e/128)},Bt=new Uint8Array(3e4),Ji=Bt.length/3,Gi=(s,e)=>{if(e.length<Ji){const t=Ie.encodeInto(e,Bt).written||0;p(s,t);for(let n=0;n<t;n++)A(s,Bt[n])}else E(s,mi(e))},Wi=(s,e)=>{const t=unescape(encodeURIComponent(e)),n=t.length;p(s,n);for(let i=0;i<n;i++)A(s,t.codePointAt(i))},le=Ie&&Ie.encodeInto?Gi:Wi,tt=(s,e)=>{const t=s.cbuf.length,n=s.cpos,i=Dt(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(ae(t*2,r)),s.cbuf.set(e.subarray(i)),s.cpos=r)},E=(s,e)=>{p(s,e.byteLength),tt(s,e)},Nt=(s,e)=>{Xi(s,e);const t=new DataView(s.cbuf.buffer,s.cpos,e);return s.cpos+=e,t},Pi=(s,e)=>Nt(s,4).setFloat32(0,e,!1),Qi=(s,e)=>Nt(s,8).setFloat64(0,e,!1),Zi=(s,e)=>Nt(s,8).setBigInt64(0,e,!1),Ts=new DataView(new ArrayBuffer(4)),er=s=>(Ts.setFloat32(0,s),Ts.getFloat32(0)===s),Oe=(s,e)=>{switch(typeof e){case"string":A(s,119),le(s,e);break;case"number":Ui(e)&&We(e)<=Ti?(A(s,125),Rt(s,e)):er(e)?(A(s,124),Pi(s,e)):(A(s,123),Qi(s,e));break;case"bigint":A(s,122),Zi(s,e);break;case"object":if(e===null)A(s,126);else if(li(e)){A(s,117),p(s,e.length);for(let t=0;t<e.length;t++)Oe(s,e[t])}else if(e instanceof Uint8Array)A(s,116),E(s,e);else{A(s,118);const t=Object.keys(e);p(s,t.length);for(let n=0;n<t.length;n++){const i=t[n];le(s,i),Oe(s,e[i])}}break;case"boolean":A(s,e?120:121);break;default:A(s,127)}};class Us extends ze{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 zs=s=>{s.count>0&&(Rt(s.encoder,s.count===1?s.s:-s.s),s.count>1&&p(s.encoder,s.count-2))};class st{constructor(){this.encoder=new ze,this.s=0,this.count=0}write(e){this.s===e?this.count++:(zs(this),this.count=1,this.s=e)}toUint8Array(){return zs(this),S(this.encoder)}}const Os=s=>{if(s.count>0){const e=s.diff*2+(s.count===1?0:1);Rt(s.encoder,e),s.count>1&&p(s.encoder,s.count-2)}};class Ft{constructor(){this.encoder=new ze,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Os(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Os(this),S(this.encoder)}}class tr{constructor(){this.sarr=[],this.s="",this.lensE=new st}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 ze;return this.sarr.push(this.s),this.s="",le(e,this.sarr.join("")),tt(e,this.lensE.toUint8Array()),S(e)}}const sr=crypto.getRandomValues.bind(crypto),Rs=()=>sr(new Uint32Array(1))[0],nr=[1e7]+-1e3+-4e3+-8e3+-1e11,ir=()=>nr.replace(/[018]/g,s=>(s^Rs()&15>>s/4).toString(16)),he=Date.now,_e=s=>new Promise(s);Promise.all.bind(Promise);class rr{constructor(e,t){this.left=e,this.right=t}}const G=(s,e)=>new rr(s,e);typeof DOMParser<"u"&&new DOMParser;const or=s=>oi(s,(e,t)=>`${t}:${e};`).join(""),W=Symbol,Bs=W(),Ns=W(),ar=W(),cr=W(),lr=W(),Fs=W(),hr=W(),Vs=W(),ur=W(),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},fr={[Bs]:G("font-weight","bold"),[Ns]:G("font-weight","normal"),[ar]:G("color","blue"),[lr]:G("color","green"),[cr]:G("color","grey"),[Fs]:G("color","red"),[hr]:G("color","purple"),[Vs]:G("color","orange"),[ur]:G("color","black")},gr=Mi?s=>{const e=[],t=[],n=_();let i=[],r=0;for(;r<s.length;r++){const o=s[r],a=fr[o];if(a!==void 0)n.set(a.left,a.right);else if(o.constructor===String||o.constructor===Number){const c=or(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,pr=(...s)=>{console.log(...gr(s)),kr.forEach(e=>e.print(s))},kr=oe(),Hs=s=>({[Symbol.iterator](){return this},next:s}),mr=(s,e)=>Hs(()=>{let t;do t=s.next();while(!t.done&&!e(t.value));return t}),Vt=(s,e)=>Hs(()=>{const{done:t,value:n}=s.next();return{done:t,value:t?void 0:e(n)}});class Ht{constructor(e,t){this.clock=e,this.len=t}}class Re{constructor(){this.clients=new Map}}const $s=(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];ln(s,r,a.clock,a.len,t)}}),br=(s,e)=>{let t=0,n=s.length-1;for(;t<=n;){const i=K((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},qs=(s,e)=>{const t=s.clients.get(e.client);return t!==void 0&&br(t,e.clock)!==null},$t=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=ae(i.len,r.clock+r.len-i.clock):(n<t&&(e[n]=r),n++)}e.length=n})},wr=s=>{const e=new Re;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++)ci(r,s[o].clients.get(i)||[]);e.clients.set(i,r)}});return $t(e),e},nt=(s,e,t,n)=>{Y(s.clients,e,()=>[]).push(new Ht(t,n))},yr=()=>new Re,_r=s=>{const e=yr();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 Ht(a,c))}}i.length>0&&e.clients.set(n,i)}),e},Se=(s,e)=>{p(s.restEncoder,e.clients.size),ee(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)}})},qt=s=>{const e=new Re,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 Ht(s.readDsClock(),s.readDsLen()))}}return e},Ys=(s,e,t)=>{const n=new Re,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=x(t,o);for(let h=0;h<a;h++){const u=s.readDsClock(),d=u+s.readDsLen();if(u<l){l<d&&nt(n,o,l,d-l);let f=F(c,u),g=c[f];for(!g.deleted&&g.id.clock<u&&(c.splice(f+1,0,bt(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,bt(e,g,d-g.id.clock)),g.delete(e))}else nt(n,o,u,d-u)}}if(n.clients.size>0){const r=new de;return p(r.restEncoder,0),Se(r,n),r.toUint8Array()}return null},Ks=Rs;class ue extends Ge{constructor({guid:e=ir(),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=Ks(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new on,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=_e(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const c=()=>_e(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&&y(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ee(this.subdocs).map(e=>e.guid))}transact(e,t=null){return y(this,e,t)}get(e,t=L){const n=Y(this.share,e,()=>{const r=new t;return r._integrate(this,null),r}),i=n.constructor;if(t!==L&&i!==t)if(i===L){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,Ce)}getText(e=""){return this.get(e,Ae)}getMap(e=""){return this.get(e,fe)}getXmlFragment(e=""){return this.get(e,ge)}toJSON(){const e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){ee(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new ue({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,y(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 Xs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Js extends Xs{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 ye(this.restDecoder)}readString(){return se(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Ue(this.restDecoder)}readBuf(){return Ki(I(this.restDecoder))}readJSON(){return JSON.parse(se(this.restDecoder))}readKey(){return se(this.restDecoder)}}class Sr{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 De extends Sr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Tt(I(e)),this.clientDecoder=new et(I(e)),this.leftClockDecoder=new Tt(I(e)),this.rightClockDecoder=new Tt(I(e)),this.infoDecoder=new js(I(e),ye),this.stringDecoder=new Bi(I(e)),this.parentInfoDecoder=new js(I(e),ye),this.typeRefDecoder=new et(I(e)),this.lenDecoder=new et(I(e))}readLeftID(){return new Ee(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ee(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 Ue(this.restDecoder)}readBuf(){return I(this.restDecoder)}readJSON(){return Ue(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 Gs{constructor(){this.restEncoder=j()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Be extends Gs{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){Ot(this.restEncoder,e)}writeString(e){le(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){Oe(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){le(this.restEncoder,JSON.stringify(e))}writeKey(e){le(this.restEncoder,e)}}class Ws{constructor(){this.restEncoder=j(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,t)}writeDsLen(e){e===0&&N(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class de extends Ws{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ft,this.clientEncoder=new st,this.leftClockEncoder=new Ft,this.rightClockEncoder=new Ft,this.infoEncoder=new Us(Ot),this.stringEncoder=new tr,this.parentInfoEncoder=new Us(Ot),this.typeRefEncoder=new st,this.lenEncoder=new st}toUint8Array(){const e=j();return p(e,0),E(e,this.keyClockEncoder.toUint8Array()),E(e,this.clientEncoder.toUint8Array()),E(e,this.leftClockEncoder.toUint8Array()),E(e,this.rightClockEncoder.toUint8Array()),E(e,S(this.infoEncoder)),E(e,this.stringEncoder.toUint8Array()),E(e,S(this.parentInfoEncoder)),E(e,this.typeRefEncoder.toUint8Array()),E(e,this.lenEncoder.toUint8Array()),tt(e,S(this.restEncoder)),S(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){Oe(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){Oe(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 Dr=(s,e,t,n)=>{n=ae(n,e[0].id.clock);const i=F(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)},Yt=(s,e,t)=>{const n=new Map;t.forEach((i,r)=>{x(e,r)>i&&n.set(r,i)}),rt(e).forEach((i,r)=>{t.has(r)||n.set(r,0)}),p(s.restEncoder,n.size),ee(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{Dr(s,e.clients.get(i),i,r)})},Er=(s,e)=>{const t=_(),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(Qe&h){case 0:{const u=s.readLen();o[l]=new z(w(a,c),u),c+=u;break}case 10:{const u=k(s.restDecoder);o[l]=new O(w(a,c),u),c+=u;break}default:{const u=(h&(X|M))===0,d=new v(w(a,c),null,(h&M)===M?s.readLeftID():null,null,(h&X)===X?s.readRightID():null,u?s.readParentInfo()?e.get(s.readString()):s.readLeftID():null,u&&(h&Te)===Te?s.readString():null,Un(s,h));o[l]=d,c+=d.length}}}}return t},Cr=(s,e,t)=>{const n=[];let i=ee(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 on,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(D=>D!==g)}n.length=0};for(;;){if(h.constructor!==O){const g=Y(u,h.id.client,()=>x(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 D=t.get(m)||{refs:[],i:0};if(D.refs.length===D.i)l(m,x(e,m)),d();else{h=D.refs[D.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 de;return Yt(f,a,new Map),p(f.restEncoder,0),{missing:c,update:f.toUint8Array()}}return null},vr=(s,e)=>Yt(s,e.doc.store,e.beforeState),Ar=(s,e,t,n=new De(s))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,a=o.store,c=Er(n,o),l=Cr(i,a,c),h=a.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<x(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=at([h.update,l.update])}}else a.pendingStructs=l;const u=Ys(n,i,a);if(a.pendingDs){const d=new De(te(a.pendingDs));k(d.restDecoder);const f=Ys(d,i,a);u&&f?a.pendingDs=at([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(r){const d=a.pendingStructs.update;a.pendingStructs=null,Ps(i.doc,d)}},t,!1),Ps=(s,e,t,n=De)=>{const i=te(e);Ar(i,s,t,new n(i))},Qs=(s,e,t)=>Ps(s,e,t,Js),xr=(s,e,t=new Map)=>{Yt(s,e.store,t),Se(s,_r(e.store))},Lr=(s,e=new Uint8Array([0]),t=new de)=>{const n=Zs(e);xr(t,s,n);const i=[t.toUint8Array()];if(s.store.pendingDs&&i.push(s.store.pendingDs),s.store.pendingStructs&&i.push($r(s.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Be)return Vr(i.map((r,o)=>o===0?r:Yr(r)));if(t.constructor===de)return at(i)}return i[0]},Kt=(s,e)=>Lr(s,e,new Be),Ir=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},Zs=s=>Ir(new Xs(te(s))),en=(s,e)=>(p(s.restEncoder,e.size),ee(e.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{p(s.restEncoder,t),p(s.restEncoder,n)}),s),jr=(s,e)=>en(s,rt(e.store)),Mr=(s,e=new Ws)=>(s instanceof Map?en(e,s):jr(e,s),e.toUint8Array()),Tr=s=>Mr(s,new Gs);class Ur{constructor(){this.l=[]}}const tn=()=>new Ur,sn=(s,e)=>s.l.push(e),nn=(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.")},rn=(s,e,t)=>Ct(s.l,[e,t]);class Ee{constructor(e,t){this.client=e,this.clock=t}}const it=(s,e)=>s===e||s!==null&&e!==null&&s.client===e.client&&s.clock===e.clock,w=(s,e)=>new Ee(s,e),zr=s=>{for(const[e,t]of s.doc.share.entries())if(t===s)return e;throw N()},Ne=(s,e)=>e===void 0?!s.deleted:e.sv.has(s.id.client)&&(e.sv.get(s.id.client)||0)>s.id.clock&&!qs(e.ds,s.id),Xt=(s,e)=>{const t=Y(s.meta,Xt,oe),n=s.doc.store;t.has(e)||(e.sv.forEach((i,r)=>{i<x(n,r)&&ne(s,w(r,i))}),$s(s,e.ds,i=>{}),t.add(e))};class on{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const rt=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},x=(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},an=(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 N()}t.push(e)},F=(s,e)=>{let t=0,n=s.length-1,i=s[n],r=i.id.clock;if(r===e)return n;let o=K(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=K((t+n)/2)}throw N()},Jt=(s,e)=>{const t=s.clients.get(e.client);return t[F(t,e.clock)]},Gt=(s,e,t)=>{const n=F(e,t),i=e[n];return i.id.clock<t&&i instanceof v?(e.splice(n+1,0,bt(s,i,t-i.id.clock)),n+1):n},ne=(s,e)=>{const t=s.doc.store.clients.get(e.client);return t[Gt(s,t,e.clock)]},cn=(s,e,t)=>{const n=e.clients.get(t.client),i=F(n,t.clock),r=n[i];return t.clock!==r.id.clock+r.length-1&&r.constructor!==z&&n.splice(i+1,0,bt(s,r,t.clock-r.id.clock+1)),r},Or=(s,e,t)=>{const n=s.clients.get(e.id.client);n[F(n,e.id.clock)]=t},ln=(s,e,t,n,i)=>{if(n===0)return;const r=t+n;let o=Gt(s,e,t),a;do a=e[o++],r<a.id.clock+a.length&&Gt(s,e,r),i(a);while(o<e.length&&e[o].id.clock<r)};class Rr{constructor(e,t,n){this.doc=e,this.deleteSet=new Re,this.beforeState=rt(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 hn=(s,e)=>e.deleteSet.clients.size===0&&!ai(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:($t(e.deleteSet),vr(s,e),Se(s,e.deleteSet),!0),un=(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,oe).add(t)},ot=(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 v&&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},Br=(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=F(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 v&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Nr=(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=Dt(i.length-1,1+F(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+ot(i,c)}})},dn=(s,e)=>{if(e<s.length){const t=s[e],n=t.doc,i=n.store,r=t.deleteSet,o=t._mergeStructs;try{$t(r),t.afterState=rt(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),rn(l._dEH,c,t))})}),a.push(()=>n.emit("afterTransaction",[t,n])),Ct(a,[]),t._needFormattingCleanup&&io(t)}finally{n.gc&&Br(r,i,n.gcFilter),Nr(r,i),t.afterState.forEach((h,u)=>{const d=t.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ae(F(f,d),1);for(let m=f.length-1;m>=g;)m-=1+ot(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=F(f,d);g+1<f.length&&ot(f,g+1)>1||g>0&&ot(f,g)}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(pr(Vs,Bs,"[yjs] ",Ns,Fs,"Changed the client-id because another client seems to be using it."),n.clientID=Ks()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){const h=new Be;hn(h,t)&&n.emit("update",[h.toUint8Array(),t.origin,n,t])}if(n._observers.has("updateV2")){const h=new de;hn(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])):dn(s,e+1)}}},y=(s,e,t=null,n=!0)=>{const i=s._transactionCleanups;let r=!1,o=null;s._transaction===null&&(r=!0,s._transaction=new Rr(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&&dn(i,0)}}return o};function*Fr(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 O(w(i,r),c),r+=c}else if(Qe&a){const c=(a&(X|M))===0,l=new v(w(i,r),null,(a&M)===M?s.readLeftID():null,null,(a&X)===X?s.readRightID():null,c?s.readParentInfo()?s.readString():s.readLeftID():null,c&&(a&Te)===Te?s.readString():null,Un(s,a));yield l,r+=l.length}else{const c=s.readLen();yield new z(w(i,r),c),r+=c}}}}class Wt{constructor(e,t){this.gen=Fr(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===O);return this.curr}}class Pt{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Vr=s=>at(s,Js,Be),Hr=(s,e)=>{if(s.constructor===z){const{client:t,clock:n}=s.id;return new z(w(t,n+e),s.length-e)}else if(s.constructor===O){const{client:t,clock:n}=s.id;return new O(w(t,n+e),s.length-e)}else{const t=s,{client:n,clock:i}=t.id;return new v(w(n,i+e),null,w(n,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},at=(s,e=De,t=de)=>{if(s.length===1)return s[0];const n=s.map(h=>new e(te(h)));let i=n.map(h=>new Wt(h,!0)),r=null;const o=new t,a=new Pt(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===O?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)ie(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===O)r.struct.length=d.id.clock+d.length-r.struct.id.clock;else{ie(a,r.struct,r.offset);const g=d.id.clock-r.struct.id.clock-r.struct.length;r={struct:new O(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===O?r.struct.length-=g:d=Hr(d,g)),r.struct.mergeWith(d)||(ie(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!==O;d=h.next())ie(a,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(ie(a,r.struct,r.offset),r=null),Qt(a);const c=n.map(h=>qt(h)),l=wr(c);return Se(o,l),o.toUint8Array()},$r=(s,e,t=De,n=de)=>{const i=Zs(e),r=new n,o=new Pt(r),a=new t(te(s)),c=new Wt(a,!1);for(;c.curr;){const h=c.curr,u=h.id.client,d=i.get(u)||0;if(c.curr.constructor===O){c.next();continue}if(h.id.clock+h.length>d)for(ie(o,h,ae(d-h.id.clock,0)),c.next();c.curr&&c.curr.id.client===u;)ie(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()}Qt(o);const l=qt(a);return Se(r,l),r.toUint8Array()},fn=s=>{s.written>0&&(s.clientStructs.push({written:s.written,restEncoder:S(s.encoder.restEncoder)}),s.encoder.restEncoder=j(),s.written=0)},ie=(s,e,t)=>{s.written>0&&s.currClient!==e.id.client&&fn(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++},Qt=s=>{fn(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),tt(e,n.restEncoder)}},qr=(s,e,t,n)=>{const i=new t(te(s)),r=new Wt(i,!1),o=new n,a=new Pt(o);for(let l=r.curr;l!==null;l=r.next())ie(a,e(l),0);Qt(a);const c=qt(i);return Se(o,c),o.toUint8Array()},Yr=s=>qr(s,xi,De,Be),gn="You must not compute changes after the event-handler fired.";class ct{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=Kr(this.currentTarget,this.target))}deletes(e){return qs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw J(gn);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=St(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",a=St(c.content.getContent())):(o="add",a=void 0)}else if(this.deletes(r))o="delete",a=St(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 J(gn);const t=this.target,n=oe(),i=oe(),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 Kr=(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},pn=80;let Zt=0;class Xr{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Zt++}}const Jr=s=>{s.timestamp=Zt++},kn=(s,e,t)=>{s.p.marker=!1,s.p=e,e.marker=!0,s.index=t,s.timestamp=Zt++},Gr=(s,e,t)=>{if(s.length>=pn){const n=s.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return kn(n,e,t),n}else{const n=new Xr(e,t);return s.push(n),n}},lt=(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)=>We(e-r.index)<We(e-o.index)?r:o);let n=s._start,i=0;for(t!==null&&(n=t.p,i=t.index,Jr(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&&We(t.index-i)<n.parent.length/pn?(kn(t,n,i),t):Gr(s._searchMarker,n,i)},Fe=(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=ae(e,i.index+t))}},ht=(s,e,t)=>{const n=s,i=e.changedParentTypes;for(;Y(i,s,()=>[]).push(t),s._item!==null;)s=s._item.parent;rn(n._eH,t,e)};class L{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=tn(),this._dEH=tn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw B()}clone(){throw B()}_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){sn(this._eH,e)}observeDeep(e){sn(this._dEH,e)}unobserve(e){nn(this._eH,e)}unobserveDeep(e){nn(this._dEH,e)}toJSON(){}}const mn=(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},bn=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},Ve=(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}},wn=(s,e)=>{const t=[];return Ve(s,(n,i)=>{t.push(e(n,i,s))}),t},Wr=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}}}},yn=(s,e)=>{const t=lt(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}},ut=(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 v(w(o,x(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new ke(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 v(w(o,x(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new $e(new Uint8Array(u))),i.integrate(s,0);break;case ue:i=new v(w(o,x(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Ye(u)),i.integrate(s,0);break;default:if(u instanceof L)i=new v(w(o,x(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new P(u)),i.integrate(s,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},_n=()=>J("Length exceeded!"),Sn=(s,e,t,n)=>{if(t>e._length)throw _n();if(t===0)return e._searchMarker&&Fe(e._searchMarker,t,n.length),ut(s,e,null,n);const i=t,r=lt(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&&ne(s,w(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Fe(e._searchMarker,i,n.length),ut(s,e,o,n)},Pr=(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 ut(s,e,i,t)},Dn=(s,e,t,n)=>{if(n===0)return;const i=t,r=n,o=lt(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&&ne(s,w(a.id.client,a.id.clock+t)),t-=a.length);for(;n>0&&a!==null;)a.deleted||(n<a.length&&ne(s,w(a.id.client,a.id.clock+n)),a.delete(s),n-=a.length),a=a.right;if(n>0)throw _n();e._searchMarker&&Fe(e._searchMarker,i,-r+n)},dt=(s,e,t)=>{const n=e._map.get(t);n!==void 0&&n.delete(s)},es=(s,e,t,n)=>{const i=e._map.get(t)||null,r=s.doc,o=r.clientID;let a;if(n==null)a=new ke([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:a=new ke([n]);break;case Uint8Array:a=new $e(n);break;case ue:a=new Ye(n);break;default:if(n instanceof L)a=new P(n);else throw new Error("Unexpected content type")}new v(w(o,x(r.store,o)),i,i&&i.lastId,null,null,e,t,a).integrate(s,0)},ts=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},En=s=>{const e={};return s._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},Cn=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted},ft=s=>mr(s.entries(),e=>!e[1].deleted);class Qr extends ct{constructor(e,t){super(e,t),this._transaction=t}}class Ce extends L{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Ce;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ce}clone(){const e=new Ce;return e.insert(0,this.toArray().map(t=>t instanceof L?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),ht(this,e,new Qr(this,e))}insert(e,t){this.doc!==null?y(this.doc,n=>{Sn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?y(this.doc,t=>{Pr(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return yn(this,e)}toArray(){return bn(this)}slice(e=0,t=this.length){return mn(this,e,t)}toJSON(){return this.map(e=>e instanceof L?e.toJSON():e)}map(e){return wn(this,e)}forEach(e){Ve(this,e)}[Symbol.iterator](){return Wr(this)}_write(e){e.writeTypeRef(Do)}}const Zr=s=>new Ce;class eo extends ct{constructor(e,t,n){super(e,t),this.keysChanged=n}}class fe extends L{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 fe}clone(){const e=new fe;return this.forEach((t,n)=>{e.set(n,t instanceof L?t.clone():t)}),e}_callObserver(e,t){ht(this,e,new eo(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 L?i.toJSON():i}}),e}get size(){return[...ft(this._map)].length}keys(){return Vt(ft(this._map),e=>e[0])}values(){return Vt(ft(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Vt(ft(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?y(this.doc,t=>{dt(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?y(this.doc,n=>{es(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return ts(this,e)}has(e){return Cn(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(t,n,i){dt(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Eo)}}const to=s=>new fe,re=(s,e)=>s===e||typeof s=="object"&&typeof e=="object"&&s&&e&&Ai(s,e);class ss{constructor(e,t,n,i){this.left=e,this.right=t,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&N(),this.right.content.constructor){case C:this.right.deleted||ve(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 vn=(s,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case C:e.right.deleted||ve(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&ne(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},gt=(s,e,t)=>{const n=new Map,i=lt(e,t);if(i){const r=new ss(i.p.left,i.p,i.index,n);return vn(s,r,t-i.index)}else{const r=new ss(null,e._start,0,n);return vn(s,r,t)}},An=(s,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===C&&re(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 v(w(r,x(i.store,r)),c,c&&c.lastId,l,l&&l.id,e,null,new C(a,o));h.integrate(s,0),t.right=h,t.forward()})},ve=(s,e)=>{const{key:t,value:n}=e;n===null?s.delete(t):s.set(t,n)},xn=(s,e)=>{for(;s.right!==null;){if(!(s.right.deleted||s.right.content.constructor===C&&re(e[s.right.content.key]||null,s.right.content.value)))break;s.forward()}},Ln=(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(!re(l,c)){o.set(a,l);const{left:h,right:u}=t;t.right=new v(w(r,x(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new C(a,c)),t.right.integrate(s,0),t.forward()}}return o},ns=(s,e,t,n,i)=>{t.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=s.doc,o=r.clientID;xn(t,i);const a=Ln(s,e,t,i),c=n.constructor===String?new V(n):n instanceof L?new P(n):new pe(n);let{left:l,right:h,index:u}=t;e._searchMarker&&Fe(e._searchMarker,t.index,c.getLength()),h=new v(w(o,x(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(),An(s,e,t,a)},In=(s,e,t,n,i)=>{const r=s.doc,o=r.clientID;xn(t,i);const a=Ln(s,e,t,i);e:for(;t.right!==null&&(n>0||a.size>0&&(t.right.deleted||t.right.content.constructor===C));){if(!t.right.deleted)switch(t.right.content.constructor){case C:{const{key:c,value:l}=t.right.content,h=i[c];if(h!==void 0){if(re(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&&ne(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
+ `;t.right=new v(w(o,x(r.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new V(c)),t.right.integrate(s,0),t.forward()}An(s,e,t,a)},jn=(s,e,t,n,i)=>{let r=e;const o=_();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===C){const l=r.content;o.set(l.key,l)}r=r.right}let a=0,c=!1;for(;e!==r;){if(t===e&&(c=!0),!e.deleted){const l=e.content;switch(l.constructor){case C:{const{key:h,value:u}=l,d=n.get(h)||null;(o.get(h)!==l||d===u)&&(e.delete(s),a++,!c&&(i.get(h)||null)===u&&d!==u&&(d===null?i.delete(h):i.set(h,d))),!c&&!e.deleted&&ve(i,l);break}}}e=e.right}return a},so=(s,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===C){const n=e.content.key;t.has(n)?e.delete(s):t.add(n)}e=e.left}},no=s=>{let e=0;return y(s.doc,t=>{let n=s._start,i=s._start,r=_();const o=q(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case C:ve(o,i.content);break;default:e+=jn(t,n,i,r,o),r=q(o),n=i;break}i=i.right}}),e},io=s=>{const e=new Set,t=s.doc;for(const[n,i]of s.afterState.entries()){const r=s.beforeState.get(n)||0;i!==r&&ln(s,t.store.clients.get(n),r,i,o=>{!o.deleted&&o.content.constructor===C&&o.constructor!==z&&e.add(o.parent)})}y(t,n=>{$s(s,s.deleteSet,i=>{if(i instanceof z||!i.parent._hasFormatting||e.has(i.parent))return;const r=i.parent;i.content.constructor===C?e.add(r):so(n,i)});for(const i of e)no(i)})},Mn=(s,e,t)=>{const n=t,i=q(e.currentAttributes),r=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case P:case pe:case V:t<e.right.length&&ne(s,w(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(s);break}e.forward()}r&&jn(s,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Fe(o._searchMarker,e.index,-n+t),e};class ro extends ct{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];y(e,n=>{const i=new Map,r=new Map;let o=this.target._start,a=null;const c={};let l="",h=0,u=0;const d=()=>{if(a!==null){let f=null;switch(a){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},i.size>0&&(f.attributes={},i.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),l="";break;case"retain":h>0&&(f={retain:h},Ci(c)||(f.attributes=_i({},c))),h=0;break}f&&t.push(f),a=null}};for(;o!==null;){switch(o.content.constructor){case P:case pe:this.adds(o)?this.deletes(o)||(d(),a="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),u+=1):o.deleted||(a!=="retain"&&(d(),a="retain"),h+=1);break;case V:this.adds(o)?this.deletes(o)||(a!=="insert"&&(d(),a="insert"),l+=o.content.str):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),u+=o.length):o.deleted||(a!=="retain"&&(d(),a="retain"),h+=o.length);break;case C:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=i.get(f)||null;re(m,g)?g!==null&&o.delete(n):(a==="retain"&&d(),re(g,r.get(f)||null)?delete c[f]:c[f]=g)}}else if(this.deletes(o)){r.set(f,g);const m=i.get(f)||null;re(m,g)||(a==="retain"&&d(),c[f]=m)}else if(!o.deleted){r.set(f,g);const m=c[f];m!==void 0&&(re(m,g)?m!==null&&o.delete(n):(a==="retain"&&d(),g===null?delete c[f]:c[f]=g))}o.deleted||(a==="insert"&&d(),ve(i,o.content));break}}o=o.right}for(d();t.length>0;){const f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class Ae extends L{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new Ae}clone(){const e=new Ae;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new ro(this,e,t);ht(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===V&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?y(this.doc,n=>{const i=new ss(null,this._start,0,new Map);for(let r=0;r<e.length;r++){const o=e[r];if(o.insert!==void 0){const a=!t&&typeof o.insert=="string"&&r===e.length-1&&i.right===null&&o.insert.slice(-1)===`
3
+ `?o.insert.slice(0,-1):o.insert;(typeof a!="string"||a.length>0)&&ns(n,this,i,a,o.attributes||{})}else o.retain!==void 0?In(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Mn(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(Ne(c,e)||t!==void 0&&Ne(c,t))switch(c.content.constructor){case V:{const u=r.get("ychange");e!==void 0&&!Ne(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&&!Ne(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 P:case pe:{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 C:Ne(c,e)&&(l(),ve(r,c.content));break}c=c.right}l()};return e||t?y(o,u=>{e&&Xt(u,e),t&&Xt(u,t),h()},"cleanup"):h(),i}insert(e,t,n){if(t.length<=0)return;const i=this.doc;i!==null?y(i,r=>{const o=gt(r,this,e);n||(n={},o.currentAttributes.forEach((a,c)=>{n[c]=a})),ns(r,this,o,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n={}){const i=this.doc;i!==null?y(i,r=>{const o=gt(r,this,e);ns(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?y(n,i=>{Mn(i,gt(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?y(i,r=>{const o=gt(r,this,e);o.right!==null&&In(r,this,o,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){this.doc!==null?y(this.doc,t=>{dt(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{es(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ts(this,e)}getAttributes(){return En(this)}_write(e){e.writeTypeRef(Co)}}const oo=s=>new Ae;class is{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===He||t.constructor===ge)&&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 ge extends L{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 ge}clone(){const e=new ge;return e.insert(0,this.toArray().map(t=>t instanceof L?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new is(this,e)}querySelector(e){e=e.toUpperCase();const n=new is(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),ee(new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ht(this,e,new lo(this,t,e))}toString(){return wn(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),Ve(this,r=>{i.insertBefore(r.toDOM(e,t,n),null)}),i}insert(e,t){this.doc!==null?y(this.doc,n=>{Sn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)y(this.doc,n=>{const i=e&&e instanceof L?e._item:e;ut(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 J("Reference item not found");n.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return bn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yn(this,e)}slice(e=0,t=this.length){return mn(this,e,t)}forEach(e){Ve(this,e)}_write(e){e.writeTypeRef(Ao)}}const ao=s=>new ge;class He extends ge{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 He(this.nodeName)}clone(){const e=new He(this.nodeName),t=this.getAttributes();return Di(t,(n,i)=>{typeof n=="string"&&e.setAttribute(i,n)}),e.insert(0,this.toArray().map(n=>n instanceof L?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?y(this.doc,t=>{dt(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{es(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return ts(this,e)}hasAttribute(e){return Cn(this,e)}getAttributes(){return En(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 Ve(this,o=>{i.appendChild(o.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(vo),e.writeKey(this.nodeName)}}const co=s=>new He(s.readKey());class lo extends ct{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 pt extends fe{constructor(e){super(),this.hookName=e}_copy(){return new pt(this.hookName)}clone(){const e=new pt(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(xo),e.writeKey(this.hookName)}}const ho=s=>new pt(s.readKey());class kt extends Ae{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 kt}clone(){const e=new kt;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(Lo)}}const uo=s=>new kt;class rs{constructor(e,t){this.id=e,this.length=t}get deleted(){throw B()}mergeWith(e){return!1}write(e,t,n){throw B()}integrate(e,t){throw B()}}const fo=0;class z extends rs{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),an(e.doc.store,this)}write(e,t){e.writeInfo(fo),e.writeLen(this.length-t)}getMissing(e,t){return null}}class $e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new $e(this.content)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const go=s=>new $e(s.readBuf());class qe{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new qe(this.len)}splice(e){const t=new qe(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){nt(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 po=s=>new qe(s.readLen()),Tn=(s,e)=>new ue({guid:s,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ye{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 Ye(Tn(this.doc.guid,this.opts))}splice(e){throw B()}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 ko=s=>new Ye(Tn(s.readString(),s.readAny()));class pe{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new pe(this.embed)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const mo=s=>new pe(s.readJSON());class C{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new C(this.key,this.value)}splice(e){throw B()}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 bo=s=>new C(s.readKey(),s.readJSON());class mt{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new mt(this.arr)}splice(e){const t=new mt(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 wo=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 mt(t)};class ke{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ke(this.arr)}splice(e){const t=new ke(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 yo=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++)t.push(s.readAny());return new ke(t)};class V{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new V(this.str)}splice(e){const t=new V(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 _o=s=>new V(s.readString()),So=[Zr,to,oo,co,ao,ho,uo],Do=0,Eo=1,Co=2,vo=3,Ao=4,xo=5,Lo=6;class P{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new P(this.type._copy())}splice(e){throw B()}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 Io=s=>new P(So[s.readTypeRef()](s)),bt=(s,e,t)=>{const{client:n,clock:i}=e.id,r=new v(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 v extends rs{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()?As:0}set marker(e){(this.info&Lt)>0!==e&&(this.info^=Lt)}get marker(){return(this.info&Lt)>0}get keep(){return(this.info&vs)>0}set keep(e){this.keep!==e&&(this.info^=vs)}get countable(){return(this.info&As)>0}get deleted(){return(this.info&xt)>0}set deleted(e){this.deleted!==e&&(this.info^=xt)}markDeleted(){this.info|=xt}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=x(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=x(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ee&&this.id.client!==this.parent.client&&this.parent.clock>=x(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=cn(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ne(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===z||this.right&&this.right.constructor===z)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===v&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===v&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ee){const n=Jt(t,this.parent);n.constructor===z?this.parent=null:this.parent=n.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=cn(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),it(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(it(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Jt(e.doc.store,i.origin)))r.has(Jt(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),an(e.doc.store,this),this.content.integrate(e,this),un(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new z(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&&it(e.origin,this.lastId)&&this.right===e&&it(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(),nt(e.deleteSet,this.id.client,this.id.clock,this.length),un(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw N();this.content.gc(e),t?Or(e,this,new z(this.id,this.length)):this.content=new qe(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()&Qe|(n===null?0:M)|(i===null?0:X)|(r===null?0:Te);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=zr(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===Ee?(e.writeParentInfo(!1),e.writeLeftID(a)):N();r!==null&&e.writeString(r)}this.content.write(e,t)}}const Un=(s,e)=>jo[e&Qe](s),jo=[()=>{N()},po,wo,go,_o,mo,bo,Io,yo,ko,()=>{N()}],Mo=10;class O extends rs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){N()}write(e,t){e.writeInfo(Mo),p(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},On="__ $YJS$ __";zn[On]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),zn[On]=!0;const Rn=new Map;class To{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:Yi(t.newValue||"")}),wi(this._onChange)}postMessage(e){Ss.setItem(this.room,qi(Ni(e)))}close(){yi(this._onChange)}}const Uo=typeof BroadcastChannel>"u"?To:BroadcastChannel,os=s=>Y(Rn,s,()=>{const e=oe(),t=new Uo(s);return t.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:t,subs:e}}),zo=(s,e)=>(os(s).subs.add(e),e),Oo=(s,e)=>{const t=os(s),n=t.subs.delete(e);return n&&t.subs.size===0&&(t.bc.close(),Rn.delete(s)),n},xe=(s,e,t=null)=>{const n=os(s);n.bc.postMessage(e),n.subs.forEach(i=>i(e,t))},Bn=0,as=1,Nn=2,cs=(s,e)=>{p(s,Bn);const t=Tr(e);E(s,t)},Fn=(s,e,t)=>{p(s,as),E(s,Kt(e,t))},Ro=(s,e,t)=>Fn(e,t,I(s)),Vn=(s,e,t)=>{try{Qs(e,I(s),t)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Bo=(s,e)=>{p(s,Nn),E(s,e)},No=Vn,Fo=(s,e,t,n)=>{const i=k(s);switch(i){case Bn:Ro(s,e,t);break;case as:Vn(s,t,n);break;case Nn:No(s,t,n);break;default:throw new Error("Unknown message type")}return i},Vo=0,Ho=(s,e,t)=>{switch(k(s)){case Vo:t(e,se(s))}},ls=3e4;class $o extends Ge{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=he();this.getLocalState()!==null&&ls/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&ls<=t-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&hs(this,n,"timeout")},K(ls/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:he()});const o=[],a=[],c=[],l=[];e===null?l.push(t):r==null?e!=null&&o.push(t):(a.push(t),Me(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 hs=(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:he()})}n.push(r)}}n.length>0&&(s.emit("change",[{added:[],updated:[],removed:n},t]),s.emit("update",[{added:[],updated:[],removed:n},t]))},Ke=(s,e,t=s.states)=>{const n=e.length,i=j();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),le(i,JSON.stringify(a))}return S(i)},qo=(s,e,t)=>{const n=te(e),i=he(),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(se(n)),g=s.meta.get(u),m=s.states.get(u),D=g===void 0?0:g.clock;(D<d||D===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&&(Me(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])},Yo=s=>Ei(s,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var me=0,Hn=3,Le=1,Ko=2,Xo=typeof window>"u";function Jo(s,e){if(!s)throw new Error(e)}var Xe=[];Xe[me]=(s,e,t,n,i)=>{p(s,me);const r=Fo(e,s,t.doc,t);n&&r===as&&!t.synced&&(t.synced=!0)},Xe[Hn]=(s,e,t,n,i)=>{p(s,Le),E(s,Ke(t.awareness,Array.from(t.awareness.getStates().keys())))},Xe[Le]=(s,e,t,n,i)=>{qo(t.awareness,I(e),t)},Xe[Ko]=(s,e,t,n,i)=>{Ho(e,t.doc,(r,o)=>Go(t,o))};var $n=3e4;function Go(s,e){console.warn(`Permission denied to access ${s.url}.
4
+ ${e}`)}function qn(s,e,t){const n=te(e),i=j(),r=k(n),o=s.messageHandlers[r];return o?o(i,n,s,t,r):console.error("Unable to compute message"),i}function Yn(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=he();const n=qn(s,new Uint8Array(t.data),!0);zt(n)>1&&e.send(S(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,hs(s.awareness,Array.from(s.awareness.getStates().keys()).filter(n=>n!==s.doc.clientID),s),s.emit("status",[{status:"disconnected"}])):s.wsUnsuccessfulReconnects++,setTimeout(Yn,Dt(hi(2,s.wsUnsuccessfulReconnects)*100,s.maxBackoffTime),s)},e.onopen=()=>{s.wsLastMessageReceived=he(),s.wsconnecting=!1,s.wsconnected=!0,s.wsUnsuccessfulReconnects=0,s.emit("status",[{status:"connected"}]);const t=j();if(p(t,me),cs(t,s.doc),e.send(S(t)),s.awareness.getLocalState()!==null){const n=j();p(n,Le),E(n,Ke(s.awareness,[s.doc.clientID])),e.send(S(n))}},s.emit("status",[{status:"connecting"}])}}function us(s,e){const t=s.ws;s.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),s.bcconnected&&xe(s.bcChannel,e,s)}var Wo=class extends Ge{constructor(e,t,n,{connect:i=!0,awareness:r=new $o(n),params:o={},WebSocketPolyfill:a=WebSocket,resyncInterval:c=-1,maxBackoffTime:l=2500,disableBc:h=Xo}={}){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=Yo(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=Xe.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=j();p(d,me),cs(d,n),this.ws.send(S(d))}},c)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=qn(this,new Uint8Array(d),!1);zt(g)>1&&xe(this.bcChannel,S(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=j();p(g,me),Bo(g,d),us(this,S(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const D=d.concat(f).concat(g),Z=j();p(Z,Le),E(Z,Ke(r,D)),us(this,S(Z))},this._unloadHandler=()=>{hs(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&&$n<he()-this.wsLastMessageReceived&&(Jo(this.ws!==null,"ws must not be null"),this.ws.close())},$n/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||(zo(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=j();p(e,me),cs(e,this.doc),xe(this.bcChannel,S(e),this);const t=j();p(t,me),Fn(t,this.doc),xe(this.bcChannel,S(t),this);const n=j();p(n,Hn),xe(this.bcChannel,S(n),this);const i=j();p(i,Le),E(i,Ke(this.awareness,[this.doc.clientID])),xe(this.bcChannel,S(i),this)}disconnectBc(){const e=j();p(e,Le),E(e,Ke(this.awareness,[this.doc.clientID],new Map)),us(this,S(e)),this.bcconnected&&(Oo(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&&(Yn(this),this.connectBc())}};function Po(){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 Kn(s,e,t){if(typeof s!==t)throw new Error(`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${t}, received: ${s}`)}var Qo=class extends Wo{constructor(e,t,n,i={}){Kn(e,"host","string"),Kn(t,"room","string"),e=e.replace(/^(http|https|ws|wss):\/\//,"");const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}${i.party?`/parties/${i.party}`:"/party"}`,o=Po();i.params===void 0?i.params={_pk:o}:i.params._pk=o;super(r,t,n??new ue,i);b(this,"id");this.id=o}};const be=s=>_e((e,t)=>{s.onerror=n=>t(new Error(n.target.error)),s.onsuccess=n=>e(n.target.result)}),Zo=(s,e)=>_e((t,n)=>{const i=indexedDB.open(s);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(J(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),t(o)}}),ea=s=>be(indexedDB.deleteDatabase(s)),ta=(s,e)=>e.forEach(t=>s.createObjectStore.apply(s,t)),Je=(s,e,t="readwrite")=>{const n=s.transaction(e,t);return e.map(i=>la(n,i))},Xn=(s,e)=>be(s.count(e)),sa=(s,e)=>be(s.get(e)),Jn=(s,e)=>be(s.delete(e)),na=(s,e,t)=>be(s.put(e,t)),ds=(s,e)=>be(s.add(e)),ia=(s,e,t)=>be(s.getAll(e,t)),ra=(s,e,t)=>{let n=null;return ca(s,e,i=>(n=i,!1),t).then(()=>n)},oa=(s,e=null)=>ra(s,e,"prev"),aa=(s,e)=>_e((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()}}),ca=(s,e,t,n="next")=>aa(s.openKeyCursor(e,n),i=>t(i.key)),la=(s,e)=>s.objectStore(e),ha=(s,e)=>IDBKeyRange.upperBound(s,e),ua=(s,e)=>IDBKeyRange.lowerBound(s,e),fs="custom",Gn="updates",Wn=500,Pn=(s,e=()=>{},t=()=>{})=>{const[n]=Je(s.db,[Gn]);return ia(n,ua(s._dbref,!1)).then(i=>{s._destroyed||(e(n),y(s.doc,()=>{i.forEach(r=>Qs(s.doc,r))},s,!1),t(n))}).then(()=>oa(n).then(i=>{s._dbref=i+1})).then(()=>Xn(n).then(i=>{s._dbsize=i})).then(()=>n)},da=(s,e=!0)=>Pn(s).then(t=>{(e||s._dbsize>=Wn)&&ds(t,Kt(s.doc)).then(()=>Jn(t,ha(s._dbref,!0))).then(()=>Xn(t).then(n=>{s._dbsize=n}))});class fa extends Ge{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=Zo(e,n=>ta(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=_e(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,Pn(this,o=>ds(o,Kt(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]=Je(this.db,[Gn]);ds(r,n),++this._dbsize>=Wn&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{da(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(()=>{ea(this.name)})}get(e){return this._db.then(t=>{const[n]=Je(t,[fs],"readonly");return sa(n,e)})}set(e,t){return this._db.then(n=>{const[i]=Je(n,[fs]);return na(i,t,e)})}del(e){return this._db.then(t=>{const[n]=Je(t,[fs]);return Jn(n,e)})}}const qa="";function ga(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var pa=["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 ka=ga(pa),ma={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},ba="can-duplicate-to";var T=(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))(T||{});function wa(s){return s.id}function Qn(s){return document.getElementById(s)}const Zn=`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`,_c=`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 ni(s,{getData:e,getElement:t,getLocalData:n,setLocalData:i}){const r=e(),o=n(),c=t();if(o.isHovering=!0,s.altKey){if(r.scale<=.5){c.style.cursor="not-allowed";return}c.style.cursor=_c}else{if(r.scale>=r.maxScale){c.style.cursor="not-allowed";return}c.style.cursor=si}i(o)}function yt(s){if("touches"in s){const{clientX:e,clientY:t}=s.touches[0];return{clientX:e,clientY:t}}return{clientX:s.clientX,clientY:s.clientY}}const ii={[Q.CanMove]:{defaultData:{x:0,y:0},defaultLocalData:{startMouseX:0,startMouseY:0},updateElement:({element:s,data:e})=>{s.style.transform=`translate(${e.x}px, ${e.y}px)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t,clientY:n}=yt(s);e({startMouseX:t,startMouseY:n})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:c}=yt(s),{top:a,left:l,bottom:h,right:u}=r.getBoundingClientRect();u>window.outerWidth&&o>t.startMouseX||h>window.innerHeight&&c>t.startMouseY||l<0&&o<t.startMouseX||a<0&&c<t.startMouseY||(n({x:e.x+o-t.startMouseX,y:e.y+c-t.startMouseY}),i({startMouseX:o,startMouseY:c}))},resetShortcut:"shiftKey"},[Q.CanSpin]:{defaultData:{rotation:0},defaultLocalData:{startMouseX:0},updateElement:({element:s,data:e})=>{s.style.transform=`rotate(${e.rotation}deg)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t}=yt(s);e({startMouseX:t})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i})=>{const{clientX:r}=yt(s);let o=Math.abs(r-t.startMouseX)*2,c=e.rotation;r>t.startMouseX?c+=o:r<t.startMouseX&&(c-=o),n({rotation:c}),i({startMouseX:r})},resetShortcut:"shiftKey"},[Q.CanToggle]:{defaultData:!1,updateElement:({element:s,data:e})=>{s.classList.toggle("clicked",e)},onClick:(s,{data:e,setData:t})=>{t(!e)},resetShortcut:"shiftKey"},[Q.CanGrow]:{defaultData:{scale:1},defaultLocalData:{maxScale:2,isHovering:!1},updateElement:({element:s,data:e})=>{s.style.transform=`scale(${e.scale})`},onClick:(s,{data:e,element:t,setData:n,localData:i})=>{let{scale:r}=e;if(s.altKey){if(e.scale<=.5)return;r-=.1}else{if(t.style.cursor=si,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:s=>{s.getElement().addEventListener("mouseenter",e=>{ni(e,s);const t=n=>ni(n,s);document.addEventListener("keydown",t),document.addEventListener("keyup",t),s.getElement().addEventListener("mouseleave",n=>{document.removeEventListener("keydown",t),document.removeEventListener("keyup",t)})})},resetShortcut:"shiftKey"},[Q.CanPost]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:s,localData:{addedEntries:e},setLocalData:t})=>{const n=s.filter(r=>!e.has(r.id)),i=ei("guestbookMessages");n.forEach(r=>{const o=document.createElement("div");o.classList.add("guestbook-entry");const c=new Date(r.timestamp),a=c.toTimeString().split(" ")[0],l=c.toDateString()===new Date().toDateString(),h=(()=>{const u=new Date;return u.getFullYear()!==c.getFullYear()||u.getMonth()!==c.getMonth()?"Sometime before":l?"Today":u.getDate()-c.getDate()===1?"Yesterday":u.getDate()-c.getDate()<7?"This week":"Sometime before"})();o.innerHTML=`
7
- <span class="guestbook-entry-timestamp">${h} at ${a}</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 c(){const u=n.querySelector('input[name="message"]');u&&(u.value="")}const a=Object.fromEntries(o.entries());if(!a.name)return c(),!1;if(Sc.some(u=>{const d=new RegExp(`\\b${u}\\b`,"gi");return d.test(a.message)||d.test(a.name)}))return alert("now why would you try to do something like that?"),c(),!1;const l=Date.now(),h={name:"someone",message:"something",...a,timestamp:l,id:`${l}-${a.name}`};return t([...r,h]),c(),!1})}},[Q.CanDuplicate]:{defaultData:[],defaultLocalData:[],updateElement:({data:s,localData:e,setLocalData:t,element:n})=>{var h;const i=n.getAttribute(Q.CanDuplicate),r=document.getElementById(i);let o=document.getElementById((h=e.slice(-1))==null?void 0:h[0])??null;if(!r){console.error(`Element with id ${i} not found. Cannot duplicate.`);return}const c=n.getAttribute(bc);function a(u){if(c){const d=document.getElementById(c)||document.querySelector(c);if(d){d.appendChild(u);return}}r.parentNode.insertBefore(u,(o||r).nextSibling)}const l=new Set(e);for(const u of s){if(l.has(u))continue;const d=r.cloneNode(!0);Object.assign(d,{...r}),d.id=u,a(d),e.push(u),window.playhtml.setupPlayElement(d),o=d}t(e)},onClick:(s,{data:e,element:t,setData:n})=>{const r=t.getAttribute(Q.CanDuplicate)+"-"+Math.random().toString(36).substr(2,9);n([...e,r])}}};class Dc{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:c,data:a,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=ti(this.onChange,f),this.onAwarenessChange=i,this.updateElement=h,this.updateElementAwareness=u;const m=a===void 0?this.defaultData:a;l!==void 0&&(this.__awareness=l);const D=c instanceof Function?c(t):c;D!==void 0&&this.setLocalAwareness(D),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:c,onDragStart:a,resetShortcut:l,debounceMs:h,triggerAwarenessUpdate:u}){this.triggerAwarenessUpdate=u,this.onChange=t,this.resetShortcut=l,this.debouncedOnChange=ti(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,c&&!this.onDrag&&(e.addEventListener("touchstart",d=>{var m;d.preventDefault(),(m=this.onDragStart)==null||m.call(this,d,this.getEventHandlerData());const f=D=>{var ee;D.preventDefault(),(ee=this.onDrag)==null||ee.call(this,D,this.getEventHandlerData())},g=D=>{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=D=>{var ee;D.preventDefault(),(ee=this.onDrag)==null||ee.call(this,D,this.getEventHandlerData())},g=D=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",g)})),this.onDrag=c,this.onDragStart=a,l&&!this.resetShortcut&&(e.title||(e.title=`Hold down the ${mc[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){this.updateElementAwareness&&(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 Cc="playhtml.spencerc99.partykit.dev",ps=new de,Ec=window.location.href;let Z,V,$;const ri=new Map;let ks=!1,ms=!0;function oi({room:s=Ec,host:e=Cc}={}){if(!ms){console.error("playhtml already set up!");return}const t=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
6
+ auto`,ya=`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 ei(s,{getData:e,getElement:t,getLocalData:n,setLocalData:i}){const r=e(),o=n(),a=t();if(o.isHovering=!0,s.altKey){if(r.scale<=.5){a.style.cursor="not-allowed";return}a.style.cursor=ya}else{if(r.scale>=r.maxScale){a.style.cursor="not-allowed";return}a.style.cursor=Zn}i(o)}function wt(s){if("touches"in s){const{clientX:e,clientY:t}=s.touches[0];return{clientX:e,clientY:t}}return{clientX:s.clientX,clientY:s.clientY}}const ti={["can-move"]:{defaultData:{x:0,y:0},defaultLocalData:{startMouseX:0,startMouseY:0},updateElement:({element:s,data:e})=>{s.style.transform=`translate(${e.x}px, ${e.y}px)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t,clientY:n}=wt(s);e({startMouseX:t,startMouseY:n})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:a}=wt(s),{top:c,left:l,bottom:h,right:u}=r.getBoundingClientRect();u>window.outerWidth&&o>t.startMouseX||h>window.innerHeight&&a>t.startMouseY||l<0&&o<t.startMouseX||c<0&&a<t.startMouseY||(n({x:e.x+o-t.startMouseX,y:e.y+a-t.startMouseY}),i({startMouseX:o,startMouseY:a}))},resetShortcut:"shiftKey"},["can-spin"]:{defaultData:{rotation:0},defaultLocalData:{startMouseX:0},updateElement:({element:s,data:e})=>{s.style.transform=`rotate(${e.rotation}deg)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t}=wt(s);e({startMouseX:t})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i})=>{const{clientX:r}=wt(s);let o=Math.abs(r-t.startMouseX)*2,a=e.rotation;r>t.startMouseX?a+=o:r<t.startMouseX&&(a-=o),n({rotation:a}),i({startMouseX:r})},resetShortcut:"shiftKey"},["can-toggle"]:{defaultData:!1,updateElement:({element:s,data:e})=>{s.classList.toggle("clicked",e)},onClick:(s,{data:e,setData:t})=>{t(!e)},resetShortcut:"shiftKey"},["can-grow"]:{defaultData:{scale:1},defaultLocalData:{maxScale:2,isHovering:!1},updateElement:({element:s,data:e})=>{s.style.transform=`scale(${e.scale})`},onClick:(s,{data:e,element:t,setData:n,localData:i})=>{let{scale:r}=e;if(s.altKey){if(e.scale<=.5)return;r-=.1}else{if(t.style.cursor=Zn,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:s=>{s.getElement().addEventListener("mouseenter",e=>{ei(e,s);const t=n=>ei(n,s);document.addEventListener("keydown",t),document.addEventListener("keyup",t),s.getElement().addEventListener("mouseleave",n=>{document.removeEventListener("keydown",t),document.removeEventListener("keyup",t)})})},resetShortcut:"shiftKey"},["can-post"]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:s,localData:{addedEntries:e},setLocalData:t})=>{const n=s.filter(r=>!e.has(r.id)),i=Qn("guestbookMessages");n.forEach(r=>{const o=document.createElement("div");o.classList.add("guestbook-entry");const a=new Date(r.timestamp),c=a.toTimeString().split(" ")[0],l=a.toDateString()===new Date().toDateString(),h=(()=>{const u=new Date;return u.getFullYear()!==a.getFullYear()||u.getMonth()!==a.getMonth()?"Sometime before":l?"Today":u.getDate()-a.getDate()===1?"Yesterday":u.getDate()-a.getDate()<7?"This week":"Sometime before"})();o.innerHTML=`
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(ka.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(ba);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])}}},si=(s,e=300)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>s.apply(this,n),e)}};class _a{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=si(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 D=a instanceof Function?a(t):a;D!==void 0&&this.setLocalAwareness(D),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=si(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=D=>{var Z;D.preventDefault(),(Z=this.onDrag)==null||Z.call(this,D,this.getEventHandlerData())},g=D=>{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=D=>{var Z;D.preventDefault(),(Z=this.onDrag)==null||Z.call(this,D,this.getEventHandlerData())},g=D=>{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 ${ma[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 Sa="playhtml.spencerc99.partykit.dev",gs=new ue,Da=window.location.href;let Q,H,$;const ni=new Map;let ps=!1,ks=!0;function ii({room:s=Da,host:e=Sa}={}){if(!ks){console.error("playhtml already set up!");return}const t=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
8
8
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
9
9
  ࿂࿂࿂࿂ booting up playhtml... ࿂࿂࿂࿂
10
10
  ࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
11
11
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
12
- ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),Z=new ec(t,s,ps),V=ps.getMap("playhtml-global"),$=new Map,new pc(s,ps),St.globalData=V,St.elementHandlers=$,Z.on("sync",n=>{n||console.error("Issue connecting to yjs..."),ks=!0,Lc()}),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."),oi())},3e3);function vc(s,e){const t=Z.awareness.getLocalState();return((t==null?void 0:t[s])??{})[e]}function bs(s){return s instanceof HTMLElement}function Ac(s,e,t,n){const i=V.get(e);return{...t,data:i.get(n)??t.defaultData,awareness:vc(e,n)??t.myDefaultAwareness!==void 0?[t.myDefaultAwareness]:void 0,element:s,onChange:o=>{i.get(n)!==o&&i.set(n,o)},onAwarenessChange:o=>{var a;const c=((a=Z.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,Z.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{ci()}}}function xc(s){return s.defaultData!==void 0&&s.updateElement!==void 0}function Ic(s,e){if(s===T.CanPlay){const t=e;return{defaultData:t.defaultData,defaultLocalData:t.defaultLocalData,myDefaultAwareness:t.myDefaultAwareness,updateElement:t.updateElement,updateElementAwareness:t.updateElementAwareness,onDrag:t.onDrag,onDragStart:t.onDragStart,onClick:t.onClick,additionalSetup:t.additionalSetup,resetShortcut:t.resetShortcut,debounceMs:t.debounceMs}}return ii[s]}function ci(){const s=new Map;function e(t,n,i,r){s.has(t)||s.set(t,new Map);const o=s.get(t);o.has(n)||o.set(n,new Map),o.get(n).set(i,r)}Z.awareness.getStates().forEach((t,n)=>{var i;for(const[r,o]of Object.entries(t)){const c=$.get(r);if(c)for(const[a,l]of c){if(!(a in o))continue;const h=o[a];e(r,a,n,h)}}for(const[r,o]of s){const c=$.get(r);if(c)for(const[a,l]of c){const h=(i=o.get(a))==null?void 0:i.values();if(!h)continue;let u=Array.from(h);l.__awareness=u}}})}function Lc(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const s of Object.values(T)){const e=Array.from(document.querySelectorAll(`[${s}]`)).filter(bs);if(e.length)for(let t=0;t<e.length;t++){const n=e[t];_t(n,s)}}ms&&(V.observe(s=>{s.changes.keys.forEach((e,t)=>{e.action==="add"&&V.set(t,V.get(t))})}),Z.awareness.on("change",()=>ci()),ms=!1)}const St={init:oi,setupPlayElement:Tc,removePlayElement:Uc,setupPlayElementForTag:_t,globalData:void 0,elementHandlers:void 0};window.playhtml=St;function jc(s){if($.has(s)||!ks)return;$.set(s,new Map),s!==T.CanPlay&&ii[s],V.get(s)||V.set(s,new ge);const e=V.get(s);e.observe(t=>{t.changes.keys.forEach((n,i)=>{const r=$.get(s);if(n.action==="add"){const o=ei(i);if(!bs(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}_t(o,s)}else if(n.action==="update"){const o=r.get(i);o.__data=e.get(i)}else n.action==="delete"?r.delete(i):console.log(`Unhandled action: ${n.action}`)})})}function Mc(s,e){const t=s.getAttribute(e);switch(e){case T.CanPlay:case T.CanMove:case T.CanSpin:case T.CanGrow:case T.CanToggle:case T.CanPost:return!0;case T.CanDuplicate:return t?(document.getElementById(t)||console.warn(`${T.CanDuplicate} element (${s.id}) duplicate element ("${t}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function _t(s,e){var c;if(!Mc(s,e)||!ks)return;if(!s.id){const a=s.getAttribute("selector-id");if(a){const l=ri.get(a)??0;s.id=btoa(`${e}-${a}-${l}`),ri.set(a,l+1)}else s.id=btoa(`${e}-${s.innerHTML}}`)}const t=kc(s);if(!t){console.error(`Element ${s} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}jc(e);const n=$.get(e),i=Ic(e,s);if(!xc(i)){console.error(`Element ${t} 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 r=V.get(e),o=Ac(s,e,i,t);if(n.has(t)){n.get(t).reinitializeElementData(o);return}else n.set(t,new Dc(o));r.get(t)===void 0&&i.defaultData!==void 0&&r.set(t,i.defaultData),(c=o.triggerAwarenessUpdate)==null||c.call(o),s.classList.add("__playhtml-element"),s.classList.add(`__playhtml-${e}`),s.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function Tc(s){if(!bs(s)){console.log(`Element ${s.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(T))s.hasAttribute(e)&&_t(s,e)}function Uc(s){if(!(!s||!s.id))for(const e of Object.keys($)){const t=$.get(e);t.has(s.id)&&t.delete(s.id)}}U.playhtml=St,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
12
+ ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),Q=new Qo(t,s,gs),H=gs.getMap("playhtml-global"),$=new Map,new fa(s,gs),yt.globalData=H,yt.elementHandlers=$,Q.on("sync",n=>{n||console.error("Issue connecting to yjs..."),ps=!0,xa()}),Q}setTimeout(()=>{Q||(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."),ii())},3e3);function Ea(s,e){const t=Q.awareness.getLocalState();return((t==null?void 0:t[s])??{})[e]}function ms(s){return s instanceof HTMLElement}function Ca(s,e,t,n){const i=H.get(e);return{...t,data:i.get(n)??t.defaultData,awareness:Ea(e,n)??t.myDefaultAwareness!==void 0?[t.myDefaultAwareness]:void 0,element:s,onChange:o=>{i.get(n)!==o&&i.set(n,o)},onAwarenessChange:o=>{var c;const a=((c=Q.awareness.getLocalState())==null?void 0:c[e])||{};a[n]!==o&&(a[n]=o,Q.awareness.setLocalStateField(e,a))},triggerAwarenessUpdate:()=>{ri()}}}function va(s){return s.defaultData!==void 0&&s.updateElement!==void 0}function Aa(s,e){if(s===T.CanPlay){const t=e;return{defaultData:t.defaultData,defaultLocalData:t.defaultLocalData,myDefaultAwareness:t.myDefaultAwareness,updateElement:t.updateElement,updateElementAwareness:t.updateElementAwareness,onDrag:t.onDrag,onDragStart:t.onDragStart,onClick:t.onClick,additionalSetup:t.additionalSetup,resetShortcut:t.resetShortcut,debounceMs:t.debounceMs}}return ti[s]}function ri(){const s=new Map;function e(t,n,i,r){s.has(t)||s.set(t,new Map);const o=s.get(t);o.has(n)||o.set(n,new Map),o.get(n).set(i,r)}Q.awareness.getStates().forEach((t,n)=>{var i;for(const[r,o]of Object.entries(t)){const a=$.get(r);if(a)for(const[c,l]of a){if(!(c in o))continue;const h=o[c];e(r,c,n,h)}}for(const[r,o]of s){const a=$.get(r);if(a)for(const[c,l]of a){const h=(i=o.get(c))==null?void 0:i.values();if(!h)continue;let u=Array.from(h);l.__awareness=u}}})}function xa(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const s of Object.values(T)){const e=Array.from(document.querySelectorAll(`[${s}]`)).filter(ms);if(e.length)for(let t=0;t<e.length;t++){const n=e[t];_t(n,s)}}ks&&(H.observe(s=>{s.changes.keys.forEach((e,t)=>{e.action==="add"&&H.set(t,H.get(t))})}),Q.awareness.on("change",()=>ri()),ks=!1)}const yt={init:ii,setupPlayElement:ja,removePlayElement:Ma,setupPlayElementForTag:_t,globalData:void 0,elementHandlers:void 0};window.playhtml=yt;function La(s){if($.has(s)||!ps)return;$.set(s,new Map),s!==T.CanPlay&&ti[s],H.get(s)||H.set(s,new fe);const e=H.get(s);e.observe(t=>{t.changes.keys.forEach((n,i)=>{const r=$.get(s);if(n.action==="add"){const o=Qn(i);if(!ms(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}_t(o,s)}else if(n.action==="update"){const o=r.get(i);o.__data=e.get(i)}else n.action==="delete"?r.delete(i):console.log(`Unhandled action: ${n.action}`)})})}function Ia(s,e){const t=s.getAttribute(e);switch(e){case T.CanPlay:case T.CanMove:case T.CanSpin:case T.CanGrow:case T.CanToggle:case T.CanPost:return!0;case T.CanDuplicate:return t?(document.getElementById(t)||console.warn(`${T.CanDuplicate} element (${s.id}) duplicate element ("${t}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function _t(s,e){var a;if(!Ia(s,e)||!ps)return;if(!s.id){const c=s.getAttribute("selector-id");if(c){const l=ni.get(c)??0;s.id=btoa(`${e}-${c}-${l}`),ni.set(c,l+1)}else s.id=btoa(`${e}-${s.innerHTML}}`)}const t=wa(s);if(!t){console.error(`Element ${s} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}La(e);const n=$.get(e),i=Aa(e,s);if(!va(i)){console.error(`Element ${t} 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 r=H.get(e),o=Ca(s,e,i,t);if(n.has(t)){n.get(t).reinitializeElementData(o);return}else n.set(t,new _a(o));r.get(t)===void 0&&i.defaultData!==void 0&&r.set(t,i.defaultData),(a=o.triggerAwarenessUpdate)==null||a.call(o),s.classList.add("__playhtml-element"),s.classList.add(`__playhtml-${e}`),s.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function ja(s){if(!ms(s)){console.log(`Element ${s.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(T))s.hasAttribute(e)&&_t(s,e)}function Ma(s){if(!(!s||!s.id))for(const e of Object.keys($)){const t=$.get(e);t.has(s.id)&&t.delete(s.id)}}U.playhtml=yt,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});