@jxsuite/studio 5.5.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/chunks/{2020-g8mwpbkq.js → 2020-cs2sb9t1.js} +3 -3
- package/dist/chunks/adapter-y5gdq19c.js +4 -0
- package/dist/chunks/cf-account-picker-882a7ecm.js +4 -0
- package/dist/chunks/cf-settings-20dznc3j.js +4 -0
- package/dist/chunks/components-q037dya7.js +4 -0
- package/dist/chunks/content-source-37x3vsap.js +4 -0
- package/dist/chunks/convert-to-repeater-grfep2w8.js +4 -0
- package/dist/chunks/editor-j5sq149q.js +4 -0
- package/dist/chunks/entry-commands-c5h3nqck.js +4 -0
- package/dist/chunks/extension-sections-dp8endhx.js +4 -0
- package/dist/chunks/file-ops-937cvqk6.js +4 -0
- package/dist/chunks/files-tznwe1p1.js +4 -0
- package/dist/chunks/format-host-e2pjvd25.js +4 -0
- package/dist/chunks/fs-events-fv64ak3s.js +4 -0
- package/dist/chunks/git-panel-gb713ttc.js +4 -0
- package/dist/chunks/grid-view-5amhg604.js +51 -0
- package/dist/chunks/grid-view-5mqv1cbd.css +1 -0
- package/dist/chunks/iframe-host-t819mcg5.js +4 -0
- package/dist/chunks/{index-arg188jq.js → index-9ydfe04y.js} +3 -3
- package/dist/chunks/index-m0x5ztax.js +4 -0
- package/dist/chunks/{javascript-zcdmye2k.js → javascript-d9pqgc2p.js} +2 -2
- package/dist/chunks/{jsonMode-6x5e1nbf.js → jsonMode-800yvbem.js} +5 -5
- package/dist/chunks/jx-validate-zc9zp77s.js +4 -0
- package/dist/chunks/layers-4bsr82wz.js +4 -0
- package/dist/chunks/layers-panel-b6shnaax.js +4 -0
- package/dist/chunks/lit-html-cfn61dn7.js +4 -0
- package/dist/chunks/media-picker-ej0kdh1j.js +4 -0
- package/dist/chunks/menu-rtxf9chb.js +4 -0
- package/dist/chunks/{monaco-binding-4az2kh5p.js → monaco-binding-62dtmgbf.js} +3 -3
- package/dist/chunks/monaco-buffer-nn4dtx27.js +4 -0
- package/dist/chunks/{monaco-setup-d7mwkcx3.js → monaco-setup-tj13ndtm.js} +3 -3
- package/dist/chunks/notify-ahs57a2z.js +4 -0
- package/dist/chunks/platform-v9xyfkbx.js +4 -0
- package/dist/chunks/publish-panel-bq36xcmj.js +4 -0
- package/dist/chunks/quick-search-zm00h9dh.js +4 -0
- package/dist/chunks/references-99ws0b0m.js +4 -0
- package/dist/chunks/right-panel-pq2f71q3.js +4 -0
- package/dist/chunks/section-registry-b2yzp9sw.js +4 -0
- package/dist/chunks/studio-01kbbqg3.js +928 -0
- package/dist/chunks/{studio-hf4qdjc8.js → studio-01qza1n3.js} +4 -4
- package/dist/chunks/{studio-pkkw32j0.js → studio-03wwfvyt.js} +4 -4
- package/dist/chunks/{studio-7gqyhjns.js → studio-0bbxhhce.js} +4 -4
- package/dist/chunks/studio-0k9mvpgj.js +14 -0
- package/dist/chunks/studio-0scebvb9.js +6 -0
- package/dist/chunks/studio-1a99w39s.js +5 -0
- package/dist/chunks/studio-1wvfxkyy.js +5 -0
- package/dist/chunks/studio-1x8x26k3.js +5 -0
- package/dist/chunks/studio-222rqyyc.js +5 -0
- package/dist/chunks/studio-4xppwncr.js +4 -0
- package/dist/chunks/{studio-xcng8nx7.js → studio-54g077x3.js} +5 -5
- package/dist/chunks/studio-56z7evx4.js +10 -0
- package/dist/chunks/studio-5e9zsamh.js +9 -0
- package/dist/chunks/studio-65fhspdd.js +5 -0
- package/dist/chunks/studio-693nhyky.js +5 -0
- package/dist/chunks/{studio-7jazdy6y.js → studio-7pgy3xaf.js} +4 -4
- package/dist/chunks/studio-888knnkc.js +5 -0
- package/dist/chunks/studio-9mqfamps.js +5 -0
- package/dist/chunks/studio-a7xqhc3n.js +5 -0
- package/dist/chunks/studio-aje966s9.js +5 -0
- package/dist/chunks/studio-aqmph6k4.js +5 -0
- package/dist/chunks/studio-c6w3tq7t.js +5 -0
- package/dist/chunks/{studio-6j2jn55a.js → studio-c6zdm25z.js} +8 -8
- package/dist/chunks/{studio-f8jyp45j.js → studio-c9d3pxf7.js} +4 -4
- package/dist/chunks/studio-ceb34dxj.js +5 -0
- package/dist/chunks/studio-cvbkkfqb.js +5 -0
- package/dist/chunks/studio-cxt150pj.js +7 -0
- package/dist/chunks/studio-dkn3x3hz.js +5 -0
- package/dist/chunks/studio-e6re3rk1.js +5 -0
- package/dist/chunks/{studio-5n1km79v.js → studio-edbtvcd1.js} +4 -4
- package/dist/chunks/{studio-xc8ebsts.js → studio-eh0rac07.js} +4 -4
- package/dist/chunks/{studio-625ezz59.js → studio-evwgp1ym.js} +4 -4
- package/dist/chunks/{studio-he2fhrgp.js → studio-f195h2hq.js} +4 -4
- package/dist/chunks/studio-fqq890ap.js +4 -0
- package/dist/chunks/studio-frb0qbf7.js +6 -0
- package/dist/chunks/studio-gfn1kpxj.js +6 -0
- package/dist/chunks/studio-gh97gngt.js +5 -0
- package/dist/chunks/{studio-awqghqxv.js → studio-gp02nqnw.js} +4 -4
- package/dist/chunks/{studio-x9sagq2d.js → studio-hjbg8d5y.js} +7 -7
- package/dist/chunks/studio-j6gnhvaa.js +5 -0
- package/dist/chunks/studio-mwxgyn9h.js +7 -0
- package/dist/chunks/{studio-x5esgzct.js → studio-n78gjfy8.js} +4 -4
- package/dist/chunks/studio-nbxqcgvf.js +5 -0
- package/dist/chunks/{studio-p1eggxcf.js → studio-nt06yybj.js} +4 -4
- package/dist/chunks/{studio-hc9q4j24.js → studio-p7c1agz0.js} +5 -5
- package/dist/chunks/{studio-8r4y2x0z.js → studio-pwqfmt4p.js} +4 -4
- package/dist/chunks/{studio-5wfrgee9.js → studio-r3kaka4d.js} +4 -4
- package/dist/chunks/studio-semd1s8s.js +5 -0
- package/dist/chunks/studio-skzanb0k.js +5 -0
- package/dist/chunks/studio-spf2skgc.js +5 -0
- package/dist/chunks/{studio-b4epb26c.js → studio-st75kn99.js} +7 -7
- package/dist/chunks/{studio-eq27rrr0.js → studio-sxc0zvpt.js} +3 -3
- package/dist/chunks/studio-t1eedsyx.js +4 -0
- package/dist/chunks/{studio-73czgk6a.js → studio-tp642n5g.js} +4 -4
- package/dist/chunks/studio-tw7rre6s.js +5 -0
- package/dist/chunks/{studio-7by9a93k.js → studio-tzegmy4w.js} +4 -4
- package/dist/chunks/studio-vavmwshr.js +5 -0
- package/dist/chunks/studio-wma2c6g8.js +5 -0
- package/dist/chunks/studio-x92tgnee.js +64 -0
- package/dist/chunks/studio-xk0z6msk.js +5 -0
- package/dist/chunks/{studio-c4pnt1c6.js → studio-xry7tk3z.js} +5 -5
- package/dist/chunks/studio-xta2vxp6.js +9 -0
- package/dist/chunks/{studio-21enxdr8.js → studio-xy3tv3az.js} +4 -4
- package/dist/chunks/studio-y7jehjrp.js +5 -0
- package/dist/chunks/{studio-k1eaqyzm.js → studio-yr04mv2j.js} +4 -4
- package/dist/chunks/{studio-mhhc9btt.js → studio-zd4kayn2.js} +4 -4
- package/dist/chunks/studio-zpnk016a.js +16 -0
- package/dist/chunks/{tsMode-rtwt7w1a.js → tsMode-k9s9fcag.js} +5 -5
- package/dist/chunks/workspace-b69mgm0e.js +4 -0
- package/dist/chunks/ws-client-0ja08haa.js +4 -0
- package/dist/iframe-entry.js +14 -14
- package/dist/manifest.json +62 -59
- package/dist/studio.css +1 -1
- package/dist/studio.js +121 -123
- package/package.json +5 -5
- package/src/account/action-flow.ts +294 -0
- package/src/account/action-required.ts +68 -0
- package/src/account-status.ts +29 -1
- package/src/browse/library-model.ts +3 -1
- package/src/browse/library-preview.ts +6 -2
- package/src/canvas/asset-refs.ts +3 -1
- package/src/canvas/asset-resolve.ts +79 -1
- package/src/canvas/iframe-entry.ts +38 -1
- package/src/canvas/iframe-host.ts +85 -0
- package/src/canvas/iframe-protocol.ts +13 -0
- package/src/canvas/stage-scrollbar.ts +7 -7
- package/src/files/asset-versions.ts +294 -0
- package/src/files/file-ops.ts +5 -8
- package/src/files/files.ts +61 -9
- package/src/files/fs-events.ts +279 -28
- package/src/files/media-meta.ts +2 -1
- package/src/files/media-paths.ts +5 -2
- package/src/files/media-upload.ts +5 -1
- package/src/new-project/add-repo-modal.ts +12 -1
- package/src/new-project/new-project-modal.ts +12 -1
- package/src/panels/git-panel.ts +25 -2
- package/src/panels/jump-bar.ts +132 -158
- package/src/panels/pane-context.ts +8 -8
- package/src/panels/pane-grid.ts +18 -26
- package/src/panels/style-panel.ts +2 -2
- package/src/platform-errors.ts +61 -1
- package/src/platforms/cloud.ts +389 -50
- package/src/platforms/devserver.ts +17 -1
- package/src/publish/pages-service.ts +17 -7
- package/src/services/ai-models.ts +30 -6
- package/src/services/ai-system-prompt.ts +81 -51
- package/src/services/context-manager.ts +41 -70
- package/src/services/document-assistant.ts +12 -3
- package/src/services/harness/chat-reducer.ts +115 -0
- package/src/services/harness/turn-hooks.ts +50 -0
- package/src/services/tool-executor.ts +69 -288
- package/src/services/tool-outcomes.ts +12 -10
- package/src/settings/preferences-accounts.ts +42 -3
- package/src/settings/preferences-dialog.ts +8 -1
- package/src/studio.ts +20 -6
- package/src/surfaces/block-action-bar.json +6 -1
- package/src/surfaces/dialog.ts +5 -0
- package/src/surfaces/jump-bar.json +9 -12
- package/src/surfaces/jump-bar.ts +15 -16
- package/src/surfaces/pane-context.json +2 -2
- package/src/surfaces/pane-grid.json +8 -25
- package/src/surfaces/pane-grid.ts +7 -8
- package/src/surfaces/statusbar.json +71 -3
- package/src/surfaces/statusbar.ts +66 -139
- package/src/surfaces/style-panel.json +3 -3
- package/src/surfaces/style-panel.ts +11 -1
- package/src/surfaces/welcome.json +86 -1
- package/src/surfaces/welcome.ts +61 -2
- package/src/types.ts +84 -2
- package/src/ui/ai-managed-connect.ts +41 -4
- package/src/ui/media-picker.ts +2 -1
- package/dist/chunks/adapter-bsbs78x9.js +0 -4
- package/dist/chunks/cf-account-picker-gnm7xeqb.js +0 -4
- package/dist/chunks/cf-settings-9y6jyscp.js +0 -4
- package/dist/chunks/components-s51h3b7c.js +0 -4
- package/dist/chunks/content-source-ty3be0qg.js +0 -4
- package/dist/chunks/convert-to-repeater-c3e7q61z.js +0 -4
- package/dist/chunks/editor-t002b41m.js +0 -4
- package/dist/chunks/entry-commands-sb72e9gy.js +0 -4
- package/dist/chunks/extension-sections-ktn2ntnj.js +0 -4
- package/dist/chunks/file-ops-78zeytkm.js +0 -4
- package/dist/chunks/files-gatzrz8v.js +0 -4
- package/dist/chunks/format-host-r59b1651.js +0 -4
- package/dist/chunks/fs-events-f8h91ndt.js +0 -4
- package/dist/chunks/git-panel-y12zf7nj.js +0 -4
- package/dist/chunks/grid-view-rfd8b2pg.js +0 -51
- package/dist/chunks/grid-view-tafenfm2.css +0 -1
- package/dist/chunks/iframe-host-vsrsj20g.js +0 -4
- package/dist/chunks/index-5aghyrfh.js +0 -4
- package/dist/chunks/jx-validate-653krkrf.js +0 -4
- package/dist/chunks/layers-32p8gtae.js +0 -4
- package/dist/chunks/layers-panel-rs58m105.js +0 -4
- package/dist/chunks/lit-html-54bmkwz3.js +0 -4
- package/dist/chunks/media-picker-5bb04wct.js +0 -4
- package/dist/chunks/menu-cbha7w2e.js +0 -4
- package/dist/chunks/monaco-buffer-9vbbyfr1.js +0 -4
- package/dist/chunks/notify-dc1nz5ar.js +0 -4
- package/dist/chunks/platform-2m49s1zf.js +0 -4
- package/dist/chunks/publish-panel-nx3ycmma.js +0 -4
- package/dist/chunks/quick-search-yzrzh9x3.js +0 -4
- package/dist/chunks/references-vx7mbj9f.js +0 -4
- package/dist/chunks/right-panel-7jzpbxja.js +0 -4
- package/dist/chunks/section-registry-gjryse41.js +0 -4
- package/dist/chunks/studio-3znfhcxg.js +0 -5
- package/dist/chunks/studio-58qam27v.js +0 -4
- package/dist/chunks/studio-6j59fwaw.js +0 -5
- package/dist/chunks/studio-7z69g1gx.js +0 -5
- package/dist/chunks/studio-93j3v6zx.js +0 -5
- package/dist/chunks/studio-9gf6v8zy.js +0 -5
- package/dist/chunks/studio-9rhmettf.js +0 -4
- package/dist/chunks/studio-ac5aq677.js +0 -10
- package/dist/chunks/studio-as65vbns.js +0 -5
- package/dist/chunks/studio-bkv0sga4.js +0 -6
- package/dist/chunks/studio-bttmqef4.js +0 -5
- package/dist/chunks/studio-c3y9d41k.js +0 -5
- package/dist/chunks/studio-ccegp7gz.js +0 -9
- package/dist/chunks/studio-chxabn98.js +0 -6
- package/dist/chunks/studio-cktcdsxz.js +0 -16
- package/dist/chunks/studio-cnspfke5.js +0 -5
- package/dist/chunks/studio-de3p1ktm.js +0 -5
- package/dist/chunks/studio-fsbcn530.js +0 -928
- package/dist/chunks/studio-gftga7a3.js +0 -64
- package/dist/chunks/studio-hf1rpcq0.js +0 -4
- package/dist/chunks/studio-hz02hq70.js +0 -5
- package/dist/chunks/studio-jnb285we.js +0 -5
- package/dist/chunks/studio-jsv3s3s1.js +0 -5
- package/dist/chunks/studio-ks7cksh0.js +0 -5
- package/dist/chunks/studio-nptx0dbs.js +0 -5
- package/dist/chunks/studio-pg0z7k98.js +0 -5
- package/dist/chunks/studio-pve0b2f2.js +0 -5
- package/dist/chunks/studio-q7zmjv3b.js +0 -6
- package/dist/chunks/studio-rpmvw7kj.js +0 -5
- package/dist/chunks/studio-rwhss52s.js +0 -5
- package/dist/chunks/studio-sbg3g3h0.js +0 -5
- package/dist/chunks/studio-sq1bn60g.js +0 -14
- package/dist/chunks/studio-vwz7rma2.js +0 -5
- package/dist/chunks/studio-wa55e8gf.js +0 -5
- package/dist/chunks/studio-x0mzdha2.js +0 -5
- package/dist/chunks/studio-xrgpakvc.js +0 -9
- package/dist/chunks/studio-xt3djk1w.js +0 -7
- package/dist/chunks/studio-yh3nggx1.js +0 -7
- package/dist/chunks/studio-zmecp6hq.js +0 -5
- package/dist/chunks/workspace-g6dvaete.js +0 -4
- package/dist/chunks/ws-client-shf41j5p.js +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var O=()=>new Map,Se=(t)=>{let e=O();return t.forEach((n,r)=>{e.set(r,n)}),e},P=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},vr=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},Rr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Y=()=>new Set;var _e=(t)=>t[t.length-1];var Lr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},z=Array.from,Te=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},zt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var Vr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var tt=Array.isArray;class Ue{constructor(){this._observers=O()}on(t,e){return P(this._observers,t,Y).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return z((this._observers.get(t)||O()).values()).forEach((n)=>n(...e))}destroy(){this._observers=O()}}var N=Math.floor;var ct=Math.abs;var Ee=(t,e)=>t<e?t:e,et=(t,e)=>t>e?t:e;var Be=(t)=>t!==0?t<0:1/t<0;var Un=1,En=2,Ae=4,Ce=8;var bt=32,G=64,A=128;var Wt=31,Zt=63,nt=127;var Mr=2147483647;var{MAX_SAFE_INTEGER:It,MIN_SAFE_INTEGER:An}=Number;var Fr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&N(t)===t);var{fromCharCode:Dn,fromCodePoint:Wo}=String,Hl=Dn(65535),Zo=(t)=>t.toLowerCase(),Xo=/^\s*/g,Qo=(t)=>t.replace(Xo,""),Yo=/([A-Z])/g,On=(t,e)=>Qo(t.replace(Yo,(n)=>`${e}${Zo(n)}`));var ti=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},St=typeof TextEncoder<"u"?new TextEncoder:null,ei=(t)=>St.encode(t),$r=St?ei:ti;var kt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(kt&&kt.decode(new Uint8Array).length===1)kt=null;var jr=(t,e)=>Vr(e,()=>t).join("");class Tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Xt=()=>new Tt;var ni=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var H=(t)=>{let e=new Uint8Array(ni(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ri=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(et(n,e)*2),t.cpos=0},E=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var Oe=E;var w=(t,e)=>{while(e>nt)E(t,A|nt&e),e=N(e/128);E(t,nt&e)},Ne=(t,e)=>{let n=Be(e);if(n)e=-e;E(t,(e>Zt?A:0)|(n?G:0)|Zt&e),e=N(e/64);while(e>0)E(t,(e>nt?A:0)|nt&e),e=N(e/128)},Nn=new Uint8Array(30000),si=Nn.length/3,oi=(t,e)=>{if(e.length<si){let n=St.encodeInto(e,Nn).written||0;w(t,n);for(let r=0;r<n;r++)E(t,Nn[r])}else R(t,$r(e))},ii=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;w(t,r);for(let s=0;s<r;s++)E(t,n.codePointAt(s))},lt=St&&St.encodeInto?oi:ii;var Qt=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Ee(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(et(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},R=(t,e)=>{w(t,e.byteLength),Qt(t,e)},vn=(t,e)=>{ri(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ci=(t,e)=>vn(t,4).setFloat32(0,e,!1),li=(t,e)=>vn(t,8).setFloat64(0,e,!1),ai=(t,e)=>vn(t,8).setBigInt64(0,e,!1);var qr=new DataView(new ArrayBuffer(4)),hi=(t)=>(qr.setFloat32(0,t),qr.getFloat32(0)===t),_t=(t,e)=>{switch(typeof e){case"string":E(t,119),lt(t,e);break;case"number":if(Fr(e)&&ct(e)<=Mr)E(t,125),Ne(t,e);else if(hi(e))E(t,124),ci(t,e);else E(t,123),li(t,e);break;case"bigint":E(t,122),ai(t,e);break;case"object":if(e===null)E(t,126);else if(tt(e)){E(t,117),w(t,e.length);for(let n=0;n<e.length;n++)_t(t,e[n])}else if(e instanceof Uint8Array)E(t,116),R(t,e);else{E(t,118);let n=Object.keys(e);w(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(t,s),_t(t,e[s])}}break;case"boolean":E(t,e?120:121);break;default:E(t,127)}};class ve extends Tt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var Gr=(t)=>{if(t.count>0){if(Ne(t.encoder,t.count===1?t.s:-t.s),t.count>1)w(t.encoder,t.count-2)}};class Ut{constructor(){this.encoder=new Tt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else Gr(this),this.count=1,this.s=t}toUint8Array(){return Gr(this),H(this.encoder)}}var Hr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(Ne(t.encoder,e),t.count>1)w(t.encoder,t.count-2)}};class Yt{constructor(){this.encoder=new Tt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Hr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Hr(this),H(this.encoder)}}class Rn{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new Tt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),H(t)}}var M=(t)=>Error(t),F=()=>{throw M("Method unimplemented")},v=()=>{throw M("Unexpected case")};var Pr=M("Unexpected end of array"),zr=M("Integer out of Range");class te{constructor(t){this.arr=t,this.pos=0}}var ut=(t)=>new te(t),Jr=(t)=>t.pos!==t.arr.length;var fi=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},L=(t)=>fi(t,x(t));var at=(t)=>t.arr[t.pos++];var x=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&nt)*n,n*=128,s<A)return e;if(e>It)throw zr}throw Pr},Re=(t)=>{let e=t.arr[t.pos++],n=e&Zt,r=64,s=(e&G)>0?-1:1;if((e&A)===0)return s*n;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],n=n+(e&nt)*r,r*=128,e<A)return s*n;if(n>It)throw zr}throw Pr};var di=(t)=>{let e=x(t);if(e===0)return"";else{let n=String.fromCodePoint(at(t));if(--e<100)while(e--)n+=String.fromCodePoint(at(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},pi=(t)=>kt.decode(L(t)),ht=kt?pi:di;var Vn=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},gi=(t)=>Vn(t,4).getFloat32(0,!1),mi=(t)=>Vn(t,8).getFloat64(0,!1),xi=(t)=>Vn(t,8).getBigInt64(0,!1);var wi=[(t)=>{return},(t)=>null,Re,gi,mi,xi,(t)=>!1,(t)=>!0,ht,(t)=>{let e=x(t),n={};for(let r=0;r<e;r++){let s=ht(t);n[s]=Et(t)}return n},(t)=>{let e=x(t),n=[];for(let r=0;r<e;r++)n.push(Et(t));return n},L],Et=(t)=>wi[127-at(t)](t);class Le extends te{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Jr(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class Bt extends te{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Re(this);let t=Be(this.s);if(this.count=1,t)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class ee extends te{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Re(this),e=t&1;if(this.diff=N(t/2),this.count=1,e)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Mn{constructor(t){this.decoder=new Bt(t),this.str=ht(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Jl=crypto.subtle,Kr=crypto.getRandomValues.bind(crypto);var Fn=()=>Kr(new Uint32Array(1))[0];var bi=[1e7]+-1000+-4000+-8000+-100000000000,Wr=()=>bi.replace(/[018]/g,(t)=>(t^Fn()&15>>t/4).toString(16));var Ve=Date.now;var $n=(t)=>new Promise(t);var Zl=Promise.all.bind(Promise);var jn=(t)=>t===void 0?null:t;class Xr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Qr=new Xr,_i=!0;try{if(typeof localStorage<"u"&&localStorage)Qr=localStorage,_i=!1}catch(t){}var Yr=Qr;var ft=Symbol("Equality"),Me=(t,e)=>t===e||!!t?.[ft]?.(e)||!1;var ts=(t)=>typeof t==="object",{assign:es,keys:Ui}=Object;var ns=(t,e)=>{for(let n in t)e(t[n],n)};var ne=(t)=>Ui(t).length;var rs=(t)=>{for(let e in t)return!1;return!0},At=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=(t,e)=>t===e||ne(t)===ne(e)&&At(t,(n,r)=>(n!==void 0||re(e,r))&&Me(e[r],n)),Ei=Object.freeze,Hn=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")Hn(t[e])}return Ei(t)};var oe=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)oe(t,e,n+1)}};var ss=(t)=>t;var se=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ft]!=null)return t[ft](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!se(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ne(t)!==ne(e))return!1;for(let n in t)if(!re(t,n)||!se(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!se(t[n],e[n]))return!1;break;default:return!1}return!0},is=(t,e)=>e.includes(t);var ie=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var Xl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,J,Bi=[],Ai=()=>{if(J===void 0)if(ie){J=O();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)J.set(e,"");e=r}else if(e!==null)J.set(e,r),e=null;else Bi.push(r)}if(e!==null)J.set(e,"")}else if(typeof location==="object")J=O(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");J.set(`--${On(e,"-")}`,n),J.set(`-${On(e,"-")}`,n)}});else J=O();return J},Jn=(t)=>Ai().has(t);var ce=(t)=>ie?jn(process.env[t.toUpperCase().replaceAll("-","_")]):jn(Yr.getItem(t));var cs=(t)=>Jn("--"+t)||ce(t)!==null,ls=cs("production"),Ci=ie&&is(process.env.FORCE_COLOR,["true","1","2"]),as=Ci||!Jn("--no-colors")&&!cs("no-color")&&(!ie||process.stdout.isTTY)&&(!ie||Jn("--color")||ce("COLORTERM")!==null||(ce("TERM")||"").includes("color"));var Di=(t)=>new Uint8Array(t);var hs=(t)=>{let e=Di(t.byteLength);return e.set(t),e};class us{constructor(t,e){this.left=t,this.right=e}}var K=(t,e)=>new us(t,e);var Wn=(t)=>t.next()>=0.5,Fe=(t,e,n)=>N(t.next()*(n+1-e)+e);var Zn=(t,e,n)=>N(t.next()*(n+1-e)+e);var Xn=(t,e,n)=>Zn(t,e,n);var vi=(t)=>Dn(Xn(t,97,122)),fs=(t,e=0,n=20)=>{let r=Xn(t,e,n),s="";for(let o=0;o<r;o++)s+=vi(t);return s};var $e=(t,e)=>e[Xn(t,0,e.length-1)];var Li=Symbol("0schema");class ps{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(jr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
|
|
2
|
-
`)}}var Qn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[ft])return Me(t,e);if(tt(t))return Te(t,(n)=>zt(e,(r)=>Qn(n,r)));else if(ts(t))return At(t,(n,r)=>Qn(n,e[r]));return!1};class C{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];if(this.constructor._dilutes)[n,e]=[e,n];return Qn(e,n)}equals(t){return this.constructor===t.constructor&&se(this.shape,t.shape)}[Li](){return!0}[ft](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){F()}get nullable(){return Nt(this,We)}get optional(){return new Yn(this)}cast(t){return ds(t,this),t}expect(t){return ds(t,this),t}}class Ge extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let n=t?.constructor===this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var S=(t,e=null)=>new Ge(t,e),Yl=S(Ge);class He extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}var _=(t)=>new He(t),ta=S(He);class ae extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape.some((r)=>r===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}var Pe=(...t)=>new ae(t),gs=S(ae),Vi=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),ms=(t)=>{if(Ot.check(t))return[Vi(t)];if(gs.check(t))return t.shape.map((e)=>e+"");if(
|
|
3
|
-
${n.toString()}`)};class Bs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var rc=(t)=>new Bs(t),As=rc(qe).if(Ts,(t,e)=>Fe(e,An,It)).if(Us,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=As(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Es,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>As(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===lc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===oc);var ma=_((t)=>t.nodeType===ic);var Cs=(t)=>vr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:oc,TEXT_NODE:ic,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:cc,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:lc}=dt,ba=_((t)=>t.nodeType===cc);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Ds=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=Cs(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Os=as?dc:Ds,Ns=(...t)=>{console.log(...Os(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Os(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Lr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class nc extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Is)}getText(t=""){return this.get(t,os)}getMap(t=""){return this.get(t,Br)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new nc({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(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 Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(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){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},WS=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},VS=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},US=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},Ly=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},mf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(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}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!Rr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Ns(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Cr(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class wR extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof nc?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Nr=m-k;if(Nr>0)de(h,B,k,Nr)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Cr(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{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=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Ur=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Ur++}}var qc=(t)=>{t.timestamp=Ur++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ur++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case nc:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Er=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case nc:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Ar=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Tg extends ye{}class Is extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Is;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Is}clone(){let t=new Is;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Tg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Is;class Iy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Br extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Br}clone(){let t=new Br;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new Iy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Ar(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Br,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
-
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Ar(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new os;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Ar(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Br{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends os{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.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(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(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}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new nc({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let 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}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Cr=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Cr(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var gf=()=>new Po;var e_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var bf=(t)=>{let e=new Uint8Array(e_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Dr=new Uint8Array(30000),Dl=Dr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Dr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Dr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Or=(t)=>Error(t);var Jo=Or("Unexpected end of array"),Vl=Or("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var $y=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var qS=0,GS=1,KS=2,JS=3;class vf extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function t_(t){let e=gf();switch(t.type){case"doc-sync":{rt(e,qS),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,GS),kn(e,t.body);break}case"doc-close":{rt(e,KS),In(e,t.path);break}case"control":{rt(e,JS),In(e,JSON.stringify(t.message));break}default:throw new vf(`unknown-frame:${t.type}`)}return bf(e)}function n_(t){try{let e=$y(t),n=ke(e);switch(n){case qS:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case GS:return{body:Sn(e),type:"awareness"};case KS:return{path:_n(e),type:"doc-close"};case JS:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new vf("malformed-control");return{message:r,type:"control"}}default:throw new vf(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof vf)throw e;throw new vf(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
-
export{
|
|
1
|
+
var O=()=>new Map,Se=(t)=>{let e=O();return t.forEach((n,r)=>{e.set(r,n)}),e},P=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},vr=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},Rr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Y=()=>new Set;var _e=(t)=>t[t.length-1];var Lr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},z=Array.from,Te=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},zt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var Vr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var tt=Array.isArray;class Ue{constructor(){this._observers=O()}on(t,e){return P(this._observers,t,Y).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return z((this._observers.get(t)||O()).values()).forEach((n)=>n(...e))}destroy(){this._observers=O()}}var N=Math.floor;var ct=Math.abs;var Ee=(t,e)=>t<e?t:e,et=(t,e)=>t>e?t:e;var Be=(t)=>t!==0?t<0:1/t<0;var Un=1,En=2,Ae=4,Ce=8;var bt=32,G=64,A=128;var Wt=31,Zt=63,nt=127;var Mr=2147483647;var{MAX_SAFE_INTEGER:It,MIN_SAFE_INTEGER:An}=Number;var Fr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&N(t)===t);var{fromCharCode:Dn,fromCodePoint:Wo}=String,Hl=Dn(65535),Zo=(t)=>t.toLowerCase(),Xo=/^\s*/g,Qo=(t)=>t.replace(Xo,""),Yo=/([A-Z])/g,On=(t,e)=>Qo(t.replace(Yo,(n)=>`${e}${Zo(n)}`));var ti=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},St=typeof TextEncoder<"u"?new TextEncoder:null,ei=(t)=>St.encode(t),$r=St?ei:ti;var kt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(kt&&kt.decode(new Uint8Array).length===1)kt=null;var jr=(t,e)=>Vr(e,()=>t).join("");class Tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Xt=()=>new Tt;var ni=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var H=(t)=>{let e=new Uint8Array(ni(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ri=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(et(n,e)*2),t.cpos=0},E=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var Oe=E;var w=(t,e)=>{while(e>nt)E(t,A|nt&e),e=N(e/128);E(t,nt&e)},Ne=(t,e)=>{let n=Be(e);if(n)e=-e;E(t,(e>Zt?A:0)|(n?G:0)|Zt&e),e=N(e/64);while(e>0)E(t,(e>nt?A:0)|nt&e),e=N(e/128)},Nn=new Uint8Array(30000),si=Nn.length/3,oi=(t,e)=>{if(e.length<si){let n=St.encodeInto(e,Nn).written||0;w(t,n);for(let r=0;r<n;r++)E(t,Nn[r])}else R(t,$r(e))},ii=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;w(t,r);for(let s=0;s<r;s++)E(t,n.codePointAt(s))},lt=St&&St.encodeInto?oi:ii;var Qt=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Ee(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(et(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},R=(t,e)=>{w(t,e.byteLength),Qt(t,e)},vn=(t,e)=>{ri(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ci=(t,e)=>vn(t,4).setFloat32(0,e,!1),li=(t,e)=>vn(t,8).setFloat64(0,e,!1),ai=(t,e)=>vn(t,8).setBigInt64(0,e,!1);var qr=new DataView(new ArrayBuffer(4)),hi=(t)=>(qr.setFloat32(0,t),qr.getFloat32(0)===t),_t=(t,e)=>{switch(typeof e){case"string":E(t,119),lt(t,e);break;case"number":if(Fr(e)&&ct(e)<=Mr)E(t,125),Ne(t,e);else if(hi(e))E(t,124),ci(t,e);else E(t,123),li(t,e);break;case"bigint":E(t,122),ai(t,e);break;case"object":if(e===null)E(t,126);else if(tt(e)){E(t,117),w(t,e.length);for(let n=0;n<e.length;n++)_t(t,e[n])}else if(e instanceof Uint8Array)E(t,116),R(t,e);else{E(t,118);let n=Object.keys(e);w(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(t,s),_t(t,e[s])}}break;case"boolean":E(t,e?120:121);break;default:E(t,127)}};class ve extends Tt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var Gr=(t)=>{if(t.count>0){if(Ne(t.encoder,t.count===1?t.s:-t.s),t.count>1)w(t.encoder,t.count-2)}};class Ut{constructor(){this.encoder=new Tt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else Gr(this),this.count=1,this.s=t}toUint8Array(){return Gr(this),H(this.encoder)}}var Hr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(Ne(t.encoder,e),t.count>1)w(t.encoder,t.count-2)}};class Yt{constructor(){this.encoder=new Tt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Hr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Hr(this),H(this.encoder)}}class Rn{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new Tt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),H(t)}}var M=(t)=>Error(t),F=()=>{throw M("Method unimplemented")},v=()=>{throw M("Unexpected case")};var Pr=M("Unexpected end of array"),zr=M("Integer out of Range");class te{constructor(t){this.arr=t,this.pos=0}}var ut=(t)=>new te(t),Jr=(t)=>t.pos!==t.arr.length;var fi=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},L=(t)=>fi(t,x(t));var at=(t)=>t.arr[t.pos++];var x=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&nt)*n,n*=128,s<A)return e;if(e>It)throw zr}throw Pr},Re=(t)=>{let e=t.arr[t.pos++],n=e&Zt,r=64,s=(e&G)>0?-1:1;if((e&A)===0)return s*n;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],n=n+(e&nt)*r,r*=128,e<A)return s*n;if(n>It)throw zr}throw Pr};var di=(t)=>{let e=x(t);if(e===0)return"";else{let n=String.fromCodePoint(at(t));if(--e<100)while(e--)n+=String.fromCodePoint(at(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},pi=(t)=>kt.decode(L(t)),ht=kt?pi:di;var Vn=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},gi=(t)=>Vn(t,4).getFloat32(0,!1),mi=(t)=>Vn(t,8).getFloat64(0,!1),xi=(t)=>Vn(t,8).getBigInt64(0,!1);var wi=[(t)=>{return},(t)=>null,Re,gi,mi,xi,(t)=>!1,(t)=>!0,ht,(t)=>{let e=x(t),n={};for(let r=0;r<e;r++){let s=ht(t);n[s]=Et(t)}return n},(t)=>{let e=x(t),n=[];for(let r=0;r<e;r++)n.push(Et(t));return n},L],Et=(t)=>wi[127-at(t)](t);class Le extends te{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Jr(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class Bt extends te{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Re(this);let t=Be(this.s);if(this.count=1,t)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class ee extends te{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Re(this),e=t&1;if(this.diff=N(t/2),this.count=1,e)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Mn{constructor(t){this.decoder=new Bt(t),this.str=ht(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Jl=crypto.subtle,Kr=crypto.getRandomValues.bind(crypto);var Fn=()=>Kr(new Uint32Array(1))[0];var bi=[1e7]+-1000+-4000+-8000+-100000000000,Wr=()=>bi.replace(/[018]/g,(t)=>(t^Fn()&15>>t/4).toString(16));var Ve=Date.now;var $n=(t)=>new Promise(t);var Zl=Promise.all.bind(Promise);var jn=(t)=>t===void 0?null:t;class Xr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Qr=new Xr,_i=!0;try{if(typeof localStorage<"u"&&localStorage)Qr=localStorage,_i=!1}catch(t){}var Yr=Qr;var ft=Symbol("Equality"),Me=(t,e)=>t===e||!!t?.[ft]?.(e)||!1;var ts=(t)=>typeof t==="object",{assign:es,keys:Ui}=Object;var ns=(t,e)=>{for(let n in t)e(t[n],n)};var ne=(t)=>Ui(t).length;var rs=(t)=>{for(let e in t)return!1;return!0},At=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=(t,e)=>t===e||ne(t)===ne(e)&&At(t,(n,r)=>(n!==void 0||re(e,r))&&Me(e[r],n)),Ei=Object.freeze,Hn=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")Hn(t[e])}return Ei(t)};var oe=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)oe(t,e,n+1)}};var ss=(t)=>t;var se=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ft]!=null)return t[ft](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!se(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ne(t)!==ne(e))return!1;for(let n in t)if(!re(t,n)||!se(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!se(t[n],e[n]))return!1;break;default:return!1}return!0},os=(t,e)=>e.includes(t);var ie=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var Xl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,J,Bi=[],Ai=()=>{if(J===void 0)if(ie){J=O();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)J.set(e,"");e=r}else if(e!==null)J.set(e,r),e=null;else Bi.push(r)}if(e!==null)J.set(e,"")}else if(typeof location==="object")J=O(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");J.set(`--${On(e,"-")}`,n),J.set(`-${On(e,"-")}`,n)}});else J=O();return J},Jn=(t)=>Ai().has(t);var ce=(t)=>ie?jn(process.env[t.toUpperCase().replaceAll("-","_")]):jn(Yr.getItem(t));var is=(t)=>Jn("--"+t)||ce(t)!==null,cs=is("production"),Ci=ie&&os(process.env.FORCE_COLOR,["true","1","2"]),ls=Ci||!Jn("--no-colors")&&!is("no-color")&&(!ie||process.stdout.isTTY)&&(!ie||Jn("--color")||ce("COLORTERM")!==null||(ce("TERM")||"").includes("color"));var Di=(t)=>new Uint8Array(t);var hs=(t)=>{let e=Di(t.byteLength);return e.set(t),e};class us{constructor(t,e){this.left=t,this.right=e}}var K=(t,e)=>new us(t,e);var Wn=(t)=>t.next()>=0.5,Fe=(t,e,n)=>N(t.next()*(n+1-e)+e);var Zn=(t,e,n)=>N(t.next()*(n+1-e)+e);var Xn=(t,e,n)=>Zn(t,e,n);var vi=(t)=>Dn(Xn(t,97,122)),fs=(t,e=0,n=20)=>{let r=Xn(t,e,n),s="";for(let o=0;o<r;o++)s+=vi(t);return s};var $e=(t,e)=>e[Xn(t,0,e.length-1)];var Li=Symbol("0schema");class ps{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(jr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
|
|
2
|
+
`)}}var Qn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[ft])return Me(t,e);if(tt(t))return Te(t,(n)=>zt(e,(r)=>Qn(n,r)));else if(ts(t))return At(t,(n,r)=>Qn(n,e[r]));return!1};class C{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];if(this.constructor._dilutes)[n,e]=[e,n];return Qn(e,n)}equals(t){return this.constructor===t.constructor&&se(this.shape,t.shape)}[Li](){return!0}[ft](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){F()}get nullable(){return Nt(this,We)}get optional(){return new Yn(this)}cast(t){return ds(t,this),t}expect(t){return ds(t,this),t}}class Ge extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let n=t?.constructor===this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var S=(t,e=null)=>new Ge(t,e),Yl=S(Ge);class He extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}var _=(t)=>new He(t),ta=S(He);class ae extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape.some((r)=>r===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}var Pe=(...t)=>new ae(t),gs=S(ae),Vi=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),ms=(t)=>{if(Ot.check(t))return[Vi(t)];if(gs.check(t))return t.shape.map((e)=>e+"");if(_s.check(t))return["[+-]?\\d+.?\\d*"];if(Ts.check(t))return[".*"];if(je.check(t))return t.shape.map(ms).flat(1);v()};class xs extends C{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(ms).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let n=this._r.exec(t)!=null;return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}var ea=S(xs),Mi=Symbol("optional");class Yn extends C{constructor(t){super();this.shape=t}check(t,e){let n=t===void 0||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[Mi](){return!0}}var Fi=S(Yn);class tr extends C{check(t,e){return e?.extend(null,"never",typeof t),!1}}var na=new tr,ra=S(tr);class ze extends C{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new ze(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return At(this.shape,(n,r)=>{let s=this._isPartial&&!re(t,r)||n.check(t[r],e);return!s&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),s})}}var $i=(t)=>new ze(t),ji=S(ze),qi=_((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class er extends C{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&At(t,(n,r)=>{let s=this.shape.keys.check(r,e);return!s&&e?.extend(r+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,e)})}}var ws=(t,e)=>new er(t,e),Gi=S(er);class nr extends C{constructor(t){super();this.shape=t}check(t,e){return t!=null&&At(this.shape,(n,r)=>{let s=n.check(t[r],e);return!s&&e?.extend(r.toString(),"Tuple",typeof n),s})}}var Hi=(...t)=>new nr(t),sa=S(nr);class rr extends C{constructor(t){super();this.shape=t.length===1?t[0]:new Je(t)}check(t,e){let n=tt(t)&&Te(t,(r)=>this.shape.check(r));return!n&&e?.extend(null,"Array",""),n}}var ys=(...t)=>new rr(t),Pi=S(rr),zi=_((t)=>tt(t));class sr extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let n=t instanceof this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}}var Ji=(t,e=null)=>new sr(t,e),oa=S(sr),Ki=Ji(C);class bs extends C{constructor(t){super();this.len=t.length-1,this.args=Hi(...t.slice(-1)),this.res=t[this.len]}check(t,e){let n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}var Wi=S(bs),Zi=_((t)=>typeof t==="function");class Is extends C{constructor(t){super();this.shape=t}check(t,e){let n=Te(this.shape,(r)=>r.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}}var ia=S(Is,(t)=>t.shape.length>0);class Je extends C{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let n=zt(this.shape,(r)=>r.check(t,e));return e?.extend(null,"Union",typeof t),n}}var Nt=(...t)=>t.findIndex((e)=>je.check(e))>=0?Nt(...t.map((e)=>le(e)).map((e)=>je.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Je(t),je=S(Je),ks=()=>!0,qe=_(ks),Xi=S(He,(t)=>t.shape===ks),or=_((t)=>typeof t==="bigint"),Qi=_((t)=>t===or),Ss=_((t)=>typeof t==="symbol"),ca=_((t)=>t===Ss),Dt=_((t)=>typeof t==="number"),_s=_((t)=>t===Dt),Ot=_((t)=>typeof t==="string"),Ts=_((t)=>t===Ot),Ke=_((t)=>typeof t==="boolean"),Yi=_((t)=>t===Ke),Us=Pe(void 0),la=S(ae,(t)=>t.shape.length===1&&t.shape[0]===void 0),aa=Pe(void 0);var We=Pe(null),tc=S(ae,(t)=>t.shape.length===1&&t.shape[0]===null),ha=S(Uint8Array),ua=S(Ge,(t)=>t.shape===Uint8Array),ec=Nt(Dt,Ot,We,Us,or,Ke,Ss),fa=(()=>{let t=ys(qe),e=ws(Ot,qe),n=Nt(Dt,Ot,We,Ke,t,e);return t.shape=n,e.shape.values=n,n})(),le=(t)=>{if(Ki.check(t))return t;else if(qi.check(t)){let e={};for(let n in t)e[n]=le(t[n]);return $i(e)}else if(zi.check(t))return Nt(...t.map(le));else if(ec.check(t))return Pe(t);else if(Zi.check(t))return S(t);v()},ds=cs?()=>{}:(t,e)=>{let n=new ps;if(!e.check(t,n))throw M(`Expected value to be of type ${e.constructor.name}.
|
|
3
|
+
${n.toString()}`)};class Es{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var nc=(t)=>new Es(t),Bs=nc(qe).if(_s,(t,e)=>Fe(e,An,It)).if(Ts,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=Bs(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Us,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>Bs(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===cc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===sc);var ma=_((t)=>t.nodeType===oc);var As=(t)=>vr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:sc,TEXT_NODE:oc,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:ic,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:cc}=dt,ba=_((t)=>t.nodeType===ic);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Cs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=As(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Ds=ls?dc:Cs,Ns=(...t)=>{console.log(...Ds(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Ds(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Lr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class ac extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Os)}getText(t=""){return this.get(t,as)}getMap(t=""){return this.get(t,Ur)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new ac({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(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 Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(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){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},fS=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},mS=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},gS=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},zy=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Cf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(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}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!Rr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Ns(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Cr(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class YR extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof ac?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Nr=m-k;if(Nr>0)de(h,B,k,Nr)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Cr(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{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=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Er=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Er++}}var qc=(t)=>{t.timestamp=Er++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Er++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case ac:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Br=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case ac:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Ar=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Mg extends ye{}class Os extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Os;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Os}clone(){let t=new Os;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Mg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Os;class Wy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Ur extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Ur}clone(){let t=new Ur;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new Wy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Ar(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Ur,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
+
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class Vy extends ye{constructor(t,e,n){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,n.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.keysChanged.add(r)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];y(t,(n)=>{let r=new Map,s=new Map,o=this.target._start,i=null,c={},a="",f=0,l=0,h=()=>{if(i!==null){let u=null;switch(i){case"delete":if(l>0)u={delete:l};l=0;break;case"insert":if(typeof a==="object"||a.length>0){if(u={insert:a},r.size>0)u.attributes={},r.forEach((d,p)=>{if(d!==null)u.attributes[p]=d})}a="";break;case"retain":if(f>0){if(u={retain:f},!rs(c))u.attributes=es({},c)}f=0;break}if(u)e.push(u);i=null}};while(o!==null){switch(o.content.constructor){case Q:case yt:if(this.adds(o)){if(!this.deletes(o))h(),i="insert",a=o.content.getContent()[0],h()}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=1}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=1}break;case X:if(this.adds(o)){if(!this.deletes(o)){if(i!=="insert")h(),i="insert";a+=o.content.str}}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=o.length}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=o.length}break;case U:{let{key:u,value:d}=o.content;if(this.adds(o)){if(!this.deletes(o)){let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();if(ot(d,s.get(u)??null))delete c[u];else c[u]=d}else if(d!==null)o.delete(n)}}else if(this.deletes(o)){s.set(u,d);let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();c[u]=p}}else if(!o.deleted){s.set(u,d);let p=c[u];if(p!==void 0){if(!ot(p,d)){if(i==="retain")h();if(d===null)delete c[u];else c[u]=d}else if(p!==null)o.delete(n)}}if(!o.deleted){if(i==="insert")h();jt(r,o.content)}break}}o=o.right}h();while(e.length>0){let u=e[e.length-1];if(u.retain!==void 0&&u.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class as extends T{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??D(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((n)=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new as}clone(){let t=new as;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let n=new Vy(this,t,e);if(xn(this,t,n),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??D();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===X)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)y(this.doc,(n)=>{let r=new ln(null,this._start,0,new Map);for(let s=0;s<t.length;s++){let o=t[s];if(o.insert!==void 0){let i=!e&&typeof o.insert==="string"&&s===t.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Ar(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new as;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Ar(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Ur{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends as{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.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(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(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}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new ac({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let 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}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Cr=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Cr(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var kf=()=>new Po;var y_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Sf=(t)=>{let e=new Uint8Array(y_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Dr=new Uint8Array(30000),Dl=Dr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Dr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Dr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Or=(t)=>Error(t);var Jo=Or("Unexpected end of array"),Vl=Or("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var Uy=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var bS=0,vS=1,yS=2,wS=3;class Ef extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function w_(t){let e=kf();switch(t.type){case"doc-sync":{rt(e,bS),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,vS),kn(e,t.body);break}case"doc-close":{rt(e,yS),In(e,t.path);break}case"control":{rt(e,wS),In(e,JSON.stringify(t.message));break}default:throw new Ef(`unknown-frame:${t.type}`)}return Sf(e)}function x_(t){try{let e=Uy(t),n=ke(e);switch(n){case bS:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case vS:return{body:Sn(e),type:"awareness"};case yS:return{path:_n(e),type:"doc-close"};case wS:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Ef("malformed-control");return{message:r,type:"control"}}default:throw new Ef(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Ef)throw e;throw new Ef(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
+
export{ac,fS,mS,gS,zy,Cf,YR,Mg,Os,Wy,Ur,Vy,as,kf,y_,Sf,Uy,bS,vS,yS,wS,Ef,w_,x_};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=30E520B49AEAE2EA64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-c6zdm25z.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{hn,sn,ne}from"./studio-sq1bn60g.js";import{f}from"./studio-jsv3s3s1.js";import{v}from"./studio-9rhmettf.js";import{ud,FE,Gf,w1,jE,ra,Qh}from"./studio-yh3nggx1.js";import{Sf,f_}from"./studio-7z69g1gx.js";import{Rs}from"./studio-pve0b2f2.js";import{rt,zt,T,R,Nn,Lt}from"./studio-zmecp6hq.js";import{D}from"./studio-73czgk6a.js";import{me}from"./studio-7gqyhjns.js";var P={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPublish",$description:"Publish: the one-click Cloudflare Pages flow, as a `jx-dialog` over the kit. Eight bodies, one at a time, because the reader is at exactly one point of a chain — a host that cannot reach Cloudflare at all, a question still in flight, a connection that lapsed, an invitation to connect, a stored token Cloudflare refused, a field to paste a replacement into, the create-and-connect form, and the connected status. `publish/publish-panel.ts` keeps every one of those decisions and the calls that settle them; this document knows only which of the eight it was told to draw. **The token is never painted.** The field below binds no `value` — it is written by the reader and read once, on its way to storage — so a stored secret cannot reach the attribute, the serialised HTML or the accessibility tree, which is `studio.md` §15 rule 1 written as a missing binding rather than as a rule somebody remembers.",tagName:"jx-dialog",$props:{headline:"Publish",confirmLabel:"",cancelLabel:"Close",size:"md"},attributes:{part:"publish"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"What the five `.publish-*` names carried, keyed on `part`, and most of them do not survive the move. `.publish-modal` and its `.new-project-modal` base were a fixed card, a scroll body, a border, a shadow and a `z-index: 1000` — a modal `<dialog>` is every one of those, and the top layer is what the z-index was climbing towards. `.publish-field` was a label stacked over a control, which is `jx-field`'s whole shape. What is left is the column gap between bodies, the two button rows, the hint and the refusal. Nothing here uses `--spectrum-*`: those custom properties resolve only inside `<sp-theme>`, and a document mounted in a layer host is outside it, so each would silently have taken its hard-coded fallback.",'& [part="body"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)"},'& [part="note"], & [part="status-line"], & [part="deployment"]':{margin:"0",lineHeight:"1.5"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)"},'& [part="actions"]':{$description:'Wraps rather than overflows (studio-ui-guidelines.md §4.6): two buttons whose labels are whole phrases — "Verify & Connect", "Preferences › Accounts" — are wider than a narrow dialog at the sizes a reader may have set.',display:"flex",flexWrap:"wrap",gap:"var(--jx-space-2)"},'& [part="submit"]':{alignSelf:"flex-start"},'& [part="hint"]':{$description:"Publishing rides every commit, so the connected body's only job is to say what is already happening. Dim, because it is a standing fact rather than something to act on.",margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="failure"]':{$description:'`failure` and not `error`: `jx-textfield` and `jx-select` each draw a `[part="error"]` of their own inside this same tree, and the kit is light DOM — a scoped rule on that name would restyle the token field\'s refusal line too.',margin:"0",color:"var(--danger)",lineHeight:"1.5"},'& [part="link"], & [part="install-link"]':{color:"var(--accent)",textDecoration:"underline"},"& code":{fontFamily:"var(--font-mono)",fontSize:"var(--jx-text-sm)"}},children:[{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"body-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/body"},cases:{unsupported:{tagName:"p",attributes:{part:"note"},children:["This platform cannot reach the Cloudflare API. Publish by committing and pushing — your host builds ",{tagName:"code",textContent:"bunx jx build"}," and serves ",{tagName:"code",textContent:"dist/"},"."]},loading:{tagName:"p",attributes:{part:"note"},textContent:"Checking Cloudflare connection…"},lapsed:{tagName:"div",attributes:{part:"lapsed",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Your Cloudflare connection has expired, so publishing cannot reach your account. Reconnect to restore it — this site's Pages project and its settings are untouched."},{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"reconnect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/connect"},value:[]}]},children:[{tagName:"span",textContent:"${state.connectLabel}"}]}]},hosted:{tagName:"div",attributes:{part:"hosted",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Connect your Cloudflare account to publish this site."},{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"connect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/connect"},value:[]}]},children:[{tagName:"span",textContent:"Connect Cloudflare"}]}]},stored:{tagName:"div",attributes:{part:"stored",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"A Cloudflare API token is stored on this machine, and Cloudflare did not accept it. It may have been revoked, or it may be missing the Account Settings Read and Pages Read/Write permissions."},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"replace"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/replace"},value:[]}]},children:[{tagName:"span",textContent:"Replace token"}]},{tagName:"jx-button",$props:{quiet:!0},attributes:{part:"accounts"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openAccounts"},value:[]}]},children:[{tagName:"span",textContent:"Preferences › Accounts"}]}]}]},token:{tagName:"div",attributes:{part:"token-form",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Paste a Cloudflare API token (permissions: Account Settings Read, Pages Read/Write). It is stored on this machine and only sent to the same-origin proxy — Studio never renders it back."},{tagName:"jx-field",$props:{span:!0,label:"API token"},attributes:{part:"token-row","data-field":"token"},children:[{tagName:"jx-textfield",$description:"No `value` binding, and its absence is the contract: a secret may pass through a field the reader typed it into and may never be painted into one they did not. The draft lives in the adapter's closure until Verify reads it, so nothing here — not the attribute, not the accessibility tree, not a DOM dump — has ever held it.",$props:{type:"password",placeholder:"cf_..."},attributes:{part:"token"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setToken"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"verify"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/verify"},value:[]}]},children:[{tagName:"span",textContent:"Verify & Connect"}]},{tagName:"jx-button",$props:{quiet:!0},attributes:{part:"accounts"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openAccounts"},value:[]}]},children:[{tagName:"span",textContent:"Preferences › Accounts"}]}]}]},form:{tagName:"div",attributes:{part:"connect-form",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},children:["Create a Cloudflare Pages project connected to this repository. Every commit then builds and publishes automatically (",{tagName:"code",textContent:"bunx jx build"},")."]},{tagName:"div",attributes:{part:"rows"},children:[{tagName:"jx-field",$props:{span:!0,label:"Account"},attributes:{part:"row","data-field":"account"},children:[{tagName:"jx-select",$props:{options:{$ref:"#/state/accountOptions"},value:{$ref:"#/state/accountId"}},attributes:{part:"account"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setAccount"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"Pages project name"},attributes:{part:"row","data-field":"projectName"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/projectName"}},attributes:{part:"project-name"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setProjectName"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"GitHub owner"},attributes:{part:"row","data-field":"owner"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/owner"}},attributes:{part:"owner"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setOwner"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"GitHub repository"},attributes:{part:"row","data-field":"repo"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/repo"}},attributes:{part:"repo"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setRepo"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"Production branch"},attributes:{part:"row","data-field":"branch"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/branch"}},attributes:{part:"branch"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setBranch"},value:[{$ref:"event#/target/value"}]}]}}]}]},{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"submit"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/submit"},value:[]}]},children:[{tagName:"span",textContent:"${state.submitLabel}"}]}]},status:{tagName:"div",attributes:{part:"status",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"status-line"},children:["Connected to Pages project ",{tagName:"strong",attributes:{part:"project-name"},textContent:"${state.deployProject}"},{tagName:"span",attributes:{part:"site-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasProductionUrl"},cases:{true:{tagName:"span",children:[" — ",{tagName:"a",attributes:{part:"link",href:"${state.productionUrl}",target:"_blank",rel:"noreferrer"},textContent:"${state.productionUrl}"}]}}}]},{tagName:"div",attributes:{part:"deployment-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasDeployment"},cases:{true:{tagName:"p",attributes:{part:"deployment"},children:["Latest deployment: ",{tagName:"strong",attributes:{part:"deployment-state"},textContent:"${state.deploymentState}"}," (${state.deploymentEnvironment}) — ",{tagName:"a",attributes:{part:"link",href:"${state.deploymentUrl}",target:"_blank",rel:"noreferrer"},textContent:"preview"}]},false:{tagName:"p",attributes:{part:"deployment"},textContent:"No deployments yet — the first commit after connecting triggers one."}}},{tagName:"p",attributes:{part:"hint"},textContent:"Publishing happens automatically on every commit."},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}]},children:[{tagName:"span",textContent:"Refresh"}]},{tagName:"jx-button",$props:{variant:"negative",disabled:{$ref:"#/state/busy"}},attributes:{part:"disconnect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/disconnect"},value:[]}]},children:[{tagName:"span",textContent:"Disconnect"}]}]}]}}},{tagName:"div",attributes:{part:"failure-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasFailure"},cases:{true:{tagName:"p",attributes:{part:"failure"},children:["${state.failure}",{tagName:"span",attributes:{part:"pages-app-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/needsPagesApp"},cases:{true:{tagName:"span",children:[" — if the Cloudflare Pages GitHub App is not installed on the repository, ",{tagName:"a",attributes:{part:"install-link",href:"${state.pagesAppUrl}",target:"_blank",rel:"noreferrer"},textContent:"install it"}," and retry."]}}}]}}}]}]};T("publish",P);var S="https://github.com/apps/cloudflare-pages/installations/new";function F(e){if(!e.supported)return"unsupported";if(e.loading)return"loading";if(e.connected&&e.lapsed)return"lapsed";if(!e.connected){if(e.hosted)return"hosted";return e.tokenStored&&!e.replacing?"stored":"token"}return e.deploy?"status":"form"}function w(e){let{error:t}=e;return{accountId:e.form.accountId,accountOptions:e.accounts,body:F(e),branch:e.form.branch,busy:e.busy,connectLabel:e.busy?"Reconnecting…":"Reconnect Cloudflare",deploymentEnvironment:e.deployment?.environment??"",deploymentState:e.deployment?`${e.deployment.stage}: ${e.deployment.status}`:"",deploymentUrl:e.deployment?.url??"",deployProject:e.deploy?.projectName??"",failure:t,hasDeployment:e.deployment!==null,hasFailure:t!=="",hasProductionUrl:(e.deploy?.productionUrl??"")!=="",needsPagesApp:/github/i.test(t)&&/app|install|source|repo/i.test(t),owner:e.form.owner,pagesAppUrl:S,productionUrl:e.deploy?.productionUrl??"",projectName:e.form.projectName,repo:e.form.repo,submitLabel:e.busy?"Connecting…":"Create & Connect"}}function C(e){let t=document.createElement("div");t.style.pointerEvents="auto",e.layer.append(t);let l="",g=!1,N=()=>{if(g)return;g=!0,e.onClosed()},p=v({...w(e.view),closed:N,connect:()=>{e.onConnect()},disconnect:()=>{e.onDisconnect()},openAccounts:()=>{e.onOpenAccounts()},refresh:()=>{e.onRefresh()},replace:()=>{l="",e.onReplaceToken()},setAccount:(o)=>{p.accountId=o,e.onField("accountId",o)},setBranch:(o)=>{p.branch=o,e.onField("branch",o)},setOwner:(o)=>{p.owner=o,e.onField("owner",o)},setProjectName:(o)=>{p.projectName=o,e.onField("projectName",o)},setRepo:(o)=>{p.repo=o,e.onField("repo",o)},setToken:(o)=>{l=o},submit:()=>{e.onSubmit()},verify:()=>{let o=l;l="",e.onSaveToken(o)}}),b=null,k=R("publish",p,t).then(async(o)=>{b=o;let d=o.root;if(g)return o.dispose(),d;if(await Nn(d),g)return d;return(d.querySelector('dialog[part="dialog"]')??d).setAttribute(rt,zt("modal","publish")),hn(d),d});return{close(){let o=b?.root;if(o instanceof HTMLElement)sn(o);b?.dispose(),b=null,l="",t.remove(),N()},host:t,ready:k,update(o){Object.assign(p,w(o))}}}var u=null,s="loading",m=[],i=null,a="",c=!1,h=!1,n={accountId:"",branch:"main",owner:"",projectName:"",repo:""};function x(){return D?.projectConfig??null}function I(e){return e.toLowerCase().replaceAll(/[^a-z0-9]+/g,"-").replaceAll(/^-+|-+$/g,"").slice(0,58)||"site"}function H(){let e=f().projectRoot,t=/^([\w.-]+)\/([\w.-]+)(?:@.+)?$/.exec(e);return t?{owner:t[1],repo:t[2]}:{owner:"",repo:""}}function L(){let e=ra();return e?{productionUrl:e.productionUrl??"",projectName:e.projectName}:null}function j(){let e=ud(),t=s==="loading"?null:s;return{accounts:m.map((l)=>({label:l.name,value:l.id})),busy:c,connected:t?.connected===!0,deploy:L(),deployment:i?{environment:i.environment,stage:i.stage,status:i.status,url:i.url}:null,error:a,form:{...n},hosted:e&&typeof f().cfConnect==="function",lapsed:t?.connected===!0&&t.needsReconnect===!0,loading:s==="loading",replacing:h,supported:e,tokenStored:Sf()!==""}}function r(){if(u){u.update(j());return}u=C({layer:Lt("modal"),onClosed:V,onConnect:()=>{O()},onDisconnect:()=>{M()},onField:(e,t)=>{n={...n,[e]:t}},onOpenAccounts:E,onRefresh:()=>{y()},onReplaceToken:()=>{h=!0,a="",r()},onSaveToken:(e)=>{U(e)},onSubmit:()=>{_()},view:j()})}async function y(){s="loading",r();try{if(s=await f().cfConnection?.()??null,s?.connected&&!s.needsReconnect){m=await FE(),n={...n,accountId:s.accountId??m[0]?.id??""};let e=ra();if(e)i=await Gf(e),Qh(i)}}catch(e){s=null,a=e instanceof Error?e.message:String(e)}r()}async function U(e){let t=e.trim();if(!t){a="Paste a token, or use Preferences › Accounts to forget the stored one.",r();return}f_(t),h=!1,a="",await y()}function E(){ne()?.run("app.preferences",{section:"accounts"})}async function O(){c=!0,a="",r();try{let e=await f().cfConnect?.()??null;if(e?.status==="timeout")a="The Cloudflare window didn't finish. Sign in there, then reconnect — nothing was changed.";else if(e?.status==="connected"&&!e.connection.accountId){let{openCfAccountPicker:t}=await (me("gnm7xeqb"),import("./cf-account-picker-gnm7xeqb.js"));await t()}}catch(e){a=e instanceof Error?e.message:String(e)}c=!1,Rs(),await y()}async function _(){let e=x();if(!e)return;if(!n.projectName||!n.owner||!n.repo||!n.accountId){a="Account, project name, and the GitHub owner/repo are all required.",r();return}c=!0,a="",r();try{let t=await jE(e,{accountId:n.accountId,owner:n.owner,productionBranch:n.branch||"main",projectName:n.projectName,repo:n.repo});i=await Gf(t).catch(()=>null)}catch(t){a=t instanceof Error?t.message:String(t)}c=!1,r()}async function M(){let e=x();if(!e)return;c=!0,r();try{await w1(e,null),i=null}catch(t){a=t instanceof Error?t.message:String(t)}c=!1,r()}function V(){let e=u;u=null,e?.close()}function i_(e){s={accountId:e.accountId??"demo-account",connected:!0},m=[],i=e.deployment,Qh(e.deployment),a="",c=!1,h=!1,r()}function OR(){let e=x(),{owner:t,repo:l}=H();s="loading",m=[],i=null,a="",c=!1,h=!1,n={accountId:"",branch:"main",owner:t,projectName:ra()?.projectName??I(e?.name??""),repo:l},r(),y()}
|
|
2
|
-
export{
|
|
1
|
+
import{un,rn,ne}from"./studio-0k9mvpgj.js";import{p}from"./studio-y7jehjrp.js";import{Tr}from"./studio-222rqyyc.js";import{v}from"./studio-fqq890ap.js";import{rt,zt,T,R,An,Ct}from"./studio-spf2skgc.js";import{gd,YE,Zf,P1,ZE,ca,rp}from"./studio-cxt150pj.js";import{Rf,$_}from"./studio-1a99w39s.js";import{D}from"./studio-tp642n5g.js";import{me}from"./studio-0bbxhhce.js";var P={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPublish",$description:"Publish: the one-click Cloudflare Pages flow, as a `jx-dialog` over the kit. Eight bodies, one at a time, because the reader is at exactly one point of a chain — a host that cannot reach Cloudflare at all, a question still in flight, a connection that lapsed, an invitation to connect, a stored token Cloudflare refused, a field to paste a replacement into, the create-and-connect form, and the connected status. `publish/publish-panel.ts` keeps every one of those decisions and the calls that settle them; this document knows only which of the eight it was told to draw. **The token is never painted.** The field below binds no `value` — it is written by the reader and read once, on its way to storage — so a stored secret cannot reach the attribute, the serialised HTML or the accessibility tree, which is `studio.md` §15 rule 1 written as a missing binding rather than as a rule somebody remembers.",tagName:"jx-dialog",$props:{headline:"Publish",confirmLabel:"",cancelLabel:"Close",size:"md"},attributes:{part:"publish"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"What the five `.publish-*` names carried, keyed on `part`, and most of them do not survive the move. `.publish-modal` and its `.new-project-modal` base were a fixed card, a scroll body, a border, a shadow and a `z-index: 1000` — a modal `<dialog>` is every one of those, and the top layer is what the z-index was climbing towards. `.publish-field` was a label stacked over a control, which is `jx-field`'s whole shape. What is left is the column gap between bodies, the two button rows, the hint and the refusal. Nothing here uses `--spectrum-*`: those custom properties resolve only inside `<sp-theme>`, and a document mounted in a layer host is outside it, so each would silently have taken its hard-coded fallback.",'& [part="body"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)"},'& [part="note"], & [part="status-line"], & [part="deployment"]':{margin:"0",lineHeight:"1.5"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)"},'& [part="actions"]':{$description:'Wraps rather than overflows (studio-ui-guidelines.md §4.6): two buttons whose labels are whole phrases — "Verify & Connect", "Preferences › Accounts" — are wider than a narrow dialog at the sizes a reader may have set.',display:"flex",flexWrap:"wrap",gap:"var(--jx-space-2)"},'& [part="submit"]':{alignSelf:"flex-start"},'& [part="hint"]':{$description:"Publishing rides every commit, so the connected body's only job is to say what is already happening. Dim, because it is a standing fact rather than something to act on.",margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="failure"]':{$description:'`failure` and not `error`: `jx-textfield` and `jx-select` each draw a `[part="error"]` of their own inside this same tree, and the kit is light DOM — a scoped rule on that name would restyle the token field\'s refusal line too.',margin:"0",color:"var(--danger)",lineHeight:"1.5"},'& [part="link"], & [part="install-link"]':{color:"var(--accent)",textDecoration:"underline"},"& code":{fontFamily:"var(--font-mono)",fontSize:"var(--jx-text-sm)"}},children:[{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"body-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/body"},cases:{unsupported:{tagName:"p",attributes:{part:"note"},children:["This platform cannot reach the Cloudflare API. Publish by committing and pushing — your host builds ",{tagName:"code",textContent:"bunx jx build"}," and serves ",{tagName:"code",textContent:"dist/"},"."]},loading:{tagName:"p",attributes:{part:"note"},textContent:"Checking Cloudflare connection…"},lapsed:{tagName:"div",attributes:{part:"lapsed",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Your Cloudflare connection has expired, so publishing cannot reach your account. Reconnect to restore it — this site's Pages project and its settings are untouched."},{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"reconnect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/connect"},value:[]}]},children:[{tagName:"span",textContent:"${state.connectLabel}"}]}]},hosted:{tagName:"div",attributes:{part:"hosted",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Connect your Cloudflare account to publish this site."},{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"connect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/connect"},value:[]}]},children:[{tagName:"span",textContent:"Connect Cloudflare"}]}]},stored:{tagName:"div",attributes:{part:"stored",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"A Cloudflare API token is stored on this machine, and Cloudflare did not accept it. It may have been revoked, or it may be missing the Account Settings Read and Pages Read/Write permissions."},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"replace"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/replace"},value:[]}]},children:[{tagName:"span",textContent:"Replace token"}]},{tagName:"jx-button",$props:{quiet:!0},attributes:{part:"accounts"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openAccounts"},value:[]}]},children:[{tagName:"span",textContent:"Preferences › Accounts"}]}]}]},token:{tagName:"div",attributes:{part:"token-form",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},textContent:"Paste a Cloudflare API token (permissions: Account Settings Read, Pages Read/Write). It is stored on this machine and only sent to the same-origin proxy — Studio never renders it back."},{tagName:"jx-field",$props:{span:!0,label:"API token"},attributes:{part:"token-row","data-field":"token"},children:[{tagName:"jx-textfield",$description:"No `value` binding, and its absence is the contract: a secret may pass through a field the reader typed it into and may never be painted into one they did not. The draft lives in the adapter's closure until Verify reads it, so nothing here — not the attribute, not the accessibility tree, not a DOM dump — has ever held it.",$props:{type:"password",placeholder:"cf_..."},attributes:{part:"token"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setToken"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"verify"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/verify"},value:[]}]},children:[{tagName:"span",textContent:"Verify & Connect"}]},{tagName:"jx-button",$props:{quiet:!0},attributes:{part:"accounts"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openAccounts"},value:[]}]},children:[{tagName:"span",textContent:"Preferences › Accounts"}]}]}]},form:{tagName:"div",attributes:{part:"connect-form",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"note"},children:["Create a Cloudflare Pages project connected to this repository. Every commit then builds and publishes automatically (",{tagName:"code",textContent:"bunx jx build"},")."]},{tagName:"div",attributes:{part:"rows"},children:[{tagName:"jx-field",$props:{span:!0,label:"Account"},attributes:{part:"row","data-field":"account"},children:[{tagName:"jx-select",$props:{options:{$ref:"#/state/accountOptions"},value:{$ref:"#/state/accountId"}},attributes:{part:"account"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setAccount"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"Pages project name"},attributes:{part:"row","data-field":"projectName"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/projectName"}},attributes:{part:"project-name"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setProjectName"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"GitHub owner"},attributes:{part:"row","data-field":"owner"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/owner"}},attributes:{part:"owner"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setOwner"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"GitHub repository"},attributes:{part:"row","data-field":"repo"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/repo"}},attributes:{part:"repo"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setRepo"},value:[{$ref:"event#/target/value"}]}]}}]},{tagName:"jx-field",$props:{span:!0,label:"Production branch"},attributes:{part:"row","data-field":"branch"},children:[{tagName:"jx-textfield",$props:{value:{$ref:"#/state/branch"}},attributes:{part:"branch"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setBranch"},value:[{$ref:"event#/target/value"}]}]}}]}]},{tagName:"jx-button",$props:{variant:"accent",disabled:{$ref:"#/state/busy"}},attributes:{part:"submit"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/submit"},value:[]}]},children:[{tagName:"span",textContent:"${state.submitLabel}"}]}]},status:{tagName:"div",attributes:{part:"status",role:"none"},style:{display:"contents"},children:[{tagName:"p",attributes:{part:"status-line"},children:["Connected to Pages project ",{tagName:"strong",attributes:{part:"project-name"},textContent:"${state.deployProject}"},{tagName:"span",attributes:{part:"site-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasProductionUrl"},cases:{true:{tagName:"span",children:[" — ",{tagName:"a",attributes:{part:"link",href:"${state.productionUrl}",target:"_blank",rel:"noreferrer"},textContent:"${state.productionUrl}"}]}}}]},{tagName:"div",attributes:{part:"deployment-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasDeployment"},cases:{true:{tagName:"p",attributes:{part:"deployment"},children:["Latest deployment: ",{tagName:"strong",attributes:{part:"deployment-state"},textContent:"${state.deploymentState}"}," (${state.deploymentEnvironment}) — ",{tagName:"a",attributes:{part:"link",href:"${state.deploymentUrl}",target:"_blank",rel:"noreferrer"},textContent:"preview"}]},false:{tagName:"p",attributes:{part:"deployment"},textContent:"No deployments yet — the first commit after connecting triggers one."}}},{tagName:"p",attributes:{part:"hint"},textContent:"Publishing happens automatically on every commit."},{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{disabled:{$ref:"#/state/busy"}},attributes:{part:"refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}]},children:[{tagName:"span",textContent:"Refresh"}]},{tagName:"jx-button",$props:{variant:"negative",disabled:{$ref:"#/state/busy"}},attributes:{part:"disconnect"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/disconnect"},value:[]}]},children:[{tagName:"span",textContent:"Disconnect"}]}]}]}}},{tagName:"div",attributes:{part:"failure-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasFailure"},cases:{true:{tagName:"p",attributes:{part:"failure"},children:["${state.failure}",{tagName:"span",attributes:{part:"pages-app-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/needsPagesApp"},cases:{true:{tagName:"span",children:[" — if the Cloudflare Pages GitHub App is not installed on the repository, ",{tagName:"a",attributes:{part:"install-link",href:"${state.pagesAppUrl}",target:"_blank",rel:"noreferrer"},textContent:"install it"}," and retry."]}}}]}}}]}]};T("publish",P);var S="https://github.com/apps/cloudflare-pages/installations/new";function F(e){if(!e.supported)return"unsupported";if(e.loading)return"loading";if(e.connected&&e.lapsed)return"lapsed";if(!e.connected){if(e.hosted)return"hosted";return e.tokenStored&&!e.replacing?"stored":"token"}return e.deploy?"status":"form"}function w(e){let{error:t}=e;return{accountId:e.form.accountId,accountOptions:e.accounts,body:F(e),branch:e.form.branch,busy:e.busy,connectLabel:e.busy?"Reconnecting…":"Reconnect Cloudflare",deploymentEnvironment:e.deployment?.environment??"",deploymentState:e.deployment?`${e.deployment.stage}: ${e.deployment.status}`:"",deploymentUrl:e.deployment?.url??"",deployProject:e.deploy?.projectName??"",failure:t,hasDeployment:e.deployment!==null,hasFailure:t!=="",hasProductionUrl:(e.deploy?.productionUrl??"")!=="",needsPagesApp:/github/i.test(t)&&/app|install|source|repo/i.test(t),owner:e.form.owner,pagesAppUrl:S,productionUrl:e.deploy?.productionUrl??"",projectName:e.form.projectName,repo:e.form.repo,submitLabel:e.busy?"Connecting…":"Create & Connect"}}function C(e){let t=document.createElement("div");t.style.pointerEvents="auto",e.layer.append(t);let l="",g=!1,N=()=>{if(g)return;g=!0,e.onClosed()},d=v({...w(e.view),closed:N,connect:()=>{e.onConnect()},disconnect:()=>{e.onDisconnect()},openAccounts:()=>{e.onOpenAccounts()},refresh:()=>{e.onRefresh()},replace:()=>{l="",e.onReplaceToken()},setAccount:(o)=>{d.accountId=o,e.onField("accountId",o)},setBranch:(o)=>{d.branch=o,e.onField("branch",o)},setOwner:(o)=>{d.owner=o,e.onField("owner",o)},setProjectName:(o)=>{d.projectName=o,e.onField("projectName",o)},setRepo:(o)=>{d.repo=o,e.onField("repo",o)},setToken:(o)=>{l=o},submit:()=>{e.onSubmit()},verify:()=>{let o=l;l="",e.onSaveToken(o)}}),b=null,k=R("publish",d,t).then(async(o)=>{b=o;let u=o.root;if(g)return o.dispose(),u;if(await An(u),g)return u;return(u.querySelector('dialog[part="dialog"]')??u).setAttribute(rt,zt("modal","publish")),un(u),u});return{close(){let o=b?.root;if(o instanceof HTMLElement)rn(o);b?.dispose(),b=null,l="",t.remove(),N()},host:t,ready:k,update(o){Object.assign(d,w(o))}}}var m=null,s="loading",f=[],i=null,a="",c=!1,h=!1,n={accountId:"",branch:"main",owner:"",projectName:"",repo:""};function x(){return D?.projectConfig??null}function I(e){return e.toLowerCase().replaceAll(/[^a-z0-9]+/g,"-").replaceAll(/^-+|-+$/g,"").slice(0,58)||"site"}function H(){let e=p().projectRoot,t=/^([\w.-]+)\/([\w.-]+)(?:@.+)?$/.exec(e);return t?{owner:t[1],repo:t[2]}:{owner:"",repo:""}}function L(){let e=ca();return e?{productionUrl:e.productionUrl??"",projectName:e.projectName}:null}function j(){let e=gd(),t=s==="loading"?null:s;return{accounts:f.map((l)=>({label:l.name,value:l.id})),busy:c,connected:t?.connected===!0,deploy:L(),deployment:i?{environment:i.environment,stage:i.stage,status:i.status,url:i.url}:null,error:a,form:{...n},hosted:e&&typeof p().cfConnect==="function",lapsed:t?.connected===!0&&t.needsReconnect===!0,loading:s==="loading",replacing:h,supported:e,tokenStored:Rf()!==""}}function r(){if(m){m.update(j());return}m=C({layer:Ct("modal"),onClosed:V,onConnect:()=>{O()},onDisconnect:()=>{M()},onField:(e,t)=>{n={...n,[e]:t}},onOpenAccounts:E,onRefresh:()=>{y()},onReplaceToken:()=>{h=!0,a="",r()},onSaveToken:(e)=>{U(e)},onSubmit:()=>{_()},view:j()})}async function y(){s="loading",r();try{if(s=await p().cfConnection?.()??null,s?.connected&&!s.needsReconnect){f=await YE(),n={...n,accountId:s.accountId??f[0]?.id??""};let e=ca();if(e)i=await Zf(e),rp(i)}}catch(e){s=null,a=e instanceof Error?e.message:String(e)}r()}async function U(e){let t=e.trim();if(!t){a="Paste a token, or use Preferences › Accounts to forget the stored one.",r();return}$_(t),h=!1,a="",await y()}function E(){ne()?.run("app.preferences",{section:"accounts"})}async function O(){c=!0,a="",r();try{let e=await p().cfConnect?.()??null;if(e?.status==="timeout")a="The Cloudflare window didn't finish. Sign in there, then reconnect — nothing was changed.";else if(e?.status==="connected"&&!e.connection.accountId){let{openCfAccountPicker:t}=await (me("882a7ecm"),import("./cf-account-picker-882a7ecm.js"));await t()}}catch(e){a=e instanceof Error?e.message:String(e)}c=!1,Tr(),await y()}async function _(){let e=x();if(!e)return;if(!n.projectName||!n.owner||!n.repo||!n.accountId){a="Account, project name, and the GitHub owner/repo are all required.",r();return}c=!0,a="",r();try{let t=await ZE(e,{accountId:n.accountId,owner:n.owner,productionBranch:n.branch||"main",projectName:n.projectName,repo:n.repo});i=await Zf(t).catch(()=>null)}catch(t){a=t instanceof Error?t.message:String(t)}c=!1,r()}async function M(){let e=x();if(!e)return;c=!0,r();try{await P1(e,null),i=null}catch(t){a=t instanceof Error?t.message:String(t)}c=!1,r()}function V(){let e=m;m=null,e?.close()}function __(e){s={accountId:e.accountId??"demo-account",connected:!0},f=[],i=e.deployment,rp(e.deployment),a="",c=!1,h=!1,r()}function u$(){let e=x(),{owner:t,repo:l}=H();s="loading",f=[],i=null,a="",c=!1,h=!1,n={accountId:"",branch:"main",owner:t,projectName:ca()?.projectName??I(e?.name??""),repo:l},r(),y()}
|
|
2
|
+
export{__,u$};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=86CB7ADEC271EE1764756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-c9d3pxf7.js.map
|