@jxsuite/studio 10.1.0 → 10.2.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/dist/chunks/{2020-mkb0qa6p.js → 2020-bx702wqa.js} +3 -3
- package/dist/chunks/adapter-pp011m5x.js +4 -0
- package/dist/chunks/add-new-flow-ecqmzz76.js +4 -0
- package/dist/chunks/cf-account-picker-c07znkqt.js +4 -0
- package/dist/chunks/cf-settings-0v2bmqy0.js +4 -0
- package/dist/chunks/components-yn0dn2pq.js +4 -0
- package/dist/chunks/content-source-g0j41yy6.js +4 -0
- package/dist/chunks/{convert-to-repeater-f92ey3kp.js → convert-to-repeater-sbjk7tgn.js} +3 -3
- package/dist/chunks/editor-xz02jeh1.js +4 -0
- package/dist/chunks/entry-commands-kmt02crp.js +4 -0
- package/dist/chunks/extension-sections-0rprf12d.js +4 -0
- package/dist/chunks/file-ops-mexj5qed.js +4 -0
- package/dist/chunks/files-b2tcppdd.js +4 -0
- package/dist/chunks/format-host-btsevv0c.js +4 -0
- package/dist/chunks/fs-events-r0apejva.js +4 -0
- package/dist/chunks/grid-open-n2a8xkht.js +4 -0
- package/dist/chunks/{grid-view-r22jsqht.js → grid-view-tghcwrrt.js} +12 -12
- package/dist/chunks/iframe-host-gx0ypyh3.js +4 -0
- package/dist/chunks/index-bs4k9tr6.js +4 -0
- package/dist/chunks/{index-pxwwf00y.js → index-vr006kbt.js} +3 -3
- package/dist/chunks/{javascript-pzqryby6.js → javascript-z1g3s9fd.js} +2 -2
- package/dist/chunks/{jsonMode-tcnyxyap.js → jsonMode-7szwg8c4.js} +5 -5
- package/dist/chunks/jx-validate-ymf10teh.js +4 -0
- package/dist/chunks/layers-p9nfya38.js +4 -0
- package/dist/chunks/layers-panel-tt1hzhhf.js +4 -0
- package/dist/chunks/lit-html-x18n2sfz.js +4 -0
- package/dist/chunks/media-library-0n45gv8r.js +4 -0
- package/dist/chunks/media-picker-s09at95z.js +4 -0
- package/dist/chunks/{monaco-binding-bqpge64f.js → monaco-binding-v42w9c1v.js} +3 -3
- package/dist/chunks/monaco-buffer-een2ea0v.js +4 -0
- package/dist/chunks/{monaco-setup-1mkab762.js → monaco-setup-7bffxd6v.js} +3 -3
- package/dist/chunks/notify-qwb8radt.js +4 -0
- package/dist/chunks/parse-v77xtwv7.js +4 -0
- package/dist/chunks/platform-8jnez0wr.js +4 -0
- package/dist/chunks/publish-panel-aysnj611.js +4 -0
- package/dist/chunks/{publish-quick-m9vkhahq.js → publish-quick-kpbqs9mz.js} +3 -3
- package/dist/chunks/publish-workspace-nd0a8q99.js +4 -0
- package/dist/chunks/quick-search-vg0jkhk2.js +4 -0
- package/dist/chunks/references-a7v6a0e2.js +4 -0
- package/dist/chunks/right-panel-cvk1vxx5.js +4 -0
- package/dist/chunks/source-control-fsqzc6he.js +4 -0
- package/dist/chunks/studio-05jfwbmf.js +5 -0
- package/dist/chunks/{studio-qyb5bebs.js → studio-0q5jwddh.js} +7 -7
- package/dist/chunks/{studio-cvz0e00f.js → studio-0w2dr0q8.js} +4 -4
- package/dist/chunks/{studio-eesyjg7h.js → studio-1tzpds97.js} +5 -5
- package/dist/chunks/{studio-a3s6frde.js → studio-216b27sv.js} +3 -3
- package/dist/chunks/studio-2ejhqns4.js +5 -0
- package/dist/chunks/studio-2r90cts3.js +16 -0
- package/dist/chunks/{studio-dy2xtt7a.js → studio-399a25za.js} +4 -4
- package/dist/chunks/studio-399xknkb.js +6 -0
- package/dist/chunks/{studio-jh6t5qz4.js → studio-43y04qck.js} +4 -4
- package/dist/chunks/{studio-skynbac3.js → studio-4g8yb6jn.js} +2 -2
- package/dist/chunks/{studio-jw0q5j6k.js → studio-4jhw38b2.js} +4 -4
- package/dist/chunks/{studio-4smcnv33.js → studio-4ncmwqw5.js} +4 -4
- package/dist/chunks/studio-5atwjgkj.js +7 -0
- package/dist/chunks/{studio-vcz63n42.js → studio-5frqk7c0.js} +4 -4
- package/dist/chunks/{studio-hsr3k06v.js → studio-646nn2ys.js} +5 -5
- package/dist/chunks/{studio-ch8gt8vt.js → studio-6cwj6xrx.js} +4 -4
- package/dist/chunks/studio-6hzdjfv0.js +5 -0
- package/dist/chunks/{studio-9cp96v90.js → studio-71m92v9s.js} +7 -7
- package/dist/chunks/{studio-brdp85q7.js → studio-75kcdbsk.js} +4 -4
- package/dist/chunks/{studio-6vwvshw8.js → studio-78pywnp2.js} +5 -5
- package/dist/chunks/{studio-ggm7zf70.js → studio-86r8hp7r.js} +5 -5
- package/dist/chunks/studio-886t6ztg.js +5 -0
- package/dist/chunks/{studio-5dmgmyw4.js → studio-8wnvtr4z.js} +4 -4
- package/dist/chunks/studio-8z66jk4z.js +5 -0
- package/dist/chunks/{studio-x2metr13.js → studio-9rbe2xpw.js} +3 -3
- package/dist/chunks/{studio-8qejv8yf.js → studio-awxwjawq.js} +4 -4
- package/dist/chunks/studio-b2qpt0xy.js +14 -0
- package/dist/chunks/{studio-9rcbvksg.js → studio-bvs9kpst.js} +7 -7
- package/dist/chunks/studio-c71806xz.js +7 -0
- package/dist/chunks/{studio-vjhej0w5.js → studio-cbwks69x.js} +140 -140
- package/dist/chunks/studio-cg1bfyhf.js +9 -0
- package/dist/chunks/studio-cg710sk9.js +5 -0
- package/dist/chunks/studio-cw0wb9qk.js +7 -0
- package/dist/chunks/studio-cyheys7k.js +5 -0
- package/dist/chunks/studio-ea5m9kg5.js +5 -0
- package/dist/chunks/{studio-4nkm4404.js → studio-ea74s8c1.js} +4 -4
- package/dist/chunks/{studio-37twdaf7.js → studio-efdxjwyp.js} +34 -34
- package/dist/chunks/{studio-pmzg17fj.js → studio-egmw2837.js} +4 -4
- package/dist/chunks/{studio-8jb31dcf.js → studio-er5f383a.js} +4 -4
- package/dist/chunks/studio-f746039f.js +5 -0
- package/dist/chunks/studio-fmdymd9v.js +5 -0
- package/dist/chunks/studio-gcm12z00.js +6 -0
- package/dist/chunks/{studio-t3j8htp7.js → studio-gj98m8gy.js} +5 -5
- package/dist/chunks/{studio-cgb97rwv.js → studio-hasbgjah.js} +4 -4
- package/dist/chunks/studio-hhp4x8xf.js +6 -0
- package/dist/chunks/{studio-848rk4p1.js → studio-hz5n7x27.js} +4 -4
- package/dist/chunks/{studio-0g2sm01j.js → studio-j3d2fjqz.js} +4 -4
- package/dist/chunks/studio-jeraxdgv.js +7 -0
- package/dist/chunks/studio-jvgek9xt.js +5 -0
- package/dist/chunks/studio-jws1a87n.js +5 -0
- package/dist/chunks/studio-k2sz13zg.js +5 -0
- package/dist/chunks/studio-k3m4jkdk.js +5 -0
- package/dist/chunks/{studio-7vb997ff.js → studio-kg1abnz0.js} +4 -4
- package/dist/chunks/{studio-s0fg2wav.js → studio-kg5ya5r2.js} +4 -4
- package/dist/chunks/studio-khwbgrtg.js +5 -0
- package/dist/chunks/studio-mx6wzh25.js +5 -0
- package/dist/chunks/studio-mxs3ar9t.js +5 -0
- package/dist/chunks/studio-nm4szey4.js +5 -0
- package/dist/chunks/studio-nqxqf8p2.js +4 -0
- package/dist/chunks/{studio-07k0geap.js → studio-pjtntksy.js} +4 -4
- package/dist/chunks/studio-qh8berdz.js +5 -0
- package/dist/chunks/studio-qn7z4krm.js +5 -0
- package/dist/chunks/studio-qyed0ah6.js +5 -0
- package/dist/chunks/{studio-5e7p1vgd.js → studio-r4bcdwhq.js} +4 -4
- package/dist/chunks/{studio-mwnmzx7g.js → studio-r7pf0rkv.js} +6 -6
- package/dist/chunks/studio-rtfnhrdg.js +5 -0
- package/dist/chunks/{studio-zacvfm31.js → studio-rzqaz21g.js} +4 -4
- package/dist/chunks/studio-s5tzw84t.js +5 -0
- package/dist/chunks/{studio-nf0pqpbj.js → studio-sevbc3xv.js} +4 -4
- package/dist/chunks/{studio-va0e63sk.js → studio-sxdb9h3q.js} +6 -6
- package/dist/chunks/studio-t51y8v1d.js +5 -0
- package/dist/chunks/{studio-pd9dsqpq.js → studio-t98vq4r6.js} +4 -4
- package/dist/chunks/studio-th7z3fg7.js +5 -0
- package/dist/chunks/studio-tsxpqvh0.js +6 -0
- package/dist/chunks/{studio-7823f0g8.js → studio-v1yascv2.js} +4 -4
- package/dist/chunks/{studio-tpy3rdxn.js → studio-wc6za3zs.js} +4 -4
- package/dist/chunks/{studio-5m0w815d.js → studio-wxq6v5sv.js} +4 -4
- package/dist/chunks/{studio-ahf3cspq.js → studio-y60sts62.js} +3 -3
- package/dist/chunks/studio-ybnwymxw.js +5 -0
- package/dist/chunks/studio-zndrqawb.js +5 -0
- package/dist/chunks/studio-zwaxn5s2.js +5 -0
- package/dist/chunks/{tsMode-6vwhy6ty.js → tsMode-f54j66ym.js} +5 -5
- package/dist/chunks/workspace-home-x1787wpv.js +4 -0
- package/dist/chunks/workspace-zpe1np43.js +4 -0
- package/dist/chunks/{ws-client-zcxkfgmf.js → ws-client-e8kj684q.js} +3 -3
- package/dist/manifest.json +76 -75
- package/dist/studio.js +81 -82
- package/package.json +4 -4
- package/src/browse/library-model.ts +56 -23
- package/src/commands/context.ts +1 -0
- package/src/editor/shortcuts.ts +3 -0
- package/src/panels/data-grid.ts +0 -4
- package/src/panels/settings-menu.ts +3 -3
- package/src/panels/settings-pane.ts +42 -56
- package/src/services/ai-import-tools.ts +6 -3
- package/src/services/ai-models.ts +65 -11
- package/src/services/ai-settings.ts +45 -5
- package/src/services/document-assistant.ts +5 -2
- package/src/services/settings/definitions.ts +19 -0
- package/src/settings/contributed-section.ts +16 -7
- package/src/settings/css-vars-editor.ts +4 -4
- package/src/settings/general-settings.ts +1 -4
- package/src/settings/preferences-accounts.ts +2 -2
- package/src/settings/preferences-dialog.ts +4 -2
- package/src/settings/project-sections.ts +1 -1
- package/src/settings/section-registry.ts +5 -4
- package/src/settings/settings-document.ts +33 -24
- package/src/settings/settings-workspace.ts +205 -0
- package/src/shell.ts +31 -6
- package/src/surfaces/ai-credentials-form.json +59 -5
- package/src/surfaces/ai-credentials-form.ts +15 -2
- package/src/surfaces/commandbar.ts +7 -3
- package/src/surfaces/settings-contributed.json +4 -4
- package/src/surfaces/settings-contributed.ts +2 -2
- package/src/surfaces/settings-pane.json +262 -180
- package/src/surfaces/settings-pane.ts +63 -14
- package/src/ui/ai-credentials-form.ts +128 -11
- package/src/ui/regions.ts +5 -5
- package/src/workspace/tab-workspace.ts +3 -2
- package/src/workspace/workspace-home.ts +18 -4
- package/src/workspace/workspace-ids.ts +40 -7
- package/dist/chunks/adapter-xcpsmecx.js +0 -4
- package/dist/chunks/add-new-flow-ptmhmzr9.js +0 -4
- package/dist/chunks/cf-account-picker-z1sgwpwd.js +0 -4
- package/dist/chunks/cf-settings-xqvhxxe9.js +0 -4
- package/dist/chunks/components-whsc81a7.js +0 -4
- package/dist/chunks/content-source-jwtxg78w.js +0 -4
- package/dist/chunks/editor-zdqdpq1x.js +0 -4
- package/dist/chunks/entry-commands-w8p2fbpt.js +0 -4
- package/dist/chunks/extension-sections-y2p1te2r.js +0 -4
- package/dist/chunks/file-ops-13ab4swj.js +0 -4
- package/dist/chunks/files-zbc8p6v1.js +0 -4
- package/dist/chunks/format-host-zjsbktbx.js +0 -4
- package/dist/chunks/fs-events-t6x0hch6.js +0 -4
- package/dist/chunks/grid-open-fyzdwpkh.js +0 -4
- package/dist/chunks/iframe-host-kbyqc7pt.js +0 -4
- package/dist/chunks/index-6nvj89vb.js +0 -4
- package/dist/chunks/jx-validate-5sp8a4rm.js +0 -4
- package/dist/chunks/layers-panel-qrxj9vr2.js +0 -4
- package/dist/chunks/layers-tpzayggx.js +0 -4
- package/dist/chunks/lit-html-x6nrxsx3.js +0 -4
- package/dist/chunks/media-library-ywppnjrz.js +0 -4
- package/dist/chunks/media-picker-etxgc8qq.js +0 -4
- package/dist/chunks/monaco-buffer-qrnqhk0b.js +0 -4
- package/dist/chunks/notify-kcv38wwe.js +0 -4
- package/dist/chunks/parse-df2kkmhc.js +0 -4
- package/dist/chunks/platform-dtsysmyd.js +0 -4
- package/dist/chunks/publish-panel-evb1rcxt.js +0 -4
- package/dist/chunks/publish-workspace-ktk9h536.js +0 -4
- package/dist/chunks/quick-search-2f47fxcw.js +0 -4
- package/dist/chunks/references-5w6ajjv7.js +0 -4
- package/dist/chunks/right-panel-kz0a6byf.js +0 -4
- package/dist/chunks/source-control-1phx90zk.js +0 -4
- package/dist/chunks/studio-0hr000ba.js +0 -5
- package/dist/chunks/studio-1wyp7dt5.js +0 -5
- package/dist/chunks/studio-20ap8dds.js +0 -5
- package/dist/chunks/studio-291gqh98.js +0 -5
- package/dist/chunks/studio-4zqfw5ha.js +0 -5
- package/dist/chunks/studio-56egy6vf.js +0 -5
- package/dist/chunks/studio-695k95bw.js +0 -5
- package/dist/chunks/studio-732mw0g8.js +0 -5
- package/dist/chunks/studio-76t560kn.js +0 -6
- package/dist/chunks/studio-8486jn4r.js +0 -5
- package/dist/chunks/studio-8x8616xd.js +0 -5
- package/dist/chunks/studio-bkmv1h3e.js +0 -9
- package/dist/chunks/studio-cqf1k4qk.js +0 -5
- package/dist/chunks/studio-dbgv4fv9.js +0 -16
- package/dist/chunks/studio-et6t8g4m.js +0 -4
- package/dist/chunks/studio-f2j9et3h.js +0 -14
- package/dist/chunks/studio-fep7hr66.js +0 -7
- package/dist/chunks/studio-fyf7j57j.js +0 -5
- package/dist/chunks/studio-g5prntab.js +0 -5
- package/dist/chunks/studio-ga77mf07.js +0 -5
- package/dist/chunks/studio-h7gy12h2.js +0 -5
- package/dist/chunks/studio-j933k8nr.js +0 -5
- package/dist/chunks/studio-jgbvqcgh.js +0 -5
- package/dist/chunks/studio-k4xc5g6h.js +0 -5
- package/dist/chunks/studio-p0nf2e1f.js +0 -6
- package/dist/chunks/studio-pzfa2vmb.js +0 -5
- package/dist/chunks/studio-rf8d6p9f.js +0 -7
- package/dist/chunks/studio-rt498t2v.js +0 -5
- package/dist/chunks/studio-sd07xva5.js +0 -6
- package/dist/chunks/studio-thj81e98.js +0 -7
- package/dist/chunks/studio-tyw7tk0x.js +0 -5
- package/dist/chunks/studio-vffwe9k7.js +0 -5
- package/dist/chunks/studio-vxjap704.js +0 -5
- package/dist/chunks/studio-w67vfgy5.js +0 -5
- package/dist/chunks/studio-xebavr9s.js +0 -5
- package/dist/chunks/studio-yg5n49za.js +0 -5
- package/dist/chunks/studio-yhz5b313.js +0 -5
- package/dist/chunks/studio-zsjpsw08.js +0 -5
- package/dist/chunks/studio-zxm98z2m.js +0 -7
- package/dist/chunks/workspace-d65bz1qk.js +0 -4
- package/dist/chunks/workspace-home-vbg9b3jh.js +0 -4
- package/src/settings/settings-dialog.ts +0 -192
- package/src/surfaces/settings-dialog.json +0 -51
- package/src/surfaces/settings-dialog.ts +0 -169
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{n,_}from"./studio-zsjpsw08.js";var os=Math.floor;var nt=Math.abs;var ue=(t,e)=>t<e?t:e,Z=(t,e)=>t>e?t:e;var de=(t)=>t!==0?t<0:1/t<0;var cn=1,ln=2,fe=4,pe=8;var dt=32,F=64,D=128;var Vt=31,Mt=63,X=127;var fr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:hn}=Number;var pr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&os(t)===t);var G=()=>new Set;var ge=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},j=Array.from,me=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},$t=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Q=Array.isArray;var{fromCharCode:fn,fromCodePoint:yi}=String,Zc=fn(65535),bi=(t)=>t.toLowerCase(),ki=/^\s*/g,_i=(t)=>t.replace(ki,""),Si=/([A-Z])/g,pn=(t,e)=>_i(t.replace(Si,(r)=>`${e}${bi(r)}`));var Ei=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ii=(t)=>gt.encode(t),wr=gt?Ii:Ei;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var xr=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ka=()=>new wt;var fk=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var br=(t)=>{let e=new Uint8Array(fk(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ui=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Z(r,e)*2),t.cpos=0},T=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=T;var _t=(t,e)=>{while(e>X)T(t,D|X&e),e=os(e/128);T(t,X&e)},ye=(t,e)=>{let r=de(e);if(r)e=-e;T(t,(e>Mt?D:0)|(r?F:0)|Mt&e),e=os(e/64);while(e>0)T(t,(e>X?D:0)|X&e),e=os(e/128)},gn=new Uint8Array(30000),Ti=gn.length/3,Ai=(t,e)=>{if(e.length<Ti){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)T(t,gn[s])}else Bo(t,wr(e))},Ci=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)T(t,r.codePointAt(i))},Ja=gt&>.encodeInto?Ai:Ci;var jt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ue(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Z(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},Bo=(t,e)=>{_t(t,e.byteLength),jt(t,e)},mn=(t,e)=>{Ui(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Di=(t,e)=>mn(t,4).setFloat32(0,e,!1),Bi=(t,e)=>mn(t,8).setFloat64(0,e,!1),Oi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var yr=new DataView(new ArrayBuffer(4)),vi=(t)=>(yr.setFloat32(0,t),yr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":T(t,119),Ja(t,e);break;case"number":if(pr(e)&&nt(e)<=fr)T(t,125),ye(t,e);else if(vi(e))T(t,124),Di(t,e);else T(t,123),Bi(t,e);break;case"bigint":T(t,122),Oi(t,e);break;case"object":if(e===null)T(t,126);else if(Q(e)){T(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)T(t,116),Bo(t,e);else{T(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];Ja(t,i),mt(t,e[i])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}};class be extends wt{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)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),br(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class qt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),br(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}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 wt;return this.sarr.push(this.s),this.s="",Ja(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),br(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var ke=R("Unexpected end of array"),Er=R("Integer out of Range"),Ni=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,r)};class Gt{constructor(t){this.arr=t,this.pos=0}}var Ya=(t)=>new Gt(t),Ir=(t)=>t.pos!==t.arr.length;var Li=(t,e)=>{let r=Ni(t.arr,t.pos,e);return t.pos+=e,r},Xo=(t)=>Li(t,Dt(t));var rt=(t)=>t.arr[t.pos++];var Dt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&X)*r,r*=128,i<D)return e;if(e>ft)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],r=e&Mt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&X)*s,s*=128,e<D)return i*r;if(r>ft)throw Er}throw ke};var Vi=(t)=>{let e=Dt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},Mi=(t)=>pt.decode(Xo(t)),Za=pt?Mi:Vi;var yn=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},$i=(t)=>yn(t,4).getFloat32(0,!1),Fi=(t)=>yn(t,8).getFloat64(0,!1),ji=(t)=>yn(t,8).getBigInt64(0,!1);var qi=[(t)=>{return},(t)=>null,_e,$i,Fi,ji,(t)=>!1,(t)=>!0,Za,(t)=>{let e=Dt(t),r={};for(let s=0;s<e;s++){let i=Za(t);r[i]=yt(t)}return r},(t)=>{let e=Dt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xo],yt=(t)=>qi[127-rt(t)](t);class Se extends Gt{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),Ir(this))this.count=Dt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends Gt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=de(this.s);if(this.count=1,t)this.s=-this.s,this.count=Dt(this)+2}return this.count--,this.s}}class zt extends Gt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=os(t/2),this.count=1,e)this.count=Dt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=Za(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 A=()=>new Map,Ee=(t)=>{let e=A();return t.forEach((r,s)=>{e.set(s,r)}),e},q=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},Tr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},Ar=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};class Ie{constructor(){this._observers=A()}on(t,e){return q(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}class pk{constructor(){this._observers=A()}on(t,e){q(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}var tl=crypto.subtle,Cr=crypto.getRandomValues.bind(crypto);var kn=()=>Cr(new Uint32Array(1))[0];var Gi=[1e7]+-1000+-4000+-8000+-100000000000,Dr=()=>Gi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var Su=Date.now;var _n=(t)=>new Promise(t);var rl=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Or{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var vr=new Or,Pi=!0;try{if(typeof localStorage<"u"&&localStorage)vr=localStorage,Pi=!1}catch(t){}var Nr=vr;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Rr=(t)=>typeof t==="object",{assign:Lr,keys:Wi}=Object;var Vr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Wi(t).length;var Mr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Zi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Zi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var $r=(t)=>t;var op=(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[st]!=null)return t[st](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 r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!op(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!op(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!op(t[r],e[r]))return!1;break;default:return!1}return!0},Fr=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var sl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Xi=[],Qi=()=>{if(z===void 0)if(Wt){z=A();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Xi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=A(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=A();return z},Cn=(t)=>Qi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(Nr.getItem(t));var jr=(t)=>Cn("--"+t)||Zt(t)!==null,qr=jr("production"),Yi=Wt&&Fr(process.env.FORCE_COLOR,["true","1","2"]),Gr=Yi||!Cn("--no-colors")&&!jr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var to=(t)=>new Uint8Array(t);var zr=(t)=>{let e=to(t.byteLength);return e.set(t),e};class Hr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new Hr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>os(t.next()*(r+1-e)+e);var On=(t,e,r)=>os(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var ro=(t)=>fn(vn(t,97,122)),Jr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=ro(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var io=Symbol("0schema");class Kr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(xr(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
-
`)}}var Nn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[st])return Ue(t,e);if(Q(t))return me(t,(r)=>$t(e,(s)=>Nn(r,s)));else if(Rr(t))return kt(t,(r,s)=>Nn(r,e[s]));return!1};class B{static _dilutes=!1;extends(t){let[e,r]=[this.shape,t.shape];if(this.constructor._dilutes)[r,e]=[e,r];return Nn(e,r)}equals(t){return this.constructor===t.constructor&&
|
|
3
|
-
${r.toString()}`)};class hs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Uo=(t)=>new hs(t),us=Uo(De).if(cs,(t,e)=>Te(e,hn,ft)).if(ls,(t,e)=>Jr(e)).if(So,(t,e)=>Bn(e)).if(_o,(t,e)=>BigInt(Te(e,hn,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(ho,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(lo.check(i)){if(Bn(e))continue;i=i.shape}r[s]=us(i,e)}return r}).if(go,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Wr,(t,e)=>Ae(e,t.shape)).if(Eo,(t,e)=>null).if(yo,(t,e)=>{let r=St(e,t.res);return()=>r}).if(ko,(t,e)=>St(e,Ae(e,[Et,It,Ve,as,jn,Le,Yr(Et),Qr(Ut("a","b","c"),Et)]))).if(fo,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>us(Xt(e),t);var it=typeof document<"u"?document:{};var bl=E((t)=>t.nodeType===Oo);var kl=typeof DOMParser<"u"?new DOMParser:null;var _l=E((t)=>t.nodeType===Ao);var Sl=E((t)=>t.nodeType===Co);var ds=(t)=>Tr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:El,COMMENT_NODE:Il,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Ul,DOCUMENT_FRAGMENT_NODE:Oo}=it,Tl=E((t)=>t.nodeType===Do);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),fs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Al=Su();var Lo={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Vo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=A(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Lo[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=ds(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},ps=Gr?Vo:fs,gs=(...t)=>{console.log(...ps(t)),ms.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...ps(t)),t.unshift(Tt),ms.forEach((e)=>e.print(t))};var ms=G();var ws=(t)=>({[Symbol.iterator](){return this},next:t}),xs=(t,e)=>ws(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>ws(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Bt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Js(t,o,f.clock,f.len,r)}}),Fo=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=os((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&Fo(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,Z(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{q(t.clients,e,()=>[]).push(new oe(r,s))},vs=()=>new ht,jo=(t)=>{let e=vs();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},vt=(t,e)=>{_t(t.restEncoder,e.clients.size),j(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Dt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Dt(t.restDecoder),o=Dt(t.restDecoder);if(o>0){let c=q(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},ys=(t,e,r)=>{let s=new ht,i=Dt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Dt(t.restDecoder),l=Dt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),vt(o,s),o.toUint8Array()}return null};var Ns=kn;class wd extends Ie{constructor({guid:t=Dr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Ns(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(j(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=q(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,va)}getText(t=""){return this.get(t,ss)}getMap(t=""){return this.get(t,rs)}getXmlElement(t=""){return this.get(t,Ot)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,j(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new wd({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Dt(this.restDecoder)}readDsLen(){return Dt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readRightID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readClient(){return Dt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return Za(this.restDecoder)}readParentInfo(){return Dt(this.restDecoder)===1}readTypeRef(){return Dt(this.restDecoder)}readLen(){return Dt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return zr(Xo(this.restDecoder))}readJSON(){return JSON.parse(Za(this.restDecoder))}readKey(){return Za(this.restDecoder)}}class Rs{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Dt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Rs{constructor(t){super(t);this.keys=[],Dt(t),this.keyClockDecoder=new zt(Xo(t)),this.clientDecoder=new bt(Xo(t)),this.leftClockDecoder=new zt(Xo(t)),this.rightClockDecoder=new zt(Xo(t)),this.infoDecoder=new Se(Xo(t),rt),this.stringDecoder=new bn(Xo(t)),this.parentInfoDecoder=new Se(Xo(t),rt),this.typeRefDecoder=new bt(Xo(t)),this.lenDecoder=new bt(Xo(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(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 yt(this.restDecoder)}readBuf(){return Xo(this.restDecoder)}readJSON(){return yt(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 rr{constructor(){this.restEncoder=Ka()}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class Nt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){Ja(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){Ja(this.restEncoder,JSON.stringify(t))}writeKey(t){Ja(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Ka(),this.dsCurrVal=0}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new qt,this.clientEncoder=new xt,this.leftClockEncoder=new qt,this.rightClockEncoder=new qt,this.infoEncoder=new be(xe),this.stringEncoder=new wn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Ka();return _t(t,0),Bo(t,this.keyClockEncoder.toUint8Array()),Bo(t,this.clientEncoder.toUint8Array()),Bo(t,this.leftClockEncoder.toUint8Array()),Bo(t,this.rightClockEncoder.toUint8Array()),Bo(t,br(this.infoEncoder)),Bo(t,this.stringEncoder.toUint8Array()),Bo(t,br(this.parentInfoEncoder)),Bo(t,this.typeRefEncoder.toUint8Array()),Bo(t,this.lenEncoder.toUint8Array()),jt(t,br(this.restEncoder)),br(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){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){mt(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 qo=(t,e,r,s)=>{s=Z(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),j(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{qo(t,e.clients.get(i),i,o)})},Go=(t,e)=>{let r=A(),s=Dt(t.restDecoder);for(let i=0;i<s;i++){let o=Dt(t.restDecoder),c=Array(o),l=t.readClient(),h=Dt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Vt&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Dt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,mi(t,a));c[f]=d,h+=d.length}}}}return r},zo=(t,e,r)=>{let s=[],i=j(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=q(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Ho=(t,e)=>ir(t,e.doc.store,e.beforeState),Jo=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=Go(s,c),f=zo(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=ys(s,i,l);if(l.pendingDs){let d=new ct(Ya(l.pendingDs));Dt(d.restDecoder);let p=ys(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Ls(i.doc,d)}},r,!1);var Ls=(t,e,r,s=ct)=>{let i=Ya(e);Jo(i,t,r,new s(i))},KI=(t,e,r)=>Ls(t,e,r,nr),Po=(t,e,r=new Map)=>{ir(t,e.store,r),vt(t,jo(e.store))},Ko=(t,e=new Uint8Array([0]),r=new et)=>{let s=Vs(e);Po(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===Nt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},JI=(t,e)=>Ko(t,e,new Nt),Wo=(t)=>{let e=new Map,r=Dt(t.restDecoder);for(let s=0;s<r;s++){let i=Dt(t.restDecoder),o=Dt(t.restDecoder);e.set(i,o)}return e},Vs=(t)=>Wo(new er(Ya(t))),Ms=(t,e)=>(_t(t.restEncoder,e.size),j(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Zo=(t,e)=>Ms(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)Ms(e,t);else Zo(e,t);return e.toUint8Array()},YI=(t)=>Qo(t,new rr);class $s{constructor(){this.l=[]}}var bs=()=>new $s,ks=(t,e)=>t.l.push(e),_s=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Fs=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var js=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class qs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class Gs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new Gs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=js(t);else s=m(t._item.id.client,t._item.id.clock);return new qs(s,i,e,r)},Q0=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},Pg=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class zs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new zs(t,e),$l=ec(vs(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=q(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Bt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Hs=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=os(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=os((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Ss=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Js=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ps{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(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=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Es=(t,e)=>{if(e.deleteSet.clients.size===0&&!Ar(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Ho(t,e),vt(t,e.deleteSet),!0},Is=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)q(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ue(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ks=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),Fs(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=Z(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))gs(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Ns();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new Nt;if(Es(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Es(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ks(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ps(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ks(i,0)}}return c};class Ws{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Us=(t,e,r)=>{Bt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},Ts=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Bt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Bt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=gi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class k2 extends Ie{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Q(t)?t[0].doc:t instanceof wd?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=Su(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Ws(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Bt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},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=Q(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}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((r)=>{if(t)this.undoStack.forEach((s)=>Us(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Us(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ts(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ts(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*oc(t){let e=Dt(t.restDecoder);for(let r=0;r<e;r++){let s=Dt(t.restDecoder),i=t.readClient(),o=Dt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Dt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Vt&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,mi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(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===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,Nt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(Ya(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return vt(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Vs(e),o=new s,c=new nn(o),l=new r(Ya(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,Z(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return vt(o,f),o.toUint8Array()};var Zs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:br(t.encoder.restEncoder)}),t.encoder.restEncoder=Ka(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Zs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Zs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),jt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(Ya(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return vt(c,h),c.toUint8Array()};var uc=(t)=>hc(t,$r,ct,Nt),As="You must not compute changes after the event-handler fired.";class le{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=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=ge(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=ge(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=ge(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),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 R(As);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Xs=80,lr=0;class Qs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},Ys=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Xs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Ys(s,e,r),s}else{let s=new Qs(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Xs)return Ys(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=Z(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(q(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}Fs(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=bs(),this._dEH=bs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_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){ks(this._eH,t)}observeDeep(t){ks(this._dEH,t)}unobserve(t){_s(this._eH,t)}unobserveDeep(t){_s(this._dEH,t)}toJSON(){}}var ti=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ei=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ni=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},ri=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case wd:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},si=()=>R("Length exceeded!"),ii=(t,e,r,s)=>{if(r>e._length)throw si();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},oi=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw si();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case wd:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ci=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},li=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;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&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),xs(t._map.entries(),(e)=>!e[1].deleted));class ky extends le{}class va extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new va;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new va}clone(){let t=new va;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new ky(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ri(this,t)}toArray(){return ei(this)}slice(t=0,e=this.length){return ti(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ni(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new va;class e_ extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class rs extends I{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((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new rs}clone(){let t=new rs;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new e_(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return li(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new rs,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(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 Cs=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Cs(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Cs(t,c,r)}},ai=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},hi=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},ui=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),ai(t,e,r,l)},Ds=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
|
|
1
|
+
import{n,_}from"./studio-8z66jk4z.js";var os=Math.floor;var nt=Math.abs;var ue=(t,e)=>t<e?t:e,Z=(t,e)=>t>e?t:e;var de=(t)=>t!==0?t<0:1/t<0;var cn=1,ln=2,fe=4,pe=8;var dt=32,F=64,D=128;var Vt=31,Mt=63,X=127;var fr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:hn}=Number;var pr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&os(t)===t);var G=()=>new Set;var ge=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},j=Array.from,me=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},$t=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Q=Array.isArray;var{fromCharCode:fn,fromCodePoint:yi}=String,Zc=fn(65535),bi=(t)=>t.toLowerCase(),ki=/^\s*/g,_i=(t)=>t.replace(ki,""),Si=/([A-Z])/g,pn=(t,e)=>_i(t.replace(Si,(r)=>`${e}${bi(r)}`));var Ei=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ii=(t)=>gt.encode(t),wr=gt?Ii:Ei;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var xr=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Za=()=>new wt;var fk=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var br=(t)=>{let e=new Uint8Array(fk(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ui=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Z(r,e)*2),t.cpos=0},T=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=T;var _t=(t,e)=>{while(e>X)T(t,D|X&e),e=os(e/128);T(t,X&e)},ye=(t,e)=>{let r=de(e);if(r)e=-e;T(t,(e>Mt?D:0)|(r?F:0)|Mt&e),e=os(e/64);while(e>0)T(t,(e>X?D:0)|X&e),e=os(e/128)},gn=new Uint8Array(30000),Ti=gn.length/3,Ai=(t,e)=>{if(e.length<Ti){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)T(t,gn[s])}else zo(t,wr(e))},Ci=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)T(t,r.codePointAt(i))},Xa=gt&>.encodeInto?Ai:Ci;var jt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ue(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Z(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},zo=(t,e)=>{_t(t,e.byteLength),jt(t,e)},mn=(t,e)=>{Ui(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Di=(t,e)=>mn(t,4).setFloat32(0,e,!1),Bi=(t,e)=>mn(t,8).setFloat64(0,e,!1),Oi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var yr=new DataView(new ArrayBuffer(4)),vi=(t)=>(yr.setFloat32(0,t),yr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":T(t,119),Xa(t,e);break;case"number":if(pr(e)&&nt(e)<=fr)T(t,125),ye(t,e);else if(vi(e))T(t,124),Di(t,e);else T(t,123),Bi(t,e);break;case"bigint":T(t,122),Oi(t,e);break;case"object":if(e===null)T(t,126);else if(Q(e)){T(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)T(t,116),zo(t,e);else{T(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];Xa(t,i),mt(t,e[i])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}};class be extends wt{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)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),br(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class qt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),br(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}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 wt;return this.sarr.push(this.s),this.s="",Xa(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),br(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var ke=R("Unexpected end of array"),Er=R("Integer out of Range"),Ni=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,r)};class Gt{constructor(t){this.arr=t,this.pos=0}}var Qa=(t)=>new Gt(t),Ir=(t)=>t.pos!==t.arr.length;var Li=(t,e)=>{let r=Ni(t.arr,t.pos,e);return t.pos+=e,r},Xo=(t)=>Li(t,Dt(t));var rt=(t)=>t.arr[t.pos++];var Dt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&X)*r,r*=128,i<D)return e;if(e>ft)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],r=e&Mt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&X)*s,s*=128,e<D)return i*r;if(r>ft)throw Er}throw ke};var Vi=(t)=>{let e=Dt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},Mi=(t)=>pt.decode(Xo(t)),el=pt?Mi:Vi;var yn=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},$i=(t)=>yn(t,4).getFloat32(0,!1),Fi=(t)=>yn(t,8).getFloat64(0,!1),ji=(t)=>yn(t,8).getBigInt64(0,!1);var qi=[(t)=>{return},(t)=>null,_e,$i,Fi,ji,(t)=>!1,(t)=>!0,el,(t)=>{let e=Dt(t),r={};for(let s=0;s<e;s++){let i=el(t);r[i]=yt(t)}return r},(t)=>{let e=Dt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xo],yt=(t)=>qi[127-rt(t)](t);class Se extends Gt{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),Ir(this))this.count=Dt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends Gt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=de(this.s);if(this.count=1,t)this.s=-this.s,this.count=Dt(this)+2}return this.count--,this.s}}class zt extends Gt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=os(t/2),this.count=1,e)this.count=Dt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=el(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 A=()=>new Map,Ee=(t)=>{let e=A();return t.forEach((r,s)=>{e.set(s,r)}),e},q=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},Tr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},Ar=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};class Ie{constructor(){this._observers=A()}on(t,e){return q(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}class pk{constructor(){this._observers=A()}on(t,e){q(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}var tl=crypto.subtle,Cr=crypto.getRandomValues.bind(crypto);var kn=()=>Cr(new Uint32Array(1))[0];var Gi=[1e7]+-1000+-4000+-8000+-100000000000,Dr=()=>Gi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var Su=Date.now;var _n=(t)=>new Promise(t);var sl=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Or{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var vr=new Or,Pi=!0;try{if(typeof localStorage<"u"&&localStorage)vr=localStorage,Pi=!1}catch(t){}var Nr=vr;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Rr=(t)=>typeof t==="object",{assign:Lr,keys:Wi}=Object;var Vr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Wi(t).length;var Mr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Zi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Zi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var $r=(t)=>t;var rp=(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[st]!=null)return t[st](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 r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!rp(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!rp(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!rp(t[r],e[r]))return!1;break;default:return!1}return!0},Fr=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var il=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Xi=[],Qi=()=>{if(z===void 0)if(Wt){z=A();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Xi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=A(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=A();return z},Cn=(t)=>Qi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(Nr.getItem(t));var jr=(t)=>Cn("--"+t)||Zt(t)!==null,qr=jr("production"),Yi=Wt&&Fr(process.env.FORCE_COLOR,["true","1","2"]),Gr=Yi||!Cn("--no-colors")&&!jr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var to=(t)=>new Uint8Array(t);var zr=(t)=>{let e=to(t.byteLength);return e.set(t),e};class Hr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new Hr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>os(t.next()*(r+1-e)+e);var On=(t,e,r)=>os(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var ro=(t)=>fn(vn(t,97,122)),Jr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=ro(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var io=Symbol("0schema");class Kr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(xr(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
+
`)}}var Nn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[st])return Ue(t,e);if(Q(t))return me(t,(r)=>$t(e,(s)=>Nn(r,s)));else if(Rr(t))return kt(t,(r,s)=>Nn(r,e[s]));return!1};class B{static _dilutes=!1;extends(t){let[e,r]=[this.shape,t.shape];if(this.constructor._dilutes)[r,e]=[e,r];return Nn(e,r)}equals(t){return this.constructor===t.constructor&&rp(this.shape,t.shape)}[io](){return!0}[st](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){L()}get nullable(){return Ut(this,Ve)}get optional(){return new Rn(this)}cast(t){return Pr(t,this),t}expect(t){return Pr(t,this),t}}class Be extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var S=(t,e=null)=>new Be(t,e),cl=S(Be);class Oe extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}}var E=(t)=>new Oe(t),ll=S(Oe);class Qt extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape.some((s)=>s===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}}var ve=(...t)=>new Qt(t),Wr=S(Qt),oo=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),Zr=(t)=>{if(It.check(t))return[oo(t)];if(Wr.check(t))return t.shape.map((e)=>e+"");if(cs.check(t))return["[+-]?\\d+.?\\d*"];if(ls.check(t))return[".*"];if(Ce.check(t))return t.shape.map(Zr).flat(1);v()};class Xr extends B{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(Zr).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}}var al=S(Xr),co=Symbol("optional");class Rn extends B{constructor(t){super();this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[co](){return!0}}var lo=S(Rn);class Ln extends B{check(t,e){return e?.extend(null,"never",typeof t),!1}}var hl=new Ln,ul=S(Ln);class Ne extends B{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new Ne(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return kt(this.shape,(r,s)=>{let i=this._isPartial&&!Pt(t,s)||r.check(t[s],e);return!i&&e?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}}var ao=(t)=>new Ne(t),ho=S(Ne),uo=E((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class Vn extends B{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&kt(t,(r,s)=>{let i=this.shape.keys.check(s,e);return!i&&e?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,e)})}}var Qr=(t,e)=>new Vn(t,e),fo=S(Vn);class Mn extends B{constructor(t){super();this.shape=t}check(t,e){return t!=null&&kt(this.shape,(r,s)=>{let i=r.check(t[s],e);return!i&&e?.extend(s.toString(),"Tuple",typeof r),i})}}var po=(...t)=>new Mn(t),dl=S(Mn);class $n extends B{constructor(t){super();this.shape=t.length===1?t[0]:new Re(t)}check(t,e){let r=Q(t)&&me(t,(s)=>this.shape.check(s));return!r&&e?.extend(null,"Array",""),r}}var Yr=(...t)=>new $n(t),go=S($n),mo=E((t)=>Q(t));class Fn extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}}var wo=(t,e=null)=>new Fn(t,e),fl=S(Fn),xo=wo(B);class ts extends B{constructor(t){super();this.len=t.length-1,this.args=po(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}}var yo=S(ts),bo=E((t)=>typeof t==="function");class es extends B{constructor(t){super();this.shape=t}check(t,e){let r=me(this.shape,(s)=>s.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}}var pl=S(es,(t)=>t.shape.length>0);class Re extends B{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let r=$t(this.shape,(s)=>s.check(t,e));return e?.extend(null,"Union",typeof t),r}}var Ut=(...t)=>t.findIndex((e)=>Ce.check(e))>=0?Ut(...t.map((e)=>Xt(e)).map((e)=>Ce.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Re(t),Ce=S(Re),ns=()=>!0,De=E(ns),ko=S(Oe,(t)=>t.shape===ns),jn=E((t)=>typeof t==="bigint"),_o=E((t)=>t===jn),is=E((t)=>typeof t==="symbol"),gl=E((t)=>t===is),Et=E((t)=>typeof t==="number"),cs=E((t)=>t===Et),It=E((t)=>typeof t==="string"),ls=E((t)=>t===It),Le=E((t)=>typeof t==="boolean"),So=E((t)=>t===Le),as=ve(void 0),ml=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===void 0),wl=ve(void 0);var Ve=ve(null),Eo=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===null),xl=S(Uint8Array),yl=S(Be,(t)=>t.shape===Uint8Array),Io=Ut(Et,It,Ve,as,jn,Le,is),bl=(()=>{let t=Yr(De),e=Qr(It,De),r=Ut(Et,It,Ve,Le,t,e);return t.shape=r,e.shape.values=r,r})(),Xt=(t)=>{if(xo.check(t))return t;else if(uo.check(t)){let e={};for(let r in t)e[r]=Xt(t[r]);return ao(e)}else if(mo.check(t))return Ut(...t.map(Xt));else if(Io.check(t))return ve(t);else if(bo.check(t))return S(t);v()},Pr=qr?()=>{}:(t,e)=>{let r=new Kr;if(!e.check(t,r))throw R(`Expected value to be of type ${e.constructor.name}.
|
|
3
|
+
${r.toString()}`)};class hs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Uo=(t)=>new hs(t),us=Uo(De).if(cs,(t,e)=>Te(e,hn,ft)).if(ls,(t,e)=>Jr(e)).if(So,(t,e)=>Bn(e)).if(_o,(t,e)=>BigInt(Te(e,hn,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(ho,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(lo.check(i)){if(Bn(e))continue;i=i.shape}r[s]=us(i,e)}return r}).if(go,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Wr,(t,e)=>Ae(e,t.shape)).if(Eo,(t,e)=>null).if(yo,(t,e)=>{let r=St(e,t.res);return()=>r}).if(ko,(t,e)=>St(e,Ae(e,[Et,It,Ve,as,jn,Le,Yr(Et),Qr(Ut("a","b","c"),Et)]))).if(fo,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>us(Xt(e),t);var it=typeof document<"u"?document:{};var kl=E((t)=>t.nodeType===Bo);var _l=typeof DOMParser<"u"?new DOMParser:null;var Sl=E((t)=>t.nodeType===Ao);var El=E((t)=>t.nodeType===Co);var ds=(t)=>Tr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:Il,COMMENT_NODE:Ul,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Tl,DOCUMENT_FRAGMENT_NODE:Bo}=it,Al=E((t)=>t.nodeType===Do);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),fs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Cl=Su();var Ro={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Lo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=A(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Ro[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=ds(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},ps=Gr?Lo:fs,gs=(...t)=>{console.log(...ps(t)),ms.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...ps(t)),t.unshift(Tt),ms.forEach((e)=>e.print(t))};var ms=G();var ws=(t)=>({[Symbol.iterator](){return this},next:t}),xs=(t,e)=>ws(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>ws(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Bt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Js(t,o,f.clock,f.len,r)}}),$o=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=os((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&$o(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,Z(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{q(t.clients,e,()=>[]).push(new oe(r,s))},vs=()=>new ht,Fo=(t)=>{let e=vs();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},vt=(t,e)=>{_t(t.restEncoder,e.clients.size),j(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Dt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Dt(t.restDecoder),o=Dt(t.restDecoder);if(o>0){let c=q(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},ys=(t,e,r)=>{let s=new ht,i=Dt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Dt(t.restDecoder),l=Dt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),vt(o,s),o.toUint8Array()}return null};var Ns=kn;class xd extends Ie{constructor({guid:t=Dr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Ns(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(j(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=q(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,va)}getText(t=""){return this.get(t,ss)}getMap(t=""){return this.get(t,rs)}getXmlElement(t=""){return this.get(t,Ot)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,j(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new xd({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Dt(this.restDecoder)}readDsLen(){return Dt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readRightID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readClient(){return Dt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return el(this.restDecoder)}readParentInfo(){return Dt(this.restDecoder)===1}readTypeRef(){return Dt(this.restDecoder)}readLen(){return Dt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return zr(Xo(this.restDecoder))}readJSON(){return JSON.parse(el(this.restDecoder))}readKey(){return el(this.restDecoder)}}class Rs{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Dt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Rs{constructor(t){super(t);this.keys=[],Dt(t),this.keyClockDecoder=new zt(Xo(t)),this.clientDecoder=new bt(Xo(t)),this.leftClockDecoder=new zt(Xo(t)),this.rightClockDecoder=new zt(Xo(t)),this.infoDecoder=new Se(Xo(t),rt),this.stringDecoder=new bn(Xo(t)),this.parentInfoDecoder=new Se(Xo(t),rt),this.typeRefDecoder=new bt(Xo(t)),this.lenDecoder=new bt(Xo(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(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 yt(this.restDecoder)}readBuf(){return Xo(this.restDecoder)}readJSON(){return yt(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 rr{constructor(){this.restEncoder=Za()}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class Nt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){Xa(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){zo(this.restEncoder,t)}writeJSON(t){Xa(this.restEncoder,JSON.stringify(t))}writeKey(t){Xa(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Za(),this.dsCurrVal=0}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new qt,this.clientEncoder=new xt,this.leftClockEncoder=new qt,this.rightClockEncoder=new qt,this.infoEncoder=new be(xe),this.stringEncoder=new wn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Za();return _t(t,0),zo(t,this.keyClockEncoder.toUint8Array()),zo(t,this.clientEncoder.toUint8Array()),zo(t,this.leftClockEncoder.toUint8Array()),zo(t,this.rightClockEncoder.toUint8Array()),zo(t,br(this.infoEncoder)),zo(t,this.stringEncoder.toUint8Array()),zo(t,br(this.parentInfoEncoder)),zo(t,this.typeRefEncoder.toUint8Array()),zo(t,this.lenEncoder.toUint8Array()),jt(t,br(this.restEncoder)),br(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){mt(this.restEncoder,t)}writeBuf(t){zo(this.restEncoder,t)}writeJSON(t){mt(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 jo=(t,e,r,s)=>{s=Z(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),j(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{jo(t,e.clients.get(i),i,o)})},qo=(t,e)=>{let r=A(),s=Dt(t.restDecoder);for(let i=0;i<s;i++){let o=Dt(t.restDecoder),c=Array(o),l=t.readClient(),h=Dt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Vt&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Dt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,mi(t,a));c[f]=d,h+=d.length}}}}return r},Go=(t,e,r)=>{let s=[],i=j(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=q(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Ho=(t,e)=>ir(t,e.doc.store,e.beforeState),Jo=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=qo(s,c),f=Go(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=ys(s,i,l);if(l.pendingDs){let d=new ct(Qa(l.pendingDs));Dt(d.restDecoder);let p=ys(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Ls(i.doc,d)}},r,!1);var Ls=(t,e,r,s=ct)=>{let i=Qa(e);Jo(i,t,r,new s(i))},XI=(t,e,r)=>Ls(t,e,r,nr),Po=(t,e,r=new Map)=>{ir(t,e.store,r),vt(t,Fo(e.store))},Ko=(t,e=new Uint8Array([0]),r=new et)=>{let s=Vs(e);Po(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===Nt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},QI=(t,e)=>Ko(t,e,new Nt),Wo=(t)=>{let e=new Map,r=Dt(t.restDecoder);for(let s=0;s<r;s++){let i=Dt(t.restDecoder),o=Dt(t.restDecoder);e.set(i,o)}return e},Vs=(t)=>Wo(new er(Qa(t))),Ms=(t,e)=>(_t(t.restEncoder,e.size),j(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Zo=(t,e)=>Ms(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)Ms(e,t);else Zo(e,t);return e.toUint8Array()},eR=(t)=>Qo(t,new rr);class $s{constructor(){this.l=[]}}var bs=()=>new $s,ks=(t,e)=>t.l.push(e),_s=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Fs=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var js=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class qs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class Gs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new Gs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=js(t);else s=m(t._item.id.client,t._item.id.clock);return new qs(s,i,e,r)},Q0=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},jg=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class zs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new zs(t,e),Fl=ec(vs(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=q(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Bt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Hs=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=os(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=os((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Ss=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Js=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ps{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(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=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Es=(t,e)=>{if(e.deleteSet.clients.size===0&&!Ar(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Ho(t,e),vt(t,e.deleteSet),!0},Is=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)q(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ue(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ks=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),Fs(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=Z(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))gs(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Ns();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new Nt;if(Es(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Es(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ks(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ps(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ks(i,0)}}return c};class Ws{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Us=(t,e,r)=>{Bt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},Ts=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Bt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Bt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=gi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class N2 extends Ie{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Q(t)?t[0].doc:t instanceof xd?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=Su(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Ws(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Bt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},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=Q(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}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((r)=>{if(t)this.undoStack.forEach((s)=>Us(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Us(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ts(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ts(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*oc(t){let e=Dt(t.restDecoder);for(let r=0;r<e;r++){let s=Dt(t.restDecoder),i=t.readClient(),o=Dt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Dt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Vt&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,mi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(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===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,Nt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(Qa(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return vt(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Vs(e),o=new s,c=new nn(o),l=new r(Qa(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,Z(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return vt(o,f),o.toUint8Array()};var Zs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:br(t.encoder.restEncoder)}),t.encoder.restEncoder=Za(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Zs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Zs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),jt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(Qa(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return vt(c,h),c.toUint8Array()};var uc=(t)=>hc(t,$r,ct,Nt),As="You must not compute changes after the event-handler fired.";class le{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=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=ge(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=ge(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=ge(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),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 R(As);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Xs=80,lr=0;class Qs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},Ys=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Xs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Ys(s,e,r),s}else{let s=new Qs(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Xs)return Ys(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=Z(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(q(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}Fs(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=bs(),this._dEH=bs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_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){ks(this._eH,t)}observeDeep(t){ks(this._dEH,t)}unobserve(t){_s(this._eH,t)}unobserveDeep(t){_s(this._dEH,t)}toJSON(){}}var ti=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ei=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ni=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},ri=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case xd:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},si=()=>R("Length exceeded!"),ii=(t,e,r,s)=>{if(r>e._length)throw si();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},oi=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw si();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case xd:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ci=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},li=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;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&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),xs(t._map.entries(),(e)=>!e[1].deleted));class ky extends le{}class va extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new va;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new va}clone(){let t=new va;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new ky(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ri(this,t)}toArray(){return ei(this)}slice(t=0,e=this.length){return ti(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ni(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new va;class e_ extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class rs extends I{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((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new rs}clone(){let t=new rs;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new e_(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return li(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new rs,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(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 Cs=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Cs(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Cs(t,c,r)}},ai=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},hi=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},ui=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),ai(t,e,r,l)},Ds=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
|
|
4
4
|
`;r.right=new y(m(c,b(o.store,c)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new K(h)),r.right.integrate(t,0),r.forward()}ai(t,e,r,l)},di=(t,e,r,s,i)=>{let o=e,c=A();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;c.set(f.key,f)}o=o.right}let l=0,h=!1;while(e!==o){if(r===e)h=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:a,value:u}=f,d=s.get(a)??null;if(c.get(a)!==f||d===u){if(e.delete(t),l++,!h&&(i.get(a)??null)===u&&d!==u)if(d===null)i.delete(a);else i.set(a,d)}if(!h&&!e.deleted)Rt(i,f);break}}}e=e.right}return l},bc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let r=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let s=e.content.key;if(r.has(s))e.delete(t);else r.add(s)}e=e.left}},kc=(t)=>{let e=0;return x(t.doc,(r)=>{let{_start:s,_start:i}=t,o=A(),c=Ee(o);while(i){if(i.deleted===!1)switch(i.content.constructor){case U:Rt(c,i.content);break;default:e+=di(r,s,i,o,c),o=Ee(c),s=i;break}i=i.right}}),e},_c=(t)=>{let e=new Set,r=t.doc;for(let[s,i]of t.afterState.entries()){let o=t.beforeState.get(s)||0;if(i===o)continue;Js(t,r.store.clients.get(s),o,i,(c)=>{if(!c.deleted&&c.content.constructor===U&&c.constructor!==V)e.add(c.parent)})}x(r,(s)=>{Bt(t,t.deleteSet,(i)=>{if(i instanceof V||!i.parent._hasFormatting||e.has(i.parent))return;let o=i.parent;if(i.content.constructor===U)e.add(o);else bc(s,i)});for(let i of e)kc(i)})},Bs=(t,e,r)=>{let s=r,i=Ee(e.currentAttributes),o=e.right;while(r>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case W:case ut:case K:if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));r-=e.right.length,e.right.delete(t);break}e.forward()}if(o)di(t,o,e.right,i,e.currentAttributes);let c=(e.left||e.right).parent;if(c._searchMarker)re(c._searchMarker,e.index,-s+r);return e};class t_ extends le{constructor(t,e,r){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.keysChanged.add(s)})}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=[];x(t,(r)=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",f=0,a=0,u=()=>{if(c!==null){let d=null;switch(c){case"delete":if(a>0)d={delete:a};a=0;break;case"insert":if(typeof h==="object"||h.length>0){if(d={insert:h},s.size>0)d.attributes={},s.forEach((p,g)=>{if(p!==null)d.attributes[g]=p})}h="";break;case"retain":if(f>0){if(d={retain:f},!Mr(l))d.attributes=Lr({},l)}f=0;break}if(d)e.push(d);c=null}};while(o!==null){switch(o.content.constructor){case W:case ut:if(this.adds(o)){if(!this.deletes(o))u(),c="insert",h=o.content.getContent()[0],u()}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=1}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=1}break;case K:if(this.adds(o)){if(!this.deletes(o)){if(c!=="insert")u(),c="insert";h+=o.content.str}}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=o.length}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=o.length}break;case U:{let{key:d,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();if(tt(p,i.get(d)??null))delete l[d];else l[d]=p}else if(p!==null)o.delete(r)}}else if(this.deletes(o)){i.set(d,p);let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();l[d]=g}}else if(!o.deleted){i.set(d,p);let g=l[d];if(g!==void 0){if(!tt(g,p)){if(c==="retain")u();if(p===null)delete l[d];else l[d]=p}else if(g!==null)o.delete(r)}}if(!o.deleted){if(c==="insert")u();Rt(s,o.content)}break}}o=o.right}u();while(e.length>0){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class ss extends I{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ss}clone(){let t=new ss;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new t_(this,t,e);if(sn(this,t,r),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??O();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===K)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)x(this.doc,(r)=>{let s=new We(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!e&&typeof o.insert==="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Ds(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Bs(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Bs(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Ds(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return ci(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new ss;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[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===Ot||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;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 lt extends I{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 lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),j(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new fi(this,e,t))}toString(){return ni(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ei(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ri(this,t)}slice(t=0,e=this.length){return ti(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Ot extends lt{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((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Ot(this.nodeName)}clone(){let t=new Ot(this.nodeName),e=this.getAttributes();return Vr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return li(this,t)}getAttributes(t){return t?wc(this,t):ci(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Ot(t.readKey());class fi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends rs{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends ss{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 Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{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;Hs(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(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 Dc=(t)=>new ie(t.readLen()),pi=(t,e)=>new wd({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{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 he(pi(this.doc.guid,this.opts))}splice(t){throw L()}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 Bc=(t)=>new he(pi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(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 L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=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 Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}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((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),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((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);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=r,o},Os=(t,e)=>$t(t,(r)=>ce(r.deletions,e)),gi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||gi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||Os(o.undoStack,u.right.id)||Os(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?ln:0}set marker(t){if((this.info&pe)>0!==t)this.info^=pe}get marker(){return(this.info&pe)>0}get keep(){return(this.info&cn)>0}set keep(t){if(this.keep!==t)this.info^=cn}get countable(){return(this.info&ln)>0}get deleted(){return(this.info&fe)>0}set deleted(t){if(this.deleted!==t)this.info^=fe}markDeleted(){this.info|=fe}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Ss(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Ss(t,t.doc.store,m(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 r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;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,this.parent._start=this;this.right=r}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(Hs(t.doc.store,this),this.content.integrate(t,this),Is(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(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:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(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((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.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(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Is(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Vt|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=js(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var mi=(t,e)=>Pc[e&Vt](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{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(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xi="__ $YJS$ __";if(wi[xi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");wi[xi]=!0;var ZI=0,XI=1,QI=2,eR=3;class Fg extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return _(t)&&"type"in t&&n(t.type)}function mk(t){let e=Ka(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,ZI),Ja(e,t.path),_t(e,t.epoch),Bo(e,t.body);break}case"awareness":{_t(e,XI),Bo(e,t.body);break}case"doc-close":{_t(e,QI),Ja(e,t.path);break}case"control":{_t(e,eR),Ja(e,JSON.stringify(t.message));break}default:throw new Fg(`unknown-frame:${r}`)}return br(e)}function gk(t){try{let e=Ya(t),r=Dt(e);switch(r){case ZI:{let s=Za(e),i=Dt(e);return{body:Xo(e),epoch:i,path:s,type:"doc-sync"}}case XI:return{body:Xo(e),type:"awareness"};case QI:return{path:Za(e),type:"doc-close"};case eR:{let s=JSON.parse(Za(e));if(!Wc(s))throw new Fg("malformed-control");return{message:s,type:"control"}}default:throw new Fg(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof Fg)throw e;throw new Fg(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
-
export{pk,os,
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Ds(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Bs(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Bs(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Ds(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return ci(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new ss;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[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===Ot||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;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 lt extends I{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 lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),j(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new fi(this,e,t))}toString(){return ni(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ei(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ri(this,t)}slice(t=0,e=this.length){return ti(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Ot extends lt{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((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Ot(this.nodeName)}clone(){let t=new Ot(this.nodeName),e=this.getAttributes();return Vr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return li(this,t)}getAttributes(t){return t?wc(this,t):ci(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Ot(t.readKey());class fi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends rs{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends ss{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 Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{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;Hs(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(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 Dc=(t)=>new ie(t.readLen()),pi=(t,e)=>new xd({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{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 he(pi(this.doc.guid,this.opts))}splice(t){throw L()}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 Bc=(t)=>new he(pi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(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 L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=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 Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}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((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),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((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);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=r,o},Os=(t,e)=>$t(t,(r)=>ce(r.deletions,e)),gi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||gi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||Os(o.undoStack,u.right.id)||Os(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?ln:0}set marker(t){if((this.info&pe)>0!==t)this.info^=pe}get marker(){return(this.info&pe)>0}get keep(){return(this.info&cn)>0}set keep(t){if(this.keep!==t)this.info^=cn}get countable(){return(this.info&ln)>0}get deleted(){return(this.info&fe)>0}set deleted(t){if(this.deleted!==t)this.info^=fe}markDeleted(){this.info|=fe}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Ss(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Ss(t,t.doc.store,m(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 r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;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,this.parent._start=this;this.right=r}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(Hs(t.doc.store,this),this.content.integrate(t,this),Is(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(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:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(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((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.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(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Is(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Vt|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=js(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var mi=(t,e)=>Pc[e&Vt](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{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(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xi="__ $YJS$ __";if(wi[xi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");wi[xi]=!0;var tR=0,nR=1,iR=2,oR=3;class Hg extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return _(t)&&"type"in t&&n(t.type)}function mk(t){let e=Za(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,tR),Xa(e,t.path),_t(e,t.epoch),zo(e,t.body);break}case"awareness":{_t(e,nR),zo(e,t.body);break}case"doc-close":{_t(e,iR),Xa(e,t.path);break}case"control":{_t(e,oR),Xa(e,JSON.stringify(t.message));break}default:throw new Hg(`unknown-frame:${r}`)}return br(e)}function gk(t){try{let e=Qa(t),r=Dt(e);switch(r){case tR:{let s=el(e),i=Dt(e);return{body:Xo(e),epoch:i,path:s,type:"doc-sync"}}case nR:return{body:Xo(e),type:"awareness"};case iR:return{path:el(e),type:"doc-close"};case oR:{let s=JSON.parse(el(e));if(!Wc(s))throw new Hg("malformed-control");return{message:s,type:"control"}}default:throw new Hg(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof Hg)throw e;throw new Hg(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
+
export{pk,os,Za,fk,br,_t,Xa,zo,Qa,Xo,Dt,el,Su,rp,xd,XI,QI,eR,Q0,jg,N2,ky,va,e_,rs,t_,ss,tR,nR,iR,oR,Hg,mk,gk};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=AD65E5AE74941ADD64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-bvs9kpst.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{ft}from"./studio-9rbe2xpw.js";import{Q}from"./studio-nqxqf8p2.js";import{ae}from"./studio-b2qpt0xy.js";import{L,R,En,nt,ei}from"./studio-0w2dr0q8.js";import{g,ar,C}from"./studio-y60sts62.js";import{af,p,_e}from"./studio-jws1a87n.js";import{Ft,$h,tc,Qd,Ma,sf,fn,fl}from"./studio-hz5n7x27.js";import{Sr}from"./studio-mx6wzh25.js";import{us,Pm}from"./studio-t98vq4r6.js";import{Wt,ln,go,jm,cv,Vd,Un,fi,m,Na,Ql,ec,_i,J$,Pt,mv,Hx}from"./studio-k2sz13zg.js";import{zp,aO,lO,La}from"./studio-399a25za.js";import{rt,Eo,xr}from"./studio-th7z3fg7.js";import{Es,rA,YL,dA,ax,lx}from"./studio-2r90cts3.js";import{il}from"./studio-0q5jwddh.js";import{Xn}from"./studio-86r8hp7r.js";import{xa}from"./studio-sevbc3xv.js";import{Dp}from"./studio-8wnvtr4z.js";import{zr,Gs,Ks,Wr}from"./studio-sxdb9h3q.js";import{yw,bm,vm,xb}from"./studio-zwaxn5s2.js";import{Vc,Sa}from"./studio-f746039f.js";import{eT,oS}from"./studio-05jfwbmf.js";import{oN,jr,Cb,kb}from"./studio-qyed0ah6.js";import{Nw,xm}from"./studio-wxq6v5sv.js";import{Bt}from"./studio-r4bcdwhq.js";import{mw,gw,bw}from"./studio-mxs3ar9t.js";import{Dc}from"./studio-2ejhqns4.js";import{tS,ZE,XE,gb}from"./studio-kg5ya5r2.js";import{Ws}from"./studio-pjtntksy.js";import{S,ed,wn}from"./studio-cg710sk9.js";import{n,_}from"./studio-8z66jk4z.js";import{le}from"./studio-j3d2fjqz.js";async function pb(){if(yw(location.search))return!1;let e=p();if(!e.dependenciesNeedInstall||!e.installDependencies)return!1;let t=!1;try{t=await e.dependenciesNeedInstall()}catch{return!1}if(!t)return!1;let o=il({status:"Installing dependencies…",title:"Installing dependencies"});try{let r=await e.installDependencies();if(r.ok)return o.done(),!0;o.fail(r.log??"Install failed")}catch(r){o.fail(r instanceof Error?r.message:String(r))}return!1}var Le=["page","component"],Me={components:"component",pages:"page"};function O(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Ae(e){let t=O(e).toLowerCase();for(let[o,r]of Object.entries(Me))if(t.startsWith(`${o}/`))return r;return null}function Y(e){return Le.some((t)=>e.includes(t))}function He(e){let t=S?.projectConfig?.layout;if(!n(t))return!1;return O(t).toLowerCase()===O(e).toLowerCase()}function K_(e){let t=[{ext:".json",label:"JSON (.json)"}];for(let o of fl(e)){let r=Ma(o,"parse");if(r&&Ma(o,"serialize"))t.push({ext:o,label:`${r.name} (${o})`})}return t}function ie(){return new Set([".json",...Qd().flatMap((e)=>e.extensions)])}function J_(e){if(e===null||e===void 0||e==="")return[];let t=Ae(e);if(t===null||He(e)||Un(e))return[];let o=fn(e);if(!(o?Boolean(o.capabilities.parse)&&Y(o.documentKinds):O(e).toLowerCase().endsWith(".json")))return[];let a=[];if(o)a.push({ext:".json",label:"JSON (.json)"});for(let i of fl()){let s=Ma(i,"serialize");if(!s||s.name===o?.name||!Y(s.documentKinds)||!s.documentKinds.includes(t))continue;a.push({ext:i,label:`${s.name} (${i})`})}return a}function MD(){let e=new Set([".json"]);for(let t of Qd()){if(!t.capabilities.serialize||!Y(t.documentKinds))continue;for(let o of t.extensions)e.add(o)}return[...e].toSorted()}var X="jx-studio-recent-projects",ce="jx-studio-recent-files",se=8,We=10,E=[];function M(){if(!_e())return null;let e=p();return ze(e)?e:null}function ze(e){return Boolean(e.getRecentProjects&&e.saveRecentProjects)}function Ve(){try{let e=localStorage.getItem(X);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Z(){return M()?E:Ve()}function de(e){E=e;let t=M();if(t)t.saveRecentProjects(e);else try{localStorage.setItem(X,JSON.stringify(e))}catch{}}async function PD(){let e=M();if(!e)return;try{E=await e.getRecentProjects()}catch{E=[]}}function hw(){return Z().toSorted((e,t)=>t.timestamp-e.timestamp)}function pw(e,t){let o=Z().filter((r)=>r.root!==t);if(o.unshift({name:e,root:t,timestamp:ar()}),o.length>se)o.length=se;de(o)}function Y_(e){de(Z().filter((t)=>t.root!==e))}function FD(){E=[];let e=M();if(e)e.saveRecentProjects([]);else localStorage.removeItem(X)}function pe(){try{let e=localStorage.getItem(ce);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function jD(e){let t=pe().toSorted((o,r)=>r.timestamp-o.timestamp);return e==null?t:t.filter((o)=>o.root===e)}function fb(e){let t=pe().filter((a)=>!(a.root===e.root&&a.path===e.path));t.unshift({name:e.name,path:e.path,root:e.root,timestamp:ar()});let o=new Map,r=[];for(let a of t.toSorted((i,s)=>s.timestamp-i.timestamp)){let i=(o.get(a.root)??0)+1;if(o.set(a.root,i),i<=We)r.push(a)}localStorage.setItem(ce,JSON.stringify(r))}var ue={$schema:"https://jxsuite.com/schema/v1",$id:"StudioFilesPanel",$description:'The Navigator\'s Files tree, as a Jx document over the kit. `files/files.ts` keeps every decision — which directories are listed, which entries `.gitignore` masks, which rows the window draws, what a click on a row means, what the context menu offers and what each verb does to the filesystem — and hands this document one projection: a word saying which of three things to draw, a toolbar whose state is already resolved, and rows whose every field is already a string. Nothing here asks what a file is, how tall the Navigator is, or whether a directory has been read. THE TREE IS `jx-tree`, and that is what this document no longer says: `role="tree"`, `role="treeitem"`, `aria-level`, `aria-posinset`, `aria-setsize`, the roving `tabindex` and the five arrow-key cases were each written out here and written out again in `panel-outline.json`, two copies of one keyboard contract with nothing holding them in agreement. The element owns all of it; what is left here is what this tree IS — a flat projection of rows, each already carrying its own level and set counts, because the DOM holds a WINDOW onto the model and an expanded `node_modules` is eleven rows rather than ten thousand. The window reaches the element as `padtop`/`padbottom`, and a caret move past either comes back as `move` for the flow to scroll and repaint. Four facts a row carries are bound against ONE scope field each — the current path, the selected path, the dragged path and the drop target — so moving the caret or dragging a file re-evaluates an attribute per drawn row instead of rebuilding the list under the reader\'s pointer. The pragmatic-drag-and-drop handles are an ISLAND: the document draws the rows and the tree, and the adapter attaches sources and targets to them through `onNodeCreated` (specs/studio-ui-guidelines.md §9.4).',tagName:"div",attributes:{part:"files"},style:{$description:"What the twenty `.file-tree*`, `.files-toolbar`, `.project-header` and `.project-name` rules in `styles/panels.css` said, keyed on `part` and re-pointed at the studio token layer. Three names could not come with the declarations. The five `var(--spectrum-font-size-50 | -75, …)` reads are the kit's `--jx-text-sm` and `--jx-text-md`, which are the same 11px and 12px — a `--spectrum-*` name is declared by `<sp-theme>` and by nothing else in this package, so a document that reads one is a document whose type size changes when a component it does not use is removed. The `.selected`, `.dragging`, `.drag-over` and `.drag-over-root` classes are `data-` attributes on a part, because a part is the handle now and because a state a handler adds and forgets to take off is exactly the defect a cancelled drag used to leave on screen. MOST OF THE ROW'S OWN RULES ARE GONE, and that is the point of the element rather than an omission: `jx-tree-item` declares the flex line, the one-control-height box the window reserves scroll by, the indent (`--jx-tree-indent` times one less than `level` — exactly the `8 + depth * 16` this file composed per row), the hover and focus states, the selected wash and the faded dragged row. What is left here is what is TRUE OF THIS TREE and not of trees in general: it owns its own scrollbar, a click on a row opens it, and the row a drag is over wears the drop mark this file draws.",display:"flex",flexDirection:"column",height:"100%",minHeight:"0",overflow:"hidden",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="empty"]':{$description:"The two states that are not a tree. They are two states and not one sentence: a window with no project at all and a monorepo root that has not been pointed at a site are different situations, and only the second has anything to offer (studio-ui-guidelines.md §11).",padding:"var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)",fontSize:"var(--jx-text-md)",display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-4)"},'& [part="empty"] p':{margin:"0"},'& [part="frame"]':{display:"flex",flexDirection:"column",height:"100%",minHeight:"0"},'& [part="project-header"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)",flexShrink:"0"},'& [part="project-name"]':{fontSize:"var(--jx-text-md)",fontWeight:"600",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="toolbar"]':{display:"flex",gap:"var(--jx-space-2)",padding:"var(--jx-space-2) var(--jx-space-3)",borderBottom:"1px solid var(--border)",alignItems:"center",flexShrink:"0"},'& [part="search"]':{flex:"1",minWidth:"0"},'& [part="tree"]':{$description:"The scroller as well as the list. `ui/virtual-window.ts` walks up from the element it is given looking for the nearest thing that scrolls, and finding itself is the shortest answer — which is why the element declares no `overflow` of its own and leaves the question to the two trees that answer it differently. The colour is re-declared because `jx-tree` sets `--jx-fg` on itself, and this panel's text colour is the studio alias of it.",flex:"1",minHeight:"0",overflowY:"auto",color:"var(--fg)"},'& [part="tree"][data-drop="true"]':{background:"var(--hover-bg)"},'& [part="row"]':{$description:"What the element does not decide. A click on a row OPENS it here — a directory unfolds, a file takes a tab — so the pointer is a pointer rather than the element's default arrow; and the gap is the wider one this tree has always drawn between a 16px file glyph and its name.",gap:"var(--jx-space-3)",cursor:"pointer"},'& [part="loading-row"]':{$description:"A directory whose listing has not arrived yet. It holds the place and it is NOT a row: it is not a `jx-tree-item`, so the caret cannot land on it, the set counts do not include it and typeahead cannot match it — and it is replaced by the real rows on the repaint the listing provokes. It draws the same box by hand because it is the only line in this tree the element does not draw, and a placeholder of a different height would desynchronise the window's scroll reservation from the rows it reserves for.",display:"flex",alignItems:"center",boxSizing:"border-box",blockSize:"var(--jx-control-h)",paddingInline:"calc(var(--jx-space-3) + var(--depth, 0) * 16px) var(--jx-space-3)",color:"var(--fg-dim)",fontStyle:"italic",cursor:"default",userSelect:"none",whiteSpace:"nowrap"},'& [part="row-icon"]':{flexShrink:"0",display:"flex",alignItems:"center","--jx-icon-size":"16px"},'& [part="locale"]':{$description:"The language chip. Deliberately declares no block size, no padding and no line height: the row above is one control-height by contract, and a chip that grew the box would desynchronise the window's scroll reservation from the height it reserves by. It only ever shrinks the text. A chip, not a filter term: the search matches the file's name alone, because a query that silently also matched a language would make “why is this file here” unanswerable from what is on screen.",marginInlineStart:"auto",flexShrink:"0",fontSize:"var(--jx-text-sm)",color:"var(--fg-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxInlineSize:"6em"},'& [part="view-slot"], & [part="header-slot"], & [part="locale-slot"]':{$description:"A `$switch` renders its own container, and none of these three is a box: each stands exactly where its case does, so the case's own rule is the only one that lays anything out.",display:"contents"}},children:[{tagName:"div",attributes:{part:"view-slot",role:"none"},$switch:{$ref:"#/state/view"},cases:{none:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"No project loaded"}]},address:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Add ?project= and a project folder's absolute path to this page's address to open it."}]},welcome:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Open a project folder to get started."},{tagName:"jx-button",attributes:{part:"open-project"},$props:{variant:"accent",size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openProject"},value:[]}],description:"The declared `project.open` command, run through the registry — not a second opener of this surface's own. It is the one the chord, the palette and the status bar's PROJECT field already run, so a window that opens a project from here reports the outcome the same way they do (studio-ui-guidelines.md §12.5)."},children:[{tagName:"span",textContent:"Open Project"}]}]},tree:{tagName:"div",attributes:{part:"frame"},children:[{tagName:"div",attributes:{part:"header-slot",role:"none"},$switch:{$ref:"#/state/headerState"},cases:{shown:{tagName:"div",attributes:{part:"project-header"},children:[{tagName:"span",attributes:{part:"project-name",title:"${state.projectName}"},textContent:"${state.projectName}"}]}}},{tagName:"div",attributes:{part:"toolbar"},children:[{$description:"A row of quiet tools, so NOT compact. A compact group draws every member's frame and fill whatever its quiet says, which is the segmented look a choice wants and not the borderless one a toolbar wants; Spectrum's group here was `compact quiet`, a combination the kit spells as compact=false with its members' default quiet.",tagName:"jx-action-group",attributes:{part:"toolbar-actions"},$props:{compact:!1,label:"File tree actions"},children:[{tagName:"jx-action-button",attributes:{part:"new-file"},$props:{size:"sm",icon:"plus",label:"New File",hint:"New File"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/newFile"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"refresh"},$props:{size:"sm",icon:"arrows-clockwise",label:"Refresh",hint:"Refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}],description:"The rules go with the listings. Refresh is what an author reaches for after editing a `.gitignore` by hand, and a tree that came back still hiding by the old rules would read as the button not having worked."}},{tagName:"jx-action-button",attributes:{part:"show-ignored"},$props:{size:"sm",icon:{$ref:"#/state/ignoredIcon"},label:{$ref:"#/state/ignoredLabel"},hint:{$ref:"#/state/ignoredLabel"},selected:{$ref:"#/state/ignoredSelected"}},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleIgnored"},value:[]}],description:"A repaint and nothing else: the ignored entries were never dropped from the cached listings, only from the rows built out of them."}}]},{tagName:"jx-textfield",attributes:{part:"search"},$props:{label:"Filter files",placeholder:"Filter files…",size:"sm",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/search"},value:[{$ref:"event#/target/value"}]}],description:"The query matches a file's NAME and nothing else. A directory is kept whatever it says, because hiding the folder a match sits in would leave the match with nowhere to be drawn."}}]},{$description:'The `role="tree"`, and everything that used to be spelled out under it. The element writes the role, the name, the roving tab stop and every row\'s `aria-level` / `aria-posinset` / `aria-setsize`, and it owns the whole ARIA keyboard: the arrows walk the drawn rows without wrapping, `Home` and `End` reach the ends of the MODEL by way of the pads, `ArrowRight` opens a directory and steps into an open one, `ArrowLeft` closes one and otherwise steps out to its parent, `Enter` activates and a printable character is typeahead. Every chord it does not own — cut, copy, paste, delete, rename — passes straight through to the flow, which is the WCAG 2.5.7 obligation this tree carries because dragging a file is the other way to move it. What reaches this document is five events, and each of them is a decision `files.ts` already owned.',tagName:"jx-tree",attributes:{part:"tree",label:"Project files",current:"${state.currentPath}",padtop:"${state.padTop}",padbottom:"${state.padBottom}","data-drop":"${state.rootDrop || null}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"event#/detail/value"}]}],description:"The reader meant that row. This tree is single-select, so the element resolves every modifier to `replace` before it gets here and the detail's `mode` and `anchor` are answers to a question this tree does not ask. There is no `change` handler beside it on purpose: the element OWNS the caret and keeps it across every repaint that does not change `current`, so a second copy of it in the flow would be a variable that only ever went stale."},onactivate:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"event#/detail"}]}],description:"`Enter` or a double click. The same verb a single click reaches, by the same name."},onexpand:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/expand"},value:[{$ref:"event#/detail/value"},{$ref:"event#/detail/expanded"}]}],description:"`ArrowRight`, `ArrowLeft` or the twisty, with ONE dispatcher between them: the detail says the state the row should be PUT INTO, so the flow never has to work out which way a toggle was going."},onmove:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/move"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/key"}]}],description:"The caret has to reach a row the window did not draw. The element knows only that the pad on that side is not zero; where the row is in the model, and how far to scroll to bring it into view, is the flow's — which is why this is an event and not a `scrollIntoView`."},ontypeahead:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/typeahead"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/char"}]}],description:"A printable character, on a windowed tree. The same hand-off as `onmove` and for a sharper reason: a move off the end of the slice announces itself, and a letter never does — the element's own search over the drawn rows always answers, and over a `node_modules` of ten thousand entries the answer is whichever of the eleven painted rows happened to start with that letter. So the element dispatches EVERY such character and the flow answers it over the model."},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"row-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/kind"},cases:{item:{tagName:"jx-tree-item",attributes:{part:"row",value:"${$map.item.path}",label:"${$map.item.name}",level:"${$map.item.level}",posinset:"${$map.item.posInSet}",setsize:"${$map.item.setSize}",expanded:"${$map.item.ariaExpanded}",selected:"${state.selectedPath === $map.item.path ? 'true' : 'false'}","data-type":"${$map.item.type}","data-dragging":"${state.dragPath === $map.item.path ? '' : null}","data-drop":"${state.dropPath === $map.item.path ? '' : null}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/path"}]}],description:"A single click OPENS the row, which is this tree's own answer and not the element's. `jx-tree` answers a click with `change` and `select`, exactly as it answers an arrow key, and a tree that opened on `select` would open every file the reader arrowed past. So the opening verb is bound here, where a click is a click; what a click MEANS — unfold this directory, take a tab for that file — stays the flow's, and Enter reaches the same verb through `activate`. It does NOT stop the event, which is the correction: the tree's delegated click is what moves the caret and the selection onto the row, so a `stopPropagation` here would leave a reader who clicked a folder with the tab stop still on whatever they had open last. The twisty stops its own click, so opening a directory from the chevron does not also activate the row."},oncontextmenu:{$prototype:"Function",body:[{preventDefault:!0},{stopPropagation:!0},{operator:"call",target:{$ref:"#/state/contextMenu"},value:[{$ref:"$map/item/path"},{$ref:"event#/clientX"},{$ref:"event#/clientY"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon",part:"row-icon","aria-hidden":"true"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"div",attributes:{slot:"status",part:"locale-slot",role:"none"},$switch:{$ref:"$map/item/localeState"},cases:{shown:{tagName:"span",attributes:{part:"locale"},textContent:"${$map.item.locale}"}}}]},loading:{$description:"A directory whose listing has not arrived yet. Deliberately not a `jx-tree-item`: there is no file there to select, open, rename or drag, and a row the caret could land on that answers to none of the verbs the caret offers is a stop in the walk with nothing behind it.",tagName:"div",attributes:{part:"loading-row",role:"none","data-loading":"true",style:"--depth:${$map.item.depth}"},textContent:"Loading…"}}}}]}]}}}]};L("files-panel",ue);function fe(e,t){e.view=t.view,e.headerState=t.headerState,e.projectName=t.projectName,e.query=t.query,e.ignoredLabel=t.ignoredLabel,e.ignoredIcon=t.ignoredIcon,e.ignoredSelected=t.ignoredSelected,e.padTop=t.padTop,e.padBottom=t.padBottom,e.rows=t.rows,e.selectedPath=t.selectedPath,e.dragPath=t.dragPath,e.dropPath=t.dropPath,e.rootDrop=t.rootDrop,e.currentPath=t.currentPath}function A(){return{currentPath:"",dragPath:"",dropPath:"",headerState:"hidden",ignoredIcon:"eye-slash",ignoredLabel:"Show ignored files",ignoredSelected:!1,padBottom:0,padTop:0,projectName:"",query:"",rootDrop:"",rows:[],selectedPath:"",view:"none"}}function qe(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function Be(e){let t=e?.$map,o=_(t)&&"item"in t?t.item:void 0;if(!_(o)||!("path"in o)||!n(o.path)||!("type"in o)||!n(o.type))return null;return{path:o.path,type:o.type}}function me(e,t,o){let r=g({...A(),...o});fe(r,t);let a=null,i=!1,s=R("files-panel",r,e,{onNodeCreated:(l,c,u,d)=>{if(i||!(l instanceof HTMLElement))return;let b=qe(u);if(b==="tree"){o.treeHost(l);return}if(b!=="row")return;let v=Be(d);if(v)o.rowHost(l,v.path,v.type)}}).then((l)=>{if(i){l.dispose();return}a=l});return{connected:()=>!i&&(a===null||a.root.parentNode===e),dispose(){i=!0,a?.dispose(),a=null},ready:s,update:(l)=>{fe(r,l)}}}async function zs(e){if(!S)return;try{let t=p(),[o]=await Promise.all([us(()=>t.listDirectory(e)),aO(e)]);S.dirs.set(e,o)}catch{S.dirs.set(e,[])}}var he=new Set(["pages","layouts","components","content","data","public","styles"]);async function mm(){if(!S)return;await zs(".");let e=[];for(let t of S.dirs.get(".")??[])if(t.type==="directory"&&he.has(t.name))e.push(t.name),S.expanded.add(t.path||t.name),await zs(t.path||t.name);S.projectDirs=e}async function FE(e){let t=new Set(S?.projectDirs);if(!e.some((r)=>{let a=r.replaceAll("\\","/").replace(/^\.\//,"").split("/")[0]??"";return r.includes("/")&&he.has(a)&&!t.has(a)}))return!1;return await mm(),!0}function jE(){return Eo(rt.showIgnoredFiles)==="true"}function M2(e){xr(rt.showIgnoredFiles,e?"true":"")}async function HE(){try{let e=p(),t=await e.probeRootProject();if(!t)return;let{meta:o,info:r}=t;if($h(),Ft(),tc(e),zp(),Pm(),ed({dirs:new Map,expanded:new Set,isSiteProject:r.isSiteProject,name:r.isSiteProject?r.projectConfig?.name||o.name:o.name,projectConfig:(r.isSiteProject?r.projectConfig:null)||null,projectDirs:r.directories||[],projectRoot:".",root:o.root,searchQuery:"",selectedPath:null}),r.isSiteProject)ec(o.root||".",r.projectConfig||null);if(r.isSiteProject){if(pw(wn().name,o.root),await vm(),await pb())$h(),await Ft(),tc(e);await mm(),await xa(),await mb(),bm(o.root)}}catch{}}async function BE({renderLeftPanel:e,resetProjectCaches:t}){try{let o=p(),r=await o.openProject?.();if(!r)return!1;let{config:a,handle:i}=r;if(J$({document:{children:[],tagName:"div"},id:"initial"}),oN(),$h(),Ft(),tc(o),zp(),Pm(),ed({...S,dirs:new Map,expanded:new Set,isSiteProject:!0,name:a.name||i.name,projectConfig:a,projectRoot:i.root,searchQuery:"",selectedPath:null}),ec(i.root,a),await vm(),await pb())$h(),await Ft(),tc(o);return await mm(),await xa(),xb(),lx(),t?.(),pw(wn().name,wn().projectRoot),e(),await mb(),bm(wn().projectRoot),!0}catch(o){return C.error("Could not open the project.",{detail:Q(o),source:"Open Project"}),!1}}async function zE(e){let t=p();if(t.createDestination!=="path")return!1;try{if(await t.activate(e),(await t.gitStatus()).isRepo)return!1;return await t.gitInit(),C.success("Initialized a git repository for this project."),!0}catch(o){return C.warn("Could not initialize a git repository — the project itself was written.",{detail:Q(o),source:"Source Control"}),!1}}async function Z_(){await Ft();let e=[...fl("page"),".json"],t;try{t=await p().listDirectory("pages")}catch{return null}let o=new Set(t.filter((r)=>r.type==="file").map((r)=>r.name));for(let r of e)if(o.has(`index${r}`))return`pages/index${r}`;return null}async function P2(){let e=await Z_();if(e)await xi(e)}async function mb(){let e=dA(m.projectRoot),t=YL(m.projectRoot),o=await Ue(e);return ge?.(t),o}var ge=null;function WE(e){ge=e}async function Ue(e){if(ax(m.projectRoot),e){if(await rA(e,{ensureSecondPane:()=>{Ql(fi)},openFile:(o,r)=>xi(o,{focus:!1,paneId:r})})>0)return!0}return await P2(),!1}function Ge(e,t,o){if(t==="directory")return o?"folder-open":"folder";let r=e.split(".").pop()?.toLowerCase();switch(r){case"css":case"js":case"json":case"ts":return"file-code";case"md":return"file-text";default:return r!==void 0&&Dp(r)?"image":"file"}}var F2=24,f=[],k=null,F=new Map,z=null,we=null;function ne(){for(let e of F.values())if(e.isConnected&&e.offsetHeight>0)return e.offsetHeight;return F2}function Ke(){for(let[e,t]of F)if(!t.isConnected)F.delete(e),$e(t)}function ve(e){let t=F.get(e);return t?.isConnected===!0?t:null}function U(e){return f.find((t)=>!t.loading&&t.path===e)}function ye(e,t,o,r){let a=wn().dirs.get(e);if(!a){zs(e).then(()=>h()),o.push({depth:t,expanded:!1,key:`loading:${e}`,loading:!0,name:"Loading…",path:e,posInSet:1,setSize:1,type:"file"});return}let i=[...a].toSorted((u,d)=>{if(u.type==="directory"&&d.type!=="directory")return-1;if(u.type!=="directory"&&d.type==="directory")return 1;return u.name.localeCompare(d.name)}),s=jE()?i:i.filter((u)=>!lO(e,u.path,u.type==="directory")),l=wn().searchQuery.toLowerCase(),c=l?s.filter((u)=>u.type==="directory"||u.name.toLowerCase().includes(l)):s;for(let[u,d]of c.entries()){let v=d.type==="directory"&&wn().expanded.has(d.path);if(o.push({depth:t,expanded:v,key:d.path,loading:!1,name:d.name,path:d.path,locale:go(d.path,r)??void 0,posInSet:u+1,setSize:c.length,type:d.type}),v)ye(d.path,t+1,o,r)}}function be(e){return e===void 0?-1:f.findIndex((t)=>!t.loading&&t.path===e)}function H(e,t){for(let o=e+t;o>=0&&o<f.length;o+=t)if(!f[o].loading)return o;return-1}function Ye(e){let t=f[e];if(!t)return-1;for(let o=e-1;o>=0;o--){let r=f[o];if(!r.loading&&r.depth<t.depth)return o}return-1}function Qe(){if(k?.isConnected!==!0||j!=="")return;queueMicrotask(h)}function te(){let e=k;if(e===null)return;z=bw(z,e,{count:()=>f.length,onChange:Qe,rowHeight:ne})}function Xe(e){let t=String(e.depth+1);if(e.loading)return{ariaExpanded:"",depth:String(e.depth),icon:"",key:e.key,kind:"loading",level:t,locale:"",localeState:"hidden",name:e.name,path:e.path,posInSet:"",setSize:"",type:e.type};return{ariaExpanded:e.type==="directory"?String(e.expanded):"",depth:String(e.depth),icon:Ge(e.path,e.type,e.expanded),key:e.key,kind:"item",level:t,locale:e.locale===void 0?"":Wt(e.locale),localeState:e.locale===void 0?"hidden":"shown",name:e.name,path:e.path,posInSet:String(e.posInSet),setSize:String(e.setSize),type:e.type}}function Ze(){if(Ke(),!S){f=[];let l={...A(),view:"none"};return y=l,l}if(!S.isSiteProject&&S.projectRoot==="."){f=[];let l=af(p())?"welcome":"address",c={...A(),view:l};return y=c,c}let e=wn();f=[];let{i18n:t}=ln(e.projectConfig??{});ye(".",0,f,t);let o=mw(k,{count:f.length,rowHeight:ne()}),r=f.slice(o.start,o.end),a=(e.selectedPath!==null&&U(e.selectedPath)?e.selectedPath:"")||r.find((l)=>!l.loading)?.path||"",i=jE(),s={currentPath:a,dragPath:j,dropPath:D,headerState:e.isSiteProject?"shown":"hidden",ignoredIcon:i?"eye":"eye-slash",ignoredLabel:i?"Hide ignored files":"Show ignored files",ignoredSelected:i,padBottom:o.padBottom,padTop:o.padTop,projectName:e.projectConfig?.name||e.name,query:e.searchQuery,rootDrop:G,rows:r.map((l)=>Xe(l)),selectedPath:e.selectedPath??"",view:"tree"};return y=s,s}function oe(){if(!w||!y)return;y={...y,dragPath:j,dropPath:D,rootDrop:G},w.handle.update(y)}function h(){we?.()}async function et(){let e=wn();e.dirs.clear(),zp(),await zs(".");for(let t of e.expanded)await zs(t);h()}function tt(e){let t=U(e);if(!t)return;if(t.type==="directory"){Fe(e).then(()=>h());return}xi(e)}function ot(e,t){let o=wn();if(U(e)?.type!=="directory"||o.expanded.has(e)===t)return;if(!t){o.expanded.delete(e),h();return}Fe(e).then(()=>h())}function xe(e){if(!S||wn().selectedPath===e)return;wn().selectedPath=e,h()}function at(e,t){let o=be(e),r;switch(t){case"Home":{r=H(-1,1);break}case"End":{r=H(f.length,-1);break}case"ArrowUp":{r=H(o,-1);break}case"ArrowLeft":{r=Ye(o);break}case"ArrowDown":case"ArrowRight":{r=H(o,1);break}default:return}Pe(r)}function it(e,t){let o=be(e),r=f.length;for(let a=1;a<=r;a++){let i=(o+a+r)%r,s=f[i];if(s&&!s.loading&&s.name.trim().toLowerCase().startsWith(t)){Pe(i);return}}}function Pe(e){let t=f[e];if(!t)return;if(xe(t.path),ve(t.path))return;gw(k,e,ne()),h()}async function Fe(e){let t=wn();if(t.expanded.has(e)){t.expanded.delete(e);return}if(t.expanded.add(e),!t.dirs.has(e))await zs(e)}var N=new Map,V=null,j="",J="",D="",q=!1,G="";function j2(e){return[...e.dataTransfer?.types??[]].includes("Files")}function je(e,t,o){let r=(s)=>{if(!j2(s))return;if(s.preventDefault(),s.stopPropagation(),s.dataTransfer)s.dataTransfer.dropEffect="copy";o(!0)},a=()=>o(!1),i=(s)=>{o(!1);let l=s.dataTransfer?.files;if(!l?.length)return;s.preventDefault(),s.stopPropagation(),HD(l,t,h)};return e.addEventListener("dragover",r),e.addEventListener("dragleave",a),e.addEventListener("drop",i),()=>{e.removeEventListener("dragover",r),e.removeEventListener("dragleave",a),e.removeEventListener("drop",i)}}function VE(e,t){let o=e.replaceAll("\\","/"),r=t.replaceAll("\\","/");if(!o||o===r)return!1;if(o.startsWith(`${r}/`)||r.startsWith(`${o}/`))return!1;return B(o)!==r}function ee(e,t,o){let r=e.data.path;return o==="directory"&&n(r)&&VE(r,t)}function P(e,t){let o=t?e:"";if(J===e&&D===o)return;J=e,D=o,Se()}function W(e){if(q===e)return;q=e,Se()}function Se(){G=q&&J===""?"true":"",oe()}async function HD(e,t,o){if((await Sa([...e],{dir:t})).length===0)return;if(t!==".")wn().expanded.add(t);o()}function H2(e,t){let o=document.createElement("input");o.type="file",o.multiple=!0,o.accept=Vc(),o.addEventListener("change",()=>{if(o.files?.length)HD(o.files,e,t)}),o.click()}function st(e,t,o){$e(e),F.set(t,e);let r=[Wr({element:e,getInitialData(){return{entryType:o,path:t,type:"file-tree"}},onDragStart(){j=t,oe()},onDrop(){j="",P("",!1),oe()}}),je(e,o==="directory"?t:B(t),(a)=>{P(a?t:"",a)}),Gs({canDrop({source:a}){return a.data.type==="file-tree"},element:e,getData({source:a}){return ee(a,t,o)?{targetDir:t,type:"file-tree-target"}:{type:"file-tree-refused"}},onDrag({source:a}){P(t,ee(a,t,o))},onDragEnter({source:a}){P(t,ee(a,t,o))},onDragLeave(){P("",!1)},onDrop(){P("",!1)}})];N.set(e,zr(...r))}function $e(e){let t=N.get(e);if(t)t(),N.delete(e)}function lt(e){if(V?.element===e)return;Re(),k=e;let t=Gs({canDrop({source:r}){let a=r.data.path;return r.data.type==="file-tree"&&n(a)&&VE(a,".")},element:e,getData(){return{targetDir:".",type:"file-tree-target"}},onDragEnter(){W(!0)},onDragLeave(){W(!1)},onDrop(){W(!1)}}),o=Ks({onDrop({source:r,location:a}){let[i]=a.current.dropTargets;if(!i)return;if(r.data.type!=="file-tree")return;if(i.data.type!=="file-tree-target")return;let s=r.data.path,l=i.data.targetDir;if(!n(s)||!n(l)||!VE(s,l))return;let c=s.split("/").pop(),u=l==="."?c:`${l}/${c}`;ct(s,u,h)}});V={cleanup:zr(t,o,je(e,".",W)),element:e},te()}function Re(){V?.cleanup(),V=null;for(let e of N.values())e();N.clear(),z?.window.destroy(),z=null,k=null,j="",J="",D="",q=!1,G=""}async function ct(e,t,o){let r=p();La(e,t);try{let a=await r.renameFile(e,t);Sr();for(let[l]of m.tabs.entries())if(l===e)Hx(e,t,t);else if(l.startsWith(`${e}/`)){let c=t+l.slice(e.length);Hx(l,c,c)}let i=B(e),s=B(t);if(await zs(i),s!==i)await zs(s);if(s!==".")wn().expanded.add(s);Te(a,t),o(),BD(`Moved to ${t}`,a,t)}catch(a){C.error(`Could not move ${e}.`,{detail:Q(a),path:e,source:"Files"})}}function B(e){let t=e.replaceAll("\\","/"),o=t.lastIndexOf("/");return o===-1?".":t.slice(0,o)}var T=null;function ke(){T?.close(),T=null}function dt(e){let t={};if(e.type==="directory"){let o=Vd(e.path);if(o?.isSourceRoot===!0&&!o.fileBacked)t.name=o.name;return t}if(t.file=e.path,Dc(e.path))t.path=e.path;if(J_(e.path).length>0)t.source=e.path;return t}function x(e,t,o,r={}){return{destructive:!1,disabled:!1,dividerAbove:!1,id:e,run:o,title:t,...r}}function pt(e){let t=ae();if(!t)return[];let o=dt(e),r=[];for(let a of t.forPlacement("context/file")){let i=a.args;if(!(i?.required??[]).every((c)=>(c in o)))continue;let s={};for(let c of Object.keys(i?.properties??{}))if(c in o)s[c]=o[c];let l=t.disabledReason(a.id);r.push(l===void 0?x(a.id,a.title,()=>{En(t,a.id,s,"Files")}):{destructive:!1,disabled:!0,dividerAbove:!1,id:a.id,requires:l,title:a.title})}return r}function ut(e){let t=e.type==="directory",o=[];if(t){if(o.push(x("files.newFile","New File…",()=>{Ee(e.path,h)}),x("files.upload","Upload Files…",()=>{H2(e.path,h)})),e.path==="pages"||e.path.endsWith("/pages"))o.push(x("files.pagesGrid","Edit Pages in Grid",()=>{oS()}))}else o.push(x("files.open","Open",()=>{xi(e.path)}));return o.push(...pt(e),x("files.rename","Rename…",()=>{bt(e,h)},{dividerAbove:!0}),x("files.delete","Delete",()=>{xt(e,h)},{destructive:!0})),o}function mt(e,t,o){let r=U(e);if(!r)return;ke();let a=ve(e);T=Bt({label:"File actions",onClosed:(i)=>{if(T===i)T=null},opener:a,origin:{x:t,y:o},region:"files",rows:ut({name:r.name,path:r.path,type:r.type})})}var ht=JSON.stringify({children:[{children:[],tagName:"p"}],tagName:"div"},null,2);function gt(e){return[...(e.kind==="locked"?[{ext:e.ext,label:`${Ma(e.ext)?.name??e.ext} (${e.ext})`}]:K_(e.docKind)).map((o)=>({label:o.label,value:o.ext})),{dividerBefore:!0,label:"Other…",value:tS}]}function wt(e,t,o){let r=e.kind==="choose"?e.defaultExt:e.ext;if(r!==void 0&&t.some((i)=>i.value===r))return r;let a=ZE(o);if(a!==""&&t.some((i)=>i.value===a))return a;return t[0]?.value??tS}async function B2(e){let{dir:t,format:o,source:r="Files"}=e;await Ft();let a=await fw(t),i=o!==void 0&&o.kind!=="fixed"?o:null,s=i===null?null:gt(i),l=i===null||s===null?"":wt(i,s,e.suggestedName??""),c={choice:o,dir:t,known:ie(),rows:s,taken:a},u=(K,Oe)=>gb(K,Oe,c),d=l,b={confirmLabel:"Create",message:t==="."?"Creating in the project root.":`Creating in ${t}/`,select:s===null?"stem":"all",validate:u,value:e.suggestedName??"untitled.json"};if(s!==null)b.choice={initial:l,label:"Format",onChange:(K)=>{d=K},options:()=>s};if(e.suggestedName!==void 0)b.placeholder=e.suggestedName;let v=await ei(e.title??"New File",b);if(!v)return null;let I=XE(v,d,o),Ne=t==="."?I:`${t}/${I}`,re=fn(I),De=e.content,Ie=o!==void 0&&d!==tS,Ce=De??re?.studio?.newFileTemplate??(re?"":I.toLowerCase().endsWith(".json")?Ie?ht:`{}
|
|
2
|
+
`:"");return X_(Ne,Ce,{dir:t,source:r})}async function fw(e){try{let t=await p().listDirectory(e);return new Set(t.map((o)=>o.name.toLowerCase()))}catch{return new Set}}async function X_(e,t,o={}){let r=o.dir??(e.includes("/")?e.slice(0,e.lastIndexOf("/")):".");La(e);try{if(await p().writeFile(e,t),await zs(r),o.quiet!==!0)C.success(`Created ${e}`);return e}catch(a){return C.error(`Could not create ${e}.`,{detail:Q(a),path:e,source:o.source??"Files"}),null}}async function Ee(e,t){await Ft();let o=Vd(e);if(o?.unresolvedFormat!=null)C.error(`New files in ${e}/ cannot be constrained to the collection's format.`,{detail:`The "${o.name}" content type declares format "${o.unresolvedFormat}", which no installed extension provides. Install the extension that supplies it, or correct `+"the name in Project Settings › Content Types.",path:e,source:"Files"});let r=o?.ext!=null&&o.unresolvedFormat===null,a=r&&o.isSourceRoot&&o.def.schema!==void 0,i;if(a){let{createEntry:s}=await (le("kmt02crp"),import("./entry-commands-kmt02crp.js"));i=await s(o.name,{dir:e})}else i=await B2({dir:e,format:r&&o.ext!==null?{because:`${o.name} entries are ${o.ext} files, so a document of another format here would not be one.`,ext:o.ext,kind:"locked"}:{defaultExt:".json",kind:"choose"},suggestedName:"untitled"});if(i!==null)t()}async function vt(e,t){let o=await kb(t),r={confirmLabel:"Rename",select:"stem",validate:(a)=>a.trim()?"":"Enter a file name.",value:e};if(o!==void 0)r.message=o;return ei("Rename",r)}function yt(e,t){let o=t.references,r=t.tag?`; tag → <${t.tag.to}> (${t.tag.refsUpdated})`:"";if(o&&o.refsUpdated>0)return`Renamed to ${e}; updated ${o.refsUpdated} reference(s) in ${o.filesChanged} file(s)${r}`;if(r)return`Renamed to ${e}${r}`;return`Renamed to ${e}`}function BD(e,t,o){let r=t.errors??[];if(r.length===0){C.success(e);return}let a=r.length===1?"1 file":`${r.length} files`;C.warn(`${e} — references in ${a} could not be updated`,{detail:r.map((i)=>`${i.path}: ${i.error}`).join(`
|
|
3
|
+
`),path:o,source:"Files"})}function Te(e,t){for(let o of e.references?.files??[])if(o.path!==t&&m.tabs.has(o.path))gm(o.path)}function UE(e){let t=e.replaceAll("\\","/");return t.includes("/")?t.slice(0,t.lastIndexOf("/")):"."}async function z2(e,t,o){Sr();let r=UE(e),a=UE(t);if(await zs(r),a!==r)await zs(a);if(wn().selectedPath===e)wn().selectedPath=t;Te(o,t)}async function bt(e,t){let o=await vt(e.name,e.path);if(!o||o===e.name)return;let r=UE(e.path),a=r==="."?o:`${r}/${o}`;La(e.path,a);try{let s=await p().renameFile(e.path,a);if(m.tabs.has(e.path))Hx(e.path,a,a);await z2(e.path,a,s),t(),BD(yt(o,s),s,a)}catch(i){C.error(`Could not rename ${e.name}.`,{detail:Q(i),path:e.path,source:"Files"})}}async function xt(e,t){if(!await Cb(e))return;try{let r=p();La(e.path),await r.deleteFile(e.path),Sr();let a=e.path.replaceAll("\\","/"),i=a.includes("/")?a.slice(0,a.lastIndexOf("/")):".";if(await zs(i),wn().selectedPath===e.path)wn().selectedPath=null;t(),C.success(`Deleted ${e.name}`)}catch(r){C.error(`Could not delete ${e.name}.`,{detail:Q(r),path:e.path,source:"Files"})}}function jt(e,t){let o=t.paneId,r=Na(e);if(o!==void 0&&r){if(r.activeTabId===e&&t.focus===!1)return;mv(e,o)}Pt(e,{focus:t.focus!==!1})}async function xi(e,t={}){let o=t.focus!==!1;for(let[a,i]of m.tabs.entries())if(i.documentPath===e){if(t.canvasMode!==void 0)i.session.ui.canvasMode=t.canvasMode;if(jt(a,t),o)wn().selectedPath=e;return}if(Nw(e)){if(xm(e,t),o)wn().selectedPath=e;fb({name:e.split("/").pop()||e,path:e,root:wn().projectRoot});return}if(e.toLowerCase().endsWith(".csv")){try{if(await eT(e,t),o)wn().selectedPath=e;fb({name:e.split("/").pop()||e,path:e,root:wn().projectRoot})}catch(a){C.error(`Could not open ${e}.`,{detail:Q(a),path:e,source:"Open File"})}return}let r=p();try{let a=await r.readFile(e);if(!a){if(await Ft(),!fn(e)&&!e.toLowerCase().endsWith(".json"))throw sf(e);return}await Ft();let i,s,l=null,c=fn(e);if(c){let d=await jr(e,a);({document:i}=d),{frontmatter:s}=d}else if(e.endsWith(".json"))({document:i,layout:l}=Es(a));else throw sf(e);if(_i({id:e,documentPath:e,document:i,...s!=null&&{frontmatter:s},layout:l,source:c?a:null,sourceFormat:c?.name??null,...t.paneId!==void 0&&{paneId:t.paneId},...t.preview===!0&&{preview:!0},...t.focus===!1&&{focus:!1},...t.canvasMode!==void 0&&{canvasMode:t.canvasMode}}),o)wn().selectedPath=e;fb({name:e.split("/").pop()||e,path:e,root:wn().projectRoot})}catch(a){C.error(`Could not open ${e}.`,{detail:Q(a),path:e,source:"Open File"})}}async function Q_(e,t){await xi(t,{focus:!1,paneId:e,preview:!0})}function qE(e){if(cv(e))return;for(let[,t]of m.tabs.entries())if(t.documentPath===e&&!t.doc.dirty){gm(e);return}}function GE(e){for(let t of e)gm(t,{onlyIfChanged:!0})}async function gm(e,t={}){for(let[,o]of m.tabs.entries())if(o.documentPath===e){let r=p(),a=o.doc.dirty,i=()=>!a&&o.doc.dirty||cv(e);try{let s=await r.readFile(e);if(!s)return;if(await Ft(),i())return;if(fn(e)){let{document:l,frontmatter:c}=await jr(e,s);if(i())return;if(t.onlyIfChanged&&Ws(l,o.doc.document)&&Ws(c,o.doc.content.frontmatter))return;o.doc.document=l,o.doc.content.frontmatter=c,o.doc.source=s}else if(e.endsWith(".json")){let l=Es(s);o.doc.layout=l.layout;let c=l.document;if(o.doc.bareRepeaters=jm(c),t.onlyIfChanged&&Ws(c,o.doc.document))return;o.doc.document=c}o.doc.dirty=!1}catch(s){C.error(`Could not reload ${e} after it changed on disk.`,{detail:Q(s),key:`reload:${e}`,path:e,source:"Files"})}return}}function KE(){Xn({id:"files",title:"Files",level:"project",dock:"navigator",icon:"folder",rail:"developer",render:()=>ft,afterRender:(e,t)=>{W2(t,e.rerender)}})}var St={activate:tt,contextMenu:mt,expand:ot,move:at,newFile:()=>{Ee(".",h)},openProject:()=>{nt("project.open",void 0,"Files")},refresh:()=>{et()},rowHost:st,search:(e)=>{wn().searchQuery=e,h()},select:xe,toggleIgnored:()=>{M2(!jE()),h()},treeHost:lt,typeahead:it},w=null,y=null;function W2(e,t){let o=e.querySelector(".panel-content")??e;if(we=t,w&&(w.host!==o||!w.handle.connected()))V2();let r=Ze();if(w)w.handle.update(r);else{let a=me(o,r,St);w={handle:a,host:o},a.ready.then(te)}queueMicrotask(te)}function V2(){ke(),w?.handle.dispose(),w=null,y=null,Re(),F.clear(),f=[]}
|
|
4
|
+
export{pb,K_,J_,MD,PD,hw,pw,Y_,FD,jD,fb,zs,mm,FE,jE,M2,HE,BE,zE,Z_,P2,mb,WE,F2,j2,VE,HD,H2,B2,fw,X_,BD,UE,z2,xi,Q_,qE,GE,gm,KE,W2,V2};
|
|
5
|
+
|
|
6
|
+
//# debugId=4E7E7D34CE9A8F6C64756E2164756E21
|
|
7
|
+
//# sourceMappingURL=studio-c71806xz.js.map
|