@emailmaker/emailmaker 1.0.49 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/asset-manifest.json +52 -49
- package/emailmaker-esm.js +1 -1
- package/emailmaker.d.ts +49 -0
- package/emailmaker.js +1 -1
- package/iframe/{iframe-eblock.c516d87b9fc19e67c43a.html → iframe-eblock.984ccdb9e9538ea29c8a.html} +1 -1
- package/iframe/{iframe.c516d87b9fc19e67c43a.html → iframe.984ccdb9e9538ea29c8a.html} +1 -1
- package/iframe/js/cssbeautify.js +1 -1
- package/iframe/sandbox-eblock.js +1 -1
- package/iframe/sandbox.js +1 -1
- package/package.json +1 -1
- package/plugin.html +2 -2
- package/plugin_blocks_test.html +1 -1
- package/plugin_default.html +1 -1
- package/plugin_idigital.html +262 -0
- package/plugin_s.html +1 -1
- package/static/css/3062.52a0a40e.css +1 -0
- package/static/css/{3430.1e30bbcf.css → 3430.8008d20d.css} +1 -1
- package/static/css/5211.8f70ec84.css +1 -0
- package/static/css/8995.3b37ba81.css +1 -0
- package/static/js/1147.b3554098.js +1 -0
- package/static/js/1399.258dd710.js +1 -0
- package/static/js/1481.1c9eb31e.js +1 -0
- package/static/js/{1821.3a961d73.js → 1821.456c1a15.js} +1 -1
- package/static/js/{2151.0935f51b.js → 2151.516911d8.js} +1 -1
- package/static/js/2299.a10e8024.chunk.js +1 -0
- package/static/js/3040.3377e943.js +1 -0
- package/static/js/3062.c4964587.js +1 -0
- package/static/js/3430.81e9a5aa.js +1 -0
- package/static/js/4035.8367303a.js +1 -0
- package/static/js/5211.0ebfdb27.js +1 -0
- package/static/js/{5234.f4717ce4.js → 5234.2b7c442d.js} +1 -1
- package/static/js/6898.9eb2b03f.js +1 -0
- package/static/js/7291.06a4c8c4.js +1 -0
- package/static/js/7415.a9cc050d.js +2 -0
- package/static/js/7623.8bcd5fed.js +2 -0
- package/static/js/78.dca8224c.js +1 -0
- package/static/js/7835.3a7dd512.js +2 -0
- package/static/js/8458.7ac6ec33.js +1 -0
- package/static/js/8689.fa42b226.chunk.js +1 -0
- package/static/js/8995.d8b7e9e5.js +1 -0
- package/static/js/{emailmaker_core.22b19970.js → emailmaker_core.f53b7c8e.js} +1 -1
- package/translations.pot +535 -411
- package/static/css/2208.56ea0abb.css +0 -1
- package/static/css/4877.237f7f6b.css +0 -1
- package/static/css/5571.e4f09995.css +0 -1
- package/static/js/1399.b4cd707b.js +0 -1
- package/static/js/1477.46df6668.js +0 -2
- package/static/js/1481.cd1a0886.js +0 -1
- package/static/js/18.c23b78e8.js +0 -1
- package/static/js/2208.f73122ba.js +0 -1
- package/static/js/2299.03050dc1.chunk.js +0 -1
- package/static/js/3430.0fd120a4.js +0 -1
- package/static/js/3991.d0073826.js +0 -1
- package/static/js/4035.1e8d8ad5.js +0 -1
- package/static/js/4877.eaf2cc44.js +0 -1
- package/static/js/5571.cca36131.js +0 -1
- package/static/js/7159.56dbb0aa.js +0 -2
- package/static/js/723.e748d062.js +0 -2
- package/static/js/7291.50326502.js +0 -1
- package/static/js/78.595b3c2e.js +0 -1
- package/static/js/8458.f8ef5e55.js +0 -1
- package/static/js/8689.5ec8c633.chunk.js +0 -1
- /package/static/js/{723.e748d062.js.LICENSE.txt → 7415.a9cc050d.js.LICENSE.txt} +0 -0
- /package/static/js/{7159.56dbb0aa.js.LICENSE.txt → 7623.8bcd5fed.js.LICENSE.txt} +0 -0
- /package/static/js/{1477.46df6668.js.LICENSE.txt → 7835.3a7dd512.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[3040],{63040:(t,e,n)=>{n.d(e,{FX:()=>Z,IT:()=>gt,JA:()=>T,PR:()=>Q,QE:()=>q,SF:()=>ut});var r=n(36842),s=n(86046),i=n(70737),l=n(38873),o=n(13430),c=n(21502),h=n(54017),d=n(5594),a=n(16341),u=n(69985),g=n(78582),f=n(57439),p=n(15295),w=n(74204),_=n(8140),k=(n(96498),n(15029)),m=n(33268),b=n(27794);r.W;class y{constructor(t,e){this.clock=t,this.len=e}}class D{constructor(){this.clients=new Map}}const S=(t,e,n)=>e.clients.forEach(((e,r)=>{const s=t.doc.store.clients.get(r);for(let i=0;i<e.length;i++){const r=e[i];At(t,s,r.clock,r.len,n)}})),C=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=i.RI((n+r)/2),l=t[s],o=l.clock;if(o<=e){if(e<o+l.len)return s;n=s+1}else r=s-1}return null})(n,e.clock)},E=t=>{t.clients.forEach((t=>{let e,n;for(t.sort(((t,e)=>t.clock-e.clock)),e=1,n=1;e<t.length;e++){const r=t[n-1],s=t[e];r.clock+r.len>=s.clock?r.len=i.T9(r.len,s.clock+s.len-r.clock):(n<e&&(t[n]=s),n++)}t.length=n}))},v=t=>{const e=new D;for(let n=0;n<t.length;n++)t[n].clients.forEach(((r,i)=>{if(!e.clients.has(i)){const l=r.slice();for(let e=n+1;e<t.length;e++)s.S2(l,t[e].clients.get(i)||[]);e.clients.set(i,l)}}));return E(e),e},A=(t,e,n,r)=>{l._4(t.clients,e,(()=>[])).push(new y(n,r))},x=()=>new D,I=t=>{const e=x();return t.clients.forEach(((t,n)=>{const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.deleted){const s=n.id.clock;let i=n.length;if(e+1<t.length)for(let n=t[e+1];e+1<t.length&&n.deleted;n=t[1+ ++e])i+=n.length;r.push(new y(s,i))}}r.length>0&&e.clients.set(n,r)})),e},M=(t,e)=>{o.zd(t.restEncoder,e.clients.size),s.HT(e.clients.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,n])=>{t.resetDsCurVal(),o.zd(t.restEncoder,e);const r=n.length;o.zd(t.restEncoder,r);for(let s=0;s<r;s++){const e=n[s];t.writeDsClock(e.clock),t.writeDsLen(e.len)}}))},L=t=>{const e=new D,n=c.cw(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const n=c.cw(t.restDecoder),r=c.cw(t.restDecoder);if(r>0){const s=l._4(e.clients,n,(()=>[]));for(let e=0;e<r;e++)s.push(new y(t.readDsClock(),t.readDsLen()))}}return e},O=(t,e,n)=>{const r=new D,s=c.cw(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const s=c.cw(t.restDecoder),i=c.cw(t.restDecoder),l=n.clients.get(s)||[],o=bt(n,s);for(let n=0;n<i;n++){const n=t.readDsClock(),i=n+t.readDsLen();if(n<o){o<i&&A(r,s,o,i-o);let t=Dt(l,n),c=l[t];for(!c.deleted&&c.id.clock<n&&(l.splice(t+1,0,pn(e,c,n-c.id.clock)),t++);t<l.length&&(c=l[t++],c.id.clock<i);)c.deleted||(i<c.id.clock+c.length&&l.splice(t,0,pn(e,c,i-c.id.clock)),c.delete(e))}else A(r,s,n,i-n)}}if(r.clients.size>0){const t=new H;return o.zd(t.restEncoder,0),M(t,r),t.toUint8Array()}return null},N=h.S8;class T extends r.W{constructor({guid:t=h.gZ(),collectionid:e=null,gc:n=!0,gcFilter:r=(()=>!0),meta:s=null,autoLoad:i=!1,shouldLoad:l=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=N(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new kt,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=d.vt((t=>{this.on("load",(()=>{this.isLoaded=!0,t(this)}))}));const o=()=>d.vt((t=>{const e=n=>{void 0!==n&&!0!==n||(this.off("sync",e),t())};this.on("sync",e)}));this.on("sync",(t=>{!1===t&&this.isSynced&&(this.whenSynced=o()),this.isSynced=void 0===t||!0===t,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=o()}load(){const t=this._item;null===t||this.shouldLoad||Rt(t.parent.doc,(t=>{t.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(s.HT(this.subdocs).map((t=>t.guid)))}transact(t,e=null){return Rt(this,t,e)}get(t,e=re){const n=l._4(this.share,t,(()=>{const t=new e;return t._integrate(this,null),t})),r=n.constructor;if(e!==re&&r!==e){if(r===re){const r=new e;r._map=n._map,n._map.forEach((t=>{for(;null!==t;t=t.left)t.parent=r})),r._start=n._start;for(let t=r._start;null!==t;t=t.right)t.parent=r;return r._length=n._length,this.share.set(t,r),r._integrate(this,null),r}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return n}getArray(t=""){return this.get(t,ye)}getText(t=""){return this.get(t,Ve)}getMap(t=""){return this.get(t,Se)}getXmlElement(t=""){return this.get(t,He)}getXmlFragment(t=""){return this.get(t,We)}toJSON(){const t={};return this.share.forEach(((e,n)=>{t[n]=e.toJSON()})),t}destroy(){this.isDestroyed=!0,s.HT(this.subdocs).forEach((t=>t.destroy()));const t=this._item;if(null!==t){this._item=null;const e=t.content;e.doc=new T({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,Rt(t.parent.doc,(n=>{const r=e.doc;t.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class R{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return c.cw(this.restDecoder)}readDsLen(){return c.cw(this.restDecoder)}}class z extends R{readLeftID(){return ot(c.cw(this.restDecoder),c.cw(this.restDecoder))}readRightID(){return ot(c.cw(this.restDecoder),c.cw(this.restDecoder))}readClient(){return c.cw(this.restDecoder)}readInfo(){return c.xh(this.restDecoder)}readString(){return c.t3(this.restDecoder)}readParentInfo(){return 1===c.cw(this.restDecoder)}readTypeRef(){return c.cw(this.restDecoder)}readLen(){return c.cw(this.restDecoder)}readAny(){return c.Jg(this.restDecoder)}readBuf(){return a.HR(c.bo(this.restDecoder))}readJSON(){return JSON.parse(c.t3(this.restDecoder))}readKey(){return c.t3(this.restDecoder)}}class J{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=c.cw(this.restDecoder),this.dsCurrVal}readDsLen(){const t=c.cw(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class U extends J{constructor(t){super(t),this.keys=[],c.cw(t),this.keyClockDecoder=new c.xK(c.bo(t)),this.clientDecoder=new c.VQ(c.bo(t)),this.leftClockDecoder=new c.xK(c.bo(t)),this.rightClockDecoder=new c.xK(c.bo(t)),this.infoDecoder=new c.cQ(c.bo(t),c.xh),this.stringDecoder=new c.Ib(c.bo(t)),this.parentInfoDecoder=new c.cQ(c.bo(t),c.xh),this.typeRefDecoder=new c.VQ(c.bo(t)),this.lenDecoder=new c.VQ(c.bo(t))}readLeftID(){return new it(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new it(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return c.Jg(this.restDecoder)}readBuf(){return c.bo(this.restDecoder)}readJSON(){return c.Jg(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class V{constructor(){this.restEncoder=o.xv()}toUint8Array(){return o.Fo(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){o.zd(this.restEncoder,t)}writeDsLen(t){o.zd(this.restEncoder,t)}}class F extends V{writeLeftID(t){o.zd(this.restEncoder,t.client),o.zd(this.restEncoder,t.clock)}writeRightID(t){o.zd(this.restEncoder,t.client),o.zd(this.restEncoder,t.clock)}writeClient(t){o.zd(this.restEncoder,t)}writeInfo(t){o.QJ(this.restEncoder,t)}writeString(t){o.Qj(this.restEncoder,t)}writeParentInfo(t){o.zd(this.restEncoder,t?1:0)}writeTypeRef(t){o.zd(this.restEncoder,t)}writeLen(t){o.zd(this.restEncoder,t)}writeAny(t){o.IO(this.restEncoder,t)}writeBuf(t){o.Gu(this.restEncoder,t)}writeJSON(t){o.Qj(this.restEncoder,JSON.stringify(t))}writeKey(t){o.Qj(this.restEncoder,t)}}class W{constructor(){this.restEncoder=o.xv(),this.dsCurrVal=0}toUint8Array(){return o.Fo(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,o.zd(this.restEncoder,e)}writeDsLen(t){0===t&&u.Mq(),o.zd(this.restEncoder,t-1),this.dsCurrVal+=t}}class H extends W{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new o.FA,this.clientEncoder=new o.D$,this.leftClockEncoder=new o.FA,this.rightClockEncoder=new o.FA,this.infoEncoder=new o.cq(o.QJ),this.stringEncoder=new o.Sw,this.parentInfoEncoder=new o.cq(o.QJ),this.typeRefEncoder=new o.D$,this.lenEncoder=new o.D$}toUint8Array(){const t=o.xv();return o.zd(t,0),o.Gu(t,this.keyClockEncoder.toUint8Array()),o.Gu(t,this.clientEncoder.toUint8Array()),o.Gu(t,this.leftClockEncoder.toUint8Array()),o.Gu(t,this.rightClockEncoder.toUint8Array()),o.Gu(t,o.Fo(this.infoEncoder)),o.Gu(t,this.stringEncoder.toUint8Array()),o.Gu(t,o.Fo(this.parentInfoEncoder)),o.Gu(t,this.typeRefEncoder.toUint8Array()),o.Gu(t,this.lenEncoder.toUint8Array()),o.LH(t,o.Fo(this.restEncoder)),o.Fo(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){o.IO(this.restEncoder,t)}writeBuf(t){o.Gu(this.restEncoder,t)}writeJSON(t){o.IO(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);void 0===e?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}}const K=(t,e,n)=>{const r=new Map;n.forEach(((t,n)=>{bt(e,n)>t&&r.set(n,t)})),mt(e).forEach(((t,e)=>{n.has(e)||r.set(e,0)})),o.zd(t.restEncoder,r.size),s.HT(r.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([n,r])=>{((t,e,n,r)=>{r=i.T9(r,e[0].id.clock);const s=Dt(e,r);o.zd(t.restEncoder,e.length-s),t.writeClient(n),o.zd(t.restEncoder,r);const l=e[s];l.write(t,r-l.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)})(t,e.clients.get(n),n,r)}))},$=(t,e,n,r=new U(t))=>Rt(e,(t=>{t.local=!1;let e=!1;const n=t.doc,i=n.store,h=((t,e)=>{const n=l.vt(),r=c.cw(t.restDecoder);for(let s=0;s<r;s++){const r=c.cw(t.restDecoder),s=new Array(r),i=t.readClient();let l=c.cw(t.restDecoder);n.set(i,{i:0,refs:s});for(let n=0;n<r;n++){const r=t.readInfo();switch(g.WY&r){case 0:{const e=t.readLen();s[n]=new Pe(ot(i,l),e),l+=e;break}case 10:{const e=c.cw(t.restDecoder);s[n]=new mn(ot(i,l),e),l+=e;break}default:{const o=0===(r&(g.D7|g.wt)),c=new wn(ot(i,l),null,(r&g.wt)===g.wt?t.readLeftID():null,null,(r&g.D7)===g.D7?t.readRightID():null,o?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,o&&(r&g.KJ)===g.KJ?t.readString():null,_n(t,r));s[n]=c,l+=c.length}}}}return n})(r,n),d=((t,e,n)=>{const r=[];let i=s.HT(n.keys()).sort(((t,e)=>t-e));if(0===i.length)return null;const c=()=>{if(0===i.length)return null;let t=n.get(i[i.length-1]);for(;t.refs.length===t.i;){if(i.pop(),!(i.length>0))return null;t=n.get(i[i.length-1])}return t};let h=c();if(null===h)return null;const d=new kt,a=new Map,u=(t,e)=>{const n=a.get(t);(null==n||n>e)&&a.set(t,e)};let g=h.refs[h.i++];const f=new Map,p=()=>{for(const t of r){const e=t.id.client,r=n.get(e);r?(r.i--,d.clients.set(e,r.refs.slice(r.i)),n.delete(e),r.i=0,r.refs=[]):d.clients.set(e,[t]),i=i.filter((t=>t!==e))}r.length=0};for(;;){if(g.constructor!==mn){const s=l._4(f,g.id.client,(()=>bt(e,g.id.client)))-g.id.clock;if(s<0)r.push(g),u(g.id.client,g.id.clock-1),p();else{const i=g.getMissing(t,e);if(null!==i){r.push(g);const t=n.get(i)||{refs:[],i:0};if(t.refs.length!==t.i){g=t.refs[t.i++];continue}u(i,bt(e,i)),p()}else(0===s||s<g.length)&&(g.integrate(t,s),f.set(g.id.client,g.id.clock+g.length))}}if(r.length>0)g=r.pop();else if(null!==h&&h.i<h.refs.length)g=h.refs[h.i++];else{if(h=c(),null===h)break;g=h.refs[h.i++]}}if(d.clients.size>0){const t=new H;return K(t,d,new Map),o.zd(t.restEncoder,0),{missing:a,update:t.toUint8Array()}}return null})(t,i,h),a=i.pendingStructs;if(a){for(const[t,n]of a.missing)if(n<bt(i,t)){e=!0;break}if(d){for(const[t,e]of d.missing){const n=a.missing.get(t);(null==n||n>e)&&a.missing.set(t,e)}a.update=Ft([a.update,d.update])}}else i.pendingStructs=d;const u=O(r,t,i);if(i.pendingDs){const e=new U(c.$C(i.pendingDs));c.cw(e.restDecoder);const n=O(e,t,i);i.pendingDs=u&&n?Ft([u,n]):u||n}else i.pendingDs=u;if(e){const e=i.pendingStructs.update;i.pendingStructs=null,j(t.doc,e)}}),n,!1),j=(t,e,n,r=U)=>{const s=c.$C(e);$(s,t,n,new r(s))},q=(t,e,n)=>j(t,e,n,z),P=(t,e=new Uint8Array([0]),n=new H)=>{((t,e,n=new Map)=>{K(t,e.store,n),M(t,I(e.store))})(n,t,B(e));const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(Wt(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===F)return Ut(r.map(((t,e)=>0===e?t:qt(t))));if(n.constructor===H)return Ft(r)}return r[0]},Q=(t,e)=>P(t,e,new F),G=t=>{const e=new Map,n=c.cw(t.restDecoder);for(let r=0;r<n;r++){const n=c.cw(t.restDecoder),r=c.cw(t.restDecoder);e.set(n,r)}return e},B=t=>G(new R(c.$C(t))),Y=(t,e)=>(o.zd(t.restEncoder,e.size),s.HT(e.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,n])=>{o.zd(t.restEncoder,e),o.zd(t.restEncoder,n)})),t),X=(t,e=new W)=>(t instanceof Map?Y(e,t):((t,e)=>{Y(t,mt(e.store))})(e,t),e.toUint8Array()),Z=t=>X(t,new V);class tt{constructor(){this.l=[]}}const et=()=>new tt,nt=(t,e)=>t.l.push(e),rt=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter((t=>e!==t)),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},st=(t,e,n)=>f.OK(t.l,[e,n]);class it{constructor(t,e){this.client=t,this.clock=e}}const lt=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,ot=(t,e)=>new it(t,e),ct=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw u.Mq()};class ht{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class dt{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}const at=(t,e,n)=>{let r=null,s=null;return null===t._item?s=ct(t):r=ot(t._item.id.client,t._item.id.clock),new ht(r,s,e,n)},ut=(t,e,n=0)=>{let r=t._start;if(n<0){if(0===e)return at(t,null,n);e--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>e)return at(t,ot(r.id.client,r.id.clock+e),n);e-=r.length}if(null===r.right&&n<0)return at(t,r.lastId,n);r=r.right}return at(t,null,n)},gt=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,l=t.tname,o=t.assoc;let c=null,h=0;if(null!==s){if(bt(r,s.client)<=s.clock)return null;const t=n?fn(r,s):{item:St(r,s),diff:0},e=t.item;if(!(e instanceof wn))return null;if(c=e.parent,null===c._item||!c._item.deleted){h=e.deleted||!e.countable?0:t.diff+(o>=0?0:1);let n=e.left;for(;null!==n;)!n.deleted&&n.countable&&(h+=n.length),n=n.left}}else{if(null!==l)c=e.get(l);else{if(null===i)throw u.Mq();{if(bt(r,i.client)<=i.clock)return null;const{item:t}=n?fn(r,i):{item:St(r,i)};if(!(t instanceof wn&&t.content instanceof gn))return null;c=t.content.type}}h=o>=0?c._length:0}return((t,e,n=0)=>new dt(t,e,n))(c,h,t.assoc)};class ft{constructor(t,e){this.ds=t,this.sv=e}}const pt=(t,e)=>new ft(t,e),wt=(pt(x(),new Map),(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!C(e.ds,t.id)),_t=(t,e)=>{const n=l._4(t.meta,_t,p.vt),r=t.doc.store;n.has(e)||(e.sv.forEach(((e,n)=>{e<bt(r,n)&&Et(t,ot(n,e))})),S(t,e.ds,(t=>{})),n.add(e))};class kt{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const mt=t=>{const e=new Map;return t.clients.forEach(((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)})),e},bt=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},yt=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw u.Mq()}n.push(e)},Dt=(t,e)=>{let n=0,r=t.length-1,s=t[r],l=s.id.clock;if(l===e)return r;let o=i.RI(e/(l+s.length-1)*r);for(;n<=r;){if(s=t[o],l=s.id.clock,l<=e){if(e<l+s.length)return o;n=o+1}else r=o-1;o=i.RI((n+r)/2)}throw u.Mq()},St=(t,e)=>{const n=t.clients.get(e.client);return n[Dt(n,e.clock)]},Ct=(t,e,n)=>{const r=Dt(e,n),s=e[r];return s.id.clock<n&&s instanceof wn?(e.splice(r+1,0,pn(t,s,n-s.id.clock)),r+1):r},Et=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Ct(t,n,e.clock)]},vt=(t,e,n)=>{const r=e.clients.get(n.client),s=Dt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Pe&&r.splice(s+1,0,pn(t,i,n.clock-i.id.clock+1)),i},At=(t,e,n,r,s)=>{if(0===r)return;const i=n+r;let l,o=Ct(t,e,n);do{l=e[o++],i<l.id.clock+l.length&&Ct(t,e,i),s(l)}while(o<e.length&&e[o].id.clock<i)};class xt{constructor(t,e,n){this.doc=t,this.deleteSet=new D,this.beforeState=mt(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const It=(t,e)=>!(0===e.deleteSet.clients.size&&!l.bz(e.afterState,((t,n)=>e.beforeState.get(n)!==t)))&&(E(e.deleteSet),((t,e)=>{K(t,e.doc.store,e.beforeState)})(t,e),M(t,e.deleteSet),!0),Mt=(t,e,n)=>{const r=e._item;(null===r||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&l._4(t.changed,e,p.vt).add(n)},Lt=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=t[--s-1])n instanceof wn&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const i=e-s;return i&&t.splice(e+1-i,i),i},Ot=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const t=e.clients.get(r);for(let r=s.length-1;r>=0;r--){const i=s[r],l=i.clock+i.len;for(let r=Dt(t,i.clock),s=t[r];r<t.length&&s.id.clock<l;s=t[++r]){const s=t[r];if(i.clock+i.len<=s.id.clock)break;s instanceof wn&&s.deleted&&!s.keep&&n(s)&&s.gc(e,!1)}}}},Nt=(t,e)=>{t.clients.forEach(((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=i.jk(r.length-1,1+Dt(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[t])t-=1+Lt(r,t)}}))},Tt=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,l=n.deleteSet,o=n._mergeStructs;try{E(l),n.afterState=mt(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const t=[];n.changed.forEach(((e,r)=>t.push((()=>{null!==r._item&&r._item.deleted||r._callObserver(n,e)})))),t.push((()=>{n.changedParentTypes.forEach(((t,e)=>{e._dEH.l.length>0&&(null===e._item||!e._item.deleted)&&((t=t.filter((t=>null===t.target._item||!t.target._item.deleted))).forEach((t=>{t.currentTarget=e,t._path=null})),t.sort(((t,e)=>t.path.length-e.path.length)),st(e._dEH,t,n))}))})),t.push((()=>r.emit("afterTransaction",[n,r]))),(0,f.OK)(t,[]),n._needFormattingCleanup&&ze(n)}finally{r.gc&&Ot(l,s,r.gcFilter),Nt(l,s),n.afterState.forEach(((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=s.clients.get(e),n=i.T9(Dt(t,r),1);for(let e=t.length-1;e>=n;)e-=1+Lt(t,e)}}));for(let t=o.length-1;t>=0;t--){const{client:e,clock:n}=o[t].id,r=s.clients.get(e),i=Dt(r,n);i+1<r.length&&Lt(r,i+1)>1||i>0&&Lt(r,i)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(w.yy(_.hN,_.Y,"[yjs] ",_.Ny,_.UH,"Changed the client-id because another client seems to be using it."),r.clientID=N()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new F;It(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new H;It(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:h,subdocsRemoved:d}=n;(c.size>0||d.size>0||h.size>0)&&(c.forEach((t=>{t.clientID=r.clientID,null==t.collectionid&&(t.collectionid=r.collectionid),r.subdocs.add(t)})),d.forEach((t=>r.subdocs.delete(t))),r.emit("subdocs",[{loaded:h,added:c,removed:d},r,n]),d.forEach((t=>t.destroy()))),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):Tt(t,e+1)}}},Rt=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,l=null;null===t._transaction&&(i=!0,t._transaction=new xt(t,n,r),s.push(t._transaction),1===s.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(i){const e=t._transaction===s[0];t._transaction=null,e&&Tt(s,0)}}return l};r.W;class zt{constructor(t,e){this.gen=function*(t){const e=c.cw(t.restDecoder);for(let n=0;n<e;n++){const e=c.cw(t.restDecoder),n=t.readClient();let r=c.cw(t.restDecoder);for(let s=0;s<e;s++){const e=t.readInfo();if(10===e){const e=c.cw(t.restDecoder);yield new mn(ot(n,r),e),r+=e}else if(0!==(g.WY&e)){const s=0===(e&(g.D7|g.wt)),i=new wn(ot(n,r),null,(e&g.wt)===g.wt?t.readLeftID():null,null,(e&g.D7)===g.D7?t.readRightID():null,s?t.readParentInfo()?t.readString():t.readLeftID():null,s&&(e&g.KJ)===g.KJ?t.readString():null,_n(t,e));yield i,r+=i.length}else{const e=t.readLen();yield new Pe(ot(n,r),e),r+=e}}}}(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===mn);return this.curr}}class Jt{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const Ut=t=>Ft(t,z,F),Vt=(t,e)=>{if(t.constructor===Pe){const{client:n,clock:r}=t.id;return new Pe(ot(n,r+e),t.length-e)}if(t.constructor===mn){const{client:n,clock:r}=t.id;return new mn(ot(n,r+e),t.length-e)}{const n=t,{client:r,clock:s}=n.id;return new wn(ot(r,s+e),null,ot(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Ft=(t,e=U,n=H)=>{if(1===t.length)return t[0];const r=t.map((t=>new e(c.$C(t))));let s=r.map((t=>new zt(t,!0))),i=null;const l=new n,o=new Jt(l);for(;s=s.filter((t=>null!==t.curr)),s.sort(((t,e)=>{if(t.curr.id.client===e.curr.id.client){const n=t.curr.id.clock-e.curr.id.clock;return 0===n?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===mn?1:-1:n}return e.curr.id.client-t.curr.id.client})),0!==s.length;){const t=s[0],e=t.curr.id.client;if(null!==i){let n=t.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=i.struct.id.clock+i.struct.length&&n.id.client>=i.struct.id.client;)n=t.next(),r=!0;if(null===n||n.id.client!==e||r&&n.id.clock>i.struct.id.clock+i.struct.length)continue;if(e!==i.struct.id.client)Kt(o,i.struct,i.offset),i={struct:n,offset:0},t.next();else if(i.struct.id.clock+i.struct.length<n.id.clock)if(i.struct.constructor===mn)i.struct.length=n.id.clock+n.length-i.struct.id.clock;else{Kt(o,i.struct,i.offset);const t=n.id.clock-i.struct.id.clock-i.struct.length;i={struct:new mn(ot(e,i.struct.id.clock+i.struct.length),t),offset:0}}else{const e=i.struct.id.clock+i.struct.length-n.id.clock;e>0&&(i.struct.constructor===mn?i.struct.length-=e:n=Vt(n,e)),i.struct.mergeWith(n)||(Kt(o,i.struct,i.offset),i={struct:n,offset:0},t.next())}}else i={struct:t.curr,offset:0},t.next();for(let n=t.curr;null!==n&&n.id.client===e&&n.id.clock===i.struct.id.clock+i.struct.length&&n.constructor!==mn;n=t.next())Kt(o,i.struct,i.offset),i={struct:n,offset:0}}null!==i&&(Kt(o,i.struct,i.offset),i=null),$t(o);const h=r.map((t=>L(t))),d=v(h);return M(l,d),l.toUint8Array()},Wt=(t,e,n=U,r=H)=>{const s=B(e),l=new r,o=new Jt(l),h=new n(c.$C(t)),d=new zt(h,!1);for(;d.curr;){const t=d.curr,e=t.id.client,n=s.get(e)||0;if(d.curr.constructor!==mn)if(t.id.clock+t.length>n)for(Kt(o,t,i.T9(n-t.id.clock,0)),d.next();d.curr&&d.curr.id.client===e;)Kt(o,d.curr,0),d.next();else for(;d.curr&&d.curr.id.client===e&&d.curr.id.clock+d.curr.length<=n;)d.next();else d.next()}$t(o);const a=L(h);return M(l,a),l.toUint8Array()},Ht=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:o.Fo(t.encoder.restEncoder)}),t.encoder.restEncoder=o.xv(),t.written=0)},Kt=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Ht(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),o.zd(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},$t=t=>{Ht(t);const e=t.encoder.restEncoder;o.zd(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];o.zd(e,r.written),o.LH(e,r.restEncoder)}},jt=(t,e,n,r)=>{const s=new n(c.$C(t)),i=new zt(s,!1),l=new r,o=new Jt(l);for(let c=i.curr;null!==c;c=i.next())Kt(o,e(c),0);$t(o);const h=L(s);return M(l,h),l.toUint8Array()},qt=t=>jt(t,f.id,U,F),Pt="You must not compute changes after the event-handler fired.";class Qt{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Gt(this.currentTarget,this.target))}deletes(t){return C(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw u.vt(Pt);const t=new Map,e=this.target;this.transaction.changed.get(e).forEach((n=>{if(null!==n){const r=e._map.get(n);let i,l;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;i="delete",l=s.HV(t.content.getContent())}else null!==t&&this.deletes(t)?(i="update",l=s.HV(t.content.getContent())):(i="add",l=void 0)}else{if(!this.deletes(r))return;i="delete",l=s.HV(r.content.getContent())}t.set(n,{action:i,oldValue:l})}})),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){if(0===this.transaction.doc._transactionCleanups.length)throw u.vt(Pt);const e=this.target,n=p.vt(),r=p.vt(),s=[];t={added:n,deleted:r,delta:s,keys:this.keys};if(this.transaction.changed.get(e).has(null)){let t=null;const i=()=>{t&&s.push(t)};for(let s=e._start;null!==s;s=s.right)s.deleted?this.deletes(s)&&!this.adds(s)&&(null!==t&&void 0!==t.delete||(i(),t={delete:0}),t.delete+=s.length,r.add(s)):this.adds(s)?(null!==t&&void 0!==t.insert||(i(),t={insert:[]}),t.insert=t.insert.concat(s.content.getContent()),n.add(s)):(null!==t&&void 0!==t.retain||(i(),t={retain:0}),t.retain+=s.length);null!==t&&void 0===t.retain&&i()}this._changes=t}return t}}const Gt=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)!r.deleted&&r.countable&&(t+=r.length),r=r.right;n.unshift(t)}e=e._item.parent}return n},Bt=()=>{w.R8("Invalid access: Add Yjs type to a document before reading data.")};let Yt=0;class Xt{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Yt++}}const Zt=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Yt++},te=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce(((t,n)=>i.tn(e-t.index)<i.tn(e-n.index)?t:n));let r=t._start,s=0;for(null!==n&&(r=n.p,s=n.index,(t=>{t.timestamp=Yt++})(n));null!==r.right&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;null!==r.left&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return null!==n&&i.tn(n.index-s)<r.parent.length/80?(Zt(n,r,s),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce(((t,e)=>t.timestamp<e.timestamp?t:e));return Zt(r,e,n),r}{const r=new Xt(e,n);return t.push(r),r}})(t._searchMarker,r,s)},ee=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let e=s.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(s.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}s.p=e,e.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=i.T9(e,s.index+n))}},ne=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;l._4(s,t,(()=>[])).push(n),null!==t._item;)t=t._item.parent;st(r._eH,n,e)};class re{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=et(),this._dEH=et(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw u.bD()}clone(){throw u.bD()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){nt(this._eH,t)}observeDeep(t){nt(this._dEH,t)}unobserve(t){rt(this._eH,t)}unobserveDeep(t){rt(this._dEH,t)}toJSON(){}}const se=(t,e,n)=>{t.doc??Bt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;null!==i&&r>0;){if(i.countable&&!i.deleted){const t=i.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)s.push(t[n]),r--;e=0}}i=i.right}return s},ie=t=>{t.doc??Bt();const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},le=(t,e)=>{let n=0,r=t._start;for(t.doc??Bt();null!==r;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let r=0;r<s.length;r++)e(s[r],n++,t)}r=r.right}},oe=(t,e)=>{const n=[];return le(t,((r,s)=>{n.push(e(r,s,t))})),n},ce=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},he=(t,e)=>{t.doc??Bt();const n=te(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},de=(t,e,n,r)=>{let s=n;const i=t.doc,l=i.clientID,o=i.store,c=null===n?e._start:n.right;let h=[];const d=()=>{h.length>0&&(s=new wn(ot(l,bt(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new nn(h)),s.integrate(t,0),h=[])};r.forEach((n=>{if(null===n)h.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(n);break;default:switch(d(),n.constructor){case Uint8Array:case ArrayBuffer:s=new wn(ot(l,bt(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new Qe(new Uint8Array(n))),s.integrate(t,0);break;case T:s=new wn(ot(l,bt(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new Ye(n)),s.integrate(t,0);break;default:if(!(n instanceof re))throw new Error("Unexpected content type in insert operation");s=new wn(ot(l,bt(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new gn(n)),s.integrate(t,0)}}})),d()},ae=()=>u.vt("Length exceeded!"),ue=(t,e,n,r)=>{if(n>e._length)throw ae();if(0===n)return e._searchMarker&&ee(e._searchMarker,n,r.length),de(t,e,null,r);const s=n,i=te(e,n);let l=e._start;for(null!==i&&(l=i.p,0===(n-=i.index)&&(l=l.prev,n+=l&&l.countable&&!l.deleted?l.length:0));null!==l;l=l.right)if(!l.deleted&&l.countable){if(n<=l.length){n<l.length&&Et(t,ot(l.id.client,l.id.clock+n));break}n-=l.length}return e._searchMarker&&ee(e._searchMarker,s,r.length),de(t,e,l,r)},ge=(t,e,n,r)=>{if(0===r)return;const s=n,i=r,l=te(e,n);let o=e._start;for(null!==l&&(o=l.p,n-=l.index);null!==o&&n>0;o=o.right)!o.deleted&&o.countable&&(n<o.length&&Et(t,ot(o.id.client,o.id.clock+n)),n-=o.length);for(;r>0&&null!==o;)o.deleted||(r<o.length&&Et(t,ot(o.id.client,o.id.clock+r)),o.delete(t),r-=o.length),o=o.right;if(r>0)throw ae();e._searchMarker&&ee(e._searchMarker,s,-i+r)},fe=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},pe=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,l=i.clientID;let o;if(null==r)o=new nn([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:o=new nn([r]);break;case Uint8Array:o=new Qe(r);break;case T:o=new Ye(r);break;default:if(!(r instanceof re))throw new Error("Unexpected content type");o=new gn(r)}new wn(ot(l,bt(i.store,l)),s,s&&s.lastId,null,null,e,n,o).integrate(t,0)},we=(t,e)=>{t.doc??Bt();const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},_e=t=>{const e={};return t.doc??Bt(),t._map.forEach(((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])})),e},ke=(t,e)=>{t.doc??Bt();const n=t._map.get(e);return void 0!==n&&!n.deleted},me=t=>(t.doc??Bt(),k.$5(t._map.entries(),(t=>!t[1].deleted)));class be extends Qt{}class ye extends re{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const e=new ye;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ye}clone(){const t=new ye;return t.insert(0,this.toArray().map((t=>t instanceof re?t.clone():t))),t}get length(){return this.doc??Bt(),this._length}_callObserver(t,e){super._callObserver(t,e),ne(this,t,new be(this,t))}insert(t,e){null!==this.doc?Rt(this.doc,(n=>{ue(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}push(t){null!==this.doc?Rt(this.doc,(e=>{((t,e,n)=>{let r=(e._searchMarker||[]).reduce(((t,e)=>e.index>t.index?e:t),{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;de(t,e,r,n)})(e,this,t)})):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?Rt(this.doc,(n=>{ge(n,this,t,e)})):this._prelimContent.splice(t,e)}get(t){return he(this,t)}toArray(){return ie(this)}slice(t=0,e=this.length){return se(this,t,e)}toJSON(){return this.map((t=>t instanceof re?t.toJSON():t))}map(t){return oe(this,t)}forEach(t){le(this,t)}[Symbol.iterator](){return ce(this)}_write(t){t.writeTypeRef(ln)}}class De extends Qt{constructor(t,e,n){super(t,e),this.keysChanged=n}}class Se extends re{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach(((t,e)=>{this.set(e,t)})),this._prelimContent=null}_copy(){return new Se}clone(){const t=new Se;return this.forEach(((e,n)=>{t.set(n,e instanceof re?e.clone():e)})),t}_callObserver(t,e){ne(this,t,new De(this,t,e))}toJSON(){this.doc??Bt();const t={};return this._map.forEach(((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof re?r.toJSON():r}})),t}get size(){return[...me(this)].length}keys(){return k.n(me(this),(t=>t[0]))}values(){return k.n(me(this),(t=>t[1].content.getContent()[t[1].length-1]))}entries(){return k.n(me(this),(t=>[t[0],t[1].content.getContent()[t[1].length-1]]))}forEach(t){this.doc??Bt(),this._map.forEach(((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)}))}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?Rt(this.doc,(e=>{fe(e,this,t)})):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?Rt(this.doc,(n=>{pe(n,this,t,e)})):this._prelimContent.set(t,e),e}get(t){return we(this,t)}has(t){return ke(this,t)}clear(){null!==this.doc?Rt(this.doc,(t=>{this.forEach((function(e,n,r){fe(t,r,n)}))})):this._prelimContent.clear()}_write(t){t.writeTypeRef(on)}}const Ce=(t,e)=>t===e||"object"===typeof t&&"object"===typeof e&&t&&e&&m.SQ(t,e);class Ee{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&u.Mq(),this.right.content.constructor===Ze)this.right.deleted||Ie(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const ve=(t,e,n)=>{for(;null!==e.right&&n>0;){if(e.right.content.constructor===Ze)e.right.deleted||Ie(e.currentAttributes,e.right.content);else e.right.deleted||(n<e.right.length&&Et(t,ot(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);e.left=e.right,e.right=e.right.right}return e},Ae=(t,e,n,r)=>{const s=new Map,i=r?te(e,n):null;if(i){const e=new Ee(i.p.left,i.p,i.index,s);return ve(t,e,n-i.index)}{const r=new Ee(null,e._start,0,s);return ve(t,r,n)}},xe=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===Ze&&Ce(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach(((r,l)=>{const o=n.left,c=n.right,h=new wn(ot(i,bt(s.store,i)),o,o&&o.lastId,c,c&&c.id,e,null,new Ze(l,r));h.integrate(t,0),n.right=h,n.forward()}))},Ie=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},Me=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===Ze&&Ce(e[t.right.content.key]??null,t.right.content.value));)t.forward()},Le=(t,e,n,r)=>{const s=t.doc,i=s.clientID,l=new Map;for(const o in r){const c=r[o],h=n.currentAttributes.get(o)??null;if(!Ce(h,c)){l.set(o,h);const{left:r,right:d}=n;n.right=new wn(ot(i,bt(s.store,i)),r,r&&r.lastId,d,d&&d.id,e,null,new Ze(o,c)),n.right.integrate(t,0),n.forward()}}return l},Oe=(t,e,n,r,s)=>{n.currentAttributes.forEach(((t,e)=>{void 0===s[e]&&(s[e]=null)}));const i=t.doc,l=i.clientID;Me(n,s);const o=Le(t,e,n,s),c=r.constructor===String?new rn(r):r instanceof re?new gn(r):new Xe(r);let{left:h,right:d,index:a}=n;e._searchMarker&&ee(e._searchMarker,n.index,c.getLength()),d=new wn(ot(l,bt(i.store,l)),h,h&&h.lastId,d,d&&d.id,e,null,c),d.integrate(t,0),n.right=d,n.index=a,n.forward(),xe(t,e,n,o)},Ne=(t,e,n,r,s)=>{const i=t.doc,l=i.clientID;Me(n,s);const o=Le(t,e,n,s);t:for(;null!==n.right&&(r>0||o.size>0&&(n.right.deleted||n.right.content.constructor===Ze));){if(!n.right.deleted)switch(n.right.content.constructor){case Ze:{const{key:e,value:i}=n.right.content,l=s[e];if(void 0!==l){if(Ce(l,i))o.delete(e);else{if(0===r)break t;o.set(e,i)}n.right.delete(t)}else n.currentAttributes.set(e,i);break}default:r<n.right.length&&Et(t,ot(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let s="";for(;r>0;r--)s+="\n";n.right=new wn(ot(l,bt(i.store,l)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new rn(s)),n.right.integrate(t,0),n.forward()}xe(t,e,n,o)},Te=(t,e,n,r,s)=>{let i=e;const o=l.vt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Ze){const t=i.content;o.set(t.key,t)}i=i.right}let c=0,h=!1;for(;e!==i;){if(n===e&&(h=!0),!e.deleted){const n=e.content;switch(n.constructor){case Ze:{const{key:i,value:l}=n,d=r.get(i)??null;o.get(i)===n&&d!==l||(e.delete(t),c++,h||(s.get(i)??null)!==l||d===l||(null===d?s.delete(i):s.set(i,d))),h||e.deleted||Ie(s,n);break}}}e=e.right}return c},Re=t=>{let e=0;return Rt(t.doc,(n=>{let r=t._start,s=t._start,i=l.vt();const o=l.C(i);for(;s;){if(!1===s.deleted)if(s.content.constructor===Ze)Ie(o,s.content);else e+=Te(n,r,s,i,o),i=l.C(o),r=s;s=s.right}})),e},ze=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&At(t,n.store.clients.get(r),i,s,(t=>{t.deleted||t.content.constructor!==Ze||t.constructor===Pe||e.add(t.parent)}))}Rt(n,(n=>{S(t,t.deleteSet,(t=>{if(t instanceof Pe||!t.parent._hasFormatting||e.has(t.parent))return;const r=t.parent;t.content.constructor===Ze?e.add(r):((t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Ze){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(n,t)}));for(const t of e)Re(t)}))},Je=(t,e,n)=>{const r=n,s=l.C(e.currentAttributes),i=e.right;for(;n>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case gn:case Xe:case rn:n<e.right.length&&Et(t,ot(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t)}e.forward()}i&&Te(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&ee(o._searchMarker,e.index,-r+n),e};class Ue extends Qt{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)}))}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];Rt(t,(t=>{const n=new Map,r=new Map;let s=this.target._start,i=null;const l={};let o="",c=0,h=0;const d=()=>{if(null!==i){let t=null;switch(i){case"delete":h>0&&(t={delete:h}),h=0;break;case"insert":("object"===typeof o||o.length>0)&&(t={insert:o},n.size>0&&(t.attributes={},n.forEach(((e,n)=>{null!==e&&(t.attributes[n]=e)})))),o="";break;case"retain":c>0&&(t={retain:c},m.Im(l)||(t.attributes=m.kp({},l))),c=0}t&&e.push(t),i=null}};for(;null!==s;){switch(s.content.constructor){case gn:case Xe:this.adds(s)?this.deletes(s)||(d(),i="insert",o=s.content.getContent()[0],d()):this.deletes(s)?("delete"!==i&&(d(),i="delete"),h+=1):s.deleted||("retain"!==i&&(d(),i="retain"),c+=1);break;case rn:this.adds(s)?this.deletes(s)||("insert"!==i&&(d(),i="insert"),o+=s.content.str):this.deletes(s)?("delete"!==i&&(d(),i="delete"),h+=s.length):s.deleted||("retain"!==i&&(d(),i="retain"),c+=s.length);break;case Ze:{const{key:e,value:o}=s.content;if(this.adds(s)){if(!this.deletes(s)){const c=n.get(e)??null;Ce(c,o)?null!==o&&s.delete(t):("retain"===i&&d(),Ce(o,r.get(e)??null)?delete l[e]:l[e]=o)}}else if(this.deletes(s)){r.set(e,o);const t=n.get(e)??null;Ce(t,o)||("retain"===i&&d(),l[e]=t)}else if(!s.deleted){r.set(e,o);const n=l[e];void 0!==n&&(Ce(n,o)?null!==n&&s.delete(t):("retain"===i&&d(),null===o?delete l[e]:l[e]=o))}s.deleted||("insert"===i&&d(),Ie(n,s.content));break}}s=s.right}for(d();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}})),this._delta=e}return this._delta}}class Ve extends re{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Bt(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((t=>t()))}catch(n){console.error(n)}this._pending=null}_copy(){return new Ve}clone(){const t=new Ve;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);const n=new Ue(this,t,e);ne(this,t,n),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??Bt();let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===rn&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?Rt(this.doc,(n=>{const r=new Ee(null,this._start,0,new Map);for(let s=0;s<t.length;s++){const i=t[s];if(void 0!==i.insert){const l=e||"string"!==typeof i.insert||s!==t.length-1||null!==r.right||"\n"!==i.insert.slice(-1)?i.insert:i.insert.slice(0,-1);("string"!==typeof l||l.length>0)&&Oe(n,this,r,l,i.attributes||{})}else void 0!==i.retain?Ne(n,this,r,i.retain,i.attributes||{}):void 0!==i.delete&&Je(n,r,i.delete)}})):this._pending.push((()=>this.applyDelta(t)))}toDelta(t,e,n){this.doc??Bt();const r=[],s=new Map,i=this.doc;let l="",o=this._start;function c(){if(l.length>0){const t={};let e=!1;s.forEach(((n,r)=>{e=!0,t[r]=n}));const n={insert:l};e&&(n.attributes=t),r.push(n),l=""}}const h=()=>{for(;null!==o;){if(wt(o,t)||void 0!==e&&wt(o,e))switch(o.content.constructor){case rn:{const r=s.get("ychange");void 0===t||wt(o,t)?void 0===e||wt(o,e)?void 0!==r&&(c(),s.delete("ychange")):void 0!==r&&r.user===o.id.client&&"added"===r.type||(c(),s.set("ychange",n?n("added",o.id):{type:"added"})):void 0!==r&&r.user===o.id.client&&"removed"===r.type||(c(),s.set("ychange",n?n("removed",o.id):{type:"removed"})),l+=o.content.str;break}case gn:case Xe:{c();const t={insert:o.content.getContent()[0]};if(s.size>0){const e={};t.attributes=e,s.forEach(((t,n)=>{e[n]=t}))}r.push(t);break}case Ze:wt(o,t)&&(c(),Ie(s,o.content))}o=o.right}c()};return t||e?Rt(i,(n=>{t&&_t(n,t),e&&_t(n,e),h()}),"cleanup"):h(),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?Rt(r,(r=>{const s=Ae(r,this,t,!n);n||(n={},s.currentAttributes.forEach(((t,e)=>{n[e]=t}))),Oe(r,this,s,e,n)})):this._pending.push((()=>this.insert(t,e,n)))}insertEmbed(t,e,n){const r=this.doc;null!==r?Rt(r,(r=>{const s=Ae(r,this,t,!n);Oe(r,this,s,e,n||{})})):this._pending.push((()=>this.insertEmbed(t,e,n||{})))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?Rt(n,(n=>{Je(n,Ae(n,this,t,!0),e)})):this._pending.push((()=>this.delete(t,e)))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?Rt(r,(r=>{const s=Ae(r,this,t,!1);null!==s.right&&Ne(r,this,s,e,n)})):this._pending.push((()=>this.format(t,e,n)))}removeAttribute(t){null!==this.doc?Rt(this.doc,(e=>{fe(e,this,t)})):this._pending.push((()=>this.removeAttribute(t)))}setAttribute(t,e){null!==this.doc?Rt(this.doc,(n=>{pe(n,this,t,e)})):this._pending.push((()=>this.setAttribute(t,e)))}getAttribute(t){return we(this,t)}getAttributes(){return _e(this)}_write(t){t.writeTypeRef(cn)}}class Fe{constructor(t,e=(()=>!0)){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??Bt()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==He&&e.constructor!==We||null===e._start)for(;null!==t;){if(null!==t.right){t=t.right;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class We extends re{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new We}clone(){const t=new We;return t.insert(0,this.toArray().map((t=>t instanceof re?t.clone():t))),t}get length(){return this.doc??Bt(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new Fe(this,t)}querySelector(t){t=t.toUpperCase();const e=new Fe(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),s.HT(new Fe(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)))}_callObserver(t,e){ne(this,t,new Ke(this,e,t))}toString(){return oe(this,(t=>t.toString())).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),le(this,(s=>{r.insertBefore(s.toDOM(t,e,n),null)})),r}insert(t,e){null!==this.doc?Rt(this.doc,(n=>{ue(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)Rt(this.doc,(n=>{const r=t&&t instanceof re?t._item:t;de(n,this,r,e)}));else{const n=this._prelimContent,r=null===t?0:n.findIndex((e=>e===t))+1;if(0===r&&null!==t)throw u.vt("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?Rt(this.doc,(n=>{ge(n,this,t,e)})):this._prelimContent.splice(t,e)}toArray(){return ie(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return he(this,t)}slice(t=0,e=this.length){return se(this,t,e)}forEach(t){le(this,t)}_write(t){t.writeTypeRef(dn)}}class He extends We{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach(((t,e)=>{this.setAttribute(e,t)})),this._prelimAttrs=null}_copy(){return new He(this.nodeName)}clone(){const t=new He(this.nodeName),e=this.getAttributes();return m.jJ(e,((e,n)=>{"string"===typeof e&&t.setAttribute(n,e)})),t.insert(0,this.toArray().map((t=>t instanceof re?t.clone():t))),t}toString(){const t=this.getAttributes(),e=[],n=[];for(const i in t)n.push(i);n.sort();const r=n.length;for(let i=0;i<r;i++){const r=n[i];e.push(r+'="'+t[r]+'"')}const s=this.nodeName.toLocaleLowerCase();return`<${s}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${s}>`}removeAttribute(t){null!==this.doc?Rt(this.doc,(e=>{fe(e,this,t)})):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?Rt(this.doc,(n=>{pe(n,this,t,e)})):this._prelimAttrs.set(t,e)}getAttribute(t){return we(this,t)}hasAttribute(t){return ke(this,t)}getAttributes(t){return t?((t,e)=>{const n={};return t._map.forEach(((t,r)=>{let s=t;for(;null!==s&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;null!==s&&wt(s,e)&&(n[r]=s.content.getContent()[s.length-1])})),n})(this,t):_e(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),s=this.getAttributes();for(const i in s){const t=s[i];"string"===typeof t&&r.setAttribute(i,t)}return le(this,(s=>{r.appendChild(s.toDOM(t,e,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(hn),t.writeKey(this.nodeName)}}class Ke extends Qt{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)}))}}class $e extends Se{constructor(t){super(),this.hookName=t}_copy(){return new $e(this.hookName)}clone(){const t=new $e(this.hookName);return this.forEach(((e,n)=>{t.set(n,e)})),t}toDOM(t=document,e={},n){const r=e[this.hookName];let s;return s=void 0!==r?r.createDom(this):document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(s,this),s}_write(t){t.writeTypeRef(an),t.writeKey(this.hookName)}}class je extends Ve{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new je}clone(){const t=new je;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){const r=t.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map((t=>{const e=[];for(const r in t.attributes){const n=[];for(const e in t.attributes[r])n.push({key:e,value:t.attributes[r][e]});n.sort(((t,e)=>t.key<e.key?-1:1)),e.push({nodeName:r,attrs:n})}e.sort(((t,e)=>t.nodeName<e.nodeName?-1:1));let n="";for(let r=0;r<e.length;r++){const t=e[r];n+=`<${t.nodeName}`;for(let e=0;e<t.attrs.length;e++){const r=t.attrs[e];n+=` ${r.key}="${r.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n})).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(un)}}class qe{constructor(t,e){this.id=t,this.length=e}get deleted(){throw u.bD()}mergeWith(t){return!1}write(t,e,n){throw u.bD()}integrate(t,e){throw u.bD()}}class Pe extends qe{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),yt(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}}class Qe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Qe(this.content)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}class Ge{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ge(this.len)}splice(t){const e=new Ge(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){A(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}const Be=(t,e)=>new T({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ye{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ye(Be(this.doc.guid,this.opts))}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class Xe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Xe(this.embed)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}class Ze{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Ze(this.key,this.value)}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){const n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}class tn{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new tn(this.arr)}splice(t){const e=new tn(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeString(void 0===e?"undefined":JSON.stringify(e))}}getRef(){return 2}}const en="development"===b.dn("node_env");class nn{constructor(t){this.arr=t,en&&m.ol(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new nn(this.arr)}splice(t){const e=new nn(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}}class rn{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new rn(this.str)}splice(t){const e=new rn(this.str.slice(t));this.str=this.str.slice(0,t);const n=this.str.charCodeAt(t-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,t-1)+"\ufffd",e.str="\ufffd"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}}const sn=[t=>new ye,t=>new Se,t=>new Ve,t=>new He(t.readKey()),t=>new We,t=>new $e(t.readKey()),t=>new je],ln=0,on=1,cn=2,hn=3,dn=4,an=5,un=6;class gn{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new gn(this.type._copy())}splice(t){throw u.bD()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach((e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)})),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((e=>{for(;null!==e;)e.gc(t,!0),e=e.left})),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const fn=(t,e)=>{let n,r=e,s=0;do{s>0&&(r=ot(r.client,r.clock+s)),n=St(t,r),s=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof wn);return{item:n,diff:s}},pn=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new wn(ot(r,s+n),e,ot(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),null!==e.redone&&(i.redone=ot(e.redone.client,e.redone.clock+n)),e.right=i,null!==i.right&&(i.right.left=i),t._mergeStructs.push(i),null!==i.parentSub&&null===i.right&&i.parent._map.set(i.parentSub,i),e.length=n,i};class wn extends qe{constructor(t,e,n,r,s,i,l,o){super(t,o.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=i,this.parentSub=l,this.redone=null,this.content=o,this.info=this.content.isCountable()?g.KD:0}set marker(t){(this.info&g.wn)>0!==t&&(this.info^=g.wn)}get marker(){return(this.info&g.wn)>0}get keep(){return(this.info&g.Dk)>0}set keep(t){this.keep!==t&&(this.info^=g.Dk)}get countable(){return(this.info&g.KD)>0}get deleted(){return(this.info&g.D1)>0}set deleted(t){this.deleted!==t&&(this.info^=g.D1)}markDeleted(){this.info|=g.D1}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bt(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bt(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===it&&this.id.client!==this.parent.client&&this.parent.clock>=bt(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=vt(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Et(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Pe||this.right&&this.right.constructor===Pe)this.parent=null;else if(this.parent){if(this.parent.constructor===it){const t=St(e,this.parent);t.constructor===Pe?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===wn&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===wn&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=vt(t,t.doc.store,ot(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,s=new Set;for(;null!==e&&e!==this.right;){if(s.add(e),r.add(e),lt(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(lt(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!s.has(St(t.doc.store,e.origin)))break;r.has(St(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),yt(t.doc.store,this),this.content.integrate(t,this),Mt(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new Pe(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:ot(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&<(t.origin,this.lastId)&&this.right===t&<(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach((e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))})),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),A(t.deleteSet,this.id.client,this.id.clock,this.length),Mt(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw u.Mq();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[Dt(r,e.id.clock)]=n})(t,this,new Pe(this.id,this.length)):this.content=new Ge(this.length)}write(t,e){const n=e>0?ot(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,i=this.content.getRef()&g.WY|(null===n?0:g.wt)|(null===r?0:g.D7)|(null===s?0:g.KJ);if(t.writeInfo(i),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=ct(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===it?(t.writeParentInfo(!1),t.writeLeftID(e)):u.Mq();null!==s&&t.writeString(s)}this.content.write(t,e)}}const _n=(t,e)=>kn[e&g.WY](t),kn=[()=>{u.Mq()},t=>new Ge(t.readLen()),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const e=t.readString();"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return new tn(n)},t=>new Qe(t.readBuf()),t=>new rn(t.readString()),t=>new Xe(t.readJSON()),t=>new Ze(t.readKey(),t.readJSON()),t=>new gn(sn[t.readTypeRef()](t)),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new nn(n)},t=>new Ye(Be(t.readString(),t.readAny())),()=>{u.Mq()}];class mn extends qe{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){u.Mq()}write(t,e){t.writeInfo(10),o.zd(t.restEncoder,this.length-e)}getMissing(t,e){return null}}const bn="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:"undefined"!==typeof global?global:{},yn="__ $YJS$ __";!0===bn[yn]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),bn[yn]=!0}}]);
|