@jxsuite/studio 5.6.0 → 6.0.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-zvax9fmb.js → 2020-cs2sb9t1.js} +3 -3
- package/dist/chunks/adapter-y5gdq19c.js +4 -0
- package/dist/chunks/{cf-account-picker-zfycs4k2.js → cf-account-picker-bb2yq946.js} +3 -3
- package/dist/chunks/cf-settings-20dznc3j.js +4 -0
- package/dist/chunks/components-q037dya7.js +4 -0
- package/dist/chunks/content-source-t0q184js.js +4 -0
- package/dist/chunks/{convert-to-repeater-x19jr6c7.js → convert-to-repeater-vqkt7s3s.js} +3 -3
- package/dist/chunks/editor-j5sq149q.js +4 -0
- package/dist/chunks/entry-commands-fxzgcc4k.js +4 -0
- package/dist/chunks/{extension-sections-y90sa0n4.js → extension-sections-8beq9ac3.js} +3 -3
- package/dist/chunks/file-ops-2n77759h.js +4 -0
- package/dist/chunks/files-fjy7zpxt.js +4 -0
- package/dist/chunks/format-host-wj3mf3n8.js +4 -0
- package/dist/chunks/fs-events-7kcgn4e9.js +4 -0
- package/dist/chunks/git-panel-7z2mpt2d.js +4 -0
- package/dist/chunks/{grid-view-d9mybhn0.js → grid-view-ca10def6.js} +10 -10
- package/dist/chunks/iframe-host-a0zjd6xp.js +4 -0
- package/dist/chunks/{index-vnwy9d44.js → index-9ydfe04y.js} +3 -3
- package/dist/chunks/index-m0x5ztax.js +4 -0
- package/dist/chunks/{javascript-f0nrbdjb.js → javascript-d9pqgc2p.js} +2 -2
- package/dist/chunks/{jsonMode-nfa90dtf.js → jsonMode-800yvbem.js} +4 -4
- package/dist/chunks/jx-validate-zc9zp77s.js +4 -0
- package/dist/chunks/layers-p677nrh5.js +4 -0
- package/dist/chunks/layers-panel-y4w1dq90.js +4 -0
- package/dist/chunks/lit-html-cfn61dn7.js +4 -0
- package/dist/chunks/media-picker-xg7yjpz9.js +4 -0
- package/dist/chunks/menu-fpekzj6w.js +4 -0
- package/dist/chunks/{monaco-binding-antn79jf.js → monaco-binding-62dtmgbf.js} +3 -3
- package/dist/chunks/monaco-buffer-nn4dtx27.js +4 -0
- package/dist/chunks/{monaco-setup-k8s40vwg.js → monaco-setup-tj13ndtm.js} +3 -3
- package/dist/chunks/notify-ahs57a2z.js +4 -0
- package/dist/chunks/platform-v9xyfkbx.js +4 -0
- package/dist/chunks/publish-panel-xtbfgg2r.js +4 -0
- package/dist/chunks/quick-search-d3a6m7j3.js +4 -0
- package/dist/chunks/references-99ws0b0m.js +4 -0
- package/dist/chunks/right-panel-31vbk5xp.js +4 -0
- package/dist/chunks/section-registry-b2yzp9sw.js +4 -0
- package/dist/chunks/{studio-y17505ge.js → studio-01kbbqg3.js} +207 -207
- package/dist/chunks/{studio-gxna6yta.js → studio-01qza1n3.js} +4 -4
- package/dist/chunks/{studio-n2e133d6.js → studio-03wwfvyt.js} +4 -4
- package/dist/chunks/{studio-09n3fyy0.js → studio-0bbxhhce.js} +4 -4
- package/dist/chunks/studio-1a99w39s.js +5 -0
- package/dist/chunks/studio-1q6amtph.js +5 -0
- package/dist/chunks/{studio-eegyf5vg.js → studio-1wvfxkyy.js} +4 -4
- package/dist/chunks/{studio-z47mm077.js → studio-3ck2a5c4.js} +6 -6
- package/dist/chunks/{studio-ymsjnvp9.js → studio-4fde4a0x.js} +4 -4
- package/dist/chunks/{studio-je15p5v8.js → studio-4jj9gme2.js} +5 -5
- package/dist/chunks/{studio-w8w9frjy.js → studio-4m50vh74.js} +12 -12
- package/dist/chunks/{studio-891t1tv9.js → studio-4r0sjtx8.js} +4 -4
- package/dist/chunks/{studio-6exg5z4x.js → studio-4xppwncr.js} +3 -3
- package/dist/chunks/{studio-011em5cf.js → studio-5d7wfmnp.js} +4 -4
- package/dist/chunks/{studio-zkkdbbvd.js → studio-5e9zsamh.js} +6 -6
- package/dist/chunks/{studio-pvj970st.js → studio-5gs9th4b.js} +4 -4
- package/dist/chunks/{studio-dtmdjmqb.js → studio-5vy2wfm5.js} +4 -4
- package/dist/chunks/{studio-654fxcr0.js → studio-7pgy3xaf.js} +4 -4
- package/dist/chunks/{studio-z1vdxq0e.js → studio-7qvs7v0m.js} +4 -4
- package/dist/chunks/studio-84rtc120.js +5 -0
- package/dist/chunks/{studio-ks0ecgjx.js → studio-8xcwewjq.js} +4 -4
- package/dist/chunks/{studio-sadckcpp.js → studio-aekhcdzw.js} +5 -5
- package/dist/chunks/{studio-mf41717j.js → studio-aje966s9.js} +4 -4
- package/dist/chunks/studio-aqmph6k4.js +5 -0
- package/dist/chunks/{studio-28pz4s1k.js → studio-bftp4n4b.js} +4 -4
- package/dist/chunks/{studio-tzs6njnb.js → studio-c6zdm25z.js} +7 -7
- package/dist/chunks/{studio-sgzss898.js → studio-capk0583.js} +7 -7
- package/dist/chunks/{studio-805fwp9k.js → studio-cbr9czkn.js} +4 -4
- package/dist/chunks/{studio-1pxvgx1t.js → studio-chdmwwzw.js} +4 -4
- package/dist/chunks/{studio-dknr8m7b.js → studio-cp1gbff9.js} +7 -7
- package/dist/chunks/{studio-ft8pfpp0.js → studio-cqmtbg2p.js} +4 -4
- package/dist/chunks/studio-e47215hh.js +5 -0
- package/dist/chunks/{studio-9n2j9nqk.js → studio-edbtvcd1.js} +4 -4
- package/dist/chunks/{studio-mm8x32gg.js → studio-evwgp1ym.js} +4 -4
- package/dist/chunks/{studio-02y9cb4h.js → studio-fbx6twps.js} +5 -5
- package/dist/chunks/{studio-0nm2skex.js → studio-fqq890ap.js} +3 -3
- package/dist/chunks/studio-fthwn4kf.js +5 -0
- package/dist/chunks/{studio-s85vah66.js → studio-g8dsj3d2.js} +5 -5
- package/dist/chunks/{studio-0c3fpdqj.js → studio-ge5fqjth.js} +5 -5
- package/dist/chunks/{studio-ebt49j3c.js → studio-gjknvzam.js} +5 -5
- package/dist/chunks/{studio-zkvyd3ev.js → studio-gp02nqnw.js} +4 -4
- package/dist/chunks/{studio-5fc0728f.js → studio-hjbg8d5y.js} +7 -7
- package/dist/chunks/{studio-d007j0z3.js → studio-hnvnfbdv.js} +6 -6
- package/dist/chunks/{studio-b5rxwkj2.js → studio-mk00zd5d.js} +4 -4
- package/dist/chunks/{studio-36s6qjgq.js → studio-n78gjfy8.js} +4 -4
- package/dist/chunks/studio-nbxqcgvf.js +5 -0
- package/dist/chunks/{studio-y164brht.js → studio-pwqfmt4p.js} +4 -4
- package/dist/chunks/studio-qa73881a.js +5 -0
- package/dist/chunks/{studio-6zyt56ek.js → studio-r3kaka4d.js} +4 -4
- package/dist/chunks/{studio-njmg0e73.js → studio-rmn2dz59.js} +5 -5
- package/dist/chunks/{studio-wr0pq67n.js → studio-rr4xkv81.js} +4 -4
- package/dist/chunks/{studio-tj28pxa1.js → studio-semd1s8s.js} +4 -4
- package/dist/chunks/{studio-7w04zw8h.js → studio-st75kn99.js} +5 -5
- package/dist/chunks/{studio-dmymvk2j.js → studio-sxc0zvpt.js} +3 -3
- package/dist/chunks/studio-t1eedsyx.js +4 -0
- package/dist/chunks/{studio-9tkaykt5.js → studio-tmeq6mjb.js} +4 -4
- package/dist/chunks/{studio-153mwkyq.js → studio-tp642n5g.js} +4 -4
- package/dist/chunks/{studio-t0v47dpc.js → studio-tzegmy4w.js} +4 -4
- package/dist/chunks/studio-vavmwshr.js +5 -0
- package/dist/chunks/studio-x5g1xk77.js +5 -0
- package/dist/chunks/studio-x92tgnee.js +64 -0
- package/dist/chunks/{studio-4yztve2t.js → studio-xg1942as.js} +4 -4
- package/dist/chunks/{studio-k9pwvmz8.js → studio-xkfs0dp2.js} +4 -4
- package/dist/chunks/{studio-6k1eswp9.js → studio-y7jehjrp.js} +4 -4
- package/dist/chunks/{studio-81twpmzj.js → studio-yr04mv2j.js} +4 -4
- package/dist/chunks/{studio-gj4j9e7k.js → studio-zd4kayn2.js} +4 -4
- package/dist/chunks/{studio-jsr14n1s.js → studio-zev8ssp1.js} +4 -4
- package/dist/chunks/{studio-r7yeeqc4.js → studio-ztvcxm3w.js} +4 -4
- package/dist/chunks/{tsMode-eq26t9gs.js → tsMode-k9s9fcag.js} +4 -4
- package/dist/chunks/workspace-5vmgsagj.js +4 -0
- package/dist/chunks/{ws-client-3gxqp06s.js → ws-client-0ja08haa.js} +3 -3
- package/dist/iframe-entry.js +3 -3
- package/dist/manifest.json +62 -62
- package/dist/studio.js +95 -95
- package/package.json +12 -12
- package/src/canvas/stage-scrollbar.ts +7 -7
- package/src/files/file-ops.ts +5 -8
- package/src/panels/jump-bar.ts +132 -158
- package/src/panels/pane-context.ts +8 -8
- package/src/panels/pane-grid.ts +18 -26
- package/src/panels/style-panel.ts +2 -2
- package/src/services/context-manager.ts +41 -70
- package/src/services/document-assistant.ts +12 -3
- package/src/services/harness/chat-reducer.ts +115 -0
- package/src/services/harness/turn-hooks.ts +50 -0
- package/src/services/tool-executor.ts +69 -288
- package/src/services/tool-outcomes.ts +12 -10
- package/src/studio.ts +2 -5
- package/src/surfaces/block-action-bar.json +6 -1
- package/src/surfaces/jump-bar.json +9 -12
- package/src/surfaces/jump-bar.ts +15 -16
- package/src/surfaces/pane-context.json +2 -2
- package/src/surfaces/pane-grid.json +8 -25
- package/src/surfaces/pane-grid.ts +7 -8
- package/src/surfaces/statusbar.json +71 -3
- package/src/surfaces/statusbar.ts +66 -139
- package/src/surfaces/style-panel.json +3 -3
- package/src/surfaces/style-panel.ts +11 -1
- package/src/ui/schema-form.ts +6 -2
- package/dist/chunks/adapter-6zhjbpmd.js +0 -4
- package/dist/chunks/cf-settings-fpa485q3.js +0 -4
- package/dist/chunks/components-b0vh4sq8.js +0 -4
- package/dist/chunks/content-source-z5t0d0h9.js +0 -4
- package/dist/chunks/editor-7e23n4a8.js +0 -4
- package/dist/chunks/entry-commands-5cm6aba2.js +0 -4
- package/dist/chunks/file-ops-hv7gf757.js +0 -4
- package/dist/chunks/files-kb0epdxf.js +0 -4
- package/dist/chunks/format-host-eg1wy2bp.js +0 -4
- package/dist/chunks/fs-events-ky3vxfmh.js +0 -4
- package/dist/chunks/git-panel-yyg3bzp2.js +0 -4
- package/dist/chunks/iframe-host-9wdf0hes.js +0 -4
- package/dist/chunks/index-2tf0m2ne.js +0 -4
- package/dist/chunks/jx-validate-7w11db9v.js +0 -4
- package/dist/chunks/layers-7zasrpse.js +0 -4
- package/dist/chunks/layers-panel-9nzc4fdq.js +0 -4
- package/dist/chunks/lit-html-5qr7nbng.js +0 -4
- package/dist/chunks/media-picker-maevn9d4.js +0 -4
- package/dist/chunks/menu-wq6q0v3y.js +0 -4
- package/dist/chunks/monaco-buffer-9ry2rn5x.js +0 -4
- package/dist/chunks/notify-g91gjd6w.js +0 -4
- package/dist/chunks/platform-jdwjp2vt.js +0 -4
- package/dist/chunks/publish-panel-8yym447p.js +0 -4
- package/dist/chunks/quick-search-9bzm9kh3.js +0 -4
- package/dist/chunks/references-znssfqvq.js +0 -4
- package/dist/chunks/right-panel-czbzktm8.js +0 -4
- package/dist/chunks/section-registry-0rtq73qs.js +0 -4
- package/dist/chunks/studio-0mm38y62.js +0 -5
- package/dist/chunks/studio-27tc8q0h.js +0 -5
- package/dist/chunks/studio-7djymzt2.js +0 -5
- package/dist/chunks/studio-ant1zbp3.js +0 -5
- package/dist/chunks/studio-b29h7g7s.js +0 -5
- package/dist/chunks/studio-eb5sty2k.js +0 -5
- package/dist/chunks/studio-frv7vjhw.js +0 -5
- package/dist/chunks/studio-mb8jhtr4.js +0 -64
- package/dist/chunks/studio-nvykrgbj.js +0 -4
- package/dist/chunks/studio-nw4q9sdn.js +0 -5
- package/dist/chunks/studio-p6avneaq.js +0 -5
- package/dist/chunks/studio-vz7b43ng.js +0 -5
- package/dist/chunks/workspace-emt8454d.js +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var O=()=>new Map,Se=(t)=>{let e=O();return t.forEach((n,r)=>{e.set(r,n)}),e},P=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},Nr=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},vr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Y=()=>new Set;var _e=(t)=>t[t.length-1];var Rr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},z=Array.from,Te=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},zt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var Lr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var tt=Array.isArray;class Ue{constructor(){this._observers=O()}on(t,e){return P(this._observers,t,Y).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return z((this._observers.get(t)||O()).values()).forEach((n)=>n(...e))}destroy(){this._observers=O()}}var N=Math.floor;var ct=Math.abs;var Ee=(t,e)=>t<e?t:e,et=(t,e)=>t>e?t:e;var Be=(t)=>t!==0?t<0:1/t<0;var Un=1,En=2,Ae=4,Ce=8;var bt=32,G=64,A=128;var Wt=31,Zt=63,nt=127;var Mr=2147483647;var{MAX_SAFE_INTEGER:It,MIN_SAFE_INTEGER:An}=Number;var Fr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&N(t)===t);var{fromCharCode:Dn,fromCodePoint:Wo}=String,Hl=Dn(65535),Zo=(t)=>t.toLowerCase(),Xo=/^\s*/g,Qo=(t)=>t.replace(Xo,""),Yo=/([A-Z])/g,On=(t,e)=>Qo(t.replace(Yo,(n)=>`${e}${Zo(n)}`));var ti=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},St=typeof TextEncoder<"u"?new TextEncoder:null,ei=(t)=>St.encode(t),$r=St?ei:ti;var kt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(kt&&kt.decode(new Uint8Array).length===1)kt=null;var jr=(t,e)=>Lr(e,()=>t).join("");class Tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Xt=()=>new Tt;var ni=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var H=(t)=>{let e=new Uint8Array(ni(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ri=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(et(n,e)*2),t.cpos=0},E=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var Oe=E;var w=(t,e)=>{while(e>nt)E(t,A|nt&e),e=N(e/128);E(t,nt&e)},Ne=(t,e)=>{let n=Be(e);if(n)e=-e;E(t,(e>Zt?A:0)|(n?G:0)|Zt&e),e=N(e/64);while(e>0)E(t,(e>nt?A:0)|nt&e),e=N(e/128)},Nn=new Uint8Array(30000),si=Nn.length/3,oi=(t,e)=>{if(e.length<si){let n=St.encodeInto(e,Nn).written||0;w(t,n);for(let r=0;r<n;r++)E(t,Nn[r])}else R(t,$r(e))},ii=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;w(t,r);for(let s=0;s<r;s++)E(t,n.codePointAt(s))},lt=St&&St.encodeInto?oi:ii;var Qt=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Ee(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(et(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},R=(t,e)=>{w(t,e.byteLength),Qt(t,e)},vn=(t,e)=>{ri(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ci=(t,e)=>vn(t,4).setFloat32(0,e,!1),li=(t,e)=>vn(t,8).setFloat64(0,e,!1),ai=(t,e)=>vn(t,8).setBigInt64(0,e,!1);var qr=new DataView(new ArrayBuffer(4)),hi=(t)=>(qr.setFloat32(0,t),qr.getFloat32(0)===t),_t=(t,e)=>{switch(typeof e){case"string":E(t,119),lt(t,e);break;case"number":if(Fr(e)&&ct(e)<=Mr)E(t,125),Ne(t,e);else if(hi(e))E(t,124),ci(t,e);else E(t,123),li(t,e);break;case"bigint":E(t,122),ai(t,e);break;case"object":if(e===null)E(t,126);else if(tt(e)){E(t,117),w(t,e.length);for(let n=0;n<e.length;n++)_t(t,e[n])}else if(e instanceof Uint8Array)E(t,116),R(t,e);else{E(t,118);let n=Object.keys(e);w(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(t,s),_t(t,e[s])}}break;case"boolean":E(t,e?120:121);break;default:E(t,127)}};class ve extends Tt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var Gr=(t)=>{if(t.count>0){if(Ne(t.encoder,t.count===1?t.s:-t.s),t.count>1)w(t.encoder,t.count-2)}};class Ut{constructor(){this.encoder=new Tt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else Gr(this),this.count=1,this.s=t}toUint8Array(){return Gr(this),H(this.encoder)}}var Hr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(Ne(t.encoder,e),t.count>1)w(t.encoder,t.count-2)}};class Yt{constructor(){this.encoder=new Tt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Hr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Hr(this),H(this.encoder)}}class Rn{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new Tt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),H(t)}}var M=(t)=>Error(t),F=()=>{throw M("Method unimplemented")},v=()=>{throw M("Unexpected case")};var Pr=M("Unexpected end of array"),zr=M("Integer out of Range");class te{constructor(t){this.arr=t,this.pos=0}}var ut=(t)=>new te(t),Jr=(t)=>t.pos!==t.arr.length;var fi=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},L=(t)=>fi(t,x(t));var at=(t)=>t.arr[t.pos++];var x=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&nt)*n,n*=128,s<A)return e;if(e>It)throw zr}throw Pr},Re=(t)=>{let e=t.arr[t.pos++],n=e&Zt,r=64,s=(e&G)>0?-1:1;if((e&A)===0)return s*n;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],n=n+(e&nt)*r,r*=128,e<A)return s*n;if(n>It)throw zr}throw Pr};var di=(t)=>{let e=x(t);if(e===0)return"";else{let n=String.fromCodePoint(at(t));if(--e<100)while(e--)n+=String.fromCodePoint(at(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},pi=(t)=>kt.decode(L(t)),ht=kt?pi:di;var Vn=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},gi=(t)=>Vn(t,4).getFloat32(0,!1),mi=(t)=>Vn(t,8).getFloat64(0,!1),xi=(t)=>Vn(t,8).getBigInt64(0,!1);var wi=[(t)=>{return},(t)=>null,Re,gi,mi,xi,(t)=>!1,(t)=>!0,ht,(t)=>{let e=x(t),n={};for(let r=0;r<e;r++){let s=ht(t);n[s]=Et(t)}return n},(t)=>{let e=x(t),n=[];for(let r=0;r<e;r++)n.push(Et(t));return n},L],Et=(t)=>wi[127-at(t)](t);class Le extends te{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Jr(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class Bt extends te{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Re(this);let t=Be(this.s);if(this.count=1,t)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class ee extends te{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Re(this),e=t&1;if(this.diff=N(t/2),this.count=1,e)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Mn{constructor(t){this.decoder=new Bt(t),this.str=ht(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Jl=crypto.subtle,Kr=crypto.getRandomValues.bind(crypto);var Fn=()=>Kr(new Uint32Array(1))[0];var bi=[1e7]+-1000+-4000+-8000+-100000000000,Wr=()=>bi.replace(/[018]/g,(t)=>(t^Fn()&15>>t/4).toString(16));var Ve=Date.now;var $n=(t)=>new Promise(t);var Zl=Promise.all.bind(Promise);var jn=(t)=>t===void 0?null:t;class Xr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Qr=new Xr,_i=!0;try{if(typeof localStorage<"u"&&localStorage)Qr=localStorage,_i=!1}catch(t){}var Yr=Qr;var ft=Symbol("Equality"),Me=(t,e)=>t===e||!!t?.[ft]?.(e)||!1;var ts=(t)=>typeof t==="object",{assign:es,keys:Ui}=Object;var ns=(t,e)=>{for(let n in t)e(t[n],n)};var ne=(t)=>Ui(t).length;var rs=(t)=>{for(let e in t)return!1;return!0},At=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=(t,e)=>t===e||ne(t)===ne(e)&&At(t,(n,r)=>(n!==void 0||re(e,r))&&Me(e[r],n)),Ei=Object.freeze,Hn=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")Hn(t[e])}return Ei(t)};var oe=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)oe(t,e,n+1)}};var ss=(t)=>t;var se=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ft]!=null)return t[ft](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!se(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ne(t)!==ne(e))return!1;for(let n in t)if(!re(t,n)||!se(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!se(t[n],e[n]))return!1;break;default:return!1}return!0},os=(t,e)=>e.includes(t);var ie=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var Xl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,J,Bi=[],Ai=()=>{if(J===void 0)if(ie){J=O();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)J.set(e,"");e=r}else if(e!==null)J.set(e,r),e=null;else Bi.push(r)}if(e!==null)J.set(e,"")}else if(typeof location==="object")J=O(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");J.set(`--${On(e,"-")}`,n),J.set(`-${On(e,"-")}`,n)}});else J=O();return J},Jn=(t)=>Ai().has(t);var ce=(t)=>ie?jn(process.env[t.toUpperCase().replaceAll("-","_")]):jn(Yr.getItem(t));var is=(t)=>Jn("--"+t)||ce(t)!==null,cs=is("production"),Ci=ie&&os(process.env.FORCE_COLOR,["true","1","2"]),ls=Ci||!Jn("--no-colors")&&!is("no-color")&&(!ie||process.stdout.isTTY)&&(!ie||Jn("--color")||ce("COLORTERM")!==null||(ce("TERM")||"").includes("color"));var Di=(t)=>new Uint8Array(t);var hs=(t)=>{let e=Di(t.byteLength);return e.set(t),e};class us{constructor(t,e){this.left=t,this.right=e}}var K=(t,e)=>new us(t,e);var Wn=(t)=>t.next()>=0.5,Fe=(t,e,n)=>N(t.next()*(n+1-e)+e);var Zn=(t,e,n)=>N(t.next()*(n+1-e)+e);var Xn=(t,e,n)=>Zn(t,e,n);var vi=(t)=>Dn(Xn(t,97,122)),fs=(t,e=0,n=20)=>{let r=Xn(t,e,n),s="";for(let o=0;o<r;o++)s+=vi(t);return s};var $e=(t,e)=>e[Xn(t,0,e.length-1)];var Li=Symbol("0schema");class ps{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(jr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
|
|
1
|
+
var O=()=>new Map,Se=(t)=>{let e=O();return t.forEach((n,r)=>{e.set(r,n)}),e},P=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},vr=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},Rr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Y=()=>new Set;var _e=(t)=>t[t.length-1];var Lr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},z=Array.from,Te=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},zt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var Vr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var tt=Array.isArray;class Ue{constructor(){this._observers=O()}on(t,e){return P(this._observers,t,Y).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return z((this._observers.get(t)||O()).values()).forEach((n)=>n(...e))}destroy(){this._observers=O()}}var N=Math.floor;var ct=Math.abs;var Ee=(t,e)=>t<e?t:e,et=(t,e)=>t>e?t:e;var Be=(t)=>t!==0?t<0:1/t<0;var Un=1,En=2,Ae=4,Ce=8;var bt=32,G=64,A=128;var Wt=31,Zt=63,nt=127;var Mr=2147483647;var{MAX_SAFE_INTEGER:It,MIN_SAFE_INTEGER:An}=Number;var Fr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&N(t)===t);var{fromCharCode:Dn,fromCodePoint:Wo}=String,Hl=Dn(65535),Zo=(t)=>t.toLowerCase(),Xo=/^\s*/g,Qo=(t)=>t.replace(Xo,""),Yo=/([A-Z])/g,On=(t,e)=>Qo(t.replace(Yo,(n)=>`${e}${Zo(n)}`));var ti=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},St=typeof TextEncoder<"u"?new TextEncoder:null,ei=(t)=>St.encode(t),$r=St?ei:ti;var kt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(kt&&kt.decode(new Uint8Array).length===1)kt=null;var jr=(t,e)=>Vr(e,()=>t).join("");class Tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Xt=()=>new Tt;var ni=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var H=(t)=>{let e=new Uint8Array(ni(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ri=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(et(n,e)*2),t.cpos=0},E=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var Oe=E;var w=(t,e)=>{while(e>nt)E(t,A|nt&e),e=N(e/128);E(t,nt&e)},Ne=(t,e)=>{let n=Be(e);if(n)e=-e;E(t,(e>Zt?A:0)|(n?G:0)|Zt&e),e=N(e/64);while(e>0)E(t,(e>nt?A:0)|nt&e),e=N(e/128)},Nn=new Uint8Array(30000),si=Nn.length/3,oi=(t,e)=>{if(e.length<si){let n=St.encodeInto(e,Nn).written||0;w(t,n);for(let r=0;r<n;r++)E(t,Nn[r])}else R(t,$r(e))},ii=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;w(t,r);for(let s=0;s<r;s++)E(t,n.codePointAt(s))},lt=St&&St.encodeInto?oi:ii;var Qt=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Ee(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(et(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},R=(t,e)=>{w(t,e.byteLength),Qt(t,e)},vn=(t,e)=>{ri(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ci=(t,e)=>vn(t,4).setFloat32(0,e,!1),li=(t,e)=>vn(t,8).setFloat64(0,e,!1),ai=(t,e)=>vn(t,8).setBigInt64(0,e,!1);var qr=new DataView(new ArrayBuffer(4)),hi=(t)=>(qr.setFloat32(0,t),qr.getFloat32(0)===t),_t=(t,e)=>{switch(typeof e){case"string":E(t,119),lt(t,e);break;case"number":if(Fr(e)&&ct(e)<=Mr)E(t,125),Ne(t,e);else if(hi(e))E(t,124),ci(t,e);else E(t,123),li(t,e);break;case"bigint":E(t,122),ai(t,e);break;case"object":if(e===null)E(t,126);else if(tt(e)){E(t,117),w(t,e.length);for(let n=0;n<e.length;n++)_t(t,e[n])}else if(e instanceof Uint8Array)E(t,116),R(t,e);else{E(t,118);let n=Object.keys(e);w(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(t,s),_t(t,e[s])}}break;case"boolean":E(t,e?120:121);break;default:E(t,127)}};class ve extends Tt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var Gr=(t)=>{if(t.count>0){if(Ne(t.encoder,t.count===1?t.s:-t.s),t.count>1)w(t.encoder,t.count-2)}};class Ut{constructor(){this.encoder=new Tt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else Gr(this),this.count=1,this.s=t}toUint8Array(){return Gr(this),H(this.encoder)}}var Hr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(Ne(t.encoder,e),t.count>1)w(t.encoder,t.count-2)}};class Yt{constructor(){this.encoder=new Tt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Hr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Hr(this),H(this.encoder)}}class Rn{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new Tt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),H(t)}}var M=(t)=>Error(t),F=()=>{throw M("Method unimplemented")},v=()=>{throw M("Unexpected case")};var Pr=M("Unexpected end of array"),zr=M("Integer out of Range");class te{constructor(t){this.arr=t,this.pos=0}}var ut=(t)=>new te(t),Jr=(t)=>t.pos!==t.arr.length;var fi=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},L=(t)=>fi(t,x(t));var at=(t)=>t.arr[t.pos++];var x=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&nt)*n,n*=128,s<A)return e;if(e>It)throw zr}throw Pr},Re=(t)=>{let e=t.arr[t.pos++],n=e&Zt,r=64,s=(e&G)>0?-1:1;if((e&A)===0)return s*n;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],n=n+(e&nt)*r,r*=128,e<A)return s*n;if(n>It)throw zr}throw Pr};var di=(t)=>{let e=x(t);if(e===0)return"";else{let n=String.fromCodePoint(at(t));if(--e<100)while(e--)n+=String.fromCodePoint(at(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},pi=(t)=>kt.decode(L(t)),ht=kt?pi:di;var Vn=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},gi=(t)=>Vn(t,4).getFloat32(0,!1),mi=(t)=>Vn(t,8).getFloat64(0,!1),xi=(t)=>Vn(t,8).getBigInt64(0,!1);var wi=[(t)=>{return},(t)=>null,Re,gi,mi,xi,(t)=>!1,(t)=>!0,ht,(t)=>{let e=x(t),n={};for(let r=0;r<e;r++){let s=ht(t);n[s]=Et(t)}return n},(t)=>{let e=x(t),n=[];for(let r=0;r<e;r++)n.push(Et(t));return n},L],Et=(t)=>wi[127-at(t)](t);class Le extends te{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Jr(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class Bt extends te{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Re(this);let t=Be(this.s);if(this.count=1,t)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class ee extends te{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Re(this),e=t&1;if(this.diff=N(t/2),this.count=1,e)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Mn{constructor(t){this.decoder=new Bt(t),this.str=ht(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Jl=crypto.subtle,Kr=crypto.getRandomValues.bind(crypto);var Fn=()=>Kr(new Uint32Array(1))[0];var bi=[1e7]+-1000+-4000+-8000+-100000000000,Wr=()=>bi.replace(/[018]/g,(t)=>(t^Fn()&15>>t/4).toString(16));var Ve=Date.now;var $n=(t)=>new Promise(t);var Zl=Promise.all.bind(Promise);var jn=(t)=>t===void 0?null:t;class Xr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Qr=new Xr,_i=!0;try{if(typeof localStorage<"u"&&localStorage)Qr=localStorage,_i=!1}catch(t){}var Yr=Qr;var ft=Symbol("Equality"),Me=(t,e)=>t===e||!!t?.[ft]?.(e)||!1;var ts=(t)=>typeof t==="object",{assign:es,keys:Ui}=Object;var ns=(t,e)=>{for(let n in t)e(t[n],n)};var ne=(t)=>Ui(t).length;var rs=(t)=>{for(let e in t)return!1;return!0},At=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=(t,e)=>t===e||ne(t)===ne(e)&&At(t,(n,r)=>(n!==void 0||re(e,r))&&Me(e[r],n)),Ei=Object.freeze,Hn=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")Hn(t[e])}return Ei(t)};var oe=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)oe(t,e,n+1)}};var ss=(t)=>t;var se=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ft]!=null)return t[ft](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!se(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ne(t)!==ne(e))return!1;for(let n in t)if(!re(t,n)||!se(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!se(t[n],e[n]))return!1;break;default:return!1}return!0},os=(t,e)=>e.includes(t);var ie=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var Xl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,J,Bi=[],Ai=()=>{if(J===void 0)if(ie){J=O();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)J.set(e,"");e=r}else if(e!==null)J.set(e,r),e=null;else Bi.push(r)}if(e!==null)J.set(e,"")}else if(typeof location==="object")J=O(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");J.set(`--${On(e,"-")}`,n),J.set(`-${On(e,"-")}`,n)}});else J=O();return J},Jn=(t)=>Ai().has(t);var ce=(t)=>ie?jn(process.env[t.toUpperCase().replaceAll("-","_")]):jn(Yr.getItem(t));var is=(t)=>Jn("--"+t)||ce(t)!==null,cs=is("production"),Ci=ie&&os(process.env.FORCE_COLOR,["true","1","2"]),ls=Ci||!Jn("--no-colors")&&!is("no-color")&&(!ie||process.stdout.isTTY)&&(!ie||Jn("--color")||ce("COLORTERM")!==null||(ce("TERM")||"").includes("color"));var Di=(t)=>new Uint8Array(t);var hs=(t)=>{let e=Di(t.byteLength);return e.set(t),e};class us{constructor(t,e){this.left=t,this.right=e}}var K=(t,e)=>new us(t,e);var Wn=(t)=>t.next()>=0.5,Fe=(t,e,n)=>N(t.next()*(n+1-e)+e);var Zn=(t,e,n)=>N(t.next()*(n+1-e)+e);var Xn=(t,e,n)=>Zn(t,e,n);var vi=(t)=>Dn(Xn(t,97,122)),fs=(t,e=0,n=20)=>{let r=Xn(t,e,n),s="";for(let o=0;o<r;o++)s+=vi(t);return s};var $e=(t,e)=>e[Xn(t,0,e.length-1)];var Li=Symbol("0schema");class ps{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(jr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
|
|
2
2
|
`)}}var Qn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[ft])return Me(t,e);if(tt(t))return Te(t,(n)=>zt(e,(r)=>Qn(n,r)));else if(ts(t))return At(t,(n,r)=>Qn(n,e[r]));return!1};class C{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];if(this.constructor._dilutes)[n,e]=[e,n];return Qn(e,n)}equals(t){return this.constructor===t.constructor&&se(this.shape,t.shape)}[Li](){return!0}[ft](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){F()}get nullable(){return Nt(this,We)}get optional(){return new Yn(this)}cast(t){return ds(t,this),t}expect(t){return ds(t,this),t}}class Ge extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let n=t?.constructor===this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var S=(t,e=null)=>new Ge(t,e),Yl=S(Ge);class He extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}var _=(t)=>new He(t),ta=S(He);class ae extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape.some((r)=>r===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}var Pe=(...t)=>new ae(t),gs=S(ae),Vi=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),ms=(t)=>{if(Ot.check(t))return[Vi(t)];if(gs.check(t))return t.shape.map((e)=>e+"");if(_s.check(t))return["[+-]?\\d+.?\\d*"];if(Ts.check(t))return[".*"];if(je.check(t))return t.shape.map(ms).flat(1);v()};class xs extends C{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(ms).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let n=this._r.exec(t)!=null;return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}var ea=S(xs),Mi=Symbol("optional");class Yn extends C{constructor(t){super();this.shape=t}check(t,e){let n=t===void 0||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[Mi](){return!0}}var Fi=S(Yn);class tr extends C{check(t,e){return e?.extend(null,"never",typeof t),!1}}var na=new tr,ra=S(tr);class ze extends C{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new ze(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return At(this.shape,(n,r)=>{let s=this._isPartial&&!re(t,r)||n.check(t[r],e);return!s&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),s})}}var $i=(t)=>new ze(t),ji=S(ze),qi=_((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class er extends C{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&At(t,(n,r)=>{let s=this.shape.keys.check(r,e);return!s&&e?.extend(r+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,e)})}}var ws=(t,e)=>new er(t,e),Gi=S(er);class nr extends C{constructor(t){super();this.shape=t}check(t,e){return t!=null&&At(this.shape,(n,r)=>{let s=n.check(t[r],e);return!s&&e?.extend(r.toString(),"Tuple",typeof n),s})}}var Hi=(...t)=>new nr(t),sa=S(nr);class rr extends C{constructor(t){super();this.shape=t.length===1?t[0]:new Je(t)}check(t,e){let n=tt(t)&&Te(t,(r)=>this.shape.check(r));return!n&&e?.extend(null,"Array",""),n}}var ys=(...t)=>new rr(t),Pi=S(rr),zi=_((t)=>tt(t));class sr extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let n=t instanceof this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}}var Ji=(t,e=null)=>new sr(t,e),oa=S(sr),Ki=Ji(C);class bs extends C{constructor(t){super();this.len=t.length-1,this.args=Hi(...t.slice(-1)),this.res=t[this.len]}check(t,e){let n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}var Wi=S(bs),Zi=_((t)=>typeof t==="function");class Is extends C{constructor(t){super();this.shape=t}check(t,e){let n=Te(this.shape,(r)=>r.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}}var ia=S(Is,(t)=>t.shape.length>0);class Je extends C{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let n=zt(this.shape,(r)=>r.check(t,e));return e?.extend(null,"Union",typeof t),n}}var Nt=(...t)=>t.findIndex((e)=>je.check(e))>=0?Nt(...t.map((e)=>le(e)).map((e)=>je.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Je(t),je=S(Je),ks=()=>!0,qe=_(ks),Xi=S(He,(t)=>t.shape===ks),or=_((t)=>typeof t==="bigint"),Qi=_((t)=>t===or),Ss=_((t)=>typeof t==="symbol"),ca=_((t)=>t===Ss),Dt=_((t)=>typeof t==="number"),_s=_((t)=>t===Dt),Ot=_((t)=>typeof t==="string"),Ts=_((t)=>t===Ot),Ke=_((t)=>typeof t==="boolean"),Yi=_((t)=>t===Ke),Us=Pe(void 0),la=S(ae,(t)=>t.shape.length===1&&t.shape[0]===void 0),aa=Pe(void 0);var We=Pe(null),tc=S(ae,(t)=>t.shape.length===1&&t.shape[0]===null),ha=S(Uint8Array),ua=S(Ge,(t)=>t.shape===Uint8Array),ec=Nt(Dt,Ot,We,Us,or,Ke,Ss),fa=(()=>{let t=ys(qe),e=ws(Ot,qe),n=Nt(Dt,Ot,We,Ke,t,e);return t.shape=n,e.shape.values=n,n})(),le=(t)=>{if(Ki.check(t))return t;else if(qi.check(t)){let e={};for(let n in t)e[n]=le(t[n]);return $i(e)}else if(zi.check(t))return Nt(...t.map(le));else if(ec.check(t))return Pe(t);else if(Zi.check(t))return S(t);v()},ds=cs?()=>{}:(t,e)=>{let n=new ps;if(!e.check(t,n))throw M(`Expected value to be of type ${e.constructor.name}.
|
|
3
|
-
${n.toString()}`)};class Es{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var nc=(t)=>new Es(t),Bs=nc(qe).if(_s,(t,e)=>Fe(e,An,It)).if(Ts,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=Bs(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Us,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>Bs(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===cc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===sc);var ma=_((t)=>t.nodeType===oc);var As=(t)=>Nr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:sc,TEXT_NODE:oc,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:ic,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:cc}=dt,ba=_((t)=>t.nodeType===ic);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Cs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=As(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Ds=ls?dc:Cs,Os=(...t)=>{console.log(...Ds(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Ds(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Rr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class ac extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Ns)}getText(t=""){return this.get(t,as)}getMap(t=""){return this.get(t,Vr)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new ac({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},bk=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},vk=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},yk=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},By=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},kf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!vr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Os(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Ar(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class n$ extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof ac?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Or=m-k;if(Or>0)de(h,B,k,Or)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Ar(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Ur=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Ur++}}var qc=(t)=>{t.timestamp=Ur++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ur++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case ac:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Er=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case ac:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Br=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Fg extends ye{}class Ns extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Ns;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ns}clone(){let t=new Ns;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Fg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Ns;class zy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Vr extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Vr}clone(){let t=new Vr;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new zy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Br(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Vr,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
-
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Br(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new as;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Er(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Br(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Vr{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends as{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new ac({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Ar=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Ar(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ef=()=>new Po;var w_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Tf=(t)=>{let e=new Uint8Array(w_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Cr=new Uint8Array(30000),Dl=Cr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Cr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Cr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Dr=(t)=>Error(t);var Jo=Dr("Unexpected end of array"),Vl=Dr("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var Vy=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var wk=0,xk=1,_k=2,Ck=3;class Lf extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function x_(t){let e=Ef();switch(t.type){case"doc-sync":{rt(e,wk),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,xk),kn(e,t.body);break}case"doc-close":{rt(e,_k),In(e,t.path);break}case"control":{rt(e,Ck),In(e,JSON.stringify(t.message));break}default:throw new Lf(`unknown-frame:${t.type}`)}return Tf(e)}function __(t){try{let e=Vy(t),n=ke(e);switch(n){case wk:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case xk:return{body:Sn(e),type:"awareness"};case _k:return{path:_n(e),type:"doc-close"};case Ck:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Lf("malformed-control");return{message:r,type:"control"}}default:throw new Lf(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Lf)throw e;throw new Lf(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
-
export{ac,
|
|
3
|
+
${n.toString()}`)};class Es{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var nc=(t)=>new Es(t),Bs=nc(qe).if(_s,(t,e)=>Fe(e,An,It)).if(Ts,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=Bs(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Us,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>Bs(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===cc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===sc);var ma=_((t)=>t.nodeType===oc);var As=(t)=>vr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:sc,TEXT_NODE:oc,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:ic,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:cc}=dt,ba=_((t)=>t.nodeType===ic);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Cs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=As(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Ds=ls?dc:Cs,Ns=(...t)=>{console.log(...Ds(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Ds(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Lr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class ac extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Os)}getText(t=""){return this.get(t,as)}getMap(t=""){return this.get(t,Ur)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new ac({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},fS=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},mS=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},gS=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},zy=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Cf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!Rr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Ns(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Cr(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class YR extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof ac?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Nr=m-k;if(Nr>0)de(h,B,k,Nr)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Cr(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Er=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Er++}}var qc=(t)=>{t.timestamp=Er++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Er++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case ac:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Br=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case ac:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Ar=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Mg extends ye{}class Os extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Os;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Os}clone(){let t=new Os;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Mg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Os;class Wy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Ur extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Ur}clone(){let t=new Ur;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new Wy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Ar(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Ur,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
+
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class Vy extends ye{constructor(t,e,n){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,n.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.keysChanged.add(r)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];y(t,(n)=>{let r=new Map,s=new Map,o=this.target._start,i=null,c={},a="",f=0,l=0,h=()=>{if(i!==null){let u=null;switch(i){case"delete":if(l>0)u={delete:l};l=0;break;case"insert":if(typeof a==="object"||a.length>0){if(u={insert:a},r.size>0)u.attributes={},r.forEach((d,p)=>{if(d!==null)u.attributes[p]=d})}a="";break;case"retain":if(f>0){if(u={retain:f},!rs(c))u.attributes=es({},c)}f=0;break}if(u)e.push(u);i=null}};while(o!==null){switch(o.content.constructor){case Q:case yt:if(this.adds(o)){if(!this.deletes(o))h(),i="insert",a=o.content.getContent()[0],h()}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=1}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=1}break;case X:if(this.adds(o)){if(!this.deletes(o)){if(i!=="insert")h(),i="insert";a+=o.content.str}}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=o.length}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=o.length}break;case U:{let{key:u,value:d}=o.content;if(this.adds(o)){if(!this.deletes(o)){let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();if(ot(d,s.get(u)??null))delete c[u];else c[u]=d}else if(d!==null)o.delete(n)}}else if(this.deletes(o)){s.set(u,d);let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();c[u]=p}}else if(!o.deleted){s.set(u,d);let p=c[u];if(p!==void 0){if(!ot(p,d)){if(i==="retain")h();if(d===null)delete c[u];else c[u]=d}else if(p!==null)o.delete(n)}}if(!o.deleted){if(i==="insert")h();jt(r,o.content)}break}}o=o.right}h();while(e.length>0){let u=e[e.length-1];if(u.retain!==void 0&&u.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class as extends T{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??D(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((n)=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new as}clone(){let t=new as;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let n=new Vy(this,t,e);if(xn(this,t,n),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??D();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===X)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)y(this.doc,(n)=>{let r=new ln(null,this._start,0,new Map);for(let s=0;s<t.length;s++){let o=t[s];if(o.insert!==void 0){let i=!e&&typeof o.insert==="string"&&s===t.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Ar(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new as;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Ar(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Ur{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends as{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new ac({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Cr=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Cr(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var kf=()=>new Po;var y_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Sf=(t)=>{let e=new Uint8Array(y_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Dr=new Uint8Array(30000),Dl=Dr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Dr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Dr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Or=(t)=>Error(t);var Jo=Or("Unexpected end of array"),Vl=Or("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var Uy=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var bS=0,vS=1,yS=2,wS=3;class Ef extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function w_(t){let e=kf();switch(t.type){case"doc-sync":{rt(e,bS),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,vS),kn(e,t.body);break}case"doc-close":{rt(e,yS),In(e,t.path);break}case"control":{rt(e,wS),In(e,JSON.stringify(t.message));break}default:throw new Ef(`unknown-frame:${t.type}`)}return Sf(e)}function x_(t){try{let e=Uy(t),n=ke(e);switch(n){case bS:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case vS:return{body:Sn(e),type:"awareness"};case yS:return{path:_n(e),type:"doc-close"};case wS:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Ef("malformed-control");return{message:r,type:"control"}}default:throw new Ef(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Ef)throw e;throw new Ef(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
+
export{ac,fS,mS,gS,zy,Cf,YR,Mg,Os,Wy,Ur,Vy,as,kf,y_,Sf,Uy,bS,vS,yS,wS,Ef,w_,x_};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=30E520B49AEAE2EA64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-c6zdm25z.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{br}from"./studio-dmymvk2j.js";import{hn,sn}from"./studio-dknr8m7b.js";import{ge,Q,v,Zi,S}from"./studio-0nm2skex.js";import{di}from"./studio-b29h7g7s.js";import{rt,zt,T,R,Nn,Ct}from"./studio-z1vdxq0e.js";import{Td}from"./studio-w8w9frjy.js";import{aT}from"./studio-sadckcpp.js";import{Gn}from"./studio-njmg0e73.js";import{yc,Fs,om}from"./studio-81twpmzj.js";var y={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPanelActivity",$description:'The Activity feed: one row per operation this session, newest last, drawn from the projection `panels/activity-panel.ts` hands in. A row is a glyph, a head line (what the operation is, who is running it, how long it has taken), the line it is doing now, the plan it declared, the log it captured and — only when the operation handed a callback over — its Cancel. Every conditional the row has is a boolean field on the projected item, because `$switch` over a value is the only conditional a document has and "is this entry cancellable" is a question the panel has already answered. Nothing here reads the activity store: the panel owns what an operation IS, and the surface owns what it looks like.',tagName:"div",attributes:{part:"panel"},style:{$description:"What `.activity-panel`, `.activity-actions`, `.activity-list`, `.activity-row`, `.activity-icon`, `.activity-body`, `.activity-head`, `.activity-title`, `.activity-source`, `.activity-duration`, `.activity-status`, `.activity-steps`, `.activity-step`, `.activity-step-icon`, `.activity-log-toggle` and `.activity-log` said in `styles/panels.css`, keyed on `part`. Two rules were DELETED rather than moved: `.activity-clear` and `.activity-cancel` drew a small bordered button by hand, and `jx-button` is that button — so the sizes, the border, the hover fill and the disabled state are the kit's now. Three token names changed meaning on the way: `--spectrum-font-size-50`, `--spectrum-font-size-75` and `--spectrum-corner-radius-75` resolve only inside `<sp-theme>`, and this document is mounted into the Bottom dock's body where that element is not an ancestor — every one of them would silently have taken its px fallback. They are the kit's own scale here (`--jx-text-sm`, `--jx-text-md`, `--jx-radius-xs`), which is the step each of them was. The `.activity-*` rules stay in the stylesheet regardless: `publish/deploy-checklist.ts` still draws the checklist above this feed in that same vocabulary, and it is a lit template until it converts.",display:"flex",flexDirection:"column",gap:"8px",padding:"8px",minWidth:"0",fontFamily:"var(--jx-font-sans)",color:"var(--fg)",'& [part="feed"]':{display:"flex",flexDirection:"column",gap:"8px",minWidth:"0"},'& [part="actions"]':{display:"flex",justifyContent:"flex-end"},'& [part="list"]':{display:"flex",flexDirection:"column",gap:"4px",margin:"0",padding:"0",listStyle:"none"},'& [part="row"]':{$description:"The left border is the state, at 3px, which is the one thing that must be legible in a column of twenty rows without reading any of them. Its default is the dim foreground so a state nobody has a colour for still draws a border rather than a gap.",display:"flex",alignItems:"flex-start",gap:"8px",padding:"6px 8px",border:"1px solid var(--border)",borderLeft:"3px solid var(--fg-dim)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",fontSize:"var(--jx-text-md)"},'& [part="row"][data-state="running"]':{borderLeftColor:"var(--accent)"},'& [part="row"][data-state="done"]':{borderLeftColor:"var(--success)"},'& [part="row"][data-state="failed"]':{borderLeftColor:"var(--danger)"},'& [part="row"][data-state="cancelled"]':{borderLeftColor:"var(--fg-dim)"},'& [part="icon"]':{flex:"none",width:"14px",textAlign:"center",fontWeight:"700",lineHeight:"1.5"},'& [part="row"][data-state="running"] [part="icon"]':{color:"var(--accent)"},'& [part="row"][data-state="done"] [part="icon"]':{color:"var(--success)"},'& [part="row"][data-state="failed"] [part="icon"]':{color:"var(--danger)"},'& [part="body"]':{flex:"1",minWidth:"0",display:"flex",flexDirection:"column",gap:"2px"},'& [part="head"]':{display:"flex",alignItems:"baseline",gap:"8px",minWidth:"0"},'& [part="row-title"]':{fontWeight:"700",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="source"], & [part="duration"]':{flex:"none",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="duration"]':{$description:"Pushed to the far edge so a column of rows reads as a column of times.",marginLeft:"auto"},'& [part="status"]':{color:"var(--fg-dim)",overflowWrap:"anywhere"},'& [part="steps"]':{$description:'The plan, declared up front, so "which of the three steps is this on" is answered by looking rather than by reading the status line and remembering what came before it.',display:"flex",flexDirection:"column",gap:"1px",margin:"2px 0 0",padding:"0",listStyle:"none",fontSize:"var(--jx-text-sm)"},'& [part="step"]':{display:"flex",gap:"6px",color:"var(--fg-dim)"},'& [part="step"][data-state="running"]':{color:"var(--fg)"},'& [part="step"][data-state="done"] [part="step-icon"]':{color:"var(--success)"},'& [part="step"][data-state="failed"] [part="step-icon"]':{color:"var(--danger)"},'& [part="step-icon"]':{flex:"none",width:"10px",textAlign:"center"},'& [part="log-toggle"]':{$description:"A plain button rather than a kit one, and the one element here that is not the kit's. The control has to carry `aria-expanded` on the node the reader actually focuses, and a `jx-button` forwards a fixed set of ARIA properties to the control inside its shadow root — an attribute written on the host would name the wrapper and not the button. Its wording is the disclosure's whole state (`docs/studio/interface/problems-and-progress.md` calls it the Show log disclosure), so nothing else has to draw one.",alignSelf:"flex-start",padding:"0",border:"none",background:"none",color:"var(--accent)",font:"inherit",fontSize:"var(--jx-text-sm)",cursor:"pointer",":hover":{textDecoration:"underline"},":focus-visible":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}},'& [part="log"]':{$description:"The captured output the progress modal used to show once and then lose. It scrolls inside the row rather than growing it, so one 400-line `bun install` failure does not become the whole panel. It is selectable against the root's `user-select: none`, the one part of an activity row that is: the output is what a reader pastes into a bug report, and the row offers no copy action.",userSelect:"text",maxHeight:"180px",margin:"2px 0 0",padding:"6px",overflow:"auto",borderRadius:"var(--jx-radius-xs)",background:"var(--bg)",color:"var(--fg-dim)",fontFamily:"var(--font-mono)",fontSize:"var(--jx-text-sm)",whiteSpace:"pre-wrap"},'& [part="cancel"]':{flex:"none"},'& [part="empty"]':{$description:"The teaching empty state, drawn here rather than borrowed from `panels/empty-state.ts`: that helper is a lit template and a document cannot call one. What it says is what is kept — one sentence saying what the region is FOR, then where its content comes from — and this region's fill is an operation somebody else starts, so it offers no button.",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",padding:"24px",textAlign:"center",fontSize:"13px",color:"var(--fg-dim)"},'& [part="empty-message"], & [part="empty-detail"]':{margin:"0",maxWidth:"34ch",lineHeight:"1.5"},'& [part="empty-detail"]':{fontSize:"var(--jx-text-sm)",opacity:"0.8"}},children:[{tagName:"div",attributes:{part:"feed-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasRows"},cases:{true:{tagName:"div",attributes:{part:"feed"},children:[{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasFinished"},cases:{true:{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{size:"sm",quiet:!0},attributes:{part:"clear"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/clearFinished"}}]},children:[{tagName:"span",textContent:"${state.clearLabel}"}]}]}}},{tagName:"ul",attributes:{part:"list"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"li",attributes:{part:"row","data-state":"${$map.item.state}"},children:[{tagName:"span",attributes:{part:"icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"head"},children:[{tagName:"span",attributes:{part:"row-title"},textContent:"${$map.item.title}"},{tagName:"span",attributes:{part:"source-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasSource"},cases:{true:{tagName:"span",attributes:{part:"source"},textContent:"${$map.item.source}"}}},{tagName:"span",attributes:{part:"duration"},textContent:"${$map.item.duration}"}]},{tagName:"div",attributes:{part:"status-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasStatus"},cases:{true:{tagName:"div",attributes:{part:"status"},textContent:"${$map.item.status}"}}},{tagName:"div",attributes:{part:"steps-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasSteps"},cases:{true:{tagName:"ol",attributes:{part:"steps"},children:[{$prototype:"Array",items:{$ref:"$map/item/steps"},key:{$ref:"$map/item/key"},map:{tagName:"li",attributes:{part:"step","data-state":"${$map.item.state}"},children:[{tagName:"span",attributes:{part:"step-icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"span",attributes:{part:"step-label"},textContent:"${$map.item.label}"}]}}]}}},{tagName:"div",attributes:{part:"log-toggle-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasLog"},cases:{true:{tagName:"button",attributes:{part:"log-toggle",type:"button","aria-expanded":"${$map.item.expanded ? 'true' : 'false'}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleLog"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.logLabel}"}}},{tagName:"div",attributes:{part:"log-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/showLog"},cases:{true:{tagName:"pre",attributes:{part:"log"},textContent:"${$map.item.logText}"}}}]},{tagName:"div",attributes:{part:"cancel-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/cancellable"},cases:{true:{tagName:"jx-button",$props:{size:"sm"},attributes:{part:"cancel",title:"Stop this operation"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[{$ref:"$map/item/id"}]}]},children:[{tagName:"span",textContent:"Cancel"}]}}}]}}]}]},false:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",attributes:{part:"empty-message"},textContent:"Long operations show their progress, their log and their Cancel button here."},{tagName:"p",attributes:{part:"empty-detail"},textContent:"Installs, clones, publishes and imports report here while they run."}]}}}]};T("panel-activity",y);var g=null,h=null,p=null,d=null;function E(t,e){t.rows=e.rows,t.hasRows=e.hasRows,t.hasFinished=e.hasFinished,t.clearLabel=e.clearLabel}function j(t){if(g!==t)return!1;return d===null?p!==null:d.root.parentNode===t}function b(t,e){if(j(t))return;f(),g=t;let a=v({cancel:e.cancel,clearFinished:e.clearFinished,clearLabel:"",hasFinished:!1,hasRows:!1,rows:[],toggleLog:e.toggleLog});h=ge(),h.run(()=>{Q(()=>{E(a,e.project())})});let o=R("panel-activity",a,t);p=o,o.then((i)=>{if(p===o)d=i;else i.dispose()})}function f(){h?.stop(),h=null;let t=p;if(p=null,d)d.dispose(),d=null;else if(t)t.then((e)=>e.dispose());g=null}var s=v([]),I=20,u=new Map,w=0;function H(){return w+=1,`a${w}`}function c(t){return t.state!=="running"}function x(){let t=s.filter((e)=>c(e)).length-I;while(t>0){let e=s.findIndex((a)=>c(a));if(e===-1)return;u.delete(s[e].id),s.splice(e,1),t-=1}}function aa(t){let e={cancellable:t.cancel!==void 0,endedAt:null,expanded:!1,id:H(),log:[],startedAt:Zi(),state:"running",status:t.status??"",steps:(t.steps??[]).map((i)=>({label:i,state:"pending"})),title:t.title,...t.source===void 0?{}:{source:t.source}};if(t.cancel)u.set(e.id,t.cancel);s.push(e);let a=s.at(-1);x();let o=(i,r)=>{if(c(a))return;if(a.state=i,a.endedAt=Zi(),r!==void 0)a.status=r;for(let n of a.steps)n.state=n.state==="done"?"done":i==="done"?"done":"failed";a.cancellable=!1,u.delete(a.id),x()};return{done(i){o("done",i)},entry:a,fail(i,r={}){if(c(a))return;let n=a.log.join(`
|
|
2
|
-
`);o("failed",i),
|
|
3
|
-
`),showLog:t.expanded&&e>0,source:t.source??"",state:t.state,status:t.status,steps:t.steps.map((a,o)=>z(a,o)),title:t.title}}function O(){let t=s.filter((e)=>c(e)).length;return{clearLabel:`Clear ${t} finished`,hasFinished:t>0,hasRows:s.length>0,rows:s.map((e)=>_(e))}}var U={cancel:(t)=>{F(t)},clearFinished:()=>{P()},project:O,toggleLog:(t)=>{let e=
|
|
4
|
-
<div data-activity-surface></div>`}function B(t){let e=t.querySelector("[data-activity-surface]");if(!e){f();return}b(e,U)}function
|
|
1
|
+
import{br}from"./studio-sxc0zvpt.js";import{un,rn}from"./studio-cp1gbff9.js";import{ge,Q,v,Mo,k}from"./studio-fqq890ap.js";import{di}from"./studio-1q6amtph.js";import{rt,zt,T,R,An,Ct}from"./studio-7qvs7v0m.js";import{Td}from"./studio-4m50vh74.js";import{QE}from"./studio-aekhcdzw.js";import{qn}from"./studio-rmn2dz59.js";import{yc,js,tm}from"./studio-yr04mv2j.js";var y={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPanelActivity",$description:'The Activity feed: one row per operation this session, newest last, drawn from the projection `panels/activity-panel.ts` hands in. A row is a glyph, a head line (what the operation is, who is running it, how long it has taken), the line it is doing now, the plan it declared, the log it captured and — only when the operation handed a callback over — its Cancel. Every conditional the row has is a boolean field on the projected item, because `$switch` over a value is the only conditional a document has and "is this entry cancellable" is a question the panel has already answered. Nothing here reads the activity store: the panel owns what an operation IS, and the surface owns what it looks like.',tagName:"div",attributes:{part:"panel"},style:{$description:"What `.activity-panel`, `.activity-actions`, `.activity-list`, `.activity-row`, `.activity-icon`, `.activity-body`, `.activity-head`, `.activity-title`, `.activity-source`, `.activity-duration`, `.activity-status`, `.activity-steps`, `.activity-step`, `.activity-step-icon`, `.activity-log-toggle` and `.activity-log` said in `styles/panels.css`, keyed on `part`. Two rules were DELETED rather than moved: `.activity-clear` and `.activity-cancel` drew a small bordered button by hand, and `jx-button` is that button — so the sizes, the border, the hover fill and the disabled state are the kit's now. Three token names changed meaning on the way: `--spectrum-font-size-50`, `--spectrum-font-size-75` and `--spectrum-corner-radius-75` resolve only inside `<sp-theme>`, and this document is mounted into the Bottom dock's body where that element is not an ancestor — every one of them would silently have taken its px fallback. They are the kit's own scale here (`--jx-text-sm`, `--jx-text-md`, `--jx-radius-xs`), which is the step each of them was. The `.activity-*` rules stay in the stylesheet regardless: `publish/deploy-checklist.ts` still draws the checklist above this feed in that same vocabulary, and it is a lit template until it converts.",display:"flex",flexDirection:"column",gap:"8px",padding:"8px",minWidth:"0",fontFamily:"var(--jx-font-sans)",color:"var(--fg)",'& [part="feed"]':{display:"flex",flexDirection:"column",gap:"8px",minWidth:"0"},'& [part="actions"]':{display:"flex",justifyContent:"flex-end"},'& [part="list"]':{display:"flex",flexDirection:"column",gap:"4px",margin:"0",padding:"0",listStyle:"none"},'& [part="row"]':{$description:"The left border is the state, at 3px, which is the one thing that must be legible in a column of twenty rows without reading any of them. Its default is the dim foreground so a state nobody has a colour for still draws a border rather than a gap.",display:"flex",alignItems:"flex-start",gap:"8px",padding:"6px 8px",border:"1px solid var(--border)",borderLeft:"3px solid var(--fg-dim)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",fontSize:"var(--jx-text-md)"},'& [part="row"][data-state="running"]':{borderLeftColor:"var(--accent)"},'& [part="row"][data-state="done"]':{borderLeftColor:"var(--success)"},'& [part="row"][data-state="failed"]':{borderLeftColor:"var(--danger)"},'& [part="row"][data-state="cancelled"]':{borderLeftColor:"var(--fg-dim)"},'& [part="icon"]':{flex:"none",width:"14px",textAlign:"center",fontWeight:"700",lineHeight:"1.5"},'& [part="row"][data-state="running"] [part="icon"]':{color:"var(--accent)"},'& [part="row"][data-state="done"] [part="icon"]':{color:"var(--success)"},'& [part="row"][data-state="failed"] [part="icon"]':{color:"var(--danger)"},'& [part="body"]':{flex:"1",minWidth:"0",display:"flex",flexDirection:"column",gap:"2px"},'& [part="head"]':{display:"flex",alignItems:"baseline",gap:"8px",minWidth:"0"},'& [part="row-title"]':{fontWeight:"700",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="source"], & [part="duration"]':{flex:"none",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="duration"]':{$description:"Pushed to the far edge so a column of rows reads as a column of times.",marginLeft:"auto"},'& [part="status"]':{color:"var(--fg-dim)",overflowWrap:"anywhere"},'& [part="steps"]':{$description:'The plan, declared up front, so "which of the three steps is this on" is answered by looking rather than by reading the status line and remembering what came before it.',display:"flex",flexDirection:"column",gap:"1px",margin:"2px 0 0",padding:"0",listStyle:"none",fontSize:"var(--jx-text-sm)"},'& [part="step"]':{display:"flex",gap:"6px",color:"var(--fg-dim)"},'& [part="step"][data-state="running"]':{color:"var(--fg)"},'& [part="step"][data-state="done"] [part="step-icon"]':{color:"var(--success)"},'& [part="step"][data-state="failed"] [part="step-icon"]':{color:"var(--danger)"},'& [part="step-icon"]':{flex:"none",width:"10px",textAlign:"center"},'& [part="log-toggle"]':{$description:"A plain button rather than a kit one, and the one element here that is not the kit's. The control has to carry `aria-expanded` on the node the reader actually focuses, and a `jx-button` forwards a fixed set of ARIA properties to the control inside its shadow root — an attribute written on the host would name the wrapper and not the button. Its wording is the disclosure's whole state (`docs/studio/interface/problems-and-progress.md` calls it the Show log disclosure), so nothing else has to draw one.",alignSelf:"flex-start",padding:"0",border:"none",background:"none",color:"var(--accent)",font:"inherit",fontSize:"var(--jx-text-sm)",cursor:"pointer",":hover":{textDecoration:"underline"},":focus-visible":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}},'& [part="log"]':{$description:"The captured output the progress modal used to show once and then lose. It scrolls inside the row rather than growing it, so one 400-line `bun install` failure does not become the whole panel. It is selectable against the root's `user-select: none`, the one part of an activity row that is: the output is what a reader pastes into a bug report, and the row offers no copy action.",userSelect:"text",maxHeight:"180px",margin:"2px 0 0",padding:"6px",overflow:"auto",borderRadius:"var(--jx-radius-xs)",background:"var(--bg)",color:"var(--fg-dim)",fontFamily:"var(--font-mono)",fontSize:"var(--jx-text-sm)",whiteSpace:"pre-wrap"},'& [part="cancel"]':{flex:"none"},'& [part="empty"]':{$description:"The teaching empty state, drawn here rather than borrowed from `panels/empty-state.ts`: that helper is a lit template and a document cannot call one. What it says is what is kept — one sentence saying what the region is FOR, then where its content comes from — and this region's fill is an operation somebody else starts, so it offers no button.",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",padding:"24px",textAlign:"center",fontSize:"13px",color:"var(--fg-dim)"},'& [part="empty-message"], & [part="empty-detail"]':{margin:"0",maxWidth:"34ch",lineHeight:"1.5"},'& [part="empty-detail"]':{fontSize:"var(--jx-text-sm)",opacity:"0.8"}},children:[{tagName:"div",attributes:{part:"feed-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasRows"},cases:{true:{tagName:"div",attributes:{part:"feed"},children:[{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasFinished"},cases:{true:{tagName:"div",attributes:{part:"actions"},children:[{tagName:"jx-button",$props:{size:"sm",quiet:!0},attributes:{part:"clear"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/clearFinished"}}]},children:[{tagName:"span",textContent:"${state.clearLabel}"}]}]}}},{tagName:"ul",attributes:{part:"list"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"li",attributes:{part:"row","data-state":"${$map.item.state}"},children:[{tagName:"span",attributes:{part:"icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"head"},children:[{tagName:"span",attributes:{part:"row-title"},textContent:"${$map.item.title}"},{tagName:"span",attributes:{part:"source-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasSource"},cases:{true:{tagName:"span",attributes:{part:"source"},textContent:"${$map.item.source}"}}},{tagName:"span",attributes:{part:"duration"},textContent:"${$map.item.duration}"}]},{tagName:"div",attributes:{part:"status-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasStatus"},cases:{true:{tagName:"div",attributes:{part:"status"},textContent:"${$map.item.status}"}}},{tagName:"div",attributes:{part:"steps-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasSteps"},cases:{true:{tagName:"ol",attributes:{part:"steps"},children:[{$prototype:"Array",items:{$ref:"$map/item/steps"},key:{$ref:"$map/item/key"},map:{tagName:"li",attributes:{part:"step","data-state":"${$map.item.state}"},children:[{tagName:"span",attributes:{part:"step-icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"span",attributes:{part:"step-label"},textContent:"${$map.item.label}"}]}}]}}},{tagName:"div",attributes:{part:"log-toggle-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/hasLog"},cases:{true:{tagName:"button",attributes:{part:"log-toggle",type:"button","aria-expanded":"${$map.item.expanded ? 'true' : 'false'}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleLog"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.logLabel}"}}},{tagName:"div",attributes:{part:"log-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/showLog"},cases:{true:{tagName:"pre",attributes:{part:"log"},textContent:"${$map.item.logText}"}}}]},{tagName:"div",attributes:{part:"cancel-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/cancellable"},cases:{true:{tagName:"jx-button",$props:{size:"sm"},attributes:{part:"cancel",title:"Stop this operation"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[{$ref:"$map/item/id"}]}]},children:[{tagName:"span",textContent:"Cancel"}]}}}]}}]}]},false:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",attributes:{part:"empty-message"},textContent:"Long operations show their progress, their log and their Cancel button here."},{tagName:"p",attributes:{part:"empty-detail"},textContent:"Installs, clones, publishes and imports report here while they run."}]}}}]};T("panel-activity",y);var g=null,h=null,p=null,d=null;function E(t,e){t.rows=e.rows,t.hasRows=e.hasRows,t.hasFinished=e.hasFinished,t.clearLabel=e.clearLabel}function j(t){if(g!==t)return!1;return d===null?p!==null:d.root.parentNode===t}function b(t,e){if(j(t))return;f(),g=t;let a=v({cancel:e.cancel,clearFinished:e.clearFinished,clearLabel:"",hasFinished:!1,hasRows:!1,rows:[],toggleLog:e.toggleLog});h=ge(),h.run(()=>{Q(()=>{E(a,e.project())})});let o=R("panel-activity",a,t);p=o,o.then((i)=>{if(p===o)d=i;else i.dispose()})}function f(){h?.stop(),h=null;let t=p;if(p=null,d)d.dispose(),d=null;else if(t)t.then((e)=>e.dispose());g=null}var s=v([]),I=20,u=new Map,w=0;function H(){return w+=1,`a${w}`}function c(t){return t.state!=="running"}function x(){let t=s.filter((e)=>c(e)).length-I;while(t>0){let e=s.findIndex((a)=>c(a));if(e===-1)return;u.delete(s[e].id),s.splice(e,1),t-=1}}function aa(t){let e={cancellable:t.cancel!==void 0,endedAt:null,expanded:!1,id:H(),log:[],startedAt:Mo(),state:"running",status:t.status??"",steps:(t.steps??[]).map((i)=>({label:i,state:"pending"})),title:t.title,...t.source===void 0?{}:{source:t.source}};if(t.cancel)u.set(e.id,t.cancel);s.push(e);let a=s.at(-1);x();let o=(i,r)=>{if(c(a))return;if(a.state=i,a.endedAt=Mo(),r!==void 0)a.status=r;for(let n of a.steps)n.state=n.state==="done"?"done":i==="done"?"done":"failed";a.cancellable=!1,u.delete(a.id),x()};return{done(i){o("done",i)},entry:a,fail(i,r={}){if(c(a))return;let n=a.log.join(`
|
|
2
|
+
`);o("failed",i),k.error(i,{source:a.source??a.title,...n===""?{}:{detail:n},...r.action===void 0?{}:{action:r.action},...r.path===void 0?{}:{path:r.path}})},id:a.id,log(i){let r=i.replace(/\s+$/,"");if(r!=="")a.log.push(r)},setStatus(i){if(!c(a))a.status=i},step(i){let r=a.steps.findIndex((n)=>n.label===i);if(r===-1)a.steps.push({label:i,state:"pending"}),r=a.steps.length-1;for(let[n,l]of a.steps.entries())l.state=n<r?"done":n===r?"running":l.state;a.status=i}}}function S(t){return s.find((e)=>e.id===t)}function m(){return s.filter((t)=>!c(t))}function F(t){let e=S(t),a=u.get(t);if(!e||!a||c(e))return!1;return a(),u.delete(t),e.state="cancelled",e.endedAt=Mo(),e.cancellable=!1,e.status="Cancelled",!0}function P(){let t=s.filter((a)=>!c(a)),e=s.length-t.length;return s.splice(0,s.length,...t),e}function qE(){return m().map((t)=>`activity: ${t.title} — ${t.status||"running"}`)}var M={cancelled:"⊘",done:"✓",failed:"✕",running:"⋯"},D={done:"✓",failed:"✕",pending:"·",running:"⋯"};function V(t,e=Mo()){let a=Math.max(0,(t.endedAt??e)-t.startedAt);if(a<1000)return`${a}ms`;let o=Math.round(a/1000);return o<60?`${o}s`:`${Math.floor(o/60)}m ${o%60}s`}function z(t,e){return{icon:D[t.state],key:`${e}:${t.label}`,label:t.label,state:t.state}}function _(t){let e=t.log.length;return{cancellable:t.cancellable,duration:V(t),expanded:t.expanded,hasLog:e>0,hasSource:(t.source??"")!=="",hasStatus:t.status!=="",hasSteps:t.steps.length>0,icon:M[t.state],id:t.id,logLabel:t.expanded?"Hide log":`Show log (${e} line(s))`,logText:t.log.join(`
|
|
3
|
+
`),showLog:t.expanded&&e>0,source:t.source??"",state:t.state,status:t.status,steps:t.steps.map((a,o)=>z(a,o)),title:t.title}}function O(){let t=s.filter((e)=>c(e)).length;return{clearLabel:`Clear ${t} finished`,hasFinished:t>0,hasRows:s.length>0,rows:s.map((e)=>_(e))}}var U={cancel:(t)=>{F(t)},clearFinished:()=>{P()},project:O,toggleLog:(t)=>{let e=S(t);if(e)e.expanded=!e.expanded}};function W(){return br`<div data-deploy-checklist></div>
|
|
4
|
+
<div data-activity-surface></div>`}function B(t){let e=t.querySelector("[data-activity-surface]");if(!e){f();return}b(e,U)}function GE(){qn({id:"activity",title:"Activity",level:"project",dock:"bottom",icon:"clock-counter-clockwise",rail:!1,badge:()=>m().length>0?m().length:null,render:()=>W(),afterRender:(t,e)=>{QE(e),B(e)}})}var q={message:"no media file to look for",status:"failed"};function A(t){let e=di(t);return e===""?null:{path:e}}function KE(t){let e=A(t);return e===null?null:yc(e)}async function Cb(t){let e=A(t);return e===null?q:js(e)}function JE(t){if(t===null)return"Counting references…";switch(t.status){case"unsupported":return null;case"pending":return"Counting references…";case"failed":return"Usage unknown";default:return tm(t.result)}}var L={$schema:"https://jxsuite.com/schema/v1",$id:"StudioProgressModal",$description:"The one surface in Studio that blocks while it works: the operation's name, a spinner, the line under it, and the two ways out. A `jx-dialog`, so the platform owns modality, the backdrop, focus restoration and Escape — which is what retired the `sp-underlay` this surface used to paint beside itself, and with it the fixed box, the panel, the shadow and the `z-index: 1000` that box needed to climb back out from under its own scrim. The two answers are the dialog's own: confirm is `Run in the background`, which stops the BLOCKING and leaves the work running in Activity, and the secondary answer is Cancel, drawn only when the operation handed one over. It is the secondary rather than the cancel answer for a reason that is behavioural, not cosmetic: the platform raises one `cancel` for Escape, for a light dismissal and for the cancel button alike, and a surface that cannot tell them apart would stop a dependency install on a keystroke. Escape therefore means what confirm means — stop blocking, not stop working — and the answer that stops the work is a button and only a button.",tagName:"jx-dialog",$props:{headline:{$ref:"#/state/title"},confirmLabel:"Run in the background",secondaryLabel:{$ref:"#/state/cancelLabel"},cancelLabel:"",size:"sm"},attributes:{part:"progress"},onconfirm:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/background"},value:[]}]},onsecondary:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/background"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"What is left once `jx-dialog` has drawn the dialog. `.progress-modal` is gone rather than moved — it positioned a fixed box, painted its panel, border, radius and shadow, capped its height and then lifted itself above the scrim it rendered beside — and a modal `<dialog>` in the top layer is every one of those. `.progress-title` went the same way: the operation's name is the dialog's headline, which is also its accessible name, so nothing here draws a title.",'& [part="row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-4)"},'& [part="status"]':{$description:"`anywhere`, because a status line is usually a path or a package spec with no space in it, and one of those would otherwise be the thing that decides how wide the dialog is. `min-width: 0` is what lets it wrap at all: a flex item's automatic minimum is its content, so without this the row refuses to shrink and the text overflows instead.",minWidth:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-md)",overflowWrap:"anywhere"}},children:[{tagName:"div",attributes:{part:"row"},children:[{tagName:"jx-spinner",attributes:{part:"busy"},$props:{size:"lg"}},{tagName:"span",attributes:{part:"status","aria-live":"polite"},textContent:"${state.status}"}]}]};T("progress-modal",L);function N(t){let e=document.createElement("div");e.style.pointerEvents="auto",e.setAttribute(rt,zt("modal","progress")),t.layer.append(e);let a=!1,o=v({background:()=>{t.onBackground()},cancel:()=>{t.onCancel()},cancelLabel:t.cancellable?"Cancel":"",closed:()=>{t.onClosed()},status:t.status,title:t.title}),i=null,r=R("progress-modal",o,e).then(async(n)=>{let l=n.root;if(a)return n.dispose(),l;if(i=n,await An(l),a)return l;return un(l),l});return{close(){if(a)return;a=!0;let n=i?.root;if(n instanceof HTMLElement)rn(n);i?.dispose(),i=null,e.remove()},host:e,ready:r,setStatus(n){o.status=n}}}function la(t){let e=!1,a=aa({title:t.title,...t.status===void 0?{}:{status:t.status},...t.source===void 0?{}:{source:t.source},...t.cancel===void 0?{}:{cancel:t.cancel}}),o=()=>{if(e)return;e=!0,r.close()},i=()=>{o(),Td("activity")},r=N({cancellable:t.cancel!==void 0,layer:Ct("modal"),onBackground:i,onCancel:()=>{o(),t.cancel?.()},onClosed:o,status:t.status??"",title:t.title});return{activity:a,done(){a.done(),o()},fail(n){let l=(n??"").trim();if(l===""||l.includes(`
|
|
5
5
|
`))a.log(l),a.fail(`${t.title} failed`);else a.fail(l);o()},log(n){a.log(n)},setStatus(n){if(a.setStatus(n),!e)r.setStatus(n)}}}
|
|
6
|
-
export{aa,
|
|
6
|
+
export{aa,qE,GE,la,KE,Cb,JE};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=3D86C10737F90A3D64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-capk0583.js.map
|